Source code
The source codes are available here .
This code is protected under GNU License Legal
Pre-Required
The doxygen software must be installed on your computer to generate the documentation http://www.doxygen.nl/ with graphviz and mathjax libraries:
- for linux: sudo apt-get install doxygen graphviz
- for mac: brew install doxygen graphviz
A G++- 20 compiler have to be installed and a compiler tool as makedepend
- for linux: sudo apt-get install g++-dev xutils-dev
- for mac: brew install g++ makedepend
- for cross compiling : sudo apt-get install mingw-w64-x86-64-dev
The libraries needed for the program are :
- boost for random functions
- for linux: sudo apt-get libboost-all-dev
- for mac: brew install boost
For linux:
sudo apt-get install g++-dev
sudo apt-get install mingw-w64-x86-64-dev
sudo apt-get install libopenmpi-dev
sudo apt-get install libboost-all-dev
code structure
The StochMagnet software contains following source paths:
- include contains all the .h .hpp files
- src contains all the .c .cpp files
- doc contains the doc files and doxygen configuration file for generating the html/latex documentation
- exe : contains the compiled code
The following paths are automatically created:
- bin : to generate all binary files
- doc : to generate the html doc by make doc command
- obj : the compiled object files for all packages
The licence files are:
It contains also model makefile files to configure the compiling:
- makefile_env.mdl to configure the paths, flags, compiler commands...
- makefile_lib.mdl to configure the thirdParty library paths
- makefile_body.mdl to compile the code thanks to the preceedind environnement variables
- Makefile is the main makefile to define the command make clean lib prog
The installation script install.sh generate the makefile for compiling the code.
the main part to change is the compiler and the library used.
compilation on PC
As the code does not use the c-make library (in the to-do list), the compiliation options is done by hands. there are 3 make files:
- makefile_env.mk : contains the generic compilation environment variables
- makefile_lib.mk : contains the library paths to find the include (.h) and library files (.so,.dll) files
- makefile_body.mk : contains the compilation commands. This files must not be touched
The file makefile_env.mk defined the environment variables:
| variable name | comment |
| OS_TYPE | platform name |
| ARCH | architecture of the machin in {32,64} |
| INSTALL_DIR | path of the instalation program |
| CC | the c compilator |
| CXX | the c++ compilator |
| CC_FLAGS | the option of the c compilator |
| CXX_FLAGS | the option of the c++ compilator |
| AR,RANLIB | the platform commands to generate library |
The file makefile_env.mk defines also the library used within the code whose paths to find library and include files are defined in the makefile_lib.mk file.
The file makefile_env.mk defines also the real type and the integer type used in the code by the define option (-D) of the compiler.
The file makefile_lib.mk define the environments variables for the library libName used:
| variable name | comment |
| libName_HDIR | path to find the include files |
| libName_LDIR | path to find the lib files |
The file makefile_body.mk runs the compilations of the .cpp . c files, generate the libraries and the document files with doxygen.
A script install.sh is furnished in order to set easily the variables of this 3 make files:
ROOT_PATH=${home}/StochMagnet-Code
OS=linux
release with -O3
RELEASE=3
with openmp
OPENMP=--use-openmp
boost paths is the default ones of the system
BOOST_INC_PATH=
BOOST_LIB_PATH=
trng library defind in external path
TRNG_INC_PATH=$ROOT_PATH/external/trng/include
TRNG_LIB_PATH=$ROOT_PATH/external/trng/lib
c++ compilation options
CXX_FLAGS="-std=c++20 -Wunused-local-typedefs"
mpi commands
MPI_CXX=mpic++
MPI_RUN=mpiexec
generate the makefile_*.mk from the template makefile_*.mdl files
./install.sh --cxx=$CXX --cxx-flags="$CXX_FLAGS" --target=$OS --release=$RELEASE $OPENMP --use-double --use-int --mpi-cxx=$MPI_CXX --mpi-run=$MPI_RUN --boost-hdir=$BOOST_INC_PATH --boost-ldir=$BOOST_LIB_PATH --trng-hdir=$TRNG_INC_PATH --trng-ldir=$TRNG_LIB_PATH
compilation command
make clean lib
make prog_withrpath
installation commands
cp bin/linux64/*.exe exe
For example to compile on mac platform, the install script is :
#!/bin/sh
#the type of operating system to compile for
OS=mac
#the version in debug or release mode
RELEASE=3
#without OpenMP module
OPENMP=
#with OpenMP module
#OPENMP=--use-openmp
#the path where to find the boost library. Let it empty for taking the default library
# must be installed on the machine
BOOST_INC_PATH=/usr/local/opt/boost
BOOST_LIB_PATH= /usr/local/opt/boost
trng library defind in external path
TRNG_INC_PATH=
TRNG_LIB_PATH=
#the compiler; The compileation of the program needs at least the Modern C++ 20
CXX=g++-12
#the flag of compilatop,
CXX_FLAGS="-std=c++20 -Wunused-local-typedefs"
MPI_CXX=mpic++
MPI_RUN=mpirun
#run the install script
./install.sh h --cxx=$CXX --cxx-flags="$CXX_FLAGS" --target=$OS --release=$RELEASE $OPENMP --use-double --use-int --mpi-cxx=$MPI_CXX --mpi-run=$MPI_RUN --boost-hdir=$BOOST_INC_PATH --boost-ldir=$BOOST_LIB_PATH --trng-hdir=$TRNG_INC_PATH --trng-ldir=$TRNG_LIB_PATH
#compile the program
make clean lib prog
#copy the compiled exe to main exe path
cp bin/mac64/*.exe exe
To install the doc, run
Perhaps it is usefull to update the doxy.conf file from main paths with doxygen -u or to generate a new one with doxygen -g doxy.conf.new and to translate the variables form old to new doxy.conf file.
The generated index file is located here : [softPath]/doc/stochmagnet/main/mpi/html/index.html
compilation on GRICAD
For parallel gricad platform, the environment has to be installed before.
The external libraries used for the program is :
To install it, run the GIX commands:
# load the GIX commands
source /applis/site/guix-start.sh
# install the library in stochmagnet profile
guix install -p $GUIX _USER_PROFILE_DIR/stochmagnet boost openmpi gcc-toolchain
guix package -I -p $GUIX_USER_PROFILE_DIR/stochmagnet
# load the stochmagnet profile
refresh_guix stochmagnet
# list all the profiles
guix package --list-profiles
# update the packages
guix package -u
Then install the code as in PC Compilation sub section :
MACHINE=luke
RELEASE=true
OS=linux
CXX_FLAGS="-std=c++20 -O3 -Wunused-local-typedefs"
CC_FLAGS="-O3 -Wunused-local-typedefs"
PRECISION="--use-double --use-int "
#PRECISION="--use-ldouble --use-llint "
./install.sh --cxx=g++ --cxx-flags="$CXX_FLAGS" --cc-flags=$CC_FLAGS $PRECISION --machine=$MACHINE --boost-hdir= --boost-ldir= --target=$OS --release=$RELEASE --use-openmp --mpi-cxx=mpic++ --mpi-run=mpirun
source /applis/site/guix-start.sh
refresh_guix stochmagnet
rm exe/*.exe
make clean lib prog_withrpath
cp bin/linux64/*.exe exe
compilation on CIGRI
For parallel idris platform, the environment has to be installed before.
The external libraries used for the program is :
To install it, run the modul load command commands:
#!/bin/bash
# clean the loaded modules
module purge
# load the libraries
module load gcc
module load boost
module load openmpi
# echo of the commands
set -x
# OpenMP threads
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
#binding of OMP threads
export OMP_PLACES=cores
Then install the code as in PC Compilation sub section :
RELEASE=true
OS=linux
CXX_FLAGS="-std=c++20 -O3 -Wunused-local-typedefs"
CC_FLAGS="-O3 -Wunused-local-typedefs"
PRECISION="--use-double --use-int "
#PRECISION="--use-ldouble --use-llint "
./install.sh --cxx=g++ --cxx-flags="$CXX_FLAGS" --cc-flags=$CC_FLAGS $PRECISION --machine=$MACHINE --boost-hdir= --boost-ldir= --target=$OS --release=$RELEASE --use-openmp --mpi-cxx=mpic++ --mpi-run=mpirun
rm exe/*
make clean lib prog_withrpath
cp bin/linux64/*.exe exe