source: issm/trunk-jpl/scripts/dailyrun.sh@ 12159

Last change on this file since 12159 was 12159, checked in by Mathieu Morlighem, 13 years ago

Changing ISSM_TIER to ISSM_DIR

  • Property svn:executable set to *
File size: 3.9 KB
RevLine 
[5077]1#!/bin/bash
2#This bash script calls the dailyrun.m matlab file to run our daily test decks.
3#It then processes the results and sends an email to the Ice developpers.
4
[5082]5#Hard coded options
6NUMCPUS_RUN=7
7NROPTIONS=""
8
[5077]9#some functions
10function timer() #{{{1
11{
12 if [[ $# -eq 0 ]]; then
13 echo $(date '+%s')
14 else
15 local stime=$1
16 etime=$(date '+%s')
17
18 if [[ -z "$stime" ]]; then stime=$etime; fi
19
20 dt=$((etime - stime))
21 ds=$((dt % 60))
22 dm=$(((dt / 60) % 60))
23 dh=$((dt / 3600))
24 printf '%d:%02d:%02d' $dh $dm $ds
25 fi
26} #}}}
27function todaydate() #{{{1
28{
29 suffix=`date | awk '{printf("%s-%s-%s %s",$2,$3,$6,$4);}'`
30 echo $suffix;
31} #}}}
32function host_name() #{{{1
33{
34 #return host name depending on the OS
35 if [ "$1" = "winxp32" ]
36 then
37 HOST_NAME=`hostname`;
38 else
39 HOST_NAME=`hostname -s`;
40 fi
41 echo $HOST_NAME;
42} #}}}
43
44#Get configuration
45#Initialize variables {{{1
46TODAY=$(todaydate);
47HOST_NAME=$(host_name $OS);
48START_TIME=$(timer);
49ISSM_RELEASE="N/A"
50USER=$(whoami);
51INIT_PATH=$(pwd);
52#}}}
53
54#Prepare run
55#Windows hack for startup.m {{{1
[12159]56#windows environments: ISSM_DIR_WIN variable not correctly picked up when using
57#the cron job. just get startup to take the ISSM_DIR variable as the pwd:
[5077]58if [ "$OS" = "winxp32" ]
59then
[12159]60 cat startup.m | sed 's/clear status/clear status; ISSM_DIR=pwd;/g' > startup.m.bak
[5077]61 mv startup.m.bak startup.m
62fi
63#}}}
[5082]64#create softlink to startup {{{1
[12159]65cd $ISSM_DIR/test/NightlyRun/
66ln -s $ISSM_DIR/startup.m .
[5082]67#}}}
68#Create dailylog directory and info.log {{{1
69#put installation elapsed time in info.log
[5077]70INSTALL_TIME=$(timer)
71ELAPSED_INSTALL=$(timer $START_TIME)
[12159]72rm -rf $ISSM_DIR/dailylog
73mkdir $ISSM_DIR/dailylog
74cat << END > $ISSM_DIR/dailylog/info.log
[5077]75today: $(echo $TODAY)
76user: $(echo $USER)
77host: $(echo $HOST_NAME)
78OS: N/A
79release: N/A
80init_path: $(echo $INIT_PATH)
81elapsed_install: $(echo $ELAPSED_INSTALL)
82END
83#}}}
[5082]84#check NUMCPUS_RUN options {{{1
85if [ "$NUMCPUS_RUN" = "" ]
86then
87 echo "NUMCPUS_RUN option not found, defaulting to NUMCPUS_RUN = 1"
88 NUMCPUS_RUN=1
89fi
90#}}}
[5077]91
92#Run tests
[5082]93#Launch all tests on different cpus {{{1
94for (( i=1;i<=$NUMCPUS_RUN;i++ ))
95do
96 #Launch matlab and the daily run script
[12159]97 cat > $ISSM_DIR/dailylog/matlab_run$i.m << EOF
[5082]98 warning off %necessary to avoid a info.log of several Go for parallel runs
99 try,
[12159]100 cd $ISSM_DIR/test/NightlyRun
[5082]101 startup;
102 $(if [ "$NROPTIONS" = "" ]
103 then
104 echo "runme('output','daily','rank',$i,'numprocs',$NUMCPUS_RUN);"
105 else
106 echo "runme($NROPTIONS,'output','daily','rank',$i,'numprocs',$NUMCPUS_RUN);"
107 fi
108 )
109 catch me,
110 %An error occured, get report and exit
111 directory=strsplit(pwd,'/');
112 message=getReport(me)
[12159]113 fid=fopen([ISSM_DIR '/dailylog/matlaberror.log'], 'at');
[5082]114 fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end});
115 fprintf(fid,'%s',message);
116 fclose(fid);
117 end
[5591]118 disp('MATLABEXITEDCORRECTLY');
[5082]119 exit
120EOF
121
122 #Start run from dailylog directory
[12159]123 cd $ISSM_DIR/dailylog/
[5082]124
125 #Start test
126 MATLAB_VERSION="7.6" #7.2,7.4,7.6 and 7.8
127 /usr/local/pkgs/matlab-$MATLAB_VERSION/bin/matlab -nojvm -nosplash -r matlab_run$i -logfile matlab_log$i.log &
128done
129
130#wait until matlab closes
131wait
[5077]132#}}}
[5082]133#concatenate all reports {{{1
[12159]134cd $ISSM_DIR/dailylog/
[5082]135mv matlab_log1.log matlab_log.log
136for (( i=2;i<=$NUMCPUS_RUN;i++ ))
137do
138 cat matlab_log.log matlab_log$i.log > matlab_log.log.bak
139 mv matlab_log.log.bak matlab_log.log
140done
141#}}}
142#Complete info.log {{{1
[5591]143if [ $(cat matlab_log.log | grep "MATLABEXITEDCORRECTLY" | wc -l) -eq $NUMCPUS_RUN ]
144then
145 MATLABCRASH=0
146else
147 MATLABCRASH=1
148fi
[5077]149ELAPSED_RUN=$(timer $INSTALL_TIME)
150ELAPSED_TOTAL=$(timer $START_TIME)
[12159]151cat << END >> $ISSM_DIR/dailylog/info.log
[5077]152elapsed_run: $(echo $ELAPSED_RUN)
153elapsed_total: $(echo $ELAPSED_TOTAL)
[5591]154matlab_crash: $(echo $MATLABCRASH)
[5077]155END
156#}}}
157
158#Send Report
159#Build html report {{{1
[12159]160cd $ISSM_DIR/dailylog/
[5082]161sh ../scripts/report.sh
[12159]162ln -s $ISSM_DIR/dailylog/report.html $INIT_PATH
163echo "html report located in $ISSM_DIR/dailylog/report.html and $INIT_PATH/report.html"
[5077]164#}}}
Note: See TracBrowser for help on using the repository browser.