source: LMDZ4/trunk/makegcm @ 948

Last change on this file since 948 was 948, checked in by Laurent Fairhead, 16 years ago

Changement option de compilation pour etre au meme niveau que makegcm_fcm
LF

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