source: CONFIG/IPSLCM/IPSLCM5/branches/IPSLCM5_v3/EXP00/COMP/opa9.driver @ 972

Last change on this file since 972 was 972, checked in by cetlod, 14 years ago

Cleaning of card and driver for NEMO-TOP

  • deleting useless *.noiomput card and driver
  • simplification of pisces.driver and opa9.driver
  • update pisces.card to store new diag file ( *dbio_T.nc)
File size: 8.9 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    # cn_exp    experience name
20    # nn_it000  number of the first time step
21    # nn_itend  number of the last time step
22    # nn_date0  initial calendar date yymmdd (used if  nn_rstctl=1)
23    # nn_leapy  Leap year calendar (1) or not (0), or 360 days calendar (30)
24    # nn_stock  frequency of creation of a restart file (modulo referenced to 1)
25    # nn_write  frequency of write in the output file   (modulo referenced to nn_it000)
26    # ln_rstart start from rest (F) or from a restart file (T)
27    # nn_rstctl restart control = 0 nn_it000 is not compared to the restart file value
28    #                           = 1 use nn_date0 in namelist (not the value in the restart file)
29    #                           = 2 calendar parameters read in the restart file
30    # nn_msh    =1 create a mesh file (coordinates, scale factors, masks)
31    # rn_rdt    time step in seconds for the dynamics (and tracer if nacc=0)   ==> 5760 (coming from namelist)
32    # nn_prg    time-step frequency of gap print in model output
33    # nf_ptr_wri frequency of zonal means and transport output
34
35    PAT_CEXPER=$( supergrep cn_exp     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
36    PAT_NIT000=$( supergrep nn_it000   ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
37    PAT_NITEND=$( supergrep nn_itend   ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
38    PAT_NDATE0=$( supergrep nn_date0   ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
39    PAT_NLEAPY=$( supergrep nn_leapy   ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
40    PAT_NSTOCK=$( supergrep nn_stock   ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
41    PAT_NWRITE=$( supergrep nn_write   ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
42    PAT_RESTAR=$( supergrep ln_rstart  ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
43    PAT_NRSTAR=$( supergrep nn_rstctl  ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
44    PAT_NMSH=$(   supergrep nn_msh     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
45    PAT_PRG=$(    supergrep nn_prg     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
46    PAT_NF_PTR=$( supergrep nf_ptr_wri ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} )
47
48    ORCA_RDT=$(   supergrep rn_rdt     ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} | sed 's/ *rn_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    ##--Variables used for XMLIO_SERVER configuration file
55    # using_server: .TRUE.(.FALSE.) to use(bypass) the io_server
56    PAT_SERVER=$( supergrep using_server ${SUBMIT_DIR}/PARAM/xmlio_server.def )
57
58    IGCM_debug_PopStack "OCE_Initialize"
59}
60
61#-----------------------------------------------------------------
62function OCE_Update
63{
64    IGCM_debug_PushStack "OCE_Update"
65
66    ## This informations are used for diaptr, trends and diagap files
67    ## only the first frequency is used for this files
68
69    ##--Write Frequency Purpose ....
70    frequency=$( echo ${config_OCE_WriteFrequency} | awk "-F " '{print $1}' )
71    factor=$( echo ${frequency} | sed -e "s/[yYmMdD]//" )
72    case ${frequency} in
73        1Y|1y)
74            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInYear  ${year} ) ))          ;
75            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}y ;
76            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_Y} ;
77            WF1=${factor}Y ;;
78        1M|1m)
79            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor * $( IGCM_date_DaysInMonth ${year} ${month} ) )) ;
80            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}m ;
81            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_M} ;
82            WF1=${factor}M ;;
83        *D|*d)
84            (( ORCA_NWRITE = ORCA_NPDT_JOUR * factor  ))  ;
85            PREFIX_NWRITE=${config_UserChoices_JobName}_${factor}d ;
86            R_OUT_OCE_NWRITE=${R_OUT_OCE_O_D} ;
87            WF1=${factor}D ;;
88        *)
89            (( ORCA_NWRITE = 0 ))                                                            ;;
90    esac
91
92    ##--Write Frequency for iomput
93    ## Differents frequencies are allowed for grid_[TUVW] and icemod files
94
95    V1D_ENABLE=".FALSE."
96    V5D_ENABLE=".FALSE."
97    V1M_ENABLE=".FALSE."
98    V1Y_ENABLE=".FALSE."
99
100    for frequency in ${config_OCE_WriteFrequency} ; do
101        case ${frequency} in
102            1D|1d) V1D_ENABLE=".TRUE." ;;
103        esac
104        case ${frequency} in
105            5D|5d) V5D_ENABLE=".TRUE." ;;
106        esac
107        case ${frequency} in
108            1M|1m) V1M_ENABLE=".TRUE." ;;
109        esac
110        case ${frequency} in
111            *[yY]) V1Y_ENABLE=".TRUE." ;;
112        esac
113    done
114
115    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
116    # Needed by OPA namelist to compute correct file names
117    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
118
119    ##-- Number of time steps updated : the first, the last and the number of time steps
120    (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 ))
121    (( ORCA_NPDT   = PeriodLengthInDays * ORCA_NPDT_JOUR ))
122    (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1))
123
124    ##-- We force one restart file at the end of the trunk
125    ORCA_NSTOCK="${ORCA_NITEND}"
126
127    ##-- Let verify the number of time steps per day
128    (( NB_SEC_JOUR_MODEL = ORCA_NPDT_JOUR * ORCA_RDT ))
129    (( NB_SEC_JOUR = 60 * 60 * 24 ))
130
131    if [ ${NB_SEC_JOUR_MODEL} -ne ${NB_SEC_JOUR} ] ; then
132        echo " VERIFY ORCA_NPDT_JOUR in opa9.card "
133        exit
134    fi
135
136    ##-- Restart configuration
137    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
138        ORCA_LRSTAR=.FALSE.
139        ORCA_NRSTDT=0
140        # Put ORCA_NMSH=0 when OPA running in parallel mode
141        ORCA_NMSH=1
142        #echo "NO OPA RESTART"
143    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
144        ORCA_LRSTAR=.TRUE.
145        ORCA_NRSTDT=0
146        ORCA_NMSH=1
147        #echo "OPA RESTART"
148    else
149        ORCA_LRSTAR=.TRUE.
150        ORCA_NRSTDT=2
151        ORCA_NMSH=0
152        #echo "OPA RESTART"
153    fi
154
155    ##-- Meshmask option
156    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask
157
158    if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then
159        ORCA_NMSH=1
160        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n"
161    fi
162
163    # nleapy configuration
164    case ${config_UserChoices_CalendarType} in
165        leap|gregorian)
166            ORCA_NLEAPY=1;;
167        noleap)
168            ORCA_NLEAPY=0;;
169        360d)
170            ORCA_NLEAPY=30;;
171        *)
172            ORCA_NLEAPY=30
173    esac
174
175    typeset -r PRECIS=8
176    NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${ORCA_NITEND} }" ) ) 
177
178
179    sed -e "s/${PAT_CEXPER}/       cn_exp=\"${config_UserChoices_JobName}\"/" \
180        -e "s/${PAT_NIT000}/       nn_it000=${ORCA_NIT000}/"                    \
181        -e "s/${PAT_NITEND}/       nn_itend=${ORCA_NITEND}/"                    \
182        -e "s/${PAT_NDATE0}/       nn_date0=${PeriodDateBegin}/"                \
183        -e "s%${PAT_NLEAPY}%       nn_leapy=${ORCA_NLEAPY}%"                    \
184        -e "s/${PAT_NSTOCK}/       nn_stock=${ORCA_NSTOCK}/"                    \
185        -e "s/${PAT_NWRITE}/       nn_write=${ORCA_NWRITE}/"                    \
186        -e "s/${PAT_RESTAR}/       ln_rstart=${ORCA_LRSTAR}/"                 \
187        -e "s/${PAT_NRSTAR}/       nn_rstctl=${ORCA_NRSTDT}/"                    \
188        -e "s/${PAT_NMSH}/         nn_msh=${ORCA_NMSH}/"                        \
189        -e "s/${PAT_NPRG}/         nn_prg=${ORCA_NWRITE}/"                      \
190        -e "s/${PAT_NF_PTR}/       nf_ptr_wri=${ORCA_NWRITE}/"                \
191        namelist > namelist.tmp
192
193    IGCM_sys_Mv namelist.tmp namelist
194
195    echo 'Variables automatically updated in ORCA namelist'
196    grep AUTO namelist
197
198    # update iodef.xml
199
200    sed -e "s/<1D_ENABLE>/${V1D_ENABLE}/" \
201        -e "s/<5D_ENABLE>/${V5D_ENABLE}/" \
202        -e "s/<1M_ENABLE>/${V1M_ENABLE}/" \
203        -e "s/<1Y_ENABLE>/${V1Y_ENABLE}/" \
204        iodef.xml > iodef.xml.tmp
205
206    IGCM_sys_Mv iodef.xml.tmp iodef.xml
207
208    # update xmlio_server.def
209
210    if [ X${opa9_UserChoices_io_server} = Xy ] ; then
211        sed -e "s/${PAT_SERVER}/  using_server = .TRUE./" \
212        xmlio_server.def > xmlio_server.def.tmp
213        IGCM_sys_Mv xmlio_server.def.tmp xmlio_server.def
214    fi
215
216    IGCM_debug_PopStack "OCE_Update"
217}
218
219#-----------------------------------
220function OCE_Finalize
221{
222    IGCM_debug_PushStack "OCE_Finalize"
223
224    if [ -f date.file ] ; then
225        # Prefix use in opa9.card AND in lim2.card :
226        DATE_OPA=$( cat date.file | \
227            sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
228        MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
229        SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
230    fi
231
232    echo FINALIZE OCE !!!
233
234    IGCM_debug_PopStack "OCE_Finalize"
235}
Note: See TracBrowser for help on using the repository browser.