###############################################################################
# Developer's configuration file for the ESMValTool
###############################################################################
# This file retains the project- and machine-dependent directory and file name
# definitions of the input and output data.
# Each dictionary is structured as follows:
#
# PROJECT:
#   input_dir:
#     default:
#     drs1:
#     drs2:
#     etc:
#   input_file:
#   output_file:
#
# Only the default drs is mandatory, the others are optional.
#
# In addition, an entry for the custom tables can be given. For this, only the
# option 'cmor_path' is considered, which specifies the directory from which
# custom CMOR tables are loaded. 'cmor_path' can be a relative path (relative
# to ESMValCore/esmvalcore/cmor/tables) or an absolute path. By default, uses
# ESMValCore/esmvalcore/cmor/tables/custom.
#
# custom:
#   cmor_path: ~/my/own/custom_tables
###############################################################################
---

CMIP6:
  cmor_strict: true
  input_dir:
    default: '/'
    BADC: '{activity}/{institute}/{dataset}/{exp}/{ensemble}/{mip}/{short_name}/{grid}/{version}'
    DKRZ: '{activity}/{institute}/{dataset}/{exp}/{ensemble}/{mip}/{short_name}/{grid}/{version}'
    ESGF: '{project}/{activity}/{institute}/{dataset}/{exp}/{ensemble}/{mip}/{short_name}/{grid}/{version}'
    ETHZ: '{exp}/{mip}/{short_name}/{dataset}/{ensemble}/{grid}/'
    SYNDA: '{activity}/{institute}/{dataset}/{exp}/{ensemble}/{mip}/{short_name}/{grid}/{version}'
  input_file: '{short_name}_{mip}_{dataset}_{exp}_{ensemble}_{grid}*.nc'
  output_file: '{project}_{dataset}_{mip}_{exp}_{ensemble}_{short_name}_{grid}'
  cmor_type: 'CMIP6'

CMIP5:
  cmor_strict: true
  input_dir:
    default: '/'
    BADC: '{institute}/{dataset}/{exp}/{frequency}/{modeling_realm}/{mip}/{ensemble}/{version}/{short_name}'
    BSC: '{type}/{project}/{exp}/{dataset.lower}'
    CP4CDS: '{institute}/{dataset}/{exp}/{frequency}/{modeling_realm}/{mip}/{ensemble}/{short_name}/latest/'
    DKRZ: '{institute}/{dataset}/{exp}/{frequency}/{modeling_realm}/{mip}/{ensemble}/{version}/{short_name}'
    ETHZ: '{exp}/{mip}/{short_name}/{dataset}/{ensemble}/'
    ESGF: '{project.lower}/{product}/{institute}/{dataset}/{exp}/{frequency}/{modeling_realm}/{mip}/{ensemble}/{version}'
    RCAST: '{exp}/{mip}/{short_name}/{dataset}/{ensemble}/'
    SMHI: '{dataset}/{ensemble}/{exp}/{frequency}'
    SYNDA: '{institute}/{dataset}/{exp}/{frequency}/{modeling_realm}/{mip}/{ensemble}/{version}'
  input_file: '{short_name}_{mip}_{dataset}_{exp}_{ensemble}*.nc'
  output_file: '{project}_{dataset}_{mip}_{exp}_{ensemble}_{short_name}'

CMIP3:
  cmor_strict: true
  input_dir:
    default: '/'
    BADC: '{institute}/{dataset}/{exp}/{frequency}/{modeling_realm}/{short_name}/{ensemble}/{version}'
    DKRZ: '{exp}/{modeling_realm}/{frequency}/{short_name}/{dataset}/{ensemble}'
    ESGF: '{project.lower}/{institute}/{dataset}/{exp}/{frequency}/{modeling_realm}/{ensemble}/{short_name}/{version}'
    IPSL: '{institute}/{dataset}/{exp}/{frequency}/{modeling_realm}/{ensemble}/{short_name}/{version}/{short_name}'
  input_file: '{short_name}_*.nc'
  output_file: '{project}_{institute}_{dataset}_{mip}_{exp}_{ensemble}_{short_name}'
  cmor_type: 'CMIP3'

OBS:
  cmor_strict: false
  input_dir:
    default: 'Tier{tier}/{dataset}'
    BSC: '{type}/{institute.lower}/{dataset.lower}/{freq_folder}/{short_name}{freq_base}'
    RCAST: '{dataset}'
  input_file:
    default: '{project}_{dataset}_{type}_{version}_{mip}_{short_name}[_.]*nc'
    BSC: '{short_name}_*.nc'
    RCAST: '{short_name}_{mip}_{type}_{dataset}_*.nc'
  output_file: '{project}_{dataset}_{type}_{version}_{mip}_{short_name}'
  cmor_type: 'CMIP5'

