source: CONFIG/IPSLCM/IPSLCM5/tags/IPSLCM5_backup/EXP00/COMP/opa9.driver @ 611

Last change on this file since 611 was 611, checked in by omamce, 14 years ago

OM : add treatment of high frequency output
WriteFrequency?="1" for instance.

  • Property svn:executable set to *
File size: 8.0 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=${opa9_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    # nf_ptr_wri frequency of zonal means and transport output
32
33            PAT_CEXPER=$( supergrep cexper     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
34            PAT_NIT000=$( supergrep nit000     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
35            PAT_NITEND=$( supergrep nitend     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
36            PAT_NWRITE=$( supergrep nwrite     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
37            PAT_NF_PTR=$( supergrep nf_ptr_wri ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
38            PAT_RESTAR=$( supergrep ln_rstart  ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
39            PAT_NSTOCK=$( supergrep nstock     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
40            PAT_NRSTAR=$( supergrep nrstdt     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
41            PAT_NDATE0=$( supergrep ndate0     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
42            PAT_NLEAPY=$( supergrep nleapy     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
43            PAT_NMSH=$(   supergrep nmsh       ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
44       
45            ORCA_RDT=$( supergrep rdt  ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} | sed 's/ *rdt *=//' | sed 's/\. *//' )
46
47    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
48    # /!\ Needed by OPA namelist to compute file names /!\
49    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
50
51    IGCM_debug_PopStack "OCE_Initialize"
52}
53
54#-----------------------------------------------------------------
55function OCE_Update
56{
57    IGCM_debug_PushStack "OCE_Update"
58
59    NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w )
60
61    ##--Write Frequency Purpose ....
62    frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $1}' )
63    factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
64    case ${frequency} in
65        1Y|1y)
66            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear  ${year} ) ))          ;
67            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}y ;
68            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_Y} ;
69            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_Y} ;
70            WF1=${factor}Y ;;
71        1M|1m)
72            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
73            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}m ;
74            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_M} ;
75            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_M} ;
76            WF1=${factor}M ;;
77        *D|*d)
78            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor  ))  ;
79            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}d ;
80            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_D} ;
81            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_D} ;
82            WF1=${factor}D ;;
83        *)     
84            (( ORCA_NWRITE = factor )) 
85            PREFIX_NWRITE=${config_UserChoices_JobName}_CU${factor} ;
86            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_I} ;
87            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_I} ;
88            WF1=CU${factor} ;;           
89    esac
90
91    ##--Write Frequency Purpose .... concerning the second opa file type.
92    if [ ${NbFreq} -eq 2 ] ; then
93        frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $2}' )
94        factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
95        case ${frequency} in
96            *Y|*y)
97                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear  ${year} ) ))          ;
98                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}y ;
99                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_Y} ;
100                WF2=${factor}Y ;;
101            *M|*m)
102                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
103                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}m ;
104                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_M} ;
105                WF2=${factor}M ;;
106            *D|*d)
107                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor ))  ;
108                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}d ;
109                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_D} ;
110                WF2=${factor}D ;;
111            *)
112                (( ORCA_NWRIHF = 0 ))                                                            ;;
113        esac
114    else
115        ORCA_NWRIHF=0
116    fi
117
118    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
119    # Needed by OPA namelist to compute correct file names
120    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
121
122    ##-- Number of time steps updated : the first, the last and the number of time steps
123    (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 ))
124    (( ORCA_NPDT   = PeriodLengthInDays * ORCA_NPDT_JOUR ))
125    (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1))
126
127    ##-- We force one restart file at the end of the trunk
128    ORCA_NSTOCK="${ORCA_NITEND}"
129
130    ##-- Let verify the number of time steps per day
131    (( NB_SEC_JOUR_MODEL = ORCA_NPDT_JOUR * ORCA_RDT ))
132    (( NB_SEC_JOUR = 60 * 60 * 24 ))
133
134    if [ ${NB_SEC_JOUR_MODEL} -ne ${NB_SEC_JOUR} ]
135        then
136        echo " VERIFY ORCA_NPDT_JOUR in opa9.card "
137        exit
138    fi
139
140    ##-- Restart configuration
141    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
142
143        ORCA_LRSTAR=.FALSE.
144        ORCA_NRSTDT=0
145        # Put ORCA_NMSH=0 when OPA running in parallel mode
146        ORCA_NMSH=1
147
148        #echo "NO OPA RESTART"
149    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
150
151        ORCA_LRSTAR=.TRUE.
152        ORCA_NRSTDT=0
153        ORCA_NMSH=0
154
155        #echo "OPA RESTART"
156    else
157
158        ORCA_LRSTAR=.TRUE.
159        ORCA_NRSTDT=2
160        ORCA_NMSH=0
161
162        #echo "OPA RESTART"
163    fi
164
165
166    # nleapy configuration
167    case ${config_UserChoices_CalendarType} in
168         leap)
169         ORCA_NLEAPY=1;;
170         noleap)
171         ORCA_NLEAPY=0;;
172         360d)
173         ORCA_NLEAPY=30;;
174         *)
175         ORCA_NLEAPY=30
176    esac
177
178
179    typeset -r PRECIS=8
180    NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${ORCA_NITEND} }" ) ) 
181
182
183    sed -e "s/${PAT_CEXPER}/       cexper=\"${config_UserChoices_JobName}\"/" \
184        -e "s/${PAT_NIT000}/       nit000=${ORCA_NIT000}/"                    \
185        -e "s/${PAT_NITEND}/       nitend=${ORCA_NITEND}/"                    \
186        -e "s/${PAT_NWRITE}/       nwrite=${ORCA_NWRITE}/"                    \
187        -e "s/${PAT_RESTAR}/       ln_rstart=${ORCA_LRSTAR}/"                 \
188        -e "s/${PAT_NPRG}/         nprg=${ORCA_NWRITE}/"                      \
189        -e "s/${PAT_NF_PTR}/       nf_ptr_wri=${ORCA_NWRITE}/"                \
190        -e "s/${PAT_NSTOCK}/       nstock=${ORCA_NSTOCK}/"                    \
191        -e "s/${PAT_NRSTAR}/       nrstdt=${ORCA_NRSTDT}/"                    \
192        -e "s/${PAT_NDATE0}/       ndate0=${PeriodDateBegin}/"                \
193        -e "s%${PAT_NLEAPY}%       nleapy=${ORCA_NLEAPY}%"                    \
194        -e "s/${PAT_NMSH}/         nmsh=${ORCA_NMSH}/"                        \
195        namelist > namelist.tmp
196
197    IGCM_sys_Mv namelist.tmp namelist
198
199    echo 'Variables automatically updated in ORCA namelist'
200    grep AUTO namelist
201
202    IGCM_debug_PopStack "OCE_Update"
203}
204
205#-----------------------------------
206function OCE_Finalize
207{
208    IGCM_debug_PushStack "OCE_Finalize"
209
210    if [ -f date.file ] ; then
211        # Prefix use in opa9.card AND in lim2.card :
212        DATE_OPA=$( cat date.file | \
213            sed "s/\ ${config_UserChoices_JobName}_[CU]*[0-9]*[a-z]*_\([0-9]*_[0-9]*\)_\ */\1/g" )
214        MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
215        SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
216    fi
217
218    echo FINALIZE OCE !!!
219
220    IGCM_debug_PopStack "OCE_Finalize"
221}
Note: See TracBrowser for help on using the repository browser.