Each of the subdirectories: main, mainf90, dummy, and photo has its own Makefile. When the make file is executed, a library corresponding to this subdirectory is created (or updated) and placed in the directory mofia/2.0/lib. The corresponding libraries are libmain.a, libmainf90.a, libdummy.a, and libphoto.a. Notice that the include files used by code in any of these subdirectories resides in the include subdirectory, and similarly the .mod files created when compiling code in any of these subdirectories resides in the modules subdirectory. In contrast, when the Makefile in the user subdirectory is executed, the .mod and .obj files remain in the user subdirectory (no libraries are created).
Users should never run there own code in any of the MOFIA subdirectories. Instead the code in mofia/2.0/source/user should be copied to the user’s own directory (which I will call mymofiain this document to distinguish it from mofia/2.0/source/user) and compiled there. If files from the other mofia/2.0/source subdirectories (mofia/2.0/source/mofia90, mofia/2.0/source/dummy, etc) are needed, these files should be copied over to mymofia and added to the list of $OBJECTS in the mymofia/Makefile.
When compiling MOFIA the user has the option of making any of three different executables: plain, mofia20 or photo. The first executable, plain, does not contain any code from the mainf90, user, or photo subdirectories. The second executable, mofia20, contains all of the MOFIA code except for the event display (photo subdirectory). The last executable, photo, contains the entire code. To make any of these three executables the user needs to issue the command "gmake executable" where "executable" stands for plain, mofia20 or photo. For example,
gmake photo
makes the photo executable. If only the gmake
command is issued (with no executable name) all three: plain,
mofia20
and photo will be made.
V.1 Compiling a debug
Version
The libraries corresponding to main, mainf90, dummy and photoin mofia/2.0/lib are all compiled with the debug flag off to allow faster execution. Since debug information may be needed at times, a debug version of all these libraries is provided in the subdirectory mofia/2.0/debug. The default libraries are the non-debug ones, so that the environment variable MOFIA_LIBDIR is assigned to mofia/2.0/lib by default, and the debug flag is turned off when the code in the usersubdirectory is compiled. To compile a debug version of MOFIA the user needs to issue the command
mlib f90 debug
before executing the Makefile in the mymofia subdirectory. This will assign the environment variable MOFIA_LIBDIR to mofia/2.0/debug and turn the debug flag on when compiling the mymofiacode. If the user wishes to go back and recompile a non-debug version, the command
mlib f90
must be issued before executing the Makefile.
It would be inefficient to recompile all the code whenever a file is modified in one of the source subdirectories. On the other hand, compiling only the file modified will not be sufficient in some cases since other files might depend on it. For example, if module A is changed, one needs to find all the modules and procedures that USE module A and recompile them. This is also true when any of the include files is changed. In each of the subdirectories main, mainf90, dummy and photo, a file called Dependencies is supplied to serve this purpose. This file contains a list of modules and include files that a .obj file "depends on" so that if any of these files is changed the .f90 (or .F) file corresponding to this .obj file is recompiled. This information is made available by inserting the statement "include Dependencies" in every Makefile in the sourcesubdirectories.
The Dependencies
file itself is created by executing the script depend_f90.csh
(which resides in the directory defined by the environment variable TRIUMF_ROOT)
from the source subdirectory
in which the dependencies are to be found. This script goes through every
file in this subdirectory and extracts all filenames that this file depends
on (by examining all the USE and include statements in that
file).