source: CONFIG/UNIFORM/v6/NEMO_v6.5/GENERAL/DRIVER/opa9.driver @ 5125

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

NEMOv6.5 : update config

File size: 8.4 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function OCE_Initialize
4{
5    IGCM_debug_PushStack "OCE_Initialize"
6
7    if [ X$ResolOce != X ]; then
8       #ResolOce is set in config.card
9       RESOL_OCE=${ResolOce}
10    else
11       RESOL_OCE=${config_UserChoices_ExpType%%_*}
12    fi
13    ORCAGRID=${opa9_UserChoices_ORCA_version%%.*}
14    exptype=${config_UserChoices_ExpType##*/}
15
16    IGCM_debug_Print 1 " "
17    IGCM_debug_Print 1 "RESOL_OCE        : ${RESOL_OCE}"
18    IGCM_debug_Print 1 "ORCAGRID         : ${ORCAGRID}"
19    IGCM_debug_Print 1 "FORCING          : ${exptype}"
20    IGCM_debug_Print 1 "EXPERIMENT TYPE  : ${opa9_UserChoices_forcing}"
21
22# Local function to find namelists parameters
23supergrep () {
24    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
25}
26
27    OPA_RDT=$( supergrep rn_rdt ${SUBMIT_DIR}/PARAM/NAMELIST/${RESOL_OCE}/namelist_${opa9_UserChoices_forcing}_${exptype}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
28
29    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
30    # /!\ Needed by OPA namelist to compute file names /!\
31    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
32
33    (( OPA_NPDT_DAY  =  86400 / OPA_RDT ))
34    (( OPA_NPDT_YEAR  =  OPA_NPDT_DAY * 365     ))
35
36    IGCM_debug_Print 1 " "
37    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
38    IGCM_debug_Print 1 "OPA_NPDT_DAY   ${OPA_NPDT_DAY}"
39    IGCM_debug_Print 1 "OPA_NPDT_YEAR  ${OPA_NPDT_YEAR}"
40
41
42    IGCM_debug_PopStack "OCE_Initialize"
43}
44
45#-----------------------------------------------------------------
46function OCE_Update
47{
48    IGCM_debug_PushStack "OCE_Update"
49
50
51    V1D_ENABLE=".FALSE."
52    V5D_ENABLE=".FALSE."
53    V1M_ENABLE=".FALSE."
54    V1Y_ENABLE=".FALSE."
55
56    for frequency in ${config_OCE_WriteFrequency} ; do
57        case ${frequency} in
58            ( 1D|1d ) V1D_ENABLE=".TRUE." ;;
59            ( 5D|5d ) V5D_ENABLE=".TRUE." ;;
60            ( 1M|1m ) V1M_ENABLE=".TRUE." ;;
61            ( *[yY] ) V1Y_ENABLE=".TRUE." ;;
62        esac
63    done
64
65    if [ "${exptype}" = "ia"   ] ; then
66       NbFileInter=${#opa9_UserChoices_ListForcing[*]}
67       (( LengthForcing=${opa9_UserChoices_YearForcingEnd} - ${opa9_UserChoices_YearForcingInit} + 1 ))
68       (( DiffForcing=abs(${opa9_UserChoices_YearForcingEnd} - ${year} )))
69       (( ModuloForcing=${DiffForcing} % ${LengthForcing} ))
70      if [ ${ModuloForcing} -eq 0 ] ; then
71          (( year_forcing=${opa9_UserChoices_YearForcingEnd} ))
72       else
73          if [ ${year} -ge ${opa9_UserChoices_YearForcingInit} ] && [ ${year} -le ${opa9_UserChoices_YearForcingEnd} ] ; then
74             year_forcing=${year}
75          elif [ ${year} -lt ${opa9_UserChoices_YearForcingInit} ] ; then
76             (( year_forcing=${opa9_UserChoices_YearForcingEnd} - ${ModuloForcing} ))
77          else
78             (( year_forcing=${opa9_UserChoices_YearForcingInit} + ${ModuloForcing} - 1 ))
79          fi
80       fi
81       (( year_forcing_m1 = ${year_forcing} - 1))
82       (( year_forcing_p1 = ${year_forcing} + 1))
83       (( i = 0 ))
84       while [ $i -lt ${NbFileInter} ] ; do
85          eval file=${opa9_UserChoices_ListForcing[$i]}
86          IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_m1}.nc  ${file}_y${year_m1}.nc
87          IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing}.nc     ${file}_y${year}.nc
88          IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_p1}.nc  ${file}_y${year_p1}.nc
89          (( i = i + 1 ))
90       done
91
92    fi
93
94    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
95    # Needed by OPA namelist to compute correct file names
96    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
97
98    ## Count of number of time steps from begin of OPA job
99    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 ))
100    (( OPA_NDT   = PeriodLengthInDays * OPA_NPDT_DAY ))
101    (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
102
103    ## Forcing to write one restart file at the end of period
104    OPA_NSTOCK="${OPA_NITEND}"
105
106    ## Verification of number of time steps per day
107    (( NB_SEC_DAY_MODEL = OPA_NPDT_DAY * OPA_RDT ))
108    (( NB_SEC_DAY = 60 * 60 * 24 ))
109
110    if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ]
111        then
112        echo " NB_SEC_DAY_MODEL "${NB_SEC_DAY_MODEL} "NB_SEC_DAY" ${NB_SEC_DAY} "OPA_NPDT_DAY" ${OPA_NPDT_DAY} "OPA_RDT" ${OPA_RDT}
113        echo " VERIFY OPA_NPDT_DAY in opa9.card "
114        exit
115    fi
116
117   ##-- Restart configuration
118    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
119      OPA_LRSTAR=.FALSE.
120      OPA_NRSTDT=0
121      #echo "NO OPA RESTART"
122    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
123      OPA_LRSTAR=.TRUE.
124      OPA_NRSTDT=0
125      #echo "OPA RESTART"
126    else
127      OPA_LRSTAR=.TRUE.
128      OPA_NRSTDT=2
129      #echo "OPA RESTART"
130    fi
131
132   
133    OPA_NMSH=.FALSE.
134    if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then
135        OPA_NMSH=.TRUE.
136        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n"
137    fi
138
139    ## nleapy configuration
140    case ${config_UserChoices_CalendarType} in
141        ( leap|gregorian) OPA_NLEAPY=1  ;;
142        ( noleap        ) OPA_NLEAPY=0  ;;
143        ( 360d          ) OPA_NLEAPY=30 ;;
144        ( *             ) OPA_NLEAPY=30 ;;
145    esac
146
147
148   typeset -r PRECIS=8
149   NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
150
151
152   IGCM_comp_modifyNamelist blocker    namelist_cfg cn_exp    ${config_UserChoices_JobName}
153   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_it000  ${OPA_NIT000}
154   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_itend  ${OPA_NITEND}
155   IGCM_comp_modifyNamelist blocker    namelist_cfg ln_rstart ${OPA_LRSTAR}
156   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock  ${OPA_NSTOCK}
157   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_rstctl ${OPA_NRSTDT}
158   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0  ${PeriodDateBegin}
159   IGCM_comp_modifyNamelist nonblocker namelist_cfg ln_meshmask ${OPA_NMSH}
160   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy  ${OPA_NLEAPY} 
161
162   IGCM_debug_Print 1 'Informations into iodef.xml : V1D_ENABLE V5D_ENABLE V1M_ENABLE V1Y_ENABLE '
163   IGCM_debug_Print 1 ${V1D_ENABLE}  ${V5D_ENABLE} ${V1M_ENABLE} ${V1Y_ENABLE}
164
165   IGCM_comp_modifyXmlFile nonblocker file_def_nemo-oce.xml 1d_opa enabled ${V1D_ENABLE}
166   IGCM_comp_modifyXmlFile nonblocker file_def_nemo-oce.xml 5d_opa enabled ${V5D_ENABLE}
167   IGCM_comp_modifyXmlFile nonblocker file_def_nemo-oce.xml 1m_opa enabled ${V1M_ENABLE}
168   IGCM_comp_modifyXmlFile nonblocker file_def_nemo-oce.xml 1y_opa enabled ${V1Y_ENABLE}
169
170   IGCM_comp_modifyXmlFile nonblocker file_def_nemo-oce.xml 1d_opa output_level ${opa9_UserChoices_OutputLevel}
171   IGCM_comp_modifyXmlFile nonblocker file_def_nemo-oce.xml 5d_opa output_level ${opa9_UserChoices_OutputLevel}
172   IGCM_comp_modifyXmlFile nonblocker file_def_nemo-oce.xml 1m_opa output_level ${opa9_UserChoices_OutputLevel}
173   IGCM_comp_modifyXmlFile nonblocker file_def_nemo-oce.xml 1y_opa output_level ${opa9_UserChoices_OutputLevel}
174
175   IGCM_comp_modifyXmlFile force context_nemo.xml ref_year NONE ${InitYear} 
176
177
178   #Long Name as global attribute (if LongName is not empty)
179   if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
180      listfile=$(ls file_def_nemo*.xml)
181      echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
182      for file in ${listfile}
183        do
184            cp ${file} ${file}.tmp
185            sed -e "/<file id/r add.tmp" \
186                ${file}.tmp > ${file}
187            rm ${file}.tmp
188        done
189        rm add.tmp
190   fi
191
192# update domain_def.xml file
193   case ${RESOL_OCE} in
194       ( *ORCA025* ) 
195        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 
196         IGCM_sys_Mv domain_def.xml.tmp domain_def_nemo.xml  ;
197   esac
198
199   IGCM_debug_PopStack "OCE_Update"
200}
201
202#-----------------------------------
203function OCE_Finalize
204{
205    IGCM_debug_PushStack "OCE_Finalize"
206
207    if [ -f date.file ] ; then
208        # Prefix use in opa.card AND in lim2.card :
209        DATE_OPA=$( cat date.file | \
210            sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
211        ###DATE_OPA=$( $DATE_OPABF | cut -c1-30 )
212        MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
213        SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
214    fi
215
216    echo FINALIZE OCE !!!
217
218    IGCM_debug_PopStack "OCE_Finalize"
219}
220
Note: See TracBrowser for help on using the repository browser.