Index: /issm/trunk-jpl/src/c/modules/GiaDeflectionCorex/GiaDeflectionCorex.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/GiaDeflectionCorex/GiaDeflectionCorex.cpp	(revision 15015)
+++ /issm/trunk-jpl/src/c/modules/GiaDeflectionCorex/GiaDeflectionCorex.cpp	(revision 15016)
@@ -12,7 +12,4 @@
 #include "../InputUpdateFromConstantx/InputUpdateFromConstantx.h"
 
-#define Ntime 5 // number of times with load history 
-#define Ntimm 4 // Ntime-1 : for slope/y-cept of load segments 
-#define Ntimp 6 // Ntime+1 : for evaluation time  
 
 /*External blocks: {{{*/
@@ -20,19 +17,9 @@
 	double pset[7];
 };
-
-struct blockt{
-	double time[Ntimp];
-	double bi[Ntimm];
-	double dmi[Ntimm];
-};
-
+	
 struct blocko{
 	double rhoi;
-	double hload[Ntime];
-};
-
-struct blocky{
-	double zhload[Ntime];
-};
+};
+
 
 struct blockn{
@@ -51,10 +38,9 @@
 
 extern "C" { 
-	int distme_( int* pidisk,int* piedge);
+	int distme_( int* pidisk,int* piedge, int* pNtime, int* pNtimp, int* pNtimm, int* pNafter,double* time,double* bi,double* dmi,double* zhload,double* hload);
+
 	int what0_( int* pidisk,int* piedge);
 	extern struct blockp blockp_;
-	extern struct blockt blockt_;
 	extern struct blocko blocko_;
-	extern struct blocky blocky_;
 	extern struct blockn blockn_;
 	extern struct blockrad blockrad_;
@@ -65,4 +51,7 @@
 
 void GiaDeflectionCorex( IssmDouble* pwi, IssmDouble* pdwidt, GiaDeflectionCoreArgs* arguments){
+
+	/*intermediary: */
+	int i;
 
 	/*output: */
@@ -87,4 +76,13 @@
 	int numtimes; //loading history length
 	IssmDouble currenttime;
+	int Ntime=5; // number of times with load history 
+	int Ntimm;  // Ntime-1 : for slope/y-cept of load segments 
+	int Ntimp; // Ntime+1 : for evaluation time  
+	int Nafter;
+	IssmDouble* blockt_time=NULL;
+	IssmDouble* blockt_bi=NULL;
+	IssmDouble* blockt_dmi=NULL;
+	IssmDouble* blocky_zhload=NULL;
+	IssmDouble* blocko_hload=NULL;
 
 	/*gia material parameters: */
@@ -128,4 +126,8 @@
 	//from our model, irate comes in with values in [1,2], which maps into [0,1] in naruse: 
 	irate=irate-1;
+	Nafter=1;
+	Ntime=numtimes;
+	Ntimm=Ntime-1;
+	Ntimp=Ntime+Nafter;
 
 	/*Prepare block inputs for fortran distme and what0 routines of the naruse code: {{{*/
@@ -141,17 +143,24 @@
 
 	/*loading history: */
-	blocky_.zhload[0]=hes[0];
-	blocky_.zhload[1]=hes[1];
-	blocky_.zhload[2]=hes[2];
-	blocky_.zhload[3]=hes[3];
-	blocky_.zhload[4]=hes[numtimes-1];
+	blocky_zhload=xNew<IssmDouble>(numtimes);
+	for(i=0;i<numtimes;i++){
+	blocky_zhload[i]=hes[i];
+	}
 
 	/*times: */
-	blockt_.time[0]=times[0]/1000.0/yts;    // in kyr
-	blockt_.time[1]=times[1]/1000.0/yts;    // in kyr
-	blockt_.time[2]=times[2]/1000.0/yts;    // in kyr
-	blockt_.time[3]=times[3]/1000.0/yts;    // in kyr
-	blockt_.time[4]=2500.0;                 // in kyr  
-	blockt_.time[5]=times[numtimes-1]/1000.0/yts;  // evaluation time, in kyr 
+	blockt_time=xNew<IssmDouble>(numtimes+1);
+	for (i=0;i<numtimes;i++){
+		blockt_time[i]=times[i]/1000.0/yts; //in kyr
+		if(i==numtimes-2)blockt_time[i]=2500.0;                 // in kyr  
+	}
+	
+	/*bi: */
+	blockt_bi=xNew<IssmDouble>(numtimes-1);
+
+	/*dmi: */
+	blockt_dmi=xNew<IssmDouble>(numtimes-1);
+	
+	/*hload:*/
+	blocko_hload=xNew<IssmDouble>(numtimes);
 
 	/*irate: */
@@ -163,5 +172,6 @@
 
 	/*Call distme driver: */
-	distme_(&idisk,&iedge); 
+	distme_(&idisk,&iedge,&Ntime,&Ntimp,&Ntimm,&Nafter,blockt_time,blockt_bi,blockt_dmi,blocky_zhload,blocko_hload); 
+
 
 	/*Call what0 driver: */
@@ -180,3 +190,11 @@
 	}
 
+	/*Free ressources: */
+	xDelete<IssmDouble>(blockt_time);
+	xDelete<IssmDouble>(blockt_bi);
+	xDelete<IssmDouble>(blockt_dmi);
+	xDelete<IssmDouble>(blocky_zhload);
+	xDelete<IssmDouble>(blocko_hload);
+
 }
+      
Index: /issm/trunk-jpl/src/c/modules/GiaDeflectionCorex/distme.f
===================================================================
--- /issm/trunk-jpl/src/c/modules/GiaDeflectionCorex/distme.f	(revision 15015)
+++ /issm/trunk-jpl/src/c/modules/GiaDeflectionCorex/distme.f	(revision 15016)
@@ -1,9 +1,7 @@
-      subroutine distme(idisk,iedge)
+      subroutine distme(idisk,iedge,Ntime,Ntimp,Ntimm,Nafter,time,bi,
+     &dmi,zhload,hload)
       implicit double precision (a-h,o-y)
+      integer idisk,iedge,Ntime,Ntimp,Ntimm,Nafter
       parameter (N3G = 1)
-      parameter (Ntime = 5)
-      parameter (Ntimm = Ntime-1)
-      parameter (Nafter = 1)
-      parameter (Ntimp = Ntime + Nafter)
       double precision pset(7)
       double precision time(Ntimp),dmi(Ntimm),bi(Ntimm),dumbt(Ntimp)
@@ -13,7 +11,5 @@
       common /blockp/ pset
       common /blockrad/ distrad 
-      common /blockt/ time,bi,dmi
-      common /blocky/ zhload
-      common /blocko/ rhoi,hload
+      common /blocko/ rhoi
       data g /9.832186d0/, yearco /3.15576d7/, eradm/6.371d6/
       data dpi /3.1415926535897932d0/, dzero/0.0d0/
@@ -27,5 +23,4 @@
   776 continue
 c      write(6,*) time(1), time(2), time(3)
-c      write(6,*) zhload(1), zhload(2), distrad, rhoi
 c      write(6,*) pset(1), pset(2), pset(3), pset(4), pset(5), pset(6)
 c      write(6,*) pset(7)
