- Timestamp:
- 2017-11-28T15:01:16+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/trusting_func.sh
r8826 r8834 2 2 3 3 4 ##-------------------------------------------------------------------------------- 4 5 ## Messenger filenames 5 6 ##-------------------------------------------------------------------------------- … … 13 14 14 15 16 ##-------------------------------------------------------------------------------- 15 17 ## Functions in order of use 16 ##--------------------------------------------------------------------------------17 18 ##19 18 ##-------------------------------------------------------------------------------- 20 19 … … 30 29 ##-------------------------------------------------------------------------------- 31 30 32 init_files() { 33 echo 'Date' > ${file_date} 34 echo 'Result' > ${file_rslt} 35 echo 'Status' > ${file_stat} 36 echo 'NEMOGCM rev.' > ${file_nemo} 37 echo 'XIOS rev.' > ${file_xios} 38 echo 'Fortran compiler' > ${file_cmpf} 39 echo 'MPI libs' > ${file_lmpi} 40 echo 'NetCDF libs' > ${file_ncdf} 41 echo 'Input files' > ${file_inpt} 42 echo 'Elapsed time' > ${file_time} 43 echo 'Memory (Phy./Virt.)' > ${file_memy} 44 echo 'Comments' > ${file_note} 31 init() { 32 mkdir -p ${TRUST_TEST_DIR} ${TRUST_TEST_BENCHMARK} || get_out B 33 cd ${TRUST_TEST_DIR} 34 echo ${TRUST_TEST_DIR} 35 36 echo 'Date' > ${file_date}; echo 'Result' > ${file_rslt} 37 echo 'Status' > ${file_stat}; echo 'NEMOGCM' > ${file_nemo} 38 echo 'XIOS' > ${file_xios}; echo 'Fortran' > ${file_cmpf} 39 echo 'MPI' > ${file_lmpi}; echo 'NetCDF' > ${file_ncdf} 40 echo 'Inputs' > ${file_inpt}; echo 'Elapsed time' > ${file_time} 41 echo 'RAM (Phy./Virt.)' > ${file_memy}; echo 'Comments' > ${file_note} 45 42 46 43 ## 'FAILED' status with 'Unknown error' by default … … 49 46 echo 'Unknown error' \ 50 47 >> ${file_stat} 51 } 52 53 54 ## 55 ##-------------------------------------------------------------------------------- 56 57 get_date() { 48 58 49 ## UTC time zone for timestamping 59 50 local dat=$( date -ud "${TRUST_TEST_DATE}" +"%F %R %Z" ) … … 72 63 73 64 ## Loop on essential NEMO directories 74 for dir in ${TRUST_SVN_UP} ${TRUST_IO_XIOS}; do 75 76 ## For time being, just get revision from XIOS with no action on directory 77 if [ $dir == ${TRUST_IO_XIOS} ]; then 78 rev_loc=$( svn info $dir | awk '/Last Changed Rev/ {print $NF}' ) 79 echo 'XIOS '${rev_loc} \ 80 >> model.log 81 echo "<a href=\"https://forge.ipsl.jussieu.fr/ioserver/changeset/${rev_loc}\" target=\"_blank\">${rev_loc}</a>" \ 82 >> ${file_xios} 83 continue 84 fi 65 for dir in ${TRUST_SVN_UP}; do 85 66 86 67 echo $dir && ${TRUST_SVN_ACTION} ${TRUST_SVN_NEMOGCM}/$dir || get_out C 87 rev_loc=$( svn info ${TRUST_SVN_NEMOGCM}/$dir \68 rev_loc=$( svn info ${TRUST_SVN_NEMOGCM}/$dir \ 88 69 | awk '/Last Changed Rev/ {print $NF}' ) 89 70 … … 94 75 echo 'NEMOGCM '$rev \ 95 76 >> model.log 96 echo "<a href=\" https://forge.ipsl.jussieu.fr/nemo/changeset/$rev\" target=\"_blank\">$rev</a>" \77 echo "<a href=\"${TRUST_SVN_REPO}/nemo/changeset/$rev\" target=\"_blank\">$rev</a>" \ 97 78 >> ${file_nemo} 98 79 } 80 99 81 100 82 ## … … 123 105 124 106 ## Cleaning characters string to display proper soft name 125 #str=$( echo $str | sed 's|[/-]||g' )126 107 ver=$( echo $ver | sed 's|[/-]| |g' ) 127 108 … … 130 111 done 131 112 113 sed -n 2p model.log \ 114 >> ${file_cmpf} 132 115 sed -n 3p model.log \ 133 >> ${file_ cmpf}116 >> ${file_lmpi} 134 117 sed -n 4p model.log \ 135 >> ${file_lmpi}136 sed -n 5p model.log \137 118 >> ${file_ncdf} 119 120 cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}' 121 env | sort > env.log 122 } 123 124 125 ## 126 ##-------------------------------------------------------------------------------- 127 128 compile_xios() { 129 cd ${TRUST_IO_XIOS} 130 131 rev=$( svn info | awk '/Last Changed Rev/ {print $NF}' ) 132 echo 'XIOS '$rev \ 133 >> ${TRUST_TEST_DIR}/model.log 134 echo "<a href=\"${TRUST_SVN_REPO}/ioserver/changeset/$rev target=\"_blank\">$rev</a>" \ 135 >> ${TRUST_TEST_DIR}/${file_xios} 136 137 eval " 138 ./make_xios ${TRUST_IO_XIOS_MODE} --arch ${TRUST_MAIN_HPCC} \ 139 --job ${TRUST_COMPILE_NPROC} \ 140 ${TRUST_MAIN_STDOUT} 141 " 142 143 [ ! -e ./lib/libxios.a ] && get_out D || echo 'Success' 144 } 145 146 147 ## 148 ##-------------------------------------------------------------------------------- 149 150 compile_nemo() { 151 cd ${TRUST_SVN_NEMOGCM}/CONFIG 152 153 ## Recompiling from scratch if not in debug mode 154 if [[ -d ${TRUST_CFG_NEW} && ${TRUST_FLAG_DEBUG} == 'false' ]]; then 155 ./makenemo -n ${TRUST_CFG_NEW} clean_config \ 156 > /dev/null <<EOF 157 y 158 EOF 159 fi 160 161 eval " 162 ./makenemo -n ${TRUST_CFG_NEW} -r ${TRUST_CFG_REF} \ 163 -m ${TRUST_MAIN_HPCC} -j ${TRUST_COMPILE_NPROC} \ 164 ${TRUST_CFG_KEY_ADD} ${TRUST_CFG_KEY_DEL} \ 165 ${TRUST_MAIN_STDOUT} 166 " 167 168 [ ! -e ./${TRUST_CFG_NEW}/BLD/bin/nemo.exe ] && get_out E || echo 'Success' 138 169 } 139 170 … … 144 175 get_inputs() { 145 176 # List archive content & extract it by default 146 local inputs_list= $( eval"147 for archive in ${TRUST_IO_FORC_TAR}; do148 tar -tvf ${TRUST_IO_FORC_PATH}/\$archive >> inputs_list.txt;177 local inputs_list=" 178 for archive in \${TRUST_IO_FORC_TAR}; do 179 tar -tvf \${TRUST_IO_FORC_PATH}/\$archive >> inputs_list.txt; 149 180 done 150 " )151 local inputs_get= $( eval"152 for archive in ${TRUST_IO_FORC_TAR}; do153 tar -vxf ${TRUST_IO_FORC_PATH}/\$archive > /dev/null;181 " 182 local inputs_get=" 183 for archive in \${TRUST_IO_FORC_TAR}; do 184 tar -vxf \${TRUST_IO_FORC_PATH}/\$archive > /dev/null; 154 185 done 155 " )156 186 " 187 157 188 ## List & copy files without archive 158 189 if [ -z "${TRUST_IO_FORC_TAR}" ]; then 159 inputs_list=" ls -lh ${TRUST_IO_FORC_PATH}/* >> inputs_list.txt" 160 inputs_get=" \cp ${TRUST_IO_FORC_PATH}/* . " 161 fi 162 163 ${inputs_list}; ${inputs_get} 164 165 # for entry in ${TRUST_IO_FORC_PATH}; do 166 # 167 # If path to file (assuming it is an archive) 168 # if [ -e $entry ]; then 169 # tar -tvf $entry >> inputs_list.txt; 170 # tar -vxf $entry > /dev/null; 171 # If path to directory 172 # elif [ -d $entry ]; then 173 # inputs_list=" ls -lh ${TRUST_IO_FORC_PATH}/* >> inputs_list.txt" 174 # inputs_get=" \cp ${TRUST_IO_FORC_PATH}/* . " 175 # fi 176 177 # done 190 inputs_list=" ls -lh \${TRUST_IO_FORC_PATH}/* >> inputs_list.txt" 191 inputs_get=" \cp \${TRUST_IO_FORC_PATH}/* . " 192 fi 193 194 cd ${TRUST_TEST_DIR} 195 eval ${inputs_list} 196 echo ${inputs_get}; eval ${inputs_get} 178 197 179 198 if [ $( find -name '*.gz' -print -quit ) ]; then 180 199 find . -name '*.gz' -exec gzip -d {} \; 181 200 fi 201 202 cp ${TRUST_SVN_NEMOGCM}/CONFIG/${TRUST_CFG_NEW}/cpp_* . 203 find ${TRUST_SVN_NEMOGCM}/CONFIG/${TRUST_CFG_NEW}/EXP00 \ 204 -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)' \ 205 -exec cp {} . \; 182 206 } 183 207 … … 221 245 [ -n "${files_list}" ] && echo 'Inputs : '${files_list}'differ<br>' \ 222 246 >> temp_${file_note} 247 } 248 249 250 ## 251 ##-------------------------------------------------------------------------------- 252 253 job_submit() { 254 ## Copy the submitting script to testing folder 255 cp ${TRUST_JOB_SCRIPT} ${TRUST_TEST_DIR} 256 257 TRUST_JOB_ID=$( eval ${TRUST_JOB_SUBMIT} ) 258 [ $? -ne 0 ] && get_out G || printf "Success (job ID %s)\n" ${TRUST_JOB_ID} 223 259 } 224 260 … … 257 293 ##-------------------------------------------------------------------------------- 258 294 295 job_perfs() { 296 if [ -n "${TRUST_JOB_TIME}" ]; then 297 298 ## Interest for checking unusual time computation 299 local time_cpu=$( eval ${TRUST_JOB_TIME} ) 300 301 printf "Elapsed time: " 302 echo ${time_cpu} | tee -a ${file_time} 303 304 fi 305 306 if [[ -n "${TRUST_JOB_RAM_P}" && -n "${TRUST_JOB_RAM_V}" ]]; then 307 308 ## Interest for checking unusual memory usage 309 local memory_pmax=$( eval ${TRUST_JOB_RAM_P} ) 310 local memory_vmax=$( eval ${TRUST_JOB_RAM_V} ) 311 312 printf "Memory max usage (physical/virtual): " 313 echo ${memory_pmax}' / '${memory_vmax} | tee -a ${file_memy} 314 fi 315 } 316 317 318 ## 319 ##-------------------------------------------------------------------------------- 320 321 job_state() { 322 if [[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]]; then 323 get_out H 324 else 325 echo 'Success' ## Must be reviewed 326 fi 327 } 328 329 330 ## 331 ##-------------------------------------------------------------------------------- 332 259 333 diff_results() { 260 334 local file … … 264 338 ## Think of copying initial test ## 265 339 ################################### 340 341 ## Now test is good by default ('OK') 342 TRUST_FLAG_RESULT='OK' 266 343 267 344 ## Simple diff … … 290 367 diff_restarts() { 291 368 local dif filebase filebases ndomain out 292 local files_list='' dif_sum='0' #bcmk='false'369 local files_list='' dif_sum='0' 293 370 294 371 ## Find all restart files to rebuild … … 352 429 fi 353 430 354 } 355 356 357 ## 358 ##-------------------------------------------------------------------------------- 359 360 get_time() { 361 [ -z "${TRUST_JOB_TIME}" ] && return 362 363 ## Interest for checking unusual time computation 364 local time_cpu=$( eval ${TRUST_JOB_TIME} ) 365 366 printf "Elapsed time: " 367 echo ${time_cpu} | tee -a ${file_time} 368 } 369 370 371 ## 372 ##-------------------------------------------------------------------------------- 373 374 get_memy() { 375 [[ -z "${TRUST_JOB_RAM_P}" && -z "${TRUST_JOB_RAM_V}" ]] && return 376 377 ## Interest for checking unusual memory usage 378 local memory_pmax=$( eval ${TRUST_JOB_RAM_P} ) 379 local memory_vmax=$( eval ${TRUST_JOB_RAM_V} ) 380 381 printf "Memory max usage (physical/virtual): " 382 echo ${memory_pmax}' / '${memory_vmax} | tee -a ${file_memy} 431 [ $TRUST_FLAG_RESULT == 'FAILED' ] && get_out L 383 432 } 384 433 … … 428 477 429 478 ## Production mode (-p|--prod) 430 if [ ${TRUST_FLAG_PROD} -eq 1]; then479 if [ ${TRUST_FLAG_PROD} == 'true' ]; then 431 480 432 481 ## Create or append trusting logfile … … 542 591 543 592 ## Save tested configuration if trusting failed in production mode (-p|--prod) 544 if [[ ${TRUST_FLAG_RESULT} == 'FAILED' && ${TRUST_FLAG_PROD} -eq 1]]; then593 if [[ ${TRUST_FLAG_RESULT} == 'FAILED' && ${TRUST_FLAG_PROD} == 'true' ]]; then 545 594 echo 'Creating archive '${TRUST_TEST_BACKUP}' under '${TRUST_TEST_BENCHMARK} 546 595 tar -czf ${TRUST_TEST_BENCHMARK}/${TRUST_TEST_BACKUP} * \
Note: See TracChangeset
for help on using the changeset viewer.