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

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

NEMO_v6 for OMIP : Add new version of sub-dir PARAM + update driver

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