### Build and Run Library Examples Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md Builds and runs the library's example programs if examples were enabled during CMake configuration. This command is optional. ```bash make example ``` -------------------------------- ### Installing the Library Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Installs the target library to a specified destination within the installation prefix. It also specifies runtime dependencies and configurations for which the installation should occur. ```cmake install(TARGETS "${libname}" CONFIGURATIONS "${CMAKE_BUILD_TYPE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" RUNTIME_DEPENDENCY_SET pmdeps ) ``` -------------------------------- ### Build and Run Examples Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md Builds and runs the library's example programs, if enabled during CMake configuration. ```batch nmake example ``` -------------------------------- ### Configure Examples to Build and Run (Shell) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use this option with install.bat or install.sh to specify which library examples to build and run after building the library. ```bash --exam "example_list" ``` -------------------------------- ### Install the Library Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md Installs the built library into the 'lib' subdirectory within the build directory. ```bash make install ``` -------------------------------- ### Build and Run Examples for C, C++, Fortran (Windows) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Builds the C, C++, and Fortran libraries and runs all their examples in serial on Windows. ```batch install.bat --lang "c;cpp;fortran" --exam all ``` -------------------------------- ### Prepare Installation Directory Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Prepares the target directory for binary installation by removing it if it exists and then creating it. Sets the environment variable paramonte_bin_current_dir. ```cmake set(paramonte_bin_current_dir "${ddir}/${libname}") set(ENV{paramonte_bin_current_dir} "${paramonte_bin_current_dir}") message(NOTICE "${pmattn} All binary files will be installed at paramonte_bin_current_dir=\"${paramonte_bin_current_dir}\"") if (EXISTS "${paramonte_bin_current_dir}/") message(NOTICE "${pmattn} Removing the existing paramonte_bin_current_dir=\"${paramonte_bin_current_dir}\"") file(REMOVE_RECURSE "${paramonte_bin_current_dir}/") else() message(NOTICE "${pmattn} Generating the non-existing paramonte_bin_current_dir=\"${paramonte_bin_current_dir}\"") file(MAKE_DIRECTORY "${paramonte_bin_current_dir}") endif() ``` -------------------------------- ### Build and Run Examples for C, C++, Fortran (Unix/Linux/macOS) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Builds the C, C++, and Fortran libraries and runs all their examples in serial on Linux and macOS. ```bash ./install.sh --lang "c;cpp;fortran" --exam all ``` -------------------------------- ### Copy ParaMonte Fortran Examples Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Copies the ParaMonte library examples for the Fortran language to the installation directory. It also sets up build scripts for these examples. ```cmake # Copy the ParaMonte library examples to the package directory. #message(NOTICE "${pmattn} Setting the rule for copying the ParaMonte library examples in ${lang} language to the installation directory...") #set(origin "${paramonte_example_dir}/${lang}") #set(destin "${paramonte_bld_pkg_dir}/example") #if (EXISTS "${origin}") # # Copy the example files. # message(NOTICE "${pmattn} Setting the rule for copying the paramonte::${lang} library example files to the installation directory...\n" # "${pmattn} - from: ${origin}\n" # "${pmattn} - to: ${destin}") # add_custom_target(copyDirExample ALL COMMAND ${CMAKE_COMMAND} -E copy_directory "${origin}" "${destin}") # #add_dependencies("${libname}" copyDirExample) # # # Loop over all directories to add the build scripts. # # if ("${build}" STREQUAL "debug") # set(paramonte_example_build_type "debug") # else() # set(paramonte_example_build_type "release") # endif() # # if (${MPI_ENABLED}) # set(paramonte_example_par_type ".mpi") # else() # unset(paramonte_example_par_type) # endif() # # set(paramonte_example_build_script_bash "build.${csid}.${paramonte_example_build_type}${paramonte_example_par_type}.sh") # set(paramonte_example_build_script_batch "build.${csid}.${paramonte_example_build_type}${paramonte_example_par_type}.bat") # # # Loop over all directories to add the build scripts. # # if ("${lang}" STREQUAL "fortran") # if (csid_is_gnu OR csid_is_intel) # setSubDirList(subDirList "${destin}") # set(counter 1) # #message(FATAL_ERROR "${pmattn} destin: ${destin}") # message(FATAL_ERROR "${pmattn} subDirList: ${subDirList}") # message(FATAL_ERROR "${pmattn} Bash build script: ${paramonte_example_build_script_bash}") # message(NOTICE "${pmattn} Batch build script: ${paramonte_example_build_script_batch}") # foreach(subDir ${subDirList}) # setSubDirList(subSubDirList "${destin}/${subDir}") # foreach(subSubDir ${subSubDirList}) # set(example_current_dir "${destin}/${subDir}/${subSubDir}") # message(NOTICE "${pmattn} Adding the build scripts to example at: ${example_current_dir}") # #file(COPY "${paramonte_example_dir}/auxil/${lang}/${paramonte_example_build_script_bash}" DESTINATION "${example_current_dir}" # #FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # #file(RENAME "${example_current_dir}/${paramonte_example_build_script_bash}" "${example_current_dir}/build.sh") # add_custom_target(copyBuildBash${counter} ALL COMMAND ${CMAKE_COMMAND} -E copy # "${paramonte_example_dir}/auxil/${lang}/${paramonte_example_build_script_bash}" "${example_current_dir}/build.sh") # add_dependencies("${libname}" copyBuildBash${counter}) # math(EXPR counter "${counter}+1") # if (WIN32) # #file(COPY "${paramonte_example_dir}/auxil/${lang}/${paramonte_example_build_script_batch}" DESTINATION "${example_current_dir}" # #FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # #file(RENAME "${example_current_dir}/${paramonte_example_build_script_batch}" "${example_current_dir}/build.bat") # add_custom_target(copyBuildBatch${counter} ALL COMMAND ${CMAKE_COMMAND} -E copy # "${paramonte_example_dir}/auxil/${lang}/${paramonte_example_build_script_batch}" "${example_current_dir}/build.bat") # add_dependencies("${libname}" copyBuildBatch${counter}) # math(EXPR counter "${counter}+1") # endif() # endforeach() # endforeach() # else() # message(WARNING "${pmwarn} Unrecognized unsupported compiler detected. ParaMonte examples build scripts will likely not function.") # endif() # else() # message(FATAL_ERROR "${pmfatal} Internal CMake error. Unsupported example language.") # endif() # # ## Set the first line of the build scripts. # # # #set(example_build_precompile_bash "#!/bin/bash") # #set(example_build_precompile_batch "set PATH=..\\..\\..\\lib;%PATH%") # # # ## Set the library name for example build scripts. # # # #set(example_build_compile_bash "main.F90 ../../../lib/libparamonte_*") ``` -------------------------------- ### Configure Examples to Build and Run (CMake) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use this option with the cmake binary executable to specify which library examples to build and run after building the library. ```cmake -Dexam="example_list" ``` -------------------------------- ### Install the Built Library Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md Installs the ParMonte library to the 'lib' subdirectory within the build directory. ```batch nmake install ``` -------------------------------- ### Install ParaMonte C Library (Windows) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Use install.bat to build the ParaMonte C library on Windows. Ensure CMake and compatible compilers are installed. ```batch install.bat --lang c ``` -------------------------------- ### Configure Example Postprocessing Scripts (install.sh) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use this option with install.sh to specify example postprocessing scripts to run after building the library. The value can be 'none', 'all', a file path, or a semicolon-separated list of script names. ```bash --exampp "example_postprocessing_list" ``` -------------------------------- ### Copy Python Setup Files to Package Directory Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.txt Copies Python-specific setup files (e.g., setup.py) to the main package directory. This is necessary for Python package distribution and installation. ```cmake set(origin "${paramonte_src_${lang}_dir}/setup") set(destin "${paramonte_bld_pkg_dir}/setup") message(NOTICE "${pmattn} Setting the rule for copying the paramonte::${lang} library setup files to the package directory...\n" "${pmattn} - from: ${origin}\n" "${pmattn} - to: ${destin}") add_custom_target(copyDirSetup COMMAND ${CMAKE_COMMAND} -E copy_directory "${origin}" "${destin}") add_dependencies(package copyDirSetup) ``` -------------------------------- ### Include ParaMonte Examples Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.txt Adds the ParaMonte example subdirectory if it exists. This is used to build and test library examples. ```cmake if (EXISTS "${paramonte_example_dir}") add_subdirectory("${paramonte_example_dir}" "${paramonte_bld_example_dir}") else() message(WARNING "\n" "${pmwarn} The example directory in the root directory of the ParaMonte library is missing.\n" "${pmwarn} paramonte_example_dir=${paramonte_example_dir}\n" "${pmwarn} Skipping the ParaMonte library example build...\n" "\n" ) endif() ``` -------------------------------- ### Install ParaMonte C++ Library (Windows) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Use install.bat to build the ParaMonte C++ library on Windows. Ensure CMake and compatible compilers are installed. ```batch install.bat --lang cpp ``` -------------------------------- ### Quick Start: Build with install.sh Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Run the install.sh script with the target language to begin the build process. Replace TARGET_LANAGUAGE with your desired programming language. ```bash ./install.sh --lang TARGET_LANAGUAGE ``` -------------------------------- ### Install ParaMonte Fortran Library (Unix/Linux/macOS) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Use install.sh to build the ParaMonte Fortran library on Unix-like systems. Ensure CMake and compatible compilers are installed. ```bash ./install.sh --lang fortran ``` -------------------------------- ### Install ParaMonte C Library (Unix/Linux/macOS) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Use install.sh to build the ParaMonte C library on Unix-like systems. Ensure CMake and compatible compilers are installed. ```bash ./install.sh --lang c ``` -------------------------------- ### Install ParaMonte Fortran Library (Windows) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Use install.bat to build the ParaMonte Fortran library on Windows. Ensure CMake and compatible compilers are installed. ```batch install.bat --lang fortran ``` -------------------------------- ### Handling Unsupported Examples Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt This block is executed when a specified example (exam) is not found. It prints usage instructions and then terminates the CMake process with a fatal error, indicating unsupported examples. ```cmake else() printUsage() message(FATAL_ERROR "\n" "${pmfatal} Unsupported user-specified ParaMonte library examples. exam=${exam}\n" "${pmfatal} Follow the guidelines above to appropriately specify the testing mode or drop the option.\n" "\n" ) ``` -------------------------------- ### Install ParaMonte C++ Library (Unix/Linux/macOS) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Use install.sh to build the ParaMonte C++ library on Unix-like systems. Ensure CMake and compatible compilers are installed. ```bash ./install.sh --lang cpp ``` -------------------------------- ### Install ParaMonte MATLAB Library (Windows) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Use install.bat to build the ParaMonte MATLAB library on Windows. Ensure CMake and compatible compilers are installed. ```batch install.bat --lang matlab ``` -------------------------------- ### Set Build and Installation Directories Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.txt Configures the build directory and installation prefix for the ParaMonte project. It sets the build directory to the binary directory and forces the CMake install prefix to this path. ```cmake if (TRUE) if (DEFINED fresh) string(TOLOWER "${fresh}" fresh) endif() message(NOTICE "${pmattn} Setting up the ParaMonte build directories...") set(bdir "${CMAKE_BINARY_DIR}") set(paramonte_bld_dir "${bdir}") set(ENV{paramonte_bld_dir} "${paramonte_bld_dir}") set(CMAKE_INSTALL_PREFIX "${paramonte_bld_dir}" CACHE BOOL "ParaMonte/OpenBLAS/dependencies install directory prefix." FORCE) message(NOTICE "${pmattn} All build files will be stored at paramonte_bld_dir=\"${paramonte_bld_dir}\"") #### Purge files or folders within the build folder if requested. file(GLOB bld_dir_items LIST_DIRECTORIES true RELATIVE "${paramonte_bld_dir}" "${paramonte_bld_dir}/*") message(NOTICE "${pmattn} The current contents of the ParaMonte build directory: \"${bld_dir_items}\"") message(NOTICE "${pmattn} Purging any requested contents prior to the ParaMonte library build...") endif() ``` -------------------------------- ### Build the Library with Make Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md Builds the library using the GNU Make utility. Ensure Make is installed in your environment. ```bash make ``` -------------------------------- ### Install ParaMonte MATLAB Library (Unix/Linux/macOS) Source: https://github.com/cdslaborg/paramonte/blob/main/QUICKSTART.md Use install.sh to build the ParaMonte MATLAB library on Unix-like systems. Ensure CMake and compatible compilers are installed. ```bash ./install.sh --lang matlab ``` -------------------------------- ### Help Flag Usage Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Displays all contents of the configuration file and available installation flags on the command line. Not available for the CMake binary executable. ```bash --help ``` -------------------------------- ### Specify Parallelization Paradigm (Install Script) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the --par flag with install scripts to specify the parallelization paradigm (e.g., none, mpi, omp). ```bash --par "parallelization_type" ``` -------------------------------- ### Specify Library File Type (Install Script) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the --lib flag with install scripts to specify the library file type (static or shared). ```bash --lib "library_type" ``` -------------------------------- ### Fortran Example Build Script Generation (Intel Compiler) Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Generates build commands for Fortran examples using the Intel compiler. It includes specific flags for optimization, debugging, and linking, tailored for Intel's compiler suite. ```cmake #if (${csid_is_intel}) set(example_build_compile_bash "-standard-semantics -fpp -Wl,-rpath,../../../lib -I../../../inc ${example_build_compile_bash}") if ("${build}" STREQUAL "debug") set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O0 -g3 -CB -debug full -traceback -check all -fpe0 ${example_build_compile_bash}") elseif ("${build}" STREQUAL "testing") set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O2 ${example_build_compile_bash}") else() set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O3 ${example_build_compile_bash}") endif() set(example_build_compile_bash "${example_build_compile_bash} -o main.exe") set(example_build_compile_batch "/standard-semantics /fpp /I:..\..\..\include ${example_build_compile_batch}") if ("${build}" STREQUAL "debug") set(example_build_compile_batch "${CMAKE_Fortran_COMPILER} /Od /debug:full /CB /Qinit:snan,arrays /warn:all /gen-interfaces /traceback /check:all /fpe-all:0 /Qtrapuv ${example_build_compile_batch}") elseif ("${build}" STREQUAL "testing") set(example_build_compile_batch "${CMAKE_Fortran_COMPILER} /O2 ${example_build_compile_batch}") else() set(example_build_compile_batch "${CMAKE_Fortran_COMPILER} /O3 ${example_build_compile_batch}") endif() set(example_build_compile_batch "${example_build_compile_batch} /exe:main.exe") else() message(WARNING "${pmwarn} Unrecognized unsupported compiler detected. ParaMonte examples build scripts will likely not function.") endif() ``` -------------------------------- ### Fortran Example Build Script Generation (GNU Compiler) Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Generates build commands for Fortran examples using the GNU compiler. It includes options for optimization, debugging, and linking. ```cmake #if (${csid_is_gnu}) set(example_build_compile_bash "-cpp -ffree-line-length-none -Wl,-rpath,../../../lib -I../../../inc ${example_build_compile_bash}") if ("${build}" STREQUAL "debug") set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O0 -g -fcheck=all -fbacktrace ${example_build_compile_bash}") elseif ("${build}" STREQUAL "testing") set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O2 ${example_build_compile_bash}") else() set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O3 ${example_build_compile_bash}") endif() set(example_build_compile_bash "${example_build_compile_bash} -o main.exe") set(example_build_compile_batch "${example_build_compile_bash}") elseif (${csid_is_intel}) set(example_build_compile_bash "-standard-semantics -fpp -Wl,-rpath,../../../lib -I../../../inc ${example_build_compile_bash}") if ("${build}" STREQUAL "debug") set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O0 -g3 -CB -debug full -traceback -check all -fpe0 ${example_build_compile_bash}") elseif ("${build}" STREQUAL "testing") set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O2 ${example_build_compile_bash}") else() set(example_build_compile_bash "${CMAKE_Fortran_COMPILER} -O3 ${example_build_compile_bash}") endif() set(example_build_compile_bash "${example_build_compile_bash} -o main.exe") set(example_build_compile_batch "/standard-semantics /fpp /I:..\..\..\include ${example_build_compile_batch}") if ("${build}" STREQUAL "debug") set(example_build_compile_batch "${CMAKE_Fortran_COMPILER} /Od /debug:full /CB /Qinit:snan,arrays /warn:all /gen-interfaces /traceback /check:all /fpe-all:0 /Qtrapuv ${example_build_compile_batch}") elseif ("${build}" STREQUAL "testing") set(example_build_compile_batch "${CMAKE_Fortran_COMPILER} /O2 ${example_build_compile_batch}") else() set(example_build_compile_batch "${CMAKE_Fortran_COMPILER} /O3 ${example_build_compile_batch}") endif() set(example_build_compile_batch "${example_build_compile_batch} /exe:main.exe") else() message(WARNING "${pmwarn} Unrecognized unsupported compiler detected. ParaMonte examples build scripts will likely not function.") endif() ``` -------------------------------- ### Copy README.md to Installation Directory Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Sets up a custom target to copy the README.md file from the source directory to the build package directory. This is useful for including project documentation with the installation. ```cmake #set(origin "${paramonte_src_${lang}_dir}/README.md") #set(destin "${paramonte_bld_pkg_dir}/README.md") #message(NOTICE "${pmattn} Setting the rule for copying the paramonte::${lang} library README.md file to the installation directory...\n" # "${pmattn} - from: ${origin}\n" # "${pmattn} - to: ${destin}") #add_custom_target(copyFileREADME ALL COMMAND ${CMAKE_COMMAND} -E copy "${origin}" "${destin}") #add_dependencies("${libname}" copyFileREADME) ``` -------------------------------- ### Install Open-MPI on Linux Ubuntu Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Use this command to install the Open-MPI MPI library on Linux Ubuntu systems via the APT package manager. ```bash sudo apt install openmpi-bin openmpi-common libopenmpi-dev ``` -------------------------------- ### Configure Example Postprocessing Scripts (cmake) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use this option with the cmake executable to specify example postprocessing scripts. The value can be 'none', 'all', a file path, or a semicolon-separated list of script names. ```cmake -Dexampp="example_postprocessing_list" ``` -------------------------------- ### All-in-One Build for Unix-compatible Environments Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md A single command to create build directory, configure with Unix Makefiles, build, and install the library in other Unix-compatible environments. ```bash mkdir build; cd build && cmake -G "Unix Makefiles" .. -Dfc="$(command -v gfortran)" && make && make install ``` -------------------------------- ### Copy Python Setup Files Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Specifically for Python, this adds a custom target to copy the 'setup' directory to the build package directory. This is essential for Python package distribution. ```cmake # if ("${lang}" STREQUAL "python") # # set(origin "${paramonte_src_${lang}_dir}/setup") # set(destin "${paramonte_bld_pkg_dir}/setup") # message(NOTICE "${pmattn} Setting the rule for copying the paramonte::${lang} library setup files to the installation directory...\n" # "${pmattn} - from: ${origin}\n" # "${pmattn} - to: ${destin}") # add_custom_target(copyDirSetup ALL COMMAND ${CMAKE_COMMAND} -E copy_directory "${origin}" "${destin}") # add_dependencies("${libname}" copyDirSetup) # ``` -------------------------------- ### All-in-One Build for MinGW Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md A single command to create build directory, configure with MinGW Makefiles, build, and install the library in MinGW environments. ```bash mkdir build; cd build && cmake -G "MinGW Makefiles" .. -Dfc="$(command -v gfortran.exe)" && make && make install ``` -------------------------------- ### Specify Memory Usage Type (Install Script) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the --mem flag with install scripts to specify the memory allocation type (stack or heap). ```bash --mem "memory_allocation_type" ``` -------------------------------- ### Specify Target Programming Language (Install Script) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the --lang flag with install scripts to specify the target programming language(s). A semi-colon-separated list can be provided for multiple languages. ```bash --lang "programming_language" ``` -------------------------------- ### Define Binary Installation Directory Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.txt Sets the ParaMonte binary installation directory. It uses a predefined 'ddir' variable if available, otherwise defaults to a subdirectory within the main ParaMonte directory. ```cmake if (DEFINED ddir) set(paramonte_bin_dir "${ddir}") else() set(paramonte_bin_dir "${paramonte_dir}/_bin") endif() ``` -------------------------------- ### Specify Library Modules with install scripts Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the --mod flag with install scripts to specify which ParaMonte library modules to compile. This helps reduce library size and build time by including only essential components. ```bash --mod "module_list" ``` -------------------------------- ### Specify Output Library Name with install scripts Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the --libname flag with install scripts to define the binary name of the output library. The default name is 'libparamonte'. ```bash --libname "desired_paramonte_library_name" ``` -------------------------------- ### All-in-One Build for MSYS2 Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md A single command to create build directory, configure with MSYS2 Makefiles, build, and install the library in MSYS2 environments. ```bash mkdir build; cd build && cmake -G "MSYS2 Makefiles" .. -Dfc="$(command -v gfortran.exe)" && make && make install ``` -------------------------------- ### Get Character at Index Source: https://github.com/cdslaborg/paramonte/blob/main/cmake/string/README.md Retrieves the character at a specific index within a string. Indexing starts at 0, and negative indices are supported. ```cmake set(input "example") string_char_at("${input}" 3) # => "m" string_char_at("${input}"-3) # => "l" ``` -------------------------------- ### All-in-One CMake Build Command Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.md A concise command to create the build directory, configure, build, and install the ParMonte library. ```batch mkdir build & cd build && cmake -G "NMake Makefiles" .. && nmake && nmake install ``` -------------------------------- ### Define Project Root Directories Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.txt Sets up the ParaMonte directory hierarchy, defining the project root and external directories. Example paths are provided. ```cmake message(NOTICE "${pmattn} setting up the ParaMonte directory hierarchy...") message(NOTICE "${pmattn} project root directory: ${CMAKE_SOURCE_DIR}") # define paramonte_dir as CMAKE_SOURCE_DIR set(paramonte_dir "${CMAKE_SOURCE_DIR}") set(paramonte_ext_dir "${paramonte_dir}/external") set(paramonte_ext_obl_dir "${paramonte_dir}/external/OpenBLAS") set(paramonte_example_dir "${paramonte_dir}/example" CACHE PATH "ParaMonte example source files directory") set(paramonte_benchmark_dir "${paramonte_dir}/benchmark" CACHE PATH "ParaMonte benchmark source files directory") ``` -------------------------------- ### Install MATLAB Mex Targets Source: https://github.com/cdslaborg/paramonte/blob/main/src/matlab/xrc/CMakeLists.txt Installs the compiled MATLAB MEX targets into the 'lib' subdirectory of the installation prefix. This ensures that the MEX files are placed in the correct location for MATLAB to find them. ```cmake install(TARGETS ${xtargets} CONFIGURATIONS "${CMAKE_BUILD_TYPE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" #RUNTIME_DEPENDENCY_SET xdeps ) ``` -------------------------------- ### Specify CMake Build Generator with install scripts Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the -G flag with install scripts to specify the CMake build generator. This is useful when the install scripts fail to auto-detect the correct generator. ```bash -G "cmake_build_generator" ``` -------------------------------- ### Run install.bat script Source: https://github.com/cdslaborg/paramonte/blob/main/install.bat.md Execute the install.bat script to build the ParaMonte library. Replace TARGET_LANAGUAGE with your desired programming language. ```batch install.bat --lang TARGET_LANAGUAGE ``` -------------------------------- ### Check if String Starts With Prefix Source: https://github.com/cdslaborg/paramonte/blob/main/cmake/string/README.md Returns true if the input string starts with the specified search string. ```cmake string_starts_with("substring" "sub") # => true ``` ```cmake string_starts_with("substring" "ub") # => false ``` -------------------------------- ### Install Open-MPI on macOS Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Use this command to install the Open-MPI MPI library on macOS systems via the Homebrew package manager. ```bash brew install openmpi && brew link openmpi ``` -------------------------------- ### Install.sh with release build and MPI/checking disabled Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Run the install.sh script to build in release mode, enable MPI parallelism, and disable checking. ```bash ./install.sh --lang c --build release --par mpi --checking nocheck ``` -------------------------------- ### Install MPICH on macOS Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Use this command to install the MPICH MPI library on macOS systems via the Homebrew package manager. ```bash brew install mpich && brew link mpich ``` -------------------------------- ### string_slice Source: https://github.com/cdslaborg/paramonte/blob/main/cmake/string/README.md Extracts a portion of a string based on start and end indices. The slice includes the start index but excludes the end index. ```APIDOC ## string_slice ### Description Extracts a portion from string "str" at the specified index: [start_index, end_index). Indexing of slices starts at 0. Indices less than -1 are translated into "length - |index|". ### Parameters #### Path Parameters - **str** (string) - Required - The input string. - **start_index** (int) - Required - The starting index of the slice (inclusive). - **end_index** (int) - Required - The ending index of the slice (exclusive). ### Request Example ``` set(input "abc") string_slice("${input}" 0 1) ``` ### Response #### Success Response (200) - **result** (string) - The extracted portion of the string. ``` -------------------------------- ### Specify Benchmarks with install.bat/sh Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the `--bench` flag with `install.bat` or `install.sh` to select which library benchmarks to build and run. The default is 'none'. ```bash --bench "benchmark_list" ``` -------------------------------- ### Build Flag Usage with install scripts Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Specifies the library build type for install scripts. Can accept a semi-colon-separated list of build types. ```bash --build "build_type" ``` -------------------------------- ### Usage with install.sh Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md General syntax for using configuration flags with the install.sh script. Multiple flag-value pairs can be used. ```bash ./install.sh --flag value ``` -------------------------------- ### Define Binary Installation Directory Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Sets the binary installation directory 'ddir'. If not specified, it defaults to a subdirectory within the CMAKE_SOURCE_DIR. Ensures the path is absolute. ```cmake if ("${ddir}" STREQUAL "") set(ddir "${CMAKE_SOURCE_DIR}/_bin") message(NOTICE "${pmattn} Unspecified ParaMonte binary install directory `ddir`.") message(NOTICE "${pmattn} Defining and generating the ParaMonte build directory: ddir=\"${ddir}\"") else() message(NOTICE "${pmattn} User-specified ParaMonte binary install directory detected. ddir=\"${ddir}\"") if (NOT IS_ABSOLUTE "${ddir}") set(ddir "${CMAKE_SOURCE_DIR}/${ddir}") message(NOTICE "${pmattn} Absolute path for the user-specified ParaMonte binary install directory: ddir=\"${ddir}\"") endif() endif() ``` -------------------------------- ### Install MPICH on Linux Ubuntu Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Use this command to install the MPICH MPI library on Linux Ubuntu systems via the APT package manager. ```bash sudo apt install mpich ``` -------------------------------- ### Install.sh with release build and MPI/OpenMP parallelism, checking disabled Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Execute the install.sh script for a release build, enabling both MPI and OpenMP parallelism, and disabling checking. ```bash ./install.sh --lang c --build release --par "mpi;omp" --checking nocheck ``` -------------------------------- ### ParaMonte Build Commands on TACC Source: https://github.com/cdslaborg/paramonte/blob/main/CMakeLists.txt Example commands for building the ParaMonte library on TACC systems, including setting up the development environment and configuring CMake with various options. ```bash idev -N 1 -n 68 -m 15 # on KNL idev -p skx-dev -N 1 -n 48 -t 00:15:00 # on SKX cmake .. -DMPI_ENABLED=TRUE -DCFI_ENABLED=TRUE -DDLL_ENABLED=TRUE -DCMAKE_BUILD_TYPE=debug cmake ../../.. -Dbuild=release -Dpar=cafdist make make install make deploy make test make example make benchmark ``` -------------------------------- ### install.bat build with release configuration and MPI parallelism Source: https://github.com/cdslaborg/paramonte/blob/main/install.bat.md Builds ParaMonte in release mode, enabling C language and MPI parallelism. 'nocheck' flag disables build checks. ```batch install.bat --lang c --build release --par mpi --checking nocheck ``` -------------------------------- ### Configure Fortran Preprocessing Style with install.sh Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the --fpp flag with install.sh to specify the Fortran preprocessing style. This affects how Fortran source files are processed before building the library. ```bash --fpp "fortran_preprocessing_style" ``` -------------------------------- ### install.bat build with release configuration and MPI/OpenMP parallelism Source: https://github.com/cdslaborg/paramonte/blob/main/install.bat.md Builds ParaMonte in release mode, enabling C language and both MPI and OpenMP parallelism. 'nocheck' flag disables build checks. ```batch install.bat --lang c --build release --par "mpi;omp" --checking nocheck ``` -------------------------------- ### Infer Shell Compatibility for Examples Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Infers the shell compatibility for building ParaMonte examples. Sets the build script name based on the detected shell type. ```cmake if (DEFINED shell) string(TOLOWER "${shell}" shell) if ("${shell}" STREQUAL "posix") set(paramonte_example_build_script "build.sh") ``` -------------------------------- ### Usage with install.bat Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md General syntax for using configuration flags with the install.bat script. Multiple flag-value pairs can be used. ```bash ./install.bat --flag value ``` -------------------------------- ### Install Runtime Dependencies with Intel Compiler Support Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt This snippet installs runtime dependencies for shared libraries. It includes specific logic to find Intel compiler libraries and recursively installs resolved dependencies, while reporting unresolved and conflicting ones. Use this when building with Intel compilers and needing to ensure all library dependencies are packaged. ```cmake if (DLL_ENABLED AND DEPS_ENABLED) install(CODE [[ #### #### For intel compilers, we take an aggressive approach to find the dependencies #### as several libraries in the Intel OneAPI collection do not link statically. #### if ("${CMAKE_INSTALL_PREFIX}" MATCHES ".*[Ii][Nn][Tt][Ee][Ll].*") execute_process(COMMAND which ifx OUTPUT_VARIABLE ifcpath) string(REGEX REPLACE "\n$" "" ifcpath "${ifcpath}") if (IS_DIRECTORY "${ifcpath}" OR NOT EXISTS "${ifcpath}") execute_process(COMMAND which ifx OUTPUT_VARIABLE ifcpath) string(REGEX REPLACE "\n$" "" ifcpath "${ifcpath}") if (IS_DIRECTORY "${ifcpath}" OR NOT EXISTS "${ifcpath}") unset(ifcpath) endif() endif() endif() set(ilibdir ".") if (DEFINED ifcpath) get_filename_component(ilibdir "${ifcpath}" DIRECTORY) get_filename_component(ilibdir "${ilibdir}" DIRECTORY) set(ilibdir "${ilibdir}/lib") if (NOT IS_DIRECTORY "${ilibdir}") message(NOTICE "${pmwarn} Failed to find the Intel compilers library path from: ${ifcpath}") message(NOTICE "${pmwarn} The expected Intel compilers library path is: ${ilibdir}") set(ilibdir ".") endif() endif() #### #### Now recursively find dependencies. #### function(install_library_with_deps LIBRARY) file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FOLLOW_SYMLINK_CHAIN FILES "${LIBRARY}" ) file(GET_RUNTIME_DEPENDENCIES LIBRARIES ${LIBRARY} RESOLVED_DEPENDENCIES_VAR resolved_deps UNRESOLVED_DEPENDENCIES_VAR unresolved_deps CONFLICTING_DEPENDENCIES_PREFIX colflicting POST_EXCLUDE_REGEXES ".*MATLAB.*" ".*matlab.* DIRECTORIES "${ilibdir}" ) foreach(FILE ${resolved_deps}) if(NOT IS_SYMLINK ${FILE}) install_library_with_deps(${FILE}) endif() endforeach() foreach(FILE ${unresolved_deps}) message(NOTICE "${pmwarn} Unresolved dependency from ${LIBRARY}: ${FILE}") endforeach() foreach(FILE ${colflicting_FILENAMES}) message(NOTICE "${pmwarn} Conflicting dependency: ${FILE}") endforeach() endfunction() file(GET_RUNTIME_DEPENDENCIES LIBRARIES $ CONFLICTING_DEPENDENCIES_PREFIX colflicting UNRESOLVED_DEPENDENCIES_VAR unresolved_deps RESOLVED_DEPENDENCIES_VAR resolved_deps POST_EXCLUDE_REGEXES ".*MATLAB.*" ".*matlab.* DIRECTORIES "${ilibdir}" ) foreach(FILE ${resolved_deps}) install_library_with_deps(${FILE}) endforeach() foreach(FILE ${unresolved_deps}) message(NOTICE "${pmwarn} Unresolved dependency: ${FILE}") endforeach() foreach(FILE ${colflicting_FILENAMES}) message(NOTICE "${pmwarn} Conflicting dependency: ${FILE}") endforeach() ]]) endif() ``` -------------------------------- ### Specify Build Directory with install.bat/sh Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use the `--bdir` flag with `install.bat` or `install.sh` to specify the library build directory. The path must be absolute. ```bash --bdir "cmake_build_directory_path" ``` -------------------------------- ### Copy LICENSE.md to Installation Directory Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Configures a custom target to copy the LICENSE.md file from the source directory to the build package directory. This ensures the license is included with the installed package. ```cmake #set(origin "${paramonte_dir}/LICENSE.md") #set(destin "${paramonte_bld_pkg_dir}/LICENSE.md") #message(NOTICE "${pmattn} Setting the rule for copying the paramonte::${lang} library LICENSE.md file to the installation directory...\n" # "${pmattn} - from: ${origin}\n" # "${pmattn} - to: ${destin}") #add_custom_target(copyFileLICENSE ALL COMMAND ${CMAKE_COMMAND} -E copy "${origin}" "${destin}") #add_dependencies("${libname}" copyFileLICENSE) ``` -------------------------------- ### Install Test Executable Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/test/CMakeLists.txt Installs the ParaMonte test executable to a specified runtime destination based on the build type. This command ensures the executable is placed in the correct location after building. ```cmake set(CMAKE_INSTALL_PREFIX "${paramonte_bld_test_bin_dir}/") install(TARGETS ${ParaMonteTest_EXE_NAME} CONFIGURATIONS "${CMAKE_BUILD_TYPE}" RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" ) ``` -------------------------------- ### Run install.sh in Background with Output Redirection Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Execute the install.sh script in the background while redirecting its output to a file. This allows the script to run without blocking the terminal. ```bash ./install.sh --lang TARGET_LANAGUAGE > install.sh.out 2>&1 & ``` -------------------------------- ### Install Shared Library with Dependencies Source: https://github.com/cdslaborg/paramonte/blob/main/src/matlab/xrc/CMakeLists.txt This CMake function recursively installs a shared library and its resolved runtime dependencies. It handles both resolved and unresolved dependencies by logging unresolved ones. ```cmake function(install_library_with_deps LIBRARY) file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FOLLOW_SYMLINK_CHAIN FILES "${LIBRARY}" ) file(GET_RUNTIME_DEPENDENCIES LIBRARIES ${LIBRARY} RESOLVED_DEPENDENCIES_VAR resolved_deps UNRESOLVED_DEPENDENCIES_VAR unresolved_deps ) foreach(FILE ${resolved_deps}) if(NOT IS_SYMLINK ${FILE}) install_library_with_deps(${FILE}) endif() endforeach() foreach(FILE ${unresolved_deps}) message(STATUS "Unresolved from ${LIBRARY}: ${FILE}") endforeach() endfunction() ``` -------------------------------- ### Run install.sh in Background, Redirect Output, and Disown Source: https://github.com/cdslaborg/paramonte/blob/main/install.sh.md Run the install.sh script in the background, redirect its output, and disown the process. This ensures the script continues to run even after the terminal session is closed. ```bash ./install.sh --lang TARGET_LANAGUAGE > install.sh.out 2>&1 & jobs; disown ``` -------------------------------- ### Copy CHANGES.md to Installation Directory Source: https://github.com/cdslaborg/paramonte/blob/main/src/fortran/main/CMakeLists.txt Configures a custom target to copy the CHANGES.md file from the source directory to the build package directory. This ensures that change logs are available with the installed software. ```cmake #set(origin "${paramonte_dir}/CHANGES.md") #set(destin "${paramonte_bld_pkg_dir}/CHANGES.md") #message(NOTICE "${pmattn} Setting the rule for copying the paramonte::${lang} library CHANGES.md file to the installation directory...\n" # "${pmattn} - from: ${origin}\n" # "${pmattn} - to: ${destin}") #add_custom_target(copyFileCHANGES ALL COMMAND ${CMAKE_COMMAND} -E copy "${origin}" "${destin}") #add_dependencies("${libname}" copyFileCHANGES) ``` -------------------------------- ### Configure logical kinds indices with install.sh Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use this option with install.sh to specify logical kind indices for the ParaMonte library build. The indices are a semicolon-separated list. ```bash --lki "logical_kinds_indices" ``` -------------------------------- ### Configure Additional Fortran Compiler Flags (install.sh) Source: https://github.com/cdslaborg/paramonte/blob/main/install.config.md Use this option with install.sh to pass additional flags to the Fortran compiler during library build. Flags are semicolon-separated. ```bash --fcf "additional_fortran_compiler_flags" ```