1 | #!/bin/bash |
---|
2 | |
---|
3 | echo ./make_icosa $* > rebuild |
---|
4 | chmod a+x rebuild |
---|
5 | |
---|
6 | compil_mode_defined="FALSE" |
---|
7 | compil_mode="prod" |
---|
8 | |
---|
9 | job=1 |
---|
10 | full_defined="FALSE" |
---|
11 | with_xios_defined="FALSE" |
---|
12 | arch_defined="FALSE" |
---|
13 | parallel_defined="FALSE" |
---|
14 | arch_default_path="arch" |
---|
15 | arch_path="arch" |
---|
16 | parallel="none" |
---|
17 | physics="none" |
---|
18 | external_ioipsl="FALSE" |
---|
19 | external_physics="FALSE" |
---|
20 | no_io_defined="FALSE" |
---|
21 | |
---|
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 | -arch nom_arch : target architecture, use paths and compilation options from arch files arch/arch-NAME.* |
---|
34 | -arch_path PATH : use arch files PATH/arch-ARCH.* |
---|
35 | -parallel mpi|mpi_omp : pure MPI or hybrid MPI/OpenMP parallelism |
---|
36 | -job N : parallel compilation as with make -j N |
---|
37 | -full : full compilation |
---|
38 | -with_xios : use XIOS for I/O (default is NetCDF-CF on native grid) |
---|
39 | -no_io : disable I/O altogether |
---|
40 | -external_ioipsl PATH : use IOIPSL from PATH rather than tools/ioipsl |
---|
41 | -physics lmdz_generic : use LMDZ generic physics (planets) |
---|
42 | -external_physics : allows external physics |
---|
43 | fin |
---|
44 | exit;; |
---|
45 | |
---|
46 | "-prod") |
---|
47 | compil_mode="prod" ; shift ;; |
---|
48 | |
---|
49 | "-dev") |
---|
50 | compil_mode="dev" ; shift ;; |
---|
51 | |
---|
52 | "-debug") |
---|
53 | compil_mode="debug" ; shift ;; |
---|
54 | |
---|
55 | "-arch") |
---|
56 | arch=$2 ; arch_defined="TRUE"; shift ; shift ;; |
---|
57 | |
---|
58 | "-arch_path") |
---|
59 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
60 | |
---|
61 | "-parallel") |
---|
62 | parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;; |
---|
63 | |
---|
64 | "-physics") |
---|
65 | physics=$2 ; physics_defined="TRUE"; shift ; shift ;; |
---|
66 | |
---|
67 | "-job") |
---|
68 | job=$2 ; shift ; shift;; |
---|
69 | |
---|
70 | "-full") |
---|
71 | full_defined="TRUE" ; shift ;; |
---|
72 | |
---|
73 | "-with_xios") |
---|
74 | with_xios_defined="TRUE" ; shift ;; |
---|
75 | |
---|
76 | "-no_io") |
---|
77 | no_io_defined="TRUE" ; shift ;; |
---|
78 | |
---|
79 | "-external_ioipsl") |
---|
80 | external_ioipsl="TRUE" ; shift ;; |
---|
81 | |
---|
82 | "-external_physics") |
---|
83 | external_physics="TRUE" ; shift ;; |
---|
84 | |
---|
85 | *) |
---|
86 | code="$1" ; shift ;; |
---|
87 | esac |
---|
88 | done |
---|
89 | |
---|
90 | rm -f .void_file |
---|
91 | echo > .void_file |
---|
92 | rm -rf .void_dir |
---|
93 | mkdir .void_dir |
---|
94 | |
---|
95 | if [[ "$arch_defined" == "TRUE" ]] |
---|
96 | then |
---|
97 | rm -f arch.path |
---|
98 | rm -f arch.fcm |
---|
99 | rm -f arch.env |
---|
100 | |
---|
101 | if test -f $arch_path/arch-${arch}.path |
---|
102 | then |
---|
103 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
104 | elif test -f $arch_default_path/arch-${arch}.path |
---|
105 | then |
---|
106 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
107 | fi |
---|
108 | |
---|
109 | if test -f $arch_path/arch-${arch}.fcm |
---|
110 | then |
---|
111 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
---|
112 | elif test -f $arch_default_path/arch-${arch}.fcm |
---|
113 | then |
---|
114 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
---|
115 | fi |
---|
116 | |
---|
117 | if test -f $arch_path/arch-${arch}.env |
---|
118 | then |
---|
119 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
120 | elif test -f $arch_default_path/arch-${arch}.env |
---|
121 | then |
---|
122 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
123 | else |
---|
124 | ln -s .void_file arch.env |
---|
125 | fi |
---|
126 | source arch.env |
---|
127 | source arch.path |
---|
128 | else |
---|
129 | echo "Veuillez definir une architecture cible" |
---|
130 | exit 1 |
---|
131 | fi |
---|
132 | |
---|
133 | LD_FLAGS="%BASE_LD" |
---|
134 | |
---|
135 | if [[ "$compil_mode" == "prod" ]] |
---|
136 | then |
---|
137 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
138 | elif [[ "$compil_mode" == "dev" ]] |
---|
139 | then |
---|
140 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
141 | elif [[ "$compil_mode" == "debug" ]] |
---|
142 | then |
---|
143 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
144 | fi |
---|
145 | |
---|
146 | if [[ "$parallel" == "mpi" ]] |
---|
147 | then |
---|
148 | CPP_KEY="$CPP_KEY CPP_USING_MPI" |
---|
149 | elif [[ "$parallel" == "omp" ]] |
---|
150 | then |
---|
151 | CPP_KEY="$CPP_KEY CPP_USING_OMP" |
---|
152 | COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS" |
---|
153 | LD_FLAGS="$LD_FLAGS %OMP_LD" |
---|
154 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
155 | then |
---|
156 | CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP" |
---|
157 | COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS" |
---|
158 | LD_FLAGS="$LD_FLAGS %OMP_LD" |
---|
159 | elif [[ "$parallel" == "none" ]] |
---|
160 | then |
---|
161 | parallel="none" |
---|
162 | else |
---|
163 | echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>" |
---|
164 | exit 1 |
---|
165 | fi |
---|
166 | |
---|
167 | if [[ "$physics" == "lmdz_generic" ]] |
---|
168 | then |
---|
169 | CPP_KEY="$CPP_KEY CPP_PHYSICS_LMDZ_GENERIC" |
---|
170 | COMPIL_FFLAGS="$COMPIL_FFLAGS $PHYSICS_INCDIR" |
---|
171 | ICOSA_LIB="$ICOSA_LIB $PHYSICS_LIBDIR $PHYSICS_LIB" |
---|
172 | fi |
---|
173 | |
---|
174 | if [[ "$no_io_defined" == "TRUE" ]] |
---|
175 | then |
---|
176 | CPP_KEY="$CPP_KEY CPP_NO_IO" |
---|
177 | with_xios_defined="FALSE" |
---|
178 | fi |
---|
179 | |
---|
180 | if [[ "$with_xios_defined" == "TRUE" ]] |
---|
181 | then |
---|
182 | CPP_KEY="$CPP_KEY CPP_USING_XIOS" |
---|
183 | COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR" |
---|
184 | ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB" |
---|
185 | fi |
---|
186 | |
---|
187 | if [[ "$external_ioipsl" == "TRUE" ]] |
---|
188 | then |
---|
189 | ioipsl_path=".void_dir" |
---|
190 | use_ioipsl="use::ioipsl" |
---|
191 | COMPIL_FFLAGS="$COMPIL_FFLAGS $IOIPSL_INCDIR" |
---|
192 | ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB" |
---|
193 | else |
---|
194 | ioipsl_path="tools/ioipsl" |
---|
195 | use_ioipsl="" |
---|
196 | fi |
---|
197 | |
---|
198 | if [[ "$external_physics" == "TRUE" ]] |
---|
199 | then |
---|
200 | CPP_KEY="$CPP_KEY CPP_USING_EXTERNAL_PHYSICS" |
---|
201 | fi |
---|
202 | |
---|
203 | if [[ "$no_io_defined" == "FALSE" ]] |
---|
204 | then |
---|
205 | ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB" |
---|
206 | COMPIL_FFLAGS="$COMPIL_FFLAGS $NETCDF_INCDIR" |
---|
207 | fi |
---|
208 | |
---|
209 | rm -f config.fcm |
---|
210 | |
---|
211 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm |
---|
212 | echo "%LD_FLAGS $LD_FLAGS" >> config.fcm |
---|
213 | echo "%CPP_KEY $CPP_KEY" >> config.fcm |
---|
214 | echo "%LIB $ICOSA_LIB">> config.fcm |
---|
215 | echo "%IOIPSL_PATH $ioipsl_path">> config.fcm |
---|
216 | echo "%USE_IOIPSL $use_ioipsl">> config.fcm |
---|
217 | |
---|
218 | if [[ "$full_defined" == "TRUE" ]] |
---|
219 | then |
---|
220 | ./build --job $job --full |
---|
221 | else |
---|
222 | ./build --job $job |
---|
223 | fi |
---|