Index: /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 5095)
+++ /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 5096)
@@ -126,4 +126,2 @@
 	*pmy_vertices=my_vertices;
 }
-
-
Index: /issm/trunk/src/c/objects/DofIndexing.cpp
===================================================================
--- /issm/trunk/src/c/objects/DofIndexing.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/DofIndexing.cpp	(revision 5096)
@@ -24,11 +24,7 @@
 	this->numberofdofs=UNDEF;
 	this->clone=0;
-
-	for (i=0;i<MAXDOFSPERNODE;i++){
-		/*assume dof is free, no constraints, no rigid body constraint: */
-		this->f_set[i]=1;
-		this->s_set[i]=0;
-		this->doflist[i]=UNDEF;
-	}
+	this->f_set=NULL;
+	this->s_set=NULL;
+	this->doflist=NULL;
 }
 /*}}}*/
@@ -45,5 +41,9 @@
 	this->clone=in->clone;
 
-	for(i=0;i<MAXDOFSPERNODE;i++){
+	this->f_set=(int*)xmalloc(this->numberofdofs*sizeof(int));
+	this->s_set=(int*)xmalloc(this->numberofdofs*sizeof(int));
+	this->doflist=(int*)xmalloc(this->numberofdofs*sizeof(int));
+
+	for(i=0;i<this->numberofdofs;i++){
 		this->f_set[i]=in->f_set[i];
 		this->s_set[i]=in->s_set[i];
@@ -63,5 +63,11 @@
 	this->clone=0;
 
-	for (i=0;i<MAXDOFSPERNODE;i++){
+	/*allocate: */
+	this->f_set=(int*)xmalloc(this->numberofdofs*sizeof(int));
+	this->s_set=(int*)xmalloc(this->numberofdofs*sizeof(int));
+	this->doflist=(int*)xmalloc(this->numberofdofs*sizeof(int));
+
+
+	for (i=0;i<this->numberofdofs;i++){
 		/*assume dof is free, no constraints, no rigid body constraint: */
 		this->f_set[i]=1;
@@ -94,5 +100,4 @@
 	printf("   set membership: f,s sets \n");
 	for(i=0;i<numberofdofs;i++){
-		if(i>MAXDOFSPERNODE)break;
 		printf("      dof %i: %i %i\n",i,f_set[i],s_set[i]);
 	}
@@ -101,5 +106,4 @@
 	printf("   doflist: |");
 	for(i=0;i<numberofdofs;i++){
-		if(i>MAXDOFSPERNODE)break;
 		printf(" %i |",doflist[i]);
 	}
@@ -122,7 +126,13 @@
 	memcpy(&numberofdofs,marshalled_dataset,sizeof(numberofdofs));marshalled_dataset+=sizeof(numberofdofs);
 	memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone);
-	memcpy(&f_set,marshalled_dataset,sizeof(f_set));marshalled_dataset+=sizeof(f_set);
-	memcpy(&s_set,marshalled_dataset,sizeof(s_set));marshalled_dataset+=sizeof(s_set);
-	memcpy(&doflist,marshalled_dataset,sizeof(doflist));marshalled_dataset+=sizeof(doflist);
+	
+	/*Allocate: */
+	this->f_set=(int*)xmalloc(this->numberofdofs*sizeof(int));
+	this->s_set=(int*)xmalloc(this->numberofdofs*sizeof(int));
+	this->doflist=(int*)xmalloc(this->numberofdofs*sizeof(int));
+
+	memcpy(f_set,marshalled_dataset,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int);
+	memcpy(s_set,marshalled_dataset,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int);
+	memcpy(doflist,marshalled_dataset,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int);
 	
 	/*return: */
@@ -149,7 +159,7 @@
 	memcpy(marshalled_dataset,&numberofdofs,sizeof(numberofdofs));marshalled_dataset+=sizeof(numberofdofs);
 	memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone);
-	memcpy(marshalled_dataset,&f_set,sizeof(f_set));marshalled_dataset+=sizeof(f_set);
-	memcpy(marshalled_dataset,&s_set,sizeof(s_set));marshalled_dataset+=sizeof(s_set);
-	memcpy(marshalled_dataset,&doflist,sizeof(doflist));marshalled_dataset+=sizeof(doflist);
+	memcpy(marshalled_dataset,f_set,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int);
+	memcpy(marshalled_dataset,s_set,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int);
+	memcpy(marshalled_dataset,doflist,numberofdofs*sizeof(int));marshalled_dataset+=numberofdofs*sizeof(int);
 
 	*pmarshalled_dataset=marshalled_dataset;
@@ -162,7 +172,7 @@
 	return sizeof(numberofdofs)+
 		sizeof(clone)+
-		sizeof(f_set)+
-		sizeof(s_set)+
-		sizeof(doflist)+
+		numberofdofs*sizeof(int)+
+		numberofdofs*sizeof(int)+
+		numberofdofs*sizeof(int)+
 		sizeof(int); //sizeof(int) for enum type
 }
Index: /issm/trunk/src/c/objects/DofIndexing.h
===================================================================
--- /issm/trunk/src/c/objects/DofIndexing.h	(revision 5095)
+++ /issm/trunk/src/c/objects/DofIndexing.h	(revision 5096)
@@ -6,11 +6,9 @@
 #define  _DOFINDEXING_H_
 
-#define MAXDOFSPERNODE 4
-
 class DofIndexing{
 	
 	public:
 
-		int numberofdofs; //number of dofs for a node.
+		int numberofdofs; //number of dofs for a node, variable
 
 		/*partitioning: */
@@ -18,9 +16,9 @@
 
 		/*boundary conditions sets: */
-		int     f_set[MAXDOFSPERNODE];
-		int     s_set[MAXDOFSPERNODE];
+		int*     f_set; //set on which we solve
+		int*     s_set; //set on which boundary conditions (dirichlet) are applied
 
 		/*list of degrees of freedom: */
-		int     doflist[MAXDOFSPERNODE]; //dof list on which we solve
+		int*     doflist; //dof list on which we solve
 
 		/*DofIndexing constructors, destructors {{{1*/
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 5096)
@@ -2048,6 +2048,5 @@
 	const int    numdof=2*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* 3d gaussian points: */
@@ -2172,5 +2171,5 @@
 		/* Get node coordinates and dof list: */
 		GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-		GetDofList(&doflist[0],&numberofdofspernode);
+		GetDofList(&doflist);
 
 		/*Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore 
@@ -2274,5 +2273,5 @@
 	xfree((void**)&third_gauss_area_coord2d);
 	xfree((void**)&gauss_weights2d);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -2285,7 +2284,6 @@
 	const int NDOF2=2;
 	const int numdofs=NDOF2*numgrids;
-	int       doflist[numdofs];
+	int*      doflist=NULL;
 	double    Ke_gg[numdofs][numdofs]={0.0};
-	int       numberofdofspernode;
 	bool      onbed;
 	bool      onsurface;
@@ -2306,5 +2304,5 @@
 	inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum);
 
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*Spawn 3 beam elements: */
@@ -2357,4 +2355,7 @@
 	MatSetValues(Kgg,numdofs,doflist,numdofs,doflist,(const double*)Ke_gg,ADD_VALUES);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -2367,6 +2368,5 @@
 	const int DOFPERGRID=4;
 	const int numdof=numgrids*DOFPERGRID;
-	int doflist[numdof];
-	int numberofdofspernode;
+	int*      doflist=NULL;
 
 	const int numgrids2d=3;
@@ -2469,5 +2469,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore 
@@ -2636,4 +2636,5 @@
 	xfree((void**)&vert_gauss_coord);
 	xfree((void**)&vert_gauss_weights);
+	xfree((void**)&doflist);
 
 	return;
@@ -2651,6 +2652,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* 3d gaussian points: */
@@ -2704,5 +2704,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore 
@@ -2763,4 +2763,5 @@
 	xfree((void**)&area_gauss_weights);
 	xfree((void**)&vert_gauss_weights);
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -2870,7 +2871,6 @@
 	const int    NDOF1=1;
 	const int    numdof=NDOF1*numgrids;
-	double xyz_list[numgrids][3];
-	int    doflist[numdof];
-	int    numberofdofspernode;
+	double       xyz_list[numgrids][3];
+	int*         doflist=NULL;
 
 	/* gaussian points: */
@@ -2947,5 +2947,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	// /*recovre material parameters: */
@@ -3088,4 +3088,13 @@
 	MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)K_terms,ADD_VALUES);
 
