#!/bin/ksh
#-----------------------------------------------------------------
function ATM_Initialize
{
IGCM_debug_PushStack "ATM_Initialize"
##- Horizontal resolution read from dynamicolmdz.card
if [ ! X${dynamicolmdz_UserChoices_RESOL_NBP} = X ] ; then
RESOL_NBP=${dynamicolmdz_UserChoices_RESOL_NBP}
else
# Set default resolution
RESOL_NBP=20
fi
##- Horizontal resolution read from dynamicolmdz.card
if [ ! X${dynamicolmdz_UserChoices_RESOL_LLM} = X ] ; then
RESOL_LLM=${dynamicolmdz_UserChoices_RESOL_LLM}
else
# Set default resolution
RESOL_LLM=79
fi
##- LMDZ physics version
## Read LMDZ_Physics option in lmdz.card, if not present take default value NPv6.1.3
if [ ! X${dynamicolmdz_UserChoices_LMDZ_Physics} = X ] ; then
LMDZ_Physics=${dynamicolmdz_UserChoices_LMDZ_Physics}
else
LMDZ_Physics=NPv6.0.11
fi
echo LMDZ physics version : ${LMDZ_Physics}
IGCM_debug_PopStack "ATM_Initialize"
}
#-----------------------------------------------------------------
function ATM_Update
{
IGCM_debug_PushStack "ATM_Update"
##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
if [ ${CumulPeriod} -eq 1 ] ; then
IGCM_comp_modifyDefFile blocker run.def raz_date 1
else
IGCM_comp_modifyDefFile blocker run.def raz_date 0
fi
##-- Calendar type for LMDZ and create_etat0_limit
case ${config_UserChoices_CalendarType} in
leap|gregorian)
IGCM_comp_modifyDefFile blocker run.def calend gregorian ;;
noleap)
IGCM_comp_modifyDefFile blocker run.def calend earth_365d ;;
360d)
IGCM_comp_modifyDefFile blocker run.def calend earth_360d ;;
*)
IGCM_comp_modifyDefFile blocker run.def calend earth_360d ;;
esac
IGCM_comp_modifyDefFile blocker run.def dayref ${InitDay}
IGCM_comp_modifyDefFile blocker run.def anneeref ${InitYear}
IGCM_comp_modifyDefFile blocker run_icosa.def run_length $(( ${PeriodLengthInDays} * 86400 ))
if [ X${RESOL_NBP} == X40 ] || [ X${RESOL_NBP} == X20 ]; then
IGCM_comp_modifyDefFile nonblocker run_icosa.def nbp ${RESOL_NBP}
IGCM_comp_modifyDefFile nonblocker run_icosa.def nsplit_i $(( ${RESOL_NBP} / 10 ))
IGCM_comp_modifyDefFile nonblocker run_icosa.def nsplit_j $(( ${RESOL_NBP} / 10 ))
IGCM_comp_modifyDefFile nonblocker run_icosa.def llm 79
IGCM_debug_Print 1 "Maximum nubmer of MPI for resolution nbp=${RESOL_NBP} is $(( ${RESOL_NBP} * ${RESOL_NBP} / 10 ))"
else
IGCM_debug_Print 1 "nbp=${RESOL_NBP} is set in dynamicolmdz.card"
IGCM_debug_Exit "This resolution has not been prepared in dynamicolmdz.driver"
IGCM_debug_Verif_Exit
fi
if [ X${dynamicolmdz_UserChoices_Aquaplanet} == Xy ] ; then
IGCM_comp_modifyDefFile nonblocker earth_const.def solarlong0 1000.0
IGCM_comp_modifyDefFile nonblocker config.def R_ecc 0
IGCM_comp_modifyDefFile nonblocker config.def read_climoz -1
IGCM_comp_modifyDefFile nonblocker run_icosa.def etat0 held_suarez
else
IGCM_comp_modifyDefFile nonblocker earth_const.def solarlong0 -9999.999
IGCM_comp_modifyDefFile nonblocker config.def R_ecc 0.016715
IGCM_comp_modifyDefFile nonblocker config.def read_climoz 1
# IGCM_comp_modifyDefFile nonblocker run_icosa.def etat0 database
IGCM_comp_modifyDefFile nonblocker run_icosa.def etat0 start_file
fi
# Add include of context xml files for LMDZ and DYNAMICO in iodef.xml
# In iodef.xml add on the next line after "COMPONENT CONTEXT"
echo '' > add.tmp
echo '' >> add.tmp
# Add inclusion of file context_input_lmdz.xml if this file exists
if [ -f context_input_lmdz.xml ] ; then
echo '' >> add.tmp
fi
# 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
echo '' >> add.tmp
echo '' >> add.tmp
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*lmdz.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
# Do modifications for LMDZ output according to settings in dynamicolmdz.card
if [ ! X${dynamicolmdz_UserChoices_output_histmth_lmdz} = X ]; then
IGCM_comp_modifyXmlFile nonblocker file_def_histmth_lmdz.xml histmth enabled ${dynamicolmdz_UserChoices_output_histmth_lmdz}
else
IGCM_comp_modifyXmlFile nonblocker file_def_histmth_lmdz.xml histmth enabled FALSE
fi
if [ ! X${dynamicolmdz_UserChoices_output_histday_lmdz} = X ]; then
IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday enabled ${dynamicolmdz_UserChoices_output_histday_lmdz}
else
IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday enabled FALSE
fi
if [ ! X${dynamicolmdz_UserChoices_output_histhf_lmdz} = X ]; then
IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf enabled ${dynamicolmdz_UserChoices_output_histhf_lmdz}
else
IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf enabled FALSE
fi
if [ ! X${dynamicolmdz_UserChoices_output_histmthNMC_lmdz} = X ]; then
IGCM_comp_modifyXmlFile nonblocker file_def_histmthNMC_lmdz.xml histmthNMC enabled ${dynamicolmdz_UserChoices_output_histmthNMC_lmdz}
else
IGCM_comp_modifyXmlFile nonblocker file_def_histmthNMC_lmdz.xml histmthNMC enabled FALSE
fi
if [ ! X${dynamicolmdz_UserChoices_output_histdayNMC_lmdz} = X ]; then
IGCM_comp_modifyXmlFile nonblocker file_def_histdayNMC_lmdz.xml histdayNMC enabled ${dynamicolmdz_UserChoices_output_histdayNMC_lmdz}
else
IGCM_comp_modifyXmlFile nonblocker file_def_histdayNMC_lmdz.xml histdayNMC enabled FALSE
fi
if [ ! X${dynamicolmdz_UserChoices_output_histhfNMC_lmdz} = X ]; then
IGCM_comp_modifyXmlFile nonblocker file_def_histhfNMC_lmdz.xml histhfNMC enabled ${dynamicolmdz_UserChoices_output_histhfNMC_lmdz}
else
IGCM_comp_modifyXmlFile nonblocker file_def_histhfNMC_lmdz.xml histhfNMC enabled FALSE
fi
if [ ! X${dynamicolmdz_UserChoices_output_histstn_lmdz} = X ]; then
IGCM_comp_modifyXmlFile nonblocker file_def_histstn_lmdz.xml histstn enabled ${dynamicolmdz_UserChoices_output_histstn_lmdz}
else
IGCM_comp_modifyXmlFile nonblocker file_def_histstn_lmdz.xml histstn enabled FALSE
fi
if [ ! X${dynamicolmdz_UserChoices_output_histstrataer_lmdz} = X ]; then
IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer enabled ${dynamicolmdz_UserChoices_output_histstrataer_lmdz}
else
IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer enabled FALSE
fi
IGCM_debug_PopStack "ATM_Update"
}
#-----------------------------------
function ATM_Finalize
{
IGCM_debug_PushStack "ATM_Finalize"
IGCM_debug_PopStack "ATM_Finalize"
}