source: LMDZ5/trunk/makegcm @ 1514

Last change on this file since 1514 was 1514, checked in by Ehouarn Millour, 13 years ago

Update default compiler options implied by makegcm's '-debug' option.

EM

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 33.1 KB
Line 
1#!/bin/csh
2#
3# $Id: makegcm 1514 2011-05-03 08:23:59Z emillour $
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 -fdefault-real-8"
26set OPT_LINUX="-O3 -fdefault-real-8"
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"
35else if ( $FC_LINUX == gfortran ) then
36  set OPT_LINUX="-fdefault-real-8 -O3"
37#   set OPT_LINUX="-O3 -fno-second-underscore"
38  set OPT_LINUX="-O3 "
39else
40# pgf90 options
41  set OPT_LINUX="-i4 -r8 -O2 -Munroll -Mnoframe -Mautoinline -Mcache_align"
42endif
43
44########################################################################
45# path a changer contenant les sources et les objets du modele
46########################################################################
47
48###### VERSION LMDZ.4
49set INCALIB=../INCA3/config/lib
50set LMDGCM="`pwd`"
51setenv LIBOGCM $LMDGCM/libo
52#
53#
54setenv IOIPSLDIR /d4/fairhead/LMDZ20100928.trunk/modipsl/lib
55setenv MODIPSLDIR /d4/fairhead/LMDZ20100928.trunk/modipsl/lib
56setenv NCDFINC /d4/fairhead/LMDZ20100928.trunk/netcdf-4.0.1/include
57setenv NCDFLIB /d4/fairhead/LMDZ20100928.trunk/netcdf-4.0.1/lib
58
59
60
61
62
63setenv localdir "`pwd`"
64set MODIPSL=0
65echo $localdir | grep modipsl >& /dev/null
66if ( ! $status ) then
67  set MODIPSL=1
68  setenv LMDGCM $localdir
69  cd ../..
70  setenv LIBOGCM "`pwd`/lib"
71  setenv IOIPSLDIR $LIBOGCM
72  setenv MODIPSLDIR $LIBOGCM
73  cd $localdir
74  if ( `hostname` == rhodes ) then
75    set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
76    set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
77  else
78    if ( `hostname` == nymphea0 ) then
79      set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
80      set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
81    else if ( `hostname` == mercure ) then
82      set NCDFINC=`grep sx6nec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
83      set NCDFLIB=`grep sx6nec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
84    else  if ( `hostname` == brodie ) then
85      set NCDFINC=`grep sx8brodie ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
86      set NCDFLIB=`grep sx8brodie ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
87    else
88      echo 'Probleme de definition des variables NCDFINC et NCDFLIB'
89    endif
90  endif
91else
92  if ( ! $?LMDGCM ) then
93    echo You must initialize the variable LMDGCM in your environnement
94    echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc
95    exit
96  endif
97  if ( ! $?LIBOGCM ) then
98    set LIBOGCM=$LMDGCM/libo
99  endif
100  if ( ! $?IOIPSLDIR ) then
101    echo You must initialize the variable IOIPSLDIR in your environnement
102    echo for instance: "setenv IOIPSLDIR /usr/myself/ioipsl" in .cshrc
103    exit
104  else
105      setenv MODIPSLDIR $IOIPSLDIR
106  endif
107  if ( ! $?NCDFLIB ) then
108    echo You must initialize the variable NCDFLIB in your environnement
109    echo for instance: "setenv NCDFLIB /d4/fairhead/LMDZ20100928.trunk/netcdf-4.0.1/lib
110    exit
111  endif
112  if ( ! $?NCDFINC ) then
113    echo You must initialize the variable NCDFINC in your environnement
114    echo for instance: "setenv NCDFINC /d4/fairhead/LMDZ20100928.trunk/netcdf-4.0.1/include
115    exit
116  endif
117endif
118set model=$LMDGCM
119set libo=$LIBOGCM
120
121########################################################################
122#  Les differentes platformes reconnues
123########################################################################
124
125set HP=0
126set IBM=0
127set SUN=0
128set VPP=0
129set CRAY=0
130set DEC=0
131set LINUX=0
132set NEC=0
133set XNEC=0
134set X6NEC=0
135set X8BRODIE=0
136if ( `uname` == HP-UX ) then
137   set machine=HP
138   set HP=1
139else if (`uname` == UNIX_System_V ) then
140   set machine=VPP
141   set VPP=1
142else if (`uname` == SunOS ) then
143   set machine=SUN
144   set SUN=1
145else if ( `uname` == AIX ) then
146   set machine=IBM
147   set IBM=1
148else if ( `uname` == OSF1 ) then
149   set machine=ALPHA
150   set DEC=1
151else if ( `uname` == Linux && `hostname` != mercure  && `hostname` != brodie ) then
152   set machine=LINUX
153   set LINUX=1
154else if ( `hostname` == atlas || `hostname` == axis  || `hostname` == etoile ) then
155   set machine=CRAY
156   set CRAY=1
157else if ( `uname` == SUPER-UX ) then
158   set machine=NEC
159   set NEC=1
160else if ( `hostname` == rhodes) then
161   set machine=XNEC
162   set XNEC=1
163else if ( `hostname` == mercure) then
164   set machine=X6NEC
165   set X6NEC=1
166else if ( `hostname` == brodie) then
167   set machine=X8BRODIE
168   set X8BRODIE=1
169else
170   echo Vous travaillez sur une machine non prevue par le reglement
171   exit
172endif
173
174if ( ! -d $libo )  then
175   mkdir $libo
176endif
177
178
179if $VPP then
180set netcdf=netcdf_v
181else
182set netcdf=netcdf
183endif
184########################################################################
185#  Quelques initialisations de variables du shell.
186########################################################################
187
188set dyn=
189set opt_link=""
190set adjnt=""
191set lcosp=""
192set opt_dep=""
193set libchimie=""
194
195set optim=""
196set optimbis=""
197set optim90=""
198set oplink=""
199
200########################################################################
201#  Optimisations par defaut suivant les machines
202########################################################################
203
204echo "Optimisations par defaut suivant les machines"
205set libf=$model/libf
206#setenv localdir "LOCAL_DIR=`pwd`"
207#setenv localdir "`pwd`"
208cd $model
209#############
210if $CRAY then
211#############
212#   set optim="-Wf'-ei' -dp -Wf'-a static'"
213   set optimbis=" -DCRAY "
214   set optim90="-Wp'-P' -DCRAY -p$IOIPSLDIR "'-p$(LIBO) -eiv '
215   set optim="$optim90"
216   if ( $io == "ioipsl" ) then
217     set oplink="-Wl'-DSTACK=128 -f indef' -L$IOIPSLDIR -lioipsl  -L$NCDFLIB -lnetcdf "
218   else
219     set oplink="-Wl'-DSTACK=128 -f indef' -L$IOIPSLDIR -L$NCDFLIB -lnetcdf "
220   endif
221   set mod_loc_dir=" "
222   set mod_suffix=" "
223#################
224else if $SUN then
225#################
226   set optim=" -fast "
227   set optimbis=" "
228   set optim90=" -fast -fixed "
229   set optimtru90=" -fast -free "
230   if ( $io == "ioipsl" ) then
231     set opt_link="-lf77compat -L$MODIPSLDIR -lsechiba -lparameters -lstomate -lioipsl -L$NCDFLIB -lnetcdf "
232   else
233     set opt_link="-lf77compat -L$MODIPSLDIR -lsechiba -lparameters -lstomate -L$NCDFLIB -lnetcdf "
234   endif
235   set mod_loc_dir=$localdir
236   set mod_suffix=mod
237#################
238else if $HP then
239#################
240   set optim=" +U77 -O +E1 "
241   set optimbis=" "
242#################
243else if $IBM then
244#################
245   set optim=" -O3 -qtune=pwr2 -qarch=pwr2"
246   set optimbis=" "
247#################
248else if $VPP then
249#################
250#   set optim="-Dasuxm  -On, -g -Ad -Potilax -Eciplume -Si"
251#   set optimbis="  -Wv,-m3 -Wp,-DVPP -Z $LMDGCM/listage"
252   set optimbis=" -Wp,-DNC_DOUBLE -Ad -Z $LMDGCM/listage -X9"
253   set optim90="$optim $optimbis -X9 -w"
254   set mod_loc_dir=$MODIPSLDIR
255   set mod_suffix=mod
256#################
257else if $DEC then
258#################
259   set optim=" "
260   set optimbis=" "
261#################
262else if $LINUX then
263#################
264   if ( $FC_LINUX == pgf90 || $FC_LINUX == g95 || $FC_LINUX == gfortran ) then
265     set optim=" $OPT_LINUX "
266     set optim90=" $OPT_LINUX "
267     set optimtru90=" $OPT_LINUX "
268   else
269     echo 'compilateur linux non reconnu'
270     exit
271   endif
272   set mod_loc_dir=$MODIPSLDIR
273   set mod_suffix=mod
274#################
275else if $NEC then
276#################
277   set optim90=' -clear -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
278   set optimtru90=' -clear -f4 -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
279   set optim="$optim90"
280   set optimbis=" "
281   if ( $io == "ioipsl" ) then
282     set opt_link=" -C hopt -float0 -ew -P static -L$MODIPSLDIR -lioipsl  $NCDFLIB -lnetcdf_i8r8_v "
283   else
284     set opt_link=" -C hopt -float0 -ew -P static -L$MODIPSLDIR $NCDFLIB -lnetcdf_i8r8_v "
285   endif
286   set mod_loc_dir="."
287   set mod_suffix="mod"
288#################
289else if $XNEC then
290#################
291   set optdbl='-dw -Wf\"-A dbl4\"'
292   set optim90=' -clear -float0 -f3 -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
293   set optimtru90=' -clear -f4 -float0 -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R2 -R3 -R4 -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume"'
294   set optim="$optim90"
295   set optimbis=" "
296   set mod_suffix="mod"
297   set mod_loc_dir="./"
298#################
299else if $X6NEC then
300#################
301   set optdbl='-dw -Wf\"-A dbl4\"' 
302   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 "'
303   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"'
304   set optim="$optim90"
305   set optimbis=" "
306   set mod_suffix="mod"
307   set mod_loc_dir="./"
308#################
309else if $X8BRODIE then
310##################
311   set optdbl='-dw -Wf\"-A dbl4\"' 
312#   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'
313   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'
314#   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'
315   set optimtru90="$optim90"
316   set optim90="$optim90"
317   set optim="$optim90"
318   set optimbis=" "
319   set mod_suffix="mod"
320   set mod_loc_dir="./"
321else
322   set optim=""
323   set optimbis=" "
324endif
325
326set nomlib=$machine
327
328########################################################################
329# lecture des options de mymake
330########################################################################
331
332top:
333if ($#argv > 0) then
334    switch ($1:q)
335
336    case -h:
337
338########################################################################
339# Manuel en ligne
340########################################################################
341more <<eod
342
343
344makegcm [Options] prog
345
346
347
348
349Par default, la commande makegcm:
350---------------------------------
351
3521. compile une serie de sous programmes se trouvant dans des sous-repertoires
353de $LMDGCM/libf.
354Les sous programmes sont ensuite stokes sur dans des librairies FORTRAN
355sur $LIBOGCM.
356
3572. Ensuite, makegcm compile le programme prog.f se trouvant par default sur
358$LMDGCM/libf/dyn3d et effectue le lien avec l ensemble des librairies.
359
360La variable '$LMDGCM' doit etre initialisee dans votre .cshrc ou en dur
361dans la comande makegcm.
362
363La commande makegcm est faite pour permettre de gerer en parallele des
364versions differentes du modele, compilees avec des options de compilation
365et des dimensions differentes sans avoir a chaque fois a recompiler tout
366le modele.
367
368Les librairies FORTRAN sont stoquees sur le directory $LIBOGCM.
369
370
371OPTIONS:
372--------
373
374Les options suivantes peuvent etre definies soit par defaut en editant le
375"script" makegcm, soit en interactif:
376
377-d imxjmxlm  ou im, jm, et lm sont resp. le nombre de longitudes, latitudes
378             et couches verticales.
379             L'effet des options -d est d'ecraser le fichier
380             $LMDGCM/libf/grid/dimensions.h
381             qui contient sous forme de 3 PARAMETER FORTRAN les 3 dimensions
382             de la grille horizontale im, jm et verticale lm, par un nouveu fichier
383             $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm
384             Si ce fichier n'existe pas encore, il est cree par le script
385             $LMDGCM/libf/grid/dimension/makdim
386
387-p PHYS    pour selectionner le jeu de parametrisations physiques avec
388           lequel on veut compiler le modele.
389           Le modele sera alors compile en prenant les sources des
390           parametrisations physiques dans le repertoire:
391            $LMDGCM/libf/phyPHYS
392
393-c false|true
394           pour selectionner le mode force (par defaut) ou couple
395
396-io ioipsl|noioipsl
397           pour selectionner le logiciel IO : IOIPSL par defaut
398
399-psmile false|true
400           pour selectionner le mode psmile ou non (par defaut)
401
402-parallel  false|true
403           pour selectionner le mode parallele ou non (false par defaut)
404
405-v true|false
406           pour selectionner la vegetation (par defaut) ou non
407
408-chimie INCA|false
409           pour selectionner ou non la chimie (par defaut sans)
410
411-g grille  selectionne le type de grille qu'on veut utiliser.
412           L'effet de cette option est d'ecraser le fichier
413           $LMDGCM/libf/grid/fxyprim.h
414           avec le fichier
415           $LMDGCM/libf/grid/fxy_grille.h
416           grille peut prendre les valeurs:
417           1. reg pour la grille reguliere
418           2. sin pour avoir des points equidistants en sinus de la latitude
419           3. new pour pouvoir zoomer sur une partie du globe
420
421-O "optimisation fortran" ou les optimisations fortran sont les options de la
422            commande f77
423
424-include path
425           Dans le cas ou on a dans des sous programmes des fichiers
426           #include (cpp) qui se trouve sur des repertoires non references
427           par defaut
428
429-adjnt     Pour compiler la l'adjoint du code dynamique
430
431-cosp true|false     
432           Pour compiler avec cosp
433
434-filtre  filtre
435           Pour choisir le filtre en longitude dans les regions polaires.
436           "filtre" correspond au nom d'un repertoire se trouvant sur
437           $LMDGCM/libf. Le filtre standard du modele est "filtrez" qui peut
438           etre utilise aussi bien pour une grille reguliere que pour une
439           grille zoomee en longitude.
440
441-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
442          Pour rajouter un lien avec les librairies FORTRAN
443          libfile1.a, libfile2.a ... se trouvant respectivement sur les
444          repertoires dir1, dir2 ...
445          Si dirn est un repertoire dont le chemin est automatique (comme
446          par exemple /usr/lib ...) il n'est pas besoin de specifier -Ldirn.
447
448Auteur: Frederic Hourdin  (hourdin@lmd.jussieu.fr)
449eod
450exit
451
452########################################################################
453# Lecture des differentes options
454########################################################################
455
456    case -d:
457        set dim=$2 ; shift ; shift ; goto top
458                       
459    case -O:
460        set optim="$2" ; shift ; shift ; goto top
461
462     case -p
463        set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top
464
465     case -g
466        set grille="$2" ; shift ; shift ; goto top
467
468     case -c
469        set couple="$2" ; shift ; shift ; goto top
470
471     case -io
472        set io="$2" ; shift ; shift ; goto top
473
474     case -v
475        set veget="$2" ; shift ; shift ; goto top
476
477     case -chimie
478        set chimie="$2" ; shift ; shift ; goto top
479
480     case -parallel
481        set parallel="$2" ; shift ; shift ; goto top
482 
483     case -include
484        set include="$include -I$2" ; shift ; shift ; goto top
485
486     case -adjnt
487        set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d "
488        set optim="$optim -Dadj" ; shift ; goto top
489
490     case -cosp
491        set cosp="$2"; shift ; shift ; goto top
492
493     case -filtre
494        set filtre=$2 ; shift ; shift ; goto top
495
496     case -link
497        set opt_link="$opt_link $2" ; shift ; shift ; goto top
498
499     case -debug
500        if $HP then
501           set optim=" -g "
502        else if $SUN then
503           setenv PARALLEL 2
504# Il faut rajouter l'option -dalign a -g pour pouvoir editer les liens
505# avec des programmes compiles avec -fast
506           set optim=" -g -dalign "
507           set optim90=" -fixed -g "
508           set optimtru90=" -free -g -C -dalign "
509        else if $CRAY then
510           set optim="$optim"" -g "
511           set optim90="$optim90"" -G1 "
512        else if $LINUX then
513           if ( $FC_LINUX == "pgf90" ) then
514             set optim="$optim"" -g -Mbounds -Kieee -Ktrap=fp -traceback "
515             set optim90="$optim90"" -g -Mbounds -Kieee -Ktrap=fp -traceback "
516             set optimtru90="$optimtru90"" -g -Mbounds -Kieee -Ktrap=fp -traceback "
517           else if ( $FC_LINUX == 'gfortran' ) then
518             set optim="$optim"" -g -ffpe-trap=invalid,zero,overflow -fbounds-check -Wall "
519             set optim90="$optim90"" -g -ffpe-trap=invalid,zero,overflow -fbounds-check -Wall "
520             set optimtru90="$optimtru90"" -ffpe-trap=invalid,zero,overflow -g -fbounds-check -Wall "
521           else if ( $FC_LINUX == 'g95' ) then
522             set optim="$optim"" -g -fbounds-check -freal=nan -ftrace=full -Wall "
523             set optim90="$optim90"" -g -fbounds-check -freal=nan -ftrace=full -Wall "
524             set optimtru90="$optimtru90"" -g -fbounds-check -freal=nan -ftrace=full -Wall "
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  "
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 "
1038#  set ar=sxar
1039else if $X8BRODIE then
1040  set link="sxld $opt_link"
1041  set link="$f90 -Wl,-hlib_cyclic "
1042#  set ar=sxar
1043endif
1044
1045
1046cd $localdir
1047
1048set source_code=${code}.F
1049if ( -f $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ) then
1050  set source_code=${code}.F90
1051endif
1052
1053echo $make -f $LMDGCM/makefile \
1054OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
1055OPTIM90="$optim90" \
1056OPTIMTRU90="$optimtru90" \
1057OPTIM="$optim$optimbis" \
1058INCLUDE="$include" \
1059$filtre \
1060LIBO=$libo \
1061$dyn \
1062$phys \
1063DIM=$dimc \
1064FLAG_PARA="$FLAG_PARA"\
1065L_ADJNT="$adjnt" \
1066L_COSP="$lcosp" \
1067L_CHIMIE="$libchimie" \
1068LOCAL_DIR="$localdir"  \
1069F77="$f77" \
1070F90="$f90" \
1071OPLINK="$oplink" \
1072LINK="$link" \
1073GCM="$LMDGCM" \
1074MOD_LOC_DIR=$mod_loc_dir \
1075MOD_SUFFIX=$mod_suffix \
1076AR=$ar \
1077SOURCE=$source_code \
1078PROG=$code
1079
1080$make -f $LMDGCM/makefile \
1081OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
1082OPTIM90="$optim90" \
1083OPTIMTRU90="$optimtru90" \
1084OPTIM="$optim$optimbis" \
1085INCLUDE="$include" \
1086$filtre \
1087LIBO=$libo \
1088$dyn \
1089$phys \
1090DIM=$dimc \
1091FLAG_PARA="$FLAG_PARA"\
1092L_ADJNT="$adjnt" \
1093L_COSP="$lcosp" \
1094L_CHIMIE="$libchimie" \
1095LOCAL_DIR="$localdir"  \
1096F77="$f77" \
1097F90="$f90" \
1098OPLINK="$oplink" \
1099LINK="$link" \
1100GCM="$LMDGCM" \
1101MOD_LOC_DIR=$mod_loc_dir \
1102MOD_SUFFIX=$mod_suffix \
1103AR=$ar \
1104SOURCE=$source_code \
1105PROG=$code
1106
1107\rm -f $libf/grid/dimensions.h
Note: See TracBrowser for help on using the repository browser.