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

Last change on this file since 4912 was 4912, checked in by cetlod, 4 years ago

Adding new NEMO configuration using NEMO_v4 model

File size: 9.8 KB
Line 
1#!/bin/ksh
2
3#-----------------------------------
4function MBG_Initialize
5{ 
6    IGCM_debug_PushStack "MBG_Initialize"
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
14       RESOL_OCE=${config_UserChoices_ExpType%%_*}
15       exptype=${config_UserChoices_ExpType##*/}
16
17       IGCM_debug_Print 1 " "
18       IGCM_debug_Print 1 "RESOL_OCE        : ${RESOL_OCE}"
19       IGCM_debug_Print 1 "EXPERIMENT TYPE  : ${exptype}"
20
21       OPA_RDT=$( supergrep rn_rdt  ${SUBMIT_DIR}/PARAM/NAMELIST/${RESOL_OCE}/namelist_offline_${exptype}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
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
26       (( OPA_NPDT_DAY  =  86400 / OPA_RDT ))
27       (( OPA_NPDT_YEAR  =  OPA_NPDT_DAY * 365     ))
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
35     fi
36
37    IGCM_debug_PopStack "MBG_Initialize"
38}
39
40#-----------------------------------
41function MBG_Update
42{
43    IGCM_debug_PushStack "MBG_Update"
44
45   
46    ##--Write Frequency for iomput
47    ## Differents frequencies are allowed for MBG files
48
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
55        case ${frequency} in
56            ( 1D|1d ) VT1D_ENABLE=".TRUE." ;;
57            ( 5D|5d ) VT5D_ENABLE=".TRUE." ;;
58            ( 1M|1m ) VT1M_ENABLE=".TRUE." ;;
59            ( *[yY] ) VT1Y_ENABLE=".TRUE." ;;
60        esac
61    done
62
63
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
71       (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 ))
72       (( OPA_NDT   = PeriodLengthInDays * OPA_NPDT_DAY ))
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} }" ) )
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             ln -sf ${RunFileName}_y${year}.nc ${RunFileName}.nc
125             (( i = i + 1 ))
126          done
127          if [ ${year_forcing} = ${pisces_UserChoices_DynYearStart} ] ; then
128             DYN_SSH_INI=.TRUE.
129          else
130             DYN_SSH_INI=.FALSE
131          fi
132       fi
133    fi
134
135    ##-- Restart configuration
136    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then
137
138        #echo "NO RESTART FOR TOP"
139        TOP_LRSTTR=.FALSE.
140        TOP_NRSTTR=0
141
142    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then
143
144        #echo "RESTART TOP"
145        TOP_LRSTTR=.TRUE.
146        TOP_NRSTTR=0
147
148    else
149
150        #echo "RESTART TOP"
151        TOP_LRSTTR=.TRUE.
152        TOP_NRSTTR=2
153    fi
154
155# on force les sorties PISCES comme les sorties OPA
156    if [ X"${pisces_UserChoices_Offline_Mode}" = X"y" ] ; then
157      IGCM_comp_modifyNamelist blocker    namelist_cfg cn_exp    ${config_UserChoices_JobName}
158      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_it000  ${OPA_NIT000}
159      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_itend  ${OPA_NITEND}
160      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock ${OPA_NSTOCK}
161      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0 ${PeriodDateBegin}
162      IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy  ${OPA_NLEAPY}
163
164# update domain_def.xml file
165      case ${RESOL_OCE} in
166          ( *ORCA025* ) 
167            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 
168            IGCM_sys_Mv domain_def.xml.tmp domain_def_nemo.xml  ;
169      esac
170
171      IGCM_comp_modifyXmlFile force context_nemo.xml ref_year NONE ${InitYear}
172
173   fi
174
175   if [ X"${pisces_UserChoices_age}" = X"y" ] ; then
176      echo "Activate age tracer"
177      TOP_AGE=.TRUE.
178      IGCM_comp_modifyXmlFile force file_def_nemo-pisces.xml file38 enabled .TRUE.
179   else
180      TOP_AGE=.FALSE.
181      IGCM_comp_modifyXmlFile force file_def_nemo-pisces.xml file38 enabled .FALSE.
182   fi
183##
184   if [ X"${pisces_UserChoices_cfc11}" = X"y" ] ; then
185      echo "Activate CFC11  tracer"
186      TOP_CFC11=.TRUE.
187      IGCM_comp_modifyXmlFile force file_def_nemo-pisces.xml file39 enabled .FALSE.
188   else
189      TOP_CFC11=.FALSE.
190      IGCM_comp_modifyXmlFile force file_def_nemo-pisces.xml file39 enabled .FALSE.
191   fi
192##
193   if [ X"${pisces_UserChoices_cfc12}" = X"y" ] ; then
194      echo "Activate CFC12  tracer"
195      TOP_CFC12=.TRUE.
196      IGCM_comp_modifyXmlFile force file_def_nemo-pisces.xml file40 enabled .TRUE.
197   else
198      TOP_CFC12=.FALSE.
199      IGCM_comp_modifyXmlFile force file_def_nemo-pisces.xml file40 enabled .FALSE.
200   fi
201##
202   if [ X"${pisces_UserChoices_Co2Anthr}" = X"y" ] ; then
203      LCO2INT=.TRUE.
204   else
205      LCO2INT=.FALSE.
206   fi
207   ##-- Update namelist_top_cfg and namelist_pisces_cfg
208    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_rsttr  ${TOP_LRSTTR}
209    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     nn_rsttr  ${TOP_NRSTTR}
210    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_age    ${TOP_AGE}
211    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_cfc11  ${TOP_CFC11}
212    IGCM_comp_modifyNamelist blocker    namelist_top_cfg     ln_cfc12  ${TOP_CFC12}
213    IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  ln_co2int ${LCO2INT}
214    IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  atcco2    ${pisces_UserChoices_AtmCo2}
215    IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  nrdttrc   ${pisces_UserChoices_PisFreq}
216    IGCM_comp_modifyNamelist blocker    namelist_pisces_cfg  nn_pisdmp ${OPA_NPDT_YEAR}
217
218 
219    # Update iodef.xml
220
221    IGCM_debug_Print 1 'Informations into iodef.xml : VT1D_ENABLE VT5D_ENABLE VT1M_ENABLE VT1Y_ENABLE '
222    IGCM_debug_Print 1 ${VT1D_ENABLE}  ${VT5D_ENABLE} ${VT1M_ENABLE} ${VT1Y_ENABLE}
223
224    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1d_pis enabled ${VT1D_ENABLE}
225    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 5d_pis enabled ${VT5D_ENABLE}
226    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1m_pis enabled ${VT1M_ENABLE}
227    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1y_pis enabled ${VT1Y_ENABLE}
228
229    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1d_pis output_level ${pisces_UserChoices_OutputLevel}
230    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 5d_pis output_level ${pisces_UserChoices_OutputLevel}
231    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1m_pis output_level ${pisces_UserChoices_OutputLevel}
232    IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1y_pis output_level ${pisces_UserChoices_OutputLevel}
233
234
235
236   IGCM_debug_PopStack "MBG_Update"
237}
238
239#-----------------------------------
240function MBG_Finalize
241{
242    IGCM_debug_PushStack "MBG_Finalize"
243
244    echo FINALIZE MBG !!!
245
246    IGCM_debug_PopStack "MBG_Finalize"
247}
248
Note: See TracBrowser for help on using the repository browser.