source: LMDZ6/branches/LMDZ_cdrag_LSCE/makelmdz @ 5437

Last change on this file since 5437 was 4669, checked in by Laurent Fairhead, 16 months ago

Merged with trunk revision 4586 corresponding to june 2023 testing

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