source: CONFIG/trunk/IPSLCM4_v2/EXP00/COMP/opa.driver @ 155

Last change on this file since 155 was 155, checked in by sdipsl, 17 years ago

Modifications :

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