+	//Ice/ocean heat exchange flux on ice shelf base 
+	if(onbed && shelf){
+
+		tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
+		tria->CreateKMatrixThermal(Kgg);
+		delete tria->matice; delete tria;
+	}
+	
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
@@ -3094,12 +3103,6 @@
 	xfree((void**)&vert_gauss_weights);
 	xfree((void**)&vert_gauss_coord);
-
-	//Ice/ocean heat exchange flux on ice shelf base 
-	if(onbed && shelf){
-
-		tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
-		tria->CreateKMatrixThermal(Kgg);
-		delete tria->matice; delete tria;
-	}
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -3186,6 +3189,5 @@
 	const int    numdof=NDOF2*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* parameters: */
@@ -3262,5 +3264,5 @@
 		/* Get node coordinates and dof list: */
 		GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-		GetDofList(&doflist[0],&numberofdofspernode);
+		GetDofList(&doflist);
 
 		/*Get gaussian points and weights :*/
@@ -3327,5 +3329,5 @@
 	xfree((void**)&area_gauss_weights);
 	xfree((void**)&vert_gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3383,6 +3385,5 @@
 	const int NDOF2=2;
 	const int numdofs=NDOF2*numgrids;
-	int       doflist[numdofs];
-	int       numberofdofspernode;
+	int*      doflist=NULL;
 	double    pe_g[numdofs]={0.0};
 	double    xyz_list[numgrids][3];
@@ -3428,5 +3429,5 @@
 
 	/*recover doflist: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*recover some inputs: */
@@ -3523,4 +3524,5 @@
 	xfree((void**)&gauss_weights);
 	xfree((void**)&segment_gauss_coord);
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3535,7 +3537,6 @@
 	const int numdof=numgrids*DOFPERGRID;
 	const int numgrids2d=3;
-	int numdof2d=numgrids2d*DOFPERGRID;
-	int doflist[numdof];
-	int numberofdofspernode;
+	int       numdof2d=numgrids2d*DOFPERGRID;
+	int*      doflist=NULL;
 
 	/*Material properties: */
@@ -3627,5 +3628,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore 
@@ -3777,5 +3778,6 @@
 	xfree((void**)&area_gauss_weights);
 	xfree((void**)&vert_gauss_coord);
-	xfree((void**)&vert_gauss_weights);
+	xfree((void**)&vert_gauss_weights); 
+	xfree((void**)&doflist);
 
 }
@@ -3815,6 +3817,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* gaussian points: */
@@ -3876,5 +3877,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*Get gaussian points and weights :*/
@@ -3935,4 +3936,5 @@
 	xfree((void**)&area_gauss_weights);
 	xfree((void**)&vert_gauss_weights);
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4015,6 +4017,5 @@
 	const int  NDOF1=1;
 	const int  numdof=numgrids*NDOF1;
-	int        doflist[numdof];
-	int        numberofdofspernode;
+	int*       doflist=NULL;
 
 	/*Grid data: */
@@ -4096,5 +4097,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*recovre material parameters: */
@@ -4191,4 +4192,5 @@
 	xfree((void**)&area_gauss_weights);
 	xfree((void**)&vert_gauss_weights);
+	xfree((void**)&doflist);
 
 }
@@ -4234,19 +4236,30 @@
 /*}}}*/
 /*FUNCTION Penta::GetDofList {{{1*/
