source: CONFIG/UNIFORM/u1/LMDZOR_u1/GENERAL/DRIVER/orchidee.driver @ 1692

Last change on this file since 1692 was 1692, checked in by jgipsl, 10 years ago

Changed to _AUTO_ all variables that will be modified by the orchidee.driver or stomate.driver. Added, where missing, "else ORCHIDEE_sed..." to set default values.

File size: 4.0 KB
Line 
1#!/bin/ksh
2
3#D- Driver du script pour ORCHIDEE
4
5function ORCHIDEE_sed
6{
7    IGCM_debug_PushStack "ORCHIDEE_sed"
8   
9    sed -e "s/^${1}\ *=.*/${1}= ${2}/" \
10        orchidee.def > orchidee.def.tmp
11    RET=$?
12    echo "ORCHIDEE_sed : ${1} ${2}"
13    \mv orchidee.def.tmp orchidee.def
14   
15    IGCM_debug_PopStack "ORCHIDEE_sed"
16    return $RET
17}
18
19#-----------------------------------------------------------------
20function SRF_Initialize
21{
22    IGCM_debug_PushStack "SRF_Initialize"
23
24    RESOL_SRF=ALL
25
26    for frequency in ${config_SRF_WriteFrequency} ; do
27        case ${frequency} in
28            HF|hf) SRF_ok_hf=y ;;
29        esac
30    done
31
32    IGCM_debug_PopStack "SRF_Initialize"
33}
34
35#-----------------------------------------------------------------
36function SRF_Update
37{
38    IGCM_debug_PushStack "SRF_Update"
39
40    typeset SECHIBA_WRITE_STEP
41
42    SRF_WriteFrequency=$( echo ${config_SRF_WriteFrequency} | sed -e 's/\([0-9]*[yYmMdDs]\).*/\1/' ) 
43    case ${SRF_WriteFrequency} in
44        *Y|*y) 
45            WriteInYears=$( echo ${SRF_WriteFrequency} | awk -F '[yY]' '{print $1}' )
46            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
47            (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInYears / PeriodLengthInYears * 86400 )) ;;
48        1M)
49            case ${config_UserChoices_PeriodLength} in
50            *Y|*y)
51                SECHIBA_WRITE_STEP=-1.
52                ;;
53            *M|*m)
54                SECHIBA_WRITE_STEP=-1.
55                ;;
56            *)
57                (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
58                ;;
59            esac
60            ;;
61        *M|*m) 
62            WriteInMonths=$( echo ${SRF_WriteFrequency} | awk -F '[mM]' '{print $1}' )
63            case ${config_UserChoices_PeriodLength} in
64            *Y|*y)
65                PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
66                (( SECHIBA_WRITE_STEP = PeriodLengthInDays * 86400 / PeriodLengthInYears / 12  ))
67                ;;
68            *M|*m)
69                PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
70                (( SECHIBA_WRITE_STEP = PeriodLengthInDays * WriteInMonths  * 86400 / PeriodLengthInMonths  ))
71                ;;
72            *)
73                (( SECHIBA_WRITE_STEP = $( IGCM_date_DaysInMonth $year $month ) * 86400 ))
74                ;;
75            esac
76            ;;
77        5D|5d) 
78            (( SECHIBA_WRITE_STEP = 5 * 86400 )) ;;
79        1D|1d) 
80            (( SECHIBA_WRITE_STEP = 86400 )) ;;
81        *s)
82            WriteInSeconds=$( echo ${SRF_WriteFrequency} | awk -F '[s]' '{print $1}' )
83            (( SECHIBA_WRITE_STEP = WriteInSeconds )) ;;
84        *) 
85            IGCM_debug_Exit "SRF_Update " ${SRF_WriteFrequency} " invalid WriteFrequency : choose in 1Y, 1M, 5D, 1D." 
86            IGCM_debug_Verif_Exit ;;
87    esac
88
89    ORCHIDEE_sed HYDROL_CWRR ${orchidee_UserChoices_NEWHYDROL}
90
91    ORCHIDEE_sed WRITE_STEP ${SECHIBA_WRITE_STEP}
92    ORCHIDEE_sed SECHIBA_HISTLEVEL ${orchidee_UserChoices_sechiba_LEVEL}
93
94    # Outputs HF in HISTFILE2 if required
95    if [ X${SRF_ok_hf} = Xy ] ; then
96        ORCHIDEE_sed SECHIBA_HISTFILE2 y
97    else
98        ORCHIDEE_sed SECHIBA_HISTFILE2 n
99    fi
100    ORCHIDEE_sed SECHIBA_HISTLEVEL2 1
101    ORCHIDEE_sed WRITE_STEP2 10800.0
102
103    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
104        ORCHIDEE_sed SECHIBA_restart_in sechiba_rest_in.nc
105    else
106        ORCHIDEE_sed SECHIBA_restart_in NONE
107    fi
108
109# Modify in orchidee.def VEGET_UPDATE and LAND_COVER_CHANGE if they are set in orchidee.card section UserChoices
110    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
111        ORCHIDEE_sed VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
112    else
113        ORCHIDEE_sed VEGET_UPDATE 0Y
114    fi
115    if [ ! X${orchidee_UserChoices_LAND_COVER_CHANGE} = X ] ; then
116        ORCHIDEE_sed LAND_COVER_CHANGE ${orchidee_UserChoices_LAND_COVER_CHANGE}
117    else
118        ORCHIDEE_sed LAND_COVER_CHANGE n
119    fi
120
121    #IGCM_sys_Cp ${RUN_DIR}/orchidee.def ${RUN_DIR}/run.def
122    #IGCM_sys_Put_Out ${RUN_DIR}/run.def ${R_SAVE}/${PREFIX}_run.def
123
124
125    IGCM_debug_PopStack "SRF_Update"
126}
127
128#-----------------------------------------------------------------
129function SRF_Finalize
130{
131    IGCM_debug_PushStack "SRF_Finalize"
132
133    #IGCM_sys_Put_Out ${RUN_DIR}/used_run.def ${R_SAVE}/${PREFIX}_used_run.def
134
135    echo FINALIZE SRF !!!
136
137    IGCM_debug_PopStack "SRF_Finalize"
138}
Note: See TracBrowser for help on using the repository browser.