Index: /issm/trunk-jpl/src/m/array/ArrayOperations.js
===================================================================
--- /issm/trunk-jpl/src/m/array/ArrayOperations.js	(revision 19718)
+++ /issm/trunk-jpl/src/m/array/ArrayOperations.js	(revision 19719)
@@ -55,2 +55,45 @@
 	return list;
 } //}}}
+function IsArray(object) { //{{{
+
+	if( Object.prototype.toString.call( object ) === '[object Array]' ) {
+		return 1;
+	}
+	else return 0;
+
+} //}}}
+function ArrayNot(array) { //{{{
+
+	var notarray=array;
+	for (i=0;i<array.length;i++)notarray[i]=-array[i];
+	return notarray;
+} //}}}
+function ArrayAnd(array1,array2) { //{{{
+
+	var array=array1;
+	for (i=0;i<array1.length;i++)array[i]=array1[i] & array2[i];
+	return array;
+} //}}}
+function NewArrayFill(size,value) { //{{{
+
+	return new Array(size).fill(value);
+} //}}}
+function ArrayFind(array,value) { //{{{
+	
+	//find number of indices
+	var count=0;
+	for (i=0;i<array.length;i++)if(array[i]==value)count++;
+
+	//allocate:
+	var indices= NewArrayFill(count,0);
+
+	//fill in:
+	count=0;
+	for (i=0;i<array.length;i++){
+		if(array[i]==value){
+			indices[count]=i;
+			count++;
+		}
+	}
+	return indices;
+} //}}}
Index: /issm/trunk-jpl/src/m/classes/constants.js
===================================================================
--- /issm/trunk-jpl/src/m/classes/constants.js	(revision 19719)
+++ /issm/trunk-jpl/src/m/classes/constants.js	(revision 19719)
@@ -0,0 +1,39 @@
+//CONSTANTS class definition
+//
+//   Usage:
+//      constants=constants();
+
+function constants() {
+	//methods 
+		this.setdefaultparameters = function (){ //{{{
+
+			//acceleration due to gravity (m/s^2)
+			this.g=9.81;
+
+			//Earth's rotation speed 
+			this.omega = 7.292*1e-5;
+
+			//converstion from year to seconds
+			this.yts=365*24*3600;
+
+			//the reference temperature for enthalpy model (cf Aschwanden)
+			this.referencetemperature=223.15;
+		}// }}}
+		this.disp = function () { //{{{
+			console.log(sprintf("   Constants parameters:")); 
+			
+			fielddisplay(this,'g','gravitational acceleration [m/s^2]');
+			fielddisplay(this,'omega','angular velocity of Earth [rad/s]');
+			fielddisplay(this,'yts','number of seconds in a year [s/yr]');
+			fielddisplay(this,'referencetemperature','reference temperature used in the enthalpy model [K]');
+
+		} //}}}
+	//properties 
+	// {{{
+		this.g                    = 0.;
+		this.omega                = 0.;
+		this.yts                  = 0.;
+		this.referencetemperature = 0.;
+		this.setdefaultparameters();
+		//}}}
+}
Index: /issm/trunk-jpl/src/m/classes/geometry.js
===================================================================
--- /issm/trunk-jpl/src/m/classes/geometry.js	(revision 19719)
+++ /issm/trunk-jpl/src/m/classes/geometry.js	(revision 19719)
@@ -0,0 +1,28 @@
+//GEOMETRY class definition
+//
+//   Usage:
+//      geometry=geometry();
+
+function geometry(){
+	//methods 
+		this.setdefaultparameters = function (){ //{{{
+		}// }}}
+		this.disp = function () { //{{{
+			console.log(sprintf("   Geometry parameters:"));
+
+			fielddisplay(this,'surface','ice upper surface elevation [m]');
+			fielddisplay(this,'thickness','ice thickness [m]');
+			fielddisplay(this,'base','ice base elevation [m]');
+			fielddisplay(this,'bed','bed elevation [m]');
+		} //}}}
+	//properties 
+	// {{{
+		this.surface           = NaN;
+		this.thickness         = NaN;
+		this.base              = NaN;
+		this.bed               = NaN;
+		this.hydrostatic_ratio = NaN;
+		this.setdefaultparameters();
+		//}}}
+
+}
Index: /issm/trunk-jpl/src/m/classes/mask.js
===================================================================
--- /issm/trunk-jpl/src/m/classes/mask.js	(revision 19719)
+++ /issm/trunk-jpl/src/m/classes/mask.js	(revision 19719)
@@ -0,0 +1,22 @@
+//MASK class definition
+//
+//   Usage:
+//      mask= new mask();
+
+function mask () {
+	//properties 
+	// {{{
+		this.groundedice_levelset                           = NaN;
+		this.ice_levelset                           = NaN;
+		//}}}
+	//methods 
+		this.setdefaultparameters = function (){ //{{{
+		} // }}}
+		this.disp = function () { //{{{
+			console.log(sprintf("   mask:")); 
+
+			fielddisplay(this,"groundedice_levelset","is ice grounded ? grounded ice if > 0, grounding line position if = 0, floating ice if < 0");
+			fielddisplay(this,"ice_levelset","presence of ice if < 0, icefront position if = 0, no ice if > 0");
+		} //}}}
+
+}
Index: /issm/trunk-jpl/src/m/classes/mesh2d.js
===================================================================
--- /issm/trunk-jpl/src/m/classes/mesh2d.js	(revision 19718)
+++ /issm/trunk-jpl/src/m/classes/mesh2d.js	(revision 19719)
@@ -5,29 +5,4 @@
 
 function mesh2d () {
-	//properties 
-	// {{{
-		this.x                           = NaN;
-		this.y                           = NaN;
-		this.elements                    = NaN;
-		this.numberofelements            = 0;
-		this.numberofvertices            = 0;
-		this.numberofedges               = 0;
-
-		this.lat                         = NaN;
-		this.long                        = NaN;
-		this.epsg                        = 0;
-
-		this.vertexonboundary            = NaN;
-
-		this.edges                       = NaN;
-		this.segments                    = NaN;
-		this.segmentmarkers              = NaN;
-		this.vertexconnectivity          = NaN;
-		this.elementconnectivity         = NaN;
-		this.average_vertex_connectivity = 0;
-
-		this.extractedvertices           = NaN;
-		this.extractedelements           = NaN;
-		//}}}
 	//methods 
 		this.setdefaultparameters = function () //{{{
@@ -69,4 +44,31 @@
 			fielddisplay(this,"epsg","EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)");
 		} //}}}
