source: CONFIG/UNIFORM/v6/NEMO_v6/GENERAL/DRIVER/pisces.driver @ 3961

Last change on this file since 3961 was 3961, checked in by cetlod, 6 years ago

Consolidation of NEMO_v6 for OMIP

  • Property svn:executable set to *
File size: 8.5 KB
RevLine 
[2639]1#!/bin/ksh
2
3#-----------------------------------
4function MBG_Initialize
5{ 
6    IGCM_debug_PushStack "MBG_Initialize"
[2706]7
8# Local function to find namelists parameters
9supergrep () {
10    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
11}
12
13    if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then
[3203]14       RESOL_OCE=${config_UserChoices_ExpType%%_*}
[3854]15       exptype=${config_UserChoices_ExpType##*/}
[3203]16
17       IGCM_debug_Print 1 " "
18       IGCM_debug_Print 1 "RESOL_OCE        : ${RESOL_OCE}"
[3854]19       IGCM_debug_Print 1 "EXPERIMENT TYPE  : ${exptype}"
[3203]20
[3854]21       OPA_RDT=$( supergrep rn_rdt  ${SUBMIT_DIR}/PARAM/NAMELIST/${RESOL_OCE}$/namelist_offline_${exptype}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
[2706]22       # Period Length In Days between DateBegin and first day of calendar 0001 01 01
23       # /!\ Needed by OPA namelist to compute file names /!\
24       (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
25
[2875]26       (( OPA_NPDT_DAY  =  86400 / OPA_RDT ))
[2871]27       (( OPA_NPDT_YEAR  =  OPA_NPDT_DAY * 365     ))
[2875]28
29
30       IGCM_debug_Print 1 " "
31       IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
32       IGCM_debug_Print 1 "OPA_NPDT_DAY   ${OPA_NPDT_DAY}"
33       IGCM_debug_Print 1 "OPA_NPDT_YEAR  ${OPA_NPDT_YEAR}"
34
[2706]35     fi
36
[2639]37    IGCM_debug_PopStack "MBG_Initialize"
38}
39
40#-----------------------------------
41function MBG_Update
42{
43    IGCM_debug_PushStack "MBG_Update"
44
[3435]45   
46    ##--Write Frequency for iomput
47    ## Differents frequencies are allowed for MBG files
[2639]48
[3435]49    VT1D_ENABLE=".FALSE."
50    VT5D_ENABLE=".FALSE."
51    VT1M_ENABLE=".FALSE."
52    VT1Y_ENABLE=".FALSE."
53
54    for frequency in ${config_MBG_WriteFrequency} ; do
[3408]55        case ${frequency} in
[3435]56            ( 1D|1d ) VT1D_ENABLE=".TRUE." ;;
57            ( 5D|5d ) VT5D_ENABLE=".TRUE." ;;
58            ( 1M|1m ) VT1M_ENABLE=".TRUE." ;;
59            ( *[yY] ) VT1Y_ENABLE=".TRUE." ;;
[3408]60        esac
[2639]61    done
62
[3408]63
[2706]64    if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then
65
66       # Period Length In Days between DateBegin and first day of calendar 0001 01 01
67       # Needed by OPA namelist to compute correct file names
68       (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
69
70       ## Count of number of time steps from begin of OPA job
[2875]71       (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 ))
72       (( OPA_NDT   = PeriodLengthInDays * OPA_NPDT_DAY ))
[2706]73       (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
74
75       ## Forcing to write one restart file at the end of period
76       OPA_NSTOCK="${OPA_NITEND}"
77
78       # nleapy configuration
79       case ${config_UserChoices_CalendarType} in
80           leap)
81               OPA_NLEAPY=1;;
82           noleap)
83               OPA_NLEAPY=0;;
84           360d)
85               OPA_NLEAPY=30;;
86       esac
87
88       typeset -r PRECIS=8
89       NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) )
[3408]90
91
92       DYN_SSH_INI=.TRUE.
93       if [ "${EXPTYPE}" = "ia"   ] ; then
94          NbDynFile=${#pisces_UserChoices_DynFiles[*]}
95          (( LengthForcing=${pisces_UserChoices_DynYearEnd} - ${pisces_UserChoices_DynYearStart} + 1 ))
96          (( DiffForcing=abs( ${pisces_UserChoices_DynYearEnd} - ${year} ) ))
97          (( ModuloForcing=${DiffForcing} % ${LengthForcing} ))
98          if [ ${ModuloForcing} -eq 0 ] ; then
99             (( year_forcing=${pisces_UserChoices_DynYearEnd} ))
100          else
101             if [ ${year} -ge ${pisces_UserChoices_DynYearStart} ] && [ ${year} -le ${pisces_UserChoices_DynYearEnd} ] ; then
102                year_forcing=${year}
103             elif [ ${year} -lt ${pisces_UserChoices_DynYearStart} ] ; then
104                (( year_forcing=${pisces_UserChoices_DynYearEnd} - ${ModuloForcing} ))
105             else
106                (( year_forcing=${pisces_UserChoices_DynYearStart} + ${ModuloForcing} - 1 ))
107             fi
108          fi
109          (( year_forcing_m1 = ${year_forcing} - 1))
110          (( year_forcing_p1 = ${year_forcing} + 1))
111          eval CurrDateFor=${year_forcing}0101_${year_forcing}1231
112          eval PrevDateFor=${year_forcing_m1}0101_${year_forcing_m1}1231
113          eval NextDateFor=${year_forcing_p1}0101_${year_forcing_p1}1231
114          (( i = 0 ))
115           while [ $i -lt ${NbDynFile} ] ; do
116             eval Suffix=${pisces_UserChoices_DynFiles[$i]}
117             eval RunFileName=${pisces_UserChoices_DynRunName}_${Suffix}
118             eval PrevDynFileName=${pisces_UserChoices_DynName}_${PrevDateFor}_${pisces_UserChoices_DynFreq}_${Suffix}
119             eval CurrDynFileName=${pisces_UserChoices_DynName}_${CurrDateFor}_${pisces_UserChoices_DynFreq}_${Suffix}
120             eval NextDynFileName=${pisces_UserChoices_DynName}_${NextDateFor}_${pisces_UserChoices_DynFreq}_${Suffix}
121##             IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${PrevDynFileName}.nc  ${RunFileName}_y${year_m1}.nc
122             IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${CurrDynFileName}.nc  ${RunFileName}_y${year}.nc
123##             IGCM_sys_Get ${pisces_UserChoices_R_DYN}/${NextDynFileName}.nc  ${RunFileName}_y${year_p1}.nc
124             (( i = i + 1 ))
125          done
126          if [ ${year_forcing} = ${pisces_UserChoices_DynYearStart} ] ; then
127             DYN_SSH_INI=.TRUE.
128          else
129             DYN_SSH_INI=.FALSE
130          fi
131       fi
[2706]132    fi
133
[2639]134    ##-- Restart configuration
135    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
136
137        #echo "NO RESTART FOR TOP"
138        TOP_LRSTTR=.FALSE.
139        TOP_NRSTTR=0
140
141    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
142
143        #echo "RESTART TOP"
144        TOP_LRSTTR=.TRUE.
145        TOP_NRSTTR=0
146
147    else
148
149        #echo "RESTART TOP"
150        TOP_LRSTTR=.TRUE.
151        TOP_NRSTTR=2
152    fi
153
154# on force les sorties PISCES comme les sorties OPA
[2706]155    if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then
156      IGCM_comp_modifyNamelist blocker    namelist_cfg cn_exp    ${config_UserChoices_JobName}
157      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_it000  ${OPA_NIT000}
158      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_itend  ${OPA_NITEND}
159      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock ${OPA_NSTOCK}
160      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0 ${PeriodDateBegin}
161      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy  ${OPA_NLEAPY}
[3203]162
163# update domain_def.xml file
164      case ${RESOL_OCE} in
165          ( *ORCA025* ) 
[3210]166            sed -e 's/<zoom_domain id="1point" ibegin="139" jbegin="119"/<zoom_domain id="1point" ibegin="600" jbegin="600"/' domain_def_nemo.xml > domain_def.xml.tmp 
167            IGCM_sys_Mv domain_def.xml.tmp domain_def_nemo.xml  ;
[3203]168      esac
169
[3854]170      IGCM_comp_modifyXmlFile force context_nemo.xml ref_year NONE ${InitYear}
171
[2706]172   fi
[2639]173
[3961]174   if [ X"${pisces_UserChoices_Co2Anthr}" = X"y" ] ; then
175      LCO2INT=.TRUE.
176   else
177      LCO2INT=.FALSE.
178   fi
[3440]179   ##-- Update namelist_top_cfg and namelist_pisces_cfg
180    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_rsttr  ${TOP_LRSTTR}
181    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     nn_rsttr  ${TOP_NRSTTR}
[3961]182    IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  ln_co2int ${LCO2INT}
[3440]183    IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  atcco2    ${pisces_UserChoices_AtmCo2}
[3961]184    IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  nrdttrc   ${pisces_UserChoices_PisFreq}
[3440]185    IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  nn_pisdmp ${OPA_NPDT_YEAR}
186
[3435]187 
188    # Update iodef.xml
[2639]189
[3435]190    IGCM_debug_Print 1 'Informations into iodef.xml : VT1D_ENABLE VT5D_ENABLE VT1M_ENABLE VT1Y_ENABLE '
191    IGCM_debug_Print 1 ${VT1D_ENABLE}  ${VT5D_ENABLE} ${VT1M_ENABLE} ${VT1Y_ENABLE}
[3408]192
[3512]193    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1d_pis enabled ${VT1D_ENABLE}
194    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 5d_pis enabled ${VT5D_ENABLE}
195    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1m_pis enabled ${VT1M_ENABLE}
196    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1y_pis enabled ${VT1Y_ENABLE}
[3408]197
[3854]198    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1d_pis output_level ${pisces_UserChoices_OutputLevel}
199    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 5d_pis output_level ${pisces_UserChoices_OutputLevel}
200    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1m_pis output_level ${pisces_UserChoices_OutputLevel}
201    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1y_pis output_level ${pisces_UserChoices_OutputLevel}
[3408]202
[3435]203
[3854]204
[2848]205   IGCM_debug_PopStack "MBG_Update"
[2639]206}
207
208#-----------------------------------
209function MBG_Finalize
210{
211    IGCM_debug_PushStack "MBG_Finalize"
212
213    echo FINALIZE MBG !!!
214
215    IGCM_debug_PopStack "MBG_Finalize"
216}
217
Note: See TracBrowser for help on using the repository browser.