Skip to content

Commit ee56541

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents ba7d364 + e34d30b commit ee56541

File tree

3 files changed

+78
-152
lines changed

3 files changed

+78
-152
lines changed

Build/Scripts/build_thirdparty_libs.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ fi
77

88
echo "FIREMODELS=$FIREMODELS"
99

10+
clean_fds=false
1011
clean_hypre=false
1112
clean_sundials=false
1213
ARG=""
@@ -15,10 +16,15 @@ ARG=""
1516
while [[ $# -gt 0 ]]; do
1617
case "$1" in
1718
--clean-all)
19+
clean_fds=true
1820
clean_hypre=true
1921
clean_sundials=true
2022
shift
2123
;;
24+
--clean-fds)
25+
clean_fds=true
26+
shift
27+
;;
2228
--clean-hypre)
2329
clean_hypre=true # Set the flag to true when --clean-hypre is used
2430
shift
@@ -41,6 +47,11 @@ done
4147
# Trim leading spaces from ARG, if necessary
4248
ARG="${ARG#"${ARG%%[![:space:]]*}"}"
4349

50+
if [ "$clean_fds" = true ]; then
51+
echo "Option --clean-fds is set."
52+
rm *.o *.mod >& /dev/null
53+
fi
54+
4455
if [ "$clean_hypre" = true ]; then
4556
echo "Option --clean-hypre is set."
4657
fi
Lines changed: 59 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,79 @@
11
echo "FDS build target = $FDS_BUILD_TARGET"
22

3-
# For following variables 1- indicate availble through
4-
# environment variable FIREMODELS_LIBS_CC, FIREMODELS_LIBS_CXX, and FIREMODELS_LIBS_FC
5-
set_CC=0
6-
set_CXX=0
7-
set_FC=0
3+
# 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)
88

9-
if [ -n "$FIREMODELS_LIBS_CC" ]; then
10-
CC=$FIREMODELS_LIBS_CC
11-
if command -v $CC &> /dev/null; then
12-
set_CC=1
13-
else
14-
echo "The compiler specified by the FIREMODELS_LIBS_CC environment variable ($CC) is not available on this system. Searching for an alternative compiler."
15-
fi
16-
fi
9+
if [ -n "${!env_var}" ]; then
10+
eval "$var_name=${!env_var}"
11+
if command -v "${!var_name}" &> /dev/null; then
12+
eval "$set_flag_var=1"
13+
else
14+
echo "Warning: ${!env_var} specified by $env_var is not available. Searching for an alternative."
15+
fi
16+
fi
17+
}
1718

18-
if [ -n "$FIREMODELS_LIBS_CXX" ]; then
19-
CXX=$FIREMODELS_LIBS_CXX
20-
if command -v $CXX &> /dev/null; then
21-
set_CXX=1
22-
else
23-
echo "The compiler specified by the FIREMODELS_LIBS_CXX environment variable ($CXX) is not available on this system. Searching for an alternative compiler."
24-
fi
25-
fi
2619

27-
if [ -n "$FIREMODELS_LIBS_FC" ]; then
28-
FC=$FIREMODELS_LIBS_FC
29-
if command -v $FC &> /dev/null; then
30-
set_FC=1
31-
else
32-
echo "The compiler specified by the FIREMODELS_LIBS_FC environment variable ($FC) is not available on this system. Searching for an alternative compiler."
33-
fi
34-
fi
20+
# Set compilers based on the build target
21+
select_compiler() {
22+
local var_name=$1 # Variable to set (CC, CXX, FC)
23+
shift
24+
local compilers=("$@") # List of compilers to check in order
25+
local set_flag_var="set_$var_name"
3526

27+
# Only proceed if the compiler flag is not set
28+
if [ "$(eval echo \$$set_flag_var)" -eq 0 ]; then
29+
for compiler in "${compilers[@]}"; do
30+
if command -v "$compiler" &> /dev/null; then
31+
# Set the compiler variable
32+
eval "$var_name=$compiler"
33+
# Set the flag variable to 1 (indicating the compiler was found)
34+
eval "$set_flag_var=1"
35+
return
36+
fi
37+
done
38+
echo "Error: None of the specified compilers (${compilers[*]}) are available for $var_name on this system."
39+
exit 1
40+
fi
41+
}
3642

