source: LMDZ6/trunk/makelmdz_fcm @ 5325

Last change on this file since 5325 was 5313, checked in by Laurent Fairhead, 11 days ago

EM justly pointed out that ce0l is compiled with makelmdz_gcm also

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