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