source: CONFIG/UNIFORM/v5/IPSLCM5_v5/GENERAL/DRIVER/pisces.driver @ 1785

Last change on this file since 1785 was 1785, checked in by aclsce, 12 years ago

Moved lmdzgrep function from *_update function to *_initialize function
for oasis and pisces component (because of bad behaviour on SX9).

File size: 3.8 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    PAT_TOP_LRSTTR=$( supergrep ln_rsttr          ${SUBMIT_DIR}/PARAM/namelist_top_${RESOL_OCE} )
27    PAT_TOP_NRSTTR=$( supergrep nrsttr            ${SUBMIT_DIR}/PARAM/namelist_top_${RESOL_OCE} )
28    PAT_PIS_ATCCO2=$( supergrep atcco2            ${SUBMIT_DIR}/PARAM/namelist_pisces_${RESOL_OCE} )
29    PAT_PIS_LRIVER=$( supergrep ln_river          ${SUBMIT_DIR}/PARAM/namelist_pisces_${RESOL_OCE} )
30
31    IGCM_debug_PopStack "MBG_Initialize"
32}
33
34#-----------------------------------
35function MBG_Update
36{
37    IGCM_debug_PushStack "MBG_Update"
38
39    ##-- Restart configuration
40    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
41
42        #echo "NO RESTART FOR TOP"
43        TOP_LRSTTR=.FALSE.
44        TOP_NRSTTR=0
45
46        PISCES_LRIVER=.FALSE.
47
48    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
49
50        #echo "RESTART TOP"
51        TOP_LRSTTR=.TRUE.
52        TOP_NRSTTR=0
53
54        PISCES_LRIVER=.TRUE.
55
56    else
57
58        #echo "RESTART TOP"
59        TOP_LRSTTR=.TRUE.
60        TOP_NRSTTR=2
61
62        PISCES_LRIVER=.TRUE.
63
64    fi
65
66    ##-- Enable dbio output file
67    DBIO_ENABLE=".FALSE." 
68    eval pisces_DBIO_ENABLE=\${pisces_UserChoices_DBIO_ENABLE} > /dev/null 2>&1
69    if [ "${pisces_DBIO_ENABLE}" = "y" ]; then
70        DBIO_ENABLE=".TRUE."
71    fi
72
73    # update iodef.xml
74
75    echo 'Informations into iodef.xml : DBIO_ENABLE'
76    echo ${DBIO_ENABLE}
77
78    sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \
79        iodef.xml > iodef.xml.tmp
80
81    IGCM_sys_Mv iodef.xml.tmp iodef.xml
82
83    ##-- CO2 forcing : update atcco2 value in namelist_pisces
84    if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then
85        # Special case for carbon cycle
86        # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices
87        echo 'Update atcco2 in namelist_pisces with value from file co2.log'
88        PathCO2log=${SUBMIT_DIR}
89        PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
90        IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
91        sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${IPCC_PIS_CO2}%"             \
92            namelist_pisces > namelist_pisces.tmp
93        IGCM_sys_Mv namelist_pisces.tmp namelist_pisces
94    else
95        # Take same CO2 as for LMDZ, in parameter file config.def.
96        # ATM_Update is done before MBG_Update and therefor config.def file contains the correct value for CO2.
97        echo 'Update atcco2 in namelist_pisces with same value as for LMDZ'
98        LMDZ_CO2=$( lmdzgrep co2_ppm config.def )
99        sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${LMDZ_CO2}%"             \
100            namelist_pisces > namelist_pisces.tmp
101        IGCM_sys_Mv namelist_pisces.tmp namelist_pisces
102    fi
103
104    ##-- Update namelist_top and namelist_pisces
105
106    sed -e "s%${PAT_TOP_LRSTTR}%          ln_rsttr=${TOP_LRSTTR}%"                   \
107        -e "s%${PAT_TOP_NRSTTR}%          nrsttr=${TOP_NRSTTR}%"                   \
108        namelist_top > namelist_top.tmp
109
110    IGCM_sys_Mv namelist_top.tmp namelist_top
111
112    sed -e "s%${PAT_PIS_LRIVER}%          ln_river=${PISCES_LRIVER}%"                \
113        namelist_pisces > namelist_pisces.tmp
114
115    IGCM_sys_Mv namelist_pisces.tmp namelist_pisces
116
117
118    IGCM_debug_PopStack "MBG_Update"
119}
120
121#-----------------------------------
122function MBG_Finalize
123{
124    IGCM_debug_PushStack "MBG_Finalize"
125
126    echo FINALIZE MBG !!!
127
128    IGCM_debug_PopStack "MBG_Finalize"
129}
130
Note: See TracBrowser for help on using the repository browser.