-void  Penta::GetDofList(int* doflist,int* pnumberofdofspernode){
+void  Penta::GetDofList(int** pdoflist){
 
 	int i,j;
-	int doflist_per_node[MAXDOFSPERNODE];
-	int numberofdofspernode;
-
+	int numberofdofs=0;
+	int count=0;
+
+	/*output: */
+	int* doflist=NULL;
+
+	/*First, figure out size of doflist: */
 	for(i=0;i<6;i++){
-		nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-		for(j=0;j<numberofdofspernode;j++){
-			doflist[i*numberofdofspernode+j]=doflist_per_node[j];
-		}
+		numberofdofs+=nodes[i]->GetNumberOfDofs();
+	}
+
+	/*Allocate: */
+	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+
+	/*Populate: */
+	count=0;
+	for(i=0;i<6;i++){
+		nodes[i]->GetDofList(doflist+count);
+		count+=nodes[i]->GetNumberOfDofs();
 	}
 
 	/*Assign output pointers:*/
-	*pnumberofdofspernode=numberofdofspernode;
+	*pdoflist=doflist;
 
 }
@@ -4440,14 +4453,11 @@
 	const int    numdof=numdofpervertex*numvertices;
 	double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx;
 	double       vy;
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Ok, we have vx and vy in values, fill in vx and vy arrays: */
@@ -4465,4 +4475,6 @@
 	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4476,14 +4488,11 @@
 	const int    numdof=numdofpervertex*numvertices;
 	double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx;
 	double       vy;
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Ok, we have vx and vy in values, fill in vx and vy arrays: */
@@ -4501,4 +4510,6 @@
 	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4512,13 +4523,10 @@
 	const int    numdof=numdofpervertex*numvertices;
 	double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vz;
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Ok, we have vx and vy in values, fill in vx and vy arrays: */
@@ -4533,4 +4541,7 @@
 	/*Add value to global vector*/
 	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4544,14 +4555,11 @@
 	const int    numdof=numdofpervertex*numvertices;
 	double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx,vy,vz,p;
-
-	int          dummy;
 	double       stokesreconditioning;
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Recondition pressure: */
@@ -4576,4 +4584,6 @@
 	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4587,13 +4597,11 @@
 	const int    numdof=numdofpervertex*numvertices;
 	double       gauss[numvertices][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vz;
 
-	int          dummy;
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Ok, we have vx and vy in values, fill in vx and vy arrays: */
@@ -4608,4 +4616,7 @@
 	/*Add value to global vector*/
 	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4907,6 +4918,5 @@
 	const int    numdofpervertex=2;
 	const int    numdof=numdofpervertex*numvertices;
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx[numvertices];
@@ -4928,5 +4938,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -4988,4 +4998,7 @@
 		penta=penta->GetUpperElement(); ISSMASSERT(penta->Id()!=this->id);
 	}
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4998,6 +5011,5 @@
 	const int    numdofpervertex=2;
 	const int    numdof=numdofpervertex*numvertices;
-	
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx[numvertices];
@@ -5016,5 +5028,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Get node data: */
@@ -5068,4 +5080,7 @@
 	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
 	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 
@@ -5079,6 +5094,5 @@
 	const int    numdofpervertex=2;
 	const int    numdof=numdofpervertex*numvertices;
-	
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx[numvertices];
@@ -5097,5 +5111,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Get node data: */
@@ -5149,4 +5163,7 @@
 	this->inputs->AddInput(new TriaVertexInput(VelEnum,vel));
 	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 
@@ -5160,6 +5177,5 @@
 	const int    numdofpervertex=1;
 	const int    numdof=numdofpervertex*numvertices;
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx[numvertices];
@@ -5180,5 +5196,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Get node data: */
@@ -5233,5 +5249,9 @@
 	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
 	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
-} /*}}}*/
+
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+}
+/*}}}*/
 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{1*/
 void  Penta::InputUpdateFromSolutionDiagnosticStokes(double* solution){
@@ -5242,6 +5262,5 @@
 	const int    numdofpervertex=4;
 	const int    numdof=numdofpervertex*numvertices;
-	
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx[numvertices];
@@ -5250,9 +5269,8 @@
 	double       vel[numvertices];
 	double       pressure[numvertices];
-	int          dummy;
 	double       stokesreconditioning;
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -5291,4 +5309,7 @@
 	this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
 	this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
+
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 
@@ -5302,6 +5323,5 @@
 	const int    numdofpervertex=4;
 	const int    numdof=numdofpervertex*numvertices;
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       lambdax[numvertices];
@@ -5310,8 +5330,6 @@
 	double       lambdap[numvertices];
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -5334,4 +5352,6 @@
 	this->inputs->AddInput(new PentaVertexInput(AdjointpEnum,lambdap));
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -5344,14 +5364,11 @@
 	const int    numdofpervertex=2;
 	const int    numdof=numdofpervertex*numvertices;
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       lambdax[numvertices];
 	double       lambday[numvertices];
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -5370,4 +5387,6 @@
 	this->inputs->AddInput(new PentaVertexInput(AdjointyEnum,lambday));
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -5380,14 +5399,11 @@
 	const int    numdofpervertex=1;
 	const int    numdof=numdofpervertex*numvertices;
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       B[numdof];
 	double       B_average;
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -5407,4 +5423,6 @@
 	this->matice->inputs->AddInput(new PentaVertexInput(RheologyBEnum,B));
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -5415,10 +5433,9 @@
 	const int numdofpervertex = 1;
 	const int numdof          = numdofpervertex *numvertices;
-	int       doflist[numdof];
+	int*         doflist=NULL;
 	double    values[numdof];
-	int       dummy;
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -5429,4 +5446,7 @@
 	/*Add input to the element: */
 	this->inputs->AddInput(new PentaVertexInput(enum_type,values));
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -5438,7 +5458,6 @@
 	const int  numdof          = numdofpervertex *numvertices;
 	const int  numdof2d        = numdof/2;
-	int        doflist[numdof];
+	int*         doflist=NULL;
 	double     values[numdof];
-	int        dummy;
 	Penta     *penta           = NULL;
 	bool       onbed;
@@ -5451,5 +5470,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector and extrude it */
@@ -5472,4 +5491,7 @@
 		penta=penta->GetUpperElement(); ISSMASSERT(penta->Id()!=this->id);
 	}
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 5095)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 5096)
@@ -135,8 +135,8 @@
 		void	  CreatePVectorSlope( Vec pg);
 		void	  CreatePVectorThermal( Vec pg);
-		double* GaussFromNode(Node* node);
-		void	  GetDofList(int* doflist,int* pnumberofdofs);
+		double*   GaussFromNode(Node* node);
+		void	  GetDofList(int** pdoflist);
 		void	  GetDofList1(int* doflist);
-		int     GetElementType(void);
+		int       GetElementType(void);
 		void	  GetNodalFunctions(double* l1l6, double* gauss_coord);
 		void	  GetNodalFunctionsDerivatives(double* dh1dh6,double* xyz_list, double* gauss_coord);
@@ -145,6 +145,6 @@
 		void	  GetNodalFunctionsDerivativesStokes(double* dh1dh7,double* xyz_list, double* gauss_coord);
 		void	  GetNodalFunctionsStokes(double* l1l7, double* gauss_coord);
-		void    GetParameterValue(double* pvalue,Node* node,int enumtype);
-		void    GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_seg,Input* input_in);
+		void      GetParameterValue(double* pvalue,Node* node,int enumtype);
+		void      GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_seg,Input* input_in);
 		void	  GetPhi(double* phi, double*  epsilon, double viscosity);
 		void	  GetSolutionFromInputsDiagnosticHoriz(Vec solutiong);
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 5096)
@@ -1384,5 +1384,4 @@
 	const int    numgrids=3;
 	const int    numdofs=2;
-	int          numberofdofspernode;
 	double mass_flux=0;
 	double xyz_list[numgrids][3];
@@ -2328,6 +2327,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* gaussian points: */
@@ -2374,5 +2372,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*retrieve some parameters: */
@@ -2482,5 +2480,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -2496,6 +2494,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* gaussian points: */
@@ -2530,5 +2527,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	this->parameters->FindParam(&dim,DimEnum);
 
@@ -2585,5 +2582,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -2599,6 +2596,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 	double  gaussgrids[numgrids][numgrids]={{1,0,0},{0,1,0},{0,0,1}};
 
@@ -2652,5 +2648,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*Retrieve all inputs we will be needed*/
@@ -2767,4 +2763,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -2779,6 +2776,5 @@
 	const int    numdof=2*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* gaussian points: */
@@ -2839,5 +2835,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -2910,5 +2906,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -2924,6 +2920,6 @@
 	const int numdof   = 2 *numvertices;
 	double    xyz_list[numvertices][3];
-	int       doflist[numdof];
-	int       numberofdofspernode;
+	int*      doflist=NULL;
+	int       numberofdofspernode=2;
 
 	/* gaussian points: */
@@ -2981,5 +2977,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numvertices);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	if (shelf){
@@ -3050,6 +3046,6 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
+	xfree((void**)&doflist);
 	delete friction;
-
 }	
 /*}}}*/
@@ -3063,6 +3059,5 @@
 	const int NDOF2=2;
 	const int numdofs=numgrids*NDOF2;
-	int    doflist[numdofs];
-	int    numberofdofspernode;
+	int*         doflist=NULL;
 
 	double Ke_gg[numdofs][numdofs]={0.0};
