! ######################################################################
! ###
! ### TM5 - Expert settings.
! ###
! ### The variables '${..}' in this file are expanded on reading.
! ### See the description in 'rc.py' .
! ### Special variables are (read 'S' as '$'):
! ###   S{pid}       : evalutates to the process id of the calling script
! ###   S{script}    : "          "  "   name       "  "   "       "
! ###
! ######################################################################

! ------------------------------------------------
! logging
! ------------------------------------------------
! Default setting for print debug messages (True|False) ? Passing '--verbose'
! or '-v' options to setup_tm5 script will set this value to 'True'
verbose      :  False

! set log file for setup script:
logfile      :  ${script}.0000.log

! ------------------------------------------------
! run directory (where submit script, executable, and settings are installed)
! ------------------------------------------------
rundir    :  ${my.run.dir}

! ------------------------------------------------
! build source
! ------------------------------------------------
!
! Building an executable could consist of 3 steps:
!   copy       : gather a source code into a build directory
!   configure  : generate source files if necessary, create Makefile
!   make       : compile and link executable
!

! absolute path of location where code is gathered
build.prefix      :  ${my.project.dir}/build

! extend with flag groups ? e.g.  build_optim-all_mpi
! a link with the original name will be created to this extended name
build.prefix.extend     :  True

! actual source codes will end up here (must be one of build.copy.subdirs)
build.sourcedir   :  ${build.prefix}

! Number of jobs (commands) to run simultaneously.
! An empty value indicates unlimitted number, which might claim all resources;
! better is to specify a value which will be the default maximum.
! The value is overwritten by the '-j' or '--jobs' flag passed to the submit script
! The final number (specified here or from the flags) will be inserted in the maker command:
!    maker       :  gmake -j ${build.jobs}
!
build.jobs          :  8
!build.jobs          :  1

! remove existing build directory for a complete new copy of code and scripts ?
! NOTE: this flag is set to true by the '--new' option. This is equivalent to 'realclean' in many other programs.
build.new           :  False

!
! Create a source
!

! gather source code into the build prefix directory (True|False) ?
build.copy                      : True

! list of source directories, content of which (build.copy.subdirs) will be copied into build.prefix
! files in latest directory overwrite previously copied versions:
build.copy.dirs : base ${my.source.levs} ${my.source.proj}

! what is copied from the build.copy.dirs (one of those must contains
! the bin with the pycasso scripts, UNLESS ${my.project.dir} is also
! current installation, i.e. "build in place" case)
#if "${my.project.dir}" != "${PWD}":
build.copy.subdirs              : . ../bin
#else
build.copy.subdirs              : .
#endif

! remove project extenstions (True|False) ?
build.copy.remove.__part        : True

! skip some extensions (list of regex pattern) ?
build.copy.skip.ext             : \.pyc$ \..*~$ \..+#

! skip some files ? include in this list:
!  o files that are (re)written by the scripts, e.g. include files and dims_grid.F90;
!    if these are copied, the creation times are obscured, which leads to a
!    re-make during every build 
!  o old stuff that should be removed in a new version;
!    skip them now to test if these files are really not necessary anymore
!
build.copy.skip.file            : configure config.compiler \
                                  Makefile.template Makefile.tm5 \
                                  parray_cwp.F90.in  parray_iwp.F90.in  parray_rwp.F90.in \
                                  file_hdf_iwp.F90.in  file_hdf_rwp.F90.in \
                                  tmkit.F90 \
                                  advect.h \
                                  dims_grid.h_template dims_grid.F90 \
                                  mdf.h tmm.h tm5.h \
                                  mdf.inc tmm.inc tm5.inc \
                                  tmm_mf_hdf.F90 tmm_mf_grib.F90 tmm_mf_ecmwf_mars.F90 \
                                  rcfilename.h

! extend python path with '<build>/py' directory (True|False) ?
build.copy.pypath               :  False


!
! configure
!

! configure source (True|False) ?
build.configure                   :  True

! * macro's