OBS6:
  cmor_strict: false
  input_dir:
    default: 'Tier{tier}/{dataset}'
    BSC: '{type}/{institute.lower}/{dataset.lower}/{freq_folder}/{short_name}{freq_base}'
  input_file:
    default: '{project}_{dataset}_{type}_{version}_{mip}_{short_name}[_.]*nc'
    BSC: '{short_name}_*.nc'
  output_file: '{project}_{dataset}_{type}_{version}_{mip}_{short_name}'
  cmor_type: 'CMIP6'

native6:
  cmor_strict: false
  input_dir:
    default: 'Tier{tier}/{dataset}/{version}/{frequency}/{short_name}'
  input_file:
    default: '*.nc'
  output_file: '{project}_{dataset}_{type}_{version}_{mip}_{short_name}'
  cmor_type: 'CMIP6'
  cmor_default_table_prefix: 'CMIP6_'

obs4MIPs:
  cmor_strict: false
  input_dir:
    default: 'Tier{tier}/{dataset}'
    ESGF: '{project}/{dataset}/{version}'
    RCAST: '/'
    IPSL: '{realm}/{short_name}/{freq}/{grid}/{institute}/{dataset}/{latest_version}'
  input_file:
    default: '{short_name}_*.nc'
    ESGF: '{short_name}_*.nc'
  output_file: '{project}_{dataset}_{short_name}'
  cmor_type: 'CMIP6'
  cmor_path: 'obs4mips'
  cmor_default_table_prefix: 'obs4MIPs_'

ana4mips:
  cmor_strict: false
  input_dir:
    default: 'Tier{tier}/{dataset}'
    RCAST: '/'
  input_file: '{short_name}_{mip}_{type}_{dataset}_*.nc'
  output_file: '{project}_{mip}_{type}_{dataset}_{short_name}'
  cmor_type: 'CMIP5'
  # TODO: add cmor_path and table and set cmor_strict to true

EMAC:
  cmor_strict: false
  input_dir:
    default: '{exp}/{channel}'
  input_file:
    default: '{exp}*{channel}{postproc_flag}.nc'
  output_file: '{project}_{dataset}_{exp}_{channel}_{mip}_{short_name}'
  cmor_type: 'CMIP6'
  ignore_warnings:
    load:
      - {message: 'Ignored formula of unrecognised type: .*', module: iris}
      - {message: 'Ignoring formula terms variable .* referenced by data variable .* via variable .*', module: iris}
      - {message: 'Missing CF-netCDF formula term variable .*, referenced by netCDF variable .*', module: iris}
      - {message: 'NetCDF variable .* contains unknown cell method .*', module: iris}

CORDEX:
  input_dir:
    default: '/'
    spec: '{domain}/{institute}/{driver}/{exp}/{ensemble}/{dataset}/{rcm_version}/{mip}/{short_name}'
    BADC: '{domain}/{institute}/{driver}/{exp}/{ensemble}/{dataset}/{rcm_version}/{mip}/{short_name}/{version}'
    ESGF: '{project.lower}/output/{domain}/{institute}/{driver}/{exp}/{ensemble}/{dataset}/{rcm_version}/{frequency}/{short_name}/{version}'
  input_file: '{short_name}_{domain}_{driver}_{exp}_{ensemble}_{dataset}_{rcm_version}_{mip}*.nc'
  output_file: '{project}_{dataset}_{rcm_version}_{driver}_{domain}_{mip}_{exp}_{ensemble}_{short_name}'
  cmor_type: 'CMIP5'
  cmor_path: 'cordex'

IPSLCM:
  cmor_strict: false
  input_dir:
    default: '{root}/{account}/{model}/{status}/{exp}/{simulation}/{dir}/{out}/{freq}'
  input_file:
    default:
      - '{simulation}_*_{ipsl_varname}.nc'
      - '{simulation}_*_{group}.nc'
  output_file: '{dataset}_{account}_{model}_{status}_{exp}_{simulation}_{freq}_{short_name}'
  cmor_type: 'CMIP6'
  cmor_default_table_prefix: 'CMIP6_'

ICON:
  cmor_strict: false
  input_dir:
    default:
      - '{exp}'
      - '{exp}/outdata'
  input_file:
    default: '{exp}_{var_type}*.nc'
  output_file: '{project}_{dataset}_{exp}_{var_type}_{mip}_{short_name}'
  cmor_type: 'CMIP6'
  cmor_default_table_prefix: 'CMIP6_'

CESM:
  cmor_strict: false
  input_dir:
    default:
      - '/'  # run directory
      - '{case}/{gcomp}/hist'  # short-term archiving
      - '{case}/{gcomp}/proc/{tdir}/{tperiod}'  # postprocessed data
  input_file:
    default: '{case}.{scomp}.{type}.{string}*nc'
  output_file: '{project}_{dataset}_{case}_{gcomp}_{scomp}_{type}_{mip}_{short_name}'
  cmor_type: 'CMIP6'
  cmor_default_table_prefix: 'CMIP6_'
