source: CONFIG/UNIFORM/v6/IPSLCM6CHT/GENERAL/DRIVER/pisces.driver @ 2456

Last change on this file since 2456 was 2456, checked in by acosce, 6 years ago

Add new configuration IPSLCM6CHT

File size: 4.1 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 nn_rsttr          ${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        # If we start from IPSLCM5* restart files.
60        for file in restart_trc*.nc ; do
61            ncrename -v TRBDSi,TRBGSi -v TRNDSi,TRNGSi -v TRNBSi,TRNDSi -v TRBBSi,TRBDSi ${file} > /dev/null 2>&1
62        done
63
64    else
65
66        #echo "RESTART TOP"
67        TOP_LRSTTR=.TRUE.
68        TOP_NRSTTR=2
69
70        PISCES_LRIVER=.FALSE.
71
72    fi
73
74    ##-- Enable dbio output file
75    DBIO_ENABLE=".FALSE." 
76    eval pisces_DBIO_ENABLE=\${pisces_UserChoices_DBIO_ENABLE} > /dev/null 2>&1
77    if [ "${pisces_DBIO_ENABLE}" = "y" ]; then
78        DBIO_ENABLE=".TRUE."
79    fi
80
81    # update iodef.xml
82
83    echo 'Informations into iodef.xml : DBIO_ENABLE'
84    echo ${DBIO_ENABLE}
85
86    sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \
87        iodef.xml > iodef.xml.tmp
88
89    IGCM_sys_Mv iodef.xml.tmp iodef.xml
90
91    ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg
92    if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then
93        # Special case for carbon cycle
94        # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices
95        echo 'Update atcco2 in namelist_pisces_cfg with value from file co2.log'
96        PathCO2log=${SUBMIT_DIR}
97        PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
98        IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
99        sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${IPCC_PIS_CO2}%"             \
100            namelist_pisces_cfg > namelist_pisces_cfg.tmp
101        IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
102    else
103        # Take same CO2 as for LMDZ, in parameter file config.def.
104        # ATM_Update is done before MBG_Update and therefor config.def file contains the correct value for CO2.
105        echo 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ'
106        LMDZ_CO2=$( lmdzgrep co2_ppm config.def )
107        sed -e "s%${PAT_PIS_ATCCO2}%          atcco2=${LMDZ_CO2}%"             \
108            namelist_pisces_cfg > namelist_pisces_cfg.tmp
109        IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
110    fi
111
112    ##-- Update namelist_top_cfg and namelist_pisces_cfg
113
114    sed -e "s%${PAT_TOP_LRSTTR}%          ln_rsttr=${TOP_LRSTTR}%"                   \
115        -e "s%${PAT_TOP_NRSTTR}%          nn_rsttr=${TOP_NRSTTR}%"                   \
116        namelist_top_cfg > namelist_top_cfg.tmp
117
118    IGCM_sys_Mv namelist_top_cfg.tmp namelist_top_cfg
119
120    sed -e "s%${PAT_PIS_LRIVER}%          ln_river=${PISCES_LRIVER}%"                \
121        namelist_pisces_cfg > namelist_pisces_cfg.tmp
122
123    IGCM_sys_Mv namelist_pisces_cfg.tmp namelist_pisces_cfg
124
125
126    IGCM_debug_PopStack "MBG_Update"
127}
128
129#-----------------------------------
130function MBG_Finalize
131{
132    IGCM_debug_PushStack "MBG_Finalize"
133
134    echo FINALIZE MBG !!!
135
136    IGCM_debug_PopStack "MBG_Finalize"
137}
138
Note: See TracBrowser for help on using the repository browser.