source: LMDZ6/trunk/makegcm @ 3793

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

Ajout INLANDSIS phase 2: mise à jour des makefile et creation du
inlandsis.def

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