Scons:构建 Fortran 时“FORTRAN*”变量的用途是什么?

Scons: What is the purpose of `FORTRAN*` variables when building Fortran?

Scons 中 FORTRAN* 变量的用途是什么?联机帮助页将它们描述为 所有版本 Fortran 的默认设置。但据我所知,实际上它们从未被使用过,因为不同 Fortran 方言的特定变量始终优先(F77*F90*F95*)。

有没有办法更改从文件扩展名到 Fortran 方言的映射,以便某些文件改为映射到默认值?

查看 SCons 源代码(特别是 Tool/FortranCommon.py),似乎 FORTRANF77F90F95F03 而不是 parent 。看起来变量的 FORTRAN 变体将用于以 .f.for.ftn.fpp 和 [=23= 命名的源文件] 尽管它们可以被变量 FORTRANFILESUFFIXESFORTRANPPFILESUFFIXES 覆盖。

设置它的代码是:

def add_fortran_to_env(env):
    """Add Builders and construction variables for Fortran to an Environment."""
    try:
        FortranSuffixes = env['FORTRANFILESUFFIXES']
    except KeyError:
        FortranSuffixes = ['.f', '.for', '.ftn']

    #print "Adding %s to fortran suffixes" % FortranSuffixes
    try:
        FortranPPSuffixes = env['FORTRANPPFILESUFFIXES']
    except KeyError:
        FortranPPSuffixes = ['.fpp', '.FPP']

    DialectAddToEnv(env, "FORTRAN", FortranSuffixes,
                    FortranPPSuffixes, support_module = 1)

其中 DialectAddToEnv 为 Fortran 构建变量赋值,例如(dialect 是传递给函数的第二个变量):

 env['%sCOM' % dialect]     = '$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)

设置F77F90F95等的代码非常相似,例如:

def add_f90_to_env(env):
    """Add Builders and construction variables for f90 to an Environment."""
    try:
        F90Suffixes = env['F90FILESUFFIXES']
    except KeyError:
        F90Suffixes = ['.f90']

    #print "Adding %s to f90 suffixes" % F90Suffixes
    try:
        F90PPSuffixes = env['F90PPFILESUFFIXES']
    except KeyError:
        F90PPSuffixes = []

    DialectAddToEnv(env, "F90", F90Suffixes, F90PPSuffixes,
                    support_module = 1)

没有从一种方言退回到FORTRAN的机制。每个方言(包括FORTRAN)都是独立的,并从文件名结尾映射,这是可配置的。