Using scons


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Using scons
# 1  
Old 10-04-2014
Using scons

I am trying to use scons to build a program in fortran 2008.

I am using a makefile to build the program as follows

Code:
all:
    /home/cdim/Local/gcc-4.9.0/bin/gfortran -ffree-form -c endian.f
    /home/cdim/Local/gcc-4.9.0/bin/gfortran -ffree-form -c testconvert.f
    /home/cdim/Local/gcc-4.9.0/bin/gfortran testconvert.o endian.o -o endian

Then I created SConstuct as follows

Code:
path = ['/bin', '/usr/bin', '/home/cdim/Local/gcc-4.9.0/bin']

env = Environment(ENV = {'PATH' : path})
env.Append(tools=['default','gfortran'],LINK='gfortran',LINKFLAGS='-g')
env.Append(F90FLAGS='-g')

sources = ['endian.f','testconvert.f']
objs = env.Object(sources)

# Get rid of the .mod names
objs2 = [obj for obj in objs if obj.get_suffix() == ".o"]
env.Program("endian.x",objs2)

The makefile builds the program successfully. However I am having problems
with SConstruct. I do need to add the -ffree-form somehow. Any way I can
do that? If I do not incude it, the compiler complains as it will assume fixed
format for .f files. My .f files conform to fortran 2008 standard. However I
want to still have the files as .f, rather than ending up with .f, .f90, .f95, .f03, .f08, ....

---------- Post updated at 08:19 PM ---------- Previous update was at 06:49 PM ----------

After updating SContruct as follows, the .mod and .o files have
been created. The solution was to use

Code:
env.Append(FORTRANFLAGS='-ffree-form -g')

However there stilll exists a problem because the executable
testconvert.x is not being created.

endian.f consists of a module called Endian

testconvert.f contains the main program which uses the
module Endian.

Code:
path = ['/bin', '/usr/bin', '/home/cdim/Local/gcc-4.9.0/bin']

env = Environment(ENV = {'PATH' : path})
env.Append(tools=['default','gfortran'],LINK='gfortran',LINKFLAGS='-g')
env.Append(FORTRANFLAGS='-ffree-form -g')

sources = ['endian.f','testconvert.f']
objs = env.Object(sources)

# Print the kind of object in the list that comes back from env.Object
#print "Object list item type: " + type(objs[0])

# Get rid of the .mod names
objs2 = [obj for obj in objs if obj.get_suffix() == ".o"]
env.Program("testconvert.x",objs2)


Last edited by kristinu; 10-04-2014 at 08:59 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Build using scons

I have a tree structure as follows: /vik/build/sc/botoh.sc /vik/lib/endian.f /vik/utils/botoh.f Then I run the build script as cd vik/build/sc scons -f botoh.sc The above shows that the SConstruct botoh.sc is down a few levels, and it may be easiest to have the main... (6 Replies)
Discussion started by: kristinu
6 Replies
Login or Register to Ask a Question