This section provides steps and links on obtaining and setting up Lecode model.
The following instructions assume a beginner’s level of familiarity with the Unix/Linux operating environment, including:
How to open a terminal window,
How to navigate between directories using a terminal application,
How to open, edit, save and close a file using an editor through a terminal application.
There are many beginners Unix/Linux guides available as textbooks and on the Internet, including the
Unix Tutorial for Beginners.
For help, advice or the latest information, check out the documentation in the child pages as well as the wiki or contact the SGFM support team and we’ll help you sort it out.
Lecode relies on a suite of software applications, which need to be installed prior to installing Lecode. It is recommended that you install each program in the order listed.
Below is the list of required dependencies:
Lecode will work and is supported on:
Linux-based OS (desktop and supercomputers)
Mac OS X (Intel)
Note: Lecode is currently not available on Windows.
Lecode is currently supported for GNU compilers , however it works as well with Intel compilers.
Both C, C++ and fortran compilers are required. For Linux OS , they should already been installed with your distribution.
GNU compilers for Mac OS can be downloaded from the HPC website. To install them you could follow the explanations provided on the website or proceed as follow in a Terminal:
$ gunzip gcc-X.X-bin.tar.gz
$ sudo tar -xvf gcc-X.X-bin.tar -C /
It installs everything in /usr/local. Then edit your ~/.profile in Mac OS or ~/.bashrc in Linux environment and set up the path to the installed compilers.
export PATH=/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Now update the configuration file in your Terminal by typing:
$ source ~/.profile (on Mac)
$ source ~/.bashrc (on Linux)
Then check that the version you've just installed of the compilers is set as the default one.
$ g++ --version
$ gfortran --version
$ gcc --version
Lecode supports MPICH and OpenMPI. Below you will find guide to install MPICH.
MPICH can be downloaded from the MPICH website. You will need to download the
source code such as the mpich-3.1 (stable release). Once downloaded, open a Terminal, go to the untar folder and do:
$ tar -xvf mpich3-xxx.tar
$ cd mpich3-xxx
$ CC=gcc FC=gfortran CXX=g++ ./configure --prefix=/usr/local/lecode/mpich --enable-fast=all --enable-shared --enable-sharedlibs=osx-gcc
$ make
$ sudo make install
Then edit your ~/.profile in Mac OS or ~/.bashrc in Linux environment and set up the paths to the installed libraries and compilers.
export MPI_DIR=/usr/local/lecode/mpich
export PATH=$MPI_DIR/bin:$PATH
export LD_LIBRARY_PATH=$MPI_DIR/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$MPI_DIR/lib:$DYLD_LIBRARY_PATH
Now update the configuration file in your Terminal by typing:
$ source ~/.profile (on Mac)
$ source ~/.bashrc (on Linux)
Then check that the version you've just installed of the compilers is set as the default one.
$ which mpicc
$ which mpif90
$ which mpic++
Lecode uses Hdf5 as default library to produce its outputs.
Hdf5 can be downloaded from the Hdf5 website.
You will need to download the source code available for all platform such as the HDF5-1.8.13 Source Code.
Once downloaded, open a Terminal and navigate to the untar folder and do:
$ CC=mpicc FC=mpif90 ./configure --prefix=/usr/local/lecode/hdf5 --enable-parallel --enable-fortran --enable-shared
After the configuration script has finished, checked the summary of the log which is printed on your screen and ensure that both Hdf5 for Fortran and Hdf5 for C are present as well as the Hdf5 compression facility (Zlib). If Zlib is missing you will have to install it first following documentation in the Zlib website.
$ make
$ sudo make install
Then edit your ~/.profile in Mac OS or ~/.bashrc in Linux environment and set up the paths to the installed libraries and compilers.
export HDF5_DIR=/usr/local/lecode/hdf5
export PATH=$HDF5_DIR/bin:$PATH
export LD_LIBRARY_PATH=$HDF5_DIR/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$HDF5_DIR/lib:$DYLD_LIBRARY_PATH
Now update the configuration file in your Terminal by typing:
$ source ~/.profile (on Mac)
$ source ~/.bashrc (on Linux)
Lecode uses FoX XmL parser for fortran.
FoX can be downloaded from the FoX repository.
You will need to download the source code available as a tarball such as FoX-4.1.2.tar.gz.
Once downloaded, open a Terminal and navigate to the untar folder and do:
$ cd FoX-xxx
$ FCFLAGS='-O2 -fPIC' FC=mpif90 ./configure --prefix=/usr/local/lecode/FoX
$ make
$ sudo make install
Once compiled, you will need to open the /usr/local/lecode/FoX/bin/FoX-config file using your preferred editing file:
$ sudo emacs /usr/local/lecode/FoX-xxx/bin/FoX-config
And change the comp_prefix (third line of the file) to the correct prefix in this case: /usr/local/lecode/FoX and delete the /objs at the end of the path.
Then edit your ~/.profile in Mac OS or ~/.bashrc in Linux environment and set up the paths to the installed libraries and compilers.
export PATH=/usr/local/lecode/FoX/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/lecode/FoX/lib:$LD_LIBRARY_PATH
Now update the configuration file in your Terminal by typing:
$ source ~/.profile (on Mac)
$ source ~/.bashrc (on Linux)
Lecode uses a kd-Tree search algorithm to position flow walkers over the grids.
A kd-Tree algorithm for fortran can be downloaded from the kd-Tree repository.
Before downloading the required files, you will have to create a folder called kdtree2 on your desktop and then download the following files from the kd-Tree webpage:
kdtree.f90, and
kdtree2.f90
Then in your preferred text editor, copy the lines below in a new file named Makefile within the new kdtree2 folder:
# KD_TREE2
# For gfortran
#
FLAGSOPT= -O3 -funroll-loops --param max-unroll-times=2 -cpp -ftree-vectorize -ffast-math -lstdc++
F90=mpif90
#
FLAGS= ${FLAGSMACHINE} ${FLAGSALWAYS} ${FLAGSOPT}
MY_DIR=`basename ${PWD}`
all: kdtree2_test kdtree_test
ar -rcs libkdtree.a kdtree.o kdtree2.o
kdtree2_test: kdtree2.o
${F90} ${FLAGS} -c kdtree2.o
kdtree_test: kdtree.o
${F90} ${FLAGS} -c kdtree.o
%.o : %.f90
${F90} ${FLAGS} -c $<
clean:
/bin/rm -f *.o *.mod *.il
Save and close the file and open the downloaded kdtree2.f90 file and change lines 22 and 23 to:
! integer, parameter :: kdkind = sp
integer, parameter :: kdkind = dp
It will enable the use of double precision real numbers.
Then compile the kd-Tree library by writing the following command in your Terminal:
$ cd ~/Desktop/kdtree2
$ make
Once compiled, move the folder to a place that will be pointed out within Lecode configuration file. The default is:
$ sudo mv ~/Desktop/kdtree2 /usr/local/lecode/kdtree2
Then edit your ~/.profile in Mac OS or ~/.bashrc in Linux environment and set up the paths to the installed libraries and compilers.
export PATH=/usr/local/lecode/kdtree2:$PATH
export LD_LIBRARY_PATH=/usr/local/lecode/kdtree2:$LD_LIBRARY_PATH
Now update the configuration file in your Terminal by typing:
$ source ~/.profile (on Mac)
$ source ~/.bashrc (on Linux)
To generate the triangular irregular network (TIN), Lecode uses the Triangle Library.
Triangle can be downloaded from the Triangle website.
You will need to download the source code available as a zip file.
Once downloaded, open a Terminal and navigate to the zip file and using root privileges move it:
$ sudo mv triangle.zip /usr/local/
$ sudo unzip triangle.zip
$ sudo make
Then go within the triangle.c file and change the main(int argc, char **argv) &
main(argc, argv) to main2(int argc, char **argv) & main2(argc, argv) at lines 15682 & 15684 respectively.
Then compile the new file using:
$ gcc -O -DLINUX -I/usr/X11R6/include -L/usr/X11R6/lib -c -o ./triangle.o ./triangle.c
Then edit your ~/.profile in Mac OS or ~/.bashrc in Linux environment and set up the paths to the installed libraries and compilers.
export PATH=/usr/local/lecode/triangle:$PATH
Now update the configuration file in your Terminal by typing:
$ source ~/.profile (on Mac)
$ source ~/.bashrc (on Linux)
Finally do one of the following depending of your compiler (GNU or Intel):
$ gcc -O3 -m64 -fno-common -fPIC -c -o triangle.o triangle.c
$ icc -O3 -m64 -fno-common -fPIC -c -o triangle.o triangle.c
If you've obtained the authorisations required for Lecode source code and if you've managed to install all the dependencies above, you are ready to compile Lecode.
Prior to starting the compilation process, you will need to check the path to the libraries you've installed on your system as they might differs from one to the other. In Lecode, the configuration are defined in the config folder.
The folder contains a bunch of configuration files associated to different configuration e.g. Linux/Mac or Intel/Gnu. Depending on the ones you've installed copy of the files and edit it:
$ cp Makefile.cfg.osx Makefile.cfg.myconfig
$ emacs Makefile.cfg.myconfig
In the file insure that the paths are set correctly (if not sure look at your ~/.profile or ~/.bashrc :
FC= mpif90
CC=mpicc
CPP=mpicxx
FOX=/usr/local/lecode/FoX/bin
TRIANGLELIB=/usr/local/lecode/triangle
HDF5=/usr/local/lecode/hdf5
KDTREE=/usr/local/lecode/kdtree2
Make the necessary changes and save your file. Now open the Makefile.inc file and change the first line to match with your new configuration file name:
CFGFILE = $(TOP)/config/Makefile.cfg.myconfig
If you are using Intel compilers there are 3 other things that needs to be done in the file Classes/ClassGeneral.f90:
at line 18 of the file: delete the comment "!" in front of the line
at line 65 of the file: delete the comment "!" in front of the line
at line 67 of the file: add a comment "!" in front of the line
Then compile Lecode sources from the top directory:
$ make clobber
$ make dist
And edit your ~/.profile in Mac OS or ~/.bashrc in Linux environment and set up the paths to the installed libraries and compilers.
export PATH=/lecode-install-dir/bin:$PATH
export DYLD_LIBRARY_PATH=/lecode-install-dir/build/lib:$DYLD_LIBRARY_PATH
Now update the configuration file in your Terminal by typing:
$ source ~/.profile (on Mac)
$ source ~/.bashrc (on Linux)
You are now ready to go... well done!