source: CONFIG/UNIFORM/v6/NEMO_v7_dev/GENERAL/DRIVER/opa9.driver @ 3221

Last change on this file since 3221 was 3186, checked in by flavoni, 5 years ago

add NEMO_v7_dev to run NEMO forced mode, trunk version

File size: 6.6 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function OCE_Initialize
4{
5    IGCM_debug_PushStack "OCE_Initialize"
6
7    RESOL_OCE=$( echo ${config_UserChoices_ExperimentName} | cut -c1-5 )
8    EXPTYPE=$( echo ${config_UserChoices_ExperimentName} | cut -c6- )
9
10# Local function to find namelists parameters
11supergrep () {
12    grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
13}
14
15    OPA_RDT=$( supergrep rn_rdt  ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}${EXPTYPE}_cfg | sed 's/ *rn_rdt *=//' | sed 's/\. *,//' )
16
17    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
18    # /!\ Needed by OPA namelist to compute file names /!\
19    (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 ))
20
21    (( OPA_NPDT_DAY  =  86400 / OPA_RDT ))
22    (( OPA_NPDT_YEAR  =  OPA_NPDT_DAY * 365     ))
23
24    IGCM_debug_Print 1 " "
25    IGCM_debug_Print 1 "OPA_RDT        ${OPA_RDT}"
26    IGCM_debug_Print 1 "OPA_NPDT_DAY   ${OPA_NPDT_DAY}"
27    IGCM_debug_Print 1 "OPA_NPDT_YEAR  ${OPA_NPDT_YEAR}"
28
29    IGCM_debug_PopStack "OCE_Initialize"
30}
31
32#-----------------------------------------------------------------
33function OCE_Update
34{
35    IGCM_debug_PushStack "OCE_Update"
36
37
38    if [ "${EXPTYPE}" = "ia"   ] ; then
39       NbFileInter=${#opa9_UserChoices_ListForcing[*]}
40       if [ ${year} -ge ${opa9_UserChoices_YearForcingInit} ] ; then
41          year_forcing=${year}
42       else
43          (( LengthForcing=${opa9_UserChoices_YearForcingEnd} - ${opa9_UserChoices_YearForcingInit} + 1 ))
44          (( DiffForcing=${opa9_UserChoices_YearForcingEnd} - ${year} ))
45          (( ModuloForcing=${opa9_UserChoices_YearForcingEnd} % ${LengthForcing} ))
46          (( year_forcing=${opa9_UserChoices_YearForcingEnd} - ${ModuloForcing} ))
47       fi
48       (( year_forcing_m1 = ${year_forcing} - 1))
49       (( year_forcing_p1 = ${year_forcing} + 1))
50       (( i = 0 ))
51        while [ $i -lt ${NbFileInter} ] ; do
52           eval file=${opa9_UserChoices_ListForcing[$i]}
53           IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_m1}.nc  ${file}_y${year_m1}.nc
54           IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing}.nc     ${file}_y${year}.nc
55           IGCM_sys_Get ${opa9_UserChoices_R_FORCING}/${file}_${year_forcing_p1}.nc  ${file}_y${year_p1}.nc
56           (( i = i + 1 ))
57        done
58    fi
59
60    NbFreq=$( echo ${config_OCE_WriteFrequency} | wc -w )
61    ##--Write Frequency Purpose ....
62    typeset -Z1 i=1
63    while [ $i -le ${NbFreq} ]; do
64        frequency=$( echo ${config_OCE_WriteFrequency} | awk -v var="$i" "-F " '{print $var}' )
65        factor=$( echo ${frequency} | sed -e "s/[yYmMdDhH]//" )
66
67        case ${frequency} in
68            *Y|*y)
69                eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}y_${DatesPeriod} ;
70                eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_Y} ;
71                eval WF${i}=${factor}Y ;;
72            *M|*m)
73                eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}m_${DatesPeriod} ;
74                eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_M} ;
75                eval WF${i}=${factor}M ;;
76            *D|*d)
77                eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}d_${DatesPeriod} ;
78                eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_D} ;
79                eval WF${i}=${factor}D ;;
80            *H|*h)
81                eval PREFIX_WF${i}=${config_UserChoices_JobName}_${factor}h_${DatesPeriod} ;
82                eval R_OUT_OCE_WF${i}=${R_OUT_OCE_O_H} ;
83                eval WF${i}=${factor}H ;;
84            *)
85        esac
86        let i=$i+1
87
88    done
89    # Period Length In Days between DateBegin and first day of calendar 0001 01 01
90    # Needed by OPA namelist to compute correct file names
91    (( PeriodDaysSinceJC =  $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1  ))
92
93    ## Count of number of time steps from begin of OPA job
94    (( OPA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * OPA_NPDT_DAY + 1 ))
95    (( OPA_NDT   = PeriodLengthInDays * OPA_NPDT_DAY ))
96    (( OPA_NITEND = OPA_NIT000 + OPA_NDT - 1))
97
98    ## Forcing to write one restart file at the end of period
99    OPA_NSTOCK="${OPA_NITEND}"
100
101    ## Verification of number of time steps per day
102    (( NB_SEC_DAY_MODEL = OPA_NPDT_DAY * OPA_RDT ))
103    (( NB_SEC_DAY = 60 * 60 * 24 ))
104
105    if [ ${NB_SEC_DAY_MODEL} -ne ${NB_SEC_DAY} ]
106        then
107        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}
108        echo " VERIFY OPA_NPDT_DAY in opa9.card "
109        exit
110    fi
111
112    ##-- Restart configuration
113    if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then
114
115        #echo "NO OPA RESTART"
116        OPA_LRSTAR=.FALSE.
117        OPA_NRSTDT=0
118    elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then
119
120        #echo "OPA RESTART"
121        OPA_LRSTAR=.TRUE.
122        OPA_NRSTDT=0
123    else
124
125        #echo "OPA RESTART"
126        OPA_LRSTAR=.TRUE.
127        OPA_NRSTDT=2
128    fi
129   
130    OPA_NMSH=0
131    if [ "${opa9_UserChoices_mesh_mask}" = "y" ]; then
132        OPA_NMSH=1
133        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/opa9.card UserChoices mesh_mask "n"
134    fi
135    ## nleapy configuration
136    case ${config_UserChoices_CalendarType} in
137        ( leap|gregorian) OPA_NLEAPY=1  ;;
138        ( noleap        ) OPA_NLEAPY=0  ;;
139        ( 360d          ) OPA_NLEAPY=30 ;;
140        ( *             ) OPA_NLEAPY=30 ;;
141    esac
142
143   typeset -r PRECIS=8
144   NEMO_END=$( echo $( awk "BEGIN { printf \"%0${PRECIS}d\",${OPA_NITEND} }" ) ) 
145
146   IGCM_comp_modifyNamelist blocker    namelist_cfg cn_exp    ${config_UserChoices_JobName}
147   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_it000  ${OPA_NIT000}
148   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_itend  ${OPA_NITEND}
149   IGCM_comp_modifyNamelist blocker    namelist_cfg ln_rstart ${OPA_LRSTAR}
150   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_stock ${OPA_NSTOCK}
151   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_rstctl ${OPA_NRSTDT}
152   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_date0 ${PeriodDateBegin}
153   IGCM_comp_modifyNamelist nonblocker namelist_cfg nn_msh    ${OPA_NMSH}
154   IGCM_comp_modifyNamelist blocker    namelist_cfg nn_leapy  ${OPA_NLEAPY} 
155
156   IGCM_debug_PopStack "OCE_Update"
157}
158
159#-----------------------------------
160function OCE_Finalize
161{
162    IGCM_debug_PushStack "OCE_Finalize"
163
164    if [ -f date.file ] ; then
165        # Prefix use in opa.card AND in lim2.card :
166        DATE_OPA=$( cat date.file | \
167            sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_\ */\1/g" )
168        ###DATE_OPA=$( $DATE_OPABF | cut -c1-30 )
169        MainPrefix=${config_UserChoices_JobName}_1d_${DATE_OPA}
170        SecondPrefix=${config_UserChoices_JobName}_5d_${DATE_OPA}
171    fi
172
173    echo FINALIZE OCE !!!
174
175    IGCM_debug_PopStack "OCE_Finalize"
176}
177
Note: See TracBrowser for help on using the repository browser.