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