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.
trusting.sh in branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST – NEMO

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

Last change on this file since 5356 was 5355, checked in by nicolasmartin, 9 years ago

dev_r5092_CNRS_SETTE Many improvments

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