|
||||||||||
Section Contents
|
fmkmf: Makefiles for Fortran 9xThe perl program fmkmf constructs a make file for a Fortran 90 (or 95) program that uses modules. The shell script fmkmf.sh does the same thing, but more slowly. Why bother to do such a thing? The main reason is that the make utility really has C or FORTRAN 77 in mind. In these languages, you can compile your various source files in any order before you do the link step. A typical make file looks like this:
foo:foo.o bar.o baz.o
<-tab->cc -o foo foo.o bar.o baz.o
foo.o:foo.c
<-tab->cc -c foo.c
bar.o:bar.c
<-tab->cc -c bar.c
baz.o:baz.c
<-tab->cc -c baz.c
In Fortran 90, however, you have to compile a sourcefile containing a module before you compile any source files which use that module. (Why? So that compile-time type checking can be done at subprogram calls, eliminating those horrid Bus Error crashes.) Soooo, if main.f90 contains the line use foomod and the file foo.f90 contains the line module foomod then you need a makefile like this:
main:main.o foo.o
<-tab->f90 -o main.o foo.o
main.o:main.f90 foo.o #Note main.o depends on foo.o
<-tab->f90 -c main.o
foo.o:foo.f90
<-tab->f90 -c foo.f90
The important difference is that main.o depends on foo.o, even though the command to generate main.o doesn't seem to use foo.o. This dependency forces foo.f90 to be compiled before main.f90. If your Fortran 90 project has a messy dependency tree of modules and use statements, then writing a make file which compiles things in the right order is a royal pain in the neck. Now, however, fmkmf uses the magic of fmkmf main.f90 >makefile ...and your makefile would be ready to go! You can get the shell script here and the perl script here; there are also some instructions . Meteorology dept folk: just add /home/hcp/bin to your PATH and fmkmf should become available. I'm not doing version numbers, but I'll make a note here when I fix bugs.
If fmkmf is not exactly what you are after, have a look at these alternatives: |
|||||||||
|
© School of GeoSciences ---
Privacy & Cookies ---
Last modified: 08 Sep, 2011 --- Page contact:
|
||||||||||