source: LMDZ5/branches/testing/makegcm @ 1999

Last change on this file since 1999 was 1999, checked in by Laurent Fairhead, 10 years ago

Merged trunk changes r1920:1997 into testing branch

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