source: LMDZ4/trunk/makegcm @ 1307

Last change on this file since 1307 was 1297, checked in by Laurent Fairhead, 14 years ago

Inclusion de gfortan comme compilateur valide

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