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