[1199] | 1 | #!/bin/bash |
---|
| 2 | # $Id: makelmdz_fcm 1261 2009-11-16 15:24:31Z fairhead $ |
---|
[1197] | 3 | # This is a script in Bash. |
---|
| 4 | |
---|
[1140] | 5 | # FH : on ne crée plus le fichier arch.mk qui est supposé exister par |
---|
[783] | 6 | # FH : ailleurs. |
---|
[1140] | 7 | # FH : ulterieurement, ce fichier sera pré-existant pour une série |
---|
| 8 | # FH : de configurations en versions optimisées et debug qui seront |
---|
| 9 | # FH : liés (ln -s) avec arch.mk en fonction de l'architecture. |
---|
| 10 | # FH : Pour le moment, cette version est en test et on peut créer les |
---|
| 11 | # FH : arch.mk en lançant une première fois makegcm. |
---|
[783] | 12 | # |
---|
[1197] | 13 | ##set -x |
---|
[783] | 14 | ######################################################################## |
---|
| 15 | # options par defaut pour la commande make |
---|
| 16 | ######################################################################## |
---|
| 17 | |
---|
[1197] | 18 | dim="96x72x19" |
---|
| 19 | physique=lmd |
---|
| 20 | filtre=filtrez |
---|
| 21 | grille=reg |
---|
| 22 | couple=false |
---|
| 23 | veget=false |
---|
| 24 | chimie=false |
---|
| 25 | parallel=none |
---|
| 26 | compil_mod=prod |
---|
| 27 | io=ioipsl |
---|
| 28 | LIBPREFIX="" |
---|
| 29 | fcm_path=none |
---|
[1261] | 30 | cosp=false |
---|
[783] | 31 | |
---|
[1197] | 32 | LMDGCM=`/bin/pwd` |
---|
| 33 | LIBOGCM=$LMDGCM/libo |
---|
| 34 | LIBFGCM=$LMDGCM/libf |
---|
[783] | 35 | |
---|
| 36 | ######################################################################## |
---|
| 37 | # Quelques initialisations de variables du shell. |
---|
| 38 | ######################################################################## |
---|
| 39 | |
---|
[1197] | 40 | CPP_KEY="" |
---|
| 41 | INCLUDE="" |
---|
| 42 | LIB="" |
---|
| 43 | adjnt="" |
---|
| 44 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 45 | PARA_FFLAGS="" |
---|
| 46 | PARA_LD="" |
---|
[1228] | 47 | EXT_SRC="" |
---|
[783] | 48 | |
---|
| 49 | ######################################################################## |
---|
| 50 | # lecture des options de mymake |
---|
| 51 | ######################################################################## |
---|
| 52 | |
---|
[1197] | 53 | while (($# > 0)) |
---|
| 54 | do |
---|
| 55 | case $1 in |
---|
| 56 | "-h") cat <<fin |
---|
[783] | 57 | manuel complet sur http://... |
---|
| 58 | Usage : |
---|
[1002] | 59 | makegcm [options] -m arch exec |
---|
| 60 | [-h] : manuel abrégé |
---|
| 61 | [-d [[IMx]JMx]LM] : IM, JM, LM sont les dims en x, y, z (def: $dim) |
---|
| 62 | [-p PHYS] : compilation avec la physique libf/phyPHYS, (def: lmd) |
---|
| 63 | [-prod / -dev / -debug] : compilation en mode production (default) / developpement / debug . |
---|
| 64 | [-c false/MPI1/MPI2] : couplé océan : MPI1/MPI2/false (def: false) |
---|
| 65 | [-v false/true] : avec ou sans végétation (def: false) |
---|
[1018] | 66 | [-chimie INCA/false] : avec ou sans model de chimie INCA (def: false) |
---|
[1002] | 67 | [-parallel none/mpi/omp/mpi_omp] : parallelisation (default: none) : mpi, openmp ou mixte mpi_openmp |
---|
| 68 | [-g GRI] : conf. grille dans dyn3d/GRI_xy.h (def: reg inclue un zoom) |
---|
| 69 | [-io IO] : choix d'une librairie I/O, experts (def: ioipsl) |
---|
[1132] | 70 | [-include INCLUDES] : variables supplementaires pour include |
---|
| 71 | [-cpp CPP_KEY] : cle cpp supplementaires |
---|
[1002] | 72 | [-adjnt] : adjoint, a remettre en route ... |
---|
| 73 | [-filtre NOMFILTRE] : prend le filtre dans libf/NOMFILTRE (def: filtrez) |
---|
| 74 | [-link LINKS] : liens optionels avec d'autres librairies |
---|
[1136] | 75 | [-fcm_path path] : chemin pour fcm (def: le chemin est suppose deja exister dans le PATH) |
---|
[1228] | 76 | [-ext_src path] : chemin d'un repertoire source avec des sources externe a compiler avec le modele |
---|
[1137] | 77 | -arch nom_arch : nom de l'architecture cible |
---|
[1002] | 78 | exec : exécutable généré |
---|
[783] | 79 | fin |
---|
[1197] | 80 | exit;; |
---|
[783] | 81 | |
---|
[1197] | 82 | "-d") |
---|
| 83 | dim=$2 ; shift ; shift ;; |
---|
| 84 | |
---|
| 85 | "-O") |
---|
| 86 | echo "option obsolete dans cette version intermediaire de makegcm" |
---|
| 87 | exit;; |
---|
[783] | 88 | |
---|
[1197] | 89 | "-p") |
---|
| 90 | physique="$2" ; shift ; shift ;; |
---|
[783] | 91 | |
---|
[1197] | 92 | "-g") |
---|
| 93 | grille="$2" ; shift ; shift ;; |
---|
[783] | 94 | |
---|
[1197] | 95 | "-c") |
---|
| 96 | couple="$2" ; shift ; shift ;; |
---|
[783] | 97 | |
---|
[1197] | 98 | "-prod") |
---|
| 99 | compil_mod="prod" ; shift ;; |
---|
[1002] | 100 | |
---|
[1197] | 101 | "-dev") |
---|
| 102 | compil_mod="dev" ; shift ;; |
---|
[1002] | 103 | |
---|
[1197] | 104 | "-debug") |
---|
| 105 | compil_mod="debug" ; shift ;; |
---|
[1002] | 106 | |
---|
[1197] | 107 | "-io") |
---|
| 108 | io="$2" ; shift ; shift ;; |
---|
[783] | 109 | |
---|
[1197] | 110 | "-v") |
---|
| 111 | veget="$2" ; shift ; shift ;; |
---|
[783] | 112 | |
---|
[1197] | 113 | "-chimie") |
---|
| 114 | chimie="$2" ; shift ; shift ;; |
---|
[783] | 115 | |
---|
[1197] | 116 | "-parallel") |
---|
| 117 | parallel="$2" ; shift ; shift ;; |
---|
| 118 | |
---|
| 119 | "-include") |
---|
| 120 | INCLUDE="$INCLUDE -I$2" ; shift ; shift ;; |
---|
[783] | 121 | |
---|
[1197] | 122 | "-cpp") |
---|
| 123 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
[1132] | 124 | |
---|
[1197] | 125 | "-adjnt") |
---|
| 126 | echo "otpion a reactiver ";exit |
---|
| 127 | opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d " |
---|
| 128 | optim="$optim -Dadj" ; shift ;; |
---|
[783] | 129 | |
---|
[1261] | 130 | "-cosp") |
---|
| 131 | cosp="$2" ; shift ; shift ;; |
---|
[783] | 132 | |
---|
[1261] | 133 | |
---|
[1197] | 134 | "-filtre") |
---|
| 135 | filtre=$2 ; shift ; shift ;; |
---|
[783] | 136 | |
---|
[1197] | 137 | "-link") |
---|
| 138 | LIB="$LIB $2" ; shift ; shift ;; |
---|
[783] | 139 | |
---|
[1197] | 140 | "-fcm_path") |
---|
| 141 | fcm_path=$2 ; shift ; shift ;; |
---|
[1136] | 142 | |
---|
[1228] | 143 | "-ext_src") |
---|
| 144 | EXT_SRC=$2 ; shift ; shift ;; |
---|
| 145 | |
---|
[1197] | 146 | "-arch") |
---|
| 147 | arch=$2 ; shift ; shift ;; |
---|
[783] | 148 | |
---|
[1197] | 149 | *) |
---|
| 150 | code="$1" ; shift ;; |
---|
| 151 | esac |
---|
| 152 | done |
---|
[783] | 153 | |
---|
[1136] | 154 | ############################################################### |
---|
| 155 | # mettre le chemin du fcm dans le path |
---|
| 156 | ############################################################### |
---|
[1197] | 157 | if [[ "$fcm_path" != "none" ]] |
---|
| 158 | then |
---|
| 159 | export PATH=${fcm_path}:${PATH} |
---|
| 160 | fi |
---|
[783] | 161 | |
---|
[1136] | 162 | echo "Chemin du fcm utlise :" |
---|
| 163 | which fcm |
---|
| 164 | |
---|
[783] | 165 | ############################################################### |
---|
[1140] | 166 | # lecture des chemins propres à l'architecture de la machine # |
---|
[783] | 167 | ############################################################### |
---|
[1250] | 168 | rm -f .void_file |
---|
| 169 | echo > .void_file |
---|
| 170 | rm -f arch.path |
---|
| 171 | ln -s arch/arch-${arch}.path ./arch.path |
---|
[783] | 172 | source arch.path |
---|
| 173 | |
---|
| 174 | ######################################################################## |
---|
| 175 | # Definition des clefs CPP, des chemins des includes et modules |
---|
| 176 | # et des libraries |
---|
| 177 | ######################################################################## |
---|
| 178 | |
---|
[1197] | 179 | if [[ "$compil_mod" == "prod" ]] |
---|
| 180 | then |
---|
| 181 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 182 | elif [[ "$compil_mod" == "dev" ]] |
---|
| 183 | then |
---|
| 184 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
| 185 | elif [[ "$compil_mod" == "debug" ]] |
---|
| 186 | then |
---|
| 187 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
| 188 | fi |
---|
[783] | 189 | |
---|
[1197] | 190 | if [[ "$physique" != "nophys" ]] |
---|
| 191 | then |
---|
[1140] | 192 | #Default planet type is Earth |
---|
[1197] | 193 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
| 194 | fi |
---|
[783] | 195 | |
---|
[1197] | 196 | if [[ "$chimie" == "INCA" ]] |
---|
| 197 | then |
---|
| 198 | CPP_KEY="$CPP_KEY INCA" |
---|
| 199 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
| 200 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
| 201 | fi |
---|
[783] | 202 | |
---|
[1197] | 203 | if [[ "$couple" != "false" ]] |
---|
| 204 | then |
---|
| 205 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
| 206 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
| 207 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
---|
| 208 | fi |
---|
[783] | 209 | |
---|
[1197] | 210 | if [[ "$parallel" == "mpi" ]] |
---|
| 211 | then |
---|
| 212 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
| 213 | PARA_FFLAGS="%MPI_FFLAGS" |
---|
| 214 | PARA_LD="%MPI_LD" |
---|
| 215 | elif [[ "$parallel" == "omp" ]] |
---|
| 216 | then |
---|
| 217 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
| 218 | PARA_FFLAGS="%OMP_FFLAGS" |
---|
| 219 | PARA_LD="%OMP_LD" |
---|
| 220 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
| 221 | then |
---|
| 222 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
| 223 | PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
---|
| 224 | PARA_LD="%MPI_LD %OMP_LD" |
---|
| 225 | fi |
---|
[783] | 226 | |
---|
[1197] | 227 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
| 228 | && "$compil_mod" == "debug" ]] |
---|
| 229 | then |
---|
| 230 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
| 231 | echo "We suggest switching to \"-dev\"." |
---|
| 232 | fi |
---|
[1154] | 233 | |
---|
[1197] | 234 | if [[ "$veget" == "true" ]] |
---|
| 235 | then |
---|
| 236 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
| 237 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
| 238 | LIB="${LIB} -L${ORCH_LIBDIR} -l${LIBPREFIX}sechiba -l${LIBPREFIX}parameters -l${LIBPREFIX}stomate -l${LIBPREFIX}parallel -l${LIBPREFIX}orglob" |
---|
| 239 | fi |
---|
[783] | 240 | |
---|
[1197] | 241 | if [[ $io == ioipsl ]] |
---|
| 242 | then |
---|
| 243 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
| 244 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
| 245 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
| 246 | fi |
---|
[1261] | 247 | if [[ "$cosp" == "true" ]] |
---|
| 248 | then |
---|
| 249 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
| 250 | INCLUDE="$INCLUDE -I$(LIBFGCM)/cosp" |
---|
| 251 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
| 252 | fi |
---|
[1197] | 253 | INCLUDE="$INCLUDE -I${NETCDF_INCDIR}" |
---|
| 254 | LIB="$LIB -L${NETCDF_LIBDIR} -lnetcdf" |
---|
[783] | 255 | |
---|
| 256 | ######################################################################## |
---|
| 257 | # calcul du nombre de dimensions |
---|
| 258 | ######################################################################## |
---|
| 259 | |
---|
| 260 | |
---|
[1197] | 261 | dim_full=$dim |
---|
| 262 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
[1199] | 263 | set $dim |
---|
| 264 | dimc=$# |
---|
[783] | 265 | echo calcul de la dimension |
---|
| 266 | echo dim $dim |
---|
| 267 | echo dimc $dimc |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | ######################################################################## |
---|
| 271 | # Gestion des dimensions du modele. |
---|
[1114] | 272 | # on cree ou remplace le fichier des dimensions |
---|
[783] | 273 | ######################################################################## |
---|
| 274 | |
---|
| 275 | cd $LIBFGCM/grid/dimension |
---|
[1114] | 276 | ./makdim $dim |
---|
[783] | 277 | cat $LIBFGCM/grid/dimensions.h |
---|
| 278 | cd $LMDGCM |
---|
| 279 | |
---|
| 280 | |
---|
| 281 | ######################################################################## |
---|
| 282 | # Differentes dynamiques (3d, 2d, 1d) |
---|
| 283 | ######################################################################## |
---|
| 284 | |
---|
[1197] | 285 | dimension=`echo $dim | wc -w` |
---|
[783] | 286 | echo dimension $dimension |
---|
| 287 | |
---|
[1197] | 288 | if (( $dimension == 3 )) |
---|
| 289 | then |
---|
[783] | 290 | cd $LIBFGCM/grid |
---|
| 291 | \rm fxyprim.h |
---|
| 292 | cp -p fxy_${grille}.h fxyprim.h |
---|
[1197] | 293 | else |
---|
| 294 | echo "Probleme dans les dimensions de la dynamique !!" |
---|
| 295 | echo "Non reactive pour l'instant !!!" |
---|
| 296 | fi |
---|
[783] | 297 | |
---|
| 298 | ###################################################################### |
---|
| 299 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
---|
| 300 | # ---> YM desactive pour le traitemement en parallele |
---|
| 301 | ###################################################################### |
---|
| 302 | |
---|
[1197] | 303 | #if [[ -f $libf/phy$physique/raddim.h ]] |
---|
| 304 | #then |
---|
| 305 | # if [[ -f $libf/phy$physique/raddim.$dimh.h ]] |
---|
| 306 | #then |
---|
[783] | 307 | # \rm -f $libf/phy$physique/raddim.h |
---|
| 308 | # cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
---|
| 309 | # echo $libf/phy$physique/raddim.$dimh.h |
---|
| 310 | # cat $libf/phy$physique/raddim.h |
---|
| 311 | # else |
---|
| 312 | # echo On peut diminuer la taille de l executable en creant |
---|
| 313 | # echo le fichier $libf/phy$physique/raddim.$dimh.h |
---|
| 314 | # \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
---|
[1197] | 315 | # fi |
---|
| 316 | #fi |
---|
[783] | 317 | |
---|
| 318 | ###################################################################### |
---|
| 319 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
| 320 | ###################################################################### |
---|
| 321 | |
---|
[1197] | 322 | if (( `expr $dimc \> 2` == 1 )) |
---|
| 323 | then |
---|
| 324 | filtre="FILTRE=$filtre" |
---|
[783] | 325 | else |
---|
[1197] | 326 | filtre="FILTRE= L_FILTRE= " |
---|
| 327 | fi |
---|
[783] | 328 | echo MACRO FILTRE $filtre |
---|
| 329 | |
---|
| 330 | echo $dimc |
---|
| 331 | |
---|
| 332 | |
---|
| 333 | |
---|
| 334 | ###################################################################### |
---|
| 335 | # Creation du suffixe de la configuration |
---|
| 336 | ###################################################################### |
---|
| 337 | |
---|
| 338 | |
---|
[1197] | 339 | SUFF_NAME=_${dim_full} |
---|
| 340 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
[783] | 341 | |
---|
[1197] | 342 | if [[ "$parallel" != "none" ]] |
---|
| 343 | then |
---|
| 344 | SUFF_NAME=${SUFF_NAME}_para |
---|
| 345 | DYN=dyn${dimc}dpar |
---|
[783] | 346 | else |
---|
[1197] | 347 | SUFF_NAME=${SUFF_NAME}_seq |
---|
| 348 | DYN=dyn${dimc}d |
---|
| 349 | fi |
---|
[783] | 350 | |
---|
[1197] | 351 | if [[ $veget == "true" ]] |
---|
| 352 | then |
---|
| 353 | SUFF_NAME=${SUFF_NAME}_orch |
---|
| 354 | fi |
---|
[783] | 355 | |
---|
[1197] | 356 | if [[ $couple != "false" ]] |
---|
| 357 | then |
---|
| 358 | SUFF_NAME=${SUFF_NAME}_couple |
---|
| 359 | fi |
---|
[783] | 360 | |
---|
[1197] | 361 | if [[ $chimie == "INCA" ]] |
---|
| 362 | then |
---|
| 363 | SUFF_NAME=${SUFF_NAME}_inca |
---|
| 364 | fi |
---|
[783] | 365 | |
---|
| 366 | cd $LMDGCM |
---|
[1197] | 367 | config_fcm="config.fcm" |
---|
[783] | 368 | rm -f $config_fcm |
---|
| 369 | touch $config_fcm |
---|
| 370 | rm -f bin/${code}${SUFF_NAME}.e |
---|
| 371 | rm -f arch.fcm |
---|
[1250] | 372 | rm -f arch.opt |
---|
[783] | 373 | |
---|
| 374 | echo "%ARCH $arch" >> $config_fcm |
---|
| 375 | echo "%INCDIR $INCLUDE" >> $config_fcm |
---|
| 376 | echo "%LIB $LIB" >> $config_fcm |
---|
| 377 | echo "%ROOT_PATH $PWD" >> $config_fcm |
---|
| 378 | echo "%LIBF $LIBFGCM" >> $config_fcm |
---|
| 379 | echo "%LIBO $LIBOGCM" >> $config_fcm |
---|
| 380 | echo "%DYN $DYN" >> $config_fcm |
---|
| 381 | echo "%PHYS phy${physique}" >> $config_fcm |
---|
| 382 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
---|
| 383 | echo "%EXEC $code" >> $config_fcm |
---|
| 384 | echo "%SUFF_NAME $SUFF_NAME" >> $config_fcm |
---|
[1002] | 385 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm |
---|
| 386 | echo "%PARA_FFLAGS $PARA_FFLAGS" >> $config_fcm |
---|
| 387 | echo "%PARA_LD $PARA_LD" >> $config_fcm |
---|
[1228] | 388 | echo "%EXT_SRC $EXT_SRC" >> $config_fcm |
---|
[783] | 389 | |
---|
[1002] | 390 | |
---|
| 391 | |
---|
[1137] | 392 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
[1250] | 393 | if test -f arch/arch-${arch}.opt && [ $compil_mod = "prod" ] |
---|
| 394 | then |
---|
| 395 | ln -s arch/arch-${arch}.opt arch.opt |
---|
| 396 | else |
---|
| 397 | ln -s .void_file arch.opt |
---|
| 398 | fi |
---|
| 399 | |
---|
| 400 | |
---|
[1002] | 401 | rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock |
---|
[783] | 402 | ./build_gcm |
---|
| 403 | |
---|
[1249] | 404 | rm -rf tmp_src |
---|
| 405 | rm -rf config |
---|
[783] | 406 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config |
---|
| 407 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/tmp tmp_src |
---|