@@ -3077,5 +3072,5 @@
 	if(onwater)return;
 
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*Spawn 3 sing elements: */
@@ -3088,4 +3083,6 @@
 	MatSetValues(Kgg,numdofs,doflist,numdofs,doflist,(const double*)Ke_gg,ADD_VALUES);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3100,6 +3097,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* gaussian points: */
@@ -3134,5 +3130,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -3205,4 +3201,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3216,6 +3213,5 @@
 	const int  NDOF1=1;
 	const int  numdof=numgrids*NDOF1;
-	int        doflist[numdof];
-	int        numberofdofspernode;
+	int*       doflist=NULL;
 
 	/*Grid data: */
@@ -3248,5 +3244,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights: */
@@ -3287,5 +3283,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3301,6 +3297,6 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
+	int          numberofdofspernode=1;
 
 	/* gaussian points: */
@@ -3351,5 +3347,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*Retrieve all inputs we will be needing: */
@@ -3469,5 +3465,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3483,6 +3479,6 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
+	int          numberofdofspernode=1;
 
 	/* gaussian points: */
@@ -3524,5 +3520,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -3595,5 +3591,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3609,6 +3605,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 	
 	/* gaussian points: */
@@ -3633,5 +3628,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -3672,4 +3667,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3685,6 +3681,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	double mixed_layer_capacity;
@@ -3718,5 +3713,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	//recover material parameters
@@ -3766,5 +3761,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3780,6 +3775,6 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
+	int          numberofdofspernode=1;
 
 	/* gaussian points: */
@@ -3807,5 +3802,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -3846,4 +3841,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3859,6 +3855,6 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
+	int          numberofdofspernode=1;
 
 	/* gaussian points: */
@@ -3888,5 +3884,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -3929,4 +3925,5 @@
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -3942,6 +3939,6 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
+	int          numberofdofspernode=1;
 
 	/* gaussian points: */
@@ -3969,5 +3966,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -4004,9 +4001,10 @@
 	VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES);
 
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4021,6 +4019,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 
 	/* gaussian points: */
@@ -4060,5 +4057,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -4112,9 +4109,10 @@
 	VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES);
 
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4129,6 +4127,5 @@
 	const int    NDOF2=2;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 	
 	/* parameters: */
@@ -4178,5 +4175,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 
@@ -4235,9 +4232,10 @@
 	VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES);
 
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4252,6 +4250,5 @@
 	const int    NDOF2=2;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 	double  gaussgrids[numgrids][numgrids]={{1,0,0},{0,1,0},{0,0,1}};
 
@@ -4302,5 +4299,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Recover input data: */
@@ -4474,10 +4471,10 @@
 	VecSetValues(p_g,numdof,doflist,(const double*)pe_g,ADD_VALUES);
 
-	/*Clean up*/
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4492,6 +4489,5 @@
 	const int    numdof=NDOF4*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 	double  gaussgrids[numgrids][numgrids]={{1,0,0},{0,1,0},{0,0,1}};
 
@@ -4541,6 +4537,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
-	ISSMASSERT(numberofdofspernode==4);
+	GetDofList(&doflist);
 
 	/* Recover input data: */
@@ -4709,10 +4704,10 @@
 	VecSetValues(p_g,numdof,doflist,(const double*)pe_g,ADD_VALUES);
 
-	/*Clean up*/
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4725,6 +4720,5 @@
 	const int NDOF2=2;
 	const int numdofs=NDOF2*numgrids;
-	int       doflist[numdofs];
-	int       numberofdofspernode;
+	int*         doflist=NULL;
 	double    constant_part,ub,vb;
 	double    rho_ice,gravity,n,B;
@@ -4748,5 +4742,5 @@
 	if(onwater)return;
 
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	
 	/* Get parameters */
@@ -4783,4 +4777,7 @@
 
 	VecSetValues(pg,numdofs,doflist,(const double*)pe_g,ADD_VALUES);
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4797,6 +4794,6 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
+	int          numberofdofspernode=1;
 
 	/* gaussian points: */
@@ -4830,5 +4827,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -4867,8 +4864,10 @@
 	VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES);
 
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
+	xfree((void**)&doflist);
 
 }
@@ -4885,6 +4884,6 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
+	int          numberofdofspernode=1;
 
 	/* gaussian points: */
@@ -4916,5 +4915,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
@@ -4953,9 +4952,10 @@
 	VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES);
 
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -4970,6 +4970,5 @@
 	const int    numdof=NDOF1*numgrids;
 	double       xyz_list[numgrids][3];
-	int          doflist[numdof];
-	int          numberofdofspernode;
+	int*         doflist=NULL;
 	
 	/* gaussian points: */
@@ -5002,5 +5001,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Get gaussian points and weights: */
@@ -5047,9 +5046,10 @@
 	VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES);
 
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -5062,6 +5062,5 @@
 	const int  NDOF1=1;
 	const int  numdof=numgrids*NDOF1;
-	int        doflist[numdof];
-	int        numberofdofspernode;
+	int*         doflist=NULL;
 	double       xyz_list[numgrids][3];
 
@@ -5101,5 +5100,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	//recover material parameters
@@ -5153,9 +5152,10 @@
 	VecSetValues(pg,numdof,doflist,(const double*)P_terms,ADD_VALUES);
 
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
-
+	xfree((void**)&doflist);
 }
 /*}}}*/
@@ -5168,7 +5168,6 @@
 	const int  NDOF1=1;
 	const int  numdof=numgrids*NDOF1;
-	int        doflist[numdof];
-	int        numberofdofspernode;
-	double       xyz_list[numgrids][3];
+	int*       doflist=NULL;
+	double     xyz_list[numgrids][3];
 
 	double rho_ice;
@@ -5218,5 +5217,5 @@
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	//recover material parameters
@@ -5286,10 +5285,11 @@
 	VecSetValues(pg,numdof,doflist,(const double*)P_terms,ADD_VALUES);
 
+	/*Free ressources:*/
 	xfree((void**)&first_gauss_area_coord);
 	xfree((void**)&second_gauss_area_coord);
 	xfree((void**)&third_gauss_area_coord);
 	xfree((void**)&gauss_weights);
+	xfree((void**)&doflist);
 	delete friction;
-
 }
 /*}}}*/
@@ -5353,25 +5353,30 @@
 /*}}}*/
 /*FUNCTION Tria::GetDofList {{{1*/
