Index: /issm/trunk-jpl/src/c/classes/Elements/Element.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 19273)
+++ /issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 19274)
@@ -513,8 +513,10 @@
 
 	int        i;
-	IssmDouble monthlytemperatures[numvertices][12],monthlyprec[numvertices][12];
-	IssmDouble TemperaturesPresentday[numvertices][12],TemperaturesLgm[numvertices][12];
-	IssmDouble PrecipitationsPresentday[numvertices][12];
-	IssmDouble tmp[numvertices];
+	IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* TemperaturesLgm=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* tmp=xNew<IssmDouble>(numvertices);
 	IssmDouble Delta18oPresent,Delta18oLgm,Delta18oTime;
 	IssmDouble Delta18oSurfacePresent,Delta18oSurfaceLgm,Delta18oSurfaceTime;
@@ -536,9 +538,9 @@
 		for(int iv=0;iv<numvertices;iv++){
 			gauss->GaussVertex(iv);
-			input->GetInputValue(&TemperaturesPresentday[iv][month],gauss,month/12.*yts);
-			input2->GetInputValue(&TemperaturesLgm[iv][month],gauss,month/12.*yts);
-			input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts);
-
-			PrecipitationsPresentday[iv][month]=PrecipitationsPresentday[iv][month]*yts;
+			input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts);
+			input2->GetInputValue(&TemperaturesLgm[iv*12+month],gauss,month/12.*yts);
+			input3->GetInputValue(&PrecipitationsPresentday[iv*12+month],gauss,month/12.*yts);
+
+			PrecipitationsPresentday[iv*12+month]=PrecipitationsPresentday[iv*12+month]*yts;
 		}
 	}
@@ -556,7 +558,7 @@
 		ComputeDelta18oTemperaturePrecipitation(Delta18oSurfacePresent, Delta18oSurfaceLgm, Delta18oSurfaceTime,
 					Delta18oPresent, Delta18oLgm, Delta18oTime,
-					&PrecipitationsPresentday[iv][0],
-					&TemperaturesLgm[iv][0], &TemperaturesPresentday[iv][0],
-					&monthlytemperatures[iv][0], &monthlyprec[iv][0]);
+					&PrecipitationsPresentday[iv*12],
+					&TemperaturesLgm[iv*12], &TemperaturesPresentday[iv*12],
+					&monthlytemperatures[iv*12], &monthlyprec[iv*12]);
 	}
 
@@ -565,5 +567,5 @@
 	TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum);
 	for (int imonth=0;imonth<12;imonth++) {
-		for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i][imonth];
+		for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth];
 		switch(this->ObjectEnum()){
 			case TriaEnum:  NewTemperatureInput->AddTimeInput(new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break;
@@ -572,5 +574,5 @@
 			default: _error_("Not implemented yet");
 		}
-		for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i][imonth]/yts;
+		for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts;
 		switch(this->ObjectEnum()){
 			case TriaEnum:  NewPrecipitationInput->AddTimeInput(new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break;
@@ -607,8 +609,11 @@
 
 	int        i;
-	IssmDouble monthlytemperatures[numvertices][12],monthlyprec[numvertices][12];
-	IssmDouble TemperaturesPresentday[numvertices][12],TemperaturesLgm[numvertices][12];
-	IssmDouble PrecipitationsPresentday[numvertices][12],PrecipitationsLgm[numvertices][12];
-	IssmDouble tmp[numvertices];
+	IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* TemperaturesLgm=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* PrecipitationsLgm=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* tmp=xNew<IssmDouble>(numvertices);
 	IssmDouble TdiffTime,PfacTime;
 	IssmDouble time,yts,time_yr;
@@ -627,11 +632,11 @@
 		for(int iv=0;iv<numvertices;iv++) {
 			gauss->GaussVertex(iv);
-			input->GetInputValue(&TemperaturesPresentday[iv][month],gauss,month/12.*yts);
-			input2->GetInputValue(&TemperaturesLgm[iv][month],gauss,month/12.*yts);
-			input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts);
-			input4->GetInputValue(&PrecipitationsLgm[iv][month],gauss,month/12.*yts);
-
-			PrecipitationsPresentday[iv][month]=PrecipitationsPresentday[iv][month]*yts;
-			PrecipitationsLgm[iv][month]=PrecipitationsLgm[iv][month]*yts;
+			input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts);
+			input2->GetInputValue(&TemperaturesLgm[iv*12+month],gauss,month/12.*yts);
+			input3->GetInputValue(&PrecipitationsPresentday[iv*12+month],gauss,month/12.*yts);
+			input4->GetInputValue(&PrecipitationsLgm[iv*12+month],gauss,month/12.*yts);
+
+			PrecipitationsPresentday[iv*12+month]=PrecipitationsPresentday[iv*12+month]*yts;
+			PrecipitationsLgm[iv*12+month]=PrecipitationsLgm[iv*12+month]*yts;
 		}
 	}
