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