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

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

Bug correction : NWRITE and NWRITEHF was not properly handle. OPA can output two differents write frequency, opa.card take it in account. IPSLCM4_v2 can now run with PeriodLength?=1Y in config.card

File size: 6.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_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
67    case ${frequency} in
68        1Y|1y)
69            (( ORCA_NWRITE = ORCA_NPDT_JOUR * $( IGCM_date_DaysInYear  ${year} ) ))          ;
70            PREFIX_OPA=${config_UserChoices_JobName}_1y ;;
71        1M|1m)
72            (( ORCA_NWRITE = ORCA_NPDT_JOUR * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
73            PREFIX_OPA=${config_UserChoices_JobName}_1m ;;
74        *D|*d)
75            (( ORCA_NWRITE = ORCA_NPDT_JOUR * $( echo ${frequency} | sed -e "s/[dD]//" ) ))  ;
76            PREFIX_OPA=${config_UserChoices_JobName}_$( echo ${frequency} | sed -e "s/[dD]//" )d ;;
77        *)
78            (( ORCA_NWRITE = 0 ))                                                            ;;
79    esac
80
81    ##--Write Frequency Purpose .... concerning the second opa file type.
82    if [ ${NbFreq} -eq 2 ] ; then
83        frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $2}' )
84        case ${frequency} in
85            1Y|1y)
86                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * $( IGCM_date_DaysInYear  ${year} ) ))          ;
87                PREFIX_HF=${config_UserChoices_JobName}_1y ;;
88            1M|1m)
89                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
90                PREFIX_HF=${config_UserChoices_JobName}_1m ;;
91            *D|*d)
92                (( ORCA_NWRIHF = ORCA_NPDT_JOUR * $( echo ${frequency} | sed -e "s/[dD]//" ) ))  ;
93                PREFIX_HF=${config_UserChoices_JobName}_$( echo ${frequency} | sed -e "s/[dD]//" )d ;;
94            *)
95                (( ORCA_NWRIHF = 0 ))                                                            ;;
96        esac
97    else
98        ORCA_NWRIHF=0
99    fi
100
101    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
102    # Needed by OPA namelist to compute correct file names
103    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
104
105    ##-- Calcul du numero de pas de temps de debut de job ORCA
106    (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 ))
107    (( ORCA_NPDT   = PeriodLengthInDays * ORCA_NPDT_JOUR ))
108    (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1))
109
110    if [ "${ORCA_NSTOCK}" -gt "${ORCA_NPDT}" ]
111        then
112        ORCA_NSTOCK="${ORCA_NPDT}"
113    fi
114
115    ##-- verification du nb de pas de temps par jour
116    (( NB_SEC_JOUR_MODEL = ORCA_NPDT_JOUR * ORCA_RDT ))
117    (( NB_SEC_JOUR = 60 * 60 * 24 ))
118
119    if [ ${NB_SEC_JOUR_MODEL} -ne ${NB_SEC_JOUR} ]
120        then
121        echo " VERIFIER ORCA_NPDT_JOUR dans le job ${JOB} "
122        exit
123    fi
124
125    ##-- Restart configuration
126    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
127
128        ORCA_LRSTAR=.FALSE.
129        ORCA_NRSTDT=0
130        ORCA_NMSH=1
131        # ??? a garder ???
132        # cat <<EOF > EMPave_old.dat
133        # Old global EMP coeff =   1.000000000
134        # EOF
135
136        #echo "PAS DE RESTART OPA"
137    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
138
139        ORCA_LRSTAR=.TRUE.
140        ORCA_NRSTDT=0
141        ORCA_NMSH=0
142
143        #echo "RESTART OPA"
144    else
145
146        ORCA_LRSTAR=.TRUE.
147        ORCA_NRSTDT=1
148        ORCA_NMSH=0
149
150        #echo "RESTART OPA"
151    fi
152
153    sed -e "s/${PAT_CEXPER}/       cexper=\"${config_UserChoices_JobName}\"/" \
154        -e "s/${PAT_NIT000}/       nit000=${ORCA_NIT000}/" \
155        -e "s/${PAT_NITEND}/       nitend=${ORCA_NITEND}/" \
156        -e "s/${PAT_NWRITE}/       nwrite=${ORCA_NWRITE}/" \
157        -e "s/${PAT_RESTAR}/       lrstar=${ORCA_LRSTAR}/" \
158        -e "s/${PAT_NPRG}/         nprg=${ORCA_NWRITE}/" \
159        -e "s/${PAT_NSTOCK}/       nstock=${ORCA_NSTOCK}/" \
160        -e "s/${PAT_NRSTAR}/       nrstdt=${ORCA_NRSTDT}/" \
161        -e "s/${PAT_NDATE0}/       ndate0=${PeriodDateBegin}/" \
162        -e "s/${PAT_NMSH}/         nmsh=${ORCA_NMSH}/" \
163        -e "s/${PAT_NWRIHF}/       nwrihf=${ORCA_NWRIHF}/" \
164        namelist > namelist.tmp
165
166    IGCM_sys_Mv namelist.tmp namelist
167
168    IGCM_debug_PopStack "OCE_Update"
169}
170
171#-----------------------------------
172function OCE_Finalize
173{
174    IGCM_debug_PushStack "OCE_Finalize"
175
176    if [ -f date.file ] ; then
177        # Prefix use in opa.card AND in lim.card :
178        DATE_OPA=$( cat date.file | \
179            sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_output\ */\1/g" )
180
181        MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
182        SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
183    fi
184
185    echo FINALIZE OCE !!!
186
187    IGCM_debug_PopStack "OCE_Finalize"
188}
Note: See TracBrowser for help on using the repository browser.