source: LMDZ6/trunk/makegcm @ 3982

Last change on this file since 3982 was 3901, checked in by evignon, 3 years ago

Commission LMDZ-sisvat, deuxieme phase:

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