source: LMDZ6/branches/LMDZ-ECRAD/makelmdz @ 4075

Last change on this file since 4075 was 3880, checked in by idelkadi, 4 years ago

Online implementation of the radiative transfer code ECRAD in LMDZ.

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