! defined macro's :
build.configure.macro.define      :  ${my.df.define} \
                                     ${my.tmm.define} \
                                     ${my.tm5.define} 
! Specify a list of macro groups:
build.configure.macro.groups      : go num grid mdf tmm tm5 user_output

! For each of the groups, specify:
!
!  o all supported macro's 
!    (sometimes necessary to identify which macros are NOT defined ...)
!
!  o optionally the name of header file; if provided,
!    this file is filed with appropriate '#define' commands
!
! In addition to the macro's defined here, others might be defined
! in 'pycasso_user_scripts/Build_Define' given the other settings.
!
! ~ GO modules
! TO BE REMOVED:
!    with_go             # not necessary, go modules present by default
!    PRINT_MINU              # used for testing ?
build.configure.macro.go.all        :  __INTEL_COMPILER \
                                       __GFORTRAN__ \
                                       __GNUC____GNUC_MINOR____GNUC_PATCHLEVEL__ \
                                       __IBMC__ \
                                       __ecmwf__ \
                                       with_go \
                                       PRINT_MINU
build.configure.macro.go.hfile      :  
!
! ~ num modules:
build.configure.macro.num.all       :  with_lapack
build.configure.macro.num.hfile     :  
!
! ~ grid modules:
build.configure.macro.grid.all      :  check_all
build.configure.macro.grid.hfile    :  
!
! ~ mdf interface to hdf/netcdf
! TO BE REMOVED:
!    with_go             # not necessary, go modules present by default
!    with_hdf5_beta          # testing ...
build.configure.macro.mdf.all       :  with_hdf4 \
                                         with_hdf5 with_hdf5_par \
                                         with_netcdf with_netcdf4 with_netcdf4_par \
                                         with_go \
                                         with_hdf5_beta
build.configure.macro.mdf.hfile     :  mdf.inc
!
! ~ tmm meteo input
build.configure.macro.tmm.all       :  with_tmm_tmpp \
                                         with_tmm_tm5 \
                                         with_tmm_ecmwf \
                                         with_tmm_ecearth \
                                         with_tmm_ncep \
                                         with_tmm_msc \
                                         with_prism \
                                         with_tmm_convec_raw with_tmm_convec_ec with_tmm_convec_ec_gg with_ec_aver \
                                         with_grib_api \
                                         with_parallel_io_meteo \
                                         with_udunits1 with_udunits2
build.configure.macro.tmm.hfile     :  tmm.inc
!
! ~ tm5 settings
!
! Cpp used in coupled version of TM5:
my.macro.tm5.coupling.all           :  with_prism \
                                       oasis3 \
                                       oasis4 \
                                       with_tendencies \
                                       with_ecearth_optics \
                                       with_feedback
!
! List of all C-pre-processors flags used in the code. BUT: 
!
!   * Do not include macro for meteo (tmm* and mdf* files)
!   * Move macros used in coupled version to my.macro.tm5.coupling.all
!   * Move obsolete macros (i.e. to be deleted) to my.macro.tm5.old.all
!
! See tools/misc/find_cpp script to generate initial list of macro
! starting by with_ or without_
! 
build.configure.macro.tm5.all       :  slopes \
                                       secmom \
                                       MPI \
                                       _OPENMP \
                                       with_budgets \
                                       with_cariolle \
                                       with_lapack \
                                       with_m7 \
                                       with_aqchem \
                                       with_kpp \
                                       FULL_ALGEBRA \
                                       with_online_bvoc \
                                       with_online_nox \
                                       with_optics \
                                       with_optics_output \
                                       without_advection \
                                       without_boundary \
                                       without_chemistry \
                                       without_convection \
                                       without_diffusion \
                                       without_dry_deposition \
                                       without_emission \
                                       without_lmax_conv \
                                       without_nmhc_gfed \
                                       without_o3_nudging \
                                       without_photolysis \
                                       without_sedimentation \
                                       without_wet_deposition \
                                       with_ch4_emis \
                                       with_pm \
                                       with_w3 \
                                       with_netcdf4_par \
                                       with_zoom \
                                       tropomi \
                                       ${my.macro.tm5.coupling.all}

