source: LMDZ4/branches/LMDZ4_V3_patches/makegcm

Last change on this file was 914, checked in by Laurent Fairhead, 16 years ago

Il manque un NC_DOUBLE depuis pas mal de temps pour Brodie
LF

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