1+ #! /bin/bash
2+
13echo " FDS build target = $FDS_BUILD_TARGET "
24
35# Initialize variables and check environment variables
4- set_compiler_var () {
5- local var_name=$1 # Variable name to set (e.g., CC, CXX, FC )
6- local env_var=$2 # Environment variable to check (e.g., FIREMODELS_LIBS_CC )
7- local set_flag_var=$3 # Flag variable name (e.g., set_CC, set_CXX, set_FC )
6+ set_compiler_from_env_var () {
7+ local var_name=$1 # Variable name to set (e.g., COMP_CC, COMP_CXX, COMP_FC )
8+ local env_var=$2 # Environment variable to check (e.g., FIREMODELS_CC )
9+ local set_flag_var=$3 # Flag variable name (e.g., set_COMP_CC, set_COMP_CXX, set_COMP_FC )
810
911 if [ -n " ${! env_var} " ]; then
1012 eval " $var_name =${! env_var} "
@@ -18,8 +20,8 @@ set_compiler_var() {
1820
1921
2022# Set compilers based on the build target
21- select_compiler () {
22- local var_name=$1 # Variable to set (CC, CXX, FC )
23+ select_compiler_from_system () {
24+ local var_name=$1 # Variable to set (COMP_CC, COMP_CXX, COMP_FC )
2325 shift
2426 local compilers=(" $@ " ) # List of compilers to check in order
2527 local set_flag_var=" set_$var_name "
@@ -41,39 +43,35 @@ select_compiler() {
4143}
4244
4345
44- # Following variables indicate if compilers are set using environment variables FIREMODELS_LIBS_XXX .
45- set_CC =0
46- set_CXX =0
47- set_FC =0
46+ # Following variables indicate if compilers are set using environment variables FIREMODELS_XXX .
47+ set_COMP_CC =0
48+ set_COMP_CXX =0
49+ set_COMP_FC =0
4850
4951# Check environment variables for compilers
50- set_compiler_var CC FIREMODELS_LIBS_CC set_CC
51- set_compiler_var CXX FIREMODELS_LIBS_CXX set_CXX
52- set_compiler_var FC FIREMODELS_LIBS_FC set_FC
52+ set_compiler_from_env_var COMP_CC FIREMODELS_CC set_COMP_CC
53+ set_compiler_from_env_var COMP_CXX FIREMODELS_CXX set_COMP_CXX
54+ set_compiler_from_env_var COMP_FC FIREMODELS_FC set_COMP_FC
5355
5456# Determine compiler list based on build target
5557if [[ " $FDS_BUILD_TARGET " == * " osx" * ]]; then
56- select_compiler CC mpicc clang gcc
57- select_compiler CXX mpicxx clang++ g++
58- select_compiler FC mpifort gfortran
58+ select_compiler_from_system COMP_CC mpicc clang gcc
59+ select_compiler_from_system COMP_CXX mpicxx clang++ g++
60+ select_compiler_from_system COMP_FC mpifort
5961elif [[ " $FDS_BUILD_TARGET " == * " intel" * ]]; then
60- select_compiler CC mpiicx icx mpiicc icc
61- select_compiler CXX mpiicpx icpx mpiicpc icpc
62- select_compiler FC ifort mpiifx ifx
62+ select_compiler_from_system COMP_CC mpiicx icx mpiicc icc
63+ select_compiler_from_system COMP_CXX mpiicpx icpx mpiicpc icpc
64+ select_compiler_from_system COMP_FC mpiifx mpiifort
6365else # Default to GNU compilers
64- select_compiler CC mpicc gcc
65- select_compiler CXX mpicxx g++
66- select_compiler FC mpifort gfortran
66+ select_compiler_from_system COMP_CC mpicc gcc
67+ select_compiler_from_system COMP_CXX mpicxx g++
68+ select_compiler_from_system COMP_FC mpifort
6769fi
6870
71+ echo " Thirdparty libs C Compiler COMP_CC=$COMP_CC "
72+ echo " Thirdparty libs C++ compiler COMP_CXX=$COMP_CXX "
73+ echo " Firemodels and Thirdparty libs Fortran compiler COMP_FC=$COMP_FC "
6974
70- echo " Third-party libs C Compiler=$CC "
71- echo " Third-party libs C++ compiler=$CXX "
72- echo " Third-party libs Fortran compiler=$FC "
73-
74- export CC=$CC
75- export CXX=$CXX
76- export FC=$FC
77-
78-
79-
75+ export COMP_CC=$COMP_CC
76+ export COMP_CXX=$COMP_CXX
77+ export COMP_FC=$COMP_FC
0 commit comments