source: LMDZ5/branches/testing/makegcm @ 2056

Last change on this file since 2056 was 2056, checked in by Laurent Fairhead, 10 years ago

Merged trunk changes r1997:2055 into testing branch

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