I am trying to use scons to build a program in fortran 2008.
I am using a makefile to build the program as follows
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
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
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.
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)