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