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,

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.
  • On Linux OS
    • We recommend installing and using the Intel Parallel Studio2019.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 version 10.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 library 3.2 or newer.
  • 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 library 4.0.5.

Preamble: Setting up the environment

In brief, the process of building your Fortran application involves the following steps,

  1. 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,
    • or build the ParaMonte library for the configuration of your choice.
  2. Navigate to the directory containing your uncompressed ParaMonte library files and paste (that is, overwrite the existing three paramonte.in, logfunc.f90, and main.f90 files with) your files and codes.
  3. 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.
        Intel Parallel Studio's customized command-line interface

        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 environmental PATH variable.
    • On Linux / macOS, use a Bash terminal.

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.

  • On Linux / macOS
    Type the following on the Bash terminal that you opened in the previous section,
    chmod +x build.sh
    ./build.sh
    

    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.

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 and main.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
    
  • 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 the PREPROCESSOR_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 in logfunc.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 and main.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
    
  • 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 the PREPROCESSOR_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 in logfunc.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.
  • 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 and main.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 the PREPROCESSOR_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 in logfunc.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.
  • 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 and main.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 the PREPROCESSOR_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 in logfunc.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.
  • 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 and main.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
    
  • 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 the PREPROCESSOR_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 in logfunc.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.
  • 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 and main.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 the PREPROCESSOR_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 in logfunc.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.
  • 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 and main.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 the PREPROCESSOR_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 in logfunc.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.
  • 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 and main.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 the PREPROCESSOR_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 in logfunc.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.
  • 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 and main.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
    
  • 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 the PREPROCESSOR_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 in logfunc.f90.


If you have any questions about the topics discussed on this page, feel free to ask in the comment section below, or raise an issue on the GitHub page of the library, or reach out to the ParaMonte library authors.