source: trunk/LMDZ.COMMON/makelmdz @ 1521

Last change on this file since 1521 was 1521, checked in by emillour, 9 years ago

All GCMs: Updates to make planetary codes (+Earth) setups converge.

  • Made a "phy_common" directory in libf, to contain routines common (wrt structural nature of underlying code/grid) to all LMDZ-related physics packages.
  • moved all "mod_phys_*" and "mod_grid_phy_lmdz" files from dynlonlat_phylonlat to "phy_common"
  • moved "ioipsl_getincom_p.F90 from "misc" to "phy_common" and modified it to match Earth GCM version and renamed it ioipsl_getin_p_mod.F90
  • added an "abort_physics" (as in Earth GCM) in "phy_common"
  • added a "print_control_mod.F90 (as in Earth GCM) in phy_common
  • made similar changes in LMDZ.GENERIC and LMDZ.MARS

EM

  • Property svn:executable set to *
File size: 25.2 KB
Line 
1#!/bin/bash
2#
3# $Id $
4#
5#
6########################################################################
7# for debug, uncomment line below
8#set -xv
9########################################################################
10# options par defaut pour la commande make
11########################################################################
12dim="96x72x19"
13physique=lmd
14code=gcm
15filtre=filtrez
16grille=reg
17couple=false
18veget=false
19chimie=false
20parallel=none
21paramem="par"
22compil_mod=prod
23io=ioipsl
24LIBPREFIX=""
25fcm_path=none
26cosp=false
27sisvat=false
28rrtm=false
29bands=""
30scatterers=""
31full=''
32
33# guess a default 'arch'
34arch="local" # start with assuming we're on a local machine with local arch file
35## try to recognise machine and infer arch from it
36machine=`hostname`
37if [[ "${machine:0:3}" == "ada" ]]
38then
39  arch="X64_ADA"
40fi
41if [[ "${machine:0:7}" == "platine" ]]
42then
43  arch="IA64_PLATINE"
44fi
45if [[ "${machine:0:6}" == "titane" ]]
46then
47  arch="X64_TITANE"
48fi
49if [[ "${machine:0:8}" == "mercure1" ]]
50then
51  arch="SX8_MERCURE"
52fi
53if [[ "${machine:0:8}" == "mercure2" ]]
54then
55  arch="SX9_MERCURE"
56fi
57
58LMDGCM=`pwd -P`
59LIBFGCM=$LMDGCM/libf
60LIBOGCM=$LMDGCM/libo
61if [[ ! -d $LIBOGCM ]]
62then
63  # create the directory
64  mkdir $LIBOGCM
65  if [[ ! $? ]]
66  then
67  echo "Failed to create directory $LIBOGCM"
68  exit
69  fi
70fi
71COSP_PATH=$LMDGCM/.void_dir
72
73
74
75localdir=`pwd -P`
76########################################################################
77#  Quelques initialisations de variables du shell.
78########################################################################
79
80CPP_KEY="" 
81INCLUDE='-I$(LIBF)/grid -I$(LIBF)/misc -I$(LIBF)/filtrez -I. '
82LIB=""
83adjnt=""
84##COMPIL_FFLAGS="%PROD_FFLAGS"
85PARA_FFLAGS=""
86PARA_LD=""
87EXT_SRC=""
88#src_dirs: directories containing source files
89src_dirs="grid misc" 
90ccompiler=""
91OPTIMC=""
92INCLUDEC=""
93
94########################################################################
95# lecture des options
96########################################################################
97
98while (($# > 0))
99  do
100  case $1 in
101      "-h") cat <<fin
102manuel complet sur http://...
103Usage :
104makeldmz [options] -arch arch exec
105[-h]                       : brief help
106[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
107[-s nscat]                 : (Generic) Number of radiatively active scatterers
108[-b IRxVIS]                : (Generic) Number of infrared (IR) and visible (VIS) bands for radiative transfer
109[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
110[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug .
111[-c false/MPI1/MPI2]       : (Earth) coupling with ocean model : MPI1/MPI2/false (default: false)
112[-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false)
113          false       : no vegetation model
114          orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version)
115          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
116          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
117
118[-chimie INCA/false]       : (Earth) with INCA chemistry model or without (default: false)
119[-cosp cosp/false]         : (Earth) add the cosp model (default: false)
120[-sisvat true/false]  : (Earth) compile with/without sisvat package (default: false)
121[-rrtm true/false]    : (Earth) compile with/without rrtm package (default: false)
122[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
123[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
124[-io ioipsl/mix/xios]                   : Input/Output library (default: ioipsl)
125[-include INCLUDES]        : extra include path to add
126[-cpp CPP_KEY]             : additional preprocessing definitions
127[-adjnt]                   : adjoint model, not operational ...
128[-mem]                     : reduced memory dynamics (if in parallel mode)
129[-filtre NOMFILTRE]        : use filtre from libf/NOMFILTRE (default: filtrez)
130[-link LINKS]              : additional links with other libraries
131[-full]                    : full (re-)compilation (from scratch)
132[-ext_src path]            : path to an additional set of routines to compile with the model
133 -arch arch                : target architecture
134 exec                      : executable to build
135fin
136          exit;;
137      "-d")
138          dim=$2 ; shift ; shift ;;
139     
140      "-p")
141          physique="$2" ; shift ; shift ;;
142
143      "-s")
144          scatterers=$2 ; shift ; shift ;;
145
146      "-b")
147          bands=$2 ; shift ; shift ;;
148
149      "-g")
150          grille="$2" ; shift ; shift ;;
151
152      "-c")
153          couple="$2" ; shift ; shift ;;
154
155      "-prod")
156          compil_mod="prod" ; shift ;;
157
158      "-dev")
159          compil_mod="dev" ; shift ;;
160
161      "-debug")
162          compil_mod="debug" ; shift ;;
163
164      "-io")
165          io="$2" ; shift ; shift ;;
166
167      "-v")
168          veget="$2" ; shift ; shift ;;
169
170      "-chimie")
171          chimie="$2" ; shift ; shift ;;
172
173      "-parallel")
174          parallel="$2" ; shift ; shift ;;
175     
176      "-include")
177          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
178
179      "-cpp")
180          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
181
182      "-cosp")
183          cosp="$2" ; shift ; shift ;;
184     
185      "-sisvat")
186          sisvat="$2" ; shift ; shift ;;
187     
188      "-rrtm")
189          rrtm="$2" ; shift ; shift ;;
190     
191      "-mem")
192          paramem="mem" ; shift ;;
193
194      "-filtre")
195          filtre=$2 ; shift ; shift ;;
196
197      "-link")
198          LIB="$LIB $2" ; shift ; shift ;;
199
200      "-full")
201          full="full" ; shift ;;
202
203      "-ext_src")
204          EXT_SRC=$2 ; shift ; shift ;;
205
206      "-arch")
207          arch=$2 ; shift ; shift ;;
208
209      *)
210          code="$1" ; shift ;;
211  esac
212done
213
214###############################################################
215# lecture des chemins propres \`a l'architecture de la machine #
216###############################################################
217rm -f .void_file
218echo > .void_file
219rm -rf .void_dir
220mkdir .void_dir
221rm -f arch.path
222if [[ -r arch/arch-${arch}.path ]]
223then
224  ln -s arch/arch-${arch}.path ./arch.path
225  source arch.path
226else
227  echo "Error: missing arch/arch-${arch}.path file !"
228  exit
229fi
230rm -f arch.fcm
231if [[ -r arch/arch-${arch}.fcm ]]
232then
233  ln -s arch/arch-${arch}.fcm arch.fcm
234else
235  echo "Error: missing arch/arch-${arch}.fcm file !"
236  exit
237fi
238########################################################################
239# Definition des clefs CPP, des chemins des includes et modules
240#  et des libraries
241########################################################################
242
243# basic compile flags from arch.fcm file
244archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm )
245COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} )
246
247# other compile flags, depending on compilation mode
248if [[ "$compil_mod" == "prod" ]]
249then
250## read COMPIL_FFLAGS from arch.fcm file
251  archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm )
252  archfileopt=$( echo ${archfileline##%PROD_FFLAGS} )
253  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
254elif [[ "$compil_mod" == "dev" ]]
255then
256## read %DEV_FFLAGS from arch.fcm file
257  archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm )
258  archfileopt=$( echo ${archfileline##%DEV_FFLAGS} )
259  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
260elif [[ "$compil_mod" == "debug" ]]
261then
262## read %DEBUG_FFLAGS from arch.fcm file
263  archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm )
264  archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} )
265  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
266fi
267
268# add CPP_KEY defined in arch.fcm file
269archfileline=$( grep -i '^%FPP_DEF' arch.fcm )
270archfileopt=$( echo ${archfileline##%FPP_DEF} )
271CPP_KEY="$CPP_KEY ${archfileopt}"
272
273# get compiler name from arch.fcm file
274archfileline=$( grep -i '^%COMPILER' arch.fcm )
275fcompiler=$( echo ${archfileline##%COMPILER} )
276
277# get linker name from arch.fcm file
278archfileline=$( grep -i '^%LINK' arch.fcm )
279linker=$( echo ${archfileline##%LINK} )
280
281# get ar command from arch.fcm file
282archfileline=$( grep -i '^%AR' arch.fcm )
283arcommand=$( echo ${archfileline##%AR} )
284
285# get make utility from arch.fcm file
286archfileline=$( grep -i '^%MAKE' arch.fcm )
287makecommand=$( echo ${archfileline##%MAKE} )
288
289# get basic libraries to link with arch.fcm file
290archfileline=$( grep -i '^%BASE_LD' arch.fcm )
291archfileopt=$( echo ${archfileline##%BASE_LD} )
292LIB="$LIB  ${archfileopt}"
293
294#NB some -I... might be located in the %FPP_FLAGS section of the arch file
295archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm )
296for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done
297
298phys_root=$physique
299if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi
300if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi
301if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi
302if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi
303if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi
304if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi
305if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi
306
307if [[ "$physique" != "nophys" ]]
308then
309   #We'll use some physics
310   src_dirs="$src_dirs phy_common phy$physique"
311   LIBPHY='$(LIBO)/libphy'"$physique"'.a'
312   LIBPHY_COMMON='$(LIBO)/libphy_common.a'
313   lib_phy='-lphy'"$physique"' -lphy_common'
314   CPP_KEY="$CPP_KEY CPP_PHYS"
315   if [[ "${phys_root}" == "lmd" ]]
316   then
317   #For lmd physics, default planet type is Earth
318   CPP_KEY="$CPP_KEY CPP_EARTH"
319   fi
320fi
321
322######### CAS PARTICULIER CHIMIE TITAN
323if [[ "$physique" == "titan" ]]
324then
325   INCLUDE="$INCLUDE"' -I$(LIBF)/chim'"$physique"
326   LIB="$LIB -l${LIBPREFIX}chim$physique"
327   opt_dep="$opt_dep chim$physique"
328   src_dirs="$src_dirs chim$physique"
329# get C compiler name and optim from arch.fcm file
330   archfileline=$( grep -i '^%C_COMPILER' arch.fcm )
331   ccompiler=$( echo ${archfileline##%C_COMPILER} )
332   archfileline=$( grep -i '^%C_OPTIM' arch.fcm )
333   coptim=$( echo ${archfileline##%C_OPTIM} )
334   OPTIMC="${coptim}"
335   INCLUDEC='-I$(LIBF)/grid -I.'
336fi
337#########
338
339# for Mars (but could be used by others as well), there is also "aeronomars"
340if [[ -d ${LIBFGCM}/aerono${physique} ]]
341then
342   src_dirs="$src_dirs aerono$physique"
343   INCLUDE="$INCLUDE -I${LIBFGCM}/aerono${physique}"
344   LIB="$LIB -l${LIBPREFIX}aerono$physique"
345   opt_dep="$opt_dep aerono$physique"
346   laeronomars="-l${LIBPREFIX}aeronomars"
347fi
348
349
350if [[ "$chimie" == "INCA" ]]
351then
352   CPP_KEY="$CPP_KEY INCA"
353   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
354   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
355   libchimie=" -L${INCA_LIBDIR} -lchimie"
356fi
357
358if [[ "$couple" != "false" ]]
359then
360   CPP_KEY="$CPP_KEY CPP_COUPLE"
361   INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
362   LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io"
363fi
364
365if [[ "$parallel" == "none" ]]
366then
367  FLAG_PARA=''
368else
369  FLAG_PARA="$paramem"
370fi
371
372if [[ "$parallel" == "mpi" ]]
373then
374   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
375  # MPI additional compilation options
376  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
377  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
378  # MPI additional links
379  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
380  PARA_LD=$( echo ${archfileline##%MPI_LD} )
381elif [[ "$parallel" == "omp" ]]
382then
383   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
384  # OMP additional compilation options
385  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
386  PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} )
387  # OMP additional links
388  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
389  PARA_LD=$( echo ${archfileline##%OMP_LD} )
390elif [[ "$parallel" == "mpi_omp" ]]
391then
392   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
393  # MPI additional compilation options
394  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
395  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
396  # OMP additional compilation options
397  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
398  PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} )
399  # MPI additional links
400  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
401  PARA_LD=$( echo ${archfileline##%MPI_LD} )
402  # OMP additional links
403  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
404  PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} )
405fi
406
407if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
408   && "$compil_mod" == "debug" ]]
409then
410    echo "Usually, parallelization with OpenMP requires some optimization."
411    echo "We suggest switching to \"-dev\"."
412fi
413
414if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
415then
416
417   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
418   CPP_KEY="$CPP_KEY CPP_VEGET"
419# temporary, for Orchidee versions 1.9.* (before openmp activation)
420   if [[ "$veget" == "orchidee1.9" ]] ; then
421      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
422   fi
423   if [[ "$veget" == "orchidee2.0" ]] ; then
424      orch_libs="sechiba parameters stomate parallel orglob orchidee"
425   else
426      orch_libs="sechiba parameters stomate parallel orglob"
427   fi
428   LIB="${LIB} -L${ORCH_LIBDIR}"
429   for lib in ${orch_libs} ; do
430      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
431         LIB="${LIB} -l${LIBPREFIX}$lib "
432      fi
433   done
434elif [[ "$veget" != "false" ]] ; then
435   echo "Option -v $veget does not exist"
436   echo "Use ./makelmdz -h for more information"
437   exit 
438fi
439
440if [[ $io == ioipsl ]]
441then
442   CPP_KEY="$CPP_KEY CPP_IOIPSL"
443   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
444   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
445elif [[ $io == mix ]]
446then
447   # For now, xios implies also using ioipsl
448   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
449   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
450   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
451elif [[ $io == xios ]]
452then
453   # For now, xios implies also using ioipsl
454   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
455   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
456   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
457fi
458
459if [[ "$cosp" == "true" ]]
460then
461   CPP_KEY="$CPP_KEY CPP_COSP"
462   COSP_PATH="$LIBFGCM/cosp"
463   src_dirs="$src_dirs cosp"
464#   LIB="${LIB} -l${LIBPREFIX}cosp"
465   opt_dep="$opt_dep cosp"
466   lcosp="-l${LIBPREFIX}cosp"
467   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
468fi
469
470if [[ "$sisvat" == "true" ]]
471then
472   CPP_KEY="$CPP_KEY CPP_SISVAT"
473   src_dirs="$src_dirs phy${physique}/sisvat"
474fi
475
476if [[ "$rrtm" == "true" ]]
477then
478   CPP_KEY="$CPP_KEY CPP_RRTM"
479   src_dirs="$src_dirs phy${physique}/rrtm"
480fi
481
482
483INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
484LIB="$LIB ${NETCDF_LIBDIR}"
485
486########################################################################
487# calcul du nombre de dimensions
488########################################################################
489
490
491dim_full=$dim
492dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
493set $dim
494dimc=$#
495echo calcul de la dimension
496echo dim $dim
497echo dimc $dimc
498
499
500########################################################################
501# Gestion des dimensions du modele.
502# on cree ou remplace le fichier des dimensions
503########################################################################
504
505cd $LIBFGCM/grid
506if [[ -f dimensions.h ]]
507then
508  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
509  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
510  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
511  echo  vous pouvez continuer en repondant oui.
512  echo "Voulez-vous vraiment continuer?"
513  echo ""
514  echo "WARNING: you are probably already compiling the model somewhere else."
515  echo "Wait until the first compilation is finished before launching this one."
516  echo "If you are sure that you are not compiling elsewhere, just answer "
517  echo "yes (or 'oui') to the question below to proceed."
518  echo "Do you wish to continue?"
519  read reponse
520  if [[ $reponse == "oui" || $reponse == "yes" ]]
521  then
522    \rm -f $LIBFGCM/grid/dimensions.h
523  else
524    exit
525  fi
526fi
527
528
529cd $LIBFGCM/grid/dimension
530./makdim $dim
531if (($? != 0))
532then
533    exit 1
534fi
535
536cat $LIBFGCM/grid/dimensions.h
537cd $LMDGCM
538
539if [[ "$bands" != "" ]]
540then
541  # Generic model, recreate bands.h (IR & VIS bands for radiative transfer)
542  bands=$(echo $bands | sed -e 's/[^0-9]/ /g')
543  cd $LIBFGCM/phy$physique/bands
544  ./makbands $bands
545  cat $LIBFGCM/phy$physique/bands.h
546  cd $LMDGCM
547fi
548
549if [[ "$scatterers" != "" ]]
550then
551  # Generic model, recreate scatterers.h
552  cd $LIBFGCM/phy$physique/scatterers
553  ./make_scatterers $scatterers
554  cat $LIBFGCM/phy$physique/scatterers.h
555  cd $LMDGCM
556fi
557
558
559########################################################################
560# Differentes dynamiques (3d, 2d, 1d)
561########################################################################
562
563if (( $dimc == 3 )) ; then
564   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
565   if [[ $physique != "nophys" ]] ; then
566     src_dirs="$src_dirs dynlonlat_phylonlat dynlonlat_phylonlat/phy${phys_root}"
567     libdyn_phy="-ldynlonlat_phylonlat"
568     LIBDYN_PHYS='$(LIBO)/libdynlonlat_phylonlat.a'
569     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat'
570     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat/'"${phys_root}"
571   fi
572  cd $LIBFGCM/grid
573  \rm fxyprim.h
574  cp -p fxy_${grille}.h fxyprim.h
575  filtre="FILTRE=$filtre"
576  INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
577elif (( $dimc == 2 )) ; then
578   src_dirs="$src_dirs dyn2d"
579   filtre="FILTRE= L_FILTRE= "
580   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
581elif (( $dimc == 1 )) ; then
582   echo pas de dynamique
583   src_dirs="$src_dirs phy${physique}/dyn1d"
584   CPP_KEY="$CPP_KEY CPP_1D"
585   filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
586   #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
587   INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d'
588else
589   echo Dimension dimc=$dimc pas prevu ; exit
590fi
591
592cd $LMDGCM
593
594########################################################################
595# library directory name:
596########################################################################
597
598nomlib=`echo ${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_parall${parallel}_${CPP_KEY}_${FLAG_PARA} | sed -e 's/ //g' -e 's/-//g ' | sed -e 's/CPP_//g'`
599echo "Path to library: "$nomlib
600
601########################################################################
602#  Cleanup for a full recompilation, if requested
603########################################################################
604
605if [[ $full == "full" ]]
606then
607# remove makefile and libraries
608  echo "-full option: recompiling from scratch"
609  \rm -f makefile
610  \rm -rf "${LIBOGCM}/${nomlib}"
611fi
612
613########################################################################
614#  Avant de lancer le make, on recree le makefile si necessaire
615########################################################################
616########################################################################
617# c'est a dire dans 3 cas:
618# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
619#    derniere creation du makefile
620# 2. si le fichier contenant cette liste "liste_des_sources"
621#    n'existe pas.
622# 3. Si le makefile n'existe pas.
623########################################################################
624cd $LMDGCM
625
626
627if [[ -r .makelmdz ]]
628then
629old_lmdz_configuration=$(cat .makelmdz )
630else
631old_lmdz_configuration=""
632fi
633lmdz_configuration="$src_dirs"
634if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
635then
636  configuration_change="true"
637else
638  configuration_change="false"
639fi
640
641mkdir -p make_dir
642suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'`
643echo suf_make $suf_make
644
645\rm tmp77 tmp90
646for dir in $src_dirs ; do
647find libf/$dir -name '*.[Fh]' -print | sort >> tmp77
648find libf/$dir -name '*.F90' -print | sort >> tmp90
649######### CAS PARTICULIER CHIMIE TITAN
650if [[ "$physique" == "titan" ]]
651then 
652  find libf -name '*.[ch]' -print | sort > tmpC
653fi
654#########
655done
656
657liste77=make_dir/liste_des_sources_f77_$suf_make
658liste90=make_dir/liste_des_sources_f90_$suf_make
659if [[ "$physique" == "titan" ]] ; then
660listeC=make_dir/liste_des_sources_C_$suf_make
661fi
662makefile=make_dir/makefile_$suf_make
663
664if [[ $configuration_change == "true" || ! ( -r makefile ) || ! ( -r $liste90 ) || ! ( -r $liste77 ) || ` diff tmp77 $liste77 | wc -w ` -ne 0 || ` diff tmp90 $liste90 | wc -w ` -ne 0 ]]
665then
666  echo "les fichiers suivants ont ete crees ou detruits"
667  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
668  diff $liste77  tmp77
669  diff $liste90 tmp90
670  \cp -f tmp77 $liste77
671  \cp -f tmp90 $liste90
672######### CAS PARTICULIER CHIMIE TITAN
673  if [[ "$physique" == "titan" ]]
674  then 
675  diff $listeC tmpC
676  \cp -f tmpC $listeC
677  fi
678#########
679  echo "Recreating the makefile"
680  echo "src_dirs: $src_dirs"
681  ./create_make_gcm $src_dirs > tmp
682  \mv -f tmp $makefile
683  echo "New makefile created"
684######### CAS PARTICULIER CHIMIE TITAN
685else if [[ "$physique" == "titan" ]]
686 then
687   if [[ ! ( -r $listeC ) || ` diff tmpC $listeC | wc -w ` -ne 0 ]]
688   then
689     diff $listeC tmpC
690     \cp -f tmpC $listeC
691     echo "on recree le makefile"
692     ./create_make_gcm $src_dirs > tmp
693     \mv -f tmp $makefile
694     echo "Nouveau makefile cree"
695   fi
696 fi
697#########
698fi
699
700ln -sf $makefile makefile
701
702#Create a .makelmdz file containing main compilation option for later comparisons
703echo "$lmdz_configuration" > .makelmdz
704
705#################################################################
706# Preparation de l'execution de la commande make
707#################################################################
708
709# find code suffix and directory where code is located
710if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F ]]
711then
712  source_code=${code}.F
713  dirmain=dyn${dimc}d${FLAG_PARA}
714else
715  if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
716  then
717    source_code=${code}.F90
718    dirmain=dyn${dimc}d${FLAG_PARA}
719  else
720    if [[ -r $LMDGCM/libf/phy${physique}/${code}.F ]]
721    then
722      source_code=${code}.F
723      dirmain=phy${physique}
724    else
725      if [[ -r $LMDGCM/libf/phy${physique}/${code}.F90 ]]
726      then
727        source_code=${code}.F90
728        dirmain=phy${physique}
729      else
730        if [[ -r $LMDGCM/libf/dynlonlat_phylonlat/phy$phys_root/${code}.F ]] 
731        then
732          source_code=${code}.F
733          dirmain="dynlonlat_phylonlat/phy${phys_root}"
734        else
735          if [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F ]]
736          then
737            source_code=${code}.F
738            dirmain=phy$physique/dyn1d
739          else
740            echo "Error: cannot find ${code}.F[90]"
741            echo " neither in dyn${dimc}d${FLAG_PARA} nor in phy${physique}"
742            exit
743          fi
744        fi
745      fi
746    fi
747  fi
748fi
749
750if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
751then
752  mkdir ${LIBOGCM}/${nomlib}
753  # check we indeed managed to create the directory
754  if [[ ! $? ]]
755  then
756    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
757    exit
758  fi
759fi
760
761# where module files are created
762mod_loc_dir=$localdir
763
764if [[ "$physique" != "nophys" ]]
765then
766  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
767#  phys="PHYS=$physique"
768#else
769#  # trick to avoid having a physics-related library in the makefile
770#  phys="L_PHY= LIBPHY="
771fi
772INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
773#if (( $dimension == 1 ))
774#then
775# INCLUDE="$INCLUDE"' -I$(LIBF)/dyn3d -I'${LIBOGCM}/${nomlib}
776#else
777#INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
778#fi
779
780# ranlib utility (check it exists or else default to ls)
781if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
782then
783  ranlib="ranlib"
784else
785  ranlib="ls"
786fi
787
788# add CPP keys to COMPIL_FLAGS
789# (but first add -D before all CPP_KEY items)
790cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
791# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
792if [[ "${fcompiler:0:3}" == "xlf" ]]
793then
794cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
795fi
796COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
797
798#################################################################
799# Execution du make
800#################################################################
801echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
802OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
803OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
804OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
805OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
806OPTIMC="$OPTIMC" \
807INCLUDE="$INCLUDE" \
808INCLUDEC="$includec" \
809$filtre \
810LIBO=${LIBOGCM}/${nomlib} \
811"PHYS=$physique" \
812LIBPHY=${LIBPHY} \
813LIBPHY_COMMON=${LIBPHY_COMMON} \
814LIBDYN_PHYS=${LIBDYN_PHYS} \
815DIM=$dimc \
816FLAG_PARA=$FLAG_PARA \
817L_PHY="$lib_phy" \
818L_DYN_PHY="$libdyn_phy" \
819L_ADJNT=$adjnt \
820L_COSP="$lcosp" \
821L_AERONOMARS="$laeronomars" \
822L_CHIMIE="$libchimie" \
823LOCAL_DIR="$localdir"  \
824F77="$fcompiler" \
825F90="$fcompiler" \
826CCC="$ccompiler" \
827OPLINK="$LIB" \
828LINK="$linker" \
829GCM="$LMDGCM" \
830MOD_LOC_DIR=$mod_loc_dir \
831MOD_SUFFIX="mod" \
832AR=$arcommand \
833DIRMAIN=$dirmain \
834SOURCE=$source_code \
835PROG=$code
836
837$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
838OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
839OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
840OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
841OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
842OPTIMC="$OPTIMC" \
843INCLUDE="$INCLUDE" \
844INCLUDEC="$includec" \
845$filtre \
846LIBO=${LIBOGCM}/${nomlib} \
847"PHYS=$physique" \
848LIBPHY=${LIBPHY} \
849LIBPHY_COMMON=${LIBPHY_COMMON} \
850LIBDYN_PHYS=${LIBDYN_PHYS} \
851DIM=$dimc \
852FLAG_PARA=$FLAG_PARA \
853L_PHY="$lib_phy" \
854L_DYN_PHY="$libdyn_phy" \
855L_ADJNT="$adjnt" \
856L_COSP="$lcosp" \
857L_AERONOMARS="$laeronomars" \
858L_CHIMIE="$libchimie" \
859LOCAL_DIR="$localdir"  \
860F77="$fcompiler" \
861F90="$fcompiler" \
862CCC="$ccompiler" \
863OPLINK="$LIB" \
864LINK="$linker" \
865GCM="$LMDGCM" \
866MOD_LOC_DIR=$mod_loc_dir \
867MOD_SUFFIX="mod" \
868AR=$arcommand \
869DIRMAIN=$dirmain \
870SOURCE=$source_code \
871PROG=$code
872
873if [[ -r $LIBFGCM/grid/dimensions.h ]]
874then
875  # Cleanup: remove dimension.h file
876  \rm -f $LIBFGCM/grid/dimensions.h
877fi
Note: See TracBrowser for help on using the repository browser.