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

Last change on this file since 2198 was 2198, checked in by aclsce, 10 years ago

Modifications to use Oasis-MCT coupler.
Modifications to use namelist*cfg for NEMO components.

File size: 3.9 KB
Line 
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
13# Local function to find parameters in LMDZ .def files
14
15lmdzgrep () {
16    grep $1 $2 |grep -v "#" | awk "-F=" '{print $2}'
17}
18
19    ##--Variables used by MBG --
20
21    # ln_rsttr  boolean term for tracer model restart (true or false)
22    # nrsttr    control of the time step (0, 1 or 2)
23   
24    ##--Variables used by PISCES --
25 
26    NAMELIST_TOP_CFG=${SUBMIT_DIR}/PARAM/namelist_top_${RESOL_OCE}_cfg
27    NAMELIST_PISCES_CFG=${SUBMIT_DIR}/PARAM/namelist_pisces_${RESOL_OCE}_cfg
28
29    PAT_TOP_LRSTTR=$( supergrep ln_rsttr          ${NAMELIST_TOP_CFG} )
30    PAT_TOP_NRSTTR=$( supergrep nrsttr            ${NAMELIST_TOP_CFG} )
31    PAT_PIS_ATCCO2=$( supergrep atcco2            ${NAMELIST_PISCES_CFG} )
32    PAT_PIS_LRIVER=$( supergrep ln_river          ${NAMELIST_PISCES_CFG} )
33
34    IGCM_debug_PopStack "MBG_Initialize"
35}
36
37#-----------------------------------
38function MBG_Update
39{
40    IGCM_debug_PushStack "MBG_Update"
41
42    ##-- Restart configuration
43    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
44
45        #echo "NO RESTART FOR TOP"
46        TOP_LRSTTR=.FALSE.
47        TOP_NRSTTR=0
48
49        PISCES_LRIVER=.FALSE.
50
51    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
52
53        #echo "RESTART TOP"
54        TOP_LRSTTR=.TRUE.
55        TOP_NRSTTR=0
56
57        PISCES_LRIVER=.TRUE.
58
59    else
60
61        #echo "RESTART TOP"
62        TOP_LRSTTR=.TRUE.
63        TOP_NRSTTR=2
64
65        PISCES_LRIVER=.TRUE.
66
67    fi
68
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
78    echo 'Informations into iodef.xml : DBIO_ENABLE'
79    echo ${DBIO_ENABLE}
80
81    sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \
82        iodef.xml > iodef.xml.tmp
83
84    IGCM_sys_Mv iodef.xml.tmp iodef.xml
85
86    ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg
87    if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then
88        # Special case for carbon cycle
89        # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices
90        echo 'Update atcco2 in namelist_pisces_cfg with value from file co2.log'
91        PathCO2log=${SUBMIT_DIR}
92        PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
93        IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
94        sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${IPCC_PIS_CO2}%"             \
95            namelist_pisces_cfg > namelist_pisces_cfg.tmp
96        IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
97    else
98        # Take same CO2 as for LMDZ, in parameter file config.def.
99        # ATM_Update is done before MBG_Update and therefor config.def file contains the correct value for CO2.
100        echo 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ'
101        LMDZ_CO2=$( lmdzgrep co2_ppm config.def )
102        sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${LMDZ_CO2}%"             \
103            namelist_pisces_cfg > namelist_pisces_cfg.tmp
104        IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
105    fi
106
107    ##-- Update namelist_top_cfg and namelist_pisces_cfg
108
109    sed -e "s%${PAT_TOP_LRSTTR}%          ln_rsttr=${TOP_LRSTTR}%"                   \
110        -e "s%${PAT_TOP_NRSTTR}%          nrsttr=${TOP_NRSTTR}%"                   \
111        namelist_top_cfg > namelist_top_cfg.tmp
112
113    IGCM_sys_Mv namelist_top_cfg.tmp namelist_top_cfg
114
115    sed -e "s%${PAT_PIS_LRIVER}%          ln_river=${PISCES_LRIVER}%"                \
116        namelist_pisces_cfg > namelist_pisces_cfg.tmp
117
118    IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
119
120
121    IGCM_debug_PopStack "MBG_Update"
122}
123
124#-----------------------------------
125function MBG_Finalize
126{
127    IGCM_debug_PushStack "MBG_Finalize"
128
129    echo FINALIZE MBG !!!
130
131    IGCM_debug_PopStack "MBG_Finalize"
132}
133
Note: See TracBrowser for help on using the repository browser.