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