Index: /issm/trunk/scripts/dailyrun.sh
===================================================================
--- /issm/trunk/scripts/dailyrun.sh	(revision 5081)
+++ /issm/trunk/scripts/dailyrun.sh	(revision 5082)
@@ -2,4 +2,8 @@
 #This bash script calls the dailyrun.m matlab file to run our daily test decks. 
 #It then processes the results and sends an email to the Ice developpers.
+
+#Hard coded options
+NUMCPUS_RUN=7
+NROPTIONS=""
 
 #some functions
@@ -58,11 +62,15 @@
 fi
 #}}}
-#Create dailylog directory and daily.log {{{1
-#put installation elapsed time in daily.log
+#create softlink to startup {{{1
+cd $ISSM_DIR/test/NightlyRun/
+ln -s $ISSM_DIR/startup.m .
+#}}}
+#Create dailylog directory and info.log {{{1
+#put installation elapsed time in info.log
 INSTALL_TIME=$(timer)
 ELAPSED_INSTALL=$(timer $START_TIME)
 rm -rf $ISSM_DIR/dailylog
 mkdir  $ISSM_DIR/dailylog
-cat << END > $ISSM_DIR/dailylog/daily.log
+cat << END > $ISSM_DIR/dailylog/info.log
 today:     $(echo $TODAY)
 user:      $(echo $USER)
@@ -74,14 +82,67 @@
 END
 #}}}
+#check NUMCPUS_RUN options {{{1
+if [ "$NUMCPUS_RUN" = "" ]
+then
+	echo "NUMCPUS_RUN option not found, defaulting to NUMCPUS_RUN = 1"
+	NUMCPUS_RUN=1
+fi
+#}}}
 
 #Run tests
-#Call run.sh script{{{1
-cd $ISSM_DIR/scripts
-./run.sh
+#Launch all tests on different cpus {{{1
+for (( i=1;i<=$NUMCPUS_RUN;i++ ))
+do
+	#Launch matlab and the daily run script
+	cat > $ISSM_DIR/dailylog/matlab_run$i.m << EOF
+	warning off %necessary to avoid a info.log of several Go for parallel runs
+	try,
+	cd $ISSM_DIR/test/NightlyRun
+	startup;
+	$(if [ "$NROPTIONS" = ""  ]
+	then
+		echo "runme('output','daily','rank',$i,'numprocs',$NUMCPUS_RUN);"
+	else
+		echo "runme($NROPTIONS,'output','daily','rank',$i,'numprocs',$NUMCPUS_RUN);"
+	fi
+	)
+	catch me,
+		%An error occured, get report and exit
+		directory=strsplit(pwd,'/');
+		message=getReport(me)
+		fid=fopen([ISSM_DIR '/dailylog/matlaberror.log'], 'at');
+		fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end});
+		fprintf(fid,'%s',message);
+		fclose(fid);
+	end
+	exit
+EOF
+
+	#Start run from dailylog directory
+	cd $ISSM_DIR/dailylog/
+
+	#Start test
+	MATLAB_VERSION="7.6" #7.2,7.4,7.6 and 7.8
+	/usr/local/pkgs/matlab-$MATLAB_VERSION/bin/matlab  -nojvm -nosplash  -r matlab_run$i -logfile matlab_log$i.log &
+done
+
+#wait until matlab closes
+wait
 #}}}
-#Complete daily.log {{{1
+#concatenate all reports {{{1
+cd $ISSM_DIR/dailylog/
+mv matlab_log1.log  matlab_log.log
+for (( i=2;i<=$NUMCPUS_RUN;i++ ))
+do
+	cat matlab_log.log matlab_log$i.log > matlab_log.log.bak
+	mv matlab_log.log.bak matlab_log.log
+	rm matlab_log$i.log
+
+done
+#}}}
+#Complete info.log {{{1
 ELAPSED_RUN=$(timer $INSTALL_TIME)
 ELAPSED_TOTAL=$(timer $START_TIME)
-cat << END >>  $ISSM_DIR/dailylog/daily.log
+cat << END >>  $ISSM_DIR/dailylog/info.log
 elapsed_run:   $(echo $ELAPSED_RUN)
 elapsed_total: $(echo $ELAPSED_TOTAL)
