[38] | 1 | #!/bin/csh -f |
---|
| 2 | # $Header: /users/lmdz/cvsroot/LMDZ.3.3/makegcm,v 1.21 2001/07/04 08:41:44 lmdz Exp $ |
---|
| 3 | #set verbose echo |
---|
| 4 | ######################################################################## |
---|
| 5 | # options par defaut pour la commande make |
---|
| 6 | ######################################################################## |
---|
| 7 | set dim="64x48x32" |
---|
| 8 | set physique=mars |
---|
| 9 | set phys="PHYS=$physique" |
---|
| 10 | set include='-I$(LIBF)/grid -I$(LIBF)/bibio -I. -I$(LIBF)/aeronomars' |
---|
| 11 | set ntrac = 1 |
---|
| 12 | set filtre=filtrez |
---|
| 13 | set grille=reg |
---|
| 14 | set dyntype="dyn" |
---|
[148] | 15 | set scatterers="1" |
---|
[1085] | 16 | set full="" |
---|
[38] | 17 | ######################################################################## |
---|
| 18 | # path a changer contenant les sources et les objets du modele |
---|
| 19 | ######################################################################## |
---|
| 20 | |
---|
| 21 | #### If you want you can set environment variables here (instead of |
---|
| 22 | #### relying on the C-shell environment variables) |
---|
| 23 | # default LMDGCM to where makegcm script is located: |
---|
[519] | 24 | set scriptdir=`dirname $0` |
---|
| 25 | setenv LMDGCM `readlink -f $scriptdir` |
---|
[38] | 26 | # You may set LIBOGCM to something else; otherwise we default to: |
---|
[519] | 27 | setenv LIBOGCM $LMDGCM/libo |
---|
[38] | 28 | ## NetCDF Libraries: what follows is OK for LMD 32 and 64bit Linux Machines |
---|
| 29 | #if ( `uname -m` == "x86_64" ) then |
---|
| 30 | # 64 bit machines |
---|
[519] | 31 | setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_gfortran/lib |
---|
| 32 | setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_gfortran/include |
---|
[38] | 33 | #else |
---|
| 34 | # setenv NCDFLIB /donnees/emlmd/netcdf-4.0.1_gfortran/lib |
---|
| 35 | # setenv NCDFINC /donnees/emlmd/netcdf-4.0.1_gfortran/include |
---|
| 36 | #endif |
---|
| 37 | #### |
---|
| 38 | |
---|
| 39 | setenv localdir "`pwd`" |
---|
| 40 | set MODIPSL=0 |
---|
| 41 | echo $localdir | grep modipsl >& /dev/null |
---|
| 42 | if ( ! $status ) then |
---|
| 43 | set MODIPSL=1 |
---|
| 44 | setenv LMDGCM $localdir |
---|
| 45 | cd ../.. |
---|
| 46 | setenv LIBOGCM "`pwd`/lib" |
---|
| 47 | cd $localdir |
---|
| 48 | if ( `hostname` == rhodes ) then |
---|
| 49 | set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"` |
---|
| 50 | set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'` |
---|
| 51 | else |
---|
| 52 | if ( `hostname` == nymphea0 ) then |
---|
| 53 | set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"` |
---|
| 54 | set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'` |
---|
| 55 | else |
---|
| 56 | echo 'Probleme de definition des variables NCDFINC et NCDFLIB' |
---|
| 57 | endif |
---|
| 58 | endif |
---|
| 59 | else |
---|
| 60 | if ( ! $?LMDGCM ) then |
---|
| 61 | echo You must initialize the variable LMDGCM in your environnement |
---|
| 62 | echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc |
---|
| 63 | exit |
---|
| 64 | endif |
---|
| 65 | if ( ! $?LIBOGCM ) then |
---|
| 66 | set LIBOGCM=$LMDGCM/libo |
---|
| 67 | endif |
---|
| 68 | if ( ! $?NCDFLIB ) then |
---|
| 69 | echo You must initialize the variable NCDFLIB in your environnement |
---|
| 70 | echo for instance: "setenv NCDFLIB /usr/myself/netcdf" in .cshrc |
---|
| 71 | exit |
---|
| 72 | endif |
---|
| 73 | if ( ! $?NCDFINC ) then |
---|
| 74 | echo You must initialize the variable NCDFINC in your environnement |
---|
| 75 | echo for instance: "setenv NCDFINC /usr/myself/netcdf" in .cshrc |
---|
| 76 | exit |
---|
| 77 | endif |
---|
| 78 | endif |
---|
| 79 | set model=$LMDGCM |
---|
| 80 | set libo=$LIBOGCM |
---|
| 81 | |
---|
| 82 | ######################################################################## |
---|
| 83 | # Les differentes platformes reconnues |
---|
| 84 | ######################################################################## |
---|
| 85 | |
---|
| 86 | set HP=0 |
---|
| 87 | set IBM=0 |
---|
| 88 | set SUN=0 |
---|
| 89 | set VPP=0 |
---|
| 90 | set CRAY=0 |
---|
| 91 | set DEC=0 |
---|
| 92 | set LINUX=0 |
---|
| 93 | set NEC=0 |
---|
| 94 | set XNEC=0 |
---|
| 95 | if ( `uname` == HP-UX ) then |
---|
| 96 | set machine=HP |
---|
| 97 | set HP=1 |
---|
| 98 | else if (`uname` == UNIX_System_V ) then |
---|
| 99 | set machine=VPP |
---|
| 100 | set VPP=1 |
---|
| 101 | else if (`uname` == SunOS ) then |
---|
| 102 | set machine=SUN |
---|
| 103 | set SUN=1 |
---|
| 104 | else if ( `uname` == AIX ) then |
---|
| 105 | set machine=IBM |
---|
| 106 | set IBM=1 |
---|
| 107 | else if ( `uname` == OSF1 ) then |
---|
| 108 | set machine=ALPHA |
---|
| 109 | set DEC=1 |
---|
| 110 | else if ( `uname` == Linux ) then |
---|
| 111 | set machine=LINUX |
---|
| 112 | set LINUX=1 |
---|
| 113 | else if ( `hostname` == atlas || `hostname` == axis || `hostname` == etoile ) then |
---|
| 114 | set machine=CRAY |
---|
| 115 | set CRAY=1 |
---|
| 116 | else if ( `uname` == SUPER-UX ) then |
---|
| 117 | set machine=NEC |
---|
| 118 | set NEC=1 |
---|
| 119 | else if ( `hostname` == rhodes) then |
---|
| 120 | set machine=XNEC |
---|
| 121 | set XNEC=1 |
---|
| 122 | else |
---|
| 123 | echo Vous travaillez sur une machine non prevue par le reglement |
---|
| 124 | exit |
---|
| 125 | endif |
---|
| 126 | |
---|
| 127 | # create $libo directory if it doesn't exist |
---|
| 128 | if ( ! -d $libo ) then |
---|
| 129 | mkdir $libo |
---|
| 130 | endif |
---|
| 131 | |
---|
| 132 | if $VPP then |
---|
| 133 | set netcdf=netcdf_v |
---|
| 134 | else |
---|
| 135 | set netcdf=netcdf |
---|
| 136 | endif |
---|
| 137 | ######################################################################## |
---|
| 138 | # Quelques initialisations de variables du shell. |
---|
| 139 | ######################################################################## |
---|
| 140 | |
---|
| 141 | set dyn= |
---|
| 142 | set opt_link="" |
---|
| 143 | set adjnt="" |
---|
| 144 | set opt_dep="" |
---|
| 145 | |
---|
| 146 | set optim90="" |
---|
| 147 | set oplink="" |
---|
| 148 | |
---|
| 149 | ######################################################################## |
---|
| 150 | # Optimisations par defaut suivant les machines |
---|
| 151 | ######################################################################## |
---|
| 152 | |
---|
| 153 | echo "Optimisations par defaut suivant les machines" |
---|
| 154 | set libf=$model/libf |
---|
| 155 | #setenv localdir "LOCAL_DIR=`pwd`" |
---|
| 156 | #setenv localdir "`pwd`" |
---|
| 157 | cd $model |
---|
| 158 | if $CRAY then |
---|
| 159 | set optim90="-Wp'-P' -DCRAY "'-p$(LIBO) -eiv ' |
---|
| 160 | set oplink="-Wl'-DSTACK=128 -f indef' -L$NCDFLIB -lnetcdf " |
---|
| 161 | set mod_loc_dir=" " |
---|
| 162 | set mod_suffix=" " |
---|
| 163 | else if $SUN then |
---|
| 164 | set optim90=" -fast" |
---|
| 165 | set optimtru90=" -fast -free" |
---|
| 166 | set opt_link="-L$NCDFLIB -lnetcdf" |
---|
| 167 | set mod_loc_dir=$localdir |
---|
| 168 | set mod_suffix=mod |
---|
| 169 | else if $HP then |
---|
| 170 | else if $IBM then |
---|
| 171 | else if $VPP then |
---|
| 172 | set optim90="$optim -X9 -w" |
---|
| 173 | if $COUPLE then |
---|
| 174 | set opt_link="-Wg,-c $IOIPSLDIR/liboasis2.4_mpi2.a /usr/lang/mpi2/lib64/libmpi.a /usr/lang/mpi2/lib64/libmp.a /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl" |
---|
| 175 | set oplink="-Wl,-t,-P,-dy " |
---|
| 176 | else |
---|
| 177 | set opt_link="-Wg,-c /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl" |
---|
| 178 | set oplink="-Wl,-t,-dy " |
---|
| 179 | endif |
---|
| 180 | set mod_loc_dir=$IOIPSLDIR |
---|
| 181 | set mod_suffix=mod |
---|
| 182 | else if $DEC then |
---|
| 183 | else if $LINUX then |
---|
| 184 | # Ehouarn 'gfortran' compiler |
---|
| 185 | set optim="-O3 -funroll-loops " |
---|
| 186 | set optim90="-O3 -funroll-loops " |
---|
| 187 | set optimtru90="-O3 -funroll-loops " |
---|
| 188 | # |
---|
| 189 | set opt_link=" -L$NCDFLIB -lnetcdf " |
---|
| 190 | set mod_loc_dir=$localdir |
---|
| 191 | set mod_suffix=mod |
---|
| 192 | else if $NEC then |
---|
| 193 | set optim90=' -clear -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "' |
---|
| 194 | set optimtru90=' -clear -f4 -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "' |
---|
| 195 | ### set opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lioipsl -L/u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v " |
---|
| 196 | set opt_link=" -C hopt -float0 -ew -P static -L/SX/usr/local/lib -lnetcdf_i8r8 " |
---|
| 197 | set mod_loc_dir="." |
---|
| 198 | set mod_suffix="mod" |
---|
| 199 | else if $XNEC then |
---|
| 200 | set optim90=' -clear -R5 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "' |
---|
| 201 | set optimtru90=' -clear -R5 -f4 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "' |
---|
| 202 | if $MODIPSL then |
---|
| 203 | if $COUPLE then |
---|
| 204 | set opt_link="-L$IOIPSLDIR -lsxioipsl -loasis2.4_mpi2 -float0 -ew -P static -I$NCDFINC $NCDFLIB " |
---|
| 205 | else |
---|
| 206 | set opt_link="-L$IOIPSLDIR -lsxioipsl -float0 -ew -P static -I$NCDFINC $NCDFLIB " |
---|
| 207 | endif |
---|
| 208 | set mod_loc_dir="./" |
---|
| 209 | else |
---|
| 210 | #### set opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lsxioipsl -L /u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8" |
---|
| 211 | set opt_link=" -C hopt -float0 -ew -P static -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8" |
---|
| 212 | set mod_loc_dir="." |
---|
| 213 | endif |
---|
| 214 | set mod_suffix="mod" |
---|
| 215 | |
---|
| 216 | endif |
---|
| 217 | |
---|
| 218 | # Ehouarn: add 'g9fortran' string to pathname |
---|
| 219 | set nomlib=${machine}_gfortran |
---|
| 220 | |
---|
| 221 | # Impose distinct name for 64 bit Linux machines (to avoid mixing 32 and 64) |
---|
| 222 | if (`uname` == Linux && `uname -m` == "x86_64") then |
---|
| 223 | set nomlib=${machine}64_gfortran |
---|
| 224 | endif |
---|
| 225 | |
---|
| 226 | ######################################################################## |
---|
| 227 | # lecture des options de mymake |
---|
| 228 | ######################################################################## |
---|
| 229 | |
---|
| 230 | top: |
---|
| 231 | if ($#argv > 0) then |
---|
| 232 | switch ($1:q) |
---|
| 233 | |
---|
| 234 | case -h: |
---|
| 235 | |
---|
| 236 | ######################################################################## |
---|
| 237 | # Manuel en ligne |
---|
| 238 | ######################################################################## |
---|
| 239 | more <<eod |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | makegcm [Options] prog |
---|
| 243 | |
---|
| 244 | |
---|
| 245 | The makegcm script: |
---|
| 246 | ------------------- |
---|
| 247 | |
---|
| 248 | 1. compiles a series of subroutines located in the $LMDGCM/libf |
---|
| 249 | sub-directories. |
---|
| 250 | The objects are then stored in the libraries in $LIBOGCM. |
---|
| 251 | |
---|
| 252 | 2. then, makegcm compiles program prog.f located by default in |
---|
| 253 | $LMDGCM/libf/dyn3d and makes the link with the libraries. |
---|
| 254 | |
---|
| 255 | Environment Variables '$LMDGCM' and '$LIBOGCM' |
---|
| 256 | must be set as environment variables or directly |
---|
| 257 | in the makegcm file. |
---|
| 258 | |
---|
| 259 | The makegcm command is used to control the different versions of the model |
---|
| 260 | in parallel, compiled using the compilation options |
---|
| 261 | and the various dimensions, without having to recompile the whole model. |
---|
| 262 | |
---|
| 263 | The FORTRAN libraries are stored in directory $LIBOGCM. |
---|
| 264 | |
---|
| 265 | |
---|
| 266 | OPTIONS: |
---|
| 267 | -------- |
---|
| 268 | |
---|
| 269 | The following options can either be defined by default by editing the |
---|
| 270 | makegcm "script", or in interactive mode: |
---|
| 271 | |
---|
| 272 | -d imxjmxlm where im, jm, and lm are the number of longitudes, |
---|
| 273 | latitudes and vertical layers respectively. |
---|
| 274 | |
---|
| 275 | -t ntrac Selects the number of tracers present in the model |
---|
| 276 | |
---|
| 277 | Options -d and -t overwrite file |
---|
| 278 | $LMDGCM/libf/grid/dimensions.h |
---|
| 279 | which contains the 3 dimensions of the |
---|
| 280 | horizontal grid |
---|
| 281 | im, jm, lm plus the number of tracers passively advected |
---|
| 282 | by the dynamics ntrac, |
---|
| 283 | in 4 PARAMETER FORTRAN format |
---|
| 284 | with a new file: |
---|
| 285 | $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac |
---|
| 286 | If the file does not exist already |
---|
| 287 | it is created by the script |
---|
| 288 | $LMDGCM/libf/grid/dimension/makdim |
---|
| 289 | |
---|
[148] | 290 | -s nscat Number of radiatively active scatterers |
---|
| 291 | |
---|
[38] | 292 | -p PHYS Selects the set of physical parameterizations |
---|
| 293 | you want to compile the model with. |
---|
| 294 | The model is then compiled using the physical |
---|
| 295 | parameterization sources in directory: |
---|
| 296 | $LMDGCM/libf/phyPHYS |
---|
| 297 | |
---|
| 298 | -g grille Selects the grid type. |
---|
| 299 | This option overwrites file |
---|
| 300 | $LMDGCM/libf/grid/fxyprim.h |
---|
| 301 | with file |
---|
| 302 | $LMDGCM/libf/grid/fxy_grille.h |
---|
| 303 | the grid can take the following values: |
---|
| 304 | 1. reg - the regular grid |
---|
| 305 | 2. sin - to obtain equidistant points in terms of sin(latitude) |
---|
| 306 | 3. new - to zoom into a part of the globe |
---|
| 307 | |
---|
| 308 | -O "compilation options" set of fortran compilation options to use |
---|
| 309 | |
---|
| 310 | -include path |
---|
| 311 | Used if the subroutines contain #include files (ccp) that |
---|
| 312 | are located in directories that are not referenced by default. |
---|
| 313 | |
---|
| 314 | -adjnt Compiles the adjoint model to the dynamical code. |
---|
| 315 | |
---|
| 316 | -olddyn To compile GCM with "old dynamics" |
---|
| 317 | |
---|
| 318 | -filtre filter |
---|
| 319 | To select the longitudinal filter in the polar regions. |
---|
| 320 | "filter" corresponds to the name of a directory located in |
---|
| 321 | $LMDGCM/libf. The standard filter for the model is "filtrez" |
---|
| 322 | which can be used for a regular grid and for a |
---|
| 323 | grid with longitudinal zoom. |
---|
| 324 | |
---|
| 325 | -link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..." |
---|
| 326 | Adds a link to FORTRAN libraries |
---|
| 327 | libfile1.a, libfile2.a ... |
---|
| 328 | located in directories dir1, dir2 ...respectively |
---|
| 329 | If dirn is a directory with an automatic path |
---|
| 330 | (/usr/lib ... for example) |
---|
| 331 | there is no need to specify -Ldirn. |
---|
| 332 | |
---|
[1085] | 333 | -full Full (re)compilation (from scratch) |
---|
| 334 | |
---|
[38] | 335 | eod |
---|
| 336 | exit |
---|
| 337 | |
---|
| 338 | ######################################################################## |
---|
| 339 | # Lecture des differentes options |
---|
| 340 | ######################################################################## |
---|
| 341 | |
---|
| 342 | case -d: |
---|
| 343 | set dim=$2 ; shift ; shift ; goto top |
---|
| 344 | |
---|
| 345 | case -O: |
---|
| 346 | set optim="$2" ; set optim90="$2" ; set optimtru90="$2" ; shift ; shift ; goto top |
---|
| 347 | |
---|
| 348 | case -p |
---|
| 349 | set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top |
---|
| 350 | |
---|
[148] | 351 | case -s |
---|
| 352 | set scatterers="$2" ; shift ; goto top |
---|
| 353 | |
---|
[38] | 354 | case -g |
---|
| 355 | set grille="$2" ; shift ; shift ; goto top |
---|
| 356 | |
---|
| 357 | case -t |
---|
| 358 | set ntrac=$2 ; shift ; shift ; goto top |
---|
| 359 | |
---|
| 360 | case -include |
---|
| 361 | set include="$include -I$2" ; shift ; shift ; goto top |
---|
| 362 | |
---|
| 363 | case -adjnt |
---|
| 364 | set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d " |
---|
| 365 | |
---|
| 366 | case -olddyn |
---|
| 367 | set dyntype="olddyn" ; shift; goto top |
---|
| 368 | |
---|
[1085] | 369 | case -full |
---|
| 370 | set full="full" ; shift ; goto top |
---|
| 371 | |
---|
[38] | 372 | case -filtre |
---|
| 373 | set filtre=$2 ; shift ; shift ; goto top |
---|
| 374 | |
---|
| 375 | case -link |
---|
| 376 | set opt_link="$opt_link $2" ; shift ; shift ; goto top |
---|
| 377 | |
---|
| 378 | case -debug |
---|
| 379 | if $HP then |
---|
| 380 | set optim90=" -g " |
---|
| 381 | else if $SUN then |
---|
| 382 | setenv PARALLEL 4 |
---|
| 383 | set optim90=" -g -C " |
---|
| 384 | set optimtru90=" -g -C " |
---|
| 385 | else if $CRAY then |
---|
| 386 | set optim90="$optim90"" -G1 " |
---|
| 387 | else if $LINUX then |
---|
| 388 | ## for gfortran |
---|
[648] | 389 | set optim="-g -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow" |
---|
| 390 | set optim90="-g -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow" |
---|
| 391 | set optimtru90="-g -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow" |
---|
[38] | 392 | else |
---|
| 393 | echo "pas d option debug predefinie pour cette machine" |
---|
| 394 | exit |
---|
| 395 | endif |
---|
| 396 | shift ; goto top |
---|
| 397 | |
---|
| 398 | default |
---|
| 399 | set code="$1" ; shift ; goto top |
---|
| 400 | |
---|
| 401 | endsw |
---|
| 402 | endif |
---|
| 403 | |
---|
| 404 | echo "apres les opts dim $dim" |
---|
| 405 | |
---|
| 406 | ######################################################################## |
---|
| 407 | # cas special sans physique |
---|
| 408 | ######################################################################## |
---|
| 409 | if ( "$physique" == 'nophys' ) then |
---|
| 410 | set phys="L_PHY= LIBPHY=" |
---|
| 411 | endif |
---|
| 412 | |
---|
| 413 | ######################################################################## |
---|
| 414 | # choix du nombre de traceur par defaut si il n'a pas ete choisi, |
---|
| 415 | # suivant la physique |
---|
| 416 | ######################################################################## |
---|
| 417 | |
---|
| 418 | if ( $ntrac == 0 ) then |
---|
| 419 | if ( "$physique" == 'nophys' ) then |
---|
| 420 | set ntrac=1 |
---|
| 421 | else if ( "$physique" == 'lmd' ) then |
---|
| 422 | set ntrac=2 |
---|
| 423 | else if ( "$physique" == 'lmd_test_li' ) then |
---|
| 424 | set ntrac=2 |
---|
| 425 | else if ( "$physique" == 'ec' ) then |
---|
| 426 | set ntrac=1 |
---|
| 427 | else |
---|
| 428 | set ntrac = 1 |
---|
| 429 | endif |
---|
| 430 | endif |
---|
| 431 | |
---|
| 432 | ######################################################################## |
---|
| 433 | #subtilites sur le nom de la librairie |
---|
| 434 | ######################################################################## |
---|
| 435 | |
---|
| 436 | \rm tmp ; touch tmp |
---|
| 437 | \rm tmp90 ; touch tmp90 |
---|
| 438 | foreach i ( $optim90 ) |
---|
| 439 | echo $i | sed -e 's/\"//g' -e "s/\'//g" -e 's/-//g' -e 's/://g' -e 's/=//g' -e 's/%//g' >> tmp |
---|
| 440 | end |
---|
| 441 | set suf= |
---|
| 442 | foreach i ( `sort tmp | uniq ` ) |
---|
| 443 | set suf=$suf$i |
---|
| 444 | end |
---|
| 445 | if ( ! $IBM ) then |
---|
| 446 | set nomlib="$nomlib$suf" |
---|
| 447 | endif |
---|
| 448 | if ( $DEC ) then |
---|
| 449 | set nomlib=DEC |
---|
| 450 | endif |
---|
| 451 | |
---|
| 452 | # dimension |
---|
| 453 | |
---|
| 454 | echo "dimension avant sed $dim" |
---|
| 455 | if ( $IBM ) then |
---|
| 456 | set dim=`echo $dim | sed -en 's/[^0-9]/ /g'` |
---|
| 457 | set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'` |
---|
| 458 | else if ( $SUN || $XNEC ) then |
---|
| 459 | set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
| 460 | set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'` |
---|
| 461 | else |
---|
| 462 | # set dim=`echo $dim | sed -n -e 's/[^0-9]/ /gp'` |
---|
| 463 | # set dim_=`echo $dim | sed -n -e 's/[^0-9]/_/gp'` |
---|
| 464 | set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
| 465 | set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'` |
---|
| 466 | endif |
---|
| 467 | |
---|
| 468 | # build final name of libraries directory: |
---|
| 469 | if ( "$dyntype" == "olddyn" ) then |
---|
[148] | 470 | set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille}_olddyn |
---|
[38] | 471 | else |
---|
[148] | 472 | set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille} |
---|
[38] | 473 | endif |
---|
| 474 | |
---|
| 475 | # Append 'physique' type, if it is not mars, to nomlib |
---|
| 476 | if ( "$physique" != "mars" ) then |
---|
| 477 | set nomlib=${nomlib}_${physique} |
---|
| 478 | endif |
---|
| 479 | |
---|
| 480 | ## M-A-F nomlib trop long sur CRAY pour ar |
---|
| 481 | if ( $CRAY ) then |
---|
| 482 | set nomlib=F90_${dim_}_t${ntrac} |
---|
| 483 | endif |
---|
| 484 | if ( $NEC || $XNEC ) then |
---|
| 485 | set nomlib=F90_${dim_}_t${ntrac} |
---|
| 486 | endif |
---|
| 487 | |
---|
| 488 | echo "calcul de la dimension" |
---|
| 489 | set dimc=`echo $dim | wc -w` |
---|
| 490 | |
---|
| 491 | if ( "$dimc" == "2" ) then |
---|
| 492 | set include="$include "'-I$(LIBF)/dyn2d ' |
---|
| 493 | set dimh=$dim |
---|
| 494 | else |
---|
| 495 | if ( "$dyntype" == "olddyn" ) then |
---|
| 496 | set include="$include "'-I$(LIBF)/olddyn3d ' |
---|
| 497 | else |
---|
| 498 | set include="$include "'-I$(LIBF)/dyn3d ' |
---|
| 499 | endif |
---|
| 500 | set dimh=`echo $dim | awk ' { print $1 "." $2 } '` |
---|
| 501 | endif |
---|
| 502 | echo "dimc is $dimc" |
---|
| 503 | |
---|
| 504 | ######################################################################## |
---|
| 505 | # path pour les #include |
---|
| 506 | ######################################################################## |
---|
| 507 | |
---|
| 508 | set include="$include -I$NCDFINC " |
---|
| 509 | echo $include |
---|
| 510 | |
---|
| 511 | ######################################################################## |
---|
| 512 | # Gestion des dimensions du modele. |
---|
| 513 | # on cree ou remplace le fichier des dimensions/nombre de traceur |
---|
| 514 | ######################################################################## |
---|
| 515 | |
---|
| 516 | cd $libf/grid |
---|
| 517 | if ( -f dimensions.h ) then |
---|
[148] | 518 | echo "WARNING: you are probably already compiling the model (perhaps" |
---|
| 519 | echo " elsewhere). Wait until the first compilation ends before " |
---|
| 520 | echo " compiling a different configuration." |
---|
| 521 | echo "If you are sure that you are not already compiling, then you" |
---|
| 522 | echo " may continue this compilation by answering yes." |
---|
| 523 | echo "Do you want to continue?" |
---|
| 524 | if ( $< == "yes" ) then |
---|
[38] | 525 | #remove old dimensions.h file |
---|
| 526 | \rm -f $libf/grid/dimensions.h |
---|
[148] | 527 | #remove old scatterers.h file |
---|
[882] | 528 | \rm -f $libf/phy$physique/scatterers.h |
---|
[38] | 529 | else |
---|
| 530 | exit |
---|
| 531 | endif |
---|
| 532 | endif |
---|
| 533 | |
---|
| 534 | # Build the appropriate 'dimensions.h' file |
---|
| 535 | cd dimension |
---|
[1036] | 536 | ./makdim $dim |
---|
[38] | 537 | # echo contents of dimensions.h to standard output |
---|
| 538 | cat $libf/grid/dimensions.h |
---|
| 539 | |
---|
[882] | 540 | cd $libf/phy$physique/scatterers |
---|
[148] | 541 | # Build the appropriate 'scatterers.h' file |
---|
| 542 | ./make_scatterers $scatterers |
---|
| 543 | # echo contents of scatterers.h to standard output |
---|
[882] | 544 | cat $libf/phy$physique/scatterers.h |
---|
[148] | 545 | |
---|
[38] | 546 | cd $LMDGCM |
---|
| 547 | # set path to objects directory |
---|
| 548 | set libo=$libo/$nomlib |
---|
| 549 | # create objects directory, if it doesn't exist |
---|
| 550 | if ( ! -d $libo ) then |
---|
| 551 | mkdir $libo |
---|
| 552 | cd $model |
---|
| 553 | endif |
---|
| 554 | |
---|
| 555 | ######################################################################## |
---|
| 556 | # Differentes dynamiques (3d, 2d, 1d) |
---|
| 557 | ######################################################################## |
---|
| 558 | |
---|
| 559 | set dimension=`echo $dim | wc -w` |
---|
| 560 | echo dimension $dimension dim $dim |
---|
| 561 | if ( $dimension == 1 ) then |
---|
[1036] | 562 | echo "No dynamics" |
---|
| 563 | ## set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique " |
---|
| 564 | ## NB: we still need to have L_DYN=libdyn3d to reach routines and module |
---|
| 565 | ## objects which are located in dyn3d |
---|
| 566 | set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique " |
---|
[38] | 567 | endif |
---|
| 568 | endif |
---|
| 569 | |
---|
| 570 | cd $model |
---|
| 571 | if ( $dimension == 3 ) then |
---|
| 572 | cd libf/grid |
---|
| 573 | \rm fxyprim.h |
---|
| 574 | cp -p fxy_${grille}.h fxyprim.h |
---|
| 575 | endif |
---|
| 576 | |
---|
| 577 | ###################################################################### |
---|
| 578 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
---|
| 579 | ###################################################################### |
---|
| 580 | |
---|
| 581 | if ( -f $libf/phy$physique/raddim.h ) then |
---|
| 582 | if ( -f $libf/phy$physique/raddim.$dimh.h ) then |
---|
| 583 | \rm $libf/phy$physique/raddim.h |
---|
| 584 | cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
---|
| 585 | echo $libf/phy$physique/raddim.$dimh.h |
---|
| 586 | cat $libf/phy$physique/raddim.$dimh.h |
---|
| 587 | cat $libf/phy$physique/raddim.h |
---|
| 588 | else |
---|
| 589 | echo On peut diminuer la taille de l executable en creant |
---|
| 590 | echo le fichier $libf/phy$physique/raddim.$dimh.h |
---|
| 591 | \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
---|
| 592 | endif |
---|
| 593 | endif |
---|
| 594 | |
---|
| 595 | ###################################################################### |
---|
| 596 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
| 597 | ###################################################################### |
---|
| 598 | |
---|
| 599 | # set filtre to 'oldfiltrez' if using -olddyn option |
---|
| 600 | if ( "$dyntype" == "olddyn" ) then |
---|
| 601 | set filtre="oldfiltrez" |
---|
| 602 | endif |
---|
| 603 | |
---|
| 604 | if ( `expr $dimc \> 2` == 1 ) then |
---|
| 605 | set filtre="FILTRE=$filtre" |
---|
| 606 | else |
---|
| 607 | set filtre="FILTRE= L_FILTRE= " |
---|
| 608 | endif |
---|
| 609 | echo "MACRO FILTRE $filtre" |
---|
| 610 | |
---|
| 611 | echo "dimc $dimc" |
---|
| 612 | |
---|
[1085] | 613 | #cleanup for a full recompilation, if requested |
---|
| 614 | if ("$full" == "full") then |
---|
| 615 | # remove makefile and $libo |
---|
| 616 | cd $model |
---|
| 617 | \rm -f makefile |
---|
| 618 | \rm -rf $libo/* |
---|
| 619 | endif |
---|
| 620 | |
---|
[38] | 621 | ######################################################################## |
---|
| 622 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
| 623 | ######################################################################## |
---|
| 624 | # c'est a dire dans 3 cas: |
---|
| 625 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
| 626 | # derniere creation du makefile |
---|
| 627 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
| 628 | # n'existe pas. |
---|
| 629 | # 3. Si le makefile n'existe pas. |
---|
| 630 | ######################################################################## |
---|
| 631 | |
---|
| 632 | cd $model |
---|
[646] | 633 | find libf -name '*.[Fh]' -print | sort >! tmp77 |
---|
[38] | 634 | #find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90 |
---|
[646] | 635 | find libf -name '*.[Fh]90' -print | sort >> tmp90 |
---|
[38] | 636 | |
---|
| 637 | if ( `diff tmp77 liste_des_sources_f77 | wc -w` \ |
---|
| 638 | || `diff tmp90 liste_des_sources_f90 | wc -w` \ |
---|
| 639 | || ! -f makefile \ |
---|
| 640 | || ! -f liste_des_sources_f90 \ |
---|
| 641 | || ! -f liste_des_sources_f77 ) then |
---|
| 642 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
| 643 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
| 644 | diff liste_des_sources_f77 tmp77 |
---|
| 645 | diff liste_des_sources_f90 tmp90 |
---|
| 646 | \cp tmp77 liste_des_sources_f77 |
---|
| 647 | \cp tmp90 liste_des_sources_f90 |
---|
| 648 | echo "On recree le makefile" |
---|
| 649 | if ("$dyntype" == "olddyn") then |
---|
| 650 | ./create_make_gcm olddyn3d grid bibio aeronomars phy$physique >! tmp |
---|
| 651 | else |
---|
| 652 | ./create_make_gcm dyn3d grid bibio aeronomars phy$physique >! tmp |
---|
| 653 | endif |
---|
| 654 | \mv tmp makefile |
---|
| 655 | echo "Nouveau makefile cree." |
---|
| 656 | endif |
---|
| 657 | |
---|
| 658 | ######################################################################## |
---|
| 659 | # Execution de la comande make |
---|
| 660 | ######################################################################## |
---|
| 661 | |
---|
| 662 | echo PHYSIQUE $phys |
---|
| 663 | echo dynamique $dyn $dimension |
---|
| 664 | echo OPTIM90="$optim90" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code |
---|
| 665 | echo PATH pour les fichiers INCLUDE $include |
---|
| 666 | echo OPLINK="$oplink" |
---|
| 667 | |
---|
| 668 | if $HP then |
---|
| 669 | set f77='fort77 +OP' |
---|
| 670 | set f90='jensaisrien' |
---|
| 671 | set opt_link="$opt_link -lm" |
---|
| 672 | else if $VPP then |
---|
| 673 | set f77=frt |
---|
| 674 | set f90=$f77 |
---|
| 675 | else if $CRAY then |
---|
| 676 | set f77=f90 |
---|
| 677 | set f90=f90 |
---|
| 678 | else if $LINUX then |
---|
| 679 | # set f77=pgf90 |
---|
| 680 | # set f90=pgf90 |
---|
| 681 | set f77=gfortran |
---|
| 682 | set f90=gfortran |
---|
| 683 | else if $SUN then |
---|
| 684 | set f77=f90 |
---|
| 685 | set f90=f90 |
---|
| 686 | else if $NEC then |
---|
| 687 | set f77=f90 |
---|
| 688 | set f90=f90 |
---|
| 689 | else if $XNEC then |
---|
| 690 | set f77=sxmpif90 |
---|
| 691 | set f90=sxmpif90 |
---|
| 692 | else |
---|
| 693 | set f77=f77 |
---|
| 694 | set f90=f90 |
---|
| 695 | endif |
---|
| 696 | |
---|
| 697 | cd $model |
---|
| 698 | |
---|
| 699 | if $VPP then |
---|
| 700 | set make="gmake RANLIB=ls" |
---|
| 701 | else if $CRAY then |
---|
| 702 | set make="make RANLIB=ls" |
---|
| 703 | else if $NEC then |
---|
| 704 | set make="make RANLIB=ls" |
---|
| 705 | else if $LINUX then |
---|
| 706 | set make="make -k RANLIB=ranlib" |
---|
| 707 | else if $XNEC then |
---|
| 708 | set make="/usr/local/bin/gmake RANLIB=ls" |
---|
| 709 | set make="/usr/freeware/bin/gmake RANLIB=ls" |
---|
| 710 | else |
---|
| 711 | set make="make RANLIB=ranlib" |
---|
| 712 | endif |
---|
| 713 | |
---|
| 714 | set include="$include"" -I$libf/phy$physique" |
---|
| 715 | |
---|
| 716 | |
---|
| 717 | ################################################################# |
---|
| 718 | # Execution de la comande make... ENFIN! |
---|
| 719 | ################################################################# |
---|
| 720 | |
---|
| 721 | if $VPP then |
---|
| 722 | set optim90=" $optim90 -Am -M$libo" |
---|
| 723 | set optimtru90="$optim90" |
---|
| 724 | else if $SUN then |
---|
| 725 | set optim90=" $optim90 -M$libo" |
---|
| 726 | set optimtru90=" $optimtru90 " |
---|
| 727 | else if $NEC then |
---|
| 728 | set optim90=" $optim90 -I$libo " |
---|
| 729 | else if $XNEC then |
---|
| 730 | set optim90=" $optim90 -I$libo " |
---|
| 731 | set optimtru90=" $optimtru90 -I$libo " |
---|
| 732 | else if $LINUX then |
---|
| 733 | # Ehouarn : adapt to gfortran |
---|
| 734 | set optim="$optim -I${libo}" |
---|
| 735 | set optim90="$optim90 -I${libo}" |
---|
| 736 | set optimtru90="$optimtru90 -ffree-form -I${libo}" |
---|
| 737 | # Ehouarn: remove set mod_loc_dir def below; mod_loc_dir=$localdir (set above) |
---|
| 738 | # set mod_loc_dir=$libo |
---|
| 739 | endif |
---|
| 740 | |
---|
| 741 | set link="$f90 $optim90" |
---|
| 742 | |
---|
| 743 | set ar=ar |
---|
| 744 | |
---|
| 745 | if $XNEC then |
---|
| 746 | set link="sxld $opt_link" |
---|
| 747 | set link="$f90 " |
---|
| 748 | # set ar=sxar |
---|
| 749 | endif |
---|
| 750 | |
---|
| 751 | |
---|
| 752 | cd $localdir |
---|
| 753 | |
---|
[519] | 754 | ## locate main program (could be in dyn3d or phy$physique |
---|
| 755 | ## and could be .F or .F90) |
---|
| 756 | set source_code=${code}.F |
---|
| 757 | if ( -f $LMDGCM/libf/dyn3d/${code}.F90 ) then |
---|
| 758 | set source_code=${code}.F90 |
---|
| 759 | endif |
---|
| 760 | if ( -f $LMDGCM/libf/phy${physique}/${code}.F ) then |
---|
| 761 | set source_code=${code}.F |
---|
| 762 | endif |
---|
| 763 | if ( -f $LMDGCM/libf/phy${physique}/${code}.F90 ) then |
---|
| 764 | set source_code=${code}.F90 |
---|
| 765 | endif |
---|
| 766 | |
---|
| 767 | ## locate directory where main program is located |
---|
| 768 | if ( $dimension == 3 ) then |
---|
| 769 | if ( -f $LMDGCM/libf/dyn3d/${source_code} ) then |
---|
| 770 | set dyn="DIRMAIN=dyn3d " |
---|
| 771 | endif |
---|
| 772 | if ( -f $LMDGCM/libf/phy${physique}/${source_code} ) then |
---|
| 773 | set dyn="DIRMAIN=phy${physique} " |
---|
| 774 | endif |
---|
| 775 | endif |
---|
| 776 | |
---|
[38] | 777 | echo $make -f $LMDGCM/makefile \ |
---|
| 778 | OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \ |
---|
| 779 | OPTIM="$optim" \ |
---|
| 780 | OPTIM90="$optim90" \ |
---|
| 781 | OPTIMTRU90="$optimtru90" \ |
---|
| 782 | INCLUDE="$include" \ |
---|
| 783 | $filtre \ |
---|
| 784 | LIBO=$libo \ |
---|
| 785 | $dyn \ |
---|
| 786 | $phys \ |
---|
| 787 | DIM=$dimc \ |
---|
| 788 | DYNTYPE="$dyntype" \ |
---|
| 789 | L_ADJNT="$adjnt" \ |
---|
| 790 | LOCAL_DIR="$localdir" \ |
---|
| 791 | F77="$f77" \ |
---|
| 792 | F90="$f90" \ |
---|
| 793 | OPLINK="$oplink" \ |
---|
| 794 | LINK="$link" \ |
---|
| 795 | GCM="$LMDGCM" \ |
---|
| 796 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
| 797 | MOD_SUFFIX=$mod_suffix \ |
---|
| 798 | AR=$ar \ |
---|
[519] | 799 | SOURCE=$source_code \ |
---|
[38] | 800 | PROG=$code |
---|
| 801 | |
---|
| 802 | |
---|
| 803 | $make -f $LMDGCM/makefile \ |
---|
| 804 | OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \ |
---|
| 805 | OPTIM="$optim" \ |
---|
| 806 | OPTIM90="$optim90" \ |
---|
| 807 | OPTIMTRU90="$optimtru90" \ |
---|
| 808 | INCLUDE="$include" \ |
---|
| 809 | $filtre \ |
---|
| 810 | LIBO=$libo \ |
---|
| 811 | $dyn \ |
---|
| 812 | $phys \ |
---|
| 813 | DIM=$dimc \ |
---|
| 814 | DYNTYPE="$dyntype" \ |
---|
| 815 | L_ADJNT="$adjnt" \ |
---|
| 816 | LOCAL_DIR="$localdir" \ |
---|
| 817 | F77="$f77" \ |
---|
| 818 | F90="$f90" \ |
---|
| 819 | OPLINK="$oplink" \ |
---|
| 820 | LINK="$link" \ |
---|
| 821 | GCM="$LMDGCM" \ |
---|
| 822 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
| 823 | MOD_SUFFIX=$mod_suffix \ |
---|
| 824 | AR=$ar \ |
---|
[519] | 825 | SOURCE=$source_code \ |
---|
[38] | 826 | PROG=$code |
---|
| 827 | |
---|
[148] | 828 | # cleanup, remove dimensions.h and scatterers.h |
---|
| 829 | \rm -f $libf/grid/dimensions.h |
---|
[882] | 830 | \rm -f $libf/phy$physique/scatterers.h |
---|