! Header file 
build.configure.macro.tm5.hfile     :  tm5.inc
!
! cpp used in user output routines ()
build.configure.macro.user_output.all       :  with_retro_output \
                                               with_cf_output \
                                               with_hdf4
! Header file 
build.configure.macro.user_output.hfile     :  output.inc

! 
! REMOVED:
!    with_mpi                # should be MPI ?
!    with_openmp             # should be _OPENMP
!    with_barrier            # used for testing ?
!    with_budget             # should be with_budgets
!    with_okdebug            # via logical flag
!    without_wetdeposition   # should be without_wet_deposition
!    with_restart            # not necessary anymore with new restart module
!    with_pnetcdf            # depricated library; use netcdf4 instead
!    with_go                 # should use module GO instead
!    with_hdf                # still in some tmkit.F90 in some 4D branches - should update

my.macro.tm5.old.all          :  with_barrier \
                                 with_budget \
                                 with_go \
                                 with_mpi \
                                 with_okdebug \
                                 with_openmp \
                                 without_wetdeposition \
                                 with_restart \
                                 with_hdf \
                                 with_pnetcdf

! Pass macro definitions to command lines, e.g. -Dwith_this_flag (True|False) ?
! The source code checking tests on '#include "tm5.inc"', 
! so this flag could be set to False:
build.configure.define.D      :  False

! * remove files

! remove some files ?
build.configure.remove       :  tmm_mf_tm5_hdf.F90

! remove if macro's are *not* defined ? Use list of files and/or pattern (i.e. *,?, and range of characters with [])
build.configure.remove.ifndef.MPI                   :  mpi_const.F90 mpi_comm.F90
build.configure.remove.ifndef.with_hdf4             :  file_hdf*.F90 io_hdf.F90
build.configure.remove.ifndef.with_tmm_tmpp         :  tmm_mf_tmpp.F90
build.configure.remove.ifndef.with_tmm_tm5          :  tmm_mf_tm5_nc.F90
build.configure.remove.ifndef.with_tmm_ecmwf        :  tmm_mf_ecmwf_tmpp.F90 tmm_mf_ecmwf_tm5.F90 file_grib*.F90 grib_table.F90
build.configure.remove.ifndef.with_tmm_ncep         :  tmm_mf_ncep_gfs.F90 tmm_mf_ncep_cdc.F90 file_ncb.F90 file_ncg.F90
build.configure.remove.ifndef.with_tmm_msc          :  tmm_mf_msc.F90
build.configure.remove.ifndef.with_prism            :  prism_putget.F90 tmm_mf_prism.F90 tm5_prism.F90 appl-tm5.F90
build.configure.remove.ifndef.with_tendencies       :  tm5_tendency.F90 tm5_tendency_eval.F90
build.configure.remove.ifndef.with_budgets          :  budget_global.F90
build.configure.remove.ifndef.with_udunits1         :  udunits.F90 udunits_inc.F
build.configure.remove.ifndef.with_udunits2         :  f_udunits_2.f90 f_udunits_2.inc
build.configure.remove.ifndef.with_m7               :  mo_*.F90 m7_*.F90 m7.F90 emission_ss.F90 emission_pom.F90 emission_dust.F90 emission_bc.F90 PM.F90 optics.F90 calc_pm.F90 user_output_aerocom.F90 user_output_general.F90 user_output_aerchemmip.F90
build.configure.remove.ifndef.with_aqchem           :  aqchem.F90
build.configure.remove.ifndef.with_kpp              :  kpp_aqchem.F90
build.configure.remove.ifndef.with_cariolle         :  tm5_climat.F90 file_fortkeld.F90 file_cariolle.F90 chemistry_cariolle.F90 chemistry_0d__o3tracer.F90
build.configure.remove.ifndef.with_ecearth_optics   :  ecearth_optics.F90
build.configure.remove.ifndef.with_grib_api         :  file_grib_api.F90

