source: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/pisces.driver @ 2792

Last change on this file since 2792 was 2753, checked in by omamce, 8 years ago

O.M. : gestion des sorties PISCES, gestion du CO2

File size: 4.1 KB
RevLine 
[925]1#!/bin/ksh
2
3#-----------------------------------
4function MBG_Initialize
5{ 
6    IGCM_debug_PushStack "MBG_Initialize"
7
8# Local function to find namelists parameters
9supergrep () {
10    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
11}
12
[1785]13# Local function to find parameters in LMDZ .def files
14
[2753]15lmdzgrep2 () {
16     grep ${1} ${2} | grep -v "#"  | sed -e 's/=//g' -e 's/://g' -e 's/_AUTO_//' -e 's/DEFAULT//' | sed -e "s/${1}//" 
[1785]17}
18
[925]19    ##--Variables used by MBG --
20
[972]21    # ln_rsttr  boolean term for tracer model restart (true or false)
[925]22    # nrsttr    control of the time step (0, 1 or 2)
23   
24    ##--Variables used by PISCES --
25 
[2198]26    NAMELIST_TOP_CFG=${SUBMIT_DIR}/PARAM/namelist_top_${RESOL_OCE}_cfg
27    NAMELIST_PISCES_CFG=${SUBMIT_DIR}/PARAM/namelist_pisces_${RESOL_OCE}_cfg
[925]28
[2198]29    PAT_TOP_LRSTTR=$( supergrep ln_rsttr          ${NAMELIST_TOP_CFG} )
[2221]30    PAT_TOP_NRSTTR=$( supergrep nn_rsttr          ${NAMELIST_TOP_CFG} )
[2198]31    PAT_PIS_ATCCO2=$( supergrep atcco2            ${NAMELIST_PISCES_CFG} )
32
[2753]33    IGCM_debug_Print 1 " PAT_PIS_ATCCO2 : ${PAT_PIS_ATCCO2} "
34
[925]35    IGCM_debug_PopStack "MBG_Initialize"
36}
37
38#-----------------------------------
39function MBG_Update
40{
41    IGCM_debug_PushStack "MBG_Update"
42
43    ##-- Restart configuration
44    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
45
46        #echo "NO RESTART FOR TOP"
47        TOP_LRSTTR=.FALSE.
48        TOP_NRSTTR=0
49
50    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
51
52        #echo "RESTART TOP"
53        TOP_LRSTTR=.TRUE.
54        TOP_NRSTTR=0
55
[2206]56        # If we start from IPSLCM5* restart files.
57        for file in restart_trc*.nc ; do
58            ncrename -v TRBDSi,TRBGSi -v TRNDSi,TRNGSi -v TRNBSi,TRNDSi -v TRBBSi,TRBDSi ${file} > /dev/null 2>&1
59        done
60
[925]61    else
62
63        #echo "RESTART TOP"
64        TOP_LRSTTR=.TRUE.
65        TOP_NRSTTR=2
66
67    fi
68
[1437]69    ##-- Enable dbio output file
70    DBIO_ENABLE=".FALSE." 
71    eval pisces_DBIO_ENABLE=\${pisces_UserChoices_DBIO_ENABLE} > /dev/null 2>&1
72    if [ "${pisces_DBIO_ENABLE}" = "y" ]; then
73        DBIO_ENABLE=".TRUE."
74    fi
75
76    # update iodef.xml
77
[2753]78    IGCM_debug_Print 1 " 'Informations into iodef.xml : DBIO_ENABLE : ${DBIO_ENABLE}"
[1437]79
80    sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \
81        iodef.xml > iodef.xml.tmp
82
83    IGCM_sys_Mv iodef.xml.tmp iodef.xml
84
[2198]85    ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg
[1775]86    if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then
[2753]87        IGCM_debug_Print 1 "Special case for carbon cycle"
[1535]88        # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices
[2753]89        IGCM_debug_Print 1  'Update atcco2 in namelist_pisces_cfg with value from file co2.log'
[1535]90        PathCO2log=${SUBMIT_DIR}
91        PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
92        IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
[2753]93        IGCM_debug_Print 1 "IPCC_PIS_CO2 : ${IPCC_PIS_CO2} "
[1535]94        sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${IPCC_PIS_CO2}%"             \
[2198]95            namelist_pisces_cfg > namelist_pisces_cfg.tmp
96        IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
[1550]97    else
[2753]98        IGCM_debug_Print 1 "Take same CO2 as for LMDZ, in parameter file config.def."
[1550]99        # ATM_Update is done before MBG_Update and therefor config.def file contains the correct value for CO2.
[2753]100        IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ'
101        LMDZ_CO2=$( lmdzgrep2 co2_ppm config.def )
102        IGCM_debug_Print 1 "LMDZ_CO2 : ${LMDZ_CO2} "
[1550]103        sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${LMDZ_CO2}%"             \
[2198]104            namelist_pisces_cfg > namelist_pisces_cfg.tmp
105        IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
[1535]106    fi
107
[2198]108    ##-- Update namelist_top_cfg and namelist_pisces_cfg
[925]109
110    sed -e "s%${PAT_TOP_LRSTTR}%          ln_rsttr=${TOP_LRSTTR}%"                   \
[2221]111        -e "s%${PAT_TOP_NRSTTR}%          nn_rsttr=${TOP_NRSTTR}%"                   \
[2198]112        namelist_top_cfg > namelist_top_cfg.tmp
[925]113
[2198]114    IGCM_sys_Mv namelist_top_cfg.tmp namelist_top_cfg
[925]115
116    IGCM_debug_PopStack "MBG_Update"
117}
118
119#-----------------------------------
120function MBG_Finalize
121{
122    IGCM_debug_PushStack "MBG_Finalize"
123
124    echo FINALIZE MBG !!!
125
126    IGCM_debug_PopStack "MBG_Finalize"
127}
128
Note: See TracBrowser for help on using the repository browser.