1 | #!/bin/bash |
---|
2 | #set -x |
---|
3 | |
---|
4 | # Use FCM from DYNAMICO |
---|
5 | export PATH=$PWD/../DYNAMICO/tools/FCM/bin:$PATH |
---|
6 | export ROOT=$PWD |
---|
7 | |
---|
8 | echo $0 $* > rebuild_all |
---|
9 | chmod a+x rebuild_all |
---|
10 | |
---|
11 | compil_mode_defined="FALSE" |
---|
12 | compil_mode="prod" |
---|
13 | |
---|
14 | job=1 |
---|
15 | full_defined="FALSE" |
---|
16 | with_xios_defined="TRUE" |
---|
17 | with_orchidee_defined="FALSE" |
---|
18 | arch_defined="FALSE" |
---|
19 | parallel_defined="FALSE" |
---|
20 | arch_path="../ARCH" |
---|
21 | arch_default_path="arch" |
---|
22 | parallel="none" |
---|
23 | phys="none" |
---|
24 | build_deps="TRUE" |
---|
25 | CPP_KEY="CPP_NONE" |
---|
26 | ICOSA_LIB="" |
---|
27 | rrtm="false" |
---|
28 | |
---|
29 | while (($# > 0)) |
---|
30 | do |
---|
31 | case $1 in |
---|
32 | "-h") cat <<fin |
---|
33 | Usage : |
---|
34 | makegcm [options] -m arch -p phys exec |
---|
35 | [-h] : help |
---|
36 | [-prod / -dev / -debug] : compilation en mode production (default) / developpement / debug . |
---|
37 | [-nodeps] : do not build dependencies (XIOS, IOIPSL, LMDZ, DYNAMICO must be compiled already) |
---|
38 | -arch nom_arch : nom de l\'architecture cible |
---|
39 | -p phys : physics package (e.g. std , venus , ...) |
---|
40 | [-p_opt "options"] : additional options for physics package |
---|
41 | fin |
---|
42 | exit;; |
---|
43 | |
---|
44 | "-p") |
---|
45 | phys=$2 ; shift ; shift ;; |
---|
46 | |
---|
47 | "-p_opt") |
---|
48 | phys_opt=$2 ; shift ; shift ;; |
---|
49 | |
---|
50 | "-rrtm") |
---|
51 | rrtm=$2 ; shift ; shift ;; |
---|
52 | |
---|
53 | "-prod") |
---|
54 | compil_mode="prod" ; shift ;; |
---|
55 | |
---|
56 | "-dev") |
---|
57 | compil_mode="dev" ; shift ;; |
---|
58 | |
---|
59 | "-debug") |
---|
60 | compil_mode="debug" ; shift ;; |
---|
61 | |
---|
62 | "-arch") |
---|
63 | arch=$2 ; arch_defined="TRUE"; shift ; shift ;; |
---|
64 | |
---|
65 | "-arch_path") |
---|
66 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
67 | |
---|
68 | "-parallel") |
---|
69 | parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;; |
---|
70 | |
---|
71 | "-job") |
---|
72 | job=$2 ; shift ; shift;; |
---|
73 | |
---|
74 | "-full") |
---|
75 | full_defined="TRUE" ; shift ;; |
---|
76 | |
---|
77 | "-nodeps") |
---|
78 | build_deps="FALSE" ; shift ;; |
---|
79 | |
---|
80 | "-with_xios") |
---|
81 | with_xios_defined="TRUE" ; shift ;; |
---|
82 | |
---|
83 | "-with_orchidee") |
---|
84 | with_orchidee_defined="TRUE" ; shift ;; |
---|
85 | |
---|
86 | *) |
---|
87 | code="$1" ; shift ;; |
---|
88 | esac |
---|
89 | done |
---|
90 | |
---|
91 | rm -f .void_file |
---|
92 | echo > .void_file |
---|
93 | rm -rf .void_dir |
---|
94 | mkdir .void_dir |
---|
95 | |
---|
96 | if [[ "$arch_defined" == "TRUE" ]] |
---|
97 | then |
---|
98 | rm -f arch.path |
---|
99 | rm -f arch.fcm |
---|
100 | rm -f arch.env |
---|
101 | |
---|
102 | if test -f $arch_path/arch-${arch}.path |
---|
103 | then |
---|
104 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
105 | elif test -f $arch_default_path/arch-${arch}.path |
---|
106 | then |
---|
107 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
108 | fi |
---|
109 | |
---|
110 | if test -f $arch_path/arch-${arch}.fcm |
---|
111 | then |
---|
112 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
---|
113 | elif test -f $arch_default_path/arch-${arch}.fcm |
---|
114 | then |
---|
115 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
---|
116 | fi |
---|
117 | |
---|
118 | if test -f $arch_path/arch-${arch}.env |
---|
119 | then |
---|
120 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
121 | elif test -f $arch_default_path/arch-${arch}.env |
---|
122 | then |
---|
123 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
124 | else |
---|
125 | ln -s .void_file arch.env |
---|
126 | fi |
---|
127 | source arch.env |
---|
128 | source arch.path |
---|
129 | else |
---|
130 | echo "Please define a target architecture" |
---|
131 | exit 1 |
---|
132 | fi |
---|
133 | |
---|
134 | LD_FLAGS="%BASE_LD" |
---|
135 | |
---|
136 | if [[ "$compil_mode" == "prod" ]] |
---|
137 | then |
---|
138 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
139 | elif [[ "$compil_mode" == "dev" ]] |
---|
140 | then |
---|
141 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
142 | elif [[ "$compil_mode" == "debug" ]] |
---|
143 | then |
---|
144 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
145 | fi |
---|
146 | |
---|
147 | if [[ "$parallel" == "mpi" ]] |
---|
148 | then |
---|
149 | CPP_KEY="$CPP_KEY CPP_USING_MPI" |
---|
150 | elif [[ "$parallel" == "omp" ]] |
---|
151 | then |
---|
152 | CPP_KEY="$CPP_KEY CPP_USING_OMP" |
---|
153 | COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS" |
---|
154 | LD_FLAGS="$LD_FLAGS %OMP_LD" |
---|
155 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
156 | then |
---|
157 | CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP" |
---|
158 | COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS" |
---|
159 | LD_FLAGS="$LD_FLAGS %OMP_LD" |
---|
160 | elif [[ "$parallel" == "none" ]] |
---|
161 | then |
---|
162 | parallel="none" |
---|
163 | else |
---|
164 | echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>" |
---|
165 | exit 1 |
---|
166 | fi |
---|
167 | |
---|
168 | if [[ "$with_orchidee_defined" == "TRUE" ]] |
---|
169 | then |
---|
170 | ICOSA_LIB="$ICOSA_LIB $ORCHIDEE_LIBDIR $ORCHIDEE_LIB" |
---|
171 | fi |
---|
172 | |
---|
173 | if [[ "$with_xios_defined" == "TRUE" ]] |
---|
174 | then |
---|
175 | CPP_KEY="$CPP_KEY CPP_USING_XIOS" |
---|
176 | COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR" |
---|
177 | ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB" |
---|
178 | fi |
---|
179 | |
---|
180 | ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB" |
---|
181 | |
---|
182 | rm bin/* |
---|
183 | |
---|
184 | if [[ "$full_defined" == "TRUE" ]] |
---|
185 | then |
---|
186 | full_flag="-full" |
---|
187 | full_flag2="--full" |
---|
188 | else |
---|
189 | full_flag="" |
---|
190 | full_flag2="" |
---|
191 | fi |
---|
192 | |
---|
193 | rm -f config.fcm |
---|
194 | |
---|
195 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm |
---|
196 | echo "%LD_FLAGS $LD_FLAGS" >> config.fcm |
---|
197 | echo "%CPP_KEY $CPP_KEY" >> config.fcm |
---|
198 | echo "%PHYS phy$phys" >> config.fcm |
---|
199 | echo "%LIB $ICOSA_LIB">> config.fcm |
---|
200 | |
---|
201 | if [[ "$build_deps" == "TRUE" ]] |
---|
202 | then |
---|
203 | |
---|
204 | cd ../IOIPSL |
---|
205 | ./makeioipsl_fcm -$compil_mode -parallel -arch $arch -arch_path $arch_path -j $job $full_flag || exit 1 |
---|
206 | cd - |
---|
207 | |
---|
208 | cd ../XIOS |
---|
209 | ./make_xios --$compil_mode --arch $arch --arch_path $arch_path --job $job $full_flag2 || exit 1 |
---|
210 | cd - |
---|
211 | |
---|
212 | if [[ "$with_orchidee_defined" == "TRUE" ]] |
---|
213 | then |
---|
214 | cd ../ORCHIDEE |
---|
215 | ./makeorchidee_fcm -$compil_mode -parallel $parallel -xios2 -arch $arch -arch_path $arch_path -j $job $full_flag || exit 1 |
---|
216 | cd - |
---|
217 | fi |
---|
218 | |
---|
219 | cd ../LMDZ |
---|
220 | lmdz_veget="false" |
---|
221 | if [[ "$with_orchidee_defined" == "TRUE" ]] |
---|
222 | then |
---|
223 | lmdz_veget="orchidee2.0 -cpp ORCHIDEE_NOZ0H" |
---|
224 | fi |
---|
225 | ./makelmdz_fcm -p $phys $phys_opt -rrtm $rrtm -$compil_mode -mem -parallel $parallel -libphy -io xios -v $lmdz_veget -arch $arch -arch_path $arch_path -j $job $full_flag || exit 1 |
---|
226 | cd - |
---|
227 | |
---|
228 | cd ../DYNAMICO |
---|
229 | ./make_icosa -$compil_mode -parallel $parallel -external_ioipsl -with_xios -arch $arch -arch_path $arch_path -job $job $full_flag || exit 1 |
---|
230 | cd - |
---|
231 | fi |
---|
232 | |
---|
233 | ./build --job $job $full_flag2 |
---|