New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 8797 for branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/trusting_func.sh – NEMO

Ignore:
Timestamp:
2017-11-23T16:36:09+01:00 (6 years ago)
Author:
nicolasmartin
Message:

Modifications to get it working on Curie for all trusting tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/trusting_func.sh

    r8780 r8797  
    44## Messenger filenames 
    55file_date=mesg_01_date.txt  ; file_rslt=mesg_02_result.txt 
    6 file_stat=mesg_03_state.txt ; file_nemo=mesg_04_nemo.txt 
     6file_stat=mesg_03_status.txt; file_nemo=mesg_04_nemo.txt 
    77file_xios=mesg_05_xios.txt  ; file_cmpf=mesg_06_compiler.txt 
    88file_lmpi=mesg_07_mpi.txt   ; file_ncdf=mesg_08_netcdf.txt 
     
    1010file_memy=mesg_11_memory.txt; file_note=mesg_12_comments.txt 
    1111 
    12 ## Trusting timestamped logfile & archive 
    13 TRUS_FILE=trusting_${TRUS_DATE}_$TRUS_NAME.txt; TRUS_ARCH=trusting_${TRUS_DATE}_$TRUS_NAME.tgz 
    14  
    1512 
    1613## Functions in order of use 
     
    2421init_files() { 
    2522    echo 'Date'               > ${file_date}; echo 'Result'           > ${file_rslt} 
    26     echo 'State'              > ${file_stat}; echo 'NEMOGCM rev.'     > ${file_nemo} 
     23    echo 'Status'             > ${file_stat}; echo 'NEMOGCM rev.'     > ${file_nemo} 
    2724    echo 'XIOS rev.'          > ${file_xios}; echo 'Fortran compiler' > ${file_cmpf} 
    2825    echo 'MPI libs'           > ${file_lmpi}; echo 'NetCDF libs'      > ${file_ncdf} 
     
    118115 
    119116get_inputs() { 
    120     ## Extract archive or copy files in case of personal inputs 
    121     [ -z "${TRUS_TARF}" ] && get_io="cp ${TRUS_FORC}/* ." || get_io="tar -vxf ${TRUS_FORC}/${TRUS_TARF}" 
    122  
    123     ${get_io} > /dev/null 
    124     [ $? -ne 0 ] && get_out 3 || echo 'Success' 
    125     [ $( find -name '*.gz' -print -quit ) ] && find . -name '*.gz' -exec gzip -d {} \; 
    126  
    127     ls -lh > inputs_list.txt 
     117    # List archive content & extract it by default 
     118    local get_iol=$( eval " 
     119   for archive in ${TRUS_TARF}; do 
     120       tar -tvf ${TRUS_FORC}/\$archive >> inputs_list.txt; 
     121   done 
     122   " ) 
     123    local get_iof=$( eval " 
     124   for archive in ${TRUS_TARF}; do 
     125       tar -vxf ${TRUS_FORC}/\$archive > /dev/null; 
     126   done 
     127   " ) 
     128 
     129    ## List & copy files in case of personal inputs 
     130    if [ -z "${TRUS_TARF}" ]; then 
     131   get_iol="ls ${TRUS_FORC}/*" 
     132   get_iof="\cp ${TRUS_FORC}/* ." 
     133    fi 
     134 
     135    ${get_iol}; ${get_iof} 
     136 
     137    if [ `find -name '*.gz' -print -quit` ]; then 
     138   find . -name '*.gz' -exec gzip -d {} \; 
     139    fi 
    128140} 
    129141 
     
    196208 
    197209diff_restart() { 
    198     local base_name comp dif file list_comp list_tmsp nb_dom time_step tmsp 
    199     local files_list='' dif_sum=0 
    200  
    201     ## Stop if no benchmark files (ie time.step) 
    202     [ ! -e ${TRUS_STOR}/time.step ] && { TRUS_RSLT='FAILED'; get_out 7; } 
    203     time_step=$( cat ${TRUS_STOR}/time.step | tr -d [:space:] ) 
     210    local dif filebase filebases ndomain out 
     211    local files_list='' dif_sum='undef' 
    204212 
    205213    ## Find all restart files to rebuild 
    206214    if [ $( find -regex ".*_restart.*[0-9]\.nc" -print -quit ) ]; then 
    207    base_name=$( find -regex ".*_restart.*[0-9]\.nc"                       \ 
    208                 | sed "s#^\./\(.*\)_[0-9]*_restart.*#\1#"       | sort -u   ) 
    209    list_comp=$( find -regex ".*_restart.*[0-9]\.nc"                       \ 
    210                 | sed "s#^.*\(restart[a-z_]*\)_[0-9].*\.nc#\1#" | sort -u   ) 
    211    list_tmsp=$( find -regex ".*_restart.*[0-9]\.nc"                       \ 
    212                 | sed "s#^.*\([0-9]\{8\}\)_restart.*#\1#"       | sort -u   ) 
    213  
    214    ## Loop on each time step 
    215    for tmsp in ${list_tmsp}; do 
    216  
    217        for comp in ${list_comp}; do 
    218       file=${base_name}_${tmsp}_${comp} 
    219       nb_dom=$( find -name "${file}_[0-9]*.nc" | wc -l | awk '{ print $1 }' ) 
    220  
    221       if   [ ${nb_dom} -gt 1 ]; then 
    222           ${TRUS_NGCM}/TOOLS/REBUILD_NEMO/rebuild_nemo -t ${TRUS_NPRO} $file ${nb_dom} \ 
    223          > /dev/null 
    224  
    225            ## Possibility of remaining decomposed restarts (even after rebuild) 
    226           [ $? -eq 0 ] && rm -f ${file}_[0-9]*.nc \ 
    227                         > /dev/null 
    228  
    229       elif [ ${nb_dom} -eq 0 ]; then 
    230           TRUS_RSLT='FAILED' && get_out 8 
     215   filebases=$( find -regextype sed -regex ".*_[0-9]\{4\}\.nc" \ 
     216                | sed 's/\(.*\)_.*/\1/' | sort -u                ) 
     217 
     218   for filebase in ${filebases}; do 
     219 
     220       ndomain=$( find -regex ".*${name}_[0-9]*.nc" | wc -l | awk '{print $1}' ) 
     221 
     222       [ ${ndomain} -eq 0 ] && TRUS_RSLT='FAILED' && get_out 8 
     223 
     224       ${TRUS_NGCM}/TOOLS/REBUILD_NEMO/rebuild_nemo \ 
     225      -t ${TRUS_NPRO} $filebase ${ndomain}     \ 
     226      > /dev/null 
     227 
     228       ## Possibility of remaining decomposed restarts (even after rebuild) 
     229       [ $? -eq 0 ] && rm -f ${file}_[0-9]*.nc \ 
     230                > /dev/null 
     231 
     232       dif='' 
     233 
     234            ## Stop if no benchmark files (restart file) 
     235       if [ -e ${TRUS_STOR}/$file.nc ]; then 
     236 
     237      out=$( $TRUS_CDOD $name.nc ${TRUS_STOR}/$name.nc 2>&1 ) 
     238      dif=$( echo $out | grep -o "[0-9]* of [0-9]* records" ) 
     239 
     240      ## Fix for cdo aborting on restarts with different inputs 
     241      if [[ $out =~ 'Abort' ]]; then 
     242          dif=$( echo $out | awk -F: '{print $NF}' ) 
    231243      fi 
    232244 
    233       ## Compare restart files at same time step 
    234       if [ $tmsp -eq ${time_step} ]; then 
    235  
    236                     ## Stop if no benchmark files (restart file) 
    237           if [ -e ${TRUS_STOR}/$file.nc ]; then 
    238  
    239                    ## UNIX `cmp` not suitable (timestamp in .nc file) 
    240          dif=$( $TRUS_CDOD $file.nc ${TRUS_STOR}/$file.nc 2> /dev/null          \ 
    241                 | awk '/records/ {print $0}' | sed '2 s/^/,/' | tr -d '\n' ) 
    242  
    243          ## CDO can return void stdout with no difference 
    244          if [[ -n "$dif" && $( echo $dif | awk '{print $1}' ) -ne 0 ]]; then 
    245              TRUS_RSLT='FAILED' 
    246              files_list+=$comp' ' && let dif_sum+=$( echo $dif | awk '{print $1}' ) 
    247              echo $file.nc': '$dif 
    248          fi 
    249  
    250           else 
    251          TRUS_RSLT='FAILED' && get_out 7 
    252           fi 
    253  
    254       else 
    255           continue 
     245      if [ -n "$dif" ]; then 
     246          export TRUS_RSLT='FAILED' 
     247          files_list+=$name' ' && echo $name'.nc: '$dif 
     248          let dif_sum+=$( echo $dif | awk '{print $1}' ) 
    256249      fi 
    257250 
    258        done 
    259  
    260251   done 
    261252 
     253    ## Stop if no benchmark files (ie time.step) 
     254   if   [ ${dif_sum} == 'undef' ]; then 
     255       TRUS_RSLT='FAILED' 
     256       get_out 7 
    262257        ## List different files for web comment with sum of different records 
    263    if [ ${dif_sum} -ne 0 ]; then 
     258   elif [ ${dif_sum} -ne 0      ]; then 
    264259       echo 'Restarts: '${files_list}${dif_sum}' record(s) differ<br>' \ 
    265260      >> temp_${file_note} 
     
    328323 
    329324   ## Create or append trusting logfile 
    330    if [ -f ${TRUS_STOR}/trusting_$TRUS_NAME.txt ]; then cmd='tail -1'; else cmd='cat'; fi 
    331  
    332    $cmd ${TRUS_FILE}                            \ 
    333        >> ${TRUS_STOR}/trusting_$TRUS_NAME.txt 
     325   if [ -f ${TRUS_HIST} ]; then cmd='tail -1'; else cmd='cat'; fi 
     326 
     327   $cmd ${TRUS_FILE}   \ 
     328       >> ${TRUS_HIST} 
    334329 
    335330        ## Send mail only when FAILED 
Note: See TracChangeset for help on using the changeset viewer.