#!/bin/ksh
#-----------------------------------------------------------------
function ICO_Initialize
{
IGCM_debug_PushStack "ICO_Initialize"
##- Horizontal resolution read from dynamic.card
if [ ! X${dynamico_UserChoices_RESOL_NBP} = X ] ; then
RESOL_NBP=${dynamico_UserChoices_RESOL_NBP}
else
# Set default resolution
RESOL_NBP=20
fi
##- Horizontal resolution read from dynamico.card
if [ ! X${dynamico_UserChoices_RESOL_ATM_Z} = X ] ; then
RESOL_ATM_Z=${dynamico_UserChoices_RESOL_ATM_Z}
else
# RESOL_ATM_Z is not set in dynamico.card but this is needed
IGCM_debug_Exit "RESOL_ATM_Z must be set in dynamico.card UserSection"
IGCM_debug_Verif_Exit
fi
IGCM_debug_PopStack "ICO_Initialize"
}
#-----------------------------------------------------------------
function ICO_Update
{
IGCM_debug_PushStack "ICO_Update"
IGCM_comp_modifyDefFile blocker run_icosa.def run_length $(( ${PeriodLengthInDays} * 86400 ))
# Change run_dynamico.def according to UserChoices options set in dynmaico.card
# Activate create_etat0_limit
if [ X${dynamico_UserChoices_create_etat0_limit} = Xy ] ; then
# create_etat0_limit is set in dynamcio.card to y
IGCM_comp_modifyDefFile nonblocker run_dynamico.def create_etat0_limit y
# Use iflag_phys=101 or higher to activate aquaplanet mode
if [ X${dynamico_UserChoices_iflag_phys} = X ] || X${dynamico_UserChoices_iflag_phys} = X1 ]; then
# iflag_phys is not set or iflag_phys=1 => run is not an aquaplanet
IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 database
IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys 1
else
# This is an aquaplanet
IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 held_suarez
IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys ${dynamico_UserChoices_iflag_phys}
fi
else
# Deactivate create_etat0_limit
IGCM_comp_modifyDefFile nonblocker run_dynamico.def create_etat0_limit n
IGCM_comp_modifyDefFile nonblocker run_dynamico.def etat0 start_file
# iflag_phys is read but not used when running with DYNAMCIO and create_etat0_limit=n
IGCM_comp_modifyDefFile nonblocker run_dynamico.def iflag_phys 1
fi
# Add include of context xml files for DYNAMICO in iodef.xml
# In iodef.xml add on the next line after "COMPONENT CONTEXT"
echo '' >> add.tmp
# Add inclusion of file context_input_dynamico.xml if this file exists
if [ -f context_input_dynamico.xml ] ; then
echo '' >> add.tmp
fi
# Include xml files for output configuration if running with workflow CMIP6
if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
if [ -f ping_dynamico.xml ] ; then
echo '' >> add.tmp
echo '' >> add.tmp
fi
fi
cp iodef.xml iodef.xml.tmp
sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
rm iodef.xml.tmp add.tmp
# Add a Long Name as global attribute in output files if LongName is set in config.card
if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
listfile=$(ls file_def*dynamico.xml)
echo "${config_UserChoices_LongName}" > add.tmp
for file in ${listfile} ; do
cp ${file} ${file}.tmp
sed -e "/ ${file}
rm ${file}.tmp
done
rm add.tmp
fi
IGCM_debug_PopStack "ICO_Update"
}
#-----------------------------------
function ICO_Finalize
{
IGCM_debug_PushStack "ICO_Finalize"
IGCM_debug_PopStack "ICO_Finalize"
}