Make it’s a great Unix utility when you are compiling big programs, because automatically builds executable programs and libraries from source code by reading a file called makefile.
The text file named makefile must be in the source folder and it’s runs by the command make in the terminal.
Here a generic makefile:
F90 = gfortran
CFLAGS := -g -fbounds-check
NETCDF := -I/usr/include -L/usr/lib -lnetcdff -lnetcdf
OBJECTS = main.o subrutine.o function.o
.PHONY : clean
all : program1 program2
program1 : $(OBJECTS)
$(F90) $(CFLAGS) -o Program1 $(OBJECTS)
main.o : main.f90
$(F90) $(CFLAGS) $(NETCDF) -c main.f90
subrutine.o : subrutine.f90
$(F90) $(CFLAGS) -c subrutine.f90
function.o : function.f90
$(F90) $(CFLAGS) -c function.f90
program2 : prog2.o
$(F90) $(CFLAGS) -o Program2 prog2.o
prog2.o : prog2.f90
$(F90) $(CFLAGS) -c prog2.f90
cp Program1 /Home/JP/
cp Program2 /Home/JP/sub/
rm –f *.o *.mod
Most of the times the most difficult step it is the first one…
Every programing languages have differents statements to interpretate in code what you wants your programs do. To compile is the process to translate from text of source code written in a defined programming language to binary machine language, creating an executable program.
The process of develop a program have some main steps, define the flowchart of information, write the code, test and optimize.
The compilation commands are different if we are in the tests and debugging step or in the optimization step, because for tests of functionality the speed it is not an issue but it is possible to use the debugger and to easily understand where are the problems.
The basic structure of Fortran is:
end program <name>