+	//properties 
+	// {{{
+		this.x                           = NaN;
+		this.y                           = NaN;
+		this.elements                    = NaN;
+		this.numberofelements            = 0;
+		this.numberofvertices            = 0;
+		this.numberofedges               = 0;
+
+		this.lat                         = NaN;
+		this.long                        = NaN;
+		this.epsg                        = 0;
+
+		this.vertexonboundary            = NaN;
+
+		this.edges                       = NaN;
+		this.segments                    = NaN;
+		this.segmentmarkers              = NaN;
+		this.vertexconnectivity          = NaN;
+		this.elementconnectivity         = NaN;
+		this.average_vertex_connectivity = 0;
+
+		this.extractedvertices           = NaN;
+		this.extractedelements           = NaN;
+
+		this.setdefaultparameters();
+		//}}}
 
 }
Index: /issm/trunk-jpl/src/m/classes/model.js
===================================================================
--- /issm/trunk-jpl/src/m/classes/model.js	(revision 19718)
+++ /issm/trunk-jpl/src/m/classes/model.js	(revision 19719)
@@ -49,7 +49,7 @@
 			//initialize subclasses
 			this.mesh             = new mesh2d();
-//			this.mask             = mask();
-//			this.constants        = constants();
-//			this.geometry         = geometry();
+			this.mask             = new mask();
+			this.constants        = new constants();
+			this.geometry         = new geometry();
 //			this.initialization   = initialization();
 //			this.smb              = SMBforcing();
