#!/bin/ksh

#-----------------------------------
function ICE_Initialize
{ 
    IGCM_debug_PushStack "ICE_Initialize"

    echo INITIALIZE ICE !!!

    IGCM_debug_PopStack "ICE_Initialize"
}

#-----------------------------------
function ICE_Update
{
    IGCM_debug_PushStack "ICE_Update"

    ##--Write Frequency for iomput
    ## Differents frequencies are allowed for ICE files

    VI1D_ENABLE=".FALSE."
    VI5D_ENABLE=".FALSE."
    VI1M_ENABLE=".FALSE."
    VI1Y_ENABLE=".FALSE."

    for frequency in ${config_ICE_WriteFrequency} ; do
        case ${frequency} in
            ( 1D|1d ) VI1D_ENABLE=".TRUE." ;;
            ( 5D|5d ) VI5D_ENABLE=".TRUE." ;;
            ( 1M|1m ) VI1M_ENABLE=".TRUE." ;;
            ( *[yY] ) VI1Y_ENABLE=".TRUE." ;;
        esac
    done


  # Update iodef.xml

    IGCM_debug_Print 1 'Informations into iodef.xml : VI1D_ENABLE VI5D_ENABLE VI1M_ENABLE VI1Y_ENABLE '
    IGCM_debug_Print 1 ${VI1D_ENABLE}  ${VI5D_ENABLE} ${VI1M_ENABLE} ${VI1Y_ENABLE}

    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1d_lim enabled ${VI1D_ENABLE}
    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 5d_lim enabled ${VI5D_ENABLE}
    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1m_lim enabled ${VI1M_ENABLE}
    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1y_lim enabled ${VI1Y_ENABLE}

    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1d_lim output_level ${lim3_UserChoices_OutputLevel}
    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 5d_lim output_level ${lim3_UserChoices_OutputLevel}
    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1m_lim output_level ${lim3_UserChoices_OutputLevel}
    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-lim.xml 1y_lim output_level ${lim3_UserChoices_OutputLevel}


    echo UPDATE ICE !!!

    IGCM_debug_PopStack "ICE_Update"
}

#-----------------------------------
function ICE_Finalize
{
    IGCM_debug_PushStack "ICE_Finalize"

    echo FINALIZE ICE !!!

    IGCM_debug_PopStack "ICE_Finalize"
}
