source: CONFIG/IPSLCM/IPSLCM5/trunk/EXP00/COMP/nemo.driver @ 568

Last change on this file since 568 was 568, checked in by mafoipsl, 15 years ago

MAF : adapt namelist and nemo driver to nemo_v3_1, upgrade nemo.driver

File size: 7.4 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function OCE_Initialize
4{
5    IGCM_debug_PushStack "OCE_Initialize"
6
7    JOB_NAME=${config_UserChoices_JobName}
8    RESOL_OCE=$( echo $RESOL | awk "-Fx" '{print $1}' )
9
10    ORCA_NPDT_JOUR=${nemo_UserChoices_OPA_NPDT_JOURS:=15}
11
12# Local function to find namelists parameters
13        supergrep () {
14            grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
15        }
16       
17    ##--Variables used by OPA --
18
19    # cexper experience name for vairmer format
20    # ln_rstart boolean term for restart (true or false)
21    # nrstdt control of the time step (0, 1 or 2)
22    # nit000 number of the first time step
23    # nitend number of the last time step
24    # ndate0 initial calendar date aammjj
25    # nleapy Leap year calendar (1) or not (0), or 360 days calendar (30)
26    # nstock frequency of restart file
27    # nwrite frequency of OUTPUT file
28    # nmsh  =1 create a mesh file (coordinates, scale factors, masks)
29    # nwrihf frequency of HF OUTPUT file
30    # rdt time step in seconds (coming from namelist)
31
32            PAT_CEXPER=$( supergrep cexper    ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
33            PAT_NIT000=$( supergrep nit000    ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
34            PAT_NITEND=$( supergrep nitend    ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
35            PAT_NWRITE=$( supergrep nwrite    ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
36            PAT_RESTAR=$( supergrep ln_rstart ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
37            PAT_NSTOCK=$( supergrep nstock    ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
38            PAT_NRSTAR=$( supergrep nrstdt    ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
39            PAT_NDATE0=$( supergrep ndate0    ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
40            PAT_NLEAPY=$( supergrep nleapy    ${SUBMIT_DIR}/PARAM/namelist )
41            PAT_NMSH=$(   supergrep nmsh      ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
42       
43            ORCA_RDT=$( supergrep rdt  ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} | sed 's/ *rdt *=//' | sed 's/\. *//' )
44
45    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
46    # /!\ Needed by OPA namelist to compute file names /!\
47    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
48
49    IGCM_debug_PopStack "OCE_Initialize"
50}
51
52#-----------------------------------------------------------------
53function OCE_Update
54{
55    IGCM_debug_PushStack "OCE_Update"
56
57    NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w )
58
59    ##--Write Frequency Purpose ....
60    frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $1}' )
61    factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
62    case ${frequency} in
63        1Y|1y)
64            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear  ${year} ) ))          ;
65            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}y ;
66            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_Y} ;
67            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_Y} ;
68            WF1=${factor}Y ;;
69        1M|1m)
70            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
71            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}m ;
72            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_M} ;
73            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_M} ;
74            WF1=${factor}M ;;
75        *D|*d)
76            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor  ))  ;
77            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}d ;
78            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_D} ;
79            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_D} ;
80            WF1=${factor}D ;;
81        *)
82            (( ORCA_NWRITE = 0 ))                                                            ;;
83    esac
84
85    ##--Write Frequency Purpose .... concerning the second opa file type.
86    if [ ${NbFreq} -eq 2 ] ; then
87        frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $2}' )
88        factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
89        case ${frequency} in
90            *Y|*y)
91                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear  ${year} ) ))          ;
92                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}y ;
93                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_Y} ;
94                WF2=${factor}Y ;;
95            *M|*m)
96                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
97                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}m ;
98                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_M} ;
99                WF2=${factor}M ;;
100            *D|*d)
101                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor ))  ;
102                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}d ;
103                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_D} ;
104                WF2=${factor}D ;;
105            *)
106                (( ORCA_NWRIHF = 0 ))                                                            ;;
107        esac
108    else
109        ORCA_NWRIHF=0
110    fi
111
112    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
113    # Needed by OPA namelist to compute correct file names
114    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
115
116    ##-- Calcul du numero de pas de temps de debut de job ORCA
117    (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 ))
118    (( ORCA_NPDT   = PeriodLengthInDays * ORCA_NPDT_JOUR ))
119    (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1))
120
121    ORCA_NSTOCK="${ORCA_NPDT}"
122
123    ##-- verification du nb de pas de temps par jour
124    (( NB_SEC_JOUR_MODEL = ORCA_NPDT_JOUR * ORCA_RDT ))
125    (( NB_SEC_JOUR = 60 * 60 * 24 ))
126
127    if [ ${NB_SEC_JOUR_MODEL} -ne ${NB_SEC_JOUR} ]
128        then
129        echo " VERIFIER ORCA_NPDT_JOUR dans nemo.card "
130        exit
131    fi
132
133    ##-- Restart configuration
134    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
135
136        ORCA_LRSTAR=.FALSE.
137        ORCA_NRSTDT=0
138        ORCA_NMSH=1
139
140        #echo "PAS DE RESTART OPA"
141    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
142
143        ORCA_LRSTAR=.TRUE.
144        ORCA_NRSTDT=0
145        ORCA_NMSH=0
146
147        #echo "RESTART OPA"
148    else
149
150        ORCA_LRSTAR=.TRUE.
151        ORCA_NRSTDT=2
152        ORCA_NMSH=0
153
154        #echo "RESTART OPA"
155    fi
156
157
158    # nleapy configuration
159    case ${config_UserChoices_CalendarType} in
160         leap)
161         ORCA_NLEAPY=1;;
162         noleap)
163         ORCA_NLEAPY=0;;
164         360d)
165         ORCA_NLEAPY=30;;
166         *)
167         ORCA_NLEAPY=30
168    esac
169
170
171    typeset -r PRECIS=8
172    NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${ORCA_NITEND} }" ) ) 
173
174
175    sed -e "s/${PAT_CEXPER}/       cexper=\"${config_UserChoices_JobName}\"/" \
176        -e "s/${PAT_NIT000}/       nit000=${ORCA_NIT000}/"                    \
177        -e "s/${PAT_NITEND}/       nitend=${ORCA_NITEND}/"                    \
178        -e "s/${PAT_NWRITE}/       nwrite=${ORCA_NWRITE}/"                    \
179        -e "s/${PAT_RESTAR}/       ln_rstart=${ORCA_LRSTAR}/"                 \
180        -e "s/${PAT_NPRG}/         nprg=${ORCA_NWRITE}/"                      \
181        -e "s/${PAT_NSTOCK}/       nstock=${ORCA_NSTOCK}/"                    \
182        -e "s/${PAT_NRSTAR}/       nrstdt=${ORCA_NRSTDT}/"                    \
183        -e "s/${PAT_NDATE0}/       ndate0=${PeriodDateBegin}/"                \
184        -e "s%${PAT_NLEAPY}%       nleapy=${ORCA_NLEAPY}%"                    \
185        -e "s/${PAT_NMSH}/         nmsh=${ORCA_NMSH}/"                        \
186        namelist > namelist.tmp
187
188    IGCM_sys_Mv namelist.tmp namelist
189
190    echo 'Variables automatically updated in namelist'
191    grep AUTO namelist
192
193    IGCM_debug_PopStack "OCE_Update"
194}
195
196#-----------------------------------
197function OCE_Finalize
198{
199    IGCM_debug_PushStack "OCE_Finalize"
200
201    if [ -f date.file ] ; then
202        # Prefix use in opa.card AND in lim.card :
203        DATE_OPA=$( cat date.file | \
204            sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
205        MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
206        SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
207    fi
208
209    echo FINALIZE OCE !!!
210
211    IGCM_debug_PopStack "OCE_Finalize"
212}
Note: See TracBrowser for help on using the repository browser.