| 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 : 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. |
|---|
| 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 filtre=filtrez |
|---|
| 21 | set grille=reg |
|---|
| 22 | set couple=false |
|---|
| 23 | set veget=false |
|---|
| 24 | set chimie=false |
|---|
| 25 | set parallel=none |
|---|
| 26 | set compil_mod=prod |
|---|
| 27 | set io=ioipsl |
|---|
| 28 | set LIBPREFIX="" |
|---|
| 29 | set fcm_path=none |
|---|
| 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 | [-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) |
|---|
| 66 | [-chimie INCA/false] : avec ou sans model de chimie INCA (def: false) |
|---|
| 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) |
|---|
| 70 | [-include INCLUDES] : variables supplementaires pour include |
|---|
| 71 | [-cpp CPP_KEY] : cle cpp supplementaires |
|---|
| 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 | [-fcm_path path] : chemin pour fcm (def: le chemin est suppose deja exister dans le PATH) |
|---|
| 76 | -arch nom_arch : nom de l'architecture cible |
|---|
| 77 | exec : exécutable généré |
|---|
| 78 | fin |
|---|
| 79 | exit |
|---|
| 80 | |
|---|
| 81 | case -d: |
|---|
| 82 | set dim=$2 ; shift ; shift ; goto top |
|---|
| 83 | |
|---|
| 84 | case -O: |
|---|
| 85 | echo "option obsolete dans cette version intermediaire de makegcm" |
|---|
| 86 | exit |
|---|
| 87 | |
|---|
| 88 | case -p |
|---|
| 89 | set physique="$2" ; shift ; shift ; goto top |
|---|
| 90 | |
|---|
| 91 | case -g |
|---|
| 92 | set grille="$2" ; shift ; shift ; goto top |
|---|
| 93 | |
|---|
| 94 | case -c |
|---|
| 95 | set couple="$2" ; shift ; shift ; goto top |
|---|
| 96 | |
|---|
| 97 | case -prod |
|---|
| 98 | set compil_mod="prod" ; shift ; goto top |
|---|
| 99 | |
|---|
| 100 | case -dev |
|---|
| 101 | set compil_mod="dev" ; shift ; goto top |
|---|
| 102 | |
|---|
| 103 | case -debug |
|---|
| 104 | set compil_mod="debug" ; shift ; goto top |
|---|
| 105 | |
|---|
| 106 | case -io |
|---|
| 107 | set io="$2" ; shift ; shift ; goto top |
|---|
| 108 | |
|---|
| 109 | case -v |
|---|
| 110 | set veget="$2" ; shift ; shift ; goto top |
|---|
| 111 | |
|---|
| 112 | case -chimie |
|---|
| 113 | set chimie="$2" ; shift ; shift ; goto top |
|---|
| 114 | |
|---|
| 115 | case -parallel |
|---|
| 116 | set parallel="$2" ; shift ; shift ; goto top |
|---|
| 117 | |
|---|
| 118 | case -include |
|---|
| 119 | set INCLUDE="$INCLUDE -I$2" ; shift ; shift ; goto top |
|---|
| 120 | |
|---|
| 121 | case -cpp |
|---|
| 122 | set CPP_KEY="$CPP_KEY $2" ; shift ; shift ; goto top |
|---|
| 123 | |
|---|
| 124 | case -adjnt |
|---|
| 125 | echo 'otpion a reactiver ';exit |
|---|
| 126 | set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d " |
|---|
| 127 | set optim="$optim -Dadj" ; shift ; goto top |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | case -filtre |
|---|
| 131 | set filtre=$2 ; shift ; shift ; goto top |
|---|
| 132 | |
|---|
| 133 | case -link |
|---|
| 134 | set LIB="$LIB $2" ; shift ; shift ; goto top |
|---|
| 135 | |
|---|
| 136 | case -fcm_path |
|---|
| 137 | set fcm_path=$2 ; shift ; shift ; goto top |
|---|
| 138 | |
|---|
| 139 | case -arch |
|---|
| 140 | set arch=$2 ; shift ; shift ; goto top |
|---|
| 141 | |
|---|
| 142 | default |
|---|
| 143 | set code="$1" ; shift ; goto top |
|---|
| 144 | |
|---|
| 145 | endsw |
|---|
| 146 | endif |
|---|
| 147 | |
|---|
| 148 | ############################################################### |
|---|
| 149 | # mettre le chemin du fcm dans le path |
|---|
| 150 | ############################################################### |
|---|
| 151 | if ( "$fcm_path" != 'none' ) then |
|---|
| 152 | setenv PATH ${fcm_path}:${PATH} |
|---|
| 153 | endif |
|---|
| 154 | |
|---|
| 155 | echo "Chemin du fcm utlise :" |
|---|
| 156 | which fcm |
|---|
| 157 | |
|---|
| 158 | ############################################################### |
|---|
| 159 | # lecture des chemins propres à l'architecture de la machine # |
|---|
| 160 | ############################################################### |
|---|
| 161 | |
|---|
| 162 | rm -f ./arch.path |
|---|
| 163 | ln -s ./arch/arch-${arch}.path ./arch.path |
|---|
| 164 | source arch.path |
|---|
| 165 | |
|---|
| 166 | ######################################################################## |
|---|
| 167 | # Definition des clefs CPP, des chemins des includes et modules |
|---|
| 168 | # et des libraries |
|---|
| 169 | ######################################################################## |
|---|
| 170 | |
|---|
| 171 | if ( "$compil_mod" == 'prod' ) then |
|---|
| 172 | set COMPIL_FFLAGS="%PROD_FFLAGS" |
|---|
| 173 | else if ( "$compil_mod" == 'dev' ) then |
|---|
| 174 | set COMPIL_FFLAGS="%DEV_FFLAGS" |
|---|
| 175 | else if ( "$compil_mod" == 'debug' ) then |
|---|
| 176 | set COMPIL_FFLAGS="%DEBUG_FFLAGS" |
|---|
| 177 | endif |
|---|
| 178 | |
|---|
| 179 | if ( "$physique" == 'nophys' ) then |
|---|
| 180 | |
|---|
| 181 | else |
|---|
| 182 | #Default planet type is Earth |
|---|
| 183 | set CPP_KEY="$CPP_KEY CPP_EARTH" |
|---|
| 184 | endif |
|---|
| 185 | |
|---|
| 186 | if ( "$chimie" == 'INCA' ) then |
|---|
| 187 | set CPP_KEY="$CPP_KEY INCA" |
|---|
| 188 | set INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
|---|
| 189 | set LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
|---|
| 190 | endif |
|---|
| 191 | |
|---|
| 192 | if ( "$couple" != 'false' ) then |
|---|
| 193 | set CPP_KEY="$CPP_KEY CPP_COUPLE" |
|---|
| 194 | set INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
|---|
| 195 | set LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
|---|
| 196 | endif |
|---|
| 197 | |
|---|
| 198 | if ( "$parallel" == 'mpi' ) then |
|---|
| 199 | set CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
|---|
| 200 | set PARA_FFLAGS="%MPI_FFLAGS" |
|---|
| 201 | set PARA_LD="%MPI_LD" |
|---|
| 202 | else if ("$parallel" == 'omp' ) then |
|---|
| 203 | set CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
|---|
| 204 | set PARA_FFLAGS="%OMP_FFLAGS" |
|---|
| 205 | set PARA_LD="%OMP_LD" |
|---|
| 206 | else if ("$parallel" == 'mpi_omp' ) then |
|---|
| 207 | set CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
|---|
| 208 | set PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
|---|
| 209 | set PARA_LD="%MPI_LD %OMP_LD" |
|---|
| 210 | endif |
|---|
| 211 | |
|---|
| 212 | if ( "$veget" == 'true' ) then |
|---|
| 213 | set CPP_KEY="$CPP_KEY CPP_VEGET" |
|---|
| 214 | set INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
|---|
| 215 | set LIB="${LIB} -L${ORCH_LIBDIR} -l${LIBPREFIX}sechiba -l${LIBPREFIX}parameters -l${LIBPREFIX}stomate -l${LIBPREFIX}parallel -l${LIBPREFIX}orglob" |
|---|
| 216 | endif |
|---|
| 217 | |
|---|
| 218 | if ( $io == ioipsl ) then |
|---|
| 219 | set CPP_KEY="$CPP_KEY CPP_IOIPSL" |
|---|
| 220 | set INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
|---|
| 221 | set LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
|---|
| 222 | endif |
|---|
| 223 | |
|---|
| 224 | set INCLUDE="$INCLUDE -I${NETCDF_INCDIR}" |
|---|
| 225 | set LIB="$LIB -L${NETCDF_LIBDIR} -lnetcdf" |
|---|
| 226 | |
|---|
| 227 | ######################################################################## |
|---|
| 228 | # calcul du nombre de dimensions |
|---|
| 229 | ######################################################################## |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | set dim_full=$dim |
|---|
| 233 | set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
|---|
| 234 | set dimc=`echo $dim | wc -w` |
|---|
| 235 | |
|---|
| 236 | echo calcul de la dimension |
|---|
| 237 | echo dim $dim |
|---|
| 238 | echo dimc $dimc |
|---|
| 239 | |
|---|
| 240 | |
|---|
| 241 | ######################################################################## |
|---|
| 242 | # Gestion des dimensions du modele. |
|---|
| 243 | # on cree ou remplace le fichier des dimensions |
|---|
| 244 | ######################################################################## |
|---|
| 245 | |
|---|
| 246 | cd $LIBFGCM/grid/dimension |
|---|
| 247 | ./makdim $dim |
|---|
| 248 | cat $LIBFGCM/grid/dimensions.h |
|---|
| 249 | cd $LMDGCM |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | ######################################################################## |
|---|
| 253 | # Differentes dynamiques (3d, 2d, 1d) |
|---|
| 254 | ######################################################################## |
|---|
| 255 | |
|---|
| 256 | set dimension=`echo $dim | wc -w` |
|---|
| 257 | echo dimension $dimension |
|---|
| 258 | |
|---|
| 259 | if ( $dimension != 3 ) then |
|---|
| 260 | echo "Probleme dans les dimensions de la dynamique !!" |
|---|
| 261 | echo "Non reactive pour l'instant !!!" |
|---|
| 262 | endif |
|---|
| 263 | |
|---|
| 264 | if ( $dimension == 3 ) then |
|---|
| 265 | cd $LIBFGCM/grid |
|---|
| 266 | \rm fxyprim.h |
|---|
| 267 | cp -p fxy_${grille}.h fxyprim.h |
|---|
| 268 | endif |
|---|
| 269 | |
|---|
| 270 | ###################################################################### |
|---|
| 271 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
|---|
| 272 | # ---> YM desactive pour le traitemement en parallele |
|---|
| 273 | ###################################################################### |
|---|
| 274 | |
|---|
| 275 | #if ( -f $libf/phy$physique/raddim.h ) then |
|---|
| 276 | # if ( -f $libf/phy$physique/raddim.$dimh.h ) then |
|---|
| 277 | # \rm -f $libf/phy$physique/raddim.h |
|---|
| 278 | # cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
|---|
| 279 | # echo $libf/phy$physique/raddim.$dimh.h |
|---|
| 280 | # cat $libf/phy$physique/raddim.h |
|---|
| 281 | # else |
|---|
| 282 | # echo On peut diminuer la taille de l executable en creant |
|---|
| 283 | # echo le fichier $libf/phy$physique/raddim.$dimh.h |
|---|
| 284 | # \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
|---|
| 285 | # endif |
|---|
| 286 | #endif |
|---|
| 287 | |
|---|
| 288 | ###################################################################### |
|---|
| 289 | # Gestion du filtre qui n'existe qu'en 3d. |
|---|
| 290 | ###################################################################### |
|---|
| 291 | |
|---|
| 292 | if ( `expr $dimc \> 2` == 1 ) then |
|---|
| 293 | set filtre="FILTRE=$filtre" |
|---|
| 294 | else |
|---|
| 295 | set filtre="FILTRE= L_FILTRE= " |
|---|
| 296 | endif |
|---|
| 297 | echo MACRO FILTRE $filtre |
|---|
| 298 | |
|---|
| 299 | echo $dimc |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | ###################################################################### |
|---|
| 304 | # Creation du suffixe de la configuration |
|---|
| 305 | ###################################################################### |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | set SUFF_NAME=_${dim_full} |
|---|
| 309 | set SUFF_NAME=${SUFF_NAME}_phy${physique} |
|---|
| 310 | |
|---|
| 311 | if ( "$parallel" != 'none' ) then |
|---|
| 312 | set SUFF_NAME=${SUFF_NAME}_para |
|---|
| 313 | set DYN=dyn${dimc}dpar |
|---|
| 314 | else |
|---|
| 315 | set SUFF_NAME=${SUFF_NAME}_seq |
|---|
| 316 | set DYN=dyn${dimc}d |
|---|
| 317 | endif |
|---|
| 318 | |
|---|
| 319 | if ( $veget == "true" ) then |
|---|
| 320 | set SUFF_NAME=${SUFF_NAME}_orch |
|---|
| 321 | endif |
|---|
| 322 | |
|---|
| 323 | if ( $couple != "false" ) then |
|---|
| 324 | set SUFF_NAME=${SUFF_NAME}_couple |
|---|
| 325 | endif |
|---|
| 326 | |
|---|
| 327 | if ( $chimie == 'INCA' ) then |
|---|
| 328 | set SUFF_NAME=${SUFF_NAME}_inca |
|---|
| 329 | endif |
|---|
| 330 | |
|---|
| 331 | cd $LMDGCM |
|---|
| 332 | set config_fcm="config.fcm" |
|---|
| 333 | rm -f $config_fcm |
|---|
| 334 | touch $config_fcm |
|---|
| 335 | rm -f bin/${code}${SUFF_NAME}.e |
|---|
| 336 | rm -f arch.fcm |
|---|
| 337 | |
|---|
| 338 | echo "%ARCH $arch" >> $config_fcm |
|---|
| 339 | echo "%INCDIR $INCLUDE" >> $config_fcm |
|---|
| 340 | echo "%LIB $LIB" >> $config_fcm |
|---|
| 341 | echo "%ROOT_PATH $PWD" >> $config_fcm |
|---|
| 342 | echo "%LIBF $LIBFGCM" >> $config_fcm |
|---|
| 343 | echo "%LIBO $LIBOGCM" >> $config_fcm |
|---|
| 344 | echo "%DYN $DYN" >> $config_fcm |
|---|
| 345 | echo "%PHYS phy${physique}" >> $config_fcm |
|---|
| 346 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
|---|
| 347 | echo "%EXEC $code" >> $config_fcm |
|---|
| 348 | echo "%SUFF_NAME $SUFF_NAME" >> $config_fcm |
|---|
| 349 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm |
|---|
| 350 | echo "%PARA_FFLAGS $PARA_FFLAGS" >> $config_fcm |
|---|
| 351 | echo "%PARA_LD $PARA_LD" >> $config_fcm |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | |
|---|
| 355 | ln -s arch/arch-${arch}.fcm arch.fcm |
|---|
| 356 | rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock |
|---|
| 357 | ./build_gcm |
|---|
| 358 | |
|---|
| 359 | rm -f tmp_src |
|---|
| 360 | rm -f config |
|---|
| 361 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config |
|---|
| 362 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/tmp tmp_src |
|---|
| 363 | #\rm -f $libf/grid/dimensions.h |
|---|