source: trunk/LMDZ.COMMON/makelmdz @ 1421

Last change on this file since 1421 was 1403, checked in by emillour, 10 years ago

All models: Reorganizing the physics/dynamics interface.

  • makelmdz and makelmdz_fcm scripts adapted to handle the new directory settings
  • misc: (replaces what was the "bibio" directory)
  • Should only contain extremely generic (and non physics or dynamics-specific) routines
  • Therefore moved initdynav.F90, initfluxsto.F, inithist.F, writedynav.F90, write_field.F90, writehist.F to "dyn3d_common"
  • dynlonlat_phylonlat: (new interface directory)
  • This directory contains routines relevent to physics/dynamics grid interactions, e.g. routines gr_dyn_fi or gr_fi_dyn and calfis
  • Moreover the dynlonlat_phylonlat contains directories "phy*" corresponding to each physics package "phy*" to be used. These subdirectories should only contain specific interfaces (e.g. iniphysiq) or main programs (e.g. newstart)
  • phy*/dyn1d: this subdirectory contains the 1D model using physics from phy*

EM

  • Property svn:executable set to *
File size: 25.0 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$physique"
311   LIBPHY='$(LIBO)/libphy'"$physique"'.a'
312   lib_phy='-lphy'"$physique"
313   CPP_KEY="$CPP_KEY CPP_PHYS"
314   if [[ "${phys_root}" == "lmd" ]]
315   then
316   #For lmd physics, default planet type is Earth
317   CPP_KEY="$CPP_KEY CPP_EARTH"
318   fi
319fi
320
321######### CAS PARTICULIER CHIMIE TITAN
322if [[ "$physique" == "titan" ]]
323then
324   INCLUDE="$INCLUDE"' -I$(LIBF)/chim'"$physique"
325   LIB="$LIB -l${LIBPREFIX}chim$physique"
326   opt_dep="$opt_dep chim$physique"
327   src_dirs="$src_dirs chim$physique"
328# get C compiler name and optim from arch.fcm file
329   archfileline=$( grep -i '^%C_COMPILER' arch.fcm )
330   ccompiler=$( echo ${archfileline##%C_COMPILER} )
331   archfileline=$( grep -i '^%C_OPTIM' arch.fcm )
332   coptim=$( echo ${archfileline##%C_OPTIM} )
333   OPTIMC="${coptim}"
334   INCLUDEC='-I$(LIBF)/grid -I.'
335fi
336#########
337
338# for Mars (but could be used by others as well), there is also "aeronomars"
339if [[ -d ${LIBFGCM}/aerono${physique} ]]
340then
341   src_dirs="$src_dirs aerono$physique"
342   INCLUDE="$INCLUDE -I${LIBFGCM}/aerono${physique}"
343   LIB="$LIB -l${LIBPREFIX}aerono$physique"
344   opt_dep="$opt_dep aerono$physique"
345   laeronomars="-l${LIBPREFIX}aeronomars"
346fi
347
348
349if [[ "$chimie" == "INCA" ]]
350then
351   CPP_KEY="$CPP_KEY INCA"
352   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
353   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
354   libchimie=" -L${INCA_LIBDIR} -lchimie"
355fi
356
357if [[ "$couple" != "false" ]]
358then
359   CPP_KEY="$CPP_KEY CPP_COUPLE"
360   INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
361   LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io"
362fi
363
364if [[ "$parallel" == "none" ]]
365then
366  FLAG_PARA=''
367else
368  FLAG_PARA="$paramem"
369fi
370
371if [[ "$parallel" == "mpi" ]]
372then
373   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
374  # MPI additional compilation options
375  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
376  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
377  # MPI additional links
378  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
379  PARA_LD=$( echo ${archfileline##%MPI_LD} )
380elif [[ "$parallel" == "omp" ]]
381then
382   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
383  # OMP additional compilation options
384  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
385  PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} )
386  # OMP additional links
387  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
388  PARA_LD=$( echo ${archfileline##%OMP_LD} )
389elif [[ "$parallel" == "mpi_omp" ]]
390then
391   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
392  # MPI additional compilation options
393  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
394  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
395  # OMP additional compilation options
396  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
397  PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} )
398  # MPI additional links
399  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
400  PARA_LD=$( echo ${archfileline##%MPI_LD} )
401  # OMP additional links
402  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
403  PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} )
404fi
405
406if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
407   && "$compil_mod" == "debug" ]]
408then
409    echo "Usually, parallelization with OpenMP requires some optimization."
410    echo "We suggest switching to \"-dev\"."
411fi
412
413if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
414then
415
416   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
417   CPP_KEY="$CPP_KEY CPP_VEGET"
418# temporary, for Orchidee versions 1.9.* (before openmp activation)
419   if [[ "$veget" == "orchidee1.9" ]] ; then
420      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
421   fi
422   if [[ "$veget" == "orchidee2.0" ]] ; then
423      orch_libs="sechiba parameters stomate parallel orglob orchidee"
424   else
425      orch_libs="sechiba parameters stomate parallel orglob"
426   fi
427   LIB="${LIB} -L${ORCH_LIBDIR}"
428   for lib in ${orch_libs} ; do
429      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
430         LIB="${LIB} -l${LIBPREFIX}$lib "
431      fi
432   done
433elif [[ "$veget" != "false" ]] ; then
434   echo "Option -v $veget does not exist"
435   echo "Use ./makelmdz -h for more information"
436   exit 
437fi
438
439if [[ $io == ioipsl ]]
440then
441   CPP_KEY="$CPP_KEY CPP_IOIPSL"
442   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
443   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
444elif [[ $io == mix ]]
445then
446   # For now, xios implies also using ioipsl
447   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
448   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
449   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
450elif [[ $io == xios ]]
451then
452   # For now, xios implies also using ioipsl
453   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
454   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
455   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
456fi
457
458if [[ "$cosp" == "true" ]]
459then
460   CPP_KEY="$CPP_KEY CPP_COSP"
461   COSP_PATH="$LIBFGCM/cosp"
462   src_dirs="$src_dirs cosp"
463#   LIB="${LIB} -l${LIBPREFIX}cosp"
464   opt_dep="$opt_dep cosp"
465   lcosp="-l${LIBPREFIX}cosp"
466   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
467fi
468
469if [[ "$sisvat" == "true" ]]
470then
471   CPP_KEY="$CPP_KEY CPP_SISVAT"
472   src_dirs="$src_dirs phy${physique}/sisvat"
473fi
474
475if [[ "$rrtm" == "true" ]]
476then
477   CPP_KEY="$CPP_KEY CPP_RRTM"
478   src_dirs="$src_dirs phy${physique}/rrtm"
479fi
480
481
482INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
483LIB="$LIB ${NETCDF_LIBDIR}"
484
485########################################################################
486# calcul du nombre de dimensions
487########################################################################
488
489
490dim_full=$dim
491dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
492set $dim
493dimc=$#
494echo calcul de la dimension
495echo dim $dim
496echo dimc $dimc
497
498
499########################################################################
500# Gestion des dimensions du modele.
501# on cree ou remplace le fichier des dimensions
502########################################################################
503
504cd $LIBFGCM/grid
505if [[ -f dimensions.h ]]
506then
507  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
508  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
509  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
510  echo  vous pouvez continuer en repondant oui.
511  echo "Voulez-vous vraiment continuer?"
512  echo ""
513  echo "WARNING: you are probably already compiling the model somewhere else."
514  echo "Wait until the first compilation is finished before launching this one."
515  echo "If you are sure that you are not compiling elsewhere, just answer "
516  echo "yes (or 'oui') to the question below to proceed."
517  echo "Do you wish to continue?"
518  read reponse
519  if [[ $reponse == "oui" || $reponse == "yes" ]]
520  then
521    \rm -f $LIBFGCM/grid/dimensions.h
522  else
523    exit
524  fi
525fi
526
527
528cd $LIBFGCM/grid/dimension
529./makdim $dim
530if (($? != 0))
531then
532    exit 1
533fi
534
535cat $LIBFGCM/grid/dimensions.h
536cd $LMDGCM
537
538if [[ "$bands" != "" ]]
539then
540  # Generic model, recreate bands.h (IR & VIS bands for radiative transfer)
541  bands=$(echo $bands | sed -e 's/[^0-9]/ /g')
542  cd $LIBFGCM/phy$physique/bands
543  ./makbands $bands
544  cat $LIBFGCM/phy$physique/bands.h
545  cd $LMDGCM
546fi
547
548if [[ "$scatterers" != "" ]]
549then
550  # Generic model, recreate scatterers.h
551  cd $LIBFGCM/phy$physique/scatterers
552  ./make_scatterers $scatterers
553  cat $LIBFGCM/phy$physique/scatterers.h
554  cd $LMDGCM
555fi
556
557
558########################################################################
559# Differentes dynamiques (3d, 2d, 1d)
560########################################################################
561
562if (( $dimc == 3 )) ; then
563   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
564   if [[ $physique != "nophys" ]] ; then
565     src_dirs="$src_dirs dynlonlat_phylonlat dynlonlat_phylonlat/phy${phys_root}"
566     libdyn_phy="-ldynlonlat_phylonlat"
567     LIBDYN_PHYS='$(LIBO)/libdynlonlat_phylonlat.a'
568     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat'
569     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat/'"${phys_root}"
570   fi
571  cd $LIBFGCM/grid
572  \rm fxyprim.h
573  cp -p fxy_${grille}.h fxyprim.h
574  filtre="FILTRE=$filtre"
575  INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
576elif (( $dimc == 2 )) ; then
577   src_dirs="$src_dirs dyn2d"
578   filtre="FILTRE= L_FILTRE= "
579   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
580elif (( $dimc == 1 )) ; then
581   echo pas de dynamique
582   src_dirs="$src_dirs phy${physique}/dyn1d"
583   CPP_KEY="$CPP_KEY CPP_1D"
584   filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
585   #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
586   INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d'
587else
588   echo Dimension dimc=$dimc pas prevu ; exit
589fi
590
591cd $LMDGCM
592
593########################################################################
594# library directory name:
595########################################################################
596
597nomlib=`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'`
598echo "Path to library: "$nomlib
599
600########################################################################
601#  Cleanup for a full recompilation, if requested
602########################################################################
603
604if [[ $full == "full" ]]
605then
606# remove makefile and libraries
607  echo "-full option: recompiling from scratch"
608  \rm -f makefile
609  \rm -rf "${LIBOGCM}/${nomlib}"
610fi
611
612########################################################################
613#  Avant de lancer le make, on recree le makefile si necessaire
614########################################################################
615########################################################################
616# c'est a dire dans 3 cas:
617# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
618#    derniere creation du makefile
619# 2. si le fichier contenant cette liste "liste_des_sources"
620#    n'existe pas.
621# 3. Si le makefile n'existe pas.
622########################################################################
623cd $LMDGCM
624
625
626if [[ -r .makelmdz ]]
627then
628old_lmdz_configuration=$(cat .makelmdz )
629else
630old_lmdz_configuration=""
631fi
632lmdz_configuration="$src_dirs"
633if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
634then
635  configuration_change="true"
636else
637  configuration_change="false"
638fi
639
640mkdir -p make_dir
641suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'`
642echo suf_make $suf_make
643
644\rm tmp77 tmp90
645for dir in $src_dirs ; do
646find libf/$dir -name '*.[Fh]' -print | sort >> tmp77
647find libf/$dir -name '*.F90' -print | sort >> tmp90
648######### CAS PARTICULIER CHIMIE TITAN
649if [[ "$physique" == "titan" ]]
650then 
651  find libf -name '*.[ch]' -print | sort > tmpC
652fi
653#########
654done
655
656liste77=make_dir/liste_des_sources_f77_$suf_make
657liste90=make_dir/liste_des_sources_f90_$suf_make
658if [[ "$physique" == "titan" ]] ; then
659listeC=make_dir/liste_des_sources_C_$suf_make
660fi
661makefile=make_dir/makefile_$suf_make
662
663if [[ $configuration_change == "true" || ! ( -r makefile ) || ! ( -r $liste_90 ) || ! ( -r $liste_77 ) || ` diff tmp77 $liste_77 | wc -w ` -ne 0 || ` diff tmp90 $liste_90 | wc -w ` -ne 0 ]]
664then
665  echo "les fichiers suivants ont ete crees ou detruits"
666  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
667  diff $liste77  tmp77
668  diff $liste90 tmp90
669  \cp -f tmp77 $liste77
670  \cp -f tmp90 $liste90
671######### CAS PARTICULIER CHIMIE TITAN
672  if [[ "$physique" == "titan" ]]
673  then 
674  diff $listeC tmpC
675  \cp -f tmpC $listeC
676  fi
677#########
678  echo "Recreating the makefile"
679  echo "src_dirs: $src_dirs"
680  ./create_make_gcm $src_dirs > tmp
681  \mv -f tmp $makefile
682  echo "New makefile created"
683######### CAS PARTICULIER CHIMIE TITAN
684else if [[ "$physique" == "titan" ]]
685 then
686   if [[ ! ( -r $listeC ) || ` diff tmpC $listeC | wc -w ` -ne 0 ]]
687   then
688     diff $listeC tmpC
689     \cp -f tmpC $listeC
690     echo "on recree le makefile"
691     ./create_make_gcm $src_dirs > tmp
692     \mv -f tmp $makefile
693     echo "Nouveau makefile cree"
694   fi
695 fi
696#########
697fi
698
699ln -sf $makefile makefile
700
701#Create a .makelmdz file containing main compilation option for later comparisons
702echo "$lmdz_configuration" > .makelmdz
703
704#################################################################
705# Preparation de l'execution de la commande make
706#################################################################
707
708# find code suffix and directory where code is located
709if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F ]]
710then
711  source_code=${code}.F
712  dirmain=dyn${dimc}d${FLAG_PARA}
713else
714  if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
715  then
716    source_code=${code}.F90
717    dirmain=dyn${dimc}d${FLAG_PARA}
718  else
719    if [[ -r $LMDGCM/libf/phy${physique}/${code}.F ]]
720    then
721      source_code=${code}.F
722      dirmain=phy${physique}
723    else
724      if [[ -r $LMDGCM/libf/phy${physique}/${code}.F90 ]]
725      then
726        source_code=${code}.F90
727        dirmain=phy${physique}
728      else
729        if [[ -r $LMDGCM/libf/dynlonlat_phylonlat/phy$phys_root/${code}.F ]] 
730        then
731          source_code=${code}.F
732          dirmain="dynlonlat_phylonlat/phy${phys_root}"
733        else
734          if [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F ]]
735          then
736            source_code=${code}.F
737            dirmain=phy$physique/dyn1d
738          else
739            echo "Error: cannot find ${code}.F[90]"
740            echo " neither in dyn${dimc}d${FLAG_PARA} nor in phy${physique}"
741            exit
742          fi
743        fi
744      fi
745    fi
746  fi
747fi
748
749if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
750then
751  mkdir ${LIBOGCM}/${nomlib}
752  # check we indeed managed to create the directory
753  if [[ ! $? ]]
754  then
755    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
756    exit
757  fi
758fi
759
760# where module files are created
761mod_loc_dir=$localdir
762
763if [[ "$physique" != "nophys" ]]
764then
765  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
766#  phys="PHYS=$physique"
767#else
768#  # trick to avoid having a physics-related library in the makefile
769#  phys="L_PHY= LIBPHY="
770fi
771INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
772#if (( $dimension == 1 ))
773#then
774# INCLUDE="$INCLUDE"' -I$(LIBF)/dyn3d -I'${LIBOGCM}/${nomlib}
775#else
776#INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
777#fi
778
779# ranlib utility (check it exists or else default to ls)
780if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
781then
782  ranlib="ranlib"
783else
784  ranlib="ls"
785fi
786
787# add CPP keys to COMPIL_FLAGS
788# (but first add -D before all CPP_KEY items)
789cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
790# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
791if [[ "${fcompiler:0:3}" == "xlf" ]]
792then
793cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
794fi
795COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
796
797#################################################################
798# Execution du make
799#################################################################
800echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
801OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
802OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
803OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
804OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
805OPTIMC="$OPTIMC" \
806INCLUDE="$INCLUDE" \
807INCLUDEC="$includec" \
808$filtre \
809LIBO=${LIBOGCM}/${nomlib} \
810"PHYS=$physique" \
811LIBPHY=${LIBPHY} \
812LIBDYN_PHYS=${LIBDYN_PHYS} \
813DIM=$dimc \
814FLAG_PARA=$FLAG_PARA \
815L_PHY="$lib_phy" \
816L_DYN_PHY="$libdyn_phy" \
817L_ADJNT=$adjnt \
818L_COSP="$lcosp" \
819L_AERONOMARS="$laeronomars" \
820L_CHIMIE="$libchimie" \
821LOCAL_DIR="$localdir"  \
822F77="$fcompiler" \
823F90="$fcompiler" \
824CCC="$ccompiler" \
825OPLINK="$LIB" \
826LINK="$linker" \
827GCM="$LMDGCM" \
828MOD_LOC_DIR=$mod_loc_dir \
829MOD_SUFFIX="mod" \
830AR=$arcommand \
831DIRMAIN=$dirmain \
832SOURCE=$source_code \
833PROG=$code
834
835$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
836OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
837OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
838OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
839OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
840OPTIMC="$OPTIMC" \
841INCLUDE="$INCLUDE" \
842INCLUDEC="$includec" \
843$filtre \
844LIBO=${LIBOGCM}/${nomlib} \
845"PHYS=$physique" \
846LIBPHY=${LIBPHY} \
847LIBDYN_PHYS=${LIBDYN_PHYS} \
848DIM=$dimc \
849FLAG_PARA=$FLAG_PARA \
850L_PHY="$lib_phy" \
851L_DYN_PHY="$libdyn_phy" \
852L_ADJNT="$adjnt" \
853L_COSP="$lcosp" \
854L_AERONOMARS="$laeronomars" \
855L_CHIMIE="$libchimie" \
856LOCAL_DIR="$localdir"  \
857F77="$fcompiler" \
858F90="$fcompiler" \
859CCC="$ccompiler" \
860OPLINK="$LIB" \
861LINK="$linker" \
862GCM="$LMDGCM" \
863MOD_LOC_DIR=$mod_loc_dir \
864MOD_SUFFIX="mod" \
865AR=$arcommand \
866DIRMAIN=$dirmain \
867SOURCE=$source_code \
868PROG=$code
869
870if [[ -r $LIBFGCM/grid/dimensions.h ]]
871then
872  # Cleanup: remove dimension.h file
873  \rm -f $LIBFGCM/grid/dimensions.h
874fi
Note: See TracBrowser for help on using the repository browser.