@@ -644,7 +649,7 @@
 	for(int iv=0;iv<numvertices;iv++){
 		ComputeMungsmTemperaturePrecipitation(TdiffTime,PfacTime,
-					&PrecipitationsLgm[iv][0],&PrecipitationsPresentday[iv][0],
-					&TemperaturesLgm[iv][0], &TemperaturesPresentday[iv][0],
-					&monthlytemperatures[iv][0], &monthlyprec[iv][0]);
+					&PrecipitationsLgm[iv*12],&PrecipitationsPresentday[iv*12],
+					&TemperaturesLgm[iv*12], &TemperaturesPresentday[iv*12],
+					&monthlytemperatures[iv*12], &monthlyprec[iv*12]);
 	}
 
@@ -653,5 +658,5 @@
 	TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum);
 	for (int imonth=0;imonth<12;imonth++) {
-		for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i][imonth];
+		for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth];
 		switch(this->ObjectEnum()){
 			case TriaEnum:  NewTemperatureInput->AddTimeInput(new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break;
@@ -660,5 +665,5 @@
 			default: _error_("Not implemented yet");
 		}
-		for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i][imonth]/yts;
+		for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts;
 		switch(this->ObjectEnum()){
 			case TriaEnum:  NewPrecipitationInput->AddTimeInput(new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break;
@@ -695,8 +700,9 @@
 
 	int        i;
-	IssmDouble monthlytemperatures[numvertices][12],monthlyprec[numvertices][12];
-	IssmDouble TemperaturesPresentday[numvertices][12];
-	IssmDouble PrecipitationsPresentday[numvertices][12];
-	IssmDouble tmp[numvertices];
+	IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* tmp=xNew<IssmDouble>(numvertices);
 	IssmDouble Delta18oTime;
 	IssmDouble dpermil;
@@ -717,8 +723,8 @@
 		for(int iv=0;iv<numvertices;iv++) {
 			gauss->GaussVertex(iv);
-			input->GetInputValue(&TemperaturesPresentday[iv][month],gauss,month/12.*yts);
-			input2->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts);
-
-			PrecipitationsPresentday[iv][month]=PrecipitationsPresentday[iv][month]*yts;
+			input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts);
+			input2->GetInputValue(&PrecipitationsPresentday[iv*12+month],gauss,month/12.*yts);
+
+			PrecipitationsPresentday[iv*12+month]=PrecipitationsPresentday[iv*12+month]*yts;
 		}
 	}
@@ -730,6 +736,6 @@
 	for(int iv=0;iv<numvertices;iv++){
 		ComputeD18OTemperaturePrecipitationFromPD(Delta18oTime,dpermil,
-					&PrecipitationsPresentday[iv][0], &TemperaturesPresentday[iv][0],
-					&monthlytemperatures[iv][0], &monthlyprec[iv][0]);
+					&PrecipitationsPresentday[iv*12], &TemperaturesPresentday[iv*12],
+					&monthlytemperatures[iv*12], &monthlyprec[iv*12]);
 	}
 
