source: LMDZ6/trunk/makegcm @ 3359

Last change on this file since 3359 was 3359, checked in by idelkadi, 6 years ago

Implementation de la version COSPv2 dans LMDZ.

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