| 1 | #!/bin/csh |
|---|
| 2 | # |
|---|
| 3 | # $Header$ |
|---|
| 4 | # |
|---|
| 5 | # FH : on ne cr�e plus le fichier arch.mk qui est suppos� exister par |
|---|
| 6 | # FH : ailleurs. |
|---|
| 7 | # FH : ult�rieurement, 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 makegcm7. |
|---|
| 12 | # |
|---|
| 13 | set verbose echo |
|---|
| 14 | ######################################################################## |
|---|
| 15 | # options par defaut pour la commande make |
|---|
| 16 | ######################################################################## |
|---|
| 17 | |
|---|
| 18 | set dim="96x72x19" |
|---|
| 19 | set physique=lmd |
|---|
| 20 | set ntrac = 4 |
|---|
| 21 | set filtre=filtrez |
|---|
| 22 | set grille=reg |
|---|
| 23 | set couple=false |
|---|
| 24 | set veget=false |
|---|
| 25 | set chimie=false |
|---|
| 26 | set parallel=none |
|---|
| 27 | set compil_mod=prod |
|---|
| 28 | set io=ioipsl |
|---|
| 29 | set LIBPREFIX="" |
|---|
| 30 | |
|---|
| 31 | set LMDGCM=`/bin/pwd` |
|---|
| 32 | set LIBOGCM=$LMDGCM/libo |
|---|
| 33 | set LIBFGCM=$LMDGCM/libf |
|---|
| 34 | |
|---|
| 35 | ######################################################################## |
|---|
| 36 | # Quelques initialisations de variables du shell. |
|---|
| 37 | ######################################################################## |
|---|
| 38 | |
|---|
| 39 | set CPP_KEY="" |
|---|
| 40 | set INCLUDE="" |
|---|
| 41 | set LIB="" |
|---|
| 42 | set adjnt="" |
|---|
| 43 | set COMPIL_FFLAGS="%PROD_FFLAGS" |
|---|
| 44 | set PARA_FFLAGS="" |
|---|
| 45 | set PARA_LD="" |
|---|
| 46 | |
|---|
| 47 | ######################################################################## |
|---|
| 48 | # lecture des options de mymake |
|---|
| 49 | ######################################################################## |
|---|
| 50 | |
|---|
| 51 | top: |
|---|
| 52 | if ($#argv > 0) then |
|---|
| 53 | switch ($1:q) |
|---|
| 54 | |
|---|
| 55 | case -h: |
|---|
| 56 | cat <<fin |
|---|
| 57 | manuel complet sur http://... |
|---|
| 58 | Usage : |
|---|
| 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 | [-t NTRAC] : nombre de traceurs (def: 4) |
|---|
| 63 | [-p PHYS] : compilation avec la physique libf/phyPHYS, (def: lmd) |
|---|
| 64 | [-prod / -dev / -debug] : compilation en mode production (default) / developpement / debug . |
|---|
| 65 | [-c false/MPI1/MPI2] : couplé océan : MPI1/MPI2/false (def: false) |
|---|
| 66 | [-v false/true] : avec ou sans végétation (def: false) |
|---|
| 67 | [-chimie INCA/false] : avec ou sans model de chimie INCA (def: false) |
|---|
| 68 | [-parallel none/mpi/omp/mpi_omp] : parallelisation (default: none) : mpi, openmp ou mixte mpi_openmp |
|---|
| 69 | [-g GRI] : conf. grille dans dyn3d/GRI_xy.h (def: reg inclue un zoom) |
|---|
| 70 | [-io IO] : choix d'une librairie I/O, experts (def: ioipsl) |
|---|
| 71 | [-include INCLUDES] : variables supplementaires pour include cpp, experts. |
|---|
| 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 |
|---|
| 75 | -m arch : nom de l'architecture cible |
|---|
| 76 | exec : exécutable généré |
|---|
| 77 | fin |
|---|
| 78 | exit |
|---|
| 79 | |
|---|
| 80 | case -d: |
|---|
| 81 | set dim=$2 ; shift ; shift ; goto top |
|---|
| 82 | |
|---|
| 83 | case -O: |
|---|
| 84 | echo "option obsolete dans cette version intermediaire de makegcm" |
|---|
| 85 | exit |
|---|
| 86 | |
|---|
| 87 | case -p |
|---|
| 88 | set physique="$2" ; shift ; shift ; goto top |
|---|
| 89 | |
|---|
| 90 | case -g |
|---|
| 91 | set grille="$2" ; shift ; shift ; goto top |
|---|
| 92 | |
|---|
| 93 | case -c |
|---|
| 94 | set couple="$2" ; shift ; shift ; goto top |
|---|
| 95 | |
|---|
| 96 | case -prod |
|---|
| 97 | set compil_mod="prod" ; shift ; goto top |
|---|
| 98 | |
|---|
| 99 | case -dev |
|---|
| 100 | set compil_mod="dev" ; shift ; goto top |
|---|
| 101 | |
|---|
| 102 | case -debug |
|---|
| 103 | set compil_mod="debug" ; shift ; goto top |
|---|
| 104 | |
|---|
| 105 | case -io |
|---|
| 106 | set io="$2" ; shift ; shift ; goto top |
|---|
| 107 | |
|---|
| 108 | case -v |
|---|
| 109 | set veget="$2" ; shift ; shift ; goto top |
|---|
| 110 | |
|---|
| 111 | case -chimie |
|---|
| 112 | set chimie="$2" ; shift ; shift ; goto top |
|---|
| 113 | |
|---|
| 114 | case -parallel |
|---|
| 115 | set parallel="$2" ; shift ; shift ; goto top |
|---|
| 116 | |
|---|
| 117 | case -t |
|---|
| 118 | set ntrac=$2 ; shift ; shift ; goto top |
|---|
| 119 | |
|---|
| 120 | case -include |
|---|
| 121 | set INCLUDE="$INCLUDE -I$2" ; shift ; shift ; goto top |
|---|
| 122 | |
|---|
| 123 | case -adjnt |
|---|
| 124 | echo 'otpion a reactiver ';exit |
|---|
| 125 | set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d " |
|---|
| 126 | set optim="$optim -Dadj" ; shift ; goto top |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | case -filtre |
|---|
| 130 | set filtre=$2 ; shift ; shift ; goto top |
|---|
| 131 | |
|---|
| 132 | case -link |
|---|
| 133 | set LIB="$LIB $2" ; shift ; shift ; goto top |
|---|
| 134 | |
|---|
| 135 | case -m |
|---|
| 136 | set arch=$2 ; shift ; shift ; goto top |
|---|
| 137 | |
|---|
| 138 | default |
|---|
| 139 | set code="$1" ; shift ; goto top |
|---|
| 140 | |
|---|
| 141 | endsw |
|---|
| 142 | endif |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | ############################################################### |
|---|
| 146 | # lecture des chemins propres � l'architecture de la machine # |
|---|
| 147 | ############################################################### |
|---|
| 148 | |
|---|
| 149 | rm -f ./arch.path |
|---|
| 150 | ln -s ./machine/arch-${arch}.path ./arch.path |
|---|
| 151 | source arch.path |
|---|
| 152 | |
|---|
| 153 | ######################################################################## |
|---|
| 154 | # Definition des clefs CPP, des chemins des includes et modules |
|---|
| 155 | # et des libraries |
|---|
| 156 | ######################################################################## |
|---|
| 157 | |
|---|
| 158 | if ( "$compil_mod" == 'prod' ) then |
|---|
| 159 | set COMPIL_FFLAGS="%PROD_FFLAGS" |
|---|
| 160 | else if ( "$compil_mod" == 'dev' ) then |
|---|
| 161 | set COMPIL_FFLAGS="%DEV_FFLAGS" |
|---|
| 162 | else if ( "$compil_mod" == 'debug' ) then |
|---|
| 163 | set COMPIL_FFLAGS="%DEBUG_FFLAGS" |
|---|
| 164 | endif |
|---|
| 165 | |
|---|
| 166 | if ( "$physique" == 'nophys' ) then |
|---|
| 167 | |
|---|
| 168 | else |
|---|
| 169 | set CPP_KEY="$CPP_KEY CPP_PHYS" |
|---|
| 170 | endif |
|---|
| 171 | |
|---|
| 172 | if ( "$chimie" == 'INCA' ) then |
|---|
| 173 | set CPP_KEY="$CPP_KEY INCA" |
|---|
| 174 | set INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
|---|
| 175 | set LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
|---|
| 176 | endif |
|---|
| 177 | |
|---|
| 178 | if ( "$couple" != 'false' ) then |
|---|
| 179 | set CPP_KEY="$CPP_KEY CPP_COUPLE" |
|---|
| 180 | set INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
|---|
| 181 | set LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
|---|
| 182 | endif |
|---|
| 183 | |
|---|
| 184 | if ( "$parallel" == 'mpi' ) then |
|---|
| 185 | set CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
|---|
| 186 | set PARA_FFLAGS="%MPI_FFLAGS" |
|---|
| 187 | set PARA_LD="%MPI_LD" |
|---|
| 188 | else if ("$parallel" == 'omp' ) then |
|---|
| 189 | set CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
|---|
| 190 | set PARA_FFLAGS="%OMP_FFLAGS" |
|---|
| 191 | set PARA_LD="%OMP_LD" |
|---|
| 192 | else if ("$parallel" == 'mpi_omp' ) then |
|---|
| 193 | set CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
|---|
| 194 | set PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
|---|
| 195 | set PARA_LD="%MPI_LD %OMP_LD" |
|---|
| 196 | endif |
|---|
| 197 | |
|---|
| 198 | if ( "$veget" == 'true' ) then |
|---|
| 199 | set CPP_KEY="$CPP_KEY CPP_VEGET" |
|---|
| 200 | set INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
|---|
| 201 | set LIB="${LIB} -L${ORCH_LIBDIR} -l${LIBPREFIX}sechiba -l${LIBPREFIX}parameters -l${LIBPREFIX}stomate -l${LIBPREFIX}parallel -l${LIBPREFIX}orglob" |
|---|
| 202 | endif |
|---|
| 203 | |
|---|
| 204 | if ( $io == ioipsl ) then |
|---|
| 205 | set CPP_KEY="$CPP_KEY CPP_IOIPSL" |
|---|
| 206 | set INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
|---|
| 207 | set LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
|---|
| 208 | endif |
|---|
| 209 | |
|---|
| 210 | set INCLUDE="$INCLUDE -I${NETCDF_INCDIR}" |
|---|
| 211 | set LIB="$LIB -L${NETCDF_LIBDIR} -lnetcdf" |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | ######################################################################## |
|---|
| 215 | # choix du nombre de traceur par defaut si il n'a pas ete choisi, |
|---|
| 216 | # suivant la physique |
|---|
| 217 | ######################################################################## |
|---|
| 218 | |
|---|
| 219 | if ( $ntrac == 0 ) then |
|---|
| 220 | if ( "$physique" == 'nophys' ) then |
|---|
| 221 | set ntrac=1 |
|---|
| 222 | else if ( "$physique" == 'lmd' ) then |
|---|
| 223 | set ntrac=2 |
|---|
| 224 | else if ( "$physique" == 'lmd_test_li' ) then |
|---|
| 225 | set ntrac=2 |
|---|
| 226 | else if ( "$physique" == 'ec' ) then |
|---|
| 227 | set ntrac=1 |
|---|
| 228 | else |
|---|
| 229 | set ntrac = 1 |
|---|
| 230 | endif |
|---|
| 231 | endif |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | ######################################################################## |
|---|
| 235 | # calcul du nombre de dimensions |
|---|
| 236 | ######################################################################## |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | set dim_full=$dim |
|---|
| 240 | set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
|---|
| 241 | set dimc=`echo $dim | wc -w` |
|---|
| 242 | |
|---|
| 243 | echo calcul de la dimension |
|---|
| 244 | echo dim $dim |
|---|
| 245 | echo dimc $dimc |
|---|
| 246 | |
|---|
| 247 | |
|---|
| 248 | ######################################################################## |
|---|
| 249 | # Gestion des dimensions du modele. |
|---|
| 250 | # on cree ou remplace le fichier des dimensions/nombre de traceur |
|---|
| 251 | ######################################################################## |
|---|
| 252 | |
|---|
| 253 | cd $LIBFGCM/grid/dimension |
|---|
| 254 | ./makdim $ntrac $dim |
|---|
| 255 | cat $LIBFGCM/grid/dimensions.h |
|---|
| 256 | cd $LMDGCM |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | ######################################################################## |
|---|
| 260 | # Differentes dynamiques (3d, 2d, 1d) |
|---|
| 261 | ######################################################################## |
|---|
| 262 | |
|---|
| 263 | set dimension=`echo $dim | wc -w` |
|---|
| 264 | echo dimension $dimension |
|---|
| 265 | |
|---|
| 266 | if ( $dimension != 3 ) then |
|---|
| 267 | echo "Probleme dans les dimensions de la dynamique !!" |
|---|
| 268 | echo "Non reactive pour l'instant !!!" |
|---|
| 269 | endif |
|---|
| 270 | |
|---|
| 271 | if ( $dimension == 3 ) then |
|---|
| 272 | cd $LIBFGCM/grid |
|---|
| 273 | \rm fxyprim.h |
|---|
| 274 | cp -p fxy_${grille}.h fxyprim.h |
|---|
| 275 | endif |
|---|
| 276 | |
|---|
| 277 | ###################################################################### |
|---|
| 278 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
|---|
| 279 | # ---> YM desactive pour le traitemement en parallele |
|---|
| 280 | ###################################################################### |
|---|
| 281 | |
|---|
| 282 | #if ( -f $libf/phy$physique/raddim.h ) then |
|---|
| 283 | # if ( -f $libf/phy$physique/raddim.$dimh.h ) then |
|---|
| 284 | # \rm -f $libf/phy$physique/raddim.h |
|---|
| 285 | # cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
|---|
| 286 | # echo $libf/phy$physique/raddim.$dimh.h |
|---|
| 287 | # cat $libf/phy$physique/raddim.h |
|---|
| 288 | # else |
|---|
| 289 | # echo On peut diminuer la taille de l executable en creant |
|---|
| 290 | # echo le fichier $libf/phy$physique/raddim.$dimh.h |
|---|
| 291 | # \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
|---|
| 292 | # endif |
|---|
| 293 | #endif |
|---|
| 294 | |
|---|
| 295 | ###################################################################### |
|---|
| 296 | # Gestion du filtre qui n'existe qu'en 3d. |
|---|
| 297 | ###################################################################### |
|---|
| 298 | |
|---|
| 299 | if ( `expr $dimc \> 2` == 1 ) then |
|---|
| 300 | set filtre="FILTRE=$filtre" |
|---|
| 301 | else |
|---|
| 302 | set filtre="FILTRE= L_FILTRE= " |
|---|
| 303 | endif |
|---|
| 304 | echo MACRO FILTRE $filtre |
|---|
| 305 | |
|---|
| 306 | echo $dimc |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | ###################################################################### |
|---|
| 311 | # Creation du suffixe de la configuration |
|---|
| 312 | ###################################################################### |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | set SUFF_NAME=_${dim_full} |
|---|
| 316 | set SUFF_NAME=${SUFF_NAME}_t${ntrac}_phy${physique} |
|---|
| 317 | |
|---|
| 318 | if ( "$parallel" != 'none' ) then |
|---|
| 319 | set SUFF_NAME=${SUFF_NAME}_para |
|---|
| 320 | set DYN=dyn${dimc}dpar |
|---|
| 321 | else |
|---|
| 322 | set SUFF_NAME=${SUFF_NAME}_seq |
|---|
| 323 | set DYN=dyn${dimc}d |
|---|
| 324 | endif |
|---|
| 325 | |
|---|
| 326 | if ( $veget == "true" ) then |
|---|
| 327 | set SUFF_NAME=${SUFF_NAME}_orch |
|---|
| 328 | endif |
|---|
| 329 | |
|---|
| 330 | if ( $couple != "false" ) then |
|---|
| 331 | set SUFF_NAME=${SUFF_NAME}_couple |
|---|
| 332 | endif |
|---|
| 333 | |
|---|
| 334 | if ( $chimie == 'INCA' ) then |
|---|
| 335 | set SUFF_NAME=${SUFF_NAME}_inca |
|---|
| 336 | endif |
|---|
| 337 | |
|---|
| 338 | cd $LMDGCM |
|---|
| 339 | set config_fcm="config.fcm" |
|---|
| 340 | rm -f $config_fcm |
|---|
| 341 | touch $config_fcm |
|---|
| 342 | rm -f bin/${code}${SUFF_NAME}.e |
|---|
| 343 | rm -f arch.fcm |
|---|
| 344 | |
|---|
| 345 | echo "%ARCH $arch" >> $config_fcm |
|---|
| 346 | echo "%INCDIR $INCLUDE" >> $config_fcm |
|---|
| 347 | echo "%LIB $LIB" >> $config_fcm |
|---|
| 348 | echo "%ROOT_PATH $PWD" >> $config_fcm |
|---|
| 349 | echo "%LIBF $LIBFGCM" >> $config_fcm |
|---|
| 350 | echo "%LIBO $LIBOGCM" >> $config_fcm |
|---|
| 351 | echo "%DYN $DYN" >> $config_fcm |
|---|
| 352 | echo "%PHYS phy${physique}" >> $config_fcm |
|---|
| 353 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
|---|
| 354 | echo "%EXEC $code" >> $config_fcm |
|---|
| 355 | echo "%SUFF_NAME $SUFF_NAME" >> $config_fcm |
|---|
| 356 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm |
|---|
| 357 | echo "%PARA_FFLAGS $PARA_FFLAGS" >> $config_fcm |
|---|
| 358 | echo "%PARA_LD $PARA_LD" >> $config_fcm |
|---|
| 359 | |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | ln -s machine/arch-${arch}.fcm arch.fcm |
|---|
| 363 | rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock |
|---|
| 364 | ./build_gcm |
|---|
| 365 | |
|---|
| 366 | rm -f tmp_src |
|---|
| 367 | rm -f config |
|---|
| 368 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config |
|---|
| 369 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/tmp tmp_src |
|---|
| 370 | #\rm -f $libf/grid/dimensions.h |
|---|