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

Last change on this file since 2839 was 2839, checked in by cetlod, 6 years ago

Use the IGCM_comp_modifyNamelist function for PISCES parameters

File size: 3.2 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
15lmdzgrep2 () {
16     grep ${1} ${2} | grep -v "#"  | sed -e 's/=//g' -e 's/://g' -e 's/_AUTO_//' -e 's/DEFAULT//' | sed -e "s/${1}//" 
17}
18
19    IGCM_debug_PopStack "MBG_Initialize"
20}
21
22#-----------------------------------
23function MBG_Update
24{
25    IGCM_debug_PushStack "MBG_Update"
26
27    ##-- Restart configuration
28    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
29
30        #echo "NO RESTART FOR TOP"
31        TOP_LRSTTR=.FALSE.
32        TOP_NRSTTR=0
33
34    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
35
36        #echo "RESTART TOP"
37        TOP_LRSTTR=.TRUE.
38        TOP_NRSTTR=0
39
40        # If we start from IPSLCM5* restart files.
41        for file in restart_trc*.nc ; do
42            ncrename -v TRBDSi,TRBGSi -v TRNDSi,TRNGSi -v TRNBSi,TRNDSi -v TRBBSi,TRBDSi ${file} > /dev/null 2>&1
43        done
44
45    else
46
47        #echo "RESTART TOP"
48        TOP_LRSTTR=.TRUE.
49        TOP_NRSTTR=2
50
51    fi
52
53    ##-- Enable dbio output file
54    DBIO_ENABLE=".FALSE." 
55    eval pisces_DBIO_ENABLE=\${pisces_UserChoices_DBIO_ENABLE} > /dev/null 2>&1
56    if [ "${pisces_DBIO_ENABLE}" = "y" ]; then
57        DBIO_ENABLE=".TRUE."
58    fi
59
60    # update iodef.xml
61
62    IGCM_debug_Print 1 " 'Informations into iodef.xml : DBIO_ENABLE : ${DBIO_ENABLE}"
63
64    sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \
65        iodef.xml > iodef.xml.tmp
66
67    IGCM_sys_Mv iodef.xml.tmp iodef.xml
68
69    ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg
70    if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then
71        IGCM_debug_Print 1 "Special case for carbon cycle"
72        # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices
73        IGCM_debug_Print 1  'Update atcco2 in namelist_pisces_cfg with value from file co2.log'
74        PathCO2log=${SUBMIT_DIR}
75        PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
76        IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
77        IGCM_debug_Print 1 "IPCC_PIS_CO2 : ${IPCC_PIS_CO2} "
78        IGCM_comp_modifyNamelist nonblocker    namelist_pisces_cfg atcco2 ${IPCC_PIS_CO2} 
79    else
80        IGCM_debug_Print 1 "Take same CO2 as for LMDZ, in parameter file config.def."
81        # ATM_Update is done before MBG_Update and therefor config.def file contains the correct value for CO2.
82        IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ'
83        LMDZ_CO2=$( lmdzgrep2 co2_ppm config.def )
84        IGCM_debug_Print 1 "LMDZ_CO2 : ${LMDZ_CO2} "
85        IGCM_comp_modifyNamelist nonblocker    namelist_pisces_cfg atcco2 ${LMDZ_CO2} 
86    fi
87
88    ##-- Update namelist_top_cfg and namelist_pisces_cfg
89   IGCM_comp_modifyNamelist blocker    namelist_top_cfg ln_rsttr  ${TOP_LRSTTR}
90   IGCM_comp_modifyNamelist blocker    namelist_top_cfg nn_rsttr  ${TOP_NRSTTR}
91
92   IGCM_debug_PopStack "MBG_Update"
93}
94
95#-----------------------------------
96function MBG_Finalize
97{
98    IGCM_debug_PushStack "MBG_Finalize"
99
100    echo FINALIZE MBG !!!
101
102    IGCM_debug_PopStack "MBG_Finalize"
103}
104
Note: See TracBrowser for help on using the repository browser.