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

Last change on this file since 375 was 375, checked in by mafoipsl, 16 years ago

ACa + MAFo : first import for IPSLCM5 configuration

File size: 7.8 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_NO=$(     grep 'no'     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} | grep -v off )
35    PAT_CEXPER=$( grep 'cexper' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
36    PAT_NIT000=$( grep 'nit000' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
37    PAT_NITEND=$( grep 'nitend' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
38    PAT_NBISEX=$( grep 'nbisex  =' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}| sed 's/ nbisex  =//' |sed '/^[ ]$/d'|sed 's/,//' )
39    PAT_NWRITE=$( grep 'nwrite  =' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
40    PAT_RESTAR=$( grep 'ln_rstart' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
41    PAT_NSTOCK=$( grep 'nstock  =' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
42    PAT_NRSTAR=$( grep 'nrstdt' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
43    PAT_NPRG=$(   grep 'nprg'   ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
44    PAT_NDATE0=$( grep 'ndate0' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
45    PAT_NMSH=$(   grep 'nmsh'   ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) 
46#######    PAT_NWRIHF=$( grep 'nwrihf' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
47
48    ORCA_NSTOCK=$( echo $PAT_NSTOCK | sed "s/[a-z,A-Z,=]//g" )
49    ORCA_RDT=$( egrep 'rdt *=' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} | sed 's/ *rdt *=//' | sed 's/\. *,//' )
50
51    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
52    # /!\ Needed by OPA namelist to compute file names /!\
53    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
54
55    IGCM_debug_PopStack "OCE_Initialize"
56}
57
58#-----------------------------------------------------------------
59function OCE_Update
60{
61###    set -vx
62    IGCM_debug_PushStack "OCE_Update"
63
64    NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w )
65
66    ##--Write Frequency Purpose ....
67    frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $1}' )
68    factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
69    case ${frequency} in
70        1Y|1y)
71            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear  ${year} ) ))          ;
72            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}y ;
73            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_Y} ;
74            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_Y} ;
75            WF1=${factor}Y ;;
76        1M|1m)
77            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
78            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}m ;
79            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_M} ;
80            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_M} ;
81            WF1=${factor}M ;;
82        *D|*d)
83            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor  ))  ;
84            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}d ;
85            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_D} ;
86            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_D} ;
87            WF1=${factor}D ;;
88        *)
89            (( ORCA_NWRITE = 0 ))                                                            ;;
90    esac
91###            (( ORCA_NWRITE = 1 ))  ;
92###            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}d ;
93###            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_D} ;
94###            R_OUT_ICE_NWRITE=${R_OUT_ICE_O_D} ;
95###            WF1=${factor}D ;
96
97
98    ##--Write Frequency Purpose .... concerning the second opa file type.
99    if [ ${NbFreq} -eq 2 ] ; then
100        frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $2}' )
101        factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
102        case ${frequency} in
103            *Y|*y)
104                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear  ${year} ) ))          ;
105                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}y ;
106                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_Y} ;
107                WF2=${factor}Y ;;
108            *M|*m)
109                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
110                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}m ;
111                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_M} ;
112                WF2=${factor}M ;;
113            *D|*d)
114                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * factor ))  ;
115                PREFIX_NWRIHF=${config_UserChoices_JobName}_${factor}d ;
116                R_OUT_OCE_NWRIHF=${R_OUT_OCE_O_D} ;
117                WF2=${factor}D ;;
118            *)
119                (( ORCA_NWRIHF = 0 ))                                                            ;;
120        esac
121    else
122        ORCA_NWRIHF=0
123    fi
124
125    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
126    # Needed by OPA namelist to compute correct file names
127    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
128
129    ##-- Calcul du numero de pas de temps de debut de job ORCA
130    (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 ))
131    (( ORCA_NPDT   = PeriodLengthInDays * ORCA_NPDT_JOUR ))
132    (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1))
133
134    if [ "${ORCA_NSTOCK}" -gt "${ORCA_NPDT}" ]
135        then
136        ORCA_NSTOCK="${ORCA_NPDT}"
137    fi
138
139    ##-- verification du nb de pas de temps par jour
140    (( NB_SEC_JOUR_MODEL = ORCA_NPDT_JOUR * ORCA_RDT ))
141    (( NB_SEC_JOUR = 60 * 60 * 24 ))
142
143    if [ ${NB_SEC_JOUR_MODEL} -ne ${NB_SEC_JOUR} ]
144        then
145        echo " VERIFIER ORCA_NPDT_JOUR dans le job ${JOB} "
146        exit
147    fi
148
149    ##-- Restart configuration
150    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
151
152        ORCA_LRSTAR=.FALSE.
153        ORCA_NRSTDT=0
154        ORCA_NMSH=1
155        # ??? a garder ???
156        # cat <<EOF > EMPave_old.dat
157        # Old global EMP coeff =   1.000000000
158        # EOF
159
160        #echo "PAS DE RESTART OPA"
161    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
162
163        ORCA_LRSTAR=.TRUE.
164        ORCA_NRSTDT=0
165        ORCA_NMSH=0
166
167        #echo "RESTART OPA"
168    else
169
170        ORCA_LRSTAR=.TRUE.
171        ORCA_NRSTDT=1
172        ORCA_NMSH=0
173
174        #echo "RESTART OPA"
175    fi
176        typeset -r PRECIS=8
177        NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${ORCA_NITEND} }" ) ) 
178
179    sed -e "s/${PAT_CEXPER}/       cexper=\"${config_UserChoices_JobName}\"/" \
180        -e "s/${PAT_NIT000}/       nit000=${ORCA_NIT000}/" \
181        -e "s/${PAT_NITEND}/       nitend=${ORCA_NITEND}/" \
182        -e "s/${PAT_NWRITE}/       nwrite=${ORCA_NWRITE}/" \
183        -e "s/${PAT_RESTAR}/       ln_rstart=${ORCA_LRSTAR}/" \
184        -e "s/${PAT_NPRG}/         nprg=${ORCA_NWRITE}/" \
185        -e "s/${PAT_NSTOCK}/       nstock=${ORCA_NSTOCK}/" \
186        -e "s/${PAT_NRSTAR}/       nrstdt=${ORCA_NRSTDT}/" \
187        -e "s/${PAT_NDATE0}/       ndate0=${PeriodDateBegin}/" \
188        -e "s/${PAT_NMSH}/         nmsh=${ORCA_NMSH}/" \
189        namelist > namelist.tmp
190
191    IGCM_sys_Mv namelist.tmp 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###DATE_OPA=$( $DATE_OPABF | cut -c1-30 )
206        MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
207        SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
208    fi
209
210    echo FINALIZE OCE !!!
211
212    IGCM_debug_PopStack "OCE_Finalize"
213}
Note: See TracBrowser for help on using the repository browser.