-void  Tria::GetDofList(int* doflist,int* pnumberofdofspernode){
+void  Tria::GetDofList(int** pdoflist){
 
 	int i,j;
-	int doflist_per_node[MAXDOFSPERNODE];
-	int numberofdofspernode;
-
-	/*Some checks for debugging*/
-	ISSMASSERT(doflist);
-	ISSMASSERT(pnumberofdofspernode);
-	ISSMASSERT(nodes);
-
-	/*Build doflist from nodes*/
+	int numberofdofs=0;
+	int count=0;
+
+	/*output: */
+	int* doflist=NULL;
+
+	/*First, figure out size of doflist: */
 	for(i=0;i<3;i++){
-		nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-		for(j=0;j<numberofdofspernode;j++){
-			doflist[i*numberofdofspernode+j]=doflist_per_node[j];
-		}
+		numberofdofs+=nodes[i]->GetNumberOfDofs();
+	}
+
+	/*Allocate: */
+	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+
+	/*Populate: */
+	count=0;
+	for(i=0;i<3;i++){
+		nodes[i]->GetDofList(doflist+count);
+		count+=nodes[i]->GetNumberOfDofs();
 	}
 
 	/*Assign output pointers:*/
-	*pnumberofdofspernode=numberofdofspernode;
+	*pdoflist=doflist;
 
 }
@@ -5549,14 +5554,11 @@
 	const int    numdof=numdofpervertex*numvertices;
 	double       gauss[numvertices][numvertices]={{1,0,0},{0,1,0},{0,0,1}};
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx;
 	double       vy;
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Ok, we have vx and vy in values, fill in vx and vy arrays: */
@@ -5574,4 +5576,7 @@
 	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -5585,14 +5590,11 @@
 	const int    numdof=numdofpervertex*numvertices;
 	double       gauss[numvertices][numvertices]={{1,0,0},{0,1,0},{0,0,1}};
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       lambdax;
 	double       lambday;
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Ok, we have lambdax and lambday in values, fill in lambdax and lambday arrays: */
@@ -5610,4 +5612,7 @@
 	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -5621,14 +5626,12 @@
 	const int    numdof=numdofpervertex*numvertices;
 	double       gauss[numvertices][numvertices]={{1,0,0},{0,1,0},{0,0,1}};
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx;
 	double       vy;
-
 	int          dummy;
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Ok, we have vx and vy in values, fill in vx and vy arrays: */
@@ -5645,4 +5648,7 @@
 	/*Add value to global vector*/
 	VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);
+
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 
 }
@@ -5854,14 +5860,11 @@
 	const int    numdofpervertex=2;
 	const int    numdof=numdofpervertex*numvertices;
-
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       lambdax[numvertices];
 	double       lambday[numvertices];
 
-	int          dummy;
-
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -5880,4 +5883,7 @@
 	this->inputs->AddInput(new TriaVertexInput(AdjointyEnum,lambday));
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -5890,6 +5896,5 @@
 	const int    numdofpervertex=2;
 	const int    numdof=numdofpervertex*numvertices;
-	
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx[numvertices];
@@ -5901,11 +5906,10 @@
 	double       rho_ice,g;
 	double       gauss[numvertices][numvertices]={{1,0,0},{0,1,0},{0,0,1}};
-
-	int          dummy;
 	Input*       vz_input=NULL;
 	double*      vz_ptr=NULL;
+	int          dummy;
 	
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -5958,4 +5962,7 @@
 	this->inputs->AddInput(new TriaVertexInput(PressureEnum,pressure));
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -5968,6 +5975,5 @@
 	const int    numdofpervertex=2;
 	const int    numdof=numdofpervertex*numvertices;
-	
-	int          doflist[numdof];
+	int*         doflist=NULL;
 	double       values[numdof];
 	double       vx[numvertices];
@@ -5979,11 +5985,10 @@
 	double       rho_ice,g;
 	double       gauss[numvertices][numvertices]={{1,0,0},{0,1,0},{0,0,1}};
-
-	int          dummy;
 	Input*       vz_input=NULL;
 	double*      vz_ptr=NULL;
+	int          dummy;
 	
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -6036,4 +6041,7 @@
 	this->inputs->AddInput(new TriaVertexInput(PressureEnum,pressure));
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -6044,10 +6052,9 @@
 	const int numdofpervertex = 1;
 	const int numdof          = numdofpervertex *numvertices;
-	int       doflist[numdof];
+	int*         doflist=NULL;
 	double    values[numdof];
-	int       dummy;
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&dummy);
+	GetDofList(&doflist);
 
 	/*Use the dof list to index into the solution vector: */
@@ -6058,4 +6065,8 @@
 	/*Add input to the element: */
 	this->inputs->AddInput(new TriaVertexInput(enum_type,values));
+
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 5095)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 5096)
@@ -136,12 +136,12 @@
 		void	  CreatePVectorThermalSheet( Vec pg);
 		void	  CreatePVectorThermalShelf( Vec pg);
-		double  GetArea(void);
-		double  GetAreaCoordinate(double x, double y, int which_one);
-		int     GetElementType(void);
-		void	  GetDofList(int* doflist,int* pnumberofdofs);
+		double    GetArea(void);
+		double    GetAreaCoordinate(double x, double y, int which_one);
+		int       GetElementType(void);
+		void	  GetDofList(int** pdoflist);
 		void	  GetDofList1(int* doflist);
-		void    GetParameterValue(double* pvalue,Node* node,int enumtype);
-		void    GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_seg,int enumtype);
-		void    GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_seg,Input* input_in);
+		void      GetParameterValue(double* pvalue,Node* node,int enumtype);
+		void      GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_seg,int enumtype);
+		void      GetParameterValue(double* pvalue,Node* node1,Node* node2,double gauss_seg,Input* input_in);
 		void	  GetSolutionFromInputsDiagnosticHoriz(Vec solution);
 		void	  GetSolutionFromInputsAdjointHoriz(Vec solution);
Index: /issm/trunk/src/c/objects/Loads/Icefront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 5096)
@@ -401,6 +401,5 @@
 	const int NDOF2    = 2;
 	const int numdofs = numgrids *NDOF2;
-	int       numberofdofspernode;
-	int       doflist[numdofs];
+	int*      doflist=NULL;
 	double    xyz_list[numgrids][3];
 
@@ -453,5 +452,5 @@
 
 	/* Get dof list and node coordinates: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	GetVerticesCoordinates(&xyz_list[0][0],nodes,numgrids);
 	
@@ -511,9 +510,12 @@
 	} //for(ig=0;ig<num_gauss;ig++)
 
+			
+	/*Plug pe_g into vector: */
+	VecSetValues(pg,numdofs,doflist,pe_g,ADD_VALUES);
+
+	/*Free ressources:*/
 	xfree((void**)&segment_gauss_coord);
 	xfree((void**)&gauss_weights);
-		
-	/*Plug pe_g into vector: */
-	VecSetValues(pg,numdofs,doflist,pe_g,ADD_VALUES);
+	xfree((void**)&doflist);
 
 }
@@ -527,6 +529,5 @@
 	const int NDOF2=2;
 	const int numdofs=numgrids*NDOF2;
-	int   numberofdofspernode;
-	int   doflist[numdofs];
+	int*      doflist=NULL;
 
 	double xyz_list[numgrids][3];
@@ -574,5 +575,5 @@
 
 	/* Get dof list and node coordinates: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
 	
@@ -654,4 +655,5 @@
 	/*Free ressources:*/
 	xfree((void**)&element_nodes);
+	xfree((void**)&doflist);
 
 }
@@ -665,6 +667,5 @@
 	const int NDOF4=4;
 	const int numdofs=numgrids*NDOF4;
-	int   numberofdofspernode;
-	int   doflist[numdofs];
+	int*      doflist=NULL;
 
 	double xyz_list[numgrids][3];
@@ -714,5 +715,5 @@
 
 	/* Get dof list and node coordinates: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
 	
@@ -794,41 +795,53 @@
 	/*Free ressources:*/
 	xfree((void**)&element_nodes);
