[2] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sebastien Denvil, Martial Mancip |
---|
[373] | 5 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr Martial.Mancip__at__ipsl.jussieu.fr |
---|
| 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
[2] | 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
| 14 | #======================================================================== |
---|
| 15 | function IGCM_comp_Initialize |
---|
| 16 | { |
---|
[544] | 17 | IGCM_debug_PushStack "IGCM_comp_Initialize" |
---|
[2] | 18 | |
---|
[778] | 19 | # Debug Print : |
---|
[544] | 20 | echo |
---|
| 21 | IGCM_debug_Print 1 "IGCM_comp_Initialize" |
---|
| 22 | echo |
---|
[2] | 23 | |
---|
[1244] | 24 | typeset comp compname comptagname auxprint card_UserChoices first_option option i j |
---|
[544] | 25 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[2] | 26 | |
---|
[902] | 27 | # Define component |
---|
[544] | 28 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} |
---|
| 29 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 30 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
[457] | 31 | |
---|
[615] | 32 | # Debug Print |
---|
| 33 | IGCM_debug_Print 1 "Initialize ${comp} : ${compname} component." |
---|
| 34 | |
---|
[1244] | 35 | # ${compname}.card PATH |
---|
[544] | 36 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
[2] | 37 | |
---|
[544] | 38 | # Manage component executable |
---|
| 39 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card Executable ${comp} |
---|
[2] | 40 | |
---|
[849] | 41 | # Define all options in section [comp] |
---|
| 42 | IGCM_debug_Print 3 " DefineArrayFromSection : ${comp}" |
---|
| 43 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ${comp} |
---|
| 44 | eval config_comp=\${config_${comp}[*]} > /dev/null 2>&1 |
---|
| 45 | for option in ${config_comp[*]} ; do |
---|
[902] | 46 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} ${option} |
---|
[849] | 47 | done |
---|
| 48 | IGCM_debug_Print 3 " Found in section config_${comp} : ${config_comp[*]} " |
---|
| 49 | |
---|
[544] | 50 | # Debug Print : |
---|
| 51 | eval auxprint=\${config_${comp}_WriteFrequency} |
---|
| 52 | IGCM_debug_Print 1 "Write frequency for ${compname} : ${auxprint} " |
---|
| 53 | #2> /dev/null |
---|
[2] | 54 | |
---|
[544] | 55 | # Debug Print : |
---|
| 56 | IGCM_debug_Print 2 "Initialize following component library" |
---|
[522] | 57 | |
---|
[544] | 58 | # Source drivers in directory DRIVER if it exist |
---|
| 59 | # else source them from directory COMP |
---|
| 60 | if [ -d ${SUBMIT_DIR}/DRIVER ] ; then |
---|
| 61 | IGCM_debug_Print 2 ${SUBMIT_DIR}/DRIVER/${compname}.driver |
---|
| 62 | # Source component library |
---|
| 63 | . ${SUBMIT_DIR}/DRIVER/${compname}.driver |
---|
| 64 | else |
---|
| 65 | IGCM_debug_Print 2 ${SUBMIT_DIR}/COMP/${compname}.driver |
---|
| 66 | # Source component library |
---|
| 67 | . ${SUBMIT_DIR}/COMP/${compname}.driver |
---|
| 68 | fi |
---|
| 69 | IGCM_debug_Print 3 "With tag : ${comptagname}" |
---|
[2] | 70 | |
---|
[544] | 71 | # Debug Print |
---|
| 72 | IGCM_debug_Print 3 "Initialize ${comp} output directory." |
---|
[2] | 73 | |
---|
[544] | 74 | # Define ARCHIVED Dirs |
---|
| 75 | eval R_OUT_${comp}=${R_SAVE}/${comp} |
---|
| 76 | eval IGCM_sys_MkdirArchive \${R_OUT_${comp}} |
---|
[2] | 77 | |
---|
[544] | 78 | eval R_OUT_${comp}_O=\${R_OUT_${comp}}/Output |
---|
| 79 | eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_O} |
---|
[2] | 80 | |
---|
[544] | 81 | eval R_OUT_${comp}_R=\${R_OUT_${comp}}/Restart |
---|
[804] | 82 | [ ${config_Post_PackFrequency} = NONE ] && eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_R} |
---|
[2] | 83 | |
---|
[544] | 84 | eval R_OUT_${comp}_D=\${R_OUT_${comp}}/Debug |
---|
[804] | 85 | [ ${config_Post_PackFrequency} = NONE ] && eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_D} |
---|
[2] | 86 | |
---|
[544] | 87 | eval R_OUT_${comp}_O_I=\${R_OUT_${comp}_O}/INS |
---|
| 88 | eval R_OUT_${comp}_O_H=\${R_OUT_${comp}_O}/HF |
---|
| 89 | eval R_OUT_${comp}_O_D=\${R_OUT_${comp}_O}/DA |
---|
| 90 | eval R_OUT_${comp}_O_M=\${R_OUT_${comp}_O}/MO |
---|
| 91 | eval R_OUT_${comp}_O_Y=\${R_OUT_${comp}_O}/YE |
---|
| 92 | |
---|
| 93 | # Define BUFFERED Dirs |
---|
[1022] | 94 | if ( [ ! ${config_Post_PackFrequency} = NONE ] || [ X${config_UserChoices_SpaceName} = XTEST ] ) ; then |
---|
[804] | 95 | eval R_BUF_${comp}=${R_BUFR}/${comp} |
---|
| 96 | eval IGCM_sys_Mkdir \${R_BUF_${comp}} |
---|
[544] | 97 | |
---|
[804] | 98 | eval R_BUF_${comp}_O=\${R_BUF_${comp}}/Output |
---|
| 99 | eval IGCM_sys_Mkdir \${R_BUF_${comp}_O} |
---|
[544] | 100 | |
---|
[804] | 101 | eval R_BUF_${comp}_R=\${R_BUF_${comp}}/Restart |
---|
| 102 | eval IGCM_sys_Mkdir \${R_BUF_${comp}_R} |
---|
[544] | 103 | |
---|
[804] | 104 | eval R_BUF_${comp}_D=\${R_BUF_${comp}}/Debug |
---|
| 105 | eval IGCM_sys_Mkdir \${R_BUF_${comp}_D} |
---|
[544] | 106 | |
---|
[804] | 107 | eval R_BUF_${comp}_O_I=\${R_BUF_${comp}_O}/INS |
---|
| 108 | eval R_BUF_${comp}_O_H=\${R_BUF_${comp}_O}/HF |
---|
| 109 | eval R_BUF_${comp}_O_D=\${R_BUF_${comp}_O}/DA |
---|
| 110 | eval R_BUF_${comp}_O_M=\${R_BUF_${comp}_O}/MO |
---|
| 111 | eval R_BUF_${comp}_O_Y=\${R_BUF_${comp}_O}/YE |
---|
| 112 | fi |
---|
[544] | 113 | |
---|
| 114 | # Read UserChoices section of component card |
---|
| 115 | IGCM_debug_Print 2 "DefineArrayFromSection : ${compname}_UserChoices ${card}" |
---|
| 116 | IGCM_card_DefineArrayFromSection ${card} UserChoices |
---|
| 117 | eval first_option=\${${compname}_UserChoices[0]} > /dev/null 2>&1 |
---|
[804] | 118 | |
---|
[544] | 119 | # If section is not empty we define corresponding variables |
---|
| 120 | if [ X${first_option} != X"Error:" ] ; then |
---|
| 121 | if [ X${card_UserChoices[0]} != X ] ; then |
---|
[778] | 122 | unset card_UserChoices |
---|
[544] | 123 | fi |
---|
[833] | 124 | eval set +A card_UserChoices -- \${${compname}_UserChoices[*]} > /dev/null 2>&1 |
---|
[544] | 125 | IGCM_debug_Print 3 "${compname}_UserChoices_values:" |
---|
| 126 | for option in ${card_UserChoices[*]} ; do |
---|
[778] | 127 | IGCM_card_DefineVariableFromOption ${card} UserChoices ${option} |
---|
| 128 | eval IGCM_debug_Print 3 "${option}=\${${compname}_UserChoices_${option}}" |
---|
[544] | 129 | done |
---|
| 130 | fi |
---|
| 131 | |
---|
| 132 | # Read and Build Output File stuff |
---|
| 133 | IGCM_debug_Print 2 "DefineArrayFromOption : ${compname}_OutputFiles ${card}" |
---|
| 134 | IGCM_card_DefineArrayFromOption ${card} OutputFiles List |
---|
| 135 | ListFilesName=${compname}_OutputFiles_List |
---|
| 136 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
| 137 | # |
---|
| 138 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
| 139 | # |
---|
| 140 | #IGCM_debug_Print 1 "Component : ${compname}" |
---|
| 141 | # |
---|
| 142 | # INITIALISATION |
---|
| 143 | # |
---|
| 144 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
| 145 | # |
---|
| 146 | i=2 |
---|
| 147 | # |
---|
| 148 | until [ $i -ge $NbFiles ]; do |
---|
[778] | 149 | # |
---|
| 150 | eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 151 | # |
---|
| 152 | if [ X${flag_post} != XNONE ] ; then |
---|
| 153 | # |
---|
[544] | 154 | # First of all |
---|
| 155 | # |
---|
[778] | 156 | IGCM_card_DefineArrayFromSection ${card} ${flag_post} |
---|
[1151] | 157 | # This section is mandatory |
---|
| 158 | if [ "X$( eval echo \${${compname}_${flag_post}[@]} )" = "X" ] ; then |
---|
| 159 | IGCM_debug_Print 1 "IGCM_card_DefineArrayFromSection ${card} ${flag_post}" |
---|
| 160 | IGCM_debug_Exit "${flag_post} section do not exist in ${card}. Please check your card." |
---|
| 161 | IGCM_debug_Verif_Exit |
---|
| 162 | fi |
---|
[778] | 163 | # |
---|
| 164 | # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default |
---|
| 165 | # |
---|
| 166 | # variable option allready typeset above |
---|
| 167 | for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do |
---|
| 168 | if [ ${option} = Seasonal ] ; then |
---|
| 169 | FoundSeasonal=true |
---|
| 170 | IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal |
---|
| 171 | fi |
---|
| 172 | done |
---|
| 173 | # |
---|
| 174 | if [ ! X${FoundSeasonal} = Xtrue ] ; then |
---|
| 175 | eval ${compname}_${flag_post}_Seasonal=ON |
---|
| 176 | fi |
---|
| 177 | # |
---|
| 178 | if [ $( eval echo \${${compname}_${flag_post}_Seasonal} ) = ON ] ; then |
---|
| 179 | Seasonal=true |
---|
| 180 | fi |
---|
| 181 | |
---|
| 182 | # Dimension = vide si vieille card. |
---|
| 183 | IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars |
---|
| 184 | IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches |
---|
| 185 | if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not" ] ; then |
---|
| 186 | # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob. |
---|
| 187 | ListDimension[0]=2D |
---|
| 188 | ListDimension[1]=3D |
---|
| 189 | TimeSeries=false |
---|
| 190 | iLoop=${#ListDimension[*]} |
---|
| 191 | j=0 |
---|
| 192 | until [ $j -ge ${iLoop} ]; do |
---|
| 193 | Dimension=${ListDimension[${j}]} |
---|
| 194 | IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars${Dimension} |
---|
| 195 | IGCM_card_DefineVariableFromOption ${card} ${flag_post} ChunckJob${Dimension} |
---|
[544] | 196 | # |
---|
[778] | 197 | # Time series WITHOUT chunk |
---|
| 198 | # |
---|
| 199 | if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then |
---|
| 200 | if [ $( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) = NONE ] ; then |
---|
| 201 | IGCM_debug_Print 3 "${Dimension} time series activated for ${flag_post}" |
---|
| 202 | eval TimeSeries${Dimension}=true |
---|
| 203 | fi |
---|
| 204 | fi |
---|
| 205 | # |
---|
| 206 | # Time series WITH chunk |
---|
| 207 | # |
---|
| 208 | if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then |
---|
| 209 | chunck_size=$( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) |
---|
| 210 | if [ ! ${chunck_size} = NONE ] && [ ! ${chunck_size} = OFF ] ; then |
---|
| 211 | IGCM_debug_Print 3 "${Dimension} time series activated with chunck for ${flag_post}" |
---|
| 212 | eval TimeSeriesChunck${Dimension}=true |
---|
[829] | 213 | eval CHUNCK${Dimension}_COMP[\${#CHUNCK${Dimension}_COMP[*]}]=${comp} |
---|
| 214 | eval CHUNCK${Dimension}_FLAG[\${#CHUNCK${Dimension}_FLAG[*]}]=${i} |
---|
| 215 | eval CHUNCK${Dimension}_NAME[\${#CHUNCK${Dimension}_NAME[*]}]=${flag_post} |
---|
| 216 | eval CHUNCK${Dimension}_SIZE[\${#CHUNCK${Dimension}_SIZE[*]}]=${chunck_size} |
---|
[778] | 217 | fi |
---|
| 218 | fi |
---|
| 219 | (( j=j+1 )) |
---|
| 220 | done |
---|
| 221 | else |
---|
| 222 | ListDimension[0]="" |
---|
| 223 | TimeSeries=true |
---|
| 224 | TimeSeries2D=false |
---|
| 225 | TimeSeries3D=false |
---|
| 226 | TimeSeriesChunck2D=false |
---|
| 227 | TimeSeriesChunck3D=false |
---|
| 228 | fi |
---|
| 229 | fi |
---|
| 230 | (( i=i+3 )) |
---|
[544] | 231 | done |
---|
| 232 | fi |
---|
| 233 | # Debug Print |
---|
| 234 | IGCM_debug_Print 3 "Initialize ${compname} with driver." |
---|
| 235 | # INIT component |
---|
| 236 | ${comp}_Initialize |
---|
| 237 | echo |
---|
| 238 | done |
---|
[2] | 239 | |
---|
[544] | 240 | IGCM_debug_PopStack "IGCM_comp_Initialize" |
---|
[2] | 241 | } |
---|
| 242 | |
---|
| 243 | #======================================================================= |
---|
| 244 | function IGCM_comp_PrepareDeletedFiles |
---|
| 245 | { |
---|
[544] | 246 | IGCM_debug_PushStack "IGCM_comp_PrepareDeletedFiles" $@ |
---|
[778] | 247 | |
---|
[544] | 248 | if [ X${2} != X. ] ; then |
---|
| 249 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${2} ) > /dev/null 2>&1 |
---|
| 250 | else |
---|
| 251 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${1} ) > /dev/null 2>&1 |
---|
| 252 | fi |
---|
[2] | 253 | |
---|
[544] | 254 | IGCM_debug_PopStack "IGCM_comp_PrepareDeletedFiles" |
---|
[2] | 255 | } |
---|
| 256 | |
---|
| 257 | #======================================================================= |
---|
| 258 | function IGCM_comp_GetInputInitialStateFiles |
---|
| 259 | { |
---|
[544] | 260 | IGCM_debug_PushStack "IGCM_comp_GetInputInitialStateFiles" |
---|
[2] | 261 | |
---|
[544] | 262 | # Debug Print : |
---|
| 263 | echo |
---|
| 264 | IGCM_debug_Print 1 "IGCM_comp_GetInputInitialStateFiles" |
---|
| 265 | echo |
---|
[2] | 266 | |
---|
[902] | 267 | # Only the first time step need InitialStateFiles |
---|
[544] | 268 | # otherwise it's BoundaryConditions |
---|
| 269 | if ( ${FirstInitialize} ) ; then |
---|
[902] | 270 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ |
---|
| 271 | typeset file_in_ file_in file_out_ file_out do_init |
---|
[544] | 272 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 273 | # Initialize |
---|
| 274 | do_init="y" |
---|
| 275 | # Do we need to bring initial state file for this component |
---|
| 276 | if [ "${config_Restarts_OverRule}" = "y" ] ; then |
---|
[778] | 277 | eval do_init="n" |
---|
[544] | 278 | else |
---|
[778] | 279 | # Read component Restarts parameters |
---|
| 280 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart |
---|
| 281 | eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 |
---|
| 282 | if [ "${do_start}" = "y" ] ; then |
---|
| 283 | do_init="n" |
---|
| 284 | else |
---|
| 285 | do_init="y" |
---|
| 286 | fi |
---|
[544] | 287 | fi |
---|
[2] | 288 | |
---|
[544] | 289 | if [ "${do_init}" = "y" ] ; then |
---|
[902] | 290 | # Define component |
---|
[778] | 291 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 292 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
[2] | 293 | |
---|
[778] | 294 | # Debug Print : |
---|
| 295 | IGCM_debug_Print 3 "Initialisation files ${compname}" |
---|
[2] | 296 | |
---|
[778] | 297 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
[2] | 298 | |
---|
[778] | 299 | IGCM_card_DefineArrayFromOption ${card} InitialStateFiles List |
---|
| 300 | ListFilesName=${compname}_InitialStateFiles_List |
---|
[2] | 301 | |
---|
[778] | 302 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
| 303 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
| 304 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
| 305 | (( i=0 )) |
---|
| 306 | until [ $i -ge $NbFiles ]; do |
---|
| 307 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 308 | eval file_in=${file_in_} |
---|
| 309 | (( i_ = i+1 )) |
---|
| 310 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 311 | eval file_out=${file_out_} |
---|
[2] | 312 | |
---|
[778] | 313 | IGCM_sys_IsFileArchived ${file_in} |
---|
| 314 | if [ $? = 0 ] ; then |
---|
| 315 | IGCM_sys_Get ${file_in} ${file_out} |
---|
| 316 | #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
| 317 | else |
---|
| 318 | IGCM_sys_Cp ${file_in} ${file_out} |
---|
| 319 | fi |
---|
| 320 | (( i=i+2 )) |
---|
| 321 | done |
---|
| 322 | fi |
---|
[544] | 323 | fi |
---|
| 324 | done |
---|
| 325 | fi |
---|
| 326 | IGCM_debug_PopStack "IGCM_comp_GetInputInitialStateFiles" |
---|
[2] | 327 | } |
---|
| 328 | |
---|
| 329 | #======================================================================= |
---|
[247] | 330 | # Definition of Smooth modulo function |
---|
[902] | 331 | # usage : |
---|
[247] | 332 | # IGCM_SmoothModulo StringModulo value |
---|
| 333 | # |
---|
| 334 | # StringModulo : A string of min max and modulo like definition of Scilab vectors. |
---|
| 335 | # [min]:[modulo:][max] |
---|
| 336 | # where : |
---|
[902] | 337 | # [] value are optionnals; |
---|
[247] | 338 | # empty min equal 1 |
---|
| 339 | # empty max equal infinity |
---|
| 340 | # modulo not given or empty equal 1 |
---|
| 341 | # empty string or just ':' equal always. |
---|
| 342 | # |
---|
| 343 | # value : the value to test with the definition |
---|
| 344 | # |
---|
[902] | 345 | # return : true(1)/false(0) |
---|
[247] | 346 | function IGCM_SmoothModulo |
---|
| 347 | { |
---|
[544] | 348 | IGCM_debug_PushStack "IGCM_SmoothModulo" |
---|
| 349 | typeset defVector ModValue |
---|
[247] | 350 | |
---|
[544] | 351 | eval set +A defVector -- $( echo "${1}" | \ |
---|
| 352 | gawk -F ':' '{print ($1 == "" ? 1 : $1) " " (NF==3 ? ($2 == "" ? 1 : $2) : 1) " " (NF==3 ? ($3 == "" ? -1 : $3) : ($2 == "" ? -1 : $2))}' ) |
---|
[247] | 353 | |
---|
[544] | 354 | # Save Smooth Min and Max. Needed to call IGCM_sys_Get when appropriate |
---|
| 355 | arr[1]=${defVector[0]} |
---|
| 356 | arr[2]=${defVector[2]} |
---|
[412] | 357 | |
---|
[902] | 358 | # Test limits : |
---|
| 359 | # ${defVector[0]} <= ${2} <= ${defVector[2]} |
---|
[544] | 360 | # or ${defVector[2]} == -1 |
---|
| 361 | if ( [ ${2} -ge ${defVector[0]} ] && ( [ ${2} -le ${defVector[2]} ] || [ ${defVector[2]} -lt 0 ] ) ) ; then |
---|
| 362 | # Test modulo |
---|
| 363 | ModValue=$( expr \( ${2} - ${defVector[0]} \) % ${defVector[1]} ) |
---|
| 364 | if [ ${ModValue} -eq 0 ] ; then |
---|
| 365 | arr[3]=true |
---|
| 366 | echo ${arr[@]} |
---|
| 367 | IGCM_debug_PopStack "IGCM_SmoothModulo" |
---|
| 368 | return 1 |
---|
[247] | 369 | else |
---|
[544] | 370 | arr[3]=false |
---|
| 371 | echo ${arr[@]} |
---|
| 372 | IGCM_debug_PopStack "IGCM_SmoothModulo" |
---|
| 373 | return 0 |
---|
[247] | 374 | fi |
---|
[544] | 375 | else |
---|
| 376 | arr[3]=false |
---|
| 377 | echo ${arr[@]} |
---|
| 378 | IGCM_debug_PopStack "IGCM_SmoothModulo" |
---|
| 379 | return 0 |
---|
| 380 | fi |
---|
[247] | 381 | } |
---|
| 382 | |
---|
| 383 | #======================================================================= |
---|
| 384 | function IGCM_comp_GetInputSmoothFiles |
---|
| 385 | { |
---|
[544] | 386 | IGCM_debug_PushStack "IGCM_comp_GetInputSmoothFiles" |
---|
[247] | 387 | |
---|
[544] | 388 | # Debug Print : |
---|
| 389 | echo |
---|
| 390 | IGCM_debug_Print 1 "IGCM_comp_GetInputSmoothFiles" |
---|
| 391 | echo |
---|
[247] | 392 | |
---|
[544] | 393 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles j i i_ i__ |
---|
| 394 | typeset file_in_ file_in file_out_ file_out ret SmoothDef aux val |
---|
[247] | 395 | |
---|
[544] | 396 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 397 | # Define component |
---|
| 398 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 399 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
[247] | 400 | |
---|
[544] | 401 | # Debug Print : |
---|
| 402 | IGCM_debug_Print 3 "Smooth files ${compname}" |
---|
[247] | 403 | |
---|
[544] | 404 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
[247] | 405 | |
---|
[544] | 406 | IGCM_card_DefineArrayFromOption ${card} SmoothFiles List |
---|
| 407 | ListFilesName=${compname}_SmoothFiles_List |
---|
| 408 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
[247] | 409 | |
---|
[544] | 410 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != X"Section" ] ) ; then |
---|
| 411 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
[247] | 412 | |
---|
[544] | 413 | (( i=0 )) |
---|
| 414 | until [ $i -ge $NbFiles ]; do |
---|
[778] | 415 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 416 | eval file_in=${file_in_} |
---|
| 417 | (( i_ = i+1 )) |
---|
| 418 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 419 | eval file_out=${file_out_} |
---|
[247] | 420 | |
---|
[778] | 421 | # define CumulPeriod definition for this file |
---|
| 422 | (( i__ = i+2 )) |
---|
| 423 | eval SmoothDef=\${${ListFilesName}[$i__]} |
---|
| 424 | IGCM_debug_Print 3 " ${file_in} ${SmoothDef}" |
---|
| 425 | aux=$( IGCM_SmoothModulo ${SmoothDef} ${CumulPeriod} ) |
---|
| 426 | j=1 |
---|
| 427 | for val in ${aux} ; do |
---|
| 428 | [ ${j} -eq 1 ] && SmoothMin=${val} |
---|
| 429 | [ ${j} -eq 2 ] && SmoothMax=${val} |
---|
| 430 | [ ${j} -eq 3 ] && ret=${val} |
---|
| 431 | (( j=j+1 )) |
---|
| 432 | done |
---|
| 433 | [ ${SmoothMax} -eq -1 ] && SmoothMax=${CumulPeriod} |
---|
| 434 | if ( [ X${ret} = Xtrue ] || ( [ ${Period} -eq 1 ] && [ ${CumulPeriod} -ge ${SmoothMin} ] && [ ${CumulPeriod} -le ${SmoothMax} ] ) ) ; then |
---|
[548] | 435 | |
---|
[778] | 436 | IGCM_sys_IsFileArchived ${file_in} |
---|
| 437 | if [ $? = 0 ] ; then |
---|
| 438 | IGCM_sys_Get ${file_in} ${file_out} |
---|
| 439 | #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
| 440 | else |
---|
| 441 | IGCM_sys_Cp ${file_in} ${file_out} |
---|
| 442 | fi |
---|
| 443 | fi |
---|
| 444 | (( i=i+3 )) |
---|
[544] | 445 | done |
---|
| 446 | fi |
---|
| 447 | done |
---|
[778] | 448 | |
---|
[544] | 449 | IGCM_debug_PopStack "IGCM_comp_GetInputSmoothFiles" |
---|
[247] | 450 | } |
---|
| 451 | |
---|
| 452 | #======================================================================= |
---|
[2] | 453 | function IGCM_comp_GetInputBoundaryFiles |
---|
| 454 | { |
---|
[544] | 455 | IGCM_debug_PushStack "IGCM_comp_GetInputBoundaryFiles" |
---|
[2] | 456 | |
---|
[544] | 457 | # Debug Print : |
---|
| 458 | echo |
---|
| 459 | IGCM_debug_Print 1 "IGCM_comp_GetInputBoundaryFiles" |
---|
| 460 | echo |
---|
[2] | 461 | |
---|
[902] | 462 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ |
---|
| 463 | typeset file_in_ file_in file_out_ file_out |
---|
[2] | 464 | |
---|
[544] | 465 | if [ ${Period} = 1 ]; then |
---|
| 466 | ListFixBoundary=" " |
---|
| 467 | fi |
---|
[2] | 468 | |
---|
[544] | 469 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[2] | 470 | |
---|
[544] | 471 | # Define component |
---|
| 472 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 473 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
[2] | 474 | |
---|
[544] | 475 | # Debug Print : |
---|
| 476 | IGCM_debug_Print 3 "Boundary files ${compname}" |
---|
[2] | 477 | |
---|
[544] | 478 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
[2] | 479 | |
---|
[544] | 480 | IGCM_card_DefineArrayFromOption ${card} BoundaryFiles List |
---|
| 481 | ListFilesName=${compname}_BoundaryFiles_List |
---|
| 482 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
[2] | 483 | |
---|
[544] | 484 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
| 485 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
[2] | 486 | |
---|
[544] | 487 | (( i=0 )) |
---|
| 488 | until [ $i -ge $NbFiles ]; do |
---|
[778] | 489 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 490 | eval file_in=${file_in_} |
---|
| 491 | (( i_ = i+1 )) |
---|
| 492 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 493 | eval file_out=${file_out_} |
---|
[2] | 494 | |
---|
[778] | 495 | IGCM_sys_IsFileArchived ${file_in} |
---|
| 496 | if [ $? = 0 ] ; then |
---|
| 497 | IGCM_sys_Get ${file_in} ${file_out} |
---|
[809] | 498 | IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
[778] | 499 | else |
---|
| 500 | IGCM_sys_Cp ${file_in} ${file_out} |
---|
| 501 | fi |
---|
[2] | 502 | |
---|
[778] | 503 | (( i=i+2 )) |
---|
[544] | 504 | done |
---|
| 505 | fi |
---|
[2] | 506 | |
---|
[544] | 507 | # Get non deleted files |
---|
| 508 | if [ ${Period} = 1 ]; then |
---|
[2] | 509 | |
---|
[544] | 510 | IGCM_card_DefineArrayFromOption ${card} BoundaryFiles ListNonDel |
---|
| 511 | ListFilesName=${compname}_BoundaryFiles_ListNonDel |
---|
| 512 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
[778] | 513 | |
---|
[544] | 514 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
[778] | 515 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
[2] | 516 | |
---|
[778] | 517 | (( i=0 )) |
---|
| 518 | until [ $i -ge $NbFiles ]; do |
---|
| 519 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 520 | eval file_in=${file_in_} |
---|
| 521 | (( i_ = i+1 )) |
---|
| 522 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 523 | eval file_out=${file_out_} |
---|
[2] | 524 | |
---|
[778] | 525 | IGCM_sys_IsFileArchived ${file_in} |
---|
| 526 | if [ $? = 0 ] ; then |
---|
| 527 | IGCM_sys_Get ${file_in} ${file_out} |
---|
| 528 | #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
| 529 | else |
---|
| 530 | IGCM_sys_Cp ${file_in} ${file_out} |
---|
| 531 | fi |
---|
[2] | 532 | |
---|
[778] | 533 | if [ X${file_out} != X. ] ; then |
---|
| 534 | ListFixBoundary=${ListFixBoundary}" "${file_out} |
---|
| 535 | else |
---|
| 536 | ListFixBoundary=${ListFixBoundary}" "$( basename ${file_in} ) |
---|
| 537 | fi |
---|
| 538 | |
---|
| 539 | (( i=i+2 )) |
---|
| 540 | done |
---|
[544] | 541 | fi |
---|
| 542 | fi |
---|
| 543 | done |
---|
[778] | 544 | |
---|
[544] | 545 | IGCM_debug_PopStack "IGCM_comp_GetInputBoundaryFiles" |
---|
[2] | 546 | } |
---|
| 547 | |
---|
| 548 | #======================================================================= |
---|
| 549 | function IGCM_comp_DelFixeBoundaryFiles |
---|
| 550 | { |
---|
[544] | 551 | IGCM_debug_PushStack "IGCM_comp_DelFixeBoundaryFiles" |
---|
[2] | 552 | |
---|
[544] | 553 | # Debug Print : |
---|
| 554 | echo |
---|
| 555 | IGCM_debug_Print 1 "IGCM_comp_DelFixeBoundaryFiles" |
---|
| 556 | echo |
---|
[2] | 557 | |
---|
[544] | 558 | ls -l ${ListFixBoundary} |
---|
| 559 | rm -f ${ListFixBoundary} |
---|
[2] | 560 | |
---|
[544] | 561 | IGCM_debug_PopStack "IGCM_comp_DelFixeBoundaryFiles" |
---|
[2] | 562 | } |
---|
| 563 | |
---|
| 564 | #======================================================================= |
---|
| 565 | function IGCM_comp_GetInputParametersFiles |
---|
| 566 | { |
---|
[544] | 567 | IGCM_debug_PushStack "IGCM_comp_GetInputParametersFiles" |
---|
[2] | 568 | |
---|
[544] | 569 | # Debug Print : |
---|
| 570 | echo |
---|
| 571 | IGCM_debug_Print 1 "IGCM_comp_GetInputParametersFiles" |
---|
| 572 | echo |
---|
[2] | 573 | |
---|
[544] | 574 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ file_in file_out |
---|
| 575 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[902] | 576 | # Define component |
---|
[544] | 577 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 578 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
[2] | 579 | |
---|
[544] | 580 | # Debug Print : |
---|
| 581 | IGCM_debug_Print 3 "Parameters ${compname}" |
---|
[2] | 582 | |
---|
[778] | 583 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
[2] | 584 | |
---|
[544] | 585 | IGCM_card_DefineArrayFromOption ${card} ParametersFiles List |
---|
| 586 | ListFilesName=${compname}_ParametersFiles_List |
---|
| 587 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
[2] | 588 | |
---|
[544] | 589 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
| 590 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
[2] | 591 | |
---|
[544] | 592 | (( i=0 )) |
---|
| 593 | until [ $i -ge $NbFiles ]; do |
---|
[778] | 594 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 595 | eval file_in=${file_in_} |
---|
| 596 | (( i_ = i+1 )) |
---|
| 597 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
[902] | 598 | eval file_out=${file_out_} |
---|
[2] | 599 | |
---|
[902] | 600 | IGCM_sys_Cp ${file_in} ${file_out} |
---|
[778] | 601 | IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} |
---|
[2] | 602 | |
---|
[778] | 603 | (( i=i+2 )) |
---|
[544] | 604 | done |
---|
| 605 | fi |
---|
| 606 | done |
---|
[2] | 607 | |
---|
[544] | 608 | IGCM_debug_PopStack "IGCM_comp_GetInputParametersFiles" |
---|
[2] | 609 | } |
---|
| 610 | |
---|
| 611 | #======================================================================= |
---|
| 612 | function IGCM_comp_GetInputRestartFiles |
---|
| 613 | { |
---|
[544] | 614 | IGCM_debug_PushStack "IGCM_comp_GetInputRestartFiles" |
---|
[2] | 615 | |
---|
[544] | 616 | # Debug Print : |
---|
| 617 | echo |
---|
| 618 | IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles" |
---|
| 619 | echo |
---|
[2] | 620 | |
---|
[590] | 621 | typeset Date_tmp Date_r Path_r do_start CompOldName Path_OUT Path_BUF |
---|
| 622 | typeset Buffered Archived Tared PotentialTarFile IsMatching TarFileFound |
---|
[902] | 623 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ |
---|
[544] | 624 | typeset file_in file_out file_in_ file_out_ file_in_Name |
---|
| 625 | typeset -Z4 j4 |
---|
[821] | 626 | #BASH declare j4 |
---|
[2] | 627 | |
---|
[778] | 628 | IsMatching="" |
---|
| 629 | |
---|
[544] | 630 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[902] | 631 | # Define component |
---|
[544] | 632 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 633 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
| 634 | # |
---|
| 635 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
| 636 | # |
---|
| 637 | IGCM_card_DefineArrayFromOption ${card} RestartFiles List |
---|
| 638 | ListFilesName=${compname}_RestartFiles_List |
---|
| 639 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
[2] | 640 | |
---|
[544] | 641 | # Debug Print : |
---|
| 642 | IGCM_debug_Print 3 "restart ${compname}" |
---|
[2] | 643 | |
---|
[544] | 644 | if ( ${FirstInitialize} ) ; then |
---|
[2] | 645 | |
---|
[544] | 646 | if [ "${config_Restarts_OverRule}" = "y" ] ; then |
---|
[778] | 647 | eval config_${comp}_Restart="y" |
---|
| 648 | eval config_${comp}_RestartDate=${config_Restarts_RestartDate} |
---|
| 649 | eval config_${comp}_RestartJobName=${config_Restarts_RestartJobName} |
---|
| 650 | eval config_${comp}_RestartPath=${config_Restarts_RestartPath} |
---|
| 651 | eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 |
---|
| 652 | eval CompOldName=${comp} |
---|
[544] | 653 | else |
---|
[778] | 654 | # Read component Restarts parameters |
---|
| 655 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart |
---|
| 656 | eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1 |
---|
[2] | 657 | |
---|
[778] | 658 | if [ "${do_start}" = "y" ] ; then |
---|
| 659 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartDate |
---|
| 660 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartJobName |
---|
| 661 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartPath |
---|
| 662 | else |
---|
| 663 | eval config_${comp}_RestartDate=-1 |
---|
| 664 | eval config_${comp}_RestartJobName=${NULL_STR} |
---|
| 665 | eval config_${comp}_RestartPath=${NULL_STR} |
---|
| 666 | fi |
---|
[849] | 667 | |
---|
[778] | 668 | eval CompOldName=\${config_${comp}_OldName} |
---|
| 669 | if [ X${CompOldName} = X ] ; then |
---|
| 670 | eval CompOldName=${comp} |
---|
| 671 | fi |
---|
| 672 | |
---|
| 673 | # Reinitialize IsMatching to allow searching for a different tar file for each component. |
---|
| 674 | IsMatching="" |
---|
| 675 | TarFileFound="" |
---|
[544] | 676 | fi |
---|
[2] | 677 | |
---|
[544] | 678 | if [ "${do_start}" = "y" ] ; then |
---|
[2] | 679 | |
---|
[672] | 680 | # Restore Restarts files |
---|
| 681 | #----------------------- |
---|
[778] | 682 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then |
---|
| 683 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
[2] | 684 | |
---|
[778] | 685 | (( i=1 )) |
---|
| 686 | until [ $i -gt $NbFiles ]; do |
---|
| 687 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 688 | eval file_in=${file_in_} |
---|
| 689 | (( i_ = i+1 )) |
---|
| 690 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 691 | eval file_out=${file_out_} |
---|
| 692 | |
---|
| 693 | eval Date_tmp=\${config_${comp}_RestartDate} |
---|
| 694 | Date_r=$( IGCM_date_ConvertFormatToGregorian ${Date_tmp} ) |
---|
[672] | 695 | # will be re-use |
---|
| 696 | eval RestartPath=\${config_${comp}_RestartPath} |
---|
| 697 | eval RestartJobName=\${config_${comp}_RestartJobName} |
---|
| 698 | # |
---|
[778] | 699 | Path_r=${RestartPath}/${RestartJobName}/${CompOldName}/Restart |
---|
| 700 | file_in_Name=${RestartJobName}_${Date_r}_${file_in} |
---|
[2] | 701 | |
---|
[778] | 702 | extension_in=$( echo ${file_in_Name##*.} ) |
---|
| 703 | extension_out=$( echo ${file_out##*.} ) |
---|
[672] | 704 | |
---|
[778] | 705 | generic_restart_file_name_in=$( basename ${file_in_Name} .${extension_in} ) |
---|
| 706 | generic_restart_file_name_out=$( basename ${file_out} .${extension_out} ) |
---|
[2] | 707 | |
---|
[778] | 708 | Path_OUT=${Path_r}/${generic_restart_file_name_in} |
---|
| 709 | |
---|
[672] | 710 | if [ $( IGCM_sys_TestFileBuffer ${Path_OUT}*.${extension_in} ; echo $? ) = 0 ] ; then |
---|
[897] | 711 | IGCM_debug_Print 3 "Buffered restart ${Path_OUT}*.${extension_in} " |
---|
[778] | 712 | Buffered=true |
---|
| 713 | Archived=false |
---|
| 714 | Tared=false |
---|
| 715 | nb_restart_file=$(IGCM_sys_CountFileBuffer ${Path_OUT}_????.${extension_in}) |
---|
[672] | 716 | elif [ $( IGCM_sys_TestFileArchive ${Path_OUT}*.${extension_in} ; echo $? ) = 0 ] ; then |
---|
[897] | 717 | IGCM_debug_Print 3 "Archived restart ${Path_OUT}*.${extension_in}" |
---|
[778] | 718 | Buffered=false |
---|
| 719 | Archived=true |
---|
| 720 | Tared=false |
---|
| 721 | nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_OUT}_????.${extension_in}) |
---|
[672] | 722 | else |
---|
[897] | 723 | IGCM_debug_Print 3 "No restart file in the buffer nor in the archive directory" |
---|
| 724 | IGCM_debug_Print 3 "${Path_OUT}*.${extension_in} do not exist" |
---|
[902] | 725 | IGCM_debug_Print 3 "Restart files will now be searched for in : ${RestartPath}/${RestartJobName}/RESTART" |
---|
[778] | 726 | Buffered=false |
---|
| 727 | Archived=false |
---|
| 728 | Tared=true |
---|
[672] | 729 | # Look after the tar file we want if we did not found it already |
---|
[778] | 730 | if [ X${IsMatching} = X ] ; then |
---|
[947] | 731 | IGCM_sys_TestDirArchive ${RestartPath}/${RestartJobName}/RESTART |
---|
| 732 | if [ $? ] ; then |
---|
[897] | 733 | for PotentialTarFile in $( IGCM_sys_RshArchive "find ${RestartPath}/${RestartJobName}/RESTART -name "${RestartJobName}_*restart*.tar" -print" ) ; do |
---|
| 734 | IsMatching=$( echo ${PotentialTarFile##*/} | \ |
---|
| 735 | sed "s:_restart::" | \ |
---|
| 736 | sed "s:^${RestartJobName}_::" | \ |
---|
| 737 | sed "s:\.tar$::" | \ |
---|
| 738 | gawk -F_ -v restartdate=${Date_r} \ |
---|
| 739 | '{if (($1 <= restartdate) && ($2 >= restartdate)) {print $1"_"$2}}' ) |
---|
| 740 | if [ ! X${IsMatching} = X ] ; then |
---|
| 741 | TarFileFound=${PotentialTarFile} |
---|
| 742 | break |
---|
| 743 | fi |
---|
| 744 | done |
---|
[1017] | 745 | fi |
---|
| 746 | # Stop here if nothing has been found |
---|
| 747 | if [ X${TarFileFound} = X ] ; then |
---|
[902] | 748 | IGCM_debug_Print 3 "Restart files were not found!" |
---|
| 749 | IGCM_debug_Print 3 "Restart files have been searched for in buffer and archive directory." |
---|
| 750 | IGCM_debug_Print 3 "They have been searched for in packed and unpacked format." |
---|
[897] | 751 | IGCM_debug_Exit "Please double check restart settings in config.card" |
---|
| 752 | IGCM_debug_Verif_Exit |
---|
| 753 | fi |
---|
[778] | 754 | fi |
---|
[918] | 755 | IGCM_sys_PrepareTaredRestart ${TarFileFound} |
---|
| 756 | TarFileLocation=$( basename ${TarFileFound} ) |
---|
[801] | 757 | IGCM_debug_Print 1 "tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}" |
---|
| 758 | tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in} |
---|
[778] | 759 | nb_restart_file=$( IGCM_sys_CountFileBuffer ${comp}_${generic_restart_file_name_in}_????.${extension_in} ) |
---|
| 760 | fi |
---|
[672] | 761 | |
---|
| 762 | if [ ${nb_restart_file} -gt 1 ] ; then |
---|
[821] | 763 | j=0 # BASH LINE NOT NEEDED |
---|
| 764 | # BASH for j4 in in $( eval echo {0000..$(( nb_restart_file - 1 ))} ) ; do |
---|
| 765 | until [ $j -ge ${nb_restart_file} ]; do # BASH LINE NOT NEEDED |
---|
| 766 | j4=${j} # BASH LINE NOT NEEDED |
---|
[778] | 767 | if [ X${Buffered} = Xtrue ] ; then |
---|
| 768 | IGCM_sys_GetBuffer ${Path_OUT}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out} |
---|
| 769 | elif [ X${Archived} = Xtrue ] ; then |
---|
| 770 | IGCM_sys_Get ${Path_OUT}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out} |
---|
| 771 | elif [ X${Tared} = Xtrue ] ; then |
---|
| 772 | IGCM_sys_Mv ${comp}_${generic_restart_file_name_in}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out} |
---|
| 773 | fi |
---|
[821] | 774 | (( j=j+1 )) #BASH LINE NOT NEEDED |
---|
[778] | 775 | done |
---|
[740] | 776 | |
---|
| 777 | if [ X${NUM_PROC_OCE} != X ] ; then |
---|
| 778 | if [ ${NUM_PROC_OCE} -ne ${nb_restart_file} ] ; then |
---|
| 779 | IGCM_sys_rebuild ${generic_restart_file_name_out}.${extension_out} ${generic_restart_file_name_out}_????.${extension_out} |
---|
| 780 | IGCM_sys_Rm ${generic_restart_file_name_out}_????.${extension_out} |
---|
| 781 | fi |
---|
| 782 | fi |
---|
[778] | 783 | else |
---|
| 784 | if [ X${Buffered} = Xtrue ] ; then |
---|
| 785 | IGCM_sys_GetBuffer ${Path_r}/${file_in_Name} ${file_out} |
---|
| 786 | elif [ X${Archived} = Xtrue ] ; then |
---|
| 787 | IGCM_sys_Get ${Path_r}/${file_in_Name} ${file_out} |
---|
| 788 | elif [ X${Tared} = Xtrue ] ; then |
---|
| 789 | IGCM_sys_Mv ${comp}_${file_in_Name} ${file_out} |
---|
| 790 | fi |
---|
| 791 | fi |
---|
| 792 | (( i=i+3 )) |
---|
| 793 | done |
---|
| 794 | else |
---|
| 795 | if [ X${FileName0} != XNONE ] ; then |
---|
| 796 | IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}." |
---|
| 797 | else |
---|
| 798 | IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}." |
---|
| 799 | fi |
---|
| 800 | fi |
---|
[544] | 801 | fi |
---|
[893] | 802 | elif ( [ ${Period} -eq 1 ] && [ ${DRYRUN} -eq 0 ] ) ; then |
---|
[544] | 803 | # if not FirstInitialize and first loop of this job |
---|
[2] | 804 | |
---|
[544] | 805 | # Restore Restarts files |
---|
| 806 | #----------------------- |
---|
| 807 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then |
---|
[778] | 808 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
[2] | 809 | |
---|
[778] | 810 | (( i=1 )) |
---|
| 811 | until [ $i -gt $NbFiles ]; do |
---|
| 812 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 813 | eval file_in=${file_in_} |
---|
| 814 | (( i_ = i+1 )) |
---|
| 815 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 816 | eval file_out=${file_out_} |
---|
[2] | 817 | |
---|
[1028] | 818 | file_in_Name=${config_UserChoices_JobName}_${LastPeriodDateEnd}_${file_in} |
---|
[662] | 819 | |
---|
[778] | 820 | extension_in=$( echo ${file_in_Name##*.} ) |
---|
| 821 | extension_out=$( echo ${file_out##*.} ) |
---|
[67] | 822 | |
---|
[778] | 823 | generic_restart_file_name_in=$( basename ${file_in_Name} .${extension_in} ) |
---|
| 824 | generic_restart_file_name_out=$( basename ${file_out} .${extension_out} ) |
---|
| 825 | |
---|
| 826 | eval Path_BUF=\${R_BUF_${comp}_R}/${generic_restart_file_name_in} |
---|
| 827 | eval Path_OUT=\${R_OUT_${comp}_R}/${generic_restart_file_name_in} |
---|
| 828 | |
---|
[662] | 829 | if [ $( IGCM_sys_TestFileBuffer ${Path_BUF}*.${extension_in} ; echo $? ) = 0 ] ; then |
---|
[897] | 830 | IGCM_debug_Print 3 "Buffered restart ${Path_BUF}*.${extension_in}" |
---|
[778] | 831 | Buffered=true |
---|
| 832 | Archived=false |
---|
| 833 | Tared=false |
---|
| 834 | nb_restart_file=$(IGCM_sys_CountFileBuffer ${Path_BUF}_????.${extension_in}) |
---|
[672] | 835 | elif [ $( IGCM_sys_TestFileArchive ${Path_OUT}*.${extension_in} ; echo $? ) = 0 ] ; then |
---|
[897] | 836 | IGCM_debug_Print 3 "Archived restart ${Path_OUT}*.${extension_in}" |
---|
[778] | 837 | Buffered=false |
---|
| 838 | Archived=true |
---|
| 839 | Tared=false |
---|
| 840 | nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_OUT}_????.${extension_in}) |
---|
| 841 | else |
---|
[897] | 842 | IGCM_debug_Print 3 "No restart file in the buffer nor in the archive directory" |
---|
[902] | 843 | IGCM_debug_Print 3 "Restart files will now be searched for in : ${R_SAVE}/RESTART" |
---|
[778] | 844 | Buffered=false |
---|
| 845 | Archived=false |
---|
| 846 | Tared=true |
---|
| 847 | # Look after the tar file we want if we did not found it already |
---|
| 848 | if [ X${IsMatching} = X ] ; then |
---|
[801] | 849 | for PotentialTarFile in $( IGCM_sys_RshArchive "find ${R_SAVE}/RESTART -name "${config_UserChoices_JobName}_*_restart.tar" -print" ) ; do |
---|
[778] | 850 | IsMatching=$( echo ${PotentialTarFile##*/} | sed "s:^${config_UserChoices_JobName}_::" | sed "s:\.restart\.tar$::" | gawk -F_ -v restartdate=${LastPeriodDateEnd} '{if (($1 < restartdate) && ($2 >= restartdate)) {print $1"_"$2}}' ) |
---|
| 851 | if [ ! X${IsMatching} = X ] ; then |
---|
| 852 | TarFileFound=${PotentialTarFile} |
---|
| 853 | break |
---|
| 854 | fi |
---|
| 855 | done |
---|
| 856 | fi |
---|
[1017] | 857 | # Stop here if nothing has been found |
---|
| 858 | if [ X${TarFileFound} = X ] ; then |
---|
| 859 | IGCM_debug_Print 3 "Restart files were not found!" |
---|
| 860 | IGCM_debug_Print 3 "Restart files have been searched for in buffer and archive directory." |
---|
| 861 | IGCM_debug_Print 3 "They have been searched for in packed and unpacked format." |
---|
| 862 | IGCM_debug_Exit "Please double check restart settings in config.card" |
---|
| 863 | IGCM_debug_Verif_Exit |
---|
| 864 | fi |
---|
[918] | 865 | IGCM_sys_PrepareTaredRestart ${TarFileFound} |
---|
| 866 | TarFileLocation=$( basename ${TarFileFound} ) |
---|
[801] | 867 | IGCM_debug_Print 1 "tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}" |
---|
| 868 | tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in} |
---|
[778] | 869 | nb_restart_file=$( IGCM_sys_CountFileBuffer ${comp}_${generic_restart_file_name_in}_????.${extension_in} ) |
---|
| 870 | fi |
---|
[41] | 871 | |
---|
[778] | 872 | if [ ${nb_restart_file} -gt 1 ] ; then |
---|
[821] | 873 | j=0 # BASH LINE NOT NEEDED |
---|
| 874 | #BASH for j4 in in $( eval echo {0000..$(( nb_restart_file - 1 ))} ) ; do |
---|
| 875 | until [ $j -ge ${nb_restart_file} ]; do # BASH LINE NOT NEEDED |
---|
| 876 | j4=${j} # BASH LINE NOT NEEDED |
---|
[778] | 877 | if [ X${Buffered} = Xtrue ] ; then |
---|
| 878 | IGCM_sys_GetBuffer ${Path_BUF}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out} |
---|
| 879 | elif [ X${Archived} = Xtrue ] ; then |
---|
| 880 | IGCM_sys_Get ${Path_OUT}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out} |
---|
| 881 | elif [ X${Tared} = Xtrue ] ; then |
---|
| 882 | IGCM_sys_Mv ${comp}_${generic_restart_file_name_in}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out} |
---|
| 883 | fi |
---|
[821] | 884 | (( j=j+1 )) # BASH LINE NOT NEEDED |
---|
[778] | 885 | done |
---|
| 886 | else |
---|
| 887 | if [ X${Buffered} = Xtrue ] ; then |
---|
| 888 | eval IGCM_sys_GetBuffer \${R_BUF_${comp}_R}/${file_in_Name} ${file_out} |
---|
| 889 | elif [ X${Archived} = Xtrue ] ; then |
---|
| 890 | eval IGCM_sys_Get \${R_OUT_${comp}_R}/${file_in_Name} ${file_out} |
---|
| 891 | elif [ X${Tared} = Xtrue ] ; then |
---|
| 892 | IGCM_sys_Mv ${comp}_${file_in_Name} ${file_out} |
---|
| 893 | fi |
---|
| 894 | fi |
---|
| 895 | (( i=i+3 )) |
---|
| 896 | done |
---|
[544] | 897 | else |
---|
[778] | 898 | if [ X${FileName0} != XNONE ] ; then |
---|
| 899 | IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}." |
---|
| 900 | else |
---|
| 901 | IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}." |
---|
| 902 | fi |
---|
[544] | 903 | fi |
---|
[420] | 904 | fi |
---|
[544] | 905 | done |
---|
[420] | 906 | |
---|
[544] | 907 | NbFiles=$( ls * 2> /dev/null | wc -l ) |
---|
| 908 | if [ ${NbFiles} -gt 0 ] ; then |
---|
| 909 | IGCM_sys_Chmod u+rw * |
---|
| 910 | fi |
---|
| 911 | |
---|
| 912 | IGCM_debug_PopStack "IGCM_comp_GetInputRestartFiles" |
---|
[2] | 913 | } |
---|
| 914 | |
---|
| 915 | #======================================================================= |
---|
[269] | 916 | function IGCM_comp_PeriodStart |
---|
| 917 | { |
---|
[544] | 918 | IGCM_debug_PushStack "IGCM_comp_PeriodStart" |
---|
[269] | 919 | |
---|
[544] | 920 | # Debug Print : |
---|
| 921 | echo |
---|
| 922 | IGCM_debug_Print 1 "IGCM_comp_PeriodStart" |
---|
| 923 | echo |
---|
[269] | 924 | |
---|
[902] | 925 | typeset ExeNameIn ExeNameOut |
---|
[544] | 926 | typeset comp compname comptagname |
---|
| 927 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[902] | 928 | # Define component |
---|
[544] | 929 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 930 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
[269] | 931 | |
---|
[544] | 932 | # Copy executable for this component |
---|
| 933 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 934 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
[269] | 935 | |
---|
[544] | 936 | # Debug Print |
---|
| 937 | IGCM_debug_Print 3 "PeriodStart ${compname} Driver Function (if any)." |
---|
| 938 | # UPDATE component |
---|
| 939 | ${comp}_PeriodStart 2> /dev/null |
---|
[269] | 940 | |
---|
[544] | 941 | done |
---|
[269] | 942 | |
---|
[544] | 943 | IGCM_debug_PopStack "IGCM_comp_PeriodStart" |
---|
[269] | 944 | } |
---|
| 945 | |
---|
[1166] | 946 | |
---|
| 947 | |
---|
[269] | 948 | #======================================================================= |
---|
[1166] | 949 | function IGCM_comp_modifyFile |
---|
| 950 | { |
---|
| 951 | # |
---|
| 952 | # syntax: IGCM_comp_modifyFile filein key [value] |
---|
| 953 | # |
---|
| 954 | # For example : IGCM_comp_modifyFile metrics_template.py case_id \'SE_${YEARS}\' |
---|
| 955 | # |
---|
| 956 | # This function is used to replace a pattern in a file for a specific variable. |
---|
| 957 | # |
---|
| 958 | # Arguments: |
---|
| 959 | # - filein : the file in run directory in which the variable should be set |
---|
| 960 | # - key : the variable to modify |
---|
| 961 | # - value : the value to set the key equal to |
---|
| 962 | # |
---|
| 963 | IGCM_debug_PushStack "IGCM_comp_modifyFile" |
---|
| 964 | |
---|
| 965 | typeset filein key value pattern |
---|
| 966 | |
---|
| 967 | # Set local variables and test the arguments |
---|
| 968 | if [ $# = 3 ] ; then |
---|
| 969 | # Normal case with 3 arguments |
---|
| 970 | filein=$1 ; key=$2 ; value=$3 |
---|
| 971 | else |
---|
| 972 | IGCM_debug_Exit "IGCM_comp_modifyFile: Bad number of arguments." |
---|
| 973 | IGCM_debug_PopStack "IGCM_comp_modifyFile" |
---|
| 974 | return |
---|
| 975 | fi |
---|
| 976 | IGCM_debug_Print 1 "Entering IGCM_comp_modifyFile with arguments: ${filein} ${key} ${value}" |
---|
| 977 | |
---|
| 978 | # Test if the file exist |
---|
| 979 | if [ ! -f ${filein} ] ; then |
---|
| 980 | IGCM_debug_Exit "IGCM_comp_modifyFile: ${filein} does not exist." |
---|
| 981 | IGCM_debug_PopStack "IGCM_comp_modifyFile" |
---|
| 982 | return |
---|
| 983 | fi |
---|
| 984 | |
---|
| 985 | # Read the line with key in the file without the comments |
---|
| 986 | pattern=$( grep "^ *${key} *=" ${filein} | sed -e "s% *\!.*%%" ) |
---|
| 987 | |
---|
| 988 | # Verify the existance of the pattern |
---|
| 989 | if [ X"${pattern}" = X ] ; then |
---|
| 990 | # Variable key is not set in filein, stop. |
---|
| 991 | IGCM_debug_Exit "IGCM_comp_modifyFile : Variable ${key} is not set in correct file. It should be set in ${filein}." |
---|
| 992 | IGCM_debug_PopStack "IGCM_comp_modifyFile" |
---|
| 993 | return |
---|
| 994 | fi |
---|
| 995 | |
---|
| 996 | # Now change key in filein |
---|
[1176] | 997 | #sed -e "s:${pattern}:${key}=${value}:" ${filein} > ${filein}.tmp |
---|
| 998 | sed -e "s:^ *${key} *=.*:${key}=${value}:" ${filein} > ${filein}.tmp |
---|
[1166] | 999 | IGCM_debug_Print 1 "IGCM_comp_modifyFile: In ${filein} set ${key}=${value}" |
---|
| 1000 | \mv ${filein}.tmp ${filein} |
---|
| 1001 | |
---|
| 1002 | IGCM_debug_PopStack "IGCM_comp_modifyFile" |
---|
| 1003 | } |
---|
| 1004 | |
---|
| 1005 | #======================================================================= |
---|
[1069] | 1006 | function IGCM_comp_modifyDefFile |
---|
| 1007 | { |
---|
| 1008 | # |
---|
| 1009 | # syntax: IGCM_comp_modifyDefFile type filein key [value] |
---|
| 1010 | # |
---|
| 1011 | # For example : IGCM_comp_modifyDefFile blocker run.def day_step 1200 |
---|
| 1012 | # |
---|
| 1013 | # This function is used to modify a parameter file for a specific variable. |
---|
[1075] | 1014 | # The file must be a ".def" file, i.e. with IOIPSL parameter file syntax. |
---|
| 1015 | # This function can be used in the comp.driver files for the components. |
---|
[1069] | 1016 | # |
---|
[1075] | 1017 | # Arguments: |
---|
[1081] | 1018 | # - type : first argument must be blocker, nonblocker or force |
---|
[1075] | 1019 | # For "blocker" case, the variable must be attributed the keyworld AUTO |
---|
[1069] | 1020 | # otherwise this function will exit. |
---|
[1075] | 1021 | # For "nonblocker" case, the user can remove or modify the variable. For |
---|
| 1022 | # this case, as long as AUTO is not set, no modification will be done. |
---|
[1081] | 1023 | # For "force" case, the variable will be modified even if it is not set to AUTO |
---|
[1069] | 1024 | # - filein : the file in run directory of .def type in which the variable should be set |
---|
| 1025 | # - key : the variable to modify |
---|
[1075] | 1026 | # - value : the value to set the key equal to, optional. If value is not set or if |
---|
[1069] | 1027 | # value=DEFAULT, then a default value must be given in filein using syntax : |
---|
| 1028 | # key= AUTO : DEFAULT=def_value |
---|
| 1029 | # |
---|
[1075] | 1030 | IGCM_debug_PushStack "IGCM_comp_modifyDefFile" |
---|
[1069] | 1031 | |
---|
[1166] | 1032 | typeset type filein key value |
---|
| 1033 | typeset filelist nb_occ modify |
---|
| 1034 | |
---|
[1075] | 1035 | # Set local variables and test the arguments |
---|
| 1036 | if [ $# = 4 ] ; then |
---|
| 1037 | # Normal case with 4 arguments |
---|
| 1038 | type=$1 ; filein=$2 ; key=$3 ; value=$4 |
---|
| 1039 | elif [ $# = 3 ] ; then |
---|
| 1040 | # Normal case with 3 arguments |
---|
| 1041 | type=$1 ; filein=$2 ; key=$3; value="DEFAULT" |
---|
| 1042 | else |
---|
| 1043 | IGCM_debug_Exit "IGCM_comp_modifyDefFile: Bad number of arguments." |
---|
[1079] | 1044 | IGCM_debug_PopStack "IGCM_comp_modifyDefFile" |
---|
[1075] | 1045 | return |
---|
| 1046 | fi |
---|
[1166] | 1047 | IGCM_debug_Print 1 "Entering IGCM_comp_modifyDefFile with arguments: ${type} ${filein} ${key} ${value}" |
---|
[1069] | 1048 | |
---|
[1075] | 1049 | # Test if first argument is correct |
---|
[1166] | 1050 | if [ ${type} != blocker ] && [ ${type} != nonblocker ] && [ ${type} != force ] ; then |
---|
[1081] | 1051 | IGCM_debug_Exit "IGCM_comp_modifyDefFile: Error in first argument must be blocker, nonblocker or force" |
---|
[1079] | 1052 | IGCM_debug_PopStack "IGCM_comp_modifyDefFile" |
---|
[1075] | 1053 | return |
---|
| 1054 | fi |
---|
[1069] | 1055 | |
---|
[1215] | 1056 | # Test if the file exist. |
---|
| 1057 | # Exit with error if the file does not exist for the case blocker or force. |
---|
| 1058 | # Only return for the case nonblocker. |
---|
[1075] | 1059 | if [ ! -f ${filein} ] ; then |
---|
[1215] | 1060 | if [ ${type} = blocker ] || [ ${type} = force ] ; then |
---|
| 1061 | IGCM_debug_Exit "IGCM_comp_modifyDefFile: ${filein} does not exist." |
---|
| 1062 | else |
---|
| 1063 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: ${filein} does not exist. Nothing will be done for this file." |
---|
| 1064 | fi |
---|
[1079] | 1065 | IGCM_debug_PopStack "IGCM_comp_modifyDefFile" |
---|
[1075] | 1066 | return |
---|
| 1067 | fi |
---|
[1069] | 1068 | |
---|
[1102] | 1069 | # Define list of files to test using all files with suffix .def (except used*.def) |
---|
| 1070 | filelist=$( ls *def | grep -v used ) |
---|
[1069] | 1071 | |
---|
[1075] | 1072 | # Count number of occurances for the key in all files |
---|
[1166] | 1073 | nb_occ=$( grep -w ${key} ${filelist} | grep -v "#" | wc -l ) |
---|
[1069] | 1074 | |
---|
[1075] | 1075 | # Test if key is set several times |
---|
[1166] | 1076 | if [ ${nb_occ} -gt 1 ] ; then |
---|
| 1077 | IGCM_debug_Exit "IGCM_comp_modifyDefFile : Error in ${filein}: Variable=${key} is set ${nb_occ} times" |
---|
[1079] | 1078 | IGCM_debug_PopStack "IGCM_comp_modifyDefFile" |
---|
[1075] | 1079 | return |
---|
| 1080 | fi |
---|
| 1081 | |
---|
| 1082 | # Treatement according to different cases |
---|
[1166] | 1083 | if [ ${nb_occ} -eq 0 ] && [ ${type} = blocker ] ; then |
---|
[1075] | 1084 | # Stop if the key is never set and the function is blocker |
---|
[1166] | 1085 | IGCM_debug_Exit "IGCM_comp_modifyDefFile : Error in ${filein}: Variable=${key} has been removed but this function is blocker. " |
---|
| 1086 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: restore ${filein} for variable ${key}." |
---|
| 1087 | elif [ ${nb_occ} -eq 0 ] && [ ${type} = nonblocker ] ; then |
---|
[1075] | 1088 | # The key is not set but it is a nonblocker call so nothing is done. |
---|
[1166] | 1089 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: ${key} is not set in ${filein}. This is a nonblocker call so nothing is done." |
---|
| 1090 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: Default value for ${key} from the model will be used." |
---|
[1081] | 1091 | modify=no |
---|
[1166] | 1092 | elif [ $( grep ${key} ${filein} | grep -v "\#" |wc -l ) = 0 ] ; then |
---|
[1075] | 1093 | # Variable key is not set in filein, stop. |
---|
[1166] | 1094 | IGCM_debug_Exit "IGCM_comp_modifyDefFile : Variable ${key} is not set in correct file. It should be set in ${filein}." |
---|
[1081] | 1095 | fi |
---|
| 1096 | |
---|
| 1097 | # Check if AUTO is set in the filein on the same line as the key variable |
---|
[1166] | 1098 | if [ $( grep -w ${key} ${filein} | grep -v "\#" | grep AUTO | wc -l ) = 1 ] ; then |
---|
[1156] | 1099 | # Modification will be done for all cases |
---|
| 1100 | modify=yes |
---|
| 1101 | else |
---|
| 1102 | # The variable was not set to AUTO |
---|
[1166] | 1103 | if [ ${type} = blocker ] ; then |
---|
[1156] | 1104 | # Exit because this is a blocker call |
---|
[1166] | 1105 | IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable ${key} cannot be modified. It should be set to AUTO." |
---|
[1190] | 1106 | IGCM_debug_PopStack "IGCM_comp_modifyDefFile" |
---|
[1156] | 1107 | return |
---|
[1166] | 1108 | elif [ ${type} = nonblocker ] ; then |
---|
[1156] | 1109 | # Do nothing. Suppose that the user did set the variable correct |
---|
[1166] | 1110 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: ${key} is set by the user. Nothing done." |
---|
[1156] | 1111 | modify=no |
---|
[1166] | 1112 | elif [ ${type} = force ] ; then |
---|
[1156] | 1113 | # Force modification |
---|
[1166] | 1114 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile : Variabl=${key} was not set to AUTO. Modification will be forced." |
---|
[1081] | 1115 | modify=yes |
---|
[1156] | 1116 | fi |
---|
[1081] | 1117 | fi |
---|
[1069] | 1118 | |
---|
[1081] | 1119 | # Do the modifcation now |
---|
[1166] | 1120 | if [ ${modify} = yes ] ; then |
---|
[1081] | 1121 | |
---|
[1156] | 1122 | # For option DEFAULT, read default value from file. |
---|
[1166] | 1123 | if [ X"${value}" = XDEFAULT ] || [ X"${value}" = X ] ; then |
---|
[1156] | 1124 | # Case to set DEFAULT value |
---|
| 1125 | # Read default value from filein |
---|
[1166] | 1126 | value=$( grep ${key} ${filein} | grep -v "\#" | awk -F"DEFAULT *=" '{print $2}') |
---|
[1069] | 1127 | |
---|
[1166] | 1128 | if [ X"${value}" = X ] ; then |
---|
| 1129 | IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable ${key} needs a DEFAULT value in ${filein}." |
---|
| 1130 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: The syntax in ${filein} should be:" |
---|
| 1131 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: ${key}=_AUTO_:DEFAULT=def_value" |
---|
[1156] | 1132 | IGCM_debug_PopStack "IGCM_comp_modifyDefFile" |
---|
| 1133 | return |
---|
[1075] | 1134 | fi |
---|
[1156] | 1135 | fi |
---|
[1069] | 1136 | |
---|
[1156] | 1137 | # Now change key in filein |
---|
[1166] | 1138 | sed -e "s/^${key}\ *=.*/${key}= ${value}/" ${filein} > ${filein}.tmp |
---|
| 1139 | IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: In ${filein} set ${key}=${value}" |
---|
| 1140 | \mv ${filein}.tmp ${filein} |
---|
[1075] | 1141 | fi |
---|
[1079] | 1142 | IGCM_debug_PopStack "IGCM_comp_modifyDefFile" |
---|
[1069] | 1143 | } |
---|
| 1144 | |
---|
| 1145 | #======================================================================= |
---|
[1085] | 1146 | function IGCM_comp_modifyNamelist |
---|
| 1147 | { |
---|
| 1148 | # |
---|
| 1149 | # syntax: IGCM_comp_modifyNamelist type filein key [value] |
---|
| 1150 | # |
---|
| 1151 | # For example : IGCM_comp_modifyNamelist blocker run.def day_step 1200 |
---|
| 1152 | # |
---|
| 1153 | # This function is used to modify a parameter file for a specific variable. |
---|
[1155] | 1154 | # The file must be a "namelist" file, i.e. with fortran namelist syntax. |
---|
[1085] | 1155 | # This function can be used in the comp.driver files for the components. |
---|
| 1156 | # |
---|
| 1157 | # Arguments: |
---|
| 1158 | # - type : first argument must be blocker, nonblocker or force |
---|
| 1159 | # For "blocker" case, the variable must be attributed the keyworld AUTO |
---|
| 1160 | # otherwise this function will exit. |
---|
| 1161 | # For "nonblocker" case, the user can remove or modify the variable. For |
---|
| 1162 | # this case, as long as AUTO is not set, no modification will be done. |
---|
| 1163 | # For "force" case, the variable will be modified even if it is not set to AUTO |
---|
| 1164 | # - filein : the file in run directory of .def type in which the variable should be set |
---|
| 1165 | # - key : the variable to modify |
---|
| 1166 | # - value : the value to set the key equal to, optional. If value is not set or if |
---|
| 1167 | # value=DEFAULT, then a default value must be given in filein using syntax : |
---|
| 1168 | # key= AUTO : DEFAULT=def_value |
---|
| 1169 | # |
---|
| 1170 | IGCM_debug_PushStack "IGCM_comp_modifyNamelist" |
---|
| 1171 | |
---|
[1166] | 1172 | typeset type filein key value pattern modify |
---|
| 1173 | |
---|
[1085] | 1174 | # Set local variables and test the arguments |
---|
| 1175 | if [ $# = 4 ] ; then |
---|
| 1176 | # Normal case with 4 arguments |
---|
| 1177 | type=$1 ; filein=$2 ; key=$3 ; value=$4 |
---|
| 1178 | elif [ $# = 3 ] ; then |
---|
| 1179 | # Normal case with 3 arguments |
---|
| 1180 | type=$1 ; filein=$2 ; key=$3; value="DEFAULT" |
---|
| 1181 | else |
---|
| 1182 | IGCM_debug_Exit "IGCM_comp_modifyNamelist: Bad number of arguments." |
---|
| 1183 | IGCM_debug_PopStack "IGCM_comp_modifyNamelist" |
---|
| 1184 | return |
---|
| 1185 | fi |
---|
[1166] | 1186 | IGCM_debug_Print 1 "Entering IGCM_comp_modifyNamelist with arguments: ${type} ${filein} ${key} ${value}" |
---|
[1085] | 1187 | |
---|
| 1188 | # Test if first argument is correct |
---|
[1166] | 1189 | if [ ${type} != blocker ] && [ ${type} != nonblocker ] && [ ${type} != force ] ; then |
---|
[1085] | 1190 | IGCM_debug_Exit "IGCM_comp_modifyNamelist: Error in first argument must be blocker, nonblocker or force" |
---|
| 1191 | IGCM_debug_PopStack "IGCM_comp_modifyNamelist" |
---|
| 1192 | return |
---|
| 1193 | fi |
---|
| 1194 | |
---|
[1215] | 1195 | # Test if the file exist. |
---|
| 1196 | # Exit with error if the file does not exist for the case blocker or force. |
---|
| 1197 | # Only return for the case nonblocker. |
---|
[1085] | 1198 | if [ ! -f ${filein} ] ; then |
---|
[1215] | 1199 | if [ ${type} = blocker ] || [ ${type} = force ] ; then |
---|
| 1200 | IGCM_debug_Exit "IGCM_comp_modifyNamelist: ${filein} does not exist." |
---|
| 1201 | else |
---|
| 1202 | IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: ${filein} does not exist. Nothing will be done for this file." |
---|
| 1203 | fi |
---|
[1085] | 1204 | IGCM_debug_PopStack "IGCM_comp_modifyNamelist" |
---|
| 1205 | return |
---|
| 1206 | fi |
---|
| 1207 | |
---|
| 1208 | # Read the line with key in the file without the comments |
---|
[1166] | 1209 | pattern=$( grep "^ *${key} *=" ${filein} | sed -e "s% *\!.*%%" ) |
---|
[1155] | 1210 | |
---|
[1085] | 1211 | # Verify the existance of the pattern |
---|
| 1212 | if [ X"$pattern" = X ] ; then |
---|
[1156] | 1213 | # Variable key is not set in filein, stop. |
---|
[1166] | 1214 | IGCM_debug_Exit "IGCM_comp_modifyNamelist : Variable ${key} is not set in correct file. It should be set in ${filein}." |
---|
[1156] | 1215 | IGCM_debug_PopStack "IGCM_comp_modifyNamelist" |
---|
| 1216 | return |
---|
[1085] | 1217 | fi |
---|
[1155] | 1218 | |
---|
[1085] | 1219 | # Check if the variable is set to AUTO in the filein |
---|
| 1220 | if [ $( echo $pattern | grep AUTO | wc -l ) = 1 ] ; then |
---|
[1156] | 1221 | # Modification will be done for all cases |
---|
| 1222 | modify=yes |
---|
| 1223 | else |
---|
| 1224 | # The variable was not set to AUTO |
---|
[1166] | 1225 | if [ ${type} = blocker ] ; then |
---|
[1156] | 1226 | # Exit because this is a blocker call |
---|
[1166] | 1227 | IGCM_debug_Exit "IGCM_comp_modifyNamelist : The variable ${key} cannot be modified. It should be set to AUTO." |
---|
[1156] | 1228 | IGCM_debug_PopStack "IGCM_comp_modifyNamelist" |
---|
| 1229 | return |
---|
[1166] | 1230 | elif [ ${type} = nonblocker ] ; then |
---|
[1156] | 1231 | # Do nothing. Suppose that the user did set the variable correct |
---|
[1166] | 1232 | IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: ${key} is set by the user. Nothing done." |
---|
[1156] | 1233 | modify=no |
---|
[1166] | 1234 | elif [ ${type} = force ] ; then |
---|
[1156] | 1235 | # Force modification |
---|
[1166] | 1236 | IGCM_debug_Print 1 "IGCM_comp_modifyNamelist : Variabl=${key} was not set to AUTO. Modification will be forced." |
---|
[1085] | 1237 | modify=yes |
---|
[1156] | 1238 | fi |
---|
[1085] | 1239 | fi |
---|
| 1240 | |
---|
| 1241 | # Do the modifcation now |
---|
[1166] | 1242 | if [ ${modify} = yes ] ; then |
---|
[1085] | 1243 | |
---|
[1156] | 1244 | # For option DEFAULT, read default value from file. |
---|
[1166] | 1245 | if [ X"${value}" = XDEFAULT ] || [ X"${value}" = X ] ; then |
---|
[1156] | 1246 | # Case to set DEFAULT value |
---|
| 1247 | # Read default value from filein |
---|
| 1248 | value=$( echo $pattern | awk -F"DEFAULT *=" '{print $2}') |
---|
[1085] | 1249 | |
---|
[1166] | 1250 | if [ X"${value}" = X ] ; then |
---|
| 1251 | IGCM_debug_Exit "IGCM_comp_modifyNamelist : The variable ${key} needs a DEFAULT value in ${filein}." |
---|
| 1252 | IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: The syntax in ${filein} should be:" |
---|
| 1253 | IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: ${key}=_AUTO_:DEFAULT=def_value" |
---|
[1156] | 1254 | IGCM_debug_PopStack "IGCM_comp_modifyNamelist" |
---|
| 1255 | return |
---|
[1085] | 1256 | fi |
---|
[1156] | 1257 | fi |
---|
[1085] | 1258 | |
---|
[1156] | 1259 | # Now change key in filein |
---|
[1166] | 1260 | sed -e "s/${pattern}/ ${key}=${value}/" ${filein} > ${filein}.tmp |
---|
| 1261 | IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: In ${filein} set ${key}=${value}" |
---|
| 1262 | \mv ${filein}.tmp ${filein} |
---|
[1085] | 1263 | fi |
---|
| 1264 | IGCM_debug_PopStack "IGCM_comp_modifyNamelist" |
---|
| 1265 | } |
---|
| 1266 | |
---|
| 1267 | #======================================================================= |
---|
[1074] | 1268 | function IGCM_comp_modifyXmlFile |
---|
| 1269 | { |
---|
| 1270 | # |
---|
| 1271 | # syntax: IGCM_comp_modifyXmlFile type filein keyid keyattrib value |
---|
| 1272 | # |
---|
| 1273 | # For example : IGCM_comp_modifyXmlFile force file_def_orchidee.xml sechiba2 enabled .TRUE. |
---|
| 1274 | # or IGCM_comp_modifyXmlFile blocker iodef.xml using_server NONE false |
---|
| 1275 | # |
---|
| 1276 | # This function is used to modify the value for a specific attribute and variable id. |
---|
[1155] | 1277 | # The file must be a valid xml file. |
---|
[1075] | 1278 | # This function can be used in the comp.driver files for the components. |
---|
[1074] | 1279 | # |
---|
[1075] | 1280 | # Arguments: |
---|
| 1281 | # - type : first argument must be blocker, nonblocker or force. |
---|
| 1282 | # For "blocker" case, the variable must be attributed the keyworld AUTO |
---|
[1074] | 1283 | # otherwise this function will exit. |
---|
[1075] | 1284 | # For "nonblocker" case, the user can remove or modify the variable. For |
---|
[1074] | 1285 | # this case, as long as AUTO is not set, no modification will be done. |
---|
[1075] | 1286 | # For "force" case, the variable will be modified even if it is not set to AUTO |
---|
[1074] | 1287 | # - filein : the file in run directory of .xml type in which the variable should be set |
---|
| 1288 | # - keyid : the variable to modify |
---|
| 1289 | # - keyattrib : the attribute name to modify. If NONE, then the variable itself will be modified |
---|
| 1290 | # - value : the value to set in the filein |
---|
| 1291 | # |
---|
[1075] | 1292 | IGCM_debug_PushStack "IGCM_comp_modifyXmlFile" |
---|
[1074] | 1293 | |
---|
[1166] | 1294 | typeset type filein keyid keyattrib value modify |
---|
| 1295 | |
---|
[1075] | 1296 | # Set local variables and test the arguments |
---|
| 1297 | if [ $# = 5 ] ; then |
---|
| 1298 | # Normal case with 4 arguments |
---|
| 1299 | type=$1 ; filein=$2 ; keyid=$3 ; keyattrib=$4 ; value=$5 |
---|
| 1300 | else |
---|
| 1301 | IGCM_debug_Exit "IGCM_comp_modifyXmlFile: Bad number of arguments." |
---|
[1089] | 1302 | IGCM_debug_PopStack "IGCM_comp_modifyXmlFile" |
---|
[1075] | 1303 | return |
---|
| 1304 | fi |
---|
[1166] | 1305 | IGCM_debug_Print 1 "Entering IGCM_comp_modifyXmlFile with arguments: type=${type} file=${filein}, id=${keyid} attribute=${keyattrib}, value=${value}" |
---|
[1074] | 1306 | |
---|
[1075] | 1307 | # Test if first argument is correct |
---|
[1166] | 1308 | if [ ${type} != blocker ] && [ ${type} != nonblocker ] && [ ${type} != force ] ; then |
---|
[1075] | 1309 | IGCM_debug_Exit "IGCM_comp_modifyXmlFile: Error in first argument must be blocker, nonblocker or force" |
---|
[1089] | 1310 | IGCM_debug_PopStack "IGCM_comp_modifyXmlFile" |
---|
[1075] | 1311 | return |
---|
| 1312 | fi |
---|
[1074] | 1313 | |
---|
[1215] | 1314 | # Test if the file exist. |
---|
| 1315 | # Exit with error if the file does not exist for the case blocker or force. |
---|
| 1316 | # Only return for the case nonblocker. |
---|
[1075] | 1317 | if [ ! -f ${filein} ] ; then |
---|
[1215] | 1318 | if [ ${type} = blocker ] || [ ${type} = force ] ; then |
---|
| 1319 | IGCM_debug_Exit "IGCM_comp_modifyXmlFile: ${filein} does not exist." |
---|
| 1320 | else |
---|
| 1321 | IGCM_debug_Print 1 "IGCM_comp_modifyXmlFile: ${filein} does not exist. Nothing will be done for this file." |
---|
| 1322 | fi |
---|
[1089] | 1323 | IGCM_debug_PopStack "IGCM_comp_modifyXmlFile" |
---|
[1075] | 1324 | return |
---|
| 1325 | fi |
---|
| 1326 | |
---|
| 1327 | # Test if keyid is set in filein, otherwise exit |
---|
[1166] | 1328 | if [ $( grep -w ${keyid} ${filein} | wc -l ) = 0 ] ; then |
---|
[1075] | 1329 | # Variable key is not set in filein, stop. |
---|
[1166] | 1330 | IGCM_debug_Exit "IGCM_comp_modifyXmlFile : ${keyid} is not set in the file. Bad syntax of ${filein} file." |
---|
[1089] | 1331 | IGCM_debug_PopStack "IGCM_comp_modifyXmlFile" |
---|
[1075] | 1332 | return |
---|
| 1333 | fi |
---|
| 1334 | |
---|
| 1335 | # Check if AUTO is set on the same line as keyid and keyattrib |
---|
[1166] | 1336 | if [ $( grep -w ${keyid} ${filein} | grep AUTO | wc -l ) = 1 ] ; then |
---|
[1075] | 1337 | # Modifification will be done |
---|
| 1338 | modify=yes |
---|
| 1339 | else |
---|
[1166] | 1340 | if [ ${type} = blocker ] ; then |
---|
[1075] | 1341 | # Exit, the variable must be set to AUTO |
---|
[1166] | 1342 | IGCM_debug_Exit "IGCM_comp_modifyXmlFile : blocker function. The ${keyattrib} for ${keyid} must be set to AUTO in ${filein}." |
---|
[1089] | 1343 | IGCM_debug_PopStack "IGCM_comp_modifyXmlFile" |
---|
[1075] | 1344 | return |
---|
[1166] | 1345 | elif [ ${type} = nonblocker ] ; then |
---|
[1075] | 1346 | # Nothing will be done |
---|
| 1347 | IGCM_debug_Print 1 "Nonblocker nothing is done for ${filein}, id=${keyid} and attribute ${keyattrib}" |
---|
| 1348 | modify=no |
---|
[1166] | 1349 | elif [ ${type} = force ] ; then |
---|
[1075] | 1350 | # Force modification |
---|
[1166] | 1351 | IGCM_debug_Print 1 "IGCM_comp_modifyXmlFile : Attribute=${keyattrib} for id=${keyid} was not set to AUTO. Modification will be forced." |
---|
[1075] | 1352 | modify=yes |
---|
[1074] | 1353 | fi |
---|
[1075] | 1354 | fi |
---|
[1074] | 1355 | |
---|
[1075] | 1356 | # Do the modifcation now |
---|
[1166] | 1357 | if [ ${modify} = yes ] ; then |
---|
| 1358 | if [ ${keyattrib} = NONE ] ; then |
---|
[1075] | 1359 | # Case to modify the variable itself |
---|
| 1360 | IGCM_debug_Print 1 "Now modify ${filein} for id=${keyid} by setting the variable=${value}" |
---|
[1166] | 1361 | sed -e "s/\(<[^\"]*\"${keyid}\".*>\)\([^<]*\)\(<[^>]*\)/\1${value}\3/" ${filein} > ${filein}.tmp |
---|
[1074] | 1362 | else |
---|
[1156] | 1363 | # Check if keyattrib is set on the same line as keyid |
---|
[1166] | 1364 | if [ $( grep -w ${keyid} ${filein} | grep ${keyattrib} | wc -l ) = 1 ] ; then |
---|
[1156] | 1365 | # Case to modify the attribute value |
---|
| 1366 | IGCM_debug_Print 1 "Now modify ${filein} for id=${keyid} by setting attribute to ${keyattrib}=${value}" |
---|
[1166] | 1367 | sed -e "/id=\"${keyid}\"/s/\(${keyattrib}=\"\)[^\"]*\(\"\)/\1${value}\2/" ${filein} > ${filein}.tmp |
---|
[1156] | 1368 | else |
---|
| 1369 | # Case to add the attribute and its value |
---|
| 1370 | IGCM_debug_Print 1 "Now add in ${filein} for id=${keyid} the attribute ${keyattrib} to the value ${value}" |
---|
[1166] | 1371 | sed -e "/id=\"${keyid}\"/s/\/>/ ${keyattrib}=\"${value}\"\/>/" ${filein} > ${filein}.tmp |
---|
[1156] | 1372 | fi |
---|
[1074] | 1373 | fi |
---|
[1166] | 1374 | \mv ${filein}.tmp ${filein} |
---|
[1075] | 1375 | fi |
---|
| 1376 | IGCM_debug_PopStack "IGCM_comp_modifyXmlFile" |
---|
[1074] | 1377 | } |
---|
| 1378 | |
---|
| 1379 | #======================================================================= |
---|
[2] | 1380 | function IGCM_comp_Update |
---|
| 1381 | { |
---|
[544] | 1382 | IGCM_debug_PushStack "IGCM_comp_Update" |
---|
[2] | 1383 | |
---|
| 1384 | # Debug Print : |
---|
[544] | 1385 | echo |
---|
| 1386 | IGCM_debug_Print 1 "IGCM_comp_Update" |
---|
| 1387 | echo |
---|
[2] | 1388 | |
---|
[902] | 1389 | typeset ExeNameIn ExeNameOut |
---|
[544] | 1390 | typeset comp compname comptagname |
---|
| 1391 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[902] | 1392 | # Define component |
---|
[544] | 1393 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 1394 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
[2] | 1395 | |
---|
[544] | 1396 | # Copy executable for this component |
---|
| 1397 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 1398 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
[151] | 1399 | |
---|
[622] | 1400 | # If missing executable and DRYRUN is set to 0 or 1 then stop! |
---|
| 1401 | if [ ${DRYRUN} -le 1 ] && [ X${ExeNameIn} != X\"\" ] && [ ! -f ${R_EXE}/${ExeNameIn} ] ; then |
---|
| 1402 | IGCM_debug_Exit "IGCM_comp_Update missing executable ${ExeNameIn}" |
---|
[778] | 1403 | fi |
---|
[236] | 1404 | |
---|
[544] | 1405 | if [ ${Period} -eq 1 ] && [ -f ${R_EXE}/${ExeNameIn} ] ; then |
---|
| 1406 | eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut} |
---|
| 1407 | if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then |
---|
| 1408 | eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut} |
---|
| 1409 | fi |
---|
| 1410 | elif [ -f ${R_EXE}/${ExeNameIn} ] && [ ! -f ${RUN_DIR}/${ExeNameOut} ] ; then |
---|
| 1411 | eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut} |
---|
| 1412 | if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then |
---|
| 1413 | eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut} |
---|
| 1414 | fi |
---|
| 1415 | fi |
---|
[2] | 1416 | |
---|
[544] | 1417 | # Debug Print |
---|
| 1418 | IGCM_debug_Print 1 "Update ${compname} Parameter Files." |
---|
| 1419 | # UPDATE component |
---|
| 1420 | ${comp}_Update |
---|
[2] | 1421 | |
---|
[544] | 1422 | done |
---|
[2] | 1423 | |
---|
[544] | 1424 | IGCM_debug_PopStack "IGCM_comp_Update" |
---|
[2] | 1425 | } |
---|
| 1426 | |
---|
| 1427 | #======================================================================= |
---|
| 1428 | function IGCM_comp_Finalize |
---|
| 1429 | { |
---|
[544] | 1430 | IGCM_debug_PushStack "IGCM_comp_Finalize" |
---|
[2] | 1431 | |
---|
[544] | 1432 | # Debug Print : |
---|
| 1433 | echo |
---|
| 1434 | IGCM_debug_Print 1 "IGCM_comp_Finalize" |
---|
| 1435 | echo |
---|
[2] | 1436 | |
---|
[544] | 1437 | typeset ListTextName TextName0 |
---|
| 1438 | typeset comp compname comptagname card ListFilesName FileName0 NbFiles SaveOnArchive |
---|
| 1439 | typeset i i_ file_in file_in_ file_out file_out_ file_outin file_outin_ generic_file_name nb_rebuild_file |
---|
[1165] | 1440 | typeset -Z4 j4 #BASH declare j4 |
---|
[544] | 1441 | typeset list_file nlist_file |
---|
| 1442 | typeset compactoutputs |
---|
[429] | 1443 | |
---|
[1165] | 1444 | # Initialize array hosting list of rebuilded files to copy |
---|
| 1445 | unset rebuildedActionsList |
---|
| 1446 | |
---|
| 1447 | # Text compacting options |
---|
[544] | 1448 | compactoutputs=false |
---|
| 1449 | if [ X${JobType} != XRUN ] ; then |
---|
| 1450 | compactoutputs=true |
---|
| 1451 | elif [ X${config_UserChoices_CompactText} != Xn ] ; then |
---|
| 1452 | compactoutputs=true |
---|
| 1453 | fi |
---|
[433] | 1454 | |
---|
[1043] | 1455 | # Prepare headers for the shell dedicated to offline rebuild |
---|
| 1456 | if [ X${AsynchronousRebuild} = Xtrue ] ; then |
---|
| 1457 | [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin} |
---|
| 1458 | if [ ${DRYRUN} -le 1 ] ; then |
---|
| 1459 | echo "#!/bin/ksh " > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1460 | echo "function IGCM_FlushRebuild " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1461 | echo "{ " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1462 | echo "IGCM_debug_PushStack \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1463 | echo "echo " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1464 | echo "IGCM_debug_Print 1 \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1465 | echo "echo " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1466 | echo "export R_SAVE=${R_SAVE} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1467 | echo "export R_BUFR=${R_BUFR} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1468 | echo "export R_OUT_KSH=${R_OUT_KSH} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1469 | echo "export R_BUF_KSH=${R_BUF_KSH} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1470 | echo "export config_UserChoices_JobName=${config_UserChoices_JobName} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1471 | echo "export config_UserChoices_SpaceName=${config_UserChoices_SpaceName} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1472 | fi |
---|
| 1473 | fi |
---|
| 1474 | |
---|
[544] | 1475 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[902] | 1476 | # Define component |
---|
[544] | 1477 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 1478 | eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 |
---|
[2] | 1479 | |
---|
[544] | 1480 | # Debug Print |
---|
| 1481 | IGCM_debug_Print 1 "Finalize ${comp} : ${compname} component." |
---|
| 1482 | # FINALIZE component |
---|
| 1483 | ${comp}_Finalize |
---|
[2] | 1484 | |
---|
[778] | 1485 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
[2] | 1486 | |
---|
[804] | 1487 | # Save Output Text files of models |
---|
| 1488 | #--------------------------------- |
---|
| 1489 | IGCM_debug_Print 2 "Save Output Text files for ${comp} : ${compname} component." |
---|
| 1490 | IGCM_card_DefineArrayFromOption ${card} OutputText List |
---|
| 1491 | ListTextName=${compname}_OutputText_List |
---|
| 1492 | |
---|
| 1493 | eval TextName0=\${${ListTextName}[0]} > /dev/null 2>&1 |
---|
| 1494 | if [ X${TextName0} != X${NULL_STR} ] ; then |
---|
| 1495 | eval NbFiles=\${#${ListTextName}[@]} > /dev/null 2>&1 |
---|
| 1496 | |
---|
| 1497 | (( i=0 )) |
---|
| 1498 | until [ $i -eq $NbFiles ]; do |
---|
| 1499 | eval file_in=\${${ListTextName}[$i]} > /dev/null 2>&1 |
---|
| 1500 | eval file_out=${PREFIX}_${file_in} |
---|
| 1501 | |
---|
| 1502 | (( i=i+1 )) |
---|
| 1503 | |
---|
| 1504 | unset list_file |
---|
| 1505 | #set +A list_file -- $( ls ${file_in}* | sort 2>/dev/null ) |
---|
| 1506 | # result for a a1 a10 a2 with file_in=a a a1 a2 a10 |
---|
| 1507 | set +A list_file -- $( [ -f ${file_in} ] && ls ${file_in} ; for i in $(ls ${file_in}* 2>/dev/null | sed "s/${file_in}//" | sort -n) ; do ls ${file_in}$i ; done ) |
---|
| 1508 | nlist_file=${#list_file[@]} |
---|
| 1509 | if [ ${nlist_file} -gt 1 ] ; then |
---|
| 1510 | if ( ${compactoutputs} ) ; then |
---|
| 1511 | IGCM_debug_Print 2 "Parallelism of Text Output with ${nlist_file} files." |
---|
| 1512 | IGCM_debug_Print 2 "Compact files in ${file_out} : " ${list_file[*]} |
---|
| 1513 | echo ${list_file[*]} > ${file_out} |
---|
| 1514 | echo "" >> ${file_out} |
---|
| 1515 | |
---|
| 1516 | (( i_ = 0 )) |
---|
[1080] | 1517 | for file in ${list_file[@]} ; do |
---|
[804] | 1518 | echo "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ " >> ${file_out} |
---|
| 1519 | echo "| " ${i_} " " ${file} >> ${file_out} |
---|
| 1520 | echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " >> ${file_out} |
---|
[999] | 1521 | cat ${file} | sed "s/\(.*\)/${i_}\1/" >> ${file_out} |
---|
[804] | 1522 | echo "" >> ${file_out} |
---|
| 1523 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1 |
---|
| 1524 | (( i_ = i_ + 1 )) |
---|
| 1525 | done |
---|
[1080] | 1526 | if ( ${ExecutionFail} ) ; then |
---|
| 1527 | IGCM_sys_Cp ${file_out} ${SUBMIT_DIR}/Debug |
---|
| 1528 | fi |
---|
| 1529 | |
---|
[804] | 1530 | if [ X${Pack} = Xtrue ] ; then |
---|
| 1531 | eval IGCM_sys_PutBuffer_Out ${file_out} \${R_BUF_${comp}_D}/${file_out} |
---|
| 1532 | else |
---|
| 1533 | eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}_D}/${file_out} |
---|
| 1534 | fi |
---|
[1080] | 1535 | |
---|
[804] | 1536 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_out}" > /dev/null 2>&1 |
---|
[1080] | 1537 | else |
---|
| 1538 | for file in ${list_file[@]} ; do |
---|
| 1539 | if ( ${ExecutionFail} ) ; then |
---|
| 1540 | IGCM_sys_Cp ${file} ${SUBMIT_DIR}/Debug/${PREFIX}_${file} |
---|
| 1541 | fi |
---|
[804] | 1542 | |
---|
| 1543 | if [ X${Pack} = Xtrue ] ; then |
---|
| 1544 | eval IGCM_sys_PutBuffer_Out ${file} \${R_BUF_${comp}_D}/${PREFIX}_${file} |
---|
| 1545 | else |
---|
| 1546 | eval IGCM_sys_Put_Out ${file} \${R_OUT_${comp}_D}/${PREFIX}_${file} |
---|
| 1547 | fi |
---|
[1080] | 1548 | |
---|
[804] | 1549 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1 |
---|
| 1550 | done |
---|
| 1551 | fi |
---|
| 1552 | else |
---|
| 1553 | if ( [ -f ${file_in}_0000 ] || [ -f ${file_in}0 ] ) ; then |
---|
| 1554 | eval IGCM_sys_Mv ${file_in}* ${file_in} |
---|
| 1555 | fi |
---|
[1080] | 1556 | |
---|
| 1557 | if ( ${ExecutionFail} ) ; then |
---|
| 1558 | IGCM_sys_Cp ${file_in} ${SUBMIT_DIR}/Debug/${file_out} |
---|
| 1559 | fi |
---|
| 1560 | |
---|
[804] | 1561 | if [ X${Pack} = Xtrue ] ; then |
---|
| 1562 | eval IGCM_sys_PutBuffer_Out ${file_in} \${R_BUF_${comp}_D}/${file_out} |
---|
| 1563 | else |
---|
| 1564 | eval IGCM_sys_Put_Out ${file_in} \${R_OUT_${comp}_D}/${file_out} |
---|
| 1565 | fi |
---|
| 1566 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 |
---|
| 1567 | fi |
---|
| 1568 | done |
---|
| 1569 | fi |
---|
| 1570 | |
---|
[544] | 1571 | # Save Restarts files |
---|
| 1572 | #-------------------- |
---|
| 1573 | IGCM_debug_Print 2 "Save Restart files for ${comp} : ${compname} component." |
---|
| 1574 | IGCM_card_DefineArrayFromOption ${card} RestartFiles List |
---|
| 1575 | ListFilesName=${compname}_RestartFiles_List |
---|
| 1576 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
[778] | 1577 | |
---|
[544] | 1578 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then |
---|
| 1579 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
[778] | 1580 | |
---|
[544] | 1581 | (( i=0 )) |
---|
| 1582 | until [ $i -ge $NbFiles ]; do |
---|
[778] | 1583 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 1584 | eval file_in=${file_in_} |
---|
[2] | 1585 | |
---|
[778] | 1586 | (( i_ = i+1 )) |
---|
| 1587 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 1588 | eval file_out=${file_out_} |
---|
[151] | 1589 | |
---|
[778] | 1590 | (( i_ = i+2 )) |
---|
| 1591 | eval file_outin_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 1592 | eval file_outin=${file_outin_} |
---|
[151] | 1593 | |
---|
[778] | 1594 | generic_restart_file_name_in=$( basename ${file_in} .nc ) |
---|
| 1595 | generic_restart_file_name_out=$( basename ${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} .nc ) |
---|
| 1596 | generic_restart_file_name_outin=$( basename ${file_outin} .nc ) |
---|
[2] | 1597 | |
---|
[902] | 1598 | nb_restart_file=$( ls ${generic_restart_file_name_in}_????.nc 2>/dev/null | wc -l ) |
---|
[778] | 1599 | if [ ${nb_restart_file} -gt 1 ] ; then |
---|
[821] | 1600 | j=0 # BASH LINE NOT NEEDED |
---|
| 1601 | # BASH for j4 in in $( eval echo {0000..$(( nb_restart_file - 1 ))} ) ; do |
---|
| 1602 | until [ $j -ge ${nb_restart_file} ]; do # BASH LINE NOT NEEDED |
---|
| 1603 | j4=${j} # BASH LINE NOT NEEDED |
---|
[778] | 1604 | if [ X${Pack} = Xtrue ] ; then |
---|
| 1605 | eval IGCM_sys_PutBuffer_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_BUF_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc |
---|
| 1606 | else |
---|
| 1607 | eval IGCM_sys_Put_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_OUT_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc |
---|
| 1608 | fi |
---|
| 1609 | if [ ! ${file_in} = ${file_outin} ] ; then |
---|
| 1610 | if ( ${ExitFlag} ) ; then |
---|
| 1611 | echo "IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc not executed." |
---|
| 1612 | else |
---|
| 1613 | IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc |
---|
| 1614 | fi |
---|
| 1615 | fi |
---|
[821] | 1616 | (( j=j+1 )) # BASH LINE NOT NEEDED |
---|
[778] | 1617 | done |
---|
| 1618 | else |
---|
| 1619 | if [ X${Pack} = Xtrue ] ; then |
---|
| 1620 | eval IGCM_sys_PutBuffer_Rest ${file_in} \${R_BUF_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} |
---|
| 1621 | else |
---|
| 1622 | eval IGCM_sys_Put_Rest ${file_in} \${R_OUT_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} |
---|
| 1623 | fi |
---|
| 1624 | if [ ! ${file_in} = ${file_outin} ] ; then |
---|
| 1625 | if ( ${ExitFlag} ) ; then |
---|
| 1626 | echo "IGCM_sys_Mv ${file_in} ${file_outin} not executed." |
---|
| 1627 | else |
---|
| 1628 | IGCM_sys_Mv ${file_in} ${file_outin} |
---|
| 1629 | fi |
---|
| 1630 | fi |
---|
| 1631 | fi |
---|
| 1632 | |
---|
| 1633 | (( i=i+3 )) |
---|
[544] | 1634 | done |
---|
| 1635 | else |
---|
| 1636 | if [ X${FileName0} != XNONE ] ; then |
---|
[778] | 1637 | IGCM_debug_Exit "IGCM_comp_Finalize : No file in restart list for ${compname}." |
---|
[544] | 1638 | else |
---|
[778] | 1639 | IGCM_debug_Print 1 "IGCM_comp_Finalize : NONE specified in Restart List ${compname}." |
---|
[544] | 1640 | fi |
---|
| 1641 | fi |
---|
[2] | 1642 | |
---|
[544] | 1643 | # Save Output files |
---|
| 1644 | #------------------ |
---|
| 1645 | IGCM_debug_Print 2 "Save Output files for ${comp} : ${compname} component." |
---|
| 1646 | IGCM_card_DefineArrayFromOption ${card} OutputFiles List |
---|
| 1647 | ListFilesName=${compname}_OutputFiles_List |
---|
| 1648 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
[2] | 1649 | |
---|
[544] | 1650 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
| 1651 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
[149] | 1652 | |
---|
[544] | 1653 | (( i=0 )) |
---|
| 1654 | until [ $i -ge $NbFiles ]; do |
---|
[778] | 1655 | SaveOnArchive=true |
---|
| 1656 | eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 1657 | eval file_in=${file_in_} |
---|
| 1658 | (( i_ = i+1 )) |
---|
| 1659 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 1660 | eval file_out=${file_out_} |
---|
| 1661 | # |
---|
| 1662 | # Override file_out path remplacing R_SAVE by R_BUFR |
---|
| 1663 | # |
---|
| 1664 | if [ X${Pack} = Xtrue ] ; then |
---|
| 1665 | file_out=$( echo $file_out | sed "s:^$R_SAVE:$R_BUFR:" ) |
---|
| 1666 | fi |
---|
| 1667 | # |
---|
| 1668 | # Not necessarily the best option. /!\ Potential side effects /!\ |
---|
| 1669 | # |
---|
| 1670 | (( i_ = i+2 )) |
---|
| 1671 | eval flag_post=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 1672 | # |
---|
| 1673 | generic_file_name=$( basename ${file_in} .nc ) |
---|
| 1674 | nb_rebuild_file=$( ls | grep "^${generic_file_name}_[0-9]*.nc" | wc -l ) |
---|
| 1675 | # |
---|
| 1676 | if ( [ ${nb_rebuild_file} -eq 1 ] && [ -f ${generic_file_name}_0000.nc ] ) ; then |
---|
[804] | 1677 | IGCM_debug_Print 2 "Parallelism with 1 file. Rebuilding ${file_in} not needed" |
---|
[778] | 1678 | IGCM_sys_Mv ${generic_file_name}_0000.nc ${file_in} |
---|
| 1679 | elif [ ${nb_rebuild_file} -gt 1 ] ; then |
---|
[804] | 1680 | IGCM_debug_Print 2 "Parallelism detected and rebuilding ${file_in} is needed" |
---|
[778] | 1681 | if [ X${AsynchronousRebuild} = Xfalse ] ; then |
---|
| 1682 | IGCM_debug_Print 2 "Rebuilding ${file_in} online" |
---|
[980] | 1683 | IGCM_sys_rebuild ${file_in} ${generic_file_name}_[0-9]*.nc |
---|
[778] | 1684 | else |
---|
| 1685 | IGCM_debug_Print 2 "Preparing offline rebuild for ${file_in}" |
---|
[980] | 1686 | IGCM_sys_Mv ${generic_file_name}_[0-9]*.nc ${RUN_DIR}/REBUILD_${PeriodDateBegin} |
---|
[544] | 1687 | |
---|
[778] | 1688 | # Prepare the shell dedicated to offline rebuild |
---|
| 1689 | if [ $DRYRUN -le 1 ]; then |
---|
[694] | 1690 | if [ ${file_in} = histstn.nc ] ; then |
---|
| 1691 | echo "IGCM_sys_rebuild_station ${file_in} ${generic_file_name}_*.nc" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1692 | else |
---|
[980] | 1693 | echo "IGCM_sys_rebuild ${file_in} ${generic_file_name}_[0-9]*.nc" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
[694] | 1694 | fi |
---|
[1206] | 1695 | echo "IGCM_debug_Verif_Exit" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
[778] | 1696 | fi |
---|
| 1697 | # |
---|
| 1698 | # Load Patch we need to apply and apply |
---|
| 1699 | if [ $DRYRUN -le 1 ]; then |
---|
| 1700 | if [ X$( eval echo \${${compname}_${flag_post}_Patches[0]} ) != X${NULL_STR} ]; then |
---|
[1080] | 1701 | for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ) ; do |
---|
[778] | 1702 | echo ". ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1703 | echo "IGCM_${Patch} ${file_in} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
[1206] | 1704 | echo "IGCM_debug_Verif_Exit " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
[778] | 1705 | done |
---|
| 1706 | fi |
---|
| 1707 | fi |
---|
| 1708 | # |
---|
| 1709 | if [ $DRYRUN -le 1 ]; then |
---|
| 1710 | if [ X${Pack} = Xtrue ] ; then |
---|
[1165] | 1711 | rebuildedActionsList[${#rebuildedActionsList[*]}]="IGCM_sys_PutBuffer_Out ${file_in} ${file_out}" |
---|
[778] | 1712 | else |
---|
[1165] | 1713 | rebuildedActionsList[${#rebuildedActionsList[*]}]="IGCM_sys_Put_Out ${file_in} ${file_out}" |
---|
[778] | 1714 | fi |
---|
[1206] | 1715 | rebuildedActionsList[${#rebuildedActionsList[*]}]="IGCM_debug_Verif_Exit" |
---|
[1165] | 1716 | rebuildedActionsList[${#rebuildedActionsList[*]}]="IGCM_sys_Rm ${generic_file_name}_[0-9]*.nc" |
---|
[778] | 1717 | fi |
---|
| 1718 | SaveOnArchive=false |
---|
| 1719 | fi |
---|
| 1720 | fi |
---|
| 1721 | # |
---|
| 1722 | if [ ${SaveOnArchive} = true ] ; then |
---|
| 1723 | # |
---|
| 1724 | # Rebuild has been done online or it was not needed |
---|
| 1725 | # |
---|
| 1726 | # If we need to apply a patch we use TMP DIRECTORY before ARCHIVING if asynchronous rebuild is on |
---|
| 1727 | # |
---|
| 1728 | thereisapatch=$( eval echo \${${compname}_${flag_post}_Patches[0]} ) |
---|
| 1729 | if ( [ ! X${thereisapatch} = X${NULL_STR} ] && [ X${AsynchronousRebuild} = Xtrue ] && [ -f ${file_in} ] ) ; then |
---|
| 1730 | IGCM_sys_Mv ${file_in} ${RUN_DIR}/REBUILD_${PeriodDateBegin} |
---|
| 1731 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=REBUILD_${PeriodDateBegin}/${file_in} > /dev/null 2>&1 |
---|
| 1732 | # |
---|
| 1733 | if [ $DRYRUN -le 1 ]; then |
---|
[1080] | 1734 | for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ) ; do |
---|
[778] | 1735 | echo ". ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1736 | echo "IGCM_${Patch} ${file_in} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
[1206] | 1737 | echo "IGCM_debug_Verif_Exit " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
[778] | 1738 | done |
---|
| 1739 | # |
---|
| 1740 | if [ X${Pack} = Xtrue ] ; then |
---|
| 1741 | echo "IGCM_sys_PutBuffer_Out ${file_in} ${file_out} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1742 | else |
---|
| 1743 | echo "IGCM_sys_Put_Out ${file_in} ${file_out} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1744 | fi |
---|
[1206] | 1745 | echo "IGCM_debug_Verif_Exit " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
[778] | 1746 | # |
---|
| 1747 | fi |
---|
| 1748 | else |
---|
| 1749 | # |
---|
| 1750 | # No Patch, No Asynchronous rebuild, online rebuild has been done or was not needed |
---|
| 1751 | # |
---|
| 1752 | if [ X${Pack} = Xtrue ] ; then |
---|
| 1753 | IGCM_sys_PutBuffer_Out ${file_in} ${file_out} |
---|
| 1754 | else |
---|
| 1755 | IGCM_sys_Put_Out ${file_in} ${file_out} |
---|
| 1756 | fi |
---|
| 1757 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 |
---|
| 1758 | if [ ${nb_rebuild_file} -gt 1 ] ; then |
---|
| 1759 | for DelFile in $( ls | grep "${generic_file_name}[_0-9]*.nc" ) ; do |
---|
| 1760 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${DelFile} > /dev/null 2>&1 |
---|
| 1761 | done |
---|
| 1762 | fi |
---|
| 1763 | fi |
---|
| 1764 | fi |
---|
| 1765 | (( i=i+3 )) |
---|
[544] | 1766 | done |
---|
| 1767 | fi |
---|
| 1768 | echo |
---|
| 1769 | done |
---|
[1165] | 1770 | # Append the sync call and the copy sequence to the IGCM_FlushRebuild function if needed |
---|
| 1771 | if [ ${#rebuildedActionsList[*]} -ne 0 ] ; then |
---|
[1166] | 1772 | echo "IGCM_sys_sync " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
[1165] | 1773 | i=0 |
---|
| 1774 | until [ ${i} -ge ${#rebuildedActionsList[*]} ]; do |
---|
| 1775 | echo ${rebuildedActionsList[$i]} >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh |
---|
| 1776 | (( i=i+1 )) |
---|
| 1777 | done |
---|
| 1778 | fi |
---|
[544] | 1779 | IGCM_debug_PopStack "IGCM_comp_Finalize" |
---|
[2] | 1780 | } |
---|