[Scons-users] ifort (maybe general Fortran): Module directory issues

Markus Hrywniak markus.hrywniak at rwth-aachen.de
Thu Mar 27 11:03:41 EDT 2014


Hi everybody,

I'm enjoying the scons experience so far, the automatic dependency
tracking is especially cool.
I'd like to contribute a little bit, even if it is only (potential) bug
reporting so far: I tested with scons 2.3.0 and 2.3.1 while compiling
Fortran sources into a variant directory and discovered that as soon as
I turn off duplication, it adds another path to the -module option,
effectively putting the modules back into the source directory. See the
attached minial example, which produces the following output on my system:

I don't know what the policy is on attachments, so I've pasted all the
file into the mail (fairly short, though):

$ scons -Q
ifort -o build/bar.o -c -module build -module src src/bar.f90
ifort -o build/foo.o -c -module build -module src src/foo.f90

Note that the first option is what I set, and the second one is added
automatically as soon as I set "duplicate=0". This overrides the first
invocation and causes all .mod files to be placed into src/.
Contrarily, if I remove the switch or set "duplicate=1", no extra
-module directive appears.

I think I see the logic behind this: "If we do an out-of-tree build and
do not copy the sources, usually the .mod files will be at the same
place as the source files, so let's add it to the search path".
This would work fine if the order were reversed or turned off in the
presence of a user-supplied module path (i.e. FORTRANMODDIR variable).

Cheers,
Markus

============================
My example (also available here:
http://s000.tinyupload.com/index.php?file_id=30075239291299944553)

The directory structure is
.
+-src

| +-SConscript

| +-foo.f90

| +-bar.f90

+-SConstruct
+-build (to be created)


File contents:

SConstruct
--------------------------------------------------------------
import os
env = Environment(ENV = os.environ, tools = ['default', 'ifort'])
env.Replace(
FORTRANMODDIR = '#build'
)
Export('env')
SConscript('src/SConscript', variant_dir='#build', duplicate=0)
---------------------------------------------------------------

SConscript
--------------------------------------------------------------
Import('env')
env.Program('foo', Glob('*.f90'))
--------------------------------------------------------------

foo.f90
--------------------------------------------------------------
program foo
USE bar_mod
integer :: i
i = bar_func(5)
print*, 'this is at test:', i
end program
--------------------------------------------------------------

bar.f90
--------------------------------------------------------------
module bar_mod
contains
function bar_func(x)
integer :: x, bar_func
bar_func = 2*x
end function bar_func
end module
--------------------------------------------------------------


More information about the Scons-users mailing list