source: LMDZ5/trunk/makegcm @ 1615

Last change on this file since 1615 was 1615, checked in by Ehouarn Millour, 12 years ago

Introducing "phydev", the minimal physics package.
makegcm and makelmdz_fcm script have been updated to add CPP_PHYS preprocessing key when building with physics and CPP_EARTH for Earth (LMD physics) related routines or instructions in the dynamics.
Checked (on Vargas) that "dev" physics package compiles and runs well in all (seq/mpi/omp/mpi_omp) modes and that introduced changes do not modify results when using the "lmd" physics package.
EM + FH

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 33.2 KB
Line 
1#!/bin/csh
2#
3# $Id: makegcm 1615 2012-02-10 15:42:26Z emillour $
4#
5#set verbose echo
6########################################################################
7# options par defaut pour la commande make
8########################################################################
9set dim="96x71x19"
10set physique=lmd
11set phys="PHYS=$physique"
12set include='-I$(LIBF)/grid -I$(LIBF)/bibio -I$(LIBF)/filtrez -I. '
13set filtre=filtrez
14set grille=reg
15set couple=false
16set veget=false
17set chimie=false
18set psmile=true
19set parallel=false
20set vampir=false
21set OPT_STACK='-Wf,-init stack=nan'
22set OPT_STACK=' '
23set OPTIMI='-C debug -eC '
24set OPTIMI=' -ftrace '
25set OPT_LINUX="-O3 -fdefault-real-8"
26set OPT_LINUX="-O3 -fdefault-real-8"
27set io=ioipsl
28set cosp=false
29
30set FC_LINUX=g95
31set FC_LINUX=gfortran
32#set FC_LINUX=pgf90
33if ( $FC_LINUX == g95 ) then
34  set OPT_LINUX="-O3"
35else if ( $FC_LINUX == gfortran ) then
36  set OPT_LINUX="-fdefault-real-8 -O3"
37#   set OPT_LINUX="-O3 -fno-second-underscore"
38  set OPT_LINUX="-O3 "
39else
40# pgf90 options
41  set OPT_LINUX="-i4 -r8 -O2 -Munroll -Mnoframe -Mautoinline -Mcache_align"
42endif
43
44########################################################################
45# path a changer contenant les sources et les objets du modele
46########################################################################
47
48###### VERSION LMDZ.4
49set INCALIB=../INCA3/config/lib
50set LMDGCM="`pwd`"
51setenv LIBOGCM $LMDGCM/libo
52#
53#
54setenv IOIPSLDIR /d4/fairhead/LMDZ20100928.trunk/modipsl/lib
55setenv MODIPSLDIR /d4/fairhead/LMDZ20100928.trunk/modipsl/lib
56setenv NCDFINC /d4/fairhead/LMDZ20100928.trunk/netcdf-4.0.1/include
57setenv NCDFLIB /d4/fairhead/LMDZ20100928.trunk/netcdf-4.0.1/lib
58
59
60
61
62
63setenv localdir "`pwd`"
64set MODIPSL=0
65echo $localdir | grep modipsl >& /dev/null
66if ( ! $status ) then
67  set MODIPSL=1
68  setenv LMDGCM $localdir
69  cd ../..
70  setenv LIBOGCM "`pwd`/lib"
71  setenv IOIPSLDIR $LIBOGCM
72  setenv MODIPSLDIR $LIBOGCM
73  cd $localdir
74  if ( `hostname` == rhodes ) then
75    set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
76    set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
77  else
78    if ( `hostname` == nymphea0 ) then
79      set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
80      set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
81    else if ( `hostname` == mercure ) then
82      set NCDFINC=`grep sx6nec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
83      set NCDFLIB=`grep sx6nec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
84    else  if ( `hostname` == brodie ) then
85      set NCDFINC=`grep sx8brodie ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
86      set NCDFLIB=`grep sx8brodie ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
87    else
88      echo 'Probleme de definition des variables NCDFINC et NCDFLIB'
89    endif
90  endif
91else
92  if ( ! $?LMDGCM ) then
93    echo You must initialize the variable LMDGCM in your environnement
94    echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc
95    exit
96  endif
97  if ( ! $?LIBOGCM ) then
98    set LIBOGCM=$LMDGCM/libo
99  endif
100  if ( ! $?IOIPSLDIR ) then
101    echo You must initialize the variable IOIPSLDIR in your environnement
102    echo for instance: "setenv IOIPSLDIR /usr/myself/ioipsl" in .cshrc
103    exit
104  else
105      setenv MODIPSLDIR $IOIPSLDIR
106  endif
107  if ( ! $?NCDFLIB ) then
108    echo You must initialize the variable NCDFLIB in your environnement
109    echo for instance: "setenv NCDFLIB /d4/fairhead/LMDZ20100928.trunk/netcdf-4.0.1/lib
110    exit
111  endif
112  if ( ! $?NCDFINC ) then
113    echo You must initialize the variable NCDFINC in your environnement
114    echo for instance: "setenv NCDFINC /d4/fairhead/LMDZ20100928.trunk/netcdf-4.0.1/include
115    exit
116  endif
117endif
118set model=$LMDGCM
119set libo=$LIBOGCM
120
121########################################################################
122#  Les differentes platformes reconnues
123########################################################################
124
125set HP=0
126set IBM=0
127set SUN=0
128set VPP=0
129set CRAY=0
130set DEC=0
131set LINUX=0
132set NEC=0
133set XNEC=0
134set X6NEC=0
135set X8BRODIE=0
136if ( `uname` == HP-UX ) then
137   set machine=HP
138   set HP=1
139else if (`uname` == UNIX_System_V ) then
140   set machine=VPP
141   set VPP=1
142else if (`uname` == SunOS ) then
143   set machine=SUN
144   set SUN=1
145else if ( `uname` == AIX ) then
146   set machine=IBM
147   set IBM=1
148else if ( `uname` == OSF1 ) then
149   set machine=ALPHA
150   set DEC=1
151else if ( `uname` == Linux && `hostname` != mercure  && `hostname` != brodie ) then
152   set machine=LINUX
153   set LINUX=1
154else if ( `hostname` == atlas || `hostname` == axis  || `hostname` == etoile ) then
155   set machine=CRAY
156   set CRAY=1
157else if ( `uname` == SUPER-UX ) then
158   set machine=NEC
159   set NEC=1
160else if ( `hostname` == rhodes) then
161   set machine=XNEC
162   set XNEC=1
163else if ( `hostname` == mercure) then
164   set machine=X6NEC
165   set X6NEC=1
166else if ( `hostname` == brodie) then
167   set machine=X8BRODIE
168   set X8BRODIE=1
169else
170   echo Vous travaillez sur une machine non prevue par le reglement
171   exit
172endif
173
174if ( ! -d $libo )  then
175   mkdir $libo
176endif
177
178
179if $VPP then
180set netcdf=netcdf_v
181else
182set netcdf=netcdf
183endif
184########################################################################
185#  Quelques initialisations de variables du shell.
186########################################################################
187
188set dyn=
189set opt_link=""
190set adjnt=""
191set lcosp=""
192set opt_dep=""
193set libchimie=""
194
195set optim=""
196set optimbis=""
197set optim90=""
198set oplink=""
199
200########################################################################
201#  Optimisations par defaut suivant les machines
202########################################################################
203
204echo "Optimisations par defaut suivant les machines"
205set libf=$model/libf
206#setenv localdir "LOCAL_DIR=`pwd`"
207#setenv localdir "`pwd`"
208cd $model
209#############
210if $CRAY then
211#############
212#   set optim="-Wf'-ei' -dp -Wf'-a static'"
213   set optimbis=" -DCRAY "
214   set optim90="-Wp'-P' -DCRAY -p$IOIPSLDIR "'-p$(LIBO) -eiv '
215   set optim="$optim90"
216   if ( $io == "ioipsl" ) then
217     set oplink="-Wl'-DSTACK=128 -f indef' -L$IOIPSLDIR -lioipsl  -L$NCDFLIB -lnetcdf "
218   else
219     set oplink="-Wl'-DSTACK=128 -f indef' -L$IOIPSLDIR -L$NCDFLIB -lnetcdf "
220   endif
221   set mod_loc_dir=" "
222   set mod_suffix=" "
223#################
224else if $SUN then
225#################
226   set optim=" -fast "
227   set optimbis=" "
228   set optim90=" -fast -fixed "
229   set optimtru90=" -fast -free "
230   if ( $io == "ioipsl" ) then
231     set opt_link="-lf77compat -L$MODIPSLDIR -lsechiba -lparameters -lstomate -lioipsl -L$NCDFLIB -lnetcdf "
232   else
233     set opt_link="-lf77compat -L$MODIPSLDIR -lsechiba -lparameters -lstomate -L$NCDFLIB -lnetcdf "
234   endif
235   set mod_loc_dir=$localdir
236   set mod_suffix=mod
237#################
238else if $HP then
239#################
240   set optim=" +U77 -O +E1 "
241   set optimbis=" "
242#################
243else if $IBM then
244#################
245   set optim=" -O3 -qtune=pwr2 -qarch=pwr2"
246   set optimbis=" "
247#################
248else if $VPP then
249#################
250#   set optim="-Dasuxm  -On, -g -Ad -Potilax -Eciplume -Si"
251#   set optimbis="  -Wv,-m3 -Wp,-DVPP -Z $LMDGCM/listage"
252   set optimbis=" -Wp,-DNC_DOUBLE -Ad -Z $LMDGCM/listage -X9"
253   set optim90="$optim $optimbis -X9 -w"
254   set mod_loc_dir=$MODIPSLDIR
255   set mod_suffix=mod
256#################
257else if $DEC then
258#################
259   set optim=" "
260   set optimbis=" "
261#################
262else if $LINUX then
263#################
264   if ( $FC_LINUX == pgf90 || $FC_LINUX == g95 || $FC_LINUX == gfortran ) then
265     set optim=" $OPT_LINUX "
266     set optim90=" $OPT_LINUX "
267     set optimtru90=" $OPT_LINUX "
268   else
269     echo 'compilateur linux non reconnu'
270     exit
271   endif
272   set mod_loc_dir=$MODIPSLDIR
273   set mod_suffix=mod
274#################
275else if $NEC then
276#################
277   set optim90=' -clear -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
278   set optimtru90=' -clear -f4 -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
279   set optim="$optim90"
280   set optimbis=" "
281   if ( $io == "ioipsl" ) then
282     set opt_link=" -C hopt -float0 -ew -P static -L$MODIPSLDIR -lioipsl  $NCDFLIB -lnetcdf_i8r8_v "
283   else
284     set opt_link=" -C hopt -float0 -ew -P static -L$MODIPSLDIR $NCDFLIB -lnetcdf_i8r8_v "
285   endif
286   set mod_loc_dir="."
287   set mod_suffix="mod"
288#################
289else if $XNEC then
290#################
291   set optdbl='-dw -Wf\"-A dbl4\"'
292   set optim90=' -clear -float0 -f3 -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
293   set optimtru90=' -clear -f4 -float0 -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R2 -R3 -R4 -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume"'
294   set optim="$optim90"
295   set optimbis=" "
296   set mod_suffix="mod"
297   set mod_loc_dir="./"
298#################
299else if $X6NEC then
300#################
301   set optdbl='-dw -Wf\"-A dbl4\"' 
302   set optim90=' -clear -float0 -size_t64 -P stack -Wf "-ptr byte -init stack=nan -init heap=nan" -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
303   set optimtru90=' -clear -f4 -float0 -size_t64 -P stack -Wf "-ptr byte -init stack=nan -init heap=nan" -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R2 -R3 -R4 -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume"'
304   set optim="$optim90"
305   set optimbis=" "
306   set mod_suffix="mod"
307   set mod_loc_dir="./"
308#################
309else if $X8BRODIE then
310##################
311   set optdbl='-dw -Wf\"-A dbl4\"' 
312#   set optim90='-P stack -Wf,-pvctl res=whole,-A dbl4,-init stack=nan,-init heap=nan,-ptr byte -EP -R5 -float0 -dw -Wf,"-pvctl loopcnt=999999 fullmsg noassume" -I/SX/usr/include'
313   set optim90='-C vopt -Wf,-pvctl res=whole,-A dbl4,-init stack=nan,-init heap=nan,-ptr byte -EP -DNC_DOUBLE -R5 -float0 -dw -Wf,"-pvctl loopcnt=999999 noassume" -I/SX/usr/include'
314#   set optim90='-C vsafe -P stack -Wf,-pvctl res=whole,-A dbl4,-ptr byte -EP -R5 -float0 -dw -Wf,"-pvctl loopcnt=999999 fullmsg noassume" -I/SX/usr/include'
315   set optimtru90="$optim90"
316   set optim90="$optim90"
317   set optim="$optim90"
318   set optimbis=" "
319   set mod_suffix="mod"
320   set mod_loc_dir="./"
321else
322   set optim=""
323   set optimbis=" "
324endif
325
326set nomlib=$machine
327
328########################################################################
329# lecture des options de mymake
330########################################################################
331
332top:
333if ($#argv > 0) then
334    switch ($1:q)
335
336    case -h:
337
338########################################################################
339# Manuel en ligne
340########################################################################
341more <<eod
342
343
344makegcm [Options] prog
345
346
347
348
349Par default, la commande makegcm:
350---------------------------------
351
3521. compile une serie de sous programmes se trouvant dans des sous-repertoires
353de $LMDGCM/libf.
354Les sous programmes sont ensuite stokes sur dans des librairies FORTRAN
355sur $LIBOGCM.
356
3572. Ensuite, makegcm compile le programme prog.f se trouvant par default sur
358$LMDGCM/libf/dyn3d et effectue le lien avec l ensemble des librairies.
359
360La variable '$LMDGCM' doit etre initialisee dans votre .cshrc ou en dur
361dans la comande makegcm.
362
363La commande makegcm est faite pour permettre de gerer en parallele des
364versions differentes du modele, compilees avec des options de compilation
365et des dimensions differentes sans avoir a chaque fois a recompiler tout
366le modele.
367
368Les librairies FORTRAN sont stoquees sur le directory $LIBOGCM.
369
370
371OPTIONS:
372--------
373
374Les options suivantes peuvent etre definies soit par defaut en editant le
375"script" makegcm, soit en interactif:
376
377-d imxjmxlm  ou im, jm, et lm sont resp. le nombre de longitudes, latitudes
378             et couches verticales.
379             L'effet des options -d est d'ecraser le fichier
380             $LMDGCM/libf/grid/dimensions.h
381             qui contient sous forme de 3 PARAMETER FORTRAN les 3 dimensions
382             de la grille horizontale im, jm et verticale lm, par un nouveu fichier
383             $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm
384             Si ce fichier n'existe pas encore, il est cree par le script
385             $LMDGCM/libf/grid/dimension/makdim
386
387-p PHYS    pour selectionner le jeu de parametrisations physiques avec
388           lequel on veut compiler le modele.
389           Le modele sera alors compile en prenant les sources des
390           parametrisations physiques dans le repertoire:
391            $LMDGCM/libf/phyPHYS
392
393-c false|true
394           pour selectionner le mode force (par defaut) ou couple
395
396-io ioipsl|noioipsl
397           pour selectionner le logiciel IO : IOIPSL par defaut
398
399-psmile false|true
400           pour selectionner le mode psmile ou non (par defaut)
401
402-parallel  false|true
403           pour selectionner le mode parallele ou non (false par defaut)
404
405-v true|false
406           pour selectionner la vegetation (par defaut) ou non
407
408-chimie INCA|false
409           pour selectionner ou non la chimie (par defaut sans)
410
411-g grille  selectionne le type de grille qu'on veut utiliser.
412           L'effet de cette option est d'ecraser le fichier
413           $LMDGCM/libf/grid/fxyprim.h
414           avec le fichier
415           $LMDGCM/libf/grid/fxy_grille.h
416           grille peut prendre les valeurs:
417           1. reg pour la grille reguliere
418           2. sin pour avoir des points equidistants en sinus de la latitude
419           3. new pour pouvoir zoomer sur une partie du globe
420
421-O "optimisation fortran" ou les optimisations fortran sont les options de la
422            commande f77
423
424-include path
425           Dans le cas ou on a dans des sous programmes des fichiers
426           #include (cpp) qui se trouve sur des repertoires non references
427           par defaut
428
429-adjnt     Pour compiler la l'adjoint du code dynamique
430
431-cosp true|false     
432           Pour compiler avec cosp
433
434-filtre  filtre
435           Pour choisir le filtre en longitude dans les regions polaires.
436           "filtre" correspond au nom d'un repertoire se trouvant sur
437           $LMDGCM/libf. Le filtre standard du modele est "filtrez" qui peut
438           etre utilise aussi bien pour une grille reguliere que pour une
439           grille zoomee en longitude.
440
441-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
442          Pour rajouter un lien avec les librairies FORTRAN
443          libfile1.a, libfile2.a ... se trouvant respectivement sur les
444          repertoires dir1, dir2 ...
445          Si dirn est un repertoire dont le chemin est automatique (comme
446          par exemple /usr/lib ...) il n'est pas besoin de specifier -Ldirn.
447
448Auteur: Frederic Hourdin  (hourdin@lmd.jussieu.fr)
449eod
450exit
451
452########################################################################
453# Lecture des differentes options
454########################################################################
455
456    case -d:
457        set dim=$2 ; shift ; shift ; goto top
458                       
459    case -O:
460        set optim="$2" ; shift ; shift ; goto top
461
462     case -p
463        set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top
464
465     case -g
466        set grille="$2" ; shift ; shift ; goto top
467
468     case -c
469        set couple="$2" ; shift ; shift ; goto top
470
471     case -io
472        set io="$2" ; shift ; shift ; goto top
473
474     case -v
475        set veget="$2" ; shift ; shift ; goto top
476
477     case -chimie
478        set chimie="$2" ; shift ; shift ; goto top
479
480     case -parallel
481        set parallel="$2" ; shift ; shift ; goto top
482 
483     case -include
484        set include="$include -I$2" ; shift ; shift ; goto top
485
486     case -adjnt
487        set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d "
488        set optim="$optim -Dadj" ; shift ; goto top
489
490     case -cosp
491        set cosp="$2"; shift ; shift ; goto top
492
493     case -filtre
494        set filtre=$2 ; shift ; shift ; goto top
495
496     case -link
497        set opt_link="$opt_link $2" ; shift ; shift ; goto top
498
499     case -debug
500        if $HP then
501           set optim=" -g "
502        else if $SUN then
503           setenv PARALLEL 2
504# Il faut rajouter l'option -dalign a -g pour pouvoir editer les liens
505# avec des programmes compiles avec -fast
506           set optim=" -g -dalign "
507           set optim90=" -fixed -g "
508           set optimtru90=" -free -g -C -dalign "
509        else if $CRAY then
510           set optim="$optim"" -g "
511           set optim90="$optim90"" -G1 "
512        else if $LINUX then
513           if ( $FC_LINUX == "pgf90" ) then
514             set optim="$optim"" -g -Mbounds -Kieee -Ktrap=fp -traceback "
515             set optim90="$optim90"" -g -Mbounds -Kieee -Ktrap=fp -traceback "
516             set optimtru90="$optimtru90"" -g -Mbounds -Kieee -Ktrap=fp -traceback "
517           else if ( $FC_LINUX == 'gfortran' ) then
518             set optim="$optim"" -g -ffpe-trap=invalid,zero,overflow -fbounds-check -Wall "
519             set optim90="$optim90"" -g -ffpe-trap=invalid,zero,overflow -fbounds-check -Wall "
520             set optimtru90="$optimtru90"" -ffpe-trap=invalid,zero,overflow -g -fbounds-check -Wall "
521           else if ( $FC_LINUX == 'g95' ) then
522             set optim="$optim"" -g -fbounds-check -freal=nan -ftrace=full -Wall "
523             set optim90="$optim90"" -g -fbounds-check -freal=nan -ftrace=full -Wall "
524             set optimtru90="$optimtru90"" -g -fbounds-check -freal=nan -ftrace=full -Wall "
525           else
526             echo 'compilateur linux non reconnu'
527             exit
528           endif
529        else
530           echo pas d option debug predefinie pour cette machine
531           exit
532        endif
533        shift ; goto top
534
535     default
536        set code="$1" ; shift ; goto top
537
538   endsw
539endif
540
541########################################################################
542# Definition des clefs CPP
543########################################################################
544
545set cppflags=''
546
547if $X8BRODIE then
548  set cppflags="$cppflags -DNC_DOUBLE -DBLAS -DSGEMV=DGEMV -DSGEMM=DGEMM"
549endif
550
551if ( $io == ioipsl ) then
552   set cppflags="$cppflags -DCPP_IOIPSL"
553endif
554
555if ( "$cosp" == 'true' ) then
556    set cppflags="$cppflags -DCPP_COSP"
557    set include="$include"' -I$(LIBF)/cosp '
558    set opt_dep="$opt_dep cosp"
559#    set lcosp="-lcosp -lphy$physique "
560     set lcosp="-lcosp "
561   if ( $XNEC || $X8BRODIE || $X6NEC) then
562#    set lcosp="-lsxcosp -lsxphy$physique "
563     set lcosp="-lsxcosp "
564   endif
565endif
566
567if ( "$physique" == 'nophys' ) then
568   set phys="L_PHY= LIBPHY="
569else
570   #We'll use some physics
571   set cppflags="$cppflags -DCPP_PHYS"
572   if ( `echo $physique | grep -i "^lmd"` != "" ) then
573     #For lmd physics, default planet type is Earth
574     set cppflags="$cppflags -DCPP_EARTH"
575   endif
576endif
577
578set link_veget=" "
579if ( "$veget" == 'true' ) then
580   set cppflags="$cppflags -DCPP_VEGET"
581#   set link_veget=" -lsechiba -lparameters -lstomate  "
582   set link_veget=" -lsechiba -lparameters -lstomate"
583   if ( $XNEC || $X8BRODIE || $X6NEC) then
584#      set link_veget=" -lsxsechiba -lsxparameters -lsxstomate -lsxorglob -lsxparallel"
585      set link_veget=" -lsxsechiba -lsxparameters -lsxstomate "
586   endif
587endif
588
589if ( "$chimie" == 'INCA' ) then
590    set cppflags="$cppflags -DINCA" 
591    set libchimie=" -L$INCALIB -lchimie"
592    set opt_link="$opt_link  -L$INCALIB -lchimie"
593endif
594   
595if ( "$couple" == 'true' ) then
596   set cppflags="$cppflags -DCPP_COUPLE"
597endif
598
599set FLAG_PARA=''
600if ( "$parallel" == 'true' ) then
601   set cppflags="$cppflags -DCPP_PARA"
602   set FLAG_PARA='par'
603endif
604
605set optim="$optim $cppflags"
606set optim90="$optim90 $cppflags"
607set optimtru90="$optimtru90 $cppflags"
608
609
610########################################################################
611# cas special sans physique
612########################################################################
613if ( "$physique" == 'nophys' ) then
614   set phys="L_PHY= LIBPHY="
615endif
616
617########################################################################
618#subtilites sur le nom de la librairie
619########################################################################
620
621\rm -f tmp ; touch tmp
622\rm -f tmp90 ; touch tmp90
623foreach i ( $optim )
624   echo $i | sed -e 's/\"//g' -e "s/\'//g" -e 's/-//g'  >> tmp
625end
626set suf=
627foreach i ( `sort tmp | uniq ` )
628   set suf=$suf$i
629end
630if ( ! $IBM ) then
631   set nomlib="$nomlib$suf"
632endif
633if ( $DEC ) then
634   set nomlib=DEC
635endif
636if ( $IBM ) then
637   set dim=`echo $dim | sed -en 's/[^0-9]/ /g'`
638   set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'`
639else if ( $SUN ) then
640   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
641   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
642else
643   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
644   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
645endif
646set nomlib=${nomlib}${physique}_${dim_}_$grille
647## M-A-F nomlib trop long sur CRAY pour ar
648if ( $CRAY ) then
649    set nomlib=F90_${dim_}
650endif
651if ( $NEC || $XNEC || $X6NEC || $X8BRODIE ) then
652    set nomlib=F90_${dim_}_'phy'${physique}${FLAG_PARA}
653endif
654echo calcul de la dimension
655set dimc=`echo $dim | wc -w`
656
657if ( "$dimc" == "2" ) then
658set include="$include "'-I$(LIBF)/dyn2d '
659set dimh=$dim
660else
661set include="$include "'-I$(LIBF)/dyn3d${FLAG_PARA} '
662set dimh=`echo $dim | awk ' { print $1 "." $2 } '`
663endif
664echo $dimc
665
666########################################################################
667# path pour les #include
668########################################################################
669
670if ( $XNEC ) then
671  set include="$include -I$NCDFINC -I$IOIPSLDIR"
672else
673  set include="$include -I$NCDFINC -I$IOIPSLDIR"
674endif
675echo $include
676
677########################################################################
678# Gestion des dimensions du modele.
679# on cree ou remplace le fichier des dimensions
680########################################################################
681
682cd $libf/grid
683if ( -f dimensions.h ) then
684echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
685echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
686echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
687echo  vous pouvez continuer en repondant oui.
688echo "Voulez-vous vraiment continuer?"
689if ( $< == "oui" ) then
690\rm -f $libf/grid/dimensions.h
691else
692exit
693endif
694endif
695
696cd dimension
697./makdim $dim
698cat $libf/grid/dimensions.h
699
700cd $LMDGCM
701set libo=$libo/$nomlib
702if ( ! -d $libo )  then
703   mkdir $libo
704   cd $model
705endif
706
707########################################################################
708# Differentes dynamiques (3d, 2d, 1d)
709########################################################################
710
711set dimension=`echo $dim | wc -w`
712echo dimension $dimension
713if ( $dimension == 1 ) then
714echo pas de dynamique
715set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
716endif
717endif
718cd $model
719if ( $dimension == 3 ) then
720cd libf/grid
721\rm fxyprim.h
722cp -p fxy_${grille}.h fxyprim.h
723endif
724
725######################################################################
726#   Traitement special pour le nouveau rayonnement de Laurent Li.
727######################################################################
728
729#if ( -f $libf/phy$physique/raddim.h ) then
730# if ( -f $libf/phy$physique/raddim.$dimh.h ) then
731#  \rm -f $libf/phy$physique/raddim.h
732#  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
733#  echo $libf/phy$physique/raddim.$dimh.h
734#  cat $libf/phy$physique/raddim.$dimh.h
735#  cat $libf/phy$physique/raddim.h
736# else
737#  echo On peut diminuer la taille de l executable en creant
738#  echo le fichier $libf/phy$physique/raddim.$dimh.h
739#  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
740# endif
741#endif
742
743######################################################################
744# Gestion du filtre qui n'existe qu'en 3d.
745######################################################################
746
747if ( `expr $dimc \> 2` == 1 ) then
748   set filtre="FILTRE=$filtre"
749else
750   set filtre="FILTRE= L_FILTRE= "
751endif
752echo MACRO FILTRE $filtre
753
754echo $dimc
755
756########################################################################
757#  Avant de lancer le make, on recree le makefile si necessaire
758########################################################################
759########################################################################
760# c'est a dire dans 3 cas:
761# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
762#    derniere creation du makefile
763# 2. si le fichier contenant cette liste "liste_des_sources"
764#    n'existe pas.
765# 3. Si le makefile n'existe pas.
766########################################################################
767##########################################
768# On adapte d'abord certains include à F90
769##########################################
770##########################################
771cd $model
772find libf -name '*.[Fh]' -print >! tmp77
773find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90
774find libf -name '*.[Fh]90' -print >> tmp90
775
776if (    `diff tmp77 liste_des_sources_f77 | wc -w` \
777     || `diff tmp90 liste_des_sources_f90 | wc -w` \
778     || ! -f makefile \
779     || ! -f liste_des_sources_f90 \
780     || ! -f liste_des_sources_f77 ) then
781        echo les fichiers suivants ont ete crees ou detruits
782        echo ou les fichiers suivants sont passes ou ne sont plus en Fortran 90
783        diff liste_des_sources_f77 tmp77
784        diff liste_des_sources_f90 tmp90
785        \cp tmp77 liste_des_sources_f77
786        \cp tmp90 liste_des_sources_f90
787        echo On recree le makefile
788        ./create_make_gcm >! tmp
789        \mv tmp makefile
790        echo Nouveau makefile cree.
791endif
792
793########################################################################
794#  Execution de la comande make
795########################################################################
796
797echo PHYSIQUE $phys
798echo dynamique $dyn $dimension
799echo OPTIM="$optim" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code
800echo PATH pour les fichiers INCLUDE $include
801echo OPLINK="$oplink"
802
803#################
804if $HP then
805#################
806   set f77='fort77 +OP'
807   set f90='jensaisrien'
808   set opt_link="$opt_link -lm"
809#################
810else  if $VPP then
811#################
812   set f77=frt
813   set f90=$f77
814   if ($couple == true) then
815     set opt_link="-Wg,-c $MODIPSLDIR/liboasis2.4_mpi2.a /usr/lang/mpi2/lib64/libmpi.a /usr/lang/mpi2/lib64/libmp.a -L$MODIPSLDIR -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a"
816     set oplink="-Wl,-t,-P,-dy "
817   else
818     set opt_link="-Wg,-c -L$MODIPSLDIR -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a"
819     set oplink="-Wl,-t,-dy "
820   endif
821   if ($veget == true) then
822     set opt_link="$opt_link $link_veget -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a"
823   endif
824#################
825else if $CRAY then
826#################
827   set f77=f90
828   set f90=f90
829#################
830else if $LINUX then
831#################
832#   set f77=pgf90
833#   set f90=pgf90
834   set f77=$FC_LINUX
835   set f90=$FC_LINUX
836   if ( $FC_LINUX == 'pgf90' ) then
837     if ( $io == "ioipsl" ) then
838       set opt_link=" -L$MODIPSLDIR $link_veget -L$NCDFLIB -lioipsl -lnetcdf "
839     else
840       set opt_link=" -L$MODIPSLDIR $link_veget -L$NCDFLIB -lnetcdf "
841     endif
842   else if ($FC_LINUX == 'g95' || $FC_LINUX == 'gfortran' ) then
843     if ( $io == "ioipsl" ) then
844       set opt_link="-L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf -lioipsl -lnetcdf "
845     else
846       set opt_link="-L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf -lnetcdf "
847     endif
848   else
849     set opt_link=" "
850   endif
851#################
852else if $SUN then
853#################
854   set f77=f90
855   set f90=f90
856   if ( $io == "ioipsl" ) then
857     set opt_link="-lf77compat -L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf "
858   else
859     set opt_link="-lf77compat -L$MODIPSLDIR $link_veget -L$NCDFLIB -lnetcdf "
860   endif
861#################
862else if $NEC then
863#################
864   set f77=f90 -ftrace
865   set f90=f90 -ftrace
866   set opt_link="-L$MODIPSLDIR"
867   if ($veget == true) then
868     set opt_link="$opt_link $link_veget"
869   endif
870   if ($couple == true) then
871     set opt_link="$opt_link -lioipsl -loasis2.4_mpi2 -float0 -ew -P static $NCDFLIB "
872   else
873     set opt_link="$opt_link -L$MODIPSLDIR -lioipsl -float0 -ew -P static $NCDFLIB "
874   endif
875   set mod_loc_dir="./"
876#################
877else if $XNEC then
878#################
879   set f77="sxmpif90 -ftrace"
880   set f90="sxmpif90 -ftrace"
881   if $MODIPSL then
882     set opt_link="-L$MODIPSLDIR"
883     if ($veget == true) then
884       set opt_link="$opt_link $link_veget"
885     endif
886     if ($couple == true) then
887       if ($psmile == true) then
888       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
889       else
890       set opt_link="$opt_link -lsxioipsl -loasis2.4_mpi2 -float0 $optdbl -P static $NCDFLIB "
891       endif
892     else
893       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
894     endif
895   else
896     if ($couple == true) then
897       set opt_link="-L$MODIPSLDIR"
898       set opt_link="$opt_link $link_veget -lsxioipsl -loasis2.4_mpi2 -float0 $optdbl -P static $NCDFLIB "
899     else
900       set opt_link=" -C hopt -float0 $optdbl -P static -L$MODIPSLDIR $link_veget -lsxioipsl $NCDFLIB "
901     endif
902   endif
903   set mod_loc_dir="./"
904##################
905else if $X6NEC then
906##################
907   set f77=sxmpif90
908   set f90=sxmpif90
909   if $MODIPSL then
910     set opt_link="$opt_link -L$MODIPSLDIR"
911     if ($veget == true) then
912       set opt_link="$opt_link $link_veget"
913     endif
914     if ($couple == true) then
915        if ($psmile == true) then
916        set opt_link="$opt_link -lsxioipsl -float0 -size_t64 $optdbl -P static $NCDFLIB "
917        else
918        set opt_link="$opt_link -lsxioipsl -loasis2.4_mpi2 -float0 -size_t64 $optdbl -P static $NCDFLIB "
919        endif
920     else
921       set opt_link="$opt_link -lsxioipsl -float0 -size_t64 $optdbl -P static $NCDFLIB "
922     endif
923   else
924#     set opt_link=" -float0 -size_t64 $optdbl -P static -L$MODIPSLDIR -lsxsechiba -lsxparameters -lsxstomate -lsxioipsl $NCDFLIB "
925     set opt_link=" $opt_link -float0 -size_t64 $optdbl -P static -L$MODIPSLDIR -lsxioipsl $NCDFLIB "
926
927   endif
928   set mod_loc_dir="./"
929##################
930else if $X8BRODIE then
931##################
932   set f77=sxmpif90
933   set f90=sxmpif90
934   if $MODIPSL then
935     set opt_link="$opt_link -float0 -Wf,-A dbl4 -L$MODIPSLDIR -lblas"
936     if ($veget == true) then
937       set opt_link="$opt_link $link_veget"
938     endif
939     if ($couple == true) then
940       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
941     else
942       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
943     endif
944   else
945#     set opt_link=" -float0 $optdbl -P static -L$MODIPSLDIR -lsxsechiba -lsxparameters -lsxstomate -lsxioipsl $NCDFLIB "
946     set opt_link=" -float0 $optdbl -P static -L$MODIPSLDIR -lsxioipsl $NCDFLIB -lblas"
947
948   endif
949   set mod_loc_dir="./"
950#################
951else
952#################
953   set f77=f77
954   set f90=f90
955endif
956
957cd $model
958
959if $VPP then
960set make="gmake RANLIB=ls"
961else if $CRAY then
962set make="make RANLIB=ls"
963else if $NEC then
964set make="make RANLIB=ls"
965else if $LINUX then
966set make="make -k RANLIB=ranlib"
967else if $XNEC then
968set make="gmake RANLIB=ls"
969else if $X6NEC then
970set make="gmake RANLIB=ls"
971else if $X8BRODIE then
972set make="gmake RANLIB=ls"
973else
974set make="make RANLIB=ranlib"
975endif
976
977
978
979
980#
981# etat0_netcdf a besoin d'info de la physique
982# A revoir
983set include="$include"' -I$(LIBF)/phy'"$physique"
984#
985# le programme principal create_limit a besoin de l'info du module
986# startvar: on met donc libo dans les include pour Nec
987set include="$include"' -I$(LIBO)'
988
989
990#################################################################
991# Execution de la comande make... ENFIN!
992#################################################################
993
994if $VPP then
995  set optim90=" $optim90 -Am -M$libo"
996  set optimtru90="$optim90"
997 \cp $IOIPSLDIR/*.mod $libo
998else if $SUN then
999 set optim90=" $optim90 -M$libo -M$MODIPSLDIR "
1000 set optimtru90=" $optimtru90 -M$libo -M$MODIPSLDIR "
1001 set optim="$optim90"
1002 \cp $IOIPSLDIR/*.mod $libo
1003else if $NEC then
1004 set optim90=" $optim90 -I$libo "
1005else if $XNEC then
1006 set optim90=" $optim90 -I$libo "
1007 set optimtru90=" $optimtru90 -I$libo "
1008else if $X6NEC then
1009 set optim90=" $optim90 -I$libo "
1010 set optimtru90=" $optimtru90 -I$libo "
1011else if $X8BRODIE then
1012 set optim90=" $optim90 -I$libo "
1013 set optimtru90=" $optimtru90 -I$libo "
1014else if $LINUX then
1015 if ( $FC_LINUX == "pgf90" ) then
1016   set optimtru90=" $optimtru90 -module $libo "
1017   set optim90=" $optim90 -module $libo "
1018 else if ( $FC_LINUX == 'g95' ) then
1019   set optimtru90=" $optimtru90 -fmod=$libo  "
1020   set optim90=" $optim90 -fmod=$libo  "
1021 else if ( $FC_LINUX == 'gfortran' ) then
1022   set optimtru90=" $optimtru90 -M $libo  "
1023   set optim90=" $optim90 -M $libo  "
1024 endif
1025 set optim="$optim90"
1026 set mod_loc_dir=$libo
1027# \cp /d3/fairhead/sechiba/ioipsl/*.mod $libo
1028# \cp $IOIPSLDIR/*.mod $libo
1029endif
1030
1031set link="$f90 $optim90"
1032
1033set ar=ar
1034
1035if $XNEC then
1036  set link="sxld $opt_link"
1037  set link="$f90 "
1038#  set ar=sxar
1039else if $X6NEC then
1040  set link="sxld $opt_link"
1041  set link="$f90 -Wl,-hlib_cyclic "
1042#  set ar=sxar
1043else if $X8BRODIE then
1044  set link="sxld $opt_link"
1045  set link="$f90 -Wl,-hlib_cyclic "
1046#  set ar=sxar
1047endif
1048
1049
1050cd $localdir
1051
1052set source_code=${code}.F
1053if ( -f $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ) then
1054  set source_code=${code}.F90
1055endif
1056
1057echo $make -f $LMDGCM/makefile \
1058OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
1059OPTIM90="$optim90" \
1060OPTIMTRU90="$optimtru90" \
1061OPTIM="$optim$optimbis" \
1062INCLUDE="$include" \
1063$filtre \
1064LIBO=$libo \
1065$dyn \
1066$phys \
1067DIM=$dimc \
1068FLAG_PARA="$FLAG_PARA"\
1069L_ADJNT="$adjnt" \
1070L_COSP="$lcosp" \
1071L_CHIMIE="$libchimie" \
1072LOCAL_DIR="$localdir"  \
1073F77="$f77" \
1074F90="$f90" \
1075OPLINK="$oplink" \
1076LINK="$link" \
1077GCM="$LMDGCM" \
1078MOD_LOC_DIR=$mod_loc_dir \
1079MOD_SUFFIX=$mod_suffix \
1080AR=$ar \
1081SOURCE=$source_code \
1082PROG=$code
1083
1084$make -f $LMDGCM/makefile \
1085OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
1086OPTIM90="$optim90" \
1087OPTIMTRU90="$optimtru90" \
1088OPTIM="$optim$optimbis" \
1089INCLUDE="$include" \
1090$filtre \
1091LIBO=$libo \
1092$dyn \
1093$phys \
1094DIM=$dimc \
1095FLAG_PARA="$FLAG_PARA"\
1096L_ADJNT="$adjnt" \
1097L_COSP="$lcosp" \
1098L_CHIMIE="$libchimie" \
1099LOCAL_DIR="$localdir"  \
1100F77="$f77" \
1101F90="$f90" \
1102OPLINK="$oplink" \
1103LINK="$link" \
1104GCM="$LMDGCM" \
1105MOD_LOC_DIR=$mod_loc_dir \
1106MOD_SUFFIX=$mod_suffix \
1107AR=$ar \
1108SOURCE=$source_code \
1109PROG=$code
1110
1111\rm -f $libf/grid/dimensions.h
Note: See TracBrowser for help on using the repository browser.