Index: issm/trunk/cron/nightlyrun.sh
===================================================================
--- issm/trunk/cron/nightlyrun.sh	(revision 11237)
+++ issm/trunk/cron/nightlyrun.sh	(revision 11995)
@@ -29,12 +29,22 @@
 {
 	#return host name depending on the OS
-	if [ "$1" = "wineric" ] 
+	if [ "$1" = "win7" ] 
 	then
-		HOST_NAME=`hostname`;
+		HOST_NAME=`hostname | sed 's/-//g'`;
 	else
-		HOST_NAME=`hostname -s`;
+		HOST_NAME=`hostname -s | sed 's/-//g'`;
 	fi
 	echo $HOST_NAME;
 } #}}}
+function pause() #{{{1
+{
+pid=`ps aux -W | grep $1 | awk '{printf("%s\n",$1);}'`
+
+while [ -n "$pid" ]
+do
+	pid=`ps aux -W | grep $1 | awk '{printf("%s\n",$1);}'`
+done
+}
+#}}}
 
 #Get configuration
@@ -74,5 +84,5 @@
 	#Erase previous code and Fetch the new one
 	rm -rf $ISSM_RELEASE
-	svn checkout $REPOSITORY
+	svn checkout "$REPOSITORY"
 
 elif [ "$ISSM_INSTALLATION" == "update" ]
@@ -100,9 +110,23 @@
 #create simpler  cluster.rc file, with only the cluster we are interested in.
 cd $ISSM_TIER/test/NightlyRun/
-cat << END > $HOST_NAME"_settings.m"
+if [ "$MACHINE" = "win7" ]; then
+	cat << END > $HOST_NAME"_settings.m"
+cluster.login='$USER';
+cluster.codepath='`cygpath -m $ISSM_TIER/bin`';
+cluster.executionpath='`cygpath -m $EXECUTION_PATH`';
+END
+else
+	cat << END > $HOST_NAME"_settings.m"
 cluster.login='$USER';
 cluster.codepath='$ISSM_TIER/bin';
 cluster.executionpath='$EXECUTION_PATH';
 END
+   cat << END > $ISSM_TIER/externalpackages/matlab/install.sh
+#!/bin/bash
+rm -rf install
+ln -s $MATLAB_PATH install
+END
+
+fi
 #}}}
 #Source environment variables with new matlab path {{{1
@@ -113,16 +137,16 @@
 if [ "$ISSM_EXTERNALPACKAGES" == "install" ]
 then
+	
 	cd $ISSM_TIER/externalpackages
-	for ep in $EXTERNALPACKAGES
-	do 
-		cd $ep
-		case $ep in
-			"mpich2" )   ./install-1.0.2-linux64.sh ;;
-			"petsc" )    ./install-3.2-linux64.sh   ;;
-			"metis" )    ./install-4.0-linux64.sh ;;
-			"triangle" ) ./install-linux64.sh ;;
-			"dakota" )   ./install-linux64-astrid.sh ;;
-			*)           ./install.sh $NUMCPUS_INSTALL
-		esac
+	#number of packages: 
+	numpackages=`echo $EXTERNALPACKAGES | wc -w`
+
+	for (( i=1; i<=$numpackages; i++ ))
+	do
+		package=`echo $EXTERNALPACKAGES | cut -d " " -f $i-$i`
+		package_config=`echo $EXTERNALPACKAGES_CONFIGS | cut -d " " -f $i-$i`
+
+		cd $package
+		$package_config
 		cd ..
 	done
@@ -136,4 +160,12 @@
 	cp -Rf $EXTERNALPACKAGESDIR ./
 
+elif [ "$ISSM_EXTERNALPACKAGES" == "link" ]
+then
+
+	#erase externapackages, and link with externalpackages_dir
+	cd $ISSM_TIER
+	rm -rf externalpackages
+	ln -s  $EXTERNALPACKAGESDIR  .
+
 elif [ "$ISSM_EXTERNALPACKAGES" == "none" ]
 then
@@ -158,18 +190,16 @@
 	make distclean
 	./scripts/automakererun.sh
-	./configs/config-linux64-astrid.sh
+	source ./configs/$COMPILE_CONFIG_FILE
 
 	#4: compile and install ISSM
-	if [ "$MACHINE" = "wineric" ] 
+	if [ $NUMCPUS_INSTALL -gt 1 ]
 	then
