Index: /issm/trunk/src/m/classes/public/queue/BuildQueueingScript.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/BuildQueueingScript.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/BuildQueueingScript.m	(revision 2880)
@@ -0,0 +1,23 @@
+function BuildQueueingScript(md,executionpath,codepath)
+%BUILDQUEUEINGSCRIPT - 
+%
+%   Usage:
+%      BuildQueueingScript(md,executionpath,codepath)
+
+disp('building queueing script');
+
+%First try and figure out if there is a special script for thie particular cluster
+function_name=['BuildQueueingScript' md.cluster];
+
+%some specific treatment of identical cluster, gemini, castor and pollux
+if strcmpi(md.cluster,'castor') || strcmpi(md.cluster,'pollux'),
+	function_name='BuildQueueingScriptgemini';
+end
+
+if exist(function_name,'file'),
+	%Call this function:
+	eval([function_name '(md,executionpath,codepath);']);
+else
+	%Call the generic BuildQueueingScript:
+	BuildQueueingScriptGeneric(md,executionpath,codepath);
+end
Index: /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptGeneric.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptGeneric.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptGeneric.m	(revision 2880)
@@ -0,0 +1,26 @@
+function BuildQueueingScriptGeneric(md,executionpath,codepath)
+%BUILDQUEUEINGSCRIPTGENERIC - ...
+%
+%   Usage:
+%      BuildQueueingScriptGeneric(md,executionpath,codepath)
+
+global ISSM_DIR
+
+%Open queuing script file 
+scriptname=[md.name '.queue'];
+
+fid=fopen(scriptname,'w');
+if fid==-1,
+	error(['BuildQueueingScriptGenericerror message: could not open ' scriptname ' file for ascii writing']);
+end
+
+fprintf(fid,'#!/bin/sh\n');
+fprintf(fid,'rm -rf %s/%s.lock\n',executionpath,md.name);
+
+if md.mem_debug==0,
+fprintf(fid,'mpirun -np %i %s/%s.exe %s %s.bin %s.outbin %s.lock  2> %s.errlog >%s.outlog & ',md.np,codepath,AnalysisTypeFromEnum(md.analysis_type),executionpath,md.name,md.name,md.name,md.name,md.name);
+else
+fprintf(fid,'LD_PRELOAD=%s mpirun -np %i %s --leak-check=full %s/%s.exe %s %s.bin %s.outbin %s.lock  2> %s.errlog >%s.outlog & ',[ISSM_DIR '/externalpackages/valgrind/install/lib/libmpidebug.so'],md.np,[ISSM_DIR '/externalpackages/valgrind/install/bin/valgrind'],codepath,AnalysisTypeFromEnum(md.analysis_type),executionpath,md.name,md.name,md.name,md.name,md.name);
+end
+
+fclose(fid);
Index: /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptcosmos.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptcosmos.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptcosmos.m	(revision 2880)
@@ -0,0 +1,65 @@
+function BuildQueueingScriptcosmos(md,executionpath,codepath)
+%BUILDQUEUEINGSCRIPTGEMINI - ...
+%
+%   Usage:
+%      BuildQueueingScriptcosmos(md,executionpath,codepath)
+
+scriptname=[md.name '.queue'];
+
+fid=fopen(scriptname,'w');
+if fid==-1,
+	error(['BuildQueueingScriptcosmos error message: could not open ' scriptname ' file for ascii writing']);
+end
+
+%check queue names: 
+available_queues={'debug','shortq','longq','specialq'};
+if  ~ismemberi(md.queue,available_queues),
+	error('BuildQueueingScriptcosmos error message: availables queues are debug, shortq, longq and specialq');
+end
+
+%test parameters for each queue: 
+if strcmpi(md.queue,'debug'),
+	if md.np>32,
+		error('BuildQueueingScriptcosmos error message: debug queue only allows 32 cpus');
+	end
+	if md.time>60,
+		error('BuildQueueingScriptcosmos error message: debug queue only allows 60 minutes');
+	end
+end
+
+if strcmpi(md.queue,'shortq'),
+	if md.np>128,
+		error('BuildQueueingScriptcosmos error message: shortq queue only allows 128 cpus');
+	end
+	if md.time>180,
+		error('BuildQueueingScriptcosmos error message: shortq queue only allows 180 minutes');
+	end
+end
+
+if strcmpi(md.queue,'longq'),
+	if md.np>128,
+		error('BuildQueueingScriptcosmos error message: longq queue only allows 128 cpus');
+	end
+	if md.time>720,
+		error('BuildQueueingScriptcosmos error message: longq queue only allows 720 minutes');
+	end
+end
+
+
+
+fprintf(fid,'#!/bin/bash\n');
+fprintf(fid,'#PBS -l select=%i:ncpus=1\n',md.np);
+fprintf(fid,'#PBS -l walltime=%i\n',md.time*60); %walltime is in seconds.
+if ~isempty(md.queue),
+	fprintf(fid,'#PBS -q %s\n',md.queue);
+end
+fprintf(fid,'#PBS -o %s.outlog \n',md.name);
+fprintf(fid,'#PBS -e %s.errlog \n',md.name);
+
+fprintf(fid,'export PBS_O_WORKDIR=%s\n',executionpath);
+fprintf(fid,'cd $PBS_O_WORKDIR\n');
+fprintf(fid,'export OMP_NUM_THREADS=1\n');
+fprintf(fid,'ulimit -s unlimited\n');
+fprintf(fid,'ulimit -c 0\n');
+fprintf(fid,'/opt/mpich/gm/intel10.1/bin/mpirun -np %i %s/%s.exe %s %s.bin %s.outbin %s.lock',md.np,codepath,AnalysisTypeFromEnum(md.analysis_type),executionpath,md.name,md.name,md.name);
+fclose(fid);
Index: /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptgemini.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptgemini.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptgemini.m	(revision 2880)
@@ -0,0 +1,81 @@
+function BuildQueueingScriptgemini(md,executionpath,codepath)
+%BUILDQUEUEINGSCRIPTGEMINI - ...
+%
+%   Usage:
+%      BuildQueueingScriptgemini(md,executionpath,codepath)
+
+scriptname=[md.name '.queue'];
+
+
+
+%check queue names: 
+if strcmpi(md.cluster,'gemini'),
+	available_queues={'debug','shortg','longg'};
+	if  ~ismemberi(md.queue,available_queues),
+		error('BuildQueueingScriptcosmos error message: availables queues are debug, shortg and longg');
+	end 
+
+	if strcmpi(md.queue,'debug'),
+		if md.np>50,
+			error('BuildQueueingScriptgeminierror error message: debug queue only allows for 50 cpus max');
+		end
+		
+		if md.time>60,
+			error('BuildQueueingScriptgeminierror error message: debug queue only allows for 60 minute runs');
+		end
+	end
+end
+
+if strcmpi(md.cluster,'castor'),
+	available_queues={'shortc','longc'};
+	if  ~ismemberi(md.queue,available_queues),
+		error('BuildQueueingScriptcosmos error message: availables queues are shortc and longc');
+	end 
+end
+
+if strcmpi(md.cluster,'pollux'),
+	available_queues={'shortp','longp'};
+	if  ~ismemberi(md.queue,available_queues),
+		error('BuildQueueingScriptcosmos error message: availables queues are shortp and longp');
+	end 
+end
+
+%test parameters valid for all queues
+if strcmpi(md.queue(1:5),'short'),
+	if md.np>128,
+		error('BuildQueueingScriptcosmos error message: short queue only allows 128 cpus');
+	end
+	if md.time>180,
+		error('BuildQueueingScriptcosmos error message: short queue only allows 180 minutes');
+	end
+end
+
+if strcmpi(md.queue(1:4),'long'),
+	if md.np>128,
+		error('BuildQueueingScriptcosmos error message: long queue only allows 128 cpus');
+	end
+	if md.time>720,
+		error('BuildQueueingScriptcosmos error message: long queue only allows 720 minutes');
+	end
+end
+
+fid=fopen(scriptname,'w');
+if fid==-1,
+	error(['BuildQueueingScriptgeminierror message: could not open ' scriptname ' file for ascii writing']);
+end
+
+fprintf(fid,'#!/bin/sh\n');
+fprintf(fid,'#PBS -l walltime=%i\n',md.time*60); %walltime is in seconds.
+fprintf(fid,'#PBS -l ncpus=%i\n',md.np);
+if ~isempty(md.queue),
+	fprintf(fid,'#PBS -q %s\n',md.queue);
+end
+fprintf(fid,'#PBS -o %s.outlog \n',md.name);
+fprintf(fid,'#PBS -e %s.errlog \n',md.name);
+
+fprintf(fid,'export PBS_O_WORKDIR=%s\n',executionpath);
+fprintf(fid,'cd $PBS_O_WORKDIR\n');
+fprintf(fid,'export OMP_NUM_THREADS=1\n');
+fprintf(fid,'dplace -s1 -c0-%i mpirun -np %i %s/%s.exe %s %s.bin %s.outbin %s.lock',md.np-1,md.np,codepath,AnalysisTypeFromEnum(md.analysis_type),executionpath,md.name,md.name,md.name);
+
+fclose(fid);
Index: /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptgreenplanet.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptgreenplanet.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/BuildQueueingScriptgreenplanet.m	(revision 2880)
@@ -0,0 +1,43 @@
+function BuildQueueingScriptgreenplanet(md,executionpath,codepath)
+%BUILDQUEUEINGSCRIPTGEMINI - ...
+%
+%   Usage:
+%      BuildQueueingScriptgreenplanet(md,executionpath,codepath)
+
+scriptname=[md.name '.queue'];
+
+%check queue names: 
+if strcmpi(md.cluster,'greenplanet'),
+	available_queues={'rignot','default'};
+	if  ~ismemberi(md.queue,available_queues),
+		error('BuildQueueingScriptgreenplanet error message: availables queues are rignot and default');
+	end 
+
+	if strcmpi(md.queue,'rignot'),
+		if md.np>80,
+			error('BuildQueueingScriptgreenplaneterror error message: debug queue only allows for 80 cpus max');
+		end
+		
+		if md.time>60,
+			error('BuildQueueingScriptgreenplaneterror error message: debug queue only allows for 60 minute runs');
+		end
+	end
+end
+
+fid=fopen(scriptname,'w');
+if fid==-1,
+	error(['BuildQueueingScriptgreenplaneterror message: could not open ' scriptname ' file for ascii writing']);
+end
+
+fprintf(fid,'#!/bin/csh\n');
+fprintf(fid,'#PBS -N %s\n',md.name);
+fprintf(fid,'#PBS -l nodes=%i:ppn=%i\n',md.np/8,8);
+fprintf(fid,'#PBS -q %s\n',md.queue);
+fprintf(fid,'#PBS -m bea\n');
+fprintf(fid,'#PBS -M eric.larour@jpl.nasa.gov\n');
+fprintf(fid,'#PBS -l walltime=%i\n',md.time*60); %walltime is in seconds.
+
+fprintf(fid,'cd $PBS_O_WORKDIR\n');
+fprintf(fid,'mpirun -machinefile $PBS_NODEFILE -np %i %s/%s.exe %s %s.bin %s.outbin %s.lock > %s.outlog',md.np,codepath,AnalysisTypeFromEnum(md.analysis_type),executionpath,md.name,md.name,md.name,md.name);
+
+fclose(fid);
Index: /issm/trunk/src/m/classes/public/queue/LaunchQueueJob.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/LaunchQueueJob.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/LaunchQueueJob.m	(revision 2880)
@@ -0,0 +1,21 @@
+function md=LaunchQueueJob(md,executionpath,options)
+%LAUNCHQUEUEJOB - ...
+%
+%   Usage:
+%      LaunchQueueJob(md,executionpath)
+
+%First try and figure out if there is a special script for thie particular cluster
+function_name=['LaunchQueueJob' md.cluster];
+
+%some specific treatment of identical cluster, gemini, castor and pollux
+if strcmpi(md.cluster,'castor') || strcmpi(md.cluster,'pollux'),
+	function_name='LaunchQueueJobgemini';
+end
+
+if exist(function_name,'file'),
+	%Call this function:
+	eval(['md=' function_name '(md,executionpath,options);']);
+else
+	%Call the generic LaunchQueueJob:
+	md=LaunchQueueJobGeneric(md,executionpath,options);
+end
Index: /issm/trunk/src/m/classes/public/queue/LaunchQueueJobGeneric.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/LaunchQueueJobGeneric.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/LaunchQueueJobGeneric.m	(revision 2880)
@@ -0,0 +1,34 @@
+function md=LaunchQueueJobGeneric(md,executionpath,options)
+%LAUNCHQUEUEJOBGENERIC - Generic routine to launch queueing job
+%
+%   Usage:
+%      LaunchQueueJobGeneric(md,executionpath)
+
+%first, check we have the binary file and the queueing script
+if ~exist([ md.name '.bin'],'file'),
+	error('LaunchQueueJobGeneric error message: Binary input file missing, cannot go forward');
+end
+
+if ~exist([ md.name '.queue'],'file'),
+	error('LaunchQueueJobGeneric error message: queueing script issing, cannot go forward');
+end
+
+if ~strcmpi(options.batch,'yes'),
+
+	%what files are we sending?
+	packages={[md.name '.bin'],[md.name '.queue']};
+	if md.qmu_analysis,
+		packages{end+1}=[md.name '.qmu.in'];
+	end
+
+	disp('uploading input file and queueing script');
+	scpout(md.cluster,executionpath,packages);
+	
+	disp('launching solution sequence on remote cluster');
+	issmssh(md.cluster,['cd ' executionpath ' && source ' md.name '.queue ']);
+
+else
+	disp('batch mode requested: not launching job interactively');
+	disp(['launch solution sequence by copying files ' md.name '.bin' ',' md.name '.queue and ' md.name '.qmu.in, onto remote cluster ' md.cluster]);
+	disp(['   then log int ' md.cluster ' and source queue file ' md.name '.queue']);
+end
Index: /issm/trunk/src/m/classes/public/queue/LaunchQueueJobcosmos.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/LaunchQueueJobcosmos.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/LaunchQueueJobcosmos.m	(revision 2880)
@@ -0,0 +1,32 @@
+function md=LaunchQueueJobcosmos(md,executionpath,options)
+%LAUNCHQUEUEJOBCOSMOS- Launch queue script for Cosmos cluster
+%
+%   Usage:
+%      LaunchQueueJobcosmos(md,executionpath)
+
+%first, check we have the binary file and the queueing script
+if ~exist([ md.name '.bin'],'file'),
+	error('LaunchQueueJobcosmos error message: Binary input file missing, cannot go forward');
+end
+
+if ~exist([ md.name '.queue'],'file'),
+	error('LaunchQueueJobcosmos error message: queueing script issing, cannot go forward');
+end
+
+%jpload both files to cluster
+if ~strcmpi(options.batch,'yes'),
+	disp('uploading input file,  queueing script and variables script');
+	if md.qmu_analysis, 
+		system(['scp ' md.name '.bin' ' ' md.name '.queue '  md.name '.qmu.in ' md.cluster ':' executionpath]);
+	else
+		system(['scp ' md.name '.bin' ' ' md.name '.queue '  md.cluster ':' executionpath]);
+	end
+
+	disp('launching solution sequence on remote cluster');
+	issmssh(md.cluster,['"cd ' executionpath ' && qsub -S/bin/sh ' md.name '.queue "']);
+else
+	disp('batch mode requested: not launching job interactively');
+
+	%new gemini cannot launch across cluster using ssh
+	disp(['launch solution sequence on remote cluster by logging into it and typing qsub -S/bin/sh ' md.name '.queue']);
+end
Index: /issm/trunk/src/m/classes/public/queue/LaunchQueueJobgemini.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/LaunchQueueJobgemini.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/LaunchQueueJobgemini.m	(revision 2880)
@@ -0,0 +1,32 @@
+function md=LaunchQueueJobgemini(md,executionpath,options)
+%LAUNCHQUEUEJOBGEMINI - Launch queueing script on Gemini cluster
+%
+%   Usage:
+%      LaunchQueueJobgemini(md,executionpath)
+
+%first, check we have the binary file and the queueing script
+if ~exist([ md.name '.bin'],'file'),
+	error('LaunchQueueJobgemini error message: Binary input file missing, cannot go forward');
+end
+
+if ~exist([ md.name '.queue'],'file'),
+	error('LaunchQueueJobgemini error message: queueing script issing, cannot go forward');
+end
+
+%jpload both files to cluster
+if ~strcmpi(options.batch,'yes'),
+	disp('uploading input file,  queueing script and variables script');
+	if md.qmu_analysis, 
+		system(['scp ' md.name '.bin' ' ' md.name '.queue '  md.name '.qmu.in ' md.cluster ':' executionpath]);
+	else
+		system(['scp ' md.name '.bin' ' ' md.name '.queue '  md.cluster ':' executionpath]);
+	end
+	
+	disp('launching solution sequence on remote cluster');
+	issmssh(md.cluster,['"cd ' executionpath ' && qsub ' md.name '.queue "']);
+else
+	disp('batch mode requested: not launching job interactively');
+
+	%new gemini cannot launch across cluster using ssh
+	disp(['launch solution sequence on remote cluster by logging into it and typing qsub < ' md.name '.queue']);
+end
Index: /issm/trunk/src/m/classes/public/queue/LaunchQueueJobgreenplanet.m
===================================================================
--- /issm/trunk/src/m/classes/public/queue/LaunchQueueJobgreenplanet.m	(revision 2880)
+++ /issm/trunk/src/m/classes/public/queue/LaunchQueueJobgreenplanet.m	(revision 2880)
@@ -0,0 +1,29 @@
+function md=LaunchQueueJobgreenplanet(md,executionpath,options)
+%LAUNCHQUEUEJOBGEMINI - ...
+%
+%   Usage:
+%      LaunchQueueJobgreenplanet(md,executionpath)
+
+%first, check we have the binary file and the queueing script
+if ~exist([ md.name '.bin'],'file'),
+	error('LaunchQueueJobgreenplanet error message: Binary input file missing, cannot go forward');
+end
+
+if ~exist([ md.name '.queue'],'file'),
+	error('LaunchQueueJobgreenplanet error message: queueing script issing, cannot go forward');
+end
+
+%jpload both files to cluster
+if ~strcmpi(options.batch,'yes'),
+	disp('uploading input file,  queueing script and variables script');
+	if md.qmu_analysis, 
+		system(['scp -P 1025 -o HostKeyAlias=huey.jpl.nasa.gov ' md.name '.bin' ' ' md.name '.queue '  md.name '.qmu.in elarour@localhost:' executionpath]);
+	else
+		system(['scp -P 1025 -o HostKeyAlias=huey.jpl.nasa.gov ' md.name '.bin' ' ' md.name '.queue elarour@localhost:' executionpath ]);
+	end
+else
+	disp('batch mode requested: not launching job interactively');
+end
+
+%new greenplanet cannot launch across cluster using ssh
+disp(['launch solution sequence on remote cluster by logging into it and typing qsub < ' md.name '.queue']);
