1 | #!/bin/ksh |
---|
2 | |
---|
3 | #************************************************************** |
---|
4 | # Author: Martial Mancip |
---|
5 | # Contact: Martial.Mancip__at__ipsl.jussieu.fr |
---|
6 | # $Revision:: $ Revision of last commit |
---|
7 | # $Author:: $ Author of last commit |
---|
8 | # $Date:: $ Date of last commit |
---|
9 | # IPSL (2006) |
---|
10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
11 | # |
---|
12 | #************************************************************** |
---|
13 | |
---|
14 | # Documentation : |
---|
15 | # This script gives an analyse of LAST configuration from mod.def downloaded by model command. |
---|
16 | # |
---|
17 | # It will create shell variables : |
---|
18 | # The list of components of the configuration : ModelComponents / NbComponents |
---|
19 | # And for each components : |
---|
20 | # - The tags or branch name : ModelTags |
---|
21 | # - The version control system name : ModelSystems |
---|
22 | # - The version control server address and login : ModelServers |
---|
23 | # - The version control server directory for this version : ModelDirectories |
---|
24 | # - The modipsl local directory : ModelLocalDirs |
---|
25 | |
---|
26 | |
---|
27 | typeset sizelog thedate logfile mymodel i NbModelCommands NbModelNames |
---|
28 | |
---|
29 | logfile=${MODIPSL}/util/log |
---|
30 | |
---|
31 | set -A ListModelCommands -- $( cat ${logfile} | grep '\./model' | sed -e 's& &::&g') |
---|
32 | printDebugArray ListModelCommands |
---|
33 | |
---|
34 | NbModelCommands=${#ListModelCommands[@]} |
---|
35 | |
---|
36 | set -A ListModelNames -- $( cat ${logfile} | grep '\-\-\-\ Model' | sed -e 's&.*: *&&' ) |
---|
37 | printDebugArray ListModelNames |
---|
38 | |
---|
39 | NbModelNames=${#ListModelNames[@]} |
---|
40 | |
---|
41 | if [ ${NbModelCommands} -ne ${NbModelNames} ] ; then |
---|
42 | echo "Error with $0 script. number of model calls ${NbModelCommands} is not equal to model name ${NbModelNames} in util/log file." |
---|
43 | exit 1 |
---|
44 | fi |
---|
45 | |
---|
46 | set -A ListModelDates -- $( cat ${logfile} | grep '\./model' | sed -e 's&\ \./model .*&&' | sed -e 's&/&-&g' | sed -e 's& &_&g' ) |
---|
47 | printDebugArray ListModelDates |
---|
48 | #set -A ListModelDates -- $( cat ${logfile} | grep '\./model' | sed -e 's&\ \./model .*&&' | sed -e 's&^\(.*\)&"\1"&g' | xargs date +%g-%m-%d_%R:%S -d ) |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | # We only use the last call to model here ! |
---|
53 | (( ModelNum = NbModelCommands - 1 )) |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | (( i = 0 )) |
---|
59 | for mymodel in ${ListModelNames[@]}; do |
---|
60 | thedate=$( echo ${ListModelDates[$i]} | sed -e "s&_& &g" | sed -e "s&-&/&g") |
---|
61 | # echo $model $i ${ListModelDates[$i]} $thedate |
---|
62 | ListLineModels[$i]=$( grep -ni "${thedate}" ${logfile} | sed -e "s&^\([0-9]*\):.*&\1&" ) |
---|
63 | (( i = i + 1 )) |
---|
64 | done |
---|
65 | printDebugArray ListLineModels |
---|
66 | |
---|
67 | sizelog=$( wc -l ${logfile} | sed -e 's&^\([0-9]*\).*&\1&' ) |
---|
68 | |
---|
69 | LastModelFile=log_${ModelNum} |
---|
70 | tail --lines=$(( sizelog - ListLineModels[${ModelNum}] + 1 )) ${logfile} > ${LastModelFile} |
---|
71 | |
---|
72 | set -A ModelComponents -- $( cat ${LastModelFile} | grep '\-\-\-\ Component *: ' | sed -e 's&--- Component *: \(.*\)&\1&' ) |
---|
73 | printDebugArray ModelComponents |
---|
74 | |
---|
75 | NbComponents=${#ModelComponents[@]} |
---|
76 | |
---|
77 | set -A ModelTags -- $( cat ${LastModelFile} | grep '\-\-\-\ Tag *: ' | sed -e 's&--- Tag *: \(.*\)&\1&' ) |
---|
78 | printDebugArray ModelTags |
---|
79 | |
---|
80 | set -A ModelSystems -- $( cat ${LastModelFile} | grep '\-\-\-\ System *: ' | sed -e 's&--- System *: \(.*\)&\1&' ) |
---|
81 | printDebugArray ModelSystems |
---|
82 | |
---|
83 | set -A ModelServers -- $( cat ${LastModelFile} | grep '\-\-\-\ Server *: ' | sed -e 's&--- Server *: \(.*\)&\1&' | sed -e 's& &:_:&g' ) |
---|
84 | printDebugArray ModelServers |
---|
85 | |
---|
86 | set -A ModelDirectories -- $( cat ${LastModelFile} | grep '\-\-\-\ Directory *: ' | sed -e 's&--- Directory *: \(.*\)&\1&' ) |
---|
87 | printDebugArray ModelDirectories |
---|
88 | |
---|
89 | set -A ModelLocalDirs -- $( cat ${LastModelFile} | grep '\-\-\-\ Local Dir *: ' | sed -e 's&--- Local Dir *: \(.*\)&\1&' ) |
---|
90 | printDebugArray ModelLocalDirs |
---|
91 | |
---|
92 | rm ${LastModelFile} |
---|