-
-}
-/*}}}*/
-/*FUNCTION Icefront::GetDofList{{{1*/
-
-void  Icefront::GetDofList(int* doflist,int* pnumberofdofspernode){
+	xfree((void**)&doflist);
+
+}
+/*}}}*/
+/*FUNCTION Icefront::GetDofList {{{1*/
+void  Icefront::GetDofList(int** pdoflist){
 
 	int i,j;
-	int doflist_per_node[MAXDOFSPERNODE];
-	int numberofdofspernode;
+	int numberofdofs=0;
+	int count=0;
 	int type;
-
+	int numberofnodes=2;
+
+	/*output: */
+	int* doflist=NULL;
+
+	/*pointers: */
 	Node**   nodes=NULL;
+	
+	/*recover pointers: */
 	nodes=(Node**)hnodes->deliverp();
+	
+	/*recover type: */
 	inputs->GetParameterValue(&type,TypeEnum);
-	
-	if(type==SegmentIcefrontEnum){
-		for(i=0;i<2;i++){
-			nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-			for(j=0;j<numberofdofspernode;j++){
-				doflist[i*numberofdofspernode+j]=doflist_per_node[j];
-			}
-		}
-	}
-	else{
-		for(i=0;i<4;i++){
-			nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-			for(j=0;j<numberofdofspernode;j++){
-				doflist[i*numberofdofspernode+j]=doflist_per_node[j];
-			}
-		}
-	}
-
+
+	/*Some checks for debugging*/
+	ISSMASSERT(nodes);
+		
+	/*How many nodes? :*/
+	if(type==SegmentIcefrontEnum)numberofnodes=2;
+	else numberofnodes=4;
+	
+	/*Figure out size of doflist: */
+	for(i=0;i<numberofnodes;i++){
+		numberofdofs+=nodes[i]->GetNumberOfDofs();
+	}
+
+	/*Allocate: */
+	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+
+	/*Populate: */
+	count=0;
+	for(i=0;i<numberofnodes;i++){
+		nodes[i]->GetDofList(doflist+count);
+		count+=nodes[i]->GetNumberOfDofs();
+	}
 
 	/*Assign output pointers:*/
-	*pnumberofdofspernode=numberofdofspernode;
-
+	*pdoflist=doflist;
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Icefront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 5096)
@@ -72,5 +72,5 @@
 		void  CreatePVectorDiagnosticHorizQuad( Vec pg);
 		void  CreatePVectorDiagnosticStokes( Vec pg);
-		void  GetDofList(int* doflist,int* pnumberofdofs);
+		void  GetDofList(int** pdoflist);
 		void  QuadPressureLoad(double* pe_g,double rho_water,double rho_ice,double gravity, double* thickness_list, double* bed_list, 
 		                              double* normal1,double* normal2,double* normal3,double* normal4,double* xyz_list);
Index: /issm/trunk/src/c/objects/Loads/Numericalflux.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Numericalflux.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Numericalflux.cpp	(revision 5096)
@@ -377,6 +377,5 @@
 	double    xyz_list[numgrids][3];
 	double    normal[2];
-	int       doflist[numdof];
-	int       numberofdofspernode;
+	int*        doflist=NULL;
 
 	/* gaussian points: */
@@ -431,5 +430,5 @@
 	/* Get node coordinates, dof list and normal vector: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	GetNormal(&normal[0],xyz_list);
 
@@ -490,4 +489,8 @@
 	xfree((void**)&gauss_coords);
 	xfree((void**)&gauss_weights);
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -505,6 +508,5 @@
 	double    xyz_list[numgrids][3];
 	double    normal[2];
-	int       doflist[numdof];
-	int       numberofdofspernode;
+	int*      doflist=NULL;
 
 	/* gaussian points: */
@@ -560,5 +562,5 @@
 	/* Get node coordinates, dof list and normal vector: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	GetNormal(&normal[0],xyz_list);
 
@@ -621,4 +623,7 @@
 	xfree((void**)&gauss_weights);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -644,6 +649,5 @@
 	double    xyz_list[numgrids][3];
 	double    normal[2];
-	int       doflist[numdof];
-	int       numberofdofspernode;
+	int*      doflist=NULL;
 
 	/* gaussian points: */
