source: LMDZ6/trunk/makelmdz_fcm @ 5091

Last change on this file since 5091 was 5048, checked in by fhourdin, 4 months ago

Comportemnt de makelmdz* quand on compile deja

  • 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:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 23.2 KB
RevLine 
[1279]1#!/bin/bash
2# $Id: makelmdz_fcm 5048 2024-07-12 14:19:11Z abarral $
3# This is a script in Bash.
4
[2098]5# FH : on ne cr\'ee plus le fichier arch.mk qui est suppos\'e exister par
[783]6# FH : ailleurs.
[2098]7# FH : ulterieurement, ce fichier sera pr\'e-existant pour une s\'erie
8# FH : de configurations en versions optimis\'ees et debug qui seront
9# FH : li\'es (ln -s) avec arch.mk en fonction de l'architecture.
10# FH : Pour le moment, cette version est en test et on peut cr\'eer les
11# FH : arch.mk en lan\c{}cant une premi\`ere fois makegcm.
[783]12#
[1279]13##set -x
[2202]14set -e
[783]15########################################################################
16# options par defaut pour la commande make
17########################################################################
18
[1279]19dim="96x72x19"
20physique=lmd
21filtre=filtrez
22grille=reg
23couple=false
24veget=false
[3793]25inlandsis=false
[1990]26rrtm=false
[4195]27rad="oldrad"
[2631]28dust=false
[2690]29strataer=false
[1279]30chimie=false
31parallel=none
[3997]32paramem="mem"
[1279]33compil_mod=prod
34io=ioipsl
35LIBPREFIX=""
36cosp=false
[3358]37cosp2=false
[3491]38cospv2=false
[1802]39job=1
40full=''
[2358]41libphy=false
[3924]42isotopes=false
43isoverif=false
44diagiso=false
45isotrac=false
[4096]46force_compile=false
[4247]47cplocninca=false
[783]48
[2743]49arch_defined="FALSE"
50arch_path="arch"
51arch_default_path="arch"
52
[1279]53LMDGCM=`/bin/pwd`
54LIBOGCM=$LMDGCM/libo
55LIBFGCM=$LMDGCM/libf
[2239]56DYN_COMMON_PATH=$LIBFGCM/dyn3d_common
[2084]57# path for optional packages, but default set to ".void_dir"
[2239]58FILTRE_PATH=$LMDGCM/.void_dir
59DYN_PHYS_PATH=$LMDGCM/.void_dir
[2242]60DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
[2326]61PHY_COMMON_PATH=$LMDGCM/.void_dir
[3908]62RAD_PATH=$LMDGCM/.void_dir
[3901]63INLANDSIS_PATH=$LMDGCM/.void_dir
[2631]64DUST_PATH=$LMDGCM/.void_dir
[2690]65STRATAER_PATH=$LMDGCM/.void_dir
[1327]66COSP_PATH=$LMDGCM/.void_dir
[1578]67fcm_path=$LMDGCM/tools/fcm/bin
[783]68
69########################################################################
70#  Quelques initialisations de variables du shell.
71########################################################################
72
[3815]73CPP_KEY="IN_LMDZ" 
[1279]74INCLUDE=""
75LIB=""
76adjnt=""
77COMPIL_FFLAGS="%PROD_FFLAGS"
78PARA_FFLAGS=""
79PARA_LD=""
80EXT_SRC=""
[783]81
82########################################################################
83# lecture des options de mymake
84########################################################################
85
[1279]86while (($# > 0))
87  do
88  case $1 in
89      "-h") cat <<fin
[783]90Usage :
[1772]91makelmdz_fcm [options] -arch nom_arch exec
92[-h]                       : brief help
93[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
94[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
95[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug
[1965]96[-c false/MPI1/OMCT]       : coupling with ocean model : MPI1/OMCT/false (default: false)
[4283]97[-v false/orchideetrunk/orchidee2.1/orchidee2.0/orchidee1.9] : version of the vegetation model to include (default: false)
[1772]98          false       : no vegetation model
[4283]99          orchideetrunk : compile using ORCHIDEE trunk from revision 7757 or higher
100          orchidee2.1 : compile using ORCHIDEE 2.1 until 4.1 included or until revision 7757 on the trunk
[3435]101          orchidee2.0 : compile using ORCHIDEE 2.0
[1772]102          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
103          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
104[-chimie INCA/false]       : with INCA chemistry model or without (default: false)
[4247]105[-cplocninca ]        : allow transfer of species from PISCES to INCA (default: false)
[2238]106[-cosp true/false]    : compile with/without cosp package (default: false)
[3358]107[-cosp2 true/false]    : compile with/without cosp2 package (default: false)
[3491]108[-cospv2 true/false]    : compile with/without cospv2 package (default: false)
[3793]109[-inlandsis true/false]  : compile with/without inlandsis package (default: false)
[2238]110[-rrtm true/false]    : compile with/without rrtm package (default: false)
[4195]111[-rad oldrad/rrtm/ecrad]    : compile with oldrad/rrtm/ecrad radiatif code (default: oldrad)
[2631]112[-dust true/false]    : compile with/without the dust package by Boucher and co (default: false)
[2690]113[-strataer true/false]    : compile with/without the strat aer package by Boucher and co (default: false)
[3924]114[-isotopes true/false]    : compile with/without water isotopes in the physics
115[-isoverif true/false]    : compile with/without verifications for water isotopes in the physics
116[-diagiso true/false]    : compile with/without special diagnostics for water isotopes in the physics
117[-isotrac true/false]    : compile with/without tracers of water isotopes in the physics
[1772]118[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
119[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
[2097]120[-io ioipsl/mix/xios]                   : Input/Output library (default: ioipsl)
[1772]121[-include INCLUDES]        : extra include path to add
122[-cpp CPP_KEY]             : additional preprocessing definitions
123[-adjnt]                   : adjoint model, not operational ...
[3997]124[-mem]                     : reduced memory dynamics (obsolete flag; always on in parallel mode)
[1772]125[-filtre NOMFILTRE]        : use filtre from libf/NOMFILTRE (default: filtrez)
126[-link LINKS]              : additional links with other libraries
[1802]127[-j n]                     : active parallel compiling on ntask
128[-full]                    : full recompiling
[2358]129[-libphy]                  : only compile physics package (no dynamics or main program)
[1772]130[-fcm_path path]           : path to the fcm tool (default: tools/fcm/bin)
131[-ext_src path]            : path to an additional set of routines to compile with the model
[2743]132[-arch_path path]          : path to architecture files (default: $arch_default_path)
[4096]133[-force_compile]           : recompile although there seems to be an on-going compilation
[1772]134 -arch nom_arch            : target architecture
135 exec                      : executable to build
[783]136fin
[1279]137          exit;;
[783]138
[1279]139      "-d")
140          dim=$2 ; shift ; shift ;;
141     
142      "-p")
143          physique="$2" ;  shift ; shift ;;
[783]144
[1279]145      "-g")
146          grille="$2" ; shift ; shift ;;
[783]147
[1279]148      "-c")
149          couple="$2" ; shift ; shift ;;
[783]150
[1279]151      "-prod")
152          compil_mod="prod" ; shift ;;
[1002]153
[1279]154      "-dev")
155          compil_mod="dev" ; shift ;;
[1002]156
[1279]157      "-debug")
158          compil_mod="debug" ; shift ;;
[1002]159
[1279]160      "-io")
161          io="$2" ; shift ; shift ;;
[783]162
[1279]163      "-v")
164          veget="$2" ; shift ; shift ;;
[783]165
[3793]166      "-inlandsis")
[3908]167          inlandsis="$2" ; shift ; shift ;;
[3793]168
[1990]169      "-rrtm")
[4195]170          rrtm="$2" ; if [ "$2" = "false" ] ; then rad="oldrad" ; else rad="rrtm" ; fi ; shift ; shift ;;
[1990]171
[3908]172      "-rad")
173          rad="$2" ; shift ; shift ;;
174
[2631]175      "-dust")
176          dust="$2" ; shift ; shift ;;
177
[2690]178      "-strataer")
179          strataer="$2" ; shift ; shift ;;
180
[1279]181      "-chimie")
182          chimie="$2" ; shift ; shift ;;
[783]183
[4247]184     "-cplocninca")
185          cplocninca=TRUE ; shift ;;
186
[3924]187      "-isotopes")
188          isotopes="$2" ; shift ; shift ;;
189
190      "-isoverif")
191          isoverif="$2" ; shift ; shift ;;
192
193      "-diagiso")
194          diagiso="$2" ; shift ; shift ;;
195
196      "-isotrac")
197          isotrac="$2" ; shift ; shift ;;
198
[1279]199      "-parallel")
200          parallel="$2" ; shift ; shift ;;
201     
202      "-include")
203          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
[783]204
[1279]205      "-cpp")
206          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
[1132]207
[1279]208      "-adjnt")
[1772]209          echo "not operational ... work to be done here ";exit
[1279]210          opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
211          optim="$optim -Dadj" ; shift ;;
[783]212
[1279]213      "-cosp")
214          cosp="$2" ; shift ; shift ;;
[3358]215
216      "-cosp2")
217          cosp2="$2" ; shift ; shift ;;
[3491]218
219      "-cospv2")
220          cospv2="$2" ; shift ; shift ;;
[1680]221     
222      "-mem")
[3997]223          echo "option -mem is obsolete (now always on in parallel)"
[1680]224          paramem="mem" ; shift ;;
[783]225
[1279]226      "-filtre")
227          filtre=$2 ; shift ; shift ;;
[783]228
[1279]229      "-link")
230          LIB="$LIB $2" ; shift ; shift ;;
[1136]231
[1279]232      "-fcm_path")
233          fcm_path=$2 ; shift ; shift ;;
[783]234
[1279]235      "-ext_src")
236          EXT_SRC=$2 ; shift ; shift ;;
[2358]237
[1802]238      "-j")
239          job=$2 ; shift ; shift ;;
[2358]240
[1802]241      "-full")
242          full="-full" ; shift ;;
[783]243
[2358]244      "-libphy")
245          libphy="true" ; shift ;;
246
[1279]247      "-arch")
[2743]248          arch=$2 ; arch_defined="TRUE" ; shift ; shift ;;
[783]249
[2743]250      "-arch_path")
251          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
252
[4096]253      "-force_compile")
254          force_compile=true ; shift ;;
255
[1279]256      *)
257          code="$1" ; shift ;;
258  esac
259done
260
[1136]261###############################################################
[1755]262# path to fcm
[1136]263###############################################################
[1755]264# handle case when provided path to fcm was given as a relative
265# path (from makelmdz_fcm script directory) and not an absolute path
266if [[ ${fcm_path:0:1} != "/" ]] ; then
267  # prepend with makelmdz_fcm location
268  fcm_path=$(cd $(dirname $0) ; pwd)"/"${fcm_path}
269fi
[783]270
[1757]271# add fcm_path to PATH
272export PATH=${fcm_path}:${PATH}
273
[1755]274echo "Path to fcm:"
275echo ${fcm_path}
[1136]276
[783]277###############################################################
[2098]278# lecture des chemins propres \`a l'architecture de la machine #
[783]279###############################################################
[1279]280rm -f .void_file
281echo > .void_file
[1327]282rm -rf .void_dir
283mkdir .void_dir
[783]284
[2743]285if [[ "$arch_defined" == "TRUE" ]]
286then
287  rm -f arch.path
288  rm -f arch.fcm
289  rm -f arch.env
290
291  if test -f $arch_path/arch-${arch}.path
292  then
293    ln -s $arch_path/arch-${arch}.path arch.path
294  elif test -f $arch_default_path/arch-${arch}.path
295  then
296    ln -s $arch_default_path/arch-${arch}.path arch.path
297  fi
298       
299  if test -f $arch_path/arch-${arch}.fcm
300  then
301    ln -s $arch_path/arch-${arch}.fcm arch.fcm
302  elif test -f $arch_default_path/arch-${arch}.fcm
303  then
304    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
305  fi
306
307  if test -f $arch_path/arch-${arch}.env
308  then
309    ln -s $arch_path/arch-${arch}.env arch.env
310  elif test -f $arch_default_path/arch-${arch}.env
311  then
312    ln -s $arch_default_path/arch-${arch}.env arch.env
313  else
314    ln -s .void_file arch.env
315  fi
316  # source architecture PATH and ENV files
317  source arch.env
318  source arch.path
319else
320  echo "You must define a target architecture"
321  exit 1
322fi
323
[783]324########################################################################
325# Definition des clefs CPP, des chemins des includes et modules
326#  et des libraries
327########################################################################
328
[1279]329if [[ "$compil_mod" == "prod" ]]
330then
331  COMPIL_FFLAGS="%PROD_FFLAGS"
332elif [[ "$compil_mod" == "dev" ]]
333then
334  COMPIL_FFLAGS="%DEV_FFLAGS"
335elif [[ "$compil_mod" == "debug" ]]
336then
337  COMPIL_FFLAGS="%DEBUG_FFLAGS"
338fi
[783]339
[2250]340phys_root=$physique
341if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi
342if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi
343if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi
344if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi
345if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi
346if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi
347
[1279]348if [[ "$physique" != "nophys" ]]
349then
[1615]350   #We'll use some physics
351   CPP_KEY="$CPP_KEY CPP_PHYS"
[2250]352   if [[ "${phys_root}" == "lmd" ]]
[1615]353   then
354   #For lmd physics, default planet type is Earth
[1279]355   CPP_KEY="$CPP_KEY CPP_EARTH"
[1615]356   fi
[2326]357   # set physics common utilities path
358   PHY_COMMON_PATH="${LIBFGCM}/phy_common"
[2239]359   # set the dyn/phys interface path
[2417]360   DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat"
361   DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}"
[1279]362fi
[783]363
[2239]364if [[ "$filtre" == "filtrez" ]]
365then
366   FILTRE_PATH=${LIBFGCM}/$filtre
367fi
368
[1279]369if [[ "$chimie" == "INCA" ]]
370then
371   CPP_KEY="$CPP_KEY INCA"
[4426]372   INCLUDE="$INCLUDE ${INCA_INCDIR}"
373   LIB="$LIB ${INCA_LIBDIR} ${INCA_LIB}"
[1279]374fi
[783]375
[3924]376if [[ "$isotopes" == "true" ]]
377then
378   CPP_KEY="$CPP_KEY ISO"
379fi
380
381if [[ "$isoverif" == "true" ]]
382then
383   CPP_KEY="$CPP_KEY ISOVERIF"
384fi
385
386if [[ "$diagiso" == "true" ]]
387then
388   CPP_KEY="$CPP_KEY DIAGISO"
389fi
390
391if [[ "$isotrac" == "true" ]]
392then
393   CPP_KEY="$CPP_KEY ISOTRAC"
394fi
395
[1279]396if [[ "$couple" != "false" ]]
397then
[1965]398    if [[ "$couple" == "MPI1" ]]
399    then
400        CPP_KEY="$CPP_KEY CPP_COUPLE"
401        export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1
402        export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib
403        INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
404        LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lmpp_io"
405    else
406        CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT"
[4426]407        INCLUDE="$INCLUDE ${OASIS_INCDIR}"
408        LIB="$LIB ${OASIS_LIBDIR} -lpsmile.MPI1 -lscrip -lmct -lmpeu"
[1965]409    fi
[1279]410fi
[783]411
[1279]412if [[ "$parallel" == "mpi" ]]
413then
414   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
415   PARA_FFLAGS="%MPI_FFLAGS"
416   PARA_LD="%MPI_LD"
417elif [[ "$parallel" == "omp" ]]
418then
419   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
420   PARA_FFLAGS="%OMP_FFLAGS"
421   PARA_LD="%OMP_LD"
422elif [[ "$parallel" == "mpi_omp" ]]
423then
424   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
425   PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS"
426   PARA_LD="%MPI_LD %OMP_LD"
427fi
[783]428
[1279]429if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
430   && "$compil_mod" == "debug" ]]
431then
432    echo "Usually, parallelization with OpenMP requires some optimization."
433    echo "We suggest switching to \"-dev\"."
434fi
[783]435
[4283]436if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" -o "$veget" = "orchidee2.1" -o "$veget" = "orchideetrunk" ]
[1279]437then
[4426]438        echo "doing orchidee"
[1811]439#NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6
440#    For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments
441#    option orchidee1.9 : Compile with ORCHIDEE version up to the inclusion of OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
[4426]442   INCLUDE="${INCLUDE} ${ORCH_INCDIR}"
[1772]443   CPP_KEY="$CPP_KEY CPP_VEGET"
[1811]444# temporary, for Orchidee versions 1.9.* (before openmp activation)
445   if [[ "$veget" == "orchidee1.9" ]] ; then
446      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
447   fi
448   if [[ "$veget" == "orchidee2.0" ]] ; then
[4426]449      orch_libs="-lsechiba -lparameters -lstomate -lparallel -lorglob -lorchidee"
[3435]450      CPP_KEY="$CPP_KEY ORCHIDEE_NOUNSTRUCT"
451   elif [[ "$veget" == "orchidee2.1" ]] ; then
[4283]452      CPP_KEY="$CPP_KEY ORCHIDEE_NOLIC"
[4426]453      orch_libs="-lsechiba -lparameters -lstomate -lparallel -lorglob -lorchidee"
[4283]454   elif [[ "$veget" == "orchideetrunk" ]] ; then
[4426]455      orch_libs="-lorchidee"
[1811]456   else
[4426]457      orch_libs="-lsechiba -lparameters -lstomate -lparallel -lorglob"
[1811]458   fi
[4426]459   LIB="${LIB} ${ORCH_LIBDIR} ${orch_libs}"
460#   for lib in ${orch_libs} ; do
461#      if [ -f ${ORCH_LIBDIR#-L}/lib${LIBPREFIX}$lib.a ] ; then
462#         LIB="${LIB} -l${LIBPREFIX}$lib "
463#      fi
464#   done
465   echo "orchidee lib" 
466   echo ${LIB}
[1811]467elif [[ "$veget" != "false" ]] ; then
[1772]468   echo "Option -v $veget does not exist"
469   echo "Use ./makelmdz_fcm -h for more information"
470   exit 
[1279]471fi
[783]472
[3793]473if [[ "$inlandsis" == "true" ]]
474then
475   CPP_KEY="$CPP_KEY CPP_INLANDSIS"
[5036]476   INLANDSIS_PATH="$LIBFGCM/phy${physique}/inlandsis"
[3793]477fi
478
[3908]479if [[ "$rad" == "rrtm" ]]
[1990]480then
481   CPP_KEY="$CPP_KEY CPP_RRTM"
[5036]482   RAD_PATH="$LIBFGCM/phy${physique}/rrtm"
[1990]483fi
[3908]484if [[ "$rad" == "ecrad" ]]
485then
486   CPP_KEY="$CPP_KEY CPP_ECRAD"
[5036]487   RAD_PATH="$LIBFGCM/phy${physique}/ecrad"
[3908]488fi
[1990]489
[2631]490if [[ "$dust" == "true" ]]
491then
492   CPP_KEY="$CPP_KEY CPP_Dust"
[5036]493   DUST_PATH="$LIBFGCM/phy${physique}/Dust"
[2631]494fi
495
[2690]496if [[ "$strataer" == "true" ]]
497then
498   CPP_KEY="$CPP_KEY CPP_StratAer"
[5036]499   STRATAER_PATH="$LIBFGCM/phy${physique}/StratAer"
[2690]500fi
501
[4489]502INCLUDE="$INCLUDE ${NETCDF95_INCDIR}"
503LIB="$LIB ${NETCDF95_LIBDIR} ${NETCDF95_LIB}"
504
[1279]505if [[ $io == ioipsl ]]
506then
507   CPP_KEY="$CPP_KEY CPP_IOIPSL"
[4426]508   INCLUDE="$INCLUDE ${IOIPSL_INCDIR}"
509   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}"
[2097]510elif [[ $io == mix ]]
[1897]511then
512   # For now, xios implies also using ioipsl
513   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
[4426]514   INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
515   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
[2097]516elif [[ $io == xios ]]
517then
518   # For now, xios implies also using ioipsl
519   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
[4426]520   INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
521   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
[1279]522fi
[1897]523
[1279]524if [[ "$cosp" == "true" ]]
525then
526   CPP_KEY="$CPP_KEY CPP_COSP"
[2239]527   COSP_PATH="$LIBFGCM/phylmd/cosp"
[1279]528#   LIB="${LIB} -l${LIBPREFIX}cosp"
529fi
[783]530
[3358]531if [[ "$cosp2" == "true" ]]
532then
533   CPP_KEY="$CPP_KEY CPP_COSP2"
534   COSP_PATH="$LIBFGCM/phylmd/cosp2"
535#   LIB="${LIB} -l${LIBPREFIX}cosp2"
536fi
537
[3491]538if [[ "$cospv2" == "true" ]]
539then
540   CPP_KEY="$CPP_KEY CPP_COSPV2"
541   COSP_PATH="$LIBFGCM/phylmd/cospv2"
542#   LIB="${LIB} -l${LIBPREFIX}cosp2"
543fi
[3358]544
[4247]545if [[ "$cplocninca" == "TRUE" ]]
546then
547    CPP_KEY="${CPP_KEY} CPP_CPLOCNINCA"
548fi
[3491]549
550
[1551]551INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
[4426]552LIB="$LIB ${NETCDF_LIBDIR} ${NETCDF_LIB}"
[1551]553
[783]554########################################################################
555# calcul du nombre de dimensions
556########################################################################
557
558
[1279]559dim_full=$dim
560dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
561set $dim
562dimc=$#
[783]563echo calcul de la dimension
564echo dim $dim
565echo dimc $dimc
566
567
568########################################################################
569# Gestion des dimensions du modele.
[1114]570# on cree ou remplace le fichier des dimensions
[783]571########################################################################
572
[1695]573cd $LIBFGCM/grid
574if [[ -f dimensions.h ]]
575then
[4096]576    if [[ $force_compile == true ]]
577    then
[5048]578        \rm -f $LIBFGCM/grid/dimensions.h
[4096]579    else
[5048]580        echo "WARNING: you are probably already compiling the model somewhere else."
581        echo "Wait until the first compilation is finished before launching this one."
582        echo "If you are sure that you are not compiling elsewhere, "
583        echo "If you are sure that you are not compiling elsewhere, then"
584        echo rm -f $LIBFGCM/grid/dimensions.h
585        echo "before reruning the compilation"
586        echo "or run makelmdz_fcm with option -force_compile"
587        exit 1
[4096]588    fi
[1695]589fi
590
591
[5048]592
[783]593cd $LIBFGCM/grid/dimension
[1114]594./makdim $dim
[783]595cat $LIBFGCM/grid/dimensions.h
596cd $LMDGCM
597
598
599########################################################################
600# Differentes dynamiques (3d, 2d, 1d)
601########################################################################
602
[1279]603dimension=`echo $dim | wc -w`
[783]604echo dimension $dimension
605
[1279]606if (( $dimension == 3 ))
607then
[783]608  cd $LIBFGCM/grid
609  \rm fxyprim.h
610  cp -p fxy_${grille}.h fxyprim.h
[2239]611#else
612#  echo "Probleme dans les dimensions de la dynamique !!"
613#  echo "Non reactive pour l'instant !!!"
[1279]614fi
[783]615
[2239]616if (( $dimension == 1 ))
617then
618  CPP_KEY="$CPP_KEY CPP_1D"
619## no filtre in 1d:
620  FILTRE_PATH=$LMDGCM/.void_dir
621## no need to compile all routines in dyn3d_common either:
622  DYN_COMMON_PATH=$LMDGCM/.void_dir
623## no need to compile all routines in dynlmdz_phy... ;
624## (because key ones are included in 1D main program)
625  DYN_PHYS_PATH=$LMDGCM/.void_dir
[2242]626  DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
[2239]627fi
628
[783]629######################################################################
630#   Traitement special pour le nouveau rayonnement de Laurent Li.
631#   ---> YM desactive pour le traitemement en parallele
632######################################################################
633
[1279]634#if [[ -f $libf/phy$physique/raddim.h ]]
635#then
636# if [[ -f $libf/phy$physique/raddim.$dimh.h ]]
637#then
[783]638#  \rm -f $libf/phy$physique/raddim.h
639#  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
640#  echo $libf/phy$physique/raddim.$dimh.h
641#  cat $libf/phy$physique/raddim.h
642# else
643#  echo On peut diminuer la taille de l executable en creant
644#  echo le fichier $libf/phy$physique/raddim.$dimh.h
645#  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
[1279]646# fi
647#fi
[783]648
649######################################################################
650# Gestion du filtre qui n'existe qu'en 3d.
651######################################################################
652
[1279]653if (( `expr $dimc \> 2` == 1 ))
654then
655   filtre="FILTRE=$filtre"
[783]656else
[1279]657   filtre="FILTRE= L_FILTRE= "
658fi
[783]659echo MACRO FILTRE $filtre
660
661echo $dimc
662
663
664
665######################################################################
666# Creation du suffixe de la configuration
667######################################################################
668
669
[1279]670SUFF_NAME=_${dim_full}
[4186]671SUFF_NAME=${SUFF_NAME}_phy${physique}_${rad}
[783]672
[1279]673if [[ "$parallel" != "none" ]]
674then
675  SUFF_NAME=${SUFF_NAME}_para
[1680]676  DYN=dyn${dimc}d${paramem}
677  if [[ "$paramem" == "mem" ]]
678  then
[2202]679      SUFF_NAME=${SUFF_NAME}_${paramem}
680  else
681      echo "The version of the dynamics in dyn3dpar is no longer updated."
682      echo "You should use option \"-mem\"."
683      exit 1
[1680]684  fi
[783]685else
[1279]686  SUFF_NAME=${SUFF_NAME}_seq
[2239]687  if (( $dimension == 1 ))
688  then
689    # dynamics-related routines in"dyn1d" subdirectory of phy${physique}
690    DYN=phy${physique}/dyn1d
691  else
692    DYN=dyn${dimc}d
693  fi
[1279]694fi
[783]695
[1772]696if [[ $veget != "false" ]]
[1279]697then
698  SUFF_NAME=${SUFF_NAME}_orch
699fi
[783]700
[3804]701if [[ $dust == "true" ]]
702then
703  SUFF_NAME=${SUFF_NAME}_spla
704fi
705
[1279]706if [[ $couple != "false" ]]
707then
708  SUFF_NAME=${SUFF_NAME}_couple
709fi
[783]710
[1279]711if [[ $chimie == "INCA" ]]
712then
713  SUFF_NAME=${SUFF_NAME}_inca
714fi
[783]715
[3924]716if [[ "$isotopes" == "true" ]]
[2358]717then
[3924]718  SUFF_NAME=${SUFF_NAME}_iso
719fi
720if [[ "$isoverif" == "true" ]]
721then
722  SUFF_NAME=${SUFF_NAME}_isoverif
723fi
724if [[ "$isotrac" == "true" ]]
725then
726  SUFF_NAME=${SUFF_NAME}_isotrac
727fi
728if [[ "$diagiso" == "true" ]]
729then
730  SUFF_NAME=${SUFF_NAME}_diagiso
731fi
732
[3925]733if [[ $libphy == "true" ]]
[3924]734then
[2358]735  # special case where we compile only the physics
736  DYN=$LMDGCM/.void_dir
737  DYN_COMMON_PATH=$LMDGCM/.void_dir
738  FILTRE_PATH=$LMDGCM/.void_dir
739  DYN_PHYS_PATH=$LMDGCM/.void_dir
740  DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
741  #and there is no main program to generate
742  code=""
743  SUFF_NAME=""
744else
745  SUFF_NAME=${SUFF_NAME}.e
746fi
747
[783]748cd $LMDGCM
[1279]749config_fcm="config.fcm"
[783]750rm -f $config_fcm
751touch $config_fcm
752rm -f bin/${code}${SUFF_NAME}.e
753rm -f arch.fcm
[1279]754rm -f arch.opt
[783]755
756echo "%ARCH          $arch"          >> $config_fcm
757echo "%INCDIR        $INCLUDE"       >> $config_fcm 
758echo "%LIB           $LIB"           >> $config_fcm
759echo "%ROOT_PATH     $PWD"           >> $config_fcm
760echo "%LIBF          $LIBFGCM"       >> $config_fcm
761echo "%LIBO          $LIBOGCM"       >> $config_fcm
762echo "%DYN           $DYN"           >> $config_fcm
[2239]763echo "%DYN_COMMON    $DYN_COMMON_PATH" >> $config_fcm
[2326]764echo "%PHY_COMMON    $PHY_COMMON_PATH" >> $config_fcm
[2239]765echo "%FILTRE        $FILTRE_PATH"   >> $config_fcm
[783]766echo "%PHYS          phy${physique}" >> $config_fcm
[2239]767echo "%DYN_PHYS      $DYN_PHYS_PATH" >> $config_fcm
[2242]768echo "%DYN_PHYS_SUB  $DYN_PHYS_SUB_PATH" >> $config_fcm
[3908]769echo "%RAD           $RAD_PATH"     >> $config_fcm
[2631]770echo "%DUST          $DUST_PATH"     >> $config_fcm
[2690]771echo "%STRATAER      $STRATAER_PATH" >> $config_fcm
[3793]772echo "%INLANDSIS     $INLANDSIS_PATH" >> $config_fcm
[1327]773echo "%COSP          $COSP_PATH"     >> $config_fcm
[783]774echo "%CPP_KEY       $CPP_KEY"       >> $config_fcm
775echo "%EXEC          $code"          >> $config_fcm
776echo "%SUFF_NAME     $SUFF_NAME"     >> $config_fcm
[1002]777echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm
778echo "%PARA_FFLAGS   $PARA_FFLAGS"   >> $config_fcm
779echo "%PARA_LD       $PARA_LD"       >> $config_fcm
[1279]780echo "%EXT_SRC       $EXT_SRC"       >> $config_fcm
[783]781
[4773]782if [[ "$rad" == "ecrad" ]]
783then
784\cp bld.cfg.ecrad bld.cfg
785else
786\cp bld.cfg.rrtm bld.cfg
787fi
[1002]788
[1137]789ln -s arch/arch-${arch}.fcm arch.fcm
[1279]790if test -f arch/arch-${arch}.opt &&  [ $compil_mod = "prod" ]
791  then
792  ln -s arch/arch-${arch}.opt arch.opt
793else
794  ln -s .void_file arch.opt
795fi
796
[4103]797set +e
798
[1002]799rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock
[1802]800./build_gcm ${fcm_path} -j $job $full
[4103]801build_status=$?
[783]802
[1279]803rm -rf tmp_src
804rm -rf config
[783]805ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config
[2358]806ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/ppsrc tmp_src
[1695]807
[1696]808if [[ -r $LIBFGCM/grid/dimensions.h ]]
[1695]809then
810  # Cleanup: remove dimension.h file
[1696]811  \rm -f $LIBFGCM/grid/dimensions.h
[1695]812fi
[4103]813
[4918]814# build netcdf95 library necessary for the makelmdz script
815if [[ $build_status = 0 ]]
816then
817  if [[ ! -d tools/netcdf95/include ]]
818  then
819      mkdir tools/netcdf95/include tools/netcdf95/lib
820      cp config/inc/netcdf95.mod config/inc/nf95_*mod tools/netcdf95/include
821      cp config/obj/netcdf95.o config/obj/nf95_*o config/obj/check_start_count_m.o tools/netcdf95/lib
822      cd tools/netcdf95/lib; ar rv libnetcdf95.a *.o; ranlib libnetcdf95.a
823      cd -
824    fi
825fi
826
[4103]827exit $build_status
Note: See TracBrowser for help on using the repository browser.