Preamble
Suppose you have written a file named logfunc.f90
containing an implementation of your mathematical objective function and a main.f90
file containing call(s) to the ParaMonte routines of your choice to sample the objective function.
The corresponding required paramonte.f90
module interface file can be also downloaded from here.
At this point, you need to have already made up your mind about which approach you want to take to compile and link your code to the ParaMonte library,
- you have already built the ParaMonte library from scratch on your system, or,
- you intend to use the prebuilt ParaMonte libraries.
If you have not made up your mind yet, we recommend using the prebuilt ParaMonte binaries. Although the entire ParaMonte library build process is fully automated, it can take much longer than simply downloading the prebuilt ParaMonte libraries from the project’s repository.
Preamble: The compiler choice
To build and link your application, we recommend installing the following compilers on your system,
- On Windows OS
- We recommend installing and using the Intel Parallel Studio
2019.1.1
or newer, although older versions may also work.
- We recommend installing and using the Intel Parallel Studio
- On Linux OS
- We recommend installing and using the Intel Parallel Studio ≥
2019.1.1
or newer, although older versions may also work. - Alternatively, you can also install a recent release of the GNU Compiler Collection
gcc/g++/gfortran
(preferably version10.1.0
or newer) instead of the Intel compiler suite. If you intend to build parallel applications, you will have to also have a compatible MPI library installed on your system, preferably the MPICH MPI library3.2
or newer.
- We recommend installing and using the Intel Parallel Studio ≥
- On macOS
The situation is slightly complicated on MacOS. Apparently, Apple and Intel corporations have an intense internal rivalry and competition with each other, so much that Apple did not want to help Intel make their MPI library available on macOS. As a result, the Intel Parallel Studio cannot be used to build parallel MPI applications on macOS. Therefore,- If you intend to build and use serial ParaMonte applications, then we still recommend installing and using the Intel Compiler Suite ≥ 2019.1.1 or newer on your system.
- If you intend to build and use parallel ParaMonte applications, then the best option would be to download and install a recent version of the GNU Compiler Collection (preferably, the same version with which the ParaMonte was built:
10.1.0
) as well as the Open-MPI library4.0.5
.Tip: See the instructions on the installation page on how to seamlessly install the above compilers and libraries in less than one minute on your Mac.
Preamble: Setting up the environment
In brief, the process of building your Fortran application involves the following steps,
- Either,
- Download the ParaMonte prebuilt library of your choice from the release page of the ParaMonte repository on GitHub. If you are not sure which one is suitable for your usage, see,
- the pre-installation notes and,
- the installation instructions for Windows, or,
- the installation instructions for macOS, or,
- the installation instructions for Linux.
Tip: On Windows, unzipping the compressed file is easy as clicking on the file to open it via the Windows explorer. On Linux or macOS, you can untar the compress file via the following command in a Bash terminal,tar xvzf libparamonte_fortran_linux_x64_intel_release_shared_heap.tar.gz
where you will have to replacelibparamonte_fortran_linux_x64_intel_release_shared_heap
with the name of the compressed library file that you have downloaded. - or build the ParaMonte library for the configuration of your choice.
Tip: When building the ParaMonte library or downloading the prebuilt ParaMonte libraries, always choose therelease
mode as your library build-type among the available three default choices (release
,testing
,debug
). Therelease
build-type results in the highest-performing ParaMonte library build and the fastest runtime simulations. If needed, use thetesting
build-type solely for quick application builds for testing purposes and thedebug
build-type solely for debugging your simulations at runtime. - Download the ParaMonte prebuilt library of your choice from the release page of the ParaMonte repository on GitHub. If you are not sure which one is suitable for your usage, see,
- Navigate to the directory containing your uncompressed ParaMonte library files and paste (that is, overwrite the existing three
paramonte.in
,logfunc.f90
, andmain.f90
files with) your files and codes. - Open a command-line interface and navigate to the directory containing your uncompressed ParaMonte library files.
- On Windows
- If you choose to use the Intel Fortran compiler to build your application, then we strongly recommend you to use the Intel Parallel Studio’s customized command-line interface that is automatically installed on your system. You can access it from the Windows startup menu as illustrated in the figure below.
Open a 64-bit instance of the Intel Parallel Studio’s command-line interface. This command-line prompt comes with all the relevant compiler and linker environmental variables predefined in your session so that you won’t need to manually modify the contents of your environmentalPATH
variable.
- If you choose to use the Intel Fortran compiler to build your application, then we strongly recommend you to use the Intel Parallel Studio’s customized command-line interface that is automatically installed on your system. You can access it from the Windows startup menu as illustrated in the figure below.
- On Linux / macOS, use a Bash terminal.
- On Windows
Building the executable: The quick automated approach
- On Windows
- To build your application via the Intel Fortran compiler, type the following on the Intel Parallel Studio command-line interface that you opened in the previous section,
build.bat
The above Batch script will both build and run the application executable. See this page on how to set the number of processors for parallel simulations.
- To build your application via the Intel Fortran compiler, type the following on the Intel Parallel Studio command-line interface that you opened in the previous section,
- On Linux / macOS
Type the following on the Bash terminal that you opened in the previous section,chmod +x build.sh ./build.sh
Tip: There are several options that can be specified at the time of calling thebuild.sh
script, including the option to set the default number of MPI- or Coarray- parallel tasks. To get help on the options, try,./build.sh -h
or,./build.sh --help
Tip: By default, the build-script automatically chooses the compiler for building your application based on the name of the prebuilt ParaMonte library that you have chosen to use. You can override this default option by providing the compiler name and the compile/linker flags via the two command-line options-c
and-f
to the build-script. For example,-
to compile and link a serial Fortran application via the GNU Fortran compiler against a Linux-version or a macOS-version of an Intel-prebuilt serial shared ParaMonte library in
release
mode, you can specify the following options for the build-script on the command-line,./build.sh -c gfortran -f "-std=gnu -O3 -funroll-loops -finline-functions -ftree-vectorize -cpp"
-
to compile and link an MPI-parallel Fortran application via the Intel MPI-wrapper for the GNU Fortran compiler against a Linux-version of an Intel-prebuilt serial shared ParaMonte library in
release
mode, you can specify the following options for the build-script on the command-line,./build.sh -c mpifort -f "-std=gnu -O3 -funroll-loops -finline-functions -ftree-vectorize -cpp"
-c
compiler option, it is imperative to specify the-f
compiler-flags option along with it. Failure to do so will cause the script to switch to the default inferred flags from the name of the compiler used in the filename of the ParaMonte library that is being used. The inconsistent compiler flags will then cause the application-build to abort.The build-script generates the executable along with a Bash script
run.sh
in the same directory, which can be called on the command-line to run the executable. See this page on how to set the number of processors for parallel simulations and run the executable. -
to compile and link a serial Fortran application via the GNU Fortran compiler against a Linux-version or a macOS-version of an Intel-prebuilt serial shared ParaMonte library in
If your simulation-build and run have been successful, you can skip the following detailed sections on the build process via different specific compilers on different platforms and glance through the tips and information provided in the examples on this website to post-process the ParaMonte simulation results and output files.
Building the executable: Do-it-yourself
There are currently more than 210 possible configurations with which you can build the ParaMonte library. Covering the compilation and linking procedure for all of these different scenarios here is impossible. To simplify, we will only consider compiling and linking your Fortran application via the ParaMonte library build in release
mode for only shared (dynamic) linking. Before continuing to build your application manually, make sure you follow the guidelines outlined in the Preamble section in the above.
Building the executable on Windows via the Intel Fortran compiler
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:set "COMPILER_LINKER_FLAGS=/standard-semantics /O3 /Qip /Qipo /Qunroll /Qunroll-aggressive /fpp"
- for
testing
:set "COMPILER_LINKER_FLAGS=/standard-semantics /Od /fpp"
- for
debug
:set "COMPILER_LINKER_FLAGS=/standard-semantics /Od /debug:full /CB /Qinit:snan,arrays /warn:all /gen-interfaces /traceback /check:all /fpe-all:0 /Qtrapuv /fpp"
Choose your ParaMonte interface style
If you are using the same compiler/linker version that has been used to build the ParaMonte library and you would like to use the Object-Oriented (OOP) interface of the ParaMonte routines, then you will have to pass the following preprocessor macro to the compiler as well,
set "PREPROCESSOR_FLAGS=/DIS_COMPATIBLE_COMPILER"
This will define the preprocessor macro IS_COMPATIBLE_COMPILER
, which will enable the use of the OOP interface of the ParaMonte routines. Otherwise, you may want to unset this variable to ensure that you will be using the old-style Fortran interface to the ParaMonte library,
set "PREPROCESSOR_FLAGS="
Building the executable on Windows via the Intel Fortran compiler for serial applications
-
We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,dir /a /b /n
build.bat libparamonte_fortran_windows_x64_intel_release_shared_heap.dll libparamonte_fortran_windows_x64_intel_release_shared_heap.exp libparamonte_fortran_windows_x64_intel_release_shared_heap.lib logfunc.fortran main.fortran paramonte.in README.md
Tip: If you encounter difficulties in navigating to your target build folder on the command-prompt, see the troubleshooting page for the possible cause and the solution. -
Now, we are going to use the Intel Fortran compiler to compile and link your code,
set "PREPROCESSOR_FLAGS="
set "COMPILER_LINKER_FLAGS=/standard-semantics /O3 /Qip /Qipo /Qunroll /Qunroll-aggressive /fpp"
ifort %COMPILER_LINKER_FLAGS% %PREPROCESSOR_FLAGS% paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_windows_x64_intel_release_shared_heap.lib -o main.exe
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.4.245 Build 20190417 Copyright (C) 1985-2019 Intel Corporation. All rights reserved. Microsoft (R) Incremental Linker Version 14.22.27905.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:main.exe -subsystem:console logfunc.obj main.obj libparamonte_fortran_windows_x64_intel_release_shared_heap.lib
Note the missing
/DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the old-style, but more-portable Fortran interface to the ParaMonte library. -
The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.f90
.
Building the executable on Windows via the Intel Fortran compiler for parallel applications
-
For simplicity, we will only consider the MPI-parallelism here. We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,dir /a /b /n
build.bat libparamonte_fortran_windows_x64_intel_release_shared_heap_impi.dll libparamonte_fortran_windows_x64_intel_release_shared_heap_impi.exp libparamonte_fortran_windows_x64_intel_release_shared_heap_impi.lib logfunc.fortran main.fortran paramonte.in README.md
Tip: If you encounter difficulties in navigating to your target build folder on the command-prompt, see the troubleshooting page for the possible cause and the solution. -
Now, we are going to use the Intel Fortran MPI compiler wrapper to compile and link your code,
set "PREPROCESSOR_FLAGS="
set "COMPILER_LINKER_FLAGS=/standard-semantics /O3 /Qip /Qipo /Qunroll /Qunroll-aggressive /fpp"
mpiifort %COMPILER_LINKER_FLAGS% %PREPROCESSOR_FLAGS% paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_windows_x64_intel_release_shared_heap_impi.lib -o main.exe
mpifc.bat for the Intel(R) MPI Library 2019 Update 4 for Windows* Copyright 2007-2019 Intel Corporation. Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.4.245 Build 20190417 Copyright (C) 1985-2019 Intel Corporation. All rights reserved. Microsoft (R) Incremental Linker Version 14.22.27905.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:main.exe -subsystem:console "/LIBPATH:C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\mpi\intel64\bin\..\..\intel64\lib\release" "/LIBPATH:C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\mpi\intel64\bin\..\..\intel64\lib" impi.lib C:\Users\SHAHMO~1\AppData\Local\Temp\ipo_4449624.obj libparamonte_fortran_windows_x64_intel_release_shared_heap_impi.lib
Note the missing
/DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the old-style, but more-portable Fortran interface to the ParaMonte library. -
The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.f90
.
Building the executable on macOS via the Intel Fortran compiler
Open a Bash terminal that recognizes your local installation of the Intel compilers and libraries.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:export COMPILER_LINKER_FLAGS="-standard-semantics -O3 -ip -ipo -unroll -unroll-aggressive -finline-functions -fpp"
- for
testing
:export COMPILER_LINKER_FLAGS="-standard-semantics -O0 -fpp"
- for
debug
:export COMPILER_LINKER_FLAGS="-standard-semantics -O0 -debug full -fpp"
Choose your ParaMonte interface style
If you are using the same compiler/linker version that has been used to build the ParaMonte library and you would like to use the Object-Oriented (OOP) interface of the ParaMonte routines, then you will have to pass the following preprocessor macro to the compiler as well,
export PREPROCESSOR_FLAGS="-DIS_COMPATIBLE_COMPILER"
This will define the preprocessor macro IS_COMPATIBLE_COMPILER
, which will enable the use of the OOP interface of the ParaMonte routines. Otherwise, you may want to unset this variable to ensure that you will be using the old-style Fortran interface to the ParaMonte library,
unset PREPROCESSOR_FLAGS
Building the executable on macOS via the Intel Fortran compiler for serial applications
- We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the Intel Fortran compiler, in general, you should be able to use the Intel Fortran compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU Fortran compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_fortran_darwin_x64_intel_release_shared_heap.dylib logfunc.f90 main.f90 paramonte.in README.md
-
Now, we are going to use the Intel Fortran compiler to compile and link your code,
unset PREPROCESSOR_FLAGS # the missing macro definition implies we are using the procedural-style-Fortran interface to the ParaMonte library
export COMPILER_LINKER_FLAGS="-standard-semantics -O3 -ip -ipo -unroll -unroll-aggressive -finline-functions -fpp"
ifort $COMPILER_LINKER_FLAGS $PREPROCESSOR_FLAGS paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_darwin_x64_intel_release_shared_heap.dylib -o main.exe
Note the missing
-DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the procedural-style, but more-portable Fortran interface to the ParaMonte library. - The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.f90
.
Building the executable on macOS via the GNU Fortran compiler
Open a Bash terminal that recognizes your local installation of the GNU compilers and libraries.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:export COMPILER_LINKER_FLAGS="-std=gnu -O3 -funroll-loops -finline-functions -ftree-vectorize -cpp"
- for
testing
:export COMPILER_LINKER_FLAGS="-std=gnu -O0 -cpp"
- for
debug
:export COMPILER_LINKER_FLAGS="-std=gnu -O0 -g -cpp"
Choose your ParaMonte interface style
If you are using the same compiler/linker version that has been used to build the ParaMonte library and you would like to use the Object-Oriented (OOP) interface of the ParaMonte routines, then you will have to pass the following preprocessor macro to the compiler as well,
export PREPROCESSOR_FLAGS="-DIS_COMPATIBLE_COMPILER"
This will define the preprocessor macro IS_COMPATIBLE_COMPILER
, which will enable the use of the OOP interface of the ParaMonte routines. Otherwise, you may want to unset this variable to ensure that you will be using the old-style Fortran interface to the ParaMonte library,
unset PREPROCESSOR_FLAGS
Building the executable on macOS via the GNU Fortran compiler for serial applications
- We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the GNU Fortran compiler, in general, you should be able to use the GNU Fortran compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU Fortran compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_fortran_darwin_x64_gnu_release_shared_heap.dylib logfunc.f90 main.f90 paramonte.in README.md
-
Now, we are going to use the GNU Fortran compiler to compile and link your code,
unset PREPROCESSOR_FLAGS # the missing macro definition implies we are using the procedural-style-Fortran interface to the ParaMonte library
export COMPILER_LINKER_FLAGS="-std=gnu -O3 -funroll-loops -finline-functions -ftree-vectorize -cpp"
gfortran $COMPILER_LINKER_FLAGS $PREPROCESSOR_FLAGS paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_darwin_x64_gnu_release_shared_heap.dylib -o main.exe
Note the missing
-DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the procedural-style, but more-portable Fortran interface to the ParaMonte library. - The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.f90
.
Building the executable on macOS via the GNU Fortran compiler for MPI-parallel applications
- We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the GNU Fortran compiler, in general, you should be able to use the GNU Fortran compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU Fortran compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_fortran_darwin_x64_gnu_release_shared_heap_mpich.dylib logfunc.f90 main.f90 paramonte.in README.md
Note: If you are using theOpenMPI
library in place of theMPICH
MPI library, simply replace the keywordmpich
withopenmpi
anywhere it appears on this page. -
Now, we are going to use the Open-MPI compiler wrapper for the GNU Fortran compiler to compile and link your code,
unset PREPROCESSOR_FLAGS # the missing macro definition implies we are using the procedural-style-Fortran interface to the ParaMonte library
export COMPILER_LINKER_FLAGS="-std=gnu -O3 -funroll-loops -finline-functions -ftree-vectorize -cpp"
mpifort $COMPILER_LINKER_FLAGS $PREPROCESSOR_FLAGS paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_darwin_x64_gnu_release_shared_heap_mpich.dylib -o main.exe
Note the missing
-DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the procedural-style, but more-portable Fortran interface to the ParaMonte library. - The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.f90
.
Building the executable on Linux via the Intel Fortran compiler
Open a Bash terminal that recognizes your local installation of the Intel compilers and libraries.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:export COMPILER_LINKER_FLAGS="-standard-semantics -O3 -ip -ipo -unroll -unroll-aggressive -finline-functions -fpp"
- for
testing
:export COMPILER_LINKER_FLAGS="-standard-semantics -O0 -fpp"
- for
debug
:export COMPILER_LINKER_FLAGS="-standard-semantics -O0 -debug full -fpp"
Choose your ParaMonte interface style
If you are using the same compiler/linker version that has been used to build the ParaMonte library and you would like to use the Object-Oriented (OOP) interface of the ParaMonte routines, then you will have to pass the following preprocessor macro to the compiler as well,
export PREPROCESSOR_FLAGS="-DIS_COMPATIBLE_COMPILER"
This will define the preprocessor macro IS_COMPATIBLE_COMPILER
, which will enable the use of the OOP interface of the ParaMonte routines. Otherwise, you may want to unset this variable to ensure that you will be using the old-style Fortran interface to the ParaMonte library,
unset PREPROCESSOR_FLAGS
Building the executable on Linux via the Intel Fortran compiler for serial applications
- We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the Intel Fortran compiler, in general, you should be able to use the Intel Fortran compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU Fortran compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_fortran_linux_x64_intel_release_shared_heap.so logfunc.f90 main.f90 paramonte.in README.md
-
Now, we are going to use the Intel Fortran compiler to compile and link your code,
unset PREPROCESSOR_FLAGS # the missing macro definition implies we are using the procedural-style-Fortran interface to the ParaMonte library
export COMPILER_LINKER_FLAGS="-standard-semantics -O3 -ip -ipo -unroll -unroll-aggressive -finline-functions -fpp"
ifort $COMPILER_LINKER_FLAGS $PREPROCESSOR_FLAGS paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_linux_x64_intel_release_shared_heap.so -o main.exe
Note the missing
-DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the procedural-style, but more-portable Fortran interface to the ParaMonte library. - The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.f90
.
Building the executable on Linux via the Intel Fortran compiler for MPI-parallel applications
- We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the Intel Fortran compiler, in general, you should be able to use the Intel Fortran compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU Fortran compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_fortran_linux_x64_intel_release_shared_heap_impi.so logfunc.f90 main.f90 paramonte.in README.md
-
Now, we are going to use the Intel MPI compiler wrapper for the Intel Fortran compiler to compile and link your code,
unset PREPROCESSOR_FLAGS # the missing macro definition implies we are using the procedural-style-Fortran interface to the ParaMonte library
export COMPILER_LINKER_FLAGS="-standard-semantics -O3 -ip -ipo -unroll -unroll-aggressive -finline-functions -fpp"
mpiifort $COMPILER_LINKER_FLAGS $PREPROCESSOR_FLAGS paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_linux_x64_intel_release_shared_heap_impi.so -o main.exe
Note the missing
-DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the procedural-style, but more-portable Fortran interface to the ParaMonte library. - The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.f90
.
Building the executable on Linux via the GNU Fortran compiler
Open a Bash terminal that recognizes your local installation of the GNU compilers and libraries.
Depending on the build type you would like to specify for your application ( release
, testing
, debug
), you may want to define the compiler/linker flags,
- for
release
:export COMPILER_LINKER_FLAGS="-std=gnu -O3 -funroll-loops -finline-functions -ftree-vectorize -cpp"
- for
testing
:export COMPILER_LINKER_FLAGS="-std=gnu -O0 -cpp"
- for
debug
:export COMPILER_LINKER_FLAGS="-std=gnu -O0 -g -cpp"
Choose your ParaMonte interface style
If you are using the same compiler/linker version that has been used to build the ParaMonte library and you would like to use the Object-Oriented (OOP) interface of the ParaMonte routines, then you will have to pass the following preprocessor macro to the compiler as well,
export PREPROCESSOR_FLAGS="-DIS_COMPATIBLE_COMPILER"
This will define the preprocessor macro IS_COMPATIBLE_COMPILER
, which will enable the use of the OOP interface of the ParaMonte routines. Otherwise, you may want to unset this variable to ensure that you will be using the old-style Fortran interface to the ParaMonte library,
unset PREPROCESSOR_FLAGS
Building the executable on Linux via the GNU Fortran compiler for serial applications
- We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the GNU Fortran compiler, in general, you should be able to use the GNU Fortran compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU Fortran compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_fortran_linux_x64_gnu_release_shared_heap.so logfunc.f90 main.f90 paramonte.in README.md
-
Now, we are going to use the GNU Fortran compiler to compile and link your code,
unset PREPROCESSOR_FLAGS # the missing macro definition implies we are using the procedural-style-Fortran interface to the ParaMonte library
export COMPILER_LINKER_FLAGS="-std=gnu -O3 -funroll-loops -finline-functions -ftree-vectorize -cpp"
gfortran $COMPILER_LINKER_FLAGS $PREPROCESSOR_FLAGS paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_linux_x64_gnu_release_shared_heap.so -o main.exe
Note the missing
-DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the procedural-style, but more-portable Fortran interface to the ParaMonte library. - The above step should generate a
main.exe
executable file in the same directory. You can now run this executable to generate samples from your objective function as implemented inlogfunc.f90
.
Building the executable on Linux via the GNU Fortran compiler for MPI-parallel applications
- We will consider building the Fortran application via the ParaMonte library build in
release
mode for shared (dynamic) linking. The corresponding prebuilt ParaMonte library can be downloaded from here.Tip: Although here we are downloading and using the ParaMonte libraries prebuilt via the GNU Fortran compiler, in general, you should be able to use the GNU Fortran compiler to link your applications against the ParaMonte libraries prebuilt via either Intel or GNU Fortran compilers. -
Navigate to the folder containing the ParaMonte library on your local system. Move your Fortran example codes to this folder (This will overwrite the existing
logfunc.f90
andmain.f90
files in this folder with yours). You should then be able to see the following files inside the folder,ls -1
build.sh libparamonte_fortran_linux_x64_gnu_release_shared_heap_mpich.so logfunc.f90 main.f90 paramonte.in README.md
Note: If you are using theOpenMPI
library in place of theMPICH
MPI library, simply replace the keywordmpich
withopenmpi
anywhere it appears on this page. -
Now, we are going to use the MPICH MPI compiler wrapper for the GNU Fortran compiler to compile and link your code,
unset PREPROCESSOR_FLAGS # the missing macro definition implies we are using the procedural-style-Fortran interface to the ParaMonte library
export COMPILER_LINKER_FLAGS="-std=gnu -O3 -funroll-loops -finline-functions -ftree-vectorize -cpp"
mpifort $COMPILER_LINKER_FLAGS $PREPROCESSOR_FLAGS paramonte.f90 logfunc.f90 main.f90 libparamonte_fortran_linux_x64_gnu_release_shared_heap_mpich.so -o main.exe
Note the missing
-DIS_COMPATIBLE_COMPILER
macro definition as the value of thePREPROCESSOR_FLAGS
environmental variable, implying that we have used the procedural-style, but more-portable Fortran interface to the ParaMonte library. - The above step should generate an MPI-parallelized
main.exe
executable file in the same directory. You can now run this executable – in parallel on any number of processors you wish – to generate samples from your objective function as implemented inlogfunc.f90
.