HEAD PREVIOUS

2  Building and Using LMie

This section discusses, first, the process of building (compiling) LMie including the core library, the language interfaces, the example programs, and the utility programs. Then the compilation details of using the LMie core library and the appropriate language interface in your programs is outlined.

2.1  Building LMie

2.1.1  GNU Make

The standard build system uses GNU Make (other versions of UNIX Make may work but are not tested). This should work on Linux, Unix, Mac OS, and on Windows using either Cygwin or MinGW (Minimalist GNU for Windows).
The first step is to configure the build for your environment. This includes setting the compiler commands and the associated options and setting the appropriate paths to external libraries. Settings are contained in the file make.inc in the LMie base directory.
Compiler and associated options are contained within the section identified as "Compiler and linker settings". The commands for the compilers to use are represented by the variables CC, F77, and F90, for the C, Fortran 77, and Fortran 90 compilers, respectively, and the associated options are represented by the variables CCFLAGS, F77FLAGS, and F90FLAGS. The default settings are appropriate for GCC (GNU Compiler Collection) versions 4.2 and greater and should not have to be modified unless other compilers are being used. Note that LMie is entirely C89/90 compliant except for the use of complex types. Therefore, the C compiler must be C99 compliant. As an alternative, all of LMie's C code may be built with a C++ compiler in which case the complex support is through the C++ standard library's complex class.
The next section of make.inc is for OpenMP settings. If multithreading is desired then uncomment the variable appendices in this section and set the appropriate OpenMP compiler flags for the CCFLAGS, F77FLAGS, and F90FLAGS variables.
The next section of make.inc is for MPI settings. If the MPI version of LMie is desired then an MPI implementation should be made available. The variable MPI_INCDIR should be set to the path to the directory with the MPI include files, the variable MPI_LIBDIR should be set to the path to the directory with the MPI library files, and the variable MPI_LINK should be set to the appropriate compiler link flag. The default settings are for a MPICH2 installation located at $HOME/opt/mpich2/.
Once the proper settings have been set in make.inc LMie may be compiled by executing
     make

and for the MPI version of LMie
     make mpi

2.1.2  Visual Studio

LMie may also be built on Windows using Visual Studio and, if the Fortran 77 and/or 90 interfaces are desired, with Intel's Visual Fortran Composer XE for Windows. Supported versions of Visual Studio are 2005, 2008, and 2010. Depending on which version is being used the LMie Visual Studio solution may be loaded from one of the following solution (.sln) files relative to the LMie base directory:
     msvs_2005/lmie.sln
     msvs_2008/lmie.sln
     msvs_2010/lmie.sln

2.2  Using LMie in your code

To use LMie in your own code you have to include/use the appropriate header/module file and link with the appropriate LMie library files and any required external library files.

2.2.1  C/C++

The C interface is part of the core library in the src/ directory. To use the C interface your code must include the following header file:
     src/lmie_interface.h

and must link with the following libraries:
     src/liblmie.a
     misc/liblmie_misc.a

or when using Visual Studio the following libraries:
     $(SolutionDir)/$(ConfigurationName)/liblmie.lib
     $(SolutionDir)/$(ConfigurationName)/liblmie_misc.lib

where the variable $(SolutionDir) is msvs_2005, msvs_2008, or msvs_2010 and the variable $(ConfigurationName) is Debug or Release.
For example, if one has C code in a file named my_code.c, includes the LMie C interface header file with
     #include <lmie_interface.h>

and uses GCC to compile and link the code the command may look like this
     gcc -O2 my_code.c -I$(LMIE_HOME)/src -L$(LMIE_HOME)/src -L$(LMIE_HOME)/misc \
         -llmie -llmie_misc

where the variable $(LMIE_HOME) is the location of the LMie base directory. For more information, take a look at the build details for the C interface example program examples/example_c.c.

2.2.2  Fortran 77

To use the Fortran 77 interface your code must include the following file:
     interfaces/lmie_int_f77.inc

and must link with the following libraries:
     src/liblmie.a
     misc/liblmie_misc.a
     interfaces/liblmie_interfaces.a

or when using Visual Studio the following libraries:
     $(SolutionDir)/$(ConfigurationName)/liblmie.lib
     $(SolutionDir)/$(ConfigurationName)/liblmie_misc.lib
     $(SolutionDir)/$(ConfigurationName)/liblmie_interfaces.lib
     $(SolutionDir)/$(ConfigurationName)/liblmie_interfaces_f.lib

where the variable $(SolutionDir) is msvs_2005, msvs_2008, or msvs_2010 and the variable $(ConfigurationName) is Debug or Release. For more information, take a look at the build details for the Fortran 77 interface example program examples/example_f77.f.

2.2.3  Fortran 90

To use the Fortran 90 interface your code must USE the LMIE_INT_F90 module and must link with the following libraries:
     src/liblmie.a
     misc/liblmie_misc.a
     interfaces/liblmie_interfaces.a

or when using Visual Studio the following libraries:
     $(SolutionDir)/$(ConfigurationName)/liblmie.lib
     $(SolutionDir)/$(ConfigurationName)/liblmie_misc.lib
     $(SolutionDir)/$(ConfigurationName)/liblmie_interfaces.lib
     $(SolutionDir)/$(ConfigurationName)/liblmie_interfaces_f.lib

where the variable $(SolutionDir) is msvs_2005, msvs_2008, or msvs_2010 and the variable $(ConfigurationName) is Debug or Release. For more information, take a look at the build details for the Fortran 90 interface example program examples/example_f90.f90.

HEAD NEXT