37-
if [[ "$FDS_BUILD_TARGET" == *"osx"* ]]; then
38-
# Check for C compiler (mpicc, gcc, clang)
39-
if [ $set_CC -eq 0 ]; then
40-
if command -v mpicc &> /dev/null; then
41-
CC=mpicc
42-
elif command -v clang &> /dev/null; then
43-
CC=clang
44-
elif command -v gcc &> /dev/null; then
45-
CC=gcc
46-
else
47-
echo "Error: Any of mpicc, clang, or gcc compiler is not available on this system."
48-
exit 1
49-
fi
50-
fi
5143

52-
# Check for clang C++ compiler (mpicxx, g++, clang ++)
53-
if [ $set_CXX -eq 0 ]; then
54-
if command -v mpicxx &> /dev/null; then
55-
CXX=mpicxx
56-
elif command -v clang++ &> /dev/null; then
57-
CXX=clang++
58-
elif command -v g++ &> /dev/null; then
59-
CXX=g++
60-
else
61-
echo "Error: Any of mpicxx, clang++, or g++ compiler is not available on this system."
62-
exit 1
63-
fi
64-
fi
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
6548

66-
# Check for Fortran compiler (gfortran)
67-
if [ $set_FC -eq 0 ]; then
68-
if command -v mpifort &> /dev/null; then
69-
FC=mpifort
70-
elif command -v gfortran &> /dev/null; then
71-
FC=gfortran
72-
else
73-
echo "Error: Any of mpifort or gfortran compiler is not available on this system."
74-
exit 1
75-
fi
76-
fi
49+
# 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
7753

