source: trunk/LMDZ.MARS/makegcm_ifort @ 1500

Last change on this file since 1500 was 1499, checked in by emillour, 9 years ago

Mars GCM:

  • Added option "-cpp" so that users can add the definition of specific precompiling flags in makegcm_* scripts (and added default BLAS and LAPACK flags for ifort on Gnome and Ada).
  • Put calls to dgesv (Lapack) routine in photochemistry_asis.F90 under the LAPACK preprocessing flag. Moved secondary routines in photochemistry.F and photochemistry_asis.F90 into the main (via contains instruction) to avoid multiple definitions of routines with identical names.

EM

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