! - for proj/user_output/
build.configure.remove.ifndef.with_cf_output        :  user_output_cf.F90
! - for M7 modules:
build.configure.remove.ifndef.with_optics           : optics.F90 user_output_aerocom.F90 user_output_general.F90
build.configure.remove.ifndef.with_pm               : PM.F90

! remove if macro's are defined ? Use list of files and/or pattern (i.e. *,?, and range of characters with [])
build.configure.remove.ifdef.without_advection      : advectx.F90 advecty.F90 advectz.F90
build.configure.remove.ifdef.without_diffusion      : diffusion.F90
build.configure.remove.ifdef.without_wet_deposition : wet_deposition.F90
build.configure.remove.ifdef.without_dry_deposition : dry_deposition.F90
build.configure.remove.ifdef.without_photolysis     : photolysis.i photolysis.F90 photolysis_data.F90
build.configure.remove.ifdef.without_emission       : emission.F90
build.configure.remove.ifdef.without_convection     : convection.F90
build.configure.remove.ifdef.without_boundary       : boundary.F90
build.configure.remove.ifdef.without_chemistry      : chemistry.F90 ebischeme.F90
build.configure.remove.ifdef.without_sedimentation  : sedimentation.F90
build.configure.remove.ifdef.oasis3                 : tracer.F90


! * compiler flags

! Specify space seperated list of compiler flag groups.
! See the implementation in 'pycasso_user_scripts/Build_FlagGroups' .
! Two groups are added by default, and eventually openmp is added if necessary:
!    default real8 [openmp]
! For the actual compiler flags set by a group, see the compiler specific settings.
!
build.configure.flags                   :  ${my.build.configure.flags}

! include file to be written for Makefile:
build.configure.flags.includefile       :  Makefile_flags

! * LIBRARIES
!-------------
! Libraries to be included are specified with a list of keywords, e.g.:
!    netcdf hdf5 hdf4 z jpeg
! For each library name, 2 lines should be present that specify 
! the compile and link flags (probably in the host specific rcfile)
!
! For TotalView with memory debugging, add the 'tv' library.

! list of all supported (ie in your machine rc) libraries; this defines the linking order !
build.configure.libs.all : netcdf4_par netcdf4 netcdf hdf5_par hdf5 hdf4 sz jpeg z grib_api lapack udunits1 udunits2 mpi tv oasis3
!
! ~ default libraries:
build.configure.libs                              :  
!
! ~ libraries to be included if a specific marcro is defined:
build.configure.libs.ifdef.with_pnetcdf           :  pnetcdf
build.configure.libs.ifdef.with_netcdf4_par       :  netcdf4_par
build.configure.libs.ifdef.with_netcdf4           :  netcdf4
build.configure.libs.ifdef.with_netcdf            :  netcdf
build.configure.libs.ifdef.with_hdf5_par          :  hdf5_par sz jpeg z
build.configure.libs.ifdef.with_hdf5              :  hdf5     sz jpeg z
build.configure.libs.ifdef.with_hdf4              :  hdf4     sz jpeg z
build.configure.libs.ifdef.with_grib_api          :  grib_api
build.configure.libs.ifdef.with_lapack            :  lapack
build.configure.libs.ifdef.with_mpi               :  mpi
build.configure.libs.ifdef.with_udunits1          :  udunits1
build.configure.libs.ifdef.with_udunits2          :  udunits2
build.configure.libs.ifdef.oasis3                 :  oasis3


! * user configuration

! routine 'Build_Configure' in 'pycasso_user_scripts.py' is called now;
! use this routine to write special include files etc.

! Apply some source code checks ?
! Provide a space seperated list with keywords; for each keyword, provide below:
!  o a short message to describe the test;
!  o the filename pattern to select the files on which the test should be applied;
!  o a filename pattern to exclude some files;
!  o a python boolean expression applied to each line of the file;
!    the line itself is stored in a string variable named 'line';
!  o a help text to be displayed in case a warning is issued;
!    include \n for newlines.
! If for one of the lines in a source file the test evaluates to 'True', 
! a warning is issued.
! If the test expression starts with 'not', a warning is issued if none
! of the lines evaluates to 'True' for the test after the 'not'.
! If the 'error' flag is set to 'True' and any warnings are issued, then
! the scripting will exit with an error status.