Index: /issm/trunk-jpl/src/m/geometry/FlagElements.js
===================================================================
--- /issm/trunk-jpl/src/m/geometry/FlagElements.js	(revision 19719)
+++ /issm/trunk-jpl/src/m/geometry/FlagElements.js	(revision 19719)
@@ -0,0 +1,49 @@
+function FlagElements(md,region){
+//FLAGELEMENTS - flag the elements in an region
+//
+//   The region can be given as a string, or as a javascript array
+//
+//   Usage: 
+//      flag=FlagElements(md,region);
+//
+//   Example:
+//      flag=FlagElements(md,'all');
+//      flag=FlagElements(md,'');
+//      flag=FlagElements(md,domain);
+
+	//variables
+	var flag;
+	
+	if (typeof region == 'string'){
+		if (region === ''){
+			flag=NewArrayFill(md.mesh.numberofelements,0);
+		}
+		else if (region === 'all'){
+			flag=NewArrayFill(md.mesh.numberofelements,1);
+		}
+		else{
+			flag=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,region,'element',1);
+		}
+	}
+	else if(IsArray(region)){
+		if (region.length==md.mesh.numberofelements){
+			flag=region;
+		}
+		else if (region.length==md.mesh.numberofvertices){
+			var flag=NewArrayFill(md.mesh.numberofelements,0);
+			for (i=0;i<md.mesh.numberofelements;i++)
+				var sum=0;
+				for(j=0;j<md.mesh.elements[0].length;j++){
+					sum += region[md.mesh.element[i][j]-1];
+				}
+				if (sum==md.mesh.elements[0].length)flag[i]=1;
+		}
+		else{
+			console.error('Flaglist for region must be of same size as number of elements in model');
+		}
+	}
+	else{
+		console.error('Invalid region option');
+	}
+	return flag;
+}
Index: /issm/trunk-jpl/src/m/parameterization/setmask.js
===================================================================
--- /issm/trunk-jpl/src/m/parameterization/setmask.js	(revision 19718)
+++ /issm/trunk-jpl/src/m/parameterization/setmask.js	(revision 19719)
@@ -1,70 +1,78 @@
-function md=setmask(md,floatingicename,groundedicename,varargin)
-%SETMASK - establish boundaries between grounded and floating ice.
-%
-%   By default, ice is considered grounded. The contour floatingicename defines nodes 
-%   for which ice is floating. The contour groundedicename defines nodes inside an floatingice, 
-%   that are grounded (ie: ice rises, islands, etc ...)
-%   All input files are in the Argus format (extension .exp).
-%
-%   Usage:
-%      md=setmask(md,floatingicename,groundedicename)
-%
-%   Examples:
-%      md=setmask(md,'all','');
-%      md=setmask(md,'Iceshelves.exp','Islands.exp');
+function setmask(md,floatingice,groundedice){
+//SETMASK - establish boundaries between grounded and floating ice.
+//
+//   By default, ice is considered grounded. The contour floatingice defines nodes 
+//   for which ice is floating. The contour groundedice defines nodes inside a floatingice, 
+//   that are grounded (ie: ice rises, islands, etc ...)
+//   All inputs are either strings or actually javascript arrays (included in the html file)
+//   For example: 
+//
+//	   floatingice[0]['x']=[0,0,0,1];
+//	   floatingice[0]['y']=[0,1,1,1];
+//	   floatingice[1]['x']=[0,0.5,0.5,.5];
+//	   floatingice[1]['y']=[0,.5,.5,.5];
+//
+//
+//   Usage:
+//      md=setmask(md,floatingice,groundedice)
+//
+//   Examples:
+//      md=setmask(md,'all','');
+//      md=setmask(md,iceshelves,islands);
 
-%some checks on list of arguments
-if ((mod(nargin,2)==0) | (nargout~=1)),
-	help mask
-	error('mask error message');
-end
+	//variables: 
+	var  icedomain=[];
+	
+	//some checks on list of arguments
+	if (!((arguments.length==3) | (arguments.length==5))){
+		console.error('mask error message: wrong usage.');
+	}
 
-if(nargin>3)
-	if(varargin(1)=='icedomain'),
-		icedomainname=varargin(2);	
-	else
-		error('mask error message: wrong field specified. Only icedomain allowed for now.');
-	end
-	if ~exist(icedomainname),
-        error(['setmask error message: file ' icedomainname ' not found!']);
-	end
-end
+	if(arguments.length>3){
+		if (arguments[3]=='icedomain'){
+			icedomain=arguments[4];
+		}
+		else{
+			console.error('mask error message: wrong field specified. Only icedomain allowed for now.');
+		}
+		if (IsArray(icedomain)){
+			console.error('setmask error message: icedomain should be an array!');
+		}
+	}
+	
+	//Get assigned fields
+	x=md.mesh.x;
+	y=md.mesh.y;
+	elements=md.mesh.elements;
 
-%Get assigned fields
-x=md.mesh.x;
-y=md.mesh.y;
-elements=md.mesh.elements;
+	//Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. 
+	//Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. 
+	elementonfloatingice=FlagElements(md,floatingice);
+	elementongroundedice=FlagElements(md,groundedice);
 
-%Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
-elementonfloatingice=FlagElements(md,floatingicename);
-elementongroundedice=FlagElements(md,groundedicename);
+	//Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous 
+	//arrays come from domain outlines that can intersect one another: 
+	elementonfloatingice=ArrayAnd(elementonfloatingice,ArrayNot(elementongroundedice));
+	elementongroundedice=ArrayNot(elementonfloatingice);
 
-%Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous 
-%arrays come from domain outlines that can intersect one another: 
-elementonfloatingice=double((elementonfloatingice & ~elementongroundedice));
-elementongroundedice=double(~elementonfloatingice);
+	//the order here is important. we choose vertexongroundedice as default on the grounding line.
+	vertexonfloatingice=NewArrayFill(md.mesh.numberofvertices,0);
+	vertexongroundedice=NewArrayFill(md.mesh.numberofvertices,0);
+	pos=ArrayFind(elementongroundedice,1); for (i=0;i<pos.length;i++)for(j=0;j<3;j++) vertexongroundedice[md.mesh.elements[i,j]-1]=1;
+	pos=ArrayFind(vertexongroundedice,0); for (i=0;i<pos.length;i++)vertexonfloatingice[i]=1;
 
-%the order here is important. we choose vertexongroundedice as default on the grounding line.
-vertexonfloatingice=zeros(md.mesh.numberofvertices,1);
-vertexongroundedice=zeros(md.mesh.numberofvertices,1);
-vertexongroundedice(md.mesh.elements(find(elementongroundedice),:))=1;
-vertexonfloatingice(find(~vertexongroundedice))=1;
-%}}}
+	//level sets
+	groundedice_levelset=vertexongroundedice;
+	pos=ArrayFind(vertexongroundedice,0);for(i=0;i<pos.length;i++) groundedice_levelset[i]=-1;
+	md.mask.groundedice_levelset=groundedice_levelset;
 
