From 55b9da95b9178a45ec8431344d3101e734768c8e Mon Sep 17 00:00:00 2001
From: Martin Schupfner <k204212@levante2.lvt.dkrz.de>
Date: Wed, 31 Jul 2024 11:08:25 +0200
Subject: [PATCH] Added mapping and diag/cmor fragments for vilma

---
 .../conf/PalMod2_requested_vars_AllExp.conf   |  9 ++++
 .../palmod2_aggregation_MPI-ESM1-2_vilma.h    | 23 +++++++++
 ...lmod2_cmor-rewrite_MPI-ESM1-2_vilma_auto.h | 33 +++++++++++++
 ...palmod2_diagnostic_MPI-ESM1-2_vilma_auto.h | 23 +++++++++
 .../MPI-ESM1-2_vilma_PalMod2_mapping.txt      | 47 +++++++++++++++++++
 5 files changed, 135 insertions(+)
 create mode 100644 cmor/mpiesm/scripts/palmod2_aggregation_MPI-ESM1-2_vilma.h
 create mode 100644 cmor/mpiesm/scripts/palmod2_cmor-rewrite_MPI-ESM1-2_vilma_auto.h
 create mode 100644 cmor/mpiesm/scripts/palmod2_diagnostic_MPI-ESM1-2_vilma_auto.h
 create mode 100644 cmor/mpiesm/scripts/tables/MPI-ESM1-2_vilma_PalMod2_mapping.txt

diff --git a/cmor/mpiesm/scripts/conf/PalMod2_requested_vars_AllExp.conf b/cmor/mpiesm/scripts/conf/PalMod2_requested_vars_AllExp.conf
index 9b4f8e1..4f042ce 100755
--- a/cmor/mpiesm/scripts/conf/PalMod2_requested_vars_AllExp.conf
+++ b/cmor/mpiesm/scripts/conf/PalMod2_requested_vars_AllExp.conf
@@ -37,6 +37,7 @@ echammonplev19  : interpolation = True
 echammonafter   : afterburner   = True
 jsbachdecfx     : input         = True
 echamdecfx      : input         = True
+vilmadecfx      : input         = slm  # only for SLM runs (i.e. incl vilma)
 mpiom           : basin         = False # basin file does not exist for GR30
 mpiom           : basin         = slice: first_step
 mpiom           : gridfile      = True
@@ -47,6 +48,7 @@ Ofx             : areacello     = True
 #################
 # Ocean
 #################
+Odec             : sftof        = slm   # only for SLM runs (i.e. incl vilma)
 #Ofx             : deptho       = False # variable has decadal or annual frequency
 #Ofx             : sftof        = False # variable has decadal or annual frequency
 #Ofx             : thkcello     = False # variable has monthly frequency (uppermost layer)
@@ -74,4 +76,11 @@ wetlandFrac     : Emon   = False # variable only for MPI-ESM1-2-CR-CH4
 termiteCH4      : Emon   = False # variable only for MPI-ESM1-2-CR-CH4
 fVegFireCH4     : Emon   = False # variable only for MPI-ESM1-2-CR-CH4
 herbivoreCH4    : Emon   = False # variable only for MPI-ESM1-2-CR-CH4
+##################
+# solidLand
+##################
+SLdec            : SLdec  = slm  # only for SLM runs (i.e. incl vilma)
+##################
+IdecAnt          : IdecAnt = ism  # only for ISM runs (i.e. incl mPISM)
+IdecGre          : IdecGre = ism  # only for ISM runs (i.e. incl mPISM)
 #<---- Specify your settings for Experiment AllExp here
