source: LMDZ5/trunk/makegcm @ 1867

Last change on this file since 1867 was 1865, checked in by Laurent Fairhead, 11 years ago

Inclusion de la bibliothèque SISVAT/MAR à LMDZ pour le traitement des surfaces
"land ice"

  1. Menegoz

Integration of the SISVAT/MAR library to LMDZ to model the land ice surfaces

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