Index: issm/trunk/src/c/classes/FemModel.h
===================================================================
--- issm/trunk/src/c/classes/FemModel.h	(revision 24686)
+++ issm/trunk/src/c/classes/FemModel.h	(revision 25836)
@@ -11,5 +11,5 @@
 class DataSet;
 class Parameters;
-class Inputs2;
+class Inputs;
 class Nodes;
 class Vertices;
@@ -18,8 +18,9 @@
 class Loads;
 class Materials;
+class SealevelMasks;
 class Profiler;
 class Elements;
 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_)
-#include "./AdaptiveMeshRefinement.h"
+#include "./AmrNeopz.h"
 #endif
 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_)
@@ -44,5 +45,5 @@
 		Materials   *materials;            //one set of materials, for each element
 		Parameters  *parameters;           //one set of parameters, independent of the analysis_type
-		Inputs2     *inputs2;              //one set of inputs, independent of the analysis_type
+		Inputs     *inputs;              //one set of inputs, independent of the analysis_type
 		Results     *results;              //results that cannot be fit into the elements
 		Vertices    *vertices;             //one set of vertices
@@ -56,7 +57,7 @@
 		Nodes       **nodes_list;
 
-		//FIXME: do we want only one class and have virtual functions? or keep 2 classes, at least rename AdaptiveMeshRefinement -> AmrNeopz
+		//FIXME: do we want only one class and have virtual functions? or keep 2 classes?
 		#if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_)
-		AdaptiveMeshRefinement *amr;		  //adaptive mesh refinement object. It keeps coarse mesh and execute refinement process
+		AmrNeopz *amr;		  //adaptive mesh refinement object. It keeps coarse mesh and execute refinement process
 		#endif
 
@@ -66,6 +67,7 @@
 
 		/*constructors, destructors: */
+		FemModel(void);
 		FemModel(int argc,char** argv,ISSM_MPI_Comm comm_init,bool trace=false);
-		FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, char* restartfilename, ISSM_MPI_Comm incomm, int solution_type,IssmPDouble* X);
+		FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, char* restartfilename, char* modelname, ISSM_MPI_Comm incomm, int solution_type,IssmPDouble* X);
 		~FemModel();
 
@@ -73,12 +75,14 @@
 		int  AnalysisIndex(int);
 		void CheckPoint(void);
+		void CheckPointAD(int step);
 		void CleanUp(void);
 		FemModel* copy();
 		void Echo();
 		int  GetElementsWidth(){return 3;};//just tria elements in this first version
-		void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, char* restartfilename, const int solution_type,bool trace,IssmPDouble* X=NULL);
+		void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, char* restartfilename, char* modelname, const int solution_type,bool trace,IssmPDouble* X=NULL);
 		void InitFromFids(char* rootpath, FILE* IOMODEL, FILE* toolkitsoptionsfid, int in_solution_type, bool trace, IssmPDouble* X=NULL);
-		void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction);
+		void Marshall(MarshallHandle* marshallhandle);
 		void Restart(void);
+		void RestartAD(int step);
 		void SetCurrentConfiguration(int configuration_type);
 		void SetCurrentConfiguration(int configuration_type,int analysis_type);
@@ -154,5 +158,5 @@
 		void ThicknessAbsGradientx( IssmDouble* pJ);
 		void ThicknessPositivex(IssmDouble* pJ);
-		#ifdef _HAVE_GIAIVINS_
+		#ifdef _HAVE_GIA_
 		void Deflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt, IssmDouble* x, IssmDouble* y);
 		#endif
@@ -162,9 +166,9 @@
 		#endif
 		#ifdef _HAVE_SEALEVELRISE_