! list with keywords for checks to be applied:
build.configure.checks                  :  tm5_inc tmm_inc advect_h

! all TM files should include "tm5.inc"; search files that do not do that:
build.configure.check.tm5_inc.msg       :  Test on TM5 files that do no not include "tm5.inc" ...
build.configure.check.tm5_inc.files     :  *.[Ff]* tmm_mf_prism.F90
build.configure.check.tm5_inc.skip      :  binas* parray* file_hdf* go* num* grid* phys* tmm* mdf* *grib* \
                                           xmlf* *udunits* standard_name_table.f90 *.swp .*
build.configure.check.tm5_inc.test      :  not line.startswith('#include "tm5.inc"')
build.configure.check.tm5_inc.help      :  \n\
          All files TM5 files should include "tm5.inc" in the header.\n\
          This include file is filled by the scripting with '#define' pre-processing macros.\n\
          To compile a source code with TM5 files that do not include "tm5.inc",\n\
          ensure that marco definitions are passed to the compiler directly by setting:\n\
          .   build.configure.define.D  :  True\n\
          in the expert.rc file.\n\
          .

! all TMM files should include "tmm.inc"; search files that do not do that:
build.configure.check.tmm_inc.msg       :  Test on TMM files that do no not include "tmm.inc" ...
build.configure.check.tmm_inc.files     :  tmm*.[Ff]* file_grib.F90
build.configure.check.tmm_inc.skip      :  tmm_mf_prism.F90
build.configure.check.tmm_inc.test      :  not line.startswith('#include "tmm.inc"')
build.configure.check.tmm_inc.help      :  \n\
          All files TMM files should include "tmm.inc" in the header.\n\
          This include file is filled by the scripting with '#define' pre-processing macros.\n\
          To compile a source code with TMM files that do not include "tmm.inc",\n\
          ensure that marco definitions are passed to the compiler directly by setting:\n\
          .   build.configure.define.D  :  True\n\
          in the expert.rc file.\n\
          .

! none of the TM files should include "advect.h" anymore:
build.configure.check.advect_h.msg      :  Test on TM5 files that include "advect.h" ...
build.configure.check.advect_h.files    :  *.[Ff]*
build.configure.check.advect_h.skip     :  binas* file_hdf* go* num* grid* phys* tmm*
build.configure.check.advect_h.test     :  line.startswith('#include "advect.h"')
build.configure.check.advect_h.help     :  \n\
          Including "advect.h" is depricated; include "tm5.inc" instead.\n\
          .

! special: check on unknown macros used in '#if[n]def' lines,
! but not listed in .all lists above ?
build.configure.check.unknown_macro     :  True
build.configure.check.unknown_macro.msg :  Test for unsupported macros ...

! in case some strange things are found, leave with error message (True|False)?
build.configure.checks.error            :  True

! * makedep

! create depencencies using the external 'makedep' program (True|False) ?
build.configure.makedep        :  True

! include file to be written for Makefile:
build.configure.makedep.includefile     :  Makefile_deps

! dependencies are created for files matching the pattern:
build.configure.makedep.files           :  *.[Ff]*


!
! Compilation (if need to be submitted to the queue, add a build.make.submit key and related queue.*.option.build.* to your machine file - see example in machine-ecmwf-cca-cray.rc)
!
build.make        : True
build.make.dir    : ${build.prefix}
!   the '--clean' or '-c' flag is provided to the setup script
build.make.clean  : False
! make target
#if "oasis3" in "${my.tm5.define}":
build.make.exec   : appl-tm5.x
#else
build.make.exec   : tm5.x
#endif

! ------------------------------------------------
! install executable and scripts
! ------------------------------------------------
!
! Copy files into run directory.
! Specify a space seperated list with source files.
! If the copy should obtain another name, append it seperated with a ':', e.g.
!      model.x:model-myproject.x
! 

