[6] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #D- Driver du script pour SPINUP (off-line) |
---|
| 4 | |
---|
| 5 | function ORCHIDEE_sed |
---|
| 6 | { |
---|
| 7 | IGCM_debug_PushStack "ORCHIDEE_sed" |
---|
| 8 | |
---|
| 9 | sed -e "s/^${1}\ *=.*/${1}= ${2}/" \ |
---|
| 10 | ${New_SUBMIT_DIR}/PARAM/orchidee.def > ${New_SUBMIT_DIR}/PARAM/orchidee.def.tmp |
---|
| 11 | RET=$? |
---|
| 12 | echo "ORCHIDEE_sed : ${1} ${2}" |
---|
| 13 | \mv ${New_SUBMIT_DIR}/PARAM/orchidee.def.tmp ${New_SUBMIT_DIR}/PARAM/orchidee.def |
---|
| 14 | |
---|
| 15 | IGCM_debug_PopStack "ORCHIDEE_sed" |
---|
| 16 | return $RET |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | #----------------------------------------------------------------- |
---|
| 20 | function SPIN_Initialize |
---|
| 21 | { |
---|
| 22 | IGCM_debug_PushStack "SPIN_Initialize" |
---|
| 23 | |
---|
| 24 | # No parallelization for spinup job ! |
---|
| 25 | BATCH_NUM_PROC_TOT="" |
---|
| 26 | |
---|
| 27 | RESOL=${spinup_UserChoices_RESOL} |
---|
| 28 | |
---|
| 29 | # Copy initial output card for spinup job : |
---|
| 30 | if [ ! -f ${SUBMIT_DIR}/output.card ] ; then |
---|
| 31 | IGCM_sys_Cp ${SUBMIT_DIR}/output.card_init ${SUBMIT_DIR}/output.card |
---|
| 32 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Path "${SUBMIT_DIR}" |
---|
| 33 | iter=0 |
---|
| 34 | else |
---|
| 35 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/output.card Global |
---|
| 36 | iter=${output_Global_Iteration} |
---|
| 37 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/output.card PreviousStage |
---|
| 38 | LastStageName=${output_Stage_LastStageName} |
---|
| 39 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/output.card Stage |
---|
| 40 | StageName=${output_Stage_StageName} |
---|
| 41 | fi |
---|
| 42 | |
---|
| 43 | # Compute DateEnd for ALL SPINUP |
---|
| 44 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 45 | ok_stom=1 |
---|
| 46 | else |
---|
| 47 | ok_stom=0 |
---|
| 48 | fi |
---|
| 49 | |
---|
| 50 | # Compute Spinup dates |
---|
| 51 | case ${config_UserChoices_PeriodLength} in |
---|
| 52 | *Y|*y) |
---|
| 53 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' "{print ${config_UserChoices_PeriodLength}}" ) |
---|
| 54 | ;; |
---|
| 55 | *) |
---|
| 56 | PeriodLengthInYears=1 |
---|
| 57 | esac |
---|
| 58 | |
---|
| 59 | # We must count only one PeriodLength (=${PeriodLengthInYears}) for each teststomate or forcesoil step. |
---|
| 60 | This_SpinUp_Length_In_Years=$(( \ |
---|
| 61 | ( ${spinup_UserChoices_duree_nostomate} * ( 1 - ${ok_stom} ) ) \ |
---|
| 62 | + ( ${spinup_UserChoices_duree_inistomate} + ${PeriodLengthInYears} ) * ${ok_stom} \ |
---|
| 63 | + ${spinup_UserChoices_n_iter} * ${spinup_UserChoices_duree_sechiba} \ |
---|
| 64 | + ${spinup_UserChoices_n_iter} * ${ok_stom} * ( ${PeriodLengthInYears} + ${PeriodLengthInYears} ) \ |
---|
| 65 | + ${spinup_UserChoices_duree_final} )) |
---|
| 66 | |
---|
| 67 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
| 68 | if [ X"${config_UserChoices_CalendarType}" = X"360d" ] ; then |
---|
| 69 | This_SpinUp_DateEnd=$(( year + This_SpinUp_Length_In_Years - 1 ))1230 |
---|
| 70 | This_SpinUp_HumanDateEnd=$(( year + This_SpinUp_Length_In_Years - 1 ))-12-30 |
---|
| 71 | else |
---|
| 72 | This_SpinUp_DateEnd=$(( year + This_SpinUp_Length_In_Years - 1 ))1231 |
---|
| 73 | This_SpinUp_HumanDateEnd=$(( year + This_SpinUp_Length_In_Years - 1 ))-12-31 |
---|
| 74 | fi |
---|
| 75 | IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices DateEnd ${This_SpinUp_HumanDateEnd} |
---|
| 76 | echo "SPINUP NEW Job DateEnd : " ${This_SpinUp_HumanDateEnd} |
---|
| 77 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${This_SpinUp_DateEnd} ${DateBegin} ) + 1 )) |
---|
| 78 | |
---|
| 79 | # Subjobs configuration : |
---|
| 80 | # ----------------------- |
---|
| 81 | |
---|
| 82 | # 1) SRF section of config.card |
---|
| 83 | # This section gives first restart file path, WriteFrequency and Post-treatment behaviour. |
---|
| 84 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SRF |
---|
| 85 | set +A config_SRF -- ${config_SRF[*]} > /dev/null 2>&1 |
---|
| 86 | typeset option |
---|
| 87 | for option in ${config_SRF[*]} ; do |
---|
| 88 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF ${option} |
---|
| 89 | done |
---|
| 90 | |
---|
| 91 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 92 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card SBG |
---|
| 93 | set +A config_SBG -- ${config_SBG[*]} > /dev/null 2>&1 |
---|
| 94 | typeset option |
---|
| 95 | for option in ${config_SBG[*]} ; do |
---|
| 96 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG ${option} |
---|
| 97 | done |
---|
| 98 | fi |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | # 2) Subjob orchidee.def parametrisation : SubJobParams in spinup.card |
---|
| 102 | # This section give flags to put in orchidee.def of Subjobs. |
---|
| 103 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/COMP/spinup.card SubJobParams |
---|
| 104 | set +A spinup_SubJobParams -- ${spinup_SubJobParams[*]} > /dev/null 2>&1 |
---|
| 105 | |
---|
| 106 | eval first_option=${spinup_SubJobParams[0]} > /dev/null 2>&1 |
---|
| 107 | if [ X${first_option} != X"Error:" ] ; then |
---|
| 108 | typeset option |
---|
| 109 | for option in ${spinup_SubJobParams[*]} ; do |
---|
| 110 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobParams ${option} |
---|
| 111 | done |
---|
| 112 | fi |
---|
| 113 | |
---|
| 114 | # Get the forcing file name (structure with variables inside) for this Spinup |
---|
| 115 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobForcingFile List |
---|
| 116 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobForcingFile ListNonDel |
---|
| 117 | |
---|
| 118 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobPost sechiba_TimeSeriesVars2D |
---|
| 119 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobPost sechiba_TimeSeriesVars3D |
---|
| 120 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 121 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobPost stomate_TimeSeriesVars2D |
---|
| 122 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/COMP/spinup.card SubJobPost stomate_TimeSeriesVars3D |
---|
| 123 | fi |
---|
| 124 | IGCM_debug_PopStack "SPIN_Initialize" |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | #----------------------------------------------------------------- |
---|
| 128 | function SPIN_Cp_Job |
---|
| 129 | { |
---|
| 130 | IGCM_debug_PushStack "SPIN_Cp_Job" |
---|
| 131 | |
---|
| 132 | typeset Path_Job_Ini New_Name |
---|
| 133 | |
---|
| 134 | # Where to find the standard cards/drivers for this job |
---|
| 135 | Path_Job_Ini=$1 |
---|
| 136 | |
---|
| 137 | # New Name for the Job : |
---|
| 138 | New_Name=$2 |
---|
| 139 | # New Path for the job |
---|
| 140 | New_SUBMIT_DIR=${SUBMIT_DIR}/${New_Name} |
---|
| 141 | |
---|
| 142 | # Copy the standard sub-job in the ${SUBMIT_DIR} with the New_Name |
---|
| 143 | IGCM_sys_Cp -Rp ${Path_Job_Ini} ${New_SUBMIT_DIR} |
---|
| 144 | |
---|
| 145 | # Install this directory |
---|
| 146 | # modifications on config.card |
---|
| 147 | MyJobName=${config_UserChoices_JobName} |
---|
| 148 | IGCM_card_DefineVariableFromOption ${New_SUBMIT_DIR}/config.card UserChoices JobName |
---|
| 149 | OldJobName=${config_UserChoices_JobName} |
---|
| 150 | |
---|
| 151 | SubJobName=${MyJobName}${New_Name} |
---|
| 152 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobName ${SubJobName} |
---|
| 153 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices TagName ${config_UserChoices_TagName} |
---|
| 154 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobClass ${config_UserChoices_JobClass} |
---|
| 155 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot} |
---|
| 156 | sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card |
---|
| 157 | IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card |
---|
| 158 | |
---|
| 159 | # keep the spinup JobName |
---|
| 160 | config_UserChoices_JobName=${MyJobName} |
---|
| 161 | |
---|
| 162 | # modifications on Job |
---|
| 163 | \rm ${New_SUBMIT_DIR}/Job_${OldJobName} |
---|
| 164 | |
---|
| 165 | sed -e "s/ ${MyJobName} / ${New_Name} /" \ |
---|
| 166 | -e "s/Script_Output_${MyJobName}.000001 /Script_Output_${New_Name}.000001 /" \ |
---|
| 167 | ${SUBMIT_DIR}/Job_${MyJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 168 | chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 169 | |
---|
| 170 | IGCM_sys_Cp ${SUBMIT_DIR}/PARAM/orchidee.def ${New_SUBMIT_DIR}/PARAM/orchidee.def |
---|
| 171 | |
---|
| 172 | eval first_option=${spinup_SubJobParams[0]} > /dev/null 2>&1 |
---|
| 173 | if [ X${first_option} != X"Error:" ] ; then |
---|
| 174 | typeset option |
---|
| 175 | for option in ${spinup_SubJobParams[*]} ; do |
---|
| 176 | eval echo "${option}="\${spinup_SubJobParams_${option}} |
---|
| 177 | eval ORCHIDEE_sed ${option} \${spinup_SubJobParams_${option}} |
---|
| 178 | done |
---|
| 179 | fi |
---|
| 180 | |
---|
| 181 | IGCM_debug_PopStack "SPIN_Cp_Job" |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | function SPIN_prepare |
---|
| 185 | { |
---|
| 186 | IGCM_debug_PushStack "SPIN_prepare" |
---|
| 187 | |
---|
| 188 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Restarts OverRule n |
---|
| 189 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card OOL Restart n |
---|
| 190 | |
---|
| 191 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF TimeSeriesFrequency |
---|
| 192 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF SeasonalFrequency |
---|
| 193 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post TimeSeriesFrequency ${config_SRF_TimeSeriesFrequency} |
---|
| 194 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post SeasonalFrequency ${config_SRF_SeasonalFrequency} |
---|
| 195 | |
---|
| 196 | # For Subjob special flags |
---|
| 197 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card UserChoices ROUTING ${spinup_UserChoices_ok_routing} |
---|
| 198 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card UserChoices NEWHYDROL ${spinup_UserChoices_ok_newhydrol} |
---|
| 199 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card UserChoices LAIMAP ${spinup_UserChoices_lai_map} |
---|
| 200 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card UserChoices OKCO2 ${spinup_UserChoices_ok_co2} |
---|
| 201 | |
---|
| 202 | if [ X${spinup_UserChoices_BoundaryFilesListNonDel} = Xy ] ; then |
---|
| 203 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card BoundaryFiles ListNonDel "()" |
---|
| 204 | fi |
---|
| 205 | |
---|
| 206 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card UserChoices NORESTART ${spinup_UserChoices_DRIVER_NORESTART} |
---|
| 207 | |
---|
| 208 | spinup_SubJobForcingFile_List0=${spinup_SubJobForcingFile_List[0]} > /dev/null 2>&1 |
---|
| 209 | if [ X${spinup_SubJobForcingFile_List0} != X${NULL_STR} ] ; then |
---|
| 210 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card BoundaryFiles List "("$( echo ${spinup_SubJobForcingFile_List[@]} | sed -e "s/ /,/g" )")" |
---|
| 211 | else |
---|
| 212 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card BoundaryFiles List "()" |
---|
| 213 | fi |
---|
| 214 | |
---|
| 215 | spinup_SubJobForcingFile_ListNonDel0=${spinup_SubJobForcingFile_ListNonDel[0]} > /dev/null 2>&1 |
---|
| 216 | if [ X${spinup_SubJobForcingFile_ListNonDel0} != X${NULL_STR} ] ; then |
---|
| 217 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card BoundaryFiles ListNonDel "("$( echo ${spinup_SubJobForcingFile_ListNonDel[@]} | sed -e "s/ /,/g" )")" |
---|
| 218 | else |
---|
| 219 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee_ol.card BoundaryFiles ListNonDel "()" |
---|
| 220 | fi |
---|
| 221 | |
---|
| 222 | IGCM_debug_PopStack "SPIN_prepare" |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | #----------------------------------------------------------------- |
---|
| 226 | function SPIN_OptionsSechiba |
---|
| 227 | { |
---|
| 228 | IGCM_debug_PushStack "SPIN_OptionsSechiba" |
---|
| 229 | |
---|
| 230 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card UserChoices sechiba_LEVEL ${spinup_UserChoices_sechiba_LEVEL} |
---|
| 231 | spinup_SubJobPost_sechiba_TimeSeriesVars0=${spinup_SubJobPost_sechiba_TimeSeriesVars2D[0]} > /dev/null 2>&1 |
---|
| 232 | if [ X${spinup_SubJobPost_sechiba_TimeSeriesVars0} != X${NULL_STR} ] ; then |
---|
| 233 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card Post_1M_sechiba_history TimeSeriesVars2D "("$( echo ${spinup_SubJobPost_sechiba_TimeSeriesVars[@]} | sed -e "s/ /,/g" )")" |
---|
| 234 | else |
---|
| 235 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card Post_1M_sechiba_history TimeSeriesVars2D "()" |
---|
| 236 | fi |
---|
| 237 | spinup_SubJobPost_sechiba_TimeSeriesVars0=${spinup_SubJobPost_sechiba_TimeSeriesVars3D[0]} > /dev/null 2>&1 |
---|
| 238 | if [ X${spinup_SubJobPost_sechiba_TimeSeriesVars0} != X${NULL_STR} ] ; then |
---|
| 239 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card Post_1M_sechiba_history TimeSeriesVars3D "("$( echo ${spinup_SubJobPost_sechiba_TimeSeriesVars[@]} | sed -e "s/ /,/g" )")" |
---|
| 240 | else |
---|
| 241 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card Post_1M_sechiba_history TimeSeriesVars3D "()" |
---|
| 242 | fi |
---|
| 243 | |
---|
| 244 | IGCM_debug_PopStack "SPIN_OptionsSechiba" |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | #----------------------------------------------------------------- |
---|
| 248 | function SPIN_OptionsStomate |
---|
| 249 | { |
---|
| 250 | IGCM_debug_PushStack "SPIN_OptionsStomate" |
---|
| 251 | |
---|
| 252 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card UserChoices stomate_LEVEL ${spinup_UserChoices_stomate_LEVEL} |
---|
| 253 | spinup_SubJobPost_stomate_TimeSeriesVars0=${spinup_SubJobPost_stomate_TimeSeriesVars2D[0]} > /dev/null 2>&1 |
---|
| 254 | if [ X${spinup_SubJobPost_stomate_TimeSeriesVars0} != X${NULL_STR} ] ; then |
---|
| 255 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card Post_1M_stomate_history TimeSeriesVars2D "("$( echo ${spinup_SubJobPost_stomate_TimeSeriesVars2D[@]} | sed -e "s/ /,/g" )")" |
---|
| 256 | else |
---|
| 257 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card Post_1M_stomate_history TimeSeriesVars3D "()" |
---|
| 258 | fi |
---|
| 259 | spinup_SubJobPost_stomate_TimeSeriesVars0=${spinup_SubJobPost_stomate_TimeSeriesVars3D[0]} > /dev/null 2>&1 |
---|
| 260 | if [ X${spinup_SubJobPost_stomate_TimeSeriesVars0} != X${NULL_STR} ] ; then |
---|
| 261 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card Post_1M_stomate_history TimeSeriesVars3D "("$( echo ${spinup_SubJobPost_stomate_TimeSeriesVars3D[@]} | sed -e "s/ /,/g" )")" |
---|
| 262 | else |
---|
| 263 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card Post_1M_stomate_history TimeSeriesVars3D "()" |
---|
| 264 | fi |
---|
| 265 | |
---|
| 266 | # Nb years for forcing FORCESOIL |
---|
| 267 | ORCHIDEE_sed FORCESOIL_NB_YEAR ${PeriodLengthInYears} |
---|
| 268 | |
---|
| 269 | IGCM_debug_PopStack "SPIN_OptionsStomate" |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | #----------------------------------------------------------------- |
---|
| 273 | Update_SPIN_iter=false |
---|
| 274 | function SPIN_Update |
---|
| 275 | { |
---|
| 276 | IGCM_debug_PushStack "SPIN_Update" |
---|
| 277 | |
---|
| 278 | Update_SPIN_iter=false |
---|
| 279 | |
---|
| 280 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/output.card Global |
---|
| 281 | SpinUpPath=${output_Global_Path} |
---|
| 282 | |
---|
| 283 | # StageName is the internal name for the interation for spinup |
---|
| 284 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card Stage StageName |
---|
| 285 | StageName=${output_Stage_StageName} |
---|
| 286 | |
---|
| 287 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastStageName |
---|
| 288 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastExtName |
---|
| 289 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastRestartDate |
---|
| 290 | |
---|
| 291 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card Global Iteration |
---|
| 292 | iter=${output_Global_Iteration} |
---|
| 293 | |
---|
| 294 | config_SubJob_PeriodLength="${config_UserChoices_PeriodLength}" |
---|
| 295 | |
---|
| 296 | # ExtName is the short JobName of this stage |
---|
| 297 | |
---|
| 298 | if ( [ X${StageName} = X"start" ] ) ; then |
---|
| 299 | # We are in first step. |
---|
| 300 | if ( ${FirstInitialize} ) ; then |
---|
| 301 | # What is the first step ? |
---|
| 302 | |
---|
| 303 | # First phase : Is there restarts (we would initialize ORCHIDEE) or not ? |
---|
| 304 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastStageName "start" |
---|
| 305 | output_PreviousStage_LastStageName="start" |
---|
| 306 | if ( [ X"${config_SRF_Restart}" = "Xn" ] && [ X"${config_SBG_Restart}" = "Xn" ] ) ; then |
---|
| 307 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 308 | if [ ${spinup_UserChoices_duree_inistomate} -gt 0 ] ; then |
---|
| 309 | # Perhaps we want to by-pass first SECHIBA-ONLY Stage and do a SECSTO Job first ? |
---|
| 310 | StageName=SECSTOINI |
---|
| 311 | ExtName=STOI |
---|
| 312 | else |
---|
| 313 | echo "SPINUP no restart : !!!! Error !!!! " |
---|
| 314 | echo "ok_stomate = " ${spinup_UserChoices_ok_stomate} |
---|
| 315 | echo "duree_inistomate = " ${spinup_UserChoices_duree_inistomate} |
---|
| 316 | echo "NO SPINUP possible !!" |
---|
| 317 | exit 1 |
---|
| 318 | fi |
---|
| 319 | elif [ ${spinup_UserChoices_duree_nostomate} -gt 0 ] ; then |
---|
| 320 | StageName=SECINI |
---|
| 321 | ExtName=SECI |
---|
| 322 | else |
---|
| 323 | echo "SPINUP : NO RESTART and NO INITIALIZATION !" |
---|
| 324 | echo " We will launch the iteration loop directly." |
---|
| 325 | if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then |
---|
| 326 | StageName=SECSTO |
---|
| 327 | iter=1 |
---|
| 328 | ExtName=ORC_${iter} |
---|
| 329 | Update_SPIN_iter=true |
---|
| 330 | else |
---|
| 331 | echo "SPINUP : !!!! Error !!!! " |
---|
| 332 | echo "duree_sechiba = " ${spinup_UserChoices_duree_sechiba} |
---|
| 333 | echo "NO SPINUP possible !!" |
---|
| 334 | exit 1 |
---|
| 335 | fi |
---|
| 336 | fi |
---|
| 337 | else |
---|
| 338 | echo "SPINUP : " |
---|
| 339 | echo " We will to launch the iteration loop WITH RESTARTS." |
---|
| 340 | echo " Global Restart path = " ${config_Restarts_RestartPath} |
---|
| 341 | if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then |
---|
| 342 | StageName=SECSTO |
---|
| 343 | iter=1 |
---|
| 344 | ExtName=ORC_${iter} |
---|
| 345 | Update_SPIN_iter=true |
---|
| 346 | else |
---|
| 347 | echo "SPINUP : !!!! Error !!!! " |
---|
| 348 | echo " duree_sechiba = " ${spinup_UserChoices_duree_sechiba} |
---|
| 349 | echo "NO SPINUP possible !!" |
---|
| 350 | exit 1 |
---|
| 351 | fi |
---|
| 352 | fi |
---|
| 353 | echo "(" start "," ${ExtName} ") \\" >> ${SUBMIT_DIR}/output.card |
---|
| 354 | |
---|
| 355 | else |
---|
| 356 | echo "SPINUP : !!!! Error with output !!!! " |
---|
| 357 | echo " duree_sechiba = " ${spinup_UserChoices_duree_sechiba} |
---|
| 358 | echo "NO SPINUP possible !!" |
---|
| 359 | exit 1 |
---|
| 360 | fi |
---|
| 361 | |
---|
| 362 | else |
---|
| 363 | # We are not in first step. |
---|
| 364 | |
---|
| 365 | # WHAT IS THE NEXT STEP ? |
---|
| 366 | case ${output_PreviousStage_LastStageName} in |
---|
| 367 | "SECINI") |
---|
| 368 | echo " We begin the iteration loop !!" |
---|
| 369 | if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then |
---|
| 370 | StageName=SECSTO |
---|
| 371 | iter=1 |
---|
| 372 | ExtName=ORC_${iter} |
---|
| 373 | Update_SPIN_iter=true |
---|
| 374 | else |
---|
| 375 | echo "SPINUP : !!!! Error !!!! " |
---|
| 376 | echo "duree_sechiba = " ${spinup_UserChoices_duree_sechiba} |
---|
| 377 | echo "NO SPINUP possible !!" |
---|
| 378 | exit 1 |
---|
| 379 | fi |
---|
| 380 | ;; |
---|
| 381 | "SECSTOINI") |
---|
| 382 | if [ ${spinup_UserChoices_duree_offlineini} -gt 0 ] ; then |
---|
| 383 | StageName=TSTOINI |
---|
| 384 | ExtName=TSTOI |
---|
| 385 | else |
---|
| 386 | echo " We begin the iteration loop !!" |
---|
| 387 | if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then |
---|
| 388 | StageName=SECSTO |
---|
| 389 | iter=1 |
---|
| 390 | ExtName=ORC_${iter} |
---|
| 391 | Update_SPIN_iter=true |
---|
| 392 | else |
---|
| 393 | echo "SPINUP : !!!! Error !!!! " |
---|
| 394 | echo "duree_sechiba = " ${spinup_UserChoices_duree_sechiba} |
---|
| 395 | echo "NO SPINUP possible !!" |
---|
| 396 | exit 1 |
---|
| 397 | fi |
---|
| 398 | fi |
---|
| 399 | ;; |
---|
| 400 | "TSTOINI") |
---|
| 401 | echo " We begin the iteration loop !!" |
---|
| 402 | if [ ${spinup_UserChoices_duree_sechiba} -gt 0 ] ; then |
---|
| 403 | echo " We begin the iteration loop !!" |
---|
| 404 | StageName=SECSTO |
---|
| 405 | iter=1 |
---|
| 406 | ExtName=ORC_${iter} |
---|
| 407 | Update_SPIN_iter=true |
---|
| 408 | else |
---|
| 409 | echo "SPINUP : !!!! Error !!!! " |
---|
| 410 | echo "duree_sechiba = " ${spinup_UserChoices_duree_sechiba} |
---|
| 411 | echo "NO SPINUP possible !!" |
---|
| 412 | exit 1 |
---|
| 413 | fi |
---|
| 414 | ;; |
---|
| 415 | "SECSTO") |
---|
| 416 | |
---|
| 417 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 418 | if [ ${spinup_UserChoices_duree_stomate} -gt 0 ] ; then |
---|
| 419 | StageName=TSTO |
---|
| 420 | ExtName=TST_${iter} |
---|
| 421 | elif [ ${spinup_UserChoices_duree_carbonsol} -gt 0 ] ; then |
---|
| 422 | StageName=FORC |
---|
| 423 | ExtName=FOR_${iter} |
---|
| 424 | elif [ ${iter} -eq ${spinup_UserChoices_n_iter} ] ; then |
---|
| 425 | echo "Ending loop Job" |
---|
| 426 | StageName=SECSTOF |
---|
| 427 | ExtName=FIN |
---|
| 428 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration END |
---|
| 429 | else |
---|
| 430 | StageName=SECSTO |
---|
| 431 | (( iter=iter+1 )) |
---|
| 432 | ExtName=ORC_${iter} |
---|
| 433 | Update_SPIN_iter=true |
---|
| 434 | fi |
---|
| 435 | elif [ ${iter} -eq ${spinup_UserChoices_n_iter} ] ; then |
---|
| 436 | echo "Ending loop Job" |
---|
| 437 | StageName=SECSTOF |
---|
| 438 | ExtName=FIN |
---|
| 439 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration END |
---|
| 440 | else |
---|
| 441 | StageName=SECSTO |
---|
| 442 | (( iter=iter+1 )) |
---|
| 443 | ExtName=ORC_${iter} |
---|
| 444 | Update_SPIN_iter=true |
---|
| 445 | fi |
---|
| 446 | ;; |
---|
| 447 | "TSTO") |
---|
| 448 | if [ ${spinup_UserChoices_duree_carbonsol} -gt 0 ] ; then |
---|
| 449 | StageName=FORC |
---|
| 450 | ExtName=FOR_${iter} |
---|
| 451 | elif [ ${iter} -eq ${spinup_UserChoices_n_iter} ] ; then |
---|
| 452 | echo "Ending loop Job" |
---|
| 453 | StageName=SECSTOF |
---|
| 454 | ExtName=FIN |
---|
| 455 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration END |
---|
| 456 | else |
---|
| 457 | StageName=SECSTO |
---|
| 458 | (( iter=iter+1 )) |
---|
| 459 | ExtName=ORC_${iter} |
---|
| 460 | Update_SPIN_iter=true |
---|
| 461 | fi |
---|
| 462 | ;; |
---|
| 463 | "FORC") |
---|
| 464 | if [ ${iter} -eq ${spinup_UserChoices_n_iter} ] || [ X${iter} = XEND ] ; then |
---|
| 465 | echo "Ending loop Job" |
---|
| 466 | StageName=SECSTOF |
---|
| 467 | ExtName=FIN |
---|
| 468 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration END |
---|
| 469 | else |
---|
| 470 | StageName=SECSTO |
---|
| 471 | (( iter=iter+1 )) |
---|
| 472 | ExtName=ORC_${iter} |
---|
| 473 | Update_SPIN_iter=true |
---|
| 474 | fi |
---|
| 475 | ;; |
---|
| 476 | "SECSTOF") |
---|
| 477 | echo "Begin Historical Job" |
---|
| 478 | StageName=HISTO |
---|
| 479 | ExtName=HIST |
---|
| 480 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration HIST |
---|
| 481 | ;; |
---|
| 482 | |
---|
| 483 | "HISTO") |
---|
| 484 | echo "SPINUP : We have done the SPINUP !! " |
---|
| 485 | echo "The job will be closed." |
---|
| 486 | ;; |
---|
| 487 | esac |
---|
| 488 | fi |
---|
| 489 | |
---|
| 490 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Stage StageName ${StageName} |
---|
| 491 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Stage ExtName ${ExtName} |
---|
| 492 | |
---|
| 493 | # BEGIN THE NEW STEP : |
---|
| 494 | LastJobName=${config_UserChoices_JobName}${output_PreviousStage_LastExtName} |
---|
| 495 | |
---|
| 496 | # Copy and modifications of the standard card set |
---|
| 497 | case $StageName in |
---|
| 498 | "SECINI") |
---|
| 499 | |
---|
| 500 | # SECHIBA only initialisation step |
---|
| 501 | This_Job_Length_In_Years=${spinup_UserChoices_duree_nostomate} |
---|
| 502 | |
---|
| 503 | # Copy the standard card set |
---|
| 504 | # !!! must not have been modified !!! |
---|
| 505 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC ${ExtName} |
---|
| 506 | |
---|
| 507 | # For some jobs : |
---|
| 508 | if ( [ X${config_UserChoices_JobNumProcTot} != X ] && [ "${config_UserChoices_JobNumProcTot}" -gt 1 ] ) ; then |
---|
| 509 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot} |
---|
| 510 | gawk -- "{if (! match(\$0,/^# .Date.*/) ) { print \$0 } else { printf(\"BATCH_NUM_PROC_TOT=%d \\n\\n\",${config_UserChoices_JobNumProcTot}) ; print \$0 } }" \ |
---|
| 511 | ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_ |
---|
| 512 | IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 513 | chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 514 | if [ X"${config_UserChoices_JobRunOptions}" != X ] ; then |
---|
| 515 | sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card |
---|
| 516 | IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card |
---|
| 517 | fi |
---|
| 518 | fi |
---|
| 519 | |
---|
| 520 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart n |
---|
| 521 | |
---|
| 522 | SPIN_prepare |
---|
| 523 | |
---|
| 524 | SPIN_OptionsSechiba |
---|
| 525 | |
---|
| 526 | ;; |
---|
| 527 | "SECSTOINI") |
---|
| 528 | |
---|
| 529 | # SECHIBA+STOMATE initialisation step |
---|
| 530 | This_Job_Length_In_Years=${spinup_UserChoices_duree_inistomate} |
---|
| 531 | |
---|
| 532 | # Copy the standard card set |
---|
| 533 | # !!! must not have been modified !!! |
---|
| 534 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC_STO ${ExtName} |
---|
| 535 | |
---|
| 536 | # For some jobs : |
---|
| 537 | if ( [ X${config_UserChoices_JobNumProcTot} != X ] && [ "${config_UserChoices_JobNumProcTot}" -gt 1 ] ) ; then |
---|
| 538 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot} |
---|
| 539 | gawk -- "{if (! match(\$0,/^# .Date.*/) ) { print \$0 } else { printf(\"BATCH_NUM_PROC_TOT=%d \\n\\n\",${config_UserChoices_JobNumProcTot}) ; print \$0 } }" \ |
---|
| 540 | ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_ |
---|
| 541 | IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 542 | chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 543 | if [ X"${config_UserChoices_JobRunOptions}" != X ] ; then |
---|
| 544 | sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card |
---|
| 545 | IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card |
---|
| 546 | fi |
---|
| 547 | fi |
---|
| 548 | |
---|
| 549 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart n |
---|
| 550 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 551 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart n |
---|
| 552 | fi |
---|
| 553 | |
---|
| 554 | SPIN_prepare |
---|
| 555 | |
---|
| 556 | SPIN_OptionsSechiba |
---|
| 557 | SPIN_OptionsStomate |
---|
| 558 | |
---|
| 559 | ;; |
---|
| 560 | |
---|
| 561 | "TSTOINI") |
---|
| 562 | |
---|
| 563 | # TESTSTOMATE initialisation step |
---|
| 564 | This_Job_Length_In_Years=${spinup_UserChoices_duree_offlineini} |
---|
| 565 | |
---|
| 566 | # TESTSTOMATE will run in one execution only |
---|
| 567 | config_SubJob_PeriodLength="${This_Job_Length_In_Years}Y" |
---|
| 568 | |
---|
| 569 | # Copy the standard card set |
---|
| 570 | # !!! must not have been modified !!! |
---|
| 571 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/TESTSTOMATE ${ExtName} |
---|
| 572 | |
---|
| 573 | # Always restart for teststomate |
---|
| 574 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Restarts OverRule n |
---|
| 575 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y |
---|
| 576 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate $( IGCM_date_ConvertFormatToHuman ${output_PreviousStage_LastRestartDate} ) |
---|
| 577 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y |
---|
| 578 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate $( IGCM_date_ConvertFormatToHuman ${output_PreviousStage_LastRestartDate} ) |
---|
| 579 | |
---|
| 580 | # Define restart simulation name |
---|
| 581 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName} |
---|
| 582 | config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 583 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath} |
---|
| 584 | |
---|
| 585 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName} |
---|
| 586 | config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 587 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath} |
---|
| 588 | |
---|
| 589 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastRestartDate |
---|
| 590 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card BoundaryFiles ListNonDel \ |
---|
| 591 | "(${config_SRF_RestartPath}/${LastJobName}/SBG/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_stomate_forcing.nc, stomate_forcing.nc)" |
---|
| 592 | |
---|
| 593 | SPIN_OptionsStomate |
---|
| 594 | |
---|
| 595 | ;; |
---|
| 596 | "SECSTO") |
---|
| 597 | |
---|
| 598 | # loop step |
---|
| 599 | |
---|
| 600 | This_Job_Length_In_Years=${spinup_UserChoices_duree_sechiba} |
---|
| 601 | |
---|
| 602 | # Copy the standard card set |
---|
| 603 | # !!! must not have been modified !!! |
---|
| 604 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 605 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC_STO ${ExtName} |
---|
| 606 | else |
---|
| 607 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC ${ExtName} |
---|
| 608 | fi |
---|
| 609 | |
---|
| 610 | # For some jobs : |
---|
| 611 | if ( [ X${config_UserChoices_JobNumProcTot} != X ] && [ "${config_UserChoices_JobNumProcTot}" -gt 1 ] ) ; then |
---|
| 612 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot} |
---|
| 613 | gawk -- "{if (! match(\$0,/^# .Date.*/) ) { print \$0 } else { printf(\"BATCH_NUM_PROC_TOT=%d \\n\\n\",${config_UserChoices_JobNumProcTot}) ; print \$0 } }" \ |
---|
| 614 | ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_ |
---|
| 615 | IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 616 | chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 617 | if [ X"${config_UserChoices_JobRunOptions}" != X ] ; then |
---|
| 618 | sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card |
---|
| 619 | IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card |
---|
| 620 | fi |
---|
| 621 | fi |
---|
| 622 | |
---|
| 623 | SPIN_prepare |
---|
| 624 | |
---|
| 625 | if [ X${output_PreviousStage_LastStageName} != X"start" ] ; then |
---|
| 626 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y |
---|
| 627 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${output_PreviousStage_LastRestartDate} |
---|
| 628 | # Define restart simulation name |
---|
| 629 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName} |
---|
| 630 | config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 631 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath} |
---|
| 632 | |
---|
| 633 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 634 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y |
---|
| 635 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate} |
---|
| 636 | # Define restart simulation name |
---|
| 637 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName} |
---|
| 638 | config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 639 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath} |
---|
| 640 | fi |
---|
| 641 | else |
---|
| 642 | # If we begin directly with the loop. |
---|
| 643 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF Restart |
---|
| 644 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF RestartDate |
---|
| 645 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF RestartJobName |
---|
| 646 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF RestartPath |
---|
| 647 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SRF OldName |
---|
| 648 | echo "Run in iteration loop with restarts : " |
---|
| 649 | echo ${config_SRF_Restart}, ${config_SRF_RestartDate}, ${config_SRF_RestartJobName}, ${config_SRF_RestartPath}, ${config_SRF_OldName} |
---|
| 650 | |
---|
| 651 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart ${config_SRF_Restart} |
---|
| 652 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${config_SRF_RestartDate} |
---|
| 653 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${config_SRF_RestartJobName} |
---|
| 654 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath} |
---|
| 655 | if [ X${config_SRF_OldName} != X"" ] ; then |
---|
| 656 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF OldName ${config_SRF_OldName} |
---|
| 657 | fi |
---|
| 658 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 659 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG Restart |
---|
| 660 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartDate |
---|
| 661 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartJobName |
---|
| 662 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG RestartPath |
---|
| 663 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card SBG OldName |
---|
| 664 | echo "Run in iteration loop with STOMATE restarts : " |
---|
| 665 | echo ${config_SBG_Restart}, ${config_SBG_RestartDate}, ${config_SBG_RestartJobName}, ${config_SBG_RestartPath}, ${config_SBG_OldName} |
---|
| 666 | |
---|
| 667 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart ${config_SBG_Restart} |
---|
| 668 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${config_SBG_RestartDate} |
---|
| 669 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${config_SBG_RestartJobName} |
---|
| 670 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath} |
---|
| 671 | if [ X${config_SBG_OldName} != X"" ] ; then |
---|
| 672 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG OldName ${config_SBG_OldName} |
---|
| 673 | fi |
---|
| 674 | fi |
---|
| 675 | fi |
---|
| 676 | |
---|
| 677 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 678 | SPIN_OptionsSechiba |
---|
| 679 | SPIN_OptionsStomate |
---|
| 680 | else |
---|
| 681 | SPIN_OptionsSechiba |
---|
| 682 | fi |
---|
| 683 | |
---|
| 684 | ;; |
---|
| 685 | "TSTO") |
---|
| 686 | |
---|
| 687 | # TESTSTOMATE loop step |
---|
| 688 | This_Job_Length_In_Years=${spinup_UserChoices_duree_stomate} |
---|
| 689 | |
---|
| 690 | # One execution only |
---|
| 691 | config_SubJob_PeriodLength="${This_Job_Length_In_Years}Y" |
---|
| 692 | |
---|
| 693 | # Copy the standard card set |
---|
| 694 | # !!! must not have been modified !!! |
---|
| 695 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/TESTSTOMATE ${ExtName} |
---|
| 696 | |
---|
| 697 | # Always restart for teststomate |
---|
| 698 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Restarts OverRule n |
---|
| 699 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y |
---|
| 700 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate $( IGCM_date_ConvertFormatToHuman ${output_PreviousStage_LastRestartDate} ) |
---|
| 701 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y |
---|
| 702 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate $( IGCM_date_ConvertFormatToHuman ${output_PreviousStage_LastRestartDate} ) |
---|
| 703 | |
---|
| 704 | # Define restart simulation name |
---|
| 705 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName} |
---|
| 706 | config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 707 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath} |
---|
| 708 | |
---|
| 709 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName} |
---|
| 710 | config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 711 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath} |
---|
| 712 | |
---|
| 713 | # We Get the forcing file from the previous run of ORCHIDEE |
---|
| 714 | ORCHIDEE_JobName=${config_UserChoices_JobName}ORC_${iter} |
---|
| 715 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/orchidee.card BoundaryFiles ListNonDel \ |
---|
| 716 | "(${config_SBG_RestartPath}/${ORCHIDEE_JobName}/SBG/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastRestartDate}_stomate_forcing.nc, stomate_forcing.nc), \\" |
---|
| 717 | |
---|
| 718 | SPIN_OptionsStomate |
---|
| 719 | |
---|
| 720 | ;; |
---|
| 721 | "FORC") |
---|
| 722 | # FORCESOIL loop step |
---|
| 723 | This_Job_Length_In_Years=${spinup_UserChoices_duree_carbonsol} |
---|
| 724 | |
---|
| 725 | # One execution only |
---|
| 726 | config_SubJob_PeriodLength="${This_Job_Length_In_Years}Y" |
---|
| 727 | |
---|
| 728 | # Copy the standard card set |
---|
| 729 | # !!! must not have been modified !!! |
---|
| 730 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/FORCESOIL ${ExtName} |
---|
| 731 | |
---|
| 732 | # For some jobs : |
---|
| 733 | if ( [ X${config_UserChoices_JobNumProcTot} != X ] && [ "${config_UserChoices_JobNumProcTot}" -gt 1 ] ) ; then |
---|
| 734 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot} |
---|
| 735 | gawk -- "{if (! match(\$0,/^# .Date.*/) ) { print \$0 } else { printf(\"BATCH_NUM_PROC_TOT=%d \\n\\n\",${config_UserChoices_JobNumProcTot}) ; print \$0 } }" \ |
---|
| 736 | ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_ |
---|
| 737 | IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 738 | chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 739 | if [ X"${config_UserChoices_JobRunOptions}" != X ] ; then |
---|
| 740 | sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card |
---|
| 741 | IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card |
---|
| 742 | fi |
---|
| 743 | fi |
---|
| 744 | |
---|
| 745 | # Always restart for forcesoil |
---|
| 746 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Restarts OverRule n |
---|
| 747 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y |
---|
| 748 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate $( IGCM_date_ConvertFormatToHuman ${output_PreviousStage_LastRestartDate} ) |
---|
| 749 | |
---|
| 750 | # Define restart simulation name |
---|
| 751 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName} |
---|
| 752 | config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 753 | config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 754 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath} |
---|
| 755 | |
---|
| 756 | # We Get the forcing file from the previous run of ORCHIDEE |
---|
| 757 | ORCHIDEE_JobName=${config_UserChoices_JobName}ORC_${iter} |
---|
| 758 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastORCRestartDate |
---|
| 759 | if ( [ X${spinup_UserChoices_DEBUG_SPIN} = Xn ] && [ X${output_PreviousStage_LastExtName} != XORC_${iter} ] ) ; then |
---|
| 760 | last_Cforcing=${config_SBG_RestartPath}/${config_UserChoices_JobName}/SPIN/Output/${ORCHIDEE_JobName}/SBG/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastORCRestartDate}_stomate_Cforcing.nc |
---|
| 761 | else |
---|
| 762 | last_Cforcing=${config_SBG_RestartPath}/${ORCHIDEE_JobName}/SBG/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastORCRestartDate}_stomate_Cforcing.nc |
---|
| 763 | fi |
---|
| 764 | ls -lrt ${last_Cforcing} |
---|
| 765 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card BoundaryFiles ListNonDel "(${last_Cforcing}, stomate_Cforcing.nc), \\" |
---|
| 766 | |
---|
| 767 | # Nb years for forcing FORCESOIL |
---|
| 768 | ORCHIDEE_sed FORCESOIL_NB_YEAR ${PeriodLengthInYears} |
---|
| 769 | |
---|
| 770 | ;; |
---|
| 771 | "SECSTOF") |
---|
| 772 | |
---|
| 773 | # END step |
---|
| 774 | |
---|
| 775 | This_Job_Length_In_Years=${spinup_UserChoices_duree_final} |
---|
| 776 | |
---|
| 777 | # Copy the standard card set |
---|
| 778 | # !!! must not have been modified !!! |
---|
| 779 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 780 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC_STO ${ExtName} |
---|
| 781 | else |
---|
| 782 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC ${ExtName} |
---|
| 783 | fi |
---|
| 784 | |
---|
| 785 | # For some jobs : |
---|
| 786 | if ( [ X${config_UserChoices_JobNumProcTot} != X ] && [ "${config_UserChoices_JobNumProcTot}" -gt 1 ] ) ; then |
---|
| 787 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot} |
---|
| 788 | gawk -- "{if (! match(\$0,/^# .Date.*/) ) { print \$0 } else { printf(\"BATCH_NUM_PROC_TOT=%d \\n\\n\",${config_UserChoices_JobNumProcTot}) ; print \$0 } }" \ |
---|
| 789 | ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_ |
---|
| 790 | IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 791 | chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 792 | if [ X"${config_UserChoices_JobRunOptions}" != X ] ; then |
---|
| 793 | sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card |
---|
| 794 | IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card |
---|
| 795 | fi |
---|
| 796 | fi |
---|
| 797 | |
---|
| 798 | SPIN_prepare |
---|
| 799 | |
---|
| 800 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y |
---|
| 801 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${output_PreviousStage_LastRestartDate} |
---|
| 802 | # Define restart simulation name |
---|
| 803 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName} |
---|
| 804 | config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 805 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath} |
---|
| 806 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 807 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y |
---|
| 808 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate} |
---|
| 809 | # Define restart simulation name |
---|
| 810 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName} |
---|
| 811 | config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 812 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath} |
---|
| 813 | fi |
---|
| 814 | |
---|
| 815 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 816 | SPIN_OptionsSechiba |
---|
| 817 | SPIN_OptionsStomate |
---|
| 818 | else |
---|
| 819 | SPIN_OptionsSechiba |
---|
| 820 | fi |
---|
| 821 | |
---|
| 822 | ;; |
---|
| 823 | |
---|
| 824 | "HISTO") |
---|
| 825 | |
---|
| 826 | # Historical step |
---|
| 827 | |
---|
| 828 | case ${config_SubJob_PeriodLength} in |
---|
| 829 | *Y|*y) |
---|
| 830 | This_Job_Length_In_Years=$( echo ${1} | awk -F '[yY]' "{print ${config_SubJob_PeriodLength}}" ) |
---|
| 831 | ;; |
---|
| 832 | *M|*m) |
---|
| 833 | This_Job_Length_In_Years=1 |
---|
| 834 | ;; |
---|
| 835 | *) |
---|
| 836 | echo "SPINUP : Impossible" |
---|
| 837 | echo " We have a PeriodLength less than 1M : " ${config_SubJob_PeriodLength} |
---|
| 838 | echo " We can't do the spinup with such a frequency !" |
---|
| 839 | exit 1 |
---|
| 840 | ;; |
---|
| 841 | esac |
---|
| 842 | |
---|
| 843 | # Copy the standard card set |
---|
| 844 | # !!! must not have been modified !!! |
---|
| 845 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 846 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC_STO ${ExtName} |
---|
| 847 | else |
---|
| 848 | SPIN_Cp_Job ${spinup_UserChoices_SubJobPath}/OOL_SEC ${ExtName} |
---|
| 849 | fi |
---|
| 850 | |
---|
| 851 | # For some jobs : |
---|
| 852 | if ( [ X${config_UserChoices_JobNumProcTot} != X ] && [ "${config_UserChoices_JobNumProcTot}" -gt 1 ] ) ; then |
---|
| 853 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices JobNumProcTot ${config_UserChoices_JobNumProcTot} |
---|
| 854 | gawk -- "{if (! match(\$0,/^# .Date.*/) ) { print \$0 } else { printf(\"BATCH_NUM_PROC_TOT=%d \\n\\n\",${config_UserChoices_JobNumProcTot}) ; print \$0 } }" \ |
---|
| 855 | ${New_SUBMIT_DIR}/Job_${SubJobName} > ${New_SUBMIT_DIR}/Job_${SubJobName}_ |
---|
| 856 | IGCM_sys_Mv ${New_SUBMIT_DIR}/Job_${SubJobName}_ ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 857 | chmod u+x ${New_SUBMIT_DIR}/Job_${SubJobName} |
---|
| 858 | if [ X"${config_UserChoices_JobRunOptions}" != X ] ; then |
---|
| 859 | sed -e "s/^JobRunOptions=.*/JobRunOptions=\'${config_UserChoices_JobRunOptions}\'/" ${New_SUBMIT_DIR}/config.card > temp.card |
---|
| 860 | IGCM_sys_Mv temp.card ${New_SUBMIT_DIR}/config.card |
---|
| 861 | fi |
---|
| 862 | fi |
---|
| 863 | |
---|
| 864 | SPIN_prepare |
---|
| 865 | |
---|
| 866 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF Restart y |
---|
| 867 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartDate ${output_PreviousStage_LastRestartDate} |
---|
| 868 | # Define restart simulation name |
---|
| 869 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartJobName ${LastJobName} |
---|
| 870 | config_SRF_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 871 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF RestartPath ${config_SRF_RestartPath} |
---|
| 872 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 873 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG Restart y |
---|
| 874 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartDate ${output_PreviousStage_LastRestartDate} |
---|
| 875 | # Define restart simulation name |
---|
| 876 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartJobName ${LastJobName} |
---|
| 877 | config_SBG_RestartPath=${R_OUT}/${config_UserChoices_TagName} |
---|
| 878 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG RestartPath ${config_SBG_RestartPath} |
---|
| 879 | fi |
---|
| 880 | |
---|
| 881 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 882 | SPIN_OptionsSechiba |
---|
| 883 | SPIN_OptionsStomate |
---|
| 884 | else |
---|
| 885 | SPIN_OptionsSechiba |
---|
| 886 | fi |
---|
| 887 | |
---|
| 888 | ;; |
---|
| 889 | *) |
---|
| 890 | echo "Erreur !! StageName not found." |
---|
| 891 | exit 1 |
---|
| 892 | esac |
---|
| 893 | |
---|
| 894 | |
---|
| 895 | # For all Subjobs |
---|
| 896 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Stage StageName ${StageName} |
---|
| 897 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Stage ExtName ${ExtName} |
---|
| 898 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices CalendarType ${config_UserChoices_CalendarType} |
---|
| 899 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateBegin ${config_UserChoices_DateBegin} |
---|
| 900 | |
---|
| 901 | # Compute DateEnd for SECHIBA initialisation step |
---|
| 902 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
| 903 | if [ X"${config_UserChoices_CalendarType}" = X"360d" ] ; then |
---|
| 904 | This_Job_DateEnd=$( IGCM_date_YearDigit $(( year + This_Job_Length_In_Years - 1 )) )1230 |
---|
| 905 | This_Job_HumanDateEnd=$( IGCM_date_YearDigit $(( year + This_Job_Length_In_Years - 1 )) )-12-30 |
---|
| 906 | else |
---|
| 907 | This_Job_DateEnd=$( IGCM_date_YearDigit $(( year + This_Job_Length_In_Years - 1 )) )1231 |
---|
| 908 | This_Job_HumanDateEnd=$( IGCM_date_YearDigit $(( year + This_Job_Length_In_Years - 1 )) )-12-31 |
---|
| 909 | fi |
---|
| 910 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices DateEnd ${This_Job_HumanDateEnd} |
---|
| 911 | |
---|
| 912 | |
---|
| 913 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodLength ${config_SubJob_PeriodLength} |
---|
| 914 | # Compute Subjob number of Periods |
---|
| 915 | case ${config_SubJob_PeriodLength} in |
---|
| 916 | *Y|*y) |
---|
| 917 | PeriodNbSubJob=$(( This_Job_Length_In_Years / $( echo ${1} | awk -F '[yY]' "{print ${config_SubJob_PeriodLength}}" ) )) |
---|
| 918 | ;; |
---|
| 919 | *M|*m) |
---|
| 920 | PeriodNbSubJob=$(( 12 * This_Job_Length_In_Years / $( echo ${1} | awk -F '[mM]' "{print ${config_SubJob_PeriodLength}}" ) )) |
---|
| 921 | ;; |
---|
| 922 | *) |
---|
| 923 | echo "SPINUP : Impossible" |
---|
| 924 | echo " We have a PeriodLength less than 1M : " ${config_SubJob_PeriodLength} |
---|
| 925 | echo " We can't do the spinup with such a frequency !" |
---|
| 926 | exit 1 |
---|
| 927 | ;; |
---|
| 928 | esac |
---|
| 929 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card UserChoices PeriodNb ${PeriodNbSubJob} |
---|
| 930 | |
---|
| 931 | echo "SECHIBA WriteFrequency : " ${config_SRF_WriteFrequency} |
---|
| 932 | if ( [ X${StageName} != X"TSTOINI" ] && [ X${StageName} != X"TSTO" ] && [ X${StageName} != X"FORC" ] ) ; then |
---|
| 933 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF WriteFrequency "${config_SRF_WriteFrequency}" |
---|
| 934 | fi |
---|
| 935 | if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then |
---|
| 936 | echo "STOMATE WriteFrequency : " ${config_SBG_WriteFrequency} |
---|
| 937 | IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG WriteFrequency "${config_SBG_WriteFrequency}" |
---|
| 938 | fi |
---|
| 939 | |
---|
| 940 | echo "#!/bin/ksh" > ${RUN_DIR}/SubJob$$.ksh |
---|
| 941 | echo "cd ${New_SUBMIT_DIR}" >> ${RUN_DIR}/SubJob$$.ksh |
---|
| 942 | echo "export SUBMIT_DIR=${New_SUBMIT_DIR}" >> ${RUN_DIR}/SubJob$$.ksh |
---|
| 943 | echo "./Job_${SubJobName} > ${New_SUBMIT_DIR}/Script_${SubJobName}.1 </dev/null 2>&1" >> ${RUN_DIR}/SubJob$$.ksh |
---|
| 944 | echo "echo 'End of Subjob : ' \$( date )" >> ${RUN_DIR}/SubJob$$.ksh |
---|
| 945 | echo "echo 'finish.'" >> ${RUN_DIR}/SubJob$$.ksh |
---|
| 946 | |
---|
| 947 | chmod u+x ${RUN_DIR}/SubJob$$.ksh |
---|
| 948 | |
---|
| 949 | # force run with nohup |
---|
| 950 | BATCH_NUM_PROC_TOT=1 |
---|
| 951 | MPIRUN_COMMAND="time nohup" |
---|
| 952 | config_Executable_Name=SubJob$$.ksh |
---|
| 953 | |
---|
| 954 | IGCM_debug_PopStack "SPIN_Update" |
---|
| 955 | } |
---|
| 956 | |
---|
| 957 | #----------------------------------------------------------------- |
---|
| 958 | function SPIN_Finalize |
---|
| 959 | { |
---|
| 960 | IGCM_debug_PushStack "SPIN_Finalize" |
---|
| 961 | |
---|
| 962 | \rm ${RUN_DIR}/SubJob$$.ksh |
---|
| 963 | |
---|
| 964 | echo "Return to Master SPINUP job : " $( date ) |
---|
| 965 | |
---|
| 966 | # Does the SubJob began ? |
---|
| 967 | if [ -f ${New_SUBMIT_DIR}/run.card ] ; then |
---|
| 968 | IGCM_card_DefineVariableFromOption ${New_SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 969 | else |
---|
| 970 | run_Configuration_PeriodState="Fatal" |
---|
| 971 | fi |
---|
| 972 | |
---|
| 973 | # ATTENTION : avec ce test "!= Completed", on impose que chaque sous-job est contenu dans une seule itération PBS |
---|
| 974 | # On pourrait améliorer ce point pour tenir compte d'un sous-job long... |
---|
| 975 | # Mais il faudrait faire ce test au début de la fonction update |
---|
| 976 | # pour déterminer si on doit reprendre un job non terminer ou démarrer le suivant. |
---|
| 977 | # Did it finish ? |
---|
| 978 | if [ X${run_Configuration_PeriodState} != X"Completed" ] ; then |
---|
| 979 | IGCM_debug_Exit "SPIN_update Error Run SubJob : " ${SubJobName} |
---|
| 980 | fi |
---|
| 981 | IGCM_debug_Verif_Exit |
---|
| 982 | |
---|
| 983 | # Save the Stage in output.card |
---|
| 984 | if ( ${Update_SPIN_iter} ) ; then |
---|
| 985 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card Global Iteration ${iter} |
---|
| 986 | fi |
---|
| 987 | |
---|
| 988 | echo "(" ${StageName} "," ${ExtName} ") \\" >> ${SUBMIT_DIR}/output.card |
---|
| 989 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastStageName ${StageName} |
---|
| 990 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastExtName ${ExtName} |
---|
| 991 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastRestartDate ${This_Job_DateEnd} |
---|
| 992 | if [ X${StageName} = X"SECSTO" ] ; then |
---|
| 993 | IGCM_card_WriteOption ${SUBMIT_DIR}/output.card PreviousStage LastORCRestartDate ${This_Job_DateEnd} |
---|
| 994 | fi |
---|
| 995 | |
---|
| 996 | # For forcesoil, we have to copy the sechiba restart of last Stage |
---|
| 997 | if [ X${StageName} = X"FORC" ] ; then |
---|
| 998 | # This must be done on the ARCHIVE HOST. |
---|
| 999 | if ( [ X${spinup_UserChoices_DEBUG_SPIN} = Xn ] && [ X${output_PreviousStage_LastExtName} != XORC_${iter} ] ) ; then |
---|
| 1000 | last_restart=${config_SBG_RestartPath}/${config_UserChoices_JobName}/SPIN/Output/${ORCHIDEE_JobName}/SRF/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastORCRestartDate}_sechiba_rest.nc |
---|
| 1001 | else |
---|
| 1002 | last_restart=${config_SBG_RestartPath}/${ORCHIDEE_JobName}/SRF/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastORCRestartDate}_sechiba_rest.nc |
---|
| 1003 | fi |
---|
| 1004 | IGCM_sys_Get ${last_restart} sechiba_rest.nc |
---|
| 1005 | IGCM_sys_MkdirArchive ${config_SBG_RestartPath}/${SubJobName}/SRF/Restart |
---|
| 1006 | IGCM_sys_Put_Rest sechiba_rest.nc ${config_SBG_RestartPath}/${SubJobName}/SRF/Restart/${SubJobName}_${This_Job_DateEnd}_sechiba_rest.nc |
---|
| 1007 | # FileToBeDeleted[${#FileToBeDeleted[@]}]=sechiba_rest.nc |
---|
| 1008 | rm -f sechiba_rest.nc |
---|
| 1009 | fi |
---|
| 1010 | |
---|
| 1011 | # For SPINUP, we don't need a restart ! Then we save the output.card |
---|
| 1012 | IGCM_sys_Cp ${SUBMIT_DIR}/output.card output_out.card |
---|
| 1013 | FileToBeDeleted[${#FileToBeDeleted[@]}]=output_out.card |
---|
| 1014 | |
---|
| 1015 | #set -vx |
---|
| 1016 | # If NOT DEBUG mode : |
---|
| 1017 | # we can move Previous Job in SPINUP save DIR. |
---|
| 1018 | if ( [ X${spinup_UserChoices_DEBUG_SPIN} = Xn ] && [ X${output_PreviousStage_LastStageName} != Xstart ] ) ; then |
---|
| 1019 | IGCM_sys_RshPost <<-EOF |
---|
| 1020 | \mv -f ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}${output_PreviousStage_LastExtName} ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/SPIN/Output/ |
---|
| 1021 | EOF |
---|
| 1022 | if ( [ X${spinup_UserChoices_CONSERVE} = Xn ] \ |
---|
| 1023 | && [ X${output_PreviousStage_LastStageName} != XSECINI ] \ |
---|
| 1024 | && [ X${output_PreviousStage_LastStageName} != XSECSTOINI ] ) ; then |
---|
| 1025 | IGCM_sys_RshPost <<-EOF |
---|
| 1026 | \rm -Rf ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}${output_PreviousStage_LastExtName}/*/Analyse/* |
---|
| 1027 | EOF |
---|
| 1028 | # \rm -Rf ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}${output_PreviousStage_LastExtName}/*/Output/* |
---|
| 1029 | fi |
---|
| 1030 | fi |
---|
| 1031 | |
---|
| 1032 | # Test the end of the SPINUP ! |
---|
| 1033 | if [ X${StageName} = X"HISTO" ] ; then |
---|
| 1034 | DateEnd=${PeriodDateEnd} |
---|
| 1035 | (( SimulationLengthInDays=ExperienceLengthInDays + 1 )) |
---|
| 1036 | echo "SPINUP : END Job !!!" |
---|
| 1037 | fi |
---|
| 1038 | |
---|
| 1039 | IGCM_debug_PopStack "SPIN_Finalize" |
---|
| 1040 | } |
---|