source: LMDZ6/branches/Amaury_dev/makelmdz_fcm @ 5192

Last change on this file since 5192 was 5192, checked in by abarral, 4 days ago

Remove obsolete lmdz_description.f90
Remove unused exner_hyb_m.F90 in 1D
Re-remove filtre from source in 1D makelmdz_fcm

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