source: LMDZ6/trunk/makelmdz @ 3372

Last change on this file since 3372 was 3359, checked in by idelkadi, 6 years ago

Implementation de la version COSPv2 dans LMDZ.

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