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 @ 5383

Last change on this file since 5383 was 5383, checked in by nicolasmartin, 9 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
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 ) )
[5383]13SVN_CMD='svn status'
[5276]14DEBUG=0; PUBLISH=0; status='OK'
[5268]15
[5355]16# Get options for replacing some initials settings
17#---------------------------------------------------
[5268]18while [ $# -ne 0 ]; do
19    case $1 in
[5286]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;;
[5355]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;;
[5286]24   -t|--time   ) TIME_LIMI=$2         ; shift 2;; -p|--publish) PUBLISH=1            ; shift  ;;
[5383]25        -u|--user   ) CFG_USER=$2          ; shift 2;; -v|--version) NEMO_VERS=$2         ; shift 2;;
[5355]26                   *) cat trusting_help.txt; exit  1;;
[5268]27    esac
28done
[5276]29
[5355]30#export DEBUG PUBLISH
[5268]31
32
[5355]33# Initialization (super-computer & user environment)
34#---------------------------------------------------
35if [[ ! -z "${CFG_ARCH}" && ! -z "${CFG_USER}" ]]; then
[5268]36
[5355]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
[5268]44
[5355]45else
46    cat ${NEMO_TRUS}/trusting_help.txt; exit 1
47fi
[5268]48
[5383]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
[5355]53datestr1=$( LC_ALL=C date -d"${DATE_STR}" +%Y-%m-%dT%H:%M )
54. ./trusting_func.sh
[5268]55
[5355]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
[5383]60printf "Status\nFAILED\n"           > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt
[5355]61
62
63# Check softwares versions
64#---------------------------------------------------
[5383]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
[5268]71
72
[5355]73# SVN action on XIOS & NEMO essentials directories
74#---------------------------------------------------
[5383]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
[5292]78
[5355]79
80# NEMO config compiled from scratch
81#---------------------------------------------------
[5383]82printf "Step......................\nCompiling ${CONF_REF} configuration\n"       | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5276]83cd ${NEMO_CONF}
[5355]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
[5268]87
88
[5355]89# Get namelists, xml & forced files for running
90#---------------------------------------------------
[5383]91printf "Step......................\nPreparing job\n"                             | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]92cd ${TEST_DIR}
93find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \;
[5268]94
[5286]95if [ ! -z "${NEMO_FORC}" ]; then
96    cp ${NEMO_FORC}/${FORC_TAR} .
[5355]97    tar -tvf ${FORC_TAR} > inputs_list.txt && tar -vxf ${FORC_TAR} > /dev/null
98    [ $? -ne 0 ] && get_out
[5286]99    gunzip *.gz
100else
101    touch inputs_list.txt
102fi
[5268]103
[5286]104
[5355]105# Job submission & computing
106#---------------------------------------------------
[5383]107printf "Step......................\nRunning\n"                                   | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt; echo ${JOB_SUBM}
[5355]108job_num=$( ${JOB_SUBM} | awk '{print $NF}' )
109[ $? -ne 0 ] && get_out
[5268]110
[5355]111time_elapsed=0; time_increment=30
[5268]112sleep ${time_increment}
[5355]113while [[ $( ${JOB_LIST} | grep $job_num ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do
[5286]114    printf "\n####################################################" >> computation.log
115    ${JOB_VIEW} $job_num                                            >> computation.log
[5268]116    sleep ${time_increment}
[5286]117    let time_elapsed+=${time_increment}
[5268]118done
119
120
[5355]121# Eventual crash during computing
122#---------------------------------------------------
[5383]123printf "Step......................\nTest if ASCII output files exist\n"          | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]124if   [ ! -f ocean.output                  ]; then
[5383]125    printf "Step......................\nOpa crashed at initialization\n"         | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]126    status='FAILED'
127elif [ $( grep 'E R R O R' ocean.output ) ]; then
[5383]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
[5355]131    status='FAILED'
[5286]132fi
133
134
[5355]135# Inspect output text files
136#---------------------------------------------------
[5383]137printf "Step......................\nTest ASCII output files difference\n"        | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5286]138for file in ocean.output solver.stat tracer.stat; do
[5355]139    diff $file ${REFE_DIR}/$file
[5286]140    [ $? -ne 0 ] && status='FAILED'
141done
[5268]142
143
[5355]144# Inspect output NetCDF files
145#---------------------------------------------------
[5383]146printf "Step......................\nTest last restart NetCDF files difference\n" | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]147diff_restart 2>/dev/null
[5286]148[ $? -ne 0 ] && status='FAILED'
[5268]149
150
[5355]151# Comments
152#---------------------------------------------------
[5383]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
[5268]155
156
[5355]157# Finals tests
158#---------------------------------------------------
[5268]159if [ $status != 'FAILED' ]; then
[5383]160    printf "Step......................\nGet real CPU time\n"                     | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]161    real_cpu_time=$( ${JOB_VIEW} $job_num | awk 'END{print $9}' )
[5383]162    printf "Real CPU time\n%s\n" ${real_cpu_time} > mesg_09_realcputime_${CFG_USER}_${CFG_ARCH}.txt
[5268]163else
[5383]164    printf "Step......................\nTest input files difference\n"           | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]165    diff inputs_list.txt ${REFE_DIR}/inputs_list.txt
166
[5383]167    if [ $? -ne 0 ]; then
168   printf "Input files\nDifferent" > mesg_10_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
[5355]169    else
[5383]170   printf "Input files\nSame"      > mesg_10_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
[5355]171    fi
172
173    get_out
[5268]174fi
175
176
[5355]177# So far, everything is good
178#---------------------------------------------------
[5383]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
[5268]181
[5355]182
183# End
184#---------------------------------------------------
185get_out
Note: See TracBrowser for help on using the repository browser.