|
Spring, 2016
Jewett |
The
make program |
ATMS
502
/ CSE 566 Numerical fluid dynamics |
|
Make
Make is a Unix/Linux utility that helps you compile your program efficiently and quickly -- important when your program includes many routines. Advantages include compiling just those routines that you have recently changed; when doing a lot of work, this will speed up your code testing. So, to make best use of make, put most subroutines in separate files, and let Make compile / link them for you. Make uses a file you have created, typically named "makefile" or "Makefile", to know which files contain the routines you need to compile your program. A sample Makefile is on Stampede at ~tg457444/502/Pgm4/Fortran/Makefile. Provided you have copied the fortran files to your directory, you can use make to compile and link the test interpolation program by simply typing make upon which it automatically determines which files need compiling, and does so. The first time you do this, it compiles everything: login4%
pwd
/share/home/00478/tg457444/502/Pgm4/Fortran login4% ls contr.f90 dointerp.f90 Makefile nestwind.f90 test_interp.f90 login4% make (what is shown below is done automatically by make, for you:) ncargf90 -c test_interp.f90 (compiles test_interp) ifort -O2 -c test_interp.f90 -L/share/home/00478/tg457444/ncarg/lib -L/usr/X11R6/lib64 -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext ncargf90 -c dointerp.f90 (compiles dointerp) ifort -O2 -c dointerp.f90 -L/share/home/00478/tg457444/ncarg/lib -L/usr/X11R6/lib64 -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext ncargf90 -c contr.f90 (compiles contr) ifort -O2 -c contr.f90 -L/share/home/00478/tg457444/ncarg/lib -L/usr/X11R6/lib64 -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext ncargf90 -O -o test_interp test_interp.o dointerp.o contr.o (this step takes the compiled files above and creates your running program) ifort -O2 -O -o test_interp test_interp.o dointerp.o contr.o -L/share/home/00478/tg457444/ncarg/lib -L/usr/X11R6/lib64 -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext Suppose I now change only test_interp.f. Upon typing make again, the make utility compiles only that file, and creates a new executable program test_interp: login4%
make
ncargf90 -c test_interp.f90 (compile step, of only file needing compiling) ifort -O2 -c test_interp.f90 -L/share/home/00478/tg457444/ncarg/lib -L/usr/X11R6/lib64 -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext ncargf90 -O -o test_interp test_interp.o dointerp.o contr.o (link step, to create program test_interp) ifort -O2 -O -o test_interp test_interp.o dointerp.o contr.o -L/share/home/00478/tg457444/ncarg/lib -L/usr/X11R6/lib64 -lncarg -lncarg_gks -lncarg_c -lXpm -lX11 -lXext An example Hopefully the Program 4 test Makefile can be a useful template for you to use. Ignoring the comments at the top, it contains: F90
= ncargf90
OPTIONS = -O OBJECTS = test_interp.o dointerp.o contr.o test_interp: $(OBJECTS) $(F90) $(OPTIONS) -o test_interp $(OBJECTS) %.o: %.f90 $(F90) -c $< What is this doing? In order:
|