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