54+
# Determine compiler list based on build target
55+
if [[ "$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
7859
elif [[ "$FDS_BUILD_TARGET" == *"intel"* ]]; then
79-
# Check for Intel C compiler
80-
if [ $set_CC -eq 0 ]; then
81-
if command -v mpiicx &> /dev/null; then
82-
CC=mpiicx
83-
elif command -v icx &> /dev/null; then
84-
CC=icx
85-
elif command -v mpiicc &> /dev/null; then
86-
CC=mpiicc
87-
elif command -v icc &> /dev/null; then
88-
CC=icc
89-
else
90-
echo "Error: Any of mpiicx, icx, mpiicc, or icc compiler is not available on this system."
91-
exit 1
92-
fi
93-
fi
94-
95-
# Check for Intel C++ compiler
96-
if [ $set_CXX -eq 0 ]; then
97-
if command -v mpiicpx &> /dev/null; then
98-
CXX=mpiicpx
99-
elif command -v icpx &> /dev/null; then
100-
CXX=icpx
101-
elif command -v mpiicpc &> /dev/null; then
102-
CXX=mpiicpc
103-
elif command -v icpc &> /dev/null; then
104-
CXX=icpc
105-
else
106-
echo "Error: Any of mpiicpx, icpx, mpiicpc, or icpc compiler is not available on this system."
107-
exit 1
108-
fi
109-
fi
110-
111-
# Check for Intel Fortran compiler (ifort). ifx will be added in future.
112-
if [ $set_FC -eq 0 ]; then
113-
if command -v mpiifort &> /dev/null; then
114-
FC=mpiifort
115-
elif command -v ifort &> /dev/null; then
116-
FC=ifort
117-
else
118-
echo "Error: Any of mpiifort, or ifort compiler is not available on this system."
119-
exit 1
120-
fi
121-
fi
122-
else #gnu
123-
# Check for gnu C compiler (gcc)
124-
if [ $set_CC -eq 0 ]; then
125-
if command -v mpicc &> /dev/null; then
126-
CC=mpicc
127-
elif command -v gcc &> /dev/null; then
128-
CC=gcc
129-
else
130-
echo "Error: Any of mpicc, gcc compiler is not available on this system."
131-
exit 1
132-
fi
133-
fi
134-
135-
# Check for Intel C++ compiler (g++)
136-
if [ $set_CXX -eq 0 ]; then
137-
if command -v mpicxx &> /dev/null; then
138-
CXX=mpicxx
139-
elif command -v g++ &> /dev/null; then
140-
CXX=g++
141-
else
142-
echo "Error: Any of mpicxx, g++ compiler is not available on this system."
143-
exit 1
144-
fi
145-
fi
146-
147-
# Check for Fortran compiler (gfortran)
148-
if [ $set_FC -eq 0 ]; then
149-
if command -v mpifort &> /dev/null; then
150-
FC=mpifort
151-
elif command -v gfortran &> /dev/null; then
152-
FC=gfortran
153-
else
154-
echo "Error: Any of mpifort, gfortran compiler is not available on this system."
155-
exit 1
156-
fi
157-
fi
60+
select_compiler CC mpiicx icx mpiicc icc
61+
select_compiler CXX mpiicpx icpx mpiicpc icpc
62+
select_compiler FC mpiifort ifort
63+
else # Default to GNU compilers
64+
select_compiler CC mpicc gcc
65+
select_compiler CXX mpicxx g++
66+
select_compiler FC mpifort gfortran
15867
fi
15968

69+
16070
echo "Third-party libs C Compiler=$CC"
16171
echo "Third-party libs C++ compiler=$CXX"
16272
echo "Third-party libs Fortran compiler=$FC"
16373

16474
export CC=$CC
16575
export CXX=$CXX
16676
export FC=$FC
77+
78+
79+

Source/part.f90

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,8 @@ SUBROUTINE INSERT_SPRAY_PARTICLES
529529
ELSE
530530
CALL GET_IJK(BC%X,BC%Y,BC%Z,NM,XI,YJ,ZK,II,JJ,KK)
531531
IC = CELL_INDEX(II,JJ,KK)
532-
BC%IIG = II
533-
BC%JJG = JJ
534-
BC%KKG = KK
532+
BC%IIG = II; BC%JJG = JJ; BC%KKG = KK
533+
BC%II = II; BC%JJ = JJ; BC%KK = KK
535534
IF (.NOT.CELL(IC)%SOLID) EXIT CHOOSE_COORDS
536535
ENDIF
537536

@@ -865,6 +864,7 @@ SUBROUTINE PARTICLE_FACE_INSERT(WALL_INDEX,CFACE_INDEX)
865864

866865
! Update idicies in case offset puts location in a different cell
867866
CALL GET_IJK(BC%X,BC%Y,BC%Z,NM,XI,YJ,ZK,BC%IIG,BC%JJG,BC%KKG)
867+
BC%II = BC%IIG; BC%JJ = BC%JJG; BC%KK = BC%KKG
868868

869869
! Save the insertion time (TP) and scalar property (SP) for the particle
870870

@@ -1472,9 +1472,8 @@ SUBROUTINE VOLUME_INIT_PARTICLE
14721472
INTEGER :: ND
14731473
TYPE (PROFILE_TYPE), POINTER :: PF
14741474

1475-
BC%IIG = II
1476-
BC%JJG = JJ
1477-
BC%KKG = KK
1475+
BC%IIG = II; BC%JJG = JJ; BC%KKG = KK
1476+
BC%II = II; BC%JJ = JJ; BC%KK = KK
14781477
LP%U = IN%U0
14791478
LP%V = IN%V0
14801479
LP%W = IN%W0
@@ -1886,6 +1885,7 @@ SUBROUTINE MOVE_PARTICLES(T,DT,NM)
18861885
IF (LP%PATH_PARTICLE) THEN
18871886
CALL MOVE_IN_GAS
18881887
CALL GET_IJK(BC%X,BC%Y,BC%Z,NM,XI,YJ,ZK,BC%IIG,BC%JJG,BC%KKG)
1888+
BC%II = BC%IIG; BC%JJ = BC%JJG; BC%KK = BC%KKG
18891889
ENDIF
18901890
EXIT TIME_STEP_LOOP
18911891
ENDIF
@@ -1939,6 +1939,7 @@ SUBROUTINE MOVE_PARTICLES(T,DT,NM)
19391939
! Determine the cell indices of the new particle location.
19401940

19411941
CALL GET_IJK(BC%X,BC%Y,BC%Z,NM,XI,YJ,ZK,BC%IIG,BC%JJG,BC%KKG)
1942+
BC%II = BC%IIG; BC%JJ = BC%JJG; BC%KK = BC%KKG
19421943

19431944
! If the particle is not near a boundary cell, cycle.
19441945

@@ -2520,6 +2521,7 @@ SUBROUTINE MOVE_PARTICLES(T,DT,NM)
25202521

25212522
! Store containing volume at new location
25222523
CALL GET_IJK(BC%X,BC%Y,BC%Z,NM,XI,YJ,ZK,BC%IIG,BC%JJG,BC%KKG)
2524+
BC%II = BC%IIG; BC%JJ = BC%JJG; BC%KK = BC%KKG
25232525
CALL GET_RVC(NM,BC%IIG,BC%JJG,BC%KKG,LP%RVC)
25242526

25252527
ENDDO TIME_STEP_LOOP

0 commit comments

Comments
 (0)