source: LMDZ6/branches/Amaury_dev/makelmdz_fcm @ 5103

Last change on this file since 5103 was 5103, checked in by abarral, 4 months ago

Handle CPP_INLANDSIS in lmdz_cppkeys_wrapper.F90
Remove obsolete key wrgrads_thermcell, _ADV_HALO, _ADV_HALLO, isminmax
Remove redundant uses of CPPKEY_INCA (thanks acozic)
Remove obsolete misc/write_field.F90
Remove unused ioipsl_* wrappers
Remove calls to WriteField_u with wrong signature
Convert .F -> .[fF]90
(lint) uppercase fortran operators
[note: 1d and iso still broken - working on it]

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