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