diff --git a/cmor/mpiesm/scripts/palmod2_aggregation_MPI-ESM1-2_vilma.h b/cmor/mpiesm/scripts/palmod2_aggregation_MPI-ESM1-2_vilma.h
new file mode 100644
index 0000000..654e0ff
--- /dev/null
+++ b/cmor/mpiesm/scripts/palmod2_aggregation_MPI-ESM1-2_vilma.h
@@ -0,0 +1,23 @@
+################################
+# VILMA ########################
+################################
+
+{ (if_requested $member $slmod vilmadecfx input $chunk "$vilma_input_dec_chunk" && {
+
+  # Create decadal "fx"-variables
+  ifile_topo=$input_file_topo
+  ifile_glac=$input_file_glac
+
+  #-- orog
+  $cdo setname,orog $input_file_topo $sdir/out_aggr/orog_SLdec_$period.nc || echo ERROR
+
+  #-- glac
+  $cdo setname,glac $input_file_glac $sdir/out_aggr/glac_SLdec_$period.nc || echo ERROR
+
+}; )&; }>$err.vilmadecfx.input 2>&1
+
+
+###########################################################################################################
+
+wait
+
diff --git a/cmor/mpiesm/scripts/palmod2_cmor-rewrite_MPI-ESM1-2_vilma_auto.h b/cmor/mpiesm/scripts/palmod2_cmor-rewrite_MPI-ESM1-2_vilma_auto.h
new file mode 100644
index 0000000..cf6d6c1
--- /dev/null
+++ b/cmor/mpiesm/scripts/palmod2_cmor-rewrite_MPI-ESM1-2_vilma_auto.h
@@ -0,0 +1,33 @@
+#-- CMOR-rewrite for vilma (ESM: MPI-ESM1-2) SLdec
+cn='glac orog'
+for var in $cn; do
+  { (if_requested $member $slmod SLdec $var $chunk '${slmod_dec_chunk}' || continue
+  mkdir -p $dr/$submodel/SLdec_${var}
+  find_file "$sdir" "SLdec_${var}_${period}*.nc" ifile >> $err.find_file.SLdec 2>&1
+  echo $cdo cmor,SLdec,i=$it,mt=$mt,dr=$dr/$submodel/SLdec_${var},vd=$vd,cn=$var,ta=cmip,di=$di ${cdochain-} $ifile
+  $cdo cmor,SLdec,i=$it,mt=$mt,dr=$dr/$submodel/SLdec_${var},vd=$vd,cn=$var,ta=cmip,di=$di ${cdochain-} $ifile || echo ERROR
+  )&; }>>$err.$var.SLdec 2>&1
+done
+
+#-- CMOR-rewrite for vilma (ESM: MPI-ESM1-2) SLdec
+cn='rslc'
+for var in $cn; do
+  { (if_requested $member $slmod SLdec $var $chunk '${slmod_dec_chunk}' || continue
+  mkdir -p $dr/$submodel/SLdec_${var}
+  ifile=${sdir}/out_diag/SLdec_${var}_$period.nc
+  echo $cdo cmor,SLdec,i=$it,mt=$mt,dr=$dr/$submodel/SLdec_${var},vd=$vd,cn=$var,ta=cmip,di=$di ${cdochain-} $ifile
+  $cdo cmor,SLdec,i=$it,mt=$mt,dr=$dr/$submodel/SLdec_${var},vd=$vd,cn=$var,ta=cmip,di=$di ${cdochain-} $ifile || echo ERROR
+  )&; }>>$err.$var.SLdec 2>&1
+done
+
+#-- CMOR-rewrite for vilma (ESM: MPI-ESM1-2) fx
+cn='areacellsl'
+for var in $cn; do
+  { (if_requested $member $slmod fx $var $chunk || continue
+  mkdir -p $dr/$submodel/fx_${var}
+  ifile=${sdir}/out_diag/fx_${var}_$period.nc
+  echo $cdo cmor,fx,i=$it,mt=$mt,dr=$dr/$submodel/fx_${var},vd=$vd,cn=$var,ta=cmip,di=$di $ifile
+  $cdo cmor,fx,i=$it,mt=$mt,dr=$dr/$submodel/fx_${var},vd=$vd,cn=$var,ta=cmip,di=$di $ifile || echo ERROR
+  )&; }>>$err.$var.fx 2>&1
+done
+
diff --git a/cmor/mpiesm/scripts/palmod2_diagnostic_MPI-ESM1-2_vilma_auto.h b/cmor/mpiesm/scripts/palmod2_diagnostic_MPI-ESM1-2_vilma_auto.h
new file mode 100644
index 0000000..bb8ae93
--- /dev/null
+++ b/cmor/mpiesm/scripts/palmod2_diagnostic_MPI-ESM1-2_vilma_auto.h
@@ -0,0 +1,23 @@
+#-- Diagnostic for vilma (ESM: MPI-ESM1-2) variable rslc / table SLdec
+{ (if_requested $member $slmod SLdec rslc $chunk '${slmod_dec_chunk}' && {
+  find_file -e            "$sdir" "rsl_${period}*.nc" ifile
+  echo "$cdo -f nc -O \
+    -expr,'rslc=rsl/10.;' \
+    -settaxis,'${periodbk}-07-01,00:00:00' \
+    -settunits,'days' \
+    $ifile ${sdir}/out_diag/SLdec_rslc_${periodbk}.nc"
+  $cdo -f nc -O \
+    -expr,'rslc=rsl/10.;' \
+    -settaxis,'${periodbk}-07-01,00:00:00' \
+    -settunits,'days' \
+    $ifile ${sdir}/out_diag/SLdec_rslc_${periodbk}.nc || echo ERROR
+}; )&; }>$err.rslc.SLdec 2>&1
+
+#-- Diagnostic for vilma (ESM: MPI-ESM1-2) variable areacellsl / table fx
+{ (if_requested $member $slmod fx areacellsl $chunk && {
+  find_file -e            "$sdir" "SLdec_glac_${periodbk}.nc" ifile
+  $cdo -f nc -O \
+    expr,'areacellsl=gridarea(glac);' \
+    $ifile ${sdir}/out_diag/fx_areacellsl_$period.nc || echo ERROR
+}; )&; }>$err.areacellsl.fx 2>&1
+
diff --git a/cmor/mpiesm/scripts/tables/MPI-ESM1-2_vilma_PalMod2_mapping.txt b/cmor/mpiesm/scripts/tables/MPI-ESM1-2_vilma_PalMod2_mapping.txt
new file mode 100644
index 0000000..0d63f4e
--- /dev/null
+++ b/cmor/mpiesm/scripts/tables/MPI-ESM1-2_vilma_PalMod2_mapping.txt
@@ -0,0 +1,47 @@
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Automatically created Variable-Mapping-Table for VILMA 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Creation Date: 2024-07-31 10:52:14.021843 UTC
+! Data Request Version: 00.00.03
+! $URL$
+! $Rev$  $Date$
+!----------------------------------------------------------------------------------------
+! This table contains information that has to be provided in order to use the CDO cmor operator.
+! E.g. if your data files are GRIB formatted, the code number of the variable which
+!   corresponds to the target variable indicated by the short (CMOR) name (cmor_name=)
+!   needs to be given (with keyword 'code').
+! The table format:
+!  Each line has to start with '&parameter '
+!  Comments start with an exclamation sign
+!  The order of keyword assignments does not matter
+!  There must be at least 1 space between assignments
+!  Any keyword value may be written with double-quotes
+!  If a keyword value contains spaces, it must be delimited by double-quotes
+! Keywords interpreted by cdo cmor,... are :
+!
+! Entry            	Type 	Description
+!----------------------------------------------------------------------------------------
+! name                 STRING  Name of the variable in a NetCDF model output file
+! code                 STRING  1 to 3-digit variable code (for GRIB files)
+! cmor_name            WORD    CMIP/CMOR name of the target variable
+!                              (this is not necessarily the output variable name!)
+! character_axis       STRING  Standard (CMOR) name of a character axis
+! param                STRING  GRIB parameter (GRIB1: code[.tabnum]; GRIB2: num[.cat[.dis]])
+! units                STRING  Units (UDUNITS!) of the variable
+! positive             WORD    'u' or 'd' for 'up' and 'down' flux direction
+! variable_comment     STRING  Information concerning the target variable that will be
+!                              transformed into a variable NetCDF attribute
+! cell_methods         WORD    Information about the time:cell_methods of the target variable
+! project_mip_table    WORD    MIP-table name of the target variable
+! z-axis               WORD    vertical axis name of the target variable
+!
+! OtherAdditional keywords are allowed; they will be ignored by the cmor operator.
+!
+!----------------------------------------------------------------------------------------
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Diagnosed Variables listed in the following: !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+&parameter cmor_name="areacellsl"                              project_mip_table="fx"           units="m2"            cell_methods="n"  /
+&parameter cmor_name="glac"                                    project_mip_table="SLdec"        units="1"             cell_methods="m"  /
+&parameter cmor_name="orog"                                    project_mip_table="SLdec"        units="m"             cell_methods="m"  /
+&parameter cmor_name="rslc"                                    project_mip_table="SLdec"        units="m year-1"      cell_methods="m"  /
-- 
GitLab