@@ -92,6 +153,6 @@
 #Build html report {{{1
 cd $ISSM_DIR/dailylog/
-sh ../cron/report.sh
+sh ../scripts/report.sh
 ln -s $ISSM_DIR/dailylog/report.html $INIT_PATH
-echo "html report located in $ISSM_DIR/dailylog/report.html and $INIT_PATH"
+echo "html report located in $ISSM_DIR/dailylog/report.html and $INIT_PATH/report.html"
 #}}}
Index: /issm/trunk/scripts/report.sh
===================================================================
--- /issm/trunk/scripts/report.sh	(revision 5082)
+++ /issm/trunk/scripts/report.sh	(revision 5082)
@@ -0,0 +1,200 @@
+#!/bin/bash
+#generate html report from info.log output file
+
+#----------------------------#
+# Initialize local variables #
+#----------------------------#
+
+#process info.log
+TODAY=`     cat info.log | grep "today"           | awk '{printf("%s %s",$2,$3);}'`
+USER=`      cat info.log | grep "user"            | awk '{print $2}'`
+HOST_NAME=` cat info.log | grep "host"            | awk '{print $2}'`
+OS=`        cat info.log | grep "OS"              | awk '{print $2}'`
+RELEASE=`   cat info.log | grep "release"         | awk '{print $2}'`
+EL_INSTALL=`cat info.log | grep "elapsed_install" | awk '{print $2}'`
+EL_RUN=`    cat info.log | grep "elapsed_run"     | awk '{print $2}'`
+EL_TOTAL=`  cat info.log | grep "elapsed_total"   | awk '{print $2}'`
+
+#Process matlab_log.log
+cat matlab_log.log        | egrep 'ERROR|SUCCESS|FAILURE' | sed -e "s/>/\&gt;/g" | sed -e "s/</\&lt;/g" > matlab.log
+NUM_TOT=`wc -l matlab.log | awk '{print $1}'`
+NUM_ERR=`cat matlab.log | grep 'ERROR'   | grep -v "PETSC ERROR" | wc -l`
+NUM_SUC=`cat matlab.log | grep 'SUCCESS' | wc -l`
+NUM_FAI=`cat matlab.log | grep 'FAILURE' | wc -l`
+
+#style
+H1_STYLE='width="1000px" cellpadding="20"'
+H1_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-weight: bold; font-size:35px;" align="center"'
+
+H2_STYLE='width="900px" cellpadding="20"'
+H2_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:28px; font-weight: bold;" align="left"'
+
+TABLE_STYLE='width="800px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
+TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14; font-weight: normal;" align="left"'
+
+MATLAB_STYLE='width="1000px" rules=none'
+MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
+
+BODY_STYLE='width="800px"'
+BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
+
+FOOTER_STYLE='width="800px"  cellpadding="10"'
+FOOTER_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="center"'
+
+#style 2
+BODY_FONTC=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g"`
+BODY_FONTL=`echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:left; /g"`
+
+#create some variables
+if [ $(ls -1 $ISSM_DIR/bin | wc -l) -le 20 ];
+then
+	IS_INSTALL=0
+else
+	IS_INSTALL=1
+fi
+if [ $(wc -l matlab.log | awk '{printf("%s",$1);}')  -eq 0 ] 
+then
+	IS_RUN=0
+else
+	IS_RUN=1
+fi
+
+#-------------------#
+# build report.html #
+#-------------------#
+
+#first: summary
+cat << END > summary.html
+<div align="center">
+<table $H1_STYLE><tr><td $H1_FONT>ISSM Nightly run report</td></tr></table>
+
+<table $TABLE_STYLE>
+<tr> 
+<td $TABLE_FONT>host: $HOST_NAME</td>
+<td $TABLE_FONT>date: $TODAY</td>
+</tr>
+<tr>
+<td $TABLE_FONT>OS: $OS</td>
+<td $TABLE_FONT>user: $USER</td>
+</tr>
+<tr>
+<td $TABLE_FONT>status: STATUS</td>
+<td $TABLE_FONT>release: $RELEASE</td>
+</tr>
+<tr>
+<td $TABLE_FONT>number of success: $NUM_SUC/$NUM_TOT
+<td $TABLE_FONT>total elapsed time: $EL_TOTAL</td>
+</tr>
+<tr>
+<td $TABLE_FONT>number of errors: $NUM_ERR/$NUM_TOT
+
+<td $TABLE_FONT>installation elapsed time: $EL_INSTALL</td>
+</tr>
+<tr>
+<td $TABLE_FONT>number of failures: $NUM_FAI/$NUM_TOT
+<td $TABLE_FONT>execution elapsed time: $EL_RUN</td>
+</tr>
+</table>
+<br><hr width="1000px">
+END
+
+#update status
+if [ $IS_RUN -eq 1 ]
+then
+	cat summary.html | sed -e "s/STATUS/<span style=\"color:#008000\">all test desks have been run<\/span>/g" > summary2.html
+	mv summary2.html summary.html
+else
+	if [ $IS_INSTALL -eq 1 ]
+	then
+		cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation successful but tests runs failed<\/span>/g" > summary2.html
+		mv summary2.html summary.html
+	else
+		cat summary.html | sed -e "s/STATUS/<span style=\"color:#ff0000\">installation failed<\/span>/g" > summary2.html
+		mv summary2.html summary.html
+	fi
+fi
+
+
+#report table
+if [ $IS_RUN -eq 1 ];
+then
+	cat << END > content.html
+<table $(echo $H2_STYLE)><tr><td $(echo $H2_FONT)>List of tests</td></tr></table>
+<table $(echo $BODY_STYLE) style="border-collapse:collapse;">
+<tr> 
+<th $(echo $BODY_FONT)>Result</th> 
+<th $(echo $BODY_FONT)>Tolerance</th> 
+<th $(echo $BODY_FONT)>Test id</th>  
+<th $(echo $BODY_FONT)>Test name</th> 
+<th $(echo $BODY_FONT)>Field checked</th>
+</tr>
+$(cat matlab.log | while read line
+  do
+	  echo "<tr>"
+
+	  #get status
+	  STATUS=`echo $line | awk '{print $1}'`
+
+	  #FAILURE
+	  if [ "$STATUS" = "FAILURE" ]
+	  then
+
+		  FONTC=$(echo "$BODY_FONTC bgcolor=#ffff00");
+		  FONTL=$(echo "$BODY_FONTL bgcolor=#ffff00");
+		  echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
+		  { printf("<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n\n",FONTL,$1,FONTC,$3,FONTC,$6,FONTL,$9,FONTL,$11);}
+			  '; 
+
+		  else
+
+		  #SUCCESS
+		  if [ "$STATUS" = "SUCCESS" ]
+		  then
+			  color="bgcolor=#ddffdd";
+
+		  #ERROR
+		  else
+			  color="bgcolor=#ffdddd";
+		  fi
+
+		  FONTC=$(echo "$BODY_FONTC $color")
+		  FONTL=$(echo "$BODY_FONTL $color")
+		  echo $line | awk -v FONTC="$FONTC" -v FONTL="$FONTL" '
+		  { printf("<td %s>%s</td>\n<td %s>%s%s%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n<td %s>%s</td>\n\n",FONTL,$1,FONTL,$3,$4,$5,FONTC,$8,FONTL,$11,FONTL,$13);}
+			  '; 
+	  fi
+
+	  echo "</tr>"
+
+  done
+	  )
+</table>
+<br>
+END
+else
+	mktemp content.html
+fi
+
+#Matlab error report
+if [ -e matlaberror.log ]
+then
+	cat << END > matlaberror.html
+<table $H2_STYLE><tr><td $H2_FONT>Matlab error</td></tr></table>
+<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
+<pre>$(cat matlaberror.log)</pre>
+</td></tr></table>
+END
+else
+	mktemp matlaberror.html
+fi
+
+#last footer
+cat << END > footer.html
+<br>
+<table $FOOTER_STYLE><tr><td $FOOTER_FONT><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</td></tr></table>
+</div>
+END
+
+#concatenate files
+cat summary.html content.html matlaberror.html footer.html > report.html
+rm  summary.html content.html footer.html matlaberror.html matlab.log
