source: LMDZ6/trunk/makelmdz @ 3439

Last change on this file since 3439 was 3435, checked in by Laurent Fairhead, 6 years ago

"Historic" :-) commit merging the physics branch used for DYNAMICO with the LMDZ trunk.
The same physics branch can now be used seamlessly with the traditional lon-lat LMDZ
dynamical core and DYNAMICO.
Testing consisted in running a lon-lat LMDZ bucket simulation with the NPv6.1 physics package
with the original trunk sources and the merged sources. Tests were succesful in the sense that
numeric continuity was preserved in the restart files from both simulation. Further tests
included running both versions of the physics codes for one year in a LMDZOR setting in which
the restart files also came out identical.

Caution:

  • as the physics package now manages unstructured grids, grid information needs to be transmitted

to the surface scheme ORCHIDEE. This means that the interface defined in surf_land_orchidee_mod.F90
is only compatible with ORCHIDEE version orchidee2.1 and later versions. If previous versions of
ORCHIDEE need to be used, the CPP key ORCHIDEE_NOUNSTRUCT needs to be set at compilation time.
This is done automatically if makelmdz/makelmdz_fcm are called with the veget orchidee2.0 switch

  • due to a limitation in XIOS, the time at which limit conditions will be read in by DYNAMICO will be

delayed by one physic timestep with respect to the time it is read in by the lon-lat model. This is caused
by the line

IF (MOD(itime-1, lmt_pas) == 0 .OR. (jour_lu /= jour .AND. grid_type /= unstructured)) THEN ! time to read

in limit_read_mod.F90

Work still needed on COSP integration and XML files for DYNAMICO

EM, YM, LF

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