source: LMDZ5/branches/testing/makegcm @ 1669

Last change on this file since 1669 was 1669, checked in by Laurent Fairhead, 12 years ago

Version testing basée sur la r1668

http://lmdz.lmd.jussieu.fr/utilisateurs/distribution-du-modele/versions-intermediaires


Testing release based on r1668

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 33.3 KB
Line 
1#!/bin/csh
2#
3# $Id: makegcm 1669 2012-10-16 12:41:50Z 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="-i4 -O3 -r8 -DNC_DOUBLE"
26set OPT_LINUX="-i4 -O3 -r8 -DNC_DOUBLE"
27set io=ioipsl
28set cosp=false
29
30set FC_LINUX=g95
31set FC_LINUX=g95
32#set FC_LINUX=g95
33if ( $FC_LINUX == g95 ) then
34  set OPT_LINUX="-i4 -O3 -r8 -DNC_DOUBLE"
35else if ( $FC_LINUX == gfortran ) then
36  set OPT_LINUX="-i4 -O3 -r8 -DNC_DOUBLE"
37#   set OPT_LINUX="-i4 -O3 -r8 -DNC_DOUBLE"
38  set OPT_LINUX="-i4 -O3 -r8 -DNC_DOUBLE"
39else
40# pgf90 options
41  set OPT_LINUX="-i4 -O3 -r8 -DNC_DOUBLE"
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 /d3/idelkadi/MODELE_LMDZ/LMDZ20121005.trunk/netcdf-4.0.1/include
57setenv NCDFLIB /d3/idelkadi/MODELE_LMDZ/LMDZ20121005.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 /d3/idelkadi/MODELE_LMDZ/LMDZ20121005.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 /d3/idelkadi/MODELE_LMDZ/LMDZ20121005.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
565   set opt_link="$lcosp $opt_link"
566endif
567
568if ( "$physique" == 'nophys' ) then
569   set phys="L_PHY= LIBPHY="
570else
571   #We'll use some physics
572   set cppflags="$cppflags -DCPP_PHYS"
573   if ( `echo $physique | grep -i "^lmd"` != "" ) then
574     #For lmd physics, default planet type is Earth
575     set cppflags="$cppflags -DCPP_EARTH"
576   endif
577endif
578
579set link_veget=" "
580if ( "$veget" == 'true' ) then
581   set cppflags="$cppflags -DCPP_VEGET"
582#   set link_veget=" -lsechiba -lparameters -lstomate  "
583   set link_veget=" -lsechiba -lparameters -lstomate"
584   if ( $XNEC || $X8BRODIE || $X6NEC) then
585#      set link_veget=" -lsxsechiba -lsxparameters -lsxstomate -lsxorglob -lsxparallel"
586      set link_veget=" -lsxsechiba -lsxparameters -lsxstomate "
587   endif
588endif
589
590if ( "$chimie" == 'INCA' ) then
591    set cppflags="$cppflags -DINCA" 
592    set libchimie=" -L$INCALIB -lchimie"
593    set opt_link="$opt_link  -L$INCALIB -lchimie"
594endif
595   
596if ( "$couple" == 'true' ) then
597   set cppflags="$cppflags -DCPP_COUPLE"
598endif
599
600set FLAG_PARA=''
601if ( "$parallel" == 'true' ) then
602   set cppflags="$cppflags -DCPP_PARA"
603   set FLAG_PARA='par'
604endif
605
606set optim="$optim $cppflags"
607set optim90="$optim90 $cppflags"
608set optimtru90="$optimtru90 $cppflags"
609
610
611########################################################################
612# cas special sans physique
613########################################################################
614if ( "$physique" == 'nophys' ) then
615   set phys="L_PHY= LIBPHY="
616endif
617
618########################################################################
619#subtilites sur le nom de la librairie
620########################################################################
621
622\rm -f tmp ; touch tmp
623\rm -f tmp90 ; touch tmp90
624foreach i ( $optim )
625   echo $i | sed -e 's/\"//g' -e "s/\'//g" -e 's/-//g'  >> tmp
626end
627set suf=
628foreach i ( `sort tmp | uniq ` )
629   set suf=$suf$i
630end
631if ( ! $IBM ) then
632   set nomlib="$nomlib$suf"
633endif
634if ( $DEC ) then
635   set nomlib=DEC
636endif
637if ( $IBM ) then
638   set dim=`echo $dim | sed -en 's/[^0-9]/ /g'`
639   set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'`
640else if ( $SUN ) then
641   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
642   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
643else
644   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
645   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
646endif
647set nomlib=${nomlib}${physique}_${dim_}_$grille
648## M-A-F nomlib trop long sur CRAY pour ar
649if ( $CRAY ) then
650    set nomlib=F90_${dim_}
651endif
652if ( $NEC || $XNEC || $X6NEC || $X8BRODIE ) then
653    set nomlib=F90_${dim_}_'phy'${physique}${FLAG_PARA}
654endif
655echo calcul de la dimension
656set dimc=`echo $dim | wc -w`
657
658if ( "$dimc" == "2" ) then
659set include="$include "'-I$(LIBF)/dyn2d '
660set dimh=$dim
661else
662set include="$include "'-I$(LIBF)/dyn3d${FLAG_PARA} '
663set dimh=`echo $dim | awk ' { print $1 "." $2 } '`
664endif
665echo $dimc
666
667########################################################################
668# path pour les #include
669########################################################################
670
671if ( $XNEC ) then
672  set include="$include -I$NCDFINC -I$IOIPSLDIR"
673else
674  set include="$include -I$NCDFINC -I$IOIPSLDIR"
675endif
676echo $include
677
678########################################################################
679# Gestion des dimensions du modele.
680# on cree ou remplace le fichier des dimensions
681########################################################################
682
683cd $libf/grid
684if ( -f dimensions.h ) then
685echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
686echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
687echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
688echo  vous pouvez continuer en repondant oui.
689echo "Voulez-vous vraiment continuer?"
690if ( $< == "oui" ) then
691\rm -f $libf/grid/dimensions.h
692else
693exit
694endif
695endif
696
697cd dimension
698./makdim $dim
699cat $libf/grid/dimensions.h
700
701cd $LMDGCM
702set libo=$libo/$nomlib
703if ( ! -d $libo )  then
704   mkdir $libo
705   cd $model
706endif
707
708########################################################################
709# Differentes dynamiques (3d, 2d, 1d)
710########################################################################
711
712set dimension=`echo $dim | wc -w`
713echo dimension $dimension
714if ( $dimension == 1 ) then
715echo pas de dynamique
716set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
717endif
718endif
719cd $model
720if ( $dimension == 3 ) then
721cd libf/grid
722\rm fxyprim.h
723cp -p fxy_${grille}.h fxyprim.h
724endif
725
726######################################################################
727#   Traitement special pour le nouveau rayonnement de Laurent Li.
728######################################################################
729
730#if ( -f $libf/phy$physique/raddim.h ) then
731# if ( -f $libf/phy$physique/raddim.$dimh.h ) then
732#  \rm -f $libf/phy$physique/raddim.h
733#  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
734#  echo $libf/phy$physique/raddim.$dimh.h
735#  cat $libf/phy$physique/raddim.$dimh.h
736#  cat $libf/phy$physique/raddim.h
737# else
738#  echo On peut diminuer la taille de l executable en creant
739#  echo le fichier $libf/phy$physique/raddim.$dimh.h
740#  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
741# endif
742#endif
743
744######################################################################
745# Gestion du filtre qui n'existe qu'en 3d.
746######################################################################
747
748if ( `expr $dimc \> 2` == 1 ) then
749   set filtre="FILTRE=$filtre"
750else
751   set filtre="FILTRE= L_FILTRE= "
752endif
753echo MACRO FILTRE $filtre
754
755echo $dimc
756
757########################################################################
758#  Avant de lancer le make, on recree le makefile si necessaire
759########################################################################
760########################################################################
761# c'est a dire dans 3 cas:
762# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
763#    derniere creation du makefile
764# 2. si le fichier contenant cette liste "liste_des_sources"
765#    n'existe pas.
766# 3. Si le makefile n'existe pas.
767########################################################################
768##########################################
769# On adapte d'abord certains include à F90
770##########################################
771##########################################
772cd $model
773find libf -name '*.[Fh]' -print >! tmp77
774find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90
775find libf -name '*.[Fh]90' -print >> tmp90
776
777if (    `diff tmp77 liste_des_sources_f77 | wc -w` \
778     || `diff tmp90 liste_des_sources_f90 | wc -w` \
779     || ! -f makefile \
780     || ! -f liste_des_sources_f90 \
781     || ! -f liste_des_sources_f77 ) then
782        echo les fichiers suivants ont ete crees ou detruits
783        echo ou les fichiers suivants sont passes ou ne sont plus en Fortran 90
784        diff liste_des_sources_f77 tmp77
785        diff liste_des_sources_f90 tmp90
786        \cp tmp77 liste_des_sources_f77
787        \cp tmp90 liste_des_sources_f90
788        echo On recree le makefile
789        ./create_make_gcm >! tmp
790        \mv tmp makefile
791        echo Nouveau makefile cree.
792endif
793
794########################################################################
795#  Execution de la comande make
796########################################################################
797
798echo PHYSIQUE $phys
799echo dynamique $dyn $dimension
800echo OPTIM="$optim" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code
801echo PATH pour les fichiers INCLUDE $include
802echo OPLINK="$oplink"
803
804#################
805if $HP then
806#################
807   set f77='fort77 +OP'
808   set f90='jensaisrien'
809   set opt_link="$opt_link -lm"
810#################
811else  if $VPP then
812#################
813   set f77=frt
814   set f90=$f77
815   if ($couple == true) then
816     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"
817     set oplink="-Wl,-t,-P,-dy "
818   else
819     set opt_link="-Wg,-c -L$MODIPSLDIR -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a"
820     set oplink="-Wl,-t,-dy "
821   endif
822   if ($veget == true) then
823     set opt_link="$opt_link $link_veget -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a"
824   endif
825#################
826else if $CRAY then
827#################
828   set f77=f90
829   set f90=f90
830#################
831else if $LINUX then
832#################
833#   set f77=pgf90
834#   set f90=pgf90
835   set f77=$FC_LINUX
836   set f90=$FC_LINUX
837   if ( $FC_LINUX == 'pgf90' ) then
838     if ( $io == "ioipsl" ) then
839       set opt_link=" $opt_link -L$MODIPSLDIR $link_veget -L$NCDFLIB -lioipsl -lnetcdf "
840     else
841       set opt_link="$opt_link  -L$MODIPSLDIR $link_veget -L$NCDFLIB -lnetcdf "
842     endif
843   else if ($FC_LINUX == 'g95' || $FC_LINUX == 'gfortran' ) then
844     if ( $io == "ioipsl" ) then
845       set opt_link="$opt_link -L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf -lioipsl -lnetcdf "
846     else
847       set opt_link="$opt_link -L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf -lnetcdf "
848     endif
849   endif
850#################
851else if $SUN then
852#################
853   set f77=f90
854   set f90=f90
855   if ( $io == "ioipsl" ) then
856     set opt_link="-lf77compat -L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf "
857   else
858     set opt_link="-lf77compat -L$MODIPSLDIR $link_veget -L$NCDFLIB -lnetcdf "
859   endif
860#################
861else if $NEC then
862#################
863   set f77=f90 -ftrace
864   set f90=f90 -ftrace
865   set opt_link="-L$MODIPSLDIR"
866   if ($veget == true) then
867     set opt_link="$opt_link $link_veget"
868   endif
869   if ($couple == true) then
870     set opt_link="$opt_link -lioipsl -loasis2.4_mpi2 -float0 -ew -P static $NCDFLIB "
871   else
872     set opt_link="$opt_link -L$MODIPSLDIR -lioipsl -float0 -ew -P static $NCDFLIB "
873   endif
874   set mod_loc_dir="./"
875#################
876else if $XNEC then
877#################
878   set f77="sxmpif90 -ftrace"
879   set f90="sxmpif90 -ftrace"
880   if $MODIPSL then
881     set opt_link="-L$MODIPSLDIR"
882     if ($veget == true) then
883       set opt_link="$opt_link $link_veget"
884     endif
885     if ($couple == true) then
886       if ($psmile == true) then
887       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
888       else
889       set opt_link="$opt_link -lsxioipsl -loasis2.4_mpi2 -float0 $optdbl -P static $NCDFLIB "
890       endif
891     else
892       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
893     endif
894   else
895     if ($couple == true) then
896       set opt_link="-L$MODIPSLDIR"
897       set opt_link="$opt_link $link_veget -lsxioipsl -loasis2.4_mpi2 -float0 $optdbl -P static $NCDFLIB "
898     else
899       set opt_link=" -C hopt -float0 $optdbl -P static -L$MODIPSLDIR $link_veget -lsxioipsl $NCDFLIB "
900     endif
901   endif
902   set mod_loc_dir="./"
903##################
904else if $X6NEC then
905##################
906   set f77=sxmpif90
907   set f90=sxmpif90
908   if $MODIPSL then
909     set opt_link="$opt_link -L$MODIPSLDIR"
910     if ($veget == true) then
911       set opt_link="$opt_link $link_veget"
912     endif
913     if ($couple == true) then
914        if ($psmile == true) then
915        set opt_link="$opt_link -lsxioipsl -float0 -size_t64 $optdbl -P static $NCDFLIB "
916        else
917        set opt_link="$opt_link -lsxioipsl -loasis2.4_mpi2 -float0 -size_t64 $optdbl -P static $NCDFLIB "
918        endif
919     else
920       set opt_link="$opt_link -lsxioipsl -float0 -size_t64 $optdbl -P static $NCDFLIB "
921     endif
922   else
923#     set opt_link=" -float0 -size_t64 $optdbl -P static -L$MODIPSLDIR -lsxsechiba -lsxparameters -lsxstomate -lsxioipsl $NCDFLIB "
924     set opt_link=" $opt_link -float0 -size_t64 $optdbl -P static -L$MODIPSLDIR -lsxioipsl $NCDFLIB "
925
926   endif
927   set mod_loc_dir="./"
928##################
929else if $X8BRODIE then
930##################
931   set f77=sxmpif90
932   set f90=sxmpif90
933   if $MODIPSL then
934     set opt_link="$opt_link -float0 -Wf,-A dbl4 -L$MODIPSLDIR -lblas"
935     if ($veget == true) then
936       set opt_link="$opt_link $link_veget"
937     endif
938     if ($couple == true) then
939       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
940     else
941       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
942     endif
943   else
944#     set opt_link=" -float0 $optdbl -P static -L$MODIPSLDIR -lsxsechiba -lsxparameters -lsxstomate -lsxioipsl $NCDFLIB "
945     set opt_link=" -float0 $optdbl -P static -L$MODIPSLDIR -lsxioipsl $NCDFLIB -lblas"
946
947   endif
948   set mod_loc_dir="./"
949#################
950else
951#################
952   set f77=f77
953   set f90=f90
954endif
955
956cd $model
957
958if $VPP then
959set make="gmake RANLIB=ls"
960else if $CRAY then
961set make="make RANLIB=ls"
962else if $NEC then
963set make="make RANLIB=ls"
964else if $LINUX then
965set make="make -k RANLIB=ranlib"
966else if $XNEC then
967set make="gmake RANLIB=ls"
968else if $X6NEC then
969set make="gmake RANLIB=ls"
970else if $X8BRODIE then
971set make="gmake RANLIB=ls"
972else
973set make="make RANLIB=ranlib"
974endif
975
976
977
978
979#
980# etat0_netcdf a besoin d'info de la physique
981# A revoir
982set include="$include"' -I$(LIBF)/phy'"$physique"
983#
984# le programme principal create_limit a besoin de l'info du module
985# startvar: on met donc libo dans les include pour Nec
986set include="$include"' -I$(LIBO)'
987
988
989#################################################################
990# Execution de la comande make... ENFIN!
991#################################################################
992
993if $VPP then
994  set optim90=" $optim90 -Am -M$libo"
995  set optimtru90="$optim90"
996 \cp $IOIPSLDIR/*.mod $libo
997else if $SUN then
998 set optim90=" $optim90 -M$libo -M$MODIPSLDIR "
999 set optimtru90=" $optimtru90 -M$libo -M$MODIPSLDIR "
1000 set optim="$optim90"
1001 \cp $IOIPSLDIR/*.mod $libo
1002else if $NEC then
1003 set optim90=" $optim90 -I$libo "
1004else if $XNEC then
1005 set optim90=" $optim90 -I$libo "
1006 set optimtru90=" $optimtru90 -I$libo "
1007else if $X6NEC then
1008 set optim90=" $optim90 -I$libo "
1009 set optimtru90=" $optimtru90 -I$libo "
1010else if $X8BRODIE then
1011 set optim90=" $optim90 -I$libo "
1012 set optimtru90=" $optimtru90 -I$libo "
1013else if $LINUX then
1014 if ( $FC_LINUX == "pgf90" ) then
1015   set optimtru90=" $optimtru90 -module $libo "
1016   set optim90=" $optim90 -module $libo "
1017 else if ( $FC_LINUX == 'g95' ) then
1018   set optimtru90=" $optimtru90 -fmod=$libo  "
1019   set optim90=" $optim90 -fmod=$libo  "
1020 else if ( $FC_LINUX == 'gfortran' ) then
1021   set optimtru90=" $optimtru90 -M $libo  "
1022   set optim90=" $optim90 -M $libo  "
1023 endif
1024 set optim="$optim90"
1025 set mod_loc_dir=$libo
1026# \cp /d3/fairhead/sechiba/ioipsl/*.mod $libo
1027# \cp $IOIPSLDIR/*.mod $libo
1028endif
1029
1030set link="$f90 $optim90"
1031
1032set ar=ar
1033
1034if $XNEC then
1035  set link="sxld $opt_link"
1036  set link="$f90 "
1037#  set ar=sxar
1038else if $X6NEC then
1039  set link="sxld $opt_link"
1040  set link="$f90 -Wl,-hlib_cyclic "
1041#  set ar=sxar
1042else if $X8BRODIE then
1043  set link="sxld $opt_link"
1044  set link="$f90 -Wl,-hlib_cyclic "
1045#  set ar=sxar
1046endif
1047
1048
1049cd $localdir
1050
1051set source_code=${code}.F
1052if ( -f $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ) then
1053  set source_code=${code}.F90
1054endif
1055
1056echo $make -f $LMDGCM/makefile \
1057OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
1058OPTIM90="$optim90" \
1059OPTIMTRU90="$optimtru90" \
1060OPTIM="$optim$optimbis" \
1061INCLUDE="$include" \
1062$filtre \
1063LIBO=$libo \
1064$dyn \
1065$phys \
1066DIM=$dimc \
1067FLAG_PARA="$FLAG_PARA"\
1068L_ADJNT="$adjnt" \
1069L_COSP="$lcosp" \
1070L_CHIMIE="$libchimie" \
1071LOCAL_DIR="$localdir"  \
1072F77="$f77" \
1073F90="$f90" \
1074OPLINK="$oplink" \
1075LINK="$link" \
1076GCM="$LMDGCM" \
1077MOD_LOC_DIR=$mod_loc_dir \
1078MOD_SUFFIX=$mod_suffix \
1079AR=$ar \
1080SOURCE=$source_code \
1081PROG=$code
1082
1083$make -f $LMDGCM/makefile \
1084OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
1085OPTIM90="$optim90" \
1086OPTIMTRU90="$optimtru90" \
1087OPTIM="$optim$optimbis" \
1088INCLUDE="$include" \
1089$filtre \
1090LIBO=$libo \
1091$dyn \
1092$phys \
1093DIM=$dimc \
1094FLAG_PARA="$FLAG_PARA"\
1095L_ADJNT="$adjnt" \
1096L_COSP="$lcosp" \
1097L_CHIMIE="$libchimie" \
1098LOCAL_DIR="$localdir"  \
1099F77="$f77" \
1100F90="$f90" \
1101OPLINK="$oplink" \
1102LINK="$link" \
1103GCM="$LMDGCM" \
1104MOD_LOC_DIR=$mod_loc_dir \
1105MOD_SUFFIX=$mod_suffix \
1106AR=$ar \
1107SOURCE=$source_code \
1108PROG=$code
1109
1110\rm -f $libf/grid/dimensions.h
Note: See TracBrowser for help on using the repository browser.