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