source: LMDZ6/trunk/makelmdz @ 3908

Last change on this file since 3908 was 3908, checked in by idelkadi, 3 years ago

Online implementation of the radiative transfer code ECRAD in the LMDZ model.

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