source: LMDZ6/trunk/makelmdz_fcm

Last change on this file was 6030, checked in by idelkadi, 5 days ago

Modifications in makelmdz_fcm to avoid multiplying cfg.bld* files depending on the different combinations of compilation options (rad, cosp, …)

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