source: LMDZ6/trunk/makelmdz @ 5456

Last change on this file since 5456 was 5288, checked in by abarral, 2 months ago

Remove grid argument from makegcm makelmdz makelmdz_fcm since it acts on a file that isn't included anywhere

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