-		cd $ISSM_TIER/src/c
-		./intel-compile.sh
-		cd $ISSM_TIER/src/mex
+		echo "Making with " $NUMCPUS_INSTALL "cpus"
+		make -j $NUMCPUS_INSTALL install
+	else
 		make install
-		cd $ISSM_TIER
-	else
-		make -j $NUMCPUS_INSTALL
-		make -j $NUMCPUS_INSTALL install
 	fi
+
+	make install
 
 elif [ "$ISSM_COMPILATION" == "no" ]
@@ -185,5 +215,6 @@
 #create softlink to startup {{{1
 cd $ISSM_TIER/test/NightlyRun/
-ln -s $ISSM_TIER/startup.m .
+rm startup.m #in case it alreade exists
+cp $ISSM_TIER/startup.m .
 #}}}
 #Create nightlylog directory and info.log {{{1
@@ -212,4 +243,11 @@
 
 #Run tests
+#on Matlab and windows machines, we'll need a windows style path:  {{{
+if [ "$MACHINE" = "win7" ]; then
+	MATLAB_TIER=`cygpath -m $ISSM_TIER`
+else 
+	MATLAB_TIER=$ISSM_TIER
+fi
+#}}}
 #Launch all tests on different cpus {{{1
 for (( i=1;i<=$NUMCPUS_RUN;i++ ))
@@ -219,5 +257,5 @@
 	warning off %necessary to avoid a info.log of several Go for parallel runs
 	try,
-	cd $ISSM_TIER/test/NightlyRun
+	cd $MATLAB_TIER/test/NightlyRun
 	startup;
 	$(if [ "$NROPTIONS" = ""  ]
@@ -225,4 +263,5 @@
 		echo "runme('output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);"
 	else
+		#echo "runme('id',[101 102]);" 
 		echo "runme($NROPTIONS,'output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);"
 	fi
@@ -244,15 +283,21 @@
 	cd $ISSM_TIER/nightlylog/
 
+	MATLABBIN=$MATLAB_PATH/bin/matlab
 	#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 &
+	$MATLABBIN  -nojvm -nosplash  -r matlab_run$i -logfile matlab_log$i.log &
+
 done
 
 #wait until matlab closes
-wait
+if [ "$MACHINE" = "win7" ]; then
+	pause MATLAB
+else
+	wait
+fi
+
 #}}}
 #concatenate all reports {{{1
 cd $ISSM_TIER/nightlylog/
-mv matlab_log1.log  matlab_log.log
+cp matlab_log1.log  matlab_log.log
 for (( i=2;i<=$NUMCPUS_RUN;i++ ))
 do
@@ -290,7 +335,7 @@
 	for i in `echo $MAILINGLIST`; do
 
-		if [ "$MACHINE" = "wineric" ]
+		if [ "$MACHINE" = "win7" ]
 		then
-			email -html -f "ISSM Nightly run $EMAIL_ADRESS" -s "Nightly runs of $ISSM_RELEASE , configuration: $MACHINE, host: $HOST_NAME, user: $USER. " $i < $ISSM_TIER/test/Verification/NightlyRun/report.html
+			email -html -s "Nightly runs on $HOST_NAME (version: $ISSM_RELEASE)" -n "ISSM Nightly run" -f echo $EMAIL_ADRESS $i < $ISSM_TIER/nightlylog/report.html
 		else 
 			if [ "$MACHINE" = "astrid" ]
@@ -299,5 +344,5 @@
 From: "ISSM Nightly run" <$EMAIL_ADRESS>
 To: $i
-Subject: Nightly runs of $ISSM_RELEASE, configuration: $MACHINE, host: $HOST_NAME, user: $USER.
+Subject: Nightly runs on $HOST_NAME (version: $ISSM_RELEASE)
 Mime-Version: 1.0
 Content-Type: text/html
@@ -307,5 +352,5 @@
 From: "ISSM Nightly run" <$EMAIL_ADRESS>
 To: $i
-Subject: Nightly runs of $ISSM_RELEASE, configuration: $MACHINE, host: $HOST_NAME, user: $USER.
+Subject: Nightly runs on $HOST_NAME (version: $ISSM_RELEASE)
 Mime-Version: 1.0
 Content-Type: text/html