-%level sets
-md.mask.groundedice_levelset=vertexongroundedice;
-md.mask.groundedice_levelset(find(vertexongroundedice==0.))=-1.;
-
-if(nargin>3)
-	if(varargin(1)=='icedomain')
-		md.mask.ice_levelset = 1.*ones(md.mesh.numberofvertices,1);
-		%use contourtomesh to set ice values inside ice domain
-		[vertexinsideicedomain,elementinsideicedomain]=ContourToMesh(elements,x,y,icedomainname,'node',1);
-		pos=find(vertexinsideicedomain==1.);
-		md.mask.ice_levelset(pos) = -1.;
-	end
-else
-	md.mask.ice_levelset = -1.*ones(md.mesh.numberofvertices,1);
-end
-
-
+	if(arguments.length>3){
+		md.mask.ice_levelset = NewArrayFill(md.mesh.numberofvertices,1.0);
+		//use contourtomesh to set ice values inside ice domain
+		[vertexinsideicedomain,elementinsideicedomain]=ContourToMesh(elements,x,y,icedomain,'node',1);
+		pos=ArrayFind(vertexinsideicedomain,1.0);for(i=0;i<pos.length;i++) md.mask.ice_levelset[pos]=-1;
+	}
+	else{
+		md.mask.ice_levelset = NewArrayFill(md.mesh.numberofvertices,-1);
+	}
+}