@@ -738,5 +744,5 @@
 	TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum);
 	for (int imonth=0;imonth<12;imonth++) {
-		for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i][imonth];
+		for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth];
 		switch(this->ObjectEnum()){
 			case TriaEnum:  NewTemperatureInput->AddTimeInput(new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break;
@@ -745,5 +751,5 @@
 			default: _error_("Not implemented yet");
 		}
-		for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i][imonth]/yts;
+		for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts;
 		switch(this->ObjectEnum()){
 			case TriaEnum:  NewPrecipitationInput->AddTimeInput(new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break;
@@ -1657,9 +1663,11 @@
 
 	int        i;
-	IssmDouble agd[numvertices];             // surface mass balance
-	IssmDouble monthlytemperatures[numvertices][12],monthlyprec[numvertices][12];
-	IssmDouble yearlytemperatures[numvertices]; memset(yearlytemperatures, 0., numvertices*sizeof(IssmDouble));
-	IssmDouble tmp[numvertices];
-	IssmDouble h[numvertices],s[numvertices];
+	IssmDouble* agd=xNew<IssmDouble>(numvertices); // surface mass balance
+	IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices);
+	IssmDouble* yearlytemperatures=xNew<IssmDouble>(numvertices); memset(yearlytemperatures, 0., numvertices*sizeof(IssmDouble));
+	IssmDouble* tmp=xNew<IssmDouble>(numvertices);
+	IssmDouble* h=xNew<IssmDouble>(numvertices);
+	IssmDouble* s=xNew<IssmDouble>(numvertices);
 	IssmDouble rho_water,rho_ice,desfac,s0p,s0t,rlaps,rlapslgm;
 	IssmDouble PfacTime,TdiffTime,sealevTime;
@@ -1690,9 +1698,9 @@
 		for(int iv=0;iv<numvertices;iv++) {
 			gauss->GaussVertex(iv);
-			input->GetInputValue(&monthlytemperatures[iv][month],gauss,time_yr+month/12.*yts);
-			yearlytemperatures[iv]=yearlytemperatures[iv]+monthlytemperatures[iv][month]*mavg; // Has to be in Kelvin
-			monthlytemperatures[iv][month]=monthlytemperatures[iv][month]-273.15; // conversion from Kelvin to celcius for PDD module
-			input2->GetInputValue(&monthlyprec[iv][month],gauss,time_yr+month/12.*yts);
-			monthlyprec[iv][month]=monthlyprec[iv][month]*yts;
+			input->GetInputValue(&monthlytemperatures[iv*12+month],gauss,time_yr+month/12.*yts);
+			yearlytemperatures[iv]=yearlytemperatures[iv]+monthlytemperatures[iv*12+month]*mavg; // Has to be in Kelvin
+			monthlytemperatures[iv*12+month]=monthlytemperatures[iv*12+month]-273.15; // conversion from Kelvin to celcius for PDD module
+			input2->GetInputValue(&monthlyprec[iv*12+month],gauss,time_yr+month/12.*yts);
+			monthlyprec[iv*12+month]=monthlyprec[iv*12+month]*yts;
 		}
 	}
@@ -1716,5 +1724,5 @@
 	/*measure the surface mass balance*/
 	for (int iv = 0; iv<numvertices; iv++){
-		agd[iv]=PddSurfaceMassBalance(&monthlytemperatures[iv][0], &monthlyprec[iv][0],
+		agd[iv]=PddSurfaceMassBalance(&monthlytemperatures[iv*12], &monthlyprec[iv*12],
 					pdds, pds, signorm, yts, h[iv], s[iv],
 					desfac, s0t, s0p,rlaps,rlapslgm,TdiffTime,sealevTime,
@@ -1726,9 +1734,9 @@
 	// TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum);
 	// for (int imonth=0;imonth<12;imonth++) {
-	//   for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i][imonth];
+	//   for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth];
 	//   TriaInput* newmonthinput1 = new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum);
 	//   NewTemperatureInput->AddTimeInput(newmonthinput1,time+imonth/12.*yts);
 	//
-	//   for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i][imonth];
+	//   for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts;
 	//   TriaInput* newmonthinput2 = new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum);
 	//   NewPrecipitationInput->AddTimeInput(newmonthinput2,time+imonth/12.*yts);
