diff --git a/Build/Scripts/HYPRE/build_hypre.sh b/Build/Scripts/HYPRE/build_hypre.sh index 029ced9280a..228d422b474 100755 --- a/Build/Scripts/HYPRE/build_hypre.sh +++ b/Build/Scripts/HYPRE/build_hypre.sh @@ -34,7 +34,8 @@ if [ -d "$FIREMODELS/hypre" ]; then echo "Checking out v2.32.0" $(git checkout v2.32.0) fi - cd $FIREMODELS/hypre/src + cd $FIREMODELS/hypre/src/cmbuild + rm -r $FIREMODELS/hypre/src/cmbuild/* export HYPRE_VERSION=$(git describe) echo "Cleaning hypre repository..." make distclean diff --git a/Build/Scripts/HYPRE/confmake.sh b/Build/Scripts/HYPRE/confmake.sh new file mode 100755 index 00000000000..8aab19d90f1 --- /dev/null +++ b/Build/Scripts/HYPRE/confmake.sh @@ -0,0 +1,19 @@ +export HYPRE_INSTALL_PREFIX=$FIREMODELS/libs/hypre/$HYPRE_VERSION + +if [[ "$FDS_BUILD_TARGET" == *"intel"* ]]; then + C_FLAGS="-O3 -fno-unsafe-math-optimizations -fp-model=precise" +else + C_FLAGS="-O3" +fi + +cmake ../ \ +-DCMAKE_INSTALL_PREFIX=$HYPRE_INSTALL_PREFIX \ +-DCMAKE_C_COMPILER=$CC \ +-DCMAKE_C_FLAGS=$C_FLAGS \ +-DCMAKE_INSTALL_LIBDIR="lib" +#-DCMAKE_OSX_DEPLOYMENT_TARGET="14.0" + +# ./configure CC=$CC FC=mpiifort CFLAGS="-O3 -fno-unsafe-math-optimizations -fp-model=precise" FFLAGS="-O3 -fno-unsafe-math-optimizations -fp-model=precise" \ +# --prefix=$FIREMODELS/libs/hypre/$HYPRE_VERSION + +make install diff --git a/Build/Scripts/HYPRE/confmake_impi_intel_linux.sh b/Build/Scripts/HYPRE/confmake_impi_intel_linux.sh deleted file mode 100755 index 58bd9e910ba..00000000000 --- a/Build/Scripts/HYPRE/confmake_impi_intel_linux.sh +++ /dev/null @@ -1,13 +0,0 @@ -# Check for mpiicx or mpiicc -if command -v mpiicx &> /dev/null; then - CC=mpiicx -elif command -v mpiicc &> /dev/null; then - CC=mpiicc -else - echo "Error: Neither mpiicx nor mpiicc is available on this system." - exit 1 -fi - -./configure CC=$CC FC=mpiifort CFLAGS="-O3 -fno-unsafe-math-optimizations -fp-model=precise" FFLAGS="-O3 -fno-unsafe-math-optimizations -fp-model=precise" \ - --prefix=$FIREMODELS/libs/hypre/$HYPRE_VERSION -make install diff --git a/Build/Scripts/SUNDIALS/confmake.sh b/Build/Scripts/SUNDIALS/confmake.sh new file mode 100755 index 00000000000..740f939ea9f --- /dev/null +++ b/Build/Scripts/SUNDIALS/confmake.sh @@ -0,0 +1,16 @@ +export SUNDIALS_INSTALL_PREFIX=$FIREMODELS/libs/sundials/$SUNDIALS_VERSION + +cmake ../ \ +-DCMAKE_INSTALL_PREFIX=$SUNDIALS_INSTALL_PREFIX \ +-DEXAMPLES_INSTALL_PATH=$SUNDIALS_INSTALL_PREFIX/examples \ +-DCMAKE_C_COMPILER=$CC \ +-DCMAKE_CXX_COMPILER=$CXX \ +-DCMAKE_Fortran_COMPILER=$FC \ +-DBUILD_FORTRAN_MODULE_INTERFACE=ON \ +-DEXAMPLES_ENABLE_CXX=OFF \ +-DEXAMPLES_ENABLE_CUDA=OFF \ +-DEXAMPLES_ENABLE_F2003=OFF \ +-DENABLE_OPENMP=OFF \ +-DCMAKE_INSTALL_LIBDIR="lib" + +make install diff --git a/Build/Scripts/SUNDIALS/confmake_impi_intel_linux.sh b/Build/Scripts/SUNDIALS/confmake_impi_intel_linux.sh deleted file mode 100755 index 70409510adf..00000000000 --- a/Build/Scripts/SUNDIALS/confmake_impi_intel_linux.sh +++ /dev/null @@ -1,35 +0,0 @@ -export SUNDIALS_INSTALL_PREFIX=$FIREMODELS/libs/sundials/$SUNDIALS_VERSION - -# Check for Intel C compiler (icx or icc) -if command -v icx &> /dev/null; then - CC=icx -elif command -v icc &> /dev/null; then - CC=icc -else - echo "Error: Neither icx nor icc is available on this system." - exit 1 -fi - -# Check for Intel C++ compiler (icpx or icpc) -if command -v icpx &> /dev/null; then - CXX=icpx -elif command -v icpc &> /dev/null; then - CXX=icpc -else - echo "Error: Neither icpx nor icpc is available on this system." - exit 1 -fi - -cmake ../ \ --DCMAKE_INSTALL_PREFIX=$SUNDIALS_INSTALL_PREFIX \ --DEXAMPLES_INSTALL_PATH=$SUNDIALS_INSTALL_PREFIX/examples \ --DCMAKE_C_COMPILER=$CC \ --DCMAKE_CXX_COMPILER=$CXX \ --DCMAKE_Fortran_COMPILER=ifort \ --DBUILD_FORTRAN_MODULE_INTERFACE=ON \ --DEXAMPLES_ENABLE_CXX=OFF \ --DEXAMPLES_ENABLE_CUDA=OFF \ --DEXAMPLES_ENABLE_F2003=OFF \ --DENABLE_OPENMP=ON - -make install diff --git a/Build/Scripts/build_thirdparty_libs.sh b/Build/Scripts/build_thirdparty_libs.sh new file mode 100644 index 00000000000..7004c9c7fb2 --- /dev/null +++ b/Build/Scripts/build_thirdparty_libs.sh @@ -0,0 +1,72 @@ +# PARSE OPTIONS FOR CLEAN LIBRARY BUILDS #################################### + +# Parse the long options first using getopt +#OPTIONS=$(getopt -o "" --long clean-hypre,clean-sundials -- "$@") + +# Check if getopt parsed successfully +#if [ $? -ne 0 ]; then +# echo "Error parsing options." +# exit 1 +#fi + +# Evaluate the parsed options +#eval set -- "$OPTIONS" + +# Initialize variables for options +clean_hypre=false +clean_sundials=false +ARG="" + +# Loop through the options +while [[ $# -gt 0 ]]; do + case "$1" in + --clean-hypre) + clean_hypre=true # Set the flag to true when --clean-hypre is used + shift + ;; + --clean-sundials) + clean_sundials=true + shift + ;; + --) + shift + break + ;; + *) + echo "Invalid option." + exit 1 + ;; + esac +done + +# After all options are processed, check for any remaining positional argument (ARG) +if [ -n "$1" ]; then + ARG=$1 +fi + +if [ "$clean_hypre" = true ]; then + echo "Option --clean-hypre is set." +fi + +if [ "$clean_sundials" = true ]; then + echo "Option --clean-sundials is set." +fi + +# FINISHED WITH CLEANING OPTIONS ########################################### + +# Decide compilers +echo "Before setting tpt comp" +source ../Scripts/set_thirdparty_compilers.sh + +# build hypre +source ../Scripts/HYPRE/build_hypre.sh confmake.sh $clean_hypre + +## build sundials +source ../Scripts/SUNDIALS/build_sundials.sh confmake.sh $clean_sundials + + +# Use ARG and the options +#echo "ARG is: $ARG" +if [ "$SOURCE_INTEL_IFORT" -eq 1 ]; then + source ../Scripts/set_intel_compiler.sh $ARG +fi diff --git a/Build/Scripts/set_thirdparty_compilers.sh b/Build/Scripts/set_thirdparty_compilers.sh new file mode 100755 index 00000000000..5f531e7386c --- /dev/null +++ b/Build/Scripts/set_thirdparty_compilers.sh @@ -0,0 +1,150 @@ +echo "FDS build target = $FDS_BUILD_TARGET" + +# For following variables 1- indicate availble through +# environment variable CCCOMP, CXXCOMP, and FCCOMP +set_CC=0 +set_CXX=0 +set_FC=0 + +if [ -n "$CCCOMP" ]; then + CC=$CCCOMP + set_CC=1 +fi + +if [ -n "$CXXCOMP" ]; then + CXX=$CXXCOMP + set_CXX=1 +fi + +if [ -n "$FCCOMP" ]; then + FC=$FCCOMP + set_FC=1 +fi + +if [[ "$FDS_BUILD_TARGET" == *"intel"* ]]; then + # Check for Intel C compiler + if [ $set_CC -eq 0 ]; then + if command -v mpiicx &> /dev/null; then + CC=mpiicx + elif command -v icx &> /dev/null; then + CC=icx + elif command -v mpiicc &> /dev/null; then + CC=mpiicc + elif command -v icc &> /dev/null; then + CC=icc + else + echo "Error: Any of mpiicx, icx, mpiicc, or icc is not available on this system." + exit 1 + fi + fi + + # Check for Intel C++ compiler + if [ $set_CXX -eq 0 ]; then + if command -v mpiicpx &> /dev/null; then + CXX=mpiicpx + elif command -v icpx &> /dev/null; then + CXX=icpx + elif command -v mpiicpc &> /dev/null; then + CXX=mpiicpc + elif command -v icpc &> /dev/null; then + CXX=icpc + else + echo "Error: Any of mpiicpx, icpx, mpiicpc, or icpc is not available on this system." + exit 1 + fi + fi + + # Check for Intel Fortran compiler (ifort). ifx will be added in future. + if [ $set_FC -eq 0 ]; then + if command -v mpiifort &> /dev/null; then + FC=mpiifort + elif command -v ifort &> /dev/null; then + FC=ifort + else + echo "Error: Any of mpiifort, or ifort is not available on this system." + exit 1 + fi + fi +elif [[ "$FDS_BUILD_TARGET" == *"osx"* ]]; then + # Check for C compiler (mpicc, gcc, clang) + if [ $set_CC -eq 0 ]; then + if command -v mpicc &> /dev/null; then + CC=mpicc + elif command -v gcc &> /dev/null; then + CC=gcc + elif command -v clang &> /dev/null; then + CC=clang + else + echo "Error: Any of mpicc, gcc, or clang is not available on this system." + exit 1 + fi + fi + + # Check for clang C++ compiler (mpicxx, g++, clang ++) + if [ $set_CXX -eq 0 ]; then + if command -v mpicxx &> /dev/null; then + CXX=mpicxx + elif command -v g++ &> /dev/null; then + CXX=g++ + elif command -v clang++ &> /dev/null; then + CXX=clang++ + else + echo "Error: Any of mpicxx, g++, or clang++ is not available on this system." + exit 1 + fi + fi + + # Check for Fortran compiler (gfortran) + if [ $set_FC -eq 0 ]; then + if command -v mpifort &> /dev/null; then + FC=mpifort + elif command -v gfortran &> /dev/null; then + FC=gfortran + else + echo "Error: gfortran is not available on this system." + exit 1 + fi + fi +else #gnu + # Check for gnu C compiler (gcc) + if [ $set_CC -eq 0 ]; then + if command -v mpicc &> /dev/null; then + CC=mpicc + elif command -v gcc &> /dev/null; then + CC=gcc + else + echo "Error: Any of mpicc, gcc is not available on this system." + exit 1 + fi + fi + + # Check for Intel C++ compiler (g++) + if [ $set_CXX -eq 0 ]; then + if command -v mpicxx &> /dev/null; then + CXX=mpicxx + elif command -v g++ &> /dev/null; then + CXX=g++ + else + echo "Error: Any of mpicxx, g++ is not available on this system." + exit 1 + fi + fi + + # Check for Fortran compiler (gfortran) + if [ $set_FC -eq 0 ]; then + if command -v gfortran &> /dev/null; then + FC=gfortran + else + echo "Error: gfortran is not available on this system." + exit 1 + fi + fi +fi + +echo "C Compiler CC=$CC" +echo "C++ compiler CXX=$CXX" +echo "Fortran compiler FC=$FC" + +export CC=$CC +export CXX=$CXX +export FC=$FC diff --git a/Build/impi_intel_linux_db/make_fds.sh b/Build/impi_intel_linux_db/make_fds.sh index 293acd281e7..0144295d470 100755 --- a/Build/impi_intel_linux_db/make_fds.sh +++ b/Build/impi_intel_linux_db/make_fds.sh @@ -1,74 +1,13 @@ #!/bin/bash -# PARSE OPTIONS FOR CLEAN LIBRARY BUILDS #################################### - -# Parse the long options first using getopt -OPTIONS=$(getopt -o "" --long clean-hypre,clean-sundials -- "$@") - -# Check if getopt parsed successfully -if [ $? -ne 0 ]; then - echo "Error parsing options." - exit 1 -fi - -# Evaluate the parsed options -eval set -- "$OPTIONS" - -# Initialize variables for options -clean_hypre=false -clean_sundials=false -ARG="" - -# Loop through the options -while true; do - case "$1" in - --clean-hypre) - clean_hypre=true # Set the flag to true when --clean-hypre is used - shift - ;; - --clean-sundials) - clean_sundials=true - shift - ;; - --) - shift - break - ;; - *) - echo "Invalid option." - exit 1 - ;; - esac -done - -# After all options are processed, check for any remaining positional argument (ARG) -if [ -n "$1" ]; then - ARG=$1 -fi - -# Use ARG and the options -#echo "ARG is: $ARG" - -if [ "$clean_hypre" = true ]; then - echo "Option --clean-hypre is set." -fi - -if [ "$clean_sundials" = true ]; then - echo "Option --clean-sundials is set." -fi - -# FINISHED WITH CLEANING OPTIONS ########################################### - -source ../Scripts/set_intel_compiler.sh $ARG - dir=`pwd` target=${dir##*/} -# build hypre -source ../Scripts/HYPRE/build_hypre.sh confmake_impi_intel_linux.sh $clean_hypre +# Compile third-party libraries. +export FDS_BUILD_TARGET=$target +export SOURCE_INTEL_IFORT=1 +source ../Scripts/build_thirdparty_libs.sh "$@" -## build sundials -source ../Scripts/SUNDIALS/build_sundials.sh confmake_impi_intel_linux.sh $clean_sundials # build fds echo Building $target with Intel MPI and $INTEL_IFORT diff --git a/Build/makefile b/Build/makefile index 4bcca163b77..bbc598b5bdd 100644 --- a/Build/makefile +++ b/Build/makefile @@ -109,8 +109,8 @@ endif # MKLROOT test ifdef SUNDIALS_HOME # This assumes the SUNDIALS library is available. FFLAGS_SUNDIALS = -DWITH_SUNDIALS -I"${SUNDIALS_HOME}/fortran" FFLAGS_SUNDIALS_WIN = -DWITH_SUNDIALS /I"${SUNDIALS_HOME}\fortran" - LFLAGS_SUNDIALS = -L${SUNDIALS_HOME}/lib64 -l:libsundials_fcvode_mod.a -l:libsundials_fnvecserial_mod.a -l:libsundials_cvode.a - LFLAGS_SUNDIALS_INTEL = ${SUNDIALS_HOME}/lib64/libsundials_fcvode_mod.a ${SUNDIALS_HOME}/lib64/libsundials_fnvecserial_mod.a ${SUNDIALS_HOME}/lib64/libsundials_cvode.a + LFLAGS_SUNDIALS_GNU = -L${SUNDIALS_HOME}/lib -l:libsundials_fcvode_mod.a -l:libsundials_fnvecserial_mod.a -l:libsundials_cvode.a + LFLAGS_SUNDIALS_INTEL = ${SUNDIALS_HOME}/lib/libsundials_fcvode_mod.a ${SUNDIALS_HOME}/lib/libsundials_fnvecserial_mod.a ${SUNDIALS_HOME}/lib/libsundials_cvode.a LFLAGS_SUNDIALS_OSX = ${SUNDIALS_HOME}/lib/libsundials_fcvode_mod.a ${SUNDIALS_HOME}/lib/libsundials_fnvecserial_mod.a ${SUNDIALS_HOME}/lib/libsundials_cvode.a LFLAGS_SUNDIALS_WIN = ${SUNDIALS_HOME}\lib\sundials_fcvode_mod.lib ${SUNDIALS_HOME}\lib\sundials_fnvecserial_mod.lib ${SUNDIALS_HOME}\lib\sundials_cvode.lib /link /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:libcmtd.lib endif @@ -344,7 +344,7 @@ ompi_intel_linux : setup $(obj_mpi) #*** GNU Compilers *** ompi_gnu_linux : FFLAGS = -m64 -O2 -std=f2018 -frecursive -ffpe-summary=none -fall-intrinsics $(GITINFOGNU) $(FFLAGSMKL_GNU_OPENMPI) $(GFORTRAN_OPTIONS) $(FFLAGS_HYPRE) $(FFLAGS_SUNDIALS) -ompi_gnu_linux : LFLAGSMKL = $(LFLAGSMKL_GNU_OPENMPI) $(LFLAGS_HYPRE) $(LFLAGS_SUNDIALS) +ompi_gnu_linux : LFLAGSMKL = $(LFLAGSMKL_GNU_OPENMPI) $(LFLAGS_HYPRE) $(LFLAGS_SUNDIALS_GNU) ompi_gnu_linux : FCOMPL = mpifort ompi_gnu_linux : FOPENMPFLAGS = -fopenmp ompi_gnu_linux : obj = fds_ompi_gnu_linux @@ -352,7 +352,7 @@ ompi_gnu_linux : setup $(obj_mpi) $(FCOMPL) $(FFLAGS) $(FOPENMPFLAGS) -o $(obj) $(obj_mpi) $(LFLAGSMKL) ompi_gnu_linux_db : FFLAGS = -m64 -O0 -std=f2018 -ggdb -Wall -Werror -Wunused-parameter -Wcharacter-truncation -Wno-target-lifetime -fcheck=all -fbacktrace -ffpe-trap=invalid,zero,overflow -frecursive -ffpe-summary=none -fall-intrinsics -fbounds-check $(GITINFOGNU) $(FFLAGSMKL_GNU_OPENMPI) $(GFORTRAN_OPTIONS) $(FFLAGS_HYPRE) $(FFLAGS_SUNDIALS) -ompi_gnu_linux_db : LFLAGSMKL = $(LFLAGSMKL_GNU_OPENMPI) $(LFLAGS_HYPRE) $(LFLAGS_SUNDIALS) +ompi_gnu_linux_db : LFLAGSMKL = $(LFLAGSMKL_GNU_OPENMPI) $(LFLAGS_HYPRE) $(LFLAGS_SUNDIALS_GNU) ompi_gnu_linux_db : FCOMPL = mpifort ompi_gnu_linux_db : FOPENMPFLAGS = -fopenmp ompi_gnu_linux_db : obj = fds_ompi_gnu_linux_db @@ -360,7 +360,7 @@ ompi_gnu_linux_db : setup $(obj_mpi) $(FCOMPL) $(FFLAGS) $(FOPENMPFLAGS) -o $(obj) $(obj_mpi) $(LFLAGSMKL) ompi_gnu_linux_dv : FFLAGS = -m64 -O1 -fbacktrace -std=f2018 -frecursive -ffpe-summary=none -fall-intrinsics $(GITINFOGNU) $(FFLAGSMKL_GNU_OPENMPI) $(GFORTRAN_OPTIONS) $(FFLAGS_HYPRE) $(FFLAGS_SUNDIALS) -ompi_gnu_linux_dv : LFLAGSMKL = $(LFLAGSMKL_GNU_OPENMPI) $(LFLAGS_HYPRE) $(LFLAGS_SUNDIALS) +ompi_gnu_linux_dv : LFLAGSMKL = $(LFLAGSMKL_GNU_OPENMPI) $(LFLAGS_HYPRE) $(LFLAGS_SUNDIALS_GNU) ompi_gnu_linux_dv : FCOMPL = mpifort ompi_gnu_linux_dv : FOPENMPFLAGS = -fopenmp ompi_gnu_linux_dv : obj = fds_ompi_gnu_linux_dv @@ -393,7 +393,7 @@ ompi_gnu_osx_dv : setup $(obj_mpi) mpich_gnu_polaris : FFLAGS = -m64 -O2 -fbacktrace -std=f2018 -frecursive -ffpe-summary=none -fall-intrinsics $(GITINFOGNU) $(GNU_COMPINFO) $(FFLAGSMKL_GNU_OPENMPI) $(GFORTRAN_OPTIONS) $(FFLAGS_SUNDIALS) #mpich_gnu_polaris : FFLAGS = -m64 -O0 -std=f2018 -ggdb -Wall -Wcharacter-truncation -Wno-target-lifetime -fcheck=all -fbacktrace -ffpe-trap=invalid,zero,overflow -frecursive -ffpe-summary=none -fall-intrinsics $(GITINFOGNU) $(GNU_COMPINFO) $(FFLAGSMKL_GNU_OPENMPI) $(GFORTRAN_OPTIONS) $(FFLAGS_SUNDIALS) -mpich_gnu_polaris : LFLAGSMKL = $(LFLAGSMKL_GNU_OPENMPI) $(LFLAGS_SUNDIALS) +mpich_gnu_polaris : LFLAGSMKL = $(LFLAGSMKL_GNU_OPENMPI) $(LFLAGS_SUNDIALS_GNU) mpich_gnu_polaris : FCOMPL = ftn mpich_gnu_polaris : FOPENMPFLAGS = -fopenmp mpich_gnu_polaris : obj = fds_mpich_gnu_polaris diff --git a/Build/ompi_gnu_osx_db/make_fds.sh b/Build/ompi_gnu_osx_db/make_fds.sh index 885bf58554f..c9efae70d4b 100755 --- a/Build/ompi_gnu_osx_db/make_fds.sh +++ b/Build/ompi_gnu_osx_db/make_fds.sh @@ -2,5 +2,9 @@ dir=`pwd` target=${dir##*/} +# Compile third-party libraries. +export FDS_BUILD_TARGET=$target +source ../Scripts/build_thirdparty_libs.sh "$@" + echo Building $target make -j4 VPATH="../../Source" -f ../makefile $target