[Scons-users] Does SCons work correctly for fortran submodules?

Peter Diener diener at cct.lsu.edu
Fri Apr 27 15:04:55 EDT 2018


Hi,

Is SCons supposed to work for fortran codes that use submodules and 
type bound procedures? I have a code project that relies heavily on
those features and I would really like to use SCons for it. I was able
to produce a small example code that demonstrates the problem I 
encounter (it only appears with more than one submodule) that I have
attached along with the SConstruct file I use.

The code example consists of two modules, each containing a fortran type 
with 2 type bound procedures ( a set and get for an integer value). In 
the module itself the type and the interface to the procedures are 
defined while the actual implementation of the procedures are done in 
the submodules. Normally I would keep the module and corresponding 
submodule in different files to separate the interface and 
implementations.

When I run scons on this example, I get:

scons: Reading SConscript files ...

scons: *** Multiple ways to build the same target were specified for: 
function.mod  (from ['test_1.f90'] and from ['test_2.f90'])

Is my SConstruct file incorrect, should I not expect SCons to be able 
to handle such a case or is this a bug?

My SCons is an up to date checkout of the GitHub repository, i.e.

scons --version

gives:

SCons by Steven Knight et al.:
         script: v3.1.0.alpha.yyyymmdd.867f762f6c1e23524cd1b0262b8e93e822b23d0c

Note, the example code compiles correctly with a sufficiently new 
version of gfortran and the command line:

gfortran test_1.f90 test_2.f90 test_submodules.f90 -o test_submodules.x

Thank you in advance for any advice.

Cheers,

   Peter Diener
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_1.f90
Type: text/x-fortran
Size: 718 bytes
Desc: 
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180427/58eb3131/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_2.f90
Type: text/x-fortran
Size: 718 bytes
Desc: 
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180427/58eb3131/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_submodules.f90
Type: text/x-fortran
Size: 268 bytes
Desc: 
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180427/58eb3131/attachment-0002.bin>
-------------- next part --------------
import sys
import os
env = DefaultEnvironment(ENV = {'PATH' : os.environ['PATH'],
                                'LD_LIBRARY_PATH' : os.environ['LD_LIBRARY_PATH']},
                         LINK = 'gfortran',
                         LINKFLAGS = '-g',
                         TOOLS= ['default', 'gfortran'])

# pretty output
if ARGUMENTS.get('VERBOSE') != '1':
  if sys.stdout.isatty():
    env['F90COMSTR'] = "\033[92mCompiling\033[0m $TARGET"
    env['LINKCOMSTR'] = "\033[94mLinking\033[0m $TARGET"
  else:
    env['F90COMSTR'] = "Compiling $TARGET"
    env['LINKCOMSTR'] = "Linking $TARGET"

# Build options

env['F90FILESUFFIXES']=['.f90']
env['F90']      = 'gfortran'
env['F90FLAGS'] = ['-O2', '-g']

sources = ['test_1.f90', 'test_2.f90', 'test_submodules.f90']

executable = 'test_submodules.x'

Program(executable, sources)

Decider('MD5-timestamp')


More information about the Scons-users mailing list