source: LMDZ6/trunk/makelmdz_fcm @ 5456

Last change on this file since 5456 was 5341, checked in by Laurent Fairhead, 5 weeks ago

Rollback, not needed

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