source: branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh @ 5383

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

dev_r5092_CNRS_SETTE Add rebuild tool for comparing among other improvments & bugs

  • Property eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Rev URL
File size: 7.5 KB
Line 
1#!/bin/bash
2#
3# Author: Patrick Brockmann
4# Contact: Patrick.Brockmann@cea.fr
5# History:
6# Modification: Nicolas-thierry.Martin@locean-ipsl.upmc.fr
7#
8
9
10# Set defaults
11#---------------------------------------------------
12NEMO_TRUS=$( pwd $( dirname $0 ) )
13SVN_CMD='svn status'
14DEBUG=0; PUBLISH=0; status='OK'
15
16# Get options for replacing some initials settings
17#---------------------------------------------------
18while [ $# -ne 0 ]; do
19    case $1 in
20        -b|--branch ) NEMO_BRAN=$2         ; shift 2;; -d|--debug  ) set -vx; DEBUG=1     ; shift  ;;
21   -e|--email  ) MAIL=$2              ; shift 2;; -j|--job    ) NPROC=$2             ; shift 2;;
22   -h|--help   ) cat trusting_help.txt; exit  1;; -m|--machine) CFG_ARCH=$2          ; shift 2;;
23   -n|--newconf) TEST_CONF=$2         ; shift 2;; -r|--refconf) REFE_CONF=$2         ; shift 2;;
24   -t|--time   ) TIME_LIMI=$2         ; shift 2;; -p|--publish) PUBLISH=1            ; shift  ;;
25        -u|--user   ) CFG_USER=$2          ; shift 2;; -v|--version) NEMO_VERS=$2         ; shift 2;;
26                   *) cat trusting_help.txt; exit  1;;
27    esac
28done
29
30#export DEBUG PUBLISH
31
32
33# Initialization (super-computer & user environment)
34#---------------------------------------------------
35if [[ ! -z "${CFG_ARCH}" && ! -z "${CFG_USER}" ]]; then
36
37    if   [ ! $( find ${NEMO_TRUS}/cfg -name ${CFG_USER}.cfg ) ]; then
38   echo 'No configuration file in '${NEMO_TRUS}'/cfg for '${CFG_USER}; exit 1
39    elif [ ! $( find ${NEMO_TRUS}/cfg -name ${CFG_ARCH}.cfg ) ]; then
40   echo 'No configuration file in '${NEMO_TRUS}'/cfg for '${CFG_ARCH}; exit 1
41    else
42   . ${NEMO_TRUS}/trusting.env
43    fi
44
45else
46    cat ${NEMO_TRUS}/trusting_help.txt; exit 1
47fi
48
49# If -v|--version option has been set, modify svn command
50[ $( echo ${NEMO_VERS} | grep  "up\|update"         ) ] && SVN_CMD='svn update'
51[ $( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' ) ] && SVN_CMD='svn update -r '$( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' )
52
53datestr1=$( LC_ALL=C date -d"${DATE_STR}" +%Y-%m-%dT%H:%M )
54. ./trusting_func.sh
55
56mkdir -p ${TEST_DIR} ${REFE_DIR}
57echo ${TEST_DIR} && cd ${TEST_DIR}
58printf "Date\n%s\n"       $datestr1 > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt
59# Only at end status will change to OK
60printf "Status\nFAILED\n"           > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt
61
62
63# Check softwares versions
64#---------------------------------------------------
65printf "Step......................\nGet softwares release\n"                     | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
66. ${ARCH_ENV} > /dev/null    # Sourcing architecture environment
67get_rel
68sed -n 2p model.log | sed 'i\Fortran compiler' > mesg_05_compiler_${CFG_USER}_${CFG_ARCH}.txt
69sed -n 3p model.log | sed 'i\MPI libraries   ' > mesg_06_mpi_${CFG_USER}_${CFG_ARCH}.txt
70sed -n 4p model.log | sed 'i\NetCDF libraries' > mesg_07_netcdf_${CFG_USER}_${CFG_ARCH}.txt
71
72
73# SVN action on XIOS & NEMO essentials directories
74#---------------------------------------------------
75printf "Step......................\nGet NEMO SVN revision with: ${SVN_CMD}\n"    | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
76get_rev
77sed -n 6p model.log | sed 'i\NEMO revision' > mesg_02_nemo_${CFG_USER}_${CFG_ARCH}.txt
78
79
80# NEMO config compiled from scratch
81#---------------------------------------------------
82printf "Step......................\nCompiling ${CONF_REF} configuration\n"       | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
83cd ${NEMO_CONF}
84#[ -d ${TEST_CONF} ] && ./makenemo -n ${TEST_CONF} clean
85./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m $ARCH -j $NPROC > /dev/null 2>&1
86[ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out
87
88
89# Get namelists, xml & forced files for running
90#---------------------------------------------------
91printf "Step......................\nPreparing job\n"                             | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
92cd ${TEST_DIR}
93find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \;
94
95if [ ! -z "${NEMO_FORC}" ]; then
96    cp ${NEMO_FORC}/${FORC_TAR} .
97    tar -tvf ${FORC_TAR} > inputs_list.txt && tar -vxf ${FORC_TAR} > /dev/null
98    [ $? -ne 0 ] && get_out
99    gunzip *.gz
100else
101    touch inputs_list.txt
102fi
103
104
105# Job submission & computing
106#---------------------------------------------------
107printf "Step......................\nRunning\n"                                   | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt; echo ${JOB_SUBM}
108job_num=$( ${JOB_SUBM} | awk '{print $NF}' )
109[ $? -ne 0 ] && get_out
110
111time_elapsed=0; time_increment=30
112sleep ${time_increment}
113while [[ $( ${JOB_LIST} | grep $job_num ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do
114    printf "\n####################################################" >> computation.log
115    ${JOB_VIEW} $job_num                                            >> computation.log
116    sleep ${time_increment}
117    let time_elapsed+=${time_increment}
118done
119
120
121# Eventual crash during computing
122#---------------------------------------------------
123printf "Step......................\nTest if ASCII output files exist\n"          | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
124if   [ ! -f ocean.output                  ]; then
125    printf "Step......................\nOpa crashed at initialization\n"         | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
126    status='FAILED'
127elif [ $( grep 'E R R O R' ocean.output ) ]; then
128    printf "Step......................\nOpa crashed\n"                           | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
129    grep 'E R R O R'       ocean.output >> mesg_12_comments_${CFG_USER}_${CFG_ARCH}.txt
130    sed 's/^/Time step :/' time.step    >> mesg_12_comments_${CFG_USER}_${CFG_ARCH}.txt
131    status='FAILED'
132fi
133
134
135# Inspect output text files
136#---------------------------------------------------
137printf "Step......................\nTest ASCII output files difference\n"        | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
138for file in ocean.output solver.stat tracer.stat; do
139    diff $file ${REFE_DIR}/$file
140    [ $? -ne 0 ] && status='FAILED'
141done
142
143
144# Inspect output NetCDF files
145#---------------------------------------------------
146printf "Step......................\nTest last restart NetCDF files difference\n" | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
147diff_restart 2>/dev/null
148[ $? -ne 0 ] && status='FAILED'
149
150
151# Comments
152#---------------------------------------------------
153echo 'Comments'                    >  mesg_12_comments_${CFG_USER}_${CFG_ARCH}.txt
154grep 'W A R N I N G:' ocean.output >> mesg_12_comments_${CFG_USER}_${CFG_ARCH}.txt
155
156
157# Finals tests
158#---------------------------------------------------
159if [ $status != 'FAILED' ]; then
160    printf "Step......................\nGet real CPU time\n"                     | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
161    real_cpu_time=$( ${JOB_VIEW} $job_num | awk 'END{print $9}' )
162    printf "Real CPU time\n%s\n" ${real_cpu_time} > mesg_09_realcputime_${CFG_USER}_${CFG_ARCH}.txt
163else
164    printf "Step......................\nTest input files difference\n"           | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
165    diff inputs_list.txt ${REFE_DIR}/inputs_list.txt
166
167    if [ $? -ne 0 ]; then
168   printf "Input files\nDifferent" > mesg_10_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
169    else
170   printf "Input files\nSame"      > mesg_10_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
171    fi
172
173    get_out
174fi
175
176
177# So far, everything is good
178#---------------------------------------------------
179printf "Status\nOK\n" > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt
180printf "Step......................\nCode is reliable\n"                          | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
181
182
183# End
184#---------------------------------------------------
185get_out
Note: See TracBrowser for help on using the repository browser.