1 | #!/bin/bash |
---|
2 | |
---|
3 | |
---|
4 | cd $( dirname $0 ) |
---|
5 | |
---|
6 | ## Set defaults |
---|
7 | ##--------------------------------------------------- |
---|
8 | TRUS_DBUG=0; TRUS_PROD=0; TRUS_HELP=0 |
---|
9 | |
---|
10 | |
---|
11 | ## Get options (for replacing initials settings) |
---|
12 | ##--------------------------------------------------- |
---|
13 | while [ $# -ne 0 ]; do |
---|
14 | case $1 in |
---|
15 | '-d'|'--debug' ) TRUS_DBUG=1 ; shift ;; '-j'|'--job' ) TRUS_NPRO=$2; shift 2;; |
---|
16 | '-m'|'--machine') TRUS_HPCC=$2; shift 2;; '-h'|'--help' ) TRUS_HELP=1 ; shift ;; |
---|
17 | '-u'|'--user' ) TRUS_USER=$2; shift 2;; "*" ) TRUS_HELP=1 ; shift ;; |
---|
18 | esac |
---|
19 | done |
---|
20 | |
---|
21 | |
---|
22 | ## Initialization (HPC & user environment) |
---|
23 | ##--------------------------------------------------- |
---|
24 | if [[ ! -e config/${TRUS_USER}.cfg || ! -e config/${TRUS_HPCC}.cfg || ${TRUS_HELP} -eq 1 ]]; then |
---|
25 | cat ./inc/trusting_help.txt |
---|
26 | |
---|
27 | if [ ${TRUS_HELP} -eq 0 ]; then |
---|
28 | printf "\n\n\033[0;33m" |
---|
29 | printf "At least one configuration (arch or user) file is missing or misspelled:" |
---|
30 | printf "\t'%s'.cfg\t'%s'.cfg" ${TRUS_USER} ${TRUS_HPCC} |
---|
31 | printf "\033[0m" |
---|
32 | fi |
---|
33 | |
---|
34 | printf "\n\nContent of 'config' folder:\n" |
---|
35 | find config -name *.cfg | cut -d/ -f2 \ |
---|
36 | | xargs -n 4 printf "\t- %-25s\t- %-25s\t- %-25s\t- %-25s\n" |
---|
37 | exit 1 |
---|
38 | else |
---|
39 | . ./inc/trusting.env |
---|
40 | [ ${TRUS_DBUG} -eq 1 ] && set -vx |
---|
41 | fi |
---|
42 | |
---|
43 | |
---|
44 | ## List last branches from NEMO Forge |
---|
45 | ##--------------------------------------------------- |
---|
46 | printf "\nWhat branch do you want to install in "${TRUS_WORK}" for trusting test ? " |
---|
47 | echo 'Enter 0 to abort' |
---|
48 | select branch in 'trunk' $( svn ls ${TRUS_SVNH}/branches/2015 | tr -d / | sort -r ); do |
---|
49 | |
---|
50 | if [ $REPLY -eq 0 ]; then exit 1; else export TRUS_BRAN=$branch; fi |
---|
51 | |
---|
52 | printf "\nInstallation of a working copy of '%s' branch in '%s'? " ${TRUS_BRAN} ${TRUS_WORK} |
---|
53 | printf "\nType [Y|y|yes] to confirm, if not back to branches list number\n" |
---|
54 | read answer |
---|
55 | [[ $answer == 'Y' || $answer == 'y' || $answer == 'yes' ]] && break |
---|
56 | |
---|
57 | done |
---|
58 | |
---|
59 | echo |
---|
60 | |
---|
61 | |
---|
62 | ## First checkout of selected branch |
---|
63 | ##--------------------------------------------------- |
---|
64 | echo 'Initial checkout of '${TRUS_BRAN}' branch' |
---|
65 | mkdir -p ${TRUS_WORK}/${TRUS_BRAN}/NEMOGCM |
---|
66 | cd ${TRUS_WORK}/${TRUS_BRAN}/NEMOGCM |
---|
67 | |
---|
68 | svn_bran=branches/2015/${TRUS_BRAN} |
---|
69 | [ ${TRUS_BRAN} == 'trunk' ] && svn_bran=${TRUS_BRAN} |
---|
70 | |
---|
71 | for elmt in ${TRUS_CKOT}; do |
---|
72 | [ $elmt == '\' ] && continue |
---|
73 | printf "%s " $elmt |
---|
74 | |
---|
75 | if [ $elmt == 'TOOLS/maketools' ]; then |
---|
76 | svn co -q ${TRUS_SVNH}/${svn_bran}/NEMOGCM/TOOLS --depth empty |
---|
77 | svn up -q $elmt |
---|
78 | else |
---|
79 | svn co -q ${TRUS_SVNH}/${svn_bran}/NEMOGCM/$elmt $elmt |
---|
80 | fi |
---|
81 | |
---|
82 | done |
---|
83 | |
---|
84 | printf "\n\n" |
---|
85 | |
---|
86 | |
---|
87 | ## Compile rebuild_nemo.exe in anticipation |
---|
88 | ##--------------------------------------------------- |
---|
89 | if [ $( find ARCH -name arch-${TRUS_HPCC}.fcm ) ]; then |
---|
90 | echo 'Compile NEMO rebuild tool' |
---|
91 | cd TOOLS && ./maketools -n REBUILD_NEMO -m ${TRUS_HPCC} -j ${TRUS_NPRO} >& /dev/null |
---|
92 | [ -e REBUILD_NEMO/rebuild_nemo.exe ] && printf "\033[0;32mOK\033[0m" || printf "\033[0;31mKO\033[0m" |
---|
93 | printf "\n\n" |
---|
94 | else |
---|
95 | printf "\033[0;31mNo arch file found to compile NEMO rebuild tool\033[0m\n\n" |
---|
96 | fi |
---|
97 | |
---|
98 | exit 0 |
---|
99 | |
---|