Index: sm/trunk-jpl/src/m/model/WriteData.m
===================================================================
--- /issm/trunk-jpl/src/m/model/WriteData.m	(revision 13003)
+++ 	(revision )
@@ -1,260 +1,0 @@
-function WriteData(fid,varargin)
-%WRITEDATA - write model field in binary file
-%
-%   Usage:
-%      WriteData(fid,varargin);
-
-%process options
-options=pairoptions(varargin{:});
-
-%Get data properties
-if exist(options,'object');
-	%This is a object field, construct enum and data
-	obj       = getfieldvalue(options,'object');
-	fieldname = getfieldvalue(options,'fieldname');
-	classname = class(obj);
-
-	enum      = BuildEnum([classname '_' fieldname]);
-	data      = obj.(fieldname);
-else
-	%No processing required
-	data = getfieldvalue(options,'data');
-	enum = getfieldvalue(options,'enum');
-end
-format  = getfieldvalue(options,'format');
-mattype = getfieldvalue(options,'mattype',0);    %only required for matrices
-
-%Process sparse matrices
-if issparse(data),
-	data=full(data);
-end
-
-%Step 1: write the enum to identify this record uniquely
-fwrite(fid,enum,'int'); 
-
-%Step 2: write the data itself.
-if     strcmpi(format,'Boolean'),% {{{
-	if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
-
-	%first write length of record
-	fwrite(fid,4+4,'int');  %1 bool (disguised as an int)+code
-
-	%write data code: 
-	fwrite(fid,FormatToCode(format),'int'); 
-
-	%now write integer
-	fwrite(fid,data,'int');  %send an int, not easy to send a bool
-	% }}}
-elseif strcmpi(format,'Integer'), % {{{
-	if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
-
-	%first write length of record
-	fwrite(fid,4+4,'int');  %1 integer + code
-
-	%write data code: 
-	fwrite(fid,FormatToCode(format),'int'); 
-
-	%now write integer
-	fwrite(fid,data,'int'); 
-	% }}}
-elseif strcmpi(format,'Double'), % {{{
-	if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
-
-	%first write length of record
-	fwrite(fid,8+4,'int');  %1 double+code
-
-	%write data code: 
-	fwrite(fid,FormatToCode(format),'int'); 
-
-	%now write double
-	fwrite(fid,data,'double'); 
-	% }}}
-elseif strcmpi(format,'String'), % {{{
-	%first write length of record
-	fwrite(fid,length(data)+4+4,'int');  %string + string size + code
-
-	%write data code: 
-	fwrite(fid,FormatToCode(format),'int'); 
-
-	%now write string
-	fwrite(fid,length(data),'int'); 
-	fwrite(fid,data,'char'); 
-	% }}}
-elseif strcmpi(format,'BooleanMat'), % {{{
-
-	%Get size
-	s=size(data);
-	%if matrix = NaN, then do not write anything
-	if (s(1)==1 & s(2)==1 & isnan(data)),
-		s(1)=0; s(2)=0;
-	end
-
-	%first write length of record
-	fwrite(fid,4+4+8*s(1)*s(2)+4+4,'int');  %2 integers (32 bits) + the double matrix + code + matrix type
-
-	%write data code and matrix type: 
-	fwrite(fid,FormatToCode(format),'int'); 
-	fwrite(fid,mattype,'int');
-
-	%now write matrix
-	fwrite(fid,s(1),'int'); 
-	fwrite(fid,s(2),'int'); 
-	if s(1)*s(2),
-		fwrite(fid,data','double'); %get to the "c" convention, hence the transpose
-	end
-	% }}}
-elseif strcmpi(format,'IntMat'), % {{{
-
-	%Get size
-	s=size(data);
-	%if matrix = NaN, then do not write anything
-	if (s(1)==1 & s(2)==1 & isnan(data)),
-		s(1)=0; s(2)=0;
-	end
-
-	%first write length of record
-	fwrite(fid,4+4+8*s(1)*s(2)+4+4,'int');  %2 integers (32 bits) + the double matrix + code + matrix type
-
-	%write data code and matrix type: 
-	fwrite(fid,FormatToCode(format),'int'); 
-	fwrite(fid,mattype,'int');
-
-	%now write matrix
-	fwrite(fid,s(1),'int'); 
-	fwrite(fid,s(2),'int'); 
-	if s(1)*s(2),
-		fwrite(fid,data','double'); %get to the "c" convention, hence the transpose
-	end
-	% }}}
-elseif strcmpi(format,'DoubleMat'), % {{{
-
-	%Get size
-	s=size(data);
-	%if matrix = NaN, then do not write anything
-	if (s(1)==1 & s(2)==1 & isnan(data)),
-		s(1)=0; s(2)=0;
-	end
-
-	%first write length of record
-	fwrite(fid,4+4+8*s(1)*s(2)+4+4,'int');  %2 integers (32 bits) + the double matrix + code + matrix type
-
-	%write data code and matrix type: 
-	fwrite(fid,FormatToCode(format),'int'); 
-	fwrite(fid,mattype,'int');
-
-	%now write matrix
-	fwrite(fid,s(1),'int'); 
-	fwrite(fid,s(2),'int'); 
-	if s(1)*s(2),
-		fwrite(fid,data','double'); %get to the "c" convention, hence the transpose
-	end
-	% }}}
-elseif strcmpi(format,'MatArray'), % {{{
-
-	numrecords=numel(data);
-
-	%first get length of record
-	recordlength=4+4; %number of records + code
-	for i=1:numrecords,
-		matrix=data{i};
-		s=size(matrix);
-		recordlength=recordlength+4*2+... %row and col of matrix
-			s(1)*s(2)*8; %matrix of doubles
-	end
-
-	%write length of record
-	fwrite(fid,recordlength,'int'); 
-
-	%write data code: 
-	fwrite(fid,FormatToCode(format),'int'); 
-
-	%write data, first number of records
-	fwrite(fid,numrecords,'int'); 
-
-	%write each matrix: 
-	for i=1:numrecords,
-		matrix=data{i};
-		s=size(matrix);
-		fwrite(fid,s(1),'int'); 
-		fwrite(fid,s(2),'int'); 
-		fwrite(fid,matrix','double');
-	end
-	% }}}
-elseif strcmpi(format,'StringArray'), % {{{
-
-	%first get length of string array: 
-	num=numel(data);
-	%now get length of record: 
-	recordlength=4+4; %for length of array + code
-	for i=1:num,
-		string=data{i};
-		recordlength=recordlength+4+length(string); %for each string
-	end
-
-	%write length of record
-	fwrite(fid,recordlength,'int'); 
-
-	%write data code: 
-	fwrite(fid,FormatToCode(format),'int'); 
-
-	%now write length of string array
-	fwrite(fid,num,'int'); 
-
-	%now write the strings
-	for i=1:num,
-		string=data{i};
-		fwrite(fid,length(string),'int'); 
-		fwrite(fid,string,'char'); 
-	end
-	% }}}
-else  % {{{
-	error(['WriteData error message: data type: ' num2str(format) ' not supported yet! (' EnumToString(enum) ')']);
-end % }}}
-end
-
-function enum=BuildEnum(string) % {{{
-%BUILDENUM - build enum out of string
-%
-%   Usage:
-%      enum=BuildEnum(string)
-
-	if findstr(string,'_'),
-		indices=findstr(string,'_');
-		for i=1:length(indices),
-			string(indices(i)+1)=upper(string(indices(i)+1));
-		end
-		string(indices)=[];
-	end
-
-	%take first letter of string and make it uppercase: 
-	string(1)=upper(string(1));
-
-	%Get Enum
-	enum=eval([string 'Enum();']); 
-end % }}}
-function code=FormatToCode(format) % {{{
-%This routine takes the format string, and hardcodes it into an integer, which 
-%is passed along the record, in order to identify the nature of the dataset being 
-%sent.
-	if     strcmpi(format,'Boolean'),
-		code=1;
-	elseif strcmpi(format,'Integer'), 
-		code=2;
-	elseif strcmpi(format,'Double'), 
-		code=3;
-	elseif strcmpi(format,'String'), 
-		code=4;
-	elseif strcmpi(format,'BooleanMat'),
-		code=5;
-	elseif strcmpi(format,'IntMat'),
-		code=6;
-	elseif strcmpi(format,'DoubleMat'),
-		code=7;
-	elseif strcmpi(format,'MatArray'), 
-		code=8;
-	elseif strcmpi(format,'StringArray'),
-		code=9;
-	else 
-		error('FormatToCode error message: data type not supported yet!');
-	end
-end% }}}
Index: sm/trunk-jpl/src/m/model/WriteData.py
===================================================================
--- /issm/trunk-jpl/src/m/model/WriteData.py	(revision 13003)
+++ 	(revision )
@@ -1,274 +1,0 @@
-import numpy
-import math
-import struct
-from MatlabFuncs import *
-
-def WriteData(fid,*args):
-	"""
-	WRITEDATA - write model field in binary file
- 
-	   Usage:
-	      WriteData(fid,varargin)
-	"""
-
-	#process options
-	options=pairoptions(*args)
-
-	#Get data properties
-	if options.exist('object'):
-		#This is an object field, construct enum and data
-		obj       = options.getfieldvalue('object')
-		fieldname = options.getfieldvalue('fieldname')
-		classname = type(obj)
-
-		enum      = BuildEnum(classname+'_'+fieldname)
-		data      = getattr(obj,fieldname)
-	else:
-		#No processing required
-		data = options.getfieldvalue('data')
-		enum = options.getfieldvalue('enum')
-	format  = options.getfieldvalue('format')
-	mattype = options.getfieldvalue('mattype',0)    #only required for matrices
-
-	#Process sparse matrices
-#	if issparse(data),
-#		data=full(data);
-#	end
-
-	#Step 1: write the enum to identify this record uniquely
-	fid.write(struct.pack('i',enum)) 
-
-	#Step 2: write the data itself.
-	if   strcmpi(format,'Boolean'):    # {{{
-		if len(data) !=1:
-			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
-
-		#first write length of record
-		fid.write(struct.pack('i',4+4))  #1 bool (disguised as an int)+code
-
-		#write data code: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-
-		#now write integer
-		fid.write(struct.pack('i',data))  #send an int, not easy to send a bool
-		# }}}
-
-	elif strcmpi(format,'Integer'):    # {{{
-		if len(data) !=1:
-			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
-
-		#first write length of record
-		fid.write(struct.pack('i',4+4))  #1 integer + code
-
-		#write data code: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-
-		#now write integer
-		fid.write(struct.pack('i',data)) 
-		# }}}
-
-	elif strcmpi(format,'Double'):    # {{{
-		if len(data) !=1:
-			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
-
-		#first write length of record
-		fid.write(struct.pack('i',8+4))  #1 double+code
-
-		#write data code: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-
-		#now write double
-		fid.write(struct.pack('d',data)) 
-		# }}}
-
-	elif strcmpi(format,'String'):    # {{{
-		#first write length of record
-		fid.write(struct.pack('i',len(data)+4+4))  #string + string size + code
-
-		#write data code: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-
-		#now write string
-		fid.write(struct.pack('i',len(data))) 
-		fid.write(struct.pack('%ds' % len(data),data)) 
-		# }}}
-
-	elif strcmpi(format,'BooleanMat'):    # {{{
-
-		#Get size
-		s=data.shape
-		#if matrix = NaN, then do not write anything
-		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
-			s[0]=0
-			s[1]=0
-
-		#first write length of record
-		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
-
-		#write data code and matrix type: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-		fid.write(struct.pack('i',mattype))
-
-		#now write matrix
-		fid.write(struct.pack('i',s[0])) 
-		fid.write(struct.pack('i',s[1])) 
-		for i in xrange(s[0]):
-			for j in xrange(s[1]):
-				fid.write(struct.pack('i',data[i][j]))    #get to the "c" convention, hence the transpose
-		# }}}
-
-	elif strcmpi(format,'IntMat'):    # {{{
-
-		#Get size
-		s=data.shape
-		#if matrix = NaN, then do not write anything
-		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
-			s[0]=0
-			s[1]=0
-
-		#first write length of record
-		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
-
-		#write data code and matrix type: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-		fid.write(struct.pack('i',mattype))
-
-		#now write matrix
-		fid.write(struct.pack('i',s[0])) 
-		fid.write(struct.pack('i',s[1])) 
-		for i in xrange(s[0]):
-			for j in xrange(s[1]):
-				fid.write(struct.pack('i',data[i][j]))    #get to the "c" convention, hence the transpose
-		# }}}
-
-	elif strcmpi(format,'DoubleMat'):    # {{{
-
-		#Get size
-		s=data.shape
-		#if matrix = NaN, then do not write anything
-		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
-			s[0]=0
-			s[1]=0
-
-		#first write length of record
-		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
-
-		#write data code and matrix type: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-		fid.write(struct.pack('i',mattype))
-
-		#now write matrix
-		fid.write(struct.pack('i',s[0])) 
-		fid.write(struct.pack('i',s[1])) 
-		for i in xrange(s[0]):
-			for j in xrange(s[1]):
-				fid.write(struct.pack('d',data[i][j]))    #get to the "c" convention, hence the transpose
-		# }}}
-
-	elif strcmpi(format,'MatArray'):    # {{{
-
-		#first get length of record
-		recordlength=4+4    #number of records + code
-		for matrix in data:
-			s=matrix.shape
-			recordlength+=4*2+s[0]*s[1]*8    #row and col of matrix + matrix of doubles
-
-		#write length of record
-		fid.write(struct.pack('i',recordlength)) 
-
-		#write data code: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-
-		#write data, first number of records
-		fid.write(struct.pack('i',len(data))) 
-
-		#write each matrix: 
-		for matrix in data:
-			s=matrix.shape
-			fid.write(struct.pack('i',s[0])) 
-			fid.write(struct.pack('i',s[1])) 
-			for i in xrange(s[0]):
-				for j in xrange(s[1]):
-					fid.write(struct.pack('d',matrix[i][j]))
-		# }}}
-
-	elif strcmpi(format,'StringArray'):    # {{{
-
-		#first get length of record
-		recordlength=4+4    #for length of array + code
-		for string in data:
-			recordlength+=4+len(string)    #for each string
-
-		#write length of record
-		fid.write(struct.pack('i',recordlength)) 
-
-		#write data code: 
-		fid.write(struct.pack('i',FormatToCode(format))) 
-
-		#now write length of string array
-		fid.write(struct.pack('i',len(data))) 
-
-		#now write the strings
-		for string in data:
-			fid.write(struct.pack('i',len(string))) 
-			fid.write(struct.pack('%ds' % len(string),string)) 
-		# }}}
-
-	else:    # {{{
-		raise TypeError('WriteData error message: data type: %d not supported yet! (%s)' % (format,EnumToString(enum)))
-	# }}}
-
-def BuildEnum(string): # {{{
-	"""
-	BUILDENUM - build enum out of string
- 
-    Usage:
-       enum=BuildEnum(string)
-	"""
-
-	if '_' in string:
-		substrs=string.split('_')
-		string=''
-		for str in substrs:
-			string+=str[0].upper()+str[1:]
-	else:
-		#take first letter of string and make it uppercase: 
-		string=str[0].upper()+str[1:]
-
-	#Get Enum
-	exec('enum='+string+'Enum()',globals())
-
-	return enum
-# }}}
-
-def FormatToCode(format): # {{{
-	"""
-	This routine takes the format string, and hardcodes it into an integer, which 
-	is passed along the record, in order to identify the nature of the dataset being 
-	sent.
-	"""
-
-	if   strcmpi(format,'Boolean'):
-		code=1
-	elif strcmpi(format,'Integer'):
-		code=2
-	elif strcmpi(format,'Double'):
-		code=3
-	elif strcmpi(format,'String'):
-		code=4
-	elif strcmpi(format,'BooleanMat'):
-		code=5
-	elif strcmpi(format,'IntMat'):
-		code=6
-	elif strcmpi(format,'DoubleMat'):
-		code=7
-	elif strcmpi(format,'MatArray'):
-		code=8
-	elif strcmpi(format,'StringArray'):
-		code=9
-	else:
-		raise InputError('FormatToCode error message: data type not supported yet!')
-
-	return code
-# }}}
-
Index: sm/trunk-jpl/src/m/model/ismodelselfconsistent.m
===================================================================
--- /issm/trunk-jpl/src/m/model/ismodelselfconsistent.m	(revision 13003)
+++ 	(revision )
@@ -1,40 +1,0 @@
-function ismodelselfconsistent(md),
-%ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
-%
-%   Usage:
-%      ismodelselfconsistent(md),
-
-%initialize consistency as true
-md.private.isconsistent=true;
-
-%Get solution and associated analyses
-solution=md.private.solution;
-[analyses,numanalyses]=AnalysisConfiguration(solution);
-
-%Go through a model field, check that it is a class, and call checkconsistency
-fields=properties('model');
-for i=1:length(fields),
-	field=fields{i};
-
-	%Some properties do not need to be checked
-	if ismember(field,{'results' 'debug' 'radaroverlay'}),
-		continue;
-	end
-
-	%Check that current field is an object
-	if ~isobject(md.(field))
-		md=checkmessage(md,['field ''' char(field) ''' is not an object']);
-	end
-
-	%Check consistency of the object
-	if verLessThan('matlab', '7.6')
-		md=checkconsistency(md.(field),md,solution,analyses);
-	else
-		md=md.(field).checkconsistency(md,solution,analyses);
-	end
-end
-
-%error message if mode is not consistent
-if md.private.isconsistent==false,
-	error('Model not consistent, see messages above');
-end
Index: sm/trunk-jpl/src/m/model/ismodelselfconsistent.py
===================================================================
--- /issm/trunk-jpl/src/m/model/ismodelselfconsistent.py	(revision 13003)
+++ 	(revision )
@@ -1,36 +1,0 @@
-from AnalysisConfiguration import *
-
-def ismodelselfconsistent(md):
-	"""
-	ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
-
-	   Usage:
-	      ismodelselfconsistent(md),
-	"""
-
-	#initialize consistency as true
-	md.private.isconsistent=True
-
-	#Get solution and associated analyses
-	solution=md.private.solution
-	analyses,numanalyses=AnalysisConfiguration(solution)
-
-	#Go through a model fields, check that it is a class, and call checkconsistency
-	fields=vars(md)
-	for field in fields.iterkeys():
-
-		#Some properties do not need to be checked
-		if field in ['results','debug','radaroverlay']:
-			continue
-
-		#Check that current field is an object
-		if not hasattr(getattr(md,field),'checkconsistency'):
-			md.checkmessage("field '%s' is not an object." % field)
-
-		#Check consistency of the object
-		exec("md.%s.checkconsistency(md,solution,analyses)" % field)
-
-	#error message if mode is not consistent
-	if not md.private.isconsistent:
-		raise RuntimeError('Model not consistent, see messages above.')
-
Index: sm/trunk-jpl/src/m/model/loadmultipleresultsfromcluster.m
===================================================================
--- /issm/trunk-jpl/src/m/model/loadmultipleresultsfromcluster.m	(revision 13003)
+++ 	(revision )
@@ -1,34 +1,0 @@
-function md_list=loadmultipleresultsfromcluster(md_list)
-%LOADMULTIPLERESULTSFROMCLUSTER - load multiple results of solution sequences from cluster
-%
-%   Usage:
-%      md_list=loadresultsfromcluster(md_list);
-
-nummodels=length(md_list);
-
-%Get cluster settings
-cluster=md_list{1}.cluster;
-name=md_list{1}.name;
-cluster_rc_location=which('cluster.rc');
-[codepath,executionpath,login]=ClusterParameters(cluster,cluster_rc_location);
-
-%Remote tar: 
-disp('tarring results');
-issmssh(cluster,['"cd ' executionpath ' && rm -rf file_list.txt ModelResults.tar.gz && find -iname ''*_*vs*.outbin'' > file_list.txt && tar zcvf ModelResults.tar.gz --files-from file_list.txt  && rm -rf file_list.txt "']);
-
-%copy results from cluster to present directory
-scpin(cluster, executionpath, {'ModelResults.tar.gz'});
-
-%untar:
-!tar -zxvf ModelResults.tar.gz
-
-%ok, go through list and load results from disk: 
-for i=1:nummodels,
-	%load  results for this model
-	md_list{i}=loadresultsfromdisk(md_list{i},[md_list{i}.name '.outbin']);
-
-	delete([name '.outbin']);
-end
-
-%erase files 
-delete('ModelResults.tar.gz');
Index: sm/trunk-jpl/src/m/model/loadresultsfromcluster.m
===================================================================
--- /issm/trunk-jpl/src/m/model/loadresultsfromcluster.m	(revision 13003)
+++ 	(revision )
@@ -1,60 +1,0 @@
-function md=loadresultsfromcluster(md,runtimename)
-%LOADRESULTSFROMCLUSTER - load results of solution sequence from cluster
-%
-%   Usage:
-%      md=loadresultsfromcluster(md,runtimename);
-
-%retrieve cluster, to be able to call its methods
-cluster=md.cluster;
-
-if nargin==2,
-	md.private.runtimename=runtimename;
-end
-
-%Download outputs from the cluster
-filelist={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-if md.qmu.isdakota,
-	filelist{end+1}=[md.miscellaneous.name '.qmu.err'];
-	filelist{end+1}=[md.miscellaneous.name '.qmu.out'];
-	if isfield(md.qmu.params,'tabular_graphics_data'),
-		if md.qmu.params.tabular_graphics_data==true,
-			filelist{end+1}='dakota_tabular.dat';
-		end
-	end
-else
-	filelist{end+1}=[md.miscellaneous.name '.outbin'];
-end
-Download(cluster,md.private.runtimename,filelist);
-
-%If we are here, no errors in the solution sequence, call loadresultsfromdisk.
-md=loadresultsfromdisk(md,[md.miscellaneous.name '.outbin']);
-
-%erase the log and output files
-if md.qmu.isdakota,
-	delete([['qmu' num2str(feature('GetPid')) '/'] md.miscellaneous.name '.outlog']);
-	delete([['qmu' num2str(feature('GetPid')) '/']  md.miscellaneous.name '.errlog']);
-else
-	delete([md.miscellaneous.name '.outlog']);
-	delete([md.miscellaneous.name '.errlog']);
-	delete([md.miscellaneous.name '.outbin']);
-	if ~ispc,
-		delete([md.private.runtimename '.tar.gz']);
-	end
-end
-
-%erase input file if run was carried out on same platform.
-hostname=oshostname();
-if strcmpi(hostname,cluster.name),
-	if md.qmu.isdakota,
-		delete([['qmu' num2str(feature('GetPid')) '/'] md.miscellaneous.name '.bin']);
-		delete([['qmu' num2str(feature('GetPid')) '/'] md.miscellaneous.name '.queue']);
-	else
-		delete([md.miscellaneous.name '.bin']);
-		delete([md.miscellaneous.name '.petsc']);
-		if ~ispc,
-			delete([md.miscellaneous.name '.queue']);
-		else
-			delete([md.miscellaneous.name '.bat']);
-		end
-	end
-end
Index: sm/trunk-jpl/src/m/model/loadresultsfromcluster.py
===================================================================
--- /issm/trunk-jpl/src/m/model/loadresultsfromcluster.py	(revision 13003)
+++ 	(revision )
@@ -1,61 +1,0 @@
-import os
-import platform
-import socket
-from MatlabFuncs import *
-
-def loadresultsfromcluster(md,runtimename=False):
-	"""
-	LOADRESULTSFROMCLUSTER - load results of solution sequence from cluster
- 
-	   Usage:
-	      md=loadresultsfromcluster(md,runtimename);
-	"""
-
-	#retrieve cluster, to be able to call its methods
-	cluster=md.cluster
-
-	if runtimename:
-		md.private.runtimename=runtimename
-	end
-
-	#Download outputs from the cluster
-	filelist=[md.miscellaneous.name+'.outlog',md.miscellaneous.name+'.errlog']
-	if md.qmu.isdakota:
-		filelist.append(md.miscellaneous.name+'.qmu.err')
-		filelist.append(md.miscellaneous.name+'.qmu.out')
-		if 'tabular_graphics_data' in md.qmu.params:
-			if md.qmu.params['tabular_graphics_data']:
-				filelist.append('dakota_tabular.dat')
-		filelist.append(md.miscellaneous.name+'.outbin')
-	Download(cluster,md.private.runtimename,filelist)
-
-	#If we are here, no errors in the solution sequence, call loadresultsfromdisk.
-	md=loadresultsfromdisk(md,md.miscellaneous.name+'.outbin')
-
-	#erase the log and output files
-	if md.qmu.isdakota:
-		os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.outlog'))
-		os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.errlog'))
-	else:
-		os.remove(md.miscellaneous.name+'.outlog')
-		os.remove(md.miscellaneous.name+'.errlog')
-		os.remove(md.miscellaneous.name+'.outbin')
-		if not 'Windows' in platform.system():
-			os.remove(md.private.runtimename+'.tar.gz')
-
-	#erase input file if run was carried out on same platform.
-	hostname=socket.gethostname().lower().split('.')[0]
-	if strcmpi(hostname,cluster.name):
-		if md.qmu.isdakota:
-			os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.bin'))
-			os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.queue'))
-		else:
-			os.remove(md.miscellaneous.name+'.bin')
-			os.remove(md.miscellaneous.name+'.petsc')
-			if not 'Windows' in platform.system():
-				os.remove(md.miscellaneous.name+'.queue')
-			else:
-				os.remove(md.miscellaneous.name+'.bat')
-
-	return md
-
Index: sm/trunk-jpl/src/m/model/loadresultsfromdisk.m
===================================================================
--- /issm/trunk-jpl/src/m/model/loadresultsfromdisk.m	(revision 13003)
+++ 	(revision )
@@ -1,61 +1,0 @@
-function md=loadresultsfromdisk(md,filename)
-%LOADRESULTSFROMDISK - load results of solution sequence from disk file "filename"            
-%
-%   Usage:
-%      md=loadresultsfromdisk(md,filename);
-
-%check number of inputs/outputs
-if ((nargin~=2) | (nargout~=1)),
-	help loadresultsfromdisk;
-	error('loadresultsfromdisk: error message.');
-end
-
-if ~md.qmu.isdakota,
-
-	%Check that file exists
-	if ~exist(filename,'file'),
-		error(['binary file ' filename ' not found.']);
-	end
-
-	%initialize md.results if not a structure yet
-	if ~isstruct(md.results),
-		md.results=struct();
-	end
-
-	%load results onto model
-	structure=parseresultsfromdisk(filename,~md.settings.io_gather);
-	if isempty(fieldnames(structure)),
-		error(['No result found in binary file ' filename '. Check for solution crash.']);
-	end
-	md.results.(structure(1).SolutionType)=structure;
-
-	%recover solution_type from results
-	md.private.solution=structure(1).SolutionType;
-
-	%read log files onto  fields
-	if exist([md.miscellaneous.name '.errlog'],'file'),
-		md.results.(structure(1).SolutionType)(1).errlog=char(textread([md.miscellaneous.name '.errlog'],'%s','delimiter','\n'));
-	else
-		md.results.(structure(1).SolutionType)(1).errlog='';
-	end
-
-	if exist([md.miscellaneous.name '.outlog'],'file'),
-		md.results.(structure(1).SolutionType)(1).outlog=char(textread([md.miscellaneous.name '.outlog'],'%s','delimiter','\n'));
-	else
-		md.results.(structure(1).SolutionType)(1).outlog='';
-	end
-
-	if ~isempty(md.results.(structure(1).SolutionType)(1).errlog),
-		disp(['loadresultsfromcluster info message: error during solution. Check your errlog and outlog model fields']);
-	end
-
-
-%post processes qmu results if necessary
-else
-
-	if isscalar(md.private.solution),
-		md.private.solution=EnumToString(md.private.solution);
-	end
-	md=postqmu(md);
-	cd ..
-end
Index: sm/trunk-jpl/src/m/model/loadresultsfromdisk.py
===================================================================
--- /issm/trunk-jpl/src/m/model/loadresultsfromdisk.py	(revision 13003)
+++ 	(revision )
@@ -1,60 +1,0 @@
-import os
-
-def loadresultsfromdisk(md,filename):
-	"""
-	LOADRESULTSFROMDISK - load results of solution sequence from disk file "filename"            
- 
-	   Usage:
-	      md=loadresultsfromdisk(md=False,filename=False);
-	"""
-
-	#check number of inputs/outputs
-	if not md or not filename:
-		raise ValueError("loadresultsfromdisk: error message.")
-
-	if not md.qmu.isdakota:
-
-		#Check that file exists
-		if not os.path.exists(filename):
-			raise ValueError("binary file '%s' not found." % filename)
-
-		#initialize md.results if not a structure yet
-		if not isinstance(md.results,dict):
-			md.results={}
-
-		#load results onto model
-		structure=parseresultsfromdisk(filename,~md.settings.io_gather)
-		if not len(structure):
-			raise RuntimeError("No result found in binary file '%s'. Check for solution crash." % filename)
-		end
-		md.results[structure[1]['SolutionType']]=structure;
-
-		#recover solution_type from results
-		md.private.solution=structure[1]['SolutionType']
-
-		#read log files onto fields
-		if os.path.exists(md.miscellaneous.name+'.errlog'):
-			with open(md.miscellaneous.name+'.errlog','r') as f:
-				md.results[structure[1]['SolutionType']]['errlog']=[line[:-1] for line in f]
-		else:
-			md.results[structure[1]['SolutionType']]['errlog']=[]
-
-		if os.path.exists(md.miscellaneous.name+'.outlog'):
-			with open(md.miscellaneous.name+'.outlog','r') as f:
-				md.results[structure[1]['SolutionType']]['outlog']=[line[:-1] for line in f]
-		else:
-			md.results[structure[1]['SolutionType']]['outlog']=[]
-
-		if len(md.results[structure[1]['SolutionType']]['errlog']):
-			print ("loadresultsfromcluster info message: error during solution. Check your errlog and outlog model fields.")
-
-	#post processes qmu results if necessary
-	else:
-
-		if not isinstance(md.private.solution,str):
-			md.private.solution=EnumToString(md.private.solution)
-		md=postqmu(md)
-		os.chdir('..')
-
-	return md
-
Index: sm/trunk-jpl/src/m/model/marshall.m
===================================================================
--- /issm/trunk-jpl/src/m/model/marshall.m	(revision 13003)
+++ 	(revision )
@@ -1,49 +1,0 @@
-function marshall(md)
-%MARSHALL - outputs a compatible binary file from @model md, for certain solution type.
-%
-%   The routine creates a compatible binary file from @model md
-%   This binary file will be used for parallel runs in JPL-package
-%
-%   Usage:
-%      marshall(md)
-
-disp(['marshalling file ' md.miscellaneous.name '.bin']);
-
-%open file for binary writing
-fid=fopen([ md.miscellaneous.name '.bin'],'wb');
-if fid==-1,
-	error(['marshall error message: could not open ' [md.miscellaneous.name '.bin'],' file for binary writing']);
-end
-
-%First, write MaximumNumberOfEnum to make sure that the Enums are synchronized
-WriteData(fid,'enum',MaximumNumberOfEnums(),'data',true,'format','Boolean');
-
-%Go through all model fields: check that it is a class and call checkconsistency
-fields=properties('model');
-for i=1:length(fields),
-	field=fields{i};
-
-	%Some properties do not need to be marshalled
-	if ismember(field,{'results' 'radaroverlay' 'solver' 'cluster'  'flaim' 'private'}),
-		continue;
-	end
-
-	%Check that current field is an object
-	if ~isobject(md.(field))
-		error(['field ''' char(field) ''' is not an object']);
-	end
-
-	%Marshall current object
-	%disp(['marshalling ' field '...']);
-	if verLessThan('matlab', '7.6')
-		marshall(md.(field),fid);
-	else
-		md.(field).marshall(fid);
-	end
-end
-
-%close file
-st=fclose(fid);
-if st==-1,
-	error(['marshall error message: could not close file ' [md.miscellaneous.name '.bin']]);
-end
Index: sm/trunk-jpl/src/m/model/marshall.py
===================================================================
--- /issm/trunk-jpl/src/m/model/marshall.py	(revision 13003)
+++ 	(revision )
@@ -1,47 +1,0 @@
-from WriteData import *
-
-def marshall(md):
-	"""
-	MARSHALL - outputs a compatible binary file from @model md, for certain solution type.
-
-	   The routine creates a compatible binary file from @model md
-	   This binary file will be used for parallel runs in JPL-package
-
-	   Usage:
-	      marshall(md)
-	"""
-
-	print "marshalling file '%s.bin'." % md.miscellaneous.name
-
-	#open file for binary writing
-	try:
-		fid=open(md.miscellaneous.name+'.bin','wb')
-	except IOError as e:
-		raise IOError("marshall error message: could not open '%s.bin' file for binary writing." % md.miscellaneous.name)
-
-	#First, write MaximumNumberOfEnum to make sure that the Enums are synchronized
-	WriteData(fid,'enum',MaximumNumberOfEnums(),'data',True,'format','Boolean')
-
-	#Go through all model fields: check that it is a class and call checkconsistency
-	fields=vars(md)
-
-	for field in fields.iterkeys():
-
-		#Some properties do not need to be marshalled
-		if field in ['results','radaroverlay','solver','cluster','flaim','private']:
-			continue
-
-		#Check that current field is an object
-		if not hasattr(getattr(md,field),'marshall'):
-			raise TypeError("field '%s' is not an object." % field)
-
-		#Marshall current object
-		#print "marshalling %s ..." % field
-		exec("md.%s.marshall(fid)" % field)
-
-	#close file
-	try:
-		f.close(fid)
-	except IOError as e:
-		raise IOError("marshall error message: could not close file '%s.bin'." % md.miscellaneous.name)
-
Index: sm/trunk-jpl/src/m/model/petscversion.m
===================================================================
--- /issm/trunk-jpl/src/m/model/petscversion.m	(revision 13003)
+++ 	(revision )
@@ -1,26 +1,0 @@
-function PETSC_VERSION=petscversion()
-%PETSCVERSION - recover petsc version number, inside config.h file
-%
-%   Usage:
-%       PETSC_VERSION=petscversion();
-
-%default
-PETSC_VERSION=3;
-
-configfile=[issmdir() '/config.h'];
-if ~exist(configfile,'file'),
-	error(['File ' configfile ' not found. ISSM has not been configured yet!']);
-end
-
-%go through the file, and recover the line we want
-fid=fopen(configfile,'r');
-if(fid==-1), error(['could not open file: ' configfile]); end
-
-while(true),
-	tline=fgets(fid);
-	if ~ischar(tline), break, end
-	if  strncmp(tline,'#define _PETSC_MAJOR_',21),
-		PETSC_VERSION=str2num(tline(23));
-	end
-end
-fclose(fid);
Index: sm/trunk-jpl/src/m/model/petscversion.py
===================================================================
--- /issm/trunk-jpl/src/m/model/petscversion.py	(revision 13003)
+++ 	(revision )
@@ -1,34 +1,0 @@
-import os
-from issmdir import *
-from MatlabFuncs import *
-
-def petscversion():
-	"""
-	PETSCVERSION - recover petsc version number, inside config.h file
- 
-	   Usage:
-	      PETSC_VERSION=petscversion();
-	"""
-
-	#default
-	PETSC_VERSION=3
-
-	configfile=os.path.join(issmdir(),'config.h')
-	if not os.path.exists(configfile):
-		raise RuntimeError("File '%s' not found. ISSM has not been configured yet!" % configfile)
-
-	#go through the file, and recover the line we want
-	try:
-		fid=open(configfile,'r')
-	except IOError as e:
-		raise IOerror("could not open file: '%s'" % configfile)
-
-	for tline in fid:
-		if strncmp(tline,'#define _PETSC_MAJOR_',21):
-			PETSC_VERSION=int(tline[22])
-			break
-
-	fid.close()
-
-	return PETSC_VERSION
-
Index: sm/trunk-jpl/src/m/model/process_solve_options.m
===================================================================
--- /issm/trunk-jpl/src/m/model/process_solve_options.m	(revision 13003)
+++ 	(revision )
@@ -1,39 +1,0 @@
-function outoptions=process_solve_options(options)
-%DEFAULT_SOLVE_OPTIONS - set up default options for solve phase
-%
-%   Usage:
-%      options=process_solve_options(options)
-%
-%   See also: SOLVE
-
-%solution_type: check on this option, error out otherwise
-solution_type=getfieldvalue(options,'solution_type');
-if ~ismember(solution_type,[DiagnosticSolutionEnum,PrognosticSolutionEnum,ThermalSolutionEnum,...
-		SteadystateSolutionEnum,TransientSolutionEnum,EnthalpySolutionEnum,...
-		BalancethicknessSolutionEnum,BedSlopeSolutionEnum,SurfaceSlopeSolutionEnum,HydrologySolutionEnum,FlaimSolutionEnum]),
-	error(['process_solve_options error message: solution_type ' EnumToString(solution_type) ' not supported yet!']);
-end
-outoptions.solution_type=solution_type;
-
-outoptions.upload=getfieldvalue(options,'upload','off');
-outoptions.batch=getfieldvalue(options,'batch','no');
-outoptions.loadonly=getfieldvalue(options,'loadonly',false);
-outoptions.directory=getfieldvalue(options,'directory','');
-
-%  process qmu arguments
-outoptions.qmudir=getfieldvalue(options,'qmudir',['qmu' num2str(feature('GetPid'))]);  % qmudir =['qmu_' datestr(now,'yyyymmdd_HHMMSS')];
-outoptions.qmufile=getfieldvalue(options,'qmufile','qmu');% qmufile cannot be changed unless ????script.sh is also changed
-outoptions.overwrite=getfieldvalue(options,'overwrite','n');
-outoptions.keep=getfieldvalue(options,'keep','n');
-outoptions.ivar=getfieldvalue(options,'ivar',1);
-outoptions.iresp=getfieldvalue(options,'iresp',1);
-outoptions.imethod=getfieldvalue(options,'imethod',1);
-outoptions.iparams=getfieldvalue(options,'iparams',1);
-outoptions.runmpi=getfieldvalue(options,'runmpi',false);
-
-%  process flaim arguments
-outoptions.fmdir=getfieldvalue(options,'fmdir',['fm' num2str(feature('GetPid'))]);
-outoptions.overwrite=getfieldvalue(options,'overwrite','n');
-outoptions.keep=getfieldvalue(options,'keep','y');
-outoptions.latsgn=getfieldvalue(options,'latsgn',0);
-outoptions.cmap=getfieldvalue(options,'cmap',[]);
Index: sm/trunk-jpl/src/m/model/process_solve_options.py
===================================================================
--- /issm/trunk-jpl/src/m/model/process_solve_options.py	(revision 13003)
+++ 	(revision )
@@ -1,48 +1,0 @@
-import os
-from EnumDefinitions import *
-
-def process_solve_options(options):
-	"""
-	DEFAULT_SOLVE_OPTIONS - set up default options for solve phase
- 
-	   Usage:
-	      options=process_solve_options(options)
- 
-	   See also: SOLVE
-	"""
-
-	outoptions={}
-
-	#solution_type: check on this option, error out otherwise
-	solution_type=options.getfieldvalue('solution_type')
-	if not solution_type in (DiagnosticSolutionEnum,PrognosticSolutionEnum,ThermalSolutionEnum,\
-			SteadystateSolutionEnum,TransientSolutionEnum,EnthalpySolutionEnum,\
-			BalancethicknessSolutionEnum,BedSlopeSolutionEnum,SurfaceSlopeSolutionEnum,HydrologySolutionEnum,FlaimSolutionEnum):
-		raise ValueError("process_solve_options error message: solution_type '%s' not supported yet!" % EnumToString(solution_type))
-	outoptions['solution_type']=solution_type
-
-	outoptions['upload']=options.getfieldvalue('upload','off')
-	outoptions['batch']=options.getfieldvalue('batch','no')
-	outoptions['loadonly']=options.getfieldvalue('loadonly',False)
-	outoptions['directory']=options.getfieldvalue('directory','')
-
-	#  process qmu arguments
-	outoptions['qmudir']=options.getfieldvalue('qmudir','qmu'+str(os.getpid()))
-	outoptions['qmufile']=options.getfieldvalue('qmufile','qmu')    # qmufile cannot be changed unless ????script.sh is also changed
-	outoptions['overwrite']=options.getfieldvalue('overwrite','n')
-	outoptions['keep']=options.getfieldvalue('keep','n')
-	outoptions['ivar']=options.getfieldvalue('ivar',1)
-	outoptions['iresp']=options.getfieldvalue('iresp',1)
-	outoptions['imethod']=options.getfieldvalue('imethod',1)
-	outoptions['iparams']=options.getfieldvalue('iparams',1)
-	outoptions['runmpi']=options.getfieldvalue('runmpi',False)
-
-	#  process flaim arguments
-	outoptions['fmdir']=options.getfieldvalue('fmdir','fm'+str(os.getpid()))
-	outoptions['overwrite']=options.getfieldvalue('overwrite','n')
-	outoptions['keep']=options.getfieldvalue('keep','y')
-	outoptions['latsgn']=options.getfieldvalue('latsgn',0)
-	outoptions['cmap']=options.getfieldvalue('cmap',[])
-
-	return outoptions
-
Index: sm/trunk-jpl/src/m/model/solve.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve.m	(revision 13003)
+++ 	(revision )
@@ -1,121 +1,0 @@
-function md=solve(md,solutionenum,varargin)
-%SOLVE - apply solution sequence for this model
-%
-%   Usage:
-%      md=solve(md,solutionenum,varargin)
-%      where varargin is a lit of paired arguments of string OR enums
-%
-%   solution types available comprise:
-%		 - DiagnosticSolutionEnum
-%		 - PrognosticSolutionEnum
-%		 - ThermalSolutionEnum
-%		 - SteadystateSolutionEnum
-%		 - TransientSolutionEnum...
-%		 - BalancethicknessSolutionEnum
-%		 - BedSlopeSolutionEnum
-%		 - SurfaceSlopeSolutionEnum
-%		 - HydrologySolutionEnum
-%		 - FlaimSolutionEnum
-%
-%  extra options:
-%      - loadonly : does not solve. only load results
-%
-%   Examples:
-%      md=solve(md,DiagnosticSolutionEnum);
-
-%recover and process solve options
-options=pairoptions(varargin{:},'solution_type',solutionenum);
-options=process_solve_options(options);
-
-%recover some fields
-md.private.solution=options.solution_type;
-cluster=md.cluster;
-
-%check model consistency
-disp('checking model consistency');
-if (solutionenum == FlaimSolutionEnum)
-	md.private.isconsistent=true;
-	md=checkconsistency(md.mesh,md,solutionenum);
-	md=checkconsistency(md.flaim,md,solutionenum);
-	if md.private.isconsistent==false,
-		error('Model not consistent, see messages above');
-	end
-else
-	ismodelselfconsistent(md),
-end
-
-%First, build a runtime name that is unique
-c=clock;
-md.private.runtimename=sprintf('%s-%02i-%02i-%04i-%02i-%02i-%02i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
-
-%if running qmu analysis, some preprocessing of dakota files using models
-%fields needs to be carried out. 
-if md.qmu.isdakota,
-	md=preqmu(md,options);
-end
-
-%flaim analysis
-if (options.solution_type == FlaimSolutionEnum)
-	md=flaim_sol(md,options);
-	md.private.solution=EnumToString(options.solution_type);
-	return;
-end
-
-%Do we load results only?
-if options.loadonly,  
-	md=loadresultsfromcluster(md);
-	return;
-end
-
-%we need to make sure we have PETSC support, otherwise, we run with only one cpu: 
-if ~ispetsc,
-	disp('PETSC support not included, running on 1 cpu only!');
-	cluster.np=1;
-end
-
-
-%Wite all input files
-marshall(md);                                          % bin file
-PetscFile(md.solver,[md.miscellaneous.name '.petsc']); % petsc file
-BuildQueueScript(cluster,md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof); % queue file
-
-
-%Stop here if batch mode
-if strcmpi(options.batch,'yes')
-	disp('batch mode requested: not launching job interactively');
-	disp('launch solution sequence on remote cluster by hand');
-	return;
-end
-
-%Launch job
-modelname = md.miscellaneous.name;
-filelist  = {[modelname '.bin '] [modelname '.petsc '] [modelname '.queue ']};
-if md.qmu.isdakota,
-	filelist{end+1} = [modelname '.qmu.in'];
-end
-LaunchQueueJob(cluster,md.miscellaneous.name,md.private.runtimename,filelist);
-
-%did we even try to run? if so, wait on lock
-if strcmpi(options.upload,'on'),
-	disp('solve done uploading test decks');
-	return;
-end
-
-%wait on lock
-if md.settings.waitonlock>0,
-	%we wait for the done file
-	islock=waitonlock(md);
-	if islock==0, %no results to be loaded
-		disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
-	else          %load results
-		disp('loading results from cluster');
-		md=loadresultsfromcluster(md);
-	end
-end
-
-%post processes qmu results if necessary
-if md.qmu.isdakota,
-	if ~strncmpi(options.keep,'y',1)
-		system(['rm -rf qmu' num2str(feature('GetPid'))]);
-	end
-end
Index: sm/trunk-jpl/src/m/model/solve.py
===================================================================
--- /issm/trunk-jpl/src/m/model/solve.py	(revision 13003)
+++ 	(revision )
@@ -1,119 +1,0 @@
-import datetime
-import os
-import shutil
-from pairoptions import *
-from process_solve_options import *
-from EnumDefinitions import *
-from ismodelselfconsistent import *
-
-def solve(md,solutionenum,*args):
-	"""
-	SOLVE - apply solution sequence for this model
- 
-	   Usage:
-	      md=solve(md,solutionenum,varargin)
-	      where varargin is a list of paired arguments of string OR enums
- 
-	   solution types available comprise:
-	      - DiagnosticSolutionEnum
-	      - PrognosticSolutionEnum
-	      - ThermalSolutionEnum
-	      - SteadystateSolutionEnum
-	      - TransientSolutionEnum...
-	      - BalancethicknessSolutionEnum
-	      - BedSlopeSolutionEnum
-	      - SurfaceSlopeSolutionEnum
-	      - HydrologySolutionEnum
-	      - FlaimSolutionEnum
- 
-	   extra options:
-	      - loadonly : does not solve. only load results
- 
-	   Examples:
-	      md=solve(md,DiagnosticSolutionEnum);
-	"""
-
-	#recover and process solve options
-	options=pairoptions('solution_type',solutionenum,*args)
-	options=process_solve_options(options)
-
-	#recover some fields
-	md.private.solution=options['solution_type']
-	cluster=md.cluster
-
-	#check model consistency
-	print "checking model consistency"
-	if solutionenum == FlaimSolutionEnum:
-		md.private.isconsistent=True
-		md.mesh.checkconsistency(md,solutionenum)
-		md.flaim.checkconsistency(md,solutionenum)
-		if not md.private.isconsistent:
-			raise RuntimeError("Model not consistent, see messages above.")
-	else:
-		ismodelselfconsistent(md)
-
-	#First, build a runtime name that is unique
-	c=datetime.datetime.now()
-	md.private.runtimename="%s-%02i-%02i-%04i-%02i-%02i-%02i-%i" % (md.miscellaneous.name,c.month,c.day,c.year,c.hour,c.minute,c.second,os.getpid())
-
-	#if running qmu analysis, some preprocessing of dakota files using models
-	#fields needs to be carried out. 
-	if md.qmu.isdakota:
-		md=preqmu(md,options)
-
-	#flaim analysis
-	if options['solution_type'] == FlaimSolutionEnum:
-		md=flaim_sol(md,options)
-		md.private.solution=EnumToString(options['solution_type'])
-		return md
-
-	#Do we load results only?
-	if options['loadonly']:  
-		md=loadresultsfromcluster(md)
-		return md
-
-	#Wite all input files
-	marshall(md)                                           # bin file
-	md.solver.PetscFile(md.miscellaneous.name+'.petsc')    # petsc file
-	cluster.BuildQueueScript(md.miscellaneous.name,md.private.runtimename,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof)    # queue file
-
-	#we need to make sure we have PETSC support, otherwise, we run with only one cpu: 
-	if not ispetsc:
-		print "PETSC support not included, running on 1 cpu only!"
-		cluster.np=1
-
-	#Stop here if batch mode
-	if strcmpi(options['batch'],'yes'):
-		print 'batch mode requested: not launching job interactively'
-		print 'launch solution sequence on remote cluster by hand'
-		return md
-
-	#Launch job
-	modelname = md.miscellaneous.name
-	filelist  = [modelname+'.bin ',modelname+'.petsc ',modelname+'.queue ']
-	if md.qmu.isdakota:
-		filelist.append(modelname+'.qmu.in')
-	cluster.LaunchQueueJob(md.miscellaneous.name,md.private.runtimename,filelist)
-
-	#did we even try to run? if so, wait on lock
-	if strcmpi(options['upload'],'on'):
-		print 'solve done uploading test decks'
-		return md
-
-	#wait on lock
-	if md.settings.waitonlock>0:
-		#we wait for the done file
-		islock=waitonlock(md)
-		if islock==0:    #no results to be loaded
-			print 'The results must be loaded manually with md=loadresultsfromcluster(md).'
-		else:            #load results
-			print 'loading results from cluster'
-			md=loadresultsfromcluster(md)
-
-	#post processes qmu results if necessary
-	if md.qmu.isdakota:
-		if not strncmpi(options['keep'],'y',1):
-			shutil.rmtree('qmu'+str(os.getpid()))
-
-	return md
-
Index: /issm/trunk-jpl/src/m/model/solve/WriteData.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/WriteData.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/WriteData.m	(revision 13004)
@@ -0,0 +1,260 @@
+function WriteData(fid,varargin)
+%WRITEDATA - write model field in binary file
+%
+%   Usage:
+%      WriteData(fid,varargin);
+
+%process options
+options=pairoptions(varargin{:});
+
+%Get data properties
+if exist(options,'object');
+	%This is a object field, construct enum and data
+	obj       = getfieldvalue(options,'object');
+	fieldname = getfieldvalue(options,'fieldname');
+	classname = class(obj);
+
+	enum      = BuildEnum([classname '_' fieldname]);
+	data      = obj.(fieldname);
+else
+	%No processing required
+	data = getfieldvalue(options,'data');
+	enum = getfieldvalue(options,'enum');
+end
+format  = getfieldvalue(options,'format');
+mattype = getfieldvalue(options,'mattype',0);    %only required for matrices
+
+%Process sparse matrices
+if issparse(data),
+	data=full(data);
+end
+
+%Step 1: write the enum to identify this record uniquely
+fwrite(fid,enum,'int'); 
+
+%Step 2: write the data itself.
+if     strcmpi(format,'Boolean'),% {{{
+	if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
+
+	%first write length of record
+	fwrite(fid,4+4,'int');  %1 bool (disguised as an int)+code
+
+	%write data code: 
+	fwrite(fid,FormatToCode(format),'int'); 
+
+	%now write integer
+	fwrite(fid,data,'int');  %send an int, not easy to send a bool
+	% }}}
+elseif strcmpi(format,'Integer'), % {{{
+	if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
+
+	%first write length of record
+	fwrite(fid,4+4,'int');  %1 integer + code
+
+	%write data code: 
+	fwrite(fid,FormatToCode(format),'int'); 
+
+	%now write integer
+	fwrite(fid,data,'int'); 
+	% }}}
+elseif strcmpi(format,'Double'), % {{{
+	if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
+
+	%first write length of record
+	fwrite(fid,8+4,'int');  %1 double+code
+
+	%write data code: 
+	fwrite(fid,FormatToCode(format),'int'); 
+
+	%now write double
+	fwrite(fid,data,'double'); 
+	% }}}
+elseif strcmpi(format,'String'), % {{{
+	%first write length of record
+	fwrite(fid,length(data)+4+4,'int');  %string + string size + code
+
+	%write data code: 
+	fwrite(fid,FormatToCode(format),'int'); 
+
+	%now write string
+	fwrite(fid,length(data),'int'); 
+	fwrite(fid,data,'char'); 
+	% }}}
+elseif strcmpi(format,'BooleanMat'), % {{{
+
+	%Get size
+	s=size(data);
+	%if matrix = NaN, then do not write anything
+	if (s(1)==1 & s(2)==1 & isnan(data)),
+		s(1)=0; s(2)=0;
+	end
+
+	%first write length of record
+	fwrite(fid,4+4+8*s(1)*s(2)+4+4,'int');  %2 integers (32 bits) + the double matrix + code + matrix type
+
+	%write data code and matrix type: 
+	fwrite(fid,FormatToCode(format),'int'); 
+	fwrite(fid,mattype,'int');
+
+	%now write matrix
+	fwrite(fid,s(1),'int'); 
+	fwrite(fid,s(2),'int'); 
+	if s(1)*s(2),
+		fwrite(fid,data','double'); %get to the "c" convention, hence the transpose
+	end
+	% }}}
+elseif strcmpi(format,'IntMat'), % {{{
+
+	%Get size
+	s=size(data);
+	%if matrix = NaN, then do not write anything
+	if (s(1)==1 & s(2)==1 & isnan(data)),
+		s(1)=0; s(2)=0;
+	end
+
+	%first write length of record
+	fwrite(fid,4+4+8*s(1)*s(2)+4+4,'int');  %2 integers (32 bits) + the double matrix + code + matrix type
+
+	%write data code and matrix type: 
+	fwrite(fid,FormatToCode(format),'int'); 
+	fwrite(fid,mattype,'int');
+
+	%now write matrix
+	fwrite(fid,s(1),'int'); 
+	fwrite(fid,s(2),'int'); 
+	if s(1)*s(2),
+		fwrite(fid,data','double'); %get to the "c" convention, hence the transpose
+	end
+	% }}}
+elseif strcmpi(format,'DoubleMat'), % {{{
+
+	%Get size
+	s=size(data);
+	%if matrix = NaN, then do not write anything
+	if (s(1)==1 & s(2)==1 & isnan(data)),
+		s(1)=0; s(2)=0;
+	end
+
+	%first write length of record
+	fwrite(fid,4+4+8*s(1)*s(2)+4+4,'int');  %2 integers (32 bits) + the double matrix + code + matrix type
+
+	%write data code and matrix type: 
+	fwrite(fid,FormatToCode(format),'int'); 
+	fwrite(fid,mattype,'int');
+
+	%now write matrix
+	fwrite(fid,s(1),'int'); 
+	fwrite(fid,s(2),'int'); 
+	if s(1)*s(2),
+		fwrite(fid,data','double'); %get to the "c" convention, hence the transpose
+	end
+	% }}}
+elseif strcmpi(format,'MatArray'), % {{{
+
+	numrecords=numel(data);
+
+	%first get length of record
+	recordlength=4+4; %number of records + code
+	for i=1:numrecords,
+		matrix=data{i};
+		s=size(matrix);
+		recordlength=recordlength+4*2+... %row and col of matrix
+			s(1)*s(2)*8; %matrix of doubles
+	end
+
+	%write length of record
+	fwrite(fid,recordlength,'int'); 
+
+	%write data code: 
+	fwrite(fid,FormatToCode(format),'int'); 
+
+	%write data, first number of records
+	fwrite(fid,numrecords,'int'); 
+
+	%write each matrix: 
+	for i=1:numrecords,
+		matrix=data{i};
+		s=size(matrix);
+		fwrite(fid,s(1),'int'); 
+		fwrite(fid,s(2),'int'); 
+		fwrite(fid,matrix','double');
+	end
+	% }}}
+elseif strcmpi(format,'StringArray'), % {{{
+
+	%first get length of string array: 
+	num=numel(data);
+	%now get length of record: 
+	recordlength=4+4; %for length of array + code
+	for i=1:num,
+		string=data{i};
+		recordlength=recordlength+4+length(string); %for each string
+	end
+
+	%write length of record
+	fwrite(fid,recordlength,'int'); 
+
+	%write data code: 
+	fwrite(fid,FormatToCode(format),'int'); 
+
+	%now write length of string array
+	fwrite(fid,num,'int'); 
+
+	%now write the strings
+	for i=1:num,
+		string=data{i};
+		fwrite(fid,length(string),'int'); 
+		fwrite(fid,string,'char'); 
+	end
+	% }}}
+else  % {{{
+	error(['WriteData error message: data type: ' num2str(format) ' not supported yet! (' EnumToString(enum) ')']);
+end % }}}
+end
+
+function enum=BuildEnum(string) % {{{
+%BUILDENUM - build enum out of string
+%
+%   Usage:
+%      enum=BuildEnum(string)
+
+	if findstr(string,'_'),
+		indices=findstr(string,'_');
+		for i=1:length(indices),
+			string(indices(i)+1)=upper(string(indices(i)+1));
+		end
+		string(indices)=[];
+	end
+
+	%take first letter of string and make it uppercase: 
+	string(1)=upper(string(1));
+
+	%Get Enum
+	enum=eval([string 'Enum();']); 
+end % }}}
+function code=FormatToCode(format) % {{{
+%This routine takes the format string, and hardcodes it into an integer, which 
+%is passed along the record, in order to identify the nature of the dataset being 
+%sent.
+	if     strcmpi(format,'Boolean'),
+		code=1;
+	elseif strcmpi(format,'Integer'), 
+		code=2;
+	elseif strcmpi(format,'Double'), 
+		code=3;
+	elseif strcmpi(format,'String'), 
+		code=4;
+	elseif strcmpi(format,'BooleanMat'),
+		code=5;
+	elseif strcmpi(format,'IntMat'),
+		code=6;
+	elseif strcmpi(format,'DoubleMat'),
+		code=7;
+	elseif strcmpi(format,'MatArray'), 
+		code=8;
+	elseif strcmpi(format,'StringArray'),
+		code=9;
+	else 
+		error('FormatToCode error message: data type not supported yet!');
+	end
+end% }}}
Index: /issm/trunk-jpl/src/m/model/solve/WriteData.py
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/WriteData.py	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/WriteData.py	(revision 13004)
@@ -0,0 +1,274 @@
+import numpy
+import math
+import struct
+from MatlabFuncs import *
+
+def WriteData(fid,*args):
+	"""
+	WRITEDATA - write model field in binary file
+ 
+	   Usage:
+	      WriteData(fid,varargin)
+	"""
+
+	#process options
+	options=pairoptions(*args)
+
+	#Get data properties
+	if options.exist('object'):
+		#This is an object field, construct enum and data
+		obj       = options.getfieldvalue('object')
+		fieldname = options.getfieldvalue('fieldname')
+		classname = type(obj)
+
+		enum      = BuildEnum(classname+'_'+fieldname)
+		data      = getattr(obj,fieldname)
+	else:
+		#No processing required
+		data = options.getfieldvalue('data')
+		enum = options.getfieldvalue('enum')
+	format  = options.getfieldvalue('format')
+	mattype = options.getfieldvalue('mattype',0)    #only required for matrices
+
+	#Process sparse matrices
+#	if issparse(data),
+#		data=full(data);
+#	end
+
+	#Step 1: write the enum to identify this record uniquely
+	fid.write(struct.pack('i',enum)) 
+
+	#Step 2: write the data itself.
+	if   strcmpi(format,'Boolean'):    # {{{
+		if len(data) !=1:
+			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4))  #1 bool (disguised as an int)+code
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write integer
+		fid.write(struct.pack('i',data))  #send an int, not easy to send a bool
+		# }}}
+
+	elif strcmpi(format,'Integer'):    # {{{
+		if len(data) !=1:
+			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4))  #1 integer + code
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write integer
+		fid.write(struct.pack('i',data)) 
+		# }}}
+
+	elif strcmpi(format,'Double'):    # {{{
+		if len(data) !=1:
+			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
+
+		#first write length of record
+		fid.write(struct.pack('i',8+4))  #1 double+code
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write double
+		fid.write(struct.pack('d',data)) 
+		# }}}
+
+	elif strcmpi(format,'String'):    # {{{
+		#first write length of record
+		fid.write(struct.pack('i',len(data)+4+4))  #string + string size + code
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write string
+		fid.write(struct.pack('i',len(data))) 
+		fid.write(struct.pack('%ds' % len(data),data)) 
+		# }}}
+
+	elif strcmpi(format,'BooleanMat'):    # {{{
+
+		#Get size
+		s=data.shape
+		#if matrix = NaN, then do not write anything
+		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
+			s[0]=0
+			s[1]=0
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
+
+		#write data code and matrix type: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+		fid.write(struct.pack('i',mattype))
+
+		#now write matrix
+		fid.write(struct.pack('i',s[0])) 
+		fid.write(struct.pack('i',s[1])) 
+		for i in xrange(s[0]):
+			for j in xrange(s[1]):
+				fid.write(struct.pack('i',data[i][j]))    #get to the "c" convention, hence the transpose
+		# }}}
+
+	elif strcmpi(format,'IntMat'):    # {{{
+
+		#Get size
+		s=data.shape
+		#if matrix = NaN, then do not write anything
+		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
+			s[0]=0
+			s[1]=0
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
+
+		#write data code and matrix type: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+		fid.write(struct.pack('i',mattype))
+
+		#now write matrix
+		fid.write(struct.pack('i',s[0])) 
+		fid.write(struct.pack('i',s[1])) 
+		for i in xrange(s[0]):
+			for j in xrange(s[1]):
+				fid.write(struct.pack('i',data[i][j]))    #get to the "c" convention, hence the transpose
+		# }}}
+
+	elif strcmpi(format,'DoubleMat'):    # {{{
+
+		#Get size
+		s=data.shape
+		#if matrix = NaN, then do not write anything
+		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
+			s[0]=0
+			s[1]=0
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
+
+		#write data code and matrix type: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+		fid.write(struct.pack('i',mattype))
+
+		#now write matrix
+		fid.write(struct.pack('i',s[0])) 
+		fid.write(struct.pack('i',s[1])) 
+		for i in xrange(s[0]):
+			for j in xrange(s[1]):
+				fid.write(struct.pack('d',data[i][j]))    #get to the "c" convention, hence the transpose
+		# }}}
+
+	elif strcmpi(format,'MatArray'):    # {{{
+
+		#first get length of record
+		recordlength=4+4    #number of records + code
+		for matrix in data:
+			s=matrix.shape
+			recordlength+=4*2+s[0]*s[1]*8    #row and col of matrix + matrix of doubles
+
+		#write length of record
+		fid.write(struct.pack('i',recordlength)) 
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#write data, first number of records
+		fid.write(struct.pack('i',len(data))) 
+
+		#write each matrix: 
+		for matrix in data:
+			s=matrix.shape
+			fid.write(struct.pack('i',s[0])) 
+			fid.write(struct.pack('i',s[1])) 
+			for i in xrange(s[0]):
+				for j in xrange(s[1]):
+					fid.write(struct.pack('d',matrix[i][j]))
+		# }}}
+
+	elif strcmpi(format,'StringArray'):    # {{{
+
+		#first get length of record
+		recordlength=4+4    #for length of array + code
+		for string in data:
+			recordlength+=4+len(string)    #for each string
+
+		#write length of record
+		fid.write(struct.pack('i',recordlength)) 
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write length of string array
+		fid.write(struct.pack('i',len(data))) 
+
+		#now write the strings
+		for string in data:
+			fid.write(struct.pack('i',len(string))) 
+			fid.write(struct.pack('%ds' % len(string),string)) 
+		# }}}
+
+	else:    # {{{
+		raise TypeError('WriteData error message: data type: %d not supported yet! (%s)' % (format,EnumToString(enum)))
+	# }}}
+
+def BuildEnum(string): # {{{
+	"""
+	BUILDENUM - build enum out of string
+ 
+    Usage:
+       enum=BuildEnum(string)
+	"""
+
+	if '_' in string:
+		substrs=string.split('_')
+		string=''
+		for str in substrs:
+			string+=str[0].upper()+str[1:]
+	else:
+		#take first letter of string and make it uppercase: 
+		string=str[0].upper()+str[1:]
+
+	#Get Enum
+	exec('enum='+string+'Enum()',globals())
+
+	return enum
+# }}}
+
+def FormatToCode(format): # {{{
+	"""
+	This routine takes the format string, and hardcodes it into an integer, which 
+	is passed along the record, in order to identify the nature of the dataset being 
+	sent.
+	"""
+
+	if   strcmpi(format,'Boolean'):
+		code=1
+	elif strcmpi(format,'Integer'):
+		code=2
+	elif strcmpi(format,'Double'):
+		code=3
+	elif strcmpi(format,'String'):
+		code=4
+	elif strcmpi(format,'BooleanMat'):
+		code=5
+	elif strcmpi(format,'IntMat'):
+		code=6
+	elif strcmpi(format,'DoubleMat'):
+		code=7
+	elif strcmpi(format,'MatArray'):
+		code=8
+	elif strcmpi(format,'StringArray'):
+		code=9
+	else:
+		raise InputError('FormatToCode error message: data type not supported yet!')
+
+	return code
+# }}}
+
Index: /issm/trunk-jpl/src/m/model/solve/ismodelselfconsistent.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/ismodelselfconsistent.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/ismodelselfconsistent.m	(revision 13004)
@@ -0,0 +1,40 @@
+function ismodelselfconsistent(md),
+%ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
+%
+%   Usage:
+%      ismodelselfconsistent(md),
+
+%initialize consistency as true
+md.private.isconsistent=true;
+
+%Get solution and associated analyses
+solution=md.private.solution;
+[analyses,numanalyses]=AnalysisConfiguration(solution);
+
+%Go through a model field, check that it is a class, and call checkconsistency
+fields=properties('model');
+for i=1:length(fields),
+	field=fields{i};
+
+	%Some properties do not need to be checked
+	if ismember(field,{'results' 'debug' 'radaroverlay'}),
+		continue;
+	end
+
+	%Check that current field is an object
+	if ~isobject(md.(field))
+		md=checkmessage(md,['field ''' char(field) ''' is not an object']);
+	end
+
+	%Check consistency of the object
+	if verLessThan('matlab', '7.6')
+		md=checkconsistency(md.(field),md,solution,analyses);
+	else
+		md=md.(field).checkconsistency(md,solution,analyses);
+	end
+end
+
+%error message if mode is not consistent
+if md.private.isconsistent==false,
+	error('Model not consistent, see messages above');
+end
Index: /issm/trunk-jpl/src/m/model/solve/ismodelselfconsistent.py
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/ismodelselfconsistent.py	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/ismodelselfconsistent.py	(revision 13004)
@@ -0,0 +1,36 @@
+from AnalysisConfiguration import *
+
+def ismodelselfconsistent(md):
+	"""
+	ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
+
+	   Usage:
+	      ismodelselfconsistent(md),
+	"""
+
+	#initialize consistency as true
+	md.private.isconsistent=True
+
+	#Get solution and associated analyses
+	solution=md.private.solution
+	analyses,numanalyses=AnalysisConfiguration(solution)
+
+	#Go through a model fields, check that it is a class, and call checkconsistency
+	fields=vars(md)
+	for field in fields.iterkeys():
+
+		#Some properties do not need to be checked
+		if field in ['results','debug','radaroverlay']:
+			continue
+
+		#Check that current field is an object
+		if not hasattr(getattr(md,field),'checkconsistency'):
+			md.checkmessage("field '%s' is not an object." % field)
+
+		#Check consistency of the object
+		exec("md.%s.checkconsistency(md,solution,analyses)" % field)
+
+	#error message if mode is not consistent
+	if not md.private.isconsistent:
+		raise RuntimeError('Model not consistent, see messages above.')
+
Index: /issm/trunk-jpl/src/m/model/solve/loadmultipleresultsfromcluster.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/loadmultipleresultsfromcluster.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/loadmultipleresultsfromcluster.m	(revision 13004)
@@ -0,0 +1,34 @@
+function md_list=loadmultipleresultsfromcluster(md_list)
+%LOADMULTIPLERESULTSFROMCLUSTER - load multiple results of solution sequences from cluster
+%
+%   Usage:
+%      md_list=loadresultsfromcluster(md_list);
+
+nummodels=length(md_list);
+
+%Get cluster settings
+cluster=md_list{1}.cluster;
+name=md_list{1}.name;
+cluster_rc_location=which('cluster.rc');
+[codepath,executionpath,login]=ClusterParameters(cluster,cluster_rc_location);
+
+%Remote tar: 
+disp('tarring results');
+issmssh(cluster,['"cd ' executionpath ' && rm -rf file_list.txt ModelResults.tar.gz && find -iname ''*_*vs*.outbin'' > file_list.txt && tar zcvf ModelResults.tar.gz --files-from file_list.txt  && rm -rf file_list.txt "']);
+
+%copy results from cluster to present directory
+scpin(cluster, executionpath, {'ModelResults.tar.gz'});
+
+%untar:
+!tar -zxvf ModelResults.tar.gz
+
+%ok, go through list and load results from disk: 
+for i=1:nummodels,
+	%load  results for this model
+	md_list{i}=loadresultsfromdisk(md_list{i},[md_list{i}.name '.outbin']);
+
+	delete([name '.outbin']);
+end
+
+%erase files 
+delete('ModelResults.tar.gz');
Index: /issm/trunk-jpl/src/m/model/solve/loadresultsfromcluster.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/loadresultsfromcluster.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/loadresultsfromcluster.m	(revision 13004)
@@ -0,0 +1,60 @@
+function md=loadresultsfromcluster(md,runtimename)
+%LOADRESULTSFROMCLUSTER - load results of solution sequence from cluster
+%
+%   Usage:
+%      md=loadresultsfromcluster(md,runtimename);
+
+%retrieve cluster, to be able to call its methods
+cluster=md.cluster;
+
+if nargin==2,
+	md.private.runtimename=runtimename;
+end
+
+%Download outputs from the cluster
+filelist={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
+if md.qmu.isdakota,
+	filelist{end+1}=[md.miscellaneous.name '.qmu.err'];
+	filelist{end+1}=[md.miscellaneous.name '.qmu.out'];
+	if isfield(md.qmu.params,'tabular_graphics_data'),
+		if md.qmu.params.tabular_graphics_data==true,
+			filelist{end+1}='dakota_tabular.dat';
+		end
+	end
+else
+	filelist{end+1}=[md.miscellaneous.name '.outbin'];
+end
+Download(cluster,md.private.runtimename,filelist);
+
+%If we are here, no errors in the solution sequence, call loadresultsfromdisk.
+md=loadresultsfromdisk(md,[md.miscellaneous.name '.outbin']);
+
+%erase the log and output files
+if md.qmu.isdakota,
+	delete([['qmu' num2str(feature('GetPid')) '/'] md.miscellaneous.name '.outlog']);
+	delete([['qmu' num2str(feature('GetPid')) '/']  md.miscellaneous.name '.errlog']);
+else
+	delete([md.miscellaneous.name '.outlog']);
+	delete([md.miscellaneous.name '.errlog']);
+	delete([md.miscellaneous.name '.outbin']);
+	if ~ispc,
+		delete([md.private.runtimename '.tar.gz']);
+	end
+end
+
+%erase input file if run was carried out on same platform.
+hostname=oshostname();
+if strcmpi(hostname,cluster.name),
+	if md.qmu.isdakota,
+		delete([['qmu' num2str(feature('GetPid')) '/'] md.miscellaneous.name '.bin']);
+		delete([['qmu' num2str(feature('GetPid')) '/'] md.miscellaneous.name '.queue']);
+	else
+		delete([md.miscellaneous.name '.bin']);
+		delete([md.miscellaneous.name '.petsc']);
+		if ~ispc,
+			delete([md.miscellaneous.name '.queue']);
+		else
+			delete([md.miscellaneous.name '.bat']);
+		end
+	end
+end
Index: /issm/trunk-jpl/src/m/model/solve/loadresultsfromcluster.py
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/loadresultsfromcluster.py	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/loadresultsfromcluster.py	(revision 13004)
@@ -0,0 +1,61 @@
+import os
+import platform
+import socket
+from MatlabFuncs import *
+
+def loadresultsfromcluster(md,runtimename=False):
+	"""
+	LOADRESULTSFROMCLUSTER - load results of solution sequence from cluster
+ 
+	   Usage:
+	      md=loadresultsfromcluster(md,runtimename);
+	"""
+
+	#retrieve cluster, to be able to call its methods
+	cluster=md.cluster
+
+	if runtimename:
+		md.private.runtimename=runtimename
+	end
+
+	#Download outputs from the cluster
+	filelist=[md.miscellaneous.name+'.outlog',md.miscellaneous.name+'.errlog']
+	if md.qmu.isdakota:
+		filelist.append(md.miscellaneous.name+'.qmu.err')
+		filelist.append(md.miscellaneous.name+'.qmu.out')
+		if 'tabular_graphics_data' in md.qmu.params:
+			if md.qmu.params['tabular_graphics_data']:
+				filelist.append('dakota_tabular.dat')
+		filelist.append(md.miscellaneous.name+'.outbin')
+	Download(cluster,md.private.runtimename,filelist)
+
+	#If we are here, no errors in the solution sequence, call loadresultsfromdisk.
+	md=loadresultsfromdisk(md,md.miscellaneous.name+'.outbin')
+
+	#erase the log and output files
+	if md.qmu.isdakota:
+		os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.outlog'))
+		os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.errlog'))
+	else:
+		os.remove(md.miscellaneous.name+'.outlog')
+		os.remove(md.miscellaneous.name+'.errlog')
+		os.remove(md.miscellaneous.name+'.outbin')
+		if not 'Windows' in platform.system():
+			os.remove(md.private.runtimename+'.tar.gz')
+
+	#erase input file if run was carried out on same platform.
+	hostname=socket.gethostname().lower().split('.')[0]
+	if strcmpi(hostname,cluster.name):
+		if md.qmu.isdakota:
+			os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.bin'))
+			os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.queue'))
+		else:
+			os.remove(md.miscellaneous.name+'.bin')
+			os.remove(md.miscellaneous.name+'.petsc')
+			if not 'Windows' in platform.system():
+				os.remove(md.miscellaneous.name+'.queue')
+			else:
+				os.remove(md.miscellaneous.name+'.bat')
+
+	return md
+
Index: /issm/trunk-jpl/src/m/model/solve/loadresultsfromdisk.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/loadresultsfromdisk.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/loadresultsfromdisk.m	(revision 13004)
@@ -0,0 +1,61 @@
+function md=loadresultsfromdisk(md,filename)
+%LOADRESULTSFROMDISK - load results of solution sequence from disk file "filename"            
+%
+%   Usage:
+%      md=loadresultsfromdisk(md,filename);
+
+%check number of inputs/outputs
+if ((nargin~=2) | (nargout~=1)),
+	help loadresultsfromdisk;
+	error('loadresultsfromdisk: error message.');
+end
+
+if ~md.qmu.isdakota,
+
+	%Check that file exists
+	if ~exist(filename,'file'),
+		error(['binary file ' filename ' not found.']);
+	end
+
+	%initialize md.results if not a structure yet
+	if ~isstruct(md.results),
+		md.results=struct();
+	end
+
+	%load results onto model
+	structure=parseresultsfromdisk(filename,~md.settings.io_gather);
+	if isempty(fieldnames(structure)),
+		error(['No result found in binary file ' filename '. Check for solution crash.']);
+	end
+	md.results.(structure(1).SolutionType)=structure;
+
+	%recover solution_type from results
+	md.private.solution=structure(1).SolutionType;
+
+	%read log files onto  fields
+	if exist([md.miscellaneous.name '.errlog'],'file'),
+		md.results.(structure(1).SolutionType)(1).errlog=char(textread([md.miscellaneous.name '.errlog'],'%s','delimiter','\n'));
+	else
+		md.results.(structure(1).SolutionType)(1).errlog='';
+	end
+
+	if exist([md.miscellaneous.name '.outlog'],'file'),
+		md.results.(structure(1).SolutionType)(1).outlog=char(textread([md.miscellaneous.name '.outlog'],'%s','delimiter','\n'));
+	else
+		md.results.(structure(1).SolutionType)(1).outlog='';
+	end
+
+	if ~isempty(md.results.(structure(1).SolutionType)(1).errlog),
+		disp(['loadresultsfromcluster info message: error during solution. Check your errlog and outlog model fields']);
+	end
+
+
+%post processes qmu results if necessary
+else
+
+	if isscalar(md.private.solution),
+		md.private.solution=EnumToString(md.private.solution);
+	end
+	md=postqmu(md);
+	cd ..
+end
Index: /issm/trunk-jpl/src/m/model/solve/loadresultsfromdisk.py
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/loadresultsfromdisk.py	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/loadresultsfromdisk.py	(revision 13004)
@@ -0,0 +1,60 @@
+import os
+
+def loadresultsfromdisk(md,filename):
+	"""
+	LOADRESULTSFROMDISK - load results of solution sequence from disk file "filename"            
+ 
+	   Usage:
+	      md=loadresultsfromdisk(md=False,filename=False);
+	"""
+
+	#check number of inputs/outputs
+	if not md or not filename:
+		raise ValueError("loadresultsfromdisk: error message.")
+
+	if not md.qmu.isdakota:
+
+		#Check that file exists
+		if not os.path.exists(filename):
+			raise ValueError("binary file '%s' not found." % filename)
+
+		#initialize md.results if not a structure yet
+		if not isinstance(md.results,dict):
+			md.results={}
+
+		#load results onto model
+		structure=parseresultsfromdisk(filename,~md.settings.io_gather)
+		if not len(structure):
+			raise RuntimeError("No result found in binary file '%s'. Check for solution crash." % filename)
+		end
+		md.results[structure[1]['SolutionType']]=structure;
+
+		#recover solution_type from results
+		md.private.solution=structure[1]['SolutionType']
+
+		#read log files onto fields
+		if os.path.exists(md.miscellaneous.name+'.errlog'):
+			with open(md.miscellaneous.name+'.errlog','r') as f:
+				md.results[structure[1]['SolutionType']]['errlog']=[line[:-1] for line in f]
+		else:
+			md.results[structure[1]['SolutionType']]['errlog']=[]
+
+		if os.path.exists(md.miscellaneous.name+'.outlog'):
+			with open(md.miscellaneous.name+'.outlog','r') as f:
+				md.results[structure[1]['SolutionType']]['outlog']=[line[:-1] for line in f]
+		else:
+			md.results[structure[1]['SolutionType']]['outlog']=[]
+
+		if len(md.results[structure[1]['SolutionType']]['errlog']):
+			print ("loadresultsfromcluster info message: error during solution. Check your errlog and outlog model fields.")
+
+	#post processes qmu results if necessary
+	else:
+
+		if not isinstance(md.private.solution,str):
+			md.private.solution=EnumToString(md.private.solution)
+		md=postqmu(md)
+		os.chdir('..')
+
+	return md
+
Index: /issm/trunk-jpl/src/m/model/solve/marshall.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/marshall.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/marshall.m	(revision 13004)
@@ -0,0 +1,49 @@
+function marshall(md)
+%MARSHALL - outputs a compatible binary file from @model md, for certain solution type.
+%
+%   The routine creates a compatible binary file from @model md
+%   This binary file will be used for parallel runs in JPL-package
+%
+%   Usage:
+%      marshall(md)
+
+disp(['marshalling file ' md.miscellaneous.name '.bin']);
+
+%open file for binary writing
+fid=fopen([ md.miscellaneous.name '.bin'],'wb');
+if fid==-1,
+	error(['marshall error message: could not open ' [md.miscellaneous.name '.bin'],' file for binary writing']);
+end
+
+%First, write MaximumNumberOfEnum to make sure that the Enums are synchronized
+WriteData(fid,'enum',MaximumNumberOfEnums(),'data',true,'format','Boolean');
+
+%Go through all model fields: check that it is a class and call checkconsistency
+fields=properties('model');
+for i=1:length(fields),
+	field=fields{i};
+
+	%Some properties do not need to be marshalled
+	if ismember(field,{'results' 'radaroverlay' 'solver' 'cluster'  'flaim' 'private'}),
+		continue;
+	end
+
+	%Check that current field is an object
+	if ~isobject(md.(field))
+		error(['field ''' char(field) ''' is not an object']);
+	end
+
+	%Marshall current object
+	%disp(['marshalling ' field '...']);
+	if verLessThan('matlab', '7.6')
+		marshall(md.(field),fid);
+	else
+		md.(field).marshall(fid);
+	end
+end
+
+%close file
+st=fclose(fid);
+if st==-1,
+	error(['marshall error message: could not close file ' [md.miscellaneous.name '.bin']]);
+end
Index: /issm/trunk-jpl/src/m/model/solve/marshall.py
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/marshall.py	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/marshall.py	(revision 13004)
@@ -0,0 +1,47 @@
+from WriteData import *
+
+def marshall(md):
+	"""
+	MARSHALL - outputs a compatible binary file from @model md, for certain solution type.
+
+	   The routine creates a compatible binary file from @model md
+	   This binary file will be used for parallel runs in JPL-package
+
+	   Usage:
+	      marshall(md)
+	"""
+
+	print "marshalling file '%s.bin'." % md.miscellaneous.name
+
+	#open file for binary writing
+	try:
+		fid=open(md.miscellaneous.name+'.bin','wb')
+	except IOError as e:
+		raise IOError("marshall error message: could not open '%s.bin' file for binary writing." % md.miscellaneous.name)
+
+	#First, write MaximumNumberOfEnum to make sure that the Enums are synchronized
+	WriteData(fid,'enum',MaximumNumberOfEnums(),'data',True,'format','Boolean')
+
+	#Go through all model fields: check that it is a class and call checkconsistency
+	fields=vars(md)
+
+	for field in fields.iterkeys():
+
+		#Some properties do not need to be marshalled
+		if field in ['results','radaroverlay','solver','cluster','flaim','private']:
+			continue
+
+		#Check that current field is an object
+		if not hasattr(getattr(md,field),'marshall'):
+			raise TypeError("field '%s' is not an object." % field)
+
+		#Marshall current object
+		#print "marshalling %s ..." % field
+		exec("md.%s.marshall(fid)" % field)
+
+	#close file
+	try:
+		f.close(fid)
+	except IOError as e:
+		raise IOError("marshall error message: could not close file '%s.bin'." % md.miscellaneous.name)
+
Index: /issm/trunk-jpl/src/m/model/solve/process_solve_options.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/process_solve_options.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/process_solve_options.m	(revision 13004)
@@ -0,0 +1,39 @@
+function outoptions=process_solve_options(options)
+%DEFAULT_SOLVE_OPTIONS - set up default options for solve phase
+%
+%   Usage:
+%      options=process_solve_options(options)
+%
+%   See also: SOLVE
+
+%solution_type: check on this option, error out otherwise
+solution_type=getfieldvalue(options,'solution_type');
+if ~ismember(solution_type,[DiagnosticSolutionEnum,PrognosticSolutionEnum,ThermalSolutionEnum,...
+		SteadystateSolutionEnum,TransientSolutionEnum,EnthalpySolutionEnum,...
+		BalancethicknessSolutionEnum,BedSlopeSolutionEnum,SurfaceSlopeSolutionEnum,HydrologySolutionEnum,FlaimSolutionEnum]),
+	error(['process_solve_options error message: solution_type ' EnumToString(solution_type) ' not supported yet!']);
+end
+outoptions.solution_type=solution_type;
+
+outoptions.upload=getfieldvalue(options,'upload','off');
+outoptions.batch=getfieldvalue(options,'batch','no');
+outoptions.loadonly=getfieldvalue(options,'loadonly',false);
+outoptions.directory=getfieldvalue(options,'directory','');
+
+%  process qmu arguments
+outoptions.qmudir=getfieldvalue(options,'qmudir',['qmu' num2str(feature('GetPid'))]);  % qmudir =['qmu_' datestr(now,'yyyymmdd_HHMMSS')];
+outoptions.qmufile=getfieldvalue(options,'qmufile','qmu');% qmufile cannot be changed unless ????script.sh is also changed
+outoptions.overwrite=getfieldvalue(options,'overwrite','n');
+outoptions.keep=getfieldvalue(options,'keep','n');
+outoptions.ivar=getfieldvalue(options,'ivar',1);
+outoptions.iresp=getfieldvalue(options,'iresp',1);
+outoptions.imethod=getfieldvalue(options,'imethod',1);
+outoptions.iparams=getfieldvalue(options,'iparams',1);
+outoptions.runmpi=getfieldvalue(options,'runmpi',false);
+
+%  process flaim arguments
+outoptions.fmdir=getfieldvalue(options,'fmdir',['fm' num2str(feature('GetPid'))]);
+outoptions.overwrite=getfieldvalue(options,'overwrite','n');
+outoptions.keep=getfieldvalue(options,'keep','y');
+outoptions.latsgn=getfieldvalue(options,'latsgn',0);
+outoptions.cmap=getfieldvalue(options,'cmap',[]);
Index: /issm/trunk-jpl/src/m/model/solve/process_solve_options.py
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/process_solve_options.py	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/process_solve_options.py	(revision 13004)
@@ -0,0 +1,48 @@
+import os
+from EnumDefinitions import *
+
+def process_solve_options(options):
+	"""
+	DEFAULT_SOLVE_OPTIONS - set up default options for solve phase
+ 
+	   Usage:
+	      options=process_solve_options(options)
+ 
+	   See also: SOLVE
+	"""
+
+	outoptions={}
+
+	#solution_type: check on this option, error out otherwise
+	solution_type=options.getfieldvalue('solution_type')
+	if not solution_type in (DiagnosticSolutionEnum,PrognosticSolutionEnum,ThermalSolutionEnum,\
+			SteadystateSolutionEnum,TransientSolutionEnum,EnthalpySolutionEnum,\
+			BalancethicknessSolutionEnum,BedSlopeSolutionEnum,SurfaceSlopeSolutionEnum,HydrologySolutionEnum,FlaimSolutionEnum):
+		raise ValueError("process_solve_options error message: solution_type '%s' not supported yet!" % EnumToString(solution_type))
+	outoptions['solution_type']=solution_type
+
+	outoptions['upload']=options.getfieldvalue('upload','off')
+	outoptions['batch']=options.getfieldvalue('batch','no')
+	outoptions['loadonly']=options.getfieldvalue('loadonly',False)
+	outoptions['directory']=options.getfieldvalue('directory','')
+
+	#  process qmu arguments
+	outoptions['qmudir']=options.getfieldvalue('qmudir','qmu'+str(os.getpid()))
+	outoptions['qmufile']=options.getfieldvalue('qmufile','qmu')    # qmufile cannot be changed unless ????script.sh is also changed
+	outoptions['overwrite']=options.getfieldvalue('overwrite','n')
+	outoptions['keep']=options.getfieldvalue('keep','n')
+	outoptions['ivar']=options.getfieldvalue('ivar',1)
+	outoptions['iresp']=options.getfieldvalue('iresp',1)
+	outoptions['imethod']=options.getfieldvalue('imethod',1)
+	outoptions['iparams']=options.getfieldvalue('iparams',1)
+	outoptions['runmpi']=options.getfieldvalue('runmpi',False)
+
+	#  process flaim arguments
+	outoptions['fmdir']=options.getfieldvalue('fmdir','fm'+str(os.getpid()))
+	outoptions['overwrite']=options.getfieldvalue('overwrite','n')
+	outoptions['keep']=options.getfieldvalue('keep','y')
+	outoptions['latsgn']=options.getfieldvalue('latsgn',0)
+	outoptions['cmap']=options.getfieldvalue('cmap',[])
+
+	return outoptions
+
Index: /issm/trunk-jpl/src/m/model/solve/solve.m
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/solve.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/solve.m	(revision 13004)
@@ -0,0 +1,121 @@
+function md=solve(md,solutionenum,varargin)
+%SOLVE - apply solution sequence for this model
+%
+%   Usage:
+%      md=solve(md,solutionenum,varargin)
+%      where varargin is a lit of paired arguments of string OR enums
+%
+%   solution types available comprise:
+%		 - DiagnosticSolutionEnum
+%		 - PrognosticSolutionEnum
+%		 - ThermalSolutionEnum
+%		 - SteadystateSolutionEnum
+%		 - TransientSolutionEnum...
+%		 - BalancethicknessSolutionEnum
+%		 - BedSlopeSolutionEnum
+%		 - SurfaceSlopeSolutionEnum
+%		 - HydrologySolutionEnum
+%		 - FlaimSolutionEnum
+%
+%  extra options:
+%      - loadonly : does not solve. only load results
+%
+%   Examples:
+%      md=solve(md,DiagnosticSolutionEnum);
+
+%recover and process solve options
+options=pairoptions(varargin{:},'solution_type',solutionenum);
+options=process_solve_options(options);
+
+%recover some fields
+md.private.solution=options.solution_type;
+cluster=md.cluster;
+
+%check model consistency
+disp('checking model consistency');
+if (solutionenum == FlaimSolutionEnum)
+	md.private.isconsistent=true;
+	md=checkconsistency(md.mesh,md,solutionenum);
+	md=checkconsistency(md.flaim,md,solutionenum);
+	if md.private.isconsistent==false,
+		error('Model not consistent, see messages above');
+	end
+else
+	ismodelselfconsistent(md),
+end
+
+%First, build a runtime name that is unique
+c=clock;
+md.private.runtimename=sprintf('%s-%02i-%02i-%04i-%02i-%02i-%02i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
+
+%if running qmu analysis, some preprocessing of dakota files using models
+%fields needs to be carried out. 
+if md.qmu.isdakota,
+	md=preqmu(md,options);
+end
+
+%flaim analysis
+if (options.solution_type == FlaimSolutionEnum)
+	md=flaim_sol(md,options);
+	md.private.solution=EnumToString(options.solution_type);
+	return;
+end
+
+%Do we load results only?
+if options.loadonly,  
+	md=loadresultsfromcluster(md);
+	return;
+end
+
+%we need to make sure we have PETSC support, otherwise, we run with only one cpu: 
+if ~ispetsc,
+	disp('PETSC support not included, running on 1 cpu only!');
+	cluster.np=1;
+end
+
+
+%Wite all input files
+marshall(md);                                          % bin file
+PetscFile(md.solver,[md.miscellaneous.name '.petsc']); % petsc file
+BuildQueueScript(cluster,md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof); % queue file
+
+
+%Stop here if batch mode
+if strcmpi(options.batch,'yes')
+	disp('batch mode requested: not launching job interactively');
+	disp('launch solution sequence on remote cluster by hand');
+	return;
+end
+
+%Launch job
+modelname = md.miscellaneous.name;
+filelist  = {[modelname '.bin '] [modelname '.petsc '] [modelname '.queue ']};
+if md.qmu.isdakota,
+	filelist{end+1} = [modelname '.qmu.in'];
+end
+LaunchQueueJob(cluster,md.miscellaneous.name,md.private.runtimename,filelist);
+
+%did we even try to run? if so, wait on lock
+if strcmpi(options.upload,'on'),
+	disp('solve done uploading test decks');
+	return;
+end
+
+%wait on lock
+if md.settings.waitonlock>0,
+	%we wait for the done file
+	islock=waitonlock(md);
+	if islock==0, %no results to be loaded
+		disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
+	else          %load results
+		disp('loading results from cluster');
+		md=loadresultsfromcluster(md);
+	end
+end
+
+%post processes qmu results if necessary
+if md.qmu.isdakota,
+	if ~strncmpi(options.keep,'y',1)
+		system(['rm -rf qmu' num2str(feature('GetPid'))]);
+	end
+end
Index: /issm/trunk-jpl/src/m/model/solve/solve.py
===================================================================
--- /issm/trunk-jpl/src/m/model/solve/solve.py	(revision 13004)
+++ /issm/trunk-jpl/src/m/model/solve/solve.py	(revision 13004)
@@ -0,0 +1,119 @@
+import datetime
+import os
+import shutil
+from pairoptions import *
+from process_solve_options import *
+from EnumDefinitions import *
+from ismodelselfconsistent import *
+
+def solve(md,solutionenum,*args):
+	"""
+	SOLVE - apply solution sequence for this model
+ 
+	   Usage:
+	      md=solve(md,solutionenum,varargin)
+	      where varargin is a list of paired arguments of string OR enums
+ 
+	   solution types available comprise:
+	      - DiagnosticSolutionEnum
+	      - PrognosticSolutionEnum
+	      - ThermalSolutionEnum
+	      - SteadystateSolutionEnum
+	      - TransientSolutionEnum...
+	      - BalancethicknessSolutionEnum
+	      - BedSlopeSolutionEnum
+	      - SurfaceSlopeSolutionEnum
+	      - HydrologySolutionEnum
+	      - FlaimSolutionEnum
+ 
+	   extra options:
+	      - loadonly : does not solve. only load results
+ 
+	   Examples:
+	      md=solve(md,DiagnosticSolutionEnum);
+	"""
+
+	#recover and process solve options
+	options=pairoptions('solution_type',solutionenum,*args)
+	options=process_solve_options(options)
+
+	#recover some fields
+	md.private.solution=options['solution_type']
+	cluster=md.cluster
+
+	#check model consistency
+	print "checking model consistency"
+	if solutionenum == FlaimSolutionEnum:
+		md.private.isconsistent=True
+		md.mesh.checkconsistency(md,solutionenum)
+		md.flaim.checkconsistency(md,solutionenum)
+		if not md.private.isconsistent:
+			raise RuntimeError("Model not consistent, see messages above.")
+	else:
+		ismodelselfconsistent(md)
+
+	#First, build a runtime name that is unique
+	c=datetime.datetime.now()
+	md.private.runtimename="%s-%02i-%02i-%04i-%02i-%02i-%02i-%i" % (md.miscellaneous.name,c.month,c.day,c.year,c.hour,c.minute,c.second,os.getpid())
+
+	#if running qmu analysis, some preprocessing of dakota files using models
+	#fields needs to be carried out. 
+	if md.qmu.isdakota:
+		md=preqmu(md,options)
+
+	#flaim analysis
+	if options['solution_type'] == FlaimSolutionEnum:
+		md=flaim_sol(md,options)
+		md.private.solution=EnumToString(options['solution_type'])
+		return md
+
+	#Do we load results only?
+	if options['loadonly']:  
+		md=loadresultsfromcluster(md)
+		return md
+
+	#Wite all input files
+	marshall(md)                                           # bin file
+	md.solver.PetscFile(md.miscellaneous.name+'.petsc')    # petsc file
+	cluster.BuildQueueScript(md.miscellaneous.name,md.private.runtimename,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof)    # queue file
+
+	#we need to make sure we have PETSC support, otherwise, we run with only one cpu: 
+	if not ispetsc:
+		print "PETSC support not included, running on 1 cpu only!"
+		cluster.np=1
+
+	#Stop here if batch mode
+	if strcmpi(options['batch'],'yes'):
+		print 'batch mode requested: not launching job interactively'
+		print 'launch solution sequence on remote cluster by hand'
+		return md
+
+	#Launch job
+	modelname = md.miscellaneous.name
+	filelist  = [modelname+'.bin ',modelname+'.petsc ',modelname+'.queue ']
+	if md.qmu.isdakota:
+		filelist.append(modelname+'.qmu.in')
+	cluster.LaunchQueueJob(md.miscellaneous.name,md.private.runtimename,filelist)
+
+	#did we even try to run? if so, wait on lock
+	if strcmpi(options['upload'],'on'):
+		print 'solve done uploading test decks'
+		return md
+
+	#wait on lock
+	if md.settings.waitonlock>0:
+		#we wait for the done file
+		islock=waitonlock(md)
+		if islock==0:    #no results to be loaded
+			print 'The results must be loaded manually with md=loadresultsfromcluster(md).'
+		else:            #load results
+			print 'loading results from cluster'
+			md=loadresultsfromcluster(md)
+
+	#post processes qmu results if necessary
+	if md.qmu.isdakota:
+		if not strncmpi(options['keep'],'y',1):
+			shutil.rmtree('qmu'+str(os.getpid()))
+
+	return md
+
Index: /issm/trunk-jpl/src/m/os/petscversion.m
===================================================================
--- /issm/trunk-jpl/src/m/os/petscversion.m	(revision 13004)
+++ /issm/trunk-jpl/src/m/os/petscversion.m	(revision 13004)
@@ -0,0 +1,26 @@
+function PETSC_VERSION=petscversion()
+%PETSCVERSION - recover petsc version number, inside config.h file
+%
+%   Usage:
+%       PETSC_VERSION=petscversion();
+
+%default
+PETSC_VERSION=3;
+
+configfile=[issmdir() '/config.h'];
+if ~exist(configfile,'file'),
+	error(['File ' configfile ' not found. ISSM has not been configured yet!']);
+end
+
+%go through the file, and recover the line we want
+fid=fopen(configfile,'r');
+if(fid==-1), error(['could not open file: ' configfile]); end
+
+while(true),
+	tline=fgets(fid);
+	if ~ischar(tline), break, end
+	if  strncmp(tline,'#define _PETSC_MAJOR_',21),
+		PETSC_VERSION=str2num(tline(23));
+	end
+end
+fclose(fid);
Index: /issm/trunk-jpl/src/m/os/petscversion.py
===================================================================
--- /issm/trunk-jpl/src/m/os/petscversion.py	(revision 13004)
+++ /issm/trunk-jpl/src/m/os/petscversion.py	(revision 13004)
@@ -0,0 +1,34 @@
+import os
+from issmdir import *
+from MatlabFuncs import *
+
+def petscversion():
+	"""
+	PETSCVERSION - recover petsc version number, inside config.h file
+ 
+	   Usage:
+	      PETSC_VERSION=petscversion();
+	"""
+
+	#default
+	PETSC_VERSION=3
+
+	configfile=os.path.join(issmdir(),'config.h')
+	if not os.path.exists(configfile):
+		raise RuntimeError("File '%s' not found. ISSM has not been configured yet!" % configfile)
+
+	#go through the file, and recover the line we want
+	try:
+		fid=open(configfile,'r')
+	except IOError as e:
+		raise IOerror("could not open file: '%s'" % configfile)
+
+	for tline in fid:
+		if strncmp(tline,'#define _PETSC_MAJOR_',21):
+			PETSC_VERSION=int(tline[22])
+			break
+
+	fid.close()
+
+	return PETSC_VERSION
+
