Re: support for F90/F95 in SCons

From: Chris Murray (murpup_at_comcast.net)
Date: 08/21/04


Date: Fri, 20 Aug 2004 22:49:45 -0400

Michael Prager wrote:

> Chris Murray <murpup@comcast.net> wrote:
>
>
>>Michael Prager wrote:
>>
>>
>>>In article <Db2dndMJy85QlbncRVn-sw@comcast.com>, Chris Murray
>>>wrote:
>>>
>
> [...]
>
>>>If anyone has a working Fortran example (especially one that
>>>does NOT assume the Fortran compiler is invoked with 'f77',
>>>please post it.
>>>
>>
>>Well, the following would be a very basic example of a mixed-language
>>project being compiled. I have not verified that it works because it is
>>boiled down from a much larger script that I know does work, but all the
>>basic elements are there. Really, only the last line is truly needed if
>>you are willing to pass Program an explicit list of source file names.
>>If they have a .f90 extension, scons should be smart enough to call
>>'f90' to compile them. .f and .f77 extensions would by default, get
>>compiled with 'f77', but this is overrideable. [...]
>
>
> Right, the question is HOW to override it. A quick look through
> the documentation and search for "fortran," "compiler", and
> similar things didn't turn up anything. The information may be
> there, but it's hard to find.
>
> In my test, scons was using "f77" as the compile command for
> files ending in ".f90". I need to be able to specify what
> string to use. I imagine that is possible in the SConstruct
> file, but how?
>
>

Check out the FORTRAN* construction variables. If you search the man
page for FORTRAN, F90, F95, F77, you'll see all the various construction
variables that you can set in an environment. Unless you have a project
in which you are calling different fortran compilers for source files
that conform to different standards, the recommended practice is to
simply use the FORTRAN construction variables as the means for
overriding the defaults built in to SCons. SCons is supposed to just
'do the right thing'. The caveat is that SCons does not automatically
inherit your environment like make does (in order to ensure correct
builds independent of user-environment), so it won't necessarily know
where to find compilers that may be in your path. If SCons can't find
an executable like 'f90' to compile a .f90 file, it will just default to
f77. You can import specific environment variables into an SCons
construction environment (use env.Append()) or set env['FORTRAN']
specifically (as you might set $F90 in a makefile). So to tell SCons to
use a command called 'lf95' for example (the lahey compiler), you would
need a line in your SConstruct something akin to this

env = Environment() # Instantiates a construction environment
env['FORTRAN'] = '/usr/lf95/bin/lf95' # Path to a fortran compiler exe



Relevant Pages

  • Re: returning a vector from a funciton
    ... >> The code above has default construction and assignment. ... >> many compilers. ... You should try it in your environment... ... Again though, the way you wrote it, the assignment operator is ...
    (comp.lang.cpp)
  • Compiler positions available for week ending September 19
    ... advertise a position having something to do with compilers and must also ... generation graphics hardware. ... Excellent C programming skills ... Small office environment within campus of>300 staff, ...
    (comp.compilers)
  • RE: WinCE and version control
    ... considder installing your CE development environment in a virtual PC. ... control system a combination of compiler tools and source code ... scattered in a few directories in the \Program Files tree. ... Are all of the CE binary tools (compilers, debugger plug-ins, remote ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Various "debuggin" tools (for IBM mainframe development)
    ... > different about the IBM mainframe COBOL environment and the COBOL ... The internals of Unisys MCP compilers, ... supports only those compilers that Unisys compiles and ships. ...
    (comp.lang.cobol)
  • Re: Immutability of computer languages nee History of French
    ... > "A FORTRAN II to FORTRAN IV translator was used to retain backward ... Then there is backward compatibility - the political problem that backward people ... there are compilers that accept ... the new construction. ...
    (sci.lang)