source: LMDZ4/branches/LMDZ4-dev/makegcm @ 1174

Last change on this file since 1174 was 1167, checked in by Laurent Fairhead, 15 years ago

Les options de compilation pour g95 et pgf90 avec makegcm FH
une correction dans guide_p.F AJ
LF

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 31.7 KB
Line 
1#!/bin/csh
2#
3# $Id: makegcm 1167 2009-05-29 13:37:46Z ymeurdesoif $
4#
5#set verbose echo
6########################################################################
7# options par defaut pour la commande make
8########################################################################
9set dim="96x71x19"
10set physique=lmd
11set phys="PHYS=$physique"
12set include='-I$(LIBF)/grid -I$(LIBF)/bibio -I$(LIBF)/filtrez -I. '
13set filtre=filtrez
14set grille=reg
15set couple=false
16set veget=false
17set chimie=false
18set psmile=true
19set parallel=false
20set vampir=false
21set OPT_STACK='-Wf,-init stack=nan'
22set OPT_STACK=' '
23set OPTIMI='-C debug -eC '
24set OPTIMI=' -ftrace '
25set OPT_LINUX='-O3'
26set io=ioipsl
27
28set FC_LINUX=g95
29if ( FC_LINUX == g95 ) then
30   set OPT_LINUX="-i4 -r8 -O3"
31else
32   set OPT_LINUX="-O2 -Munroll -Mnoframe -Mautoinline -Mcache_align"
33endif
34
35
36########################################################################
37# path a changer contenant les sources et les objets du modele
38########################################################################
39
40###### VERSION LMDZ.4
41#set LMDGCM=/workdir/p86cozic/INCA_dev/LMDZ4
42#setenv LIBOGCM $LMDGCM/libo
43set INCALIB=../INCA3/config/lib
44#set LMDGCM="`pwd`"
45#setenv LIBOGCM $LMDGCM/libo
46#set LMDGCM=/d4/fairhead/V4/
47#setenv LIBOGCM $LMDGCM/libo
48#
49#
50#setenv IOIPSLDIR /u/fairhead/modipsl_ioipsl_3/lib_i4r4_32bits
51#setenv MODIPSLDIR /u/fairhead/modipsl_ioipsl_3/lib_i4r4_32bits
52#setenv NCDFINC /distrib/local/netcdf/pgi_32bits/include
53#setenv NCDFLIB /distrib/local/netcdf/pgi_32bits/lib/
54#setenv IOIPSLDIR /d4/fairhead/Install_LMDZ4_FH/LMDZ4preV4/modipsl/lib/
55#setenv MODIPSLDIR /d4/fairhead/Install_LMDZ4_FH/LMDZ4preV4/modipsl/lib/
56#setenv NCDFINC /d4/fairhead/Install_LMDZ4_FH/LMDZ4preV4/netcdf-3.6.1/include
57#setenv NCDFLIB /d4/fairhead/Install_LMDZ4_FH/LMDZ4preV4/netcdf-3.6.1/lib
58
59
60
61setenv localdir "`pwd`"
62set MODIPSL=0
63echo $localdir | grep modipsl >& /dev/null
64if ( ! $status ) then
65  set MODIPSL=1
66  setenv LMDGCM $localdir
67  cd ../..
68  setenv LIBOGCM "`pwd`/lib"
69  setenv IOIPSLDIR $LIBOGCM
70  setenv MODIPSLDIR $LIBOGCM
71  cd $localdir
72  if ( `hostname` == rhodes ) then
73    set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
74    set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
75  else
76    if ( `hostname` == nymphea0 ) then
77      set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
78      set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
79    else if ( `hostname` == mercure ) then
80      set NCDFINC=`grep sx6nec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
81      set NCDFLIB=`grep sx6nec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
82    else  if ( `hostname` == brodie ) then
83      set NCDFINC=`grep sx8brodie ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
84      set NCDFLIB=`grep sx8brodie ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
85    else
86      echo 'Probleme de definition des variables NCDFINC et NCDFLIB'
87    endif
88  endif
89else
90  if ( ! $?LMDGCM ) then
91    echo You must initialize the variable LMDGCM in your environnement
92    echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc
93    exit
94  endif
95  if ( ! $?LIBOGCM ) then
96    set LIBOGCM=$LMDGCM/libo
97  endif
98  if ( ! $?IOIPSLDIR ) then
99    echo You must initialize the variable IOIPSLDIR in your environnement
100    echo for instance: "setenv IOIPSLDIR /usr/myself/ioipsl" in .cshrc
101    exit
102  else
103      setenv MODIPSLDIR $IOIPSLDIR
104  endif
105  if ( ! $?NCDFLIB ) then
106    echo You must initialize the variable NCDFLIB in your environnement
107    echo for instance: "setenv NCDFLIB /usr/myself/netcdf" in .cshrc
108    exit
109  endif
110  if ( ! $?NCDFINC ) then
111    echo You must initialize the variable NCDFINC in your environnement
112    echo for instance: "setenv NCDFINC /usr/myself/netcdf" in .cshrc
113    exit
114  endif
115endif
116set model=$LMDGCM
117set libo=$LIBOGCM
118
119########################################################################
120#  Les differentes platformes reconnues
121########################################################################
122
123set HP=0
124set IBM=0
125set SUN=0
126set VPP=0
127set CRAY=0
128set DEC=0
129set LINUX=0
130set NEC=0
131set XNEC=0
132set X6NEC=0
133set X8BRODIE=0
134if ( `uname` == HP-UX ) then
135   set machine=HP
136   set HP=1
137else if (`uname` == UNIX_System_V ) then
138   set machine=VPP
139   set VPP=1
140else if (`uname` == SunOS ) then
141   set machine=SUN
142   set SUN=1
143else if ( `uname` == AIX ) then
144   set machine=IBM
145   set IBM=1
146else if ( `uname` == OSF1 ) then
147   set machine=ALPHA
148   set DEC=1
149else if ( `uname` == Linux && `hostname` != mercure  && `hostname` != brodie ) then
150   set machine=LINUX
151   set LINUX=1
152else if ( `hostname` == atlas || `hostname` == axis  || `hostname` == etoile ) then
153   set machine=CRAY
154   set CRAY=1
155else if ( `uname` == SUPER-UX ) then
156   set machine=NEC
157   set NEC=1
158else if ( `hostname` == rhodes) then
159   set machine=XNEC
160   set XNEC=1
161else if ( `hostname` == mercure) then
162   set machine=X6NEC
163   set X6NEC=1
164else if ( `hostname` == brodie) then
165   set machine=X8BRODIE
166   set X8BRODIE=1
167else
168   echo Vous travaillez sur une machine non prevue par le reglement
169   exit
170endif
171
172if ( ! -d $libo )  then
173   mkdir $libo
174endif
175
176
177if $VPP then
178set netcdf=netcdf_v
179else
180set netcdf=netcdf
181endif
182########################################################################
183#  Quelques initialisations de variables du shell.
184########################################################################
185
186set dyn=
187set opt_link=""
188set adjnt=""
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 ) 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-filtre  filtre
429           Pour choisir le filtre en longitude dans les regions polaires.
430           "filtre" correspond au nom d'un repertoire se trouvant sur
431           $LMDGCM/libf. Le filtre standard du modele est "filtrez" qui peut
432           etre utilise aussi bien pour une grille reguliere que pour une
433           grille zoomee en longitude.
434
435-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
436          Pour rajouter un lien avec les librairies FORTRAN
437          libfile1.a, libfile2.a ... se trouvant respectivement sur les
438          repertoires dir1, dir2 ...
439          Si dirn est un repertoire dont le chemin est automatique (comme
440          par exemple /usr/lib ...) il n'est pas besoin de specifier -Ldirn.
441
442Auteur: Frederic Hourdin  (hourdin@lmd.jussieu.fr)
443eod
444exit
445
446########################################################################
447# Lecture des differentes options
448########################################################################
449
450    case -d:
451        set dim=$2 ; shift ; shift ; goto top
452                       
453    case -O:
454        set optim="$2" ; shift ; shift ; goto top
455
456     case -p
457        set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top
458
459     case -g
460        set grille="$2" ; shift ; shift ; goto top
461
462     case -c
463        set couple="$2" ; shift ; shift ; goto top
464
465     case -io
466        set io="$2" ; shift ; shift ; goto top
467
468     case -v
469        set veget="$2" ; shift ; shift ; goto top
470
471     case -chimie
472        set chimie="$2" ; shift ; shift ; goto top
473
474     case -parallel
475        set parallel="$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   #Default planet type is Earth
546   set cppflags="$cppflags -DCPP_EARTH"
547endif
548
549set link_veget=" "
550if ( "$veget" == 'true' ) then
551   set cppflags="$cppflags -DCPP_VEGET"
552   set link_veget=" -lsechiba -lparameters -lstomate -lorglob -lparallel"
553   if ( $XNEC || $X8BRODIE || $X6NEC) then
554      set link_veget=" -lsxsechiba -lsxparameters -lsxstomate -lsxorglob -lsxparallel"
555   endif
556endif
557
558if ( "$chimie" == 'INCA' ) then
559    set cppflags="$cppflags -DINCA" 
560    set libchimie=" -L$INCALIB -lchimie"
561    set opt_link="$opt_link  -L$INCALIB -lchimie"
562endif
563   
564if ( "$couple" == 'true' ) then
565   set cppflags="$cppflags -DCPP_COUPLE"
566endif
567
568set FLAG_PARA=''
569if ( "$parallel" == 'true' ) then
570   set cppflags="$cppflags -DCPP_PARA"
571   set FLAG_PARA='par'
572endif
573
574set optim="$optim $cppflags"
575set optim90="$optim90 $cppflags"
576set optimtru90="$optimtru90 $cppflags"
577
578
579########################################################################
580# cas special sans physique
581########################################################################
582if ( "$physique" == 'nophys' ) then
583   set phys="L_PHY= LIBPHY="
584endif
585
586########################################################################
587#subtilites sur le nom de la librairie
588########################################################################
589
590\rm -f tmp ; touch tmp
591\rm -f tmp90 ; touch tmp90
592foreach i ( $optim )
593   echo $i | sed -e 's/\"//g' -e "s/\'//g" -e 's/-//g'  >> tmp
594end
595set suf=
596foreach i ( `sort tmp | uniq ` )
597   set suf=$suf$i
598end
599if ( ! $IBM ) then
600   set nomlib="$nomlib$suf"
601endif
602if ( $DEC ) then
603   set nomlib=DEC
604endif
605if ( $IBM ) then
606   set dim=`echo $dim | sed -en 's/[^0-9]/ /g'`
607   set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'`
608else if ( $SUN ) then
609   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
610   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
611else
612   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
613   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
614endif
615set nomlib=${nomlib}${physique}_${dim_}_$grille
616## M-A-F nomlib trop long sur CRAY pour ar
617if ( $CRAY ) then
618    set nomlib=F90_${dim_}
619endif
620if ( $NEC || $XNEC || $X6NEC || $X8BRODIE ) then
621    set nomlib=F90_${dim_}_'phy'${physique}${FLAG_PARA}
622endif
623echo calcul de la dimension
624set dimc=`echo $dim | wc -w`
625
626if ( "$dimc" == "2" ) then
627set include="$include "'-I$(LIBF)/dyn2d '
628set dimh=$dim
629else
630set include="$include "'-I$(LIBF)/dyn3d${FLAG_PARA} '
631set dimh=`echo $dim | awk ' { print $1 "." $2 } '`
632endif
633echo $dimc
634
635########################################################################
636# path pour les #include
637########################################################################
638
639if ( $XNEC ) then
640  set include="$include -I$NCDFINC -I$IOIPSLDIR"
641else
642  set include="$include -I$NCDFINC -I$IOIPSLDIR"
643endif
644echo $include
645
646########################################################################
647# Gestion des dimensions du modele.
648# on cree ou remplace le fichier des dimensions
649########################################################################
650
651cd $libf/grid
652if ( -f dimensions.h ) then
653echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
654echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
655echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
656echo  vous pouvez continuer en repondant oui.
657echo "Voulez-vous vraiment continuer?"
658if ( $< == "oui" ) then
659\rm -f $libf/grid/dimensions.h
660else
661exit
662endif
663endif
664
665cd dimension
666./makdim $dim
667cat $libf/grid/dimensions.h
668
669cd $LMDGCM
670set libo=$libo/$nomlib
671if ( ! -d $libo )  then
672   mkdir $libo
673   cd $model
674endif
675
676########################################################################
677# Differentes dynamiques (3d, 2d, 1d)
678########################################################################
679
680set dimension=`echo $dim | wc -w`
681echo dimension $dimension
682if ( $dimension == 1 ) then
683echo pas de dynamique
684set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
685endif
686endif
687cd $model
688if ( $dimension == 3 ) then
689cd libf/grid
690\rm fxyprim.h
691cp -p fxy_${grille}.h fxyprim.h
692endif
693
694######################################################################
695#   Traitement special pour le nouveau rayonnement de Laurent Li.
696######################################################################
697
698#if ( -f $libf/phy$physique/raddim.h ) then
699# if ( -f $libf/phy$physique/raddim.$dimh.h ) then
700#  \rm -f $libf/phy$physique/raddim.h
701#  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
702#  echo $libf/phy$physique/raddim.$dimh.h
703#  cat $libf/phy$physique/raddim.$dimh.h
704#  cat $libf/phy$physique/raddim.h
705# else
706#  echo On peut diminuer la taille de l executable en creant
707#  echo le fichier $libf/phy$physique/raddim.$dimh.h
708#  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
709# endif
710#endif
711
712######################################################################
713# Gestion du filtre qui n'existe qu'en 3d.
714######################################################################
715
716if ( `expr $dimc \> 2` == 1 ) then
717   set filtre="FILTRE=$filtre"
718else
719   set filtre="FILTRE= L_FILTRE= "
720endif
721echo MACRO FILTRE $filtre
722
723echo $dimc
724
725########################################################################
726#  Avant de lancer le make, on recree le makefile si necessaire
727########################################################################
728########################################################################
729# c'est a dire dans 3 cas:
730# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
731#    derniere creation du makefile
732# 2. si le fichier contenant cette liste "liste_des_sources"
733#    n'existe pas.
734# 3. Si le makefile n'existe pas.
735########################################################################
736##########################################
737# On adapte d'abord certains include à F90
738##########################################
739##########################################
740cd $model
741find libf -name '*.[Fh]' -print >! tmp77
742find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90
743find libf -name '*.[Fh]90' -print >> tmp90
744
745if (    `diff tmp77 liste_des_sources_f77 | wc -w` \
746     || `diff tmp90 liste_des_sources_f90 | wc -w` \
747     || ! -f makefile \
748     || ! -f liste_des_sources_f90 \
749     || ! -f liste_des_sources_f77 ) then
750        echo les fichiers suivants ont ete crees ou detruits
751        echo ou les fichiers suivants sont passes ou ne sont plus en Fortran 90
752        diff liste_des_sources_f77 tmp77
753        diff liste_des_sources_f90 tmp90
754        \cp tmp77 liste_des_sources_f77
755        \cp tmp90 liste_des_sources_f90
756        echo On recree le makefile
757        ./create_make_gcm >! tmp
758        \mv tmp makefile
759        echo Nouveau makefile cree.
760endif
761
762########################################################################
763#  Execution de la comande make
764########################################################################
765
766echo PHYSIQUE $phys
767echo dynamique $dyn $dimension
768echo OPTIM="$optim" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code
769echo PATH pour les fichiers INCLUDE $include
770echo OPLINK="$oplink"
771
772#################
773if $HP then
774#################
775   set f77='fort77 +OP'
776   set f90='jensaisrien'
777   set opt_link="$opt_link -lm"
778#################
779else  if $VPP then
780#################
781   set f77=frt
782   set f90=$f77
783   if ($couple == true) then
784     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"
785     set oplink="-Wl,-t,-P,-dy "
786   else
787     set opt_link="-Wg,-c -L$MODIPSLDIR -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a"
788     set oplink="-Wl,-t,-dy "
789   endif
790   if ($veget == true) then
791     set opt_link="$opt_link $link_veget -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a"
792   endif
793#################
794else if $CRAY then
795#################
796   set f77=f90
797   set f90=f90
798#################
799else if $LINUX then
800#################
801#   set f77=pgf90
802#   set f90=pgf90
803   set f77=$FC_LINUX
804   set f90=$FC_LINUX
805   if ( $FC_LINUX == 'pgf90' ) then
806     if ( $io == "ioipsl" ) then
807       set opt_link=" -L$MODIPSLDIR $link_veget -L$NCDFLIB -lioipsl -lnetcdf "
808     else
809       set opt_link=" -L$MODIPSLDIR $link_veget -L$NCDFLIB -lnetcdf "
810     endif
811   else if ($FC_LINUX == 'g95') then
812     if ( $io == "ioipsl" ) then
813       set opt_link="-L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf -lioipsl -lnetcdf "
814     else
815       set opt_link="-L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf -lnetcdf "
816     endif
817   else
818     set opt_link=" "
819   endif
820#################
821else if $SUN then
822#################
823   set f77=f90
824   set f90=f90
825   if ( $io == "ioipsl" ) then
826     set opt_link="-lf77compat -L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf "
827   else
828     set opt_link="-lf77compat -L$MODIPSLDIR $link_veget -L$NCDFLIB -lnetcdf "
829   endif
830#################
831else if $NEC then
832#################
833   set f77=f90 -ftrace
834   set f90=f90 -ftrace
835   set opt_link="-L$MODIPSLDIR"
836   if ($veget == true) then
837     set opt_link="$opt_link $link_veget"
838   endif
839   if ($couple == true) then
840     set opt_link="$opt_link -lioipsl -loasis2.4_mpi2 -float0 -ew -P static $NCDFLIB "
841   else
842     set opt_link="$opt_link -L$MODIPSLDIR -lioipsl -float0 -ew -P static $NCDFLIB "
843   endif
844   set mod_loc_dir="./"
845#################
846else if $XNEC then
847#################
848   set f77="sxmpif90 -ftrace"
849   set f90="sxmpif90 -ftrace"
850   if $MODIPSL then
851     set opt_link="-L$MODIPSLDIR"
852     if ($veget == true) then
853       set opt_link="$opt_link $link_veget"
854     endif
855     if ($couple == true) then
856       if ($psmile == true) then
857       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
858       else
859       set opt_link="$opt_link -lsxioipsl -loasis2.4_mpi2 -float0 $optdbl -P static $NCDFLIB "
860       endif
861     else
862       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
863     endif
864   else
865     if ($couple == true) then
866       set opt_link="-L$MODIPSLDIR"
867       set opt_link="$opt_link $link_veget -lsxioipsl -loasis2.4_mpi2 -float0 $optdbl -P static $NCDFLIB "
868     else
869       set opt_link=" -C hopt -float0 $optdbl -P static -L$MODIPSLDIR $link_veget -lsxioipsl $NCDFLIB "
870     endif
871   endif
872   set mod_loc_dir="./"
873##################
874else if $X6NEC then
875##################
876   set f77=sxmpif90
877   set f90=sxmpif90
878   if $MODIPSL then
879     set opt_link="$opt_link -L$MODIPSLDIR"
880     if ($veget == true) then
881       set opt_link="$opt_link $link_veget"
882     endif
883     if ($couple == true) then
884        if ($psmile == true) then
885        set opt_link="$opt_link -lsxioipsl -float0 -size_t64 $optdbl -P static $NCDFLIB "
886        else
887        set opt_link="$opt_link -lsxioipsl -loasis2.4_mpi2 -float0 -size_t64 $optdbl -P static $NCDFLIB "
888        endif
889     else
890       set opt_link="$opt_link -lsxioipsl -float0 -size_t64 $optdbl -P static $NCDFLIB "
891     endif
892   else
893#     set opt_link=" -float0 -size_t64 $optdbl -P static -L$MODIPSLDIR -lsxsechiba -lsxparameters -lsxstomate -lsxioipsl $NCDFLIB "
894     set opt_link=" $opt_link -float0 -size_t64 $optdbl -P static -L$MODIPSLDIR -lsxioipsl $NCDFLIB "
895
896   endif
897   set mod_loc_dir="./"
898##################
899else if $X8BRODIE then
900##################
901   set f77=sxmpif90
902   set f90=sxmpif90
903   if $MODIPSL then
904     set opt_link="$opt_link -float0 -Wf,-A dbl4 -L$MODIPSLDIR -lblas"
905     if ($veget == true) then
906       set opt_link="$opt_link $link_veget"
907     endif
908     if ($couple == true) then
909       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
910     else
911       set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB "
912     endif
913   else
914#     set opt_link=" -float0 $optdbl -P static -L$MODIPSLDIR -lsxsechiba -lsxparameters -lsxstomate -lsxioipsl $NCDFLIB "
915     set opt_link=" -float0 $optdbl -P static -L$MODIPSLDIR -lsxioipsl $NCDFLIB -lblas"
916
917   endif
918   set mod_loc_dir="./"
919#################
920else
921#################
922   set f77=f77
923   set f90=f90
924endif
925
926cd $model
927
928if $VPP then
929set make="gmake RANLIB=ls"
930else if $CRAY then
931set make="make RANLIB=ls"
932else if $NEC then
933set make="make RANLIB=ls"
934else if $LINUX then
935set make="make -k RANLIB=ranlib"
936else if $XNEC then
937set make="gmake RANLIB=ls"
938else if $X6NEC then
939set make="gmake RANLIB=ls"
940else if $X8BRODIE then
941set make="gmake RANLIB=ls"
942else
943set make="make RANLIB=ranlib"
944endif
945
946
947
948
949#
950# etat0_netcdf a besoin d'info de la physique
951# A revoir
952set include="$include"' -I$(LIBF)/phy'"$physique"
953#
954# le programme principal create_limit a besoin de l'info du module
955# startvar: on met donc libo dans les include pour Nec
956set include="$include"' -I$(LIBO)'
957
958
959#################################################################
960# Execution de la comande make... ENFIN!
961#################################################################
962
963if $VPP then
964  set optim90=" $optim90 -Am -M$libo"
965  set optimtru90="$optim90"
966 \cp $IOIPSLDIR/*.mod $libo
967else if $SUN then
968 set optim90=" $optim90 -M$libo -M$MODIPSLDIR "
969 set optimtru90=" $optimtru90 -M$libo -M$MODIPSLDIR "
970 set optim="$optim90"
971 \cp $IOIPSLDIR/*.mod $libo
972else if $NEC then
973 set optim90=" $optim90 -I$libo "
974else if $XNEC then
975 set optim90=" $optim90 -I$libo "
976 set optimtru90=" $optimtru90 -I$libo "
977else if $X6NEC then
978 set optim90=" $optim90 -I$libo "
979 set optimtru90=" $optimtru90 -I$libo "
980else if $X8BRODIE then
981 set optim90=" $optim90 -I$libo "
982 set optimtru90=" $optimtru90 -I$libo "
983else if $LINUX then
984 if ( $FC_LINUX == "pgf90" ) then
985   set optimtru90=" $optimtru90 -module $libo "
986   set optim90=" $optim90 -module $libo "
987 else if ( $FC_LINUX == 'g95' ) then
988   set optimtru90=" $optimtru90 -fmod=$libo  "
989   set optim90=" $optim90 -fmod=$libo  "
990 endif
991 set optim="$optim90"
992 set mod_loc_dir=$libo
993# \cp /d3/fairhead/sechiba/ioipsl/*.mod $libo
994# \cp $IOIPSLDIR/*.mod $libo
995endif
996
997set link="$f90 $optim90"
998
999set ar=ar
1000
1001if $XNEC then
1002  set link="sxld $opt_link"
1003  set link="$f90 "
1004#  set ar=sxar
1005else if $X6NEC then
1006  set link="sxld $opt_link"
1007  set link="$f90 -Wl,-hlib_cyclic "
1008else if $X8BRODIE then
1009  set link="sxld $opt_link"
1010  set link="$f90 -Wl,-hlib_cyclic "
1011endif
1012
1013
1014cd $localdir
1015
1016echo $make -f $LMDGCM/makefile \
1017OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
1018OPTIM90="$optim90" \
1019OPTIMTRU90="$optimtru90" \
1020OPTIM="$optim$optimbis" \
1021INCLUDE="$include" \
1022$filtre \
1023LIBO=$libo \
1024$dyn \
1025$phys \
1026DIM=$dimc \
1027FLAG_PARA="$FLAG_PARA"\
1028L_ADJNT="$adjnt" \
1029L_CHIMIE="$libchimie" \
1030LOCAL_DIR="$localdir"  \
1031F77="$f77" \
1032F90="$f90" \
1033OPLINK="$oplink" \
1034LINK="$link" \
1035GCM="$LMDGCM" \
1036MOD_LOC_DIR=$mod_loc_dir \
1037MOD_SUFFIX=$mod_suffix \
1038AR=$ar \
1039PROG=$code
1040
1041$make -f $LMDGCM/makefile \
1042OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
1043OPTIM90="$optim90" \
1044OPTIMTRU90="$optimtru90" \
1045OPTIM="$optim$optimbis" \
1046INCLUDE="$include" \
1047$filtre \
1048LIBO=$libo \
1049$dyn \
1050$phys \
1051DIM=$dimc \
1052FLAG_PARA="$FLAG_PARA"\
1053L_ADJNT="$adjnt" \
1054L_CHIMIE="$libchimie" \
1055LOCAL_DIR="$localdir"  \
1056F77="$f77" \
1057F90="$f90" \
1058OPLINK="$oplink" \
1059LINK="$link" \
1060GCM="$LMDGCM" \
1061MOD_LOC_DIR=$mod_loc_dir \
1062MOD_SUFFIX=$mod_suffix \
1063AR=$ar \
1064PROG=$code
1065
1066\rm -f $libf/grid/dimensions.h
Note: See TracBrowser for help on using the repository browser.