@@ -707,5 +711,5 @@
 	/* Get node coordinates, dof list and normal vector: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	GetNormal(&normal[0],xyz_list);
 
@@ -757,4 +761,7 @@
 	xfree((void**)&gauss_weights);
 
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}*/
@@ -775,17 +782,20 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::GetDofList{{{1*/
-
-void  Numericalflux::GetDofList(int* doflist,int* pnumberofdofspernode){
+/*FUNCTION Numericalflux::GetDofList {{{1*/
+void  Numericalflux::GetDofList(int** pdoflist){
 
 	int i,j;
-	int doflist_per_node[MAXDOFSPERNODE];
-	int numberofdofspernode;
-
-	/*dynamic objects pointed to by hooks: */
-	Node**  nodes=NULL;
+	int numberofdofs=0;
+	int count=0;
 	int type;
-
-	/*recover objects from hooks: */
+	int numberofnodes=2;
+
+	/*output: */
+	int* doflist=NULL;
+
+	/*pointers: */
+	Node**   nodes=NULL;
+	
+	/*recover pointers: */
 	nodes=(Node**)hnodes->deliverp();
 	
@@ -793,24 +803,29 @@
 	inputs->GetParameterValue(&type,TypeEnum);
 
-	if (type==InternalEnum){
-		for(i=0;i<4;i++){
-			nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-			for(j=0;j<numberofdofspernode;j++){
-				doflist[i*numberofdofspernode+j]=doflist_per_node[j];
-			}
-		}
-	}
-	else if (type==BoundaryEnum){
-		for(i=0;i<2;i++){
-			nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-			for(j=0;j<numberofdofspernode;j++){
-				doflist[i*numberofdofspernode+j]=doflist_per_node[j];
-			}
-		}
-	}
+	/*Some checks for debugging*/
+	ISSMASSERT(nodes);
+		
+	/*How many nodes? :*/
+	if(type==InternalEnum)numberofnodes=4;
+	else if(type==BoundaryEnum)numberofnodes=2;
 	else ISSMERROR("type %s not supported yet",type);
+	
+	/*Figure out size of doflist: */
+	for(i=0;i<numberofnodes;i++){
+		numberofdofs+=nodes[i]->GetNumberOfDofs();
+	}
+
+	/*Allocate: */
+	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+
+	/*Populate: */
+	count=0;
+	for(i=0;i<numberofnodes;i++){
+		nodes[i]->GetDofList(doflist+count);
+		count+=nodes[i]->GetNumberOfDofs();
+	}
 
 	/*Assign output pointers:*/
-	*pnumberofdofspernode=numberofdofspernode;
+	*pdoflist=doflist;
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Numericalflux.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Numericalflux.h	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Numericalflux.h	(revision 5096)
@@ -67,5 +67,5 @@
 		void  GetB(double* B, double gauss_coord);
 		void  GetL(double* L, double gauss_coord,int numdof);
-		void  GetDofList(int* doflist,int* pnumberofdofs);
+		void  GetDofList(int** pdoflist);
 		void  GetNormal(double* normal,double xyz_list[4][3]);
 		void  GetParameterValue(double* pvalue, double gauss_coord,int enumtype);
Index: /issm/trunk/src/c/objects/Loads/Pengrid.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Pengrid.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Pengrid.cpp	(revision 5096)
@@ -391,9 +391,11 @@
 /*Pengrid management:*/
 /*FUNCTION Pengrid::GetDofList {{{1*/
-void  Pengrid::GetDofList(int* doflist,int* pnumberofdofspernode){
-
-	int i,j;
-	int doflist_per_node[MAXDOFSPERNODE];
-	int numberofdofspernode;
+void  Pengrid::GetDofList(int** pdoflist){
+
+	int  i,j;
+	int  numberofdofs=0;
+
+	/*output: */
+	int* doflist=NULL;
 
 	/*dynamic objects pointed to by hooks: */
@@ -402,13 +404,19 @@
 	/*recover objects from hooks: */
 	node=(Node*)hnode->delivers();
-	
-	node->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-	for(j=0;j<numberofdofspernode;j++){
-		doflist[j]=doflist_per_node[j];
-	}
+
+	/*Some checks for debugging*/
+	ISSMASSERT(node);
+
+	/*First, figure out size of doflist: */
+	numberofdofs=node->GetNumberOfDofs();
+
+	/*Allocate: */
+	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+
+	/*Populate: */
+	node->GetDofList(doflist);
 
 	/*Assign output pointers:*/
-	*pnumberofdofspernode=numberofdofspernode;
-
+	*pdoflist=doflist;
 }
 /*}}}*/
@@ -549,6 +557,5 @@
 	const int NDOF4=4;
 	const int numdof=numgrids*NDOF4;
-	int       doflist[numdof];
-	int       numberofdofspernode;
+	int*         doflist=NULL;
 
 	int dofs1[1]={0};
@@ -565,5 +572,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*recover pointers: */
@@ -589,4 +596,8 @@
 	/*Add Ke to global matrix Kgg: */
 	MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES);
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}1*/
@@ -599,9 +610,8 @@
 	const int numdof=numgrids*NDOF1;
 	double Ke[numdof][numdof]={0.0};
-	int     dofs1[1]={0};
-	int       doflist[numdof];
-	int      numberofdofspernode;
-	double  meltingpoint;
-	double* gauss=NULL;
+	int       dofs1[1]={0};
+	int*      doflist=NULL;
+	double    meltingpoint;
+	double*   gauss=NULL;
 
 	double pressure;
@@ -632,5 +642,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 	
 	//Compute pressure melting point
@@ -648,4 +658,5 @@
 	/*Clean up*/
 	xfree((void**)&gauss);
+	xfree((void**)&doflist);
 }
 /*}}}1*/
@@ -659,6 +670,5 @@
 	const int numdof=numgrids*NDOF1;
 	double Ke[numdof][numdof];
-	int       doflist[numdof];
-	int       numberofdofspernode;
+	int*         doflist=NULL;
 	double    penalty_offset;
 
@@ -669,5 +679,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	Ke[0][0]=kmax*pow((double)10,penalty_offset);
@@ -675,4 +685,7 @@
 	/*Add Ke to global matrix Kgg: */
 	MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES);
+
+	/*Free ressources:*/
+	xfree((void**)&doflist);
 }
 /*}}}1*/
@@ -683,7 +696,6 @@
 	const int NDOF1=1;
 	const int numdof=numgrids*NDOF1;
-	int    doflist[numdof];
+	int*   doflist=NULL;
 	double P_terms[numdof]={0.0};
-	int    numberofdofspernode;
 	int    found=0;
 	int    dofs1[1]={0};
@@ -712,5 +724,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	//First recover pressure and temperature values, using the element: */
@@ -751,4 +763,6 @@
 	/*Clean up*/
 	xfree((void**)&gauss);
+	xfree((void**)&doflist);
+
 }
 /*}}}1*/
@@ -759,7 +773,6 @@
 	const int NDOF1=1;
 	const int numdof=numgrids*NDOF1;
-	int       doflist[numdof];
+	int*      doflist=NULL;
 	double  P_terms[numdof]={0.0};
-	int    numberofdofspernode;
 	int    found=0;
 	double pressure;
@@ -784,5 +797,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	//First recover pressure  and penalty_offset
@@ -804,4 +817,6 @@
 	/*Clean up*/
 	xfree((void**)&gauss);
+	xfree((void**)&doflist);
+
 }
 /*}}}1*/
Index: /issm/trunk/src/c/objects/Loads/Pengrid.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Pengrid.h	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Pengrid.h	(revision 5096)
@@ -70,5 +70,5 @@
 		/*Pengrid management {{{1*/
 		void  PenaltyCreateKMatrixDiagnosticStokes(Mat Kgg,double kmax);
-		void  GetDofList(int* doflist,int* pnumberofdofspernode);
+		void  GetDofList(int** pdoflist);
 		void  GetParameterValue(double* pvalue,int enumtype);
 		void  PenaltyCreateKMatrixThermal(Mat Kgg,double kmax);
Index: /issm/trunk/src/c/objects/Loads/Penpair.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Penpair.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Penpair.cpp	(revision 5096)
@@ -257,5 +257,5 @@
 	const int NDOF2=2;
 	const int numdof=numgrids*NDOF2;
-	int       doflist[numdof];
+	int*         doflist=NULL;
 	int       numberofdofspernode;
 
@@ -267,5 +267,5 @@
 
 	/*Get dof list: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*recover pointers: */
@@ -288,12 +288,19 @@
 	/*Add Ke to global matrix Kgg: */
 	MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES);
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}1*/
 /*FUNCTION Penpair::GetDofList {{{1*/
-void  Penpair::GetDofList(int* doflist,int* pnumberofdofspernode){
+void  Penpair::GetDofList(int** pdoflist){
 
 	int i,j;
-	int doflist_per_node[MAXDOFSPERNODE];
-	int numberofdofspernode;
+	int numberofdofs=0;
+	int count=0;
+
+	/*output: */
+	int* doflist=NULL;
 
 	/*pointers: */
@@ -304,19 +311,23 @@
 
 	/*Some checks for debugging*/
-	ISSMASSERT(doflist);
-	ISSMASSERT(pnumberofdofspernode);
 	ISSMASSERT(nodes);
 
-	/*Build doflist from nodes*/
+	/*First, figure out size of doflist: */
 	for(i=0;i<2;i++){
-		nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-		for(j=0;j<numberofdofspernode;j++){
-			doflist[i*numberofdofspernode+j]=doflist_per_node[j];
-		}
+		numberofdofs+=nodes[i]->GetNumberOfDofs();
 	}
 
+	/*Allocate: */
+	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+
+	/*Populate: */
+	count=0;
+	for(i=0;i<2;i++){
+		nodes[i]->GetDofList(doflist+count);
+		count+=nodes[i]->GetNumberOfDofs();
+	}
+
 	/*Assign output pointers:*/
-	*pnumberofdofspernode=numberofdofspernode;
-
-}
-/*}}}*/
+	*pdoflist=doflist;
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Penpair.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Penpair.h	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Penpair.h	(revision 5096)
@@ -62,5 +62,5 @@
 			/*Penpair management: {{{1*/
 		void  PenaltyCreateKMatrixDiagnosticHoriz(Mat Kgg,double kmax);
-		void  GetDofList(int* doflist,int* pnumberofdofspernode);
+		void  GetDofList(int** pdoflist);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/Loads/Riftfront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 5096)
@@ -336,6 +336,5 @@
 	double      Ke_gg[4][4];
 	const int   numdof              = 2 *numgrids;