! If 'rundir' key is not empty, then 'install.copy' *must* include the
! 'submit.script' key value ("submit_tm5" here), and should not be renamed (why?)

! 
! Include the build directory if necessary, e.g. '${build.prefix}/src/model.x' .
! 
#if "oasis3" not in "${my.tm5.define}":
install.copy             : ${build.prefix}/${build.make.exec}:${job.step.run.exe} \
                           ${build.prefix}/../bin/submit_tm5
#else
install.copy             : ${build.prefix}/bin/submit_tm5
#endif

! name of processed rc file to be written (original this file); 
! leave empty for not writing:
install.rc               :  ${my.basename}.rc


! ------------------------------------------------
! Post-processing : archive sources
! ------------------------------------------------
! Add the name 'sources' to the 'store.tasks' list to enable this!

! specify how to store source files wiht output:
! o store with respect to rundir run directory:
sources.store.from            :  ..
! o target file name:
sources.store.files           :  ${my.basename}__sources.tar
! o filter for files to be included:
sources.store.tarfilter       :  build/bin/ \
                                 build/src/Makefile* \
                                 build/src/*.[Ff]* \
                                 build/src/*.inc \
                                 run/${install.rc}

! ------------------------------------------------
! job script
! ------------------------------------------------
! name of job in queue etc:
job.name            :  ${my.basename}
! names used for job steps (can be overwritten on the command line
! with --steps='init' for example)
job.steps           :  init run done
! executable used by the 'run' step:
job.step.run.exe    :  ${my.basename}.x

! ------------------------------------------------
! submit script
! ------------------------------------------------
! name of submit script:
submit.script       :  submit_tm5
! full submit command from rundirectory:
submit.command      :  ./${submit.script} ${job.step.run.exe} ${install.rc}
! try to use relative paths if possible ?
! this will facilitate moving the complete build/run/output directory:
submit.relpaths     :  False
! abs. path to bin, without 'bin' itself (default to ${build.prefix}). This must be, and could be coded as, ${build.prefix}/${build.copy.subdirs}[element with bin]
submit.bin.path     :  ${my.project.dir}
! submit job to : foreground | background | queue
! might be replaced given the flags passed to the submit script
submit.to           :  foreground
! options passed directly to a submission command (llsubmit, qsub, ...):
submit.options      : 
! run in debugger (True|False) ?
submit.debugger     :  False

! ------------------------------------------------
! horizontal grids
! ------------------------------------------------
!
! List with model regions (space seperated):
!    
!  o the routine 'dims_grid' is automatically re-written if the region list
!    change ;
!    
!  o do not include the 'globe' and 'glb100x100' regions in the region list
!    but specify them seperately below;
!    
!  o the parameter 'nregions' will be set to the number of regions in
!    this list;

regions  :  ${my.region1}

! special: single cell global region:
region.globe                            :  globe

! special: global surface fields (unless region 1 is on the same grid)
#if ("${my.region1}" == "glb100x100") or ("${my.region1}" == "glb050x050") :
region.glbsfc                            :  
#else:
region.glbsfc                            :  glb100x100
#endif

! parent regions for zoom; Must use 'globe' for the global region:
region.${my.region1}.parent             :  ${region.globe}

! 'parent' region for global surface field; used to match surface
! pressures if necessary: 
#if ("${my.region1}" != "glb100x100") and ("${my.region1}" != "glb050x050") :
region.${region.glbsfc}.parent          :  ${my.region1}
#endif

!=====================================================================!
! OpenMP keys are not an option yet.                                  !
!=====================================================================! 
par.openmp    : F
par.nthread   : 1

!=====================================================================!
! Miscelleaneous (do not modify, unless you know what you're doing!)  !
!=====================================================================!
jobstep                 : 0
jobstep.timerange.start : ${timerange.start}
jobstep.timerange.end   : ${timerange.end}
prev.output.dir         : 

! code source for levels definition
#if "${my.levs}" == "all"
my.source.levs :  levels/${my.eclevs}
#else
my.source.levs :  levels/${my.eclevs} levels/${my.eclevs}/${my.levs}
#endif
