diff --git a/cmor/mpiesm/scripts/ssp119-future-methane_r1i1p1f1-CR_cdocmorinfo b/cmor/mpiesm/scripts/ssp119-future-methane_r1i1p1f1-CR_cdocmorinfo index 3fdc2ac92c802a022bcff58283b44a7dec4ca5a1..5b8e0b2d838a40d0612eac0d2202f1e2229b32fc 100644 --- a/cmor/mpiesm/scripts/ssp119-future-methane_r1i1p1f1-CR_cdocmorinfo +++ b/cmor/mpiesm/scripts/ssp119-future-methane_r1i1p1f1-CR_cdocmorinfo @@ -43,8 +43,8 @@ SUB_EXPERIMENT=none # SOURCE_ID=MPI-ESM1-2-CR-CH4 #MODEL_ID=MPI-ESM1-2-CR-CH4 -REFERENCES="Kleinen, T., Mikolajewicz, U. and Brovkin, V. (2020). Terrestrial methane emissions from the Last Glacial Maximum to the preindustrial period. Climate of the Past, 16(2):575–595. doi: 10.5194/cp-16-575-2020.\nKleinen, T., Gromov, S., Steil, B. and Brovkin, V. (2021). Atmospheric methane underestimated in future climate projections. Environmental Research Letters, 16(9):094006. doi: 10.1088/1748-9326/ac1814.\nKapsch, M.-L., Mikolajewicz, U., Ziemen, F., & Schannwell, C. (2022). Ocean response in transient simulations of the last deglaciation dominated by underlying ice-sheet reconstruction and method of meltwater distribution. Geophysical Research Letters, 49, e2021GL096767. https://doi.org/10.1029/2021GL096767\nMPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPIâ€M Earth System Model version 1.2 (MPIâ€ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400" -#,\nMueller, W.A. et al. (2018): A highâ€resolution version of the Max Planck Institute Earth System Model MPIâ€ESM1.2â€HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217" +REFERENCES="Kleinen, T., Mikolajewicz, U. and Brovkin, V. (2020). Terrestrial methane emissions from the Last Glacial Maximum to the preindustrial period. Climate of the Past, 16(2):575–595. doi: 10.5194/cp-16-575-2020\nKleinen, T., Gromov, S., Steil, B. and Brovkin, V. (2021). Atmospheric methane underestimated in future climate projections. Environmental Research Letters, 16(9):094006. doi: 10.1088/1748-9326/ac1814\nKapsch, M.-L., Mikolajewicz, U., Ziemen, F., & Schannwell, C. (2022). Ocean response in transient simulations of the last deglaciation dominated by underlying ice-sheet reconstruction and method of meltwater distribution. Geophysical Research Letters, 49, e2021GL096767. https://doi.org/10.1029/2021GL096767\nMPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPIâ€M Earth System Model version 1.2 (MPIâ€ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400" +#\nMueller, W.A. et al. (2018): A highâ€resolution version of the Max Planck Institute Earth System Model MPIâ€ESM1.2â€HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217" SOURCE="MPI-ESM1.2-CR (2017): \naerosol: none, prescribed Kinne (2010)\natmos: ECHAM6.3 (spectral T31; 96 x 48 longitude/latitude; 31 levels; top level 10 hPa)\natmosChem: unnamed (accelerated methane chemistry)\nland: JSBACH3.20, River Transport Model\nlandIce: none, prescribed\nocean: MPIOM1.63 (bipolar GR3.0, approximately 300km; 122 x 101 longitude/latitude; 40 levels; top grid cell 0-15 m)\nocnBgchem: none, prescribed\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\nsolidLand: none, prescribed" SOURCE_TYPE="AOGCM CHEM" #CALENDAR=proleptic_gregorian diff --git a/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.cmor_ctl b/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.cmor_ctl new file mode 100755 index 0000000000000000000000000000000000000000..0399cb3a540eac78db9444cb7193a9b3a7f6d58a --- /dev/null +++ b/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.cmor_ctl @@ -0,0 +1,57 @@ +#! /bin/sh -e +#SBATCH --account=bm0021 +#SBATCH --qos=esgf +#SBATCH --time=48:00:00 +#SBATCH --partition=shared +#SBATCH --mail-type=FAIL +#SBATCH --output=%x_%j.log + +# Number of sub-simulations +n_subsim=1 +#initial and final year of the experiment +spinup=0 +iniyeararr=( $(( 5900 + spinup )) ) +finyeararr=( 7099 ) +iniyear=$(( 1850 + spinup )) +finyear=3049 +#offset compared to startyear +inioffsetarr=(-4050) + +# Chunksize +# Note that there are prerequisites concerning the chunksize: +# - the defined decadal timeslizes may not overlap between two chunks! +# - decadal bounds have to be defined accordingly - "???01231" in this case +# - usually this is the case by default due to decadal model output! +chunksize=100 + +# Create list +for i in $(seq 0 $(( n_subsim - 1 )) ) +do + for yyyy in $(seq ${iniyeararr[$i]} ${finyeararr[$i]} ) + do + paramarr+=( "$i $yyyy" ) + done +done + +rm -f cmor_ctl_list_ssp126_r1i1p1f1 +in=0 +for i in $(seq $((iniyear-iniyear)) $chunksize $((finyear-iniyear))) +do + [[ $i -eq $((iniyear-iniyear)) ]] && continue + li=$(echo ${paramarr[$in]} | cut -d " " -f1) + ly=$(echo ${paramarr[$in]} | cut -d " " -f2) + ui=$(echo ${paramarr[$((i-1))]} | cut -d " " -f1) + uy=$(echo ${paramarr[$((i-1))]} | cut -d " " -f2) + in=$i + echo "$li $ui $ly $uy" >> cmor_ctl_list_ssp126_r1i1p1f1 +done +[[ $i -ne $((finyear-iniyear)) ]] && { + li=$(echo ${paramarr[$in]} | cut -d " " -f1) + ly=$(echo ${paramarr[$in]} | cut -d " " -f2) + ui=$(echo ${paramarr[$((finyear-iniyear))]} | cut -d " " -f1) + uy=$(echo ${paramarr[$((finyear-iniyear))]} | cut -d " " -f2) + echo "$li $ui $ly $uy" >> cmor_ctl_list_ssp126_r1i1p1f1 +} + +make -k -j 19 -f ssp126-future-methane_r1i1p1f1-CR.cmor_ctl.mk "$@" + diff --git a/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.cmor_ctl.mk b/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.cmor_ctl.mk new file mode 100755 index 0000000000000000000000000000000000000000..d671e31c4e3feff2019a3babd1acf1e1641f870e --- /dev/null +++ b/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.cmor_ctl.mk @@ -0,0 +1,44 @@ +EXP_ID = ssp126-future-methane_r1i1p1f1-CR + +ACCOUNT = bm0021 +PARTITION = prepost,compute,compute2 + +SUFFIX = +ARCHIVE_SUFFIX = + +TARGET_STEP=cmor +NUMCHUNKS=$(shell cat cmor_ctl_list_ssp126_r1i1p1f1 | wc -l ) + +AGGR_TIME = 00:10:00 +DIAGS_TIME = 00:30:00 +CMOR_TIME = 02:30:00 + +CMOR_FLAGS = + +SBATCHFLAGS=-W + +MESSAGE = $$(date +%Y-%m-%dT%H:%M:%S): CMIP6 diagnostics and CMOR rewriting ($(SUFFIX:_%=%)) + +.PHONY: all +.PRECIOUS: targets/$(EXP_ID).aggr$(SUFFIX).% targets/$(EXP_ID).diags$(SUFFIX).% targets/$(EXP_ID).cmor$(SUFFIX).% + + + +all: + @echo "$(MESSAGE) started" + mkdir -vp targets + $(MAKE) $(MFLAGS) -f $(MAKEFILE_LIST) $(addprefix targets/$(EXP_ID).$(TARGET_STEP)$(SUFFIX).,$(shell seq 1 $(NUMCHUNKS))) + @echo "$(MESSAGE) finished" + +targets/$(EXP_ID).aggr$(SUFFIX).%: + sbatch $(SBATCHFLAGS) --time=$(AGGR_TIME) --job-name=$(EXP_ID)_runpp_aggr$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -A $(shell sed -n '$(*)'p < cmor_ctl_list_ssp126_r1i1p1f1) + @touch $@ + +targets/$(EXP_ID).diags$(SUFFIX).%: targets/$(EXP_ID).aggr$(SUFFIX).% + sbatch $(SBATCHFLAGS) --time=$(DIAGS_TIME) --job-name=$(EXP_ID)_runpp_diag$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -d $(shell sed -n '$(*)'p < cmor_ctl_list_ssp126_r1i1p1f1) + @touch $@ + +targets/$(EXP_ID).cmor$(SUFFIX).%: targets/$(EXP_ID).diags$(SUFFIX).% + sbatch $(SBATCHFLAGS) --time=$(CMOR_TIME) --job-name=$(EXP_ID)_runpp_cmor$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -c $(CMOR_FLAGS) $(shell sed -n '$(*)'p < cmor_ctl_list_ssp126_r1i1p1f1) + @touch $@ + diff --git a/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.runpp b/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.runpp new file mode 100755 index 0000000000000000000000000000000000000000..6f81fcec2e810bbb54b1be26043c7164765645dd --- /dev/null +++ b/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR.runpp @@ -0,0 +1,607 @@ +#!/bin/ksh +# +# PalMod .runpp +# +# Wrapper Script Agg+Diag+CMOR MPI-ESM1-2 by Martin Schupfner, DKRZ +# +### Batch Queuing System is SLURM +#SBATCH --partition=compute +#SBATCH --nodes=1 +#SBATCH --mem=100G +#SBATCH --time=01:30:00 +#SBATCH --mail-type=none +#SBATCH --account=bk1192 +##SBATCH --qos=esgf +#SBATCH --exclusive +#SBATCH --output=ssp126-future-methane_r1i1p1f1-CR.runpp_%j.log + +DEBUG_LEVEL=${DEBUG_LEVEL:-0} + +# Support log style output +export LANG=C +print () { command print "$(date +'%F %T'):" "$@"; } +print_re='^[0-9]+-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}' + +warn () { print 'Hey:' "$@" >&2; } +die () { print 'Oops:' "$@" >&2; return 1; } + +# Bail out on error +trap 'print Error at line $LINENO >&2' ERR +set -eu + +# Disable core file creation +ulimit -c 0 + +# Print command info +[[ $DEBUG_LEVEL -ge 2 ]] && set -x + +#module load nco || { echo "Oops: Could not load NCO!" && exit 1 ; } +alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted + +######################################### +# Define specifics about the simulation +######################################### + +#Root directory of all scripts, outdata, logs etc +EXP_ID=ssp126-future-methane_r1i1p1f1-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_TK/ssp126-future-methane_r1i1p1f1-CR +#EXP_DIR_TRUNK=/work/bk1192/k204212/palmod_TK/ssp126-future-methane_r1i1p1f1-CR + +#initial files for aggregation +INPUT_DIR_TRUNK=/work/bm1030/from_Mistral/bm1030/m300020/mpiesm-palmod_tk_r10186_megan_next/experiments + +# RAW Data - path and sub-simulations +RAW_EXP_DIR_TRUNK=/work/bk1192/from_Mistral/bk1192/WG2/WP2.3/future_scenarios_2021/SSP1-2.6 +# As usually the Experiment is composed of several sub-simulations, define them as array +RAW_EXP_IDS=( pmt0550_20RN_SSP126_r2 ) +# Parent experiment that the first RAW_EXP_ID branched from +# (used for input data of the parent that is required for aggregation) +# !! spinup - the aggregation will fail if the spinup period +# !! is as long or longer than +# !! the length of the first sub simulation! +spinup=0 +RAW_EXP_ID_PARENT=( pmt0531_d ) +# actually, there was a 300y spinup after the branch from pmt0531_d@5600 +# but for simplicity this is ignored here +#if [[ $spinup -ne 0 ]]; then +RAW_EXP_ID_PARENT[0]=${RAW_EXP_IDS[0]} +#fi + +echo ${RAW_EXP_IDS[@]} +echo ${RAW_EXP_ID_PARENT[@]} + +#Work dir +WORK_DIR_TRUNK=$EXP_DIR_TRUNK/work + +#Where to find the scripts (runpp etc.) +SCRIPT_DIR=${EXP_DIR_TRUNK}/scripts +SCRIPT_DIR=/work/bm0021/PalMod2/cmor/mpiesm/scripts + + + +############################ +#Define necessary variables +############################ + +#Where to find cdo (incl. CMOR operator), eg.: +cdo="/work/bm0021/cdo_incl_cmor/cdo-2022-09-20_cmor3.6.0_gcc/bin/cdo -v" # latest version + +# Base directory for DataRequest related headers/scripts +SCRIPT_ROOT=${SCRIPT_DIR} + +#Where to find the functions +fpath=/work/bm0021/PalMod2/cmor/functions + +#Where to find the configuration +cpath=${SCRIPT_ROOT}/conf + +#Models +atmmod=echam6 +ocemod=mpiom +srfmod=jsbach +esmod=MPI-ESM1-2 + +#Chunks +chunks+=([echam6]=" 0 1 2 3 4 5 6 7 8 9 ") +chunks+=([jsbach]=" 0 1 2 3 4 5 6 7 8 9 ") +chunks+=([mpiom]=" 0 ") +chunks+=([jsbachdec]=" 0 ") +atmmod_dec_chunk="???9123124" +srfmod_dec_chunk="???9123124" +srfmod_input_dec_chunk="???0123124" +ocemod_dec_chunk="???0123124" +icemod_dec_chunk="???0123124" +ocemod_fxyear=5900 + +#InfoTable(s) +# Define here the "cdocmorinfo"-File or "eum"-Files +# Multiple files possible with "," as delimiter, eg: +# it=expinfo.txt,userinfo.txt,modelinfo.txt +it_temp="${SCRIPT_ROOT}/ssp126-future-methane_r1i1p1f1-CR_cdocmorinfo" +ca+=([mpiom]="${SCRIPT_ROOT}/cdocmorinfo_mpiom_CR") +ca+=([echam6]="${SCRIPT_ROOT}/cdocmorinfo_echam6_CR") +ca+=([jsbach]="${SCRIPT_ROOT}/cdocmorinfo_jsbach_CR") + +#Experiment etc +experiment=ssp126-future-methane +member=r1i1p1f1 +mip=PalMod2 +vd=v20230105 +#vd=v$(date '+%Y%m%d') #CMOR version directory name, should be a date in format YYYYMMDD + +#Where to store errors +errdir=${EXP_DIR_TRUNK}/logs/errors +errdir_cmor=${errdir}_cmor +errdir_diag=${errdir}_diag +errdir_agg=${errdir}_agg + +#initial and final year of the experiment +iniyeararr=($((5900+spinup))) # 1850-3049, after the 300y spinup +finyeararr=(7099) +iniyear=1850 +finyear=3049 +#offset compared to startyear +inioffsetarr=(-4050) # 1850-3049 +# - 5900-7099 - 1200 yrs - 1850-3049 - -4050 + +# Command line options +RUN_AGG=true +RUN_DIAGS=true +RUN_CMOR=true +SUFFIX= +CLIMSUFFIX= +ARCHIVE_SUFFIX= +USE_CHUNKS=false +REMOVE_CHUNKS=false +PROCESS_CLIM=false +while [[ "$1" == -* ]] +do + OPT= + ARG= + case "$1" in + -d|--diags|--diags-only) RUN_CMOR=false; RUN_AGG=false;; + -c|--cmor|--cmor-only) RUN_DIAGS=false; RUN_AGG=false;; + -A|--agg|--agg-only) RUN_DIAGS=false; RUN_CMOR=false;; + -C|--clim) PROCESS_CLIM=true;; + -s|--suffix) OPT=-s; ARG=SUFFIX;; + -S|--archive-suffix) OPT=-S; ARG=ARCHIVE_SUFFIX;; + -f|--force) REMOVE_CHUNKS=true;; + -a|--append) USE_CHUNKS=true;; + --) shift; break;; + -*) die "invalid option '$1'";; + esac + if [[ -n "$OPT" ]] + then + shift + [[ $# -lt 1 ]] && die "missing argument for option '$OPT'" + eval "$ARG='$1'" + fi + shift +done + +echo "-----------------" +echo $0 $1 $2 $3 $4 +echo "-----------------" + +#Write Output to: +dr_trunk=${EXP_DIR_TRUNK}/archive$ARCHIVE_SUFFIX + + + +############################################################################### +# No user input beyond this line necessary (usually) +############################################################################### + +# Store parameters +par1=$1 +par2=$2 +par3=$3 +par4=$4 +n_arr=${#inioffsetarr[@]} + +#time interval of the experiment to standardize +if [[ ${#iniyeararr[@]} != ${#inioffsetarr[@]} ]] || [[ ${#iniyeararr[@]} != ${#finyeararr[@]} ]] || [[ ${#iniyeararr[@]} != ${#RAW_EXP_IDS[@]} ]]; then + die 'Each sub-simulation needs a specified iniyear, finyear and inioffset!' +else + for y in $(seq 0 $(( n_arr - 1 )) ); do + SDIR+=( ${EXP_DIR_TRUNK}/${RAW_EXP_IDS[$y]} ) + RAWSDIR+=( ${RAW_EXP_DIR_TRUNK} ) + WORK_DIR+=( ${WORK_DIR_TRUNK}/${RAW_EXP_IDS[$y]} ) + done + [[ -z "$2" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + [[ -z "$3" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + [[ -z "$4" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + for y in $(seq 0 $(( n_arr - 1 )) ); do + if [[ $y -lt $par1 ]] || [[ $y -gt $par2 ]]; then + lrel=-1 + urel=-1 + labs=-1 + uabs=-1 + elif [[ $y -eq $1 ]] && [[ $1 -eq $2 ]]; then + lrel=$3 + urel=$4 + labs=$(( $3 + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( $4 + ${inioffsetarr[$y]} - $spinup )) + elif [[ $y -eq $1 ]]; then + lrel=$3 + urel=${finyeararr[$y]} + labs=$(( $3 + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( ${finyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + elif [[ $y -eq $2 ]]; then + lrel=${iniyeararr[$y]} + urel=$4 + labs=$(( ${iniyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( $4 + ${inioffsetarr[$y]} - $spinup )) + else + lrel=${iniyeararr[$y]} + urel=${finyeararr[$y]} + labs=$(( ${iniyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( ${finyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + fi + [[ $urel -lt $lrel ]] && die 'iniyear, finyear arrays not properly set up!' + [[ $uabs -lt $labs ]] && die 'iniyear, finyear arrays not properly set up!' + SUB_SIM_REL_L+=( $lrel ) + SUB_SIM_REL_U+=( $urel ) + SUB_SIM_ABS_L+=( $labs ) + SUB_SIM_ABS_U+=( $uabs ) + [[ $lrel -eq -1 ]] && continue + [[ "$PROCESS_CLIM" == "false" ]] && { [[ ${SUB_SIM_REL_L[$y]} -lt ${iniyeararr[$y]} ]] || [[ ${SUB_SIM_REL_L[$y]} -gt ${finyeararr[$y]} ]] ; } && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ "$PROCESS_CLIM" == "false" ]] && { [[ ${SUB_SIM_REL_U[$y]} -lt ${iniyeararr[$y]} ]] || [[ ${SUB_SIM_REL_U[$y]} -gt ${finyeararr[$y]} ]] ; } && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + done + echo ${SUB_SIM_REL_L[@]} + echo ${SUB_SIM_REL_U[@]} + echo ${SUB_SIM_ABS_L[@]} + echo ${SUB_SIM_ABS_U[@]} + [[ $1 -ge ${#iniyeararr[@]} ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ $2 -ge ${#iniyeararr[@]} ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ $1 -gt $2 ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + cmorstart=$(( $3 + ${inioffsetarr[$1]} - $spinup )) + cmorend=$(( $4 + ${inioffsetarr[$2]} -spinup )) +fi +MESSAGE='PalMod2' +$RUN_AGG && MESSAGE+=' - Aggregation - ' +$RUN_DIAGS && MESSAGE+=' - Diagnostics - ' +$RUN_CMOR && MESSAGE+=" - CMOR rewriting - " +$PROCESS_CLIM && MESSAGE+=' for only climatological variables' +print "$(date +%Y-%m-%dT%H:%M:%S): $MESSAGE started for ${cmorstart}-${cmorend} $SUFFIX" +print " ... translating to ${RAW_EXP_IDS[$1]}@$3 to ${RAW_EXP_IDS[$2]}@$4" + +#exit 0 + + + +############################## +# Load the required functions +# function_Read_request_config: read data request / user configuration and initialize the if_requested check +# function_if_requested: checks if the currently processed variable is requested for the current timestep +# function_find_file: searches for inputfiles +############################## +. $fpath/function_Read_request_config_palmod +. $fpath/function_if_requested +. $fpath/function_find_file + +#Load predefined timeslices (depends on $iniyear/$finyear) +. $cpath/TimeSlices.h + +##Additionally define custom TimeSlices +## Example on how to define TimeSlices +## format: YYYYMMDDHH-YYYYMMDDHH +## +#TimeSlices+=([custom1]=(1850010100-1850010100)) +#TimeSlices+=([custom2]=(1850010100-1850123124)) +##TimeSlice dependend on variable +#TimeSlices+=([custom3]=(${iniyear}010100-${iniyear}123124)) +##TimeSlice dependend on arithmetics using variable +#TimeSlices+=([custom4]=($((iniyear+121))010100-$((iniyear+150))123124)) + +##Define SettingsContainer +## The following Option 3hrtest will activate the listed 3hr variables and deactivate any other variable for the given member (= realisation) +## The UserSettings for the given experiment have to contain the line: +## Option: 3hrtest = True +## or the setting will not be active! +#SettingsContainer+=([3hrtest]=([3hr]=(clt hfls hfss pr prc ps rlds rlus rsds rsus tas tos uas vas))) +#SettingsContainer[3hrtest]+=([${member}]=(${member}:False)) + +#Initialize DataRequest/User Configuration for the if_requested function +# This will read all SettingsContainers, TimeSlices and the configuration file +rrc_option=-s +[[ $DEBUG_LEVEL -ge 1 ]] && rrc_option= +[[ $DEBUG_LEVEL -ge 2 ]] && rrc_option=-v + + + +################################# +# Run agg, diag and cmor-rewrite +################################# + +function run_agg +{ + # Loop over file output periods and load diagnostic script fragment + if $RUN_AGG; then + + for y in $(seq ${par1} ${par2}); do + + # perform time shift for selected variables + cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day" + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + l_chunk=$(echo $chunk | cut -d "-" -f1) + r_chunk=$(echo $chunk | cut -d "-" -f2) + + l_chunk_year=${l_chunk%??????} + r_chunk_year=${r_chunk%??????} + + inv_chunk_year=$(( 1 + ${finyear} - ${l_chunk_year##+(0)} )) + print "Aggregation $chunk ($period): Reading forcing/input of year $inv_chunk_year" + + # Clean up stdout/stderr from previous run of this script + errtemp_agg="${errdir_agg}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_agg} + err="${errtemp_agg}/err${period}" + rm -f ${err}* + + # Read input file - for SSP* runs the jsbach input is time invariant + echo "Reading from ${RAW_EXP_IDS[$y]} jsbach_T31GR30_11tiles_5layers_natural-veg_100k.nc" + input_file_jsbach=$INPUT_DIR_TRUNK/${RAW_EXP_IDS[$y]}/restart/topo/jsbach_T31GR30_11tiles_5layers_natural-veg_100k.nc + + # Perform aggregation for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): Aggregation started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment aggr/${RAW_EXP_IDS[$y]}/$submodel/$period + + # Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $sdir/out_aggr" + echo "... writing log to $errtemp_agg" + + # Create output dirs + mkdir -p ${sdir}/tmp_aggr + mkdir -p ${sdir}/out_aggr + + # Create softlinks to raw model output + echo "... creating links from '$rawsdir' for $period, $submodel" + ln -sf $rawsdir/*_${period}* $sdir/ 2>/dev/null 1>&2 || { echo "ERROR creating links for $period ${RAW_EXP_IDS[$y]} $submodel" && exit 1 ; } + + # Load and run the aggr ScriptFragment + . ${SCRIPT_DIR}/palmod2_aggregation_${esmod}_${submodel}.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): Aggregation ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + done # EXP ID Index y + fi # if RUN_AGG +} + +function run_diag +{ + # Loop over file output periods and load diagnostic script fragment + if $RUN_DIAGS; then + for y in $(seq ${par1} ${par2}); do + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + + # Clean up stdout/stderr from previous run of this script + errtemp_diag="${errdir_diag}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_diag} + err="${errtemp_diag}/err${period}" + rm -f ${err}* + + # Perform diagnostic for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): Diagnostic started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment diag/${RAW_EXP_IDS[$y]}/$submodel/$period + + #Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $sdir/out_diag" + echo "... writing log to $errtemp_diag" + + # Diagnostic Output + mkdir -p ${sdir}/tmp_diag + mkdir -p ${sdir}/out_diag + + # Load and run the diag ScriptFragment + . ${SCRIPT_DIR}/palmod2_diagnostic_${esmod}_${submodel}_auto.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): Diagnostic ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + done # EXP ID Index y + fi # if RUN_DIAG +} + +function run_cmor +{ + # Loop over file output periods and load CMOR-Rewrite script fragment + if $RUN_CMOR; then + + for y in $(seq ${par1} ${par2}); do + + # Use working directory to hold .CHUNK and other tmp files + current_dir=${WORK_DIR[$y]}/cmor${SUFFIX}_${cmorstart}-${cmorend}${CLIMSUFFIX} + if [[ -e $current_dir ]] && [[ "$PROCESS_CLIM" == "false" ]] + then + if $USE_CHUNKS + then + warn "appending to existing chunk" + elif $REMOVE_CHUNKS + then + warn "moving chunk info to backup" + mkdir -p ${WORK_DIR[$y]}/backup + mv -v --backup=numbered $current_dir ${WORK_DIR[$y]}/backup + else + die "please check if cmor is running or has already been run for this chunk. Use --force to re-run" + fi + else + if $USE_CHUNKS + then + die "cannot find chunk info for appending" + fi + fi + mkdir -p $current_dir + previous_dir=$PWD + # Link gridinfo files + ln -sf $SCRIPT_DIR/gridinfo*nc $current_dir/ + cd $current_dir + + # perform time shift + cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day" + + # Define DRS root dir + dr=$dr_trunk/cmor${SUFFIX}_${cmorstart}-${cmorend}${CLIMSUFFIX} + mkdir -p $dr + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + # Define decadal interval + di="$(( ${period} + ${inioffsetarr[$y]} - 9 - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup ))" + dioce="$(( ${period} + ${inioffsetarr[$y]} - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup + 9 ))" + + # Clean up stdout/stderr from previous run of this script + errtemp_cmor="${errdir_cmor}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_cmor} + err="${errtemp_cmor}/err${period}" + rm -f ${err}* + + # Perform CMOR rewrite for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): CMORisation started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment cmor/${RAW_EXP_IDS[$y]}/$submodel/$period + + #Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $dr/$submodel" + echo "... writing log to $errtemp_cmor" + + # Output + mkdir -p $dr/$submodel + + #Location of Mapping table: + mt="${SCRIPT_DIR}/tables/${esmod}_${submodel}_${mip}_mapping.txt" + + #Define cdocmorinfo + it="${it_temp},${ca[${submodel}]}" + + # Load and run the CMOR-Rewrite ScriptFragment + . ${SCRIPT_DIR}/palmod2_cmor-rewrite_${esmod}_${submodel}_auto.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): CMORisation ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + cd $previous_dir + done # EXP ID Index y + + # Run NCO ncatted cleanup of unappropriate/unnecessary attributes + # this is necessary since CMOR sets attributes necessary only for CMIP6 + # that are unnecessary/wrong for PalMod + post_nco + + fi # if RUN_CMOR +} + +function post_nco { + +print "$(date +%Y-%m-%dT%H:%M:%S): NCO cleanup started for $dr" +# Load nco +#module load nco || { echo "Oops: Could not load NCO!" && exit 1 ; } + +# Post Processing with ncatted +#Find netCDF files in DRS directory +flist=( $( find $dr -name "*.nc" -type f | sort ) ) + +#Loop and run ncatted +echo "-> Looping over ${#flist[@]} netCDF files!" +for f in ${flist[@]} +do + echo "... editing $f" + ncatted -O -h -a further_info_url,global,d,, $f && echo "... deleted 'further_info_url'." || echo "... failed (ERROR)" + [[ "$(basename $f)" == *"cen"* ]] && { + ncatted -O -h -a frequency,global,m,c,"cen" $f && echo "... changed frequency to 'cen'." || echo "... failed (ERROR)" + } +done + +print "$(date +%Y-%m-%dT%H:%M:%S): NCO cleanup ended for $dr" + +} + + + +#Initialize DataRequest/User Configuration for the if_requested function +# This will read all SettingsContainers, TimeSlices and the configuration file +# Thereafter run aggregation, diagnostic, cmorization +if $PROCESS_CLIM +then + # Overwrite cmorstart/cmorend: + cmorstart=$iniyear + cmorend=$finyear + + # Read settings for clim1 + CLIMSUFFIX=_clim + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExp${SUFFIX}${CLIMSUFFIX}.conf || die "error while reading request config" + # Run diag&cmor + run_diag + run_cmor + + if [[ "$experiment" != "ssp"* ]] + then + # Reset Read_requested_config + l_linu=0 + unset DreqSettings + unset SliceSettings + unset UserSettings + unset TimeSlicesBounds + unset PriorityOrder + + # Read settings for clim2 + CLIMSUFFIX=_clim2 + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExp${SUFFIX}${CLIMSUFFIX}.conf || die "error while reading request config" + # Run diag&cmor + run_diag + run_cmor + fi +else + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExpTK$SUFFIX.conf || die "error while reading request config" + $RUN_AGG && run_agg || echo "Could not run agg" + $RUN_DIAGS && run_diag || echo "Could not run diag" + $RUN_CMOR && run_cmor || echo "Could not run cmor" + wait +fi + + + +print "$(date +%Y-%m-%dT%H:%M:%S): $MESSAGE finished for $cmorstart-$cmorend$SUFFIX" + +# Update run dates and submit job scripts + +# $Id$ + + diff --git a/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR_cdocmorinfo b/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR_cdocmorinfo new file mode 100644 index 0000000000000000000000000000000000000000..d524e5ac40cd53a3349a9a3e717b2a1c1266fdae --- /dev/null +++ b/cmor/mpiesm/scripts/ssp126-future-methane_r1i1p1f1-CR_cdocmorinfo @@ -0,0 +1,114 @@ +# +# experiment info: +# +_CONTROLLED_VOCABULARY_FILE=PalMod2_CV.json +_FORMULA_VAR_FILE=PalMod2_formula_terms.json +_AXIS_ENTRY_FILE=PalMod2_coordinate.json +CONVENTIONS="CF-1.7 PalMod-2.0" +TITLE="MPI-ESM1-2 output prepared for PalMod2" +_history_template="%s ; CMOR rewrote data to be consistent with <activity_id>, <Conventions> and CF standards." + +EXPERIMENT_ID=ssp126-future-methane +EXPERIMENT="future methane under SSP1-2.6" +#Specify VARIANT_LABEL explicitly or realization_index, physics_index, initialization_index and forcing_index: +VARIANT_LABEL=r1i1p1f1 +REALIZATION_INDEX=1 +INITIALIZATION_INDEX=1 +PHYSICS_INDEX=1 +FORCING_INDEX=1 +VARIANT_INFO="PalMod MPI-ESM1-2-CR setup with full methane cycle. Model physics identical to MPI-ESM1-2-CR simulation transient-deglaciation-prescribed_r1i1p1f1." +ACTIVITY_ID=PalMod2 +#MIP_ERA=PalMod2 #ONLY CMIP6 +PROJECT_ID=PalMod2 +REQUIRED_TIME_UNITS="days since 1-1-1 00:00:00" +#FURTHER_INFO_URL="https://furtherinfo.es-doc.org/<mip_era>.<institution_id>.<source_id>.<experiment_id>.<sub_experiment_id>.<variant_label> +#Branch Info: If needed use the following 2 attributes to define the branch time +# in Parent_Time_Units and Required_Time_Units (=child) +# else use BRANCH_DATES to give the dates in YYYYMMDD,YYYYMMDD format +#BRANCH_TIME_IN_PARENT= +#BRANCH_TIME_IN_CHILD= +BRANCH_DATES=248010101,18500101 +BRANCH_METHOD="standard" +#PARENT_MIP_ERA=none #ONLY CMIP6 +PARENT_ACTIVITY_ID=PalMod2 +PARENT_EXPERIMENT="transient deglaciation with GLAC-1D ice sheets, with methane cycle" +PARENT_EXPERIMENT_ID=transient-deglaciation-prescribed-glac1d-methane +PARENT_SOURCE_ID=MPI-ESM1-2-CR-CH4 +PARENT_TIME_UNITS="days since 1-1-1 00:00:00" +PARENT_VARIANT_LABEL=r1i1p1f1 +SUB_EXPERIMENT_ID=none +SUB_EXPERIMENT=none +# +#model info: +# +SOURCE_ID=MPI-ESM1-2-CR-CH4 +#MODEL_ID=MPI-ESM1-2-CR-CH4 +REFERENCES="Kleinen, T., Mikolajewicz, U. and Brovkin, V. (2020). Terrestrial methane emissions from the Last Glacial Maximum to the preindustrial period. Climate of the Past, 16(2):575–595. doi: 10.5194/cp-16-575-2020\nKleinen, T., Gromov, S., Steil, B. and Brovkin, V. (2021). Atmospheric methane underestimated in future climate projections. Environmental Research Letters, 16(9):094006. doi: 10.1088/1748-9326/ac1814\nKapsch, M.-L., Mikolajewicz, U., Ziemen, F., & Schannwell, C. (2022). Ocean response in transient simulations of the last deglaciation dominated by underlying ice-sheet reconstruction and method of meltwater distribution. Geophysical Research Letters, 49, e2021GL096767. https://doi.org/10.1029/2021GL096767\nMPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPIâ€M Earth System Model version 1.2 (MPIâ€ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400" +#\nMueller, W.A. et al. (2018): A highâ€resolution version of the Max Planck Institute Earth System Model MPIâ€ESM1.2â€HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217" +SOURCE="MPI-ESM1.2-CR (2017): \naerosol: none, prescribed Kinne (2010)\natmos: ECHAM6.3 (spectral T31; 96 x 48 longitude/latitude; 31 levels; top level 10 hPa)\natmosChem: unnamed (accelerated methane chemistry)\nland: JSBACH3.20, River Transport Model\nlandIce: none, prescribed\nocean: MPIOM1.63 (bipolar GR3.0, approximately 300km; 122 x 101 longitude/latitude; 40 levels; top grid cell 0-15 m)\nocnBgchem: none, prescribed\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\nsolidLand: none, prescribed" +SOURCE_TYPE="AOGCM CHEM" +#CALENDAR=proleptic_gregorian +#MAPPING_TABLE_DIR=cmip6_mapping_tables +#MAPPING_TABLE=MPIESM1_CMIP6.txt +#GRID_FILE_DIR=__GRID_FILE_DIR +#GRID_FILE=__GRID_FILE +GRID=gn +GRID_LABEL=gn +#NOMINAL_RESOLUTION read from external file +#For MPIOM/HAMOCC CR / GR30 +#NOMINAL_RESOLUTION="500 km" +#For ECHAM6/JSBACH CR / T31 +#NOMINAL_RESOLUTION="500 km" +# +CHAR_AXIS_VEGTYPE=bare_land,glacier,tropical_evergreen_trees,tropical_deciduous_trees,extra-tropical_evergreen_trees,extra-tropical_deciduous_trees,raingreen_shrubs,deciduous_shrubs,C3_grass,C4_grass,C3_pasture,C4_pasture,C3_crops,C4_crops +CHAR_AXIS_SOILPOOLS=acid-soluble_below_ground_leaf_litter,acid-soluble_below_ground_woody_litter,water-soluble_below_ground_leaf_litter,water-soluble_below_ground_woody_litter,ethanol-soluble_below_ground_leaf_litter,ethanol-soluble_below_ground_woody_litter,non-soluble_below_ground_leaf_litter,non-soluble_below_ground_woody_litter,humus_from_leaf_litter,humus_from_woody_litter +CHAR_AXIS_LANDUSE=primary_and_secondary_land,crops,pastures,urban +CHAR_AXIS_BASIN=global_ocean,atlantic_arctic_ocean,indian_pacific_ocean +CHAR_AXIS_OLINE=barents_opening,bering_strait,canadian_archipelago,denmark_strait,drake_passage,english_channel,pacific_equatorial_undercurrent,faroe_scotland_channel,florida_bahamas_strait,fram_strait,iceland_faroe_channel,indonesian_throughflow,mozambique_channel,taiwan_luzon_straits,windward_passage +CHAR_AXIS_SILINE=barents_opening,bering_strait,canadian_archipelago,fram_strait +#spectband for the 3 aeropt variables +CHAR_AXIS_SPECTBAND_aeroptbnd=1818182 +CHAR_AXIS_SPECTBAND_aeroptbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aeroptbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_aerssabnd=1818182 +CHAR_AXIS_SPECTBAND_aerssabnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aerssabnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_aerasymbnd=1818182 +CHAR_AXIS_SPECTBAND_aerasymbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aerasymbnd_UNITS="m-1" +# 2d-spectband for the albedos +CHAR_AXIS_SPECTBAND_albdirbnd=3225689,766690 +CHAR_AXIS_SPECTBAND_albdirbnd_BOUNDS=5000000,1451379,1451379,82001 +CHAR_AXIS_SPECTBAND_albdirbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_albdiffbnd=3225689,766690 +CHAR_AXIS_SPECTBAND_albdiffbnd_BOUNDS=5000000,1451379,1451379,82001 +CHAR_AXIS_SPECTBAND_albdiffbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_solbnd=1818182 +CHAR_AXIS_SPECTBAND_solbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_solbnd_UNITS="m-1" +# PalMod +CHAR_AXIS_TYPELICE="ice sheet","ice shelf","ocean","ice-free land" +#T_AXIS="cmip" causes the time axis to be rewritten according to the requested time stamps +T_AXIS="cmip" +#OUTPUT_MODE="r" +OUTPUT_MODE="a" +MAX_SIZE=0 +SAVE_CHUNK="n" +#For files without time axis, if one is requested: +#firsttimeval=1 (1850-01-02 00:00:00 wenn days since 1850-01-01 00:00:00) +FIRSTTIMEVAL=1 +# +# institution and contact info: +# +# none of these can be set in the command line +# +DEFLATE_LEVEL=1 +CONTACT=palmod2-mpi-esm@dkrz.de +# +# MPI-M +# +INSTITUTION_ID=MPI-M +INSTITUTION="Max Planck Institute for Meteorology, Hamburg 20146, Germany" +LICENSE="PalMod2 model data produced by MPI-M is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law." +#MIP_TABLE_DIR="/pool/data/CMIP6/cmip6-cmor-tables/Tables/" +MIP_TABLE_DIR="/work/bm0021/PalMod2/cmor_tables/" diff --git a/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.cmor_ctl b/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.cmor_ctl new file mode 100755 index 0000000000000000000000000000000000000000..dae320c0c9ba03030558ee1796445d8f73d8cb8a --- /dev/null +++ b/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.cmor_ctl @@ -0,0 +1,57 @@ +#! /bin/sh -e +#SBATCH --account=bm0021 +#SBATCH --qos=esgf +#SBATCH --time=48:00:00 +#SBATCH --partition=shared +#SBATCH --mail-type=FAIL +#SBATCH --output=%x_%j.log + +# Number of sub-simulations +n_subsim=1 +#initial and final year of the experiment +spinup=0 +iniyeararr=( $(( 5900 + spinup )) ) +finyeararr=( 7099 ) +iniyear=$(( 1850 + spinup )) +finyear=3049 +#offset compared to startyear +inioffsetarr=(-4050) + +# Chunksize +# Note that there are prerequisites concerning the chunksize: +# - the defined decadal timeslizes may not overlap between two chunks! +# - decadal bounds have to be defined accordingly - "???01231" in this case +# - usually this is the case by default due to decadal model output! +chunksize=100 + +# Create list +for i in $(seq 0 $(( n_subsim - 1 )) ) +do + for yyyy in $(seq ${iniyeararr[$i]} ${finyeararr[$i]} ) + do + paramarr+=( "$i $yyyy" ) + done +done + +rm -f cmor_ctl_list_ssp245_r1i1p1f1 +in=0 +for i in $(seq $((iniyear-iniyear)) $chunksize $((finyear-iniyear))) +do + [[ $i -eq $((iniyear-iniyear)) ]] && continue + li=$(echo ${paramarr[$in]} | cut -d " " -f1) + ly=$(echo ${paramarr[$in]} | cut -d " " -f2) + ui=$(echo ${paramarr[$((i-1))]} | cut -d " " -f1) + uy=$(echo ${paramarr[$((i-1))]} | cut -d " " -f2) + in=$i + echo "$li $ui $ly $uy" >> cmor_ctl_list_ssp245_r1i1p1f1 +done +[[ $i -ne $((finyear-iniyear)) ]] && { + li=$(echo ${paramarr[$in]} | cut -d " " -f1) + ly=$(echo ${paramarr[$in]} | cut -d " " -f2) + ui=$(echo ${paramarr[$((finyear-iniyear))]} | cut -d " " -f1) + uy=$(echo ${paramarr[$((finyear-iniyear))]} | cut -d " " -f2) + echo "$li $ui $ly $uy" >> cmor_ctl_list_ssp245_r1i1p1f1 +} + +make -k -j 19 -f ssp245-future-methane_r1i1p1f1-CR.cmor_ctl.mk "$@" + diff --git a/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.cmor_ctl.mk b/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.cmor_ctl.mk new file mode 100755 index 0000000000000000000000000000000000000000..0bbcc739ac0941526d1dbf2debbd62bca341b21d --- /dev/null +++ b/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.cmor_ctl.mk @@ -0,0 +1,44 @@ +EXP_ID = ssp245-future-methane_r1i1p1f1-CR + +ACCOUNT = bm0021 +PARTITION = prepost,compute,compute2 + +SUFFIX = +ARCHIVE_SUFFIX = + +TARGET_STEP=cmor +NUMCHUNKS=$(shell cat cmor_ctl_list_ssp245_r1i1p1f1 | wc -l ) + +AGGR_TIME = 00:10:00 +DIAGS_TIME = 00:30:00 +CMOR_TIME = 02:30:00 + +CMOR_FLAGS = + +SBATCHFLAGS=-W + +MESSAGE = $$(date +%Y-%m-%dT%H:%M:%S): CMIP6 diagnostics and CMOR rewriting ($(SUFFIX:_%=%)) + +.PHONY: all +.PRECIOUS: targets/$(EXP_ID).aggr$(SUFFIX).% targets/$(EXP_ID).diags$(SUFFIX).% targets/$(EXP_ID).cmor$(SUFFIX).% + + + +all: + @echo "$(MESSAGE) started" + mkdir -vp targets + $(MAKE) $(MFLAGS) -f $(MAKEFILE_LIST) $(addprefix targets/$(EXP_ID).$(TARGET_STEP)$(SUFFIX).,$(shell seq 1 $(NUMCHUNKS))) + @echo "$(MESSAGE) finished" + +targets/$(EXP_ID).aggr$(SUFFIX).%: + sbatch $(SBATCHFLAGS) --time=$(AGGR_TIME) --job-name=$(EXP_ID)_runpp_aggr$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -A $(shell sed -n '$(*)'p < cmor_ctl_list_ssp245_r1i1p1f1) + @touch $@ + +targets/$(EXP_ID).diags$(SUFFIX).%: targets/$(EXP_ID).aggr$(SUFFIX).% + sbatch $(SBATCHFLAGS) --time=$(DIAGS_TIME) --job-name=$(EXP_ID)_runpp_diag$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -d $(shell sed -n '$(*)'p < cmor_ctl_list_ssp245_r1i1p1f1) + @touch $@ + +targets/$(EXP_ID).cmor$(SUFFIX).%: targets/$(EXP_ID).diags$(SUFFIX).% + sbatch $(SBATCHFLAGS) --time=$(CMOR_TIME) --job-name=$(EXP_ID)_runpp_cmor$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -c $(CMOR_FLAGS) $(shell sed -n '$(*)'p < cmor_ctl_list_ssp245_r1i1p1f1) + @touch $@ + diff --git a/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.runpp b/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.runpp new file mode 100755 index 0000000000000000000000000000000000000000..cb0c6e73569859467904fca7ee3cd502092dfbe8 --- /dev/null +++ b/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR.runpp @@ -0,0 +1,607 @@ +#!/bin/ksh +# +# PalMod .runpp +# +# Wrapper Script Agg+Diag+CMOR MPI-ESM1-2 by Martin Schupfner, DKRZ +# +### Batch Queuing System is SLURM +#SBATCH --partition=compute +#SBATCH --nodes=1 +#SBATCH --mem=100G +#SBATCH --time=01:30:00 +#SBATCH --mail-type=none +#SBATCH --account=bk1192 +##SBATCH --qos=esgf +#SBATCH --exclusive +#SBATCH --output=ssp245-future-methane_r1i1p1f1-CR.runpp_%j.log + +DEBUG_LEVEL=${DEBUG_LEVEL:-0} + +# Support log style output +export LANG=C +print () { command print "$(date +'%F %T'):" "$@"; } +print_re='^[0-9]+-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}' + +warn () { print 'Hey:' "$@" >&2; } +die () { print 'Oops:' "$@" >&2; return 1; } + +# Bail out on error +trap 'print Error at line $LINENO >&2' ERR +set -eu + +# Disable core file creation +ulimit -c 0 + +# Print command info +[[ $DEBUG_LEVEL -ge 2 ]] && set -x + +#module load nco || { echo "Oops: Could not load NCO!" && exit 1 ; } +alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted + +######################################### +# Define specifics about the simulation +######################################### + +#Root directory of all scripts, outdata, logs etc +EXP_ID=ssp245-future-methane_r1i1p1f1-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_TK/ssp245-future-methane_r1i1p1f1-CR +#EXP_DIR_TRUNK=/work/bk1192/k204212/palmod_TK/ssp245-future-methane_r1i1p1f1-CR + +#initial files for aggregation +INPUT_DIR_TRUNK=/work/bm1030/from_Mistral/bm1030/m300020/mpiesm-palmod_tk_r10186_megan_next/experiments + +# RAW Data - path and sub-simulations +RAW_EXP_DIR_TRUNK=/work/bk1192/from_Mistral/bk1192/WG2/WP2.3/future_scenarios_2021/SSP2-4.5 +# As usually the Experiment is composed of several sub-simulations, define them as array +RAW_EXP_IDS=( pmt0550_20RN_SSP245_r2 ) +# Parent experiment that the first RAW_EXP_ID branched from +# (used for input data of the parent that is required for aggregation) +# !! spinup - the aggregation will fail if the spinup period +# !! is as long or longer than +# !! the length of the first sub simulation! +spinup=0 +RAW_EXP_ID_PARENT=( pmt0531_d ) +# actually, there was a 300y spinup after the branch from pmt0531_d@5600 +# but for simplicity this is ignored here +#if [[ $spinup -ne 0 ]]; then +RAW_EXP_ID_PARENT[0]=${RAW_EXP_IDS[0]} +#fi + +echo ${RAW_EXP_IDS[@]} +echo ${RAW_EXP_ID_PARENT[@]} + +#Work dir +WORK_DIR_TRUNK=$EXP_DIR_TRUNK/work + +#Where to find the scripts (runpp etc.) +SCRIPT_DIR=${EXP_DIR_TRUNK}/scripts +SCRIPT_DIR=/work/bm0021/PalMod2/cmor/mpiesm/scripts + + + +############################ +#Define necessary variables +############################ + +#Where to find cdo (incl. CMOR operator), eg.: +cdo="/work/bm0021/cdo_incl_cmor/cdo-2022-09-20_cmor3.6.0_gcc/bin/cdo -v" # latest version + +# Base directory for DataRequest related headers/scripts +SCRIPT_ROOT=${SCRIPT_DIR} + +#Where to find the functions +fpath=/work/bm0021/PalMod2/cmor/functions + +#Where to find the configuration +cpath=${SCRIPT_ROOT}/conf + +#Models +atmmod=echam6 +ocemod=mpiom +srfmod=jsbach +esmod=MPI-ESM1-2 + +#Chunks +chunks+=([echam6]=" 0 1 2 3 4 5 6 7 8 9 ") +chunks+=([jsbach]=" 0 1 2 3 4 5 6 7 8 9 ") +chunks+=([mpiom]=" 0 ") +chunks+=([jsbachdec]=" 0 ") +atmmod_dec_chunk="???9123124" +srfmod_dec_chunk="???9123124" +srfmod_input_dec_chunk="???0123124" +ocemod_dec_chunk="???0123124" +icemod_dec_chunk="???0123124" +ocemod_fxyear=5900 + +#InfoTable(s) +# Define here the "cdocmorinfo"-File or "eum"-Files +# Multiple files possible with "," as delimiter, eg: +# it=expinfo.txt,userinfo.txt,modelinfo.txt +it_temp="${SCRIPT_ROOT}/ssp245-future-methane_r1i1p1f1-CR_cdocmorinfo" +ca+=([mpiom]="${SCRIPT_ROOT}/cdocmorinfo_mpiom_CR") +ca+=([echam6]="${SCRIPT_ROOT}/cdocmorinfo_echam6_CR") +ca+=([jsbach]="${SCRIPT_ROOT}/cdocmorinfo_jsbach_CR") + +#Experiment etc +experiment=ssp245-future-methane +member=r1i1p1f1 +mip=PalMod2 +vd=v20230105 +#vd=v$(date '+%Y%m%d') #CMOR version directory name, should be a date in format YYYYMMDD + +#Where to store errors +errdir=${EXP_DIR_TRUNK}/logs/errors +errdir_cmor=${errdir}_cmor +errdir_diag=${errdir}_diag +errdir_agg=${errdir}_agg + +#initial and final year of the experiment +iniyeararr=($((5900+spinup))) # 1850-3049, after the 300y spinup +finyeararr=(7099) +iniyear=1850 +finyear=3049 +#offset compared to startyear +inioffsetarr=(-4050) # 1850-3049 +# - 5900-7099 - 1200 yrs - 1850-3049 - -4050 + +# Command line options +RUN_AGG=true +RUN_DIAGS=true +RUN_CMOR=true +SUFFIX= +CLIMSUFFIX= +ARCHIVE_SUFFIX= +USE_CHUNKS=false +REMOVE_CHUNKS=false +PROCESS_CLIM=false +while [[ "$1" == -* ]] +do + OPT= + ARG= + case "$1" in + -d|--diags|--diags-only) RUN_CMOR=false; RUN_AGG=false;; + -c|--cmor|--cmor-only) RUN_DIAGS=false; RUN_AGG=false;; + -A|--agg|--agg-only) RUN_DIAGS=false; RUN_CMOR=false;; + -C|--clim) PROCESS_CLIM=true;; + -s|--suffix) OPT=-s; ARG=SUFFIX;; + -S|--archive-suffix) OPT=-S; ARG=ARCHIVE_SUFFIX;; + -f|--force) REMOVE_CHUNKS=true;; + -a|--append) USE_CHUNKS=true;; + --) shift; break;; + -*) die "invalid option '$1'";; + esac + if [[ -n "$OPT" ]] + then + shift + [[ $# -lt 1 ]] && die "missing argument for option '$OPT'" + eval "$ARG='$1'" + fi + shift +done + +echo "-----------------" +echo $0 $1 $2 $3 $4 +echo "-----------------" + +#Write Output to: +dr_trunk=${EXP_DIR_TRUNK}/archive$ARCHIVE_SUFFIX + + + +############################################################################### +# No user input beyond this line necessary (usually) +############################################################################### + +# Store parameters +par1=$1 +par2=$2 +par3=$3 +par4=$4 +n_arr=${#inioffsetarr[@]} + +#time interval of the experiment to standardize +if [[ ${#iniyeararr[@]} != ${#inioffsetarr[@]} ]] || [[ ${#iniyeararr[@]} != ${#finyeararr[@]} ]] || [[ ${#iniyeararr[@]} != ${#RAW_EXP_IDS[@]} ]]; then + die 'Each sub-simulation needs a specified iniyear, finyear and inioffset!' +else + for y in $(seq 0 $(( n_arr - 1 )) ); do + SDIR+=( ${EXP_DIR_TRUNK}/${RAW_EXP_IDS[$y]} ) + RAWSDIR+=( ${RAW_EXP_DIR_TRUNK} ) + WORK_DIR+=( ${WORK_DIR_TRUNK}/${RAW_EXP_IDS[$y]} ) + done + [[ -z "$2" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + [[ -z "$3" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + [[ -z "$4" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + for y in $(seq 0 $(( n_arr - 1 )) ); do + if [[ $y -lt $par1 ]] || [[ $y -gt $par2 ]]; then + lrel=-1 + urel=-1 + labs=-1 + uabs=-1 + elif [[ $y -eq $1 ]] && [[ $1 -eq $2 ]]; then + lrel=$3 + urel=$4 + labs=$(( $3 + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( $4 + ${inioffsetarr[$y]} - $spinup )) + elif [[ $y -eq $1 ]]; then + lrel=$3 + urel=${finyeararr[$y]} + labs=$(( $3 + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( ${finyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + elif [[ $y -eq $2 ]]; then + lrel=${iniyeararr[$y]} + urel=$4 + labs=$(( ${iniyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( $4 + ${inioffsetarr[$y]} - $spinup )) + else + lrel=${iniyeararr[$y]} + urel=${finyeararr[$y]} + labs=$(( ${iniyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( ${finyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + fi + [[ $urel -lt $lrel ]] && die 'iniyear, finyear arrays not properly set up!' + [[ $uabs -lt $labs ]] && die 'iniyear, finyear arrays not properly set up!' + SUB_SIM_REL_L+=( $lrel ) + SUB_SIM_REL_U+=( $urel ) + SUB_SIM_ABS_L+=( $labs ) + SUB_SIM_ABS_U+=( $uabs ) + [[ $lrel -eq -1 ]] && continue + [[ "$PROCESS_CLIM" == "false" ]] && { [[ ${SUB_SIM_REL_L[$y]} -lt ${iniyeararr[$y]} ]] || [[ ${SUB_SIM_REL_L[$y]} -gt ${finyeararr[$y]} ]] ; } && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ "$PROCESS_CLIM" == "false" ]] && { [[ ${SUB_SIM_REL_U[$y]} -lt ${iniyeararr[$y]} ]] || [[ ${SUB_SIM_REL_U[$y]} -gt ${finyeararr[$y]} ]] ; } && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + done + echo ${SUB_SIM_REL_L[@]} + echo ${SUB_SIM_REL_U[@]} + echo ${SUB_SIM_ABS_L[@]} + echo ${SUB_SIM_ABS_U[@]} + [[ $1 -ge ${#iniyeararr[@]} ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ $2 -ge ${#iniyeararr[@]} ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ $1 -gt $2 ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + cmorstart=$(( $3 + ${inioffsetarr[$1]} - $spinup )) + cmorend=$(( $4 + ${inioffsetarr[$2]} -spinup )) +fi +MESSAGE='PalMod2' +$RUN_AGG && MESSAGE+=' - Aggregation - ' +$RUN_DIAGS && MESSAGE+=' - Diagnostics - ' +$RUN_CMOR && MESSAGE+=" - CMOR rewriting - " +$PROCESS_CLIM && MESSAGE+=' for only climatological variables' +print "$(date +%Y-%m-%dT%H:%M:%S): $MESSAGE started for ${cmorstart}-${cmorend} $SUFFIX" +print " ... translating to ${RAW_EXP_IDS[$1]}@$3 to ${RAW_EXP_IDS[$2]}@$4" + +#exit 0 + + + +############################## +# Load the required functions +# function_Read_request_config: read data request / user configuration and initialize the if_requested check +# function_if_requested: checks if the currently processed variable is requested for the current timestep +# function_find_file: searches for inputfiles +############################## +. $fpath/function_Read_request_config_palmod +. $fpath/function_if_requested +. $fpath/function_find_file + +#Load predefined timeslices (depends on $iniyear/$finyear) +. $cpath/TimeSlices.h + +##Additionally define custom TimeSlices +## Example on how to define TimeSlices +## format: YYYYMMDDHH-YYYYMMDDHH +## +#TimeSlices+=([custom1]=(1850010100-1850010100)) +#TimeSlices+=([custom2]=(1850010100-1850123124)) +##TimeSlice dependend on variable +#TimeSlices+=([custom3]=(${iniyear}010100-${iniyear}123124)) +##TimeSlice dependend on arithmetics using variable +#TimeSlices+=([custom4]=($((iniyear+121))010100-$((iniyear+150))123124)) + +##Define SettingsContainer +## The following Option 3hrtest will activate the listed 3hr variables and deactivate any other variable for the given member (= realisation) +## The UserSettings for the given experiment have to contain the line: +## Option: 3hrtest = True +## or the setting will not be active! +#SettingsContainer+=([3hrtest]=([3hr]=(clt hfls hfss pr prc ps rlds rlus rsds rsus tas tos uas vas))) +#SettingsContainer[3hrtest]+=([${member}]=(${member}:False)) + +#Initialize DataRequest/User Configuration for the if_requested function +# This will read all SettingsContainers, TimeSlices and the configuration file +rrc_option=-s +[[ $DEBUG_LEVEL -ge 1 ]] && rrc_option= +[[ $DEBUG_LEVEL -ge 2 ]] && rrc_option=-v + + + +################################# +# Run agg, diag and cmor-rewrite +################################# + +function run_agg +{ + # Loop over file output periods and load diagnostic script fragment + if $RUN_AGG; then + + for y in $(seq ${par1} ${par2}); do + + # perform time shift for selected variables + cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day" + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + l_chunk=$(echo $chunk | cut -d "-" -f1) + r_chunk=$(echo $chunk | cut -d "-" -f2) + + l_chunk_year=${l_chunk%??????} + r_chunk_year=${r_chunk%??????} + + inv_chunk_year=$(( 1 + ${finyear} - ${l_chunk_year##+(0)} )) + print "Aggregation $chunk ($period): Reading forcing/input of year $inv_chunk_year" + + # Clean up stdout/stderr from previous run of this script + errtemp_agg="${errdir_agg}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_agg} + err="${errtemp_agg}/err${period}" + rm -f ${err}* + + # Read input file - for SSP* runs the jsbach input is time invariant + echo "Reading from ${RAW_EXP_IDS[$y]} jsbach_T31GR30_11tiles_5layers_natural-veg_100k.nc" + input_file_jsbach=$INPUT_DIR_TRUNK/${RAW_EXP_IDS[$y]}/restart/topo/jsbach_T31GR30_11tiles_5layers_natural-veg_100k.nc + + # Perform aggregation for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): Aggregation started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment aggr/${RAW_EXP_IDS[$y]}/$submodel/$period + + # Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $sdir/out_aggr" + echo "... writing log to $errtemp_agg" + + # Create output dirs + mkdir -p ${sdir}/tmp_aggr + mkdir -p ${sdir}/out_aggr + + # Create softlinks to raw model output + echo "... creating links from '$rawsdir' for $period, $submodel" + ln -sf $rawsdir/*_${period}* $sdir/ 2>/dev/null 1>&2 || { echo "ERROR creating links for $period ${RAW_EXP_IDS[$y]} $submodel" && exit 1 ; } + + # Load and run the aggr ScriptFragment + . ${SCRIPT_DIR}/palmod2_aggregation_${esmod}_${submodel}.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): Aggregation ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + done # EXP ID Index y + fi # if RUN_AGG +} + +function run_diag +{ + # Loop over file output periods and load diagnostic script fragment + if $RUN_DIAGS; then + for y in $(seq ${par1} ${par2}); do + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + + # Clean up stdout/stderr from previous run of this script + errtemp_diag="${errdir_diag}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_diag} + err="${errtemp_diag}/err${period}" + rm -f ${err}* + + # Perform diagnostic for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): Diagnostic started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment diag/${RAW_EXP_IDS[$y]}/$submodel/$period + + #Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $sdir/out_diag" + echo "... writing log to $errtemp_diag" + + # Diagnostic Output + mkdir -p ${sdir}/tmp_diag + mkdir -p ${sdir}/out_diag + + # Load and run the diag ScriptFragment + . ${SCRIPT_DIR}/palmod2_diagnostic_${esmod}_${submodel}_auto.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): Diagnostic ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + done # EXP ID Index y + fi # if RUN_DIAG +} + +function run_cmor +{ + # Loop over file output periods and load CMOR-Rewrite script fragment + if $RUN_CMOR; then + + for y in $(seq ${par1} ${par2}); do + + # Use working directory to hold .CHUNK and other tmp files + current_dir=${WORK_DIR[$y]}/cmor${SUFFIX}_${cmorstart}-${cmorend}${CLIMSUFFIX} + if [[ -e $current_dir ]] && [[ "$PROCESS_CLIM" == "false" ]] + then + if $USE_CHUNKS + then + warn "appending to existing chunk" + elif $REMOVE_CHUNKS + then + warn "moving chunk info to backup" + mkdir -p ${WORK_DIR[$y]}/backup + mv -v --backup=numbered $current_dir ${WORK_DIR[$y]}/backup + else + die "please check if cmor is running or has already been run for this chunk. Use --force to re-run" + fi + else + if $USE_CHUNKS + then + die "cannot find chunk info for appending" + fi + fi + mkdir -p $current_dir + previous_dir=$PWD + # Link gridinfo files + ln -sf $SCRIPT_DIR/gridinfo*nc $current_dir/ + cd $current_dir + + # perform time shift + cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day" + + # Define DRS root dir + dr=$dr_trunk/cmor${SUFFIX}_${cmorstart}-${cmorend}${CLIMSUFFIX} + mkdir -p $dr + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + # Define decadal interval + di="$(( ${period} + ${inioffsetarr[$y]} - 9 - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup ))" + dioce="$(( ${period} + ${inioffsetarr[$y]} - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup + 9 ))" + + # Clean up stdout/stderr from previous run of this script + errtemp_cmor="${errdir_cmor}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_cmor} + err="${errtemp_cmor}/err${period}" + rm -f ${err}* + + # Perform CMOR rewrite for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): CMORisation started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment cmor/${RAW_EXP_IDS[$y]}/$submodel/$period + + #Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $dr/$submodel" + echo "... writing log to $errtemp_cmor" + + # Output + mkdir -p $dr/$submodel + + #Location of Mapping table: + mt="${SCRIPT_DIR}/tables/${esmod}_${submodel}_${mip}_mapping.txt" + + #Define cdocmorinfo + it="${it_temp},${ca[${submodel}]}" + + # Load and run the CMOR-Rewrite ScriptFragment + . ${SCRIPT_DIR}/palmod2_cmor-rewrite_${esmod}_${submodel}_auto.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): CMORisation ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + cd $previous_dir + done # EXP ID Index y + + # Run NCO ncatted cleanup of unappropriate/unnecessary attributes + # this is necessary since CMOR sets attributes necessary only for CMIP6 + # that are unnecessary/wrong for PalMod + post_nco + + fi # if RUN_CMOR +} + +function post_nco { + +print "$(date +%Y-%m-%dT%H:%M:%S): NCO cleanup started for $dr" +# Load nco +#module load nco || { echo "Oops: Could not load NCO!" && exit 1 ; } + +# Post Processing with ncatted +#Find netCDF files in DRS directory +flist=( $( find $dr -name "*.nc" -type f | sort ) ) + +#Loop and run ncatted +echo "-> Looping over ${#flist[@]} netCDF files!" +for f in ${flist[@]} +do + echo "... editing $f" + ncatted -O -h -a further_info_url,global,d,, $f && echo "... deleted 'further_info_url'." || echo "... failed (ERROR)" + [[ "$(basename $f)" == *"cen"* ]] && { + ncatted -O -h -a frequency,global,m,c,"cen" $f && echo "... changed frequency to 'cen'." || echo "... failed (ERROR)" + } +done + +print "$(date +%Y-%m-%dT%H:%M:%S): NCO cleanup ended for $dr" + +} + + + +#Initialize DataRequest/User Configuration for the if_requested function +# This will read all SettingsContainers, TimeSlices and the configuration file +# Thereafter run aggregation, diagnostic, cmorization +if $PROCESS_CLIM +then + # Overwrite cmorstart/cmorend: + cmorstart=$iniyear + cmorend=$finyear + + # Read settings for clim1 + CLIMSUFFIX=_clim + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExp${SUFFIX}${CLIMSUFFIX}.conf || die "error while reading request config" + # Run diag&cmor + run_diag + run_cmor + + if [[ "$experiment" != "ssp"* ]] + then + # Reset Read_requested_config + l_linu=0 + unset DreqSettings + unset SliceSettings + unset UserSettings + unset TimeSlicesBounds + unset PriorityOrder + + # Read settings for clim2 + CLIMSUFFIX=_clim2 + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExp${SUFFIX}${CLIMSUFFIX}.conf || die "error while reading request config" + # Run diag&cmor + run_diag + run_cmor + fi +else + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExpTK$SUFFIX.conf || die "error while reading request config" + $RUN_AGG && run_agg || echo "Could not run agg" + $RUN_DIAGS && run_diag || echo "Could not run diag" + $RUN_CMOR && run_cmor || echo "Could not run cmor" + wait +fi + + + +print "$(date +%Y-%m-%dT%H:%M:%S): $MESSAGE finished for $cmorstart-$cmorend$SUFFIX" + +# Update run dates and submit job scripts + +# $Id$ + + diff --git a/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR_cdocmorinfo b/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR_cdocmorinfo new file mode 100644 index 0000000000000000000000000000000000000000..b01627f9e22414e587a3d59c8b9e877e85882135 --- /dev/null +++ b/cmor/mpiesm/scripts/ssp245-future-methane_r1i1p1f1-CR_cdocmorinfo @@ -0,0 +1,114 @@ +# +# experiment info: +# +_CONTROLLED_VOCABULARY_FILE=PalMod2_CV.json +_FORMULA_VAR_FILE=PalMod2_formula_terms.json +_AXIS_ENTRY_FILE=PalMod2_coordinate.json +CONVENTIONS="CF-1.7 PalMod-2.0" +TITLE="MPI-ESM1-2 output prepared for PalMod2" +_history_template="%s ; CMOR rewrote data to be consistent with <activity_id>, <Conventions> and CF standards." + +EXPERIMENT_ID=ssp245-future-methane +EXPERIMENT="future methane under SSP2-4.5" +#Specify VARIANT_LABEL explicitly or realization_index, physics_index, initialization_index and forcing_index: +VARIANT_LABEL=r1i1p1f1 +REALIZATION_INDEX=1 +INITIALIZATION_INDEX=1 +PHYSICS_INDEX=1 +FORCING_INDEX=1 +VARIANT_INFO="PalMod MPI-ESM1-2-CR setup with full methane cycle. Model physics identical to MPI-ESM1-2-CR simulation transient-deglaciation-prescribed_r1i1p1f1." +ACTIVITY_ID=PalMod2 +#MIP_ERA=PalMod2 #ONLY CMIP6 +PROJECT_ID=PalMod2 +REQUIRED_TIME_UNITS="days since 1-1-1 00:00:00" +#FURTHER_INFO_URL="https://furtherinfo.es-doc.org/<mip_era>.<institution_id>.<source_id>.<experiment_id>.<sub_experiment_id>.<variant_label> +#Branch Info: If needed use the following 2 attributes to define the branch time +# in Parent_Time_Units and Required_Time_Units (=child) +# else use BRANCH_DATES to give the dates in YYYYMMDD,YYYYMMDD format +#BRANCH_TIME_IN_PARENT= +#BRANCH_TIME_IN_CHILD= +BRANCH_DATES=248010101,18500101 +BRANCH_METHOD="standard" +#PARENT_MIP_ERA=none #ONLY CMIP6 +PARENT_ACTIVITY_ID=PalMod2 +PARENT_EXPERIMENT="transient deglaciation with GLAC-1D ice sheets, with methane cycle" +PARENT_EXPERIMENT_ID=transient-deglaciation-prescribed-glac1d-methane +PARENT_SOURCE_ID=MPI-ESM1-2-CR-CH4 +PARENT_TIME_UNITS="days since 1-1-1 00:00:00" +PARENT_VARIANT_LABEL=r1i1p1f1 +SUB_EXPERIMENT_ID=none +SUB_EXPERIMENT=none +# +#model info: +# +SOURCE_ID=MPI-ESM1-2-CR-CH4 +#MODEL_ID=MPI-ESM1-2-CR-CH4 +REFERENCES="Kleinen, T., Mikolajewicz, U. and Brovkin, V. (2020). Terrestrial methane emissions from the Last Glacial Maximum to the preindustrial period. Climate of the Past, 16(2):575–595. doi: 10.5194/cp-16-575-2020\nKleinen, T., Gromov, S., Steil, B. and Brovkin, V. (2021). Atmospheric methane underestimated in future climate projections. Environmental Research Letters, 16(9):094006. doi: 10.1088/1748-9326/ac1814\nKapsch, M.-L., Mikolajewicz, U., Ziemen, F., & Schannwell, C. (2022). Ocean response in transient simulations of the last deglaciation dominated by underlying ice-sheet reconstruction and method of meltwater distribution. Geophysical Research Letters, 49, e2021GL096767. https://doi.org/10.1029/2021GL096767\nMPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPIâ€M Earth System Model version 1.2 (MPIâ€ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400" +#\nMueller, W.A. et al. (2018): A highâ€resolution version of the Max Planck Institute Earth System Model MPIâ€ESM1.2â€HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217" +SOURCE="MPI-ESM1.2-CR (2017): \naerosol: none, prescribed Kinne (2010)\natmos: ECHAM6.3 (spectral T31; 96 x 48 longitude/latitude; 31 levels; top level 10 hPa)\natmosChem: unnamed (accelerated methane chemistry)\nland: JSBACH3.20, River Transport Model\nlandIce: none, prescribed\nocean: MPIOM1.63 (bipolar GR3.0, approximately 300km; 122 x 101 longitude/latitude; 40 levels; top grid cell 0-15 m)\nocnBgchem: none, prescribed\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\nsolidLand: none, prescribed" +SOURCE_TYPE="AOGCM CHEM" +#CALENDAR=proleptic_gregorian +#MAPPING_TABLE_DIR=cmip6_mapping_tables +#MAPPING_TABLE=MPIESM1_CMIP6.txt +#GRID_FILE_DIR=__GRID_FILE_DIR +#GRID_FILE=__GRID_FILE +GRID=gn +GRID_LABEL=gn +#NOMINAL_RESOLUTION read from external file +#For MPIOM/HAMOCC CR / GR30 +#NOMINAL_RESOLUTION="500 km" +#For ECHAM6/JSBACH CR / T31 +#NOMINAL_RESOLUTION="500 km" +# +CHAR_AXIS_VEGTYPE=bare_land,glacier,tropical_evergreen_trees,tropical_deciduous_trees,extra-tropical_evergreen_trees,extra-tropical_deciduous_trees,raingreen_shrubs,deciduous_shrubs,C3_grass,C4_grass,C3_pasture,C4_pasture,C3_crops,C4_crops +CHAR_AXIS_SOILPOOLS=acid-soluble_below_ground_leaf_litter,acid-soluble_below_ground_woody_litter,water-soluble_below_ground_leaf_litter,water-soluble_below_ground_woody_litter,ethanol-soluble_below_ground_leaf_litter,ethanol-soluble_below_ground_woody_litter,non-soluble_below_ground_leaf_litter,non-soluble_below_ground_woody_litter,humus_from_leaf_litter,humus_from_woody_litter +CHAR_AXIS_LANDUSE=primary_and_secondary_land,crops,pastures,urban +CHAR_AXIS_BASIN=global_ocean,atlantic_arctic_ocean,indian_pacific_ocean +CHAR_AXIS_OLINE=barents_opening,bering_strait,canadian_archipelago,denmark_strait,drake_passage,english_channel,pacific_equatorial_undercurrent,faroe_scotland_channel,florida_bahamas_strait,fram_strait,iceland_faroe_channel,indonesian_throughflow,mozambique_channel,taiwan_luzon_straits,windward_passage +CHAR_AXIS_SILINE=barents_opening,bering_strait,canadian_archipelago,fram_strait +#spectband for the 3 aeropt variables +CHAR_AXIS_SPECTBAND_aeroptbnd=1818182 +CHAR_AXIS_SPECTBAND_aeroptbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aeroptbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_aerssabnd=1818182 +CHAR_AXIS_SPECTBAND_aerssabnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aerssabnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_aerasymbnd=1818182 +CHAR_AXIS_SPECTBAND_aerasymbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aerasymbnd_UNITS="m-1" +# 2d-spectband for the albedos +CHAR_AXIS_SPECTBAND_albdirbnd=3225689,766690 +CHAR_AXIS_SPECTBAND_albdirbnd_BOUNDS=5000000,1451379,1451379,82001 +CHAR_AXIS_SPECTBAND_albdirbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_albdiffbnd=3225689,766690 +CHAR_AXIS_SPECTBAND_albdiffbnd_BOUNDS=5000000,1451379,1451379,82001 +CHAR_AXIS_SPECTBAND_albdiffbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_solbnd=1818182 +CHAR_AXIS_SPECTBAND_solbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_solbnd_UNITS="m-1" +# PalMod +CHAR_AXIS_TYPELICE="ice sheet","ice shelf","ocean","ice-free land" +#T_AXIS="cmip" causes the time axis to be rewritten according to the requested time stamps +T_AXIS="cmip" +#OUTPUT_MODE="r" +OUTPUT_MODE="a" +MAX_SIZE=0 +SAVE_CHUNK="n" +#For files without time axis, if one is requested: +#firsttimeval=1 (1850-01-02 00:00:00 wenn days since 1850-01-01 00:00:00) +FIRSTTIMEVAL=1 +# +# institution and contact info: +# +# none of these can be set in the command line +# +DEFLATE_LEVEL=1 +CONTACT=palmod2-mpi-esm@dkrz.de +# +# MPI-M +# +INSTITUTION_ID=MPI-M +INSTITUTION="Max Planck Institute for Meteorology, Hamburg 20146, Germany" +LICENSE="PalMod2 model data produced by MPI-M is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law." +#MIP_TABLE_DIR="/pool/data/CMIP6/cmip6-cmor-tables/Tables/" +MIP_TABLE_DIR="/work/bm0021/PalMod2/cmor_tables/" diff --git a/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.cmor_ctl b/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.cmor_ctl new file mode 100755 index 0000000000000000000000000000000000000000..7d15174c727586ff6fe2e68c8134a8fb8dfdb0b2 --- /dev/null +++ b/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.cmor_ctl @@ -0,0 +1,57 @@ +#! /bin/sh -e +#SBATCH --account=bm0021 +#SBATCH --qos=esgf +#SBATCH --time=48:00:00 +#SBATCH --partition=shared +#SBATCH --mail-type=FAIL +#SBATCH --output=%x_%j.log + +# Number of sub-simulations +n_subsim=1 +#initial and final year of the experiment +spinup=0 +iniyeararr=( $(( 5900 + spinup )) ) +finyeararr=( 7099 ) +iniyear=$(( 1850 + spinup )) +finyear=3049 +#offset compared to startyear +inioffsetarr=(-4050) + +# Chunksize +# Note that there are prerequisites concerning the chunksize: +# - the defined decadal timeslizes may not overlap between two chunks! +# - decadal bounds have to be defined accordingly - "???01231" in this case +# - usually this is the case by default due to decadal model output! +chunksize=100 + +# Create list +for i in $(seq 0 $(( n_subsim - 1 )) ) +do + for yyyy in $(seq ${iniyeararr[$i]} ${finyeararr[$i]} ) + do + paramarr+=( "$i $yyyy" ) + done +done + +rm -f cmor_ctl_list_ssp370_r1i1p1f1 +in=0 +for i in $(seq $((iniyear-iniyear)) $chunksize $((finyear-iniyear))) +do + [[ $i -eq $((iniyear-iniyear)) ]] && continue + li=$(echo ${paramarr[$in]} | cut -d " " -f1) + ly=$(echo ${paramarr[$in]} | cut -d " " -f2) + ui=$(echo ${paramarr[$((i-1))]} | cut -d " " -f1) + uy=$(echo ${paramarr[$((i-1))]} | cut -d " " -f2) + in=$i + echo "$li $ui $ly $uy" >> cmor_ctl_list_ssp370_r1i1p1f1 +done +[[ $i -ne $((finyear-iniyear)) ]] && { + li=$(echo ${paramarr[$in]} | cut -d " " -f1) + ly=$(echo ${paramarr[$in]} | cut -d " " -f2) + ui=$(echo ${paramarr[$((finyear-iniyear))]} | cut -d " " -f1) + uy=$(echo ${paramarr[$((finyear-iniyear))]} | cut -d " " -f2) + echo "$li $ui $ly $uy" >> cmor_ctl_list_ssp370_r1i1p1f1 +} + +make -k -j 19 -f ssp370-future-methane_r1i1p1f1-CR.cmor_ctl.mk "$@" + diff --git a/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.cmor_ctl.mk b/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.cmor_ctl.mk new file mode 100755 index 0000000000000000000000000000000000000000..e3216b79f726f8e5bd992507bd12fafaa7bf93ee --- /dev/null +++ b/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.cmor_ctl.mk @@ -0,0 +1,44 @@ +EXP_ID = ssp370-future-methane_r1i1p1f1-CR + +ACCOUNT = bm0021 +PARTITION = prepost,compute,compute2 + +SUFFIX = +ARCHIVE_SUFFIX = + +TARGET_STEP=cmor +NUMCHUNKS=$(shell cat cmor_ctl_list_ssp370_r1i1p1f1 | wc -l ) + +AGGR_TIME = 00:10:00 +DIAGS_TIME = 00:30:00 +CMOR_TIME = 02:30:00 + +CMOR_FLAGS = + +SBATCHFLAGS=-W + +MESSAGE = $$(date +%Y-%m-%dT%H:%M:%S): CMIP6 diagnostics and CMOR rewriting ($(SUFFIX:_%=%)) + +.PHONY: all +.PRECIOUS: targets/$(EXP_ID).aggr$(SUFFIX).% targets/$(EXP_ID).diags$(SUFFIX).% targets/$(EXP_ID).cmor$(SUFFIX).% + + + +all: + @echo "$(MESSAGE) started" + mkdir -vp targets + $(MAKE) $(MFLAGS) -f $(MAKEFILE_LIST) $(addprefix targets/$(EXP_ID).$(TARGET_STEP)$(SUFFIX).,$(shell seq 1 $(NUMCHUNKS))) + @echo "$(MESSAGE) finished" + +targets/$(EXP_ID).aggr$(SUFFIX).%: + sbatch $(SBATCHFLAGS) --time=$(AGGR_TIME) --job-name=$(EXP_ID)_runpp_aggr$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -A $(shell sed -n '$(*)'p < cmor_ctl_list_ssp370_r1i1p1f1) + @touch $@ + +targets/$(EXP_ID).diags$(SUFFIX).%: targets/$(EXP_ID).aggr$(SUFFIX).% + sbatch $(SBATCHFLAGS) --time=$(DIAGS_TIME) --job-name=$(EXP_ID)_runpp_diag$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -d $(shell sed -n '$(*)'p < cmor_ctl_list_ssp370_r1i1p1f1) + @touch $@ + +targets/$(EXP_ID).cmor$(SUFFIX).%: targets/$(EXP_ID).diags$(SUFFIX).% + sbatch $(SBATCHFLAGS) --time=$(CMOR_TIME) --job-name=$(EXP_ID)_runpp_cmor$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -c $(CMOR_FLAGS) $(shell sed -n '$(*)'p < cmor_ctl_list_ssp370_r1i1p1f1) + @touch $@ + diff --git a/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.runpp b/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.runpp new file mode 100755 index 0000000000000000000000000000000000000000..767c9b4028bc4c65bdc70f9683a318c0c94358b8 --- /dev/null +++ b/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR.runpp @@ -0,0 +1,607 @@ +#!/bin/ksh +# +# PalMod .runpp +# +# Wrapper Script Agg+Diag+CMOR MPI-ESM1-2 by Martin Schupfner, DKRZ +# +### Batch Queuing System is SLURM +#SBATCH --partition=compute +#SBATCH --nodes=1 +#SBATCH --mem=100G +#SBATCH --time=01:30:00 +#SBATCH --mail-type=none +#SBATCH --account=bk1192 +##SBATCH --qos=esgf +#SBATCH --exclusive +#SBATCH --output=ssp370-future-methane_r1i1p1f1-CR.runpp_%j.log + +DEBUG_LEVEL=${DEBUG_LEVEL:-0} + +# Support log style output +export LANG=C +print () { command print "$(date +'%F %T'):" "$@"; } +print_re='^[0-9]+-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}' + +warn () { print 'Hey:' "$@" >&2; } +die () { print 'Oops:' "$@" >&2; return 1; } + +# Bail out on error +trap 'print Error at line $LINENO >&2' ERR +set -eu + +# Disable core file creation +ulimit -c 0 + +# Print command info +[[ $DEBUG_LEVEL -ge 2 ]] && set -x + +#module load nco || { echo "Oops: Could not load NCO!" && exit 1 ; } +alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted + +######################################### +# Define specifics about the simulation +######################################### + +#Root directory of all scripts, outdata, logs etc +EXP_ID=ssp370-future-methane_r1i1p1f1-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_TK/ssp370-future-methane_r1i1p1f1-CR +#EXP_DIR_TRUNK=/work/bk1192/k204212/palmod_TK/ssp370-future-methane_r1i1p1f1-CR + +#initial files for aggregation +INPUT_DIR_TRUNK=/work/bm1030/from_Mistral/bm1030/m300020/mpiesm-palmod_tk_r10186_megan_next/experiments + +# RAW Data - path and sub-simulations +RAW_EXP_DIR_TRUNK=/work/bk1192/from_Mistral/bk1192/WG2/WP2.3/future_scenarios_2021/SSP3-7.0 +# As usually the Experiment is composed of several sub-simulations, define them as array +RAW_EXP_IDS=( pmt0550_20RN_SSP370_r2 ) +# Parent experiment that the first RAW_EXP_ID branched from +# (used for input data of the parent that is required for aggregation) +# !! spinup - the aggregation will fail if the spinup period +# !! is as long or longer than +# !! the length of the first sub simulation! +spinup=0 +RAW_EXP_ID_PARENT=( pmt0531_d ) +# actually, there was a 300y spinup after the branch from pmt0531_d@5600 +# but for simplicity this is ignored here +#if [[ $spinup -ne 0 ]]; then +RAW_EXP_ID_PARENT[0]=${RAW_EXP_IDS[0]} +#fi + +echo ${RAW_EXP_IDS[@]} +echo ${RAW_EXP_ID_PARENT[@]} + +#Work dir +WORK_DIR_TRUNK=$EXP_DIR_TRUNK/work + +#Where to find the scripts (runpp etc.) +SCRIPT_DIR=${EXP_DIR_TRUNK}/scripts +SCRIPT_DIR=/work/bm0021/PalMod2/cmor/mpiesm/scripts + + + +############################ +#Define necessary variables +############################ + +#Where to find cdo (incl. CMOR operator), eg.: +cdo="/work/bm0021/cdo_incl_cmor/cdo-2022-09-20_cmor3.6.0_gcc/bin/cdo -v" # latest version + +# Base directory for DataRequest related headers/scripts +SCRIPT_ROOT=${SCRIPT_DIR} + +#Where to find the functions +fpath=/work/bm0021/PalMod2/cmor/functions + +#Where to find the configuration +cpath=${SCRIPT_ROOT}/conf + +#Models +atmmod=echam6 +ocemod=mpiom +srfmod=jsbach +esmod=MPI-ESM1-2 + +#Chunks +chunks+=([echam6]=" 0 1 2 3 4 5 6 7 8 9 ") +chunks+=([jsbach]=" 0 1 2 3 4 5 6 7 8 9 ") +chunks+=([mpiom]=" 0 ") +chunks+=([jsbachdec]=" 0 ") +atmmod_dec_chunk="???9123124" +srfmod_dec_chunk="???9123124" +srfmod_input_dec_chunk="???0123124" +ocemod_dec_chunk="???0123124" +icemod_dec_chunk="???0123124" +ocemod_fxyear=5900 + +#InfoTable(s) +# Define here the "cdocmorinfo"-File or "eum"-Files +# Multiple files possible with "," as delimiter, eg: +# it=expinfo.txt,userinfo.txt,modelinfo.txt +it_temp="${SCRIPT_ROOT}/ssp370-future-methane_r1i1p1f1-CR_cdocmorinfo" +ca+=([mpiom]="${SCRIPT_ROOT}/cdocmorinfo_mpiom_CR") +ca+=([echam6]="${SCRIPT_ROOT}/cdocmorinfo_echam6_CR") +ca+=([jsbach]="${SCRIPT_ROOT}/cdocmorinfo_jsbach_CR") + +#Experiment etc +experiment=ssp370-future-methane +member=r1i1p1f1 +mip=PalMod2 +vd=v20230105 +#vd=v$(date '+%Y%m%d') #CMOR version directory name, should be a date in format YYYYMMDD + +#Where to store errors +errdir=${EXP_DIR_TRUNK}/logs/errors +errdir_cmor=${errdir}_cmor +errdir_diag=${errdir}_diag +errdir_agg=${errdir}_agg + +#initial and final year of the experiment +iniyeararr=($((5900+spinup))) # 1850-3049, after the 300y spinup +finyeararr=(7099) +iniyear=1850 +finyear=3049 +#offset compared to startyear +inioffsetarr=(-4050) # 1850-3049 +# - 5900-7099 - 1200 yrs - 1850-3049 - -4050 + +# Command line options +RUN_AGG=true +RUN_DIAGS=true +RUN_CMOR=true +SUFFIX= +CLIMSUFFIX= +ARCHIVE_SUFFIX= +USE_CHUNKS=false +REMOVE_CHUNKS=false +PROCESS_CLIM=false +while [[ "$1" == -* ]] +do + OPT= + ARG= + case "$1" in + -d|--diags|--diags-only) RUN_CMOR=false; RUN_AGG=false;; + -c|--cmor|--cmor-only) RUN_DIAGS=false; RUN_AGG=false;; + -A|--agg|--agg-only) RUN_DIAGS=false; RUN_CMOR=false;; + -C|--clim) PROCESS_CLIM=true;; + -s|--suffix) OPT=-s; ARG=SUFFIX;; + -S|--archive-suffix) OPT=-S; ARG=ARCHIVE_SUFFIX;; + -f|--force) REMOVE_CHUNKS=true;; + -a|--append) USE_CHUNKS=true;; + --) shift; break;; + -*) die "invalid option '$1'";; + esac + if [[ -n "$OPT" ]] + then + shift + [[ $# -lt 1 ]] && die "missing argument for option '$OPT'" + eval "$ARG='$1'" + fi + shift +done + +echo "-----------------" +echo $0 $1 $2 $3 $4 +echo "-----------------" + +#Write Output to: +dr_trunk=${EXP_DIR_TRUNK}/archive$ARCHIVE_SUFFIX + + + +############################################################################### +# No user input beyond this line necessary (usually) +############################################################################### + +# Store parameters +par1=$1 +par2=$2 +par3=$3 +par4=$4 +n_arr=${#inioffsetarr[@]} + +#time interval of the experiment to standardize +if [[ ${#iniyeararr[@]} != ${#inioffsetarr[@]} ]] || [[ ${#iniyeararr[@]} != ${#finyeararr[@]} ]] || [[ ${#iniyeararr[@]} != ${#RAW_EXP_IDS[@]} ]]; then + die 'Each sub-simulation needs a specified iniyear, finyear and inioffset!' +else + for y in $(seq 0 $(( n_arr - 1 )) ); do + SDIR+=( ${EXP_DIR_TRUNK}/${RAW_EXP_IDS[$y]} ) + RAWSDIR+=( ${RAW_EXP_DIR_TRUNK} ) + WORK_DIR+=( ${WORK_DIR_TRUNK}/${RAW_EXP_IDS[$y]} ) + done + [[ -z "$2" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + [[ -z "$3" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + [[ -z "$4" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + for y in $(seq 0 $(( n_arr - 1 )) ); do + if [[ $y -lt $par1 ]] || [[ $y -gt $par2 ]]; then + lrel=-1 + urel=-1 + labs=-1 + uabs=-1 + elif [[ $y -eq $1 ]] && [[ $1 -eq $2 ]]; then + lrel=$3 + urel=$4 + labs=$(( $3 + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( $4 + ${inioffsetarr[$y]} - $spinup )) + elif [[ $y -eq $1 ]]; then + lrel=$3 + urel=${finyeararr[$y]} + labs=$(( $3 + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( ${finyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + elif [[ $y -eq $2 ]]; then + lrel=${iniyeararr[$y]} + urel=$4 + labs=$(( ${iniyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( $4 + ${inioffsetarr[$y]} - $spinup )) + else + lrel=${iniyeararr[$y]} + urel=${finyeararr[$y]} + labs=$(( ${iniyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( ${finyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + fi + [[ $urel -lt $lrel ]] && die 'iniyear, finyear arrays not properly set up!' + [[ $uabs -lt $labs ]] && die 'iniyear, finyear arrays not properly set up!' + SUB_SIM_REL_L+=( $lrel ) + SUB_SIM_REL_U+=( $urel ) + SUB_SIM_ABS_L+=( $labs ) + SUB_SIM_ABS_U+=( $uabs ) + [[ $lrel -eq -1 ]] && continue + [[ "$PROCESS_CLIM" == "false" ]] && { [[ ${SUB_SIM_REL_L[$y]} -lt ${iniyeararr[$y]} ]] || [[ ${SUB_SIM_REL_L[$y]} -gt ${finyeararr[$y]} ]] ; } && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ "$PROCESS_CLIM" == "false" ]] && { [[ ${SUB_SIM_REL_U[$y]} -lt ${iniyeararr[$y]} ]] || [[ ${SUB_SIM_REL_U[$y]} -gt ${finyeararr[$y]} ]] ; } && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + done + echo ${SUB_SIM_REL_L[@]} + echo ${SUB_SIM_REL_U[@]} + echo ${SUB_SIM_ABS_L[@]} + echo ${SUB_SIM_ABS_U[@]} + [[ $1 -ge ${#iniyeararr[@]} ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ $2 -ge ${#iniyeararr[@]} ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ $1 -gt $2 ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + cmorstart=$(( $3 + ${inioffsetarr[$1]} - $spinup )) + cmorend=$(( $4 + ${inioffsetarr[$2]} -spinup )) +fi +MESSAGE='PalMod2' +$RUN_AGG && MESSAGE+=' - Aggregation - ' +$RUN_DIAGS && MESSAGE+=' - Diagnostics - ' +$RUN_CMOR && MESSAGE+=" - CMOR rewriting - " +$PROCESS_CLIM && MESSAGE+=' for only climatological variables' +print "$(date +%Y-%m-%dT%H:%M:%S): $MESSAGE started for ${cmorstart}-${cmorend} $SUFFIX" +print " ... translating to ${RAW_EXP_IDS[$1]}@$3 to ${RAW_EXP_IDS[$2]}@$4" + +#exit 0 + + + +############################## +# Load the required functions +# function_Read_request_config: read data request / user configuration and initialize the if_requested check +# function_if_requested: checks if the currently processed variable is requested for the current timestep +# function_find_file: searches for inputfiles +############################## +. $fpath/function_Read_request_config_palmod +. $fpath/function_if_requested +. $fpath/function_find_file + +#Load predefined timeslices (depends on $iniyear/$finyear) +. $cpath/TimeSlices.h + +##Additionally define custom TimeSlices +## Example on how to define TimeSlices +## format: YYYYMMDDHH-YYYYMMDDHH +## +#TimeSlices+=([custom1]=(1850010100-1850010100)) +#TimeSlices+=([custom2]=(1850010100-1850123124)) +##TimeSlice dependend on variable +#TimeSlices+=([custom3]=(${iniyear}010100-${iniyear}123124)) +##TimeSlice dependend on arithmetics using variable +#TimeSlices+=([custom4]=($((iniyear+121))010100-$((iniyear+150))123124)) + +##Define SettingsContainer +## The following Option 3hrtest will activate the listed 3hr variables and deactivate any other variable for the given member (= realisation) +## The UserSettings for the given experiment have to contain the line: +## Option: 3hrtest = True +## or the setting will not be active! +#SettingsContainer+=([3hrtest]=([3hr]=(clt hfls hfss pr prc ps rlds rlus rsds rsus tas tos uas vas))) +#SettingsContainer[3hrtest]+=([${member}]=(${member}:False)) + +#Initialize DataRequest/User Configuration for the if_requested function +# This will read all SettingsContainers, TimeSlices and the configuration file +rrc_option=-s +[[ $DEBUG_LEVEL -ge 1 ]] && rrc_option= +[[ $DEBUG_LEVEL -ge 2 ]] && rrc_option=-v + + + +################################# +# Run agg, diag and cmor-rewrite +################################# + +function run_agg +{ + # Loop over file output periods and load diagnostic script fragment + if $RUN_AGG; then + + for y in $(seq ${par1} ${par2}); do + + # perform time shift for selected variables + cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day" + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + l_chunk=$(echo $chunk | cut -d "-" -f1) + r_chunk=$(echo $chunk | cut -d "-" -f2) + + l_chunk_year=${l_chunk%??????} + r_chunk_year=${r_chunk%??????} + + inv_chunk_year=$(( 1 + ${finyear} - ${l_chunk_year##+(0)} )) + print "Aggregation $chunk ($period): Reading forcing/input of year $inv_chunk_year" + + # Clean up stdout/stderr from previous run of this script + errtemp_agg="${errdir_agg}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_agg} + err="${errtemp_agg}/err${period}" + rm -f ${err}* + + # Read input file - for SSP* runs the jsbach input is time invariant + echo "Reading from ${RAW_EXP_IDS[$y]} jsbach_T31GR30_11tiles_5layers_natural-veg_100k.nc" + input_file_jsbach=$INPUT_DIR_TRUNK/${RAW_EXP_IDS[$y]}/restart/topo/jsbach_T31GR30_11tiles_5layers_natural-veg_100k.nc + + # Perform aggregation for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): Aggregation started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment aggr/${RAW_EXP_IDS[$y]}/$submodel/$period + + # Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $sdir/out_aggr" + echo "... writing log to $errtemp_agg" + + # Create output dirs + mkdir -p ${sdir}/tmp_aggr + mkdir -p ${sdir}/out_aggr + + # Create softlinks to raw model output + echo "... creating links from '$rawsdir' for $period, $submodel" + ln -sf $rawsdir/*_${period}* $sdir/ 2>/dev/null 1>&2 || { echo "ERROR creating links for $period ${RAW_EXP_IDS[$y]} $submodel" && exit 1 ; } + + # Load and run the aggr ScriptFragment + . ${SCRIPT_DIR}/palmod2_aggregation_${esmod}_${submodel}.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): Aggregation ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + done # EXP ID Index y + fi # if RUN_AGG +} + +function run_diag +{ + # Loop over file output periods and load diagnostic script fragment + if $RUN_DIAGS; then + for y in $(seq ${par1} ${par2}); do + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + + # Clean up stdout/stderr from previous run of this script + errtemp_diag="${errdir_diag}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_diag} + err="${errtemp_diag}/err${period}" + rm -f ${err}* + + # Perform diagnostic for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): Diagnostic started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment diag/${RAW_EXP_IDS[$y]}/$submodel/$period + + #Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $sdir/out_diag" + echo "... writing log to $errtemp_diag" + + # Diagnostic Output + mkdir -p ${sdir}/tmp_diag + mkdir -p ${sdir}/out_diag + + # Load and run the diag ScriptFragment + . ${SCRIPT_DIR}/palmod2_diagnostic_${esmod}_${submodel}_auto.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): Diagnostic ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + done # EXP ID Index y + fi # if RUN_DIAG +} + +function run_cmor +{ + # Loop over file output periods and load CMOR-Rewrite script fragment + if $RUN_CMOR; then + + for y in $(seq ${par1} ${par2}); do + + # Use working directory to hold .CHUNK and other tmp files + current_dir=${WORK_DIR[$y]}/cmor${SUFFIX}_${cmorstart}-${cmorend}${CLIMSUFFIX} + if [[ -e $current_dir ]] && [[ "$PROCESS_CLIM" == "false" ]] + then + if $USE_CHUNKS + then + warn "appending to existing chunk" + elif $REMOVE_CHUNKS + then + warn "moving chunk info to backup" + mkdir -p ${WORK_DIR[$y]}/backup + mv -v --backup=numbered $current_dir ${WORK_DIR[$y]}/backup + else + die "please check if cmor is running or has already been run for this chunk. Use --force to re-run" + fi + else + if $USE_CHUNKS + then + die "cannot find chunk info for appending" + fi + fi + mkdir -p $current_dir + previous_dir=$PWD + # Link gridinfo files + ln -sf $SCRIPT_DIR/gridinfo*nc $current_dir/ + cd $current_dir + + # perform time shift + cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day" + + # Define DRS root dir + dr=$dr_trunk/cmor${SUFFIX}_${cmorstart}-${cmorend}${CLIMSUFFIX} + mkdir -p $dr + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + # Define decadal interval + di="$(( ${period} + ${inioffsetarr[$y]} - 9 - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup ))" + dioce="$(( ${period} + ${inioffsetarr[$y]} - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup + 9 ))" + + # Clean up stdout/stderr from previous run of this script + errtemp_cmor="${errdir_cmor}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_cmor} + err="${errtemp_cmor}/err${period}" + rm -f ${err}* + + # Perform CMOR rewrite for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): CMORisation started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment cmor/${RAW_EXP_IDS[$y]}/$submodel/$period + + #Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $dr/$submodel" + echo "... writing log to $errtemp_cmor" + + # Output + mkdir -p $dr/$submodel + + #Location of Mapping table: + mt="${SCRIPT_DIR}/tables/${esmod}_${submodel}_${mip}_mapping.txt" + + #Define cdocmorinfo + it="${it_temp},${ca[${submodel}]}" + + # Load and run the CMOR-Rewrite ScriptFragment + . ${SCRIPT_DIR}/palmod2_cmor-rewrite_${esmod}_${submodel}_auto.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): CMORisation ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + cd $previous_dir + done # EXP ID Index y + + # Run NCO ncatted cleanup of unappropriate/unnecessary attributes + # this is necessary since CMOR sets attributes necessary only for CMIP6 + # that are unnecessary/wrong for PalMod + post_nco + + fi # if RUN_CMOR +} + +function post_nco { + +print "$(date +%Y-%m-%dT%H:%M:%S): NCO cleanup started for $dr" +# Load nco +#module load nco || { echo "Oops: Could not load NCO!" && exit 1 ; } + +# Post Processing with ncatted +#Find netCDF files in DRS directory +flist=( $( find $dr -name "*.nc" -type f | sort ) ) + +#Loop and run ncatted +echo "-> Looping over ${#flist[@]} netCDF files!" +for f in ${flist[@]} +do + echo "... editing $f" + ncatted -O -h -a further_info_url,global,d,, $f && echo "... deleted 'further_info_url'." || echo "... failed (ERROR)" + [[ "$(basename $f)" == *"cen"* ]] && { + ncatted -O -h -a frequency,global,m,c,"cen" $f && echo "... changed frequency to 'cen'." || echo "... failed (ERROR)" + } +done + +print "$(date +%Y-%m-%dT%H:%M:%S): NCO cleanup ended for $dr" + +} + + + +#Initialize DataRequest/User Configuration for the if_requested function +# This will read all SettingsContainers, TimeSlices and the configuration file +# Thereafter run aggregation, diagnostic, cmorization +if $PROCESS_CLIM +then + # Overwrite cmorstart/cmorend: + cmorstart=$iniyear + cmorend=$finyear + + # Read settings for clim1 + CLIMSUFFIX=_clim + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExp${SUFFIX}${CLIMSUFFIX}.conf || die "error while reading request config" + # Run diag&cmor + run_diag + run_cmor + + if [[ "$experiment" != "ssp"* ]] + then + # Reset Read_requested_config + l_linu=0 + unset DreqSettings + unset SliceSettings + unset UserSettings + unset TimeSlicesBounds + unset PriorityOrder + + # Read settings for clim2 + CLIMSUFFIX=_clim2 + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExp${SUFFIX}${CLIMSUFFIX}.conf || die "error while reading request config" + # Run diag&cmor + run_diag + run_cmor + fi +else + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExpTK$SUFFIX.conf || die "error while reading request config" + $RUN_AGG && run_agg || echo "Could not run agg" + $RUN_DIAGS && run_diag || echo "Could not run diag" + $RUN_CMOR && run_cmor || echo "Could not run cmor" + wait +fi + + + +print "$(date +%Y-%m-%dT%H:%M:%S): $MESSAGE finished for $cmorstart-$cmorend$SUFFIX" + +# Update run dates and submit job scripts + +# $Id$ + + diff --git a/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR_cdocmorinfo b/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR_cdocmorinfo new file mode 100644 index 0000000000000000000000000000000000000000..5f56bf913f8a61c34fdefb6acf0a23d5aa7250bc --- /dev/null +++ b/cmor/mpiesm/scripts/ssp370-future-methane_r1i1p1f1-CR_cdocmorinfo @@ -0,0 +1,114 @@ +# +# experiment info: +# +_CONTROLLED_VOCABULARY_FILE=PalMod2_CV.json +_FORMULA_VAR_FILE=PalMod2_formula_terms.json +_AXIS_ENTRY_FILE=PalMod2_coordinate.json +CONVENTIONS="CF-1.7 PalMod-2.0" +TITLE="MPI-ESM1-2 output prepared for PalMod2" +_history_template="%s ; CMOR rewrote data to be consistent with <activity_id>, <Conventions> and CF standards." + +EXPERIMENT_ID=ssp370-future-methane +EXPERIMENT="future methane under SSP3-7.0" +#Specify VARIANT_LABEL explicitly or realization_index, physics_index, initialization_index and forcing_index: +VARIANT_LABEL=r1i1p1f1 +REALIZATION_INDEX=1 +INITIALIZATION_INDEX=1 +PHYSICS_INDEX=1 +FORCING_INDEX=1 +VARIANT_INFO="PalMod MPI-ESM1-2-CR setup with full methane cycle. Model physics identical to MPI-ESM1-2-CR simulation transient-deglaciation-prescribed_r1i1p1f1." +ACTIVITY_ID=PalMod2 +#MIP_ERA=PalMod2 #ONLY CMIP6 +PROJECT_ID=PalMod2 +REQUIRED_TIME_UNITS="days since 1-1-1 00:00:00" +#FURTHER_INFO_URL="https://furtherinfo.es-doc.org/<mip_era>.<institution_id>.<source_id>.<experiment_id>.<sub_experiment_id>.<variant_label> +#Branch Info: If needed use the following 2 attributes to define the branch time +# in Parent_Time_Units and Required_Time_Units (=child) +# else use BRANCH_DATES to give the dates in YYYYMMDD,YYYYMMDD format +#BRANCH_TIME_IN_PARENT= +#BRANCH_TIME_IN_CHILD= +BRANCH_DATES=248010101,18500101 +BRANCH_METHOD="standard" +#PARENT_MIP_ERA=none #ONLY CMIP6 +PARENT_ACTIVITY_ID=PalMod2 +PARENT_EXPERIMENT="transient deglaciation with GLAC-1D ice sheets, with methane cycle" +PARENT_EXPERIMENT_ID=transient-deglaciation-prescribed-glac1d-methane +PARENT_SOURCE_ID=MPI-ESM1-2-CR-CH4 +PARENT_TIME_UNITS="days since 1-1-1 00:00:00" +PARENT_VARIANT_LABEL=r1i1p1f1 +SUB_EXPERIMENT_ID=none +SUB_EXPERIMENT=none +# +#model info: +# +SOURCE_ID=MPI-ESM1-2-CR-CH4 +#MODEL_ID=MPI-ESM1-2-CR-CH4 +REFERENCES="Kleinen, T., Mikolajewicz, U. and Brovkin, V. (2020). Terrestrial methane emissions from the Last Glacial Maximum to the preindustrial period. Climate of the Past, 16(2):575–595. doi: 10.5194/cp-16-575-2020\nKleinen, T., Gromov, S., Steil, B. and Brovkin, V. (2021). Atmospheric methane underestimated in future climate projections. Environmental Research Letters, 16(9):094006. doi: 10.1088/1748-9326/ac1814\nKapsch, M.-L., Mikolajewicz, U., Ziemen, F., & Schannwell, C. (2022). Ocean response in transient simulations of the last deglaciation dominated by underlying ice-sheet reconstruction and method of meltwater distribution. Geophysical Research Letters, 49, e2021GL096767. https://doi.org/10.1029/2021GL096767\nMPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPIâ€M Earth System Model version 1.2 (MPIâ€ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400" +#\nMueller, W.A. et al. (2018): A highâ€resolution version of the Max Planck Institute Earth System Model MPIâ€ESM1.2â€HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217" +SOURCE="MPI-ESM1.2-CR (2017): \naerosol: none, prescribed Kinne (2010)\natmos: ECHAM6.3 (spectral T31; 96 x 48 longitude/latitude; 31 levels; top level 10 hPa)\natmosChem: unnamed (accelerated methane chemistry)\nland: JSBACH3.20, River Transport Model\nlandIce: none, prescribed\nocean: MPIOM1.63 (bipolar GR3.0, approximately 300km; 122 x 101 longitude/latitude; 40 levels; top grid cell 0-15 m)\nocnBgchem: none, prescribed\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\nsolidLand: none, prescribed" +SOURCE_TYPE="AOGCM CHEM" +#CALENDAR=proleptic_gregorian +#MAPPING_TABLE_DIR=cmip6_mapping_tables +#MAPPING_TABLE=MPIESM1_CMIP6.txt +#GRID_FILE_DIR=__GRID_FILE_DIR +#GRID_FILE=__GRID_FILE +GRID=gn +GRID_LABEL=gn +#NOMINAL_RESOLUTION read from external file +#For MPIOM/HAMOCC CR / GR30 +#NOMINAL_RESOLUTION="500 km" +#For ECHAM6/JSBACH CR / T31 +#NOMINAL_RESOLUTION="500 km" +# +CHAR_AXIS_VEGTYPE=bare_land,glacier,tropical_evergreen_trees,tropical_deciduous_trees,extra-tropical_evergreen_trees,extra-tropical_deciduous_trees,raingreen_shrubs,deciduous_shrubs,C3_grass,C4_grass,C3_pasture,C4_pasture,C3_crops,C4_crops +CHAR_AXIS_SOILPOOLS=acid-soluble_below_ground_leaf_litter,acid-soluble_below_ground_woody_litter,water-soluble_below_ground_leaf_litter,water-soluble_below_ground_woody_litter,ethanol-soluble_below_ground_leaf_litter,ethanol-soluble_below_ground_woody_litter,non-soluble_below_ground_leaf_litter,non-soluble_below_ground_woody_litter,humus_from_leaf_litter,humus_from_woody_litter +CHAR_AXIS_LANDUSE=primary_and_secondary_land,crops,pastures,urban +CHAR_AXIS_BASIN=global_ocean,atlantic_arctic_ocean,indian_pacific_ocean +CHAR_AXIS_OLINE=barents_opening,bering_strait,canadian_archipelago,denmark_strait,drake_passage,english_channel,pacific_equatorial_undercurrent,faroe_scotland_channel,florida_bahamas_strait,fram_strait,iceland_faroe_channel,indonesian_throughflow,mozambique_channel,taiwan_luzon_straits,windward_passage +CHAR_AXIS_SILINE=barents_opening,bering_strait,canadian_archipelago,fram_strait +#spectband for the 3 aeropt variables +CHAR_AXIS_SPECTBAND_aeroptbnd=1818182 +CHAR_AXIS_SPECTBAND_aeroptbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aeroptbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_aerssabnd=1818182 +CHAR_AXIS_SPECTBAND_aerssabnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aerssabnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_aerasymbnd=1818182 +CHAR_AXIS_SPECTBAND_aerasymbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aerasymbnd_UNITS="m-1" +# 2d-spectband for the albedos +CHAR_AXIS_SPECTBAND_albdirbnd=3225689,766690 +CHAR_AXIS_SPECTBAND_albdirbnd_BOUNDS=5000000,1451379,1451379,82001 +CHAR_AXIS_SPECTBAND_albdirbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_albdiffbnd=3225689,766690 +CHAR_AXIS_SPECTBAND_albdiffbnd_BOUNDS=5000000,1451379,1451379,82001 +CHAR_AXIS_SPECTBAND_albdiffbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_solbnd=1818182 +CHAR_AXIS_SPECTBAND_solbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_solbnd_UNITS="m-1" +# PalMod +CHAR_AXIS_TYPELICE="ice sheet","ice shelf","ocean","ice-free land" +#T_AXIS="cmip" causes the time axis to be rewritten according to the requested time stamps +T_AXIS="cmip" +#OUTPUT_MODE="r" +OUTPUT_MODE="a" +MAX_SIZE=0 +SAVE_CHUNK="n" +#For files without time axis, if one is requested: +#firsttimeval=1 (1850-01-02 00:00:00 wenn days since 1850-01-01 00:00:00) +FIRSTTIMEVAL=1 +# +# institution and contact info: +# +# none of these can be set in the command line +# +DEFLATE_LEVEL=1 +CONTACT=palmod2-mpi-esm@dkrz.de +# +# MPI-M +# +INSTITUTION_ID=MPI-M +INSTITUTION="Max Planck Institute for Meteorology, Hamburg 20146, Germany" +LICENSE="PalMod2 model data produced by MPI-M is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law." +#MIP_TABLE_DIR="/pool/data/CMIP6/cmip6-cmor-tables/Tables/" +MIP_TABLE_DIR="/work/bm0021/PalMod2/cmor_tables/" diff --git a/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.cmor_ctl b/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.cmor_ctl new file mode 100755 index 0000000000000000000000000000000000000000..6fd0c9186cce00afa0a9c910dacfbd67d275d3e7 --- /dev/null +++ b/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.cmor_ctl @@ -0,0 +1,57 @@ +#! /bin/sh -e +#SBATCH --account=bm0021 +#SBATCH --qos=esgf +#SBATCH --time=48:00:00 +#SBATCH --partition=shared +#SBATCH --mail-type=FAIL +#SBATCH --output=%x_%j.log + +# Number of sub-simulations +n_subsim=1 +#initial and final year of the experiment +spinup=0 +iniyeararr=( $(( 5900 + spinup )) ) +finyeararr=( 7099 ) +iniyear=$(( 1850 + spinup )) +finyear=3049 +#offset compared to startyear +inioffsetarr=(-4050) + +# Chunksize +# Note that there are prerequisites concerning the chunksize: +# - the defined decadal timeslizes may not overlap between two chunks! +# - decadal bounds have to be defined accordingly - "???01231" in this case +# - usually this is the case by default due to decadal model output! +chunksize=100 + +# Create list +for i in $(seq 0 $(( n_subsim - 1 )) ) +do + for yyyy in $(seq ${iniyeararr[$i]} ${finyeararr[$i]} ) + do + paramarr+=( "$i $yyyy" ) + done +done + +rm -f cmor_ctl_list_ssp585_r1i1p1f1 +in=0 +for i in $(seq $((iniyear-iniyear)) $chunksize $((finyear-iniyear))) +do + [[ $i -eq $((iniyear-iniyear)) ]] && continue + li=$(echo ${paramarr[$in]} | cut -d " " -f1) + ly=$(echo ${paramarr[$in]} | cut -d " " -f2) + ui=$(echo ${paramarr[$((i-1))]} | cut -d " " -f1) + uy=$(echo ${paramarr[$((i-1))]} | cut -d " " -f2) + in=$i + echo "$li $ui $ly $uy" >> cmor_ctl_list_ssp585_r1i1p1f1 +done +[[ $i -ne $((finyear-iniyear)) ]] && { + li=$(echo ${paramarr[$in]} | cut -d " " -f1) + ly=$(echo ${paramarr[$in]} | cut -d " " -f2) + ui=$(echo ${paramarr[$((finyear-iniyear))]} | cut -d " " -f1) + uy=$(echo ${paramarr[$((finyear-iniyear))]} | cut -d " " -f2) + echo "$li $ui $ly $uy" >> cmor_ctl_list_ssp585_r1i1p1f1 +} + +make -k -j 19 -f ssp585-future-methane_r1i1p1f1-CR.cmor_ctl.mk "$@" + diff --git a/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.cmor_ctl.mk b/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.cmor_ctl.mk new file mode 100755 index 0000000000000000000000000000000000000000..e9303a14a93231e10756d51095f0909982ed671c --- /dev/null +++ b/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.cmor_ctl.mk @@ -0,0 +1,44 @@ +EXP_ID = ssp585-future-methane_r1i1p1f1-CR + +ACCOUNT = bm0021 +PARTITION = prepost,compute,compute2 + +SUFFIX = +ARCHIVE_SUFFIX = + +TARGET_STEP=cmor +NUMCHUNKS=$(shell cat cmor_ctl_list_ssp585_r1i1p1f1 | wc -l ) + +AGGR_TIME = 00:10:00 +DIAGS_TIME = 00:30:00 +CMOR_TIME = 02:30:00 + +CMOR_FLAGS = + +SBATCHFLAGS=-W + +MESSAGE = $$(date +%Y-%m-%dT%H:%M:%S): CMIP6 diagnostics and CMOR rewriting ($(SUFFIX:_%=%)) + +.PHONY: all +.PRECIOUS: targets/$(EXP_ID).aggr$(SUFFIX).% targets/$(EXP_ID).diags$(SUFFIX).% targets/$(EXP_ID).cmor$(SUFFIX).% + + + +all: + @echo "$(MESSAGE) started" + mkdir -vp targets + $(MAKE) $(MFLAGS) -f $(MAKEFILE_LIST) $(addprefix targets/$(EXP_ID).$(TARGET_STEP)$(SUFFIX).,$(shell seq 1 $(NUMCHUNKS))) + @echo "$(MESSAGE) finished" + +targets/$(EXP_ID).aggr$(SUFFIX).%: + sbatch $(SBATCHFLAGS) --time=$(AGGR_TIME) --job-name=$(EXP_ID)_runpp_aggr$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -A $(shell sed -n '$(*)'p < cmor_ctl_list_ssp585_r1i1p1f1) + @touch $@ + +targets/$(EXP_ID).diags$(SUFFIX).%: targets/$(EXP_ID).aggr$(SUFFIX).% + sbatch $(SBATCHFLAGS) --time=$(DIAGS_TIME) --job-name=$(EXP_ID)_runpp_diag$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -d $(shell sed -n '$(*)'p < cmor_ctl_list_ssp585_r1i1p1f1) + @touch $@ + +targets/$(EXP_ID).cmor$(SUFFIX).%: targets/$(EXP_ID).diags$(SUFFIX).% + sbatch $(SBATCHFLAGS) --time=$(CMOR_TIME) --job-name=$(EXP_ID)_runpp_cmor$(SUFFIX) --output=%x_%j.log --comment=$* $(EXP_ID).runpp -s '$(SUFFIX)' -S '$(ARCHIVE_SUFFIX)' -c $(CMOR_FLAGS) $(shell sed -n '$(*)'p < cmor_ctl_list_ssp585_r1i1p1f1) + @touch $@ + diff --git a/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.runpp b/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.runpp new file mode 100755 index 0000000000000000000000000000000000000000..247789220f9b4a7cc355c43641deb1b9c443fcab --- /dev/null +++ b/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR.runpp @@ -0,0 +1,607 @@ +#!/bin/ksh +# +# PalMod .runpp +# +# Wrapper Script Agg+Diag+CMOR MPI-ESM1-2 by Martin Schupfner, DKRZ +# +### Batch Queuing System is SLURM +#SBATCH --partition=compute +#SBATCH --nodes=1 +#SBATCH --mem=100G +#SBATCH --time=01:30:00 +#SBATCH --mail-type=none +#SBATCH --account=bm0021 +#SBATCH --qos=esgf +#SBATCH --exclusive +#SBATCH --output=ssp585-future-methane_r1i1p1f1-CR.runpp_%j.log + +DEBUG_LEVEL=${DEBUG_LEVEL:-0} + +# Support log style output +export LANG=C +print () { command print "$(date +'%F %T'):" "$@"; } +print_re='^[0-9]+-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}' + +warn () { print 'Hey:' "$@" >&2; } +die () { print 'Oops:' "$@" >&2; return 1; } + +# Bail out on error +trap 'print Error at line $LINENO >&2' ERR +set -eu + +# Disable core file creation +ulimit -c 0 + +# Print command info +[[ $DEBUG_LEVEL -ge 2 ]] && set -x + +#module load nco || { echo "Oops: Could not load NCO!" && exit 1 ; } +alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted + +######################################### +# Define specifics about the simulation +######################################### + +#Root directory of all scripts, outdata, logs etc +EXP_ID=ssp585-future-methane_r1i1p1f1-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_TK/ssp585-future-methane_r1i1p1f1-CR +#EXP_DIR_TRUNK=/work/bk1192/k204212/palmod_TK/ssp585-future-methane_r1i1p1f1-CR + +#initial files for aggregation +INPUT_DIR_TRUNK=/work/bm1030/from_Mistral/bm1030/m300020/mpiesm-palmod_tk_r10186_megan_next/experiments + +# RAW Data - path and sub-simulations +RAW_EXP_DIR_TRUNK=/work/bk1192/from_Mistral/bk1192/WG2/WP2.3/future_scenarios_2021/SSP5-8.5 +# As usually the Experiment is composed of several sub-simulations, define them as array +RAW_EXP_IDS=( pmt0550_20RN_SSP585_r2 ) +# Parent experiment that the first RAW_EXP_ID branched from +# (used for input data of the parent that is required for aggregation) +# !! spinup - the aggregation will fail if the spinup period +# !! is as long or longer than +# !! the length of the first sub simulation! +spinup=0 +RAW_EXP_ID_PARENT=( pmt0531_d ) +# actually, there was a 300y spinup after the branch from pmt0531_d@5600 +# but for simplicity this is ignored here +#if [[ $spinup -ne 0 ]]; then +RAW_EXP_ID_PARENT[0]=${RAW_EXP_IDS[0]} +#fi + +echo ${RAW_EXP_IDS[@]} +echo ${RAW_EXP_ID_PARENT[@]} + +#Work dir +WORK_DIR_TRUNK=$EXP_DIR_TRUNK/work + +#Where to find the scripts (runpp etc.) +SCRIPT_DIR=${EXP_DIR_TRUNK}/scripts +SCRIPT_DIR=/work/bm0021/PalMod2/cmor/mpiesm/scripts + + + +############################ +#Define necessary variables +############################ + +#Where to find cdo (incl. CMOR operator), eg.: +cdo="/work/bm0021/cdo_incl_cmor/cdo-2022-09-20_cmor3.6.0_gcc/bin/cdo -v" # latest version + +# Base directory for DataRequest related headers/scripts +SCRIPT_ROOT=${SCRIPT_DIR} + +#Where to find the functions +fpath=/work/bm0021/PalMod2/cmor/functions + +#Where to find the configuration +cpath=${SCRIPT_ROOT}/conf + +#Models +atmmod=echam6 +ocemod=mpiom +srfmod=jsbach +esmod=MPI-ESM1-2 + +#Chunks +chunks+=([echam6]=" 0 1 2 3 4 5 6 7 8 9 ") +chunks+=([jsbach]=" 0 1 2 3 4 5 6 7 8 9 ") +chunks+=([mpiom]=" 0 ") +chunks+=([jsbachdec]=" 0 ") +atmmod_dec_chunk="???9123124" +srfmod_dec_chunk="???9123124" +srfmod_input_dec_chunk="???0123124" +ocemod_dec_chunk="???0123124" +icemod_dec_chunk="???0123124" +ocemod_fxyear=5900 + +#InfoTable(s) +# Define here the "cdocmorinfo"-File or "eum"-Files +# Multiple files possible with "," as delimiter, eg: +# it=expinfo.txt,userinfo.txt,modelinfo.txt +it_temp="${SCRIPT_ROOT}/ssp585-future-methane_r1i1p1f1-CR_cdocmorinfo" +ca+=([mpiom]="${SCRIPT_ROOT}/cdocmorinfo_mpiom_CR") +ca+=([echam6]="${SCRIPT_ROOT}/cdocmorinfo_echam6_CR") +ca+=([jsbach]="${SCRIPT_ROOT}/cdocmorinfo_jsbach_CR") + +#Experiment etc +experiment=ssp585-future-methane +member=r1i1p1f1 +mip=PalMod2 +vd=v20230105 +#vd=v$(date '+%Y%m%d') #CMOR version directory name, should be a date in format YYYYMMDD + +#Where to store errors +errdir=${EXP_DIR_TRUNK}/logs/errors +errdir_cmor=${errdir}_cmor +errdir_diag=${errdir}_diag +errdir_agg=${errdir}_agg + +#initial and final year of the experiment +iniyeararr=($((5900+spinup))) # 1850-3049, after the 300y spinup +finyeararr=(7099) +iniyear=1850 +finyear=3049 +#offset compared to startyear +inioffsetarr=(-4050) # 1850-3049 +# - 5900-7099 - 1200 yrs - 1850-3049 - -4050 + +# Command line options +RUN_AGG=true +RUN_DIAGS=true +RUN_CMOR=true +SUFFIX= +CLIMSUFFIX= +ARCHIVE_SUFFIX= +USE_CHUNKS=false +REMOVE_CHUNKS=false +PROCESS_CLIM=false +while [[ "$1" == -* ]] +do + OPT= + ARG= + case "$1" in + -d|--diags|--diags-only) RUN_CMOR=false; RUN_AGG=false;; + -c|--cmor|--cmor-only) RUN_DIAGS=false; RUN_AGG=false;; + -A|--agg|--agg-only) RUN_DIAGS=false; RUN_CMOR=false;; + -C|--clim) PROCESS_CLIM=true;; + -s|--suffix) OPT=-s; ARG=SUFFIX;; + -S|--archive-suffix) OPT=-S; ARG=ARCHIVE_SUFFIX;; + -f|--force) REMOVE_CHUNKS=true;; + -a|--append) USE_CHUNKS=true;; + --) shift; break;; + -*) die "invalid option '$1'";; + esac + if [[ -n "$OPT" ]] + then + shift + [[ $# -lt 1 ]] && die "missing argument for option '$OPT'" + eval "$ARG='$1'" + fi + shift +done + +echo "-----------------" +echo $0 $1 $2 $3 $4 +echo "-----------------" + +#Write Output to: +dr_trunk=${EXP_DIR_TRUNK}/archive$ARCHIVE_SUFFIX + + + +############################################################################### +# No user input beyond this line necessary (usually) +############################################################################### + +# Store parameters +par1=$1 +par2=$2 +par3=$3 +par4=$4 +n_arr=${#inioffsetarr[@]} + +#time interval of the experiment to standardize +if [[ ${#iniyeararr[@]} != ${#inioffsetarr[@]} ]] || [[ ${#iniyeararr[@]} != ${#finyeararr[@]} ]] || [[ ${#iniyeararr[@]} != ${#RAW_EXP_IDS[@]} ]]; then + die 'Each sub-simulation needs a specified iniyear, finyear and inioffset!' +else + for y in $(seq 0 $(( n_arr - 1 )) ); do + SDIR+=( ${EXP_DIR_TRUNK}/${RAW_EXP_IDS[$y]} ) + RAWSDIR+=( ${RAW_EXP_DIR_TRUNK} ) + WORK_DIR+=( ${WORK_DIR_TRUNK}/${RAW_EXP_IDS[$y]} ) + done + [[ -z "$2" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + [[ -z "$3" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + [[ -z "$4" ]] && [[ "$PROCESS_CLIM" == "false" ]] && die 'invalid number of parameters; need index of start and end simulations, start year (of first index) and end year (of second index) as YYYY' + for y in $(seq 0 $(( n_arr - 1 )) ); do + if [[ $y -lt $par1 ]] || [[ $y -gt $par2 ]]; then + lrel=-1 + urel=-1 + labs=-1 + uabs=-1 + elif [[ $y -eq $1 ]] && [[ $1 -eq $2 ]]; then + lrel=$3 + urel=$4 + labs=$(( $3 + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( $4 + ${inioffsetarr[$y]} - $spinup )) + elif [[ $y -eq $1 ]]; then + lrel=$3 + urel=${finyeararr[$y]} + labs=$(( $3 + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( ${finyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + elif [[ $y -eq $2 ]]; then + lrel=${iniyeararr[$y]} + urel=$4 + labs=$(( ${iniyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( $4 + ${inioffsetarr[$y]} - $spinup )) + else + lrel=${iniyeararr[$y]} + urel=${finyeararr[$y]} + labs=$(( ${iniyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + uabs=$(( ${finyeararr[$y]} + ${inioffsetarr[$y]} - $spinup )) + fi + [[ $urel -lt $lrel ]] && die 'iniyear, finyear arrays not properly set up!' + [[ $uabs -lt $labs ]] && die 'iniyear, finyear arrays not properly set up!' + SUB_SIM_REL_L+=( $lrel ) + SUB_SIM_REL_U+=( $urel ) + SUB_SIM_ABS_L+=( $labs ) + SUB_SIM_ABS_U+=( $uabs ) + [[ $lrel -eq -1 ]] && continue + [[ "$PROCESS_CLIM" == "false" ]] && { [[ ${SUB_SIM_REL_L[$y]} -lt ${iniyeararr[$y]} ]] || [[ ${SUB_SIM_REL_L[$y]} -gt ${finyeararr[$y]} ]] ; } && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ "$PROCESS_CLIM" == "false" ]] && { [[ ${SUB_SIM_REL_U[$y]} -lt ${iniyeararr[$y]} ]] || [[ ${SUB_SIM_REL_U[$y]} -gt ${finyeararr[$y]} ]] ; } && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + done + echo ${SUB_SIM_REL_L[@]} + echo ${SUB_SIM_REL_U[@]} + echo ${SUB_SIM_ABS_L[@]} + echo ${SUB_SIM_ABS_U[@]} + [[ $1 -ge ${#iniyeararr[@]} ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ $2 -ge ${#iniyeararr[@]} ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + [[ $1 -gt $2 ]] && die 'erroneous input - input does not make sense along with the configured iniyear, finyear arrays' + cmorstart=$(( $3 + ${inioffsetarr[$1]} - $spinup )) + cmorend=$(( $4 + ${inioffsetarr[$2]} -spinup )) +fi +MESSAGE='PalMod2' +$RUN_AGG && MESSAGE+=' - Aggregation - ' +$RUN_DIAGS && MESSAGE+=' - Diagnostics - ' +$RUN_CMOR && MESSAGE+=" - CMOR rewriting - " +$PROCESS_CLIM && MESSAGE+=' for only climatological variables' +print "$(date +%Y-%m-%dT%H:%M:%S): $MESSAGE started for ${cmorstart}-${cmorend} $SUFFIX" +print " ... translating to ${RAW_EXP_IDS[$1]}@$3 to ${RAW_EXP_IDS[$2]}@$4" + +#exit 0 + + + +############################## +# Load the required functions +# function_Read_request_config: read data request / user configuration and initialize the if_requested check +# function_if_requested: checks if the currently processed variable is requested for the current timestep +# function_find_file: searches for inputfiles +############################## +. $fpath/function_Read_request_config_palmod +. $fpath/function_if_requested +. $fpath/function_find_file + +#Load predefined timeslices (depends on $iniyear/$finyear) +. $cpath/TimeSlices.h + +##Additionally define custom TimeSlices +## Example on how to define TimeSlices +## format: YYYYMMDDHH-YYYYMMDDHH +## +#TimeSlices+=([custom1]=(1850010100-1850010100)) +#TimeSlices+=([custom2]=(1850010100-1850123124)) +##TimeSlice dependend on variable +#TimeSlices+=([custom3]=(${iniyear}010100-${iniyear}123124)) +##TimeSlice dependend on arithmetics using variable +#TimeSlices+=([custom4]=($((iniyear+121))010100-$((iniyear+150))123124)) + +##Define SettingsContainer +## The following Option 3hrtest will activate the listed 3hr variables and deactivate any other variable for the given member (= realisation) +## The UserSettings for the given experiment have to contain the line: +## Option: 3hrtest = True +## or the setting will not be active! +#SettingsContainer+=([3hrtest]=([3hr]=(clt hfls hfss pr prc ps rlds rlus rsds rsus tas tos uas vas))) +#SettingsContainer[3hrtest]+=([${member}]=(${member}:False)) + +#Initialize DataRequest/User Configuration for the if_requested function +# This will read all SettingsContainers, TimeSlices and the configuration file +rrc_option=-s +[[ $DEBUG_LEVEL -ge 1 ]] && rrc_option= +[[ $DEBUG_LEVEL -ge 2 ]] && rrc_option=-v + + + +################################# +# Run agg, diag and cmor-rewrite +################################# + +function run_agg +{ + # Loop over file output periods and load diagnostic script fragment + if $RUN_AGG; then + + for y in $(seq ${par1} ${par2}); do + + # perform time shift for selected variables + cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day" + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + l_chunk=$(echo $chunk | cut -d "-" -f1) + r_chunk=$(echo $chunk | cut -d "-" -f2) + + l_chunk_year=${l_chunk%??????} + r_chunk_year=${r_chunk%??????} + + inv_chunk_year=$(( 1 + ${finyear} - ${l_chunk_year##+(0)} )) + print "Aggregation $chunk ($period): Reading forcing/input of year $inv_chunk_year" + + # Clean up stdout/stderr from previous run of this script + errtemp_agg="${errdir_agg}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_agg} + err="${errtemp_agg}/err${period}" + rm -f ${err}* + + # Read input file - for SSP* runs the jsbach input is time invariant + echo "Reading from ${RAW_EXP_IDS[$y]} jsbach_T31GR30_11tiles_5layers_natural-veg_100k.nc" + input_file_jsbach=$INPUT_DIR_TRUNK/${RAW_EXP_IDS[$y]}/restart/topo/jsbach_T31GR30_11tiles_5layers_natural-veg_100k.nc + + # Perform aggregation for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): Aggregation started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment aggr/${RAW_EXP_IDS[$y]}/$submodel/$period + + # Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $sdir/out_aggr" + echo "... writing log to $errtemp_agg" + + # Create output dirs + mkdir -p ${sdir}/tmp_aggr + mkdir -p ${sdir}/out_aggr + + # Create softlinks to raw model output + echo "... creating links from '$rawsdir' for $period, $submodel" + ln -sf $rawsdir/*_${period}* $sdir/ 2>/dev/null 1>&2 || { echo "ERROR creating links for $period ${RAW_EXP_IDS[$y]} $submodel" && exit 1 ; } + + # Load and run the aggr ScriptFragment + . ${SCRIPT_DIR}/palmod2_aggregation_${esmod}_${submodel}.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): Aggregation ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + done # EXP ID Index y + fi # if RUN_AGG +} + +function run_diag +{ + # Loop over file output periods and load diagnostic script fragment + if $RUN_DIAGS; then + for y in $(seq ${par1} ${par2}); do + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + + # Clean up stdout/stderr from previous run of this script + errtemp_diag="${errdir_diag}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_diag} + err="${errtemp_diag}/err${period}" + rm -f ${err}* + + # Perform diagnostic for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): Diagnostic started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment diag/${RAW_EXP_IDS[$y]}/$submodel/$period + + #Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $sdir/out_diag" + echo "... writing log to $errtemp_diag" + + # Diagnostic Output + mkdir -p ${sdir}/tmp_diag + mkdir -p ${sdir}/out_diag + + # Load and run the diag ScriptFragment + . ${SCRIPT_DIR}/palmod2_diagnostic_${esmod}_${submodel}_auto.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): Diagnostic ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + done # EXP ID Index y + fi # if RUN_DIAG +} + +function run_cmor +{ + # Loop over file output periods and load CMOR-Rewrite script fragment + if $RUN_CMOR; then + + for y in $(seq ${par1} ${par2}); do + + # Use working directory to hold .CHUNK and other tmp files + current_dir=${WORK_DIR[$y]}/cmor${SUFFIX}_${cmorstart}-${cmorend}${CLIMSUFFIX} + if [[ -e $current_dir ]] && [[ "$PROCESS_CLIM" == "false" ]] + then + if $USE_CHUNKS + then + warn "appending to existing chunk" + elif $REMOVE_CHUNKS + then + warn "moving chunk info to backup" + mkdir -p ${WORK_DIR[$y]}/backup + mv -v --backup=numbered $current_dir ${WORK_DIR[$y]}/backup + else + die "please check if cmor is running or has already been run for this chunk. Use --force to re-run" + fi + else + if $USE_CHUNKS + then + die "cannot find chunk info for appending" + fi + fi + mkdir -p $current_dir + previous_dir=$PWD + # Link gridinfo files + ln -sf $SCRIPT_DIR/gridinfo*nc $current_dir/ + cd $current_dir + + # perform time shift + cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day" + + # Define DRS root dir + dr=$dr_trunk/cmor${SUFFIX}_${cmorstart}-${cmorend}${CLIMSUFFIX} + mkdir -p $dr + + for period in $(seq ${SUB_SIM_REL_L[$y]} ${SUB_SIM_REL_U[$y]}); do + # Define the chunk that is tested by if_requested (YYYYMMDDHH-YYYYMMDDHH) + chunk=$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')010100-$( echo $(( ${period} + ${inioffsetarr[$y]} - $spinup )) | awk '{ printf "%06d", $0 }')123124 + # Define decadal interval + di="$(( ${period} + ${inioffsetarr[$y]} - 9 - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup ))" + dioce="$(( ${period} + ${inioffsetarr[$y]} - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup + 9 ))" + + # Clean up stdout/stderr from previous run of this script + errtemp_cmor="${errdir_cmor}${SUFFIX}${CLIMSUFFIX}/${RAW_EXP_IDS[$y]}/${RAW_EXP_IDS[$y]}_${period}" + mkdir -p ${errtemp_cmor} + err="${errtemp_cmor}/err${period}" + rm -f ${err}* + + # Perform CMOR rewrite for each submodel + for submodel in $atmmod $ocemod $srfmod; do # $bgcmod; do + + # Chunking + [[ "${chunks[$submodel]}" == *" ${period: -1} "* ]] && { + + # Show progress + print "$(date +%Y-%m-%dT%H:%M:%S): CMORisation started for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + sh -c 'scontrol update JobId=$SLURM_JOB_ID Comment="$*"' scomment cmor/${RAW_EXP_IDS[$y]}/$submodel/$period + + #Location of input/output + sdir=${SDIR[$y]}/outdata/$submodel + rawsdir=${RAWSDIR[$y]}/$submodel + echo "... writing output to $dr/$submodel" + echo "... writing log to $errtemp_cmor" + + # Output + mkdir -p $dr/$submodel + + #Location of Mapping table: + mt="${SCRIPT_DIR}/tables/${esmod}_${submodel}_${mip}_mapping.txt" + + #Define cdocmorinfo + it="${it_temp},${ca[${submodel}]}" + + # Load and run the CMOR-Rewrite ScriptFragment + . ${SCRIPT_DIR}/palmod2_cmor-rewrite_${esmod}_${submodel}_auto.h + wait + print "$(date +%Y-%m-%dT%H:%M:%S): CMORisation ended for ${RAW_EXP_IDS[$y]} $submodel $chunk ($period) ..." + } + + done # submodel + done # period + cd $previous_dir + done # EXP ID Index y + + # Run NCO ncatted cleanup of unappropriate/unnecessary attributes + # this is necessary since CMOR sets attributes necessary only for CMIP6 + # that are unnecessary/wrong for PalMod + post_nco + + fi # if RUN_CMOR +} + +function post_nco { + +print "$(date +%Y-%m-%dT%H:%M:%S): NCO cleanup started for $dr" +# Load nco +#module load nco || { echo "Oops: Could not load NCO!" && exit 1 ; } + +# Post Processing with ncatted +#Find netCDF files in DRS directory +flist=( $( find $dr -name "*.nc" -type f | sort ) ) + +#Loop and run ncatted +echo "-> Looping over ${#flist[@]} netCDF files!" +for f in ${flist[@]} +do + echo "... editing $f" + ncatted -O -h -a further_info_url,global,d,, $f && echo "... deleted 'further_info_url'." || echo "... failed (ERROR)" + [[ "$(basename $f)" == *"cen"* ]] && { + ncatted -O -h -a frequency,global,m,c,"cen" $f && echo "... changed frequency to 'cen'." || echo "... failed (ERROR)" + } +done + +print "$(date +%Y-%m-%dT%H:%M:%S): NCO cleanup ended for $dr" + +} + + + +#Initialize DataRequest/User Configuration for the if_requested function +# This will read all SettingsContainers, TimeSlices and the configuration file +# Thereafter run aggregation, diagnostic, cmorization +if $PROCESS_CLIM +then + # Overwrite cmorstart/cmorend: + cmorstart=$iniyear + cmorend=$finyear + + # Read settings for clim1 + CLIMSUFFIX=_clim + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExp${SUFFIX}${CLIMSUFFIX}.conf || die "error while reading request config" + # Run diag&cmor + run_diag + run_cmor + + if [[ "$experiment" != "ssp"* ]] + then + # Reset Read_requested_config + l_linu=0 + unset DreqSettings + unset SliceSettings + unset UserSettings + unset TimeSlicesBounds + unset PriorityOrder + + # Read settings for clim2 + CLIMSUFFIX=_clim2 + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExp${SUFFIX}${CLIMSUFFIX}.conf || die "error while reading request config" + # Run diag&cmor + run_diag + run_cmor + fi +else + Read_request_config $rrc_option AllExp ${cpath}/${mip}_requested_vars_AllExpTK$SUFFIX.conf || die "error while reading request config" + $RUN_AGG && run_agg || echo "Could not run agg" + $RUN_DIAGS && run_diag || echo "Could not run diag" + $RUN_CMOR && run_cmor || echo "Could not run cmor" + wait +fi + + + +print "$(date +%Y-%m-%dT%H:%M:%S): $MESSAGE finished for $cmorstart-$cmorend$SUFFIX" + +# Update run dates and submit job scripts + +# $Id$ + + diff --git a/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR_cdocmorinfo b/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR_cdocmorinfo new file mode 100644 index 0000000000000000000000000000000000000000..f2f0878ee2713ab43051d0d0f83bddf4abe649b1 --- /dev/null +++ b/cmor/mpiesm/scripts/ssp585-future-methane_r1i1p1f1-CR_cdocmorinfo @@ -0,0 +1,114 @@ +# +# experiment info: +# +_CONTROLLED_VOCABULARY_FILE=PalMod2_CV.json +_FORMULA_VAR_FILE=PalMod2_formula_terms.json +_AXIS_ENTRY_FILE=PalMod2_coordinate.json +CONVENTIONS="CF-1.7 PalMod-2.0" +TITLE="MPI-ESM1-2 output prepared for PalMod2" +_history_template="%s ; CMOR rewrote data to be consistent with <activity_id>, <Conventions> and CF standards." + +EXPERIMENT_ID=ssp585-future-methane +EXPERIMENT="future methane under SSP5-8.5" +#Specify VARIANT_LABEL explicitly or realization_index, physics_index, initialization_index and forcing_index: +VARIANT_LABEL=r1i1p1f1 +REALIZATION_INDEX=1 +INITIALIZATION_INDEX=1 +PHYSICS_INDEX=1 +FORCING_INDEX=1 +VARIANT_INFO="PalMod MPI-ESM1-2-CR setup with full methane cycle. Model physics identical to MPI-ESM1-2-CR simulation transient-deglaciation-prescribed_r1i1p1f1." +ACTIVITY_ID=PalMod2 +#MIP_ERA=PalMod2 #ONLY CMIP6 +PROJECT_ID=PalMod2 +REQUIRED_TIME_UNITS="days since 1-1-1 00:00:00" +#FURTHER_INFO_URL="https://furtherinfo.es-doc.org/<mip_era>.<institution_id>.<source_id>.<experiment_id>.<sub_experiment_id>.<variant_label> +#Branch Info: If needed use the following 2 attributes to define the branch time +# in Parent_Time_Units and Required_Time_Units (=child) +# else use BRANCH_DATES to give the dates in YYYYMMDD,YYYYMMDD format +#BRANCH_TIME_IN_PARENT= +#BRANCH_TIME_IN_CHILD= +BRANCH_DATES=248010101,18500101 +BRANCH_METHOD="standard" +#PARENT_MIP_ERA=none #ONLY CMIP6 +PARENT_ACTIVITY_ID=PalMod2 +PARENT_EXPERIMENT="transient deglaciation with GLAC-1D ice sheets, with methane cycle" +PARENT_EXPERIMENT_ID=transient-deglaciation-prescribed-glac1d-methane +PARENT_SOURCE_ID=MPI-ESM1-2-CR-CH4 +PARENT_TIME_UNITS="days since 1-1-1 00:00:00" +PARENT_VARIANT_LABEL=r1i1p1f1 +SUB_EXPERIMENT_ID=none +SUB_EXPERIMENT=none +# +#model info: +# +SOURCE_ID=MPI-ESM1-2-CR-CH4 +#MODEL_ID=MPI-ESM1-2-CR-CH4 +REFERENCES="Kleinen, T., Mikolajewicz, U. and Brovkin, V. (2020). Terrestrial methane emissions from the Last Glacial Maximum to the preindustrial period. Climate of the Past, 16(2):575–595. doi: 10.5194/cp-16-575-2020\nKleinen, T., Gromov, S., Steil, B. and Brovkin, V. (2021). Atmospheric methane underestimated in future climate projections. Environmental Research Letters, 16(9):094006. doi: 10.1088/1748-9326/ac1814\nKapsch, M.-L., Mikolajewicz, U., Ziemen, F., & Schannwell, C. (2022). Ocean response in transient simulations of the last deglaciation dominated by underlying ice-sheet reconstruction and method of meltwater distribution. Geophysical Research Letters, 49, e2021GL096767. https://doi.org/10.1029/2021GL096767\nMPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPIâ€M Earth System Model version 1.2 (MPIâ€ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400" +#\nMueller, W.A. et al. (2018): A highâ€resolution version of the Max Planck Institute Earth System Model MPIâ€ESM1.2â€HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217" +SOURCE="MPI-ESM1.2-CR (2017): \naerosol: none, prescribed Kinne (2010)\natmos: ECHAM6.3 (spectral T31; 96 x 48 longitude/latitude; 31 levels; top level 10 hPa)\natmosChem: unnamed (accelerated methane chemistry)\nland: JSBACH3.20, River Transport Model\nlandIce: none, prescribed\nocean: MPIOM1.63 (bipolar GR3.0, approximately 300km; 122 x 101 longitude/latitude; 40 levels; top grid cell 0-15 m)\nocnBgchem: none, prescribed\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\nsolidLand: none, prescribed" +SOURCE_TYPE="AOGCM CHEM" +#CALENDAR=proleptic_gregorian +#MAPPING_TABLE_DIR=cmip6_mapping_tables +#MAPPING_TABLE=MPIESM1_CMIP6.txt +#GRID_FILE_DIR=__GRID_FILE_DIR +#GRID_FILE=__GRID_FILE +GRID=gn +GRID_LABEL=gn +#NOMINAL_RESOLUTION read from external file +#For MPIOM/HAMOCC CR / GR30 +#NOMINAL_RESOLUTION="500 km" +#For ECHAM6/JSBACH CR / T31 +#NOMINAL_RESOLUTION="500 km" +# +CHAR_AXIS_VEGTYPE=bare_land,glacier,tropical_evergreen_trees,tropical_deciduous_trees,extra-tropical_evergreen_trees,extra-tropical_deciduous_trees,raingreen_shrubs,deciduous_shrubs,C3_grass,C4_grass,C3_pasture,C4_pasture,C3_crops,C4_crops +CHAR_AXIS_SOILPOOLS=acid-soluble_below_ground_leaf_litter,acid-soluble_below_ground_woody_litter,water-soluble_below_ground_leaf_litter,water-soluble_below_ground_woody_litter,ethanol-soluble_below_ground_leaf_litter,ethanol-soluble_below_ground_woody_litter,non-soluble_below_ground_leaf_litter,non-soluble_below_ground_woody_litter,humus_from_leaf_litter,humus_from_woody_litter +CHAR_AXIS_LANDUSE=primary_and_secondary_land,crops,pastures,urban +CHAR_AXIS_BASIN=global_ocean,atlantic_arctic_ocean,indian_pacific_ocean +CHAR_AXIS_OLINE=barents_opening,bering_strait,canadian_archipelago,denmark_strait,drake_passage,english_channel,pacific_equatorial_undercurrent,faroe_scotland_channel,florida_bahamas_strait,fram_strait,iceland_faroe_channel,indonesian_throughflow,mozambique_channel,taiwan_luzon_straits,windward_passage +CHAR_AXIS_SILINE=barents_opening,bering_strait,canadian_archipelago,fram_strait +#spectband for the 3 aeropt variables +CHAR_AXIS_SPECTBAND_aeroptbnd=1818182 +CHAR_AXIS_SPECTBAND_aeroptbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aeroptbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_aerssabnd=1818182 +CHAR_AXIS_SPECTBAND_aerssabnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aerssabnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_aerasymbnd=1818182 +CHAR_AXIS_SPECTBAND_aerasymbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_aerasymbnd_UNITS="m-1" +# 2d-spectband for the albedos +CHAR_AXIS_SPECTBAND_albdirbnd=3225689,766690 +CHAR_AXIS_SPECTBAND_albdirbnd_BOUNDS=5000000,1451379,1451379,82001 +CHAR_AXIS_SPECTBAND_albdirbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_albdiffbnd=3225689,766690 +CHAR_AXIS_SPECTBAND_albdiffbnd_BOUNDS=5000000,1451379,1451379,82001 +CHAR_AXIS_SPECTBAND_albdiffbnd_UNITS="m-1" +CHAR_AXIS_SPECTBAND_solbnd=1818182 +CHAR_AXIS_SPECTBAND_solbnd_BOUNDS=2262443,1600000 +CHAR_AXIS_SPECTBAND_solbnd_UNITS="m-1" +# PalMod +CHAR_AXIS_TYPELICE="ice sheet","ice shelf","ocean","ice-free land" +#T_AXIS="cmip" causes the time axis to be rewritten according to the requested time stamps +T_AXIS="cmip" +#OUTPUT_MODE="r" +OUTPUT_MODE="a" +MAX_SIZE=0 +SAVE_CHUNK="n" +#For files without time axis, if one is requested: +#firsttimeval=1 (1850-01-02 00:00:00 wenn days since 1850-01-01 00:00:00) +FIRSTTIMEVAL=1 +# +# institution and contact info: +# +# none of these can be set in the command line +# +DEFLATE_LEVEL=1 +CONTACT=palmod2-mpi-esm@dkrz.de +# +# MPI-M +# +INSTITUTION_ID=MPI-M +INSTITUTION="Max Planck Institute for Meteorology, Hamburg 20146, Germany" +LICENSE="PalMod2 model data produced by MPI-M is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law." +#MIP_TABLE_DIR="/pool/data/CMIP6/cmip6-cmor-tables/Tables/" +MIP_TABLE_DIR="/work/bm0021/PalMod2/cmor_tables/" diff --git a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d-methane_r1i1p1f1-CR_cdocmorinfo b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d-methane_r1i1p1f1-CR_cdocmorinfo index 95c401601d20c90e71c7cdfa96b293e6f339bc47..92c96fab2b50ee07352c426bc075ff1130ebfea1 100644 --- a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d-methane_r1i1p1f1-CR_cdocmorinfo +++ b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d-methane_r1i1p1f1-CR_cdocmorinfo @@ -43,8 +43,8 @@ SUB_EXPERIMENT=none # SOURCE_ID=MPI-ESM1-2-CR-CH4 #MODEL_ID=MPI-ESM1-2-CR-CH4 -REFERENCES="Kleinen, T., Mikolajewicz, U. and Brovkin, V. (2020). Terrestrial methane emissions from the Last Glacial Maximum to the preindustrial period. Climate of the Past, 16(2):575–595. doi: 10.5194/cp-16-575-2020.\nKleinen, T., Gromov, S., Steil, B. and Brovkin, V. (2021). Atmospheric methane underestimated in future climate projections. Environmental Research Letters, 16(9):094006. doi: 10.1088/1748-9326/ac1814.\nKapsch, M.-L., Mikolajewicz, U., Ziemen, F., & Schannwell, C. (2022). Ocean response in transient simulations of the last deglaciation dominated by underlying ice-sheet reconstruction and method of meltwater distribution. Geophysical Research Letters, 49, e2021GL096767. https://doi.org/10.1029/2021GL096767\nMPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPIâ€M Earth System Model version 1.2 (MPIâ€ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400" -#,\nMueller, W.A. et al. (2018): A highâ€resolution version of the Max Planck Institute Earth System Model MPIâ€ESM1.2â€HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217" +REFERENCES="Kleinen, T., Mikolajewicz, U. and Brovkin, V. (2020). Terrestrial methane emissions from the Last Glacial Maximum to the preindustrial period. Climate of the Past, 16(2):575–595. doi: 10.5194/cp-16-575-2020\nKleinen, T., Gromov, S., Steil, B. and Brovkin, V. (2021). Atmospheric methane underestimated in future climate projections. Environmental Research Letters, 16(9):094006. doi: 10.1088/1748-9326/ac1814\nKapsch, M.-L., Mikolajewicz, U., Ziemen, F., & Schannwell, C. (2022). Ocean response in transient simulations of the last deglaciation dominated by underlying ice-sheet reconstruction and method of meltwater distribution. Geophysical Research Letters, 49, e2021GL096767. https://doi.org/10.1029/2021GL096767\nMPI-ESM: Mauritsen, T. et al. (2019), Developments in the MPIâ€M Earth System Model version 1.2 (MPIâ€ESM1.2) and Its Response to Increasing CO2, J. Adv. Model. Earth Syst.,11, 998-1038, doi:10.1029/2018MS001400" +#\nMueller, W.A. et al. (2018): A highâ€resolution version of the Max Planck Institute Earth System Model MPIâ€ESM1.2â€HR. J. Adv. Model. EarthSyst.,10,1383–1413, doi:10.1029/2017MS001217" SOURCE="MPI-ESM1.2-CR (2017): \naerosol: none, prescribed Kinne (2010)\natmos: ECHAM6.3 (spectral T31; 96 x 48 longitude/latitude; 31 levels; top level 10 hPa)\natmosChem: unnamed (accelerated methane chemistry)\nland: JSBACH3.20, River Transport Model\nlandIce: none, prescribed\nocean: MPIOM1.63 (bipolar GR3.0, approximately 300km; 122 x 101 longitude/latitude; 40 levels; top grid cell 0-15 m)\nocnBgchem: none, prescribed\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\nsolidLand: none, prescribed" SOURCE_TYPE="AOGCM CHEM" #CALENDAR=proleptic_gregorian diff --git a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p1f1-CR.runpp b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p1f1-CR.runpp index 996f9f71d703d664d436c544a63673f92cf0842a..ae50e058c0255cc00be994a5cb2fb87f1484716e 100755 --- a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p1f1-CR.runpp +++ b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p1f1-CR.runpp @@ -44,7 +44,7 @@ alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted #Root directory of all scripts, outdata, logs etc EXP_ID=transient-deglaciation-prescribed-glac1d_r1i1p1f1-CR -EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_errataBatch/transient-deglaciation-prescribed-glac1d_r1i1p1f1-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_MK/transient-deglaciation-prescribed-glac1d_r1i1p1f1-CR #initial files for aggregation INPUT_DIR_TRUNK=/work/mh0110/m211003/mpiesm-1.2.00p1/experiments diff --git a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p2f2-CR.runpp b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p2f2-CR.runpp index 4d10d546f99737ecaba9ac1cade42068e9a7590b..4bf429de9dc34b9ed752702306520329768c4efd 100755 --- a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p2f2-CR.runpp +++ b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p2f2-CR.runpp @@ -44,7 +44,7 @@ alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted #Root directory of all scripts, outdata, logs etc EXP_ID=transient-deglaciation-prescribed-glac1d_r1i1p2f2-CR -EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_errataBatch/transient-deglaciation-prescribed-glac1d_r1i1p2f2-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_MK/transient-deglaciation-prescribed-glac1d_r1i1p2f2-CR #initial files for aggregation INPUT_DIR_TRUNK=/work/mh0110/m211003/mpiesm-1.2.00p1/experiments diff --git a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p3f2-CR.runpp b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p3f2-CR.runpp index 4f2f0c3e4aa01dcfc323a0e87c3ed3bd2f1a7ec3..0a435a7cb4170be381d081428d4290d43df3d759 100755 --- a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p3f2-CR.runpp +++ b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-glac1d_r1i1p3f2-CR.runpp @@ -44,7 +44,7 @@ alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted #Root directory of all scripts, outdata, logs etc EXP_ID=transient-deglaciation-prescribed-glac1d_r1i1p3f2-CR -EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_errataBatch/transient-deglaciation-prescribed-glac1d_r1i1p3f2-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_MK/transient-deglaciation-prescribed-glac1d_r1i1p3f2-CR #initial files for aggregation INPUT_DIR_TRUNK=/work/mh0110/m211003/mpiesm-1.2.00p1/experiments diff --git a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p1f1-CR.runpp b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p1f1-CR.runpp index 0126e5bbbcd3716f8e20f9fdede336978ef6a165..84273e9273445c91c4e4bd08587dc563172ba832 100755 --- a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p1f1-CR.runpp +++ b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p1f1-CR.runpp @@ -44,7 +44,7 @@ alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted #Root directory of all scripts, outdata, logs etc EXP_ID=transient-deglaciation-prescribed-ice6g_r1i1p1f1-CR -EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_errataBatch/transient-deglaciation-prescribed-ice6g_r1i1p1f1-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_MK/transient-deglaciation-prescribed-ice6g_r1i1p1f1-CR #initial files for aggregation INPUT_DIR_TRUNK=/work/mh0110/m211003/mpiesm-1.2.00p1/experiments diff --git a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p2f2-CR.runpp b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p2f2-CR.runpp index 5a3b0947f1c66fa915d9aa92f0b787105d542dbf..28cd595a9bebd68108607bc5f65b158bc835adcb 100755 --- a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p2f2-CR.runpp +++ b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p2f2-CR.runpp @@ -44,7 +44,7 @@ alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted #Root directory of all scripts, outdata, logs etc EXP_ID=transient-deglaciation-prescribed-ice6g_r1i1p2f2-CR -EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_errataBatch/transient-deglaciation-prescribed-ice6g_r1i1p2f2-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_MK/transient-deglaciation-prescribed-ice6g_r1i1p2f2-CR #initial files for aggregation INPUT_DIR_TRUNK=/work/mh0110/m211003/mpiesm-1.2.00p1/experiments diff --git a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p3f2-CR.runpp b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p3f2-CR.runpp index f0edf3cf558bf513903d9c469831cc5317ae3027..780a455b1897af60f4a2b9996cb1b68e4a4e9294 100755 --- a/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p3f2-CR.runpp +++ b/cmor/mpiesm/scripts/transient-deglaciation-prescribed-ice6g_r1i1p3f2-CR.runpp @@ -44,7 +44,7 @@ alias ncatted=/sw/spack-levante/nco-5.0.6-3xkdth/bin/ncatted #Root directory of all scripts, outdata, logs etc EXP_ID=transient-deglaciation-prescribed-ice6g_r1i1p3f2-CR -EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_errataBatch/transient-deglaciation-prescribed-ice6g_r1i1p3f2-CR +EXP_DIR_TRUNK=/work/kd1292/k204212/palmod_MK/transient-deglaciation-prescribed-ice6g_r1i1p3f2-CR #initial files for aggregation INPUT_DIR_TRUNK=/work/mh0110/m211003/mpiesm-1.2.00p1/experiments