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

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

dev_r5092_CNRS_SETTE Increase trusting main script clarity with new functions

  • Property eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Rev URL
File size: 5.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 ) )
[5438]13SVN_OPT='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# Initialization (super-computer & user environment)
31#---------------------------------------------------
32if [[ ! -z "${CFG_ARCH}" && ! -z "${CFG_USER}" ]]; then
[5268]33
[5355]34    if   [ ! $( find ${NEMO_TRUS}/cfg -name ${CFG_USER}.cfg ) ]; then
35   echo 'No configuration file in '${NEMO_TRUS}'/cfg for '${CFG_USER}; exit 1
36    elif [ ! $( find ${NEMO_TRUS}/cfg -name ${CFG_ARCH}.cfg ) ]; then
37   echo 'No configuration file in '${NEMO_TRUS}'/cfg for '${CFG_ARCH}; exit 1
38    else
39   . ${NEMO_TRUS}/trusting.env
40    fi
[5268]41
[5355]42else
43    cat ${NEMO_TRUS}/trusting_help.txt; exit 1
44fi
[5268]45
[5355]46. ./trusting_func.sh
[5268]47
[5424]48#
49#---------------------------------------------------
[5355]50mkdir -p ${TEST_DIR} ${REFE_DIR}
51echo ${TEST_DIR} && cd ${TEST_DIR}
[5424]52datestr1=$( LC_ALL=C date -d"${DATE_STR}" +%Y-%m-%dT%H:%M )
[5438]53printf "Date\n$datestr1\n" > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt
[5355]54# Only at end status will change to OK
[5438]55status='FAILED'
[5355]56
[5438]57# Check softwares versions (source arch environment)
[5355]58#---------------------------------------------------
[5438]59pstep 'Get softwares release'
60. ${ARCH_ENV} > /dev/null
[5424]61get_soft_rel
[5268]62
[5355]63# SVN action on XIOS & NEMO essentials directories
64#---------------------------------------------------
[5438]65pstep "Get NEMO SVN state with: ${SVN_OPT}"
[5424]66get_nemo_rev
[5438]67exit 0
[5355]68# NEMO config compiled from scratch
69#---------------------------------------------------
[5438]70pstep "Compiling ${CONF_REF} configuration"
[5276]71cd ${NEMO_CONF}
[5355]72#[ -d ${TEST_CONF} ] && ./makenemo -n ${TEST_CONF} clean
[5424]73./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m $ARCH -j $NPROC >& /dev/null
[5438]74[ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out $step $status
[5268]75
[5355]76# Get namelists, xml & forced files for running
77#---------------------------------------------------
[5438]78pstep 'Preparing job'
[5355]79find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \;
[5268]80
[5402]81if [ ! -z "${FORC_TAR}" ]; then
82    cmd_iol="tar -tvf ${NEMO_FORC}/${FORC_TAR}"; cmd_iof="tar -vxf ${NEMO_FORC}/${FORC_TAR}"
[5286]83else
[5402]84    cmd_iol="ls ${NEMO_FORC}/*"                ; cmd_iof="\cp ${NEMO_FORC}/* ."
[5286]85fi
[5268]86
[5402]87${cmd_iol} > inputs_list.txt && ${cmd_iof} > /dev/null
[5438]88[ $? -ne 0 ] && get_out $step $status
[5402]89[ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz
[5286]90
[5438]91# Check input files in all cases
92#---------------------------------------------------
93pstep 'Test input files difference'
94diff_inputs
95
[5355]96# Job submission & computing
97#---------------------------------------------------
[5438]98pstep 'Running'
[5355]99job_num=$( ${JOB_SUBM} | awk '{print $NF}' )
[5438]100[ $? -ne 0 ] && get_out $step $status
[5268]101
[5355]102time_elapsed=0; time_increment=30
[5268]103sleep ${time_increment}
[5402]104while [[ $( ${JOB_LIST} | grep ${job_num} ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do
[5286]105    printf "\n####################################################" >> computation.log
[5402]106    ${JOB_VIEW} ${job_num}                                          >> computation.log
[5268]107    sleep ${time_increment}
[5286]108    let time_elapsed+=${time_increment}
[5268]109done
[5402]110sleep ${time_increment}
[5268]111
[5355]112# Eventual crash during computing
113#---------------------------------------------------
[5438]114pstep 'Test if ASCII output files exist'
115if   [[ ! -f ocean.output || $( grep 'E R R O R' ocean.output ) ]]; then
116    ${JOB_DELE} ${job_num} &> /dev/null
117    [ ! -f ocean.output                  ] && step='nemo.exe crashed at initialization'
118    [ $( grep 'E R R O R' ocean.output ) ] && step='nemo.exe crashed'
119    comments('E R R O R')
[5402]120    ${JOB_DELE} ${job_num} >/dev/null 2>&1
[5355]121    status='FAILED'
[5438]122    get_out $step $status
123else
124    status='OK'
[5286]125
[5438]126    # Inspect output text files
127    #---------------------------------------------------
128    pstep 'Test ASCII output files diff'
129    for file in ocean.output solver.stat tracer.stat; do
130   diff $file ${REFE_DIR}/$file
131   [ $? -ne 0 ] && status='FAILED'
132    done
[5286]133
[5438]134    # Inspect output NetCDF files
135    #---------------------------------------------------
136    pstep 'Test last restart NetCDF files diff'
137    diff_restart #2> /dev/null
[5286]138    [ $? -ne 0 ] && status='FAILED'
[5268]139
[5438]140    # Get computation duration
[5402]141    #---------------------------------------------------
[5438]142    pstep 'Get real CPU time'
143    get_cpu_time
[5268]144
[5438]145    comments('W A R N I N G')
[5268]146fi
147
[5355]148# End
149#---------------------------------------------------
[5438]150if [ $status == 'FAILED' ]; then step='Test outputs difference'; else step='Code is reliable'; fi
151get_out $step $status
Note: See TracBrowser for help on using the repository browser.