-	int         doflist[numdof];
-	int         numberofdofspernode;
+	int*        doflist=NULL;
 	double      thickness;
 	double      h[2];
@@ -362,5 +361,5 @@
 	
 	/* Get node coordinates and dof list: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/* Set Ke_gg to 0: */
@@ -446,6 +445,5 @@
 	double      pe_g[4]={0.0};
 	const int   numdof              = 2 *numgrids;
-	int         doflist[numdof];
-	int         numberofdofspernode;
+	int*        doflist=NULL;
 
 	double      rho_ice;
@@ -486,5 +484,5 @@
 
 	/* Get node coordinates and dof list: */
-	GetDofList(&doflist[0],&numberofdofspernode);
+	GetDofList(&doflist);
 
 	/*Get some inputs: */
@@ -564,4 +562,8 @@
 		/*The penalty is active. No loads implied here.*/
 	}
+	
+	/*Free ressources:*/
+	xfree((void**)&doflist);
+
 }
 /*}}}1*/
@@ -669,25 +671,41 @@
 /*}}}1*/
 /*FUNCTION Riftfront::GetDofList {{{1*/
-
-void  Riftfront::GetDofList(int* doflist,int* pnumberofdofspernode){
+void  Riftfront::GetDofList(int** pdoflist){
 
 	int i,j;
-	int doflist_per_node[MAXDOFSPERNODE];
-	int numberofdofspernode;
-	Node      **nodes           = NULL;
-	
+	int numberofdofs=0;
+	int count=0;
+
+	/*output: */
+	int* doflist=NULL;
+
+	/*pointers: */
+	Node**   nodes=NULL;
+	
+	/*recover pointers: */
 	nodes=(Node**)hnodes->deliverp();
-
+	
+	/*Some checks for debugging*/
+	ISSMASSERT(nodes);
+		
+	/*Figure out size of doflist: */
 	for(i=0;i<MAX_RIFTFRONT_GRIDS;i++){
-		nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
-		for(j=0;j<numberofdofspernode;j++){
-			doflist[i*numberofdofspernode+j]=doflist_per_node[j];
-		}
+		numberofdofs+=nodes[i]->GetNumberOfDofs();
+	}
+
+	/*Allocate: */
+	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+
+	/*Populate: */
+	count=0;
+	for(i=0;i<MAX_RIFTFRONT_GRIDS;i++){
+		nodes[i]->GetDofList(doflist+count);
+		count+=nodes[i]->GetNumberOfDofs();
 	}
 
 	/*Assign output pointers:*/
-	*pnumberofdofspernode=numberofdofspernode;
-}
-/*}}}1*/
+	*pdoflist=doflist;
+}
+/*}}}*/
 /*FUNCTION Riftfront::IsFrozen{{{1*/
 bool   Riftfront::IsFrozen(void){
Index: /issm/trunk/src/c/objects/Loads/Riftfront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.h	(revision 5095)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.h	(revision 5096)
@@ -78,5 +78,5 @@
 		/*}}}*/
 		/*Riftfront management: {{{1*/
-		void  GetDofList(int* doflist,int* pnumberofdofs);
+		void  GetDofList(int** pdoflist);
 		bool  PreStable();
 		void  SetPreStable();
Index: /issm/trunk/src/c/objects/Node.cpp
===================================================================
--- /issm/trunk/src/c/objects/Node.cpp	(revision 5095)
+++ /issm/trunk/src/c/objects/Node.cpp	(revision 5096)
@@ -337,12 +337,9 @@
 /*}}}*/
 /*FUNCTION Node::GetDofList{{{1*/
-void  Node::GetDofList(int* outdoflist,int* pnumberofdofspernode){
-
+void  Node::GetDofList(int* outdoflist){
 	int i;
 	for(i=0;i<this->indexing.numberofdofs;i++){
 		outdoflist[i]=indexing.doflist[i];
 	}
-	/*Assign output pointers:*/
-	*pnumberofdofspernode=this->indexing.numberofdofs;
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Node.h
===================================================================
--- /issm/trunk/src/c/objects/Node.h	(revision 5095)
+++ /issm/trunk/src/c/objects/Node.h	(revision 5096)
@@ -75,5 +75,5 @@
 		void  CreateVecSets(Vec pv_g,Vec pv_f,Vec pv_s);
 		int   GetConnectivity();
-		void  GetDofList(int* outdoflist,int* pnumberofdofspernode);
+		void  GetDofList(int* poutdoflist);
 		int   GetDofList1(void);
 		double GetX();
Index: /issm/trunk/src/m/solutions/NewFemModel.m
===================================================================
--- /issm/trunk/src/m/solutions/NewFemModel.m	(revision 5095)
+++ /issm/trunk/src/m/solutions/NewFemModel.m	(revision 5096)
@@ -24,13 +24,13 @@
 	femmodel.results=struct([]);
 
-   %now, go through all analyses types and post-process datasets
-   for i=1:nummodels,
-	   
-	   analysis_type=femmodel.analysis_type_list(i);
-	   displaystring(md.verbose,'%s%s','   dealing with analysis type: ',EnumAsString(analysis_type));
+	%now, go through all analyses types and post-process datasets
+	for i=1:nummodels,
+
+		analysis_type=femmodel.analysis_type_list(i);
+		displaystring(md.verbose,'%s%s','   dealing with analysis type: ',EnumAsString(analysis_type));
 
 		femmodel=SetCurrentConfiguration(femmodel,analysis_type);
 
-	   displaystring(md.verbose,'%s','      generating degrees of freedom...');
+		displaystring(md.verbose,'%s','      generating degrees of freedom...');
 		if ~isfield(femmodel,'part'),
 			[femmodel.vertices,femmodel.part,femmodel.tpart]=VerticesDof(femmodel.vertices, femmodel.parameters); %do not create partition vector twice! we only have one set of vertices!
@@ -49,3 +49,3 @@
 		displaystring(md.verbose,'%s','      configuring elements and loads...');
 		[femmodel.elements,femmodel.loads,femmodel.nodes,femmodel.parameters] = ConfigureObjects( femmodel.elements, femmodel.loads, femmodel.nodes, femmodel.vertices,femmodel.materials,femmodel.parameters);
-   end
+	end
Index: /issm/trunk/test/NightlyRun/test101.m
===================================================================
--- /issm/trunk/test/NightlyRun/test101.m	(revision 5095)
+++ /issm/trunk/test/NightlyRun/test101.m	(revision 5096)
@@ -4,3 +4,5 @@
 md=setelementstype(md,'macayeal','all');
 md.cluster='none';
+md.verbose=1;
 md=solve(md,'analysis_type',DiagnosticSolutionEnum);
+
