Index: /issm/trunk-jpl/src/m/classes/clusters/discover.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/clusters/discover.m	(revision 20319)
+++ /issm/trunk-jpl/src/m/classes/clusters/discover.m	(revision 20320)
@@ -11,9 +11,10 @@
 		 name=oshostname();
 		 login='';
+		 modules        = {};
 		 numnodes=20;
 		 cpuspernode=8; 
 		 port=0;
 		 queue='general';
-		 time=12*60;
+		 time=12*60*60;
 		 processor='west';
 		 codepath='';
@@ -23,4 +24,5 @@
 		 numstreams=8;
 		 hyperthreading=0;
+		 email='';
 	 end
 	 %}}}
@@ -40,4 +42,5 @@
 			 disp(sprintf('    name: %s',cluster.name));
 			 disp(sprintf('    login: %s',cluster.login));
+			 disp(sprintf('    modules: %s',strjoin(cluster.modules,', ')));
 			 disp(sprintf('    port: %i',cluster.port));
 			 disp(sprintf('    numnodes: %i',cluster.numnodes));
@@ -51,4 +54,5 @@
 			 disp(sprintf('    interactive: %i',cluster.interactive));
 			 disp(sprintf('    hyperthreading: %i',cluster.hyperthreading));
+			 disp(sprintf('    email: %s',cluster.email));
 		 end
 		 %}}}
@@ -60,7 +64,7 @@
 		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 
-			 available_queues={'general_long','general','debug'};
-			 queue_requirements_time=[24*60 12*60 60];
-			 queue_requirements_np=[516 1024 32];
+			 available_queues={'long','general','debug'};
+			 queue_requirements_time=[24*60*60 12*60*60 60];
+			 queue_requirements_np=[4116 532 532];
 
 			 QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
@@ -71,10 +75,10 @@
 					 md = checkmessage(md,'cpuspernode should be between 1 and 16 for ''sand'' processors');
 				 end
-			 elseif strcmpi(cluster.processor,'west'),
-				 if ((cluster.cpuspernode>12 ) | (cluster.cpuspernode<1)),
-					 md = checkmessage(md,'cpuspernode should be between 1 and 12 for ''west'' processors');
-				 end
-			 else
-				 md = checkmessage(md,'unknown processor type, should be ''sand'' or ''west'' ');
+			 elseif strcmpi(cluster.processor,'hasw'),
+				 if ((cluster.cpuspernode>28 ) | (cluster.cpuspernode<1)),
+					 md = checkmessage(md,'cpuspernode should be between 1 and 28 for ''hasw'' processors');
+				 end
+			 else
+				 md = checkmessage(md,'unknown processor type, should be ''sand'' or ''hasw'' ');
 			 end
 
@@ -90,25 +94,31 @@
 			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
 
-			 %write queuing script 
+			 %write queuing script
 			 fid=fopen([modelname '.queue'],'w');
+
 			 fprintf(fid,'#!/bin/bash\n');
-%			 fprintf(fid,'#PBS -N %s\n',modelname);
-			 fprintf(fid,'#PBS -l select=%i:mpiprocs=%i:proc=%s\n',cluster.numnodes,cluster.cpuspernode,cluster.processor);
-			 fprintf(fid,'#PBS -l walltime=%i:00\n',cluster.time); %SLURM walltime is in minutes:
-			 if ~strcmp(cluster.queue,'general'),
-				 fprintf(fid,'#PBS -q %s \n',cluster.queue);
-			 end
-			 fprintf(fid,'#PBS -W group_list=s1010\n');
-			 fprintf(fid,'#PBS -m e\n');
-			 fprintf(fid,'#PBS -o %s.outlog \n',[cluster.executionpath '/' dirname '/' modelname]);
-			 fprintf(fid,'#PBS -e %s.errlog \n\n',[cluster.executionpath '/' dirname '/' modelname]);
+			 fprintf(fid,'#SBATCH -J %s \n',modelname);
+			 fprintf(fid,'#SBATCH --qos=%s \n',cluster.queue);
+			 fprintf(fid,'#SBATCH -o %s.outlog \n',modelname);
+			 fprintf(fid,'#SBATCH -e %s.errlog \n',modelname);
+			 fprintf(fid,'#SBATCH -n %i \n',cluster.numnodes*cluster.cpuspernode);
+			 fprintf(fid,'#SBATCH -N %i \n',cluster.numnodes);
+			 fprintf(fid,'#SBATCH -t %02i:%02i:00 \n',floor(cluster.time/3600),floor(mod(cluster.time,3600)/60));
+			 fprintf(fid,'#SBATCH -A s1010 \n\n');
+			 for i=1:numel(cluster.modules),
+				 fprintf(fid,['module load ' cluster.modules{i} '\n']);
+			 end
+			 if length(find(cluster.email=='@'))>0
+				 fprintf(fid,'#SBATCH --mail-user=%s \n',cluster.email);
+				 fprintf(fid,'#SBATCH --mail-type=end \n\n');
+			 end
 			 fprintf(fid,'. /usr/share/modules/init/bash\n\n');
-			 fprintf(fid,'module purge\n');
-			 fprintf(fid,'module load comp/intel-11.1.038\n');
+			 fprintf(fid,'module load comp/intel-15.0.0.090\n');
 			 fprintf(fid,'module load mpi/impi-4.0.3.008\n');
-			 fprintf(fid,'module load lib/mkl-10.1.2.024\n\n');
 			 fprintf(fid,'export PATH="$PATH:."\n\n');
-			 fprintf(fid,'export MPI_GROUP_MAX=64\n\n');
-			 fprintf(fid,'cd %s/%s/\n\n',cluster.executionpath,dirname);
+			 fprintf(fid,'export ISSM_DIR="%s/../"\n',cluster.codepath); %FIXME
+			 fprintf(fid,'source $ISSM_DIR/etc/environment.sh\n');       %FIXME
+			 fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,dirname);
+
 			 fprintf(fid,'mpirun -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),[cluster.executionpath '/' dirname],modelname);
 			 if ~io_gather, %concatenate the output files:
@@ -162,5 +172,5 @@
 		 end
 		 %}}}
-		 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart)% {{{
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist,restart,batch)% {{{
 
 			 if ~cluster.interactive, 
