source: LMDZ4/branches/V3_test/makegcm @ 737

Last change on this file since 737 was 737, checked in by Laurent Fairhead, 18 years ago

Mise en coherence pour les liens veget et pour l'edition des liens sur mercure
AC/LF

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