[Scons-users] SCons ignoring FORTRANPATH

Damien damien at khubla.com
Wed Sep 24 23:32:06 EDT 2014


All,

This comes up every few years on the list in some form or another. It is 
an annoying, fickle and somewhat temperamental aspect, but very 
effective, much like those of us who still have to have to compile 
Fortran :-).  I can't promise that this will fix your problem, but this 
is what we do to make our Fortran compiles work with gfortran on Linux.  
You can do this at the top of your SConscript.

With gfortran:

    env['FORTRAN'] = 'gfortran'

    env['FORTRANMODDIRPREFIX'] = '-J'
    env['FORTRANMODDIR'] = '${TARGET.dir}'
    env['FORTINCPREFIX'] = '-I'
    env['_FORTRANINCFLAGS'] = '$( ${_concat(FORTINCPREFIX, FORTRANPATH, 
INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
    env['FORTRANCOM'] = '$FORTRAN -o$TARGET -c $FORTRANFLAGS 
$FORTRANMODDIRPREFIX$FORTRANMODDIR $_FORTRANINCFLAGS $SOURCES'
    env['SHFORTRANCOM'] = env['FORTRANCOM']
    env['SHF90PPCOM'] = env['FORTRANCOM']
    env['SHF95PPCOM'] = env['FORTRANCOM']
    env['F90PPCOM'] = env['FORTRANCOM']
    env['F95PPCOM'] = env['FORTRANCOM']

and with Intel Fortran on Windows:

   env['FORTRANPATH'] = fortincludepath

    env['FORTRANMODDIRPREFIX'] = '/module:'
    env['FORTRANMODDIR'] = '${TARGET.dir}'

    env['_FORTRANINCFLAGS'] = '$( ${_concat(FORTINCPREFIX, FORTRANPATH, 
INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
    env['FORTINCPREFIX'] = '/I'

    env['FORTRANCOM'] = '$FORTRAN /Fo$TARGET /c $FORTRANFLAGS 
$FORTRANMODDIRPREFIX$FORTRANMODDIR $_FORTRANINCFLAGS $SOURCES'
    env['SHFORTRANCOM'] = env['FORTRANCOM']
    env['SHF90PPCOM'] = env['FORTRANCOM']
    env['SHF95PPCOM'] = env['FORTRANCOM']
    env['F90PPCOM'] = env['FORTRANCOM']
    env['F95PPCOM'] = env['FORTRANCOM']

Hope this helps,

Damien

On 2014-09-24 6:55 PM, Tom Cook wrote:
> A quick grep (on both 2.3.0 and 2.3.3) seems to show that, contrary to
> the documentation, _FORTRANINCFLAGS is never set anywhere, only used,
> unlike, say _CPPINCFLAGS, which is set in Defaults.py.  Or am I
> misreading something?
>
> Regards,
> Tom
>
> On Thu, Sep 25, 2014 at 9:51 AM, Tom Cook <tom.k.cook at gmail.com> wrote:
>> Hi Dirk,
>>
>> Renaming is a trifle difficult, but I've set up a separate test
>> environment and no, the spaces don't seem to be the problem.  See the
>> attached files for an example that fails without spaces in names.
>>
>> As for other information:
>>
>> $ scons --version
>> SCons by Steven Knight et al.:
>> script: v2.3.0, 2013/03/03 09:48:35, by garyo on reepicheep
>> engine: v2.3.0, 2013/03/03 09:48:35, by garyo on reepicheep
>> engine path: ['/usr/lib/scons/SCons']
>> Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
>> 2010, 2011, 2012, 2013 The SCons Foundation
>>
>> $ python --version
>> Python 2.7.6
>>
>> The system is Ubuntu 14.04 amd64, in case that makes a difference.
>>
>> Regards,
>> Tom
>>
>> On Wed, Sep 24, 2014 at 4:55 PM, Dirk Bächle <tshortik at gmx.de> wrote:
>>> Hi Tom,
>>>
>>> On 24.09.2014 09:00, Tom Cook wrote:
>>>> Hi,
>>>>
>>>> I have a SCons build which includes a number of Fortran modules.  For
>>>> at least some of these modules, the FORTRANPATH variable seems to be
>>>> ignored.  The output of env.Dump() is shown at the end of this email,
>>>> showing a number of directories listed in FORTRANPATH; however, when
>>>> trying to build a Fortran source file, this command-line is used:
>>>>
>>>> gfortran -o "Build/Linux/Product/Calculation/ProductSim
>>>> F/DTBWindInit.o" -c -cpp -ffixed-line-length-none
>>>> -ffree-line-length-none -fcoarray=single
>>>> "-JBuild/Linux/Product/Calculation/ProductSim F"
>>>> "Source/Product/Calculation/ProductSim F/DTBInit.f90"
>>>>
>>>> (note that the command-line has been anonymised slightly for
>>>> commercial reasons).
>>>>
>>>> What could cause this?
>>> my first bet would be the space in your pathnames like
>>> "Linux/Product/Calculation/ProductSim F". Can you rename the folder(s) for
>>> testing only, and then try again without spaces?
>>>
>>> Apart from that, it would be good to know which version of SCons you're
>>> using at the moment. The Python version is also helpful sometimes...
>>>
>>> Best regards,
>>>
>>> Dirk
>>>
>>> _______________________________________________
>>> Scons-users mailing list
>>> Scons-users at scons.org
>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users



More information about the Scons-users mailing list