#!/bin/ksh #----------------------------------- function MBG_Initialize { IGCM_debug_PushStack "MBG_Initialize" # Local function to find namelists parameters supergrep () { grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" } # Local function to find parameters in LMDZ .def files lmdzgrep2 () { grep ${1} ${2} | grep -v "#" | sed -e 's/=//g' -e 's/://g' -e 's/_AUTO_//' -e 's/DEFAULT//' | sed -e "s/${1}//" } ##--Variables used by MBG -- # ln_rsttr boolean term for tracer model restart (true or false) # nrsttr control of the time step (0, 1 or 2) ##--Variables used by PISCES -- NAMELIST_TOP_CFG=${SUBMIT_DIR}/PARAM/namelist_top_${RESOL_OCE}_cfg NAMELIST_PISCES_CFG=${SUBMIT_DIR}/PARAM/namelist_pisces_${RESOL_OCE}_cfg PAT_TOP_LRSTTR=$( supergrep ln_rsttr ${NAMELIST_TOP_CFG} ) PAT_TOP_NRSTTR=$( supergrep nn_rsttr ${NAMELIST_TOP_CFG} ) PAT_PIS_ATCCO2=$( supergrep atcco2 ${NAMELIST_PISCES_CFG} ) IGCM_debug_Print 1 " PAT_PIS_ATCCO2 : ${PAT_PIS_ATCCO2} " IGCM_debug_PopStack "MBG_Initialize" } #----------------------------------- function MBG_Update { IGCM_debug_PushStack "MBG_Update" ##-- Restart configuration if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then #echo "NO RESTART FOR TOP" TOP_LRSTTR=.FALSE. TOP_NRSTTR=0 elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then #echo "RESTART TOP" TOP_LRSTTR=.TRUE. TOP_NRSTTR=0 # If we start from IPSLCM5* restart files. for file in restart_trc*.nc ; do ncrename -v TRBDSi,TRBGSi -v TRNDSi,TRNGSi -v TRNBSi,TRNDSi -v TRBBSi,TRBDSi ${file} > /dev/null 2>&1 done else #echo "RESTART TOP" TOP_LRSTTR=.TRUE. TOP_NRSTTR=2 fi ##-- Enable dbio output file DBIO_ENABLE=".FALSE." eval pisces_DBIO_ENABLE=\${pisces_UserChoices_DBIO_ENABLE} > /dev/null 2>&1 if [ "${pisces_DBIO_ENABLE}" = "y" ]; then DBIO_ENABLE=".TRUE." fi # update iodef.xml IGCM_debug_Print 1 " 'Informations into iodef.xml : DBIO_ENABLE : ${DBIO_ENABLE}" sed -e "s//${DBIO_ENABLE}/" \ iodef.xml > iodef.xml.tmp IGCM_sys_Mv iodef.xml.tmp iodef.xml ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then IGCM_debug_Print 1 "Special case for carbon cycle" # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with value from file co2.log' PathCO2log=${SUBMIT_DIR} PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) IGCM_debug_Print 1 "IPCC_PIS_CO2 : ${IPCC_PIS_CO2} " sed -e "s%${PAT_PIS_ATCCO2}% atcco2=${IPCC_PIS_CO2}%" \ namelist_pisces_cfg > namelist_pisces_cfg.tmp IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg else IGCM_debug_Print 1 "Take same CO2 as for LMDZ, in parameter file config.def." # ATM_Update is done before MBG_Update and therefor config.def file contains the correct value for CO2. IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ' LMDZ_CO2=$( lmdzgrep2 co2_ppm config.def ) IGCM_debug_Print 1 "LMDZ_CO2 : ${LMDZ_CO2} " sed -e "s%${PAT_PIS_ATCCO2}% atcco2=${LMDZ_CO2}%" \ namelist_pisces_cfg > namelist_pisces_cfg.tmp IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg fi ##-- Update namelist_top_cfg and namelist_pisces_cfg sed -e "s%${PAT_TOP_LRSTTR}% ln_rsttr=${TOP_LRSTTR}%" \ -e "s%${PAT_TOP_NRSTTR}% nn_rsttr=${TOP_NRSTTR}%" \ namelist_top_cfg > namelist_top_cfg.tmp IGCM_sys_Mv namelist_top_cfg.tmp namelist_top_cfg IGCM_debug_PopStack "MBG_Update" } #----------------------------------- function MBG_Finalize { IGCM_debug_PushStack "MBG_Finalize" echo FINALIZE MBG !!! IGCM_debug_PopStack "MBG_Finalize" }