# Modifying makefiles to use gfortran rather than mpif90

This topic is 3141 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So my problem is this: I have downloaded some code I'd like to be able to run (http://www.mrao.cam.ac.uk/software/multinest/), it's written in fortran (mostly) and the makefiles they provide are designed to use the mpif90 compiler, which I don't have. I would like to modify their makefiles so that they use the gfortran compiler instead (although I'm not super attached to it if there is something else I should be using). Most of my problems arise from the options that need to be passed to the compiler; gfortran seems to have different options to mpif90, as I suppose one would expect, so it doesn't recognise any of the options supplied. I, however, know very little about fortran and the various compilers, so I have no idea what most of the options do and what to replace them with. I have tried scouring the documentation of each of the compilers to do some direct swaps but I haven't been very successful. As an example, here is one of the makefiles: ------------------ #FC = mpif90 FC = gfortran -ffree-line-length-none #FFLAGS += -fpp -w -O3 FFLAGS += -cpp -w -O3 #I thought this was the correct alteration to make but I seem to have been mistaken CXXFLAGS += -I. -O3 LINKLIB = ld -shared LIBDIR = .. NESTED_lib = .. NESTED_inc = .. #LIBS=-L$(NESTED_lib) -lnest3 -lmkl_lapack -lmkl -lguide -lpthread #LIBS=-L$(NESTED_lib) -lnest3 -llapack -fopenmp -liomp5 -lpthread #this was just me swapping some packages around (because I don't have the Intel stuff), I'm sort of hoping this didn't screw anything up. LIBS=-L$(NESTED_lib) -lnest3 -llapack -fopenmp -lpthread OBJFILES = params.o like.o nestwrap.o main.o all: gauss_shell %.o: %.f90$(FC) $(FFLAGS) -I$(NESTED_inc) -c $*.f90 gauss_shell:$(OBJFILES) $(FC) -o ../gauss_shell$(OBJFILES) $(FFLAGS)$(LIBS) clean: rm -f *.o *.mod ../gauss_shell -------------- The commented lines show the original contents of the makefile, my modifications are directly below. The current hiccup is the -fpp option (although there will probably be more), some kind of preprocessing command I am given to understand, which is not recognised by gfortran. I thought -cpp was the gfortran version of the same thing but that seems to be wrong, i.e. I still get errors like: ----------------- make[1]: Entering directory /home/farmer/Documents/MultiNest_v2.7/example_gauss_shell' gfortran -ffree-line-length-none -cpp -w -O3 -I.. -c params.f90 gfortran: unrecognised option '-cpp' gfortran -ffree-line-length-none -cpp -w -O3 -I.. -c like.f90 gfortran: unrecognised option '-cpp' gfortran -ffree-line-length-none -cpp -w -O3 -I.. -c nestwrap.f90 gfortran: unrecognised option '-cpp' gfortran -ffree-line-length-none -cpp -w -O3 -I.. -c main.f90 gfortran: unrecognised option '-cpp' gfortran -ffree-line-length-none -o ../gauss_shell params.o like.o nestwrap.o main.o -cpp -w -O3 -L.. -lnest3 -llapack -fopenmp -lpthread gfortran: unrecognised option '-cpp' make[1]: Leaving directory /home/farmer/Documents/MultiNest_v2.7/example_gauss_shell' ---------------------- There is also an option -nofor_main in a different file, which I believe is telling the compiler that the source file isn't written in fortran, which gfortran does not recognise. So, are there any fortran experts around? I don't really know what half the stuff in the makefile is actually doing either, so a good guide to the various components and options of makefiles would also be appreciated, although to be honest I just want the thing to compile. I'm running Ubuntu 8.04 if that's relevant.

##### Share on other sites
This doesn't seem to be an issue with makefiles but with figuring out the right command line for invoking the compiler. Have you tried reading the compiler's documentation? You know, 'man gfortran', 'gfortran --help', that sort of thing?