Skip to content

Commit

Permalink
[SCons] Make Fortran compiler and options consistent
Browse files Browse the repository at this point in the history
In some cases, the setting of "SHF90" (the compiler to use for
compiling shared objects from F90 code) does not inherit the setting
of "F90" (the compiler to use for compiling normal objects from F90
code). This changes these two to be consistent, as well as the
corresponding variables for other Fortran compilers.
  • Loading branch information
speth authored and ischoegl committed Jun 15, 2021
1 parent 3dc940d commit 9de22e8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions SConstruct
Expand Up @@ -1154,6 +1154,10 @@ else: # env['system_sundials'] == 'n'
env['sundials_version'] = '5.3'
env['has_sundials_lapack'] = int(env['use_lapack'])

def set_fortran(pattern, value):
# Set compiler / flags for all Fortran versions to be the same
for version in ("FORTRAN", "F77", "F90", "F95", "F03", "F08"):
env[pattern.format(version)] = value

# Try to find a working Fortran compiler:
def check_fortran(compiler, expected=False):
Expand All @@ -1163,7 +1167,7 @@ program main
end program main
'''
if which(compiler):
env['F77'] = env['F90'] = env['F95'] = env['F03'] = env['FORTRAN'] = compiler
set_fortran("{}", compiler)
success, output = conf.TryRun(hello_world, '.f90')
if success and 'Hello, world!' in output:
return True
Expand All @@ -1177,7 +1181,7 @@ end program main

return False

env['F77FLAGS'] = env['F90FLAGS'] = env['F95FLAGS'] = env['F03FLAGS'] = env['FORTRANFLAGS']
set_fortran("{}FLAGS", env["FORTRANFLAGS"])

if env['f90_interface'] in ('y','default'):
foundF90 = False
Expand Down Expand Up @@ -1210,8 +1214,8 @@ elif 'g95' in env['FORTRAN']:
elif 'ifort' in env['FORTRAN']:
env['FORTRANMODDIRPREFIX'] = '-module '

env['F77'] = env['F90'] = env['F95'] = env['F03'] = env['FORTRAN']

set_fortran("{}", env["FORTRAN"])
set_fortran("SH{}", env["FORTRAN"])
env['FORTRANMODDIR'] = '${TARGET.dir}'

env = conf.Finish()
Expand Down

0 comments on commit 9de22e8

Please sign in to comment.