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

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

dev_r5092_CNRS_SETTE Many improvments & bug corrections

  • Property eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Rev URL
File size: 7.7 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]53. ./trusting_func.sh
[5268]54
[5424]55
56#
57#---------------------------------------------------
[5355]58mkdir -p ${TEST_DIR} ${REFE_DIR}
59echo ${TEST_DIR} && cd ${TEST_DIR}
[5424]60datestr1=$( LC_ALL=C date -d"${DATE_STR}" +%Y-%m-%dT%H:%M )
[5355]61printf "Date\n%s\n"       $datestr1 > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt
62# Only at end status will change to OK
[5383]63printf "Status\nFAILED\n"           > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt
[5355]64
65
66# Check softwares versions
67#---------------------------------------------------
[5383]68printf "Step......................\nGet softwares release\n"                     | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
69. ${ARCH_ENV} > /dev/null    # Sourcing architecture environment
[5424]70get_soft_rel
[5402]71sed -n 2p model.log | sed 'i\Fortran compiler' | tee mesg_05_compiler_${CFG_USER}_${CFG_ARCH}.txt
72sed -n 3p model.log | sed 'i\MPI libraries   ' | tee mesg_06_mpi_${CFG_USER}_${CFG_ARCH}.txt
73sed -n 4p model.log | sed 'i\NetCDF libraries' | tee mesg_07_netcdf_${CFG_USER}_${CFG_ARCH}.txt
[5268]74
75
[5355]76# SVN action on XIOS & NEMO essentials directories
77#---------------------------------------------------
[5383]78printf "Step......................\nGet NEMO SVN revision with: ${SVN_CMD}\n"    | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5424]79get_nemo_rev
80sed -n 6p model.log | sed 'i\NEMO revision'    | tee  mesg_02_nemo_${CFG_USER}_${CFG_ARCH}.txt
[5292]81
[5355]82
83# NEMO config compiled from scratch
84#---------------------------------------------------
[5383]85printf "Step......................\nCompiling ${CONF_REF} configuration\n"       | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5276]86cd ${NEMO_CONF}
[5355]87#[ -d ${TEST_CONF} ] && ./makenemo -n ${TEST_CONF} clean
[5424]88./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m $ARCH -j $NPROC >& /dev/null
[5355]89[ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out
[5268]90
91
[5355]92# Get namelists, xml & forced files for running
93#---------------------------------------------------
[5402]94cd ${TEST_DIR}
[5383]95printf "Step......................\nPreparing job\n"                             | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]96find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \;
[5268]97
[5402]98if [ ! -z "${FORC_TAR}" ]; then
99    cmd_iol="tar -tvf ${NEMO_FORC}/${FORC_TAR}"; cmd_iof="tar -vxf ${NEMO_FORC}/${FORC_TAR}"
[5286]100else
[5402]101    cmd_iol="ls ${NEMO_FORC}/*"                ; cmd_iof="\cp ${NEMO_FORC}/* ."
[5286]102fi
[5268]103
[5402]104${cmd_iol} > inputs_list.txt && ${cmd_iof} > /dev/null
105[ $? -ne 0 ] && get_out
106[ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz
[5286]107
[5402]108
[5355]109# Job submission & computing
110#---------------------------------------------------
[5383]111printf "Step......................\nRunning\n"                                   | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt; echo ${JOB_SUBM}
[5355]112job_num=$( ${JOB_SUBM} | awk '{print $NF}' )
113[ $? -ne 0 ] && get_out
[5268]114
[5355]115time_elapsed=0; time_increment=30
[5268]116sleep ${time_increment}
[5402]117while [[ $( ${JOB_LIST} | grep ${job_num} ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do
[5286]118    printf "\n####################################################" >> computation.log
[5402]119    ${JOB_VIEW} ${job_num}                                          >> computation.log
[5268]120    sleep ${time_increment}
[5286]121    let time_elapsed+=${time_increment}
[5268]122done
[5402]123sleep ${time_increment}
[5268]124
[5355]125# Eventual crash during computing
126#---------------------------------------------------
[5383]127printf "Step......................\nTest if ASCII output files exist\n"          | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]128if   [ ! -f ocean.output                  ]; then
[5383]129    printf "Step......................\nOpa crashed at initialization\n"         | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5402]130    ${JOB_DELE} ${job_num} >/dev/null 2>&1
[5355]131    status='FAILED'
132elif [ $( grep 'E R R O R' ocean.output ) ]; then
[5383]133    printf "Step......................\nOpa crashed\n"                           | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5402]134    grep 'E R R O R'       ocean.output | tee    mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
135    sed 's/^/Time step :/' time.step    | tee -a mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
136    ${JOB_DELE} ${job_num} >/dev/null 2>&1
[5355]137    status='FAILED'
[5286]138fi
139
140
[5355]141# Inspect output text files
142#---------------------------------------------------
[5383]143printf "Step......................\nTest ASCII output files difference\n"        | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5286]144for file in ocean.output solver.stat tracer.stat; do
[5355]145    diff $file ${REFE_DIR}/$file
[5286]146    [ $? -ne 0 ] && status='FAILED'
147done
[5268]148
149
[5355]150# Inspect output NetCDF files
151#---------------------------------------------------
[5383]152printf "Step......................\nTest last restart NetCDF files difference\n" | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5355]153diff_restart 2>/dev/null
[5286]154[ $? -ne 0 ] && status='FAILED'
[5268]155
156
[5402]157# Finals tests
[5355]158#---------------------------------------------------
[5402]159if [ $status != 'FAILED' ]; then
[5268]160
[5402]161    # Comments
162    #---------------------------------------------------
163    echo 'Comments'                    | tee    mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
164    grep 'W A R N I N G:' ocean.output | tee -a mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
[5268]165
[5402]166    # Portability !
[5383]167    printf "Step......................\nGet real CPU time\n"                     | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5402]168    real_cpu_time=$( ${JOB_VIEW} ${job_num} | awk 'END{print $9}' )
169    printf "Real CPU time\n%s\n" ${real_cpu_time} | tee mesg_08_realcputime_${CFG_USER}_${CFG_ARCH}.txt
[5424]170    printf "Input files\nNA"                      | tee mesg_09_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
[5268]171else
[5383]172    printf "Step......................\nTest input files difference\n"           | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5402]173    diff_inputs
[5355]174    get_out
[5268]175fi
176
177
[5355]178# So far, everything is good
179#---------------------------------------------------
[5383]180printf "Status\nOK\n" > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt
181printf "Step......................\nCode is reliable\n"                          | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
[5268]182
[5355]183
184# End
185#---------------------------------------------------
186get_out
Note: See TracBrowser for help on using the repository browser.