source: branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh @ 5459

Last change on this file since 5459 was 5459, checked in by nicolasmartin, 5 years ago

dev_r5092_CNRS_SETTE Ping pong updates between Curie & Ada to finalize

  • Property eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Rev URL
File size: 5.6 KB
Line 
1#!/bin/bash
2
3
4comments() {
5    state=$1
6
7    if [ $state == 'E R R O R' ]; then
8   if [ -e ocean.output ]; then
9       last_time_step=$( cat ${TEST_DIR}/time.step | tr -d [:space:] )
10       STEP='nemo.exe crashed at '${last_time_step} && export STEP
11       line=$( grep -m1 -A5 "$state" ocean.output | tr -d '\n' )
12   else
13       STEP='nemo.exe crashed at initialization'    && export STEP
14       return
15   fi
16    fi
17
18    if [ $( diff -q arch_env.log ${REFE_DIR}/arch_env.log ) ]; then
19   line=$( diff arch_env.log ${REFE_DIR}/arch_env.log  | tr -d '\n' )
20    fi
21
22    printf "Comments\n$line\n" | tee mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
23}
24
25get_cpu_time() {
26    # Portability !
27    real_cpu_time=$( ${JOB_VIEW} ${JOB_ID} | awk 'END{print $9}' )
28    printf "Real CPU time\n${real_cpu_time}\n" | tee mesg_09_realcputime_${CFG_USER}_${CFG_ARCH}.txt
29}
30
31diff_inputs() {
32    mesg='Same'
33
34    for file in inputs_list.txt $( ls namelist_* ) $( ls *.xml ); do
35   diff $file ${REFE_DIR}/$file
36   [ $? -ne 0 ] && mesg='Different'
37    done
38
39    printf "Input files\n$mesg\n" | tee mesg_08_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
40}
41
42diff_restart() {
43    last_time_step=$( cat ${REFE_DIR}/time.step | tr -d [:space:] )
44    echo 'Last time step of standard run: '${last_time_step}
45
46    if [ $( find ${TEST_DIR} -name "*${last_time_step}_restart*.nc" -print -quit ) ]; then
47   base_name=$( find ${TEST_DIR} -name "*${last_time_step}_restart*.nc" -print -quit           \
48                | awk -F/ '{print $NF}' | sed "s/^\(.*\)$last_time_step\_.*/\1$last_time_step/" )
49
50   for comp in restart restart_ice restart_trc; do
51       printf "${base_name}_${comp}.nc: "
52
53       nb_dom=$( find ${TEST_DIR} -name "${base_name}_${comp}_[0-9]*.nc" | wc -l | awk '{print $1}' )
54       if [ ${nb_dom} -gt 1 ]; then
55      ${NEMO_TRBD}/rebuild_nemo -t $NPROC ${base_name}_$comp ${nb_dom} > /dev/null
56       fi
57
58       cmp ${TEST_DIR}/${base_name}_$comp.nc ${REFE_DIR}/${base_name}_$comp.nc
59       if [ $? -ne 0 ]; then
60      STATUS='FAILED'; STEP='Restart files different'
61      printf "$CDO diffn\n"
62      $CDO diffn ${TEST_DIR}/${base_name}_$comp.nc ${REFE_DIR}/${base_name}_$comp.nc 2> /dev/null
63       else
64      printf "identical\n"
65       fi
66
67       \r${TEST_DIR}/${base_name}_${comp}_[0-9]*.nc
68   done
69
70    else
71   STATUS='FAILED'; STEP='No restart files found at last time step'
72   printf "no restart files found for comparison\n"
73    fi
74
75    [ $STATUS == 'FAILED'] && get_out $STATUS $STEP
76}
77
78get_soft_rel() {
79    for rel in $CDO $COMPILER $MPI $NETCDF; do
80                                 arch_rel=$( echo $LOADEDMODULES | sed  "s#.*$rel/\([^:]*\).*#\1#" )
81   [ -z "${arch_rel}"  ] && arch_rel=$( echo $PATH          | sed  "s#.*$rel/\([^/]*\).*#\1#" )
82   [ $rel == $COMPILER ] && arch_rel=$( $rel --version      | grep -m1 -o ' [0-9.]* '         )
83   echo $rel ${arch_rel} >> arch_env.log
84    done
85
86    sed -n 3p arch_env.log | sed 'i\Compiler'    > mesg_05_compiler_${CFG_USER}_${CFG_ARCH}.txt
87    sed -n 4p arch_env.log | sed 'i\MPI libs'    > mesg_06_mpi_${CFG_USER}_${CFG_ARCH}.txt
88    sed -n 5p arch_env.log | sed 'i\NetCDF libs' > mesg_07_netcdf_${CFG_USER}_${CFG_ARCH}.txt
89}
90
91get_nemo_rev() {
92    svn_opt='status'
93
94    # If -v|--version option has been set, modify svn command
95    if [[    $( echo ${NEMO_VERS} | grep  "HEAD\|up\|update"   ) \
96     || $( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' )  ]]; then
97   rev=$( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' ) || rev='HEAD'
98   svn_cmd='svn update -r '$rev 
99    else
100   svn_cmd='svn '${svn_opt}
101    fi
102
103    rev=0
104    for dir in ${DIR_XIOS}  ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} \
105          ${NEMO_EIOI} ${NEMO_EFCM} ${NEMO_TCMP} ${NEMO_TRBD}  ; do
106
107   # For time being, just get revision number from XIOS
108   if [ $dir == ${DIR_XIOS} ]; then
109       echo 'XIOS '$( svn info $dir | awk '(NR == 5) {print $NF}' ) >> arch_env.log
110       continue
111   fi
112
113   ${svn_cmd} $dir
114   rev_loc=$( svn info $dir | awk '(NR == 5) {print $NF}' )
115   (( ${rev_loc} >= $rev )) && rev=${rev_loc}
116    done
117
118    printf "NEMOGCM rev.\n$rev\n" > mesg_02_nemogcm_${CFG_USER}_${CFG_ARCH}.txt
119}
120
121mesg_make() {
122    paste -d ';' mesg_*_${CFG_USER}_${CFG_ARCH}.txt > trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt
123    cat                                               trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt
124}
125
126mesg_publish() {
127 
128if [ $PUBLISH -eq 1 ]; then
129
130  if [ -f ${REFE_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt ]; then cmd='sed -n 2p'; else cmd='cat'; fi
131
132  $cmd trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt >> ${REFE_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt
133
134  # Send mail only when FAILED
135  if [[ ! -z $MAIL && $STATUS == 'FAILED' ]]; then
136      cat << END_MAIL > trusting.mail
137XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
138Dear $USER,
139
140The trusting sequence for ${CONF_REF} has failed at step:
141`tail -n 1 mesg_03_step_${CFG_USER}_${CFG_ARCH}.txt`
142Directory : ${TEST_DIR}
143
144XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
145
146END_MAIL
147      cat mesg_*_${CFG_USER}_${CFG_ARCH}.txt        >> trusting.mail
148      mail -s "[trusting ${CONF_REF}] FAILED" $MAIL  < trusting.mail
149  fi
150
151fi
152}
153
154print_step() { STEP=$1; export STEP && printf "Step.....\n$TEP\n"; }
155
156get_out() {
157    mesg_make; mesg_publish
158
159    # Save tested configuration if trusting failed
160    if [ $STATUS == 'FAILED' ]; then
161   cd ${TEST_DIR}
162   touch mesg_08_inputfiles_${CFG_USER}_${CFG_ARCH}.txt mesg_09_realcputime_${CFG_USER}_${CFG_ARCH}.txt \
163         mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
164   #tar -czf ${REFE_DIR}/trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.tar.gz *
165    fi
166
167    printf "Status\n$STATUS\n"  > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt
168    printf "Step.....\n$STEP\n" > mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
169
170    exit 1
171}
Note: See TracBrowser for help on using the repository browser.