In order to compile modFileSys, you need following prerequisites:
There are basically two different ways of invoking the library into your project:
Both are described below in details.
In order to create a precompiled library
During the build process of your project, you may link the library with the -lmodfilesys option. Eventually, you may need to specify options for your compiler and your linker to specify the location of those directories. Assuming you’ve put the module files in the directory <MODFILEDIR> and the library file in <LIBRARYDIR>, you would typically invoke your compiler for the source files using the libmodfilesys_module as:
F2003_COMPILER -I<MODFILEDIR> -c somesource.f90
and link your object files at the end with:
LINKER -I<LIBRARYDIR> somesource.o ... -L<LIBRARYDIR> -lmodfilesys
In order to build the library during the build process of your project:
Copy the content of the src/ folder into a separate folder within your project.
During the make process of your project, invoke the library makefile (Makefile.lib) to build the module files and the library in the folder where you’ve put the library sources.
You must pass the compiler and linker options via variable defintions at the make command line. Assuming that the variables $(FXX), $(FXXOPT), $(LN), $(LNOPT), $(CC) and $(CCOPT) contain the Fortran compiler, the Fortran compiler options, the linker, the linker options, the C compiler and its options, respectively, you would have something like:
$(MODFILESYS_SRCDIR)/libmodfilesys.a:
$(MAKE) -C $(MODFILESYS_SRCDIR) \
FXX="$(FXX)" FXXOPT="$(FXXOPT)" \
LN="$(LN)" LNOPT="$(LNOPT)" \
CC="$(CC)" CCOPT="$(CCOPT)" \
-f Makefile.lib
in the makefile of your project with $(MODFILESYS_SRCDIR) being the directory where you’ve put the source of modFileSys.
You should also have a look at the GNUmakefile in the test/ folder of modFileSys, which uses exactly the same technique to compile the library during the build process for the test programs.
[*] | GNU Fortran 4.9 (earlier versions may not work!), NAG Fortran 5.3.1 and Intel Fortran 12.1 seem to work. |