-		void SealevelriseEustatic(Vector<IssmDouble>* pSgi, IssmDouble* peustatic, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius,int loop);
-		void SealevelriseNonEustatic(Vector<IssmDouble>* pSgo, Vector<IssmDouble>* pSg_old, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius,bool verboseconvolution,int loop);
-		void SealevelriseRotationalFeedback(Vector<IssmDouble>* pRSLgo_rot, Vector<IssmDouble>* pRSLg_old, IssmDouble* pIxz, IssmDouble* pIyz, IssmDouble* pIzz, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius);
-		void SealevelriseElastic(Vector<IssmDouble>* pUp, Vector<IssmDouble>* pNorth, Vector<IssmDouble>* pEast, Vector<IssmDouble>* pSg_old, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius, IssmDouble* xx, IssmDouble* yy, IssmDouble* zz,int loop,int horiz);
-		IssmDouble SealevelriseOceanAverage(Vector<IssmDouble>* Sg);
+		void SealevelriseEustatic(Vector<IssmDouble>* pRSLgi, IssmDouble* poceanarea, IssmDouble* pbslr,IssmDouble* pbslrice, IssmDouble* pbslrhydro, IssmDouble** pbslrice_partition,IssmDouble** pbslrhydro_partition, SealevelMasks* masks); 
+		void SealevelriseNonEustatic(Vector<IssmDouble>* pSgo, Vector<IssmDouble>* pSg_old,  SealevelMasks* masks,bool verboseconvolution);
+		void SealevelriseRotationalFeedback(Vector<IssmDouble>* pRSLgo_rot, Vector<IssmDouble>* pRSLg_old, IssmDouble* pIxz, IssmDouble* pIyz, IssmDouble* pIzz, SealevelMasks* masks);
+		void SealevelriseElastic(Vector<IssmDouble>* pUp, Vector<IssmDouble>* pNorth, Vector<IssmDouble>* pEast, Vector<IssmDouble>* pSg_old, SealevelMasks* masks);
+		IssmDouble SealevelriseOceanAverage(Vector<IssmDouble>* Sg,SealevelMasks* masks, IssmDouble oceanarea);
 		#endif
 		void HydrologyEPLupdateDomainx(IssmDouble* pEplcount);
@@ -176,5 +180,7 @@
 		void InitTransientInputx(int* transientinput_enum,int numoutputs);
 		void StackTransientInputx(int* input_enum,int* transientinput_enum,IssmDouble hydrotime,int numoutputs);
-		void AverageTransientInputx(int* transientinput_enum,int* averagedinput_enum,IssmDouble init_time,IssmDouble end_time,int numoutputs);
+		void StackTransientInputonBasex(int* input_enum,int* transientinput_enum,IssmDouble hydrotime,int numoutputs);
+		void AverageTransientInputx(int* transientinput_enum,int* averagedinput_enum,IssmDouble init_time,IssmDouble end_time,int numoutputs,int averaging_method);
+		void AverageTransientInputonBasex(int* transientinput_enum,int* averagedinput_enum,IssmDouble init_time,IssmDouble end_time,int numoutputs,int averaging_method);
 		void UpdateConstraintsx(void);
 		int  UpdateVertexPositionsx(void);
@@ -195,10 +201,9 @@
 		void SetMesh(int** elementslist, IssmDouble** x, IssmDouble** y, int* numberofvertices, int* numberofelements);
 		void GetMeshOnPartition(Vertices* femmodel_vertices,Elements* femmodel_elements,IssmDouble** px, IssmDouble** py, IssmDouble** pz, int** pelementslist,int** psidtoindex);
-		void GetGroundediceLevelSet(IssmDouble** pmasklevelset);
 		void CreateElements(int newnumberofelements,int elementswidth,int* newelementslist,bool* my_elements,Elements* elements);
 		void CreateMaterials(int newnumberofelements,bool* my_elements,Materials* materials);
 		void CreateConstraints(Vertices* newfemmodel_vertices,int analysis_enum,Constraints* newfemmodel_constraints);
 		void GetInputs(int* pnumP0inputs,IssmDouble** pP0inputs,int** pP0input_enums,int** pP0input_interp,int* pnumP1inputs,IssmDouble** pP1inputs,int** pP1input_enums,int** pP1input_interp);
-		void InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements,Inputs2* new_inputs);
+		void InterpolateInputs(Vertices* newfemmodel_vertices,Elements* newfemmodel_elements,Inputs* new_inputs);
 		void UpdateElements(int newnumberofelements,int* newelementslist,bool* my_elements,int analysis_counter,Elements* newelements);
 		void WriteMeshInResults(void);
