Skip to content
Snippets Groups Projects
Commit 40fb2fdc authored by Martin Schupfner's avatar Martin Schupfner
Browse files

mpiesm: added scripts for transient-deglaciation-interactive_r1i1p1f1-CR

parent 485d5e20
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
set -ue
module load nco
# Attributes
TITLE="MPI-ESM1-2-1 output prepared for PalMod2"
REFERENCES="The paper ist currently in open discussion under the following citation:\nMikolajewicz, U., Kapsch, M.-L., Schannwell, C., Six, K. D., Ziemen, F. A., Bagge, M., Baudouin, J.-P., Erokhina, O., Gayler, V., Klemann, V., Meccia, V. L., Mouchet, A., and Riddick, T.: Deglaciation and abrupt events in a coupled comprehensive atmosphere–ocean–ice sheet–solid earth model, Clim. Past Discuss. [preprint], https://doi.org/10.5194/cp-2024-55, in review, 2024"
#NOMINAL_RESOLUTION="500 km" # echam6, jsbach, mpiom, hamocc
#NOMINAL_RESOLUTION="km" # vilma
#NOMINAL_RESOLUTION="25 km" # mPISM
SOURCE="MPI-ESM1.2.1-CR (2022): \naerosol: none, prescribed Kinne (2010)\natmos: ECHAM6.3 (spectral T31; 96 x 48 longitude/latitude; 31 levels; top level 10 hPa)\natmosChem: none\nland: JSBACH3.20\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\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\nsolidLand: none/prescribed"
CONVENTIONS="CF-1.7 PalMod-2.0"
CREATION_DATE="2024-09-20T18:00:00Z"
HISTORY="2024-09-20T18:00:00Z ; CMOR rewrote data to be consistent with PalMod2, CF-1.7 PalMod-2.0 and CF standards."
PARENTEXPID="no parent"
declare -A TABLE_INFO
# 00.00.02
#dreqversion="00.00.02"
#TABLE_INFO[Amon]="Creation Date:(14 February 2022) MD5:26bac4b397da7babac4e36561826e6b0"
#TABLE_INFO[Omon]="Creation Date:(14 February 2022) MD5:26bac4b397da7babac4e36561826e6b0"
#TABLE_INFO[Lmon]="Creation Date:(14 February 2022) MD5:26bac4b397da7babac4e36561826e6b0"
#TABLE_INFO[dec]="Creation Date:(14 February 2022) MD5:26bac4b397da7babac4e36561826e6b0"
#TABLE_INFO[fx]="Creation Date:(14 February 2022) MD5:26bac4b397da7babac4e36561826e6b0"
#TABLE_INFO[Ofx]="Creation Date:(14 February 2022) MD5:26bac4b397da7babac4e36561826e6b0"
# 00.00.03
dreqversion="00.00.03"
TABLE_INFO[AERmon]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[Amon]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[centennial]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[dec]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[Emon]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[EmonZ]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[fx]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[IcenAnt]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[IcenGre]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[IdecAnt]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[IdecGre]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[IyrAnt]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[IyrGre]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[LImon]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[Lmon]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[Odec]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[Ofx]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[Omon]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[Oyr]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
TABLE_INFO[SImon]="Creation Date:(1 February 2023) MD5:437d9b7f4524e7483e04d57b09f4aaaa"
# 00.00.04
dreqversion="00.00.04"
TABLE_INFO[AERmon]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[Amon]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[centennial]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[dec]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[Emon]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[EmonZ]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[fx]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[IcenAnt]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[IcenGre]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[IdecAnt]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[IdecGre]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[IyrAnt]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[IyrGre]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[LImon]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[Lmon]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[Odec]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[Ofx]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[Omon]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[Oyr]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[SImon]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
TABLE_INFO[SLdec]="Creation Date:(18 September 2024) MD5:028d52f4a33ef4da346678b341512dda"
#TABLE_INFO[]=
declare -A VARIANT_INFO
VARIANT_INFO["4"]="The data are from a synchronously coupled model simulation of the last deglaciation with the MPI-ESM1.2.1-CR-mPISM-VILMA setup, hence, including interactive ice sheets and solid earth components. The simulation was forced with time-varying volcanic forcing (Schindlbeck-Belo et al., 2024). GHG forcing is after Koehler et al. (2017), Orbit after Berger (1978)."
VARIANT_INFO["1"]="The data are from a synchronously coupled model simulation of the last deglaciation with the MPI-ESM1.2.1-CR-mPISM-VILMA setup, hence, including interactive ice sheets and solid earth components. The simulation used climatological volcanic forcing representing PI. GHG forcing is after Koehler et al. (2017), Orbit after Berger (1978)."
echo "------------------------"
echo $TITLE
echo $REFERENCES
#echo $NOMINAL_RESOLUTION
echo $SOURCE
echo $CONVENTIONS
echo $CREATION_DATE
echo $HISTORY
echo ${TABLE_INFO[@]}
echo "-------------------------"
exp_id=transient-deglaciation-interactive_r1i1p4f2-CR
ifolder=/work/kd1292/ESGF_Buff/k204212/palmod_CS/${exp_id}/PalMod2/
ifiles=($(find $ifolder -type f))
echo ${#ifiles[@]} files found.
i=0
for ifile in ${ifiles[@]}; do
i=$((i+1))
echo $i $ifile
table=$(echo $ifile | rev | cut -d '/' -f 1 | rev | cut -d '_' -f 2)
memberid=$(echo $ifile | rev | cut -d '/' -f 1 | rev | cut -d '_' -f 5)
physics_index=${memberid:5:1}
forcing_index=${memberid:7:1}
realization_index=${memberid:1:1}
init_index=${memberid:3:1}
variantlabel=r${realization_index}i${init_index}p${physics_index}f${forcing_index}
uuid="hdl:21.14105/$(uuidgen)"
# Run ncatted
#ncatted -O -h -a parent_experiment_id,global,m,c,"${PARENTEXPID}" -a variant_info,global,m,c,"${VARIANT_INFO[$physics_index]}" -a history,global,m,c,"$HISTORY" -a creation_date,global,m,c,"$CREATION_DATE" -a physics_index,global,m,c,"$physics_index" -a variant_label,global,m,c,"$memberid" -a table_info,global,m,c,"${TABLE_INFO[$table]}" -a Conventions,global,m,c,"$CONVENTIONS" -a title,global,m,c,"$TITLE" -a references,global,m,c,"$REFERENCES" -a source,global,m,c,"$SOURCE" -a nominal_resolution,global,m,c,"$NOMINAL_RESOLUTION" $ifile || echo "ERROR $ifile"
#ncatted -O -h -a variant_info,global,m,c,"${VARIANT_INFO[$physics_index]}" $ifile || echo "ERROR $ifile"
#ncatted -O -h -a tracking_id,global,m,c,"$uuid" $ifile || echo "ERROR $ifile"
#ncatted -O -h -a parent_experiment_id,global,m,c,"${PARENTEXPID}" -a source,global,m,c,"$SOURCE" -a references,global,m,c,"$REFERENCES" -a variant_info,global,m,c,"${VARIANT_INFO[$physics_index]}" -a table_info,global,m,c,"${TABLE_INFO[$table]}" -a data_specs_version,global,m,c,${dreqversion} -a history,global,m,c,"$HISTORY" -a creation_date,global,m,c,"$CREATION_DATE" -a Conventions,global,m,c,"$CONVENTIONS" -a title,global,m,c,"$TITLE" -a tracking_id,global,m,c,"$uuid" $ifile || echo "ERROR $ifile"
# Adjust filename timestamp
if [[ "$table" != *"fx"* ]]; then
trunk=$(echo $ifile | rev | cut -d '_' -f 2- | rev)
timestamp=$(echo $ifile | rev | cut -d '.' -f 2 | cut -d '_' -f 1 | rev)
time1=$(echo $timestamp | cut -d '-' -f 1 | sed 's/^0*//' )
time2=$(echo $timestamp | cut -d '-' -f 2 | sed 's/^0*//' )
echo $time1 $time2
# Case 1 - Decadal data
if [[ "$table" == *"dec"* ]]; then
if [[ "${time1: -1}" == "6" ]]; then
newtime1=$(printf "%05d" $(expr $time1 - 5))
newtime2=$(printf "%05d" $(expr $time2 + 4))
else
newtime1=$(printf "%05d" ${time1} )
newtime2=$(printf "%05d" ${time2} )
fi
# Case 2 - the rest - annual and monthly data
elif [[ "$table" == *"mon"* ]]; then
newtime1=$(printf "%07d" ${time1} )
newtime2=$(printf "%07d" ${time2} )
elif [[ "$table" == *"yr"* ]]; then
newtime1=$(printf "%05d" ${time1} )
newtime2=$(printf "%05d" ${time2} )
elif [[ "$table" == *"day"* ]]; then
newtime1=$(printf "%09d" ${time1} )
newtime2=$(printf "%09d" ${time2} )
elif [[ "$table" == *"hr"* ]]; then
newtime1=$(printf "%011d" ${time1} )
newtime2=$(printf "%011d" ${time2} )
else
echo "ERROR: ${table}: no timestamp renaming rule!"
continue
fi
# mv command
ifile_new=${trunk}_${newtime1}-${newtime2}.nc
[[ "$ifile" != "$ifile_new" ]] && {
mv -v $ifile $ifile_new || echo "ERROR renaming $ifile to $ifile_new"
}
fi
done
#! /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=4
#initial and final year of the experiment
spinup=1000
iniyeararr=( $((4000+spinup)) 2000 2000 2000 )
finyeararr=( 8999 8999 8999 8999 )
iniyearoffset=1000
iniyear=$(( 1 + $iniyearoffset + $spinup ))
finyear=$(( 26000 + $iniyearoffset - $spinup ))
#offset compared to startyear
inioffsetarr=( $(( -3999 + $iniyearoffset )) $(( 3001 + $iniyearoffset )) $(( 10001 + $iniyearoffset )) $(( 17001 + $iniyearoffset )) )
# Time axis (26000-1 BP)
## exp time total yrs new exp time offset
#a - 26000-21001 BP - 5000 yrs - 1- 5000 - - 3999
#b - 21000-14001 BP - 7000 yrs - 5001-12000 - 3001
#c - 14000- 7001 BP - 7000 yrs - 12001-19000 - 10001
#d - 7000- 1 BP - 7000 yrs - 19001-26000 - 17001
# 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_interactive_synch_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_interactive_synch_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_interactive_synch_r1i1p1f1
}
make -k -j 19 -f transient-deglaciation-interactive_r1i1p1f1-CR.cmor_ctl.mk "$@"
EXP_ID = transient-deglaciation-interactive_r1i1p1f1-CR
ACCOUNT = bm0021
PARTITION = compute
SUFFIX =
ARCHIVE_SUFFIX =
TARGET_STEP=cmor
NUMCHUNKS=$(shell cat cmor_ctl_list_interactive_synch_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_interactive_synch_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_interactive_synch_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_interactive_synch_r1i1p1f1)
@touch $@
#!/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=transient-deglaciation-interactive_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=transient-deglaciation-prescribed-glac1d_r1i1p1f1-CR
#EXP_DIR_TRUNK=/work/bk1192/k204212/palmod_CS/transient-deglaciation-interactive_r1i1p1f1-CR
EXP_DIR_TRUNK=/work/kd1292/ESGF_Buff/k204212/palmod_CS/transient-deglaciation-interactive_r1i1p1f1-CR
#initial files for aggregation
INPUT_DIR_TRUNK=/work/bk1192/WP1.1/MPIM_transient_deglaciation_synchronous
# RAW Data - path and sub-simulations
RAW_EXP_DIR_TRUNK=/work/bk1192/WP1.1/MPIM_transient_deglaciation_synchronous
# As usually the Experiment is composed of several sub-simulations, define them as array
RAW_EXP_IDS=( pmo0007a pmo0007b pmo0007c pmo0007d )
# 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=1000
RAW_EXP_ID_PARENT=( None pmo0007a pmo0007b pmo0007c ) # cmorizing 26000-1 BP as 1-26000 AD
if [[ $spinup -ne 0 ]]; then
RAW_EXP_ID_PARENT[0]=${RAW_EXP_IDS[0]} # cmorizing (26000-spinup)-1 BP as 1-(26000-spinup) AD
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" # surely working version
#cdo="/work/bm0021/cdo_incl_cmor/cdo-2024-09-11_cmor3.9.0_gcc/bin/cdo -v" # latest version
cdozg="/sw/spack-levante/cdo-1.9.10-j5frmz/bin/cdo -v"
# 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
icemod=mpism
slmod=vilma
#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="???0123124"
srfmod_dec_chunk="???0123124"
srfmod_input_dec_chunk="???0123124"
ocemod_dec_chunk="???1123124"
icemod_dec_chunk="???1123124"
slmod_dec_chunk="???1123124"
slmod_input_dec_chunk="???0123124"
ocemod_fxyear=3000
chunks+=([mpism]=" 0 ")
chunks+=([vilma]=" 0 1 ")
chunks+=([vilmadec]=" 0 ")
#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}/transient-deglaciation-interactive_r1i1p1f1-CR_cdocmorinfo"
ca+=([mpiom]="${SCRIPT_ROOT}/cdocmorinfo_mpiom_CR")
ca+=([echam6]="${SCRIPT_ROOT}/cdocmorinfo_echam6_CR")
ca+=([jsbach]="${SCRIPT_ROOT}/cdocmorinfo_jsbach_CR")
ca+=([mpism]="${SCRIPT_ROOT}/cdocmorinfo_mpism_CR")
ca+=([vilma]="${SCRIPT_ROOT}/cdocmorinfo_vilma_CR")
#Experiment etc
experiment=transient-deglaciation-interactive
member=r1i1p1f1
mip=PalMod2
vd=v20240920
#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=($((4000+spinup)) 2000 2000 2000) # 26000-1 BP
finyeararr=(8999 8999 8999 8999)
iniyearoffset=0 # additional optional offset
iniyear=$(( $iniyearoffset + 1 ))
finyear=$(( 26000 + $iniyearoffset - $spinup ))
#offset compared to startyear
inioffsetarr=( $(( -3999 + $iniyearoffset )) $(( 3001 + $iniyearoffset )) $(( 10001 + $iniyearoffset )) $(( 17001 + $iniyearoffset )) ) # 26000-1 BP
# Time axis (26000-1 BP)
## exp time total yrs new exp time offset
#a - 26000-21001 BP - 5000 yrs - 1- 5000 - - 3999
#b - 21000-14001 BP - 7000 yrs - 5001-12000 - 3001
#c - 14000- 7001 BP - 7000 yrs - 12001-19000 - 10001
#d - 7000- 1 BP - 7000 yrs - 19001-26000 - 17001
#pmo0007a-d: Transient simulation of the last deglaciation with interactive ice
#sheets and synchronous coupling between MPI-ESM and the ice sheet-solid earth model.
#GHG forcing is after Koehler et al. (2017), Orbit after Berger (1978).
#They are structured as follows.
#
# pmo0007a: Simulation year 4000-8999 spans the time period 26000
# years BP to 21000 years BP.
# pmo0007b: Simulation years 2000-8999; years 21000 to 14000 BP
# pmo0007c: Simulation years 2000-8999; years 14000 to 7000 BP
# pmo0007d: Simulation years 2000-8999; years 7000 BP to 0 BP
#
# 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}/${RAW_EXP_IDS[$y]} )
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))
#Define Settings for Requested_vars.conf
ism=True # Produce PISM vars
slm=True # Produce vilma vars
#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
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
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%??????}
period_bk=$period
inv_chunk_year=$(( 1 + ${finyear} - ${l_chunk_year##+(0)} ))
print "Aggregation $chunk ($period): Reading forcing/input of year $inv_chunk_year (legacy) $period (latest)"
# 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
if [[ "${iniyeararr[$y]}" == "$period" ]]
then
echo "Reading from parent ${RAW_EXP_ID_PARENT[$y]} jsbach_T31GR30_11tiles_5layers_natural-veg_$period.nc"
input_file_jsbach=$INPUT_DIR_TRUNK/${RAW_EXP_ID_PARENT[$y]}/restart/topo/jsbach_T31GR30_11tiles_5layers_natural-veg_$period.nc
input_file_glac_fx=$INPUT_DIR_TRUNK/${RAW_EXP_ID_PARENT[$y]}/restart/topo/GLAC_$((period+9)).nc
input_file_glac=$INPUT_DIR_TRUNK/${RAW_EXP_ID_PARENT[$y]}/restart/topo/GLAC_$period.nc
input_file_topo=$INPUT_DIR_TRUNK/${RAW_EXP_ID_PARENT[$y]}/restart/topo/TOPO_$period.nc
else
echo "Reading from ${RAW_EXP_IDS[$y]} jsbach_T31GR30_11tiles_5layers_natural-veg_$period.nc"
input_file_jsbach=$INPUT_DIR_TRUNK/${RAW_EXP_IDS[$y]}/restart/topo/jsbach_T31GR30_11tiles_5layers_natural-veg_$period.nc
input_file_glac_fx=$INPUT_DIR_TRUNK/${RAW_EXP_IDS[$y]}/restart/topo/GLAC_$((period+9)).nc
input_file_glac=$INPUT_DIR_TRUNK/${RAW_EXP_IDS[$y]}/restart/topo/GLAC_$period.nc
input_file_topo=$INPUT_DIR_TRUNK/${RAW_EXP_IDS[$y]}/restart/topo/TOPO_$period.nc
fi
# Perform aggregation for each submodel
for submodel in $icemod $slmod $atmmod $ocemod $srfmod; do
if [[ "$submodel" == "$icemod" ]]; then
period=$(( inv_chunk_year - 10 ))
# perform time shift for selected variables
cdochain="-shifttime,-5year -shifttime,${finyear}year" # for decadal time intervals only!
elif [[ "$submodel" == "$slmod" ]]; then
period=$(( inv_chunk_year - 10 ))
# perform no time shift
cdochain=""
echo "--------- $period $period_bk $chunk"
else
period=$period_bk
# perform time shift for selected variables
cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day"
fi
# 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]}/outdata/$submodel
rawsdir_pism_ant=$(echo $rawsdir | rev | cut -d "/" -f 3- | rev)/PISM_ANT
rawsdir_pism_nh=$(echo $rawsdir | rev | cut -d "/" -f 3- | rev)/PISM_NH
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 - PISM requires special treatment
if [[ $submodel == "$icemod" ]]; then
#ln -sf $rawsdir_pism_ant/pism_-$(printf "%06d" $((inv_chunk_year - 10)))/pism_-$(printf "%06d" $((inv_chunk_year - 10))).nc $sdir/pism_ant_${period}.nc
#ln -sf $rawsdir_pism_nh/pism_-$(printf "%06d" $((inv_chunk_year - 10)))/pism_-$(printf "%06d" $((inv_chunk_year - 10))).nc $sdir/pism_nh_${period}.nc
cp -v $rawsdir_pism_ant/pism_-$(printf "%06d" $((inv_chunk_year - 10)))/pism_-$(printf "%06d" $((inv_chunk_year - 10))).nc $sdir/pism_ant_${period}.nc
ncatted -O -h -a scale_factor_at_projection_origin,mapping,o,d,1.0 $sdir/pism_ant_${period}.nc || { echo "ERROR ncatted $sdir/pism_ant_${period}.nc" ; exit 1 ; }
cp -v $rawsdir_pism_nh/pism_-$(printf "%06d" $((inv_chunk_year - 10)))/pism_-$(printf "%06d" $((inv_chunk_year - 10))).nc $sdir/pism_nh_${period}.nc
ncatted -O -h -a ellipsoid,mapping,o,c,WGS84 -a grid_mapping_name,mapping,o,c,polar_stereographic -a false_easting,mapping,o,d,0. -a false_northing,mapping,o,d,0. -a latitude_of_projection_origin,mapping,o,d,90. -a standard_parallel,mapping,o,d,70. -a straight_vertical_longitude_from_pole,mapping,o,d,-45. -a scale_factor_at_projection_origin,mapping,o,d,1.0 $sdir/pism_nh_${period}.nc || { echo "ERROR ncatted $sdir/pism_nh_${period}.nc" ; exit 1 ; }
elif [[ $submodel == "vilma" ]]; then
if [[ "${chunks[${submodel}dec]}" == *" ${period: -1} "* ]]; then
ln -vsf $rawsdir/vilma_-$(printf "%06d" $((inv_chunk_year - 10)))/delta_rsl.nc $sdir/delta_rsl_${period_bk}.nc || echo "ERROR ln -vsf $rawsdir/vilma_-$(printf \"%06d\" $((inv_chunk_year - 10)))/delta_rsl.nc $sdir/delta_rsl_${period_bk}.nc"
fi
else
ln -sf $rawsdir/*_${period}* $sdir/ 2>/dev/null 1>&2 || { echo "ERROR creating links for $period ${RAW_EXP_IDS[$y]} $submodel" && exit 1 ; }
fi
# 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
l_chunk=$(echo $chunk | cut -d "-" -f1)
r_chunk=$(echo $chunk | cut -d "-" -f2)
period_bk=$period
l_chunk_year=${l_chunk%??????}
r_chunk_year=${r_chunk%??????}
inv_chunk_year=$(( 1 + ${finyear} - ${l_chunk_year##+(0)} ))
# 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 $icemod $slmod $atmmod $ocemod $srfmod; do
if [[ "$submodel" == "$icemod" ]]; then
period=$(( inv_chunk_year - 10 ))
# perform time shift for selected variables
cdochain="-shifttime,-5year -shifttime,${finyear}year" # for decadal time intervals only!
elif [[ "$submodel" == "$slmod" ]]; then
period=$period_bk
# create time-axis
cdochain=""
else
period=$period_bk
# perform time shift for selected variables
cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day"
fi
# 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]}/outdata/$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
# 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
l_chunk=$(echo $chunk | cut -d "-" -f1)
r_chunk=$(echo $chunk | cut -d "-" -f2)
period_bk=$period
l_chunk_year=${l_chunk%??????}
r_chunk_year=${r_chunk%??????}
inv_chunk_year=$(( 1 + ${finyear} - ${l_chunk_year##+(0)} ))
# Define decadal interval
dioce="$(( ${period} + ${inioffsetarr[$y]} - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup + 9 ))"
disl=${l_chunk_year##+(0)},$(( ${l_chunk_year##+(0)} + 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 $icemod $slmod $atmmod $ocemod $srfmod; do
if [[ "$submodel" == "$icemod" ]]; then
period=$(( inv_chunk_year - 10 ))
# perform time shift for selected variables
cdochain="-shifttime,-5year -shifttime,${finyear}year" # for decadal time intervals only!
di=${l_chunk_year##+(0)},$(( ${l_chunk_year##+(0)} + 9 ))
elif [[ "$submodel" == "$slmod" ]]; then
period=$(( inv_chunk_year - 10 ))
# create time-axis
cdochain="-shifttime,$((inioffsetarr[$y] - spinup -5 ))year -shifttime,-3day"
di="$(( ${period_bk} + ${inioffsetarr[$y]} - 9 - $spinup )),$(( ${period_bk} + ${inioffsetarr[$y]} - $spinup ))"
else
period=$period_bk
# perform time shift for selected variables
cdochain="-shifttime,$((inioffsetarr[$y] - spinup))year -shifttime,-3day"
di="$(( ${period} + ${inioffsetarr[$y]} - 9 - $spinup )),$(( ${period} + ${inioffsetarr[$y]} - $spinup ))"
fi
# 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]}/outdata/$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_ISM_SLM${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_ISM_SLM${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_AllExp_ISM_SLM$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$
#
# 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-1 output prepared for PalMod2"
_history_template="%s ; CMOR rewrote data to be consistent with <activity_id>, <Conventions> and CF standards."
EXPERIMENT_ID=transient-deglaciation-interactive
EXPERIMENT="synchronously coupled transient deglaciation with interactive ice sheets and solid earth"
#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="The data are from a synchronously coupled model simulation of the last deglaciation with the MPI-ESM1.2.1-CR-mPISM-VILMA setup, hence, including interactive ice sheets and solid earth components. The simulation used climatological volcanic forcing representing PI. GHG forcing is after Koehler et al. (2017), Orbit after Berger (1978)."
COMMENT="Earth viscosity configuration for the solid earth model VILMA. The vertical viscosity structure is piecewise constant for the following specified layers of the earth: (1) 0 to 3.480000e+06 m from earth core: 1.000000e+19 Pa s. (2) 3.480000e+06 to 5.701000e+06 m from earth core: 1.000000e+22 Pa s. (3) 5.701000e+06 to 6.291000e+06 m from earth core: 4.000000e+20 Pa s. (4) 6.291000e+06 to 6.371000e+06 m from earth core: 1.000000e+30 Pa s."
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=19000101,18500101
#BRANCH_METHOD="standard"
#PARENT_MIP_ERA=none #ONLY CMIP6
#PARENT_ACTIVITY_ID=none
#PARENT_EXPERIMENT=none
#cmip6-spinup-HR
#PARENT_EXPERIMENT_ID=none
#PARENT_SOURCE_ID=none
#PARENT_TIME_UNITS="days since 1850-1-1 00:00:00"
#PARENT_VARIANT_LABEL=none
SUB_EXPERIMENT_ID=none
SUB_EXPERIMENT=none
#
#model info:
#
SOURCE_ID=MPI-ESM1-2-1-CR
#MODEL_ID=MPI-ESM1-2-1-CR
REFERENCES="The paper ist currently in open discussion under the following citation:\nMikolajewicz, U., Kapsch, M.-L., Schannwell, C., Six, K. D., Ziemen, F. A., Bagge, M., Baudouin, J.-P., Erokhina, O., Gayler, V., Klemann, V., Meccia, V. L., Mouchet, A., and Riddick, T.: Deglaciation and abrupt events in a coupled comprehensive atmosphere–ocean–ice sheet–solid earth model, Clim. Past Discuss. [preprint], https://doi.org/10.5194/cp-2024-55, in review, 2024"
SOURCE="MPI-ESM1.2.1-CR (2022): \naerosol: none, prescribed Kinne (2010)\natmos: ECHAM6.3 (spectral T31; 96 x 48 longitude/latitude; 31 levels; top level 10 hPa)\natmosChem: none\nland: JSBACH3.20\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\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)\nsolidLand: none/prescribed"
SOURCE_TYPE="AOGCM ISM SLM"
#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_TYPELICE="ice_free_land","ice_sheet","floating_ice","ice_free_sea"
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"
#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/"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment