1 | #!/bin/ksh |
---|
2 | #----------------------------------------------------------------- |
---|
3 | function OCE_Initialize |
---|
4 | { |
---|
5 | IGCM_debug_PushStack "OCE_Initialize" |
---|
6 | |
---|
7 | JOB_NAME=${config_UserChoices_JobName} |
---|
8 | RESOL_OCE=$( echo $RESOL | awk "-Fx" '{print $1}' ) |
---|
9 | |
---|
10 | if [ -z "${opa_UserChoices_OPA_NPDT_JOURS}" ] ; then |
---|
11 | ORCA_NPDT_JOUR=15 |
---|
12 | else |
---|
13 | ORCA_NPDT_JOUR=${opa_UserChoices_OPA_NPDT_JOURS} |
---|
14 | fi |
---|
15 | |
---|
16 | ##--Transformation namelist fortran 77 --> fortran 90 |
---|
17 | # ? ? Is it really necessary ? ? |
---|
18 | #sed -e /:/d -e s/" \&END"/"\/"/ -e s/" \&"/"\&"/ ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} > ${SUBMIT_DIR}/PARAM/namelist |
---|
19 | |
---|
20 | ##--Variables used by OPA -- |
---|
21 | |
---|
22 | # cexper experience name for vairmer format |
---|
23 | # nit000 number of the first time step |
---|
24 | # nitend number of the last time step |
---|
25 | # nbisex Leap year calendar (0/1) (30 for 360d) |
---|
26 | # nwrite frequency of OUTPUT file |
---|
27 | # nwrihf frequency of HF OUTPUT file |
---|
28 | # lrstar boolean term for restart (true or false) |
---|
29 | # nstock frequency of restart file |
---|
30 | # nrstdt control of the time step (0, 1 or 2) |
---|
31 | # ndate0 initial calendar date aammjj |
---|
32 | # nmsh =1 create a mesh file (coordinates, scale factors, masks) |
---|
33 | |
---|
34 | PAT_CEXPER=$( grep 'cexper' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
35 | PAT_NIT000=$( grep 'nit000' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
36 | PAT_NITEND=$( grep 'nitend' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
37 | PAT_NBISEX=$( grep 'nbisex =' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE}| sed 's/ nbisex =//' |sed '/^[ ]$/d'|sed 's/,//' ) |
---|
38 | PAT_NWRITE=$( grep 'nwrite' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
39 | PAT_RESTAR=$( grep 'lrstar' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
40 | PAT_NSTOCK=$( grep 'nstock' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
41 | PAT_NRSTAR=$( grep 'nrstdt' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
42 | PAT_NPRG=$( grep 'nprg' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
43 | PAT_NDATE0=$( grep 'ndate0' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
44 | PAT_NMSH=$( grep 'nmsh' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
45 | PAT_NWRIHF=$( grep 'nwrihf' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} ) |
---|
46 | |
---|
47 | ORCA_NSTOCK=$( echo $PAT_NSTOCK | sed "s/[a-z,A-Z,=]//g" ) |
---|
48 | ORCA_RDT=$( egrep 'rdt *=' ${SUBMIT_DIR}/PARAM/namelist_${RESOL_OCE} | sed 's/ *rdt *=//' | sed 's/\. *,//' ) |
---|
49 | |
---|
50 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
51 | # /!\ Needed by OPA namelist to compute file names /!\ |
---|
52 | (( DaysSinceJC = $( IGCM_date_DaysSinceJC ${DateBegin} ) + 1 )) |
---|
53 | |
---|
54 | IGCM_debug_PopStack "OCE_Initialize" |
---|
55 | } |
---|
56 | |
---|
57 | #----------------------------------------------------------------- |
---|
58 | function OCE_Update |
---|
59 | { |
---|
60 | IGCM_debug_PushStack "OCE_Update" |
---|
61 | |
---|
62 | ##--Write Frequency Purpose .... |
---|
63 | for frequency in ${config_OCE_WriteFrequency} ; do |
---|
64 | case ${frequency} in |
---|
65 | 5D|5d) (( ORCA_NWRIHF=ORCA_NPDT_JOUR*5 )) ;; |
---|
66 | 1D|1d) (( ORCA_NWRIHF=ORCA_NPDT_JOUR )) ;; |
---|
67 | *) (( ORCA_NWRIHF=0 )) ;; |
---|
68 | esac |
---|
69 | done |
---|
70 | |
---|
71 | (( ORCA_NWRITE = ORCA_NPDT_JOUR * PeriodLengthInDays )) |
---|
72 | |
---|
73 | # Period Length In Days between DateBegin and first day of calendar 0001 01 01 |
---|
74 | # Needed by OPA namelist to compute correct file names |
---|
75 | (( PeriodDaysSinceJC = $( IGCM_date_DaysSinceJC ${PeriodDateBegin} ) + 1 )) |
---|
76 | |
---|
77 | ##-- Calcul du numero de pas de temps de debut de job ORCA |
---|
78 | (( ORCA_NIT000 = ( PeriodDaysSinceJC - DaysSinceJC ) * ORCA_NPDT_JOUR + 1 )) |
---|
79 | (( ORCA_NPDT = PeriodLengthInDays * ORCA_NPDT_JOUR )) |
---|
80 | (( ORCA_NITEND = ORCA_NIT000 + ORCA_NPDT - 1)) |
---|
81 | |
---|
82 | if [ "${ORCA_NSTOCK}" -gt "${ORCA_NPDT}" ] |
---|
83 | then |
---|
84 | ORCA_NSTOCK="${ORCA_NPDT}" |
---|
85 | fi |
---|
86 | |
---|
87 | ##-- verification du nb de pas de temps par jour |
---|
88 | (( NB_SEC_JOUR_MODEL = ORCA_NPDT_JOUR * ORCA_RDT )) |
---|
89 | (( NB_SEC_JOUR = 60 * 60 * 24 )) |
---|
90 | |
---|
91 | if [ ${NB_SEC_JOUR_MODEL} -ne ${NB_SEC_JOUR} ] |
---|
92 | then |
---|
93 | echo " VERIFIER ORCA_NPDT_JOUR dans le job ${JOB} " |
---|
94 | exit |
---|
95 | fi |
---|
96 | |
---|
97 | ##-- Restart configuration |
---|
98 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "n" ] ) ; then |
---|
99 | |
---|
100 | ORCA_LRSTAR=.FALSE. |
---|
101 | ORCA_NRSTDT=0 |
---|
102 | ORCA_NMSH=1 |
---|
103 | # ??? a garder ??? |
---|
104 | # cat <<EOF > EMPave_old.dat |
---|
105 | # Old global EMP coeff = 1.000000000 |
---|
106 | # EOF |
---|
107 | |
---|
108 | #echo "PAS DE RESTART OPA" |
---|
109 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_OCE_Restart}" = "y" ] ) ; then |
---|
110 | |
---|
111 | ORCA_LRSTAR=.TRUE. |
---|
112 | ORCA_NRSTDT=0 |
---|
113 | ORCA_NMSH=0 |
---|
114 | |
---|
115 | #echo "RESTART OPA" |
---|
116 | else |
---|
117 | |
---|
118 | ORCA_LRSTAR=.TRUE. |
---|
119 | ORCA_NRSTDT=1 |
---|
120 | ORCA_NMSH=0 |
---|
121 | |
---|
122 | #echo "RESTART OPA" |
---|
123 | fi |
---|
124 | |
---|
125 | sed -e "s/${PAT_CEXPER}/ cexper=\"${config_UserChoices_JobName}\"/" \ |
---|
126 | -e "s/${PAT_NIT000}/ nit000=${ORCA_NIT000}/" \ |
---|
127 | -e "s/${PAT_NITEND}/ nitend=${ORCA_NITEND}/" \ |
---|
128 | -e "s/${PAT_NWRITE}/ nwrite=${ORCA_NWRITE}/" \ |
---|
129 | -e "s/${PAT_RESTAR}/ lrstar=${ORCA_LRSTAR}/" \ |
---|
130 | -e "s/${PAT_NPRG}/ nprg=${ORCA_NWRITE}/" \ |
---|
131 | -e "s/${PAT_NSTOCK}/ nstock=${ORCA_NSTOCK}/" \ |
---|
132 | -e "s/${PAT_NRSTAR}/ nrstdt=${ORCA_NRSTDT}/" \ |
---|
133 | -e "s/${PAT_NDATE0}/ ndate0=${PeriodDateBegin}/" \ |
---|
134 | -e "s/${PAT_NMSH}/ nmsh=${ORCA_NMSH}/" \ |
---|
135 | -e "s/${PAT_NWRIHF}/ nwrihf=${ORCA_NWRIHF}/" \ |
---|
136 | namelist > namelist.tmp |
---|
137 | |
---|
138 | IGCM_sys_Mv namelist.tmp namelist |
---|
139 | |
---|
140 | IGCM_debug_PopStack "OCE_Update" |
---|
141 | } |
---|
142 | |
---|
143 | #----------------------------------- |
---|
144 | function OCE_Finalize |
---|
145 | { |
---|
146 | IGCM_debug_PushStack "OCE_Finalize" |
---|
147 | |
---|
148 | if [ -f date.file ] ; then |
---|
149 | # Prefix use in opa.card AND in lim.card : |
---|
150 | DATE_OPA=$( cat date.file | \ |
---|
151 | sed "s/\ ${config_UserChoices_JobName}_[0-9]*[a-z]_\([0-9]*_[0-9]*\)_output\ */\1/g" ) |
---|
152 | PREFIX_DA=${config_UserChoices_JobName}_1d_${DATE_OPA} |
---|
153 | PREFIX_5D=${config_UserChoices_JobName}_5d_${DATE_OPA} |
---|
154 | PREFIX_MO=${config_UserChoices_JobName}_1m_${DATE_OPA} |
---|
155 | fi |
---|
156 | |
---|
157 | echo FINALIZE OCE !!! |
---|
158 | |
---|
159 | IGCM_debug_PopStack "OCE_Finalize" |
---|
160 | } |
---|