Index: /issm/trunk/src/ad/todo
===================================================================
--- /issm/trunk/src/ad/todo	(revision 12705)
+++ /issm/trunk/src/ad/todo	(revision 12706)
@@ -41,2 +41,4 @@
 Create an alloc layer with template functions for new and delete.
 Check that the new code  is modular --without-kml, options are up to date.
+
+Replace memcpy, realloc with x layers.  Replace all calls to malloc and free in the code.
Index: /issm/trunk/src/android/ISSM_App/.classpath
===================================================================
--- /issm/trunk/src/android/ISSM_App/.classpath	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/.classpath	(revision 12706)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>
Index: /issm/trunk/src/android/ISSM_App/.project
===================================================================
--- /issm/trunk/src/android/ISSM_App/.project	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/.project	(revision 12706)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ISSM_App</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: /issm/trunk/src/android/ISSM_App/AndroidManifest.xml
===================================================================
--- /issm/trunk/src/android/ISSM_App/AndroidManifest.xml	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/AndroidManifest.xml	(revision 12706)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="issm.app"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk android:minSdkVersion="14" />
+
+    <application
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name" >
+        <activity
+            android:name=".ISSM_AppActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
Index: /issm/trunk/src/android/ISSM_App/gen/issm/app/BuildConfig.java
===================================================================
--- /issm/trunk/src/android/ISSM_App/gen/issm/app/BuildConfig.java	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/gen/issm/app/BuildConfig.java	(revision 12706)
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package issm.app;
+
+public final class BuildConfig {
+    public final static boolean DEBUG = true;
+}
Index: /issm/trunk/src/android/ISSM_App/gen/issm/app/R.java
===================================================================
--- /issm/trunk/src/android/ISSM_App/gen/issm/app/R.java	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/gen/issm/app/R.java	(revision 12706)
@@ -0,0 +1,27 @@
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package issm.app;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int ic_launcher=0x7f020000;
+    }
+    public static final class id {
+        public static final int editText2=0x7f050000;
+        public static final int seekBar2=0x7f050001;
+    }
+    public static final class layout {
+        public static final int main=0x7f030000;
+    }
+    public static final class string {
+        public static final int app_name=0x7f040001;
+        public static final int hello=0x7f040000;
+    }
+}
Index: /issm/trunk/src/android/ISSM_App/proguard-project.txt
===================================================================
--- /issm/trunk/src/android/ISSM_App/proguard-project.txt	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/proguard-project.txt	(revision 12706)
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
Index: /issm/trunk/src/android/ISSM_App/project.properties
===================================================================
--- /issm/trunk/src/android/ISSM_App/project.properties	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/project.properties	(revision 12706)
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-14
Index: /issm/trunk/src/android/ISSM_App/res/layout/main.xml
===================================================================
--- /issm/trunk/src/android/ISSM_App/res/layout/main.xml	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/res/layout/main.xml	(revision 12706)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal" >
+
+    <TextView
+        android:id="@+id/editText2"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:ems="10" android:translationX="0.5in" android:translationY="1in"/>
+    
+    <SeekBar
+        android:id="@+id/seekBar2"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:clickable="true"
+        android:max="100" android:translationY="2in" android:translationX="-0.5in"/>
+
+</LinearLayout>
Index: /issm/trunk/src/android/ISSM_App/res/values/strings.xml
===================================================================
--- /issm/trunk/src/android/ISSM_App/res/values/strings.xml	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/res/values/strings.xml	(revision 12706)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="hello">Hello World, ISSM_AppActivity!</string>
+    <string name="app_name">ISSM_App</string>
+
+</resources>
Index: /issm/trunk/src/android/ISSM_App/src/issm/app/ISSM_AppActivity.java
===================================================================
--- /issm/trunk/src/android/ISSM_App/src/issm/app/ISSM_AppActivity.java	(revision 12706)
+++ /issm/trunk/src/android/ISSM_App/src/issm/app/ISSM_AppActivity.java	(revision 12706)
@@ -0,0 +1,29 @@
+package issm.app;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.TextView;
+import android.widget.SeekBar;
+
+public class ISSM_AppActivity extends Activity implements OnClickListener
+{
+	private SeekBar sb;
+	private TextView tv;
+	
+    public void onCreate(Bundle savedInstanceState) 
+    {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main);
+        sb = (SeekBar)findViewById(R.id.seekBar2);
+        tv = (TextView)findViewById(R.id.editText2);
+        tv.setText("Current Progress: " + sb.getProgress());
+        sb.setOnClickListener(this);
+    }
+
+	public void onClick(View v)
+	{
+		tv.setText("Current Progress: " + sb.getProgress());
+	}
+}
Index: /issm/trunk/src/c/Container/Constraints.cpp
===================================================================
--- /issm/trunk/src/c/Container/Constraints.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Constraints.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,5 +25,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Constraints::Constraints(){{{1*/
+/*FUNCTION Constraints::Constraints(){{{*/
 Constraints::Constraints(){
 	enum_type=ConstraintsEnum;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Constraints::~Constraints(){{{1*/
+/*FUNCTION Constraints::~Constraints(){{{*/
 Constraints::~Constraints(){
 	return;
@@ -38,5 +38,5 @@
 
 /*Numerics: */
-/*FUNCTION Constraints::NumberOfConstraints{{{1*/
+/*FUNCTION Constraints::NumberOfConstraints{{{*/
 int Constraints::NumberOfConstraints(void){
 
Index: /issm/trunk/src/c/Container/Constraints.h
===================================================================
--- /issm/trunk/src/c/Container/Constraints.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Constraints.h	(revision 12706)
@@ -21,9 +21,9 @@
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Constraints();
 		~Constraints();
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		int   NumberOfConstraints(void);
 		/*}}}*/
Index: /issm/trunk/src/c/Container/Container.h
===================================================================
--- /issm/trunk/src/c/Container/Container.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Container.h	(revision 12706)
@@ -6,4 +6,5 @@
 #define  _CONTAINER_CONTAINER_H_
 
+#include "../include/include.h"
 #include "./DataSet.h"
 #include "./Constraints.h"
@@ -17,4 +18,5 @@
 #include "./Results.h"
 #include "./Vertices.h"
+#include "./Observations.h"
 
 #endif //ifndef _CONTAINER_H_
Index: /issm/trunk/src/c/Container/DataSet.cpp
===================================================================
--- /issm/trunk/src/c/Container/DataSet.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/DataSet.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -28,5 +28,5 @@
 
 /*Constructors/Destructors*/
-/*FUNCTION DataSet::DataSet(){{{1*/
+/*FUNCTION DataSet::DataSet(){{{*/
 DataSet::DataSet(){
 	
@@ -37,5 +37,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::DataSet(int dataset_enum){{{1*/
+/*FUNCTION DataSet::DataSet(int dataset_enum){{{*/
 DataSet::DataSet(int dataset_enum){
 	enum_type=dataset_enum;
@@ -47,5 +47,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::Copy{{{1*/
+/*FUNCTION DataSet::Copy{{{*/
 DataSet*   DataSet::Copy(void){
 
@@ -59,10 +59,10 @@
 	copy->presorted=presorted;
 	if(sorted_ids){
-		copy->sorted_ids=(int*)xmalloc(objects.size()*sizeof(int));
-		memcpy(copy->sorted_ids,sorted_ids,objects.size()*sizeof(int));
+		copy->sorted_ids=xNew<int>(objects.size());
+		xMemCpy<int>(copy->sorted_ids,sorted_ids,objects.size());
 	}
 	if(id_offsets){
-		copy->id_offsets=(int*)xmalloc(objects.size()*sizeof(int));
-		memcpy(copy->id_offsets,id_offsets,objects.size()*sizeof(int));
+		copy->id_offsets=xNew<int>(objects.size());
+		xMemCpy<int>(copy->id_offsets,id_offsets,objects.size());
 	}
 
@@ -77,14 +77,14 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::~DataSet{{{1*/
+/*FUNCTION DataSet::~DataSet{{{*/
 DataSet::~DataSet(){
 	clear();
-	xfree((void**)&sorted_ids);
-	xfree((void**)&id_offsets);
+	xDelete<int>(sorted_ids);
+	xDelete<int>(id_offsets);
 }
 /*}}}*/
 
 /*Specific methods*/
-/*FUNCTION DataSet::AddObject{{{1*/
+/*FUNCTION DataSet::AddObject{{{*/
 int  DataSet::AddObject(Object* object){
 
@@ -94,5 +94,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::clear{{{1*/
+/*FUNCTION DataSet::clear{{{*/
 void  DataSet::clear(){
 
@@ -112,5 +112,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::DeleteObject{{{1*/
+/*FUNCTION DataSet::DeleteObject{{{*/
 int  DataSet::DeleteObject(Object* object){
 
@@ -127,5 +127,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::DeepEcho{{{1*/
+/*FUNCTION DataSet::DeepEcho{{{*/
 void DataSet::DeepEcho(){
 
@@ -133,7 +133,7 @@
 	vector<Object*>::iterator object;
 
-	if(this==NULL)_error_(" trying to echo a NULL dataset");
-
-	_printf_(true,"DataSet echo: %i objects\n",objects.size());
+	if(this==NULL)_error2_("trying to echo a NULL dataset");
+
+	_pprintLine_("DataSet echo: " << objects.size() << " objects");
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
@@ -145,12 +145,12 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::Echo{{{1*/
+/*FUNCTION DataSet::Echo{{{*/
 void DataSet::Echo(){
 
 	vector<Object*>::iterator object;
 
-	if(this==NULL)_error_(" trying to echo a NULL dataset");
-
-	_printf_(true,"DataSet echo: %i objects\n",objects.size());
+	if(this==NULL)_error2_("trying to echo a NULL dataset");
+
+	_pprintLine_("DataSet echo: " << objects.size() << " objects");
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
@@ -163,10 +163,10 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::GetEnum(){{{1*/
+/*FUNCTION DataSet::GetEnum(){{{*/
 int  DataSet::GetEnum(){
 	return enum_type;
 }
 /*}}}*/
-/*FUNCTION DataSet::GetEnum(int offset){{{1*/
+/*FUNCTION DataSet::GetEnum(int offset){{{*/
 int   DataSet::GetEnum(int offset){
 
@@ -175,5 +175,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::GetObjectByOffset{{{1*/
+/*FUNCTION DataSet::GetObjectByOffset{{{*/
 Object* DataSet::GetObjectByOffset(int offset){
 
@@ -186,5 +186,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::GetObjectById{{{1*/
+/*FUNCTION DataSet::GetObjectById{{{*/
 Object* DataSet::GetObjectById(int* poffset,int eid){
 
@@ -194,9 +194,9 @@
 
 	_assert_(this);
-	if(!sorted)_error_(" trying to binary search on a non-sorted dataset!");
+	if(!sorted)_error2_("trying to binary search on a non-sorted dataset!");
 
 	/*Carry out a binary search on the sorted_ids: */
 	if(!binary_search(&id_offset,eid, sorted_ids,objects.size())){
-		_error_("could not find object with id %i in DataSet %s",eid,EnumToStringx(enum_type));
+		_error2_("could not find object with id " << eid << " in DataSet " << EnumToStringx(enum_type));
 	}
 
@@ -211,5 +211,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::Presort{{{1*/
+/*FUNCTION DataSet::Presort{{{*/
 void DataSet::Presort(){
 
@@ -221,10 +221,10 @@
 
 		/*Delete existing ids*/
-		xfree((void**)&sorted_ids);
-		xfree((void**)&id_offsets);
+		xDelete<int>(sorted_ids);
+		xDelete<int>(id_offsets);
 
 		/*Allocate new ids*/
-		sorted_ids=(int*)xmalloc(objects.size()*sizeof(int));
-		id_offsets=(int*)xmalloc(objects.size()*sizeof(int));
+		sorted_ids=xNew<int>(objects.size());
+		id_offsets=xNew<int>(objects.size());
 
 		/*Build id_offsets and sorted_ids*/
@@ -239,5 +239,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::SetSorting{{{1*/
+/*FUNCTION DataSet::SetSorting{{{*/
 void DataSet::SetSorting(int* in_sorted_ids,int* in_id_offsets){
 
@@ -247,5 +247,5 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::Size{{{1*/
+/*FUNCTION DataSet::Size{{{*/
 int  DataSet::Size(void){
 	_assert_(this!=NULL);
@@ -254,11 +254,11 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::Sort{{{1*/
+/*FUNCTION DataSet::Sort{{{*/
 void DataSet::Sort(){
 
 	/*Only sort if we are not already sorted: */
 	if(!sorted){
-		_error_(" not implemented yet!");
-	}
-}
-/*}}}*/
+		_error2_("not implemented yet!");
+	}
+}
+/*}}}*/
Index: /issm/trunk/src/c/Container/DataSet.h
===================================================================
--- /issm/trunk/src/c/Container/DataSet.h	(revision 12705)
+++ /issm/trunk/src/c/Container/DataSet.h	(revision 12706)
@@ -39,10 +39,10 @@
 		int*            id_offsets;
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		DataSet();
 		DataSet(int enum_type);
 		~DataSet();
 		/*}}}*/
-		/*management: {{{1*/
+		/*management: {{{*/
 		int   GetEnum();
 		int   GetEnum(int offset);
Index: /issm/trunk/src/c/Container/Elements.cpp
===================================================================
--- /issm/trunk/src/c/Container/Elements.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Elements.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,5 +25,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Elements::Elements(){{{1*/
+/*FUNCTION Elements::Elements(){{{*/
 Elements::Elements(){
 	enum_type=MeshElementsEnum;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Elements::~Elements(){{{1*/
+/*FUNCTION Elements::~Elements(){{{*/
 Elements::~Elements(){
 	return;
@@ -38,5 +38,5 @@
 
 /*Object management*/
-/*FUNCTION Elements::Configure{{{1*/
+/*FUNCTION Elements::Configure{{{*/
 void Elements::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
 
@@ -53,5 +53,5 @@
 }
 /*}}}*/
-/*FUNCTION Elements::ProcessResultsUnits{{{1*/
+/*FUNCTION Elements::ProcessResultsUnits{{{*/
 void Elements::ProcessResultsUnits(void){
 
@@ -63,5 +63,5 @@
 }
 /*}}}*/
-/*FUNCTION Elements::DeleteResults{{{1*/
+/*FUNCTION Elements::DeleteResults{{{*/
 void Elements::DeleteResults(void){
 	
@@ -72,5 +72,5 @@
 }
 /*}}}*/
-/*FUNCTION Elements::ResultsToPatch{{{1*/
+/*FUNCTION Elements::ResultsToPatch{{{*/
 Patch* Elements::ResultsToPatch(void){ 
 
@@ -148,5 +148,5 @@
 }
 /*}}}*/
-/*FUNCTION Elements::SetCurrentConfiguration{{{1*/
+/*FUNCTION Elements::SetCurrentConfiguration{{{*/
 void Elements::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
 
@@ -163,5 +163,5 @@
 }
 /*}}}*/
-/*FUNCTION Elements::ToResults{{{1*/
+/*FUNCTION Elements::ToResults{{{*/
 void Elements::ToResults(Results* results,Parameters* parameters){
 
@@ -173,6 +173,6 @@
 	int    *resultssizes  = NULL;
 	int    *resultssteps  = NULL;
-	double *resultstimes = NULL;
-	double *vector_serial= NULL;
+	IssmDouble *resultstimes = NULL;
+	IssmDouble *vector_serial= NULL;
 	Vector*     vector       = NULL;
 	bool   io_gather;
@@ -203,5 +203,5 @@
 		/*see what the first element of this partition has in stock (this is common to all partitions)*/
 		if(my_rank==minrank){
-			if(this->Size()==0) _error_("Cannot write results because there is no element??");
+			if(this->Size()==0) _error2_("Cannot write results because there is no element??");
 			Element* element=(Element*)this->GetObjectByOffset(0);
 			element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults);
@@ -215,8 +215,8 @@
 		#ifdef _HAVE_MPI_
 		if(my_rank!=minrank){
-			resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
-			resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
-			resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
-			resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
+			resultsenums=xNew<int>(numberofresults);
+			resultssizes=xNew<int>(numberofresults);
+			resultstimes=xNew<IssmDouble>(numberofresults);
+			resultssteps=xNew<int>(numberofresults);
 		}
 		MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
@@ -232,5 +232,5 @@
 			if(resultssizes[i]==P1Enum)      vectorsize=numberofvertices;
 			else if(resultssizes[i]==P0Enum) vectorsize=numberofelements;
-			else _error_("Unkown result size: %s",EnumToStringx(resultssizes[i]));
+			else _error2_("Unkown result size: " << EnumToStringx(resultssizes[i]));
 			vector=new Vector(vectorsize);
 
@@ -250,5 +250,5 @@
 			/*clean up*/
 			xdelete(&vector);
-			xfree((void**)&vector_serial);
+			xDelete<IssmDouble>(vector_serial);
 		}
 	}
@@ -269,12 +269,12 @@
 
 	/*Free ressources:*/
-	xfree((void**)&resultsenums);
-	xfree((void**)&resultssizes);
-	xfree((void**)&resultstimes);
-	xfree((void**)&resultssteps);
+	xDelete<int>(resultsenums);
+	xDelete<int>(resultssizes);
+	xDelete<int>(resultssteps);
+	xDelete<IssmDouble>(resultstimes);
 	delete patch;
 }
 /*}}}*/
-/*FUNCTION Elements::NumberOfElements{{{1*/
+/*FUNCTION Elements::NumberOfElements{{{*/
 int Elements::NumberOfElements(void){
 
@@ -292,5 +292,5 @@
 }
 /*}}}*/
-/*FUNCTION Elements::InputCopy{{{1*/
+/*FUNCTION Elements::InputCopy{{{*/
 void Elements::InputDuplicate(int input_enum,int output_enum){
 
Index: /issm/trunk/src/c/Container/Elements.h
===================================================================
--- /issm/trunk/src/c/Container/Elements.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Elements.h	(revision 12706)
@@ -16,14 +16,13 @@
 class Inputs;
 
-
 class Elements: public DataSet{
 
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Elements();
 		~Elements();
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
 		void DeleteResults(void);
Index: /issm/trunk/src/c/Container/Inputs.cpp
===================================================================
--- /issm/trunk/src/c/Container/Inputs.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Inputs.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,10 +25,10 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Inputs::Inputs(){{{1*/
+/*FUNCTION Inputs::Inputs(){{{*/
 Inputs::Inputs(){
 	return;
 }
 /*}}}*/
-/*FUNCTION Inputs::~Inputs(){{{1*/
+/*FUNCTION Inputs::~Inputs(){{{*/
 Inputs::~Inputs(){
 	return;
@@ -37,5 +37,5 @@
 
 /*Object management*/
-/*FUNCTION Inputs::GetInputValue(bool* pvalue,int enum-type){{{1*/
+/*FUNCTION Inputs::GetInputValue(bool* pvalue,int enum-type){{{*/
 void Inputs::GetInputValue(bool* pvalue,int enum_type){
 
@@ -57,5 +57,5 @@
 		/*we could not find an input with the correct enum type. No defaults values were provided, 
 		 * error out: */
-		_error_("could not find input with enum type %i (%s)",enum_type,EnumToStringx(enum_type));
+		_error2_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
 	}
 
@@ -65,5 +65,5 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::GetInputValue(int* pvalue,int enum-type){{{1*/
+/*FUNCTION Inputs::GetInputValue(int* pvalue,int enum-type){{{*/
 void Inputs::GetInputValue(int* pvalue,int enum_type){
 
@@ -85,5 +85,5 @@
 		/*we could not find an input with the correct enum type. No defaults values were provided, 
 		 * error out: */
-		_error_("could not find input with enum type %i (%s)",enum_type,EnumToStringx(enum_type));
+		_error2_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
 	}
 
@@ -93,6 +93,6 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::GetInputValue(double* pvalue,int enum-type){{{1*/
-void Inputs::GetInputValue(double* pvalue,int enum_type){
+/*FUNCTION Inputs::GetInputValue(IssmDouble* pvalue,int enum-type){{{*/
+void Inputs::GetInputValue(IssmDouble* pvalue,int enum_type){
 
 	vector<Object*>::iterator object;
@@ -113,5 +113,5 @@
 		/*we could not find an input with the correct enum type. No defaults values were provided, 
 		 * error out: */
-		_error_("could not find input with enum type %i (%s)",enum_type,EnumToStringx(enum_type));
+		_error2_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
 	}
 
@@ -121,6 +121,6 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::GetInputAverage{{{1*/
-void Inputs::GetInputAverage(double* pvalue,int enum_type){
+/*FUNCTION Inputs::GetInputAverage{{{*/
+void Inputs::GetInputAverage(IssmDouble* pvalue,int enum_type){
 
 	vector<Object*>::iterator object;
@@ -141,5 +141,5 @@
 		/*we could not find an input with the correct enum type. No defaults values were provided, 
 		 * error out: */
-		_error_("could not find input with enum type %i (%s)",enum_type,EnumToStringx(enum_type));
+		_error2_("could not find input with enum type " << enum_type << " (" << EnumToStringx(enum_type) << ")");
 	}
 
@@ -149,5 +149,5 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::AddInput{{{1*/
+/*FUNCTION Inputs::AddInput{{{*/
 int  Inputs::AddInput(Input* in_input){
 
@@ -175,5 +175,5 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::ChangeEnum{{{1*/
+/*FUNCTION Inputs::ChangeEnum{{{*/
 void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){
 
@@ -205,6 +205,6 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::ConstrainMin{{{1*/
-void  Inputs::ConstrainMin(int constrain_enum, double minimum){
+/*FUNCTION Inputs::ConstrainMin{{{*/
+void  Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){
 	   
 	Input* constrain_input=NULL; 
@@ -213,5 +213,5 @@
 
 	/*some checks: */
-	if(!constrain_input) _error_(" input %s could not be found!",EnumToStringx(constrain_enum));
+	if(!constrain_input) _error2_("input " << EnumToStringx(constrain_enum) << " could not be found!");
 
 	/*Apply ContrainMin: */
@@ -219,9 +219,9 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::InfinityNorm{{{1*/
-double Inputs::InfinityNorm(int enumtype){
-
-	/*Output*/
-	double norm;
+/*FUNCTION Inputs::InfinityNorm{{{*/
+IssmDouble Inputs::InfinityNorm(int enumtype){
+
+	/*Output*/
+	IssmDouble norm;
 
 	/*Get input*/
@@ -240,9 +240,9 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::Max{{{1*/
-double Inputs::Max(int enumtype){
-
-	/*Output*/
-	double max;
+/*FUNCTION Inputs::Max{{{*/
+IssmDouble Inputs::Max(int enumtype){
+
+	/*Output*/
+	IssmDouble max;
 
 	/*Get input*/
@@ -254,5 +254,5 @@
 	}
 	else{
-		_error_("Input %s not found",EnumToStringx(enumtype));
+		_error2_("Input " << EnumToStringx(enumtype) << " not found");
 	}
 
@@ -261,9 +261,9 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::MaxAbs{{{1*/
-double Inputs::MaxAbs(int enumtype){
-
-	/*Output*/
-	double max;
+/*FUNCTION Inputs::MaxAbs{{{*/
+IssmDouble Inputs::MaxAbs(int enumtype){
+
+	/*Output*/
+	IssmDouble max;
 
 	/*Get input*/
@@ -275,5 +275,5 @@
 	}
 	else{
-		_error_("Input %s not found",EnumToStringx(enumtype));
+		_error2_("Input " << EnumToStringx(enumtype) << " not found");
 	}
 
@@ -282,9 +282,9 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::Min{{{1*/
-double Inputs::Min(int enumtype){
-
-	/*Output*/
-	double min;
+/*FUNCTION Inputs::Min{{{*/
+IssmDouble Inputs::Min(int enumtype){
+
+	/*Output*/
+	IssmDouble min;
 
 	/*Get input*/
@@ -296,5 +296,5 @@
 	}
 	else{
-		_error_("Input %s not found",EnumToStringx(enumtype));
+		_error2_("Input " << EnumToStringx(enumtype) << " not found");
 	}
 
@@ -303,9 +303,9 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::MinAbs{{{1*/
-double Inputs::MinAbs(int enumtype){
-
-	/*Output*/
-	double min;
+/*FUNCTION Inputs::MinAbs{{{*/
+IssmDouble Inputs::MinAbs(int enumtype){
+
+	/*Output*/
+	IssmDouble min;
 
 	/*Get input*/
@@ -317,5 +317,5 @@
 	}
 	else{
-		_error_("Input %s not found",EnumToStringx(enumtype));
+		_error2_("Input " << EnumToStringx(enumtype) << " not found");
 	}
 
@@ -324,5 +324,5 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::GetInput{{{1*/
+/*FUNCTION Inputs::GetInput{{{*/
 Input* Inputs::GetInput(int enum_name){
 
@@ -341,5 +341,5 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::DeleteInput{{{1*/
+/*FUNCTION Inputs::DeleteInput{{{*/
 int  Inputs::DeleteInput(int enum_type){
 
@@ -361,5 +361,5 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::DuplicateInput{{{1*/
+/*FUNCTION Inputs::DuplicateInput{{{*/
 void  Inputs::DuplicateInput(int original_enum,int new_enum){
 
@@ -369,5 +369,5 @@
 	/*Make a copy of the original input: */
 	original=(Input*)this->GetInput(original_enum);
-	if(!original)_error_("could not find input with enum: %s",EnumToStringx(original_enum)); 
+	if(!original)_error2_("could not find input with enum: " << EnumToStringx(original_enum)); 
 	copy=(Input*)original->copy();
 
@@ -379,5 +379,5 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::SpawnTriaInputs{{{1*/
+/*FUNCTION Inputs::SpawnTriaInputs{{{*/
 Inputs* Inputs::SpawnTriaInputs(int* indices){
 
@@ -405,6 +405,6 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::AXPY{{{1*/
-void  Inputs::AXPY(int MeshYEnum, double scalar, int MeshXEnum){
+/*FUNCTION Inputs::AXPY{{{*/
+void  Inputs::AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum){
 	   
 	Input* xinput=NULL;
@@ -416,6 +416,6 @@
 
 	/*some checks: */
-	if(!xinput) _error_(" input %s could not be found!",EnumToStringx(MeshXEnum));
-	if(!yinput) _error_(" input %s could not be found!",EnumToStringx(MeshYEnum));
+	if(!xinput) _error2_("input " << EnumToStringx(MeshXEnum) << " could not be found!");
+	if(!yinput) _error2_("input " << EnumToStringx(MeshYEnum) << " could not be found!");
 
 	/*Apply AXPY: */
@@ -423,5 +423,5 @@
 }
 /*}}}*/
-/*FUNCTION Inputs::Configure{{{1*/
+/*FUNCTION Inputs::Configure{{{*/
 void Inputs::Configure(Parameters* parameters){
 
Index: /issm/trunk/src/c/Container/Inputs.h
===================================================================
--- /issm/trunk/src/c/Container/Inputs.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Inputs.h	(revision 12706)
@@ -23,28 +23,28 @@
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Inputs();
 		~Inputs();
 
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		int     AddInput(Input* in_input);
 		void    ChangeEnum(int enumtype,int new_enumtype);
-		void    ConstrainMin(int constrain_enum, double minimum);
+		void    ConstrainMin(int constrain_enum, IssmDouble minimum);
 		int     DeleteInput(int enum_type);
 		void    DuplicateInput(int original_enum,int new_enum);
 		Input*  GetInput(int enum_name);
 		Inputs* SpawnTriaInputs(int* indices);
-		void    AXPY(int MeshYEnum, double scalar, int MeshXEnum);
-		double  InfinityNorm(int enumtype);
-		double  Max(int enumtype);
-		double  MaxAbs(int enumtype);
-		double  Min(int enumtype);
-		double  MinAbs(int enumtype);
+		void    AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum);
+		IssmDouble  InfinityNorm(int enumtype);
+		IssmDouble  Max(int enumtype);
+		IssmDouble  MaxAbs(int enumtype);
+		IssmDouble  Min(int enumtype);
+		IssmDouble  MinAbs(int enumtype);
 		
-		void GetInputAverage(double* pvalue, int enum_type);
+		void GetInputAverage(IssmDouble* pvalue, int enum_type);
 		void GetInputValue(bool* pvalue,int enum_type);
 		void GetInputValue(int* pvalue,int enum_type);
-		void GetInputValue(double* pvalue,int enum_type);
+		void GetInputValue(IssmDouble* pvalue,int enum_type);
 
 		void Configure(Parameters* parameters);
Index: /issm/trunk/src/c/Container/Loads.cpp
===================================================================
--- /issm/trunk/src/c/Container/Loads.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Loads.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,5 +25,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Loads::Loads(){{{1*/
+/*FUNCTION Loads::Loads(){{{*/
 Loads::Loads(){
 	enum_type=LoadsEnum;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Loads::~Loads(){{{1*/
+/*FUNCTION Loads::~Loads(){{{*/
 Loads::~Loads(){
 	return;
@@ -38,5 +38,5 @@
 
 /*Numerics:*/
-/*FUNCTION Loads::Configure{{{1*/
+/*FUNCTION Loads::Configure{{{*/
 void Loads::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
 
@@ -53,5 +53,5 @@
 }
 /*}}}*/
-/*FUNCTION Loads::NumberOfLoads{{{1*/
+/*FUNCTION Loads::NumberOfLoads{{{*/
 int Loads::NumberOfLoads(void){
 
@@ -74,5 +74,5 @@
 }
 /*}}}*/
-/*FUNCTION Loads::SetCurrentConfiguration{{{1*/
+/*FUNCTION Loads::SetCurrentConfiguration{{{*/
 void Loads::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
 
Index: /issm/trunk/src/c/Container/Loads.h
===================================================================
--- /issm/trunk/src/c/Container/Loads.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Loads.h	(revision 12706)
@@ -20,9 +20,9 @@
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Loads();
 		~Loads();
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
 		int   NumberOfLoads(void);
Index: /issm/trunk/src/c/Container/Materials.cpp
===================================================================
--- /issm/trunk/src/c/Container/Materials.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Materials.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,5 +25,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Materials::Materials(){{{1*/
+/*FUNCTION Materials::Materials(){{{*/
 Materials::Materials(){
 	enum_type=MaterialsEnum;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Materials::~Materials(){{{1*/
+/*FUNCTION Materials::~Materials(){{{*/
 Materials::~Materials(){
 	return;
@@ -38,5 +38,5 @@
 
 /*Object management*/
-/*FUNCTION Materials::Configure{{{1*/
+/*FUNCTION Materials::Configure{{{*/
 void Materials::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
 
Index: /issm/trunk/src/c/Container/Materials.h
===================================================================
--- /issm/trunk/src/c/Container/Materials.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Materials.h	(revision 12706)
@@ -19,9 +19,9 @@
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Materials();
 		~Materials();
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
 		/*}}}*/
Index: /issm/trunk/src/c/Container/Nodes.cpp
===================================================================
--- /issm/trunk/src/c/Container/Nodes.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Nodes.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,5 +25,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Nodes::Nodes(){{{1*/
+/*FUNCTION Nodes::Nodes(){{{*/
 Nodes::Nodes(){
 	enum_type=NodesEnum;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Nodes::~Nodes(){{{1*/
+/*FUNCTION Nodes::~Nodes(){{{*/
 Nodes::~Nodes(){
 	return;
@@ -38,5 +38,5 @@
 
 /*Numerics*/
-/*FUNCTION Nodes::Configure{{{1*/
+/*FUNCTION Nodes::Configure{{{*/
 void Nodes::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
 
@@ -53,5 +53,5 @@
 }
 /*}}}*/
-/*FUNCTION Nodes::DistributeDofs{{{1*/
+/*FUNCTION Nodes::DistributeDofs{{{*/
 void  Nodes::DistributeDofs(int analysis_type,int setenum){
 
@@ -84,5 +84,5 @@
 	 * cpus by the total last dofs of the previus cpu, starting from 0.
 	 * First: get number of dofs for each cpu*/
-	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
+	alldofcount=xNew<int>(num_procs);
 	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
@@ -113,6 +113,6 @@
 	numnodes=this->NumberOfNodes(analysis_type);
 	if(numnodes*maxdofspernode){
-		truedofs=   (int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max
-		alltruedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int));
+		truedofs=   xNewZeroInit<int>(numnodes*maxdofspernode); //initialize to 0, so that we can pick up the max
+		alltruedofs=xNewZeroInit<int>(numnodes*maxdofspernode);
 	}
 
@@ -139,10 +139,10 @@
 
 	/* Free ressources: */
-	xfree((void**)&alldofcount);
-	xfree((void**)&truedofs);
-	xfree((void**)&alltruedofs);
-}
-/*}}}*/
-/*FUNCTION Nodes::FlagClones{{{1*/
+	xDelete<int>(alldofcount);
+	xDelete<int>(truedofs);
+	xDelete<int>(alltruedofs);
+}
+/*}}}*/
+/*FUNCTION Nodes::FlagClones{{{*/
 void  Nodes::FlagClones(int analysis_type){
 
@@ -158,6 +158,6 @@
 
 	/*Allocate ranks: */
-	ranks=(int*)xmalloc(numnodes*sizeof(int));
-	minranks=(int*)xmalloc(numnodes*sizeof(int));
+	ranks=xNew<int>(numnodes);
+	minranks=xNew<int>(numnodes);
 
 	for(i=0;i<numnodes;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit.
@@ -190,10 +190,10 @@
 
 	/*Free ressources: */
-	xfree((void**)&ranks); 
-	xfree((void**)&minranks);
-
-}
-/*}}}*/
-/*FUNCTION Nodes::MaxNumDofs{{{1*/
+	xDelete<int>(ranks); 
+	xDelete<int>(minranks);
+
+}
+/*}}}*/
+/*FUNCTION Nodes::MaxNumDofs{{{*/
 int   Nodes::MaxNumDofs(int analysis_type,int setenum){
 
@@ -225,5 +225,5 @@
 }
 /*}}}*/
-/*FUNCTION Nodes::NumberOfDofs{{{1*/
+/*FUNCTION Nodes::NumberOfDofs{{{*/
 int   Nodes::NumberOfDofs(int analysis_type,int setenum){
 
@@ -259,5 +259,5 @@
 }
 /*}}}*/
-/*FUNCTION Nodes::NumberOfNodes(){{{1*/
+/*FUNCTION Nodes::NumberOfNodes(){{{*/
 int Nodes::NumberOfNodes(void){
 
@@ -287,5 +287,5 @@
 }
 /*}}}*/
-/*FUNCTION Nodes::NumberOfNodes(analysis){{{1*/
+/*FUNCTION Nodes::NumberOfNodes(analysis){{{*/
 int Nodes::NumberOfNodes(int analysis_type){
 
@@ -326,5 +326,5 @@
 }
 /*}}}*/
-/*FUNCTION Nodes::Ranks{{{1*/
+/*FUNCTION Nodes::Ranks{{{*/
 void   Nodes::Ranks(int* ranks,int analysis_type){
 
@@ -352,5 +352,5 @@
 }
 /*}}}*/
-/*FUNCTION Nodes::SetCurrentConfiguration{{{1*/
+/*FUNCTION Nodes::SetCurrentConfiguration{{{*/
 void Nodes::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
 
Index: /issm/trunk/src/c/Container/Nodes.h
===================================================================
--- /issm/trunk/src/c/Container/Nodes.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Nodes.h	(revision 12706)
@@ -13,9 +13,9 @@
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Nodes();
 		~Nodes();
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
 		void  DistributeDofs(int analysis_type,int SETENUM);
Index: /issm/trunk/src/c/Container/Observations.cpp
===================================================================
--- /issm/trunk/src/c/Container/Observations.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Observations.cpp	(revision 12706)
@@ -20,5 +20,7 @@
 #include "../shared/shared.h"
 #include "../include/include.h"
+#include "../modules/modules.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
+#include "../io/io.h"
 
 using namespace std;
@@ -32,12 +34,12 @@
 }
 /*}}}*/
-/*FUNCTION Observations::Observations(double* observations_list,double* x,double* y,int n,Options* options){{{*/
-Observations::Observations(double* observations_list,double* x,double* y,int n,Options* options){
+/*FUNCTION Observations::Observations(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options){{{*/
+Observations::Observations(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options){
 
 	/*Intermediaries*/
 	int          i,j,maxdepth,level,counter,index;
 	int          xi,yi;
-	double       xmin,xmax,ymin,ymax;
-	double       offset,minlength,minspacing,mintrimming,maxtrimming;
+	IssmDouble       xmin,xmax,ymin,ymax;
+	IssmDouble       offset,minlength,minspacing,mintrimming,maxtrimming;
 	int         *indices     = NULL;
 	Observation *observation = NULL;
@@ -57,19 +59,19 @@
 	options->Get(&maxtrimming,"maxtrimming",+1.e+21);
 	options->Get(&minspacing,"minspacing",0.01);
-	if(minspacing<=0) _error_("minspacing must > 0");
+	if(minspacing<=0) _error2_("minspacing must > 0");
 
 	/*Get Minimum box size*/
 	if(options->GetOption("boxlength")){
 		options->Get(&minlength,"boxlength");
-		if(minlength<=0)_error_("boxlength should be a positive number");
+		if(minlength<=0)_error2_("boxlength should be a positive number");
 		maxdepth=int(log(max(xmax-xmin,ymax-ymin)/minlength +1)/log(2.0));
 	}
 	else{
 		maxdepth = 30;
-		minlength=max(xmax-xmin,ymax-ymin)/double((1L<<maxdepth)-1);
+		minlength=max(xmax-xmin,ymax-ymin)/IssmDouble((1L<<maxdepth)-1);
 	}
 
 	/*Initialize Quadtree*/
-	printf("Generating quadtree with a maximum box size %g (depth=%i)... ",minlength,maxdepth);
+	_pprintString_("Generating quadtree with a maximum box size " << minlength << " (depth=" << maxdepth << ")... ");
 	this->quadtree = new Quadtree(xmin,xmax,ymin,ymax,maxdepth);
 
@@ -101,7 +103,7 @@
 		}
 	}
-	printf("done\n");
-	printf("Initial number of observations: %i\n",n);
-	printf("  Final number of observations: %i\n",this->quadtree->NbObs);
+	_pprintLine_("done");
+	_pprintLine_("Initial number of observations: " << n);
+	_pprintLine_("  Final number of observations: " << this->quadtree->NbObs);
 }
 /*}}}*/
@@ -114,21 +116,72 @@
 
 /*Methods*/
-/*FUNCTION Observations::ObservationList{{{*/
-void Observations::ObservationList(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata){
+/*FUNCTION Observations::ClosestObservation{{{*/
+void Observations::ClosestObservation(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius){
+
+	/*Output and Intermediaries*/
+	bool         stop;
+	int          nobs,i,index;
+	IssmDouble       h2,hmin2,radius2;
+	int         *indices      = NULL;
+	Observation *observation  = NULL;
+
+	/*If radius is not provided or is 0, return all observations*/
+	if(radius==0) radius=this->quadtree->root->length;
+
+	/*Compute radius square*/
+	radius2 = radius*radius;
+
+	/*Find all observations that are in radius*/
+	this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius);
+	for (i=0;i<nobs;i++){
+		observation=(Observation*)this->GetObjectByOffset(indices[i]);
+		h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
+
+		if(i==0){
+			hmin2 = h2;
+			index = i;
+		}
+		else{
+			if(h2<hmin2){
+				hmin2 = h2;
+				index = i;
+			}
+		}
+	}  
+
+	/*Assign output pointer*/
+	if(!nobs){
+		*px=UNDEF;
+		*py=UNDEF;
+		*pobs=UNDEF;
+	}
+	else{
+		observation=(Observation*)this->GetObjectByOffset(indices[index]);
+		*px=observation->x;
+		*py=observation->y;
+		*pobs=observation->value;
+	}
+	xDelete<int>(indices);
+
+}/*}}}*/
+/*FUNCTION Observations::ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata){{{*/
+void Observations::ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata){
 
 	/*Output and Intermediaries*/
 	bool         stop;
 	int          nobs,tempnobs,i,j,k,n,counter;
-	double       h2,radius2;
+	IssmDouble       h2,radius2;
 	int         *indices      = NULL;
 	int         *tempindices  = NULL;
-	double      *dists        = NULL;
-	double      *x            = NULL;
-	double      *y            = NULL;
-	double      *obs          = NULL;
+	IssmDouble      *dists        = NULL;
+	IssmDouble      *x            = NULL;
+	IssmDouble      *y            = NULL;
+	IssmDouble      *obs          = NULL;
 	Observation *observation  = NULL;
 
+	/*If radius is not provided or is 0, return all observations*/
+	if(radius==0) radius=this->quadtree->root->length;
+
 	/*Compute radius square*/
-	if(radius==0) radius=this->quadtree->root->length;
 	radius2 = radius*radius;
 
@@ -136,6 +189,6 @@
 	this->quadtree->RangeSearch(&tempindices,&tempnobs,x_interp,y_interp,radius);
 	if(tempnobs){
-		indices = (int*)xmalloc(tempnobs*sizeof(int));
-		dists   = (double*)xmalloc(tempnobs*sizeof(double));
+		indices = xNew<int>(tempnobs);
+		dists   = xNew<IssmDouble>(tempnobs);
 	}
 	nobs = 0;
@@ -172,12 +225,12 @@
 		}
 	}  
-	xfree((void**)&dists);
-	xfree((void**)&tempindices);
+	xDelete<IssmDouble>(dists);
+	xDelete<int>(tempindices);
 
 	if(nobs){
 		/*Allocate vectors*/
-		x   = (double*)xmalloc(nobs*sizeof(double));
-		y   = (double*)xmalloc(nobs*sizeof(double));
-		obs = (double*)xmalloc(nobs*sizeof(double));
+		x   = xNew<IssmDouble>(nobs);
+		y   = xNew<IssmDouble>(nobs);
+		obs = xNew<IssmDouble>(nobs);
 
 		/*Loop over all observations and fill in x, y and obs*/
@@ -189,5 +242,5 @@
 
 	/*Assign output pointer*/
-	xfree((void**)&indices);
+	xDelete<int>(indices);
 	*px=x;
 	*py=y;
@@ -195,6 +248,182 @@
 	*pnobs=nobs;
 }/*}}}*/
+/*FUNCTION Observations::ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs){{{*/
+void Observations::ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs){
+
+	/*Output and Intermediaries*/
+	int          nobs;
+	IssmDouble      *x            = NULL;
+	IssmDouble      *y            = NULL;
+	IssmDouble      *obs          = NULL;
+	Observation *observation  = NULL;
+
+	nobs = this->Size();
+
+	if(nobs){
+		x   = xNew<IssmDouble>(nobs);
+		y   = xNew<IssmDouble>(nobs);
+		obs = xNew<IssmDouble>(nobs);
+		for(int i=0;i<this->Size();i++){
+			observation=(Observation*)this->GetObjectByOffset(i);
+			observation->WriteXYObs(&x[i],&y[i],&obs[i]);
+		}
+	}
+
+	/*Assign output pointer*/
+	*px=x;
+	*py=y;
+	*pobs=obs;
+	*pnobs=nobs;
+}/*}}}*/
+/*FUNCTION Observations::InterpolationIDW{{{*/
+void Observations::InterpolationIDW(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,IssmDouble power){
+
+	/*Intermediaries*/
+	int    i,n_obs;
+	IssmDouble prediction;
+	IssmDouble numerator,denominator,h,weight;
+	IssmDouble *x   = NULL;
+	IssmDouble *y   = NULL;
+	IssmDouble *obs = NULL;
+
+	/*Some checks*/
+	_assert_(maxdata>0);
+	_assert_(pprediction);
+	_assert_(power>0);
+
+	/*If radius is not provided or is 0, return all observations*/
+	if(radius==0) radius=this->quadtree->root->length;
+
+	/*Get list of observations for current point*/
+	this->ObservationList(&x,&y,&obs,&n_obs,x_interp,y_interp,radius,maxdata);
+
+	/*If we have less observations than mindata, return UNDEF*/
+	if(n_obs<mindata){
+		prediction = UNDEF; 
+	}
+	else{
+		numerator   = 0.;
+		denominator = 0.;
+		for(i=0;i<n_obs;i++){
+			h = sqrt( (x[i]-x_interp)*(x[i]-x_interp) + (y[i]-y_interp)*(y[i]-y_interp));
+			if (h<0.0000001){
+				numerator   = obs[i];
+				denominator = 1.;
+				break;
+			}
+			weight = 1./pow(h,power);
+			numerator   += weight*obs[i];
+			denominator += weight;
+		}
+		prediction = numerator/denominator; 
+	}
+
+	/*clean-up*/
+	*pprediction = prediction;
+	xDelete<IssmDouble>(x);
+	xDelete<IssmDouble>(y);
+	xDelete<IssmDouble>(obs);
+}/*}}}*/
+/*FUNCTION Observations::InterpolationKriging{{{*/
+void Observations::InterpolationKriging(IssmDouble *pprediction,IssmDouble *perror,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,Variogram* variogram){
+
+	/*Intermediaries*/
+	int           i,j,n_obs;
+	IssmDouble        prediction,error;
+	IssmDouble        numerator,denominator,ratio;
+	IssmDouble       *x            = NULL;
+	IssmDouble       *y            = NULL;
+	IssmDouble       *obs          = NULL;
+	IssmDouble       *Gamma        = NULL;
+	IssmDouble       *GinvG0       = NULL;
+	IssmDouble       *Ginv1        = NULL;
+	IssmDouble       *GinvZ        = NULL;
+	IssmDouble       *gamma0       = NULL;
+	IssmDouble       *ones         = NULL;
+
+	/*Some checks*/
+	_assert_(mindata>0 && maxdata>0);
+	_assert_(pprediction && perror);
+
+	/*If radius is not provided or is 0, return all observations*/
+	if(radius==0) radius=this->quadtree->root->length;
+
+	/*Get list of observations for current point*/
+	this->ObservationList(&x,&y,&obs,&n_obs,x_interp,y_interp,radius,maxdata);
+
+	/*If we have less observations than mindata, return UNDEF*/
+	if(n_obs<mindata){
+		*pprediction = -999.0; 
+		*perror      = -999.0; 
+		return;
+	}
+
+	/*Allocate intermediary matrix and vectors*/
+	Gamma  = xNew<IssmDouble>(n_obs*n_obs);
+	gamma0 = xNew<IssmDouble>(n_obs);
+	ones   = xNew<IssmDouble>(n_obs);
+
+	/*First: Create semivariogram matrix for observations*/
+	for(i=0;i<n_obs;i++){
+		for(j=0;j<=i;j++){
+			//Gamma[i*n_obs+j] = variogram->SemiVariogram(x[i]-x[j],y[i]-y[j]);
+			Gamma[i*n_obs+j] = variogram->Covariance(x[i]-x[j],y[i]-y[j]);
+			Gamma[j*n_obs+i] = Gamma[i*n_obs+j];
+		}
+	}
+	for(i=0;i<n_obs;i++) ones[i]=1;
+
+	/*Get semivariogram vector associated to this location*/
+	//for(i=0;i<n_obs;i++) gamma0[i] = variogram->SemiVariogram(x[i]-x_interp,y[i]-y_interp);
+	for(i=0;i<n_obs;i++) gamma0[i] = variogram->Covariance(x[i]-x_interp,y[i]-y_interp);
+
+	/*Solve the three linear systems*/
+#if _HAVE_GSL_
+	SolverxGsl(&GinvG0,Gamma,gamma0,n_obs); // Gamma^-1 gamma0
+	SolverxGsl(&Ginv1, Gamma,ones,n_obs);   // Gamma^-1 ones
+	SolverxGsl(&GinvZ, Gamma,obs,n_obs);    // Gamma^-1 Z
+#else
+	_error2_("GSL is required");
+#endif
+
+	/*Prepare predictor*/
+	numerator=-1.; denominator=0.;
+	for(i=0;i<n_obs;i++) numerator  +=GinvG0[i];
+	for(i=0;i<n_obs;i++) denominator+=Ginv1[i];
+	ratio=numerator/denominator;
+
+	prediction = 0.;
+	error      = - numerator*numerator/denominator;
+	for(i=0;i<n_obs;i++) prediction += (gamma0[i]-ratio)*GinvZ[i];
+	for(i=0;i<n_obs;i++) error += gamma0[i]*GinvG0[i];
+
+	/*clean-up*/
+	*pprediction = prediction;
+	*perror = error;
+	xDelete<IssmDouble>(x);
+	xDelete<IssmDouble>(y);
+	xDelete<IssmDouble>(obs);
+	xDelete<IssmDouble>(Gamma);
+	xDelete<IssmDouble>(gamma0);
+	xDelete<IssmDouble>(ones);
+	xDelete<IssmDouble>(GinvG0);
+	xDelete<IssmDouble>(Ginv1);
+	xDelete<IssmDouble>(GinvZ);
+
+}/*}}}*/
+/*FUNCTION Observations::InterpolationNearestNeighbor{{{*/
+void Observations::InterpolationNearestNeighbor(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius){
+
+	/*Intermediaries*/
+	IssmDouble        x,y,obs;
+
+	/*Get clostest observation*/
+	this->ClosestObservation(&x,&y,&obs,x_interp,y_interp,radius);
+
+	/*Assign output pointer*/
+	*pprediction = obs;
+}/*}}}*/
 /*FUNCTION Observations::QuadtreeColoring{{{*/
-void Observations::QuadtreeColoring(double* A,double *x,double *y,int n){
+void Observations::QuadtreeColoring(IssmDouble* A,IssmDouble *x,IssmDouble *y,int n){
 
 	int xi,yi,level;
@@ -203,19 +432,19 @@
 		this->quadtree->IntergerCoordinates(&xi,&yi,x[i],y[i]);
 		this->quadtree->QuadtreeDepth(&level,xi,yi);
-		A[i]=(double)level;
+		A[i]=(IssmDouble)level;
 	}
 
 }/*}}}*/
 /*FUNCTION Observations::Variomap{{{*/
-void Observations::Variomap(double* gamma,double *x,int n){
+void Observations::Variomap(IssmDouble* gamma,IssmDouble *x,int n){
 
 	/*Output and Intermediaries*/
 	int          i,j,k;
-	double       distance;
+	IssmDouble       distance;
 	Observation *observation1 = NULL;
 	Observation *observation2 = NULL;
 
-	int *counter= (int*)xmalloc(n*sizeof(int));
-	for(j=0;j<n;j++) counter[j] = 0;
+	IssmDouble *counter = xNew<IssmDouble>(n);
+	for(j=0;j<n;j++) counter[j] = 0.0;
 	for(j=0;j<n;j++) gamma[j]   = 0.0;
 
@@ -234,15 +463,15 @@
 
 			gamma[index]   += 1./2.*pow(observation1->value - observation2->value,2.);
-			counter[index] += 1;
+			counter[index] += 1.;
 		}
 	}
 
 	/*Normalize semivariogram*/
-	gamma[0]=0;
+	gamma[0]=0.;
 	for(k=0;k<n;k++){
-		if(counter[k]) gamma[k] = gamma[k]/double(counter[k]);
+		if(counter[k]) gamma[k] = gamma[k]/counter[k];
 	}
 
 	/*Assign output pointer*/
-	xfree((void**)&counter);
-}/*}}}*/
+	xDelete<IssmDouble>(counter);
+}/*}}}*/
Index: /issm/trunk/src/c/Container/Observations.h
===================================================================
--- /issm/trunk/src/c/Container/Observations.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Observations.h	(revision 12706)
@@ -6,6 +6,8 @@
 #define  _CONTAINER_OBSERVATIONS_H_
 
-class Obsevration;
+#include "../include/include.h"
+
 class Quadtree;
+class Variogram;
 class Options;
 
@@ -19,11 +21,16 @@
 		/*constructors, destructors*/
 		Observations();
-		Observations(double* observations_list,double* x,double* y,int n,Options* options);
+		Observations(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options);
 		~Observations();
 
 		/*Methods*/
-		void ObservationList(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata);
-		void QuadtreeColoring(double* A,double *x,double *y,int n);
-		void Variomap(double* gamma,double *x,int n);
+		void ClosestObservation(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
+		void InterpolationIDW(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,IssmDouble power);
+		void InterpolationKriging(IssmDouble *pprediction,IssmDouble *perror,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,Variogram* variogram);
+		void InterpolationNearestNeighbor(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
+		void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs);
+		void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
+		void QuadtreeColoring(IssmDouble* A,IssmDouble *x,IssmDouble *y,int n);
+		void Variomap(IssmDouble* gamma,IssmDouble *x,int n);
 
 };
Index: /issm/trunk/src/c/Container/Options.cpp
===================================================================
--- /issm/trunk/src/c/Container/Options.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Options.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,10 +25,10 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Options::Options(){{{1*/
+/*FUNCTION Options::Options(){{{*/
 Options::Options(){
 	return;
 }
 /*}}}*/
-/*FUNCTION Options::~Options(){{{1*/
+/*FUNCTION Options::~Options(){{{*/
 Options::~Options(){
 	return;
@@ -37,5 +37,5 @@
 
 /*Object management*/
-/*FUNCTION Options::AddOption{{{1*/
+/*FUNCTION Options::AddOption{{{*/
 int  Options::AddOption(Option* in_option){
 
@@ -47,8 +47,8 @@
 
 	/*Also, check the option name*/
-	if(!in_option->name) _error_("input option has an empty name");
-	if(strchr(in_option->name,'.')) _error_("Option \"%s\" has a protected character \".\"",in_option->name);
-	if(strchr(in_option->name,'[')) _error_("Option \"%s\" has a protected character \"[\"",in_option->name);
-	if(strchr(in_option->name,']')) _error_("Option \"%s\" has a protected character \"]\"",in_option->name);
+	if(!in_option->name) _error2_("input option has an empty name");
+	if(strchr(in_option->name,'.')) _error2_("Option \"" << in_option->name << "\" has a protected character \".\"");
+	if(strchr(in_option->name,'[')) _error2_("Option \"" << in_option->name << "\" has a protected character \"[\"");
+	if(strchr(in_option->name,']')) _error2_("Option \"" << in_option->name << "\" has a protected character \"]\"");
 
 	/*Finally, check that no option of the same name already exists in the dataset*/
@@ -57,5 +57,5 @@
 		option=(Option*)(*object); 
 		if (!strcmp(option->name,in_option->name)){
-			_error_("Options \"%s\" found multiple times",in_option->name);
+			_error2_("Options \"" << in_option->name << "\" found multiple times");
 			break;
 		}
@@ -68,5 +68,5 @@
 }
 /*}}}*/
-/*FUNCTION Options::Get(int* pvalue, char* name){{{1*/
+/*FUNCTION Options::Get(int* pvalue, char* name){{{*/
 void Options::Get(int* pvalue,const char* name){
 
@@ -83,9 +83,9 @@
 	/*Else, the Option does not exist, no default provided*/
 	else{
-		_error_("option of name \"%s\" not found, and no default value has been provided",name);
-	}
-}
-/*}}}*/
-/*FUNCTION Options::Get(int* pvalue, char* name,int default_value){{{1*/
+		_error2_("option of name \"" << name << "\" not found, and no default value has been provided");
+	}
+}
+/*}}}*/
+/*FUNCTION Options::Get(int* pvalue, char* name,int default_value){{{*/
 void Options::Get(int* pvalue,const char* name,int default_value){
 
@@ -106,25 +106,25 @@
 }
 /*}}}*/
-/*FUNCTION Options::Get(double* pvalue, char* name){{{1*/
-void Options::Get(double* pvalue,const char* name){
-
-	vector<Object*>::iterator object;
-	Option* option=NULL;
-
-	/*Get option*/
-	option=GetOption(name);
-
-	/*If the pointer is not NULL, the option has been found*/
-	if(option){
-		option->Get(pvalue);
-	}
-	/*Else, the Option does not exist, no default provided*/
-	else{
-		_error_("option of name \"%s\" not found, and no default value has been provided",name);
-	}
-}
-/*}}}*/
-/*FUNCTION Options::Get(double* pvalue, char* name,double default_value){{{1*/
-void Options::Get(double* pvalue,const char* name,double default_value){
+/*FUNCTION Options::Get(IssmDouble* pvalue, char* name){{{*/
+void Options::Get(IssmDouble* pvalue,const char* name){
+
+	vector<Object*>::iterator object;
+	Option* option=NULL;
+
+	/*Get option*/
+	option=GetOption(name);
+
+	/*If the pointer is not NULL, the option has been found*/
+	if(option){
+		option->Get(pvalue);
+	}
+	/*Else, the Option does not exist, no default provided*/
+	else{
+		_error2_("option of name \"" << name << "\" not found, and no default value has been provided");
+	}
+}
+/*}}}*/
+/*FUNCTION Options::Get(IssmDouble* pvalue, char* name,IssmDouble default_value){{{*/
+void Options::Get(IssmDouble* pvalue,const char* name,IssmDouble default_value){
 
 	vector<Object*>::iterator object;
@@ -144,5 +144,5 @@
 }
 /*}}}*/
-/*FUNCTION Options::Get(bool* pvalue, char* name){{{1*/
+/*FUNCTION Options::Get(bool* pvalue, char* name){{{*/
 void Options::Get(bool* pvalue,const char* name){
 
@@ -159,9 +159,9 @@
 	/*Else, the Option does not exist, no default provided*/
 	else{
-		_error_("option of name \"%s\" not found, and no default value has been provided",name);
-	}
-}
-/*}}}*/
-/*FUNCTION Options::Get(bool* pvalue, char* name,bool default_value){{{1*/
+		_error2_("option of name \"" << name << "\" not found, and no default value has been provided");
+	}
+}
+/*}}}*/
+/*FUNCTION Options::Get(bool* pvalue, char* name,bool default_value){{{*/
 void Options::Get(bool* pvalue,const char* name,bool default_value){
 
@@ -182,5 +182,5 @@
 }
 /*}}}*/
-/*FUNCTION Options::Get(char** pvalue, char* name){{{1*/
+/*FUNCTION Options::Get(char** pvalue, char* name){{{*/
 void Options::Get(char** pvalue,const char* name){
 
@@ -199,10 +199,10 @@
 	/*Else, the Option does not exist, no default provided*/
 	else{
-		_error_("option of name \"%s\" not found, and no default value has been provided",name);
-	}
-
-}
-/*}}}*/
-/*FUNCTION Options::Get(char** pvalue, char* name,char* default_value){{{1*/
+		_error2_("option of name \"" << name << "\" not found, and no default value has been provided");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Options::Get(char** pvalue, char* name,char* default_value){{{*/
 void Options::Get(char** pvalue,const char* name,const char* default_value){
 
@@ -222,6 +222,6 @@
 	else{
 		stringsize=strlen(default_value)+1;
-		outstring=(char*)xmalloc(stringsize*sizeof(char));
-		memcpy(outstring,default_value,stringsize*sizeof(char));
+		outstring=xNew<char>(stringsize);
+		xMemCpy<char>(outstring,default_value,stringsize);
 		*pvalue=outstring;
 	}
@@ -229,5 +229,5 @@
 }
 /*}}}*/
-/*FUNCTION Options::Get(char*** ppvalue,int* numel,char* name){{{1*/
+/*FUNCTION Options::Get(char*** ppvalue,int* numel,char* name){{{*/
 void Options::Get(char*** ppvalue,int* numel,const char* name){
 
@@ -246,5 +246,5 @@
 		if(option->ObjectEnum()==OptionCellEnum){
 			if (option->NumEl()) {
-				*ppvalue=(char **) xmalloc(option->NumEl()*sizeof(char *));
+				*ppvalue=xNew<char*>(option->NumEl());
 				if (numel) *numel=option->NumEl();
 				option->Get(&options);
@@ -264,5 +264,5 @@
 		/*Else: not supported*/
 		else{
-			_error_("Cannot recover field \"%s\" for an option of type %s",name,EnumToStringx(option->ObjectEnum()));
+			_error2_("Cannot recover field \"" << name << "\" for an option of type " << EnumToStringx(option->ObjectEnum()));
 		}
 	}
@@ -275,6 +275,6 @@
 }
 /*}}}*/
-/*FUNCTION Options::Get(double** pvalue,int* numel,const char* name){{{1*/
-void Options::Get(double** pvalue,int* numel,const char* name){
+/*FUNCTION Options::Get(IssmDouble** pvalue,int* numel,const char* name){{{*/
+void Options::Get(IssmDouble** pvalue,int* numel,const char* name){
 
 	vector<Object*>::iterator object;
@@ -290,9 +290,9 @@
 	/*Else, the Option does not exist, no default provided*/
 	else{
-		_error_("option of name \"%s\" not found, and no default value has been provided",name);
-	}
-}
-/*}}}*/
-/*FUNCTION Options::GetOption{{{1*/
+		_error2_("option of name \"" << name << "\" not found, and no default value has been provided");
+	}
+}
+/*}}}*/
+/*FUNCTION Options::GetOption{{{*/
 Option* Options::GetOption(const char* name){
 
@@ -324,5 +324,5 @@
 				/*Else: not supported*/
 				else{
-					_error_("Cannot recover field \"%s\" for an option of type %s",name,EnumToStringx(option->ObjectEnum()));
+					_error2_("Cannot recover field \"" << name << "\" for an option of type " << EnumToStringx(option->ObjectEnum()));
 				}
 			}
Index: /issm/trunk/src/c/Container/Options.h
===================================================================
--- /issm/trunk/src/c/Container/Options.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Options.h	(revision 12706)
@@ -20,6 +20,6 @@
 		int  AddOption(Option* in_oobject);
 		Option* GetOption(const char* name);
-		void Get(double*  pvalue,const char* name);
-		void Get(double*  pvalue,const char* name,double default_value);
+		void Get(IssmDouble*  pvalue,const char* name);
+		void Get(IssmDouble*  pvalue,const char* name,IssmDouble default_value);
 		void Get(int*  pvalue,const char* name);
 		void Get(int*  pvalue,const char* name,int default_value);
@@ -29,5 +29,5 @@
 		void Get(char**   pvalue,const char* name,const char* default_value);
 		void Get(char***  pvalue,int* numel,const char* name);
-		void Get(double** pvalue,int* numel,const char* name);
+		void Get(IssmDouble** pvalue,int* numel,const char* name);
 };
 
Index: /issm/trunk/src/c/Container/Parameters.cpp
===================================================================
--- /issm/trunk/src/c/Container/Parameters.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Parameters.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,5 +25,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Parameters::Parameters(){{{1*/
+/*FUNCTION Parameters::Parameters(){{{*/
 Parameters::Parameters(){
 	enum_type=ParametersEnum;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::~Parameters(){{{1*/
+/*FUNCTION Parameters::~Parameters(){{{*/
 Parameters::~Parameters(){
 	return;
@@ -38,5 +38,5 @@
 
 /*Object management*/
-/*FUNCTION Parameters::Exist{{{1*/
+/*FUNCTION Parameters::Exist{{{*/
 bool Parameters::Exist(int enum_type){
 
@@ -51,5 +51,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{1*/
+/*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{*/
 void Parameters::FindParam(bool* pbool,int enum_type){ _assert_(this);
 	
@@ -65,8 +65,8 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{*/
 void Parameters::FindParam(int* pinteger,int enum_type){ _assert_(this);
 	
@@ -82,9 +82,9 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(double* pscalar, int enum_type){{{1*/
-void Parameters::FindParam(double* pscalar, int enum_type){ _assert_(this);
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(IssmDouble* pscalar, int enum_type){{{*/
+void Parameters::FindParam(IssmDouble* pscalar, int enum_type){ _assert_(this);
 	
 	vector<Object*>::iterator object;
@@ -99,8 +99,8 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{*/
 void Parameters::FindParam(char** pstring,int enum_type){ _assert_(this);
 	
@@ -116,9 +116,9 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{*/
 void Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){ _assert_(this);
 	
@@ -134,9 +134,9 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int enum_type){{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int enum_type){{{*/
 void Parameters::FindParam(int** pintarray,int* pM, int enum_type){ _assert_(this);
 
@@ -152,9 +152,9 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int* pN,int enum_type){{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(int** pintarray,int* pM,int* pN,int enum_type){{{*/
 void Parameters::FindParam(int** pintarray,int* pM,int *pN,int enum_type){ _assert_(this);
 
@@ -170,46 +170,46 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM,int enum_type){{{1*/
-void Parameters::FindParam(double** pdoublearray,int* pM, int enum_type){ _assert_(this);
-
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
-		if(param->InstanceEnum()==enum_type){
-			param->GetParameterValue(pdoublearray,pM);
-			return;
-		}
-	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){{{1*/
-void Parameters::FindParam(double** pdoublearray,int* pM, int* pN,int enum_type){ _assert_(this);
-
-	vector<Object*>::iterator object;
-	Param* param=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		param=(Param*)(*object);
-		if(param->InstanceEnum()==enum_type){
-			param->GetParameterValue(pdoublearray,pM,pN);
-			return;
-		}
-	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{1*/
-void Parameters::FindParam(double*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){ _assert_(this);
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(IssmDouble** pIssmDoublearray,int* pM,int enum_type){{{*/
+void Parameters::FindParam(IssmDouble** pIssmDoublearray,int* pM, int enum_type){ _assert_(this);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=(Param*)(*object);
+		if(param->InstanceEnum()==enum_type){
+			param->GetParameterValue(pIssmDoublearray,pM);
+			return;
+		}
+	}
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(IssmDouble** pIssmDoublearray,int* pM, int* pN,int enum_type){{{*/
+void Parameters::FindParam(IssmDouble** pIssmDoublearray,int* pM, int* pN,int enum_type){ _assert_(this);
+
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=(Param*)(*object);
+		if(param->InstanceEnum()==enum_type){
+			param->GetParameterValue(pIssmDoublearray,pM,pN);
+			return;
+		}
+	}
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{*/
+void Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){ _assert_(this);
 	
 	vector<Object*>::iterator object;
@@ -224,8 +224,8 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(Vector** pvec,int enum_type){{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(Vector** pvec,int enum_type){{{*/
 void Parameters::FindParam(Vector** pvec,int enum_type){ _assert_(this);
 	
@@ -241,9 +241,9 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(Matrix** pmat,int enum_type){{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(Matrix** pmat,int enum_type){{{*/
 void Parameters::FindParam(Matrix** pmat,int enum_type){ _assert_(this);
 	
@@ -259,9 +259,9 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION Parameters::FindParam(FILE** pfid,int enum_type){{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+
+}
+/*}}}*/
+/*FUNCTION Parameters::FindParam(FILE** pfid,int enum_type){{{*/
 void Parameters::FindParam(FILE** pfid,int enum_type){ _assert_(this);
 
@@ -277,9 +277,9 @@
 		}
 	}
-	_error_("could not find parameter %s",EnumToStringx(enum_type));
-}
-/*}}}*/
-
-/*FUNCTION Parameters::SetParam(bool boolean,int enum_type);{{{1*/
+	_error2_("could not find parameter " << EnumToStringx(enum_type));
+}
+/*}}}*/
+
+/*FUNCTION Parameters::SetParam(bool boolean,int enum_type);{{{*/
 void   Parameters::SetParam(bool boolean,int enum_type){
 
@@ -293,5 +293,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(int integer,int enum_type);{{{1*/
+/*FUNCTION Parameters::SetParam(int integer,int enum_type);{{{*/
 void   Parameters::SetParam(int integer,int enum_type){
 
@@ -305,6 +305,6 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(double scalar,int enum_type);{{{1*/
-void   Parameters::SetParam(double scalar,int enum_type){
+/*FUNCTION Parameters::SetParam(IssmDouble scalar,int enum_type);{{{*/
+void   Parameters::SetParam(IssmDouble scalar,int enum_type){
 
 	Param* param=NULL;
@@ -317,5 +317,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(char* string,int enum_type);{{{1*/
+/*FUNCTION Parameters::SetParam(char* string,int enum_type);{{{*/
 void   Parameters::SetParam(char* string,int enum_type){
 
@@ -329,5 +329,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(char** stringarray,int M, int enum_type);{{{1*/
+/*FUNCTION Parameters::SetParam(char** stringarray,int M, int enum_type);{{{*/
 void   Parameters::SetParam(char** stringarray,int M, int enum_type){
 
@@ -341,29 +341,29 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(double* doublearray,int M,int enum_type);{{{1*/
-void   Parameters::SetParam(double* doublearray,int M, int enum_type){
-
-	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
-
-	if(param) param->SetValue(doublearray,M); //already exists, just set it.
-	else this->AddObject(new DoubleVecParam(enum_type,doublearray,M)); //just add the new parameter.
-}
-/*}}}*/
-/*FUNCTION Parameters::SetParam(double* doublearray,int M,int N, int enum_type);{{{1*/
-void   Parameters::SetParam(double* doublearray,int M, int N, int enum_type){
-
-	Param* param=NULL;
-	
-	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
-
-	if(param) param->SetValue(doublearray,M,N); //already exists, just set it.
-	else this->AddObject(new DoubleMatParam(enum_type,doublearray,M,N)); //just add the new parameter.
-}
-/*}}}*/
-/*FUNCTION Parameters::SetParam(int* intarray,int M,int enum_type);{{{1*/
+/*FUNCTION Parameters::SetParam(IssmDouble* IssmDoublearray,int M,int enum_type);{{{*/
+void   Parameters::SetParam(IssmDouble* IssmDoublearray,int M, int enum_type){
+
+	Param* param=NULL;
+	
+	/*first, figure out if the param has already been created: */
+	param=(Param*)this->FindParamObject(enum_type);
+
+	if(param) param->SetValue(IssmDoublearray,M); //already exists, just set it.
+	else this->AddObject(new DoubleVecParam(enum_type,IssmDoublearray,M)); //just add the new parameter.
+}
+/*}}}*/
+/*FUNCTION Parameters::SetParam(IssmDouble* IssmDoublearray,int M,int N, int enum_type);{{{*/
+void   Parameters::SetParam(IssmDouble* IssmDoublearray,int M, int N, int enum_type){
+
+	Param* param=NULL;
+	
+	/*first, figure out if the param has already been created: */
+	param=(Param*)this->FindParamObject(enum_type);
+
+	if(param) param->SetValue(IssmDoublearray,M,N); //already exists, just set it.
+	else this->AddObject(new DoubleMatParam(enum_type,IssmDoublearray,M,N)); //just add the new parameter.
+}
+/*}}}*/
+/*FUNCTION Parameters::SetParam(int* intarray,int M,int enum_type);{{{*/
 void   Parameters::SetParam(int* intarray,int M, int enum_type){
 
@@ -377,5 +377,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(int* intarray,int M,int N, int enum_type);{{{1*/
+/*FUNCTION Parameters::SetParam(int* intarray,int M,int N, int enum_type);{{{*/
 void   Parameters::SetParam(int* intarray,int M, int N, int enum_type){
 
@@ -389,5 +389,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(Vector* vector,int enum_type);{{{1*/
+/*FUNCTION Parameters::SetParam(Vector* vector,int enum_type);{{{*/
 void   Parameters::SetParam(Vector* vector,int enum_type){
 
@@ -401,5 +401,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(Matrix* matrix,int enum_type);{{{1*/
+/*FUNCTION Parameters::SetParam(Matrix* matrix,int enum_type);{{{*/
 void   Parameters::SetParam(Matrix* matrix,int enum_type){
 
@@ -413,5 +413,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::SetParam(FILE* fid,int enum_type);{{{1*/
+/*FUNCTION Parameters::SetParam(FILE* fid,int enum_type);{{{*/
 void   Parameters::SetParam(FILE* fid,int enum_type){
 
@@ -425,5 +425,5 @@
 }
 /*}}}*/
-/*FUNCTION Parameters::UnitConversion(int direction_enum);{{{1*/
+/*FUNCTION Parameters::UnitConversion(int direction_enum);{{{*/
 void   Parameters::UnitConversion(int direction_enum){
 
@@ -439,5 +439,5 @@
 /*}}}*/
 
-/*FUNCTION Parameters::FindParamObject{{{1*/
+/*FUNCTION Parameters::FindParamObject{{{*/
 Object* Parameters::FindParamObject(int enum_type){
 
Index: /issm/trunk/src/c/Container/Parameters.h
===================================================================
--- /issm/trunk/src/c/Container/Parameters.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Parameters.h	(revision 12706)
@@ -23,21 +23,21 @@
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Parameters();
 		~Parameters();
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		bool  Exist(int enum_type);
 
 		void  FindParam(bool* pinteger,int enum_type);
 		void  FindParam(int* pinteger,int enum_type);
-		void  FindParam(double* pscalar, int enum_type);
+		void  FindParam(IssmDouble* pscalar, int enum_type);
 		void  FindParam(char** pstring,int enum_type);
 		void  FindParam(char*** pstringarray,int* pM,int enum_type);
 		void  FindParam(int** pintarray,int* pM,int enum_type);
 		void  FindParam(int** pintarray,int* pM,int* PN,int enum_type);
-		void  FindParam(double** pdoublearray,int* pM,int enum_type);
-		void  FindParam(double** pdoublearray,int* pM,int* pN,int enum_type);
-		void  FindParam(double*** parray,int* pM, int** pmdims_array,int** pndims_array,int enum_type);
+		void  FindParam(IssmDouble** pIssmDoublearray,int* pM,int enum_type);
+		void  FindParam(IssmDouble** pIssmDoublearray,int* pM,int* pN,int enum_type);
+		void  FindParam(IssmDouble*** parray,int* pM, int** pmdims_array,int** pndims_array,int enum_type);
 		void  FindParam(Vector** pvec,int enum_type);
 		void  FindParam(Matrix** pmat,int enum_type);
@@ -46,9 +46,9 @@
 		void  SetParam(bool boolean,int enum_type);
 		void  SetParam(int integer,int enum_type);
-		void  SetParam(double scalar, int enum_type);
+		void  SetParam(IssmDouble scalar, int enum_type);
 		void  SetParam(char* string,int enum_type);
 		void  SetParam(char** stringarray,int M,int enum_type);
-		void  SetParam(double* doublearray,int M,int enum_type);
-		void  SetParam(double* doublearray,int M,int N,int enum_type);
+		void  SetParam(IssmDouble* IssmDoublearray,int M,int enum_type);
+		void  SetParam(IssmDouble* IssmDoublearray,int M,int N,int enum_type);
 		void  SetParam(int* intarray,int M,int enum_type);
 		void  SetParam(int* intarray,int M,int N,int enum_type);
Index: /issm/trunk/src/c/Container/Results.cpp
===================================================================
--- /issm/trunk/src/c/Container/Results.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Results.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,5 +25,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Results::Results(){{{1*/
+/*FUNCTION Results::Results(){{{*/
 Results::Results(){
 	enum_type=ResultsEnum;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Results::~Results(){{{1*/
+/*FUNCTION Results::~Results(){{{*/
 Results::~Results(){
 	return;
@@ -38,5 +38,5 @@
 
 /*Object management*/
-/*FUNCTION Results::SpawnTriaResults{{{1*/
+/*FUNCTION Results::SpawnTriaResults{{{*/
 Results* Results::SpawnTriaResults(int* indices){
 
@@ -64,5 +64,5 @@
 }
 /*}}}*/
-/*FUNCTION Results::Write{{{1*/
+/*FUNCTION Results::Write{{{*/
 void Results::Write(Parameters* parameters){
 	
Index: /issm/trunk/src/c/Container/Results.h
===================================================================
--- /issm/trunk/src/c/Container/Results.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Results.h	(revision 12706)
@@ -20,9 +20,9 @@
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Results();
 		~Results();
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		Results* SpawnTriaResults(int* indices);
 		void Write(Parameters* parameters);
Index: /issm/trunk/src/c/Container/Vertices.cpp
===================================================================
--- /issm/trunk/src/c/Container/Vertices.cpp	(revision 12705)
+++ /issm/trunk/src/c/Container/Vertices.cpp	(revision 12706)
@@ -4,5 +4,5 @@
  */
 
-/*Headers: {{{1*/
+/*Headers: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -25,5 +25,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Vertices::Vertices(){{{1*/
+/*FUNCTION Vertices::Vertices(){{{*/
 Vertices::Vertices(){
 	enum_type=VerticesEnum;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Vertices::~Vertices(){{{1*/
+/*FUNCTION Vertices::~Vertices(){{{*/
 Vertices::~Vertices(){
 	return;
@@ -38,5 +38,5 @@
 
 /*Numerics management*/
-/*FUNCTION Vertices::DistributeDofs{{{1*/
+/*FUNCTION Vertices::DistributeDofs{{{*/
 void  Vertices::DistributeDofs(int numberofobjects,int numberofdofsperobject){
 
@@ -60,5 +60,5 @@
 	 * cpus by the total last dofs of the previus cpu, starting from 0.
 	 * First: bet number of dofs for each cpu*/
-	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
+	alldofcount=xNew<int>(num_procs);
 	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
@@ -83,6 +83,6 @@
 	 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 
 	 * up by their clones: */
-	truedofs   =(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
-	alltruedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
+	truedofs   =xNewZeroInit<int>(numberofobjects*numberofdofsperobject);
+	alltruedofs=xNewZeroInit<int>(numberofobjects*numberofdofsperobject);
 	for (i=0;i<this->Size();i++){
 		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
@@ -102,10 +102,10 @@
 
 	/* Free ressources: */
-	xfree((void**)&alldofcount);
-	xfree((void**)&truedofs);
-	xfree((void**)&alltruedofs);
+	xDelete<int>(alldofcount);
+	xDelete<int>(truedofs);
+	xDelete<int>(alltruedofs);
 }
 /*}}}*/
-/*FUNCTION Vertices::FlagClones{{{1*/
+/*FUNCTION Vertices::FlagClones{{{*/
 void  Vertices::FlagClones(int numberofobjects){
 
@@ -117,6 +117,6 @@
 
 	/*Allocate ranks: */
-	ranks=(int*)xmalloc(numberofobjects*sizeof(int));
-	minranks=(int*)xmalloc(numberofobjects*sizeof(int));
+	ranks=xNew<int>(numberofobjects);
+	minranks=xNew<int>(numberofobjects);
 
 	for(i=0;i<numberofobjects;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit.
@@ -143,10 +143,10 @@
 
 	/*Free ressources: */
-	xfree((void**)&ranks); 
-	xfree((void**)&minranks);
+	xDelete<int>(ranks); 
+	xDelete<int>(minranks);
 
 }
 /*}}}*/
-/*FUNCTION Vertices::NumberOfVertices{{{1*/
+/*FUNCTION Vertices::NumberOfVertices{{{*/
 int Vertices::NumberOfVertices(void){
 
@@ -174,5 +174,5 @@
 }
 /*}}}*/
-/*FUNCTION Vertices::Ranks{{{1*/
+/*FUNCTION Vertices::Ranks{{{*/
 void   Vertices::Ranks(int* ranks){
 
Index: /issm/trunk/src/c/Container/Vertices.h
===================================================================
--- /issm/trunk/src/c/Container/Vertices.h	(revision 12705)
+++ /issm/trunk/src/c/Container/Vertices.h	(revision 12706)
@@ -19,9 +19,9 @@
 	public:
 
-		/*constructors, destructors: {{{1*/
+		/*constructors, destructors: {{{*/
 		Vertices();
 		~Vertices();
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void  DistributeDofs(int numberofnodes,int numdofspernode);
 		void  FlagClones(int numberofnodes);
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 12705)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 12706)
@@ -149,8 +149,8 @@
 	SettingsResultsAsPatchesEnum,
 	SettingsWaitonlockEnum,
-	DebugPetscProfilingEnum,
-	PetscProfilingCurrentMemEnum,
-	PetscProfilingCurrentFlopsEnum,
-	PetscProfilingSolutionTimeEnum,
+	DebugProfilingEnum,
+	ProfilingCurrentMemEnum,
+	ProfilingCurrentFlopsEnum,
+	ProfilingSolutionTimeEnum,
 	MaxIterationConvergenceFlagEnum,
 	SteadystateMaxiterEnum,
@@ -162,5 +162,13 @@
 	SurfaceforcingsMassBalanceEnum,
 	SurfaceforcingsIspddEnum,
+	SurfaceforcingsIssmbgradientsEnum,
 	SurfaceforcingsMonthlytemperaturesEnum,
+	SurfaceforcingsHcEnum,
+	SurfaceforcingsSmbPosMaxEnum,
+	SurfaceforcingsSmbPosMinEnum,
+	SurfaceforcingsAPosEnum,
+	SurfaceforcingsBPosEnum,
+	SurfaceforcingsANegEnum,
+	SurfaceforcingsBNegEnum,
 	ThermalMaxiterEnum,
 	ThermalPenaltyFactorEnum,
Index: /issm/trunk/src/c/EnumDefinitions/Synchronize.sh
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/Synchronize.sh	(revision 12705)
+++ /issm/trunk/src/c/EnumDefinitions/Synchronize.sh	(revision 12706)
@@ -2,9 +2,10 @@
 #Synchronize EnumToStringx.cpp and StringToEnumx.cpp and matlab Enums
 
-#Get all lines of EnumDefinitions2.h which hold Enum | remove all comas > put everything in file temp
+#Get all lines of EnumDefinitions2.h which hold Enum | remove all commas > put everything in file temp
 cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,/ /g" | awk '{print $1}' > temp
 
 #Removed existing files
 rm $ISSM_DIR/src/m/enum/*.m
+rm $ISSM_DIR/src/m/enum/*.py
 rm $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp
 rm $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
@@ -48,5 +49,5 @@
 
 	len=strlen(EnumToStringx(enum_in));
-	string=(char*)xmalloc((len+1)*sizeof(char));
+	string=xNew<char>(len+1);
 	memcpy(string,EnumToStringx(enum_in),(len+1)*sizeof(char));
 
@@ -56,5 +57,5 @@
 END
 #}}}
-#Build StringToEnumx.cpp {{{1
+#Build StringToEnumx.cpp {{{
 #Header
 cat <<END > $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
@@ -97,5 +98,5 @@
 cat <<END >> $ISSM_DIR/src/c/modules/StringToEnumx/StringToEnumx.cpp
 	/*If we reach this point, the string provided has not been found*/
-   _error_("Enum %s not found",name);
+	_error2_("Enum " << name << " not found");
 }
 END
@@ -104,4 +105,17 @@
 # go through the lines of temp
 ENUM=0;
+#Add header to pythonenum file{{{
+cat <<END > $ISSM_DIR/src/m/enum/EnumDefinitions.py
+"""
+
+   WARNING: DO NOT MODIFY THIS FILE
+            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+            Please read src/c/EnumDefinitions/README for more information
+
+"""
+
+END
+#}}}
+
 for NAMEENUM in $(cat temp); do
 
@@ -142,7 +156,21 @@
 END
 #}}}
+	#Add case to pythonenum file{{{
+	cat <<END >> $ISSM_DIR/src/m/enum/EnumDefinitions.py
+def $(echo $NAMEENUM)():
+	"""
+	$(echo $NAMEENUM | awk {'print toupper($1)'}) - Enum of $(echo $NAME)
+
+	   Usage:
+	      macro=$NAMEENUM()
+	"""
+
+	return StringToEnum('$NAME')
+
+END
+#}}}
 
 done
-#MaximumNumberOfEnums{{{
+#MaximumNumberOfEnums (matlab){{{
 cat <<END > $ISSM_DIR/src/m/enum/MaximumNumberOfEnums.m
 function macro=MaximumNumberOfEnums()
@@ -161,4 +189,20 @@
 END
 #}}}
+#MaximumNumberOfEnums (python){{{
+cat <<END >> $ISSM_DIR/src/m/enum/EnumDefinitions.py
+def MaximumNumberOfEnums():
+	"""
+	$(echo "MaximumNumberOfEnums" | awk {'print toupper($1)'}) - Enum of MaximumNumberOfEnums
+
+	   Usage:
+	      macro=MaximumNumberOfEnums()
+	"""
+
+	return $(cat EnumDefinitions.h | grep -e "[0-9]Enum" -e "[a-zA-Z]Enum" | grep -v include \
+		| awk '{ printf "%s %s\n", NR-1, $0 }' \
+		| grep "MaximumNumberOfEnums" | awk '{print $1}')
+
+END
+#}}}
 
 #clean up{{{
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 12705)
+++ /issm/trunk/src/c/Makefile.am	(revision 12706)
@@ -1,7 +1,7 @@
-INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @HYPREINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
+INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
 
 EXEEXT=$(ISSMEXT)
 
-#Library declaration {{{1
+#Library declaration {{{
 lib_LIBRARIES = libISSMCore.a libISSMOverload.a
 if PYTHON
@@ -17,5 +17,5 @@
 
 #sources
-#Core sources{{{1
+#Core sources{{{
 core_sources = ./issm.h\
 					./issm-binding.h\
@@ -176,8 +176,8 @@
 					./shared/Alloc/alloc.h\
 					./shared/Alloc/alloc.cpp\
+					./shared/Alloc/xNewDelete.h\
+					./shared/MemOps/xMemCpy.h\
 					./shared/Matrix/matrix.h\
 					./shared/Matrix/MatrixUtils.cpp\
-					./shared/Dofs/dofs.h\
-					./shared/Dofs/dofsetgen.cpp\
 					./shared/Numerics/numerics.h\
 					./shared/Numerics/Verbosity.h\
@@ -210,4 +210,7 @@
 					./shared/Wrapper/ModuleBoot.cpp\
 					./shared/Wrapper/ModuleEnd.cpp\
+					./shared/Sys/sys.h\
+					./shared/Sys/ProfilingStart.cpp\
+					./shared/Sys/ProfilingEnd.cpp\
 					./toolkits/metis/metisincludes.h\
 					./toolkits/issm/issmtoolkit.h\
@@ -285,4 +288,6 @@
 					./modules/PositiveDegreeDayx/PositiveDegreeDayx.h\
 					./modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp\
+					./modules/SmbGradientsx/SmbGradientsx.h\
+					./modules/SmbGradientsx/SmbGradientsx.cpp\
 					./modules/UpdateConstraintsx/UpdateConstraintsx.h\
 					./modules/UpdateConstraintsx/UpdateConstraintsx.cpp\
@@ -330,7 +335,16 @@
 					./solvers/solver_linear.cpp\
 					./solvers/solver_nonlinear.cpp\
-					./solvers/solver_newton.cpp
-#}}}
-#DAKOTA sources  {{{1
+					./solvers/solver_newton.cpp\
+					./objects/Options/Option.cpp\
+					./objects/Options/Option.h\
+					./objects/Options/OptionDouble.cpp\
+					./objects/Options/OptionDouble.h\
+					./objects/Options/OptionChar.cpp\
+					./objects/Options/OptionChar.h\
+					./objects/Options/OptionUtilities.cpp\
+					./objects/Options/OptionUtilities.h
+
+#}}}
+#DAKOTA sources  {{{
 dakota_sources = ./objects/DakotaPlugin.h\
 					  ./objects/DakotaPlugin.cpp\
@@ -356,13 +370,13 @@
 					  ./modules/Dakotax/SpawnCoreParallel.cpp
 #}}}
-#Transient sources  {{{1
+#Transient sources  {{{
 transient_sources  = ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp \
 					 ./solutions/transient_core.cpp
 #}}}
-#Steadystate sources  {{{1
+#Steadystate sources  {{{
 steadystate_sources = ./solutions/steadystate_core.cpp\
 					  ./solutions/steadystateconvergence.cpp
 #}}}
-#Prognostic sources  {{{1
+#Prognostic sources  {{{
 prognostic_sources = ./modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp\
 					      ./modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp\
@@ -371,5 +385,5 @@
 						  ./solutions/prognostic_core.cpp
 #}}}
-#Thermal sources  {{{1
+#Thermal sources  {{{
 thermal_sources = ./modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp\
 					   ./modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp\
@@ -391,5 +405,5 @@
 					   ./solvers/solver_thermal_nonlinear.cpp
 #}}}
-#Control sources  {{{1
+#Control sources  {{{
 control_sources= ./modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp\
 					  ./modules/ControlInputGetGradientx/ControlInputGetGradientx.h\
@@ -446,5 +460,5 @@
 
 #}}}
-#Hydrology sources  {{{1
+#Hydrology sources  {{{
 hydrology_sources  = ./modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp\
 					      ./modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp\
@@ -454,5 +468,5 @@
 						  ./solutions/hydrology_core_step.cpp 
 #}}}
-#Diagnostic sources  {{{1
+#Diagnostic sources  {{{
 diagnostic_sources = ./modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp\
 					      ./modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp \
@@ -475,5 +489,5 @@
 						  ./solvers/solver_stokescoupling_nonlinear.cpp
 #}}}
-#Balanced sources  {{{1
+#Balanced sources  {{{
 balanced_sources = ./modules/ModelProcessorx/Balancethickness/UpdateElementsBalancethickness.cpp\
 					    ./modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp\
@@ -482,5 +496,5 @@
 						./solutions/balancethickness_core.cpp
 #}}}
-#Responses sources  {{{1
+#Responses sources  {{{
 responses_sources = ./modules/MinVelx/MinVelx.h\
 					     ./modules/MinVelx/MinVelx.cpp\
@@ -512,5 +526,5 @@
 					     ./modules/MassFluxx/MassFluxx.h
 #}}}
-#Slope sources  {{{1
+#Slope sources  {{{
 slope_sources =  ./modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp\
 					  ./modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp \
@@ -524,14 +538,14 @@
 					  ./solutions/bedslope_core.cpp
 #}}}
-#Groundingline sources  {{{1
+#Groundingline sources  {{{
 groundingline_sources= ./modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp\
 					        ./modules/GroundinglineMigrationx/GroundinglineMigrationx.h
 #}}}
-#Rifts sources  {{{1
+#Rifts sources  {{{
 rifts_sources = ./objects/Loads/Riftfront.cpp\
 				    ./objects/Loads/Riftfront.h\
 				    ./modules/ConstraintsStatex/RiftConstraintsState.cpp
 #}}}
-#3D sources  {{{1
+#3D sources  {{{
 threed_sources = ./objects/Gauss/GaussPenta.h\
 				     ./objects/Gauss/GaussPenta.cpp\
@@ -547,5 +561,5 @@
 				     ./objects/Elements/PentaRef.cpp
 #}}}
-#Bamg sources  {{{1
+#Bamg sources  {{{
 bamg_sources =  ./objects/Bamg/BamgGeom.h\
 				./objects/Bamg/BamgGeom.cpp\
@@ -613,5 +627,5 @@
 				./modules/BamgTriangulatex/BamgTriangulatex.h
 #}}}
-#Kriging sources  {{{1
+#Kriging sources  {{{
 kriging_sources = ./Container/Observations.h\
 						./Container/Observations.cpp\
@@ -632,6 +646,25 @@
 						./modules/Krigingx/Krigingx.h
 
-#}}}
-#Kml sources  {{{1
+#For parallel kriging, only difference is ./modules/Krigingx/pKrigingx.cpp with no multithreading
+pkriging_sources = ./Container/Observations.h\
+						./Container/Observations.cpp\
+						./objects/Kriging/Variogram.h \
+						./objects/Kriging/GaussianVariogram.h\
+						./objects/Kriging/GaussianVariogram.cpp\
+						./objects/Kriging/ExponentialVariogram.h\
+						./objects/Kriging/ExponentialVariogram.cpp\
+						./objects/Kriging/SphericalVariogram.h\
+						./objects/Kriging/SphericalVariogram.cpp\
+						./objects/Kriging/PowerVariogram.h\
+						./objects/Kriging/PowerVariogram.cpp\
+						./objects/Kriging/Quadtree.h\
+						./objects/Kriging/Quadtree.cpp\
+						./objects/Kriging/Observation.h\
+						./objects/Kriging/Observation.cpp\
+						./modules/Krigingx/pKrigingx.cpp\
+						./modules/Krigingx/Krigingx.h
+
+#}}}
+#Kml sources  {{{
 kml_sources = ./modules/Exp2Kmlx/Exp2Kmlx.h\
 			     ./modules/Exp2Kmlx/Exp2Kmlx.cpp\
@@ -701,5 +734,5 @@
 			     ./objects/KML/KMLFileReadUtils.h
 #}}}
-#Petsc sources  {{{1
+#Petsc sources  {{{
 petsc_sources= ./toolkits/petsc\
 					./toolkits/petsc/patches\
@@ -736,9 +769,8 @@
 
 #}}}
-#Gsl sources  {{{1
+#Gsl sources  {{{
 gsl_sources= ./modules/Solverx/SolverxGsl.cpp
-
-#}}}
-#Mpi sources  {{{1
+#}}}
+#Mpi sources  {{{
 mpi_sources= ./toolkits/mpi/mpiincludes.h\
 				./toolkits/mpi/patches/mpipatches.h\
@@ -748,9 +780,9 @@
 				./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
 #}}}
-#Metis sources  {{{1
+#Metis sources  {{{
 metis_sources= ./toolkits/metis/patches/metispatches.h\
 					./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp
 #}}}
-#Python sources  {{{1
+#Python sources  {{{
 python_sources=     ./python/io/pythonio.h\
 					./python/python-binding.h\
@@ -760,5 +792,5 @@
 
 #}}}
-#Matlab sources  {{{1
+#Matlab sources  {{{
 matlab_sources= ./toolkits/matlab/matlabincludes.h\
 				    ./matlab/matlab-binding.h\
@@ -777,10 +809,10 @@
 					 ./matlab/io/MatlabVectorToSeqVec.cpp
 #}}}
-#Matlab and Petsc sources  {{{1
+#Matlab and Petsc sources  {{{
 matlabpetsc_sources= ./matlab/io/MatlabMatrixToPetscMatrix.cpp\
 					 ./matlab/io/MatlabVectorToPetscVector.cpp
 	
 #}}}
-#Modules sources{{{1
+#Modules sources{{{
 module_sources= ./objects/Options/Option.cpp\
 			./objects/Options/Option.h\
@@ -870,8 +902,7 @@
 #}}}
 
-#{{{1 Conditional build-up of sources
+#{{{ Conditional build-up of sources
 #ISSM sources are a combination of core sources and sources related to specific capabilities (which can 
 #be activated by autotools conditionals 
-
 
 #First the core
@@ -957,7 +988,9 @@
 endif
 
-
-#}}}
-#Library flags and sources {{{1
+if KRIGING
+issm_sources +=  $(pkriging_sources)
+endif
+#}}}
+#Library flags and sources {{{
 ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_  $(CXXFLAGS) $(CXXOPTFLAGS) 
 
@@ -984,10 +1017,10 @@
 
 #}}}
-#Overload library, to overload any non-standard symbols. {{{1
+#Overload library, to overload any non-standard symbols. {{{
 libISSMOverload_a_SOURCES = ./shared/String/stricmp.c
 libISSMOverload_a_CFLAGS  = -fPIC -D_C_ $(COPTFLAGS) $(CFLAGS)
 #}}}
 
-#Executable {{{1
+#Executable {{{
 bin_PROGRAMS = issm 
 
@@ -996,5 +1029,5 @@
 
 #External packages
-LDADD += $(PETSCLIB) $(TAOLIB) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB)
+LDADD += $(PETSCLIB) $(TAOLIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(ADOLCLIB)
 
 if FORTRAN
@@ -1004,4 +1037,10 @@
 issm_SOURCES = solutions/issm.cpp
 issm_CXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) 
+
+if KRIGING
+bin_PROGRAMS += kriging
+kriging_SOURCES = solutions/kriging.cpp
+kriging_CXXFLAGS= -fPIC $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) 
+endif
 #}}}
 #Automatic differentiation: append this fold to the end of the src/c/Makefile.am to get this Makefile.am {{{
Index: /issm/trunk/src/c/include/include.h
===================================================================
--- /issm/trunk/src/c/include/include.h	(revision 12705)
+++ /issm/trunk/src/c/include/include.h	(revision 12706)
@@ -10,5 +10,3 @@
 #include "./types.h"
 
-
 #endif //ifndef _INCLUDE_H_
-
Index: /issm/trunk/src/c/include/macros.h
===================================================================
--- /issm/trunk/src/c/include/macros.h	(revision 12705)
+++ /issm/trunk/src/c/include/macros.h	(revision 12706)
@@ -3,8 +3,11 @@
  */
 
-/*Header {{{1*/
+/*Header {{{*/
 #ifndef _MACROS_H_
 #define _MACROS_H_
 
+#include <iostream>
+#include <sstream>
+#include <iomanip>
 #include "./typedefs.h"
 
@@ -16,9 +19,9 @@
 /*}}}*/
 
-/* _printf_ {{{1*/
+/* _printf_ {{{*/
 /*Printing macro: only cpu number 0 */
-#define _printf_(flag,...) do { if(flag) PrintfFunction(__VA_ARGS__); }while (0)
+#define _printf_(flag,...) do{if(flag) PrintfFunction(__VA_ARGS__);}while(0)
 /*}}}*/
-/* _error_ {{{1*/
+/* _error_ {{{*/
 /*Error exception macro*/
 #ifdef _INTEL_WIN_
@@ -30,5 +33,43 @@
 #endif
 /*}}}*/
-/* _assert_ {{{1*/
+/* _error2_ {{{*/
+/*new Error exception macro*/
+#ifdef _INTEL_WIN_
+#define _error2_(StreamArgs)\
+   do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \
+   aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \
+   throw ErrorException(aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)
+#else
+#define _error2_(StreamArgs)\
+	do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \
+   aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \
+   throw ErrorException(__FILE__,__func__,__LINE__,aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)
+#endif
+/*}}}*/
+/* _printLine_ {{{*/
+/* macro to print a line, adds std::endl */
+#define _printLine_(StreamArgs)\
+   do{std::cout << StreamArgs << std::endl;}while(0)
+/*}}}*/
+/* _printString_ {{{*/
+/* macro to print some string, adds std::ends */
+#define _printString_(StreamArgs)\
+   do{std::cout << StreamArgs;}while(0)
+/*}}}*/
+/* _pprintLine_ {{{*/
+/* macro to print a line, adds std::endl */
+#define _pprintLine_(StreamArgs)\
+  do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \
+	  aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \
+	  PrintfFunction(aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)
+/*}}}*/
+/* _pprintString_ {{{*/
+/* macro to print some string, adds std::ends */
+#define _pprintString_(StreamArgs)\
+  do{std::ostringstream aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy; \
+	  aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy << StreamArgs << std::ends; \
+	  PrintfFunction2(aLoNgAnDwEiRdLoCaLnAmeFoRtHiSmAcRoOnLy.str());}while(0)
+/*}}}*/
+/* _assert_ {{{*/
 /*Assertion macro: do nothing if macro _ISSM_DEBUG_ undefined*/
 #ifdef _ISSM_DEBUG_ 
@@ -40,5 +81,5 @@
 #endif
 /*}}}*/
-/* ISSMBOOT/ISSMEND {{{1*/
+/* ISSMBOOT/ISSMEND {{{*/
 
 /*The following macros hide the error exception handling in a matlab module. Just put 
Index: /issm/trunk/src/c/include/typedefs.h
===================================================================
--- /issm/trunk/src/c/include/typedefs.h	(revision 12705)
+++ /issm/trunk/src/c/include/typedefs.h	(revision 12706)
@@ -16,5 +16,4 @@
 #define NDOF3 3
 #define NDOF4 4
-
 
 #define DIM2 2
@@ -40,6 +39,3 @@
 #endif
 
-
-
-
 #endif //ifndef _ISSMTYPEDEFS_H_
Index: /issm/trunk/src/c/include/types.h
===================================================================
--- /issm/trunk/src/c/include/types.h	(revision 12705)
+++ /issm/trunk/src/c/include/types.h	(revision 12706)
@@ -28,11 +28,17 @@
 
 #ifdef _HAVE_ADOLC_
+#include "adolc/adolc.h"
+// for active variables
 typedef adouble IssmDouble;
+// for passive variables
+typedef double IssmPDouble;
 #else 
+// see above
 typedef double IssmDouble; 
+// see above
+typedef IssmDouble IssmPDouble;
 #endif
 
 typedef bool IssmBool;
 
-
 #endif //ifndef _TYPES_H_
Index: /issm/trunk/src/c/io/Disk/diskio.h
===================================================================
--- /issm/trunk/src/c/io/Disk/diskio.h	(revision 12705)
+++ /issm/trunk/src/c/io/Disk/diskio.h	(revision 12706)
@@ -10,7 +10,4 @@
 #include "../../include/include.h"
 
-class DataSet;
-class Parameters;
-
 FILE* pfopen(char* filename,const char* format);
 void  pfclose(FILE* fid,char* filename);
Index: /issm/trunk/src/c/io/Disk/pfclose.cpp
===================================================================
--- /issm/trunk/src/c/io/Disk/pfclose.cpp	(revision 12705)
+++ /issm/trunk/src/c/io/Disk/pfclose.cpp	(revision 12706)
@@ -18,4 +18,4 @@
 	extern int my_rank;
 	_assert_(fid);
-	if(fclose(fid)!=0)_error_("%s%s","could not close file ",filename);
+	if(fclose(fid)!=0)_error2_("could not close file " << filename);
 }
Index: /issm/trunk/src/c/io/Disk/pfopen.cpp
===================================================================
--- /issm/trunk/src/c/io/Disk/pfopen.cpp	(revision 12705)
+++ /issm/trunk/src/c/io/Disk/pfopen.cpp	(revision 12706)
@@ -20,5 +20,5 @@
 	/*Open handle to data on disk: */
 	fid=fopen(filename,format);
-	if(fid==NULL) _error_("%s%s%s","could not open file ",filename," for binary reading or writing"); 
+	if(fid==NULL) _error2_("could not open file " << filename << " for binary reading or writing"); 
 
 	return fid;
Index: /issm/trunk/src/c/io/PrintfFunction.cpp
===================================================================
--- /issm/trunk/src/c/io/PrintfFunction.cpp	(revision 12705)
+++ /issm/trunk/src/c/io/PrintfFunction.cpp	(revision 12706)
@@ -25,13 +25,9 @@
 
 		/*allocate buffer for given string size*/
-		buffer=(char*)xmalloc(size*sizeof(char));
+		buffer=xNew<char>(size);
 
 		/* Try to print in the allocated space. */
 		va_start(args, format);
-#ifndef WIN32
 		n=vsnprintf(buffer,size,format,args);
-#else
-		n=vsnprintf(buffer,size,format,args);
-#endif
 		va_end(args);
 
@@ -45,12 +41,26 @@
 		 size*=2;  /* twice the old size */
 
-		xfree((void**)&buffer);
+		xDelete<char>(buffer);
 	}
 
 	/*Ok, if we are running in parallel, get node 0 to print*/
-	if(my_rank==0)printf(buffer);
+	if(my_rank==0)_printString_(buffer);
 
 	/*Clean up and return*/
-	xfree((void**)&buffer);
+	xDelete<char>(buffer);
 	return 1;
 }
+int PrintfFunction(const string & message){
+	extern int  my_rank;
+	if(my_rank==0){
+		printf("%s\n",message.c_str());
+	}
+	return 1;
+}
+int PrintfFunction2(const string & message){
+	extern int  my_rank;
+	if(my_rank==0){
+		printf("%s",message.c_str());
+	}
+	return 1;
+}
Index: /issm/trunk/src/c/io/io.h
===================================================================
--- /issm/trunk/src/c/io/io.h	(revision 12705)
+++ /issm/trunk/src/c/io/io.h	(revision 12706)
@@ -6,15 +6,15 @@
 #define _ISSM_IO_H_
 
-#ifdef HAVE_CONFIG_H //config.h {{{1
+#ifdef HAVE_CONFIG_H
 #include <config.h>
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif 
-//}}}
-
 #include "./Disk/diskio.h"
 
 /*printf: */
 int PrintfFunction(const char* format,...);
+int PrintfFunction(const string & message);
+int PrintfFunction2(const string & message);
 
 #endif	/* _IO_H_ */
Index: /issm/trunk/src/c/issm.h
===================================================================
--- /issm/trunk/src/c/issm.h	(revision 12705)
+++ /issm/trunk/src/c/issm.h	(revision 12706)
@@ -22,4 +22,3 @@
 #include "./modules/modules.h"
 
-
 #endif //ifndef _ISSM_H_
Index: /issm/trunk/src/c/matlab/include/matlab_macros.h
===================================================================
--- /issm/trunk/src/c/matlab/include/matlab_macros.h	(revision 12705)
+++ /issm/trunk/src/c/matlab/include/matlab_macros.h	(revision 12706)
@@ -3,5 +3,5 @@
  */
 
-/*Header {{{1*/
+/*Header {{{*/
 #ifndef _MATLAB_MACROS_H_
 #define _MATLAB_MACROS_H_
@@ -15,5 +15,5 @@
 
 #ifdef _HAVE_MATLAB_
-/* MODULEBOOT/MODULEEND {{{1*/
+/* MODULEBOOT/MODULEEND {{{*/
 
 /*The following macros hide the error exception handling in a matlab module. Just put 
@@ -36,9 +36,9 @@
 	}
 //}}}
-/* WRAPPER {{{1*/
+/* WRAPPER {{{*/
 #define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) 
 
 /*}}}*/
-/* CHECKARGUMENTS {{{1*/
+/* CHECKARGUMENTS {{{*/
 #define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)
 /*}}}*/
Index: /issm/trunk/src/c/matlab/io/CheckNumMatlabArguments.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/CheckNumMatlabArguments.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/CheckNumMatlabArguments.cpp	(revision 12706)
@@ -22,9 +22,9 @@
 		/* special case: */
 		function();
-		_error_("usage: see above");
+		_error2_("usage: see above");
 	}
 	else if (nlhs!=NLHS || nrhs!=NRHS ) {
 		function(); 
-		_error_("usage error.");
+		_error2_("usage error.");
 	}
 	return 1;
Index: /issm/trunk/src/c/matlab/io/FetchMatlabData.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/FetchMatlabData.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/FetchMatlabData.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 
 /*Primitive data types*/
-/*FUNCTION FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
 void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){
 
@@ -27,5 +27,9 @@
 		outmatrix=NULL;
 	}
-	else if(mxIsClass(dataref,"double") || mxIsClass(dataref,"single")){
+	else if( mxIsClass(dataref,"double") || 
+				mxIsClass(dataref,"single") || 
+				mxIsClass(dataref,"int16") || 
+				mxIsClass(dataref,"int8") || 
+				mxIsClass(dataref,"uint8")){
 		/*Check dataref is not pointing to NaN: */
 		if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
@@ -35,4 +39,7 @@
 		}
 		else{
+			if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){
+				_printLine_("Warning: converting matlab data from '" << mxGetClassName(dataref) << "' to 'double'");
+			}
 			/*Convert matlab matrix to double* matrix: */
 			MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref);
@@ -41,5 +48,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 			
@@ -51,5 +58,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
 void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
 
@@ -82,5 +89,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 			
@@ -90,9 +97,9 @@
 	if (pndims)*pndims=outmatrix_ndims;
 	if (psize )*psize =outmatrix_size;
-	else xfree((void**)&outmatrix_size);
-
-}
-/*}}}*/
-/*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+	else xDelete<int>(outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
 void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){
 
@@ -121,5 +128,5 @@
 
 			/*Convert double matrix into integer matrix: */
-			outmatrix=(int*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(int));
+			outmatrix=xNew<int>(outmatrix_rows*outmatrix_cols);
 			for(i=0;i<outmatrix_rows*outmatrix_cols;i++)outmatrix[i]=(int)doublematrix[i];
 		}
@@ -127,5 +134,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 
@@ -136,5 +143,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
 void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){
 
@@ -163,5 +170,5 @@
 
 			/*Convert double matrix into integer matrix: */
-			outmatrix=(bool*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(bool));
+			outmatrix=xNew<bool>(outmatrix_rows*outmatrix_cols);
 			for(i=0;i<outmatrix_rows;i++)outmatrix[i]=(bool)doublematrix[i];
 		}
@@ -169,5 +176,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 
@@ -178,5 +185,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
 void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
 
@@ -224,12 +231,12 @@
 
 			/*Convert double matrix into bool matrix: */
-			outmatrix=(bool*)xmalloc(outmatrix_numel*sizeof(bool));
+			outmatrix=xNew<bool>(outmatrix_numel);
 			for(i=0;i<outmatrix_numel;i++)outmatrix[i]=(bool)doublematrix[i];
-			xfree((void**)&doublematrix);
-		}
-	}
-	else{
-		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+			xDelete<double>(doublematrix);
+		}
+	}
+	else{
+		/*This is an error: we don't have the correct input!: */
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 			
@@ -239,9 +246,9 @@
 	if (pndims)*pndims=outmatrix_ndims;
 	if (psize )*psize =outmatrix_size;
-	else xfree((void**)&outmatrix_size);
-
-}
-/*}}}*/
-/*FUNCTION FetchData(double** pvector,int* pM,const mxArray* dataref){{{1*/
+	else xDelete<int>(outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchData(double** pvector,int* pM,const mxArray* dataref){{{*/
 void FetchData(double** pvector,int* pM,const mxArray* dataref){
 
@@ -262,5 +269,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 
@@ -270,5 +277,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{*/
 void FetchData(int** pvector,int* pM,const mxArray* dataref){
 
@@ -289,10 +296,10 @@
 
 		/*Convert double vector into integer vector: */
-		outvector=(int*)xmalloc(outvector_rows*sizeof(int));
+		outvector=xNew<int>(outvector_rows);
 		for(i=0;i<outvector_rows;i++)outvector[i]=(int)doublevector[i];
 	}
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 
@@ -302,5 +309,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{*/
 void FetchData(bool** pvector,int* pM,const mxArray* dataref){
 
@@ -321,10 +328,10 @@
 
 		/*Convert double vector into integer vector: */
-		outvector=(bool*)xmalloc(outvector_rows*sizeof(bool));
+		outvector=xNew<bool>(outvector_rows);
 		for(i=0;i<outvector_rows;i++)outvector[i]=(bool)doublevector[i];
 	}
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 
@@ -334,5 +341,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{*/
 void FetchData(float** pvector,int* pM,const mxArray* dataref){
 
@@ -353,10 +360,10 @@
 
 		/*Convert double vector into float vector: */
-		outvector=(float*)xmalloc(outvector_rows*sizeof(float));
+		outvector=xNew<float>(outvector_rows);
 		for(i=0;i<outvector_rows;i++)outvector[i]=(float)doublevector[i];
 	}
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 
@@ -366,5 +373,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(char** pstring,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(char** pstring,const mxArray* dataref){{{*/
 void FetchData(char** pstring,const mxArray* dataref){
 
@@ -374,5 +381,5 @@
 	/*Ok, the string should be coming directly from the matlab workspace: */
 	if (!mxIsClass(dataref,"char")){
-		_error_("input data_type is not a string!");
+		_error2_("input data_type is not a string!");
 	}
 	else{
@@ -381,5 +388,5 @@
 		
 		stringlen = mxGetM(dataref)*mxGetN(dataref)+1;
-		outstring = (char*)xmalloc(sizeof(mxChar)*stringlen);
+		outstring =xNew<char>(stringlen);
 		mxGetString(dataref,outstring,stringlen);
 	}
@@ -387,6 +394,6 @@
 	/*Assign output pointers:*/
 	*pstring=outstring;
-}
-/*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{1*/
+}/*}}}*/
+/*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
 void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
 
@@ -409,5 +416,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 			
@@ -417,9 +424,9 @@
 	if (pndims)*pndims=outmatrix_ndims;
 	if (psize )*psize =outmatrix_size;
-	else xfree((void**)&outmatrix_size);
-
-}
-/*}}}*/
-/*FUNCTION FetchData(double* pscalar,const mxArray* dataref){{{1*/
+	else xDelete<int>(outmatrix_size);
+
+}
+/*}}}*/
+/*FUNCTION FetchData(double* pscalar,const mxArray* dataref){{{*/
 void FetchData(double* pscalar,const mxArray* dataref){
 
@@ -427,5 +434,5 @@
 
 	if (!mxIsClass(dataref,"double")){
-		_error_("input data_type is not a double!");
+		_error2_("input data_type is not a double!");
 	}
 	else{
@@ -438,5 +445,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(int* pinteger,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(int* pinteger,const mxArray* dataref){{{*/
 void FetchData(int* pinteger,const mxArray* dataref){
 
@@ -444,5 +451,5 @@
 
 	if (!mxIsClass(dataref,"double")){
-		_error_("input data_type is not a scalar!");
+		_error2_("input data_type is not a scalar!");
 	}
 	else{
@@ -455,5 +462,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(bool* pboolean,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(bool* pboolean,const mxArray* dataref){{{*/
 void FetchData(bool* pboolean,const mxArray* dataref){
 
@@ -461,10 +468,10 @@
 
 	if (mxIsClass(dataref,"logical")){
-		if(mxGetM(dataref)!=1) _error_("input data is not of size 1x1");
-		if(mxGetN(dataref)!=1) _error_("input data is not of size 1x1");
+		if(mxGetM(dataref)!=1) _error2_("input data is not of size 1x1");
+		if(mxGetN(dataref)!=1) _error2_("input data is not of size 1x1");
 		mxbool_ptr=mxGetLogicals(dataref);
 	}
 	else{
-		_error_("input data_type is not a bool!");
+		_error2_("input data_type is not a bool!");
 	}
 
@@ -474,5 +481,5 @@
 
 /*ISSM objects*/
-/*FUNCTION FetchData(Matrix** pmatrix,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(Matrix** pmatrix,const mxArray* dataref){{{*/
 void FetchData(Matrix** pmatrix,const mxArray* dataref){
 
@@ -488,5 +495,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 
@@ -495,5 +502,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(Vector** pvector,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(Vector** pvector,const mxArray* dataref){{{*/
 void FetchData(Vector** pvector,const mxArray* dataref){
 
@@ -512,5 +519,5 @@
 	else{
 		/*This is an error: we don't have the correct input!: */
-		_error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
+		_error2_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
 	}
 
@@ -519,5 +526,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(BamgGeom** pbamggeom,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(BamgGeom** pbamggeom,const mxArray* dataref){{{*/
 void FetchData(BamgGeom** pbamggeom,const mxArray* dataref){
 
@@ -538,5 +545,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){{{*/
 void FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){
 
@@ -558,5 +565,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(BamgOpts** pbamgopts,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(BamgOpts** pbamgopts,const mxArray* dataref){{{*/
 void FetchData(BamgOpts** pbamgopts,const mxArray* dataref){
 
@@ -602,5 +609,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(Options** poptions,const mxArray* dataref){{{1*/
+/*FUNCTION FetchData(Options** poptions,const mxArray* dataref){{{*/
 void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref){
 
@@ -613,8 +620,8 @@
 	/*Fetch all options*/
 	for (int i=istart; i<nrhs; i=i+2){
-		if (!mxIsClass(pdataref[i],"char")) _error_("Argument %d must be name of option",i+1);
+		if (!mxIsClass(pdataref[i],"char")) _error2_("Argument " << i+1 << " must be name of option");
 
 		FetchData(&name,pdataref[i]);
-		if(i+1 == nrhs) _error_("Argument %d must exist and be value of option \"%s\".",i+2,name);
+		if(i+1 == nrhs) _error2_("Argument " << i+2 << " must exist and be value of option \"" << name << "\".");
 
 		option=(Option*)OptionParse(name,&pdataref[i+1]);
Index: /issm/trunk/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp	(revision 12706)
@@ -2,5 +2,4 @@
  * \brief: convert a sparse or dense matlab matrix to a double* pointer
  */
-
 
 #ifdef HAVE_CONFIG_H
@@ -10,15 +9,11 @@
 #endif
 
-
 /*Matlab includes: */
 #include "mex.h"
-
 #include "../../shared/shared.h"
 
 int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
 
-	int     i,j,count,rows,cols;
-	double *pmxdoublematrix = NULL;
-	float  *pmxsinglematrix = NULL;
+	int        i,j,count,rows,cols;
 
 	/*output: */
@@ -33,10 +28,10 @@
 
 		/*Dealing with sparse matrix: recover size first: */
-		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
+		double* pmxmatrix=(double*)mxGetPr(mxmatrix);
 		rows=mxGetM(mxmatrix);
 		cols=mxGetN(mxmatrix);
 		
 		if(rows*cols){
-			matrix=(double*)xcalloc(rows*cols,sizeof(double));
+			matrix=xNewZeroInit<double>(rows*cols);
 
 			/*Now, get ir,jc and pr: */
@@ -48,5 +43,5 @@
 			for(i=0;i<cols;i++){
 				for(j=0;j<(jc[i+1]-jc[i]);j++){
-					matrix[rows*ir[count]+i]=pmxdoublematrix[count];
+					matrix[rows*ir[count]+i]=pmxmatrix[count];
 					count++;
 				}
@@ -57,5 +52,5 @@
 	else if(mxIsClass(mxmatrix,"double")){
 		/*Dealing with dense matrix: recover pointer and size: */
-		pmxdoublematrix=(double*)mxGetPr(mxmatrix);
+		double* pmxmatrix=(double*)mxGetPr(mxmatrix);
 		rows=mxGetM(mxmatrix);
 		cols=mxGetN(mxmatrix);
@@ -63,9 +58,9 @@
 		/*Create serial matrix: */
 		if(rows*cols){
-			matrix=(double*)xcalloc(rows*cols,sizeof(double));
+			matrix=xNewZeroInit<double>(rows*cols);
 
 			for(i=0;i<rows;i++){
 				for(j=0;j<cols;j++){
-					matrix[cols*i+j]=(double)pmxdoublematrix[rows*j+i];
+					matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
 				}
 			}
@@ -74,5 +69,5 @@
 	else if(mxIsClass(mxmatrix,"single")){
 		/*Dealing with dense matrix: recover pointer and size: */
-		pmxsinglematrix=(float*)mxGetPr(mxmatrix);
+		float *pmxmatrix=(float*)mxGetPr(mxmatrix);
 		rows=mxGetM(mxmatrix);
 		cols=mxGetN(mxmatrix);
@@ -80,9 +75,43 @@
 		/*Create serial matrix: */
 		if(rows*cols){
-			matrix=(double*)xcalloc(rows*cols,sizeof(double));
+			matrix=xNewZeroInit<double>(rows*cols);
 
 			for(i=0;i<rows;i++){
 				for(j=0;j<cols;j++){
-					matrix[cols*i+j]=(double)pmxsinglematrix[rows*j+i];
+					matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
+				}
+			}
+		}
+	}
+	else if(mxIsClass(mxmatrix,"int16")){
+		/*Dealing with dense matrix: recover pointer and size: */
+		short int *pmxmatrix=(short*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+
+		/*Create serial matrix: */
+		if(rows*cols){
+			matrix=xNewZeroInit<double>(rows*cols);
+
+			for(i=0;i<rows;i++){
+				for(j=0;j<cols;j++){
+					matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
+				}
+			}
+		}
+	}
+	else if(mxIsClass(mxmatrix,"uint8")){
+		/*Dealing with dense matrix: recover pointer and size: */
+		char *pmxmatrix=(char*)mxGetPr(mxmatrix);
+		rows=mxGetM(mxmatrix);
+		cols=mxGetN(mxmatrix);
+
+		/*Create serial matrix: */
+		if(rows*cols){
+			matrix=xNewZeroInit<double>(rows*cols);
+
+			for(i=0;i<rows;i++){
+				for(j=0;j<cols;j++){
+					matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
 				}
 			}
@@ -90,5 +119,5 @@
 	}
 	else{
-		_error_("Matlab matrix type Not implemented yet");
+		_error2_("Matlab matrix type Not implemented yet");
 	}
 
Index: /issm/trunk/src/c/matlab/io/MatlabMatrixToMatrix.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabMatrixToMatrix.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabMatrixToMatrix.cpp	(revision 12706)
@@ -3,5 +3,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
Index: /issm/trunk/src/c/matlab/io/MatlabMatrixToPetscMatrix.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabMatrixToPetscMatrix.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabMatrixToPetscMatrix.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-
+#include "../../shared/shared.h"
 
 /*Petsc includes: */
@@ -19,21 +19,19 @@
 #include "mex.h"
 
-#include "../../shared/shared.h"
-
 int MatlabMatrixToPetscMatrix(Mat* pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
 
 	int rows, cols;
-	double* mxmatrix_ptr=NULL;
-	double* tmatrix=NULL;
+	double *mxmatrix_ptr = NULL;
+	double *tmatrix      = NULL;
 	int ierr;
 	int i,j;
 
 	/*output: */
-	Mat matrix=NULL;
+	Mat matrix = NULL;
 
 	/*matlab indices: */
-	mwIndex*    ir=NULL;
-	mwIndex*    jc=NULL;
-	double* pr=NULL;
+	mwIndex *ir = NULL;
+	mwIndex *jc = NULL;
+	double  *pr = NULL;
 	int     count;
 	int     nnz;
@@ -41,6 +39,6 @@
 
 	/*petsc indices: */
-	int* idxm=NULL;
-	int* idxn=NULL;
+	int *idxm = NULL;
+	int *idxn = NULL;
 	
 	/*Ok, first check if we are dealing with a sparse or full matrix: */
@@ -74,8 +72,6 @@
 			}
 		}
-
 	}
 	else{
-
 		/*Dealing with dense matrix: recover pointer and size: */
 		mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
@@ -84,5 +80,5 @@
 
 		/*transpose, as Petsc now does not allows MAT_COLUMN_ORIENTED matrices in MatSetValues: */
-		tmatrix=(double*)xmalloc(rows*cols*sizeof(double));
+		tmatrix=xNew<double>(rows*cols);
 		for(i=0;i<cols;i++){
 			for(j=0;j<rows;j++){
@@ -95,6 +91,6 @@
 
 		/*Insert mxmatrix_ptr values into petsc matrix: */
-		idxm=(int*)xmalloc(rows*sizeof(int));
-		idxn=(int*)xmalloc(cols*sizeof(int));
+		idxm=xNew<int>(rows);
+		idxn=xNew<int>(cols);
 
 		for(i=0;i<rows;i++)idxm[i]=i;
@@ -103,6 +99,5 @@
 		ierr=MatSetValues(matrix,rows,idxm,cols,idxn,tmatrix,INSERT_VALUES); CHKERRQ(ierr);
 
-		xfree((void**)&tmatrix);
-
+		xDelete<double>(tmatrix);
 	}
 
@@ -110,5 +105,4 @@
 	MatAssemblyBegin(matrix,MAT_FINAL_ASSEMBLY); 
 	MatAssemblyEnd(matrix,MAT_FINAL_ASSEMBLY);
-
 
 	/*Assign output pointer: */
Index: /issm/trunk/src/c/matlab/io/MatlabMatrixToSeqMat.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabMatrixToSeqMat.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabMatrixToSeqMat.cpp	(revision 12706)
@@ -3,5 +3,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
Index: /issm/trunk/src/c/matlab/io/MatlabNArrayToNArray.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabNArrayToNArray.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabNArrayToNArray.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 #include <mex.h>
 
-/*FUNCTION MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
+/*FUNCTION MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
 int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
 
@@ -39,6 +39,6 @@
 	ndims=mxGetNumberOfDimensions(mxmatrix);
 	ipt  =mxGetDimensions(mxmatrix);
-	size =(int *) xcalloc(ndims,sizeof(int));
-	for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
+	size =xNew<int>(ndims);
+	for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
 
 	/*Ok, first check if we are dealing with a sparse or full matrix: */
@@ -51,5 +51,5 @@
 		nz=(int)((double)nnz/(double)rows);
 
-		matrix=(double*)xcalloc(rows*cols,sizeof(double));
+		matrix=xNewZeroInit<double>(rows*cols);
 
 		/*Now, get ir,jc and pr: */
@@ -74,7 +74,7 @@
 		
 		/*Create serial matrix: */
-		matrix=(double*)xcalloc(numel,sizeof(double));
-
-		dims=(int *) xcalloc(ndims,sizeof(int));
+		matrix=xNewZeroInit<double>(numel);
+
+		dims=xNew<int>(ndims);
 		for(i=0;i<numel;i++){
 			ColumnWiseDimsFromIndex(dims,i,size,ndims);
@@ -82,5 +82,5 @@
 			*(matrix+j)=*(mxmatrix_ptr+i);
 		}
-		xfree((void**)&dims);
+		xDelete<int>(dims);
 		
 	}
@@ -95,5 +95,5 @@
 }
 /*}}}*/
-/*FUNCTION MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
+/*FUNCTION MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
 int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
 
@@ -119,6 +119,6 @@
 	ndims=mxGetNumberOfDimensions(mxmatrix);
 	ipt  =mxGetDimensions(mxmatrix);
-	size =(int *) xcalloc(ndims,sizeof(int));
-	for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
+	size =xNew<int>(ndims);
+	for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
 
 	/*Ok, first check if we are dealing with a sparse or full matrix: */
@@ -131,5 +131,5 @@
 		nz=(int)((double)nnz/(double)rows);
 
-		matrix=(bool*)xcalloc(rows*cols,sizeof(bool));
+		matrix=xNewZeroInit<bool>(rows*cols);
 
 		/*Now, get ir,jc and pm: */
@@ -154,7 +154,6 @@
 		
 		/*Create serial matrix: */
-		matrix=(bool*)xcalloc(numel,sizeof(bool));
-
-		dims=(int *) xcalloc(ndims,sizeof(int));
+		matrix=xNew<bool>(numel);
+		dims=xNew<int>(ndims);
 		for(i=0;i<numel;i++){
 			ColumnWiseDimsFromIndex(dims,i,size,ndims);
@@ -162,6 +161,5 @@
 			*(matrix+j)=(bool)*(mxmatrix_ptr+i);
 		}
-		xfree((void**)&dims);
-		
+		xDelete<int>(dims);
 	}
 
@@ -175,12 +173,12 @@
 }
 /*}}}*/
-/*FUNCTION MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{1*/
+/*FUNCTION MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
 int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
 
-	int  i,j,rows,cols;
-	int  numel,ndims;
-	int *size,*dims;
-	mxChar* mxmatrix_ptr=NULL;
-	const mwSize* ipt=NULL;
+	int           i,j,rows,cols;
+	int           numel,ndims;
+	int          *size , *dims;
+	mxChar       *mxmatrix_ptr = NULL;
+	const mwSize *ipt          = NULL;
 
 	/*output: */
@@ -188,10 +186,10 @@
 
 	/*matlab indices: */
-	mwIndex*    ir=NULL;
-	mwIndex*    jc=NULL;
-	char*   pm=NULL;
-	int     count;
-	int     nnz;
-	int     nz;
+	mwIndex *ir    = NULL;
+	mwIndex *jc    = NULL;
+	char    *pm    = NULL;
+	int      count;
+	int      nnz;
+	int      nz;
 
 	/*get Matlab matrix information: */
@@ -199,6 +197,6 @@
 	ndims=mxGetNumberOfDimensions(mxmatrix);
 	ipt  =mxGetDimensions(mxmatrix);
-	size =(int *) xcalloc(ndims,sizeof(int));
-	for (i=0; i<ndims; i++) size[i]=(int)ipt[i];
+	size =xNew<int>(ndims);
+	for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
 
 	/*Ok, first check if we are dealing with a sparse or full matrix: */
@@ -211,5 +209,5 @@
 		nz=(int)((double)nnz/(double)rows);
 
-		matrix=(char*)xcalloc(rows*cols,sizeof(double));
+		matrix=xNew<char>(rows*cols);
 
 		/*Now, get ir,jc and pm: */
@@ -234,5 +232,6 @@
 		
 		/*Create serial matrix: */
-		matrix=(char*)xcalloc(numel+1,sizeof(mxChar));
+		matrix=xNew<char>(numel+1);
+		matrix[numel]='\0';
 
 		/*looping code adapted from Matlab example explore.c: */
@@ -259,5 +258,4 @@
 			}
 		}
-
 	}
 
Index: /issm/trunk/src/c/matlab/io/MatlabVectorToDoubleVector.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabVectorToDoubleVector.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabVectorToDoubleVector.cpp	(revision 12706)
@@ -46,10 +46,10 @@
 		
 		/*Check that input is actualy a vector*/
-		if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
+		if (cols!=1) _error2_("input vector of size " << rows << "x" << cols << " should have only one column");
 
 		nz=(int)((double)nnz/(double)rows);
 
 		if(rows){
-			vector=(double*)xcalloc(rows,sizeof(double));
+			vector=xNewZeroInit<double>(rows);
 
 			/*Now, get ir,jc and pr: */
@@ -77,9 +77,9 @@
 
 		/*Check that input is actualy a vector*/
-		if (cols!=1) _error_("input vector of size %ix%i should have only one column",rows,cols);
+		if (cols!=1) _error2_("input vector of size " << rows << "x" << cols << " should have only one column");
 
 		/*allocate and memcpy*/
 		if(rows){
-			vector=(double*)xmalloc(rows*sizeof(double));
+			vector=xNew<double>(rows);
 			memcpy(vector,mxvector_ptr,rows*sizeof(double));
 		}
Index: /issm/trunk/src/c/matlab/io/MatlabVectorToPetscVector.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabVectorToPetscVector.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabVectorToPetscVector.cpp	(revision 12706)
@@ -79,5 +79,5 @@
 
 		/*Insert mxvector_ptr values into petsc vector: */
-		idxm=(int*)xmalloc(rows*sizeof(int));
+		idxm=xNew<int>(rows);
 
 		for(i=0;i<rows;i++)idxm[i]=i;
Index: /issm/trunk/src/c/matlab/io/MatlabVectorToSeqVec.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabVectorToSeqVec.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabVectorToSeqVec.cpp	(revision 12706)
@@ -3,5 +3,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
Index: /issm/trunk/src/c/matlab/io/MatlabVectorToVector.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/MatlabVectorToVector.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/MatlabVectorToVector.cpp	(revision 12706)
@@ -3,5 +3,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
Index: /issm/trunk/src/c/matlab/io/OptionParse.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/OptionParse.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/OptionParse.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 #include "./matlabio.h"
 
-/*FUNCTION OptionDoubleParse {{{1*/
+/*FUNCTION OptionDoubleParse {{{*/
 OptionDouble* OptionDoubleParse( char* name, const mxArray* prhs[]){
 
@@ -22,17 +22,16 @@
 	/*check and parse the name  */
 	odouble=new OptionDouble;
-	odouble->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	odouble->name =xNew<char>(strlen(name)+1);
 	memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
 
 	/*check and parse the value  */
 	if (!mxIsClass(prhs[0],"double")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",odouble->name,"double",odouble->name,mxGetClassName(prhs[0]));
+		_error2_("Value of option \"" << odouble->name  << "\" must be class \"double\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
 	}
-
 	FetchData(&odouble->values,&odouble->numel,&odouble->ndims,&odouble->size,prhs[0]);
 
 	return(odouble);
 }/*}}}*/
-/*FUNCTION OptionLogicalParse {{{1*/
+/*FUNCTION OptionLogicalParse {{{*/
 OptionLogical* OptionLogicalParse( char* name, const mxArray* prhs[]){
 
@@ -41,17 +40,16 @@
 	/*check and parse the name  */
 	ological=new OptionLogical;
-	ological->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
+	ological->name =xNew<char>(strlen(name)+1);
 	memcpy(ological->name,name,(strlen(name)+1)*sizeof(char));
 
 	/*check and parse the value  */
 	if (!mxIsClass(prhs[0],"logical")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ological->name,"logical",ological->name,mxGetClassName(prhs[0]));
+		_error2_("Value of option \"" << ological->name  << "\" must be class \"logical\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
 	}
-
 	FetchData(&ological->values,&ological->numel,&ological->ndims,&ological->size,prhs[0]);
 
 	return(ological);
 }/*}}}*/
-/*FUNCTION OptionCharParse {{{1*/
+/*FUNCTION OptionCharParse {{{*/
 OptionChar* OptionCharParse( char* name, const mxArray* prhs[]){
 
@@ -60,17 +58,16 @@
 	/*check and parse the name  */
 	ochar=new OptionChar();
-	ochar->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
+	ochar->name =xNew<char>(strlen(name)+1);
 	memcpy(ochar->name,name,(strlen(name)+1)*sizeof(char));
 
 	/*check and parse the value  */
 	if (!mxIsClass(prhs[0],"char")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ochar->name,"char",ochar->name,mxGetClassName(prhs[0]));
+		_error2_("Value of option \"" << ochar->name  << "\" must be class \"char\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
 	}
-
 	FetchData(&ochar->values,&ochar->numel,&ochar->ndims,&ochar->size,prhs[0]);
 
 	return(ochar);
 }/*}}}*/
-/*FUNCTION OptionStructParse {{{1*/
+/*FUNCTION OptionStructParse {{{*/
 OptionStruct* OptionStructParse( char* name, const mxArray* prhs[]){
 
@@ -85,18 +82,17 @@
 	/*check and parse the name  */
 	ostruct=new OptionStruct;
-	ostruct->name =(char*)xmalloc((strlen(name)+1)*sizeof(char));
+	ostruct->name =xNew<char>(strlen(name)+1);
 	memcpy(ostruct->name,name,(strlen(name)+1)*sizeof(char));
 
 	/*check and parse the value  */
 	if (!mxIsClass(prhs[0],"struct")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ostruct->name,"struct",ostruct->name,mxGetClassName(prhs[0]));
+		_error2_("Value of option \"" << ostruct->name  << "\" must be class \"struct\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
 	}
-
 	ostruct->numel=mxGetNumberOfElements(prhs[0]);
 	ostruct->ndims=mxGetNumberOfDimensions(prhs[0]);
 	ipt           =mxGetDimensions(prhs[0]);
-	ostruct->size =(int *) xmalloc(ostruct->ndims*sizeof(int));
+	ostruct->size =xNew<int>(ostruct->ndims);
 	for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i];
-	if (ostruct->numel) ostruct->values=(Options**) xmalloc(ostruct->numel*sizeof(Options *));
+	if (ostruct->numel) ostruct->values=xNew<Options*>(ostruct->numel);
 
 	/*loop through and process each element of the struct array  */
@@ -117,5 +113,5 @@
 	return(ostruct);
 }/*}}}*/
-/*FUNCTION OptionCellParse {{{1*/
+/*FUNCTION OptionCellParse {{{*/
 OptionCell* OptionCellParse( char* name, const mxArray* prhs[]){
 
@@ -132,10 +128,10 @@
 	/*check and parse the name  */
 	ocell=new OptionCell;
-	ocell->name =(char *) xmalloc((strlen(name)+1)*sizeof(char));
+	ocell->name =xNew<char>(strlen(name)+1);
 	memcpy(ocell->name,name,(strlen(name)+1)*sizeof(char));
 
 	/*check and parse the value  */
 	if (!mxIsClass(prhs[0],"cell")){
-		_error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ocell->name,"cell",ocell->name,mxGetClassName(prhs[0]));
+		_error2_("Value of option \"" << ocell->name  << "\" must be class \"cell\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
 	}
 
@@ -143,10 +139,10 @@
 	ocell->ndims=mxGetNumberOfDimensions(prhs[0]);
 	ipt         =mxGetDimensions(prhs[0]);
-	ocell->size =(int *) xmalloc(ocell->ndims*sizeof(int));
+	ocell->size =xNew<int>(ocell->ndims);
 	for (i=0; i<ocell->ndims; i++) ocell->size[i]=(int)ipt[i];
 	ocell->values=new Options;
 
 	/*loop through and process each element of the cell array  */
-	dims=(int *) xmalloc(ocell->ndims*sizeof(int));
+	dims=xNew<int>(ocell->ndims);
 	for (cindex=0; cindex<ocell->numel; cindex++) {
 		ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims);
@@ -163,9 +159,9 @@
 		option=NULL;
 	}
-	xfree((void**)&dims);
+	xDelete<int>(dims);
 
 	return(ocell);
 }/*}}}*/
-/*FUNCTION OptionParse{{{1*/
+/*FUNCTION OptionParse{{{*/
 Option* OptionParse(char* name, const mxArray* prhs[]){
 
@@ -180,10 +176,10 @@
 	else if(mxIsClass(prhs[0],"cell"))    option=(Option*)OptionCellParse(name,prhs);
 	else {
-		_printf_(true,"  Converting value of option \"%s\" from unrecognized class \"%s\" to class \"%s\".\n",name,mxGetClassName(prhs[0]),"struct");
+		_pprintLine_("  Converting value of option \"" << name << "\" from unrecognized class \"" << mxGetClassName(prhs[0]) << "\" to class \"" << "struct" << "\".");
 		if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) {
 			option=(Option*)OptionStructParse(name,(const mxArray**)lhs);
 			mxDestroyArray(lhs[0]);
 		}
-		else _error_("Second argument value of option \"%s\" is of unrecognized class \"%s\".",name,mxGetClassName(prhs[0]));
+		else _error2_("Second argument value of option \""<< name <<"\" is of unrecognized class \""<< mxGetClassName(prhs[0]) <<"\".");
 	}
 
Index: /issm/trunk/src/c/matlab/io/PrintfFunction.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/PrintfFunction.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/PrintfFunction.cpp	(revision 12706)
@@ -27,5 +27,5 @@
 
 		/*allocate buffer for given string size*/
-		buffer=(char*)xmalloc(size*sizeof(char));
+		buffer=xNew<char>(size);
 
 		/* Try to print in the allocated space. */
@@ -47,12 +47,12 @@
 		 size*=2;  /* twice the old size */
 
-		xfree((void**)&buffer);
+		xDelete<char>(buffer);
 	}
 
 	/*Ok, if we are running in parallel, get node 0 to print*/
-	if(my_rank==0)printf(buffer);
+	if(my_rank==0)_printString_(buffer);
 
 	/*Clean up and return*/
-	xfree((void**)&buffer);
+	xDelete<char>(buffer);
 	return 1;
 }
Index: /issm/trunk/src/c/matlab/io/WriteMatlabData.cpp
===================================================================
--- /issm/trunk/src/c/matlab/io/WriteMatlabData.cpp	(revision 12705)
+++ /issm/trunk/src/c/matlab/io/WriteMatlabData.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 
 /*Primitive data types*/
-/*FUNCTION WriteData(mxArray** pdataref,double* matrix, int M,int N){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,double* matrix, int M,int N){{{*/
 void WriteData(mxArray** pdataref,double* matrix, int M,int N){
 
@@ -42,5 +42,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,int* matrix, int M,int N){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,int* matrix, int M,int N){{{*/
 void WriteData(mxArray** pdataref,int* matrix, int M,int N){
 
@@ -67,5 +67,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,double* vector, int M){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,double* vector, int M){{{*/
 void WriteData(mxArray** pdataref,double* vector, int M){
 	
@@ -90,5 +90,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,double scalar){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,double scalar){{{*/
 void WriteData(mxArray** pdataref,double scalar){
 
@@ -96,5 +96,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,int integer){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,int integer){{{*/
 void WriteData(mxArray** pdataref,int integer){
 
@@ -103,5 +103,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,int boolean){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,int boolean){{{*/
 void WriteData(mxArray** pdataref,bool boolean){
 
@@ -110,5 +110,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,char* string){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,char* string){{{*/
 void WriteData(mxArray** pdataref,char* string){
 
@@ -118,5 +118,5 @@
 
 /*ISSM objects*/
-/*FUNCTION WriteData(mxArray** pdataref,BamgGeom* bamggeom){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,BamgGeom* bamggeom){{{*/
 void WriteData(mxArray** pdataref,BamgGeom* bamggeom){
 
@@ -158,5 +158,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,BamgMesh* bamgmesh){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,BamgMesh* bamgmesh){{{*/
 void WriteData(mxArray** pdataref,BamgMesh* bamgmesh){
 
@@ -216,5 +216,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,Matrix* matrix){{{1*/
+/*FUNCTION WriteData(mxArray** pdataref,Matrix* matrix){{{*/
 void WriteData(mxArray** pdataref,Matrix* matrix){
 		
@@ -249,15 +249,15 @@
 
 		/*Free ressources:*/
-		xfree((void**)&matrix_ptr);
-
-	}
-	else{
-		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
-	}
-
-	*pdataref=dataref;
-}
-/*}}}*/
-/*FUNCTION WriteData(mxArray** pdataref,Vector* vector){{{1*/
+		xDelete<double>(matrix_ptr);
+
+	}
+	else{
+		dataref = mxCreateDoubleMatrix(0,0,mxREAL);
+	}
+
+	*pdataref=dataref;
+}
+/*}}}*/
+/*FUNCTION WriteData(mxArray** pdataref,Vector* vector){{{*/
 void WriteData(mxArray** pdataref,Vector* vector){
 	
@@ -290,5 +290,5 @@
 
 	/*Clean-up and return*/
-	xfree((void**)&vector_ptr);
+	xDelete<double>(vector_ptr);
 	*pdataref=dataref;
 }
@@ -296,5 +296,5 @@
 
 /*Toolkit*/
-/*FUNCTION SetStructureField{{{1*/
+/*FUNCTION SetStructureField{{{*/
 void SetStructureField(mxArray* dataref,const char* fieldname,int M,int N,double* fieldpointer){
 
Index: /issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp
===================================================================
--- /issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp	(revision 12706)
@@ -18,7 +18,7 @@
 
 	/*output: */
-	double*         imageout=NULL;
+	double* imageout=NULL;
 
-	imageout=(double*)xmalloc(samps*lines*sizeof(double));
+	imageout=xNew<double>(samps*lines);
 
   	for ( i = 0; i < lines; i++ ){
Index: /issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
===================================================================
--- /issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp	(revision 12706)
@@ -65,5 +65,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&qmu_part);
+	xDelete<double>(qmu_part);
 	xdelete(&partition_contributions);
 	xdelete(&partition_areas);
Index: /issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.cpp
===================================================================
--- /issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.cpp	(revision 12706)
@@ -12,30 +12,19 @@
 using namespace std;
 
-int BamgConvertMeshx(BamgMesh* bamgmesh,BamgGeom* bamggeom,double* index,double* x,double* y,int nods,int nels){
-
-	/*Intermediary*/
-	int i,j,k;
-	int verbose=0;
-	int noerr=1;
+int BamgConvertMeshx(BamgMesh* bamgmesh,BamgGeom* bamggeom,int* index,double* x,double* y,int nods,int nels){
 
 	/*Options*/
-	BamgOpts* bamgopts=NULL;
-	bamgopts=new BamgOpts();
+	BamgOpts* bamgopts=new BamgOpts();
 
-	// read mesh
-	if(verbose) printf("Reading mesh\n");
+	/*read mesh*/
 	Mesh Th(index,x,y,nods,nels); 
 
-	//write mesh and geometry
-	if (verbose) printf("Write Geometry\n");
+	/*write mesh and geometry*/
 	Th.Gh.WriteGeometry(bamggeom,bamgopts);
-	if (verbose) printf("Write Mesh\n");
 	Th.WriteMesh(bamgmesh,bamgopts);
 
-	//clean up
+	/*clean up and return*/
 	delete bamgopts;
-
-	/*No error return*/
-	return noerr;
+	return 1;
 
 }
Index: /issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.h
===================================================================
--- /issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/BamgConvertMeshx/BamgConvertMeshx.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-int BamgConvertMeshx(BamgMesh* bamgmesh,BamgGeom* bamggeom,double* index,double* x,double* y,int nods,int nels);
+int BamgConvertMeshx(BamgMesh* bamgmesh,BamgGeom* bamggeom,int* index,double* x,double* y,int nods,int nels);
 
 #endif
Index: /issm/trunk/src/c/modules/Bamgx/Bamgx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Bamgx/Bamgx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Bamgx/Bamgx.cpp	(revision 12706)
@@ -38,9 +38,9 @@
 	/*If no mesh in input, generate one*/
 	if(bamgmesh_in->TrianglesSize[0]==0){
-		/*Mesh generation {{{1*/
+		/*Mesh generation {{{*/
 
 		//Step1: generate geometry Gh
-		if (verbosity>0) printf("Construction of a mesh from a given geometry\n");
-		if (verbosity>1) printf("   Processing geometry...\n");
+		if (verbosity>0) _printLine_("Construction of a mesh from a given geometry");
+		if (verbosity>1) _printLine_("   Processing geometry...");
 		Geometry Gh(bamggeom_in,bamgopts);
 
@@ -50,5 +50,5 @@
 
 		//build metric using geometry
-		if (verbosity>1) printf("   Generating Metric...\n");
+		if (verbosity>1) _printLine_("   Generating Metric...");
 		for(i=0;i<Gh.nbv;i++){
 			Metric M=Gh[i];
@@ -60,5 +60,5 @@
 
 		//generate mesh
-		if (verbosity>1) printf("   Generating Mesh...\n");
+		if (verbosity>1) _printLine_("   Generating Mesh...");
 		Mesh Th(maxnbv,Gh,bamgopts);
 
@@ -73,7 +73,7 @@
 
 		//Build output
-		if (verbosity>1) printf("   Write Mesh...\n");
+		if (verbosity>1) _printLine_("   Write Mesh...");
 		Th.WriteMesh(bamgmesh_out,bamgopts);
-		if (verbosity>1) printf("   Write Geometry...\n");
+		if (verbosity>1) _printLine_("   Write Geometry...");
 		Gh.WriteGeometry(bamggeom_out,bamgopts);
 
@@ -84,9 +84,9 @@
 	}
 	else{
-		/*Anisotropic mesh adaptation {{{1*/
+		/*Anisotropic mesh adaptation {{{*/
 
 		// read background mesh 
-		if (verbosity>0) printf("Anisotropic mesh adaptation\n");
-		if (verbosity>1) printf("   Processing initial mesh and geometry...\n");
+		if (verbosity>0) _printLine_("Anisotropic mesh adaptation");
+		if (verbosity>1) _printLine_("   Processing initial mesh and geometry...");
 		Mesh BTh(bamggeom_in,bamgmesh_in,bamgopts); 
 
@@ -100,9 +100,9 @@
 		//Generate initial metric
 		if (bamgopts->metric){
-			if (verbosity>1) printf("   Processing Metric...\n");
+			if (verbosity>1) _printLine_("   Processing Metric...");
 			BTh.ReadMetric(bamgopts);
 		}
 		else { 
-			if (verbosity>1) printf("   Generating initial Metric...\n");
+			if (verbosity>1) _printLine_("   Generating initial Metric...");
 			Metric Mhmax(bamgopts->hmax);
 			for (int iv=0;iv<BTh.nbv;iv++) BTh[iv].m = Mhmax;
@@ -111,5 +111,5 @@
 		//use present fields to generate metric if present
 		if (bamgopts->field){
-			if (verbosity>1) printf("   Merge metric with field provided...\n");
+			if (verbosity>1) _printLine_("   Merge metric with field provided...");
 			BTh.AddMetric(bamgopts);
 		}
@@ -117,7 +117,7 @@
 		// change using hVertices if provided
 		if(bamgopts->hVertices && bamgopts->hVerticesSize[0]==BTh.nbv){
-			if (verbosity>1) printf("   Merging Metric with hVertices...\n");
+			if (verbosity>1) _printLine_("   Merging Metric with hVertices...");
 			for (i=0;i<BTh.nbv;i++){
-				if (!isnan(bamgopts->hVertices[i])){
+				if (!xIsNan<IssmDouble>(bamgopts->hVertices[i])){
 					BTh[i].m=Metric((float)bamgopts->hVertices[i]);
 				}
@@ -127,7 +127,7 @@
 		// change using hminVertices if provided
 		if (bamgopts->hminVertices){
-			if (verbosity>1) printf("   Merging Metric with hminVertices...\n");
+			if (verbosity>1) _printLine_("   Merging Metric with hminVertices...");
 			for (i=0;i<BTh.nbv;i++){
-				if (!isnan(bamgopts->hminVertices[i])){
+				if (!xIsNan<IssmDouble>(bamgopts->hminVertices[i])){
 					Metric M=BTh.vertices[i].m;
 					EigenMetric Vp(M/coef);
@@ -140,7 +140,7 @@
 		// change using hmaxVertices if provided
 		if (bamgopts->hmaxVertices){
-			if (verbosity>1) printf("   Merging Metric with hmaxVertices...\n");
+			if (verbosity>1) _printLine_("   Merging Metric with hmaxVertices...");
 			for (i=0;i<BTh.nbv;i++){
-				if (!isnan(bamgopts->hmaxVertices[i])){
+				if (!xIsNan<IssmDouble>(bamgopts->hmaxVertices[i])){
 					Metric M=BTh.vertices[i].m;
 					EigenMetric Vp(M/coef);
@@ -164,5 +164,5 @@
 
 		//Build new mesh
-		if (verbosity>1) printf("   Generating Mesh...\n");
+		if (verbosity>1) _printLine_("   Generating Mesh...");
 		Thr=&BTh,Thb=0;
 		Mesh & Th( *(0 ?  new Mesh(*Thr,&Thr->Gh,Thb,maxnbv) :  new Mesh(maxnbv,BTh,bamgopts,bamgopts->KeepVertices)));
@@ -185,17 +185,17 @@
 		if(verbosity>0) {
 			if (Th.nbt-Th.nbtout-Th.nbq*2){
-				printf("   new number of triangles = %i\n",(Th.nbt-Th.nbtout-Th.nbq*2));
+				_printLine_("   new number of triangles = " << (Th.nbt-Th.nbtout-Th.nbq*2));
 			}
 			if (Th.nbq ){
-				printf("   new number of quads = %i\n",Th.nbq);
+				_printLine_("   new number of quads = " << Th.nbq);
 			}
 		}
 
 		//Build output
-		if (verbosity>1) printf("   Write Mesh...\n");
+		if (verbosity>1) _printLine_("   Write Mesh...");
 		Th.WriteMesh(bamgmesh_out,bamgopts);
-		if (verbosity>1) printf("   Write Geometry...\n");
+		if (verbosity>1) _printLine_("   Write Geometry...");
 		Th.Gh.WriteGeometry(bamggeom_out,bamgopts);
-		if (verbosity>1) printf("   Write Metric...\n");
+		if (verbosity>1) _printLine_("   Write Metric...");
 		BTh.WriteMetric(bamgopts);
 
@@ -207,5 +207,5 @@
 
 	/*No error return*/
-	if (verbosity>1) printf("   Exiting Bamg.\n");
+	if (verbosity>1) _printLine_("   Exiting Bamg.");
 	return noerr;
 
Index: /issm/trunk/src/c/modules/Chacox/Chacox.cpp
===================================================================
--- /issm/trunk/src/c/modules/Chacox/Chacox.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Chacox/Chacox.cpp	(revision 12706)
@@ -66,10 +66,10 @@
 
 	if (DEBUG_TRACE > 0) {
-		printf("<Entering main>\n");
+		_printLine_("<Entering main>");
 	}
 
 	if (PRINT_HEADERS) {
-		printf("\n                    Chaco 2.0\n");
-		printf("          Sandia National Laboratories\n\n");
+		_printLine_("\n                    Chaco 2.0");
+		_printLine_("          Sandia National Laboratories\n");
 	}
 
@@ -177,5 +177,5 @@
 
 	if (DEBUG_MEMORY > 0) {
-		printf("\n");
+		_printLine_("");
 		smalloc_stats();
 	}
@@ -185,5 +185,5 @@
 
 	if (DEBUG_TRACE > 1) {
-		printf("<Leaving main>\n");
+		_printLine_("<Leaving main>");
 	}
 	
Index: /issm/trunk/src/c/modules/Chacox/input_parse.cpp
===================================================================
--- /issm/trunk/src/c/modules/Chacox/input_parse.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Chacox/input_parse.cpp	(revision 12706)
@@ -38,13 +38,13 @@
 
 	if (DEBUG_TRACE > 0) {
-		printf("<Entering input_parse>\n");
+		_printLine_("<Entering input_parse>");
 	}
 
 	if (PROMPT) {
-		printf("Parallel machine architecture:\n");
-		printf("  (0) Hypercube\n");
-		printf("  (1) One-dimensional mesh\n");
-		printf("  (2) Two-dimensional mesh\n");
-		printf("  (3) Three-dimensional mesh\n");
+		_printLine_("Parallel machine architecture:");
+		_printLine_("  (0) Hypercube");
+		_printLine_("  (1) One-dimensional mesh");
+		_printLine_("  (2) Two-dimensional mesh");
+		_printLine_("  (3) Three-dimensional mesh");
 	}
 	*architecture = (int)options[OPT_ARCH];
@@ -57,10 +57,10 @@
 	/* Name output assignment file. */
 	if (PROMPT)
-		printf("Assignment output file: ");
+		_printString_("Assignment output file: ");
 	outassignname = NULL;
 
 	/* Name output results file. */
 	if (PROMPT)
-		printf("File name for saving run results: ");
+		_printString_("File name for saving run results: ");
 	outfilename = NULL;
 
@@ -75,12 +75,12 @@
 	else {
 		if (PROMPT) {
-			printf("Global partitioning method:\n");
-			printf("  (1) Multilevel-KL\n");
-			printf("  (2) Spectral\n");
-			printf("  (3) Inertial\n");
-			printf("  (4) Linear\n");
-			printf("  (5) Random\n");
-			printf("  (6) Scattered\n");
-			printf("  (7) Read-from-file\n");
+			_printLine_("Global partitioning method:");
+			_printLine_("  (1) Multilevel-KL");
+			_printLine_("  (2) Spectral");
+			_printLine_("  (3) Inertial");
+			_printLine_("  (4) Linear");
+			_printLine_("  (5) Random");
+			_printLine_("  (6) Scattered");
+			_printLine_("  (7) Read-from-file");
 		}
 		*global_method = (int)options[OPT_GLOBAL];
@@ -94,17 +94,17 @@
 	if (*global_method == 7) {	/* Name and open input assignment file. */
 		if (PROMPT)
-			printf("Assignment input file: ");
+			_printString_("Assignment input file: ");
 	}
 
 	else if (*global_method == 3) {
 		if (PROMPT)
-			printf("Geometry input file name: ");
+			_printString_("Geometry input file name: ");
 	}
 
 	else if (*global_method == 2) {
 		if (PROMPT) {
-			printf("Eigensolver:\n");
-			printf("  (1) Multilevel RQI/Symmlq\n");
-			printf("  (2) Lanczos\n"); 
+			_printLine_("Eigensolver:");
+			_printLine_("  (1) Multilevel RQI/Symmlq");
+			_printLine_("  (2) Lanczos"); 
 		}
 		eigensolver = (int)options[OPT_RQI];
@@ -117,9 +117,9 @@
 			if (MATCH_TYPE == 5) {	/* geometric matching */
 				if (PROMPT)
-					printf("Geometry input file name: ");
+					_printString_("Geometry input file name: ");
 			}
 			*rqi_flag = 1;
 			if (PROMPT)
-				printf("Number of vertices to coarsen down to: ");
+				_printString_("Number of vertices to coarsen down to: ");
 			*vmax = (int)options[OPT_VMAX];
 			if (*vmax <= 0) {
@@ -137,8 +137,8 @@
 		if (MATCH_TYPE == 5) {		/* geometric matching */
 			if (PROMPT)
-				printf("Geometry input file name: ");
-		}
-		if (PROMPT)
-			printf("Number of vertices to coarsen down to: ");
+				_printString_("Geometry input file name: ");
+		}
+		if (PROMPT)
+			_printString_("Number of vertices to coarsen down to: ");
 		*vmax = (int)options[OPT_VMAX];
 		if (*vmax <= 0) {
@@ -168,7 +168,7 @@
 	else {
 		if (PROMPT) {
-			printf("Local refinement method:\n");
-			printf("  (1) Kernighan-Lin\n");
-			printf("  (2) None\n");
+			_printLine_("Local refinement method:");
+			_printLine_("  (1) Kernighan-Lin");
+			_printLine_("  (2) None");
 		}
 		*local_method = (int)options[OPT_LOCAL];
@@ -185,8 +185,8 @@
 		*ndims_tot = 0;
 		if (PROMPT)
-			printf("Total number of target hypercube dimensions: ");
+			_printString_("Total number of target hypercube dimensions: ");
 		*ndims_tot = nparts[0];
 		if (*ndims_tot < 1) {
-			printf(" Number of divisions must be at least 1\n");
+			_printLine_(" Number of divisions must be at least 1");
 			printf("%s -- Number of divisions %d must be at least 1.\n",
 				   __FUNCT__,nparts[0]);
@@ -200,5 +200,5 @@
 		if (*architecture == 2) {
 			if (PROMPT)
-				printf("X and Y extent of of 2-D mesh: ");
+				_printString_("X and Y extent of of 2-D mesh: ");
 			mesh_dims[0] = nparts[0];
 			mesh_dims[1] = nparts[1];
@@ -206,5 +206,5 @@
 		else if (*architecture == 3) {
 			if (PROMPT)
-				printf("X, Y and Z extent of 3-D mesh: ");
+				_printString_("X, Y and Z extent of 3-D mesh: ");
 			mesh_dims[0] = nparts[0];
 			mesh_dims[1] = nparts[1];
@@ -213,5 +213,5 @@
 		else {			/* Anything else => 1-D mesh */
 			if (PROMPT)
-				printf("Size of 1-D mesh: ");
+				_printString_("Size of 1-D mesh: ");
 			mesh_dims[0] = nparts[0];
 			*architecture = 1;
@@ -227,7 +227,7 @@
 	else if (*nprocs <= 7) {
 		if (PROMPT) {
-			printf("Partitioning dimension: \n");
-			printf("  (1) Bisection\n");
-			printf("  (2) Quadrisection\n");
+			_printLine_("Partitioning dimension: ");
+			_printLine_("  (1) Bisection");
+			_printLine_("  (2) Quadrisection");
 		}
 		*ndims = (int)options[OPT_NDIMS];
@@ -240,8 +240,8 @@
 	else {
 		if (PROMPT) {
-			printf("Partitioning dimension: \n");
-			printf("  (1) Bisection\n");
-			printf("  (2) Quadrisection\n");
-			printf("  (3) Octasection\n");
+			_printLine_("Partitioning dimension: ");
+			_printLine_("  (1) Bisection");
+			_printLine_("  (2) Quadrisection");
+			_printLine_("  (3) Octasection");
 		}
 		*ndims = (int)options[OPT_NDIMS];
Index: /issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 	int i;
 	int      found=0;
-	double   numberofelements;
+	IssmDouble   numberofelements;
 	Element* element=NULL;
 
@@ -25,5 +25,5 @@
 
 	/*Allocate sigma on numberofelements: */
-	sigma=new Vector((int)numberofelements);
+	sigma=new Vector(reCast<int>(numberofelements));
 
 	/*Compute basal stress for each element: */
Index: /issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp	(revision 12706)
@@ -25,10 +25,10 @@
 	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
 	
-	_printf_(VerboseMProcessor(),"      Configuring elements...\n");
+	if(VerboseMProcessor()) _pprintLine_("      Configuring elements...");
 	for (i=0;i<elements->Size();i++){
 		element=(Element*)elements->GetObjectByOffset(i);
 		element->Configure(elements,loads,nodes,materials,parameters);
 	}
-	_printf_(VerboseMProcessor(),"      Configuring loads...\n");
+	if(VerboseMProcessor()) _pprintLine_("      Configuring loads...");
 	for (i=0;i<loads->Size();i++){
 		load=(Load*)loads->GetObjectByOffset(i);
@@ -37,5 +37,5 @@
 		}
 	}
-	_printf_(VerboseMProcessor(),"      Configuring nodes...\n");
+	if(VerboseMProcessor()) _pprintLine_("      Configuring nodes...");
 	for (i=0;i<nodes->Size();i++){
 		node=(Node*)nodes->GetObjectByOffset(i);
@@ -45,5 +45,5 @@
 	}
 	
-	_printf_(VerboseMProcessor(),"      Configuring materials...\n");
+	if(VerboseMProcessor()) _pprintLine_("      Configuring materials...");
 	for (i=0;i<materials->Size();i++){
 		material=(Material*)materials->GetObjectByOffset(i);
Index: /issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp
===================================================================
--- /issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp	(revision 12706)
@@ -25,5 +25,5 @@
 
 	/*Display message*/
-	_printf_(VerboseModule(),"   Constraining penalties\n");
+	if(VerboseModule()) _pprintLine_("   Constraining penalties");
 
 	/*recover parameters: */
Index: /issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp
===================================================================
--- /issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	(revision 12706)
@@ -12,5 +12,5 @@
 
 /*current module: */
-/*RiftIsPresent(Loads* loads,int configuration_type){{{1*/
+/*RiftIsPresent(Loads* loads,int configuration_type){{{*/
 int RiftIsPresent(Loads* loads,int configuration_type){
 
@@ -41,5 +41,5 @@
 }
 /*}}}*/
-/*RiftConstraintsState(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int configuration_type){{{1*/
+/*RiftConstraintsState(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int configuration_type){{{*/
 void RiftConstraintsState(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int configuration_type){
 
@@ -56,5 +56,5 @@
 	}
 	else if(num_unstable_constraints<=min_mechanical_constraints){
-		_printf_(VerboseModule(),"   freezing constraints\n");
+		if(VerboseModule()) _pprintLine_("   freezing constraints");
 		RiftFreezeConstraints(loads,configuration_type);
 	}
@@ -65,5 +65,5 @@
 }
 /*}}}*/
-/*RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int configuration_type){{{1*/
+/*RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int configuration_type){{{*/
 void RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int configuration_type){
 
@@ -106,5 +106,5 @@
 }
 /*}}}*/
-/*RiftIsFrozen(Loads* loads,int configuration_type){{{1*/
+/*RiftIsFrozen(Loads* loads,int configuration_type){{{*/
 int RiftIsFrozen(Loads* loads,int configuration_type){
 
@@ -144,5 +144,5 @@
 }
 /*}}}*/
-/*RiftFreezeConstraints(Loads* loads,int configuration_type){{{1*/
+/*RiftFreezeConstraints(Loads* loads,int configuration_type){{{*/
 void RiftFreezeConstraints(Loads* loads,int configuration_type){
 
@@ -172,5 +172,5 @@
 
 /*diverse trials and errors: */
-/*RiftIsMaterialStable(Loads* loads){{{1*/
+/*RiftIsMaterialStable(Loads* loads){{{*/
 int RiftIsMaterialStable(Loads* loads){
 
@@ -204,5 +204,5 @@
 }
 /*}}}*/
-/*RiftIsPreStable(Loads* loads){{{1*/
+/*RiftIsPreStable(Loads* loads){{{*/
 int RiftIsPreStable(Loads* loads){
 
@@ -243,5 +243,5 @@
 }
 /*}}}*/
-/*RiftSetPreStable(Loads* loads){{{1*/
+/*RiftSetPreStable(Loads* loads){{{*/
 void RiftSetPreStable(Loads* loads){
 
@@ -264,5 +264,5 @@
 }
 /*}}}*/
-/*RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){{{1*/
+/*RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){{{*/
 void RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){
 
@@ -300,5 +300,5 @@
 }
 /*}}}*/
-/*RiftMaxPenetrationInInputs(Loads* loads){{{1*/
+/*RiftMaxPenetrationInInputs(Loads* loads){{{*/
 void RiftMaxPenetrationInInputs(Loads* loads){
 
@@ -309,7 +309,7 @@
 
 	/*rift penetration: */
-	double max_penetration=0;
-	double mpi_max_penetration;
-	double penetration;
+	IssmDouble max_penetration=0;
+	IssmDouble mpi_max_penetration;
+	IssmDouble penetration;
 
 	/*Ok, we are going to find the node pairs which are not penetrating, even though they 
@@ -342,5 +342,5 @@
 }
 /*}}}*/
-/*RiftPotentialUnstableConstraints(Loads* loads){{{1*/
+/*RiftPotentialUnstableConstraints(Loads* loads){{{*/
 int RiftPotentialUnstableConstraints(Loads* loads){
 
Index: /issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	(revision 12706)
@@ -70,5 +70,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&in_nod_serial);
+	xDelete<double>(in_nod_serial);
 
 	return noerr;
Index: /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp	(revision 12706)
@@ -33,5 +33,5 @@
 
 	/*Clean up and return*/
-	xfree((void**)&control_type);
+	xDelete<int>(control_type);
 	*pgradient=gradient;
 }
Index: /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp	(revision 12706)
@@ -37,5 +37,5 @@
 
 	/*Clean up and return*/
-	xfree((void**)&control_type);
-	xfree((void**)&scalar_list);
+	xDelete<int>(control_type);
+	xDelete<double>(scalar_list);
 }
Index: /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp	(revision 12706)
@@ -27,5 +27,5 @@
 
 	/*Clean up and return*/
-	xfree((void**)&control_type);
+	xDelete<int>(control_type);
 
 }
@@ -39,4 +39,4 @@
 
 	/*Clean up and return*/
-	xfree((void**)&serial_gradient);
+	xDelete<double>(serial_gradient);
 }
Index: /issm/trunk/src/c/modules/CostFunctionx/CostFunctionx.cpp
===================================================================
--- /issm/trunk/src/c/modules/CostFunctionx/CostFunctionx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/CostFunctionx/CostFunctionx.cpp	(revision 12706)
@@ -35,5 +35,5 @@
 
 	/*Assign output pointers: */
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 	*pJ=J;
 }
Index: /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp
===================================================================
--- /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp	(revision 12706)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax){
+void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,IssmDouble kmax){
 	
 	int      i,connectivity;
Index: /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h
===================================================================
--- /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax);
+void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,IssmDouble kmax);
 
 #endif  /* _CREATEJACOBIANMATRIXX_H */
Index: /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp	(revision 12706)
@@ -30,8 +30,7 @@
 	double femmodel_response;
 	int    flag;
-	double* vertex_response=NULL;
-	double* qmu_response=NULL;
-
-	double* responses_pointer=NULL;
+	double *vertex_response   = NULL;
+	double *qmu_response      = NULL;
+	double *responses_pointer = NULL;
 
 	/*retrieve npart: */
@@ -66,6 +65,6 @@
 
 			/*Free ressources:*/
-			xfree((void**)&vertex_response);
-			xfree((void**)&qmu_response);
+			xDelete<double>(vertex_response);
+			xDelete<double>(qmu_response);
 
 		}
@@ -87,5 +86,5 @@
 		}
 		else if (flag==NodalEnum){
-			_error_(" nodal response functions not supported yet!");
+			_error2_("nodal response functions not supported yet!");
 
 			/*increment response_pointer :*/
@@ -105,5 +104,5 @@
 			}
 		}
-		else _error_("%s%i%s"," flag type ",flag," not supported yet for response analysis");
+		else _error2_("flag type " << flag << " not supported yet for response analysis");
 	}
 
@@ -111,8 +110,8 @@
 	/*Synthesize echo: {{{*/
 	if(my_rank==0){
-		printf("   responses: %i: ",d_numresponses);
-		for(i=0;i<d_numresponses-1;i++)printf("%g|",d_responses[i]);
-		printf("%g",d_responses[d_numresponses-1]);
-		printf("\n");
+		_printString_("   responses: " << d_numresponses << ": ");
+		for(i=0;i<d_numresponses-1;i++)_printString_(d_responses[i] << "|");
+		_printString_(d_responses[d_numresponses-1]);
+		_printLine_("");
 	}
 	/*}}}*/
Index: /issm/trunk/src/c/modules/Dakotax/DakotaFree.cpp
===================================================================
--- /issm/trunk/src/c/modules/Dakotax/DakotaFree.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Dakotax/DakotaFree.cpp	(revision 12706)
@@ -22,8 +22,8 @@
 	extern int my_rank;
 	
-	double* variables=NULL;
-	char**  variables_descriptors=NULL;
-	char**  responses_descriptors=NULL;
-	char*   string=NULL;
+	double  *variables             = NULL;
+	char   **variables_descriptors = NULL;
+	char   **responses_descriptors = NULL;
+	char    *string                = NULL;
 
 	/*recover pointers: */
@@ -35,10 +35,10 @@
 	/*Free variables and variables_descriptors only on cpu !=0*/
 	if(my_rank!=0){
-		xfree((void**)&variables);
+		xDelete<double>(variables);
 		for(i=0;i<numvariables;i++){
 			string=variables_descriptors[i];
-			xfree((void**)&string);
+			xDelete<char>(string);
 		}
-		xfree((void**)&variables_descriptors);
+		xDelete<char*>(variables_descriptors);
 	}
 	
@@ -46,8 +46,8 @@
 	for(i=0;i<numresponses;i++){
 		string=responses_descriptors[i];
-		xfree((void**)&string);
+		xDelete<char>(string);
 	}
 	//rest of dynamic allocations.
-	xfree((void**)&responses_descriptors);
+	xDelete<char*>(responses_descriptors);
 
 	/*Assign output pointers:*/
@@ -56,3 +56,2 @@
 	*presponses_descriptors=responses_descriptors;
 }
-
Index: /issm/trunk/src/c/modules/Dakotax/DakotaMPI_Bcast.cpp
===================================================================
--- /issm/trunk/src/c/modules/Dakotax/DakotaMPI_Bcast.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Dakotax/DakotaMPI_Bcast.cpp	(revision 12706)
@@ -38,10 +38,10 @@
 	
 	/*variables:*/
-	if(my_rank!=0)variables=(double*)xmalloc(numvariables*sizeof(double));
+	if(my_rank!=0)variables=xNew<double>(numvariables);
 	MPI_Bcast(variables,numvariables,MPI_DOUBLE,0,MPI_COMM_WORLD); 
 
 	/*variables_descriptors: */
 	if(my_rank!=0){
-		variables_descriptors=(char**)xmalloc(numvariables*sizeof(char*));
+		variables_descriptors=xNew<char*>(numvariables);
 	}
 	for(i=0;i<numvariables;i++){
@@ -51,5 +51,5 @@
 		}
 		MPI_Bcast(&string_length,1,MPI_INT,0,MPI_COMM_WORLD); 
-		if(my_rank!=0)string=(char*)xmalloc(string_length);
+		if(my_rank!=0)string=xNew<char>(string_length);
 		MPI_Bcast(string,string_length,MPI_CHAR,0,MPI_COMM_WORLD); 
 		if(my_rank!=0)variables_descriptors[i]=string;
Index: /issm/trunk/src/c/modules/Dakotax/Dakotax.cpp
===================================================================
--- /issm/trunk/src/c/modules/Dakotax/Dakotax.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Dakotax/Dakotax.cpp	(revision 12706)
@@ -121,7 +121,7 @@
 
 	/*Free ressources:*/
-	xfree((void**)&dakota_input_file);
-	xfree((void**)&dakota_error_file);
-	xfree((void**)&dakota_output_file);
+	xDelete<char>(dakota_input_file);
+	xDelete<char>(dakota_error_file);
+	xDelete<char>(dakota_output_file);
 
 	#endif //#ifdef _HAVE_DAKOTA_
Index: /issm/trunk/src/c/modules/Dakotax/DescriptorIndex.cpp
===================================================================
--- /issm/trunk/src/c/modules/Dakotax/DescriptorIndex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Dakotax/DescriptorIndex.cpp	(revision 12706)
@@ -23,10 +23,10 @@
 	/*retrieve first token, separated by underscore: */
 	pch = strtok (descriptor,"_");
-	if(!pch)_error_("%s%s%s"," descriptor ",descriptor," is not correctly formatted!");
+	if(!pch)_error2_("descriptor " << descriptor << " is not correctly formatted!");
 
 	if (strncmp(pch,"scaled",6)==0){
 		/*we have a scaled variable. recover the root: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," scaled descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("scaled descriptor " << descriptor << " is not correctly formatted!");
 		memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
 
@@ -44,9 +44,9 @@
 		/*we have an indexed variable. recover the root: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," indexed descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("indexed descriptor " << descriptor << " is not correctly formatted!");
 		memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
 		/*now recover  the index: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," indexed descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("indexed descriptor " << descriptor << " is not correctly formatted!");
 		sscanf(pch,"%i",pindex);
 		return IndexedEnum;
@@ -55,9 +55,9 @@
 		/*we have an indexed variable. recover the root: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," nodal descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("nodal descriptor " << descriptor << " is not correctly formatted!");
 		memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
 		/*now recover  the index: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," nodal descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("nodal descriptor " << descriptor << " is not correctly formatted!");
 		sscanf(pch,"%i",pindex);
 		return NodalEnum;
Index: /issm/trunk/src/c/modules/Dakotax/SpawnCoreParallel.cpp
===================================================================
--- /issm/trunk/src/c/modules/Dakotax/SpawnCoreParallel.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Dakotax/SpawnCoreParallel.cpp	(revision 12706)
@@ -53,5 +53,5 @@
 	/*synchronize all cpus, as CPU 0 is probably late (it is starting the entire dakota strategy!) : */
 	MPI_Barrier(MPI_COMM_WORLD);
-	_printf_(VerboseQmu(),"qmu iteration: %i\n",counter);
+	if(VerboseQmu()) _pprintLine_("qmu iteration: " << counter);
 	
 	/*retrieve parameters: */
@@ -67,10 +67,10 @@
 
 	/*Determine solution sequence: */
-	_printf_(VerboseQmu(),"%s%s%s\n","Starting ",EnumToStringx(solution_type)," core:");
+	if(VerboseQmu()) _pprintLine_("Starting " << EnumToStringx(solution_type) << " core:");
 	CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
 	#ifdef _HAVE_CONTROL_
 	if(control_analysis)solutioncore=&control_core;
 	#else
-	_error_("ISSM was not compiled with control capabilities, exiting!");
+	_error2_("ISSM was not compiled with control capabilities, exiting!");
 	#endif
 
@@ -79,5 +79,5 @@
 
 	/*compute responses: */
-	_printf_(VerboseQmu(),"compute dakota responses:\n");
+	if(VerboseQmu()) _pprintLine_("compute dakota responses:");
 	DakotaResponsesx(d_responses,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,responses_descriptors,numresponsedescriptors,d_numresponses);
 	
Index: /issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp	(revision 12706)
@@ -36,5 +36,5 @@
 	maxels=width-1;
 	/*Allocate connectivity: */
-	elementconnectivity=(double*)xcalloc(nel*3,sizeof(double));
+	elementconnectivity=xNewZeroInit<double>(nel*3);
 
 	/*Go through all elements, and for each element, go through its nodes, to get the neighbouring elements. 
Index: /issm/trunk/src/c/modules/ElementResponsex/ElementResponsex.cpp
===================================================================
--- /issm/trunk/src/c/modules/ElementResponsex/ElementResponsex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ElementResponsex/ElementResponsex.cpp	(revision 12706)
@@ -39,5 +39,5 @@
 	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
-	if(!sumfound)_error_("%s%i%s","could not find material with id",index," to compute ElementResponse");
+	if(!sumfound)_error2_("could not find material with id" << index << " to compute ElementResponse");
 	#endif
 
Index: /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp
===================================================================
--- /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp	(revision 12706)
@@ -154,8 +154,8 @@
 		case SettingsResultsAsPatchesEnum : return "SettingsResultsAsPatches";
 		case SettingsWaitonlockEnum : return "SettingsWaitonlock";
-		case DebugPetscProfilingEnum : return "DebugPetscProfiling";
-		case PetscProfilingCurrentMemEnum : return "PetscProfilingCurrentMem";
-		case PetscProfilingCurrentFlopsEnum : return "PetscProfilingCurrentFlops";
-		case PetscProfilingSolutionTimeEnum : return "PetscProfilingSolutionTime";
+		case DebugProfilingEnum : return "DebugProfiling";
+		case ProfilingCurrentMemEnum : return "ProfilingCurrentMem";
+		case ProfilingCurrentFlopsEnum : return "ProfilingCurrentFlops";
+		case ProfilingSolutionTimeEnum : return "ProfilingSolutionTime";
 		case MaxIterationConvergenceFlagEnum : return "MaxIterationConvergenceFlag";
 		case SteadystateMaxiterEnum : return "SteadystateMaxiter";
@@ -167,5 +167,13 @@
 		case SurfaceforcingsMassBalanceEnum : return "SurfaceforcingsMassBalance";
 		case SurfaceforcingsIspddEnum : return "SurfaceforcingsIspdd";
+		case SurfaceforcingsIssmbgradientsEnum : return "SurfaceforcingsIssmbgradients";
 		case SurfaceforcingsMonthlytemperaturesEnum : return "SurfaceforcingsMonthlytemperatures";
+		case SurfaceforcingsHcEnum : return "SurfaceforcingsHc";
+		case SurfaceforcingsSmbPosMaxEnum : return "SurfaceforcingsSmbPosMax";
+		case SurfaceforcingsSmbPosMinEnum : return "SurfaceforcingsSmbPosMin";
+		case SurfaceforcingsAPosEnum : return "SurfaceforcingsAPos";
+		case SurfaceforcingsBPosEnum : return "SurfaceforcingsBPos";
+		case SurfaceforcingsANegEnum : return "SurfaceforcingsANeg";
+		case SurfaceforcingsBNegEnum : return "SurfaceforcingsBNeg";
 		case ThermalMaxiterEnum : return "ThermalMaxiter";
 		case ThermalPenaltyFactorEnum : return "ThermalPenaltyFactor";
@@ -466,5 +474,5 @@
 
 	len=strlen(EnumToStringx(enum_in));
-	string=(char*)xmalloc((len+1)*sizeof(char));
+	string=xNew<char>(len+1);
 	memcpy(string,EnumToStringx(enum_in),(len+1)*sizeof(char));
 
Index: /issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp	(revision 12706)
@@ -11,29 +11,22 @@
 #include "../modules.h"
 
-int Exp2Kmlx(char* filexp,char* filkml,
-			 int sgn,
-			 bool holes){
+int Exp2Kmlx(char* filexp,char* filkml,int sgn,bool holes){
 
 	double  cm,sp;
 
 	Xy2lldef(&cm,&sp,sgn);
-
-	return(Exp2Kmlx(filexp,filkml,
-					sgn,cm,sp,
-					holes));
+	return(Exp2Kmlx(filexp,filkml,sgn,cm,sp,holes));
 }
 
-int Exp2Kmlx(char* filexp,char* filkml,
-			 int sgn,double cm,double sp,
-			 bool holes){
-
-	int     i,j,iret=0;
-	int     lwidth=1;
-	double  popac=0.50;
-	int     nprof;
-	int     *pnvert=NULL;
-	double  **pprofx=NULL,**pprofy=NULL;
-	bool    *closed=NULL;
-	double  *lat=NULL,*lon=NULL;
+int Exp2Kmlx(char* filexp,char* filkml,int sgn,double cm,double sp,bool holes){
+
+	int      i        ,j,iret=0;
+	int      lwidth = 1;
+	double   popac  = 0.50;
+	int      nprof;
+	int     *pnvert = NULL;
+	double **pprofx = NULL,**pprofy=NULL;
+	bool    *closed = NULL;
+	double  *lat    = NULL, *lon=NULL;
 
 	char    indent[81]="";
@@ -57,13 +50,13 @@
 	clock0=clock();
 	time0 =time(NULL);
-	_printf_(true,"\nExp2Kmlx Module -- %s",ctime(&time0));
-
-/*  read exp file  */
+	_pprintString_("\nExp2Kmlx Module -- " << ctime(&time0));
+
+	/*read exp file  */
 
 	if (!DomainOutlineRead(&nprof,&pnvert,&pprofx,&pprofy,&closed,filexp))
-		_error_("Error reading exp file.");
-	_printf_(true,"Exp2Kmlx -- Reading %d exp profiles from file \"%s\".\n",nprof,filexp);
+		_error2_("Error reading exp file.");
+	_pprintLine_("Exp2Kmlx -- Reading " << nprof << " exp profiles from file \"" << filexp << "\".");
 //	for (i=0; i<nprof; i++)
-//		printf("i=%d; nvert=%d, closed=%d\n",i,pnvert[i],closed[i]);
+//		_printLine_("i=" << i << "; nvert=" << pnvert[i] << ", closed=" << closed[i]);
 
 /*  construct kml file  */
@@ -128,5 +121,5 @@
 
 	if (holes && nprof && (pnvert[0] <= 1 || pprofx[0][pnvert[0]-1] != pprofx[0][0] || pprofy[0][pnvert[0]-1] != pprofy[0][0])) {
-		_printf_(true,"Warning -- Outer profile is not closed, so \"holes\" option will be ignored.\n");
+		_pprintLine_("Warning -- Outer profile is not closed, so \"holes\" option will be ignored.");
 		holes=false;
 	}
@@ -143,15 +136,15 @@
 
 		kring->ncoord    =pnvert[i]-1;
-		lat=(double *) xmalloc(kring->ncoord*sizeof(double));
-		lon=(double *) xmalloc(kring->ncoord*sizeof(double));
+		lat=xNew<double>(kring->ncoord);
+		lon=xNew<double>(kring->ncoord);
 		Xy2llx(lat,lon,pprofx[i],pprofy[i],kring->ncoord,sgn,cm,sp);
-		kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
+		kring->coords=xNew<double>(kring->ncoord*3);
 		for (j=0; j<kring->ncoord; j++) {
-			kring->coords[j][0]=lon[j];
-			kring->coords[j][1]=lat[j];
-			kring->coords[j][2]=0.;
+			kring->coords[3*j+0]=lon[j];
+			kring->coords[3*j+1]=lat[j];
+			kring->coords[3*j+2]=0.;
 		}
-		xfree((void**)&lon);
-		xfree((void**)&lat);
+		xDelete<double>(lon);
+		xDelete<double>(lat);
 
 		(kpoly ->outer     )->AddObject((Object*)kring);
@@ -160,5 +153,5 @@
 		for (i=1; i<nprof; i++) {
 			if (pnvert[i] <= 1 || pprofx[i][pnvert[i]-1] != pprofx[i][0] || pprofy[i][pnvert[i]-1] != pprofy[i][0]) {
-				_printf_(true,"Warning -- Inner profile %d is not closed with \"holes\" specified, so it will be ignored.\n",i+1);
+				_pprintLine_("Warning -- Inner profile " << i+1 << " is not closed with \"holes\" specified, so it will be ignored.");
 				continue;
 			}
@@ -167,15 +160,15 @@
 
 			kring->ncoord    =pnvert[i]-1;
-			lat=(double *) xmalloc(kring->ncoord*sizeof(double));
-			lon=(double *) xmalloc(kring->ncoord*sizeof(double));
+			lat=xNew<double>(kring->ncoord);
+			lon=xNew<double>(kring->ncoord);
 			Xy2llx(lat,lon,pprofx[i],pprofy[i],kring->ncoord,sgn,cm,sp);
-			kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
+			kring->coords    =xNew<double>(kring->ncoord*3);
 			for (j=0; j<kring->ncoord; j++) {
-				kring->coords[j][0]=lon[j];
-				kring->coords[j][1]=lat[j];
-				kring->coords[j][2]=0.;
-			}
-			xfree((void**)&lon);
-			xfree((void**)&lat);
+				kring->coords[3*j+0]=lon[j];
+				kring->coords[3*j+1]=lat[j];
+				kring->coords[3*j+2]=0.;
+			}
+			xDelete<double>(lon);
+			xDelete<double>(lat);
 
 			(kpoly ->inner     )->AddObject((Object*)kring);
@@ -204,15 +197,15 @@
 
 				kring->ncoord    =pnvert[i]-1;
-				lat=(double *) xmalloc(kring->ncoord*sizeof(double));
-				lon=(double *) xmalloc(kring->ncoord*sizeof(double));
+				lat=xNew<double>(kring->ncoord);
+				lon=xNew<double>(kring->ncoord);
 				Xy2llx(lat,lon,pprofx[i],pprofy[i],kring->ncoord,sgn,cm,sp);
-				kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
+				kring->coords    =xNew<double>(kring->ncoord*3);
 				for (j=0; j<kring->ncoord; j++) {
-					kring->coords[j][0]=lon[j];
-					kring->coords[j][1]=lat[j];
-					kring->coords[j][2]=0.;
+					kring->coords[3*j+0]=lon[j];
+					kring->coords[3*j+1]=lat[j];
+					kring->coords[3*j+2]=0.;
 				}
-				xfree((void**)&lon);
-				xfree((void**)&lat);
+				xDelete<double>(lon);
+				xDelete<double>(lat);
 
 				(kpoly ->outer     )->AddObject((Object*)kring);
@@ -231,15 +224,15 @@
 
 				kline->ncoord    =pnvert[i];
-				lat=(double *) xmalloc(kline->ncoord*sizeof(double));
-				lon=(double *) xmalloc(kline->ncoord*sizeof(double));
+				lat=xNew<double>(kline->ncoord);
+				lon=xNew<double>(kline->ncoord);
 				Xy2llx(lat,lon,pprofx[i],pprofy[i],kline->ncoord,sgn,cm,sp);
-				kline->coords    =(double (*)[3]) xmalloc(kline->ncoord*3*sizeof(double));
+				kline->coords    =xNew<double>(kline->ncoord*3);
 				for (j=0; j<kline->ncoord; j++) {
-					kline->coords[j][0]=lon[j];
-					kline->coords[j][1]=lat[j];
-					kline->coords[j][2]=0.;
+					kline->coords[3*j+0]=lon[j];
+					kline->coords[3*j+1]=lat[j];
+					kline->coords[3*j+2]=0.;
 				}
-				xfree((void**)&lon);
-				xfree((void**)&lat);
+				xDelete<double>(lon);
+				xDelete<double>(lat);
 
 				(kplace->geometry  )->AddObject((Object*)kline);
@@ -251,15 +244,16 @@
 				kplace->visibility=true;
 				sprintf(kplace->styleurl  ,"#RandomLineEmptyPoly");
+				int one=1;
 
 				kpoint=new KML_Point();
 
-				lat=(double *) xmalloc(sizeof(double));
-				lon=(double *) xmalloc(sizeof(double));
+				lat=xNew<double>(one);
+				lon=xNew<double>(one);
 				Xy2llx(lat,lon,pprofx[i],pprofy[i],1,sgn,cm,sp);
 				kpoint->coords[0]=lon[0];
 				kpoint->coords[1]=lat[0];
 				kpoint->coords[2]=0.;
-				xfree((void**)&lon);
-				xfree((void**)&lat);
+				xDelete<double>(lon);
+				xDelete<double>(lat);
 
 				(kplace->geometry  )->AddObject((Object*)kpoint);
@@ -281,5 +275,5 @@
 /*  write kml file  */
 
-	_printf_(true,"Exp2Kmlx -- Writing kml document to file \"%s\".\n",filkml);
+	_pprintLine_("Exp2Kmlx -- Writing kml document to file \"" << filkml << "\".");
 	fid=fopen(filkml,"w");
 	fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
@@ -289,8 +283,8 @@
 	delete kfile;
 	for (i=nprof-1; i>=0; i--) {
-		xfree((void**)&(pprofy[i]));
-		xfree((void**)&(pprofx[i]));
-	}
-	xfree((void**)&pnvert);
+		xDelete<double>(pprofy[i]);
+		xDelete<double>(pprofx[i]);
+	}
+	xDelete<int>(pnvert);
 
 	clock1=clock();
Index: /issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp	(revision 12706)
@@ -26,5 +26,5 @@
 	/*Get size of vector: */
 	gsize=nodes->NumberOfDofs(configuration_type,GsetEnum);
-	if (gsize==0) _error_("Allocating a Vec of size 0 as gsize=0 for configuration: %s",EnumToStringx(configuration_type));
+	if (gsize==0) _error2_("Allocating a Vec of size 0 as gsize=0 for configuration: " << EnumToStringx(configuration_type));
 	
 	/*Initialize solution: */
Index: /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp	(revision 12706)
@@ -32,5 +32,5 @@
 
 	/*Assign output pointers:*/
-	xfree((void**)&control_type);
+	xDelete<int>(control_type);
 	*pvector=vector;
 }
Index: /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	(revision 12706)
@@ -32,5 +32,5 @@
 	}
 	else{
-		_error_("%s%s%s"," vector type: ",EnumToStringx(type)," not supported yet!");
+		_error2_("vector type: " << EnumToStringx(type) << " not supported yet!");
 	}
 
@@ -41,8 +41,8 @@
 }
 
-void GetVectorFromInputsx( double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){
+void GetVectorFromInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){
 	
 	/*output: */
-	double* vector=NULL;
+	IssmDouble* vector=NULL;
 	
 	/*intermediary: */
Index: /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h
===================================================================
--- /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h	(revision 12706)
@@ -10,5 +10,5 @@
 /* local prototypes: */
 void	GetVectorFromInputsx( Vector** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
-void	GetVectorFromInputsx( double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
+void	GetVectorFromInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
 
 #endif  /* _GETVECTORFROMINPUTSXX_H */
Index: /issm/trunk/src/c/modules/Gradjx/Gradjx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Gradjx/Gradjx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Gradjx/Gradjx.cpp	(revision 12706)
@@ -14,9 +14,9 @@
 	int     i,j,numberofvertices;
 	int     num_controls;
-	double  norm_inf;
-	double *norm_list       = NULL;
-	int    *control_type    = NULL;
-	Vector*     gradient        = NULL;
-	Vector*    *gradient_list   = NULL;
+	double   norm_inf;
+	double  *norm_list     = NULL;
+	int     *control_type  = NULL;
+	Vector  *gradient      = NULL;
+	Vector **gradient_list = NULL;
 	
 	/*retrieve some parameters: */
@@ -26,6 +26,6 @@
 
 	/*Allocate gradient_list */
-	gradient_list = (Vector**)xmalloc(num_controls*sizeof(Vector*));
-	norm_list = (double*)xmalloc(num_controls*sizeof(double));
+	gradient_list = xNew<Vector*>(num_controls);
+	norm_list = xNew<double>(num_controls);
 	for(i=0;i<num_controls;i++){
 		gradient_list[i]=new Vector(num_controls*numberofvertices);
@@ -54,6 +54,6 @@
 	/*Check that gradient is clean*/
 	norm_inf=gradient->Norm(NORM_INF);
-	if(norm_inf<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm is zero");
-	if(isnan(norm_inf))_error_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
+	if(norm_inf<=0)    _error2_("||∂J/∂α||∞ = 0    gradient norm is zero");
+	if(xIsNan<IssmDouble>(norm_inf))_error2_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
 
 	/*Clean-up and assign output pointer*/
@@ -62,8 +62,8 @@
 	}
 	else{
-		xfree((void**)&norm_list);
+		xDelete<double>(norm_list);
 	}
 	if(pgradient)  *pgradient=gradient;
-	xfree((void**)&gradient_list);
-	xfree((void**)&control_type);
+	xDelete<Vector*>(gradient_list);
+	xDelete<int>(control_type);
 }
Index: /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 12706)
@@ -20,5 +20,5 @@
 	Element* element                          = NULL;
 	
-	_printf_(VerboseModule(),"   Migrating grounding line\n");
+	if(VerboseModule()) _pprintLine_("   Migrating grounding line");
 	
 	/*retrieve parameters: */
@@ -27,5 +27,5 @@
 
 	if(migration_style==NoneEnum) return;
-	if(migration_style!=AgressiveMigrationEnum && migration_style!=SoftMigrationEnum) _error_("%s not supported yet!",EnumToStringx(migration_style));
+	if(migration_style!=AgressiveMigrationEnum && migration_style!=SoftMigrationEnum) _error2_(EnumToStringx(migration_style) << " not supported yet!");
 
 	if(migration_style==SoftMigrationEnum){
@@ -49,10 +49,10 @@
 	/*free ressouces: */
 	xdelete(&vec_old_floatingice);
-	xfree((void**)&vertices_potentially_ungrounding);
-	xfree((void**)&vertices_ungrounding);
-	xfree((void**)&old_floatingice);
+	xDelete<double>(vertices_potentially_ungrounding);
+	xDelete<double>(vertices_ungrounding);
+	xDelete<double>(old_floatingice);
 }
 
-/*FUNCTION CreateNodesOnFloatingIce {{{1*/
+/*FUNCTION CreateNodesOnFloatingIce {{{*/
 Vector* CreateNodesOnFloatingIce(Nodes* nodes,int configuration_type){ 
 
@@ -81,5 +81,5 @@
 }
 /*%}}}*/
-/*FUNCTION PotentialSheetUngrounding {{{1*/
+/*FUNCTION PotentialSheetUngrounding {{{*/
 double*    PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){ 
 
@@ -108,5 +108,5 @@
 }
 /*}}}*/
-/*FUNCTION PropagateFloatingiceToGroundedNeighbors {{{1*/
+/*FUNCTION PropagateFloatingiceToGroundedNeighbors {{{*/
 double*    PropagateFloatingiceToGroundedNeighbors(Elements* elements,Nodes* nodes,Vertices* vertices,Parameters* parameters,double* vertices_potentially_ungrounding){ 
 
@@ -158,5 +158,5 @@
 		#ifdef _HAVE_MPI_
 		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
-		_printf_(VerboseConvergence(),"   Additional number of vertices allowed to unground: %i\n",nflipped);
+		if(VerboseConvergence()) _pprintLine_("   Additional number of vertices allowed to unground: " << nflipped);
 		#else
 		nflipped=local_nflipped;
@@ -164,6 +164,6 @@
 
 		/*Avoid leaks: */
-		xfree((void**)&elements_neighboring_floatingce);
-		xfree((void**)&nodes_on_floatingice);
+		xDelete<double>(elements_neighboring_floatingce);
+		xDelete<double>(nodes_on_floatingice);
 
 		/*Assemble and serialize:*/
@@ -174,5 +174,5 @@
 	/*Free ressources:*/
 	xdelete(&vec_nodes_on_floatingice);
-	xfree((void**)&elements_neighboring_floatingce);
+	xDelete<double>(elements_neighboring_floatingce);
 
 	return nodes_on_floatingice;
Index: /issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp
===================================================================
--- /issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp	(revision 12706)
@@ -43,5 +43,5 @@
 
 	 /*^^^^^^^^^^^^^  Remove pixels close to the holes ^^^^^^^^^^^^^*/
-	image2 = (double*) xmalloc( lines*samps*sizeof(double));
+	image2 = xNew<double>(lines*samps);
 	memcpy(image2,image,lines*samps*sizeof(double));
 	
@@ -64,5 +64,5 @@
 	}
 
-	image3 = (double*) xmalloc( lines*samps*sizeof(double));
+	image3 = xNew<double>(lines*samps);
 	memcpy(image3,image2,lines*samps*sizeof(double));
 
@@ -76,6 +76,6 @@
 			}
 		}
-		printf( "\n" );
-		printf("Number of zeroes remaining: %10ld",lines*samps-counter);
+		_printLine_( "" );
+		_printString_("Number of zeroes remaining: " << lines*samps-counter);
 		fflush( stdout );
 	#endif
@@ -95,6 +95,6 @@
 		}
 		//        n u m b e r   o f   z e r o e s   r e m a i n i n g :   1 2 3 4 5 6 7 8 9 10        
-		printf( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
-		printf("Number of zeroes remaining: %10ld",lines*samps-counter);
+		_printString_( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
+		_printString_("Number of zeroes remaining: " << lines*samps-counter);
 		fflush( stdout );
 	#endif
@@ -104,5 +104,5 @@
 /***************** FIRST RUN *********************/
 /*
-fprintf ( stdout, "First  Application:  " ); time(&t2); printf( ctime(&t2) );
+fprintf ( stdout, "First  Application:  " ); time(&t2); _printString_( ctime(&t2) );
 */
 	for ( i = 0; i < lines; i++ ){
@@ -277,5 +277,5 @@
 			
 			#ifdef _DEBUG2_
-				//printf("%g %g %g \n",temp,elev,range);
+				//_printLine_(temp << " " << elev << " " << range << " ");
 			#endif
 
@@ -304,5 +304,5 @@
 /************************ SMOOTH THE RESULT ***********************/		
 		
-	image4 = (double*) xmalloc( lines*samps*sizeof(double));
+	image4 = xNew<double>(lines*samps);
 	memcpy(image4,image3,lines*samps*sizeof(double));
 
@@ -348,5 +348,5 @@
 
 	/*Allocate output image: */
-	imageout=(double*)xmalloc(samps*lines*sizeof(double));
+	imageout=xNew<double>(samps*lines);
 	memcpy(imageout,image3,lines*samps*sizeof(double));
 
@@ -354,6 +354,6 @@
 	
 	#ifdef _DEBUG2_
-		printf( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
-		printf("Number of zeroes remaining:          0\n\n");
+		_printString_( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
+		_printLine_("Number of zeroes remaining:          0\n");
 		printf ( "\n");
 	#endif
@@ -363,6 +363,4 @@
 	/*Assign output pointers: */
 	*pimageout=imageout;
-
 	return 1;
-	
 }
Index: /issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void InputArtificialNoisex( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int enum_name,double min,double max){
+void InputArtificialNoisex( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int enum_name,IssmDouble min,IssmDouble max){
 
 	int i;
Index: /issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.h
===================================================================
--- /issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.h	(revision 12705)
+++ /issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void	InputArtificialNoisex( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int enum_name,double min,double max);
+void	InputArtificialNoisex( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int enum_name,IssmDouble min,IssmDouble max);
 
 #endif  /* _UPDATEINPUTSFROMVECTORXX_H */
Index: /issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp	(revision 12706)
@@ -9,16 +9,16 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, double* criterionvalues,int num_criterionenums){
+bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, IssmDouble* criterionvalues,int num_criterionenums){
 
 	/*intermediary:*/
-	int         i;
-	bool        converged;
-	int         num_notconverged=0;
-	int         total_notconverged;
-	double     *eps       = NULL;
-	Element*    element=NULL;
+	int      i;
+	bool     converged;
+	int      num_notconverged   = 0;
+	int      total_notconverged;
+	IssmDouble  *eps                = NULL;
+	Element *element            = NULL;
 
 	/*allocate dynamic memory: */
-	eps=(double*)xmalloc(num_criterionenums*sizeof(double));
+	eps=xNew<IssmDouble>(num_criterionenums);
 
 	/*Go through elements, and ask them to do the job: */
@@ -34,8 +34,8 @@
 	num_notconverged=total_notconverged;
 	#endif
-	_printf_(VerboseConvergence(),"      #elements above convergence criterion = %i\n",num_notconverged);
+	if(VerboseConvergence()) _pprintLine_("      #elements above convergence criterion = " << num_notconverged);
 
 	/*Free ressources:*/
-	xfree((void**)&eps);
+	xDelete<IssmDouble>(eps);
 
 	/*return: */
Index: /issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h
===================================================================
--- /issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h	(revision 12705)
+++ /issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /* local prototypes: */
-bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, double* criterionvalues,int num_criterionenums);
+bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, IssmDouble* criterionvalues,int num_criterionenums);
 
 #endif  /* _INPUTCONVERGENCEX_H */
Index: /issm/trunk/src/c/modules/InputScalex/InputScalex.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputScalex/InputScalex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputScalex/InputScalex.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, double scale_factor){
+void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, IssmDouble scale_factor){
 
 	/*intermediary:*/
Index: /issm/trunk/src/c/modules/InputScalex/InputScalex.h
===================================================================
--- /issm/trunk/src/c/modules/InputScalex/InputScalex.h	(revision 12705)
+++ /issm/trunk/src/c/modules/InputScalex/InputScalex.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, double scale_factor);
+void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, IssmDouble scale_factor);
 
 #endif  /* _SCALEINPUTX_H */
Index: /issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp	(revision 12706)
@@ -13,5 +13,5 @@
 	/*intermediary:*/
 	int      step;
-	double   time;
+	IssmDouble   time;
 	Element *element = NULL;
 
Index: /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp	(revision 12706)
@@ -49,5 +49,5 @@
 	}
 }
-void InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double constant, int name){
+void InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble constant, int name){
 
 	int i;
Index: /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h	(revision 12706)
@@ -12,5 +12,5 @@
 void		InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, bool   constant, int name);
 void		InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, int    constant, int name);
-void		InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, double constant, int name);
+void		InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, IssmDouble constant, int name);
 
 #endif  /* _UPDATEINPUTSFROMCONSTANTXX_H */
Index: /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp	(revision 12706)
@@ -21,7 +21,7 @@
 	double *qmu_part  = NULL;
 
-	double* distributed_values=NULL;
-	double* parameter=NULL;
-	char*   descriptor=NULL;
+	double *distributed_values = NULL;
+	double *parameter          = NULL;
+	char   *descriptor         = NULL;
 	char    root[50]; //root name of variable, ex: DragCoefficent, RhoIce, etc ...
 
@@ -49,5 +49,5 @@
 
 
-			distributed_values=(double*)xmalloc(npart*sizeof(double));
+			distributed_values=xNew<double>(npart);
 			for(j=0;j<npart;j++){
 				distributed_values[j]=variables[i+j];
@@ -91,12 +91,12 @@
 
 			/*Free allocations: */
-			xfree((void**)&parameter);
-			xfree((void**)&distributed_values);
+			xDelete<double>(parameter);
+			xDelete<double>(distributed_values);
 		}
 		else if (strncmp(descriptor,"indexed_",8)==0){
-			_error_(" indexed variables not supported yet!");
+			_error2_("indexed variables not supported yet!");
 		}
 		else if (strncmp(descriptor,"nodal_",8)==0){
-			_error_(" nodal variables not supported yet!");
+			_error2_("nodal variables not supported yet!");
 		}
 		else{
@@ -107,5 +107,4 @@
 
 	/*Free ressources:*/
-	xfree((void**)&qmu_part);
-
+	xDelete<double>(qmu_part);
 }
Index: /issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp	(revision 12706)
@@ -11,5 +11,5 @@
 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* solution){
 
-	double* serial_solution=NULL;
+	IssmDouble* serial_solution=NULL;
 
 	/*Serialize solution, so that elements can index into it on every CPU: */
@@ -20,10 +20,9 @@
 
 	/*Free ressources:*/
-	xfree((void**)&serial_solution);
-
+	xDelete<IssmDouble>(serial_solution);
 }
 
 
-void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution){
+void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution){
 
 	/*Intermediary*/
@@ -36,4 +35,3 @@
 		element->InputUpdateFromSolution(solution);
 	}
-
 }
Index: /issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h	(revision 12706)
@@ -11,9 +11,9 @@
 /* local prototypes: */
 void		InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* solution);
-void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution);
+void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution);
 
 //with timestep
 void		InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* solution,int timestep);
-void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution, int timestep);
+void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution, int timestep);
 
 #endif  /* _UPDATEINPUTSFROMSOLUTIONXX_H */
Index: /issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp	(revision 12706)
@@ -18,5 +18,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&serial_vector);
+	xDelete<double>(serial_vector);
 }
 
Index: /issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp	(revision 12706)
@@ -11,5 +11,5 @@
 void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* vector, int name, int type){
 
-	double* serial_vector=NULL;
+	IssmDouble* serial_vector=NULL;
 
 	serial_vector=vector->ToMPISerial();
@@ -18,9 +18,9 @@
 
 	/*Free ressources:*/
-	xfree((void**)&serial_vector);
+	xDelete<IssmDouble>(serial_vector);
 }
 
 	
-void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vector, int name, int type){
+void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* vector, int name, int type){
 
 	int i;
Index: /issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h	(revision 12706)
@@ -11,5 +11,5 @@
 /* local prototypes: */
 void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,Vector* vector, int name,int type);
-void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,double* vector, int name,int type);
+void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,IssmDouble* vector, int name,int type);
 void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int* vector, int name,int type);
 void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,bool* vector, int name,int type);
Index: /issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp	(revision 12706)
@@ -13,4 +13,5 @@
 #include "../../shared/shared.h"
 #include "../../include/include.h"
+#include "../../io/io.h"
 /*}}}*/
 
@@ -36,11 +37,11 @@
 	/*Some checks on arguments: */
 	if ((M<2) || (N<2) || (nods<=0)){
-		_error_("nothing to be done according to the dimensions of input matrices and vectors.");
+		_error2_("nothing to be done according to the dimensions of input matrices and vectors.");
 	}
 	if (x_in[1]-x_in[0]<0){
-		_error_("x coordinate vector should be increasing.\n   use Matlab's command x=flipud(x), also flip the data matrix data=fliplr(data)");
+		_error2_("x coordinate vector should be increasing.\n   use Matlab's command x=flipud(x), also flip the data matrix data=fliplr(data)");
 	}
 	if (y_in[1]-y_in[0]<0){
-		_error_("y coordinate vector should be increasing.\n   use Matlab's command y=flipud(y), also flip the data matrix data=flipud(data)");
+		_error2_("y coordinate vector should be increasing.\n   use Matlab's command y=flipud(y), also flip the data matrix data=flipud(data)");
 	}
 
@@ -52,6 +53,6 @@
 
 		/*The coordinates given in input describe the contour of each pixel. Take the center of each pixel*/
-		x=(double*)xmalloc(N*sizeof(double));
-		y=(double*)xmalloc(M*sizeof(double));
+		x=xNew<double>(N);
+		y=xNew<double>(M);
 		for (i=0;i<N;i++) x[i]=(x_in[i]+x_in[i+1])/2;
 		for (i=0;i<M;i++) y[i]=(y_in[i]+y_in[i+1])/2;
@@ -62,11 +63,11 @@
 
 		/*The coordinates given in input describe the center each pixel. Keep them*/
-		x=(double*)xmalloc(N*sizeof(double));
-		y=(double*)xmalloc(M*sizeof(double));
+		x=xNew<double>(N);
+		y=xNew<double>(M);
 		for (i=0;i<N;i++) x[i]=x_in[i];
 		for (i=0;i<M;i++) y[i]=y_in[i];
 	}
 	else{
-		_error_("x and y vectors length should be 1 or 0 more than data number of rows.");
+		_error2_("x and y vectors length should be 1 or 0 more than data number of rows.");
 	}
 
@@ -81,10 +82,12 @@
 	gate.data_mesh=data_mesh;
 	gate.data=data;
+	gate.default_value=default_value;
+	gate.interp=interpenum;
 	gate.M=M;
 	gate.N=N;
-	gate.interp=interpenum;
 
 	/*launch the thread manager with InterpFromGridToMeshxt as a core: */
 	LaunchThread(InterpFromGridToMeshxt,(void*)&gate,num);
+	_printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
 
 	/*Assign output pointers:*/
@@ -92,5 +95,5 @@
 }
 /*}}}*/
-/*InterpFromGridToMeshxt {{{1*/
+/*InterpFromGridToMeshxt {{{*/
 void* InterpFromGridToMeshxt(void* vpthread_handle){
 
@@ -124,5 +127,5 @@
 	double *y             = gate->y;
 	int     nods          = gate->nods;
-	Vector*     data_mesh     = gate->data_mesh;
+	Vector *data_mesh     = gate->data_mesh;
 	double *data          = gate->data;
 	double  default_value = gate->default_value;
@@ -131,8 +134,13 @@
 	int     N             = gate->N;
 
+	bool debug = M*N>1? true:false;
+	debug = true;
+
 	/*partition loop across threads: */
 	PartitionRange(&i0,&i1,nods,num_threads,my_thread);
 	for (i=i0;i<i1;i++) {
 
+		if(debug && my_thread==0)
+		 _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(i-i0)/double(i1-i0)*100<<"%");
 		x_grid=*(x_mesh+i);
 		y_grid=*(y_mesh+i);
@@ -170,8 +178,8 @@
 					break;
 				default:
-					printf("Interpolation %s not supported yet\n",EnumToStringx(interpenum));
+					_printLine_("Interpolation " << EnumToStringx(interpenum) << " not supported yet");
 					return NULL; /*WARNING: no error because it would blow up the multithreading!*/
 			}
-			if(isnan(data_value)) data_value=default_value;
+			if(xIsNan<IssmDouble>(data_value)) data_value=default_value;
 		}
 		else{
@@ -183,5 +191,5 @@
 }/*}}}*/
 
-/*findindices {{{1*/
+/*findindices {{{*/
 bool findindices(int* pn,int* pm,double* x,int x_rows, double* y,int y_rows, double xgrid,double ygrid){
 
@@ -218,5 +226,5 @@
 	return (foundx && foundy);
 }/*}}}*/
-/*triangleinterp{{{1*/
+/*triangleinterp{{{*/
 double triangleinterp(double x1,double x2,double y1,double y2,double Q11,double Q12,double Q21,double Q22,double x,double y){
 	/*split the rectangle in 2 triangle and
@@ -259,5 +267,5 @@
 	}
 }/*}}}*/
-/*bilinearinterp{{{1*/
+/*bilinearinterp{{{*/
 double bilinearinterp(double x1,double x2,double y1,double y2,double Q11,double Q12,double Q21,double Q22,double x,double y){
 	/*Bilinear  interpolation: (http://en.wikipedia.org/wiki/Bilinear_interpolation) */
@@ -286,5 +294,5 @@
 }
 /*}}}*/
-/*nearestinterp{{{1*/
+/*nearestinterp{{{*/
 double nearestinterp(double x1,double x2,double y1,double y2,double Q11,double Q12,double Q21,double Q22,double x,double y){
 	/*Nearest neighbor interpolation*/
Index: /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp	(revision 12706)
@@ -41,5 +41,5 @@
 	/*some checks*/
 	if (nels_data<1 || nods_data<3 || nods_prime==0){
-		_error_("nothing to be done according to the mesh given in input");
+		_error2_("nothing to be done according to the mesh given in input");
 	}
 
@@ -55,9 +55,9 @@
 	}
 	else{
-		_error_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
+		_error2_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
 	}
 
 	if((numcontours) && (interpolation_type==2)){
-		_error_(" element interpolation_type with contours not supported yet!");
+		_error2_("element interpolation_type with contours not supported yet!");
 	}
 
@@ -84,6 +84,6 @@
 	}
 	else{
-		 incontour=(double*)xmalloc(nods_prime*sizeof(double));
-		 for (i=0;i<nods_prime;i++) incontour[i]=1;
+		 incontour=xNew<double>(nods_prime);
+		 for (i=0;i<nods_prime;i++) incontour[i]=1.0;
 	}
 
@@ -112,5 +112,5 @@
 
 	/*Assign output pointers:*/
-	 xfree((void**)&incontour);
+	 xDelete<double>(incontour);
 	*pdata_prime=data_prime;
 }
Index: /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	(revision 12706)
@@ -17,17 +17,17 @@
 	bool debug;
 	int  nels_data;
-	double* index_data=NULL;
-	double* x_data=NULL;
-	double* y_data=NULL;
-	double* data=NULL;
-	double xmin,xmax;
-	double ymin,ymax;
-	int    nods_prime;
-	Vector*    data_prime=NULL;
-	double* x_prime=NULL;
-	double* y_prime=NULL;
-	double* default_values=NULL;
+	double *index_data         = NULL;
+	double *x_data             = NULL;
+	double *y_data             = NULL;
+	double *data               = NULL;
+	double  xmin                 ,xmax;
+	double  ymin                 ,ymax;
+	int     nods_prime;
+	Vector *data_prime         = NULL;
+	double *x_prime            = NULL;
+	double *y_prime            = NULL;
+	double *default_values     = NULL;
 	int     num_default_values;
-	double*    incontour=NULL;
+	double *incontour          = NULL;
 
 	/*intermediary: */
@@ -46,22 +46,22 @@
 	
 	/*recover parameters :*/
-	interpolation_type=gate->interpolation_type;
-	debug=gate->debug;
-	nels_data=gate->nels_data;
-	index_data=gate->index_data;
-	x_data=gate->x_data;
-	y_data=gate->y_data;
-	data=gate->data;
-	xmin=gate->xmin;
-	xmax=gate->xmax;
-	ymin=gate->ymin;
-	ymax=gate->ymax;
-	nods_prime=gate->nods_prime;
-	data_prime=gate->data_prime;
-	x_prime=gate->x_prime;
-	y_prime=gate->y_prime;
-	default_values=gate->default_values;
-	num_default_values=gate->num_default_values;
-	incontour=gate->incontour;
+	interpolation_type = gate->interpolation_type;
+	debug              = gate->debug;
+	nels_data          = gate->nels_data;
+	index_data         = gate->index_data;
+	x_data             = gate->x_data;
+	y_data             = gate->y_data;
+	data               = gate->data;
+	xmin               = gate->xmin;
+	xmax               = gate->xmax;
+	ymin               = gate->ymin;
+	ymax               = gate->ymax;
+	nods_prime         = gate->nods_prime;
+	data_prime         = gate->data_prime;
+	x_prime            = gate->x_prime;
+	y_prime            = gate->y_prime;
+	default_values     = gate->default_values;
+	num_default_values = gate->num_default_values;
+	incontour          = gate->incontour;
 
 	/*partition loop across threads: */
@@ -69,10 +69,9 @@
 
 	/*Loop over the elements*/
-	if (debug && my_thread==0) printf("      interpolation progress:   %5.2lf %%",0.0);
-
 	for (i=i0;i<i1;i++){
 
 		/*display current iteration*/
-		if (debug && my_thread==0 && fmod((double)i,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)i/nels_data*100*num_threads);
+		if (debug && my_thread==0 && fmod((double)i,(double)100)==0)
+		 _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(i-i0)/double(i1-i0)*100<<"%");
 
 		/*if there is no point inside the domain, go to next iteration*/
@@ -114,5 +113,5 @@
 						data_value=data[i];
 					}
-					if (isnan(data_value)){
+					if (xIsNan<IssmDouble>(data_value)){
 						if(num_default_values==1) data_value=default_values[0];
 						else data_value=default_values[j];
@@ -125,7 +124,6 @@
 		}
 	}
-	if (debug && my_thread==0) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
-	
+	if(debug && my_thread==0)
+	 _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
 	return NULL;
-
 }
Index: /issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp	(revision 12706)
@@ -30,5 +30,5 @@
 	/*some checks*/
 	if (nels<1 || nods<3 || nlines<1 || ncols<1 || xposting==0 || yposting==0){
-		_error_("nothing to be done according to the mesh given in input");
+		_error2_("nothing to be done according to the mesh given in input");
 	}
 
@@ -41,11 +41,11 @@
 	}
 	else{
-		_error_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
+		_error2_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
 	}
 
 	/*First, allocate pointers: */
-	griddata=(double*)xcalloc(nlines*ncols,sizeof(double));
-	x_grid=(double*)xcalloc(ncols,sizeof(double));
-	y_grid=(double*)xcalloc(nlines,sizeof(double));
+	griddata=xNewZeroInit<double>(nlines*ncols);
+	x_grid=xNewZeroInit<double>(ncols);
+	y_grid=xNewZeroInit<double>(nlines);
 
 	/*Set debug to 1 if there are lots of elements*/
@@ -85,9 +85,9 @@
 
 	/*Loop over the elements*/
-	if (debug) printf("      interpolation progress:   %5.2lf %%",0.0);
 	for (n=0;n<nels;n++){
 
 		/*display current iteration*/
-		if (debug && fmod((double)n,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)n/nels*100);
+		if (debug && fmod((double)n,(double)100)==0)
+		 _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(n)/double(nels)*100<<"%");
 
 		/*Get extrema coordinates of current elements*/
@@ -160,5 +160,5 @@
 						data_value=data_mesh[n];
 					}
-					if (isnan(data_value)) data_value=default_value;
+					if (xIsNan<IssmDouble>(data_value)) data_value=default_value;
 
 					/*insert value and go to the next point*/
@@ -168,5 +168,6 @@
 		}
 	}
-	if (debug) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
+	if (debug)
+	 _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 12706)
@@ -13,6 +13,6 @@
 using namespace std;
 
-int InterpFromMeshToMesh2dx(double** pdata_interp,double* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
-			double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values, DataSet* contours){
+int InterpFromMeshToMesh2dx(double** pdata_interp,int* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
+			double* data,int M_data,int N_data,double* x_interp,double* y_interp,int N_interp,Options* options){
 	
 	/*Output*/
@@ -20,4 +20,6 @@
 
 	/*Intermediary*/
+	bool   isdefault;
+	double defaultvalue;
 	R2     r;
 	I2     I;
@@ -29,76 +31,67 @@
 	double data_value;
 	Icoor2 dete[3];
-	int verbose=0;
-
-	/*default values: */
-	Vector*    vec_incontour=NULL;
-	double*    incontour=NULL;
-	bool   skip_bamg=false;
 
 	/*Checks*/
-	if (data_cols<=0){
-		_error_("data provided has a negative number of columns");
+	if (M_data!=nods_data && M_data!=nels_data){
+		_error2_("data provided should have either " << nods_data << " or " << nels_data << " lines (not " << M_data << ")");
 	}
-	if (data_rows!=nods_data && data_rows!=nels_data){
-		_error_("data provided should have either %i or %i lines (not %i)",nods_data,nels_data,data_rows);
+
+	/*Get default*/
+	if(options->GetOption("default")){
+		isdefault=true;
+		options->Get(&defaultvalue,"default");
 	}
-	if((num_default_values) && (data_cols>1)){
-		_error_("data provided can only have 1 column if a default value is provided");
-	}
-	
-	/*If default values supplied, figure out which nodes are inside the contour, including the border of the contour: */
-	if(num_default_values){
-		ContourToNodesx( &vec_incontour,x_interp,y_interp,nods_interp,contours,1);
-		incontour=vec_incontour->ToMPISerial();
+	else{
+		isdefault=false;
 	}
 
 	/*Initialize output*/
-	if (verbose) printf("Initializing output vector\n");
-	data_interp=(double*)xmalloc(nods_interp*data_cols*sizeof(double));
+	data_interp=xNew<double>(N_interp*N_data);
 
-	// read background mesh 
-	if (verbose) printf("Reading mesh\n");
+	/*read background mesh*/
 	Mesh Th(index_data,x_data,y_data,nods_data,nels_data); 
+
+	/*Get reference number (for subdomains)*/
+	long* reft = xNew<long>(Th.nbt);
+	Th.TriangleReferenceList(reft);
 	Th.CreateSingleVertexToTriangleConnectivity();
 
-	//Loop over output nodes
-	if (verbose) printf("Loop over the nodes\n");
-	for(i=0;i<nods_interp;i++){
-		
-		/*reset skip_bamg: */
-		skip_bamg=false;
+	/*Loop over output nodes*/
+	for(i=0;i<N_interp;i++){
 
-		/*figure out if we should skip bamg logic: */
-		if(num_default_values){
-			if(!incontour[i]){
-				/*This node is not inside the contour. Skip Bamg logic and apply default value.: */
-				skip_bamg=true;
+		/*Get current point coordinates*/
+		r.x=x_interp[i]; r.y=y_interp[i];
+		I2 I=Th.R2ToI2(r);
+
+		/*Find triangle holding r/I*/
+		Triangle &tb=*Th.TriangleFindFromCoord(I,dete);
+
+		/*point inside convex*/
+		if (tb.det>0){ 
+
+			/*Area coordinates*/
+			areacoord[0]= (double) dete[0]/tb.det;
+			areacoord[1]= (double) dete[1]/tb.det;
+			areacoord[2]= (double) dete[2]/tb.det;
+			/*3 vertices of the triangle*/
+			i0=Th.GetId(tb[0]);
+			i1=Th.GetId(tb[1]);
+			i2=Th.GetId(tb[2]);
+			/*triangle number*/
+			it=Th.GetId(tb);
+
+			/*Inside convex but outside mesh*/
+			if (reft[it]<0 & isdefault){
+				for(j=0;j<N_data;j++) data_interp[i*N_data+j]=defaultvalue;
+				continue;
 			}
 		}
-
-		if(skip_bamg==false){
-
-			//Get current point coordinates
-			r.x=x_interp[i]; r.y=y_interp[i];
-			I2 I=Th.R2ToI2(r);
-
-			//Find triangle holding r/I
-			Triangle &tb=*Th.TriangleFindFromCoord(I,dete);
-
-			// internal point 
-			if (tb.det>0){ 
-				//Area coordinate
-				areacoord[0]= (double) dete[0]/tb.det;
-				areacoord[1]= (double) dete[1]/tb.det;
-				areacoord[2]= (double) dete[2]/tb.det;
-				//3 vertices of the triangle
-				i0=Th.GetId(tb[0]);
-				i1=Th.GetId(tb[1]);
-				i2=Th.GetId(tb[2]);
-				//triangle number
-				it=Th.GetId(tb);
+		//external point
+		else{
+			if(isdefault){
+				for(j=0;j<N_data;j++) data_interp[i*N_data+j]=defaultvalue;
+				continue;
 			}
-			//external point
-			else {
+			else{
 				//Get closest adjacent triangle (inside the mesh)
 				AdjacentTriangle ta=CloseBoundaryEdge(I,&tb,aa,bb).Adj();
@@ -116,30 +109,24 @@
 				it=Th.GetId(tc);
 			}
-			
-			if (data_rows==nods_data){
-				for (j=0;j<data_cols;j++){
-					data_interp[i*data_cols+j]=areacoord[0]*data[data_cols*i0+j]+areacoord[1]*data[data_cols*i1+j]+areacoord[2]*data[data_cols*i2+j];
-				}
-			}
-			else{
-				for (j=0;j<data_cols;j++){
-					if (it<0 || it>=nels_data){
-						_error_("Triangle number %i not in [0 %i], because not correctly implemented yet... interpolate on grid first",it,nels_data);
-					}
-					data_interp[i*data_cols+j]=data[data_cols*it+j];
-				}
+		}
+
+		if (M_data==nods_data){
+			for (j=0;j<N_data;j++){
+				data_interp[i*N_data+j]=areacoord[0]*data[N_data*i0+j]+areacoord[1]*data[N_data*i1+j]+areacoord[2]*data[N_data*i2+j];
 			}
 		}
 		else{
-			if(num_default_values==1) data_interp[i]=default_values[0];
-			else data_interp[i]=default_values[i];
+			for (j=0;j<N_data;j++){
+				if (it<0 || it>=nels_data){
+					_error2_("Triangle number " << it << " not in [0 " << nels_data << "], report bug to developers");
+				}
+				data_interp[i*N_data+j]=data[N_data*it+j];
+			}
 		}
 	}
 
-	/*Assign output pointers:*/
-	if (verbose) printf("Assigning output\n");
+	/*clean-up and return*/
+	xDelete<long>(reft);
 	*pdata_interp=data_interp;
-
-	/*No error return*/
 	return 1;
 }
Index: /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h	(revision 12706)
@@ -6,9 +6,8 @@
 #define _INTERPFROMMESHTOMESH2DX_H
 
-#include "../../objects/objects.h"
+class Options;
 
-/* local prototypes: */
-int InterpFromMeshToMesh2dx(double** pdata_interp,double* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
-			double* data,int data_rows,int data_cols,double* x_interp,double* y_interp,int nods_interp,double* default_values,int num_default_values,DataSet* contours);
+int InterpFromMeshToMesh2dx(double** pdata_interp,int* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
+			double* data,int M_data,int N_data,double* x_interp,double* y_interp,int N_interp,Options* options);
 
 #endif
Index: /issm/trunk/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp	(revision 12706)
@@ -27,5 +27,5 @@
 	/*some checks*/
 	if (nels_data<1 || nods_data<6 || nods_prime==0){
-		_error_("nothing to be done according to the mesh given in input");
+		_error2_("nothing to be done according to the mesh given in input");
 	}
 
@@ -41,5 +41,5 @@
 	}
 	else{
-		_error_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
+		_error2_("length of vector data not supported yet. It should be of length (number of nodes) or (number of elements)!");
 	}
 
@@ -58,9 +58,9 @@
 
 	/*Loop over the elements*/
-	if (debug) printf("      interpolation progress:   %5.2lf %%",0.0);
 	for (i=0;i<nels_data;i++){
 
 		/*display current iteration*/
-		if (debug && fmod((double)i,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)i/nels_data*100);
+		if (debug && fmod((double)i,(double)100)==0)
+		 _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(i)/double(nels_data)*100<<"%");
 
 		/*Get extrema coordinates of current elements*/
@@ -124,5 +124,5 @@
 						data_value=data[i];
 					}
-					if (isnan(data_value)) data_value=default_value;
+					if (xIsNan<IssmDouble>(data_value)) data_value=default_value;
 
 					/*insert value and go to the next point*/
@@ -132,5 +132,6 @@
 		}
 	}
-	if (debug) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
+	if (debug)
+	 _printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp	(revision 12706)
@@ -22,6 +22,6 @@
 	int     counter;
 	int     nods;
-	double* times=NULL;
-	double* values=NULL;
+	IssmDouble* times=NULL;
+	IssmDouble* values=NULL;
 	bool    spcpresent=false;
 	int     count=0;
@@ -29,5 +29,5 @@
 
 	/*variables being fetched: */
-	double *doublevector  = NULL;
+	IssmDouble *IssmDoublevector  = NULL;
 	int     M,N;
 
@@ -38,9 +38,9 @@
 	fid=iomodel->SetFilePointerToData(&code, &vector_layout,vector_enum);
 
-	if(code!=7)_error_("%s%s"," expecting a double vector for constraints with enum ",EnumToStringx(vector_enum));
-	if(vector_layout!=1)_error_("%s%s"," expecting a nodal vector for constraints with enum ",EnumToStringx(vector_enum));
+	if(code!=7)_error2_("expecting a IssmDouble vector for constraints with enum " << EnumToStringx(vector_enum));
+	if(vector_layout!=1)_error2_("expecting a nodal vector for constraints with enum " << EnumToStringx(vector_enum));
 
 	/*Fetch vector:*/
-	iomodel->FetchData(&doublevector,&M,&N,vector_enum);
+	iomodel->FetchData(&IssmDoublevector,&M,&N,vector_enum);
 
 	/*Transient or static?:*/
@@ -55,7 +55,7 @@
 			if((iomodel->my_vertices[i])){
 
-				if (!isnan(doublevector[i])){
+				if (!xIsNan<IssmDouble>(IssmDoublevector[i])){
 
-					constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,doublevector[i],analysis_type));
+					constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,IssmDoublevector[i],analysis_type));
 					count++;
 				}
@@ -69,7 +69,7 @@
 
 		/*figure out times: */
-		times=(double*)xmalloc(N*sizeof(double));
+		times=xNew<IssmDouble>(N);
 		for(j=0;j<N;j++){
-			times[j]=doublevector[(M-1)*N+j];
+			times[j]=IssmDoublevector[(M-1)*N+j];
 		}
 		/*unit conversion: */
@@ -83,9 +83,9 @@
 
 				/*figure out times and values: */
-				values=(double*)xmalloc(N*sizeof(double));
+				values=xNew<IssmDouble>(N);
 				spcpresent=false;
 				for(j=0;j<N;j++){
-					values[j]=doublevector[i*N+j];
-					if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default
+					values[j]=IssmDoublevector[i*N+j];
+					if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
 				}
 
@@ -94,15 +94,15 @@
 					count++;
 				}
-				xfree((void**)&values);
+				xDelete<IssmDouble>(values);
 			}
 		}
 	}
 	else{
-		_error_("Size of field %s not supported",EnumToStringx(vector_enum));
+		_error2_("Size of field " << EnumToStringx(vector_enum) << " not supported");
 	}
 
 	/*Free ressources:*/
-	xfree((void**)&doublevector);
-	xfree((void**)&times);
-	xfree((void**)&values);
+	xDelete<IssmDouble>(IssmDoublevector);
+	xDelete<IssmDouble>(times);
+	xDelete<IssmDouble>(values);
 }
Index: /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp
===================================================================
--- /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp	(revision 12706)
@@ -21,5 +21,5 @@
 	clock0=clock();
 	time0 =time(NULL);
-	_printf_(true,"\nKMLFileReadx Module -- %s",ctime(&time0));
+	_pprintString_("\nKMLFileReadx Module -- " << ctime(&time0));
 
 /*  read kml file  */
@@ -43,15 +43,15 @@
 		}
 
-//		_printf_(true,"%s\n",kstr);
-		xfree((void**)&kstr);
+//		_pprintLine_(kstr);
+		xDelete<char>(kstr);
 	}
 
 	if (kxml) {
-		_printf_(true,"XML declaration:\n");
+		_pprintLine_("XML declaration:");
 		kxml->DeepEcho("  ");
 		delete kxml;
 	}
 	if (kdtd) {
-		_printf_(true,"DTD declaration (not yet implemented):\n");
+		_pprintLine_("DTD declaration (not yet implemented):");
 		kdtd->DeepEcho("  ");
 		delete kdtd;
Index: /issm/trunk/src/c/modules/KMLMeshWritex/KMLMeshWritex.cpp
===================================================================
--- /issm/trunk/src/c/modules/KMLMeshWritex/KMLMeshWritex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/KMLMeshWritex/KMLMeshWritex.cpp	(revision 12706)
@@ -9,28 +9,18 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void KMLMeshWritex(int* ierror,
-				   char* name,
-				   char* notes,
-				   int* elem,int melem,int nelem,
-				   int* nodecon,int mncon,int nncon,
-				   double* lat, double* lng,
-				   int* part,
-				   double* data, int mdata, int ndata,
-				   double* cmap, int mcmap, int ncmap,
-				   FILE* fid){
-
-	int     i,j,k,ipt=0,jpt=0,nnodes;
-	int     mxepg=25;
-	int     lwidth=1;
-	double  popac=0.50;
-	char    indent[81]="  ";
-	char    cstr[81];
-	double* edata=NULL;
-	bool    ncfree=false,
-			edfree=false;
-	KML_Document*  kdoc=NULL;
-	KML_Style*     kstyle;
-	KML_LineStyle* klsty;
-	KML_PolyStyle* kpsty;
+void KMLMeshWritex(int* ierror,char* name,char* notes,int* elem,int melem,int nelem,int* nodecon,int mncon,int nncon,double* lat, double* lng,int* part,double* data, int mdata, int ndata,double* cmap, int mcmap, int ncmap,FILE* fid){
+
+	int                 i,j,k,ipt=0,jpt=0,nnodes;
+	int                 mxepg      = 25;
+	int                 lwidth     = 1;
+	double              popac      = 0.50;
+	char                indent[81] = " ";
+	char                cstr[81];
+	double             *edata = NULL;
+	bool ncfree=false, edfree=false;
+	KML_Document       *kdoc = NULL;
+	KML_Style          *kstyle;
+	KML_LineStyle      *klsty;
+	KML_PolyStyle      *kpsty;
 
 	clock_t clock0,clock1,clock0a,clock0b,clock0c;
@@ -39,5 +29,5 @@
 	clock0=clock();
 	time0 =time(NULL);
-	_printf_(true,"\nKMLMeshWritex Module -- %s",ctime(&time0));
+	_pprintString_("\nKMLMeshWritex Module -- " << ctime(&time0));
 
 /*  construct kml document  */
@@ -93,5 +83,5 @@
 
 	if (cmap) {
-		_printf_(true,"Writing %d Matlab colors as KML style templates.\n",mcmap);
+		_pprintLine_("Writing " << mcmap << " Matlab colors as KML style templates.");
 		ipt=0;
 		for (i=0; i<mcmap; i++) {
@@ -128,7 +118,7 @@
 
 	if (!nodecon) {
-		_printf_(true,"Creating the node connectivity table.\n");
+		_pprintLine_("Creating the node connectivity table.");
 		nncon=mxepg+1;
-		nodecon=(int *) xcalloc(mncon*nncon,sizeof(int));
+		nodecon=xNewZeroInit<int>(mncon*nncon);
 		ncfree=true;
 
@@ -143,5 +133,5 @@
 					}
 					else
-						_error_("Nodal connectivity table needs more than specified %d columns.\n",mxepg);
+						_error2_("Nodal connectivity table needs more than specified " << mxepg << " columns.\n");
 				}
 				jpt++;
@@ -159,6 +149,6 @@
 
 		else if (mdata == mncon) {
-			_printf_(true,"Averaging nodal data to element data.\n");
-			edata=(double *) xcalloc(melem*ndata,sizeof(double));
+			_pprintLine_("Averaging nodal data to element data.");
+			edata=xNewZeroInit<double>(melem*ndata);
 			edfree=true;
 
@@ -183,5 +173,5 @@
 
 		else
-			_error_("Data matrix has incorrect number of %d rows.\n",mdata);
+			_error2_("Data matrix has incorrect number of " << mdata << " rows.\n");
 	}
 
@@ -194,6 +184,6 @@
 														cmap,mcmap,ncmap));
 
-	if (edfree) xfree((void**)&edata);
-	if (ncfree) xfree((void**)&nodecon);
+	if(edfree) xDelete<double>(edata);
+	if(ncfree) xDelete<int>(nodecon);
 	clock0a=clock();
 	time0a =time(NULL);
@@ -203,5 +193,5 @@
 /*  write kml file  */
 
-	_printf_(true,"Writing kml document to file.\n");
+	_pprintLine_("Writing kml document to file.");
 	fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
 	fprintf(fid,"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n");
@@ -213,5 +203,5 @@
 			 ((double)(clock0b-clock0a))/CLOCKS_PER_SEC,difftime(time0b,time0a));
 
-	_printf_(true,"Deleting kml document.\n");
+	_pprintLine_("Deleting kml document.");
 	delete kdoc;
 	clock0c=clock();
@@ -314,5 +304,5 @@
 /*  write each element as a polygon placemark  */
 
-	_printf_(true,"Writing %d tria elements as KML polygons.\n",melem);
+	_pprintLine_("Writing " << melem << " tria elements as KML polygons.");
 
 	for (i=0; i<melem; i++) {
@@ -344,29 +334,29 @@
 		kring=new KML_LinearRing();
 		kring->ncoord    =nelem+1;
-		kring->coords    =(double (*)[3]) xmalloc((nelem+1)*3*sizeof(double));
+		kring->coords =xNew<double>((nelem+1)*3);
 
 /*  write the nodal coordinates as a linear ring  */
 
 		for (j=0; j<nelem; j++) {
-			kring->coords[j][0]=lng[elem[ipt]-1];
-			kring->coords[j][1]=lat[elem[ipt]-1];
-			kring->coords[j][2]=alt;
+			kring->coords[3*j+0]=lng[elem[ipt]-1];
+			kring->coords[3*j+1]=lat[elem[ipt]-1];
+			kring->coords[3*j+2]=alt;
 			ipt++;
 		}
-		kring->coords[nelem][0]=kring->coords[0][0];
-		kring->coords[nelem][1]=kring->coords[0][1];
-		kring->coords[nelem][2]=kring->coords[0][2];
+		kring->coords[3*nelem+0]=kring->coords[3*0+0];
+		kring->coords[3*nelem+1]=kring->coords[3*0+1];
+		kring->coords[3*nelem+2]=kring->coords[3*0+2];
 //		kring->DeepEcho();
 
 /*  assemble the linear ring into polygon into placemark into folder  */
 
-		(kpoly ->outer     )->AddObject((Object*)kring);
-		(kplace->geometry  )->AddObject((Object*)kpoly);
-		(kfold ->feature   )->AddObject((Object*)kplace);
+		(kpoly ->outer   )->AddObject((Object*)kring);
+		(kplace->geometry)->AddObject((Object*)kpoly);
+		(kfold ->feature )->AddObject((Object*)kplace);
 
 //		if (!(int)fmod((double)(i+1),1000))
-//			_printf_(true,"  %d tria elements written.\n",(i+1));
+//			_pprintLine_("  " << (i+1) << " tria elements written.");
 	}
-	_printf_(true,"  %d tria elements written.\n",melem);
+	_pprintLine_("  " << melem << " tria elements written.");
 
 	return(kfold);
Index: /issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp
===================================================================
--- /issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp	(revision 12706)
@@ -28,5 +28,5 @@
 	clock0=clock();
 	time0 =time(NULL);
-	_printf_(true,"\nKMLOverlayx Module -- %s",ctime(&time0));
+	_pprintString_("\nKMLOverlayx Module -- " << ctime(&time0));
 
 /*  construct kml file  */
@@ -82,5 +82,5 @@
 /*  write kml file  */
 
-	_printf_(true,"Writing kml document to file.\n");
+	_pprintLine_("Writing kml document to file.");
 	fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
 	kfile->Write(fid,indent);
Index: /issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp	(revision 12706)
@@ -38,5 +38,5 @@
 	clock0=clock();
 	time0 =time(NULL);
-	_printf_(true,"\nKml2Expx Module -- %s",ctime(&time0));
+	_pprintString_("\nKml2Expx Module -- " << ctime(&time0));
 
 /*  read kml file  */
@@ -44,10 +44,10 @@
 	fidi=fopen(filkml,"r");
 	if (!(kobj=KMLFileReadx(fidi)))
-		_error_("Error reading kml file.");
+		_error2_("Error reading kml file.");
 	fclose(fidi);
 
 /*  open exp file  */
 
-	_printf_(true,"Writing exp profiles to file.\n");
+	_pprintLine_("Writing exp profiles to file.");
 	fido=fopen(filexp,"w");
 
Index: /issm/trunk/src/c/modules/Krigingx/Krigingx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Krigingx/Krigingx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Krigingx/Krigingx.cpp	(revision 12706)
@@ -10,10 +10,7 @@
 #include "../../Container/Observations.h"
 #include "../modules.h"
-
 #ifdef _HAVE_GSL_
 #include <gsl/gsl_linalg.h>
 #endif
-
-#include "../../objects/Kriging/GaussianVariogram.h"
 /*FUNCTION Krigingx{{{*/
 int Krigingx(double** ppredictions,double **perror,double* obs_x, double* obs_y, double* obs_list, int obs_length,double* x_interp,double* y_interp,int n_interp,Options* options){
@@ -47,6 +44,6 @@
 
 	/*Allocate output*/
-	predictions =(double*)xcalloc(n_interp,sizeof(double));
-	error       =(double*)xcalloc(n_interp,sizeof(double));
+	predictions =xNewZeroInit<double>(n_interp);
+	error       =xNewZeroInit<double>(n_interp);
 
 	/*Get output*/
@@ -59,6 +56,25 @@
 		observations->Variomap(predictions,x_interp,n_interp);
 	}
-	else if(strcmp(output,"prediction")==0){
-
+	else if(strcmp(output,"delaunay")==0){
+		int nobs,nel;
+		double *x     = NULL;
+		double *y     = NULL;
+		double *data  = NULL;
+		int    *index = NULL;
+
+		observations->ObservationList(&x,&y,&data,&nobs);
+
+		_printLine_("Generation Delaunay Triangulation");
+		BamgTriangulatex(&index,&nel,x,y,nobs);
+
+		_printLine_("Interpolating");
+		xDelete<double>(predictions);
+		InterpFromMeshToMesh2dx(&predictions,index,x,y,nobs,nel,data,nobs,1,x_interp,y_interp,n_interp,options);
+		xDelete<double>(x);
+		xDelete<double>(y);
+		xDelete<double>(data);
+		xDelete<int>(index);
+	}
+	else if(strcmp(output,"nearestneighbor")==0){
 		/*initialize thread parameters: */
 		gate.n_interp     = n_interp;
@@ -72,13 +88,52 @@
 		gate.predictions  = predictions;
 		gate.error        = error;
-		gate.percent      = (double*)xcalloc(num,sizeof(double));
+		gate.percent      = xNewZeroInit<double>(num);
+
+		/*launch the thread manager with Krigingxt as a core: */
+		LaunchThread(NearestNeighbort,(void*)&gate,num);
+		_printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
+		xDelete<double>(gate.percent);
+	}
+	else if(strcmp(output,"idw")==0){ //Inverse distance weighting
+		/*initialize thread parameters: */
+		gate.n_interp     = n_interp;
+		gate.x_interp     = x_interp;
+		gate.y_interp     = y_interp;
+		gate.radius       = radius;
+		gate.mindata      = mindata;
+		gate.maxdata      = maxdata;
+		gate.variogram    = variogram;
+		gate.observations = observations;
+		gate.predictions  = predictions;
+		gate.error        = error;
+		gate.percent      = xNewZeroInit<double>(num);
+
+		/*launch the thread manager with Krigingxt as a core: */
+		LaunchThread(idwt,(void*)&gate,num);
+		_printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
+		xDelete<double>(gate.percent);
+	}
+	else if(strcmp(output,"prediction")==0){
+
+		/*initialize thread parameters: */
+		gate.n_interp     = n_interp;
+		gate.x_interp     = x_interp;
+		gate.y_interp     = y_interp;
+		gate.radius       = radius;
+		gate.mindata      = mindata;
+		gate.maxdata      = maxdata;
+		gate.variogram    = variogram;
+		gate.observations = observations;
+		gate.predictions  = predictions;
+		gate.error        = error;
+		gate.percent      = xNewZeroInit<double>(num);
 
 		/*launch the thread manager with Krigingxt as a core: */
 		LaunchThread(Krigingxt,(void*)&gate,num);
-		printf("\r      interpolation progress:  100.00%%\n");
-		xfree((void**)&gate.percent);
+		_printLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
+		xDelete<double>(gate.percent);
 	}
 	else{
-		_error_("output '%s' not supported yet",output);
+		_error2_("output '" << output << "' not supported yet");
 	}
 
@@ -86,5 +141,5 @@
 	delete variogram;
 	delete observations;
-	xfree((void**)&output);
+	xDelete<char>(output);
 	*ppredictions = predictions;
 	*perror       = error;
@@ -121,15 +176,54 @@
 
 	/*Intermediaries*/
-	int           i,j,n_obs;
-	double        numerator,denominator,ratio,localpercent;
-	double       *x            = NULL;
-	double       *y            = NULL;
-	double       *obs          = NULL;
-	double       *Gamma        = NULL;
-	double       *GinvG0       = NULL;
-	double       *Ginv1        = NULL;
-	double       *GinvZ        = NULL;
-	double       *gamma0       = NULL;
-	double       *ones         = NULL;
+	double        localpercent;
+
+	/*partition loop across threads: */
+	PartitionRange(&i0,&i1,n_interp,num_threads,my_thread);
+	for(int idx=i0;idx<i1;idx++){
+
+		/*Print info*/
+		percent[my_thread]=double(idx-i0)/double(i1-i0)*100.;
+		localpercent=percent[0];
+		for(int i=1;i<num_threads;i++) localpercent=min(localpercent,percent[i]);
+		if(my_thread==0) _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<localpercent<<"%");
+
+		/*Kriging interpolation*/
+		observations->InterpolationKriging(&predictions[idx],&error[idx],x_interp[idx],y_interp[idx],radius,mindata,maxdata,variogram);
+	}
+
+	return NULL;
+}/*}}}*/
+/*FUNCTION NearestNeighbort{{{*/
+void* NearestNeighbort(void* vpthread_handle){
+
+	/*gate variables :*/
+	KrigingxThreadStruct *gate        = NULL;
+	pthread_handle       *handle      = NULL;
+	int my_thread;
+	int num_threads;
+	int i0,i1;
+
+	/*recover handle and gate: */
+	handle      = (pthread_handle*)vpthread_handle;
+	gate        = (KrigingxThreadStruct*)handle->gate;
+	my_thread   = handle->id;
+	num_threads = handle->num;
+
+	/*recover parameters :*/
+	int           n_interp     = gate->n_interp;
+	double       *x_interp     = gate->x_interp;
+	double       *y_interp     = gate->y_interp;
+	double        radius       = gate->radius;
+	int           mindata      = gate->mindata;
+	int           maxdata      = gate->maxdata;
+	Variogram    *variogram    = gate->variogram;
+	Observations *observations = gate->observations;
+	double       *predictions  = gate->predictions;
+	double       *error        = gate->error;
+	double       *percent      = gate->percent;
+
+	/*Intermediaries*/
+	int           i;
+	double        localpercent;
 
 	/*partition loop across threads: */
@@ -141,62 +235,56 @@
 		localpercent=percent[0];
 		for(i=1;i<num_threads;i++) localpercent=min(localpercent,percent[i]);
-		printf("\r      interpolation progress: %5.2lf%%",localpercent);
-
-		/*Get list of observations for current point*/
-		observations->ObservationList(&x,&y,&obs,&n_obs,x_interp[idx],y_interp[idx],radius,maxdata);
-		if(n_obs<mindata){
-			predictions[idx] = -999.0; 
-			error[idx]       = -999.0; 
-			continue;
-		}
-
-		/*Allocate intermediary matrix and vectors*/
-
-		Gamma  = (double*)xmalloc(n_obs*n_obs*sizeof(double));
-		gamma0 = (double*)xmalloc(n_obs*sizeof(double));
-		ones   = (double*)xmalloc(n_obs*sizeof(double));
-
-		/*First: Create semivariogram matrix for observations*/
-		for(i=0;i<n_obs;i++){
-			for(j=0;j<=i;j++){
-				//Gamma[i*n_obs+j] = variogram->SemiVariogram(x[i]-x[j],y[i]-y[j]);
-				Gamma[i*n_obs+j] = variogram->Covariance(x[i]-x[j],y[i]-y[j]);
-				Gamma[j*n_obs+i] = Gamma[i*n_obs+j];
-			}
-		}
-		for(i=0;i<n_obs;i++) ones[i]=1;
-
-		/*Get semivariogram vector associated to this location*/
-		//for(i=0;i<n_obs;i++) gamma0[i] = variogram->SemiVariogram(x[i]-x_interp[idx],y[i]-y_interp[idx]);
-		for(i=0;i<n_obs;i++) gamma0[i] = variogram->Covariance(x[i]-x_interp[idx],y[i]-y_interp[idx]);
-
-		/*Solve the three linear systems*/
-		GslSolve(&GinvG0,Gamma,gamma0,n_obs); // Gamma^-1 gamma0
-		GslSolve(&Ginv1, Gamma,ones,n_obs);   // Gamma^-1 ones
-		GslSolve(&GinvZ, Gamma,obs,n_obs);    // Gamma^-1 Z
-
-		/*Prepare predictor*/
-		numerator=-1.; denominator=0.;
-		for(i=0;i<n_obs;i++) numerator  +=GinvG0[i];
-		for(i=0;i<n_obs;i++) denominator+=Ginv1[i];
-		ratio=numerator/denominator;
-
-		predictions[idx] = 0.;
-		error[idx]       = - numerator*numerator/denominator;
-		for(i=0;i<n_obs;i++) predictions[idx] += (gamma0[i]-ratio)*GinvZ[i];
-		for(i=0;i<n_obs;i++) error[idx] += gamma0[i]*GinvG0[i];
-
-		/*clean-up*/
-		xfree((void**)&x);
-		xfree((void**)&y);
-		xfree((void**)&obs);
-		xfree((void**)&Gamma);
-		xfree((void**)&gamma0);
-		xfree((void**)&ones);
-		xfree((void**)&GinvG0);
-		xfree((void**)&Ginv1);
-		xfree((void**)&GinvZ);
-	}
-
+		if(my_thread==0) _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<localpercent<<"%");
+
+		observations->InterpolationNearestNeighbor(&predictions[idx],x_interp[idx],y_interp[idx],radius);
+	}
+
+	return NULL;
+}/*}}}*/
+/*FUNCTION idwt{{{*/
+void* idwt(void* vpthread_handle){
+
+	/*gate variables :*/
+	KrigingxThreadStruct *gate        = NULL;
+	pthread_handle       *handle      = NULL;
+	int my_thread;
+	int num_threads;
+	int i0,i1;
+
+	/*recover handle and gate: */
+	handle      = (pthread_handle*)vpthread_handle;
+	gate        = (KrigingxThreadStruct*)handle->gate;
+	my_thread   = handle->id;
+	num_threads = handle->num;
+
+	/*recover parameters :*/
+	int           n_interp     = gate->n_interp;
+	double       *x_interp     = gate->x_interp;
+	double       *y_interp     = gate->y_interp;
+	double        radius       = gate->radius;
+	int           mindata      = gate->mindata;
+	int           maxdata      = gate->maxdata;
+	Variogram    *variogram    = gate->variogram;
+	Observations *observations = gate->observations;
+	double       *predictions  = gate->predictions;
+	double       *error        = gate->error;
+	double       *percent      = gate->percent;
+
+	/*Intermediaries*/
+	double localpercent;
+	double  power = 2.;
+
+	/*partition loop across threads: */
+	PartitionRange(&i0,&i1,n_interp,num_threads,my_thread);
+	for(int idx=i0;idx<i1;idx++){
+
+		/*Print info*/
+		percent[my_thread]=double(idx-i0)/double(i1-i0)*100.;
+		localpercent=percent[0];
+		for(int i=1;i<num_threads;i++) localpercent=min(localpercent,percent[i]);
+		if(my_thread==0) _printString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<localpercent<<"%");
+
+		observations->InterpolationIDW(&predictions[idx],x_interp[idx],y_interp[idx],radius,mindata,maxdata,power);
+	}
 	return NULL;
 }/*}}}*/
@@ -214,50 +302,10 @@
 		else if(strcmp(model,"spherical")==0)   variogram = new SphericalVariogram(options);
 		else if(strcmp(model,"power")==0)       variogram = new PowerVariogram(options);
-		else _error_("variogram %s not supported yet (list of supported variogram: gaussian, exponential, spherical and power)",model);
+		else _error2_("variogram " << model << " not supported yet (list of supported variogram: gaussian, exponential, spherical and power)");
 	}
 	else variogram = new GaussianVariogram(options);
 
 	/*Assign output pointer*/
-	xfree((void**)&model);
+	xDelete<char>(model);
 	*pvariogram = variogram;
 }/*}}}*/
-void GslSolve(double** pX,double* A,double* B,int n){/*{{{*/
-#ifdef _HAVE_GSL_
-
-		/*GSL Matrices and vectors: */
-		int              s;
-		gsl_matrix_view  a;
-		gsl_vector_view  b;
-		gsl_vector      *x = NULL;
-		gsl_permutation *p = NULL;
-
-		/*A will be modified by LU decomposition. Use copy*/
-		double* Acopy = (double*)xmalloc(n*n*sizeof(double));
-		memcpy(Acopy,A,n*n*sizeof(double));
-
-		/*Initialize gsl matrices and vectors: */
-		a = gsl_matrix_view_array (Acopy,n,n);
-		b = gsl_vector_view_array (B,n);
-		x = gsl_vector_alloc (n);
-
-		/*Run LU and solve: */
-		p = gsl_permutation_alloc (n);
-		gsl_linalg_LU_decomp (&a.matrix, p, &s);
-		gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x);
-
-		//printf ("x = \n");
-		//gsl_vector_fprintf (stdout, x, "%g");
-
-		/*Copy result*/
-		double* X = (double*)xmalloc(n*sizeof(double));
-		memcpy(X,gsl_vector_ptr(x,0),n*sizeof(double));
-
-		/*Clean up and assign output pointer*/
-		xfree((void**)&Acopy);
-		gsl_permutation_free(p);
-		gsl_vector_free(x);
-		*pX=X;
-#else
-		_error_("GSL support required");
-#endif
-	}/*}}}*/
Index: /issm/trunk/src/c/modules/Krigingx/Krigingx.h
===================================================================
--- /issm/trunk/src/c/modules/Krigingx/Krigingx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/Krigingx/Krigingx.h	(revision 12706)
@@ -13,6 +13,6 @@
 
 int  Krigingx(double** ppredictions,double **perror,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp,Options* options);
+int  pKrigingx(double** ppredictions,double **perror,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp,Options* options);
 void ProcessVariogram(Variogram **pvariogram,Options* options);
-void GslSolve(double** pX,double* A,double* B,int n);
 
 /*threading: */
@@ -32,3 +32,5 @@
 
 void* Krigingxt(void*);
+void* NearestNeighbort(void*);
+void* idwt(void*);
 #endif /* _KRIGINGX_H */
Index: /issm/trunk/src/c/modules/Krigingx/pKrigingx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Krigingx/pKrigingx.cpp	(revision 12706)
+++ /issm/trunk/src/c/modules/Krigingx/pKrigingx.cpp	(revision 12706)
@@ -0,0 +1,135 @@
+/*!\file:  Kriging.cpp
+ * \brief  "c" core code for Kriging
+ */ 
+
+#include "./Krigingx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../toolkits/toolkits.h"
+#include "../../objects/objects.h"
+#include "../../Container/Container.h"
+#include "../../io/io.h"
+
+/*FUNCTION pKrigingx{{{*/
+int pKrigingx(double** ppredictions,double **perror,double* obs_x, double* obs_y, double* obs_list, int obs_length,double* x_interp,double* y_interp,int n_interp,Options* options){
+
+	extern int num_procs;
+	extern int my_rank;
+
+	/*output*/
+	double *predictions = NULL;
+	double *error       = NULL;
+
+	/*Intermediaries*/
+	int           mindata,maxdata;
+	double        radius;
+	char         *output       = NULL;
+	Variogram    *variogram    = NULL;
+	Observations *observations = NULL;
+
+	/*Get some Options*/
+	options->Get(&radius,"searchradius",0.);
+	options->Get(&mindata,"mindata",1);
+	options->Get(&maxdata,"maxdata",50);
+
+	/*Process observation dataset*/
+	observations=new Observations(obs_list,obs_x,obs_y,obs_length,options);
+
+	/*Allocate output*/
+	predictions =xNewZeroInit<double>(n_interp);
+	error       =xNewZeroInit<double>(n_interp);
+
+	/*Get output*/
+	options->Get(&output,"output","prediction");
+
+	if(strcmp(output,"quadtree")==0){
+		observations->QuadtreeColoring(predictions,x_interp,y_interp,n_interp);
+	}
+	else if(strcmp(output,"variomap")==0){
+		observations->Variomap(predictions,x_interp,n_interp);
+	}
+	else if(strcmp(output,"prediction")==0){
+
+		/*Process Variogram*/
+		ProcessVariogram(&variogram,options);
+
+		/*partition loop across threads: */
+		for(int idx=my_rank;idx<n_interp;idx+=num_procs){
+			_pprintString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(idx)/double(n_interp)*100<<"%");
+			observations->InterpolationKriging(&predictions[idx],&error[idx],x_interp[idx],y_interp[idx],radius,mindata,maxdata,variogram);
+		}
+		_pprintLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
+
+#ifdef _HAVE_MPI_
+		double *sumpredictions =xNew<double>(n_interp);
+		double *sumerror       =xNew<double>(n_interp);
+		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
+		MPI_Allreduce(error,sumerror,n_interp,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
+		xDelete<double>(error); error=sumerror;
+		xDelete<double>(predictions); predictions=sumpredictions;
+#endif
+	}
+	else if(strcmp(output,"nearestneighbor")==0){
+
+		/*partition loop across threads: */
+		for(int idx=my_rank;idx<n_interp;idx+=num_procs){
+			_pprintString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(idx)/double(n_interp)*100<<"%");
+			observations->InterpolationNearestNeighbor(&predictions[idx],x_interp[idx],y_interp[idx],radius);
+		}
+		_pprintLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
+
+#ifdef _HAVE_MPI_
+		double *sumpredictions =xNew<double>(n_interp);
+		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
+		xDelete<double>(predictions); predictions=sumpredictions;
+#endif
+	}
+	else if(strcmp(output,"idw")==0){
+		double power;
+		options->Get(&power,"power",2.);
+
+		/*partition loop across threads: */
+		for(int idx=my_rank;idx<n_interp;idx+=num_procs){
+			_pprintString_("\r      interpolation progress: "<<setw(6)<<setprecision(2)<<double(idx)/double(n_interp)*100<<"%");
+			observations->InterpolationIDW(&predictions[idx],x_interp[idx],y_interp[idx],radius,mindata,maxdata,power);
+		}
+		_pprintLine_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
+
+#ifdef _HAVE_MPI_
+		double *sumpredictions =xNew<double>(n_interp);
+		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
+		xDelete<double>(predictions); predictions=sumpredictions;
+#endif
+	}
+	else{
+		_error2_("output '" << output << "' not supported yet");
+	}
+
+	/*clean-up and Assign output pointer*/
+	delete variogram;
+	delete observations;
+	xDelete<char>(output);
+	*ppredictions = predictions;
+	*perror       = error;
+	return 1;
+}/*}}}*/
+void ProcessVariogram(Variogram **pvariogram,Options* options){/*{{{*/
+
+	/*Intermediaries*/
+	Variogram* variogram = NULL;
+	char      *model     = NULL;
+
+	if(options->GetOption("model")){
+		options->Get(&model,"model");
+		if     (strcmp(model,"gaussian")==0)    variogram = new GaussianVariogram(options);
+		else if(strcmp(model,"exponential")==0) variogram = new ExponentialVariogram(options);
+		else if(strcmp(model,"spherical")==0)   variogram = new SphericalVariogram(options);
+		else if(strcmp(model,"power")==0)       variogram = new PowerVariogram(options);
+		else _error2_("variogram " << model << " not supported yet (list of supported variogram: gaussian, exponential, spherical and power)");
+	}
+	else variogram = new GaussianVariogram(options);
+
+	/*Assign output pointer*/
+	xDelete<char>(model);
+	*pvariogram = variogram;
+}/*}}}*/
Index: /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Ll2xyx/Ll2xyx.cpp	(revision 12706)
@@ -52,5 +52,5 @@
 	double  T,rho,sl,tc,mc;
 
-	if((sgn!=1) && (sgn!=-1)) _error_("Sign should be either +1 or -1.\n");
+	if((sgn!=1) && (sgn!=-1)) _error2_("Sign should be either +1 or -1.\n");
 
 	delta = central_meridian;
@@ -116,12 +116,12 @@
 		*pdelta= 45;
 		*pslat = 70;
-		_printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).\n");
+		if(flag) _pprintLine_("Info: creating coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).");
 	}
 	else if (sgn == -1) {
 		*pdelta= 0;
 		*pslat = 71;
-		_printf_(flag,"Info: creating coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).\n");
+		if(flag) _pprintLine_("Info: creating coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).");
 	}
-	else _error_("Sign should be either +1 or -1.\n");
+	else _error2_("Sign should be either +1 or -1.\n");
 
 	return;
Index: /issm/trunk/src/c/modules/MassFluxx/MassFluxx.cpp
===================================================================
--- /issm/trunk/src/c/modules/MassFluxx/MassFluxx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/MassFluxx/MassFluxx.cpp	(revision 12706)
@@ -67,9 +67,9 @@
 	for(j=0;j<M;j++){
 		double* matrix=array[j];
-		xfree((void**)&matrix);
+		xDelete<double>(matrix);
 	}
-	xfree((void**)&mdims_array);
-	xfree((void**)&ndims_array);
-	xfree((void**)&array);
+	xDelete<int>(mdims_array);
+	xDelete<int>(ndims_array);
+	xDelete<double*>(array);
 	
 	/*Assign output pointers: */
Index: /issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 
 	/*Display message*/
-	_printf_(VerboseModule(),"   Merging solution vector from fset to gset\n");
+	if(VerboseModule()) _pprintLine_("   Merging solution vector from fset to gset");
 
 	/*first, get gsize, fsize and ssize: */
Index: /issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.cpp	(revision 12706)
@@ -9,6 +9,6 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,double* elements,
-		int numberofelements2d,int numberofnodes2d,double* elements2d,int numlayers,int elements_width, int dim,int num_procs){
+int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,IssmDouble* elements,
+		int numberofelements2d,int numberofnodes2d,IssmDouble* elements2d,int numlayers,int elements_width, int dim,int num_procs){
 
 	int noerr=1;
@@ -31,10 +31,10 @@
 
 	if(dim==2){
-		epart=(int*)xmalloc(numberofelements*sizeof(int));
-		npart=(int*)xmalloc(numberofnodes*sizeof(int));
-		index=(int*)xmalloc(elements_width*numberofelements*sizeof(int));
+		epart=xNew<int>(numberofelements);
+		npart=xNew<int>(numberofnodes);
+		index=xNew<int>(elements_width*numberofelements);
 		for (i=0;i<numberofelements;i++){
 			for (j=0;j<elements_width;j++){
-				*(index+elements_width*i+j)=(int)*(elements+elements_width*i+j)-1; //-1 for C indexing in Metis
+				*(index+elements_width*i+j)=reCast<int>(*(elements+elements_width*i+j))-1; //-1 for C indexing in Metis
 			}
 		}
@@ -51,5 +51,5 @@
 			for (i=0;i<numberofnodes;i++)    npart[i]=0;
 		}
-		else _error_("At least one processor is required");
+		else _error2_("At least one processor is required");
 	}
 	else{
@@ -57,11 +57,11 @@
 
 		/*First build concatenated 2d mesh  from 2d_coll and 2d_noncoll: */
-		epart2d=(int*)xmalloc(numberofelements2d*sizeof(int));
-		npart2d=(int*)xmalloc(numberofnodes2d*sizeof(int)); 
-		index2d=(int*)xmalloc(3*numberofelements2d*sizeof(int));
+		epart2d=xNew<int>(numberofelements2d);
+		npart2d=xNew<int>(numberofnodes2d); 
+		index2d=xNew<int>(3*numberofelements2d);
 
 		for (i=0;i<numberofelements2d;i++){
 			for (j=0;j<3;j++){
-				*(index2d+3*i+j)=(int)*(elements2d+3*i+j)-1; //-1 for C indexing in Metis
+				*(index2d+3*i+j)=reCast<int>(*(elements2d+3*i+j))-1; //-1 for C indexing in Metis
 			}
 		}
@@ -78,8 +78,8 @@
 			for (i=0;i<numberofnodes2d;i++)    npart2d[i]=0;
 		}
-		else _error_("At least one processor is required");
+		else _error2_("At least one processor is required");
 
 		/*Extrude epart2d to epart, using numlayers: */
-		epart=(int*)xmalloc(numberofelements*sizeof(int));
+		epart=xNew<int>(numberofelements);
 		
 		count=0;
@@ -92,5 +92,5 @@
 
 		/*Extrude npart2d to npart, using numlayers: */
-		npart=(int*)xmalloc(numberofnodes*sizeof(int));
+		npart=xNew<int>(numberofnodes);
 		
 		count=0;
@@ -108,10 +108,8 @@
 
 	/*Free ressources: */
-	xfree((void**)&index);
-	xfree((void**)&epart2d);
-	xfree((void**)&npart2d);
-	xfree((void**)&index2d);
-
+	xDelete<int>(index);
+	xDelete<int>(epart2d);
+	xDelete<int>(npart2d);
+	xDelete<int>(index2d);
 	return noerr;
-
 }
Index: /issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h
===================================================================
--- /issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h	(revision 12706)
@@ -6,7 +6,9 @@
 #define _MESHPARTITIONX_H
 
+#include "../../include/include.h"
+
 /* local prototypes: */
-int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,double* elements,
-		int numberofelements2d,int numberofnodes2d,double* elements2d,int numlayers,int elements_width, int dim,int numareas);
+int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,IssmDouble* elements,
+		int numberofelements2d,int numberofnodes2d,IssmDouble* elements2d,int numlayers,int elements_width, int dim,int numareas);
 	
 #endif /* _MESHPARTITIONX_H */
Index: /issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp	(revision 12706)
@@ -38,5 +38,5 @@
 	if(    (edge1==IntersectEnum) && (edge2==IntersectEnum) && (edge3==IntersectEnum)   ){
 		/*This case is impossible: */
-		_error_(" error: a line cannot go through 3 different vertices!");
+		_error2_("error: a line cannot go through 3 different vertices!");
 	}
 	else if(    ((edge1==IntersectEnum) && (edge2==IntersectEnum)) || ((edge2==IntersectEnum) && (edge3==IntersectEnum)) || ((edge3==IntersectEnum) && (edge1==IntersectEnum))   ){
Index: /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp	(revision 12706)
@@ -5,5 +5,4 @@
 
 void MeshProfileIntersectionx( double** psegments, int* pnumsegs, int* index, double* x, double* y, int nel, int nods,  Contour** contours,int numcontours){
-
 
 	int i,j,k;
@@ -28,6 +27,6 @@
 
 	/*Allocate: */
-	allsegments=(double**)xmalloc(numcontours*sizeof(double*));
-	allnumsegs=(int*)xmalloc(numcontours*sizeof(int));
+	allsegments=xNew<double*>(numcontours);
+	allnumsegs=xNew<int>(numcontours);
 
 	/*Loop through all contours: */
@@ -53,5 +52,5 @@
 
 	/*Out of all segments, create one common array of segments: */
-	segments=(double*)xmalloc(5*numsegs*sizeof(double));
+	segments=xNew<double>(5*numsegs);
 	count=0;
 	for(i=0;i<numcontours;i++){
Index: /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp
===================================================================
--- /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp	(revision 12706)
@@ -32,5 +32,5 @@
 	/*Using the segments_dataset dataset, create segments: */
 	numsegs=segments_dataset->Size();
-	segments=(double*)xmalloc(5*numsegs*sizeof(double));
+	segments=xNew<double>(5*numsegs);
 	for(i=0;i<numsegs;i++){
 		Segment* segment=(Segment*)segments_dataset->GetObjectByOffset(i);
Index: /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp	(revision 12706)
@@ -46,5 +46,5 @@
 
 	/*Check in 3d*/
-	if(stabilization==3 && dim==3) _error_("DG 3d not implemented yet");
+	if(stabilization==3 && dim==3) _error2_("DG 3d not implemented yet");
 
 	/*First fetch data: */
Index: /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp	(revision 12706)
@@ -63,9 +63,9 @@
 		parameters->AddObject(new DoubleVecParam(InversionMaxiterPerStepEnum,maxiter,nsteps));
 
-		xfree((void**)&control_type);
-		xfree((void**)&cm_responses);
-		xfree((void**)&cm_jump);
-		xfree((void**)&optscal);
-		xfree((void**)&maxiter);
+		xDelete<int>(control_type);
+		xDelete<double>(cm_responses);
+		xDelete<double>(cm_jump);
+		xDelete<double>(optscal);
+		xDelete<double>(maxiter);
 	}
 
Index: /issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp	(revision 12706)
@@ -48,5 +48,5 @@
 			case FrictionCoefficientEnum: iomodel->FetchData(1,FrictionCoefficientEnum); break;
 			case MaterialsRheologyBbarEnum:    iomodel->FetchData(1,MaterialsRheologyBEnum); break;
-			default: _error_("Control %s not implemented yet",EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]));
+			default: _error2_("Control " << EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]) << " not implemented yet");
 		}
 	}
Index: /issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp	(revision 12706)
@@ -124,5 +124,5 @@
 
 		default:
-			_error_("%s%s%s"," analysis_type: ",EnumToStringx(analysis_type)," not supported yet!");
+			_error2_("analysis_type: " << EnumToStringx(analysis_type) << " not supported yet!");
 	}
 
Index: /issm/trunk/src/c/modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp	(revision 12706)
@@ -23,5 +23,5 @@
 	int    numberofelements;
 	int    numberofvertices;
-	double* elements=NULL;
+	IssmDouble* elements=NULL;
 
 	/*output*/
@@ -43,5 +43,5 @@
 
 	/*Allocate ouput*/
-	connectivity=(int*)xcalloc(numberofvertices,sizeof(int));
+	connectivity=xNewZeroInit<int>(numberofvertices);
 
 	/*Get element width (3 or 6)*/
@@ -56,5 +56,5 @@
 	for (i=0;i<numberofelements;i++){
 		for (j=0;j<elementswidth;j++){
-			vertexid=(int)elements[elementswidth*i+j];
+			vertexid=reCast<int>(elements[elementswidth*i+j]);
 			_assert_(vertexid>0 && vertexid-1<numberofvertices);
 			connectivity[vertexid-1]+=1;
Index: /issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp	(revision 12706)
@@ -24,5 +24,5 @@
 	int         numoutputs;
 	Parameters *parameters       = NULL;
-	double     *requestedoutputs = NULL;
+	IssmDouble     *requestedoutputs = NULL;
 	
 	if(*pparameters)return; //do not create parameters twice!
@@ -57,5 +57,5 @@
 	parameters->AddObject(iomodel->CopyConstantObject(ThermalPenaltyFactorEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(SettingsLowmemEnum));
-	parameters->AddObject(iomodel->CopyConstantObject(DebugPetscProfilingEnum));
+	parameters->AddObject(iomodel->CopyConstantObject(DebugProfilingEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(MeshAverageVertexConnectivityEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(ConstantsReferencetemperatureEnum));
@@ -90,4 +90,5 @@
 	parameters->AddObject(iomodel->CopyConstantObject(InversionTaoEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsIspddEnum));
+	parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsIssmbgradientsEnum));
 
 	/*some parameters that did not come with the iomodel: */
@@ -105,13 +106,13 @@
 	parameters->AddObject(new IntParam(DiagnosticNumRequestedOutputsEnum,numoutputs));
 	if(numoutputs)parameters->AddObject(new IntVecParam(DiagnosticRequestedOutputsEnum,requestedoutputs,numoutputs));
-	xfree((void**)&requestedoutputs);
+	xDelete<IssmDouble>(requestedoutputs);
 	iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,TransientRequestedOutputsEnum);
 	parameters->AddObject(new IntParam(TransientNumRequestedOutputsEnum,numoutputs));
 	if(numoutputs)parameters->AddObject(new IntVecParam(TransientRequestedOutputsEnum,requestedoutputs,numoutputs));
-	xfree((void**)&requestedoutputs);
+	xDelete<IssmDouble>(requestedoutputs);
 	iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,SteadystateRequestedOutputsEnum);
 	parameters->AddObject(new IntParam(SteadystateNumRequestedOutputsEnum,numoutputs));
 	if(numoutputs)parameters->AddObject(new IntVecParam(SteadystateRequestedOutputsEnum,requestedoutputs,numoutputs));
-	xfree((void**)&requestedoutputs);
+	xDelete<IssmDouble>(requestedoutputs);
 	
 	/*Before returning, create parameters in case we are running Qmu or control types runs: */
Index: /issm/trunk/src/c/modules/ModelProcessorx/CreateSingleNodeToElementConnectivity.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/CreateSingleNodeToElementConnectivity.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/CreateSingleNodeToElementConnectivity.cpp	(revision 12706)
@@ -23,5 +23,5 @@
 	int    numberofelements;
 	int    numberofvertices;
-	double* elements=NULL;
+	IssmDouble* elements=NULL;
 
 	/*output*/
@@ -44,5 +44,5 @@
 
 	/*Allocate ouput*/
-	connectivity=(int*)xcalloc(numberofvertices,sizeof(int));
+	connectivity=xNewZeroInit<int>(numberofvertices);
 
 	/*Get element width (3 or 6)*/
@@ -59,5 +59,5 @@
 		if(iomodel->my_elements[i]){
 			for (j=0;j<elementswidth;j++){
-				vertexid=(int)elements[elementswidth*i+j];
+				vertexid=reCast<int>(elements[elementswidth*i+j]);
 				_assert_(vertexid>0 && vertexid-1<numberofvertices);
 				connectivity[vertexid-1]=i+1;
Index: /issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 void CreateParametersDakota(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type){
 
-	/*variable declarations: {{{1*/
+	/*variable declarations: {{{*/
 	int i,j,k;
 	
@@ -73,18 +73,18 @@
 		iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
-		/*name of qmu input, error and output files:{{{1*/
-		qmuinname=(char*)xmalloc((strlen(name)+strlen(".qmu.in")+1)*sizeof(char));
+		/*name of qmu input, error and output files:{{{*/
+		qmuinname=xNew<char>((strlen(name)+strlen(".qmu.in")+1));
 		sprintf(qmuinname,"%s%s",name,".qmu.in");
 		parameters->AddObject(new   StringParam(QmuInNameEnum,qmuinname));
 
-		qmuoutname=(char*)xmalloc((strlen(name)+strlen(".qmu.out")+1)*sizeof(char));
+		qmuoutname=xNew<char>((strlen(name)+strlen(".qmu.out")+1));
 		sprintf(qmuoutname,"%s%s",name,".qmu.out");
 		parameters->AddObject(new   StringParam(QmuOutNameEnum,qmuoutname));
 
-		qmuerrname=(char*)xmalloc((strlen(name)+strlen(".qmu.err")+1)*sizeof(char));
+		qmuerrname=xNew<char>((strlen(name)+strlen(".qmu.err")+1));
 		sprintf(qmuerrname,"%s%s",name,".qmu.err");
 		parameters->AddObject(new   StringParam(QmuErrNameEnum,qmuerrname));
 		/*}}}*/
-		/*Fetch variable descriptors: {{{1*/
+		/*Fetch variable descriptors: {{{*/
 		iomodel->FetchData(&variabledescriptors,&numvariabledescriptors,QmuVariabledescriptorsEnum);
 
@@ -93,5 +93,5 @@
 
 		/*}}}*/
-		/*Fetch response descriptors: {{{1*/
+		/*Fetch response descriptors: {{{*/
 		iomodel->FetchData(&responsedescriptors,&numresponsedescriptors,QmuResponsedescriptorsEnum);
 
@@ -100,5 +100,5 @@
 		parameters->AddObject(new    IntParam(QmuNumberofresponsesEnum,numberofresponses));
 		/*}}}*/
-		/*Deal with partitioning: {{{1*/
+		/*Deal with partitioning: {{{*/
 		/*partition vertices in iomodel->qmu_npart parts, unless a partition is already present: */
 		
@@ -111,10 +111,10 @@
 			ElementsAndVerticesPartitioning(&iomodel->my_elements,&iomodel->my_vertices,iomodel);
 
-			dpart=(double*)xmalloc(numberofvertices*sizeof(double));
+			dpart=xNew<double>(numberofvertices);
 			for(i=0;i<numberofvertices;i++)dpart[i]=iomodel->my_vertices[i];
 		}
 		parameters->AddObject(new DoubleVecParam(QmuPartitionEnum,dpart,numberofvertices));
 		/*}}}*/
-		/*Deal with data needed because of qmu variables: {{{1*/
+		/*Deal with data needed because of qmu variables: {{{*/
 		
 		for(i=0;i<numvariabledescriptors;i++){
@@ -136,9 +136,9 @@
 				
 				/*Free ressources:*/
-				xfree((void**)&dakota_parameter);
-			}
-		}
-		/*}}}*/
-		/*Deal with data needed to compute qmu responses: {{{1*/
+				xDelete<double>(dakota_parameter);
+			}
+		}
+		/*}}}*/
+		/*Deal with data needed to compute qmu responses: {{{*/
 		for(i=0;i<numresponsedescriptors;i++){
 			
@@ -153,5 +153,5 @@
 			/*Fetch the mass flux segments necessary to compute the mass fluxes.  Build a DoubleMatArrayParam object out of them: */ 
 			iomodel->FetchData(&array,&mdims_array,&ndims_array,&qmu_mass_flux_num_profiles,QmuMassFluxSegmentsEnum);
-			if(qmu_mass_flux_num_profiles==0)_error_(" qmu_mass_flux_num_profiles is 0, when MassFlux computations were requested!");
+			if(qmu_mass_flux_num_profiles==0)_error2_("qmu_mass_flux_num_profiles is 0, when MassFlux computations were requested!");
 
 			/*Go through segments, and extract those that belong to this cpu: */
@@ -166,5 +166,5 @@
 				}
 				if(m){
-					matrix=(double*)xcalloc(5*m,sizeof(double));
+					matrix=xNewZeroInit<double>(5*m);
 					count=0;
 					for(j=0;j<temp_m;j++){
@@ -185,5 +185,5 @@
 
 				/*Free temporary matrix: */
-				xfree((void**)&temp_matrix);
+				xDelete<double>(temp_matrix);
 			}
 
@@ -194,33 +194,33 @@
 			for(i=0;i<qmu_mass_flux_num_profiles;i++){
 				double* matrix=array[i];
-				xfree((void**)&matrix);
-			}
-			xfree((void**)&mdims_array); 
-			xfree((void**)&ndims_array);
-			xfree((void**)&array);
-		}
-		/*}}}*/
-		/*Free data: {{{1*/
+				xDelete<double>(matrix);
+			}
+			xDelete<int>(mdims_array); 
+			xDelete<int>(ndims_array);
+			xDelete<double*>(array);
+		}
+		/*}}}*/
+		/*Free data: {{{*/
 		for(i=0;i<numresponsedescriptors;i++){
 			descriptor=responsedescriptors[i];
-			xfree((void**)&descriptor);
-		}
-		xfree((void**)&responsedescriptors);
+			xDelete<char>(descriptor);
+		}
+		xDelete<char*>(responsedescriptors);
 
 		for(i=0;i<numvariabledescriptors;i++){
 			descriptor=variabledescriptors[i];
-			xfree((void**)&descriptor);
-		}
-		xfree((void**)&variabledescriptors);
-		xfree((void**)&part);
-		xfree((void**)&dpart);
-		xfree((void**)&qmuinname);
-		xfree((void**)&qmuerrname);
-		xfree((void**)&qmuoutname);
+			xDelete<char>(descriptor);
+		}
+		xDelete<char*>(variabledescriptors);
+		xDelete<int>(part);
+		xDelete<double>(dpart);
+		xDelete<char>(qmuinname);
+		xDelete<char>(qmuerrname);
+		xDelete<char>(qmuoutname);
 		/*}}}*/
 	} //if(dakota_analysis)
 
 	/*Free data*/
-	xfree((void**)&name);
+	xDelete<char>(name);
 
 	/*Assign output pointer: */
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp	(revision 12706)
@@ -87,5 +87,5 @@
 
 	/*figure out times: */
-	timesx=(double*)xmalloc(Nx*sizeof(double));
+	timesx=xNew<double>(Nx);
 	for(j=0;j<Nx;j++){
 		timesx[j]=spcvx[(Mx-1)*Nx+j];
@@ -94,5 +94,5 @@
 	UnitConversion(timesx,Nx,ExtToIuEnum,TimeEnum);
 	/*figure out times: */
-	timesy=(double*)xmalloc(Ny*sizeof(double));
+	timesy=xNew<double>(Ny);
 	for(j=0;j<Ny;j++){
 		timesy[j]=spcvy[(My-1)*Ny+j];
@@ -101,5 +101,5 @@
 	UnitConversion(timesy,Ny,ExtToIuEnum,TimeEnum);
 	/*figure out times: */
-	timesz=(double*)xmalloc(Nz*sizeof(double));
+	timesz=xNew<double>(Nz);
 	for(j=0;j<Nz;j++){
 		timesz[j]=spcvz[(Mz-1)*Nz+j];
@@ -107,5 +107,4 @@
 	/*unit conversion: */
 	UnitConversion(timesz,Nz,ExtToIuEnum,TimeEnum);
-
 
 	/*Create spcs from x,y,z, as well as the spc values on those spcs: */
@@ -121,9 +120,9 @@
 						constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 						count++;
-						if (!isnan(spcvx[i])){
+						if (!xIsNan<IssmDouble>(spcvx[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
-						if (!isnan(spcvy[i])){
+						if (!xIsNan<IssmDouble>(spcvy[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
@@ -136,9 +135,9 @@
 						constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 						count++;
-						if (!isnan(spcvx[i])){
+						if (!xIsNan<IssmDouble>(spcvx[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
-						if (!isnan(spcvy[i])){
+						if (!xIsNan<IssmDouble>(spcvy[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
@@ -146,5 +145,5 @@
 
 					}
-					else _error_("if vertices_type is MacAyealPattyn, you shoud have nodeonpattyn or nodeonmacayeal");
+					else _error2_("if vertices_type is MacAyealPattyn, you shoud have nodeonpattyn or nodeonmacayeal");
 			}
 			/*Also add spcs of coupling: zero at the border pattyn/stokes for the appropriate dofs*/
@@ -158,9 +157,9 @@
 						constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,5,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 						count++;
-						if (!isnan(spcvx[i])){
+						if (!xIsNan<IssmDouble>(spcvx[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
-						if (!isnan(spcvy[i])){
+						if (!xIsNan<IssmDouble>(spcvy[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
@@ -173,18 +172,18 @@
 						constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 						count++;
-						if (!isnan(spcvx[i])){
+						if (!xIsNan<IssmDouble>(spcvx[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
-						if (!isnan(spcvy[i])){
+						if (!xIsNan<IssmDouble>(spcvy[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
-						if (!isnan(spcvz[i])){
+						if (!xIsNan<IssmDouble>(spcvz[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,5,spcvz[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
 					}
-					else _error_("if vertices_type is PattynStokes, you shoud have nodeonpattyn or nodeonstokes");
+					else _error2_("if vertices_type is PattynStokes, you shoud have nodeonpattyn or nodeonstokes");
 			}
 			/*Also add spcs of coupling: zero at the border pattyn/stokes for the appropriate dofs*/
@@ -198,9 +197,9 @@
 						constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,5,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 						count++;
-						if (!isnan(spcvx[i])){
+						if (!xIsNan<IssmDouble>(spcvx[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
-						if (!isnan(spcvy[i])){
+						if (!xIsNan<IssmDouble>(spcvy[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
@@ -213,22 +212,22 @@
 						constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 						count++;
-						if (!isnan(spcvx[i])){
+						if (!xIsNan<IssmDouble>(spcvx[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
-						if (!isnan(spcvy[i])){
+						if (!xIsNan<IssmDouble>(spcvy[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,4,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
-						if (!isnan(spcvz[i])){
+						if (!xIsNan<IssmDouble>(spcvz[i])){
 							constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,5,spcvz[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 							count++;
 						}
 					}
-					else _error_("if vertices_type is MacAyealStokes, you shoud have nodeonmacayeal or nodeonstokes");
+					else _error2_("if vertices_type is MacAyealStokes, you shoud have nodeonmacayeal or nodeonstokes");
 			}
 			/*Now add the regular spcs*/
 			else{
-				if (Mx==numberofvertices && !isnan(spcvx[i])){
+				if (Mx==numberofvertices && !xIsNan<IssmDouble>(spcvx[i])){
 					constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 					count++;
@@ -236,9 +235,9 @@
 				else if (Mx==numberofvertices+1) {
 					/*figure out times and values: */
-					values=(double*)xmalloc(Nx*sizeof(double));
+					values=xNew<double>(Nx);
 					spcpresent=false;
 					for(j=0;j<Nx;j++){
 						values[j]=spcvx[i*Nx+j]/yts;
-						if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default
+						if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
 					}
 
@@ -247,5 +246,5 @@
 						count++;
 					}
-					xfree((void**)&values);
+					xDelete<double>(values);
 				}
 				else if (vertices_type[i]==HutterApproximationEnum){
@@ -254,5 +253,5 @@
 				}
 
-				if (My==numberofvertices && !isnan(spcvy[i])){
+				if (My==numberofvertices && !xIsNan<IssmDouble>(spcvy[i])){
 					constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vy.
 					count++;
@@ -260,9 +259,9 @@
 				else if (My==numberofvertices+1){
 					/*figure out times and values: */
-					values=(double*)xmalloc(Ny*sizeof(double));
+					values=xNew<double>(Ny);
 					spcpresent=false;
 					for(j=0;j<Ny;j++){
 						values[j]=spcvy[i*Ny+j]/yts;
-						if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default
+						if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
 					}
 					if(spcpresent){
@@ -270,5 +269,5 @@
 						count++;
 					}
-					xfree((void**)&values);
+					xDelete<double>(values);
 				}
 				else if (vertices_type[i]==HutterApproximationEnum){
@@ -278,5 +277,5 @@
 
 				if ((int)vertices_type[i]==StokesApproximationEnum ||  ((int)vertices_type[i]==NoneApproximationEnum)){
-					if (Mz==numberofvertices && !isnan(spcvz[i])){
+					if (Mz==numberofvertices && !xIsNan<IssmDouble>(spcvz[i])){
 						constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvz[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy
 						count++;
@@ -284,9 +283,9 @@
 					else if (Mz==numberofvertices+1){
 						/*figure out times and values: */
-						values=(double*)xmalloc(Nz*sizeof(double));
+						values=xNew<double>(Nz);
 						spcpresent=false;
 						for(j=0;j<Nz;j++){
 							values[j]=spcvz[i*Nz+j]/yts;
-							if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default
+							if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
 						}
 						if(spcpresent){
@@ -294,5 +293,5 @@
 							count++;
 						}
-						xfree((void**)&values);
+						xDelete<double>(values);
 					}
 
@@ -319,5 +318,5 @@
 						count++;
 						break;
-					default: _error_("Vertex approximation %s not supported",EnumToStringx((int)vertices_type[i]));
+					default: _error2_("Vertex approximation " << EnumToStringx((int)vertices_type[i]) << " not supported");
 				}
 			}
@@ -326,21 +325,21 @@
 	  
 	/*Free data: */
-	xfree((void**)&spcvx);
-	xfree((void**)&spcvy);
-	xfree((void**)&spcvz);
-	xfree((void**)&nodeonmacayeal);
-	xfree((void**)&nodeonpattyn);
-	xfree((void**)&nodeonstokes);
-	xfree((void**)&nodeonicesheet);
-	xfree((void**)&nodeonbed);
-	xfree((void**)&vertices_type);
-	xfree((void**)&surface);
-	xfree((void**)&z);
+	xDelete<double>(spcvx);
+	xDelete<double>(spcvy);
+	xDelete<double>(spcvz);
+	xDelete<double>(nodeonmacayeal);
+	xDelete<double>(nodeonpattyn);
+	xDelete<double>(nodeonstokes);
+	xDelete<double>(nodeonicesheet);
+	xDelete<double>(nodeonbed);
+	xDelete<double>(vertices_type);
+	xDelete<double>(surface);
+	xDelete<double>(z);
 
 	/*Free resources:*/
-	xfree((void**)&timesx);
-	xfree((void**)&timesy);
-	xfree((void**)&timesz);
-	xfree((void**)&values);
+	xDelete<double>(timesx);
+	xDelete<double>(timesy);
+	xDelete<double>(timesz);
+	xDelete<double>(values);
 
 	/*Assign output pointer: */
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp	(revision 12706)
@@ -120,6 +120,6 @@
 	/*Free data: */
 	iomodel->DeleteData(3,DiagnosticIcefrontEnum,ThicknessEnum,BedEnum);
-	xfree((void**)&elements_type);
-	xfree((void**)&pressureload);
+	xDelete<double>(elements_type);
+	xDelete<double>(pressureload);
 
 	/*Create Penpair for penalties: */
@@ -144,5 +144,5 @@
 
 	/*free ressources: */
-	xfree((void**)&penalties);
+	xDelete<double>(penalties);
 
 	/*Create Riffront loads for rifts: */
@@ -157,5 +157,5 @@
 		}
 		iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskVertexonfloatingiceEnum);
-		xfree((void**)&riftfront);
+		xDelete<Riftfront>(riftfront);
 	}
 
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp	(revision 12706)
@@ -60,10 +60,10 @@
 			}
 			else{
-				if (!isnan(iomodel->Data(DiagnosticSpcvxEnum)[i])){
+				if (!xIsNan<IssmDouble>(iomodel->Data(DiagnosticSpcvxEnum)[i])){
 					constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,iomodel->Data(DiagnosticSpcvxEnum)[i]/yts,DiagnosticHutterAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
 					count++;
 				}
 
-				if (!isnan(iomodel->Data(DiagnosticSpcvyEnum)[i])){
+				if (!xIsNan<IssmDouble>(iomodel->Data(DiagnosticSpcvyEnum)[i])){
 					constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,iomodel->Data(DiagnosticSpcvyEnum)[i]/yts,DiagnosticHutterAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy
 					count++;
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp	(revision 12706)
@@ -56,5 +56,5 @@
 				count++;
 			}
-			else if (!isnan(iomodel->Data(DiagnosticSpcvzEnum)[i])){
+			else if (!xIsNan<IssmDouble>(iomodel->Data(DiagnosticSpcvzEnum)[i])){
 				constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,
 								iomodel->Data(DiagnosticSpcvzEnum)[i]/yts,DiagnosticVertAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
Index: /issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp	(revision 12706)
@@ -7,5 +7,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 	
-void DistributeNumDofs(DofIndexing* index,int analysis_type,double* vertices_type){
+void DistributeNumDofs(DofIndexing* index,int analysis_type,IssmDouble* vertices_type){
 
 	/*For now, we distribute by analysis_type, later, we will distribute using the analysis_type,
@@ -35,5 +35,5 @@
 		else if (vertices_type[0]==MacAyealPattynApproximationEnum){
 			numdofs=4;
-			doftype=(int*)xmalloc(numdofs*sizeof(int));
+			doftype=xNew<int>(numdofs);
 			doftype[0]=MacAyealApproximationEnum;
 			doftype[1]=MacAyealApproximationEnum;
@@ -43,5 +43,5 @@
 		else if (vertices_type[0]==PattynStokesApproximationEnum){
 			numdofs=6;
-			doftype=(int*)xmalloc(numdofs*sizeof(int));
+			doftype=xNew<int>(numdofs);
 			doftype[0]=PattynApproximationEnum;
 			doftype[1]=PattynApproximationEnum;
@@ -53,5 +53,5 @@
 		else if (vertices_type[0]==MacAyealStokesApproximationEnum){
 			numdofs=6;
-			doftype=(int*)xmalloc(numdofs*sizeof(int));
+			doftype=xNew<int>(numdofs);
 			doftype[0]=MacAyealApproximationEnum;
 			doftype[1]=MacAyealApproximationEnum;
@@ -61,5 +61,5 @@
 			doftype[5]=StokesApproximationEnum;
 		}
-		else _error_("Approximationtype %i (%s) not implemented yet for DiagnosticHoriz",(int)*vertices_type,EnumToStringx((int)*vertices_type));
+		else _error2_("Approximationtype " << reCast<int>(*vertices_type) << " (" << EnumToStringx(reCast<int>(*vertices_type)) << ") not implemented yet for DiagnosticHoriz");
 	}
 	else if (analysis_type==DiagnosticVertAnalysisEnum){
@@ -90,5 +90,5 @@
 		numdofs=1;
 	}
-	else _error_("analysis type: %i (%s) not implemented yet",analysis_type,EnumToStringx(analysis_type));
+	else _error2_("analysis type: " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not implemented yet");
 
 	/*Now initialize the index*/
@@ -96,4 +96,4 @@
 
 	/*Clean up*/
-	 xfree((void**)&doftype);
+	 xDelete<int>(doftype);
 }
Index: /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 12706)
@@ -42,8 +42,8 @@
 	int  el1,el2;
 	int    dim;
-	double* elements=NULL;
-	double* elements2d=NULL;
-	double* riftinfo=NULL;
-	double* vertex_pairing=NULL;
+	IssmDouble* elements=NULL;
+	IssmDouble* elements2d=NULL;
+	IssmDouble* riftinfo=NULL;
+	IssmDouble* vertex_pairing=NULL;
 
 	/*Fetch parameters: */
@@ -76,6 +76,6 @@
 
 	/*Free elements and elements2d: */
-	xfree((void**)&elements);
-	xfree((void**)&elements2d);
+	xDelete<IssmDouble>(elements);
+	xDelete<IssmDouble>(elements2d);
 
 	/*Deal with rifts, they have to be included into one partition only, not several: */
@@ -83,14 +83,14 @@
 		iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftsRiftstructEnum);
 		for(i=0;i<numrifts;i++){
-			el1=(int)*(riftinfo+RIFTINFOSIZE*i+2)-1; //matlab indexing to c indexing
-			el2=(int)*(riftinfo+RIFTINFOSIZE*i+3)-1; //matlab indexing to c indexing
+			el1=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+2))-1; //matlab indexing to c indexing
+			el2=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+3))-1; //matlab indexing to c indexing
 			epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices;
 		}
-		xfree((void**)&riftinfo); 
+		xDelete<IssmDouble>(riftinfo); 
 	}
 
 	/*Used later on: */
-	my_vertices=(int*)xcalloc(numberofvertices,sizeof(int));
-	my_elements=(bool*)xcalloc(numberofelements,sizeof(bool));
+	my_vertices=xNewZeroInit<int>(numberofvertices);
+	my_elements=xNewZeroInit<bool>(numberofelements);
 
 	/*Start figuring out, out of the partition, which elements belong to this cpu: */
@@ -107,17 +107,17 @@
 			 into the vertices coordinates. If we start plugging 1 into my_vertices for each index[n][i] (i=0:2), then my_vertices 
 			 will hold which vertices belong to this partition*/
-			my_vertices[(int)*(elements+elements_width*i+0)-1]=1;
-			my_vertices[(int)*(elements+elements_width*i+1)-1]=1;
-			my_vertices[(int)*(elements+elements_width*i+2)-1]=1;
+			my_vertices[reCast<int>(*(elements+elements_width*i+0))-1]=1;
+			my_vertices[reCast<int>(*(elements+elements_width*i+1))-1]=1;
+			my_vertices[reCast<int>(*(elements+elements_width*i+2))-1]=1;
 			
 			if(elements_width==6){
-				my_vertices[(int)*(elements+elements_width*i+3)-1]=1;
-				my_vertices[(int)*(elements+elements_width*i+4)-1]=1;
-				my_vertices[(int)*(elements+elements_width*i+5)-1]=1;
+				my_vertices[reCast<int>(*(elements+elements_width*i+3))-1]=1;
+				my_vertices[reCast<int>(*(elements+elements_width*i+4))-1]=1;
+				my_vertices[reCast<int>(*(elements+elements_width*i+5))-1]=1;
 			}
 		}
 	}//for (i=0;i<numberofelements;i++)
 	/*Free data : */
-	xfree((void**)&elements);
+	xDelete<IssmDouble>(elements);
 
 	/*We might have vertex_pairing in which case, some vertices have to be cloned:
@@ -126,20 +126,20 @@
 	iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,DiagnosticVertexPairingEnum);
 	for(i=0;i<numvertex_pairing;i++){
-		if(my_vertices[(int)vertex_pairing[2*i+0]-1] && !my_vertices[(int)vertex_pairing[2*i+1]-1]){
-			my_vertices[(int)vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition
+		if(my_vertices[reCast<int>(vertex_pairing[2*i+0])-1] && !my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]){
+			my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]=2; //to know that these elements are not on the partition
 		}
 	}
-	xfree((void**)&vertex_pairing);
+	xDelete<IssmDouble>(vertex_pairing);
 	iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,PrognosticVertexPairingEnum);
 	for(i=0;i<numvertex_pairing;i++){
-		if(my_vertices[(int)vertex_pairing[2*i+0]-1] && !my_vertices[(int)vertex_pairing[2*i+1]-1]){
-			my_vertices[(int)vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition
+		if(my_vertices[reCast<int>(vertex_pairing[2*i+0])-1] && !my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]){
+			my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]=2; //to know that these elements are not on the partition
 		}
 	}
-	xfree((void**)&vertex_pairing);
+	xDelete<IssmDouble>(vertex_pairing);
 
 	/*Free ressources:*/
-	xfree((void**)&npart);
-	xfree((void**)&epart);
+	xDelete<int>(npart);
+	xDelete<int>(epart);
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp	(revision 12706)
@@ -9,4 +9,5 @@
 #include "../../../objects/objects.h"
 #include "../../../shared/shared.h"
+#include "../../../include/include.h"
 #include "../ModelProcessorx.h"
 
@@ -14,14 +15,18 @@
 
 	/*Intermediary*/
-	int i;
-	int count;
+	int    i,j;
+	int    count;
 	int    dim;
+	int    M,N;
 	int    numberofvertices;
+	bool   spcpresent=false;
 	double heatcapacity;
 	double referencetemperature;
 	
 	/*Output*/
+	IssmDouble *spcvector  = NULL;
+	IssmDouble* times=NULL;
+	IssmDouble* values=NULL;
 	Constraints* constraints = NULL;
-	SpcStatic*    spcstatic  = NULL;
 
 	/*Fetch parameters: */
@@ -44,27 +49,69 @@
 
 	/*Fetch data: */
-	double *spctemperature=NULL;
-	iomodel->FetchData(&spctemperature,NULL,NULL,ThermalSpctemperatureEnum);
+	iomodel->FetchData(&spcvector,&M,&N,ThermalSpctemperatureEnum);
 
-	/*Initialize counter*/
-	count=0;
+	//FIX ME: SHOULD USE IOMODELCREATECONSTRAINTS 
+	/*Transient or static?:*/
+	if(M==numberofvertices){
+		/*static: just create Constraints objects*/
+		count=0;
 
-	/*Create constraints from x,y,z: */
-	for (i=0;i<numberofvertices;i++){
-		/*keep only this partition's nodes:*/
-		if((iomodel->my_vertices[i])){
+		for (i=0;i<numberofvertices;i++){
+			/*keep only this partition's nodes:*/
+			if((iomodel->my_vertices[i])){
 
-			if (!isnan(spctemperature[i])){
+				if (!xIsNan<IssmDouble>(spcvector[i])){
 
-				constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spctemperature[i]-referencetemperature),EnthalpyAnalysisEnum));
-				count++;
+					constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spcvector[i]-referencetemperature),EnthalpyAnalysisEnum));
+					count++;
 
+				}
 			}
 		}
 	}
+	else if (M==(numberofvertices+1)){
+		/*transient: create transient SpcTransient objects. Same logic, except we need to retrieve 
+		 * various times and values to initialize an SpcTransient object: */
+		count=0;
 
-	/*Free data: */
-	xfree((void**)&spctemperature);
-	
+		/*figure out times: */
+		times=xNew<IssmDouble>(N);
+		for(j=0;j<N;j++){
+			times[j]=spcvector[(M-1)*N+j];
+		}
+		/*unit conversion: */
+		UnitConversion(times,N,ExtToIuEnum,TimeEnum);
+
+		/*Create constraints from x,y,z: */
+		for (i=0;i<numberofvertices;i++){
+			
+			/*keep only this partition's nodes:*/
+			if((iomodel->my_vertices[i])){
+
+				/*figure out times and values: */
+				values=xNew<IssmDouble>(N);
+				spcpresent=false;
+				for(j=0;j<N;j++){
+					values[j]=heatcapacity*(spcvector[i*N+j]-referencetemperature);
+					if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
+				}
+
+				if(spcpresent){
+					constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,N,times,values,EnthalpyAnalysisEnum));
+					count++;
+				}
+				xDelete<IssmDouble>(values);
+			}
+		}
+	}
+	else{
+		_error2_("Size of field " << EnumToStringx(ThermalSpctemperatureEnum) << " not supported");
+	}
+
+	/*Free ressources:*/
+	xDelete<IssmDouble>(spcvector);
+	xDelete<IssmDouble>(times);
+	xDelete<IssmDouble>(values);
+
 	/*Assign output pointer: */
 	*pconstraints=constraints;
Index: /issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp	(revision 12706)
@@ -26,5 +26,5 @@
 
 	/*if 2d: Error*/
-	if (dim==2) _error_("2d meshes not supported yet");
+	if (dim==2) _error2_("2d meshes not supported yet");
 
 	/*Recover pointer: */
Index: /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	(revision 12706)
@@ -68,5 +68,5 @@
 		if(solution_type==SteadystateSolutionEnum && analysis_type==EnthalpyAnalysisEnum && isenthalpy==false) continue;
 	
-		_printf_(VerboseMProcessor(),"   creating datasets for analysis %s\n",EnumToStringx(analysis_type));
+		if(VerboseMProcessor()) _pprintLine_("   creating datasets for analysis " << EnumToStringx(analysis_type));
 		CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,&parameters,iomodel,solution_type,analysis_type,nummodels,i);
 	}
Index: /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 12706)
@@ -108,5 +108,5 @@
 
 /*Distribution of dofs: */
-void DistributeNumDofs(DofIndexing* index,int analysis_type,double* vertices_type);
+void DistributeNumDofs(DofIndexing* index,int analysis_type,IssmDouble* vertices_type);
 
 #endif
Index: /issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp	(revision 12706)
@@ -24,5 +24,5 @@
 	
 	/*First thing, this is a new partition for a new analysis_type, therefore, to avoid a leak, erase the nodes partition that might come through pmy_nodes: */
-	xfree((void**)pmy_nodes);
+	xDelete<bool>(*pmy_nodes);
 
 	/*Now, depending on whether we are running galerkin discontinous or continuous elements, carry out a different partition of the nodes: */
@@ -44,6 +44,6 @@
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
-	my_nodes=(bool*)xmalloc(numberofvertices*sizeof(bool));
-	memcpy(my_nodes,my_vertices,numberofvertices*sizeof(bool));
+	my_nodes=xNew<bool>(numberofvertices);
+	for(int i=0;i<numberofvertices;i++) my_nodes[i]=(bool)my_vertices[i];
 
 	/*Assign output pointers:*/
@@ -69,11 +69,11 @@
 	bool*   my_nodes=NULL;
 
-	int     i1,i2;
-	int     cols;
-	double  e1,e2;
-	int     pos;
-	int     numberofedges;
-	double* edges=NULL;
-	double* elements=NULL;
+	int  i1,i2;
+	int  cols;
+	int  e1,e2;
+	int  pos;
+	int  numberofedges;
+	int *edges         = NULL;
+	int *elements      = NULL;
 
 	/*Fetch parameters: */
@@ -90,5 +90,5 @@
 
 	/*Allocate*/
-	my_nodes=(bool*)xcalloc(3*numberofelements,sizeof(int));
+	my_nodes=xNewZeroInit<bool>(3*numberofelements);
 
 	/*First: add all the nodes of all the elements belonging to this cpu*/
@@ -96,12 +96,12 @@
 		for (i=0;i<numberofelements;i++){
 			if (my_elements[i]){
-				my_nodes[3*i+0]=1;
-				my_nodes[3*i+1]=1;
-				my_nodes[3*i+2]=1;
+				my_nodes[3*i+0]=true;
+				my_nodes[3*i+1]=true;
+				my_nodes[3*i+2]=true;
 			}
 		}
 	}
 	else{
-		_error_("not implemented yet");
+		_error2_("not implemented yet");
 	}
 
@@ -111,5 +111,5 @@
 	iomodel->FetchData(&edges,&numberofedges,&cols,MeshEdgesEnum);
 	iomodel->FetchData(&elements,NULL,NULL,MeshElementsEnum);
-	if (cols!=4) _error_("field edges should have 4 columns");
+	if (cols!=4) _error2_("field edges should have 4 columns");
 
 	/*!All elements have been partitioned above, only create elements for this CPU: */
@@ -125,14 +125,14 @@
 		 * we must clone the nodes on this partition so that the loads (Numericalflux)
 		 * will have access to their properties (dofs,...)*/
-		if(my_elements[(int)e1] && !isnan(e2) && !my_elements[(int)e2]){ 
+		if(my_elements[e1] && e2!=-2 && !my_elements[e2]){
 
 			/*1: Get vertices ids*/
-			i1=(int)edges[4*i+0];
-			i2=(int)edges[4*i+1];
+			i1=edges[4*i+0];
+			i2=edges[4*i+1];
 
 			/*2: Get the column where these ids are located in the index*/
 			pos=UNDEF;
 			for(j=0;j<3;j++){
-				if ((int)elements[3*(int)e2+j]==i1) pos=j;
+				if (elements[3*e2+j]==i1) pos=j;
 			}
 
@@ -140,17 +140,17 @@
 			 * we can now create the corresponding nodes:*/
 			if (pos==0){
-				my_nodes[(int)e2*3+0]=1;
-				my_nodes[(int)e2*3+2]=1;
+				my_nodes[e2*3+0]=true;
+				my_nodes[e2*3+2]=true;
 			}
 			else if(pos==1){
-				my_nodes[(int)e2*3+1]=1;
-				my_nodes[(int)e2*3+0]=1;
+				my_nodes[e2*3+1]=true;
+				my_nodes[e2*3+0]=true;
 			}
 			else if (pos==2){
-				my_nodes[(int)e2*3+2]=1;
-				my_nodes[(int)e2*3+1]=1;
+				my_nodes[e2*3+2]=true;
+				my_nodes[e2*3+1]=true;
 			}
 			else{
-				_error_("Problem in edges creation");
+				_error2_("Problem in edges creation");
 			}
 		}
@@ -158,6 +158,6 @@
 
 	/*Free data: */
-	xfree((void**)&elements);
-	xfree((void**)&edges);
+	xDelete<int>(elements);
+	xDelete<int>(edges);
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp	(revision 12706)
@@ -47,5 +47,5 @@
 
 			/*Get left and right elements*/
-			element=(int)(iomodel->Data(MeshEdgesEnum)[4*i+2])-1; //edges are [node1 node2 elem1 elem2]
+			element=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2])-1; //edges are [node1 node2 elem1 elem2]
 
 			/*Now, if this element is not in the partition, pass: */
@@ -61,6 +61,6 @@
 
 	/*Create Penpair for vertex_pairing: */
-	double *vertex_pairing=NULL;
-	double *nodeonbed=NULL;
+	IssmDouble *vertex_pairing=NULL;
+	IssmDouble *nodeonbed=NULL;
 	iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,PrognosticVertexPairingEnum);
 	iomodel->FetchData(&nodeonbed,NULL,NULL,MeshVertexonbedEnum);
@@ -68,15 +68,15 @@
 	for(i=0;i<numvertex_pairing;i++){
 
-		if(iomodel->my_vertices[(int)vertex_pairing[2*i+0]-1]){
+		if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){
 
 			/*In debugging mode, check that the second node is in the same cpu*/
-			_assert_(iomodel->my_vertices[(int)vertex_pairing[2*i+1]-1]);
+			_assert_(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]);
 
 			/*Skip if one of the two is not on the bed*/
-			if(!nodeonbed[(int)vertex_pairing[2*i+0]-1] || !nodeonbed[(int)vertex_pairing[2*i+1]-1]) continue;
+			if(!(reCast<bool>(nodeonbed[reCast<int>(vertex_pairing[2*i+0])-1])) || !(reCast<bool>(nodeonbed[reCast<int>(vertex_pairing[2*i+1])-1]))) continue;
 
 			/*Get node ids*/
-			penpair_ids[0]=iomodel->nodecounter+(int)vertex_pairing[2*i+0];
-			penpair_ids[1]=iomodel->nodecounter+(int)vertex_pairing[2*i+1];
+			penpair_ids[0]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+0]);
+			penpair_ids[1]=iomodel->nodecounter+reCast<int>(vertex_pairing[2*i+1]);
 
 			/*Create Load*/
@@ -90,7 +90,6 @@
 
 	/*free ressources: */
-	xfree((void**)&vertex_pairing);
-	xfree((void**)&nodeonbed);
-
+	xDelete<IssmDouble>(vertex_pairing);
+	xDelete<IssmDouble>(nodeonbed);
 
 	/*Assign output pointer: */
Index: /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp	(revision 12706)
@@ -46,5 +46,5 @@
 
 	/*Check in 3d*/
-	if(stabilization==3 && dim==3) _error_("DG 3d not implemented yet");
+	if(stabilization==3 && dim==3) _error2_("DG 3d not implemented yet");
 
 	/*First fetch data: */
@@ -72,5 +72,5 @@
 
 					//Get index of the vertex on which the current node is located
-					vertex_id=(int)*(iomodel->Data(MeshElementsEnum)+3*i+j); //(Matlab indexing)
+					vertex_id=reCast<int>(*(iomodel->Data(MeshElementsEnum)+3*i+j)); //(Matlab indexing)
 					io_index=vertex_id-1;                      //(C indexing)
 					_assert_(vertex_id>0 && vertex_id<=numberofvertices);
Index: /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp	(revision 12706)
@@ -21,4 +21,5 @@
 	bool   dakota_analysis;
 	bool   ispdd;
+	bool   issmbgradients;
 
 	/*Fetch data needed: */
@@ -29,4 +30,5 @@
 	iomodel->FetchData(1,MeshElementsEnum);
 	iomodel->Constant(&ispdd,SurfaceforcingsIspddEnum);
+	iomodel->Constant(&issmbgradients,SurfaceforcingsIssmbgradientsEnum);
 
 	/*Update elements: */
@@ -73,4 +75,13 @@
 	  iomodel->FetchDataToInput(elements,SurfaceforcingsMonthlytemperaturesEnum);
 	}
+	if(issmbgradients){
+	  iomodel->FetchDataToInput(elements,SurfaceforcingsHcEnum);
+	  iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMaxEnum);
+	  iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMinEnum);
+	  iomodel->FetchDataToInput(elements,SurfaceforcingsAPosEnum);
+	  iomodel->FetchDataToInput(elements,SurfaceforcingsBPosEnum);
+	  iomodel->FetchDataToInput(elements,SurfaceforcingsANegEnum);
+	  iomodel->FetchDataToInput(elements,SurfaceforcingsBNegEnum);
+	}
 	else{
 		iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum);
Index: /issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp	(revision 12706)
@@ -33,5 +33,5 @@
 
 	/*return if 2d mesh*/
-	if (dim==2) _error_("2d meshes not supported yet");
+	if (dim==2) _error2_("2d meshes not supported yet");
 
 	//create penalties for nodes: no node can have a temperature over the melting point
@@ -43,5 +43,5 @@
 		/*keep only this partition's nodes:*/
 		if((iomodel->my_vertices[i]==1)){
-			if (isnan(iomodel->Data(ThermalSpctemperatureEnum)[i])){ //No penalty applied on spc nodes!
+			if (xIsNan<IssmDouble>(iomodel->Data(ThermalSpctemperatureEnum)[i])){ //No penalty applied on spc nodes!
 				loads->AddObject(new Pengrid(iomodel->loadcounter+i+1,i,iomodel,ThermalAnalysisEnum));
 			}
Index: /issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp
===================================================================
--- /issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 12706)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void NodalValuex( double* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units){
+void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units){
 
 	extern int my_rank;
@@ -16,5 +16,5 @@
 	int index;
 	Element* element=NULL;
-	double value;
+	IssmDouble value;
 	int found;
 	int sumfound;
@@ -38,5 +38,5 @@
 	#ifdef _HAVE_MPI_
 	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
-	if(!sumfound)_error_("%s%i%s%s","could not find element with vertex with id",index," to compute nodal value ",EnumToStringx(natureofdataenum));
+	if(!sumfound)_error2_("could not find element with vertex with id" << index << " to compute nodal value " << EnumToStringx(natureofdataenum));
 	#endif
 
Index: /issm/trunk/src/c/modules/NodalValuex/NodalValuex.h
===================================================================
--- /issm/trunk/src/c/modules/NodalValuex/NodalValuex.h	(revision 12705)
+++ /issm/trunk/src/c/modules/NodalValuex/NodalValuex.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void NodalValuex( double* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units);
+void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units);
 
 #endif  /* _NODALVALUEX_H */
Index: /issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp
===================================================================
--- /issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp	(revision 12706)
@@ -37,5 +37,5 @@
 
 	/*Allocate connectivity: */
-	connectivity=(double*)xcalloc(nods*width,sizeof(double));
+	connectivity=xNewZeroInit<double>(nods*width);
 
 	/*Go through all elements, and for each elements, plug into the connectivity, all the nodes. 
@@ -71,5 +71,5 @@
 	 * warn the user to increase the connectivity width: */
 	for(i=0;i<nods;i++){
-		if (*(connectivity+width*i+maxels)>maxels)_error_("%s%g%s"," max connectivity width reached (",*(connectivity+width*i+maxels),")! increase width of connectivity table");
+		if (*(connectivity+width*i+maxels)>maxels)_error2_("max connectivity width reached (" << *(connectivity+width*i+maxels) << ")! increase width of connectivity table");
 	}
 
Index: /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 12706)
@@ -16,5 +16,5 @@
 #include "../../objects/objects.h"
 		
-void OutputResultsx(                    Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){
+void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){
 
 	extern int  my_rank;
@@ -46,5 +46,5 @@
 		EnumToStringx(&solutiontypestring,solutiontype);
 		results->AddObject(new StringExternalResult(results->Size()+1,SolutionTypeEnum,solutiontypestring,1,0));
-		xfree((void**)&solutiontypestring);
+		xDelete<char>(solutiontypestring);
 	}
 
@@ -68,5 +68,5 @@
 			fid=pfopen(cpu_outputfilename ,"wb");
 		}
-		xfree((void**)&outputfilename);
+		xDelete<char>(outputfilename);
 		
 		/*Add file pointer in parameters for further calls to OutputResultsx: */
Index: /issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp	(revision 12706)
@@ -27,5 +27,5 @@
 
 	/*intermediary: */
-	double* analyses=NULL;
+	IssmDouble* analyses=NULL;
 	char** strings=NULL;
 	int numanalyses;
@@ -48,6 +48,6 @@
 
 		/*Now, allocate analyses and strings: */
-		analyses=(double*)xmalloc(numanalyses*sizeof(double));
-		strings=(char**)xmalloc(numanalyses*sizeof(char*));
+		analyses=xNew<IssmDouble>(numanalyses);
+		strings=xNew<char*>(numanalyses);
 		for(i=0;i<numanalyses;i++)strings[i]=NULL; 
 
@@ -70,6 +70,6 @@
 			to the already existing options*/
 				if(strings[numanalyses-1]==NULL){
-					string=(char*)xmalloc((strlen(line)+1)*sizeof(char)); 
-					memcpy(string,line,(strlen(line)+1)*sizeof(char));
+					string=xNew<char>((strlen(line)+1)); 
+					xMemCpy<char>(string,line,(strlen(line)+1));
 
 					strings[numanalyses-1]=string;
@@ -77,16 +77,16 @@
 				else{
 					string=strings[numanalyses-1];
-					newstring=(char*)xmalloc((strlen(line)+1)*sizeof(char));
-					memcpy(newstring,line,(strlen(line)+1)*sizeof(char));
+					newstring=xNew<char>((strlen(line)+1));
+					xMemCpy<char>(newstring,line,(strlen(line)+1));
 
 					/*concatenate:*/
-					catstring=(char*)xmalloc((strlen(string)+1+strlen(newstring)+1+1)*sizeof(char)); //fit in a space " "
-					memcpy(catstring,string,(strlen(string)+1)*sizeof(char));
+					catstring=xNew<char>(strlen(string)+1+strlen(newstring)+1+1); //fit in a space " "
+					xMemCpy<char>(catstring,string,(strlen(string)+1));
 
 					strcat(catstring," ");
 					strcat(catstring,newstring);
 					strings[numanalyses-1]=catstring;
-					xfree((void**)&newstring);
-					xfree((void**)&string);
+					xDelete<char>(newstring);
+					xDelete<char>(string);
 				}
 			}
@@ -98,6 +98,6 @@
 	MPI_Bcast(&numanalyses,1,MPI_INT,0,MPI_COMM_WORLD);
 	if(my_rank!=0){
-		analyses=(double*)xmalloc(numanalyses*sizeof(double));
-		strings=(char**)xmalloc(numanalyses*sizeof(char*));
+		analyses=xNew<IssmPDouble>(numanalyses);
+		strings=xNew<char*>(numanalyses);
 	}
 	MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,MPI_COMM_WORLD);
@@ -106,10 +106,10 @@
 		char* string=strings[i];
 		if(my_rank==0){
-			if(string==NULL) _error_("PETSc options for analysis %s have been declared but were not found",EnumToStringx((int)analyses[i]));
+			if(string==NULL) _error2_("PETSc options for analysis " << EnumToStringx(reCast<int>(analyses[i])) << " have been declared but were not found");
 		}
 		if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char);
 		#ifdef _HAVE_MPI_
 		MPI_Bcast(&stringlength,1,MPI_INT,0,MPI_COMM_WORLD);
-		if(my_rank!=0)string=(char*)xmalloc(stringlength);
+		if(my_rank!=0)string=xNew<char>(stringlength);
 		MPI_Bcast(string,stringlength,MPI_CHAR,0,MPI_COMM_WORLD);
 		if(my_rank!=0)strings[i]=string;
@@ -122,8 +122,7 @@
 
 	/*Clean up and return*/
-	for(i=0;i<numanalyses;i++) xfree((void**)&strings[i]);
-	xfree((void**)&strings);
-	xfree((void**)&analyses);
+	for(i=0;i<numanalyses;i++) xDelete<char>(strings[i]);
+	xDelete<char*>(strings);
+	xDelete<IssmDouble>(analyses);
 	return;
 }
-
Index: /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
===================================================================
--- /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	(revision 12706)
@@ -39,5 +39,5 @@
 
 	/*allocate: */
-	already=(bool*)xcalloc(nods,sizeof(bool));
+	already=xNewZeroInit<bool>(nods);
 
 	/*partition loop across threads: */
@@ -45,10 +45,9 @@
 
 	/*Loop over the nodes*/
-	if (my_thread==0) printf("      loop progress:   %5.2lf %%",0.0);
-
 	for (i=i0;i<i1;i++){
 
 		/*display current iteration*/
-		if (my_thread==0 && fmod((double)i,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)i/nods*100*num_threads);
+		if (my_thread==0 && fmod((double)i,(double)100)==0)
+		 _printString_("\r      loop progress: "<<setw(6)<<setprecision(2)<<double(i-i0)/double(i1-i0)*100<<"%");
 
 		distance=mindistance+100; //make sure initialization respects min distance criterion.
@@ -70,8 +69,9 @@
 		}
 	}
-	if (my_thread==0) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
+	if (my_thread==0)
+	 _printLine_("\r      loop progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%");
 
 	/*Free ressources:*/
-	xfree((void**)&already);
+	xDelete<bool>(already);
 	
 	return NULL;
Index: /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp
===================================================================
--- /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp	(revision 12706)
@@ -23,23 +23,23 @@
 
   int    i, it, jj, itm;
-  double DT = 0.02, sigfac, snormfac;
-  double signorm = 5.5;      // signorm : sigma of the temperature distribution for a normal day 
-  double siglim;       // sigma limit for the integration which is equal to 2.5 sigmanorm
-  double signormc = signorm - 0.5;     // sigma of the temperature distribution for cloudy day
-  double siglimc, siglim0, siglim0c;
-  double tstep, tsint, tint, tstepc;
+  IssmDouble DT = 0.02, sigfac, snormfac;
+  IssmDouble signorm = 5.5;      // signorm : sigma of the temperature distribution for a normal day 
+  IssmDouble siglim;       // sigma limit for the integration which is equal to 2.5 sigmanorm
+  IssmDouble signormc = signorm - 0.5;     // sigma of the temperature distribution for cloudy day
+  IssmDouble siglimc, siglim0, siglim0c;
+  IssmDouble tstep, tsint, tint, tstepc;
   int    NPDMAX = 1504, NPDCMAX = 1454;
-  //double pdds[NPDMAX]={0}; 
-  //double pds[NPDCMAX]={0};
-  double pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
-  double PDup, PDCUT = 2.0;    // PDcut: rain/snow cutoff temperature (C)
-  double tstar; // monthly mean surface temp
+  //IssmDouble pdds[NPDMAX]={0}; 
+  //IssmDouble pds[NPDCMAX]={0};
+  IssmDouble pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
+  IssmDouble PDup, PDCUT = 2.0;    // PDcut: rain/snow cutoff temperature (C)
+  IssmDouble tstar; // monthly mean surface temp
   
-  double* pdds=NULL; 
-  double* pds=NULL; 
+  IssmDouble* pdds=NULL; 
+  IssmDouble* pds=NULL; 
   Element* element = NULL;
   
-  pdds=(double*)xmalloc(NPDMAX*sizeof(double)+1); 
-  pds=(double*)xmalloc(NPDCMAX*sizeof(double)+1); 
+  pdds=xNew<IssmDouble>(NPDMAX+1); 
+  pds=xNew<IssmDouble>(NPDCMAX+1); 
   
   // initialize PDD (creation of a lookup table)
@@ -54,8 +54,8 @@
   PDup = siglimc+PDCUT;
 
-  itm = (int)(2*siglim/DT + 1.5);
+  itm = reCast<int,IssmDouble>((2*siglim/DT + 1.5));
   
   if (itm >= NPDMAX){
-    printf("increase NPDMAX in massBalance.cpp\n");
+    _printLine_("increase NPDMAX in massBalance.cpp");
     exit (1);
       }
@@ -81,7 +81,7 @@
   snormfac = 1.0/(signormc*sqrt(2.0*acos(-1.0)));
   siglimc = 2.5*signormc ;
-  itm = (int)((PDCUT+2.*siglimc)/DT + 1.5);
+  itm = reCast<int,IssmDouble>((PDCUT+2.*siglimc)/DT + 1.5);
   if (itm >= NPDCMAX){
-    printf("'increase NPDCMAX in p35com'\n");
+    _printLine_("'increase NPDCMAX in p35com'");
     exit (1);
       }
@@ -106,6 +106,6 @@
   }
   /*free ressouces: */
-  xfree((void**)&pdds);
-  xfree((void**)&pds);
+  xDelete<IssmDouble>(pdds);
+  xDelete<IssmDouble>(pds);
   
 }
Index: /issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp	(revision 12706)
@@ -22,5 +22,5 @@
 	int         verbose;
 
-	_printf_(VerboseModule(),"   Dirichlet lifting applied to load vector\n");
+	if(VerboseModule()) _pprintLine_("   Dirichlet lifting applied to load vector");
 
 	Kfs->GetSize(&global_m,&global_n);
Index: /issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 	int configuration_type;
 	int fsize;
-	double* ug_serial=NULL;
+	IssmDouble* ug_serial=NULL;
 
 	/*first figure out fsize: */
@@ -51,5 +51,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&ug_serial);
+	xDelete<IssmDouble>(ug_serial);
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp	(revision 12706)
@@ -51,5 +51,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&yg_serial);
+	xDelete<double>(yg_serial);
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/modules/RequestedOutputsx/RequestedOutputsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/RequestedOutputsx/RequestedOutputsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/RequestedOutputsx/RequestedOutputsx.cpp	(revision 12706)
@@ -13,6 +13,6 @@
 	int      output_enum;
 	int      step;
-	double   time;
-	double   output_value;
+	IssmDouble   time;
+	IssmDouble   output_value;
 	Element *element      = NULL;
 
Index: /issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp	(revision 12706)
@@ -22,5 +22,5 @@
 
 	/*Display message*/
-	_printf_(VerboseModule(),"   Resetting penalties\n");
+	if(VerboseModule()) _pprintLine_("   Resetting penalties");
 
 	/*recover parameters: */
@@ -30,5 +30,5 @@
 	 * management routine, otherwise, skip : */
 	if (RiftIsPresent(loads,analysis_type)){
-		_error_("rift constraints reset not supported yet!");
+		_error2_("rift constraints reset not supported yet!");
 	}
 	else if(ThermalIsPresent(loads,analysis_type)){
Index: /issm/trunk/src/c/modules/Responsex/Responsex.cpp
===================================================================
--- /issm/trunk/src/c/modules/Responsex/Responsex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Responsex/Responsex.cpp	(revision 12706)
@@ -16,5 +16,5 @@
 #include "../modules.h"
 
-void Responsex(double* responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,const char* response_descriptor,bool process_units,int weight_index){
+void Responsex(IssmDouble* responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,const char* response_descriptor,bool process_units,int weight_index){
 
 	switch (StringToEnumx(response_descriptor)){
@@ -46,7 +46,7 @@
 		case VelEnum:ElementResponsex(responses, elements,nodes, vertices, loads, materials, parameters,VelEnum,process_units); break;
 		case FrictionCoefficientEnum:NodalValuex(responses, FrictionCoefficientEnum,elements,nodes, vertices, loads, materials, parameters,process_units); break;
-		default: _error_(" response descriptor \"%s\" not supported yet!",response_descriptor); break;
+		default: _error2_("response descriptor \"" << response_descriptor << "\" not supported yet!"); break;
 		#else
-		default: _error_(" ISSM was not compiled with responses capabilities, exiting!");
+		default: _error2_("ISSM was not compiled with responses capabilities, exiting!");
 		#endif
 	}
Index: /issm/trunk/src/c/modules/Responsex/Responsex.h
===================================================================
--- /issm/trunk/src/c/modules/Responsex/Responsex.h	(revision 12705)
+++ /issm/trunk/src/c/modules/Responsex/Responsex.h	(revision 12706)
@@ -9,5 +9,5 @@
 #include "../../Container/Container.h"
 
-void Responsex(double* presponse,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,const char* response_descriptor,bool process_units,int weight_index);
+void Responsex(IssmDouble* presponse,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,const char* response_descriptor,bool process_units,int weight_index);
 
 #endif  /* _RESPONSESXX_H */
Index: /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp	(revision 12706)
@@ -25,5 +25,5 @@
 	}
 
-	xfree((void**)&control_type);
+	xDelete<int>(control_type);
 }
 
@@ -37,4 +37,4 @@
 
 	/*Free ressources:*/
-	xfree((void**)&serial_vector);
+	xDelete<double>(serial_vector);
 }
Index: /issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp	(revision 12706)
@@ -39,7 +39,7 @@
 	int     nshape,ncoord;
 	double  cpsum;
-	int     *pstype=NULL,*pnpart=NULL,**ppstrt=NULL,**pptype=NULL,*pnvert=NULL;
-	double  **pshapx=NULL,**pshapy=NULL,**pshapz=NULL,**pshapm=NULL;
-	double  *lat=NULL,*lon=NULL;
+	int     *pstype = NULL, *pnpart=NULL,**ppstrt=NULL,**pptype=NULL,*pnvert=NULL;
+	double **pshapx = NULL,**pshapy=NULL,**pshapz=NULL,**pshapm=NULL;
+	double  *lat    = NULL, *lon=NULL;
 
 	SHPHandle   hSHP;
@@ -49,18 +49,17 @@
 
 	char    indent[81]="";
-	KML_File*             kfile =NULL;
-	KML_Document*         kdoc  =NULL;
-	KML_Style*            kstyle=NULL;
-	KML_LineStyle*        klsty =NULL;
-	KML_PolyStyle*        kpsty =NULL;
-	KML_Folder*           kfold =NULL;
-	KML_Placemark*        kplace=NULL;
-	KML_MultiGeometry*    kmulti=NULL;
-	KML_Polygon*          kpoly =NULL;
-	KML_LinearRing*       kring =NULL;
-	KML_LineString*       kline =NULL;
-	KML_Point*            kpoint=NULL;
-
-	FILE*   fid=NULL;
+	KML_File          *kfile  = NULL;
+	KML_Document      *kdoc   = NULL;
+	KML_Style         *kstyle = NULL;
+	KML_LineStyle     *klsty  = NULL;
+	KML_PolyStyle     *kpsty  = NULL;
+	KML_Folder        *kfold  = NULL;
+	KML_Placemark     *kplace = NULL;
+	KML_MultiGeometry *kmulti = NULL;
+	KML_Polygon       *kpoly  = NULL;
+	KML_LinearRing    *kring  = NULL;
+	KML_LineString    *kline  = NULL;
+	KML_Point         *kpoint = NULL;
+	FILE              *fid    = NULL;
 
 	clock_t clock0,clock1;
@@ -69,5 +68,5 @@
 	clock0=clock();
 	time0 =time(NULL);
-	_printf_(true,"\nShp2Kmlx Module -- %s",ctime(&time0));
+	_pprintString_("\nShp2Kmlx Module -- " << ctime(&time0));
 
 /*  note that much of the following code is taken from shpdump.c in shapelib.  */
@@ -76,5 +75,5 @@
 
 	hSHP = SHPOpen( filshp, "rb" );
-	if (!hSHP) _error_("Error opening shp/shx files.");
+	if (!hSHP) _error2_("Error opening shp/shx files.");
 
 /*  read header and print out file bounds  */
@@ -97,13 +96,13 @@
 
 	nshape=nEntities;
-	pstype=(int *) xmalloc(nshape*sizeof(int));
-	pnpart=(int *) xmalloc(nshape*sizeof(int));
-	ppstrt=(int **) xmalloc(nshape*sizeof(int *));
-	pptype=(int **) xmalloc(nshape*sizeof(int *));
-	pnvert=(int *) xmalloc(nshape*sizeof(int));
-	pshapx=(double **) xmalloc(nshape*sizeof(double *));
-	pshapy=(double **) xmalloc(nshape*sizeof(double *));
-	pshapz=(double **) xmalloc(nshape*sizeof(double *));
-	pshapm=(double **) xmalloc(nshape*sizeof(double *));
+	pstype=xNew<int>(nshape);
+	pnpart=xNew<int>(nshape);
+	ppstrt=xNew<int*>(nshape);
+	pptype=xNew<int*>(nshape);
+	pnvert=xNew<int>(nshape);
+	pshapx=xNew<double*>(nshape);
+	pshapy=xNew<double*>(nshape);
+	pshapz=xNew<double*>(nshape);
+	pshapm=xNew<double*>(nshape);
 
 /*  loop over the list of shapes  */
@@ -129,6 +128,6 @@
 	pnpart[i]=psShape->nParts;
 	if (pnpart[i]) {
-		ppstrt[i]=(int *) xmalloc(pnpart[i]*sizeof(int));
-		pptype[i]=(int *) xmalloc(pnpart[i]*sizeof(int));
+		ppstrt[i]=xNew<int>(pnpart[i]);
+		pptype[i]=xNew<int>(pnpart[i]);
 	}
 	else {
@@ -138,8 +137,8 @@
 	pnvert[i]=psShape->nVertices;
 	if (pnvert[i]) {
-		pshapx[i]=(double *) xmalloc(pnvert[i]*sizeof(double));
-		pshapy[i]=(double *) xmalloc(pnvert[i]*sizeof(double));
-		pshapz[i]=(double *) xmalloc(pnvert[i]*sizeof(double));
-		pshapm[i]=(double *) xmalloc(pnvert[i]*sizeof(double));
+		pshapx[i]=xNew<double>(pnvert[i]);
+		pshapy[i]=xNew<double>(pnvert[i]);
+		pshapz[i]=xNew<double>(pnvert[i]);
+		pshapm[i]=xNew<double>(pnvert[i]);
 	}
 	else {
@@ -296,6 +295,6 @@
 			kpoint=new KML_Point();
 
-			lat=(double *) xmalloc(pnvert[i]*sizeof(double));
-			lon=(double *) xmalloc(pnvert[i]*sizeof(double));
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
 			if (sgn) {
 				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
@@ -310,6 +309,6 @@
 			kpoint->coords[2]=pshapz[i][0];
 
-			xfree((void**)&lon);
-			xfree((void**)&lat);
+			xDelete<double>(lon);
+			xDelete<double>(lat);
 
 			(kplace->geometry  )->AddObject((Object*)kpoint);
@@ -337,6 +336,6 @@
 /*  convert to lat/lon, if necessary  */
 
-			lat=(double *) xmalloc(pnvert[i]*sizeof(double));
-			lon=(double *) xmalloc(pnvert[i]*sizeof(double));
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
 			if (sgn) {
 				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
@@ -353,21 +352,20 @@
 
 				kline->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
-				kline->coords    =(double (*)[3]) xmalloc(kline->ncoord*3*sizeof(double));
+				kline->coords    =xNew<double>(kline->ncoord*3);
 				for (k=0; k<kline->ncoord; k++) {
-					kline->coords[k][0]=lon      [ppstrt[i][j]+k];
-					kline->coords[k][1]=lat      [ppstrt[i][j]+k];
-					kline->coords[k][2]=pshapz[i][ppstrt[i][j]+k];
+					kline->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+					kline->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+					kline->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
 				}
-
 				(kmulti->geometry  )->AddObject((Object*)kline);
-				kline =NULL;
-			}
-
-			xfree((void**)&lon);
-			xfree((void**)&lat);
-
-			(kplace->geometry  )->AddObject((Object*)kmulti);
+				kline = NULL;
+			}
+
+			xDelete<double>(lon);
+			xDelete<double>(lat);
+
+			(kplace->geometry)->AddObject((Object*)kmulti);
 			kmulti=NULL;
-			(kfold ->feature   )->AddObject((Object*)kplace);
+			(kfold ->feature )->AddObject((Object*)kplace);
 			kplace=NULL;
 		}
@@ -401,6 +399,6 @@
 /*  convert to lat/lon, if necessary  */
 
-			lat=(double *) xmalloc(pnvert[i]*sizeof(double));
-			lon=(double *) xmalloc(pnvert[i]*sizeof(double));
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
 			if (sgn) {
 				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
@@ -438,16 +436,16 @@
 
 					kring->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
-					kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
+					kring->coords    =xNew<double>(kring->ncoord*3);
 					if (cpsum < 0)
 						for (k=0; k<kring->ncoord; k++) {
-							kring->coords[kring->ncoord-1-k][0]=lon      [ppstrt[i][j]+k];
-							kring->coords[kring->ncoord-1-k][1]=lat      [ppstrt[i][j]+k];
-							kring->coords[kring->ncoord-1-k][2]=pshapz[i][ppstrt[i][j]+k];
+							kring->coords[3*(kring->ncoord-1-k)+0]=lon      [ppstrt[i][j]+k];
+							kring->coords[3*(kring->ncoord-1-k)+1]=lat      [ppstrt[i][j]+k];
+							kring->coords[3*(kring->ncoord-1-k)+2]=pshapz[i][ppstrt[i][j]+k];
 						}
 					else
 						for (k=0; k<kring->ncoord; k++) {
-							kring->coords[k                ][0]=lon      [ppstrt[i][j]+k];
-							kring->coords[k                ][1]=lat      [ppstrt[i][j]+k];
-							kring->coords[k                ][2]=pshapz[i][ppstrt[i][j]+k];
+							kring->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+							kring->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+							kring->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
 						}
 
@@ -470,9 +468,9 @@
 
 					kring->ncoord    =(j<pnpart[i]-1 ? ppstrt[i][j+1]-ppstrt[i][j] : pnvert[i]-ppstrt[i][j]);
-					kring->coords    =(double (*)[3]) xmalloc(kring->ncoord*3*sizeof(double));
+					kring->coords    =xNew<double>(kring->ncoord*3);
 					for (k=0; k<kring->ncoord; k++) {
-						kring->coords[k][0]=lon      [ppstrt[i][j]+k];
-						kring->coords[k][1]=lat      [ppstrt[i][j]+k];
-						kring->coords[k][2]=pshapz[i][ppstrt[i][j]+k];
+						kring->coords[3*k+0]=lon      [ppstrt[i][j]+k];
+						kring->coords[3*k+1]=lat      [ppstrt[i][j]+k];
+						kring->coords[3*k+2]=pshapz[i][ppstrt[i][j]+k];
 					}
 
@@ -487,6 +485,6 @@
 			}
 
-			xfree((void**)&lon);
-			xfree((void**)&lat);
+			xDelete<double>(lon);
+			xDelete<double>(lat);
 
 			(kplace->geometry  )->AddObject((Object*)kmulti);
@@ -518,6 +516,6 @@
 /*  convert to lat/lon, if necessary  */
 
-			lat=(double *) xmalloc(pnvert[i]*sizeof(double));
-			lon=(double *) xmalloc(pnvert[i]*sizeof(double));
+			lat=xNew<double>(pnvert[i]);
+			lon=xNew<double>(pnvert[i]);
 			if (sgn) {
 				Xy2llx(lat,lon,pshapx[i],pshapy[i],pnvert[i],sgn,cm,sp);
@@ -541,6 +539,6 @@
 			}
 
-			xfree((void**)&lon);
-			xfree((void**)&lat);
+			xDelete<double>(lon);
+			xDelete<double>(lat);
 
 			(kplace->geometry  )->AddObject((Object*)kmulti);
@@ -575,5 +573,5 @@
 /*  write kml file  */
 
-	_printf_(true,"Writing kml document to file.\n");
+	_pprintLine_("Writing kml document to file.");
 	fid=fopen(filkml,"w");
 	fprintf(fid,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
@@ -583,22 +581,22 @@
 	delete kfile;
 	for (i=nshape-1; i>=0; i--) {
-		xfree((void**)&(pshapm[i]));
-		xfree((void**)&(pshapz[i]));
-		xfree((void**)&(pshapy[i]));
-		xfree((void**)&(pshapx[i]));
-	}
-	xfree((void**)&pshapm);
-	xfree((void**)&pshapz);
-	xfree((void**)&pshapy);
-	xfree((void**)&pshapx);
-	xfree((void**)&pnvert);
+		xDelete<double>((pshapm[i]));
+		xDelete<double>((pshapz[i]));
+		xDelete<double>((pshapy[i]));
+		xDelete<double>((pshapx[i]));
+	}
+	xDelete<double*>(pshapm);
+	xDelete<double*>(pshapz);
+	xDelete<double*>(pshapy);
+	xDelete<double*>(pshapx);
+	xDelete<int>(pnvert);
 	for (i=nshape-1; i>=0; i--) {
-		xfree((void**)&(pptype[i]));
-		xfree((void**)&(ppstrt[i]));
-	}
-	xfree((void**)&pptype);
-	xfree((void**)&ppstrt);
-	xfree((void**)&pnpart);
-	xfree((void**)&pstype);
+		xDelete<int>((pptype[i]));
+		xDelete<int>((ppstrt[i]));
+	}
+	xDelete<int*>(pptype);
+	xDelete<int*>(ppstrt);
+	xDelete<int>(pnpart);
+	xDelete<int>(pstype);
 
 	clock1=clock();
Index: /issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.cpp	(revision 12706)
+++ /issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.cpp	(revision 12706)
@@ -0,0 +1,27 @@
+/*!\file SmbGradientsx
+ * \brief: calculates SMB as function of local elevation 
+ */
+
+#include "./SmbGradientsx.h"
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../io/io.h"
+#include "../../toolkits/toolkits.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+
+void SmbGradientsx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters){
+
+// void SmbGradientsx(hd,agd,ni){
+//    INPUT parameters: ni: working size of arrays
+//    INPUT: surface elevation (m): hd(NA)
+//    OUTPUT: mass-balance (m/yr ice): agd(NA)
+
+  int    i;
+  
+  Element* element = NULL;
+  
+  for(i=0;i<elements->Size();i++){
+    element=(Element*)elements->GetObjectByOffset(i);
+    element->SmbGradients();
+  }
+}
Index: /issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.h
===================================================================
--- /issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.h	(revision 12706)
+++ /issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.h	(revision 12706)
@@ -0,0 +1,14 @@
+/*!\file:  SmbGradientsx.h
+ * \brief header file for degree of freedoms distribution routines.
+ */ 
+
+#ifndef _SMBGRADIENTSX_H
+#define _SMBGRADIENTSX_H
+
+#include "../../Container/Container.h"
+#include "../../objects/objects.h"
+
+/* local prototypes: */
+void SmbGradientsx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters);
+
+#endif  /* _SMBGRADIENTSX_H*/
Index: /issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp
===================================================================
--- /issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp	(revision 12706)
@@ -20,5 +20,5 @@
 
 	int         start,end;
-	double*     df_local=NULL;
+	IssmDouble*     df_local=NULL;
 	int         df_local_size;
 	int         i;
@@ -46,6 +46,6 @@
 
 		/*Allocate indices: */
-		if(pressure_num)pressure_indices=(int*)xmalloc(pressure_num*sizeof(int));
-		if(velocity_num)velocity_indices=(int*)xmalloc(velocity_num*sizeof(int));
+		if(pressure_num)pressure_indices=xNew<int>(pressure_num);
+		if(velocity_num)velocity_indices=xNew<int>(velocity_num);
 
 		pressure_count=0;
@@ -74,6 +74,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&pressure_indices);
-	xfree((void**)&velocity_indices);
+	xDelete<int>(pressure_indices);
+	xDelete<int>(velocity_indices);
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Solverx/Solverx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Solverx/Solverx.cpp	(revision 12706)
@@ -55,5 +55,5 @@
 
 		#else
-			_error_("GSL support not compiled in!");
+			_error2_("GSL support not compiled in!");
 		#endif
 	#endif
Index: /issm/trunk/src/c/modules/Solverx/Solverx.h
===================================================================
--- /issm/trunk/src/c/modules/Solverx/Solverx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/Solverx/Solverx.h	(revision 12706)
@@ -19,9 +19,10 @@
 #ifdef _HAVE_PETSC_
 void	SolverxPetsc(Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df, Parameters* parameters);
-void    DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum);
+void  DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum);
 #endif
 
 #ifdef _HAVE_GSL_
-void	SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf);
+void SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf);
+void SolverxGsl(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n);
 #endif
 
Index: /issm/trunk/src/c/modules/Solverx/SolverxGsl.cpp
===================================================================
--- /issm/trunk/src/c/modules/Solverx/SolverxGsl.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Solverx/SolverxGsl.cpp	(revision 12706)
@@ -2,4 +2,12 @@
  * \brief Gsl implementation of solver
  */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+#include <cstring>
+#include <gsl/gsl_linalg.h>
 
 #include "./Solverx.h"
@@ -8,64 +16,63 @@
 #include "../../io/io.h"
 
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
- 
-#include <gsl/gsl_linalg.h>
-
-void	SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf){
-
-	/*intermediary: */
-	SeqMat* KffCopy=NULL;
-
-	/*Output: */
-	SeqVec*        uf               = NULL;
-
-	
-	/*GSL Matrices and vectors: */
-	gsl_matrix_view m;
-	gsl_vector_view b;
-	gsl_vector* x=NULL;
-	gsl_permutation* p=NULL;
-	
-	/*We are going to do an in place LU decomp, so we need to save the matrix with its original structure: */
-	KffCopy=Kff->Duplicate();
-
+void SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf){/*{{{*/
 
 	/*Intermediary: */
 	int M,N,N2,s;
+	SeqVec *uf = NULL;
+	IssmDouble *x  = NULL;
 
 	Kff->GetSize(&M,&N);
 	pf->GetSize(&N2);
 
-	if(N!=N2)_error_("Right hand side vector of size %i, when matrix is of size %i-%i !",N2,M,N);
-	if(M!=N)_error_("Stiffness matrix should be square!");
+	if(N!=N2)_error2_("Right hand side vector of size " << N2 << ", when matrix is of size " << M << "-" << N << " !");
+	if(M!=N)_error2_("Stiffness matrix should be square!");
+
+	SolverxGsl(&x,Kff->matrix,pf->vector,N);
+	uf=new SeqVec(x,N);
+
+	/*Assign output pointers:*/
+	*puf=uf;
+}/*}}}*/
+void SolverxGsl(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n){/*{{{*/
+
+	/*GSL Matrices and vectors: */
+	int              s;
+	gsl_matrix_view  a;
+	gsl_vector_view  b;
+	gsl_vector      *x = NULL;
+	gsl_permutation *p = NULL;
+#ifdef _HAVE_ADOLC_
+	// if we use Adol-C then the IssmDouble will be an adouble
+	// and the calls to gsl_... will not work
+	// and we should call  a suitable wrapped solve instead
+	_error2_("SolverxGsl: should not be here with Adol-C");
+#else
+	/*A will be modified by LU decomposition. Use copy*/
+	IssmDouble* Acopy = xNew<IssmDouble>(n*n);
+	xMemCpy<IssmDouble>(Acopy,A,n*n);
 
 	/*Initialize gsl matrices and vectors: */
-	m = gsl_matrix_view_array (KffCopy->matrix, M, N);
-	b = gsl_vector_view_array (pf->vector, N);
-	x = gsl_vector_alloc (N);
+	a = gsl_matrix_view_array (Acopy,n,n);
+	b = gsl_vector_view_array (B,n);
+	x = gsl_vector_alloc (n);
 
 	/*Run LU and solve: */
-	p = gsl_permutation_alloc (N);
-	gsl_linalg_LU_decomp (&m.matrix, p, &s);
-	gsl_linalg_LU_solve (&m.matrix, p, &b.vector, x);
+	p = gsl_permutation_alloc (n);
+	gsl_linalg_LU_decomp (&a.matrix, p, &s);
+	gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x);
 
 	//printf ("x = \n");
 	//gsl_vector_fprintf (stdout, x, "%g");
 
-	/*Get uf initialized with the results: */
-	uf=new SeqVec(gsl_vector_ptr(x,0),M);
+	/*Copy result*/
+	IssmDouble* X = xNew<IssmDouble>(n);
+	memcpy(X,gsl_vector_ptr(x,0),n*sizeof(IssmDouble));
 
-	/*Free resources:*/
-	gsl_permutation_free (p);
-	gsl_vector_free (x);
-
-	delete KffCopy;
-
-
-	/*Assign output pointers:*/
-	*puf=uf;
-}
+	/*Clean up and assign output pointer*/
+	xDelete<IssmDouble>(Acopy);
+	gsl_permutation_free(p);
+	gsl_vector_free(x);
+	*pX=X;
+#endif
+}/*}}}*/
Index: /issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp
===================================================================
--- /issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp	(revision 12706)
@@ -44,5 +44,5 @@
 
 	/*Display message*/
-	_printf_(VerboseModule(),"   Solving\n");
+	if(VerboseModule()) _pprintLine_("   Solving");
 	#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 	if(VerboseSolver())PetscOptionsPrint(stdout);
@@ -81,5 +81,5 @@
 		#if _PETSC_MAJOR_ >=3
 			#ifndef _HAVE_MUMPS_
-			_error_("requested MUMPS solver, which was not compiled into ISSM!\n");
+			_error2_("requested MUMPS solver, which was not compiled into ISSM!\n");
 			#endif
 		#endif
@@ -105,5 +105,5 @@
 	if (solver_type==StokesSolverEnum){
 		/*Make indices out of doftypes: */
-		if(!df)_error_("need doftypes for Stokes solver!\n");
+		if(!df)_error2_("need doftypes for Stokes solver!\n");
 		DofTypesToIndexSet(&isv,&isp,df,StokesSolverEnum);
 
@@ -136,5 +136,5 @@
 	/*Check convergence*/
 	KSPGetIterationNumber(ksp,&iteration_number);
-	if (iteration_number<0) _error_("%s%i"," Solver diverged at iteration number: ",-iteration_number);
+	if (iteration_number<0) _error2_("Solver diverged at iteration number: " << -iteration_number);
 
 	/*Free resources:*/
Index: /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp
===================================================================
--- /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp	(revision 12706)
@@ -158,8 +158,8 @@
 	      else if (strcmp(name,"SettingsResultsAsPatches")==0) return SettingsResultsAsPatchesEnum;
 	      else if (strcmp(name,"SettingsWaitonlock")==0) return SettingsWaitonlockEnum;
-	      else if (strcmp(name,"DebugPetscProfiling")==0) return DebugPetscProfilingEnum;
-	      else if (strcmp(name,"PetscProfilingCurrentMem")==0) return PetscProfilingCurrentMemEnum;
-	      else if (strcmp(name,"PetscProfilingCurrentFlops")==0) return PetscProfilingCurrentFlopsEnum;
-	      else if (strcmp(name,"PetscProfilingSolutionTime")==0) return PetscProfilingSolutionTimeEnum;
+	      else if (strcmp(name,"DebugProfiling")==0) return DebugProfilingEnum;
+	      else if (strcmp(name,"ProfilingCurrentMem")==0) return ProfilingCurrentMemEnum;
+	      else if (strcmp(name,"ProfilingCurrentFlops")==0) return ProfilingCurrentFlopsEnum;
+	      else if (strcmp(name,"ProfilingSolutionTime")==0) return ProfilingSolutionTimeEnum;
 	      else if (strcmp(name,"MaxIterationConvergenceFlag")==0) return MaxIterationConvergenceFlagEnum;
 	      else if (strcmp(name,"SteadystateMaxiter")==0) return SteadystateMaxiterEnum;
@@ -171,5 +171,13 @@
 	      else if (strcmp(name,"SurfaceforcingsMassBalance")==0) return SurfaceforcingsMassBalanceEnum;
 	      else if (strcmp(name,"SurfaceforcingsIspdd")==0) return SurfaceforcingsIspddEnum;
+	      else if (strcmp(name,"SurfaceforcingsIssmbgradients")==0) return SurfaceforcingsIssmbgradientsEnum;
 	      else if (strcmp(name,"SurfaceforcingsMonthlytemperatures")==0) return SurfaceforcingsMonthlytemperaturesEnum;
+	      else if (strcmp(name,"SurfaceforcingsHc")==0) return SurfaceforcingsHcEnum;
+	      else if (strcmp(name,"SurfaceforcingsSmbPosMax")==0) return SurfaceforcingsSmbPosMaxEnum;
+	      else if (strcmp(name,"SurfaceforcingsSmbPosMin")==0) return SurfaceforcingsSmbPosMinEnum;
+	      else if (strcmp(name,"SurfaceforcingsAPos")==0) return SurfaceforcingsAPosEnum;
+	      else if (strcmp(name,"SurfaceforcingsBPos")==0) return SurfaceforcingsBPosEnum;
+	      else if (strcmp(name,"SurfaceforcingsANeg")==0) return SurfaceforcingsANegEnum;
+	      else if (strcmp(name,"SurfaceforcingsBNeg")==0) return SurfaceforcingsBNegEnum;
 	      else if (strcmp(name,"ThermalMaxiter")==0) return ThermalMaxiterEnum;
 	      else if (strcmp(name,"ThermalPenaltyFactor")==0) return ThermalPenaltyFactorEnum;
@@ -253,5 +261,8 @@
 	      else if (strcmp(name,"DoubleParam")==0) return DoubleParamEnum;
 	      else if (strcmp(name,"DoubleVecParam")==0) return DoubleVecParamEnum;
-	      else if (strcmp(name,"Element")==0) return ElementEnum;
+         else stage=3;
+   }
+   if(stage==3){
+	      if (strcmp(name,"Element")==0) return ElementEnum;
 	      else if (strcmp(name,"ElementResult")==0) return ElementResultEnum;
 	      else if (strcmp(name,"ExternalResult")==0) return ExternalResultEnum;
@@ -261,8 +272,5 @@
 	      else if (strcmp(name,"Input")==0) return InputEnum;
 	      else if (strcmp(name,"IntInput")==0) return IntInputEnum;
-         else stage=3;
-   }
-   if(stage==3){
-	      if (strcmp(name,"IntParam")==0) return IntParamEnum;
+	      else if (strcmp(name,"IntParam")==0) return IntParamEnum;
 	      else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum;
 	      else if (strcmp(name,"MacAyeal2dIceFront")==0) return MacAyeal2dIceFrontEnum;
@@ -376,5 +384,8 @@
 	      else if (strcmp(name,"QmuTemperature")==0) return QmuTemperatureEnum;
 	      else if (strcmp(name,"HydrologyWaterVx")==0) return HydrologyWaterVxEnum;
-	      else if (strcmp(name,"HydrologyWaterVy")==0) return HydrologyWaterVyEnum;
+         else stage=4;
+   }
+   if(stage==4){
+	      if (strcmp(name,"HydrologyWaterVy")==0) return HydrologyWaterVyEnum;
 	      else if (strcmp(name,"StressTensor")==0) return StressTensorEnum;
 	      else if (strcmp(name,"StressTensorxx")==0) return StressTensorxxEnum;
@@ -384,8 +395,5 @@
 	      else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
 	      else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum;
-         else stage=4;
-   }
-   if(stage==4){
-	      if (strcmp(name,"IceVolume")==0) return IceVolumeEnum;
+	      else if (strcmp(name,"IceVolume")==0) return IceVolumeEnum;
 	      else if (strcmp(name,"P0")==0) return P0Enum;
 	      else if (strcmp(name,"P1")==0) return P1Enum;
@@ -470,4 +478,4 @@
    }
 	/*If we reach this point, the string provided has not been found*/
-   _error_("Enum %s not found",name);
+	_error2_("Enum " << name << " not found");
 }
Index: /issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
===================================================================
--- /issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 12706)
@@ -11,5 +11,5 @@
 #include "../InputUpdateFromConstantx/InputUpdateFromConstantx.h"
 
-void SurfaceAreax( double* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters){
+void SurfaceAreax( IssmDouble* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters){
 	
 	/*Intermediary*/
@@ -18,6 +18,6 @@
 
 	/*output: */
-	double S=0;
-	double S_sum;
+	IssmDouble S=0;
+	IssmDouble S_sum;
 	
 	/*Compute gradients: */
Index: /issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h
===================================================================
--- /issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h	(revision 12705)
+++ /issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void SurfaceAreax( double* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters);
+void SurfaceAreax( IssmDouble* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters);
 
 #endif  /* _SURFACEAREAX_H */
Index: /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 12706)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){
+void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, IssmDouble* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){
 	
 	/*intermediary: */
@@ -25,8 +25,8 @@
 	Vector*    pf   = NULL;
 	Vector*    df=NULL;
-	double kmax = 0;
+	IssmDouble kmax = 0;
 
 	/*Display message*/
-	_printf_(VerboseModule(),"   Generating matrices\n");
+	if(VerboseModule()) _pprintLine_("   Generating matrices");
 
 	/*retrive parameters: */
@@ -41,5 +41,5 @@
 	numberofdofspernode=nodes->MaxNumDofs(configuration_type,GsetEnum);
 
-	/*Checks in debugging mode {{{1*/
+	/*Checks in debugging mode {{{*/
 	if(penalty_kflag)_assert_(kflag);
 	if(penalty_pflag)_assert_(pflag);
Index: /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.h
===================================================================
--- /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,
+void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, IssmDouble* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,
 			bool kflag=true,bool pflag=true,bool penalty_kflag=true,bool penalty_pflag=true);
 
Index: /issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.cpp
===================================================================
--- /issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.cpp	(revision 12706)
@@ -10,15 +10,15 @@
 #include "../../Container/Container.h"
 
-void TimeAdaptx(double* pdt, Elements* elements, Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters){
+void TimeAdaptx(IssmDouble* pdt, Elements* elements, Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters){
 
 	int      i;
 
 	/*output: */
-	double   dt;
+	IssmDouble   dt;
 
 	/*intermediary: */
 	Element *element     = NULL;
-	double   min_dt      = 0;
-	double   node_min_dt = 0;
+	IssmDouble   min_dt      = 0;
+	IssmDouble   node_min_dt = 0;
 
 	/*Go through elements, and figure out the minimum of the time steps for each element (using CFL criterion): */
Index: /issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.h
===================================================================
--- /issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/TimeAdaptx/TimeAdaptx.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void TimeAdaptx(double* pdt, Elements* elements, Nodes* nodes,Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters);
+void TimeAdaptx(IssmDouble* pdt, Elements* elements, Nodes* nodes,Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters);
 
 #endif  /* _TIMEADAPTX_H */
Index: /issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp
===================================================================
--- /issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp	(revision 12706)
@@ -57,5 +57,5 @@
 
 	/*fill in the point list: */
-	in.pointlist = (REAL *) xmalloc(in.numberofpoints * 2 * sizeof(REAL));
+	in.pointlist = xNew<REAL>(in.numberofpoints*2);
 
 	counter=0;
@@ -78,9 +78,9 @@
 	
 	/*fill in the point attribute list: */
-	in.pointattributelist = (REAL*)xmalloc(in.numberofpoints*in.numberofpointattributes*sizeof(REAL));
+	in.pointattributelist = xNew<REAL>(in.numberofpoints*in.numberofpointattributes);
 	for (i=0;i<in.numberofpoints;i++) in.pointattributelist[i] = 0.0;
 	
 	/*fill in the point marker list: */
-	in.pointmarkerlist = (int *) xmalloc(in.numberofpoints * sizeof(int));
+	in.pointmarkerlist = xNew<int>(in.numberofpoints);
 	for(i=0;i<in.numberofpoints;i++) in.pointmarkerlist[i] = 0;
 
@@ -97,6 +97,6 @@
 	}
 	
-	in.segmentlist = (int *) xmalloc(in.numberofsegments * 2 * sizeof(int));
-	in.segmentmarkerlist = (int *) xcalloc(in.numberofsegments,sizeof(int));
+	in.segmentlist = xNew<int>(in.numberofsegments*2);
+	in.segmentmarkerlist = xNewZeroInit<int>(in.numberofsegments);
 	counter=0;
 	backcounter=0;
@@ -135,5 +135,5 @@
 	in.numberofholes = domain->Size()-1; /*everything is a hole, but for the first profile.*/
 	if(in.numberofholes){
-		in.holelist = (REAL *) xmalloc(in.numberofholes * 2 * sizeof(REAL));
+		in.holelist = xNew<REAL>(in.numberofholes*2);
 		for (i=0;i<domain->Size()-1;i++){
 			contour=(Contour*)domain->GetObjectByOffset(i+1);
@@ -164,9 +164,9 @@
 
 	/*Allocate index, x and y: */
-	index=(double*)xmalloc(3*out.numberoftriangles*sizeof(double));
-	x=(double*)xmalloc(out.numberofpoints*sizeof(double));
-	y=(double*)xmalloc(out.numberofpoints*sizeof(double));
-	segments=(double*)xmalloc(3*out.numberofsegments*sizeof(double));
-	segmentmarkerlist=(double*)xmalloc(out.numberofsegments*sizeof(double));
+	index=xNew<double>(3*out.numberoftriangles);
+	x=xNew<double>(out.numberofpoints);
+	y=xNew<double>(out.numberofpoints);
+	segments=xNew<double>(3*out.numberofsegments);
+	segmentmarkerlist=xNew<double>(out.numberofsegments);
 
 	for (i = 0; i< out.numberoftriangles; i++) {
Index: /issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp
===================================================================
--- /issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp	(revision 12706)
@@ -13,5 +13,5 @@
 using namespace std;
 
-void TriaSearchx(double** ptria,double* index,int nel, double* x, double* y, int nods,double* x0, double* y0,int numberofnodes){
+void TriaSearchx(double** ptria,int* index,int nel, double* x, double* y, int nods,double* x0, double* y0,int numberofnodes){
 
 	/*Output*/
@@ -19,5 +19,5 @@
 
 	/*allocate: */
-	tria=(double*)xmalloc(numberofnodes*sizeof(double));
+	tria=xNew<double>(numberofnodes);
 
 	/*Intermediary*/
@@ -52,5 +52,4 @@
 	}
 
-
 	/*Assign output pointers:*/
 	*ptria=tria;
Index: /issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.h
===================================================================
--- /issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.h	(revision 12705)
+++ /issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void TriaSearchx(double** ptria,double* index,int nel, double* x, double* y, int nods,double* x0, double* y0,int numberofnodes);
+void TriaSearchx(double** ptria,int* index,int nel, double* x, double* y, int nods,double* x0, double* y0,int numberofnodes);
 
 #endif
Index: /issm/trunk/src/c/modules/UpdateConstraintsx/UpdateConstraintsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/UpdateConstraintsx/UpdateConstraintsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/UpdateConstraintsx/UpdateConstraintsx.cpp	(revision 12706)
@@ -14,5 +14,5 @@
 void UpdateConstraintsx(Nodes* nodes,Constraints* constraints,Parameters* parameters){
 
-	double time;
+	IssmDouble time;
 	int    analysis_type;
 
@@ -22,5 +22,5 @@
 
 	/*start module: */
-	_printf_(VerboseModule(),"%s%g\n","   Updating constraints for time: ",time);
+	if(VerboseModule()) _pprintLine_("   Updating constraints for time: " << time);
 	
 	/*First, update dof constraints in nodes, using constraints: */
Index: /issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp	(revision 12706)
@@ -13,5 +13,5 @@
 	
 	int configuration_type;
-	double* yg_serial=NULL;
+	IssmDouble* yg_serial=NULL;
 
 	/*Get current configuration*/
@@ -34,4 +34,4 @@
 
 	/*Free ressources:*/
-	xfree((void**)&yg_serial);
+	xDelete<IssmDouble>(yg_serial);
 }
Index: /issm/trunk/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp
===================================================================
--- /issm/trunk/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp	(revision 12706)
@@ -15,6 +15,6 @@
 	Vector*     vz        = NULL;
 	Vertex *vertex    = NULL;
-	double *thickness = NULL;
-	double *bed       = NULL;
+	IssmDouble *thickness = NULL;
+	IssmDouble *bed       = NULL;
 
 	/*get vertex vectors for bed and thickness: */
@@ -38,6 +38,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&thickness);
-	xfree((void**)&bed);
+	xDelete<IssmDouble>(thickness);
+	xDelete<IssmDouble>(bed);
 	xdelete(&vz);
 	return 1;
Index: /issm/trunk/src/c/modules/VecMergex/VecMergex.cpp
===================================================================
--- /issm/trunk/src/c/modules/VecMergex/VecMergex.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/VecMergex/VecMergex.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 	int i;
 	int configuration_type;
-	double* uf_serial=NULL;
+	IssmDouble* uf_serial=NULL;
 
 	/*retrieve parameters: */
@@ -41,5 +41,5 @@
 	}
 	/*Free ressources:*/
-	xfree((void**)&uf_serial);
+	xDelete<IssmDouble>(uf_serial);
 
 	/*Assemble vector: */
Index: /issm/trunk/src/c/modules/Xy2llx/Xy2llx.cpp
===================================================================
--- /issm/trunk/src/c/modules/Xy2llx/Xy2llx.cpp	(revision 12705)
+++ /issm/trunk/src/c/modules/Xy2llx/Xy2llx.cpp	(revision 12706)
@@ -53,5 +53,5 @@
 	double  sl,rho,cm,T,chi;
 
-	if((sgn!=1) && (sgn!=-1)) _error_("Sign should be either +1 or -1.\n");
+	if((sgn!=1) && (sgn!=-1)) _error2_("Sign should be either +1 or -1.\n");
 
 	delta = central_meridian;
@@ -124,12 +124,12 @@
 		*pdelta= 45;
 		*pslat = 70;
-		_printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).\n");
+		if(flag) _pprintLine_("Warning: expecting coordinates in polar stereographic (Std Latitude: 70N Meridian: 45).");
 	}
 	else if (sgn == -1) {
 		*pdelta= 0;
 		*pslat = 71;
-		_printf_(flag,"Warning: expecting coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).\n");
+		if(flag) _pprintLine_("Warning: expecting coordinates in polar stereographic (Std Latitude: 71S Meridian: 0).");
 	}
-	else _error_("Sign should be either +1 or -1.\n");
+	else _error2_("Sign should be either +1 or -1.\n");
 
 	return;
Index: /issm/trunk/src/c/modules/modules.h
===================================================================
--- /issm/trunk/src/c/modules/modules.h	(revision 12705)
+++ /issm/trunk/src/c/modules/modules.h	(revision 12706)
@@ -106,4 +106,5 @@
 #include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h"
 #include "./Scotchx/Scotchx.h"
+#include "./SmbGradientsx/SmbGradientsx.h"
 #include "./Solverx/Solverx.h"
 #include "./SpcNodesx/SpcNodesx.h"
Index: /issm/trunk/src/c/objects/Bamg/AdjacentTriangle.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/AdjacentTriangle.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/AdjacentTriangle.cpp	(revision 12706)
@@ -14,15 +14,15 @@
 
 	/*Methods*/
-	/*FUNCTION AdjacentTriangle::Locked {{{1*/
+	/*FUNCTION AdjacentTriangle::Locked {{{*/
 	int  AdjacentTriangle::Locked() const {
 		return t->AdjEdgeIndex[a] & 4;
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::MarkUnSwap {{{1*/
+	/*FUNCTION AdjacentTriangle::MarkUnSwap {{{*/
 	int  AdjacentTriangle::MarkUnSwap() const {
 		return t->AdjEdgeIndex[a] & 8;
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::GetAllFlag_UnSwap {{{1*/
+	/*FUNCTION AdjacentTriangle::GetAllFlag_UnSwap {{{*/
 	int  AdjacentTriangle::GetAllFlag_UnSwap() const {
 		// take all flag except MarkUnSwap
@@ -30,35 +30,35 @@
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::SetLock {{{1*/
+	/*FUNCTION AdjacentTriangle::SetLock {{{*/
 	void AdjacentTriangle::SetLock(){
 		t->SetLocked(a);
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::Adj {{{1*/
+	/*FUNCTION AdjacentTriangle::Adj {{{*/
 	AdjacentTriangle AdjacentTriangle::Adj() const {
 		return  t->Adj(a);
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::EdgeVertex {{{1*/
+	/*FUNCTION AdjacentTriangle::EdgeVertex {{{*/
 	BamgVertex* AdjacentTriangle::EdgeVertex(const int & i) const {
 		return t->vertices[VerticesOfTriangularEdge[a][i]];
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::OppositeVertex {{{1*/
+	/*FUNCTION AdjacentTriangle::OppositeVertex {{{*/
 	BamgVertex* AdjacentTriangle::OppositeVertex() const {
 		return t->vertices[bamg::OppositeVertex[a]]; 
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::det {{{1*/
+	/*FUNCTION AdjacentTriangle::det {{{*/
 	Icoor2 & AdjacentTriangle::det() const {
 		return t->det;
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::swap {{{1*/
+	/*FUNCTION AdjacentTriangle::swap {{{*/
 	int AdjacentTriangle::swap(){
 		return  t->swap(a);
 	}
 	/*}}}*/
-	/*FUNCTION AdjacentTriangle::SetAdj2 {{{1*/
+	/*FUNCTION AdjacentTriangle::SetAdj2 {{{*/
 	void AdjacentTriangle::SetAdj2(const AdjacentTriangle & ta, int l  ){
 		//set Adjacent Triangle of a triangle
Index: /issm/trunk/src/c/objects/Bamg/BamgGeom.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgGeom.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/BamgGeom.cpp	(revision 12706)
@@ -5,5 +5,5 @@
 
 /*Constructors/Destructors*/
-/*FUNCTION BamgGeom::BamgGeom(){{{1*/
+/*FUNCTION BamgGeom::BamgGeom(){{{*/
 BamgGeom::BamgGeom(){
 
@@ -19,15 +19,15 @@
 }
 /*}}}*/
-/*FUNCTION BamgGeom::~BamgGeom(){{{1*/
+/*FUNCTION BamgGeom::~BamgGeom(){{{*/
 BamgGeom::~BamgGeom(){
 
-	xfree((void**)&this->Vertices);
-	xfree((void**)&this->Edges);
-	xfree((void**)&this->TangentAtEdges);
-	xfree((void**)&this->Corners);
-	xfree((void**)&this->RequiredVertices);
-	xfree((void**)&this->RequiredEdges);
-	xfree((void**)&this->CrackedEdges);
-	xfree((void**)&this->SubDomains);
+	xDelete<double>(this->Vertices);
+	xDelete<double>(this->Edges);
+	xDelete<double>(this->TangentAtEdges);
+	xDelete<double>(this->Corners);
+	xDelete<double>(this->RequiredVertices);
+	xDelete<double>(this->RequiredEdges);
+	xDelete<double>(this->CrackedEdges);
+	xDelete<double>(this->SubDomains);
 
 }
Index: /issm/trunk/src/c/objects/Bamg/BamgMesh.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgMesh.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/BamgMesh.cpp	(revision 12706)
@@ -5,5 +5,5 @@
 
 /*Constructors/Destructors*/
-/*FUNCTION BamgMesh::BamgMesh(){{{1*/
+/*FUNCTION BamgMesh::BamgMesh(){{{*/
 BamgMesh::BamgMesh(){
 
@@ -30,29 +30,27 @@
 }
 /*}}}*/
-/*FUNCTION BamgMesh::~BamgMesh(){{{1*/
+/*FUNCTION BamgMesh::~BamgMesh(){{{*/
 BamgMesh::~BamgMesh(){
 
-	xfree((void**)&this->Vertices);
-	xfree((void**)&this->Edges);
-	xfree((void**)&this->Triangles);
-	xfree((void**)&this->Quadrilaterals);
+	xDelete<double>(this->Vertices);
+	xDelete<double>(this->Edges);
+	xDelete<double>(this->Triangles);
+	xDelete<double>(this->Quadrilaterals);
 
-	xfree((void**)&this->SubDomains);
-	xfree((void**)&this->SubDomainsFromGeom);
-	xfree((void**)&this->CrackedVertices);
-	xfree((void**)&this->CrackedEdges);
+	xDelete<double>(this->SubDomains);
+	xDelete<double>(this->SubDomainsFromGeom);
+	xDelete<double>(this->CrackedVertices);
+	xDelete<double>(this->CrackedEdges);
 
-	xfree((void**)&this->VerticesOnGeomVertex);
-	xfree((void**)&this->VerticesOnGeomEdge);
-	xfree((void**)&this->EdgesOnGeomEdge);
+	xDelete<double>(this->VerticesOnGeomVertex);
+	xDelete<double>(this->VerticesOnGeomEdge);
+	xDelete<double>(this->EdgesOnGeomEdge);
 
-	xfree((void**)&this->IssmEdges);
-	xfree((void**)&this->IssmSegments);
+	xDelete<double>(this->IssmEdges);
+	xDelete<double>(this->IssmSegments);
 
-	xfree((void**)&this->ElementConnectivity);
-	xfree((void**)&this->NodalConnectivity);
-	xfree((void**)&this->NodalElementConnectivity);
-
-
+	xDelete<double>(this->ElementConnectivity);
+	xDelete<double>(this->NodalConnectivity);
+	xDelete<double>(this->NodalElementConnectivity);
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Bamg/BamgOpts.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgOpts.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/BamgOpts.cpp	(revision 12706)
@@ -6,5 +6,5 @@
 
 /*Constructors/Destructors*/
-/*FUNCTION BamgOpts::BamgOpts() {{{1*/
+/*FUNCTION BamgOpts::BamgOpts() {{{*/
 BamgOpts::BamgOpts(){
 
@@ -41,13 +41,13 @@
 }
 /*}}}*/
-/*FUNCTION BamgOpts::~BamgOpts() {{{1*/
+/*FUNCTION BamgOpts::~BamgOpts() {{{*/
 BamgOpts::~BamgOpts(){
 
-	xfree((void**)&this->hminVertices);
-	xfree((void**)&this->hmaxVertices);
-	xfree((void**)&this->hVertices);
-	xfree((void**)&this->metric);
-	xfree((void**)&this->field);
-	xfree((void**)&this->err);
+	xDelete<double>(this->hminVertices);
+	xDelete<double>(this->hmaxVertices);
+	xDelete<double>(this->hVertices);
+	xDelete<double>(this->metric);
+	xDelete<double>(this->field);
+	xDelete<double>(this->err);
 
 }
@@ -55,33 +55,33 @@
 
 /*Methods*/
-/*FUNCTION BamgOpts::Check{{{1*/
+/*FUNCTION BamgOpts::Check{{{*/
 void BamgOpts::Check(void){
 
 	int i;
 
-	if (this->anisomax<1) _error_("'anisomax' option should be >=1");
-	if (this->coeff==0) _error_("'coeff' should be positive");
-	if (this->errg<0) _error_("'errg' option should be >0");
-	if (this->gradation<1) _error_("'gradation' option should be >=1");
-	if (this->Hessiantype!=0  && this->Hessiantype!=1) _error_("'Hessiantype' supported options are 0 and 1");
-	if (this->maxnbv<3) _error_("'maxnbv' option should be >3");
-	if (this->maxsubdiv<=1) _error_("'maxsubdiv' should be >1");
-	if (this->Metrictype!=0   && this->Metrictype!=1 && this->Metrictype!=2) _error_("'Metrictype' supported options are 0, 1 and 2");
-	if (this->nbjacobi<=0) _error_("'nbjacobi' option should be >0");
-	if (this->nbsmooth<=0) _error_("'nbsmooth' option should be >0");
+	if (this->anisomax<1) _error2_("'anisomax' option should be >=1");
+	if (this->coeff==0) _error2_("'coeff' should be positive");
+	if (this->errg<0) _error2_("'errg' option should be >0");
+	if (this->gradation<1) _error2_("'gradation' option should be >=1");
+	if (this->Hessiantype!=0  && this->Hessiantype!=1) _error2_("'Hessiantype' supported options are 0 and 1");
+	if (this->maxnbv<3) _error2_("'maxnbv' option should be >3");
+	if (this->maxsubdiv<=1) _error2_("'maxsubdiv' should be >1");
+	if (this->Metrictype!=0   && this->Metrictype!=1 && this->Metrictype!=2) _error2_("'Metrictype' supported options are 0, 1 and 2");
+	if (this->nbjacobi<=0) _error2_("'nbjacobi' option should be >0");
+	if (this->nbsmooth<=0) _error2_("'nbsmooth' option should be >0");
 
-	if (this->Crack!=0  && this->Crack!=1) _error_("'Crack' supported options are 0 and 1");
-	if (this->KeepVertices!=0 && this->KeepVertices!=1) _error_("'KeepVertices' supported options are 0 and 1");
-	if (this->geometricalmetric!=0  && this->geometricalmetric!=1) _error_("'geometricalmetric' supported options are 0 and 1");
+	if (this->Crack!=0  && this->Crack!=1) _error2_("'Crack' supported options are 0 and 1");
+	if (this->KeepVertices!=0 && this->KeepVertices!=1) _error2_("'KeepVertices' supported options are 0 and 1");
+	if (this->geometricalmetric!=0  && this->geometricalmetric!=1) _error2_("'geometricalmetric' supported options are 0 and 1");
 
-	if (this->hmin<=0) _error_("'hmin' option should be >0");
-	if (this->hmax<=0 || this->hmax<this->hmin) _error_("'hmax' option should be between 0 and hmin=%g",this->hmin);
-	if (this->hminVertices && this->hminVerticesSize[1]!=1) _error_("'hminVertices' should be a column");
-	if (this->hmaxVertices && this->hmaxVerticesSize[1]!=1) _error_("'hmaxVertices' should be a column");
-	if (this->hVertices && this->hVerticesSize[1]!=1) _error_("'hVertices' should be a column");
-	if (this->metric && (this->metricSize[1]!=1 && this->metricSize[1]!=3)) _error_("'metric' should have either 1 (iso) or 3 (aniso) columns.");
+	if (this->hmin<=0) _error2_("'hmin' option should be >0");
+	if (this->hmax<=0 || this->hmax<this->hmin) _error2_("'hmax' option should be between 0 and hmin=" << this->hmin);
+	if (this->hminVertices && this->hminVerticesSize[1]!=1) _error2_("'hminVertices' should be a column");
+	if (this->hmaxVertices && this->hmaxVerticesSize[1]!=1) _error2_("'hmaxVertices' should be a column");
+	if (this->hVertices && this->hVerticesSize[1]!=1) _error2_("'hVertices' should be a column");
+	if (this->metric && (this->metricSize[1]!=1 && this->metricSize[1]!=3)) _error2_("'metric' should have either 1 (iso) or 3 (aniso) columns.");
 	if (this->field){
-		if (this->errSize[0]!=1 || this->errSize[1]!=this->fieldSize[1]) _error_("'err' should be of size %i x %i",1,this->fieldSize[1]);
-		for (i=0;i<this->fieldSize[1];i++) {if (this->err[i]<=0) _error_("'err' option should be >0");};
+		if (this->errSize[0]!=1 || this->errSize[1]!=this->fieldSize[1]) _error2_("'err' should be of size " << 1 << " x " << this->fieldSize[1]);
+		for (i=0;i<this->fieldSize[1];i++) {if (this->err[i]<=0) _error2_("'err' option should be >0");};
 	}
 
Index: /issm/trunk/src/c/objects/Bamg/BamgQuadtree.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgQuadtree.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/BamgQuadtree.cpp	(revision 12706)
@@ -7,5 +7,5 @@
 namespace bamg {
 
-	/*MACROS {{{1*/
+	/*MACROS {{{*/
 	/* 
 	 * 
@@ -48,5 +48,5 @@
 #define J_IJ(k,l)  ((k&2) ? l:0)
 	/*}}}*/
-	/*DOCUMENTATION What is a BamgQuadtree? {{{1
+	/*DOCUMENTATION What is a BamgQuadtree? {{{
 	 * A Quadtree is a very simple way to group vertices according
 	 * to their locations. A square that holds all the points of the mesh
@@ -94,8 +94,8 @@
 	 * Using binaries is therefore very easy to locate a vertex in a box:
 	 * we just need to look at the bits from the left to the right (See ::Add)
-	 }}}1*/
+	 }}}*/
 
 	/*Constructors/Destructors*/
-	/*FUNCTION BamgQuadtree::BamgQuadtree(){{{1*/
+	/*FUNCTION BamgQuadtree::BamgQuadtree(){{{*/
 	BamgQuadtree::BamgQuadtree(){
 
@@ -111,6 +111,6 @@
 
 		}
-	/*}}}1*/
-	/*FUNCTION BamgQuadtree::BamgQuadtree(Mesh * t,long nbv){{{1*/
+	/*}}}*/
+	/*FUNCTION BamgQuadtree::BamgQuadtree(Mesh * t,long nbv){{{*/
 	BamgQuadtree::BamgQuadtree(Mesh * t,long nbv){ 
 
@@ -133,14 +133,14 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION BamgQuadtree::~BamgQuadtree(){{{1*/
+	/*}}}*/
+	/*FUNCTION BamgQuadtree::~BamgQuadtree(){{{*/
 	BamgQuadtree::~BamgQuadtree() {
 		delete boxcontainer;
 		root=NULL;
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*Methods*/
-	/*FUNCTION BamgQuadtree::Add{{{1*/
+	/*FUNCTION BamgQuadtree::Add{{{*/
 	void  BamgQuadtree::Add(BamgVertex &w){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/Add)*/
@@ -230,6 +230,6 @@
 		NbVertices++;
 	}
-	/*}}}1*/
-	/*FUNCTION BamgQuadtree::NearestVertex{{{1*/
+	/*}}}*/
+	/*FUNCTION BamgQuadtree::NearestVertex{{{*/
 	BamgVertex*  BamgQuadtree::NearestVertex(Icoor1 i,Icoor1 j) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/NearestVertex)*/
@@ -389,6 +389,6 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION BamgQuadtree::NearestVertexWithNormal{{{1*/
+	/*}}}*/
+	/*FUNCTION BamgQuadtree::NearestVertexWithNormal{{{*/
 	BamgVertex*  BamgQuadtree::NearestVertexWithNormal(Icoor1 i,Icoor1 j) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/NearestVertexWithNormal)*/
@@ -497,6 +497,6 @@
 		return vn;
 	}
-	/*}}}1*/
-	/*FUNCTION BamgQuadtree::NewBamgQuadtreeBox {{{1*/
+	/*}}}*/
+	/*FUNCTION BamgQuadtree::NewBamgQuadtreeBox {{{*/
 	BamgQuadtree::BamgQuadtreeBox* BamgQuadtree::NewBamgQuadtreeBox(void){
 
@@ -521,5 +521,5 @@
 		return newbox;
 	}/*}}}*/
-	/*FUNCTION BamgQuadtree::ToClose {{{1*/
+	/*FUNCTION BamgQuadtree::ToClose {{{*/
 	BamgVertex*   BamgQuadtree::ToClose(BamgVertex & v,double seuil,Icoor1 hx,Icoor1 hy){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, BamgQuadtree.cpp/ToClose)*/
@@ -595,4 +595,4 @@
 		return 0;
 	}
-	/*}}}1*/
+	/*}}}*/
 }
Index: /issm/trunk/src/c/objects/Bamg/BamgQuadtree.h
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgQuadtree.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/BamgQuadtree.h	(revision 12706)
@@ -29,10 +29,10 @@
 					};
 					/*Object functions*/
-					void    Echo()       {_error_("not implemented yet"); };
-					void    DeepEcho()   {_error_("not implemented yet"); };
-					int     Id()         {_error_("not implemented yet"); };
-					int     MyRank()     {_error_("not implemented yet"); };
-					int     ObjectEnum() {_error_("not implemented yet"); };
-					Object *copy()       {_error_("not implemented yet"); };
+					void    Echo()       {_error2_("not implemented yet"); };
+					void    DeepEcho()   {_error2_("not implemented yet"); };
+					int     Id()         {_error2_("not implemented yet"); };
+					int     MyRank()     {_error2_("not implemented yet"); };
+					int     ObjectEnum() {_error2_("not implemented yet"); };
+					Object *copy()       {_error2_("not implemented yet"); };
 			};
 
Index: /issm/trunk/src/c/objects/Bamg/BamgVertex.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/BamgVertex.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/BamgVertex.cpp	(revision 12706)
@@ -9,12 +9,12 @@
 
 	/*Methods*/
-	/*FUNCTION BamgVertex::Echo {{{1*/
+	/*FUNCTION BamgVertex::Echo {{{*/
 
 	void BamgVertex::Echo(void){
 
-		printf("Vertex:\n");
-		printf("  integer   coordinates i.x: %i, i.y: %i\n",i.x,i.y);
-		printf("  Euclidean coordinates r.x: %g, r.y: %g\n",r.x,r.y);
-		printf("  ReferenceNumber = %i\n",ReferenceNumber);
+		_printLine_("Vertex:");
+		_printLine_("  integer   coordinates i.x: " << i.x << ", i.y: " << i.y);
+		_printLine_("  Euclidean coordinates r.x: " << r.x << ", r.y: " << r.y);
+		_printLine_("  ReferenceNumber = " << ReferenceNumber);
 		m.Echo();
 
@@ -22,10 +22,10 @@
 	}
 	/*}}}*/
-	/*FUNCTION BamgVertex::GetReferenceNumber{{{1*/
+	/*FUNCTION BamgVertex::GetReferenceNumber{{{*/
 	int  BamgVertex::GetReferenceNumber() const { 
 		return ReferenceNumber;
 	}
 	/*}}}*/
-	/*FUNCTION BamgVertex::MetricFromHessian{{{1*/
+	/*FUNCTION BamgVertex::MetricFromHessian{{{*/
 	void BamgVertex::MetricFromHessian(const double Hxx,const double Hyx, const double Hyy,const double smin,const double smax,const double s,double err,BamgOpts* bamgopts){
 		/*Compute Metric from Hessian*/
@@ -76,5 +76,5 @@
 		}
 		else{
-			_error_("Metrictype %i not supported yet (use 0,1 or 2(default))",Metrictype);
+			_error2_("Metrictype " << Metrictype << " not supported yet (use 0,1 or 2(default))");
 		}
 
@@ -105,6 +105,6 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION BamgVertex::Optim {{{1*/
+	/*}}}*/
+	/*FUNCTION BamgVertex::Optim {{{*/
 	long BamgVertex::Optim(int i,int koption){ 
 		long ret=0;
@@ -119,5 +119,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION BamgVertex::Smoothing{{{1*/
+	/*FUNCTION BamgVertex::Smoothing{{{*/
 	double  BamgVertex::Smoothing(Mesh &Th,const Mesh &BTh,Triangle* &tstart ,double omega){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Smoothing)*/
@@ -146,5 +146,5 @@
 			j = NextEdge[jc];
 			if (k>=2000){
-				_error_("k>=2000 (Maximum number of iterations reached)");
+				_error2_("k>=2000 (Maximum number of iterations reached)");
 			}
 		} while ( tbegin != tria); 
@@ -213,5 +213,5 @@
 				j = NextEdge[jc];
 				if (k>=2000){
-					_error_("k>=2000");
+					_error2_("k>=2000");
 				}
 			}while ( tbegin != tria); 
@@ -222,8 +222,8 @@
 		return delta;
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*Intermediary*/
-	/*FUNCTION QuadQuality{{{1*/
+	/*FUNCTION QuadQuality{{{*/
 	double QuadQuality(const BamgVertex & a,const BamgVertex &b,const BamgVertex &c,const BamgVertex &d) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshQuad.cpp/QuadQuality)*/
@@ -252,5 +252,5 @@
 		return 1.0-Max(Max(Abs(cosDAB),Abs(cosABC)),Max(Abs(cosBCD),Abs(cosCDA)));
 	}
-	/*}}}1*/
+	/*}}}*/
 
 } 
Index: /issm/trunk/src/c/objects/Bamg/CrackedEdge.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/CrackedEdge.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/CrackedEdge.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 
 	/*Constructors/Destructors*/
-	/*FUNCTION CrackedEdge() {{{1*/
+	/*FUNCTION CrackedEdge() {{{*/
 	CrackedEdge::CrackedEdge() {
 		a=NULL;
Index: /issm/trunk/src/c/objects/Bamg/Curve.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Curve.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/Curve.cpp	(revision 12706)
@@ -10,5 +10,5 @@
 
 	/*Constructors/Destructors*/
-	/*FUNCTION Curve::Curve(){{{1*/
+	/*FUNCTION Curve::Curve(){{{*/
 	Curve::Curve(){
 		FirstEdge=NULL;
@@ -20,5 +20,5 @@
 
 	/*Methods*/
-	/*FUNCTION Curve::Reverse {{{1*/
+	/*FUNCTION Curve::Reverse {{{*/
 	void Curve::Reverse() {
 		/*reverse the direction of the curve */
@@ -27,5 +27,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION Curve::Set {{{1*/
+	/*FUNCTION Curve::Set {{{*/
 	void Curve::Set(const Curve & rec,const Geometry & Gh ,Geometry & GhNew){
 		*this = rec;
Index: /issm/trunk/src/c/objects/Bamg/Direction.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Direction.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/Direction.cpp	(revision 12706)
@@ -9,10 +9,10 @@
 
 	/*Constructors/Destructors*/
-	/*FUNCTION Direction() {{{1*/
+	/*FUNCTION Direction() {{{*/
 	Direction::Direction():
 		dir(MaxICoor){
 
 	}/*}}}*/
-	/*FUNCTION Direction(Icoor1 i,Icoor1 j) {{{1*/
+	/*FUNCTION Direction(Icoor1 i,Icoor1 j) {{{*/
 	Direction::Direction(Icoor1 i,Icoor1 j) {
 		Icoor2 n2 = 2*(Abs(i)+Abs(j));  
@@ -23,5 +23,5 @@
 
 	/*Methods*/
-	/*FUNCTION Direction::direction{{{1*/
+	/*FUNCTION Direction::direction{{{*/
 	int Direction::direction(Icoor1 i,Icoor1 j) {
 		int r =1; 
Index: /issm/trunk/src/c/objects/Bamg/Edge.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Edge.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/Edge.cpp	(revision 12706)
@@ -13,5 +13,5 @@
 
 	/*Methods*/
-	/*FUNCTION Edge::Set {{{1*/
+	/*FUNCTION Edge::Set {{{*/
 	void Edge::Set(const Mesh & Th ,long i,Mesh & ThNew){ 
 		*this = Th.edges[i];
@@ -24,14 +24,14 @@
 	}
 	/*}}}*/
-	/*FUNCTION Edge::Echo {{{1*/
+	/*FUNCTION Edge::Echo {{{*/
 	void Edge::Echo(void){ 
-		printf("Edge:\n");
-		printf("   pointers towards two vertices: %p %p\n",v[0],v[1]);
-		printf("   ReferenceNumber = %i\n",ReferenceNumber);
-		printf("   GeomEdgeHook = %p\n",GeomEdgeHook);
-		printf("   two adjacent edges on the same curve: %p %p\n",adj[0],adj[1]);
+		_printLine_("Edge:");
+		_printLine_("   pointers towards two vertices: " << v[0] << " " << v[1]);
+		_printLine_("   ReferenceNumber = " << ReferenceNumber);
+		_printLine_("   GeomEdgeHook = " << GeomEdgeHook);
+		_printLine_("   two adjacent edges on the same curve: " << adj[0] << " " << adj[1]);
 	}
 	/*}}}*/
-	/*FUNCTION Edge::Renumbering{{{1*/
+	/*FUNCTION Edge::Renumbering{{{*/
 	void Edge::Renumbering(BamgVertex *vb,BamgVertex *ve, long *renu){
 
@@ -41,9 +41,9 @@
 	}
 	/*}}}*/
-	/*FUNCTION Edge::Intersection{{{1*/
+	/*FUNCTION Edge::Intersection{{{*/
 	int Edge::Intersection(const  Edge & e){ 
 
 		/*some shecks*/
-		if (!(adj[0]==&e || adj[1]==&e)){ _error_("Intersection bug"); }
+		if (!(adj[0]==&e || adj[1]==&e)){ _error2_("Intersection bug"); }
 		_assert_(adj[0]==&e || adj[1]==&e);
 
Index: /issm/trunk/src/c/objects/Bamg/EigenMetric.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/EigenMetric.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/EigenMetric.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 
 	/*Constructor*/
-	/*FUNCTION EigenMetric::EigenMetric(const Metric M){{{1*/
+	/*FUNCTION EigenMetric::EigenMetric(const Metric M){{{*/
 	EigenMetric::EigenMetric(const Metric& M){
 		/*From a metric (a11,a21,a22), get eigen values lambda1 and lambda2 and one eigen vector v*/
@@ -88,6 +88,6 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION EigenMetric::EigenMetric(double r1,double r2,const D2 vp1){{{1*/
+	/*}}}*/
+	/*FUNCTION EigenMetric::EigenMetric(double r1,double r2,const D2 vp1){{{*/
 	EigenMetric::EigenMetric(double r1,double r2,const D2& vp1): lambda1(r1),lambda2(r2),v(vp1){
 
@@ -95,71 +95,71 @@
 
 	/*Methods*/
-	/*FUNCTION EigenMetric::Abs{{{1*/
+	/*FUNCTION EigenMetric::Abs{{{*/
 	void   EigenMetric::Abs(){
 		lambda1=bamg::Abs(lambda1),lambda2=bamg::Abs(lambda2);
 	}/*}}}*/
-	/*FUNCTION EigenMetric::Aniso{{{1*/
+	/*FUNCTION EigenMetric::Aniso{{{*/
 	double EigenMetric::Aniso() const  { 
 		return sqrt( Aniso2());
 	}/*}}}*/
-	/*FUNCTION EigenMetric::Aniso2{{{1*/
+	/*FUNCTION EigenMetric::Aniso2{{{*/
 	double EigenMetric::Aniso2() const  { 
 		return lmax()/lmin();
 	}/*}}}*/
-	/*FUNCTION EigenMetric::BoundAniso{{{1*/
+	/*FUNCTION EigenMetric::BoundAniso{{{*/
 	void   EigenMetric::BoundAniso(const double c){ 
 		BoundAniso2(1/(c*c));
 	}/*}}}*/
-	/*FUNCTION EigenMetric::Echo {{{1*/
+	/*FUNCTION EigenMetric::Echo {{{*/
 	void EigenMetric::Echo(void){
 
-		printf("EigenMetric:\n");
-		printf("   lambda1: %g\n",lambda1);
-		printf("   lambda2: %g\n",lambda2);
-		printf("   v.x: %g\n",v.x);
-		printf("   v.y: %g\n",v.y);
+		_printLine_("EigenMetric:");
+		_printLine_("   lambda1: " << lambda1);
+		_printLine_("   lambda2: " << lambda2);
+		_printLine_("   v.x: " << v.x);
+		_printLine_("   v.y: " << v.y);
 
 		return;
 	}
 	/*}}}*/
-	/*FUNCTION EigenMetric::hmin{{{1*/
+	/*FUNCTION EigenMetric::hmin{{{*/
 	double EigenMetric::hmin() const {
 		return sqrt(1/bamg::Max3(lambda1,lambda2,1e-30));
 	}/*}}}*/
-	/*FUNCTION EigenMetric::hmax{{{1*/
+	/*FUNCTION EigenMetric::hmax{{{*/
 	double EigenMetric::hmax() const {
 		return sqrt(1/bamg::Max(bamg::Min(lambda1,lambda2),1e-30));
 	}/*}}}*/
-	/*FUNCTION EigenMetric::Isotrope{{{1*/
+	/*FUNCTION EigenMetric::Isotrope{{{*/
 	void   EigenMetric::Isotrope() {
 		lambda1=lambda2=bamg::Max(lambda1,lambda2);
 	}/*}}}*/
-	/*FUNCTION EigenMetric::lmax{{{1*/
+	/*FUNCTION EigenMetric::lmax{{{*/
 	double EigenMetric::lmax() const {
 		return bamg::Max3(lambda1,lambda2,1e-30);
 	}/*}}}*/
-	/*FUNCTION EigenMetric::lmin{{{1*/
+	/*FUNCTION EigenMetric::lmin{{{*/
 	double EigenMetric::lmin() const {
 		return bamg::Max(bamg::Min(lambda1,lambda2),1e-30);
 	}/*}}}*/
-	/*FUNCTION EigenMetric::Min{{{1*/
+	/*FUNCTION EigenMetric::Min{{{*/
 	void   EigenMetric::Min(double a) { 
 		lambda1=bamg::Min(a,lambda1); lambda2=bamg::Min(a,lambda2) ;
 	}/*}}}*/
-	/*FUNCTION EigenMetric::Max{{{1*/
+	/*FUNCTION EigenMetric::Max{{{*/
 	void   EigenMetric::Max(double a) { 
 		//change eigen values
 		lambda1=bamg::Max(a,lambda1); lambda2=bamg::Max(a,lambda2) ;
 	}/*}}}*/
-	/*FUNCTION EigenMetric::Minh{{{1*/
+	/*FUNCTION EigenMetric::Minh{{{*/
 	void   EigenMetric::Minh(double h) {
 		Min(1.0/(h*h));
 	}/*}}}*/
-	/*FUNCTION EigenMetric::Maxh{{{1*/
+	/*FUNCTION EigenMetric::Maxh{{{*/
 	void   EigenMetric::Maxh(double h) {
 		//Call Max function
 		Max(1.0/(h*h));
 	}/*}}}*/
-	/*FUNCTION EigenMetric::pow{{{1*/
+	/*FUNCTION EigenMetric::pow{{{*/
 	void   EigenMetric::pow(double p){
 		lambda1=::pow(lambda1,p);lambda2=::pow(lambda2,p);
Index: /issm/trunk/src/c/objects/Bamg/GeomEdge.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/GeomEdge.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/GeomEdge.cpp	(revision 12706)
@@ -16,9 +16,9 @@
 
 	/*Methods*/
-	/*FUNCTION GeomEdge::Cracked{{{1*/
+	/*FUNCTION GeomEdge::Cracked{{{*/
 	int    GeomEdge::Cracked() const  {
 		return type &1;  
 	}/*}}}*/
-	/*FUNCTION GeomEdge::F{{{1*/
+	/*FUNCTION GeomEdge::F{{{*/
 	R2 GeomEdge::F(double theta) const{
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/F)*/
@@ -62,10 +62,10 @@
 		return A*ca + B*cb + tg[0]*cta + tg[1]*ctb;
 	  }
-	/*}}}1*/
-	/*FUNCTION GeomEdge::Mark{{{1*/
+	/*}}}*/
+	/*FUNCTION GeomEdge::Mark{{{*/
 	int    GeomEdge::Mark()    const  {
 		return type &16; 
 	}/*}}}*/
-	/*FUNCTION GeomEdge::R1tg{{{1*/
+	/*FUNCTION GeomEdge::R1tg{{{*/
 	double GeomEdge::R1tg(double theta,R2 & t) const{
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/R1tg)*/
@@ -138,10 +138,10 @@
 		else return 0;
 	}
-	/*}}}1*/
-	/*FUNCTION GeomEdge::Required{{{1*/
+	/*}}}*/
+	/*FUNCTION GeomEdge::Required{{{*/
 	int    GeomEdge::Required()       {
 		return type &64; 
 	}/*}}}*/
-	/*FUNCTION GeomEdge::Set {{{1*/
+	/*FUNCTION GeomEdge::Set {{{*/
 	void GeomEdge::Set(const GeomEdge & rec,const Geometry & Gh ,Geometry & GhNew){ 
 		*this = rec;
@@ -152,37 +152,37 @@
 	}
 	/*}}}*/
-	/*FUNCTION GeomEdge::SetCracked{{{1*/
+	/*FUNCTION GeomEdge::SetCracked{{{*/
 	void   GeomEdge::SetCracked()     { 
 		type |= 1;/*=>1st digit to 1*/
 	}/*}}}*/
-	/*FUNCTION GeomEdge::SetTgA{{{1*/
+	/*FUNCTION GeomEdge::SetTgA{{{*/
 	void   GeomEdge::SetTgA()         { 
 		type |=4; /*=>2d digit to 1*/
 	}/*}}}*/
-	/*FUNCTION GeomEdge::SetTgB{{{1*/
+	/*FUNCTION GeomEdge::SetTgB{{{*/
 	void   GeomEdge::SetTgB()         { 
 		type |=8; /*=> 3d digit to 1*/
 	}/*}}}*/
-	/*FUNCTION GeomEdge::SetMark{{{1*/
+	/*FUNCTION GeomEdge::SetMark{{{*/
 	void   GeomEdge::SetMark()        { 
 		type |=16;/*=> 4th digiy to 1*/
 	}/*}}}*/
-	/*FUNCTION GeomEdge::SetUnMark{{{1*/
+	/*FUNCTION GeomEdge::SetUnMark{{{*/
 	void   GeomEdge::SetUnMark()      { 
 		type &= 1007 /* 1023-16 = 000111110111 => 4th digit to 0*/;
 	}/*}}}*/
-	/*FUNCTION GeomEdge::SetRequired{{{1*/
+	/*FUNCTION GeomEdge::SetRequired{{{*/
 	void   GeomEdge::SetRequired()    { 
 		type |= 64;/*=>6th digit to 1*/ 
 	}/*}}}*/
-	  /*FUNCTION GeomEdge::Tg{{{1*/
+	  /*FUNCTION GeomEdge::Tg{{{*/
 	int    GeomEdge::Tg(int i) const  {
 		return i==0 ? TgA() : TgB();
 	}/*}}}*/
-	/*FUNCTION GeomEdge::TgA{{{1*/
+	/*FUNCTION GeomEdge::TgA{{{*/
 	int    GeomEdge::TgA()     const  {
 		return type &4;  
 	}/*}}}*/
-	/*FUNCTION GeomEdge::TgB{{{1*/
+	/*FUNCTION GeomEdge::TgB{{{*/
 	int    GeomEdge::TgB()     const  {
 		return type &8;  
Index: /issm/trunk/src/c/objects/Bamg/GeomSubDomain.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/GeomSubDomain.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/GeomSubDomain.cpp	(revision 12706)
@@ -12,5 +12,5 @@
 
 	/*Methods*/
-	/*FUNCTION GeomSubDomain::Set {{{1*/
+	/*FUNCTION GeomSubDomain::Set {{{*/
 	void GeomSubDomain::Set(const GeomSubDomain & rec,const Geometry & Gh ,const Geometry & GhNew){
 		*this = rec;
Index: /issm/trunk/src/c/objects/Bamg/GeomVertex.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/GeomVertex.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/GeomVertex.cpp	(revision 12706)
@@ -14,10 +14,10 @@
 
 	/*Methods*/
-	/*FUNCTION GeomVertex::Corner {{{1*/
+	/*FUNCTION GeomVertex::Corner {{{*/
 	int  GeomVertex::Corner() const {
 		return type & 4;
 	}
 	/*}}}*/
-	/*FUNCTION GeomVertex::Required {{{1*/
+	/*FUNCTION GeomVertex::Required {{{*/
 	int  GeomVertex::Required()const {
 		// a corner is required
@@ -25,10 +25,10 @@
 	}
 	/*}}}*/
-	/*FUNCTION GeomVertex::SetCorner {{{1*/
+	/*FUNCTION GeomVertex::SetCorner {{{*/
 	void GeomVertex::SetCorner(){
 		type |= 4;
 	}
 	/*}}}*/
-	/*FUNCTION GeomVertex::SetRequired {{{1*/
+	/*FUNCTION GeomVertex::SetRequired {{{*/
 	void GeomVertex::SetRequired(){
 		type |= 2;
Index: /issm/trunk/src/c/objects/Bamg/Geometry.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Geometry.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/Geometry.cpp	(revision 12706)
@@ -13,10 +13,10 @@
 
 	/*Constructors/Destructors*/
-	/*FUNCTION Geometry::Geometry(){{{1*/
+	/*FUNCTION Geometry::Geometry(){{{*/
 	Geometry::Geometry(){
 		Init();
 	}
 	/*}}}*/
-	/*FUNCTION Geometry::Geometry(BamgGeom* bamggeom, BamgOpts* bamgopts){{{1*/
+	/*FUNCTION Geometry::Geometry(BamgGeom* bamggeom, BamgOpts* bamgopts){{{*/
 	Geometry::Geometry(BamgGeom* bamggeom, BamgOpts* bamgopts){
 		Init();
@@ -25,5 +25,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION Geometry::Geometry(const Geometry & Gh) (COPY operator){{{1*/
+	/*FUNCTION Geometry::Geometry(const Geometry & Gh) (COPY operator){{{*/
 	Geometry::Geometry(const Geometry & Gh) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/Geometry)*/
@@ -44,9 +44,9 @@
 		 subdomains[i].Set(Gh.subdomains[i],Gh,*this);
 	}
-	/*}}}1*/
-	/*FUNCTION Geometry::~Geometry(){{{1*/
+	/*}}}*/
+	/*FUNCTION Geometry::~Geometry(){{{*/
 	Geometry::~Geometry() {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/~Geometry)*/
-		if(NbRef>0){   printf("Trying to delete geometry and NbRef>0, probably due to an error"); return;}
+		if(NbRef>0){   _printString_("Trying to delete geometry and NbRef>0, probably due to an error"); return;}
 		if(vertices)   delete [] vertices;  vertices=0;
 		if(edges)      delete [] edges;     edges=0;
@@ -56,8 +56,8 @@
 		Init();
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*IO*/
-	/*FUNCTION Geometry::ReadGeometry{{{1*/
+	/*FUNCTION Geometry::ReadGeometry{{{*/
 	void Geometry::ReadGeometry(BamgGeom* bamggeom,BamgOpts* bamgopts){
 
@@ -76,11 +76,11 @@
 
 		//some checks
-		if (bamggeom->Vertices==NULL) _error_("the domain provided does not contain any vertex");
-		if (bamggeom->Edges==NULL) _error_("the domain provided does not contain any edge");
+		if (bamggeom->Vertices==NULL) _error2_("the domain provided does not contain any vertex");
+		if (bamggeom->Edges==NULL) _error2_("the domain provided does not contain any edge");
 
 		//Vertices
 		if (bamggeom->Vertices){
-			if(verbose>5) printf("      processing Vertices\n");
-			if (bamggeom->VerticesSize[1]!=3) _error_("Vertices should have 3 columns");
+			if(verbose>5) _printLine_("      processing Vertices");
+			if (bamggeom->VerticesSize[1]!=3) _error2_("Vertices should have 3 columns");
 			vertices = new GeomVertex[nbv];
 			for (i=0;i<nbv;i++) {
@@ -115,8 +115,8 @@
 			 */
 			coefIcoor=(MaxICoor)/(Max(pmax.x-pmin.x,pmax.y-pmin.y));
-			if(coefIcoor<=0) _error_("coefIcoor should be positive");
+			if(coefIcoor<=0) _error2_("coefIcoor should be positive");
 		}
 		else{
-			_error_("No BamgVertex provided");
+			_error2_("No BamgVertex provided");
 		}
 
@@ -126,6 +126,6 @@
 			double* verticeslength=NULL;
 
-			if(verbose>5) printf("      processing Edges\n");
-			if (bamggeom->EdgesSize[1]!=3) _error_("Edges should have 3 columns");
+			if(verbose>5) _printLine_("      processing Edges");
+			if (bamggeom->EdgesSize[1]!=3) _error2_("Edges should have 3 columns");
 			edges = new GeomEdge[nbe];
 
@@ -176,12 +176,12 @@
 		}
 		else{
-			_error_("No edges provided");
+			_error2_("No edges provided");
 		}
 
 		//hVertices
 		if(bamgopts->hVertices && bamgopts->hVerticesSize[0]==nbv){
-			if(verbose>5) printf("      processing hVertices\n");
+			if(verbose>5) _printLine_("      processing hVertices");
 			for (i=0;i< nbv;i++){
-				if (!isnan(bamgopts->hVertices[i])){
+				if (!xIsNan<IssmDouble>(bamgopts->hVertices[i])){
 					vertices[i].m=Metric((double)bamgopts->hVertices[i]);
 				}
@@ -191,5 +191,5 @@
 		//MetricVertices
 		if(bamgopts->metric && bamgopts->metric[0]==nbv){
-			if(verbose>5) printf("      processing MetricVertices\n");
+			if(verbose>5) _printLine_("      processing MetricVertices");
 			for (i=0;i< nbv;i++) {
 				vertices[i].m = Metric((double)bamgopts->metric[i*3+0],(double)bamgopts->metric[i*3+1],(double)bamgopts->metric[i*3+2]);
@@ -199,5 +199,5 @@
 		//MaxCornerAngle
 		if (bamgopts->MaxCornerAngle){
-			if(verbose>5) printf("      processing MaxCornerAngle\n");
+			if(verbose>5) _printLine_("      processing MaxCornerAngle");
 			MaxCornerAngle=bamgopts->MaxCornerAngle*Pi/180;
 		}
@@ -205,6 +205,6 @@
 		//TangentAtEdges
 		if (bamggeom->TangentAtEdges){
-			if(verbose>5) printf("      processing TangentAtEdges");
-			if (bamggeom->TangentAtEdgesSize[1]!=4) _error_("TangentAtEdges should have 4 columns");
+			if(verbose>5) _printString_("      processing TangentAtEdges");
+			if (bamggeom->TangentAtEdgesSize[1]!=4) _error2_("TangentAtEdges should have 4 columns");
 			int n,i,j,k;
 			R2 tg;
@@ -216,6 +216,6 @@
 				tg.x=bamggeom->TangentAtEdges[k*4+2];
 				tg.y=bamggeom->TangentAtEdges[k*4+3];
-				if (i<0 || i>=nbe) _error_("TangentAtEdges first index exceeds matrix dimension");
-				if (j!=0 && j!=1)  _error_("TangentAtEdges second index should be 1 or 2 only");
+				if (i<0 || i>=nbe) _error2_("TangentAtEdges first index exceeds matrix dimension");
+				if (j!=0 && j!=1)  _error2_("TangentAtEdges second index should be 1 or 2 only");
 				edges[i].tg[j] = tg;
 			}
@@ -224,10 +224,10 @@
 		//Corners
 		if(bamggeom->Corners){
-			if(verbose>5) printf("      processing Corners");
-			if (bamggeom->CornersSize[1]!=1) _error_("Corners should have 1 column");
+			if(verbose>5) _printString_("      processing Corners");
+			if (bamggeom->CornersSize[1]!=1) _error2_("Corners should have 1 column");
 			n=bamggeom->CornersSize[0];
 			for (i=0;i<n;i++) {     
 				j=(int)bamggeom->Corners[i]-1; //for C indexing
-				if (j>nbv-1 || j<0) _error_("Bad corner definition: should in [0 %i]",nbv);
+				if (j>nbv-1 || j<0) _error2_("Bad corner definition: should in [0 " << nbv << "]");
 				/*Required => at the same time SetRequired and SetCorner*/
 				vertices[j].SetCorner();
@@ -238,10 +238,10 @@
 		//RequiredVertices
 		if(bamggeom->RequiredVertices){
-			if(verbose>5) printf("      processing RequiredVertices\n");
-			if (bamggeom->RequiredVerticesSize[1]!=1) _error_("RequiredVertices should have 1 column");
+			if(verbose>5) _printLine_("      processing RequiredVertices");
+			if (bamggeom->RequiredVerticesSize[1]!=1) _error2_("RequiredVertices should have 1 column");
 			n=bamggeom->RequiredVerticesSize[0];
 			for (i=0;i<n;i++) {     
 				j=(int)bamggeom->RequiredVertices[i]-1; //for C indexing
-				if (j>nbv-1 || j<0) _error_("Bad RequiredVerticess  definition: should in [0 %i]",nbv);
+				if (j>nbv-1 || j<0) _error2_("Bad RequiredVerticess  definition: should in [0 " << nbv << "]");
 				vertices[j].SetRequired();
 			}
@@ -250,10 +250,10 @@
 		//RequiredEdges
 		if(bamggeom->RequiredEdges){
-			if(verbose>5) printf("      processing RequiredEdges\n");
-			if (bamggeom->RequiredEdgesSize[1]!=1) _error_("RequiredEdges should have 1 column");
+			if(verbose>5) _printLine_("      processing RequiredEdges");
+			if (bamggeom->RequiredEdgesSize[1]!=1) _error2_("RequiredEdges should have 1 column");
 			n=bamggeom->RequiredEdgesSize[0];
 			for (i=0;i<n;i++) {     
 				j=(int)bamggeom->RequiredEdges[i]-1; //for C indexing
-				if (j>nbe-1 || j<0) _error_("Bad RequiredEdges definition: should in [0 %i]",nbe);
+				if (j>nbe-1 || j<0) _error2_("Bad RequiredEdges definition: should in [0 " << nbe << "]");
 				edges[j].SetRequired();  
 			}
@@ -262,6 +262,6 @@
 		//SubDomain
 		if(bamggeom->SubDomains){
-			if(verbose>5) printf("      processing SubDomains\n");
-			if (bamggeom->SubDomainsSize[1]!=4) _error_("SubDomains should have 4 columns");
+			if(verbose>5) _printLine_("      processing SubDomains");
+			if (bamggeom->SubDomainsSize[1]!=4) _error2_("SubDomains should have 4 columns");
 			nbsubdomains=bamggeom->SubDomainsSize[0];
 			subdomains = new GeomSubDomain[nbsubdomains];
@@ -271,6 +271,6 @@
 				i2=(int)bamggeom->SubDomains[i*4+2];
 				i3=(int)bamggeom->SubDomains[i*4+3];
-				if (i0!=2) _error_("Bad Subdomain definition: first number should be 2 (for Edges)");
-				if (i1>nbe || i1<=0) _error_("Bad Subdomain definition: second number should in [1 %i] (edge number)",nbe);
+				if (i0!=2) _error2_("Bad Subdomain definition: first number should be 2 (for Edges)");
+				if (i1>nbe || i1<=0) _error2_("Bad Subdomain definition: second number should in [1 " << nbe << "] (edge number)");
 				subdomains[i].edge=edges + (i1-1);
 				subdomains[i].direction = (int) i2;
@@ -279,6 +279,6 @@
 		}
 	}
-	/*}}}1*/
-	/*FUNCTION Geometry::WriteGeometry{{{1*/
+	/*}}}*/
+	/*FUNCTION Geometry::WriteGeometry{{{*/
 	void Geometry::WriteGeometry(BamgGeom* bamggeom, BamgOpts* bamgopts){
 
@@ -294,9 +294,9 @@
 
 		/*Vertices*/
-		if(verbose>5) printf("      writing Vertices\n");
+		if(verbose>5) _printLine_("      writing Vertices");
 		bamggeom->VerticesSize[0]=nbv;
 		bamggeom->VerticesSize[1]=3;
 		if (nbv){
-			bamggeom->Vertices=(double*)xmalloc(3*nbv*sizeof(double));
+			bamggeom->Vertices=xNew<double>(3*nbv);
 			for (i=0;i<nbv;i++){
 				bamggeom->Vertices[i*3+0]=vertices[i].r.x;
@@ -310,9 +310,9 @@
 
 		/*Edges*/
-		if(verbose>5) printf("      writing Edges\n");
+		if(verbose>5) _printLine_("      writing Edges");
 		bamggeom->EdgesSize[0]=nbe;
 		bamggeom->EdgesSize[1]=3;
 		if (nbe){
-			bamggeom->Edges=(double*)xmalloc(3*nbe*sizeof(double));
+			bamggeom->Edges=xNew<double>(3*nbe);
 			for (i=0;i<nbe;i++){
 				bamggeom->Edges[i*3+0]=GetId(edges[i][0])+1; //back to Matlab indexing
@@ -328,9 +328,9 @@
 
 		/*RequiredEdges*/
-		if(verbose>5) printf("      writing %i RequiredEdges\n",nbreq);
+		if(verbose>5) _printLine_("      writing " << nbreq << " RequiredEdges");
 		bamggeom->RequiredEdgesSize[0]=nbreq;
 		bamggeom->RequiredEdgesSize[1]=1;
 		if (nbreq){
-			bamggeom->RequiredEdges=(double*)xmalloc(1*nbreq*sizeof(double));
+			bamggeom->RequiredEdges=xNew<double>(1*nbreq);
 			count=0;
 			for (i=0;i<nbe;i++){
@@ -345,9 +345,9 @@
 
 		/*RequiredVertices*/
-		if(verbose>5) printf("      writing %i RequiredVertices\n",nbreqv);
+		if(verbose>5) _printLine_("      writing " << nbreqv << " RequiredVertices");
 		bamggeom->RequiredVerticesSize[0]=nbreqv;
 		bamggeom->RequiredVerticesSize[1]=1;
 		if (nbreqv){
-			bamggeom->RequiredVertices=(double*)xmalloc(1*nbreqv*sizeof(double));
+			bamggeom->RequiredVertices=xNew<double>(1*nbreqv);
 			count=0;
 			for (i=0;i<nbv;i++){
@@ -360,9 +360,9 @@
 
 		/*SubDomains*/
-		if(verbose>5) printf("      writing SubDomains\n");
+		if(verbose>5) _printLine_("      writing SubDomains");
 		bamggeom->SubDomainsSize[0]=nbsubdomains;
 		bamggeom->SubDomainsSize[1]=4;
 		if (nbsubdomains){
-			bamggeom->SubDomains=(double*)xmalloc(4*nbsubdomains*sizeof(double));
+			bamggeom->SubDomains=xNew<double>(4*nbsubdomains);
 			for (i=0;i<nbsubdomains;i++){
 				bamggeom->SubDomains[4*i+0]=2;
@@ -374,9 +374,9 @@
 
 		/*TangentAtEdges*/
-		if(verbose>5) printf("      writing TangentAtEdges\n");
+		if(verbose>5) _printLine_("      writing TangentAtEdges");
 		bamggeom->TangentAtEdgesSize[0]=nbtan;
 		bamggeom->TangentAtEdgesSize[1]=4;
 		if (nbtan){
-			bamggeom->TangentAtEdges=(double*)xmalloc(4*nbtan*sizeof(double));
+			bamggeom->TangentAtEdges=xNew<double>(4*nbtan);
 			count=0;
 			for (i=0;i<nbe;i++){
@@ -397,29 +397,29 @@
 		}
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*Methods*/
-	/*FUNCTION Geometry::Echo {{{1*/
+	/*FUNCTION Geometry::Echo {{{*/
 	void Geometry::Echo(void){
 
-		printf("Geometry:\n");
-		printf("   nbv  (number of vertices) : %i\n",nbv);
-		printf("   nbe  (number of edges)    : %i\n",nbe);
-		printf("   nbsubdomains: %i\n",nbsubdomains);
-		printf("   nbcurves: %i\n",nbcurves);
-		printf("   vertices: %p\n",vertices);
-		printf("   edges: %p\n",edges);
-		printf("   quadtree: %p\n",quadtree);
-		printf("   subdomains: %p\n",subdomains);
-		printf("   curves: %p\n",curves);
-		printf("   pmin (x,y): (%g %g)\n",pmin.x,pmin.y);
-		printf("   pmax (x,y): (%g %g)\n",pmax.x,pmax.y);
-		printf("   coefIcoor: %g\n",coefIcoor);
-		printf("   MaxCornerAngle: %g\n",MaxCornerAngle);
+		_printLine_("Geometry:");
+		_printLine_("   nbv  (number of vertices) : " << nbv);
+		_printLine_("   nbe  (number of edges)    : " << nbe);
+		_printLine_("   nbsubdomains: " << nbsubdomains);
+		_printLine_("   nbcurves: " << nbcurves);
+		_printLine_("   vertices: " << vertices);
+		_printLine_("   edges: " << edges);
+		_printLine_("   quadtree: " << quadtree);
+		_printLine_("   subdomains: " << subdomains);
+		_printLine_("   curves: " << curves);
+		_printLine_("   pmin (x,y): (" << pmin.x << " " << pmin.y << ")");
+		_printLine_("   pmax (x,y): (" << pmax.x << " " << pmax.y << ")");
+		_printLine_("   coefIcoor: " << coefIcoor);
+		_printLine_("   MaxCornerAngle: " << MaxCornerAngle);
 
 		return;
 	}
 	/*}}}*/
-	/*FUNCTION Geometry::Init{{{1*/
+	/*FUNCTION Geometry::Init{{{*/
 	void Geometry::Init(void){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/EmptyGeometry)*/
@@ -437,6 +437,6 @@
 		MaxCornerAngle = 10*Pi/180; //default is 10 degres
 	}
-	/*}}}1*/
-	/*FUNCTION Geometry::MinimalHmin{{{1*/
+	/*}}}*/
+	/*FUNCTION Geometry::MinimalHmin{{{*/
 	double Geometry::MinimalHmin() {
 		/* coeffIcoor = (2^30-1)/D
@@ -445,29 +445,29 @@
 		return 2.0/coefIcoor;
 	}/*}}}*/
-	/*FUNCTION Geometry::MaximalHmax{{{1*/
+	/*FUNCTION Geometry::MaximalHmax{{{*/
 	double Geometry::MaximalHmax() {
 		return Max(pmax.x-pmin.x,pmax.y-pmin.y);
 	}/*}}}*/
-	/*FUNCTION Geometry::GetId(const GeomVertex &t){{{1*/
+	/*FUNCTION Geometry::GetId(const GeomVertex &t){{{*/
 	long Geometry::GetId(const GeomVertex & t) const  {
 		return &t - vertices;
 	}/*}}}*/
-	/*FUNCTION Geometry::GetId(const GeomVertex * t){{{1*/
+	/*FUNCTION Geometry::GetId(const GeomVertex * t){{{*/
 	long Geometry::GetId(const GeomVertex * t) const  {
 		return t - vertices;
 	}/*}}}*/
-	/*FUNCTION Geometry::GetId(const GeomEdge & t){{{1*/
+	/*FUNCTION Geometry::GetId(const GeomEdge & t){{{*/
 	long Geometry::GetId(const GeomEdge & t) const  {
 		return &t - edges;
 	}/*}}}*/
-	/*FUNCTION Geometry::GetId(const GeomEdge * t){{{1*/
+	/*FUNCTION Geometry::GetId(const GeomEdge * t){{{*/
 	long Geometry::GetId(const GeomEdge * t) const  {
 		return t - edges;
 	}/*}}}*/
-	/*FUNCTION Geometry::GetId(const Curve * c){{{1*/
+	/*FUNCTION Geometry::GetId(const Curve * c){{{*/
 	long Geometry::GetId(const Curve * c) const  {
 		return c - curves;
 	}/*}}}*/
-	/*FUNCTION Geometry::Containing{{{1*/
+	/*FUNCTION Geometry::Containing{{{*/
 	GeomEdge* Geometry::Containing(const R2 P,  GeomEdge * start) const {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/Contening)*/
@@ -494,6 +494,6 @@
 		return on;
 	}
-	/*}}}1*/
-	/*FUNCTION Geometry::PostRead{{{1*/
+	/*}}}*/
+	/*FUNCTION Geometry::PostRead{{{*/
 	void Geometry::PostRead(){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/AfterRead)*/
@@ -527,10 +527,10 @@
 			/*if there is a vertex found that is to close to vertices[i] -> error*/
 			if( v && Norme1(v->r - vertices[i].r) < eps ){
-				printf("reference numbers: %i %i\n",v->ReferenceNumber,vertices[i].ReferenceNumber);
-				printf("Id: %i\n",i+1);
+				_printLine_("reference numbers: " << v->ReferenceNumber << " " << vertices[i].ReferenceNumber);
+				_printLine_("Id: " << i+1);
 				delete [] next_p;
 				delete [] head_v;
 				delete [] eangle;
-				_error_("two points of the geometry are very closed to each other (see reference numbers above)");
+				_error2_("two points of the geometry are very closed to each other (see reference numbers above)");
 			}
 
@@ -610,5 +610,5 @@
 				delete [] head_v;
 				delete [] eangle;
-				_error_("Length of edge %i is 0",i);
+				_error2_("Length of edge " << i << " is 0");
 			}
 			//compute angle in [-Pi Pi]
@@ -704,5 +704,5 @@
 				long i1 = n1/2 ,j1=n1%2;
 
-				if( edges[i1].v[j1] != edges[i].v[j]) _error_("Problem while processing edges: check the edge list");
+				if( edges[i1].v[j1] != edges[i].v[j]) _error2_("Problem while processing edges: check the edge list");
 
 				edges[i1].Adj[j1] = edges + i;
@@ -817,6 +817,6 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION Geometry::ProjectOnCurve {{{1*/
+	/*}}}*/
+	/*FUNCTION Geometry::ProjectOnCurve {{{*/
 	GeomEdge* Geometry::ProjectOnCurve(const Edge &e,double s,BamgVertex &V,VertexOnGeom &GV) const {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/ProjectOnCurve)*/
@@ -831,8 +831,8 @@
 		GeomEdge* on=e.GeomEdgeHook;
 		if (!on){
-			_error_("ProjectOnCurve error message: edge provided should be on geometry");
+			_error2_("ProjectOnCurve error message: edge provided should be on geometry");
 		}
 		if (!e[0].GeomEdgeHook ||  !e[1].GeomEdgeHook){
-			_error_("ProjectOnCurve error message: at least one of the vertex of the edge provided is not on geometry");
+			_error2_("ProjectOnCurve error message: at least one of the vertex of the edge provided is not on geometry");
 		}
 
@@ -870,10 +870,10 @@
 			if (bge<=0) {
 				if(NbTry) {
-					printf("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve\n");
-					printf("That bug might come from:\n");
-					printf(" 1)  a mesh edge  containing more than %i geometrical edges\n",mxe/2);
-					printf(" 2)  code bug : be sure that we call   Mesh::SetVertexFieldOn() before\n");
-					printf("To solve the problem do a coarsening of the geometrical mesh or change the constant value of mxe (dangerous)\n");
-					_error_("see above");
+					_printLine_("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve");
+					_printLine_("That bug might come from:");
+					_printLine_(" 1)  a mesh edge  containing more than " << mxe/2 << " geometrical edges");
+					_printLine_(" 2)  code bug : be sure that we call   Mesh::SetVertexFieldOn() before");
+					_printLine_("To solve the problem do a coarsening of the geometrical mesh or change the constant value of mxe (dangerous)");
+					_error2_("see above");
 				}
 				NbTry++;
@@ -887,13 +887,13 @@
 		while (eg1 != (GeomEdge*) vg1  &&  (*eg1)(direction1) != (GeomVertex*) vg1) { 
 			if(tge>=mxe ) { 
-				printf("WARNING: on the class Mesh before call Geometry::ProjectOnCurve is having issues (isn't it Eric?)\n");
+				_printLine_("WARNING: on the class Mesh before call Geometry::ProjectOnCurve is having issues (isn't it Eric?)");
 				NbTry++;
 				if (NbTry<2) goto retry;
-				printf("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve\n");
-				printf("That bug might come from:\n");
-				printf(" 1)  a mesh edge  contening more than %i geometrical edges\n",mxe/2);
-				printf(" 2)  code bug : be sure that we call   Mesh::SetVertexFieldOn() before\n");
-				printf("To solve the problem do a coarsening of the geometrical mesh or change the constant value of mxe (dangerous)\n");
-				_error_("see above");
+				_printLine_("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve");
+				_printLine_("That bug might come from:");
+				_printLine_(" 1)  a mesh edge  contening more than " << mxe/2 << " geometrical edges");
+				_printLine_(" 2)  code bug : be sure that we call   Mesh::SetVertexFieldOn() before");
+				_printLine_("To solve the problem do a coarsening of the geometrical mesh or change the constant value of mxe (dangerous)");
+				_error2_("see above");
 			}
 			GeomEdge* tmpge = eg1;
@@ -951,6 +951,6 @@
 		return on;
 	}
-	/*}}}1*/
-	/*FUNCTION Geometry::R2ToI2{{{1*/
+	/*}}}*/
+	/*FUNCTION Geometry::R2ToI2{{{*/
 	I2 Geometry::R2ToI2(const R2 & P) const {
 		/*coefIcoor is the coefficient used for integer coordinates:
@@ -965,5 +965,5 @@
 		return  I2( (Icoor1) (coefIcoor*(P.x-pmin.x)) ,(Icoor1) (coefIcoor*(P.y-pmin.y)) );
 	}/*}}}*/
-	/*FUNCTION Geometry::UnMarkEdges{{{1*/
+	/*FUNCTION Geometry::UnMarkEdges{{{*/
 	void Geometry::UnMarkEdges() {
 		for (int i=0;i<nbe;i++) edges[i].SetUnMark();
Index: /issm/trunk/src/c/objects/Bamg/ListofIntersectionTriangles.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/ListofIntersectionTriangles.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/ListofIntersectionTriangles.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 
 	/*Constructors Destructors*/
-	/*FUNCTION ListofIntersectionTriangles::ListofIntersectionTriangles{{{1*/
+	/*FUNCTION ListofIntersectionTriangles::ListofIntersectionTriangles{{{*/
 	ListofIntersectionTriangles::ListofIntersectionTriangles(int n,int m)
 	  : MaxSize(n), Size(0), len(-1),state(-1),lIntTria(new IntersectionTriangles[n]) ,
@@ -15,5 +15,5 @@
 	  }
 	/*}}}*/
-	/*FUNCTION ListofIntersectionTriangles::~ListofIntersectionTriangles{{{1*/
+	/*FUNCTION ListofIntersectionTriangles::~ListofIntersectionTriangles{{{*/
 	ListofIntersectionTriangles::~ListofIntersectionTriangles(){
 		if (lIntTria) delete [] lIntTria,lIntTria=0;
@@ -23,5 +23,5 @@
 
 	/*Methods*/
-	/*FUNCTION ListofIntersectionTriangles::Init{{{1*/
+	/*FUNCTION ListofIntersectionTriangles::Init{{{*/
 	void ListofIntersectionTriangles::Init(void){
 		state=0;
@@ -30,5 +30,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION ListofIntersectionTriangles::Length{{{1*/
+	/*FUNCTION ListofIntersectionTriangles::Length{{{*/
 	double  ListofIntersectionTriangles::Length(){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Length)*/
@@ -38,5 +38,5 @@
 		// check Size
 		if (Size<=0){
-			_error_("Size<=0");
+			_error2_("Size<=0");
 		}
 
@@ -77,6 +77,6 @@
 		return s;
 	}
-	/*}}}1*/
-	/*FUNCTION ListofIntersectionTriangles::NewItem(Triangle * tt,double d0,double d1,double d2) {{{1*/
+	/*}}}*/
+	/*FUNCTION ListofIntersectionTriangles::NewItem(Triangle * tt,double d0,double d1,double d2) {{{*/
 	int  ListofIntersectionTriangles::NewItem(Triangle * tt,double d0,double d1,double d2) { 
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NewItem)*/
@@ -105,6 +105,6 @@
 		return n;
 	}
-	/*}}}1*/
-	/*FUNCTION ListofIntersectionTriangles::NewItem(R2 A,const Metric & mm){{{1*/
+	/*}}}*/
+	/*FUNCTION ListofIntersectionTriangles::NewItem(R2 A,const Metric & mm){{{*/
 	int ListofIntersectionTriangles::NewItem(R2 A,const Metric & mm) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NewItem)*/
@@ -121,6 +121,6 @@
 		return  n; 
 	}
-	/*}}}1*/
-	/*FUNCTION ListofIntersectionTriangles::NewPoints{{{1*/
+	/*}}}*/
+	/*FUNCTION ListofIntersectionTriangles::NewPoints{{{*/
 	long ListofIntersectionTriangles::NewPoints(BamgVertex* vertices,long &nbv,long maxnbv){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NewPoints)*/
@@ -167,5 +167,5 @@
 			//x.Echo();
 			//y.Echo();
-			//printf("cx = %g, cy=%g\n",cx,cy);
+			//_printLine_("cx = " << cx << ", cy=" << cy);
 
 			si += sint;
@@ -178,6 +178,6 @@
 		return nbv-nbvold;
 	}
-	/*}}}1*/
-	/*FUNCTION ListofIntersectionTriangles::NewSubSeg{{{1*/
+	/*}}}*/
+	/*FUNCTION ListofIntersectionTriangles::NewSubSeg{{{*/
 	void  ListofIntersectionTriangles::NewSubSeg(GeomEdge *e,double s0,double s1){ 
 		long int verbosity=0;
@@ -186,5 +186,5 @@
 			MaxNbSeg *= 2;
 			if (verbosity>3){
-				printf("   reshape lSegsI from %i to %i\n",mneo,MaxNbSeg);
+				_printLine_("   reshape lSegsI from " << mneo << " to " << MaxNbSeg);
 			}
 			_assert_(lSegsI && NbSeg<MaxNbSeg);
@@ -201,5 +201,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION ListofIntersectionTriangles::ReShape{{{1*/
+	/*FUNCTION ListofIntersectionTriangles::ReShape{{{*/
 	void ListofIntersectionTriangles::ReShape(){ 
 
@@ -211,5 +211,5 @@
 		for (int i=0;i<MaxSize;i++) nw[i] = lIntTria[i];       
 		long int verbosity=0;
-		if(verbosity>3) printf("   ListofIntersectionTriangles  ReShape Maxsize %i -> %i\n",MaxSize,MaxNbSeg);
+		if(verbosity>3) _printLine_("   ListofIntersectionTriangles  ReShape Maxsize " << MaxSize << " -> " << MaxNbSeg);
 		MaxSize = newsize; 
 		delete [] lIntTria;// remove old
@@ -217,5 +217,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION ListofIntersectionTriangles::SplitEdge{{{1*/
+	/*FUNCTION ListofIntersectionTriangles::SplitEdge{{{*/
 	void ListofIntersectionTriangles::SplitEdge(const Mesh & Bh, const R2 &A,const R2  &B,int nbegin) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ListofIntersectionTriangles)*/
@@ -268,5 +268,5 @@
 				k=(*t)(0) ?  ((  (*t)(1) ? ( (*t)(2) ? -1 : 2) : 1  )) : 0;
 				if (k<0){
-					_error_("k<0");
+					_error2_("k<0");
 				}
 				ocut = OppositeEdge[k];
@@ -312,5 +312,5 @@
 				double dij = detj-deti;
 				if (i+j+k != 0 + 1 +2){
-					_error_("i+j+k != 0 + 1 +2");
+					_error2_("i+j+k != 0 + 1 +2");
 				}
 				ba[j] =  detj/dij;
@@ -384,5 +384,5 @@
 					}
 					else {
-						_error_("Bug Split Edge");
+						_error2_("Bug Split Edge");
 					}
 				}
@@ -421,5 +421,5 @@
 		} // for(;;)
 	}
-	/*}}}1*/
+	/*}}}*/
 
 }
Index: /issm/trunk/src/c/objects/Bamg/ListofIntersectionTriangles.h
===================================================================
--- /issm/trunk/src/c/objects/Bamg/ListofIntersectionTriangles.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/ListofIntersectionTriangles.h	(revision 12706)
@@ -34,5 +34,5 @@
 					double c01=lEnd-lBegin, c0=(lEnd-s)/c01, c1=(s-lBegin)/c01;
 					if (lBegin>s || s>lEnd){
-						_error_("lBegin>s || s>lEnd");
+						_error2_("lBegin>s || s>lEnd");
 					}
 					return e->F(sBegin*c0+sEnd*c1);
Index: /issm/trunk/src/c/objects/Bamg/Mesh.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Mesh.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/Mesh.cpp	(revision 12706)
@@ -11,5 +11,5 @@
 
 	/*Constructors/Destructors*/
-	/*FUNCTION Mesh::Mesh(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts){{{1*/
+	/*FUNCTION Mesh::Mesh(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts){{{*/
 	Mesh::Mesh(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts):Gh(*(new Geometry())),BTh(*this){ 
 
@@ -29,5 +29,5 @@
 		if(bamggeom->Edges==NULL) {
 			/*Recreate geometry if needed*/
-			printf("WARNING: mesh present but no geometry found. Reconstructing...\n");
+			_printLine_("WARNING: mesh present but no geometry found. Reconstructing...");
 			BuildGeometryFromMesh(bamgopts);
 			Gh.PostRead();
@@ -40,7 +40,7 @@
 		ReconstructExistingMesh();
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::Mesh(double* index,double* x,double* y,int nods,int nels){{{1*/
-	Mesh::Mesh(double* index,double* x,double* y,int nods,int nels):Gh(*(new Geometry())),BTh(*this){
+	/*}}}*/
+	/*FUNCTION Mesh::Mesh(int* index,double* x,double* y,int nods,int nels){{{*/
+	Mesh::Mesh(int* index,double* x,double* y,int nods,int nels):Gh(*(new Geometry())),BTh(*this){
 
 		Init(0);
@@ -49,11 +49,11 @@
 		ReconstructExistingMesh();
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::Mesh(double* x,double* y,int nods){{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::Mesh(double* x,double* y,int nods){{{*/
 	Mesh::Mesh(double* x,double* y,int nods):Gh(*(new Geometry())),BTh(*this){
 		Triangulate(x,y,nods);
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::Mesh(const Mesh & Tho,const int *flag ,const int *bb){{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::Mesh(const Mesh & Tho,const int *flag ,const int *bb){{{*/
 	Mesh::Mesh(const Mesh & Tho,const int *flag ,const int *bb,BamgOpts* bamgopts) : Gh(*(new Geometry())), BTh(*this) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Triangles)*/
@@ -101,7 +101,7 @@
 			  if (kk[i]>=0) kk[i]=k++;
 			}
-		  printf("   number of vertices %i, remove = %i\n",k,Tho.nbv - k);
-		  printf("   number of triangles %i, remove = %i\n",kt,nbInT-kt);
-		  printf("   number of New boundary edge %i\n",nbNewBedge);
+		  _printLine_("   number of vertices " << k << ", remove = " << Tho.nbv - k);
+		  _printLine_("   number of triangles " << kt << ", remove = " << nbInT-kt);
+		  _printLine_("   number of New boundary edge " << nbNewBedge);
 		  long imaxnbv =k;
 		  Init(imaxnbv);
@@ -117,5 +117,5 @@
 			  delete [] kk;
 			  delete [] refv;
-			  _error_("imaxnbv != nbv");
+			  _error2_("imaxnbv != nbv");
 		  }
 		  for (i=0;i<Tho.nbt;i++)
@@ -128,8 +128,8 @@
 				if (i0<0 || i1<0 || i2<0){
 					delete [] refv;
-					_error_("i0<0 || i1<0 || i2< 0");
+					_error2_("i0<0 || i1<0 || i2< 0");
 				}
 				if (i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv){
-					_error_("i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv");
+					_error2_("i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv");
 				}
 				triangles[nbt] = Triangle(this,kk[i0],kk[i1],kk[i2]);
@@ -138,8 +138,8 @@
 			  }
 		  if (kt!=nbt){
-			  _error_("kt!=nbt");
+			  _error2_("kt!=nbt");
 		  }
 		  if (nbt==0 && nbv==0) {
-			  _error_("All triangles have been removed");
+			  _error2_("All triangles have been removed");
 		  }
 		  delete [] kk;
@@ -153,13 +153,13 @@
 
 		  if (!nbsubdomains){
-			  _error_("nbsubdomains==0");
+			  _error2_("nbsubdomains==0");
 		  }
 		  if (!subdomains[0].head || !subdomains[0].head->link){
-			  _error_("!subdomains[0].head || !subdomains[0].head->link");
+			  _error2_("!subdomains[0].head || !subdomains[0].head->link");
 		  }
 
 	  }
-	/*}}}1*/
-	/*FUNCTION Mesh::Mesh(Mesh & Th,Geometry * pGh,Mesh * pBth,long maxnbv_in) COPY{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::Mesh(Mesh & Th,Geometry * pGh,Mesh * pBth,long maxnbv_in) COPY{{{*/
 	Mesh::Mesh(Mesh & Th,Geometry * pGh,Mesh * pBth,long maxnbv_in)
 	  : Gh(*(pGh?pGh:&Th.Gh)), BTh(*(pBth?pBth:this)) {
@@ -224,18 +224,18 @@
 
 	  }
-	/*}}}1*/
-	/*FUNCTION Mesh::Mesh(long maxnbv,Mesh & BT,BamgOpts* bamgopts,int keepBackVertices){{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::Mesh(long maxnbv,Mesh & BT,BamgOpts* bamgopts,int keepBackVertices){{{*/
 	Mesh::Mesh(long imaxnbv,Mesh & BT,BamgOpts* bamgopts,int keepBackVertices) :Gh(BT.Gh),BTh(BT) {
 		this->Init(imaxnbv);
 		TriangulateFromGeom1(bamgopts,keepBackVertices);
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::Mesh(long maxnbv,Geometry & G,BamgOpts* bamgopts){{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::Mesh(long maxnbv,Geometry & G,BamgOpts* bamgopts){{{*/
 	Mesh::Mesh(long imaxnbv,Geometry & G,BamgOpts* bamgopts):Gh(G),BTh(*this){
 		Init(imaxnbv);
 		TriangulateFromGeom0(bamgopts);
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::~Mesh(){{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::~Mesh(){{{*/
 	Mesh::~Mesh() {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Triangles)*/
@@ -262,9 +262,9 @@
 		Init(0); // set all to zero 
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*IO*/
-	/*FUNCTION Mesh::ReadMesh(double* index,double* x,double* y,int nods,int nels){{{1*/
-	void Mesh::ReadMesh(double* index,double* x,double* y,int nods,int nels){
+	/*FUNCTION Mesh::ReadMesh(int* index,double* x,double* y,int nods,int nels){{{*/
+	void Mesh::ReadMesh(int* index,double* x,double* y,int nods,int nels){
 
 		double Hmin = HUGE_VAL;// the infinie value 
@@ -280,7 +280,7 @@
 
 		//Vertices
-		if (verbose) printf("Reading vertices (%i)\n",nbv);
-		vertices=(BamgVertex*)xmalloc(nbv*sizeof(BamgVertex));
-		orderedvertices=(BamgVertex**)xmalloc(nbv*sizeof(BamgVertex*));
+		if (verbose) _printLine_("Reading vertices (" << nbv << ")");
+		vertices=xNew<BamgVertex>(nbv);
+		orderedvertices=xNew<BamgVertex*>(nbv);
 		for (i=0;i<nbv;i++){
 			vertices[i].r.x=x[i];
@@ -294,7 +294,7 @@
 
 		//Triangles
-		if (verbose) printf("Reading triangles (%i)\n",nbt);
+		if (verbose) _printLine_("Reading triangles (" << nbt << ")");
 		triangles =new Triangle[maxnbt]; //we cannot allocate only nbt triangles since 
-		nodeflags=(bool*)xmalloc(nbv*sizeof(bool));
+		nodeflags=xNew<bool>(nbv);
 		for(i=0;i<nbv;i++) nodeflags[i]=false;
 		//other triangles will be added for each edge
@@ -310,7 +310,7 @@
 
 		/*Recreate geometry: */
-		if (verbose) printf("Building Geometry\n");
+		if (verbose) _printLine_("Building Geometry");
 		BuildGeometryFromMesh();
-		if (verbose) printf("Completing geometry\n");
+		if (verbose) _printLine_("Completing geometry");
 		Gh.PostRead();
 
@@ -319,15 +319,15 @@
 		for(i=0;i<nbv;i++){
 			if(!nodeflags[i]){
-				printf("Vertex %i does not belong to any element\n",i+1);
+				_printLine_("Vertex " << i+1 << " does not belong to any element");
 				isorphan=true;
 			}
 		}
-		if(isorphan) _error_("Orphan found in mesh, see ids above");
+		if(isorphan) _error2_("Orphan found in mesh, see ids above");
 
 		/*Clean up*/
-		xfree((void**)&nodeflags);
-	}
-	/*}}}1*/
-	/*FUNCTION Mesh::ReadMesh(BamgMesh* bamgmesh, BamgOpts* bamgopts){{{1*/
+		xDelete<bool>(nodeflags);
+	}
+	/*}}}*/
+	/*FUNCTION Mesh::ReadMesh(BamgMesh* bamgmesh, BamgOpts* bamgopts){{{*/
 	void Mesh::ReadMesh(BamgMesh* bamgmesh, BamgOpts* bamgopts){
 
@@ -346,8 +346,8 @@
 		//Vertices
 		if(bamgmesh->Vertices){
-			if(verbose>5) printf("      processing Vertices\n");
-
-			vertices=(BamgVertex*)xmalloc(nbv*sizeof(BamgVertex));
-			orderedvertices=(BamgVertex**)xmalloc(nbv*sizeof(BamgVertex*));
+			if(verbose>5) _printLine_("      processing Vertices");
+
+			vertices=xNew<BamgVertex>(nbv);
+			orderedvertices=xNew<BamgVertex*>(nbv);
 
 			for (i=0;i<nbv;i++){
@@ -362,10 +362,10 @@
 		}
 		else{
-			if(verbose>5) _error_("no Vertices found in the initial mesh");
+			if(verbose>5) _error2_("no Vertices found in the initial mesh");
 		}
 
 		//Triangles
 		if(bamgmesh->Triangles){
-			if(verbose>5) printf("      processing Triangles\n");
+			if(verbose>5) _printLine_("      processing Triangles");
 			triangles =new Triangle[maxnbt]; //we cannot allocate only nbt triangles since 
 			//other triangles will be added for each edge
@@ -380,10 +380,10 @@
 		}
 		else{
-			if(verbose>5) _error_("no Triangles found in the initial mesh");
+			if(verbose>5) _error2_("no Triangles found in the initial mesh");
 		}
 
 		//Quadrilaterals
 		if(bamgmesh->Quadrilaterals){
-			if(verbose>5) printf("      processing Quadrilaterals\n");
+			if(verbose>5) _printLine_("      processing Quadrilaterals");
 			long i1,i2,i3,i4,iref;
 			triangles =new Triangle[nbt];
@@ -407,5 +407,5 @@
 		//VerticesOnGeomEdge
 		if(bamgmesh->VerticesOnGeomEdge){
-			if(verbose>5) printf("      processing VerticesOnGeomEdge\n");
+			if(verbose>5) _printLine_("      processing VerticesOnGeomEdge");
 			NbVerticesOnGeomEdge=bamgmesh->VerticesOnGeomEdgeSize[0];
 			VerticesOnGeomEdge= new  VertexOnGeom[NbVerticesOnGeomEdge] ;
@@ -422,5 +422,5 @@
 		//VerticesOnGeomVertex
 		if(bamgmesh->VerticesOnGeomVertexSize[0]){
-			if(verbose>5) printf("      processing VerticesOnGeomVertex\n");
+			if(verbose>5) _printLine_("      processing VerticesOnGeomVertex");
 			NbVerticesOnGeomVertex=bamgmesh->VerticesOnGeomVertexSize[0];
 			VerticesOnGeomVertex  = new  VertexOnGeom[NbVerticesOnGeomVertex] ;
@@ -438,5 +438,5 @@
 			double* len=NULL;
 
-			if(verbose>5) printf("      processing Edges\n");
+			if(verbose>5) _printLine_("      processing Edges");
 			nbe=bamgmesh->EdgesSize[0];
 			edges= new Edge[nbe];
@@ -498,5 +498,5 @@
 		//EdgeOnGeomEdge
 		if(bamgmesh->EdgesOnGeomEdge){
-			if(verbose>5) printf("      processing EdgesOnGeomEdge\n");
+			if(verbose>5) _printLine_("      processing EdgesOnGeomEdge");
 			int i1,i2,i,j;
 			i2=bamgmesh->EdgesOnGeomEdgeSize[0];
@@ -506,5 +506,5 @@
 				//Check value
 				if(!(i>=0 && j>=0 && i<nbe && j<Gh.nbe)) {
-					_error_("ReadMesh error: EdgesOnGeomEdge edge provided (line %i: [%i %i]) is incorrect (must be positive, [0<i<nbe=%i 0<j<Gh.nbe=%i]",i1+1,i+1,j+1,nbe,Gh.nbe);
+					_error2_("ReadMesh error: EdgesOnGeomEdge edge provided (line " << i1+1 << ": [" << i+1 << " " << j+1 << "]) is incorrect (must be positive, [0<i<nbe=" << nbe << " 0<j<Gh.nbe=" << Gh.nbe << "]");
 				}
 				edges[i].GeomEdgeHook=Gh.edges+j;
@@ -515,5 +515,5 @@
 		if(bamgmesh->SubDomains){
 			long i3,head,direction;
-			if(verbose>5) printf("      processing SubDomains\n");
+			if(verbose>5) _printLine_("      processing SubDomains");
 			nbsubdomains=bamgmesh->SubDomainsSize[0];
 			subdomains = new SubDomain [ nbsubdomains ];
@@ -522,6 +522,6 @@
 				head=(int)bamgmesh->SubDomains[i*3+1]-1;//C indexing
 				direction=(int)bamgmesh->SubDomains[i*3+2];
-				if (i3!=23) _error_("Bad Subdomain definition: first number should be 3");
-				if (head<0 || head>=nbt) _error_("Bad Subdomain definition: head should in [1 %i] (triangle number)",nbt);
+				if (i3!=23) _error2_("Bad Subdomain definition: first number should be 3");
+				if (head<0 || head>=nbt) _error2_("Bad Subdomain definition: head should in [1 " << nbt << "] (triangle number)");
 				subdomains[i].head = triangles+head;
 			}
@@ -529,6 +529,6 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::WriteMesh {{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::WriteMesh {{{*/
 	void Mesh::WriteMesh(BamgMesh* bamgmesh,BamgOpts* bamgopts){
 
@@ -553,7 +553,7 @@
 
 		//Memory Allocation
-		head_1=(int*)xmalloc(nbv*sizeof(int));
-		next_1=(int*)xmalloc(3*nbt*sizeof(int));
-		connectivitysize_1=(int*)xmalloc(nbv*sizeof(int));
+		head_1=xNew<int>(nbv);
+		next_1=xNew<int>(3*nbt);
+		connectivitysize_1=xNew<int>(nbv);
 
 		//Initialization
@@ -567,7 +567,7 @@
 				for (j=0;j<3;j++){
 					int v=GetId(triangles[i][j]); //jth vertex of the ith triangle
-					if (k>3*nbt-1 || k<0) _error_("k = %i, nbt = %i",k,nbt);
+					if (k>3*nbt-1 || k<0) _error2_("k = " << k << ", nbt = " << nbt);
 					next_1[k]=head_1[v];
-					if (v>nbv-1 || v<0)   _error_("v = %i, nbv = %i",v,nbv);
+					if (v>nbv-1 || v<0)   _error2_("v = " << v << ", nbv = " << nbv);
 					head_1[v]=k++;
 					connectivitysize_1[v]+=1;
@@ -584,9 +584,9 @@
 
 		/*Vertices*/
-		if(verbose>5) printf("      writing Vertices\n");
+		if(verbose>5) _printLine_("      writing Vertices");
 		bamgmesh->VerticesSize[0]=nbv;
 		bamgmesh->VerticesSize[1]=3;
 		if (nbv){
-			bamgmesh->Vertices=(double*)xmalloc(3*nbv*sizeof(double));
+			bamgmesh->Vertices=xNew<double>(3*nbv);
 			for (i=0;i<nbv;i++){
 				bamgmesh->Vertices[i*3+0]=vertices[i].r.x;
@@ -597,10 +597,10 @@
 
 		/*Edges*/
-		if(verbose>5) printf("      writing Edges\n");
+		if(verbose>5) _printLine_("      writing Edges");
 		bamgmesh->EdgesSize[0]=nbe;
 		bamgmesh->EdgesSize[1]=3;
 		int NumIssmSegments=0;
 		if (nbe){
-			bamgmesh->Edges=(double*)xmalloc(3*nbe*sizeof(double));
+			bamgmesh->Edges=xNew<double>(3*nbe);
 			for (i=0;i<nbe;i++){
 				bamgmesh->Edges[i*3+0]=GetId(edges[i][0])+1; //back to M indexing
@@ -614,9 +614,9 @@
 
 		/*Element edges*/
-		if(verbose>5) printf("      writing element edges\n");
+		if(verbose>5) _printLine_("      writing element edges");
 		SetOfEdges4* edge4=new SetOfEdges4(nbt*3,nbv);
 		double* elemedge=NULL;
-		elemedge=(double*)xmalloc(3*nbt*sizeof(double));
-		for (i=0;i<3*nbt;i++) elemedge[i]=NAN;
+		elemedge=xNew<double>(3*nbt);
+		for (i=0;i<3*nbt;i++) elemedge[i]=-2.;//will become -1
 		k=0;
 		for (i=0;i<nbt;i++){
@@ -642,5 +642,5 @@
 		bamgmesh->IssmEdgesSize[0]=edge4->nb();
 		bamgmesh->IssmEdgesSize[1]=4;
-		bamgmesh->IssmEdges=(double*)xmalloc(4*edge4->nb()*sizeof(double));
+		bamgmesh->IssmEdges=xNew<double>(4*edge4->nb());
 		for (i=0;i<edge4->nb();i++){
 			/*Invert first two vertices if necessary*/
@@ -667,11 +667,11 @@
 		//clean up
 		delete edge4;
-		xfree((void**)&elemedge);
+		xDelete<double>(elemedge);
 
 		/*IssmSegments*/
-		if(verbose>5) printf("      writing IssmSegments\n");
+		if(verbose>5) _printLine_("      writing IssmSegments");
 		bamgmesh->IssmSegmentsSize[0]=NumIssmSegments;
 		bamgmesh->IssmSegmentsSize[1]=4;
-		bamgmesh->IssmSegments=(double*)xmalloc(4*NumIssmSegments*sizeof(double));
+		bamgmesh->IssmSegments=xNew<double>(4*NumIssmSegments);
 		num=0;
 		for (i=0;i<nbe;i++){
@@ -707,5 +707,5 @@
 				}
 				if (!stop){
-					_error_("Element holding segment [%i %i] not found...",i1+1,i2+1);
+					_error2_("Element holding segment [" << i1+1 << " " << i2+1 << "] not found...");
 				}
 			}
@@ -713,5 +713,5 @@
 
 		/*Triangles*/
-		if(verbose>5) printf("      writing Triangles\n");
+		if(verbose>5) _printLine_("      writing Triangles");
 		k=nbInT-nbq*2;
 		num=0;
@@ -719,5 +719,5 @@
 		bamgmesh->TrianglesSize[1]=4;
 		if (k){
-			bamgmesh->Triangles=(double*)xmalloc(4*k*sizeof(double));
+			bamgmesh->Triangles=xNew<double>(4*k);
 			for (i=0;i<nbt;i++){
 				Triangle &t=triangles[i];
@@ -734,9 +734,9 @@
 
 		/*Quadrilaterals*/
-		if(verbose>5) printf("      writing Quadrilaterals\n");
+		if(verbose>5) _printLine_("      writing Quadrilaterals");
 		bamgmesh->QuadrilateralsSize[0]=nbq;
 		bamgmesh->QuadrilateralsSize[1]=5;
 		if (nbq){
-			bamgmesh->Quadrilaterals=(double*)xmalloc(5*nbq*sizeof(double));
+			bamgmesh->Quadrilaterals=xNew<double>(5*nbq);
 			for (i=0;i<nbt;i++){
 				Triangle &t =triangles[i];
@@ -755,9 +755,9 @@
 
 		/*SubDomains*/
-		if(verbose>5) printf("      writing SubDomains\n");
+		if(verbose>5) _printLine_("      writing SubDomains");
 		bamgmesh->SubDomainsSize[0]=nbsubdomains;
 		bamgmesh->SubDomainsSize[1]=4;
 		if (nbsubdomains){
-			bamgmesh->SubDomains=(double*)xmalloc(4*nbsubdomains*sizeof(double));
+			bamgmesh->SubDomains=xNew<double>(4*nbsubdomains);
 			for (i=0;i<nbsubdomains;i++){
 				bamgmesh->SubDomains[i*4+0]=3;
@@ -769,9 +769,9 @@
 
 		/*SubDomainsFromGeom*/
-		if(verbose>5) printf("      writing SubDomainsFromGeom\n");
+		if(verbose>5) _printLine_("      writing SubDomainsFromGeom");
 		bamgmesh->SubDomainsFromGeomSize[0]=Gh.nbsubdomains;
 		bamgmesh->SubDomainsFromGeomSize[1]=4;
 		if (Gh.nbsubdomains){
-			bamgmesh->SubDomainsFromGeom=(double*)xmalloc(4*Gh.nbsubdomains*sizeof(double));
+			bamgmesh->SubDomainsFromGeom=xNew<double>(4*Gh.nbsubdomains);
 			for (i=0;i<Gh.nbsubdomains;i++){
 				bamgmesh->SubDomainsFromGeom[i*4+0]=2;
@@ -783,9 +783,9 @@
 
 		/*VerticesOnGeomVertex*/
-		if(verbose>5) printf("      writing VerticesOnGeomVertex\n");
+		if(verbose>5) _printLine_("      writing VerticesOnGeomVertex");
 		bamgmesh->VerticesOnGeomVertexSize[0]=NbVerticesOnGeomVertex;
 		bamgmesh->VerticesOnGeomVertexSize[1]=2;
 		if (NbVerticesOnGeomVertex){
-			bamgmesh->VerticesOnGeomVertex=(double*)xmalloc(2*NbVerticesOnGeomVertex*sizeof(double));
+			bamgmesh->VerticesOnGeomVertex=xNew<double>(2*NbVerticesOnGeomVertex);
 			for (i=0;i<NbVerticesOnGeomVertex;i++){
 				VertexOnGeom &v=VerticesOnGeomVertex[i];
@@ -797,13 +797,13 @@
 
 		/*VertexOnGeomEdge*/
-		if(verbose>5) printf("      writing VerticesOnGeomEdge\n");
+		if(verbose>5) _printLine_("      writing VerticesOnGeomEdge");
 		bamgmesh->VerticesOnGeomEdgeSize[0]=NbVerticesOnGeomEdge;
 		bamgmesh->VerticesOnGeomEdgeSize[1]=3;
 		if (NbVerticesOnGeomEdge){
-			bamgmesh->VerticesOnGeomEdge=(double*)xmalloc(3*NbVerticesOnGeomEdge*sizeof(double));
+			bamgmesh->VerticesOnGeomEdge=xNew<double>(3*NbVerticesOnGeomEdge);
 			for (i=0;i<NbVerticesOnGeomEdge;i++){
 				const VertexOnGeom &v=VerticesOnGeomEdge[i];
 				if (!v.OnGeomEdge()){
-					_error_("A vertices supposed to be OnGeomEdge is actually not");
+					_error2_("A vertices supposed to be OnGeomEdge is actually not");
 				}
 				bamgmesh->VerticesOnGeomEdge[i*3+0]=GetId((BamgVertex*)v)+1; //back to Matlab indexing
@@ -814,5 +814,5 @@
 
 		/*EdgesOnGeomEdge*/
-		if(verbose>5) printf("      writing EdgesOnGeomEdge\n");
+		if(verbose>5) _printLine_("      writing EdgesOnGeomEdge");
 		k=0;
 		for (i=0;i<nbe;i++){
@@ -822,5 +822,5 @@
 		bamgmesh->EdgesOnGeomEdgeSize[1]=2;
 		if (k){
-			bamgmesh->EdgesOnGeomEdge=(double*)xmalloc(2*(int)k*sizeof(double));
+			bamgmesh->EdgesOnGeomEdge=xNew<double>(2*(int)k);
 			int count=0;
 			for (i=0;i<nbe;i++){
@@ -834,8 +834,8 @@
 
 		/*Element Connectivity*/
-		if(verbose>5) printf("      writing Element connectivity\n");
+		if(verbose>5) _printLine_("      writing Element connectivity");
 		bamgmesh->ElementConnectivitySize[0]=nbt-nbtout;
 		bamgmesh->ElementConnectivitySize[1]=3;
-		bamgmesh->ElementConnectivity=(double*)xmalloc(3*(nbt-nbtout)*sizeof(double));
+		bamgmesh->ElementConnectivity=xNew<double>(3*(nbt-nbtout));
 		for (i=0;i<3*(nbt-nbtout);i++) bamgmesh->ElementConnectivity[i]=NAN;
 		num=0;
@@ -854,8 +854,8 @@
 
 		/*ElementNodal Connectivity*/
-		if(verbose>5) printf("      writing Nodal element connectivity\n");
+		if(verbose>5) _printLine_("      writing Nodal element connectivity");
 		bamgmesh->NodalElementConnectivitySize[0]=nbv;
 		bamgmesh->NodalElementConnectivitySize[1]=connectivitymax_1;
-		bamgmesh->NodalElementConnectivity=(double*)xmalloc(connectivitymax_1*nbv*sizeof(double));
+		bamgmesh->NodalElementConnectivity=xNew<double>(connectivitymax_1*nbv);
 		for (i=0;i<connectivitymax_1*nbv;i++) bamgmesh->NodalElementConnectivity[i]=NAN;
 		for (i=0;i<nbv;i++){
@@ -869,5 +869,5 @@
 
 		/*Nodal Connectivity*/
-		if(verbose>5) printf("      writing Nodal connectivity\n");
+		if(verbose>5) _printLine_("      writing Nodal connectivity");
 		//chaining algorithm (again...)
 		int* head_2=NULL;
@@ -877,7 +877,7 @@
 		i1=bamgmesh->IssmEdgesSize[0];
 		i2=bamgmesh->IssmEdgesSize[1];
-		head_2=(int*)xmalloc(nbv*sizeof(int));
-		next_2=(int*)xmalloc(2*i1*sizeof(int));
-		connectivitysize_2=(int*)xmalloc(nbv*sizeof(int));
+		head_2=xNew<int>(nbv);
+		next_2=xNew<int>(2*i1);
+		connectivitysize_2=xNew<int>(nbv);
 		//Initialization
 		for (i=0;i<nbv;i++) head_2[i]=-1;
@@ -888,7 +888,7 @@
 			for (j=0;j<2;j++){
 				int v=(int)bamgmesh->IssmEdges[i*i2+j]-1; //back to C indexing
-				if (k>2*i1-1 || k<0) _error_("Index exceed matrix dimensions (k=%i not in [0 %i]",k,2*i1-1);
+				if (k>2*i1-1 || k<0) _error2_("Index exceed matrix dimensions (k=" << k << " not in [0 " << 2*i1-1 << "]");
 				next_2[k]=head_2[v];
-				if (v>nbv-1 || v<0)   _error_("Index exceed matrix dimensions (v=%i not in [0 %i])",v,nbv-1);
+				if (v>nbv-1 || v<0)   _error2_("Index exceed matrix dimensions (v=" << v << " not in [0 " << nbv-1 << "])");
 				head_2[v]=k++;
 				connectivitysize_2[v]+=1;
@@ -902,5 +902,5 @@
 		bamgmesh->NodalConnectivitySize[0]=nbv;
 		bamgmesh->NodalConnectivitySize[1]=connectivitymax_2;
-		bamgmesh->NodalConnectivity=(double*)xmalloc(connectivitymax_2*nbv*sizeof(double));
+		bamgmesh->NodalConnectivity=xNew<double>(connectivitymax_2*nbv);
 		for (i=0;i<connectivitymax_2*nbv;i++) bamgmesh->NodalConnectivity[i]=NAN;
 		for (i=0;i<nbv;i++){
@@ -921,9 +921,9 @@
 
 		/*Cracked vertices*/
-		if(verbose>5) printf("      writing Cracked vertices\n");
+		if(verbose>5) _printLine_("      writing Cracked vertices");
 		bamgmesh->CrackedVerticesSize[0]=NbCrackedVertices;
 		bamgmesh->CrackedVerticesSize[1]=2;
 		if (NbCrackedVertices){
-			bamgmesh->CrackedVertices=(double*)xmalloc(2*NbCrackedVertices*sizeof(double));
+			bamgmesh->CrackedVertices=xNew<double>(2*NbCrackedVertices);
 			for (i=0;i<NbCrackedVertices;i++){
 				bamgmesh->CrackedVertices[i*2+0]=CrackedVertices[i*2+0]+1; //M indexing
@@ -933,9 +933,9 @@
 
 		/*Cracked vertices*/
-		if(verbose>5) printf("      writing Cracked vertices\n");
+		if(verbose>5) _printLine_("      writing Cracked vertices");
 		bamgmesh->CrackedEdgesSize[0]=NbCrackedEdges;
 		bamgmesh->CrackedEdgesSize[1]=4;
 		if (NbCrackedEdges){
-			bamgmesh->CrackedEdges=(double*)xmalloc(2*NbCrackedEdges*sizeof(double));
+			bamgmesh->CrackedEdges=xNew<double>(2*NbCrackedEdges);
 			for (i=0;i<NbCrackedEdges;i++){
 				bamgmesh->CrackedEdges[i*2+0]=0;//CrackedEdges[i]->+1; //M indexing
@@ -945,15 +945,15 @@
 
 		//clean up
-		xfree((void**)&connectivitysize_1);
-		xfree((void**)&head_1);
-		xfree((void**)&next_1);
-		xfree((void**)&connectivitysize_2);
-		xfree((void**)&head_2);
-		xfree((void**)&next_2);
+		xDelete<int>(connectivitysize_1);
+		xDelete<int>(head_1);
+		xDelete<int>(next_1);
+		xDelete<int>(connectivitysize_2);
+		xDelete<int>(head_2);
+		xDelete<int>(next_2);
 		delete [] reft;
 		delete [] numt;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::ReadMetric{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::ReadMetric{{{*/
 	void Mesh::ReadMetric(const BamgOpts* bamgopts) {
 
@@ -961,5 +961,5 @@
 		int  i,j;
 
-		if(bamgopts->verbose>3) printf("      processing metric\n");
+		if(bamgopts->verbose>3) _printLine_("      processing metric");
 		double hmin = Max(bamgopts->hmin,MinimalHmin());
 		double hmax = Min(bamgopts->hmax,MaximalHmax());
@@ -992,10 +992,10 @@
 		}
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::WriteMetric{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::WriteMetric{{{*/
 	void Mesh::WriteMetric(BamgOpts* bamgopts) {
 		int i;
-		xfree((void**)&bamgopts->metric);
-		bamgopts->metric=(double*)xmalloc(3*nbv*sizeof(double));
+		xDelete<double>(bamgopts->metric);
+		bamgopts->metric=xNew<double>(3*nbv);
 		for (i=0;i<nbv;i++){
 			bamgopts->metric[i*3+0]=vertices[i].m.a11;
@@ -1004,6 +1004,6 @@
 		}
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::WriteIndex{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::WriteIndex{{{*/
 	void Mesh::WriteIndex(int** pindex,int* pnels){
 
@@ -1023,15 +1023,15 @@
 
 		if (k){
-			index=(int*)xmalloc(3*k*sizeof(double));
+			index=xNew<int>(3*k);
 			num=0;
 			for (i=0;i<nbt;i++){
 				Triangle &t=triangles[i];
 				if (t.det>0 && !(t.Hidden(0)||t.Hidden(1) || t.Hidden(2) )){
-					if(t.Anisotropy()<2 & t.Length()<1.e+5){
+					//if(t.Anisotropy()<2 & t.Length()<1.e+5){
 						index[num*3+0]=GetId(t[0])+1; //back to M indexing
 						index[num*3+1]=GetId(t[1])+1; //back to M indexing
 						index[num*3+2]=GetId(t[2])+1; //back to M indexing
 						num=num+1;
-					}
+					//}
 				}
 			}
@@ -1042,8 +1042,8 @@
 		*pnels=num;
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*Methods*/
-	/*FUNCTION Mesh::AddGeometryMetric{{{1*/
+	/*FUNCTION Mesh::AddGeometryMetric{{{*/
 	void Mesh::AddGeometryMetric(BamgOpts* bamgopts){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/IntersectGeomMetric)*/
@@ -1061,5 +1061,5 @@
 		//check that hmax is positive
 		if (hmax<=0){
-			_error_("hmax<=0");
+			_error2_("hmax<=0");
 		}
 
@@ -1090,5 +1090,5 @@
 
 				if (ht<=0 || hn<=0){
-					_error_("ht<=0 || hn<=0");
+					_error2_("ht<=0 || hn<=0");
 				}
 				EigenMetric Vp(1/(ht*ht),1/(hn*hn),tg);
@@ -1099,6 +1099,6 @@
 		// the problem is for the vertex on vertex 
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::AddMetric{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::AddMetric{{{*/
 	void Mesh::AddMetric(BamgOpts* bamgopts){
 		//  Hessiantype = 0 =>  H is computed using double P2 projection
@@ -1115,9 +1115,9 @@
 		}
 		else{
-			_error_("Hessiantype %i not supported yet (1->use Green formula, 0-> double P2 projection)",Hessiantype);
-		}
-	}
-	/*}}}1*/
-	/*FUNCTION Mesh::AddVertex{{{1*/
+			_error2_("Hessiantype " << Hessiantype << " not supported yet (1->use Green formula, 0-> double P2 projection)");
+		}
+	}
+	/*}}}*/
+	/*FUNCTION Mesh::AddVertex{{{*/
 	void Mesh::AddVertex( BamgVertex &s,Triangle* t, Icoor2* det3) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Add)*/
@@ -1159,5 +1159,5 @@
 		//some checks
 		if (( infvertexindex <0 ) && (detOld <0) ||  ( infvertexindex >=0  ) && (detOld >0) ){
-			_error_("inconsistent configuration (Contact ISSM developers)");
+			_error2_("inconsistent configuration (Contact ISSM developers)");
 		}
 
@@ -1201,5 +1201,5 @@
 			}
 			else{
-				_error_("Cannot add a vertex more than once. Check duplicates");
+				_error2_("Cannot add a vertex more than once. Check duplicates");
 			}
 		}
@@ -1214,5 +1214,5 @@
 		tt[2]= &triangles[nbt++];
 
-		if (nbt>maxnbt) _error_("Not enough triangles");
+		if (nbt>maxnbt) _error2_("Not enough triangles");
 
 		*tt[1]=*tt[2]=*t;
@@ -1251,10 +1251,10 @@
 
 			if (!rswap) {
-				_error_("swap the point s is on a edge");
-			}
-		}
-	}
-	/*}}}1*/
-	/*FUNCTION Mesh::BoundAnisotropy{{{1*/
+				_error2_("swap the point s is on a edge");
+			}
+		}
+	}
+	/*}}}*/
+	/*FUNCTION Mesh::BoundAnisotropy{{{*/
 	void  Mesh::BoundAnisotropy(double anisomax,double hminaniso) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/BoundAnisotropy)*/
@@ -1264,5 +1264,5 @@
 
 		//display info
-		if (verbose > 1)  printf("   BoundAnisotropy by %g\n",anisomax);
+		if (verbose > 1)  _printLine_("   BoundAnisotropy by " << anisomax);
 
 		double h1=1.e30,h2=1e-30;
@@ -1291,10 +1291,10 @@
 		//display info
 		if (verbose>2){
-			printf("      input:  Hmin = %g, Hmax = %g, factor of anisotropy max  = %g\n",pow(h2,-0.5),pow(h1,-0.5),pow(rx,0.5));
-			printf("      output: Hmin = %g, Hmax = %g, factor of anisotropy max  = %g\n",pow(hn2,-0.5),pow(hn1,-0.5),pow(rnx,0.5));
-		}
-	}
-	/*}}}1*/
-	/*FUNCTION Mesh::BuildGeometryFromMesh{{{1*/
+			_printLine_("      input:  Hmin = " << pow(h2,-0.5)  << ", Hmax = " << pow(h1,-0.5) << ", factor of anisotropy max  = " << pow(rx,0.5));
+			_printLine_("      output: Hmin = " << pow(hn2,-0.5) << ", Hmax = " << pow(hn1,-0.5)<< ", factor of anisotropy max  = " <<pow(rnx,0.5));
+		}
+	}
+	/*}}}*/
+	/*FUNCTION Mesh::BuildGeometryFromMesh{{{*/
 	void Mesh::BuildGeometryFromMesh(BamgOpts* bamgopts){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/ConsGeometry)*/
@@ -1314,9 +1314,9 @@
 
 		//display info
-		if (verbose>1) printf("   construction of the geometry from the 2d mesh\n");
+		if (verbose>1) _printLine_("   construction of the geometry from the 2d mesh");
 
 		//check that the mesh is not empty
 		if (nbt<=0 || nbv <=0 ) {
-			_error_("nbt or nbv is negative (Mesh empty?)");
+			_error2_("nbt or nbv is negative (Mesh empty?)");
 		}
 
@@ -1340,5 +1340,5 @@
 		if (nbe !=  edge4->nb()){ 
 			delete [] st;
-			_error_("Some Double edge in the mesh, the number is %i, nbe4=%i",nbe,edge4->nb()); 
+			_error2_("Some Double edge in the mesh, the number is " << nbe << ", nbe4=" << edge4->nb()); 
 		}
 		//keep nbe in nbeold
@@ -1360,5 +1360,5 @@
 					//check that it is not an edge on boundary (should not already exist)
 					if (triangles[i].TriangleAdj(j) || triangles[st[k]/3].TriangleAdj((int) (st[k]%3))){
-						_error_("problem in Geometry reconstruction: an edge on boundary is duplicated (double element?)");
+						_error2_("problem in Geometry reconstruction: an edge on boundary is duplicated (double element?)");
 					}
 					//OK, the element is not on boundary, is belongs to 2 triangles -> build Adjacent triangles list
@@ -1374,9 +1374,9 @@
 				//else (see 3 lines above), the edge has been called more than twice: return error
 				else {
-					printf("The edge (%i,%i) belongs to more than 2 triangles (%i)\n",GetId(triangles[i][VerticesOfTriangularEdge[j][0]]),GetId(triangles[i][VerticesOfTriangularEdge[j][1]]),k);
-					printf("Edge %i of triangle %i\n",j,i);
-					printf("Edge %i of triangle %i\n",(-st[k]+2)%3,(-st[k]+2)/3);
-					printf("Edge %i of triangle %i\n",triangles[(-st[k]+2)/3].NuEdgeTriangleAdj((int)((-st[k]+2)%3)),GetId(triangles[(-st[k]+2)/3].TriangleAdj((int)((-st[k]+2)%3))));
-					_error_("An edge belongs to more than 2 triangles");
+					_printLine_("The edge (" << GetId(triangles[i][VerticesOfTriangularEdge[j][0]]) << "," << GetId(triangles[i][VerticesOfTriangularEdge[j][1]]) << ") belongs to more than 2 triangles (" << k << ")");
+					_printLine_("Edge " << j << " of triangle " << i);
+					_printLine_("Edge " << (-st[k]+2)%3 << " of triangle " << (-st[k]+2)/3);
+					_printLine_("Edge " << triangles[(-st[k]+2)/3].NuEdgeTriangleAdj((int)((-st[k]+2)%3)) << " of triangle " << GetId(triangles[(-st[k]+2)/3].TriangleAdj((int)((-st[k]+2)%3))));
+					_error2_("An edge belongs to more than 2 triangles");
 				}	
 			}
@@ -1389,10 +1389,10 @@
 		//display info
 		if(verbose>5) {
-			printf("         info on Mesh:\n");
-			printf("            - number of vertices    = %i \n",nbv); 
-			printf("            - number of triangles   = %i \n",nbt); 
-			printf("            - number of given edges = %i \n",nbe); 
-			printf("            - number of all edges   = %i \n",nbedges); 
-			printf("            - Euler number 1 - nb of holes = %i \n"  ,nbt-nbedges+nbv); 
+			_printLine_("         info on Mesh:");
+			_printLine_("            - number of vertices    = " << nbv); 
+			_printLine_("            - number of triangles   = " << nbt); 
+			_printLine_("            - number of given edges = " << nbe); 
+			_printLine_("            - number of all edges   = " << nbedges); 
+			_printLine_("            - Euler number 1 - nb of holes = " << nbt-nbedges+nbv); 
 		}
 
@@ -1425,5 +1425,5 @@
 
 			//display info
-			if(verbose>4) printf("   Construction of the edges %i\n",nbe);
+			if(verbose>4) _printLine_("   Construction of the edges " << nbe);
 
 			for (i=0;i<nbedges;i++){ 
@@ -1451,5 +1451,5 @@
 						edges[add].ReferenceNumber=edgessave[i].ReferenceNumber; 		      
 						edges[add].GeomEdgeHook=edgessave[i].GeomEdgeHook; //  HACK to get required edges
-						printf("oh no...\n");
+						_printLine_("oh no...");
 					}
 					else
@@ -1460,5 +1460,5 @@
 			//check that we have been through all edges
 			if (k!=nbe){
-				_error_("problem in edge construction process: k!=nbe (should not happen)");
+				_error2_("problem in edge construction process: k!=nbe (should not happen)");
 			}
 			//delete edgessave
@@ -1505,5 +1505,5 @@
 					//check that we have the correct vertex
 					if (v!=edges[i0 ].v[j0]){
-						_error_("v!=edges[i0 ].v[j0]: this should not happen as the vertex belongs to this edge");
+						_error2_("v!=edges[i0 ].v[j0]: this should not happen as the vertex belongs to this edge");
 					}
 
@@ -1522,5 +1522,5 @@
 		//check that nbsubdomains is empty
 		if (nbsubdomains){
-			_error_("nbsubdomains should be 0");
+			_error2_("nbsubdomains should be 0");
 		}
 		nbsubdomains=0;
@@ -1566,5 +1566,5 @@
 			}
 		}
-		if (verbose> 3) printf("      The Number of sub domain = %i\n",nbsubdomains); 
+		if (verbose> 3) _printLine_("      The Number of sub domain = " << nbsubdomains); 
 
 		//build subdomains
@@ -1591,5 +1591,5 @@
 		if (k!= nbsubdomains){
 			delete [] colorT;
-			_error_("k!= nbsubdomains");
+			_error2_("k!= nbsubdomains");
 		}
 		//delete colorT and st
@@ -1618,5 +1618,5 @@
 		Gh.nbsubdomains = nbsubdomains;
 		Gh.subdomains = new GeomSubDomain[nbsubdomains];
-		if (verbose>3) printf("   number of vertices = %i\n   number of edges = %i\n",Gh.nbv,Gh.nbe);
+		if (verbose>3) _printLine_("   number of vertices = " << Gh.nbv << "\n   number of edges = " << Gh.nbe);
 		NbVerticesOnGeomVertex = Gh.nbv;
 		VerticesOnGeomVertex = new VertexOnGeom[NbVerticesOnGeomVertex];
@@ -1652,5 +1652,5 @@
 		if (Gh.coefIcoor<=0){
 			delete [] colorV;
-			_error_("Gh.coefIcoor<=0 in infered Geometry (this should not happen)");
+			_error2_("Gh.coefIcoor<=0 in infered Geometry (this should not happen)");
 		}
 
@@ -1705,5 +1705,5 @@
 				delete [] len;
 				delete [] colorV;
-				_error_("problem in Edge4 construction: k != i");
+				_error2_("problem in Edge4 construction: k != i");
 			}
 		}
@@ -1734,5 +1734,5 @@
 			}
 			else
-			 _error_("%i should be >=0");
+			 _error2_("%i should be >=0");
 		  }
 
@@ -1748,6 +1748,6 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::BuildMetric0 (double P2 projection){{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::BuildMetric0 (double P2 projection){{{*/
 	void Mesh::BuildMetric0(BamgOpts* bamgopts){
 
@@ -1768,5 +1768,5 @@
 
 		/*Check size*/
-		if (bamgopts->fieldSize[0] != nbv) _error_("'field' should have %i rows",nbv);
+		if (bamgopts->fieldSize[0] != nbv) _error2_("'field' should have " << nbv << " rows");
 
 		//initialization of some variables
@@ -1790,12 +1790,12 @@
 		//display infos
 		if(verbose>1) {
-			printf("   Construction of Metric: number of field: %i (nbt=%i, nbv=%i)\n",nbsol,nbt,nbv);
+			_printLine_("   Construction of Metric: number of field: " << nbsol << " (nbt=" << nbt << ", nbv=" << nbv << ")");
 		}
 
 		//first, build the chains that will be used for the Hessian computation, as weel as the area of each element
 		int* head_s=NULL;
-		head_s=(int*)xmalloc(nbv*sizeof(int));
+		head_s=xNew<int>(nbv);
 		int* next_p=NULL;
-		next_p=(int*)xmalloc(3*nbt*sizeof(int));
+		next_p=xNew<int>(3*nbt);
 		int  p=0;
 		//initialization
@@ -1862,9 +1862,9 @@
 
 			//display info
-			if(verbose>2) printf("      Solution %i, Min = %g, Max = %g, Delta = %g\n",nusol,smin,smax,sdelta);
+			if(verbose>2) _printLine_("      Solution " << nusol << ", Min = " << smin << ", Max = " << smax << ", Delta = " << sdelta);
 
 			//skip constant field
 			if (sdelta < 1.0e-10*Max(absmax,1e-20)){
-				printf("      Solution %i is constant, skipping...\n",nusol);
+				_printLine_("      Solution " << nusol << " is constant, skipping...");
 				continue;
 			}
@@ -1936,6 +1936,6 @@
 
 		//clean up
-		xfree((void**)&head_s);
-		xfree((void**)&next_p);
+		xDelete<int>(head_s);
+		xDelete<int>(next_p);
 		delete [] detT;
 		delete [] alpha;
@@ -1953,6 +1953,6 @@
 		delete [] dydy_vertex;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::BuildMetric1 (Green formula){{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::BuildMetric1 (Green formula){{{*/
 	void Mesh::BuildMetric1(BamgOpts* bamgopts){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/IntersectConsMetric)*/
@@ -1973,5 +1973,5 @@
 
 		/*Check size*/
-		if (bamgopts->fieldSize[0] != nbv) _error_("'field' should have %i rows",nbv);
+		if (bamgopts->fieldSize[0] != nbv) _error2_("'field' should have " << nbv << " rows");
 
 		//initialization of some variables
@@ -1992,5 +1992,5 @@
 		//display infos
 		if(verbose>1) {
-			printf("   Construction of Metric: number of field: %i (nbt=%i, nbv=%i)\n",nbsol,nbt,nbv);
+			_printLine_("   Construction of Metric: number of field: " << nbsol << " (nbt=" << nbt << ", nbv=" << nbv << ")");
 		}
 
@@ -2075,9 +2075,9 @@
 
 			//display info
-			if(verbose>2) printf("      Solution %i, Min = %g, Max = %g, Delta = %g, number of fields = %i\n",nusol,smin,smax,sdelta,nbsol);
+			if(verbose>2) _printLine_("      Solution " << nusol << ", Min = " << smin << ", Max = " << smax << ", Delta = " << sdelta << ", number of fields = " << nbsol);
 
 			//skip constant field
 			if (sdelta < 1.0e-10*Max(absmax,1e-20) ){
-				if (verbose>2) printf("      Solution %i is constant, skipping...\n",nusol);
+				if (verbose>2) _printLine_("      Solution " << nusol << " is constant, skipping...");
 				continue;
 			}
@@ -2244,6 +2244,6 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::CrackMesh{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::CrackMesh{{{*/
 	void Mesh::CrackMesh(BamgOpts* bamgopts) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/CrackMesh)*/
@@ -2264,5 +2264,5 @@
 		//Return if no edge is cracked
 		if(k==0) return;
-		if (verbose>4) printf("      number of Cracked Edges = %i\n",k);
+		if (verbose>4) _printLine_("      number of Cracked Edges = " << k);
 
 		//Initialize Cracked edge
@@ -2298,5 +2298,5 @@
 				if (splitvertex[i1]==3 || splitvertex[i2]==3){
 					delete [] splitvertex;
-					_error_("Crossing rifts not supported yet");
+					_error2_("Crossing rifts not supported yet");
 				}
 			}
@@ -2305,7 +2305,7 @@
 
 		//Add new vertices
-		if (verbose>4) printf("      number of Cracked Vertices = %i\n",NbCrackedVertices);
+		if (verbose>4) _printLine_("      number of Cracked Vertices = " << NbCrackedVertices);
 		if (NbCrackedVertices){
-			CrackedVertices=(long*)xmalloc(2*NbCrackedVertices*sizeof(double));
+			CrackedVertices=xNew<long>(2*NbCrackedVertices);
 			num=0;
 			for (i=0;i<nbv;i++){
@@ -2374,7 +2374,7 @@
 					}
 				}
-				//printf("%i -> %i %i %i, edge [%i->%i %i->%i]\n",element_renu[GetId(ta.t)],GetId((*ta.t)[0])+1,GetId((*ta.t)[1])+1,GetId((*ta.t)[2])+1,i1,j1,i2,j2);
+				//_printLine_(element_renu[GetId(ta.t)] << " -> " << GetId((*ta.t)[0])+1 << " " << GetId((*ta.t)[1])+1 << " " << GetId((*ta.t)[2])+1 << ", edge [" << i1 << "->" << j1 << " " << i2 << "->" << j2 << "]");
 				ta = Next(ta).Adj(); 
-				if (count++>50) _error_("Maximum number of iteration exceeded");
+				if (count++>50) _error2_("Maximum number of iteration exceeded");
 			}while ((tbegin != ta)); 
 		}
@@ -2383,5 +2383,5 @@
 		for(i=0;i<NbCrackedEdges;i++){
 			if (Edgeflags[i]!=2){
-				_error_("A problem occured: at least one crack edge (number %i) does not belong to 2 elements",i+1);
+				_error2_("A problem occured: at least one crack edge (number " << i+1 << ") does not belong to 2 elements");
 			}
 		}
@@ -2392,30 +2392,30 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::Echo{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::Echo{{{*/
 	void Mesh::Echo(void) {
 
 		int i;
 
-		printf("Mesh Echo:\n");
-		printf("   nbv = %i\n",nbv);
-		printf("   nbt = %i\n",nbt);
-		printf("   nbe = %i\n",nbe);
-		printf("   nbq = %i\n",nbq);
-		printf("   index:\n");
+		_printLine_("Mesh Echo:");
+		_printLine_("   nbv = " << nbv);
+		_printLine_("   nbt = " << nbt);
+		_printLine_("   nbe = " << nbe);
+		_printLine_("   nbq = " << nbq);
+		_printLine_("   index:");
 		for (i=0;i<nbt;i++){
-			printf("   %4i: [%4i %4i %4i]\n",i+1,
-						((BamgVertex *)triangles[i](0))?GetId(triangles[i][0])+1:0,
-						((BamgVertex *)triangles[i](1))?GetId(triangles[i][1])+1:0,
-						((BamgVertex *)triangles[i](2))?GetId(triangles[i][2])+1:0);
-		}
-		printf("   coordinates:\n");
+			_printLine_("   " << setw(4) << i+1 << ": [" 
+						<< setw(4) << (((BamgVertex *)triangles[i](0))?GetId(triangles[i][0])+1:0) << " " 
+						<< setw(4) << (((BamgVertex *)triangles[i](0))?GetId(triangles[i][1])+1:0) << " " 
+						<< setw(4) << (((BamgVertex *)triangles[i](0))?GetId(triangles[i][2])+1:0) << "]");
+		}
+		_printLine_("   coordinates:");
 		for (i=0;i<nbv;i++){
-			printf("   %4i: [%g %g]\n",i+1,vertices[i].r.x,vertices[i].r.y);
-		}
-
-	}
-	/*}}}1*/
-	/*FUNCTION Mesh::ForceBoundary{{{1*/
+			_printLine_("   " << setw(4) << i+1 << ": [" << vertices[i].r.x << " " << vertices[i].r.y << "]");
+		}
+
+	}
+	/*}}}*/
+	/*FUNCTION Mesh::ForceBoundary{{{*/
 		void Mesh::ForceBoundary() {
 			/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ForceBoundary)*/
@@ -2426,5 +2426,5 @@
 
 			//display
-			if (verbose > 2) printf("   ForceBoundary  nb of edge: %i\n",nbe);
+			if (verbose > 2) _printLine_("   ForceBoundary  nb of edge: " << nbe);
 
 			//check that there is no triangle with 0 determinant
@@ -2433,5 +2433,5 @@
 			}
 			if (k!=0) {
-				_error_("there is %i triangles of mes = 0",k);
+				_error2_("there is " << k << " triangles of mes = 0");
 			}
 
@@ -2447,18 +2447,18 @@
 				if (nbswp) nbfe++;
 				if ( nbswp < 0 && k < 5){
-					_error_("Missing Edge %i, v0=%i,v1=%i",i,GetId(edges[i][0]),GetId(edges[i][1]));
+					_error2_("Missing Edge " << i << ", v0=" << GetId(edges[i][0]) << ",v1=" << GetId(edges[i][1]));
 				}
 			}
 
 			if (k!=0) {
-				_error_("There are %i lost edges, the boundary might be crossing",k);
+				_error2_("There are " << k << " lost edges, the boundary might be crossing");
 			}
 			for (int j=0;j<nbv;j++){
 				Nbswap +=  vertices[j].Optim(1,0);
 			}
-			if (verbose > 3) printf("      number of inforced edge = %i, number of swap= %i\n",nbfe,Nbswap); 
-		}
-	/*}}}1*/
-	/*FUNCTION Mesh::FindSubDomain{{{1*/
+			if (verbose > 3) _printLine_("      number of inforced edge = " << nbfe << ", number of swap= " << Nbswap); 
+		}
+	/*}}}*/
+	/*FUNCTION Mesh::FindSubDomain{{{*/
 	void Mesh::FindSubDomain(int OutSide) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FindSubDomain)*/
@@ -2467,6 +2467,6 @@
 
 		if (verbose >2){
-			if (OutSide) printf("   Find all external sub-domain\n"); 
-			else printf("   Find all internal sub-domain\n");
+			if (OutSide) _printLine_("   Find all external sub-domain"); 
+			else _printLine_("   Find all internal sub-domain");
 		  }
 		short * HeapArete = new short[nbt];
@@ -2534,5 +2534,5 @@
 			if (nbt == nbtout ||  !NbSubDomTot) {
 				delete [] HeapArete;
-				_error_("The boundary is not close: all triangles are outside");
+				_error2_("The boundary is not close: all triangles are outside");
 			}
 
@@ -2572,5 +2572,5 @@
 						if (k!=nbsubdomains){
 							delete [] mark;
-							_error_("k!=nbsubdomains");
+							_error2_("k!=nbsubdomains");
 						}
 						if(OutSide) 
@@ -2613,5 +2613,5 @@
 								 }//while (t)
 								}
-							if(verbose>4) printf("      Number of removes subdomains (OutSideMesh) = %i\n",nbsubdomains-j);
+							if(verbose>4) _printLine_("      Number of removes subdomains (OutSideMesh) = " << nbsubdomains-j);
 							nbsubdomains=j;
 						  }
@@ -2662,5 +2662,5 @@
 							 subdomains[i].head=t=ta;
 							if(t<triangles || t >= triangles+nbt || t->det < 0 || t->link == 0) {
-								_error_("bad definition of SubSomain %i",i);
+								_error2_("bad definition of SubSomain " << i);
 							}
 							long it = GetId(t);
@@ -2677,5 +2677,5 @@
 								kkk++;
 								if (mark[GetId(tt)]>=0){
-									_error_("mark[GetId(tt)]>=0");
+									_error2_("mark[GetId(tt)]>=0");
 								}
 								mark[GetId(tt)]=i;
@@ -2686,5 +2686,5 @@
 						ta = Previous(Adj(ta));         
 						if(t == (Triangle *) ta) {
-							_error_("bad definition of SubSomain %i",i);
+							_error2_("bad definition of SubSomain " << i);
 						}
 					}
@@ -2692,5 +2692,5 @@
 
 				if (inew < nbsubdomains) {
-					if (verbose>5) printf("WARNING: %i SubDomains are being removed\n",nbsubdomains-inew);
+					if (verbose>5) _printLine_("WARNING: " << nbsubdomains-inew << " SubDomains are being removed");
 					nbsubdomains=inew;}
 
@@ -2707,36 +2707,36 @@
 			 if(!triangles[it].link)  nbtout++;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::GetId(const Triangle & t) const{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::GetId(const Triangle & t) const{{{*/
 	long Mesh::GetId(const Triangle & t) const  { 
 		return &t - triangles;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::GetId(const Triangle * t) const{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::GetId(const Triangle * t) const{{{*/
 	long Mesh::GetId(const Triangle * t) const  { 
 		return t - triangles;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::GetId(const BamgVertex & t) const{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::GetId(const BamgVertex & t) const{{{*/
 	long Mesh::GetId(const BamgVertex & t) const  { 
 		return &t - vertices;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::GetId(const BamgVertex * t) const{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::GetId(const BamgVertex * t) const{{{*/
 	long Mesh::GetId(const BamgVertex * t) const  { 
 		return t - vertices;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::GetId(const Edge & t) const{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::GetId(const Edge & t) const{{{*/
 	long Mesh::GetId(const Edge & t) const  { 
 		return &t - edges;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::GetId(const Edge * t) const{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::GetId(const Edge * t) const{{{*/
 	long Mesh::GetId(const Edge * t) const  { 
 		return t - edges;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::Init{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::Init{{{*/
 	void Mesh::Init(long maxnbv_in) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/PreInit)*/
@@ -2786,6 +2786,6 @@
 		} 
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::Insert{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::Insert{{{*/
 	void Mesh::Insert() {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Insert)*/
@@ -2800,5 +2800,5 @@
 
 		//Display info
-		if (verbose>2) printf("   Insert initial %i vertices\n",nbv);
+		if (verbose>2) _printLine_("   Insert initial " << nbv << " vertices");
 
 		//Compute integer coordinates for the existing vertices
@@ -2848,5 +2848,5 @@
 			//if i is higher than nbv, it means that all the determinants are 0,
 			//all vertices are aligned!
-			if  (++i>=nbv) _error_("all the vertices are aligned");
+			if  (++i>=nbv) _error2_("all the vertices are aligned");
 		}
 		// exchange i et 2 in "orderedvertices" so that
@@ -2891,5 +2891,5 @@
 		/*Now, add the vertices One by One*/
 		long NbSwap=0;
-		if (verbose>3) printf("   Begining of insertion process...\n");
+		if (verbose>3) _printLine_("   Begining of insertion process...");
 
 		for (int icount=2; icount<nbv; icount++) {
@@ -2914,6 +2914,6 @@
 		//Display info
 		if (verbose>3) {
-			printf("      NbSwap of insertion: %i\n",NbSwap);
-			printf("      NbSwap/nbv:          %i\n",NbSwap/nbv);
+			_printLine_("      NbSwap of insertion: " << NbSwap);
+			_printLine_("      NbSwap/nbv:          " << NbSwap/nbv);
 		}
 
@@ -2929,6 +2929,6 @@
 			 NbSwap += orderedvertices[is1]->Optim(0,0);
 			if (verbose>3) {
-				printf("      Optim Loop: %i\n",Nbloop);
-				printf("      NbSwap/nbv:          %i\n",NbSwap/nbv);
+				_printLine_("      Optim Loop: " << Nbloop);
+				_printLine_("      NbSwap/nbv:          " << NbSwap/nbv);
 			}
 			if(!NbSwap) break;
@@ -2938,6 +2938,6 @@
 #endif
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::InsertNewPoints{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::InsertNewPoints{{{*/
 	long Mesh::InsertNewPoints(long nbvold,long & NbTSwap) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/InsertNewPoints)*/
@@ -2953,5 +2953,5 @@
 
 		//display info if required
-		if (verbose>5) printf("      Try to Insert %i new points\n",nbvnew);
+		if (verbose>5) _printLine_("      Try to Insert " << nbvnew << " new points");
 
 		//return if no new points
@@ -2984,5 +2984,5 @@
 				long  j=vj.ReferenceNumber; 
 				if (&vj!=orderedvertices[j]){
-					_error_("&vj!= orderedvertices[j]");
+					_error2_("&vj!= orderedvertices[j]");
 				}
 				if(i!=j){ 
@@ -2994,5 +2994,5 @@
 				if (tcvj && !tcvj->link){
 					tcvj->Echo();
-					_error_("problem inserting point in InsertNewPoints (tcvj=%p and tcvj->link=%i)",tcvj,tcvj->link);
+					_error2_("problem inserting point in InsertNewPoints (tcvj=" << tcvj << " and tcvj->link=" << tcvj->link << ")");
 				}
 				quadtree->Add(vj);
@@ -3003,28 +3003,28 @@
 		} 
 		if (verbose>3) {
-			printf("         number of new points: %i\n",iv);
-			printf("         number of to close (?) points: %i\n",nbv-iv);
-			printf("         number of swap after: %i\n",NbSwap);
+			_printLine_("         number of new points: " << iv);
+			_printLine_("         number of to close (?) points: " << nbv-iv);
+			_printLine_("         number of swap after: " << NbSwap);
 		}
 		nbv = iv;
 
 		for (i=nbvold;i<nbv;i++) NbSwap += vertices[i].Optim(1);  
-		if (verbose>3) printf("   NbSwap=%i\n",NbSwap);
+		if (verbose>3) _printLine_("   NbSwap=" << NbSwap);
 
 		NbTSwap +=  NbSwap ;
 		return nbv-nbvold;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::isCracked{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::isCracked{{{*/
 	int Mesh::isCracked() const {
 		return NbCrackedVertices != 0;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::MakeGeomEdgeToEdge{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::MakeGeomEdgeToEdge{{{*/
 	Edge** Mesh::MakeGeomEdgeToEdge() {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeGeomEdgeToEdge)*/
 
 		if (!Gh.nbe){
-			_error_("!Gh.nbe");
+			_error2_("!Gh.nbe");
 		}
 		Edge **e= new (Edge* [Gh.nbe]);
@@ -3056,13 +3056,13 @@
 			if (!e[i]){
 				kk++;
-				if(kk<10) printf("BUG: the geometrical edge %i is on no edge curve\n",i);
-			}
-		}
-		if(kk) _error_("See above");
+				if(kk<10) _printLine_("BUG: the geometrical edge " << i << " is on no edge curve");
+			}
+		}
+		if(kk) _error2_("See above");
 
 		return e;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::MakeQuadrangles{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::MakeQuadrangles{{{*/
 	void Mesh::MakeQuadrangles(double costheta){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeQuadrangles)*/
@@ -3070,8 +3070,8 @@
 		long int verbose=0;
 
-		if (verbose>2) printf("MakeQuadrangles costheta = %g\n",costheta);
+		if (verbose>2) _printLine_("MakeQuadrangles costheta = " << costheta);
 
 		if (costheta >1) {
-			if (verbose>5) printf("   do nothing: costheta > 1\n");
+			if (verbose>5) _printLine_("   do nothing: costheta > 1");
 		}
 
@@ -3100,12 +3100,12 @@
 			nbq = kk;
 			if (verbose>2){
-				printf("   number of quadrilaterals    = %i\n",nbq);
-				printf("   number of triangles         = %i\n",nbt-nbtout- nbq*2);
-				printf("   number of outside triangles = %i\n",nbtout);
+				_printLine_("   number of quadrilaterals    = " << nbq);
+				_printLine_("   number of triangles         = " << nbt-nbtout- nbq*2);
+				_printLine_("   number of outside triangles = " << nbtout);
 			}
 			delete [] qq;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::MakeBamgQuadtree{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::MakeBamgQuadtree{{{*/
 	void Mesh::MakeBamgQuadtree() {  
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MakeBamgQuadtree)*/
@@ -3115,11 +3115,11 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::MaxinalHmax{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::MaxinalHmax{{{*/
 	double Mesh::MaximalHmax() {
 		return Max(pmax.x-pmin.x,pmax.y-pmin.y);
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::MaxSubDivision{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::MaxSubDivision{{{*/
 	void  Mesh::MaxSubDivision(double maxsubdiv) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/MaxSubDivision)*/
@@ -3128,5 +3128,5 @@
 
 		const  double maxsubdiv2 = maxsubdiv*maxsubdiv;
-		if(verbose>1) printf("   Limit the subdivision of a edges in the new mesh by %g\n",maxsubdiv);
+		if(verbose>1) _printLine_("   Limit the subdivision of a edges in the new mesh by " << maxsubdiv);
 		// for all the edges 
 		// if the len of the edge is to long 
@@ -3171,9 +3171,9 @@
 		}
 		if(verbose>3){
-			printf("      number of metric changes = %i, maximum number of subdivision of a edges before change = %g\n",nbchange,pow(lmax,0.5));
-		}
-	}
-	/*}}}1*/
-	/*FUNCTION Mesh::MetricAt{{{1*/
+			_printLine_("      number of metric changes = " << nbchange << ", maximum number of subdivision of a edges before change = " << pow(lmax,0.5));
+		}
+	}
+	/*}}}*/
+	/*FUNCTION Mesh::MetricAt{{{*/
 	Metric Mesh::MetricAt(const R2 & A) const { 
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/MetricAt)*/
@@ -3195,17 +3195,17 @@
 		}
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::MininalHmin{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::MininalHmin{{{*/
 	double Mesh::MinimalHmin() {
 		return 2.0/coefIcoor;
 	}
-	/*}}}1*/
-/*FUNCTION Mesh::NearestVertex{{{1*/
+	/*}}}*/
+/*FUNCTION Mesh::NearestVertex{{{*/
 BamgVertex* Mesh::NearestVertex(Icoor1 i,Icoor1 j) {
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NearestVertex)*/
 	return  quadtree->NearestVertex(i,j); 
 } 
-/*}}}1*/
-	/*FUNCTION Mesh::NewPoints{{{1*/
+/*}}}*/
+	/*FUNCTION Mesh::NewPoints{{{*/
 	void  Mesh::NewPoints(Mesh & Bh,BamgOpts* bamgopts,int KeepVertices){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/NewPoints)*/
@@ -3225,5 +3225,5 @@
 		/*First, insert old points if requested*/
 		if (KeepVertices && (&Bh != this) && (nbv+Bh.nbv< maxnbv)){
-			if (verbose>5) printf("         Inserting initial mesh points\n");
+			if (verbose>5) _printLine_("         Inserting initial mesh points");
 			for (i=0;i<Bh.nbv;i++){ 
 				BamgVertex &bv=Bh[i];
@@ -3244,5 +3244,5 @@
 		// Big loop (most time consuming)
 		int iter=0;
-		if (verbose>5) printf("         Big loop\n");
+		if (verbose>5) _printLine_("         Big loop");
 		do {
 			/*Update variables*/
@@ -3258,5 +3258,5 @@
 				//check i
 				if (i<0 || i>=nbt ){
-					_error_("Index problem in NewPoints (i=%i not in [0 %i])",i,nbt-1);
+					_error2_("Index problem in NewPoints (i=" << i << " not in [0 " << nbt-1 << "])");
 				}
 				//change first_np_or_next_t[i]
@@ -3309,5 +3309,5 @@
 					}
 					if (ta.EdgeVertex(0)!=s){
-						_error_("ta.EdgeVertex(0)!=s");
+						_error2_("ta.EdgeVertex(0)!=s");
 					}
 					ta = Next(Adj(ta));
@@ -3326,6 +3326,6 @@
 		NbTSwap +=  NbSwapf ;
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::ProjectOnCurve{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::ProjectOnCurve{{{*/
 	GeomEdge*   Mesh::ProjectOnCurve( Edge & BhAB, BamgVertex &  vA, BamgVertex & vB,
 				double theta,BamgVertex & R,VertexOnEdge &  BR,VertexOnGeom & GR) {
@@ -3344,5 +3344,5 @@
 		}
 		else {
-			_error_("ProjectOnCurve On BamgVertex %i forget call to SetVertexFieldOnBTh",BTh.GetId(vA));
+			_error2_("ProjectOnCurve On BamgVertex " << BTh.GetId(vA) << " forget call to SetVertexFieldOnBTh");
 		} 
 
@@ -3355,9 +3355,9 @@
 		}
 		else {
-			_error_("ProjectOnCurve On BamgVertex %i forget call to SetVertexFieldOnBTh",BTh.GetId(vB));
+			_error2_("ProjectOnCurve On BamgVertex " << BTh.GetId(vB) << " forget call to SetVertexFieldOnBTh");
 		} 
 		Edge * e = &BhAB;
 		if (!pA || !pB || !e){
-			_error_("!pA || !pB || !e");
+			_error2_("!pA || !pB || !e");
 		}
 		// be carefull the back ground edge e is on same geom edge 
@@ -3365,5 +3365,5 @@
 		//check Is a background Mesh;   
 		if (e<BTh.edges || e>=BTh.edges+BTh.nbe){
-			_error_("e<BTh.edges || e>=BTh.edges+BTh.nbe");
+			_error2_("e<BTh.edges || e>=BTh.edges+BTh.nbe");
 		}
 		// walk on BTh edge 
@@ -3388,5 +3388,5 @@
 		  } 
 		else{ // do the search by walking 
-			_error_("case not supported yet");
+			_error2_("case not supported yet");
 		  }
 
@@ -3452,9 +3452,9 @@
 
 		  }
-		_error_("Big bug...");
+		_error2_("Big bug...");
 		return 0; // just for the compiler 
 	}                  
-	/*}}}1*/
-/*FUNCTION Mesh::ReconstructExistingMesh{{{1*/
+	/*}}}*/
+/*FUNCTION Mesh::ReconstructExistingMesh{{{*/
 void Mesh::ReconstructExistingMesh(){
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FillHoleInMesh)*/
@@ -3475,5 +3475,5 @@
 	// find extrema coordinates of vertices pmin,pmax
 	long i;
-	if(verbose>2) printf("      Reconstruct mesh of %i vertices\n",nbv); 
+	if(verbose>2) _printLine_("      Reconstruct mesh of " << nbv << " vertices"); 
 
 	//initialize orderedvertices
@@ -3493,5 +3493,5 @@
 	}
 	if (kk != nbe){ 
-		_error_("There are %i double edges in the mesh",kk-nbe);
+		_error2_("There are " << kk-nbe << " double edges in the mesh");
 	}
 
@@ -3525,5 +3525,5 @@
 			//An edge belongs to 2 triangles
 			else {
-				_error_("The edge (%i , %i) belongs to more than 2 triangles",GetId(triangles[i][VerticesOfTriangularEdge[j][0]]),GetId(triangles[i][VerticesOfTriangularEdge[j][1]]));
+				_error2_("The edge (" << GetId(triangles[i][VerticesOfTriangularEdge[j][0]]) << " , " << GetId(triangles[i][VerticesOfTriangularEdge[j][1]]) << ") belongs to more than 2 triangles");
 			}
 		}
@@ -3532,10 +3532,10 @@
 	//Display info if required
 	if(verbose>5) {
-		printf("         info of Mesh:\n");
-		printf("            - number of vertices    = %i \n",nbv); 
-		printf("            - number of triangles   = %i \n",nbt); 
-		printf("            - number of given edges = %i \n",nbe); 
-		printf("            - number of all edges   = %i \n"  ,edge4->nb()); 
-		printf("            - Euler number 1 - nb of holes = %i \n"  ,nbt-edge4->nb()+nbv); 
+		_printLine_("         info of Mesh:");
+		_printLine_("            - number of vertices    = " << nbv << " "); 
+		_printLine_("            - number of triangles   = " << nbt << " "); 
+		_printLine_("            - number of given edges = " << nbe << " "); 
+		_printLine_("            - number of all edges   = " << edge4->nb()); 
+		_printLine_("            - Euler number 1 - nb of holes = " << nbt-edge4->nb()+nbv); 
 	}
 
@@ -3554,8 +3554,8 @@
 				if (k<10) {
 					//print only 10 edges
-					printf("Lost boundary edges %i : %i %i\n",i,edge4->i(i),edge4->j(i));
+					_printLine_("Lost boundary edges " << i << " : " << edge4->i(i) << " " << edge4->j(i));
 				}
 				else if (k==10){
-					printf("Other lost boundary edges not shown...\n");
+					_printLine_("Other lost boundary edges not shown...");
 				}
 			}
@@ -3563,5 +3563,5 @@
 	}
 	if(k) {
-		_error_("%i boundary edges (from the geometry) are not defined as mesh edges",k);
+		_error2_(k << " boundary edges (from the geometry) are not defined as mesh edges");
 	}
 
@@ -3590,5 +3590,5 @@
 	for (i=2;det(orderedvertices[0]->i,orderedvertices[1]->i,orderedvertices[i]->i)==0;) 
 	 if  (++i>=nbvb) {
-		 _error_("ReconstructExistingMesh: All the vertices are aligned");
+		 _error2_("ReconstructExistingMesh: All the vertices are aligned");
 	 }
 	//Move this vertex (i) to the 2d position in orderedvertices
@@ -3650,5 +3650,5 @@
 	}
 	if(nbloss) {
-		_error_("we lost %i existing edges other %i",nbloss,knbe);
+		_error2_("we lost " << nbloss << " existing edges other " << knbe);
 	}
 
@@ -3725,5 +3725,5 @@
 	subdomains = savesubdomains;
 	if (k) {
-		_error_("number of triangles edges alone = %i",k);
+		_error2_("number of triangles edges alone = " << k);
 	}
 	FindSubDomain();
@@ -3745,15 +3745,15 @@
 					/*Check that the 2 vertices are on geometry AND required*/
 					if(!edges[i][j].GeomEdgeHook->IsRequiredVertex()){
-						printf("ReconstructExistingMesh error message: problem with the edge number %i: [%i %i]\n",i+1,GetId(edges[i][0])+1,GetId(edges[i][1])+1);
-						printf("This edge is on geometrical edge number %i\n",Gh.GetId(edges[i].GeomEdgeHook)+1);
+						_printLine_("ReconstructExistingMesh error message: problem with the edge number " << i+1 << ": [" << GetId(edges[i][0])+1 << " " << GetId(edges[i][1])+1 << "]");
+						_printLine_("This edge is on geometrical edge number " << Gh.GetId(edges[i].GeomEdgeHook)+1);
 						if (edges[i][j].GeomEdgeHook->OnGeomVertex())
-						 printf("the vertex number %i of this edge is a geometric BamgVertex number %i\n",GetId(edges[i][j])+1,Gh.GetId(edges[i][j].GeomEdgeHook->gv)+1);
+						 _printLine_("the vertex number " << GetId(edges[i][j])+1 << " of this edge is a geometric BamgVertex number " << Gh.GetId(edges[i][j].GeomEdgeHook->gv)+1);
 						else if (edges[i][j].GeomEdgeHook->OnGeomEdge())
-						 printf("the vertex number %i of this edge is a geometric Edge number %i\n",GetId(edges[i][j])+1,Gh.GetId(edges[i][j].GeomEdgeHook->ge)+1);
+						 _printLine_("the vertex number " << GetId(edges[i][j])+1 << " of this edge is a geometric Edge number " << Gh.GetId(edges[i][j].GeomEdgeHook->ge)+1);
 						else
-						 printf("Its pointer is %p\n",edges[i][j].GeomEdgeHook);
-
-						printf("This edge is on geometry and has no adjacent edge (open curve) and one of the tip is not required\n");
-						_error_("See above (might be cryptic...)");
+						 _printLine_("Its pointer is " << edges[i][j].GeomEdgeHook);
+
+						_printLine_("This edge is on geometry and has no adjacent edge (open curve) and one of the tip is not required");
+						_error2_("See above (might be cryptic...)");
 					}
 				}
@@ -3762,6 +3762,6 @@
 	}
 }
-/*}}}1*/
-	/*FUNCTION Mesh::TrianglesRenumberBySubDomain{{{1*/
+/*}}}*/
+	/*FUNCTION Mesh::TrianglesRenumberBySubDomain{{{*/
 	void Mesh::TrianglesRenumberBySubDomain(bool justcompress){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ReNumberingTheTriangleBySubDomain)*/
@@ -3778,13 +3778,13 @@
 			t=t0=subdomains[i].head;
 			if (!t0){ // not empty sub domain
-				_error_("!t0");
+				_error2_("!t0");
 			}
 			do { 
 				long kt = GetId(t);
 				if (kt<0 || kt >= nbt ){
-					_error_("kt<0 || kt >= nbt");
+					_error2_("kt<0 || kt >= nbt");
 				}
 				if (renu[kt]!=-1){
-					_error_("renu[kt]!=-1");
+					_error2_("renu[kt]!=-1");
 				}
 				renu[kt]=k++;
@@ -3803,5 +3803,5 @@
 		}
 		if (k != nbt){
-			_error_("k != nbt");
+			_error2_("k != nbt");
 		}
 		// do the change on all the pointeur 
@@ -3831,6 +3831,6 @@
 
 	}
-	/*}}}1*/
-	/*FUNCTION Mesh::VerticesRenumber{{{1*/
+	/*}}}*/
+	/*FUNCTION Mesh::VerticesRenumber{{{*/
 	void Mesh::VerticesRenumber(long * renu) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ReNumberingVertex)*/
@@ -3842,13 +3842,13 @@
 		long it,ie,i;
 
-		printf("renumbering triangles\n");
+		_printLine_("renumbering triangles");
 		for ( it=0;it<nbt;it++) 
 		 triangles[it].Renumbering(vertices,ve,renu);
 
-		printf("renumbering edges\n");
+		_printLine_("renumbering edges");
 		for ( ie=0;ie<nbe;ie++) 
 		 edges[ie].Renumbering(vertices,ve,renu);
 
-		printf("renumbering vertices on geom\n");
+		_printLine_("renumbering vertices on geom");
 		for (i=0;i< NbVerticesOnGeomVertex;i++)
 		  {
@@ -3858,5 +3858,5 @@
 		  }
 
-		printf("renumbering vertices on edge\n");
+		_printLine_("renumbering vertices on edge");
 		for (i=0;i< NbVerticesOnGeomEdge;i++)
 		  {
@@ -3866,5 +3866,5 @@
 		  }
 
-		printf("renumbering vertices on Bth vertex\n");
+		_printLine_("renumbering vertices on Bth vertex");
 		for (i=0;i< NbVertexOnBThVertex;i++)
 		  {
@@ -3905,6 +3905,6 @@
 		for ( it=0;it<nbv;it++) renu[i]= -renu[i]-1;
 	}
-	/*}}}1*/
-/*FUNCTION Mesh::SetIntCoor{{{1*/
+	/*}}}*/
+/*FUNCTION Mesh::SetIntCoor{{{*/
 void Mesh::SetIntCoor(const char * strfrom) {
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SetIntCoor)*/
@@ -3929,5 +3929,5 @@
 	coefIcoor= (MaxICoor)/(Max(pmax.x-pmin.x,pmax.y-pmin.y));
 	if (coefIcoor<=0){
-		_error_("coefIcoor should be positive, a problem in the geometry is likely");
+		_error2_("coefIcoor should be positive, a problem in the geometry is likely");
 	}
 
@@ -3956,5 +3956,5 @@
 				number_of_errors++;
 				if (number_of_errors<20){
-					printf("Area of Triangle %i < 0 (det=%i)\n",i+1,triangles[i].det);
+					_printLine_("Area of Triangle " << i+1 << " < 0 (det=" << triangles[i].det << ")");
 				}
 			}
@@ -3965,8 +3965,8 @@
 	}
 
-	if (number_of_errors) _error_("Fatal error: some triangles have negative areas, see above");
+	if (number_of_errors) _error2_("Fatal error: some triangles have negative areas, see above");
 }
-/*}}}1*/
-/*FUNCTION Mesh::ShowRegulaty{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::ShowRegulaty{{{*/
 void  Mesh::ShowRegulaty() const {
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr>*/
@@ -4024,13 +4024,13 @@
 	gammamn=sqrt(gammamn);
 	gammamx=sqrt(gammamx);    
-	printf("   Adaptmesh info:\n");
-	printf("      number of triangles = %i\n",nt);
-	printf("      hmin = %g, hmax=%g\n",hmin,hmax);
-	printf("      area = %g, M area = %g, M area/( |Khat| nt) = %g\n",area,Marea, Marea/(aireKh*nt));
-	printf("      infinite-regularity(?): min = %g, max = %g\n",gammamn,gammamx);
-	printf("      anisomax = %g, beta max = %g, min = %g\n",pow(alpha2,0.5),1./pow(beta/aireKh,0.5), 1./pow(beta0/aireKh,0.5));
+	_printLine_("   Adaptmesh info:");
+	_printLine_("      number of triangles = " << nt);
+	_printLine_("      hmin = " << hmin << ", hmax=" << hmax);
+	_printLine_("      area = " << area << ", M area = " << Marea << ", M area/( |Khat| nt) = " <<  Marea/(aireKh*nt));
+	_printLine_("      infinite-regularity(?): min = " << gammamn << ", max = " << gammamx);
+	_printLine_("      anisomax = " << pow(alpha2,0.5) << ", beta max = " << 1./pow(beta/aireKh,0.5) << ", min = " << 1./pow(beta0/aireKh,0.5));
 }
-/*}}}1*/
-/*FUNCTION Mesh::ShowHistogram{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::ShowHistogram{{{*/
 void  Mesh::ShowHistogram() const {
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ShowHistogram)*/
@@ -4063,19 +4063,19 @@
 			}
 		}  
-	printf(" --- Histogram of the unit mesh,  nb of edges = %i\n",nbedges);
-	printf("      length of edge in   | %% of edge  | Nb of edges \n"); 
-	printf("      --------------------+-------------+-------------\n"); 
+	_printLine_(" --- Histogram of the unit mesh,  nb of edges = " << nbedges);
+	_printLine_("      length of edge in   | %% of edge  | Nb of edges "); 
+	_printLine_("      --------------------+-------------+-------------"); 
 	for   (i=0;i<=kmax;i++){ 
-		if (i==0) printf("      %10i",0);
-		else      printf("      %10g",exp(lmin+i/delta));
-		if (i==kmax) printf("          +inf   ");
-		else printf("      %10g",exp(lmin+(i+1)/delta));
-		printf("|  %10g |\n",((long)  ((10000.0 * histo[i])/ nbedges))/100.0);
-		printf("  %i\n",histo[i]);
-	}
-	printf("      --------------------+-------------+-------------\n"); 
+		if (i==0) _printString_( "      " << setw(10) << 0.);
+		else      _printString_( "      " << setw(10) << exp(lmin+i/delta));
+		if (i==kmax) _printString_("          +inf   ");
+		else      _printString_( "      " << setw(10) << exp(lmin+(i+1)/delta));
+		_printLine_("|  " << setw(10) << (long((10000. * histo[i])/ nbedges)/100.) << " |");
+		_printLine_("  " << histo[i]);
+	}
+	_printLine_("      --------------------+-------------+-------------"); 
 }
-/*}}}1*/
-/*FUNCTION Mesh::SmoothingVertex{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::SmoothingVertex{{{*/
 void Mesh::SmoothingVertex(int nbiter,double omega ) { 
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SmoothingVertex)*/
@@ -4100,5 +4100,5 @@
 	for ( k=0;k<NbVerticesOnGeomEdge;k++ ) 
 	 tstart[ GetId(VerticesOnGeomEdge[k].meshvertex)]=&vide;
-	if(verbose>2) printf("   SmoothingVertex: nb Iteration = %i, Omega=%g\n",nbiter,omega);
+	if(verbose>2) _printLine_("   SmoothingVertex: nb Iteration = " << nbiter << ", Omega=" << omega);
 	for (k=0;k<nbiter;k++)
 	  {
@@ -4112,5 +4112,5 @@
 		  if (tstart[i] != &vide) // not a boundary vertex 
 			NbSwap += vertices[i].Optim(1);
-		if (verbose>3) printf("      move max = %g, iteration = %i, nb of swap = %i\n",pow(delta,0.5),k,NbSwap);
+		if (verbose>3) _printLine_("      move max = " << pow(delta,0.5) << ", iteration = " << k << ", nb of swap = " << NbSwap);
 	  }
 
@@ -4118,6 +4118,6 @@
 	if (quadtree) quadtree= new BamgQuadtree(this);
 }
-/*}}}1*/
-/*FUNCTION Mesh::SmoothMetric{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::SmoothMetric{{{*/
 void Mesh::SmoothMetric(double raisonmax) { 
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/SmoothMetric)*/
@@ -4126,5 +4126,5 @@
 
 	if(raisonmax<1.1) return;
-	if(verbose > 1) printf("   Mesh::SmoothMetric raisonmax = %g\n",raisonmax);
+	if(verbose > 1) _printLine_("   Mesh::SmoothMetric raisonmax = " << raisonmax);
 	CreateSingleVertexToTriangleConnectivity();
 	long i,j,kch,kk,ip;
@@ -4146,5 +4146,5 @@
 			register Triangle* t= vertices[i].t;
 			if (!t){
-				_error_("!t");
+				_error2_("!t");
 			}
 			BamgVertex & vi = vertices[i];
@@ -4154,5 +4154,5 @@
 				ta=Previous(Adj(ta));
 				if (vertices+i != ta.EdgeVertex(1)){
-					_error_("vertices+i != ta.EdgeVertex(1)");
+					_error2_("vertices+i != ta.EdgeVertex(1)");
 				}
 				BamgVertex & vj = *(ta.EdgeVertex(0));
@@ -4160,5 +4160,5 @@
 					j= &vj-vertices;
 					if (j<0 || j >= nbv){
-						_error_("j<0 || j >= nbv");
+						_error2_("j<0 || j >= nbv");
 					}
 					R2 Aij = (R2) vj - (R2) vi;
@@ -4192,10 +4192,10 @@
 		Exchange(first_np_or_next_t0,first_np_or_next_t1);
 	}
-	if(verbose>2) printf("      number of iterations = %i\n",kch); 
+	if(verbose>2) _printLine_("      number of iterations = " << kch); 
 	delete [] first_np_or_next_t0;
 	delete [] first_np_or_next_t1;
 }
-/*}}}1*/
-	/*FUNCTION Mesh::SplitElement{{{1*/
+/*}}}*/
+	/*FUNCTION Mesh::SplitElement{{{*/
 	int  Mesh::SplitElement(int choice){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, MeshQuad.cpp/SplitElement)*/
@@ -4284,5 +4284,5 @@
 					// the first PB is to now a background edge between the 2 vertices
 					if (!edgesGtoB){
-						_error_("!edgesGtoB");
+						_error2_("!edgesGtoB");
 					}
 					ong= ProjectOnCurve(*edgesGtoB[Gh.GetId(edges[i].GeomEdgeHook)],
@@ -4356,5 +4356,5 @@
 			Triangle & t = triangles[i];
 			if (!t.link){
-				_error_("!t.link");
+				_error2_("!t.link");
 			}
 			for(int j=0;j<3;j++)
@@ -4382,6 +4382,6 @@
 										||   (bb=Area2( t[0].r , A.r    , t[2].r )) < 0.0  
 										||   (cc=Area2( t[0].r , t[1].r , A.r    )) < 0.0)){
-							printf("%i not in triangle %i In= %i %g %g %g %g\n",ke + nbvold,i,!!t.link,aa,bb,cc,dd);
-							_error_("Number of triangles with P2 interpolation Problem");
+							_printLine_(ke + nbvold << " not in triangle " << i << " In= " << !!t.link << " " << aa << " " << bb << " " << cc << " " << dd);
+							_error2_("Number of triangles with P2 interpolation Problem");
 						}
 					}
@@ -4390,6 +4390,6 @@
 										||   (bb=Area2( tt[0].r , A.r     , tt[2].r )) < 0 
 										||   (cc=Area2( tt[0].r , tt[1].r , A.r     )) < 0)){
-							printf("%i not in triangle %i In= %i %g %g %g %g\n",ke + nbvold,ii,!!tt.link,aa,bb,cc,dd);
-							_error_("Number of triangles with P2 interpolation Problem");
+							_printLine_(ke + nbvold << " not in triangle " << ii << " In= " << !!tt.link << " " << aa << " " << bb << " " << cc << " " << dd);
+							_error2_("Number of triangles with P2 interpolation Problem");
 						}
 					} 
@@ -4439,5 +4439,5 @@
 						  } // tt 
 						else
-						 _error_("Bug...");
+						 _error2_("Bug...");
 					  } // ke<0	       
 					else
@@ -4452,5 +4452,5 @@
 			  } 
 			if (nbinvisible>=2){
-				_error_("nbinvisible>=2");
+				_error2_("nbinvisible>=2");
 			}
 			switch (nbsplitedge) {
@@ -4464,5 +4464,5 @@
 			} 
 			if (ksplit[i]<40){
-				_error_("ksplit[i]<40");
+				_error2_("ksplit[i]<40");
 			}
 		  }
@@ -4481,5 +4481,5 @@
 			int  ke=(int) (ksplit[i]%10);
 			if (kk>=7 || kk<=0){
-				_error_("kk>=7 || kk<=0");
+				_error2_("kk>=7 || kk<=0");
 			}
 
@@ -4498,5 +4498,5 @@
 
 			if (nbmkadj>=10){
-				_error_("nbmkadj>=10");
+				_error2_("nbmkadj>=10");
 			}
 			// --------------------------
@@ -4516,5 +4516,5 @@
 							t1=t0;
 							if (kedge[3*i+i0]<0){
-								_error_("kedge[3*i+i0]<0");
+								_error2_("kedge[3*i+i0]<0");
 							}
 							BamgVertex * v3 = vertices + kedge[3*i+k0];
@@ -4532,8 +4532,8 @@
 							t2=t1=t0;
 							if (kedge[3*i+k1]<0){
-								_error_("kedge[3*i+k1]<0");
+								_error2_("kedge[3*i+k1]<0");
 							}
 							if (kedge[3*i+k2]<0){
-								_error_("kedge[3*i+k2]<0");
+								_error2_("kedge[3*i+k2]<0");
 							}
 
@@ -4559,5 +4559,5 @@
 							t3=t2=t1=t0;
 							if (kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0){
-								_error_("kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0");
+								_error2_("kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0");
 							}
 							BamgVertex * v12 = vertices + kedge[3*i+k0];
@@ -4633,5 +4633,5 @@
 				}
 			if (nbmkadj>13){// 13 = 6 + 4 +
-				_error_("nbmkadj>13");
+				_error2_("nbmkadj>13");
 			}
 
@@ -4685,7 +4685,7 @@
 
 		if (verbose>2){
-			printf("   number of quadrilaterals    = %i\n",nbq);
-			printf("   number of triangles         = %i\n",nbt-nbtout- nbq*2);
-			printf("   number of outside triangles = %i\n",nbtout);
+			_printLine_("   number of quadrilaterals    = " << nbq);
+			_printLine_("   number of triangles         = " << nbt-nbtout- nbq*2);
+			_printLine_("   number of outside triangles = " << nbtout);
 		}
 
@@ -4706,6 +4706,6 @@
 		return ret; // ok 
 	}
-	/*}}}1*/
-/*FUNCTION Mesh::SplitInternalEdgeWithBorderVertices{{{1*/
+	/*}}}*/
+/*FUNCTION Mesh::SplitInternalEdgeWithBorderVertices{{{*/
 long  Mesh::SplitInternalEdgeWithBorderVertices(){
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SplitInternalEdgeWithBorderVertices)*/
@@ -4754,10 +4754,10 @@
 			Triangle *tcvi = TriangleFindFromCoord(vi.i,det3);
 			if (tcvi && !tcvi->link) {
-				printf("problem inserting point in SplitInternalEdgeWithBorderVertices (tcvj && !tcvj->link)\n");
+				_printLine_("problem inserting point in SplitInternalEdgeWithBorderVertices (tcvj && !tcvj->link)");
 			}
 
 			quadtree->Add(vi);
 			if (!tcvi || tcvi->det<0){// internal
-				_error_("!tcvi || tcvi->det < 0");
+				_error2_("!tcvi || tcvi->det < 0");
 			}
 			AddVertex(vi,tcvi,det3);
@@ -4767,26 +4767,26 @@
 	}
 	if (verbose>3) {
-		printf("   number of points: %i\n",iv);
-		printf("   number of swap to  split internal edges with border vertices: %i\n",NbSwap);
+		_printLine_("   number of points: " << iv);
+		_printLine_("   number of swap to  split internal edges with border vertices: " << NbSwap);
 		nbv = iv;
 	}
 }
-if (NbSplitEdge>nbv-nbvold) printf("WARNING: not enough vertices  to split all internal edges, we lost %i edges...\n",NbSplitEdge - ( nbv-nbvold));
-if (verbose>2) printf("SplitInternalEdgeWithBorderVertices: Number of splited edge %i\n",NbSplitEdge);
+if (NbSplitEdge>nbv-nbvold) _printLine_("WARNING: not enough vertices  to split all internal edges, we lost " << NbSplitEdge - ( nbv-nbvold) << " edges...");
+if (verbose>2) _printLine_("SplitInternalEdgeWithBorderVertices: Number of splited edge " << NbSplitEdge);
 
 return  NbSplitEdge;
 }
-/*}}}1*/
-/*FUNCTION Mesh::ToI2{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::ToI2{{{*/
 I2 Mesh::R2ToI2(const R2 & P) const {
 	return  I2( (Icoor1) (coefIcoor*(P.x-pmin.x)),(Icoor1) (coefIcoor*(P.y-pmin.y)) );
 }
-/*}}}1*/
-/*FUNCTION Mesh::ToR2{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::ToR2{{{*/
 R2 Mesh::I2ToR2(const I2 & P) const {
 	return  R2( (double) P.x/coefIcoor+pmin.x, (double) P.y/coefIcoor+pmin.y);
 }
-/*}}}1*/
-/*FUNCTION Mesh::TriangleFindFromCoord{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::TriangleFindFromCoord{{{*/
 Triangle * Mesh::TriangleFindFromCoord(const I2 & B,Icoor2 det3[3], Triangle *tstart) const {
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FindTriangleContening)*/
@@ -4803,5 +4803,5 @@
 
 		/*Check that the quadtree does exist*/
-		if (!quadtree) _error_("no starting triangle provided and no quadtree available");
+		if (!quadtree) _error2_("no starting triangle provided and no quadtree available");
 
 		/*Call NearestVertex*/
@@ -4809,6 +4809,6 @@
 
 		/*Check output (Vertex a)*/
-		if (!a)    _error_("problem while trying to find nearest vertex from a given point. No output found");
-		if (!a->t) _error_("no triangle is associated to vertex number %i (orphan?)",GetId(a)+1);
+		if (!a)    _error2_("problem while trying to find nearest vertex from a given point. No output found");
+		if (!a->t) _error2_("no triangle is associated to vertex number " << GetId(a)+1 << " (orphan?)");
 		_assert_(a>=vertices && a<vertices+nbv);
 
@@ -4845,5 +4845,5 @@
 
 		/*Increase counter*/
-		if (++counter>=10000) _error_("Maximum number of iteration reached (threshold = %i).",counter);
+		if (++counter>=10000) _error2_("Maximum number of iteration reached (threshold = " << counter << ").");
 
 		j= OppositeVertex[jj];
@@ -4879,6 +4879,6 @@
 	return t;
 }
-/*}}}1*/
-/*FUNCTION Mesh::TriangleIntNumbering{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::TriangleIntNumbering{{{*/
 void Mesh::TriangleIntNumbering(long* renumbering){
 
@@ -4890,6 +4890,6 @@
 	return;   
 }
-/*}}}1*/
-/*FUNCTION Mesh::TriangleReferenceList{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::TriangleReferenceList{{{*/
 long  Mesh::TriangleReferenceList(long* reft) const {
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ConsRefTriangle)*/
@@ -4909,5 +4909,5 @@
 
 		//check that the subdomain is not empty
-		if (!t0){ _error_("At least one subdomain is empty");}
+		if (!t0){ _error2_("At least one subdomain is empty");}
 
 		//loop
@@ -4930,6 +4930,6 @@
 	return k;   
 }
-/*}}}1*/
-/*FUNCTION Mesh::Triangulate{{{1*/
+/*}}}*/
+/*FUNCTION Mesh::Triangulate{{{*/
 void Mesh::Triangulate(double* x,double* y,int nods){
 
@@ -4943,5 +4943,5 @@
 
 	//Vertices
-	if(verbose) printf("Reading vertices (%i)\n",nbv);
+	if(verbose) _printLine_("Reading vertices (" << nbv << ")");
 	for (i=0;i<nbv;i++){
 		vertices[i].r.x=x[i];
@@ -4957,6 +4957,6 @@
 	Insert();
 }
-/*}}}1*/
-	/*FUNCTION Mesh::TriangulateFromGeom0{{{1*/
+/*}}}*/
+	/*FUNCTION Mesh::TriangulateFromGeom0{{{*/
 	void Mesh::TriangulateFromGeom0(BamgOpts* bamgopts){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/GeomToTriangles0)*/
@@ -4992,5 +4992,5 @@
 		//allocate
 		VerticesOnGeomVertex = new VertexOnGeom[NbVerticesOnGeomVertex];  
-		if(NbVerticesOnGeomVertex >= maxnbv) _error_("too many vertices on geometry: %i >= %i",NbVerticesOnGeomVertex,maxnbv);
+		if(NbVerticesOnGeomVertex >= maxnbv) _error2_("too many vertices on geometry: " << NbVerticesOnGeomVertex << " >= " << maxnbv);
 		_assert_(nbv==0);
 		//Build VerticesOnGeomVertex
@@ -5081,5 +5081,5 @@
 								NbNewPoints=0;
 								NbEdgeCurve=0;
-								if (nbvend>=maxnbv) _error_("maximum number of vertices too low! Check the domain outline or increase maxnbv");
+								if (nbvend>=maxnbv) _error2_("maximum number of vertices too low! Check the domain outline or increase maxnbv");
 								lcurve =0;
 								s = lstep; //-1 initially, then length of each sub edge
@@ -5255,23 +5255,23 @@
 
 		//Insert points inside existing triangles
-		if (verbose>4) printf("      -- current number of vertices = %i\n",nbv);
-		if (verbose>3) printf("      Creating initial Constrained Delaunay Triangulation...\n");
-		if (verbose>3) printf("         Inserting boundary points\n");
+		if (verbose>4) _printLine_("      -- current number of vertices = " << nbv);
+		if (verbose>3) _printLine_("      Creating initial Constrained Delaunay Triangulation...");
+		if (verbose>3) _printLine_("         Inserting boundary points");
 		Insert();
 
 		//Force the boundary
-		if (verbose>3) printf("         Forcing boundaries\n");
+		if (verbose>3) _printLine_("         Forcing boundaries");
 		ForceBoundary();
 
 		//Extract SubDomains
-		if (verbose>3) printf("         Extracting subdomains\n");
+		if (verbose>3) _printLine_("         Extracting subdomains");
 		FindSubDomain();
 
-		if (verbose>3) printf("      Inserting internal points\n");
+		if (verbose>3) _printLine_("      Inserting internal points");
 		NewPoints(*this,bamgopts,0) ;
-		if (verbose>4) printf("      -- current number of vertices = %i\n",nbv);
-	}
-	/*}}}1*/
-	/*FUNCTION Mesh::TriangulateFromGeom1{{{1*/
+		if (verbose>4) _printLine_("      -- current number of vertices = " << nbv);
+	}
+	/*}}}*/
+	/*FUNCTION Mesh::TriangulateFromGeom1{{{*/
 	void Mesh::TriangulateFromGeom1(BamgOpts* bamgopts,int KeepVertices){ 
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/GeomToTriangles1)*/
@@ -5323,5 +5323,5 @@
 		if(NbVerticesOnGeomVertex >= maxnbv){
 			delete [] bcurve;
-			_error_("too many vertices on geometry: %i >= %i",NbVerticesOnGeomVertex,maxnbv);
+			_error2_("too many vertices on geometry: " << NbVerticesOnGeomVertex << " >= " << maxnbv);
 		}
 
@@ -5373,9 +5373,9 @@
 					int nc=ei.GeomEdgeHook->CurveNumber;
 					
-					//printf("Dealing with curve number %i\n",nc);
-					//printf("edge on geometry is same as GhCurve? %s\n",(ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge)?"yes":"no");
+					//_printLine_("Dealing with curve number " << nc);
+					//_printLine_("edge on geometry is same as GhCurve? " << (ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge)?"yes":"no");
 					//if(ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge){
-					//	printf("Do we have the right extremity? curve first vertex -> %s\n",((GeomVertex *)*ei[je].GeomEdgeHook==&(*Gh.curves[nc].FirstEdge)[Gh.curves[nc].FirstVertexIndex])?"yes":"no");
-					//	printf("Do we have the right extremity? curve last  vertex -> %s\n",((GeomVertex *)*ei[je].GeomEdgeHook==&(*Gh.curves[nc].LastEdge)[Gh.curves[nc].LastVertexIndex])?"yes":"no");
+					//	_printLine_("Do we have the right extremity? curve first vertex -> " << ((GeomVertex *)*ei[je].GeomEdgeHook==&(*Gh.curves[nc].FirstEdge)[Gh.curves[nc].FirstVertexIndex])?"yes":"no");
+					//	_printLine_("Do we have the right extremity? curve last  vertex -> " << ((GeomVertex *)*ei[je].GeomEdgeHook==&(*Gh.curves[nc].LastEdge)[Gh.curves[nc].LastVertexIndex])?"yes":"no");
 					//}
 					//BUG FIX from original bamg
@@ -5394,5 +5394,5 @@
 		if (bfind!=Gh.nbcurves){
 			delete [] bcurve;
-			_error_("problem generating number of curves (%i found in the geometry but %i curve found in the mesh)",Gh.nbcurves,bfind);
+			_error2_("problem generating number of curves (" << Gh.nbcurves << " found in the geometry but " << bfind << " curve found in the mesh)");
 		}
 
@@ -5493,9 +5493,9 @@
 									double se= (sNew-L0)/LAB;
 									if (se<0 || se>=1.000000001){
-										_error_("Problem creating point on a boundary: se=%g should be in [0 1]",se);
+										_error2_("Problem creating point on a boundary: se=" << se << " should be in [0 1]");
 									}
 									se = abscisseInterpole(v0.m,v1.m,AB,se,1);
 									if (se<0 || se>1){
-										_error_("Problem creating point on a boundary: se=%g should be in [0 1]",se);
+										_error2_("Problem creating point on a boundary: se=" << se << " should be in [0 1]");
 									}
 									se = k1         ? se : 1. - se;
@@ -5529,5 +5529,5 @@
 							}
 							if (!ee.adj[k1]) {
-								_error_(" adj edge %i, nbe=%i, Gh.vertices=%i",BTh.GetId(ee),nbe,Gh.vertices);
+								_error2_("adj edge " << BTh.GetId(ee) << ", nbe=" << nbe << ", Gh.vertices=" << Gh.vertices);
 							}
 							pe = ee.adj[k1]; // next edge
@@ -5567,5 +5567,5 @@
 			if(step==0){
 				if(nbv+NbOfNewPoints > maxnbv) {
-					_error_("too many vertices on geometry: %i >= %i",nbv+NbOfNewPoints,maxnbv);
+					_error2_("too many vertices on geometry: " << nbv+NbOfNewPoints << " >= " << maxnbv);
 				}
 				edges = new Edge[NbOfNewEdge];
@@ -5585,25 +5585,25 @@
 
 		//Insert points inside existing triangles
-		if (verbose>4) printf("      -- current number of vertices = %i\n",nbv);
-		if (verbose>3) printf("      Creating initial Constrained Delaunay Triangulation...\n");
-		if (verbose>3) printf("         Inserting boundary points\n");
+		if (verbose>4) _printLine_("      -- current number of vertices = " << nbv);
+		if (verbose>3) _printLine_("      Creating initial Constrained Delaunay Triangulation...");
+		if (verbose>3) _printLine_("         Inserting boundary points");
 		Insert();
 
 		//Force the boundary
-		if (verbose>3) printf("         Forcing boundaries\n");
+		if (verbose>3) _printLine_("         Forcing boundaries");
 		ForceBoundary();
 
 		//Extract SubDomains
-		if (verbose>3) printf("         Extracting subdomains\n");
+		if (verbose>3) _printLine_("         Extracting subdomains");
 		FindSubDomain();
 
-		if (verbose>3) printf("      Inserting internal points\n");
+		if (verbose>3) _printLine_("      Inserting internal points");
 		NewPoints(BTh,bamgopts,KeepVertices) ;
-		if (verbose>4) printf("      -- current number of vertices = %i\n",nbv);
-	}
-	/*}}}1*/
+		if (verbose>4) _printLine_("      -- current number of vertices = " << nbv);
+	}
+	/*}}}*/
 
 	/*Intermediary*/
-	/*FUNCTION CloseBoundaryEdge{{{1*/
+	/*FUNCTION CloseBoundaryEdge{{{*/
 	AdjacentTriangle CloseBoundaryEdge(I2 A,Triangle *t, double &a,double &b) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/CloseBoundaryEdge)*/
@@ -5612,5 +5612,5 @@
 		int dir=0;
 		if (k<0){
-			_error_("k<0");
+			_error2_("k<0");
 		}
 		int kkk=0;  
@@ -5620,5 +5620,5 @@
 			kkk++;
 			if (kkk>=1000){
-				_error_("kkk>=1000");
+				_error2_("kkk>=1000");
 			}
 			BamgVertex  &vI =  *edge.EdgeVertex(0);
@@ -5637,5 +5637,5 @@
 							double IJ2 = IJ_IA + IJ_AJ;
 							if (IJ2==0){
-								_error_("IJ2==0");
+								_error2_("IJ2==0");
 							}
 							a= IJ_AJ/IJ2;
@@ -5644,6 +5644,6 @@
 		  } 
 	}
-	/*}}}1*/
-	/*FUNCTION CloseBoundaryEdgeV2{{{1*/
+	/*}}}*/
+	/*FUNCTION CloseBoundaryEdgeV2{{{*/
 	AdjacentTriangle CloseBoundaryEdgeV2(I2 C,Triangle *t, double &a,double &b) { 
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/CloseBoundaryEdgeV2)*/
@@ -5655,5 +5655,5 @@
 		//   int dir=0;
 		if (t->link != 0){
-			_error_("t->link != 0");
+			_error2_("t->link != 0");
 		}
 		// to have a starting edges 
@@ -5727,5 +5727,5 @@
 		  }
 		if (cas ==-2){
-			_error_("cas==-2");
+			_error2_("cas==-2");
 		}
 		// l1 = ||C s1||  , l0 = ||C s0||
@@ -5744,5 +5744,5 @@
 				kkk++;
 				if (edge.EdgeVertex(0)!=s && kkk>=10000){
-					_error_("edge.EdgeVertex(0)!=s && kkk>=10000");
+					_error2_("edge.EdgeVertex(0)!=s && kkk>=10000");
 				}
 
@@ -5776,5 +5776,5 @@
 
 			if (!(Triangle *) er){
-				_error_("!(Triangle *) er");
+				_error2_("!(Triangle *) er");
 			}
 			I2 A((I2)*er.EdgeVertex(0));
@@ -5793,6 +5793,6 @@
 		return er;
 	} 
-	/*}}}1*/
-/*FUNCTION ForceEdge{{{1*/
+	/*}}}*/
+/*FUNCTION ForceEdge{{{*/
 int ForceEdge(BamgVertex &a, BamgVertex & b,AdjacentTriangle & taret)  { 
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/ForceEdge)*/
@@ -5800,5 +5800,5 @@
 	int NbSwap =0;
 	if (!a.t || !b.t){ // the 2 vertex is in a mesh
-		_error_("!a.t || !b.t");
+		_error2_("!a.t || !b.t");
 	}
 	int k=0;
@@ -5817,5 +5817,5 @@
 		vbegin =v2;
 		if (!v2){
-			_error_("!v2");
+			_error2_("!v2");
 		}
 		det2 = det(*v2,a,b);
@@ -5834,10 +5834,10 @@
 			tc = Previous(tc);
 			if (!v1 || !v2){
-				_error_("!v1 || !v2");
+				_error2_("!v1 || !v2");
 			}
 			Icoor2 detss = 0,l=0,ks;
 			while ((ks=SwapForForcingEdge(  va,  vb, tc, detss, det1,det2,NbSwap)))
 			 if(l++ > 10000000) {
-				 _error_("Loop in forcing Egde, nb de swap=%i, nb of try swap (%i) too big",NbSwap,l);
+				 _error2_("Loop in forcing Egde, nb de swap=" << NbSwap << ", nb of try swap (" << l << ") too big");
 			 }
 			BamgVertex *aa = tc.EdgeVertex(0), *bb = tc.EdgeVertex(1);
@@ -5858,5 +5858,5 @@
 		k++;
 		if (k>=2000){
-			_error_("k>=2000");
+			_error2_("k>=2000");
 		}
 		if ( vbegin == v2 ) return -1;// error 
@@ -5869,6 +5869,6 @@
 	return NbSwap; 
 }
-/*}}}1*/
-/*FUNCTION swap{{{1*/
+/*}}}*/
+/*FUNCTION swap{{{*/
 void  swap(Triangle *t1,short a1, Triangle *t2,short a2, BamgVertex *s1,BamgVertex *s2,Icoor2 det1,Icoor2 det2){ 
 	/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/swap)*/
@@ -5914,6 +5914,6 @@
 	t2->SetSingleVertexToTriangleConnectivity();
 } // end swap 
-/*}}}1*/
-	/*FUNCTION SwapForForcingEdge{{{1*/
+/*}}}*/
+	/*FUNCTION SwapForForcingEdge{{{*/
 	int SwapForForcingEdge(BamgVertex   *  & pva ,BamgVertex  * &   pvb ,AdjacentTriangle & tt1,Icoor2 & dets1, Icoor2 & detsa,Icoor2 & detsb, int & NbSwap) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SwapForForcingEdge)*/
@@ -5930,5 +5930,5 @@
 		short a1=tt1,a2=tt2;// les 2 numero de l arete dans les 2 triangles
 		if ( a1<0 || a1>=3 ){
-			_error_("a1<0 || a1>=3");
+			_error2_("a1<0 || a1>=3");
 		}
 
@@ -5942,8 +5942,8 @@
 		Icoor2 detT = det1+det2;
 		if ((det1<=0 ) || (det2<=0)){
-			_error_("(det1<=0 ) || (det2<=0)");
+			_error2_("(det1<=0 ) || (det2<=0)");
 		}
 		if ( (detsa>=0) || (detsb<=0) ){ // [a,b] cut infinite line va,bb
-			_error_("(detsa>=0) || (detsb<=0)");
+			_error2_("(detsa>=0) || (detsb<=0)");
 		}
 		Icoor2 ndet1 = bamg::det(s1,sa,s2);
@@ -6002,5 +6002,5 @@
 		return ret;
 	}
-	/*}}}1*/
+	/*}}}*/
 
 }
Index: /issm/trunk/src/c/objects/Bamg/Mesh.h
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Mesh.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/Mesh.h	(revision 12706)
@@ -57,5 +57,5 @@
 			//Constructors/Destructors
 			Mesh(BamgGeom* bamggeom,BamgMesh* bamgmesh,BamgOpts* bamgopts);
-			Mesh(double* index,double* x,double* y,int nods,int nels);/*MeshConvert*/
+			Mesh(int* index,double* x,double* y,int nods,int nels);/*MeshConvert*/
 			Mesh(double* x,double* y,int nods); /*BamgTriangulate*/
 			Mesh(Mesh &,Geometry * pGh=0,Mesh* pBTh=0,long maxnbv_in=0 ); //copy operator
@@ -110,5 +110,5 @@
 			BamgVertex* NearestVertex(Icoor1 i,Icoor1 j) ;
 			Triangle* TriangleFindFromCoord(const I2 & ,Icoor2 [3],Triangle *tstart=0) const;
-			void ReadMesh(double* index,double* x,double* y,int nods,int nels);
+			void ReadMesh(int* index,double* x,double* y,int nods,int nels);
 			void ReadMesh(BamgMesh* bamgmesh, BamgOpts* bamgopts);
 			void WriteMesh(BamgMesh* bamgmesh,BamgOpts* bamgopts);
Index: /issm/trunk/src/c/objects/Bamg/Metric.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Metric.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/Metric.cpp	(revision 12706)
@@ -14,14 +14,13 @@
 
 	/*Constructor/Destructor*/
-	/*FUNCTION Metric::Metric(){{{1*/
-	/*FUNCTION Metric::Metric(double a){{{1*/
+	/*FUNCTION Metric::Metric(double a){{{*/
 	Metric::Metric(double a): a11(1/(a*a)),a21(0),a22(1/(a*a)){
 	
 	}/*}}}*/
-	/*FUNCTION Metric::Metric(double a,double b,double c){{{1*/
+	/*FUNCTION Metric::Metric(double a,double b,double c){{{*/
 	Metric::Metric(double a,double b,double c) :a11(a),a21(b),a22(c){
 	
 	}/*}}}*/
-	/*FUNCTION Metric::Metric(const double  a[3],const  Metric& m0, const  Metric& m1,const  Metric&  m2 ){{{1*/ 
+	/*FUNCTION Metric::Metric(const double  a[3],const  Metric& m0, const  Metric& m1,const  Metric&  m2 ){{{*/ 
 	Metric::Metric(const double  a[3],const  Metric& m0, const  Metric& m1,const  Metric& m2 ){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/Metric)*/
@@ -43,6 +42,6 @@
 		*this = vab;
 	}
-	/*}}}1*/
-	/*FUNCTION Metric::Metric(double  a,const  Metric& ma, double  b,const  Metric& mb){{{1*/
+	/*}}}*/
+	/*FUNCTION Metric::Metric(double  a,const  Metric& ma, double  b,const  Metric& mb){{{*/
 	Metric::Metric(double  a,const  Metric& ma, double  b,const  Metric& mb) { 
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/EigenMetric)*/
@@ -63,21 +62,21 @@
 		*this=vab;
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*Methods*/
-	/*FUNCTION Metric::det{{{1*/
+	/*FUNCTION Metric::det{{{*/
 	double Metric::det() const {
 		return a11*a22-a21*a21;
 	}  /*}}}*/
-	/*FUNCTION Metric::Echo {{{1*/
+	/*FUNCTION Metric::Echo {{{*/
 	void Metric::Echo(void){
 
-		printf("Metric:\n");
-		printf("   [a11 a21 a22]: [%g %g %g]\n",a11,a21,a22);
+		_printLine_("Metric:");
+		_printLine_("   [a11 a21 a22]: [" << a11 << " " << a21 << " " << a22 << "]");
 
 		return;
 	}
 	/*}}}*/
-	/*FUNCTION Metric::IntersectWith{{{1*/
+	/*FUNCTION Metric::IntersectWith{{{*/
 	int Metric::IntersectWith(const Metric& M2) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/IntersectWith)*/
@@ -131,6 +130,6 @@
 		return change;
 	}
-	/*}}}1*/
-	/*FUNCTION Metric::mul{{{1*/
+	/*}}}*/
+	/*FUNCTION Metric::mul{{{*/
 	R2     Metric::mul(const R2 x)const {
 		return R2(a11*x.x+a21*x.y,a21*x.x+a22*x.y);
@@ -138,5 +137,5 @@
 
 	/*Intermediary*/
-	/*FUNCTION LengthInterpole{{{1*/
+	/*FUNCTION LengthInterpole{{{*/
 	double LengthInterpole(const Metric& Ma,const  Metric& Mb, R2 AB) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/LengthInterpole)*/
@@ -198,13 +197,13 @@
 		// warning for optimisation S is in [0:0.5] not in [0:1]
 		if (i>=512){
-			_error_("i>=512");
+			_error2_("i>=512");
 		}
 		LastMetricInterpole.lab=l;
 		LastMetricInterpole.opt=i;
-		if (i>200 && kkk++<10) printf("WARNING: LengthInterpole: ( i=%i l=%i sss=%g ) %g\n",i,l,sss,sstop); 
+		if (i>200 && kkk++<10) _printLine_("WARNING: LengthInterpole: ( i=" << i << " l=" << l << " sss=" << sss << " ) " << sstop); 
 		return l;
 	}
-	/*}}}1*/
-	/*FUNCTION SimultaneousMatrixReduction{{{1*/
+	/*}}}*/
+	/*FUNCTION SimultaneousMatrixReduction{{{*/
 	void SimultaneousMatrixReduction( Metric M1,  Metric M2, D2xD2 &V) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/ReductionSimultanee)*/
@@ -308,6 +307,6 @@
 		}
 	}
-	/*}}}1*/
-	/*FUNCTION abscisseInterpole{{{1*/
+	/*}}}*/
+	/*FUNCTION abscisseInterpole{{{*/
 	double abscisseInterpole(const Metric& Ma,const  Metric& Mb, R2 AB,double s,int optim) { 
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/abscisseInterpole)*/
@@ -346,9 +345,9 @@
 		}
 		if (r>1 || r<0){
-			_error_("r>1 || r<0");
+			_error2_("r>1 || r<0");
 		}
 		return r ;
 	}
-	/*}}}1*/
+	/*}}}*/
 
 }
Index: /issm/trunk/src/c/objects/Bamg/SetOfE4.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/SetOfE4.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/SetOfE4.cpp	(revision 12706)
@@ -5,5 +5,5 @@
 
 	/*Constructor*/
-	/*FUNCTION  SetOfEdges4::SetOfEdges4(long mmx,long nnx){{{1*/
+	/*FUNCTION  SetOfEdges4::SetOfEdges4(long mmx,long nnx){{{*/
 	SetOfEdges4::SetOfEdges4(long mmx,long nnx){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/SetOfEdges4)*/
@@ -23,8 +23,8 @@
 		while(i--) head[i]=-1;
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*Methods*/ 
-	/*FUNCTION  SetOfEdges4::add{{{1*/
+	/*FUNCTION  SetOfEdges4::add{{{*/
 	long SetOfEdges4::add(long ii,long jj) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/add)*/
@@ -50,5 +50,5 @@
 		//check that nbax <=NbOfEdges
 		if (nbax <=NbOfEdges ) {
-			_error_("SetOfEdges4::add overflow: NbOfEdges=%i > nbax=%i",NbOfEdges,nbax);
+			_error2_("SetOfEdges4::add overflow: NbOfEdges=" << NbOfEdges << " > nbax=" << nbax);
 		}
 
@@ -60,6 +60,6 @@
 		return NbOfEdges ++;
 	}
-	/*}}}1*/
-	/*FUNCTION  SetOfEdges4::find {{{1*/
+	/*}}}*/
+	/*FUNCTION  SetOfEdges4::find {{{*/
 	long SetOfEdges4::find(long ii,long jj) { 
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, SetOfEdges4.cpp/find)*/
@@ -87,34 +87,34 @@
 		return -1;
 	}
-	/*}}}1*/
-	/*FUNCTION  SetOfEdges4::i{{{1*/
+	/*}}}*/
+	/*FUNCTION  SetOfEdges4::i{{{*/
 	long SetOfEdges4::i(long k){
 		return Edges[k].i;
 	}
-	/*}}}1*/
-	/*FUNCTION  SetOfEdges4::j{{{1*/
+	/*}}}*/
+	/*FUNCTION  SetOfEdges4::j{{{*/
 	long SetOfEdges4::j(long k){
 		return Edges[k].j;
 	}
-	/*}}}1*/
-	/*FUNCTION  SetOfEdges4::nb{{{1*/
+	/*}}}*/
+	/*FUNCTION  SetOfEdges4::nb{{{*/
 	long SetOfEdges4::nb(){
 		return NbOfEdges;
 	}
-	/*}}}1*/
-	/*FUNCTION  SetOfEdges4::newarete{{{1*/
+	/*}}}*/
+	/*FUNCTION  SetOfEdges4::newarete{{{*/
 	long SetOfEdges4::newarete(long k){
 		return NbOfEdges == k+1;
 	}
-	/*}}}1*/
-	/*FUNCTION  SetOfEdges4::SortAndAdd{{{1*/
+	/*}}}*/
+	/*FUNCTION  SetOfEdges4::SortAndAdd{{{*/
 	long SetOfEdges4::SortAndAdd (long ii,long jj) {
 		return ii <=jj ? add (ii,jj)  : add (jj,ii) ;
 	}
-	/*}}}1*/
-	/*FUNCTION  SetOfEdges4::SortAndFind{{{1*/
+	/*}}}*/
+	/*FUNCTION  SetOfEdges4::SortAndFind{{{*/
 	long SetOfEdges4::SortAndFind (long ii,long jj) {
 		return ii <=jj ? find (ii,jj)  : find (jj,ii) ;
 	}
-	/*}}}1*/
+	/*}}}*/
 }
Index: /issm/trunk/src/c/objects/Bamg/SubDomain.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/SubDomain.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/SubDomain.cpp	(revision 12706)
@@ -12,13 +12,13 @@
 
 	/*Methods*/
-	/*FUNCTION SubDomain::Set {{{1*/
+	/*FUNCTION SubDomain::Set {{{*/
 	void SubDomain::Set(const Mesh & Th ,long i,Mesh & ThNew){
 		*this = Th.subdomains[i];
 		if ( head-Th.triangles<0 || head-Th.triangles>=Th.nbt){
-			_error_("head-Th.triangles<0 || head-Th.triangles>=Th.nbt");
+			_error2_("head-Th.triangles<0 || head-Th.triangles>=Th.nbt");
 		}
 		head = ThNew.triangles + Th.GetId(head) ; 
 		if (edge-Th.edges<0 || edge-Th.edges>=Th.nbe);{
-			_error_("edge-Th.edges<0 || edge-Th.edges>=Th.nbe");
+			_error2_("edge-Th.edges<0 || edge-Th.edges>=Th.nbe");
 		}
 		edge = ThNew.edges+ Th.GetId(edge);
Index: /issm/trunk/src/c/objects/Bamg/Triangle.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Triangle.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/Triangle.cpp	(revision 12706)
@@ -9,18 +9,18 @@
 
 	/*Constructors/Destructors*/
-	/*FUNCTION Triangle(){{{1*/
+	/*FUNCTION Triangle(){{{*/
 	Triangle::Triangle(void){
 
 	}
 	/*}}}*/
-	/*FUNCTION Triangle(Mesh *Th,long i,long j,long k) {{{1*/
+	/*FUNCTION Triangle(Mesh *Th,long i,long j,long k) {{{*/
 	Triangle::Triangle(Mesh *Th,long i,long j,long k) {
 		BamgVertex *v=Th->vertices;
 		long nbv = Th->nbv;
 		if (i<0 || j<0 || k<0){
-			_error_("i<0 || j<0 || k<0");
+			_error2_("i<0 || j<0 || k<0");
 		}
 		if (i>=nbv || j>=nbv || k>=nbv){
-			_error_("i>=nbv || j>=nbv || k>=nbv");
+			_error2_("i>=nbv || j>=nbv || k>=nbv");
 		}
 		vertices[0]=v+i;
@@ -32,5 +32,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION Triangle(BamgVertex *v0,BamgVertex *v1,BamgVertex *v2) {{{1*/
+	/*FUNCTION Triangle(BamgVertex *v0,BamgVertex *v1,BamgVertex *v2) {{{*/
 	Triangle::Triangle(BamgVertex *v0,BamgVertex *v1,BamgVertex *v2){
 		vertices[0]=v0;
@@ -47,9 +47,9 @@
 
 	/*Methods*/
-	/*FUNCTION Triangle::Adj{{{1*/
+	/*FUNCTION Triangle::Adj{{{*/
 	AdjacentTriangle Triangle::Adj(int i)  const {
 		return AdjacentTriangle(adj[i],AdjEdgeIndex[i]&3);
 	};/*}}}*/
-	/*FUNCTION Triangle::Anisotropy{{{1*/
+	/*FUNCTION Triangle::Anisotropy{{{*/
 	double Triangle::Anisotropy() const{
 
@@ -80,5 +80,5 @@
 		return lmax/lmin;
 	};/*}}}*/
-	/*FUNCTION Triangle::Length{{{1*/
+	/*FUNCTION Triangle::Length{{{*/
 	double Triangle::Length() const{
 
@@ -102,23 +102,23 @@
 		return l;
 	};/*}}}*/
-	/*FUNCTION Triangle::Echo {{{1*/
+	/*FUNCTION Triangle::Echo {{{*/
 	void Triangle::Echo(void){
 
 		int i;
 
-		printf("Triangle:\n");
-		printf("   vertices pointer towards three vertices\n");
-		printf("      vertices[0] vertices[1] vertices[2] = %p %p %p\n",vertices[0],vertices[1],vertices[2]);
-		printf("   adj pointer towards three adjacent triangles\n");
-		printf("      adj[0] adj[1] adj[2] = %p %p %p\n",adj[0],adj[1],adj[2]);
-		printf("   det (integer triangle determinant) = %i\n",det);
+		_printLine_("Triangle:");
+		_printLine_("   vertices pointer towards three vertices");
+		_printLine_("      vertices[0] vertices[1] vertices[2] = " << vertices[0] << " " << vertices[1] << " " << vertices[2]);
+		_printLine_("   adj pointer towards three adjacent triangles");
+		_printLine_("      adj[0] adj[1] adj[2] = " << adj[0] << " " << adj[1] << " " << adj[2]);
+		_printLine_("   det (integer triangle determinant) = " << det);
 		if (link){
-			printf("   link (pointer toward duplicate triangle)= %p\n",link);
+			_printLine_("   link (pointer toward duplicate triangle)= " << link);
 		}
 		else{
-			printf("   color = %i\n",color);
-		}
-
-		printf("\nThree vertices:\n");
+			_printLine_("   color = " << color);
+		}
+
+		_printLine_("\nThree vertices:");
 		for(i=0;i<3;i++){
 			if (vertices[i]){
@@ -126,5 +126,5 @@
 			}
 			else{
-				printf("   vertex %i does not exist\n",i+1);
+				_printLine_("   vertex " << i+1 << " does not exist");
 			}
 		}
@@ -133,5 +133,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION Triangle::FindBoundaryEdge{{{1*/
+	/*FUNCTION Triangle::FindBoundaryEdge{{{*/
 	AdjacentTriangle Triangle::FindBoundaryEdge(int i) const{
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FindBoundaryEdge)*/
@@ -173,5 +173,5 @@
 			//check number of iterations
 			if (k>=2000){
-				_error_("too many iteration in Triangle::FindBoundaryEdge (k>=2000)");
+				_error2_("too many iteration in Triangle::FindBoundaryEdge (k>=2000)");
 			}
 		} while (this!= t);
@@ -179,23 +179,23 @@
 		return AdjacentTriangle(NULL,0);
 	}
-	/*}}}1*/
-	/*FUNCTION Triangle::GetAllflag{{{1*/
+	/*}}}*/
+	/*FUNCTION Triangle::GetAllflag{{{*/
 	int    Triangle::GetAllflag(int a){
 		return AdjEdgeIndex[a] & 1020;
 	}/*}}}*/
-	/*FUNCTION Triangle::Hidden{{{1*/
+	/*FUNCTION Triangle::Hidden{{{*/
 	int    Triangle::Hidden(int a)const {
 		return AdjEdgeIndex[a]&16;
 	} /*}}}*/
-	/*FUNCTION Triangle::Locked{{{1*/
+	/*FUNCTION Triangle::Locked{{{*/
 	int    Triangle::Locked(int a)const {
 		return AdjEdgeIndex[a]&4;
 	} /*}}}*/
-	/*FUNCTION Triangle::NuEdgeTriangleAdj{{{1*/
+	/*FUNCTION Triangle::NuEdgeTriangleAdj{{{*/
 	short  Triangle::NuEdgeTriangleAdj(int i) const {
 		/*Number of the  adjacent edge in adj tria (make sure it is between 0 and 2*/
 		return AdjEdgeIndex[i&3]&3;
 	}/*}}}*/
-	/*FUNCTION Triangle::Optim{{{1*/
+	/*FUNCTION Triangle::Optim{{{*/
 	long  Triangle::Optim(short i,int koption) {
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Optim)*/
@@ -213,5 +213,5 @@
 		do {
 			while (t->swap(j,koption)){
-				if (k>=20000) _error_("k>=20000");
+				if (k>=20000) _error2_("k>=20000");
 				NbSwap++;
 				k++;
@@ -229,6 +229,6 @@
 		return NbSwap;
 	}
-	/*}}}1*/
-	/*FUNCTION Triangle::Quadrangle {{{1*/
+	/*}}}*/
+	/*FUNCTION Triangle::Quadrangle {{{*/
 	Triangle* Triangle::Quadrangle(BamgVertex * & v0,BamgVertex * & v1,BamgVertex * & v2,BamgVertex * & v3) const{
 		// return the other triangle of the quad if a quad or 0 if not a quat
@@ -251,5 +251,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION Triangle::QualityQuad {{{1*/
+	/*FUNCTION Triangle::QualityQuad {{{*/
 	double   Triangle::QualityQuad(int a,int option) const{
 		double q;
@@ -274,5 +274,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION Triangle::Renumbering(Triangle *tb,Triangle *te, long *renu){{{1*/
+	/*FUNCTION Triangle::Renumbering(Triangle *tb,Triangle *te, long *renu){{{*/
 	void  Triangle::Renumbering(Triangle *tb,Triangle *te, long *renu){
 
@@ -282,5 +282,5 @@
 		if (adj[2] >=tb && adj[2] <te) adj[2] = tb + renu[adj[2]-tb];    
 	}/*}}}*/
-	/*FUNCTION Triangle::Renumbering(BamgVertex *vb,BamgVertex *ve, long *renu){{{1*/
+	/*FUNCTION Triangle::Renumbering(BamgVertex *vb,BamgVertex *ve, long *renu){{{*/
 	void Triangle::Renumbering(BamgVertex *vb,BamgVertex *ve, long *renu){
 		if (vertices[0] >=vb && vertices[0] <ve) vertices[0] = vb + renu[vertices[0]-vb];
@@ -288,5 +288,5 @@
 		if (vertices[2] >=vb && vertices[2] <ve) vertices[2] = vb + renu[vertices[2]-vb];    
 	}/*}}}*/
-	/*FUNCTION Triangle::Set {{{1*/
+	/*FUNCTION Triangle::Set {{{*/
 	void Triangle::Set(const Triangle & rec,const Mesh & Th ,Mesh & ThNew){ 
 		*this = rec;
@@ -301,5 +301,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION Triangle::SetAdjAdj{{{1*/
+	/*FUNCTION Triangle::SetAdjAdj{{{*/
 	void Triangle::SetAdjAdj(short a){
 		// Copy all the mark 
@@ -313,5 +313,5 @@
 		}
 	}/*}}}*/
-	/*FUNCTION Triangle::SetAdj2{{{1*/
+	/*FUNCTION Triangle::SetAdj2{{{*/
 	void Triangle::SetAdj2(short a,Triangle *t,short aat){
 		/*For current triangle:
@@ -326,14 +326,14 @@
 		}
 	}/*}}}*/
-	/*FUNCTION Triangle::SetAllFlag{{{1*/
+	/*FUNCTION Triangle::SetAllFlag{{{*/
 	void   Triangle::SetAllFlag(int a,int f){
 		AdjEdgeIndex[a] = (AdjEdgeIndex[a] &3) + (1020 & f);
 	}/*}}}*/
-	/*FUNCTION Triangle::SetDet{{{1*/
+	/*FUNCTION Triangle::SetDet{{{*/
 	void Triangle::SetDet() {
 		if(vertices[0] && vertices[1] && vertices[2])    det = bamg::det(*vertices[0],*vertices[1],*vertices[2]);
 		else det = -1; 
 	}/*}}}*/
-	/*FUNCTION Triangle::SetHidden{{{1*/
+	/*FUNCTION Triangle::SetHidden{{{*/
 	void Triangle::SetHidden(int a){
 		//Get Adjacent Triangle number a
@@ -344,5 +344,5 @@
 		AdjEdgeIndex[a] |= 16;
 	}/*}}}*/
-	/*FUNCTION Triangle::SetLocked{{{1*/
+	/*FUNCTION Triangle::SetLocked{{{*/
 	void Triangle::SetLocked(int a){
 		//mark the edge as on Boundary
@@ -351,5 +351,5 @@
 		AdjEdgeIndex[a] |= 4;
 	}/*}}}*/
-	/*FUNCTION Triangle::SetMarkUnSwap{{{1*/
+	/*FUNCTION Triangle::SetMarkUnSwap{{{*/
 	void Triangle::SetMarkUnSwap(int a){
 		register Triangle * t = adj[a];
@@ -357,5 +357,5 @@
 		AdjEdgeIndex[a] |=8 ;
 	}/*}}}*/
-	/*FUNCTION Triangle::SetSingleVertexToTriangleConnectivity{{{1*/
+	/*FUNCTION Triangle::SetSingleVertexToTriangleConnectivity{{{*/
 	void Triangle::SetSingleVertexToTriangleConnectivity() { 
 		if (vertices[0]) (vertices[0]->t=this,vertices[0]->IndexInTriangle=0);
@@ -363,5 +363,5 @@
 		if (vertices[2]) (vertices[2]->t=this,vertices[2]->IndexInTriangle=2);
 	}/*}}}*/
-	/*FUNCTION Triangle::SetUnMarkUnSwap{{{1*/
+	/*FUNCTION Triangle::SetUnMarkUnSwap{{{*/
 	void Triangle::SetUnMarkUnSwap(int a){ 
 		register Triangle * t = adj[a];
@@ -369,5 +369,5 @@
 		AdjEdgeIndex[a] &=55 ;
 	}/*}}}*/
-	/*FUNCTION Triangle::swap{{{1*/
+	/*FUNCTION Triangle::swap{{{*/
 	int Triangle::swap(short a,int koption){
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/swap)*/
@@ -483,6 +483,6 @@
 		return OnSwap;
 	}
-	/*}}}1*/
-	/*FUNCTION Triangle::TriangleAdj{{{1*/
+	/*}}}*/
+	/*FUNCTION Triangle::TriangleAdj{{{*/
 	Triangle* Triangle::TriangleAdj(int i) const {
 		return adj[i&3];
Index: /issm/trunk/src/c/objects/Bamg/VertexOnEdge.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/VertexOnEdge.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/VertexOnEdge.cpp	(revision 12706)
@@ -10,5 +10,5 @@
 
 	/*Methods*/
-	/*FUNCTION VertexOnEdge::Set {{{1*/
+	/*FUNCTION VertexOnEdge::Set {{{*/
 	void VertexOnEdge::Set(const Mesh & Th ,long i,Mesh & ThNew){
 		*this = Th.VertexOnBThEdge[i];  
@@ -16,5 +16,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION VertexOnEdge::SetOnBTh{{{1*/
+	/*FUNCTION VertexOnEdge::SetOnBTh{{{*/
 	void VertexOnEdge::SetOnBTh(){
 		v->BackgroundEdgeHook=this;
Index: /issm/trunk/src/c/objects/Bamg/VertexOnGeom.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/VertexOnGeom.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/VertexOnGeom.cpp	(revision 12706)
@@ -11,5 +11,5 @@
 
 	/*Constructors/Destructors*/
-	/*FUNCTION VertexOnGeom::VertexOnGeom(){{{1*/
+	/*FUNCTION VertexOnGeom::VertexOnGeom(){{{*/
 	VertexOnGeom::VertexOnGeom(){
 		meshvertex=NULL;
@@ -18,5 +18,5 @@
 	} 
 	/*}}}*/
-	/*FUNCTION VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomVertex &g){{{1*/
+	/*FUNCTION VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomVertex &g){{{*/
 	VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomVertex &g){
 		meshvertex=&m;
@@ -25,5 +25,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomEdge &g,double s){{{1*/
+	/*FUNCTION VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomEdge &g,double s){{{*/
 	VertexOnGeom::VertexOnGeom(BamgVertex & m,GeomEdge &g,double s){
 		meshvertex=&m;
@@ -34,5 +34,5 @@
 
 	/*Methods*/
-	/*FUNCTION VertexOnGeom::Set {{{1*/
+	/*FUNCTION VertexOnGeom::Set {{{*/
 	void VertexOnGeom::Set(const VertexOnGeom & rec,const Mesh & Th ,Mesh & ThNew){
 		*this = rec;  
@@ -46,20 +46,20 @@
 	}
 	/*}}}*/
-	/*FUNCTION VertexOnGeom::OnGeomVertex{{{1*/
+	/*FUNCTION VertexOnGeom::OnGeomVertex{{{*/
 	int VertexOnGeom::OnGeomVertex()const{
 		return this? curvilincoord <0 :0;
 	}
 	/*}}}*/
-	/*FUNCTION VertexOnGeom::OnGeomEdge{{{1*/
+	/*FUNCTION VertexOnGeom::OnGeomEdge{{{*/
 	int VertexOnGeom::OnGeomEdge() const{
 		return this? curvilincoord >=0 :0;
 	}
 	/*}}}*/
-	/*FUNCTION VertexOnGeom::IsRequiredVertex{{{1*/
+	/*FUNCTION VertexOnGeom::IsRequiredVertex{{{*/
 	int VertexOnGeom::IsRequiredVertex() {
 		return this? ((curvilincoord<0 ? (gv?gv->Required():0):0 )) : 0;
 	}
 	/*}}}*/
-	/*FUNCTION VertexOnGeom::SetOn{{{1*/
+	/*FUNCTION VertexOnGeom::SetOn{{{*/
 	void VertexOnGeom::SetOn(){
 		meshvertex->GeomEdgeHook=this;
Index: /issm/trunk/src/c/objects/Bamg/VertexOnVertex.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/VertexOnVertex.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Bamg/VertexOnVertex.cpp	(revision 12706)
@@ -10,10 +10,10 @@
 
 	/*Constructors/Destructors*/
-	/*FUNCTION VertexOnVertex::VertexOnVertex(){{{1*/
+	/*FUNCTION VertexOnVertex::VertexOnVertex(){{{*/
 	VertexOnVertex::VertexOnVertex() {
 		v=NULL;
 		bv=NULL;
 	};/*}}}*/
-	/*FUNCTION VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw){{{1*/
+	/*FUNCTION VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw){{{*/
 	VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw) :v(w),bv(bw){
 	
@@ -21,5 +21,5 @@
 
 	/*Methods*/
-	/*FUNCTION VertexOnVertex::Set{{{1*/
+	/*FUNCTION VertexOnVertex::Set{{{*/
 	void VertexOnVertex::Set(const Mesh &Th ,long i,Mesh &ThNew) { 
 		*this = Th.VertexOnBThVertex[i];  
@@ -27,5 +27,5 @@
 	}
 	/*}}}*/
-	/*FUNCTION VertexOnVertex::SetOnBTh{{{1*/
+	/*FUNCTION VertexOnVertex::SetOnBTh{{{*/
 	void VertexOnVertex::SetOnBTh(){
 		v->BackgroundVertexHook=bv;v->IndexInTriangle=IsVertexOnVertex;
Index: /issm/trunk/src/c/objects/Constraints/Constraint.h
===================================================================
--- /issm/trunk/src/c/objects/Constraints/Constraint.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Constraints/Constraint.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 class Nodes;
 #include "../Object.h"
Index: /issm/trunk/src/c/objects/Constraints/SpcDynamic.cpp
===================================================================
--- /issm/trunk/src/c/objects/Constraints/SpcDynamic.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Constraints/SpcDynamic.cpp	(revision 12706)
@@ -18,10 +18,10 @@
 
 /*SpcDynamic constructors and destructor*/
-/*FUNCTION SpcDynamic::SpcDynamic(){{{1*/
+/*FUNCTION SpcDynamic::SpcDynamic(){{{*/
 SpcDynamic::SpcDynamic(){
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid,...){{{1*/
+/*}}}*/
+/*FUNCTION SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid,...){{{*/
 SpcDynamic::SpcDynamic(int spc_sid,int spc_nodeid, int spc_dof,int spc_analysis_type){
 
@@ -35,26 +35,26 @@
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcDynamic::~SpcDynamic{{{1*/
+/*}}}*/
+/*FUNCTION SpcDynamic::~SpcDynamic{{{*/
 SpcDynamic::~SpcDynamic(){
 	return;
 }
-/*}}}1*/
+/*}}}*/
 		
 /*Object virtual functions definitions:*/
-/*FUNCTION SpcDynamic::Echo {{{1*/
+/*FUNCTION SpcDynamic::Echo {{{*/
 void SpcDynamic::Echo(void){
 
-	printf("SpcDynamic:\n");
-	printf("   sid: %i\n",sid);
-	printf("   nodeid: %i\n",nodeid);
-	printf("   dof: %i\n",dof);
-	printf("   value: %g\n",value);
-	printf("   isset: %s\n",isset?"true":"false");
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("SpcDynamic:");
+	_printLine_("   sid: " << sid);
+	_printLine_("   nodeid: " << nodeid);
+	_printLine_("   dof: " << dof);
+	_printLine_("   value: " << value);
+	_printLine_("   isset: " <<(isset?"true":"false"));
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcDynamic::DeepEcho {{{1*/
+/*}}}*/
+/*FUNCTION SpcDynamic::DeepEcho {{{*/
 void SpcDynamic::DeepEcho(void){
 
@@ -62,15 +62,15 @@
 	return;
 }		
-/*}}}1*/
-/*FUNCTION SpcDynamic::Id {{{1*/
+/*}}}*/
+/*FUNCTION SpcDynamic::Id {{{*/
 int    SpcDynamic::Id(void){ return sid; }
-/*}}}1*/
-/*FUNCTION SpcDynamic::MyRank {{{1*/
+/*}}}*/
+/*FUNCTION SpcDynamic::MyRank {{{*/
 int    SpcDynamic::MyRank(void){ 
 	extern int my_rank;
 	return my_rank; 
 }
-/*}}}1*/
-/*FUNCTION SpcDynamic::ObjectEnum{{{1*/
+/*}}}*/
+/*FUNCTION SpcDynamic::ObjectEnum{{{*/
 int SpcDynamic::ObjectEnum(void){
 
@@ -78,13 +78,13 @@
 
 }
-/*}}}1*/
-/*FUNCTION SpcDynamic::copy {{{1*/
+/*}}}*/
+/*FUNCTION SpcDynamic::copy {{{*/
 Object* SpcDynamic::copy() {
 	return new SpcDynamic(*this); 
 }
-/*}}}1*/
+/*}}}*/
 
 /*Constraint virtual functions definitions: */
-/*FUNCTION SpcDynamic::InAnalysis{{{1*/
+/*FUNCTION SpcDynamic::InAnalysis{{{*/
 bool SpcDynamic::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type) return true;
@@ -92,5 +92,5 @@
 }
 /*}}}*/
-/*FUNCTION SpcDynamic::ConstrainNode{{{1*/
+/*FUNCTION SpcDynamic::ConstrainNode{{{*/
 void SpcDynamic::ConstrainNode(Nodes* nodes,Parameters* parameters){
 
@@ -110,24 +110,24 @@
 
 /*SpcDynamic functions*/
-/*FUNCTION SpcDynamic::GetDof {{{1*/
+/*FUNCTION SpcDynamic::GetDof {{{*/
 int SpcDynamic::GetDof(){
 	return dof;
 }
-/*}}}1*/
-/*FUNCTION SpcDynamic::GetNodeId {{{1*/
+/*}}}*/
+/*FUNCTION SpcDynamic::GetNodeId {{{*/
 int   SpcDynamic::GetNodeId(){
 	
 	return nodeid;
 }
-/*}}}1*/
-/*FUNCTION SpcDynamic::GetValue {{{1*/
-double SpcDynamic::GetValue(){
+/*}}}*/
+/*FUNCTION SpcDynamic::GetValue {{{*/
+IssmDouble SpcDynamic::GetValue(){
 	_assert_(this->isset);
-	_assert_(!isnan(value));
+	_assert_(!xIsNan<IssmDouble>(value));
 	return value;
 }
-/*}}}1*/
-/*FUNCTION SpcDynamic::SetDynamicConstraint {{{1*/
-void SpcDynamic::SetDynamicConstraint(Nodes* nodes,double* yg_serial){
+/*}}}*/
+/*FUNCTION SpcDynamic::SetDynamicConstraint {{{*/
+void SpcDynamic::SetDynamicConstraint(Nodes* nodes,IssmDouble* yg_serial){
 
 	int pos;
@@ -139,3 +139,3 @@
 	this->isset=true;
 }
-/*}}}1*/
+/*}}}*/
Index: /issm/trunk/src/c/objects/Constraints/SpcDynamic.h
===================================================================
--- /issm/trunk/src/c/objects/Constraints/SpcDynamic.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Constraints/SpcDynamic.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Object.h"
 class DataSet;
@@ -18,5 +18,5 @@
 		int	nodeid; /*!node id*/
 		int dof; /*!component*/
-		double value; /*value*/
+		IssmDouble value; /*value*/
 		bool isset;
 		int analysis_type;
@@ -24,10 +24,10 @@
 	public:
 
-		/*SpcDynamic constructors, destructors:{{{1*/
+		/*SpcDynamic constructors, destructors:{{{*/
 		SpcDynamic();
 		SpcDynamic(int sid,int nodeid, int dof,int analysis_type);
 		~SpcDynamic();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -37,13 +37,13 @@
 		Object* copy();
 		/*}}}*/
-		/*Constraint virtual functions definitions: {{{1*/
+		/*Constraint virtual functions definitions: {{{*/
 		void   ConstrainNode(Nodes* nodes,Parameters* parameters);
 		bool   InAnalysis(int analysis_type);
 		/*}}}*/
-		/*SpcDynamic management:{{{1 */
+		/*SpcDynamic management:{{{ */
 		int    GetNodeId();
 		int    GetDof();
-		double GetValue();
-		void   SetDynamicConstraint(Nodes* nodes,double *yg_serial);
+		IssmDouble GetValue();
+		void   SetDynamicConstraint(Nodes* nodes,IssmDouble *yg_serial);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Constraints/SpcStatic.cpp
===================================================================
--- /issm/trunk/src/c/objects/Constraints/SpcStatic.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Constraints/SpcStatic.cpp	(revision 12706)
@@ -18,11 +18,11 @@
 
 /*SpcStatic constructors and destructor*/
-/*FUNCTION SpcStatic::SpcStatic(){{{1*/
+/*FUNCTION SpcStatic::SpcStatic(){{{*/
 SpcStatic::SpcStatic(){
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcStatic::SpcStatic(int spc_sid,int spc_nodeid,...){{{1*/
-SpcStatic::SpcStatic(int spc_sid,int spc_nodeid, int spc_dof,double spc_value,int spc_analysis_type){
+/*}}}*/
+/*FUNCTION SpcStatic::SpcStatic(int spc_sid,int spc_nodeid,...){{{*/
+SpcStatic::SpcStatic(int spc_sid,int spc_nodeid, int spc_dof,IssmDouble spc_value,int spc_analysis_type){
 
 	sid=spc_sid;
@@ -34,46 +34,46 @@
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcStatic::~SpcStatic{{{1*/
+/*}}}*/
+/*FUNCTION SpcStatic::~SpcStatic{{{*/
 SpcStatic::~SpcStatic(){
 	return;
 }
-/*}}}1*/
+/*}}}*/
 		
 /*Object virtual functions definitions:*/
-/*FUNCTION SpcStatic::Echo {{{1*/
+/*FUNCTION SpcStatic::Echo {{{*/
 void SpcStatic::Echo(void){
 
-	printf("SpcStatic:\n");
-	printf("   sid: %i\n",sid);
-	printf("   nodeid: %i\n",nodeid);
-	printf("   dof: %i\n",dof);
-	printf("   value: %g\n",value);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("SpcStatic:");
+	_printLine_("   sid: " << sid);
+	_printLine_("   nodeid: " << nodeid);
+	_printLine_("   dof: " << dof);
+	_printLine_("   value: " << value);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcStatic::DeepEcho {{{1*/
+/*}}}*/
+/*FUNCTION SpcStatic::DeepEcho {{{*/
 void SpcStatic::DeepEcho(void){
 
-	printf("SpcStatic:\n");
-	printf("   sid: %i\n",sid);
-	printf("   nodeid: %i\n",nodeid);
-	printf("   dof: %i\n",dof);
-	printf("   value: %g\n",value);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("SpcStatic:");
+	_printLine_("   sid: " << sid);
+	_printLine_("   nodeid: " << nodeid);
+	_printLine_("   dof: " << dof);
+	_printLine_("   value: " << value);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	return;
 }		
-/*}}}1*/
-/*FUNCTION SpcStatic::Id {{{1*/
+/*}}}*/
+/*FUNCTION SpcStatic::Id {{{*/
 int    SpcStatic::Id(void){ return sid; }
-/*}}}1*/
-/*FUNCTION SpcStatic::MyRank {{{1*/
+/*}}}*/
+/*FUNCTION SpcStatic::MyRank {{{*/
 int    SpcStatic::MyRank(void){ 
 	extern int my_rank;
 	return my_rank; 
 }
-/*}}}1*/
-/*FUNCTION SpcStatic::ObjectEnum{{{1*/
+/*}}}*/
+/*FUNCTION SpcStatic::ObjectEnum{{{*/
 int SpcStatic::ObjectEnum(void){
 
@@ -81,13 +81,13 @@
 
 }
-/*}}}1*/
-/*FUNCTION SpcStatic::copy {{{1*/
+/*}}}*/
+/*FUNCTION SpcStatic::copy {{{*/
 Object* SpcStatic::copy() {
 	return new SpcStatic(*this); 
 }
-/*}}}1*/
+/*}}}*/
 
 /*Constraint virtual functions definitions: */
-/*FUNCTION SpcStatic::InAnalysis{{{1*/
+/*FUNCTION SpcStatic::InAnalysis{{{*/
 bool SpcStatic::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type) return true;
@@ -95,5 +95,5 @@
 }
 /*}}}*/
-/*FUNCTION SpcStatic::ConstrainNode{{{1*/
+/*FUNCTION SpcStatic::ConstrainNode{{{*/
 void SpcStatic::ConstrainNode(Nodes* nodes,Parameters* parameters){
 
@@ -111,19 +111,19 @@
 
 /*SpcStatic functions*/
-/*FUNCTION SpcStatic::GetDof {{{1*/
+/*FUNCTION SpcStatic::GetDof {{{*/
 int SpcStatic::GetDof(){
 	return dof;
 }
-/*}}}1*/
-/*FUNCTION SpcStatic::GetNodeId {{{1*/
+/*}}}*/
+/*FUNCTION SpcStatic::GetNodeId {{{*/
 int   SpcStatic::GetNodeId(){
 	
 	return nodeid;
 }
-/*}}}1*/
-/*FUNCTION SpcStatic::GetValue {{{1*/
-double SpcStatic::GetValue(){
-	_assert_(!isnan(value));
+/*}}}*/
+/*FUNCTION SpcStatic::GetValue {{{*/
+IssmDouble SpcStatic::GetValue(){
+	_assert_(!xIsNan<IssmDouble>(value));
 	return value;
 }
-/*}}}1*/
+/*}}}*/
Index: /issm/trunk/src/c/objects/Constraints/SpcStatic.h
===================================================================
--- /issm/trunk/src/c/objects/Constraints/SpcStatic.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Constraints/SpcStatic.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Object.h"
 class DataSet;
@@ -18,15 +18,15 @@
 		int	nodeid; /*!node id*/
 		int dof; /*!component*/
-		double value; /*value*/
+		IssmDouble value; /*value*/
 		int analysis_type;
 
 	public:
 
-		/*SpcStatic constructors, destructors:{{{1*/
+		/*SpcStatic constructors, destructors:{{{*/
 		SpcStatic();
-		SpcStatic(int sid,int nodeid, int dof,double value,int analysis_type);
+		SpcStatic(int sid,int nodeid, int dof,IssmDouble value,int analysis_type);
 		~SpcStatic();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -36,12 +36,12 @@
 		Object* copy();
 		/*}}}*/
-		/*Constraint virtual functions definitions: {{{1*/
+		/*Constraint virtual functions definitions: {{{*/
 		void   ConstrainNode(Nodes* nodes,Parameters* parameters);
 		bool   InAnalysis(int analysis_type);
 		/*}}}*/
-		/*SpcStatic management:{{{1 */
+		/*SpcStatic management:{{{ */
 		int    GetNodeId();
 		int    GetDof();
-		double GetValue();
+		IssmDouble GetValue();
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Constraints/SpcTransient.cpp
===================================================================
--- /issm/trunk/src/c/objects/Constraints/SpcTransient.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Constraints/SpcTransient.cpp	(revision 12706)
@@ -18,5 +18,5 @@
 
 /*SpcTransient constructors and destructor*/
-/*FUNCTION SpcTransient::SpcTransient(){{{1*/
+/*FUNCTION SpcTransient::SpcTransient(){{{*/
 SpcTransient::SpcTransient(){
 	sid=-1;
@@ -29,7 +29,7 @@
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcTransient::SpcTransient(int spc_sid,int spc_nodeid,...){{{1*/
-SpcTransient::SpcTransient(int spc_sid,int spc_nodeid, int spc_dof,int spc_nsteps, double* spc_times, double* spc_values,int spc_analysis_type){
+/*}}}*/
+/*FUNCTION SpcTransient::SpcTransient(int spc_sid,int spc_nodeid,...){{{*/
+SpcTransient::SpcTransient(int spc_sid,int spc_nodeid, int spc_dof,int spc_nsteps, IssmDouble* spc_times, IssmDouble* spc_values,int spc_analysis_type){
 
 	sid=spc_sid;
@@ -38,54 +38,54 @@
 	nsteps=spc_nsteps;
 	if(spc_nsteps){
-		values=(double*)xmalloc(spc_nsteps*sizeof(double));
-		times=(double*)xmalloc(spc_nsteps*sizeof(double));
-		memcpy(values,spc_values,nsteps*sizeof(double));
-		memcpy(times,spc_times,nsteps*sizeof(double));
+		values=xNew<IssmDouble>(spc_nsteps);
+		times=xNew<IssmDouble>(spc_nsteps);
+		xMemCpy<IssmDouble>(values,spc_values,nsteps);
+		xMemCpy<IssmDouble>(times,spc_times,nsteps);
 	}
 	analysis_type=spc_analysis_type;
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcTransient::~SpcTransient{{{1*/
+/*}}}*/
+/*FUNCTION SpcTransient::~SpcTransient{{{*/
 SpcTransient::~SpcTransient(){
-	xfree((void**)&times);
-	xfree((void**)&values);
+	xDelete<IssmDouble>(times);
+	xDelete<IssmDouble>(values);
 	return;
 }
-/*}}}1*/
+/*}}}*/
 		
 /*Object virtual functions definitions:*/
-/*FUNCTION SpcTransient::Echo {{{1*/
+/*FUNCTION SpcTransient::Echo {{{*/
 void SpcTransient::Echo(void){
 
 	int i;
-	printf("SpcTransient:\n");
-	printf("   sid: %i\n",sid);
-	printf("   nodeid: %i\n",nodeid);
-	printf("   dof: %i\n",dof);
-	printf("   nsteps: %i\n",nsteps);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
-	printf("   steps|times|values\n");
+	_printLine_("SpcTransient:");
+	_printLine_("   sid: " << sid);
+	_printLine_("   nodeid: " << nodeid);
+	_printLine_("   dof: " << dof);
+	_printLine_("   nsteps: " << nsteps);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
+	_printLine_("   steps|times|values");
 	for(i=0;i<nsteps;i++){
-		printf("%i-%g:%g\n",i,times[i],values[i]);
+		_printLine_(i << "-" << times[i] << ":" << values[i]);
 	}
 	return;
 }
-/*}}}1*/
-/*FUNCTION SpcTransient::DeepEcho {{{1*/
+/*}}}*/
+/*FUNCTION SpcTransient::DeepEcho {{{*/
 void SpcTransient::DeepEcho(void){
 	this->Echo();
 }		
-/*}}}1*/
-/*FUNCTION SpcTransient::Id {{{1*/
+/*}}}*/
+/*FUNCTION SpcTransient::Id {{{*/
 int    SpcTransient::Id(void){ return sid; }
-/*}}}1*/
-/*FUNCTION SpcTransient::MyRank {{{1*/
+/*}}}*/
+/*FUNCTION SpcTransient::MyRank {{{*/
 int    SpcTransient::MyRank(void){ 
 	extern int my_rank;
 	return my_rank; 
 }
-/*}}}1*/
-/*FUNCTION SpcTransient::ObjectEnum{{{1*/
+/*}}}*/
+/*FUNCTION SpcTransient::ObjectEnum{{{*/
 int SpcTransient::ObjectEnum(void){
 
@@ -93,13 +93,13 @@
 
 }
-/*}}}1*/
-/*FUNCTION SpcTransient::copy {{{1*/
+/*}}}*/
+/*FUNCTION SpcTransient::copy {{{*/
 Object* SpcTransient::copy() {
 	return new SpcTransient(sid,nodeid,dof,nsteps,times,values,analysis_type);
 }
-/*}}}1*/
+/*}}}*/
 
 /*Constraint virtual functions definitions:*/
-/*FUNCTION SpcTransient::InAnalysis{{{1*/
+/*FUNCTION SpcTransient::InAnalysis{{{*/
 bool SpcTransient::InAnalysis(int in_analysis_type){
 	
@@ -108,12 +108,12 @@
 }
 /*}}}*/
-/*FUNCTION SpcTransient::ConstrainNode{{{1*/
+/*FUNCTION SpcTransient::ConstrainNode{{{*/
 void SpcTransient::ConstrainNode(Nodes* nodes,Parameters* parameters){
 
 	Node* node=NULL;
-	double time=0;
+	IssmDouble time=0;
 	int    i;
-	double alpha=-1;
-	double value;
+	IssmDouble alpha=-1;
+	IssmDouble value;
 	bool   found=false;
 
@@ -146,8 +146,8 @@
 		}
 
-		if(!found)_error_("could not find time segment for constraint");
+		if(!found)_error2_("could not find time segment for constraint");
 
 		/*Apply or relax constraint: */
-		if(isnan(value)){
+		if(xIsNan<IssmDouble>(value)){
 			node->RelaxConstraint(dof);
 		}
@@ -158,19 +158,19 @@
 
 /*SpcTransient functions*/
-/*FUNCTION SpcTransient::GetDof {{{1*/
+/*FUNCTION SpcTransient::GetDof {{{*/
 int SpcTransient::GetDof(){
 	return dof;
 }
-/*}}}1*/
-/*FUNCTION SpcTransient::GetNodeId {{{1*/
+/*}}}*/
+/*FUNCTION SpcTransient::GetNodeId {{{*/
 int   SpcTransient::GetNodeId(){
 	
 	return nodeid;
 }
-/*}}}1*/
-/*FUNCTION SpcTransient::GetValue {{{1*/
-double SpcTransient::GetValue(){
+/*}}}*/
+/*FUNCTION SpcTransient::GetValue {{{*/
+IssmDouble SpcTransient::GetValue(){
 	return values[0];
 }
-/*}}}1*/
+/*}}}*/
 
Index: /issm/trunk/src/c/objects/Constraints/SpcTransient.h
===================================================================
--- /issm/trunk/src/c/objects/Constraints/SpcTransient.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Constraints/SpcTransient.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Object.h"
 class DataSet;
@@ -18,6 +18,6 @@
 		int	nodeid; /*!node id*/
 		int dof; /*!component*/
-		double* values; /*different values in time*/
-		double* times; /*different time steps*/
+		IssmDouble* values; /*different values in time*/
+		IssmDouble* times; /*different time steps*/
 		int nsteps; /*number of time steps*/
 		int analysis_type;
@@ -25,10 +25,10 @@
 	public:
 
-		/*SpcTransient constructors, destructors:{{{1*/
+		/*SpcTransient constructors, destructors:{{{*/
 		SpcTransient();
-		SpcTransient(int sid,int nodeid, int dof,int nsteps, double* times, double* values,int analysis_type);
+		SpcTransient(int sid,int nodeid, int dof,int nsteps, IssmDouble* times, IssmDouble* values,int analysis_type);
 		~SpcTransient();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -38,12 +38,12 @@
 		Object* copy();
 		/*}}}*/
-		/*Constraint virtual functions definitions: {{{1*/
+		/*Constraint virtual functions definitions: {{{*/
 		void   ConstrainNode(Nodes* nodes,Parameters* parameters);
 		bool   InAnalysis(int analysis_type);
 		/*}}}*/
-		/*SpcTransient management:{{{1 */
+		/*SpcTransient management:{{{ */
 		int    GetNodeId();
 		int    GetDof();
-		double GetValue();
+		IssmDouble GetValue();
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Contour.cpp
===================================================================
--- /issm/trunk/src/c/objects/Contour.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Contour.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 
 /*Contour constructors and destructors:*/
-/*FUNCTION Contour::Contour() default constructor {{{1*/
+/*FUNCTION Contour::Contour() default constructor {{{*/
 Contour::Contour(){
 	this->id=0;
@@ -24,6 +24,6 @@
 }
 /*}}}*/
-/*FUNCTION Contour::Contour(int pid, int nods, double* x, double* y,bool closed) {{{1*/
-Contour::Contour(int pid,int pnods, double* px, double* py,bool pclosed){
+/*FUNCTION Contour::Contour(int pid, int nods, IssmDouble* x, IssmDouble* y,bool closed) {{{*/
+Contour::Contour(int pid,int pnods, IssmDouble* px, IssmDouble* py,bool pclosed){
 	
 	this->id=pid;
@@ -31,15 +31,15 @@
 	this->closed=pclosed;
 	if(nods){
-		this->x=(double*)xmalloc(nods*sizeof(double));
-		memcpy(this->x,px,nods*sizeof(double));
-		this->y=(double*)xmalloc(nods*sizeof(double));
-		memcpy(this->y,py,nods*sizeof(double));
+		this->x=xNew<IssmDouble>(nods);
+		xMemCpy<IssmDouble>(this->x,px,nods);
+		this->y=xNew<IssmDouble>(nods);
+		xMemCpy<IssmDouble>(this->y,py,nods);
 	}
 }
 /*}}}*/
-/*FUNCTION Contour::Contour() default constructor {{{1*/
+/*FUNCTION Contour::Contour() default constructor {{{*/
 Contour::~Contour(){
-	xfree((void**)&this->x);
-	xfree((void**)&this->y);
+	xDelete<IssmDouble>(this->x);
+	xDelete<IssmDouble>(this->y);
 }
 /*}}}*/
@@ -47,31 +47,31 @@
 
 /*Object virtual function resolutoin: */
-/*FUNCTION Contour::Echo(){{{1*/
+/*FUNCTION Contour::Echo(){{{*/
 void Contour::Echo(void){
 
 	int i;
 
-	printf("Contour: %i:\n",id);
-	printf("   nods: %i\n",nods);
-	printf("   closed: %s\n",closed?"true":"false");
+	_printLine_("Contour: " << id);
+	_printLine_("   nods: " << nods);
+	_printLine_("   closed: " << (closed?"true":"false"));
 	if(nods){
-		printf("   x,y:\n");
+	        _printLine_("   x,y:");
 		for(i=0;i<nods;i++){
-			printf("%i: %g|%g\n",i,x[i],y[i]);
+		        _printLine_(i << ": " << x[i] << "|" << y[i]);
 		}
 	}
 }
 /*}}}*/
-/*FUNCTION Contour::DeepEcho(){{{1*/
+/*FUNCTION Contour::DeepEcho(){{{*/
 void Contour::DeepEcho(void){
 	this->Echo();
 }
 /*}}}*/
-/*FUNCTION Contour::Id(){{{1*/
+/*FUNCTION Contour::Id(){{{*/
 int Contour::Id(void){
 	return id;
 }
 /*}}}*/
-/*FUNCTION Contour::MyRank{{{1*/
+/*FUNCTION Contour::MyRank{{{*/
 int    Contour::MyRank(void){ 
 	extern int my_rank;
@@ -80,5 +80,5 @@
 }
 /*}}}*/
-/*FUNCTION Contour::ObjectEnum{{{1*/
+/*FUNCTION Contour::ObjectEnum{{{*/
 int Contour::ObjectEnum(void){
 
@@ -87,5 +87,5 @@
 }
 /*}}}*/
-/*FUNCTION Contour::copy {{{1*/
+/*FUNCTION Contour::copy {{{*/
 Object* Contour::copy() {
 
Index: /issm/trunk/src/c/objects/Contour.h
===================================================================
--- /issm/trunk/src/c/objects/Contour.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Contour.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Object.h"
 #include "../shared/Exceptions/exceptions.h"
@@ -24,10 +24,10 @@
 		bool    closed; //is this contour closed?
 
-		/*Contour constructors, destructors {{{1*/
+		/*Contour constructors, destructors {{{*/
 		Contour();
 		Contour(int id, int nods, IssmDouble* x, IssmDouble* y,bool closed);
 		~Contour();
 		/*}}}*/
-		/*Object virtual functions{{{1*/
+		/*Object virtual functions{{{*/
 		void  Echo(void);
 		void  DeepEcho(void);
Index: /issm/trunk/src/c/objects/DakotaPlugin.cpp
===================================================================
--- /issm/trunk/src/c/objects/DakotaPlugin.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/DakotaPlugin.cpp	(revision 12706)
@@ -57,8 +57,8 @@
 
 	int i;
-	double* variables=NULL;
+	IssmDouble* variables=NULL;
 	char** variable_descriptors=NULL;
 	char*  variable_descriptor=NULL;
-	double* responses=NULL;
+	IssmDouble* responses=NULL;
 
 	/*increae counter: */
@@ -69,13 +69,13 @@
 
 	/*First, the variables: */
-	variables=(double*)xmalloc(numACV*sizeof(double));
+	variables=xNew<IssmDouble>(numACV);
 	for(i=0;i<numACV;i++){
 		variables[i]=xC[i];
 	}
 	/*The descriptors: */
-	variable_descriptors=(char**)xmalloc(numACV*sizeof(char*));
+	variable_descriptors=xNew<char*>(numACV);
 	for(i=0;i<numACV;i++){
 		string label=xCLabels[i];
-		variable_descriptor=(char*)xmalloc((strlen(label.c_str())+1)*sizeof(char));
+		variable_descriptor=xNew<char>(strlen(label.c_str())+1);
 		memcpy(variable_descriptor,label.c_str(),(strlen(label.c_str())+1)*sizeof(char));
 
@@ -85,5 +85,5 @@
 
 	/*Initialize responses: */
-	responses=(double*)xcalloc(numFns,sizeof(double));
+	responses=xNewZeroInit<IssmDouble>(numFns);
 
 	/*run core solution: */
@@ -97,11 +97,11 @@
 
 	/*Free ressources:*/
-	xfree((void**)&variables);
+	xDelete<IssmDouble>(variables);
 	for(i=0;i<numACV;i++){
 		variable_descriptor=variable_descriptors[i];
-		xfree((void**)&variable_descriptor);
+		xDelete<char>(variable_descriptor);
 	}
-	xfree((void**)&variable_descriptors);
-	xfree((void**)&responses);
+	xDelete<char*>(variable_descriptors);
+	xDelete<IssmDouble>(responses);
 
 	return 0;
Index: /issm/trunk/src/c/objects/DakotaPlugin.h
===================================================================
--- /issm/trunk/src/c/objects/DakotaPlugin.h	(revision 12705)
+++ /issm/trunk/src/c/objects/DakotaPlugin.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 
Index: /issm/trunk/src/c/objects/DofIndexing.cpp
===================================================================
--- /issm/trunk/src/c/objects/DofIndexing.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/DofIndexing.cpp	(revision 12706)
@@ -18,5 +18,5 @@
 
 /*DofIndexing constructors and destructor*/
-/*FUNCTION DofIndexing::DofIndexing(){{{1*/
+/*FUNCTION DofIndexing::DofIndexing(){{{*/
 DofIndexing::DofIndexing(){
 
@@ -35,10 +35,10 @@
 }
 /*}}}*/
-/*FUNCTION DofIndexing::DofIndexing(int gsize){{{1*/
+/*FUNCTION DofIndexing::DofIndexing(int gsize){{{*/
 DofIndexing::DofIndexing(int in_gsize){
 	this->Init(in_gsize,NULL);
 }
 /*}}}*/
-/*FUNCTION DofIndexing::DofIndexing(DofIndexing* in)  -> copy{{{1*/
+/*FUNCTION DofIndexing::DofIndexing(DofIndexing* in)  -> copy{{{*/
 DofIndexing::DofIndexing(DofIndexing* in){ //copy constructor
 
@@ -51,9 +51,9 @@
 
 	if(this->gsize>0){
-		this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool));
-		this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool));
-		this->svalues=(double*)xmalloc(this->gsize*sizeof(int));
-		if(in->doftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int)); 
-		this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int)); 
+		this->f_set=xNew<bool>(this->gsize);
+		this->s_set=xNew<bool>(this->gsize);
+		this->svalues=xNew<IssmDouble>(this->gsize);
+		if(in->doftype)this->doftype=xNew<int>(this->gsize); 
+		this->gdoflist=xNew<int>(this->gsize); 
 	}
 	else{
@@ -64,11 +64,11 @@
 		this->gdoflist=NULL;
 	}
-	if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=(int*)xmalloc(this->fsize*sizeof(int)); else this->fdoflist=NULL;
-	if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=(int*)xmalloc(this->ssize*sizeof(int)); else this->sdoflist=NULL;
+	if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL;
+	if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=xNew<int>(this->ssize); else this->sdoflist=NULL;
 
 	if(this->gsize>0){
 		memcpy(this->f_set,in->f_set,this->gsize*sizeof(bool));
 		memcpy(this->s_set,in->s_set,this->gsize*sizeof(bool));
-		memcpy(this->svalues,in->svalues,this->gsize*sizeof(double));
+		xMemCpy<IssmDouble>(this->svalues,in->svalues,this->gsize);
 		if(this->doftype)memcpy(this->doftype,in->doftype,this->gsize*sizeof(int));
 		memcpy(this->gdoflist,in->gdoflist,this->gsize*sizeof(int));
@@ -79,18 +79,18 @@
 }
 /*}}}*/
-/*FUNCTION DofIndexing::~DofIndexing() {{{1*/
+/*FUNCTION DofIndexing::~DofIndexing() {{{*/
 DofIndexing::~DofIndexing(){ //destructor
 
-	xfree((void**)&f_set); 
-	xfree((void**)&s_set); 
-	xfree((void**)&svalues);
-	xfree((void**)&doftype); 
-	xfree((void**)&gdoflist);
-	xfree((void**)&fdoflist);
-	xfree((void**)&sdoflist);
-
-}
-/*}}}*/
-/*FUNCTION DofIndexing::Init{{{1*/
+	xDelete<bool>(f_set); 
+	xDelete<bool>(s_set); 
+	xDelete<IssmDouble>(svalues);
+	xDelete<int>(doftype); 
+	xDelete<int>(gdoflist);
+	xDelete<int>(fdoflist);
+	xDelete<int>(sdoflist);
+
+}
+/*}}}*/
+/*FUNCTION DofIndexing::Init{{{*/
 void DofIndexing::Init(int in_gsize,int* in_doftype){
 
@@ -102,9 +102,9 @@
 	/*allocate: */
 	if(this->gsize>0){
-		this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool));
-		this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool));
-		this->svalues=(double*)xmalloc(this->gsize*sizeof(double));
-		if(in_doftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int));
-		this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int));
+		this->f_set=xNew<bool>(this->gsize);
+		this->s_set=xNew<bool>(this->gsize);
+		this->svalues=xNew<IssmDouble>(this->gsize);
+		if(in_doftype)this->doftype=xNew<int>(this->gsize);
+		this->gdoflist=xNew<int>(this->gsize);
 	}
 
@@ -119,5 +119,5 @@
 }
 /*}}}*/
-/*FUNCTION DofIndexing::InitSet{{{1*/
+/*FUNCTION DofIndexing::InitSet{{{*/
 void DofIndexing::InitSet(int setenum){
 
@@ -131,6 +131,6 @@
 		for(i=0;i<this->gsize;i++) if(f_set[i])size++;
 		this->fsize=size;
-		xfree((void**)&this->fdoflist);
-		if(this->fsize)this->fdoflist=(int*)xmalloc(size*sizeof(int));
+		xDelete<int>(this->fdoflist);
+		if(this->fsize)this->fdoflist=xNew<int>(size);
 		else this->fdoflist=NULL;
 	}
@@ -139,71 +139,71 @@
 		for(i=0;i<this->gsize;i++) if(s_set[i])size++;
 		this->ssize=size;
-		xfree((void**)&this->sdoflist);
-		if(this->ssize)this->sdoflist=(int*)xmalloc(size*sizeof(int));
+		xDelete<int>(this->sdoflist);
+		if(this->ssize)this->sdoflist=xNew<int>(size);
 		else this->sdoflist=NULL;
 	}
-	else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
+	else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
 }
 /*}}}*/
 
 /*Some of the Object functionality: */
-/*FUNCTION DofIndexing::Echo{{{1*/
+/*FUNCTION DofIndexing::Echo{{{*/
 void DofIndexing::Echo(void){
 
 	int i;
 
-	printf("DofIndexing:\n");
-	printf("   gsize: %i\n",gsize);
-	printf("   clone: %i\n",clone);
-}
-/*}}}*/
-/*FUNCTION DofIndexing::DeepEcho{{{1*/
+	_printLine_("DofIndexing:");
+	_printLine_("   gsize: " << gsize);
+	_printLine_("   clone: " << clone);
+}
+/*}}}*/
+/*FUNCTION DofIndexing::DeepEcho{{{*/
 void DofIndexing::DeepEcho(void){
 
 	int i;
 
-	printf("DofIndexing:\n");
-	printf("   gsize: %i\n",gsize);
-	printf("   fsize: %i\n",fsize);
-	printf("   ssize: %i\n",ssize);
-	printf("   clone: %i\n",clone);
+	_printLine_("DofIndexing:");
+	_printLine_("   gsize: " << gsize);
+	_printLine_("   fsize: " << fsize);
+	_printLine_("   ssize: " << ssize);
+	_printLine_("   clone: " << clone);
 	
-	printf("   set membership: f,s sets \n");
+	_printLine_("   set membership: f,s sets ");
 	for(i=0;i<gsize;i++){
-		printf("      dof %i: %s %s\n",i,f_set[i]?"true":"false",s_set[i]?"true":"false");
-	}
-
-	printf("   svalues (%i): |",this->ssize);
+		_printLine_("      dof " << i << ": " <<(f_set[i]?"true":"false")<< " " <<(s_set[i]?"true":"false"));
+	}
+
+	_printString_("   svalues (" << this->ssize << "): |");
 	for(i=0;i<this->gsize;i++){
-		if(this->s_set[i])printf(" %g |",svalues[i]);
-	}
-	printf("\n");
+		if(this->s_set[i])_printString_(" " << svalues[i] << " |");
+	}
+	_printLine_("");
 
 	if(doftype){
-		printf("   doftype: |");
+		_printString_("   doftype: |");
 		for(i=0;i<gsize;i++){
-			printf(" %i |",doftype[i]);
+			_printString_(" " << doftype[i] << " |");
 		}
-		printf("\n");
-	}
-	else printf("   doftype: NULL\n");
-
-	printf("   g_doflist (%i): |",this->gsize);
+		_printLine_("");
+	}
+	else _printLine_("   doftype: NULL");
+
+	_printString_("   g_doflist (" << this->gsize << "): |");
 	for(i=0;i<this->gsize;i++){
-		printf(" %i |",gdoflist[i]);
-	}
-	printf("\n");
-
-	printf("   f_doflist (%i): |",this->fsize);
+		_printString_(" " << gdoflist[i] << " |");
+	}
+	_printLine_("");
+
+	_printString_("   f_doflist (" << this->fsize << "): |");
 	for(i=0;i<this->fsize;i++){
-		printf(" %i |",fdoflist[i]);
-	}
-	printf("\n");
-
-	printf("   s_doflist (%i): |",this->ssize);
+		_printString_(" " << fdoflist[i] << " |");
+	}
+	_printLine_("");
+
+	_printString_("   s_doflist (" << this->ssize << "): |");
 	for(i=0;i<this->ssize;i++){
-		printf(" %i |",sdoflist[i]);
-	}
-	printf("\n");
+		_printString_(" " << sdoflist[i] << " |");
+	}
+	_printLine_("");
 }		
 /*}}}*/
Index: /issm/trunk/src/c/objects/DofIndexing.h
===================================================================
--- /issm/trunk/src/c/objects/DofIndexing.h	(revision 12705)
+++ /issm/trunk/src/c/objects/DofIndexing.h	(revision 12706)
@@ -34,5 +34,5 @@
 
 
-		/*DofIndexing constructors, destructors {{{1*/
+		/*DofIndexing constructors, destructors {{{*/
 		DofIndexing();
 		DofIndexing(int g_size);
@@ -42,10 +42,10 @@
 		~DofIndexing();
 		/*}}}*/
-		/*Object like functionality: {{{1*/
+		/*Object like functionality: {{{*/
 		void  Echo(void); 
 		void  DeepEcho(void); 
 		void  copy(DofIndexing* properties);
 		/*}}}*/
-		/*DofIndexing management: {{{1*/
+		/*DofIndexing management: {{{*/
 		DofIndexing* Spawn(int* indices, int numindices);
 		/*}}}*/
Index: /issm/trunk/src/c/objects/ElementResults/BoolElementResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/BoolElementResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/BoolElementResult.cpp	(revision 12706)
@@ -19,11 +19,11 @@
 
 /*BoolElementResult constructors and destructor*/
-/*FUNCTION BoolElementResult::BoolElementResult(){{{1*/
+/*FUNCTION BoolElementResult::BoolElementResult(){{{*/
 BoolElementResult::BoolElementResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::BoolElementResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){{{1*/
-BoolElementResult::BoolElementResult(int in_enum_type,bool in_value,int in_step, double in_time){
+/*FUNCTION BoolElementResult::BoolElementResult(int in_enum_type,IssmDouble in_value,int in_step, IssmDouble in_time){{{*/
+BoolElementResult::BoolElementResult(int in_enum_type,bool in_value,int in_step, IssmDouble in_time){
 
 	enum_type=in_enum_type;
@@ -33,5 +33,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::~BoolElementResult(){{{1*/
+/*FUNCTION BoolElementResult::~BoolElementResult(){{{*/
 BoolElementResult::~BoolElementResult(){
 	return;
@@ -40,23 +40,23 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION BoolElementResult::Echo {{{1*/
+/*FUNCTION BoolElementResult::Echo {{{*/
 void BoolElementResult::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::DeepEcho{{{1*/
+/*FUNCTION BoolElementResult::DeepEcho{{{*/
 void BoolElementResult::DeepEcho(void){
 
-	printf("BoolElementResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %s\n",this->value?"true":"false");
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("BoolElementResult:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: "<<(this->value?"true":"false"));
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::Id{{{1*/
+/*FUNCTION BoolElementResult::Id{{{*/
 int    BoolElementResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION BoolElementResult::MyRank{{{1*/
+/*FUNCTION BoolElementResult::MyRank{{{*/
 int    BoolElementResult::MyRank(void){ 
 	extern int my_rank;
@@ -64,5 +64,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::ObjectEnum{{{1*/
+/*FUNCTION BoolElementResult::ObjectEnum{{{*/
 int BoolElementResult::ObjectEnum(void){
 
@@ -71,5 +71,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::copy{{{1*/
+/*FUNCTION BoolElementResult::copy{{{*/
 Object* BoolElementResult::copy() {
 
@@ -80,5 +80,5 @@
 
 /*ElementResult management*/
-/*FUNCTION BoolElementResult::InstanceEnum{{{1*/
+/*FUNCTION BoolElementResult::InstanceEnum{{{*/
 int BoolElementResult::InstanceEnum(void){
 
@@ -87,5 +87,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::SpawnTriaElementResult{{{1*/
+/*FUNCTION BoolElementResult::SpawnTriaElementResult{{{*/
 ElementResult* BoolElementResult::SpawnTriaElementResult(int* indices){
 
@@ -104,17 +104,15 @@
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::ProcessUnits{{{1*/
+/*FUNCTION BoolElementResult::ProcessUnits{{{*/
 void BoolElementResult::ProcessUnits(Parameters* parameters){
-	
-	this->value=UnitConversion(this->value,IuToExtEnum,this->enum_type);
-
+// no op
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::NumberOfNodalValues{{{1*/
+/*FUNCTION BoolElementResult::NumberOfNodalValues{{{*/
 int BoolElementResult::NumberOfNodalValues(void){
 	return 1;
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::PatchFill{{{1*/
+/*FUNCTION BoolElementResult::PatchFill{{{*/
 void BoolElementResult::PatchFill(int row, Patch* patch){
 	
@@ -122,15 +120,15 @@
 	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
 	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
-	double doublevalue=this->value?1:0;
-	patch->fillresultinfo(row,this->enum_type,this->step,this->time,P0Enum,&doublevalue,1);
+	IssmDouble IssmDoublevalue=this->value?1:0;
+	patch->fillresultinfo(row,this->enum_type,this->step,this->time,P0Enum,&IssmDoublevalue,1);
 
 }
 /*}}}*/
-/*FUNCTION BoolElementResult::GetVectorFromResults{{{1*/
+/*FUNCTION BoolElementResult::GetVectorFromResults{{{*/
 void BoolElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
 
-	_error_("cannot return vector on vertices");
+	_error2_("cannot return vector on vertices");
 } /*}}}*/
-/*FUNCTION BoolElementResult::GetElementVectorFromResults{{{1*/
+/*FUNCTION BoolElementResult::GetElementVectorFromResults{{{*/
 void BoolElementResult::GetElementVectorFromResults(Vector* vector,int dof){
 
Index: /issm/trunk/src/c/objects/ElementResults/BoolElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/BoolElementResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/BoolElementResult.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Inputs/Input.h"
 #include "../../include/include.h"
@@ -21,14 +21,14 @@
 		bool   value;
 		int    step;
-		double time;
+		IssmDouble time;
 
 	public:
 
-		/*BoolElementResult constructors, destructors: {{{1*/
+		/*BoolElementResult constructors, destructors: {{{*/
 		BoolElementResult();
-		BoolElementResult(int enum_type,bool value,int step,double time);
+		BoolElementResult(int enum_type,bool value,int step,IssmDouble time);
 		~BoolElementResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -38,7 +38,7 @@
 		Object* copy();
 		/*}}}*/
-		/*ElementResult virtual functions definitions: {{{1*/
+		/*ElementResult virtual functions definitions: {{{*/
 		ElementResult* SpawnTriaElementResult(int* indices);
-		double  GetTime(void){return time;};
+		IssmDouble  GetTime(void){return time;};
 		int     GetStep(void){return step;};
 		void    ProcessUnits(Parameters* parameters);
@@ -46,5 +46,5 @@
 		void    PatchFill(int row, Patch* patch);
 		/*}}}*/
-		/*BoolElementResult management: {{{1*/
+		/*BoolElementResult management: {{{*/
 		int   InstanceEnum();
 		void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
Index: /issm/trunk/src/c/objects/ElementResults/DoubleElementResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/DoubleElementResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/DoubleElementResult.cpp	(revision 12706)
@@ -19,11 +19,11 @@
 
 /*DoubleElementResult constructors and destructor*/
-/*FUNCTION DoubleElementResult::DoubleElementResult(){{{1*/
+/*FUNCTION DoubleElementResult::DoubleElementResult(){{{*/
 DoubleElementResult::DoubleElementResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::DoubleElementResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){{{1*/
-DoubleElementResult::DoubleElementResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){
+/*FUNCTION DoubleElementResult::DoubleElementResult(int in_enum_type,IssmDouble in_value,int in_step, IssmDouble in_time){{{*/
+DoubleElementResult::DoubleElementResult(int in_enum_type,IssmDouble in_value,int in_step, IssmDouble in_time){
 
 	enum_type=in_enum_type;
@@ -33,5 +33,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::~DoubleElementResult(){{{1*/
+/*FUNCTION DoubleElementResult::~DoubleElementResult(){{{*/
 DoubleElementResult::~DoubleElementResult(){
 	return;
@@ -40,23 +40,23 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION DoubleElementResult::Echo {{{1*/
+/*FUNCTION DoubleElementResult::Echo {{{*/
 void DoubleElementResult::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::DeepEcho{{{1*/
+/*FUNCTION DoubleElementResult::DeepEcho{{{*/
 void DoubleElementResult::DeepEcho(void){
 
-	printf("DoubleElementResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %g\n",this->value);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("DoubleElementResult:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::Id{{{1*/
+/*FUNCTION DoubleElementResult::Id{{{*/
 int    DoubleElementResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleElementResult::MyRank{{{1*/
+/*FUNCTION DoubleElementResult::MyRank{{{*/
 int    DoubleElementResult::MyRank(void){ 
 	extern int my_rank;
@@ -64,5 +64,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::ObjectEnum{{{1*/
+/*FUNCTION DoubleElementResult::ObjectEnum{{{*/
 int DoubleElementResult::ObjectEnum(void){
 
@@ -71,5 +71,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::copy{{{1*/
+/*FUNCTION DoubleElementResult::copy{{{*/
 Object* DoubleElementResult::copy() {
 
@@ -80,5 +80,5 @@
 
 /*ElementResult management*/
-/*FUNCTION DoubleElementResult::InstanceEnum{{{1*/
+/*FUNCTION DoubleElementResult::InstanceEnum{{{*/
 int DoubleElementResult::InstanceEnum(void){
 
@@ -87,5 +87,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::SpawnTriaElementResult{{{1*/
+/*FUNCTION DoubleElementResult::SpawnTriaElementResult{{{*/
 ElementResult* DoubleElementResult::SpawnTriaElementResult(int* indices){
 
@@ -104,5 +104,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::ProcessUnits{{{1*/
+/*FUNCTION DoubleElementResult::ProcessUnits{{{*/
 void DoubleElementResult::ProcessUnits(Parameters* parameters){
 	
@@ -111,10 +111,10 @@
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::NumberOfNodalValues{{{1*/
+/*FUNCTION DoubleElementResult::NumberOfNodalValues{{{*/
 int DoubleElementResult::NumberOfNodalValues(void){
 	return 1;
 }
 /*}}}*/
-/*FUNCTION DoubleElementResult::PatchFill{{{1*/
+/*FUNCTION DoubleElementResult::PatchFill{{{*/
 void DoubleElementResult::PatchFill(int row, Patch* patch){
 	
Index: /issm/trunk/src/c/objects/ElementResults/DoubleElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/DoubleElementResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/DoubleElementResult.h	(revision 12706)
@@ -1,5 +1,5 @@
 /*! \file DoubleElementResult.h 
- *  \brief: header file for double result object
- *  A double result object is just derived from a DoubleInput object, with additional time and step information.
+ *  \brief: header file for IssmDouble result object
+ *  A IssmDouble result object is just derived from a DoubleInput object, with additional time and step information.
  */
 
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Inputs/Input.h"
 #include "../../include/include.h"
@@ -19,16 +19,16 @@
 	private: 
 		int    enum_type;
-		double value;
+		IssmDouble value;
 		int    step;
-		double time;
+		IssmDouble time;
 
 	public:
 
-		/*DoubleElementResult constructors, destructors: {{{1*/
+		/*DoubleElementResult constructors, destructors: {{{*/
 		DoubleElementResult();
-		DoubleElementResult(int enum_type,double value,int step,double time);
+		DoubleElementResult(int enum_type,IssmDouble value,int step,IssmDouble time);
 		~DoubleElementResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -38,7 +38,7 @@
 		Object* copy();
 		/*}}}*/
-		/*ElementResult virtual functions definitions: {{{1*/
+		/*ElementResult virtual functions definitions: {{{*/
 		ElementResult* SpawnTriaElementResult(int* indices);
-		double  GetTime(void){return time;};
+		IssmDouble  GetTime(void){return time;};
 		int     GetStep(void){return step;};
 		void    ProcessUnits(Parameters* parameters);
@@ -46,5 +46,5 @@
 		void    PatchFill(int row, Patch* patch);
 		/*}}}*/
-		/*DoubleElementResult management: {{{1*/
+		/*DoubleElementResult management: {{{*/
 		int   InstanceEnum();
 		void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
Index: /issm/trunk/src/c/objects/ElementResults/ElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/ElementResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/ElementResult.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Object.h"
 /*}}}*/
@@ -19,5 +19,5 @@
 		
 		virtual         ElementResult* SpawnTriaElementResult(int* indices)=0;
-		virtual double  GetTime(void)=0;
+		virtual IssmDouble  GetTime(void)=0;
 		virtual int     GetStep(void)=0;
 		virtual void    ProcessUnits(Parameters* parameters)=0;
Index: /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.cpp	(revision 12706)
@@ -19,11 +19,11 @@
 
 /*PentaP1ElementResult constructors and destructor*/
-/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(){{{1*/
+/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(){{{*/
 PentaP1ElementResult::PentaP1ElementResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
-PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
+/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){{{*/
+PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){
 
 	int i;
@@ -35,5 +35,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::~PentaP1ElementResult(){{{1*/
+/*FUNCTION PentaP1ElementResult::~PentaP1ElementResult(){{{*/
 PentaP1ElementResult::~PentaP1ElementResult(){
 	return;
@@ -42,24 +42,24 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION PentaP1ElementResult::Echo {{{1*/
+/*FUNCTION PentaP1ElementResult::Echo {{{*/
 void PentaP1ElementResult::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::DeepEcho{{{1*/
+/*FUNCTION PentaP1ElementResult::DeepEcho{{{*/
 void PentaP1ElementResult::DeepEcho(void){
 
-	printf("PentaP1ElementResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("PentaP1ElementResult:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << " " << this->values[3] << " " << this->values[4] << " " << this->values[5] << "]");
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::Id{{{1*/
+/*FUNCTION PentaP1ElementResult::Id{{{*/
 int    PentaP1ElementResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::MyRank{{{1*/
+/*FUNCTION PentaP1ElementResult::MyRank{{{*/
 int    PentaP1ElementResult::MyRank(void){ 
 	extern int my_rank;
@@ -67,5 +67,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::ObjectEnum{{{1*/
+/*FUNCTION PentaP1ElementResult::ObjectEnum{{{*/
 int PentaP1ElementResult::ObjectEnum(void){
 
@@ -74,5 +74,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::copy{{{1*/
+/*FUNCTION PentaP1ElementResult::copy{{{*/
 Object* PentaP1ElementResult::copy() {
 	
@@ -83,5 +83,5 @@
 
 /*ElementResult management*/
-/*FUNCTION PentaP1ElementResult::InstanceEnum{{{1*/
+/*FUNCTION PentaP1ElementResult::InstanceEnum{{{*/
 int PentaP1ElementResult::InstanceEnum(void){
 
@@ -90,10 +90,10 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::SpawnTriaElementResult{{{1*/
+/*FUNCTION PentaP1ElementResult::SpawnTriaElementResult{{{*/
 ElementResult* PentaP1ElementResult::SpawnTriaElementResult(int* indices){
 
 	/*output*/
 	TriaP1ElementResult* outresult=NULL;
-	double newvalues[3];
+	IssmDouble newvalues[3];
 
 	/*Loop over the new indices*/
@@ -115,5 +115,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::ProcessUnits{{{1*/
+/*FUNCTION PentaP1ElementResult::ProcessUnits{{{*/
 void PentaP1ElementResult::ProcessUnits(Parameters* parameters){
 	
@@ -122,10 +122,10 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::NumberOfNodalValues{{{1*/
+/*FUNCTION PentaP1ElementResult::NumberOfNodalValues{{{*/
 int PentaP1ElementResult::NumberOfNodalValues(void){
 	return 6;
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::PatchFill{{{1*/
+/*FUNCTION PentaP1ElementResult::PatchFill{{{*/
 void PentaP1ElementResult::PatchFill(int row, Patch* patch){
 	
@@ -137,17 +137,17 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::GetVectorFromResults{{{1*/
+/*FUNCTION PentaP1ElementResult::GetVectorFromResults{{{*/
 void PentaP1ElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
 
-	double data[6];
+	IssmDouble data[6];
 
-	if(numdofs!=6)_error_("Result %s is a PentaP1ElementResult and cannot write vector of %i dofs",numdofs);
-	for(int i=0;i<6;i++) data[i]=this->values[i]/(double)connectivitylist[i];
+	if(numdofs!=6)_error2_("Result " << EnumToStringx(this->enum_type) << " is a PentaP1ElementResult and cannot write vector of " << numdofs << " dofs");
+	for(int i=0;i<6;i++) data[i]=this->values[i]/(IssmDouble)connectivitylist[i];
 	vector->SetValues(numdofs,doflist,&data[0],ADD_VAL);
 
 } /*}}}*/
-/*FUNCTION PentaP1ElementResult::GetElementVectorFromResults{{{1*/
+/*FUNCTION PentaP1ElementResult::GetElementVectorFromResults{{{*/
 void PentaP1ElementResult::GetElementVectorFromResults(Vector* vector,int dof){
 
-	_error_("Result %s is a PentaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
+	_error2_("Result " << EnumToStringx(enum_type) << " is a PentaP1ElementResult and should not write vector of size numberofelemenrs");
 } /*}}}*/
Index: /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/PentaP1ElementResult.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Inputs/Input.h"
 #include "../../include/include.h"
@@ -18,16 +18,16 @@
 	private: 
 		int    enum_type;
-		double values[6];
+		IssmDouble values[6];
 		int    step;
-		double time;
+		IssmDouble time;
 
 	public:
 
-		/*PentaP1ElementResult constructors, destructors: {{{1*/
+		/*PentaP1ElementResult constructors, destructors: {{{*/
 		PentaP1ElementResult();
-		PentaP1ElementResult(int enum_type,double* values,int step, double time);
+		PentaP1ElementResult(int enum_type,IssmDouble* values,int step, IssmDouble time);
 		~PentaP1ElementResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -37,7 +37,7 @@
 		Object* copy();
 		/*}}}*/
-		/*ElementResult virtual functions definitions: {{{1*/
+		/*ElementResult virtual functions definitions: {{{*/
 		ElementResult* SpawnTriaElementResult(int* indices);
-		double  GetTime(void){return time;};
+		IssmDouble  GetTime(void){return time;};
 		int     GetStep(void){return step;};
 		void    ProcessUnits(Parameters* parameters);
@@ -45,5 +45,5 @@
 		void    PatchFill(int row, Patch* patch);
 		/*}}}*/
-		/*PentaP1ElementResult management: {{{1*/
+		/*PentaP1ElementResult management: {{{*/
 		int   InstanceEnum();
 		void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
Index: /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.cpp	(revision 12706)
@@ -19,11 +19,11 @@
 
 /*TriaP1ElementResult constructors and destructor*/
-/*FUNCTION TriaP1ElementResult::TriaP1ElementResult(){{{1*/
+/*FUNCTION TriaP1ElementResult::TriaP1ElementResult(){{{*/
 TriaP1ElementResult::TriaP1ElementResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
-TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
+/*FUNCTION TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){{{*/
+TriaP1ElementResult::TriaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){
 
 	enum_type=in_enum_type;
@@ -35,5 +35,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::~TriaP1ElementResult(){{{1*/
+/*FUNCTION TriaP1ElementResult::~TriaP1ElementResult(){{{*/
 TriaP1ElementResult::~TriaP1ElementResult(){
 	return;
@@ -42,23 +42,23 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION TriaP1ElementResult::Echo {{{1*/
+/*FUNCTION TriaP1ElementResult::Echo {{{*/
 void TriaP1ElementResult::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::DeepEcho{{{1*/
+/*FUNCTION TriaP1ElementResult::DeepEcho{{{*/
 void TriaP1ElementResult::DeepEcho(void){
 		
-	printf("TriaP1ElementResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("TriaP1ElementResult:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << "]");
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::Id{{{1*/
+/*FUNCTION TriaP1ElementResult::Id{{{*/
 int    TriaP1ElementResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::MyRank{{{1*/
+/*FUNCTION TriaP1ElementResult::MyRank{{{*/
 int    TriaP1ElementResult::MyRank(void){ 
 	extern int my_rank;
@@ -66,5 +66,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::ObjectEnum{{{1*/
+/*FUNCTION TriaP1ElementResult::ObjectEnum{{{*/
 int TriaP1ElementResult::ObjectEnum(void){
 
@@ -73,5 +73,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::copy{{{1*/
+/*FUNCTION TriaP1ElementResult::copy{{{*/
 Object* TriaP1ElementResult::copy() {
 	
@@ -82,5 +82,5 @@
 
 /*ElementResult management*/
-/*FUNCTION TriaP1ElementResult::InstanceEnum{{{1*/
+/*FUNCTION TriaP1ElementResult::InstanceEnum{{{*/
 int TriaP1ElementResult::InstanceEnum(void){
 
@@ -89,5 +89,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::SpawnTriaElementResult{{{1*/
+/*FUNCTION TriaP1ElementResult::SpawnTriaElementResult{{{*/
 ElementResult* TriaP1ElementResult::SpawnTriaElementResult(int* indices){
 
@@ -103,5 +103,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::ProcessUnits{{{1*/
+/*FUNCTION TriaP1ElementResult::ProcessUnits{{{*/
 void TriaP1ElementResult::ProcessUnits(Parameters* parameters){
 	
@@ -110,10 +110,10 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::NumberOfNodalValues{{{1*/
+/*FUNCTION TriaP1ElementResult::NumberOfNodalValues{{{*/
 int TriaP1ElementResult::NumberOfNodalValues(void){
 	return 3;
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::PatchFill{{{1*/
+/*FUNCTION TriaP1ElementResult::PatchFill{{{*/
 void TriaP1ElementResult::PatchFill(int row, Patch* patch){
 	
@@ -125,16 +125,16 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::GetVectorFromResults{{{1*/
+/*FUNCTION TriaP1ElementResult::GetVectorFromResults{{{*/
 void TriaP1ElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
 
-	double data[3];
+	IssmDouble data[3];
 
-	if(numdofs!=3)_error_("Result %s is a TriaP1ElementResult and cannot write vector of %i dofs",numdofs);
-	for(int i=0;i<3;i++) data[i]=this->values[i]/(double)connectivitylist[i];
+	if(numdofs!=3)_error2_("Result " << EnumToStringx(this->enum_type) << " is a TriaP1ElementResult and cannot write vector of " << numdofs << " dofs");
+	for(int i=0;i<3;i++) data[i]=this->values[i]/(IssmDouble)connectivitylist[i];
 	vector->SetValues(numdofs,doflist,&data[0],ADD_VAL);
 
 } /*}}}*/
-/*FUNCTION TriaP1ElementResult::GetElementVectorFromResults{{{1*/
+/*FUNCTION TriaP1ElementResult::GetElementVectorFromResults{{{*/
 void TriaP1ElementResult::GetElementVectorFromResults(Vector* vector,int dof){
-	_error_("Result %s is a TriaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
+	_error2_("Result " << EnumToStringx(enum_type) << " is a TriaP1ElementResult and should not write vector of size numberofelemenrs");
 } /*}}}*/
Index: /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.h
===================================================================
--- /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ElementResults/TriaP1ElementResult.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Inputs/Input.h"
 #include "../../include/include.h"
@@ -17,16 +17,16 @@
 	private: 
 		int    enum_type;
-		double values[3];
+		IssmDouble values[3];
 		int    step;
-		double time;
+		IssmDouble time;
 
 	public:
 
-		/*TriaP1ElementResult constructors, destructors: {{{1*/
+		/*TriaP1ElementResult constructors, destructors: {{{*/
 		TriaP1ElementResult();
-		TriaP1ElementResult(int enum_type,double* values,int step,double time);
+		TriaP1ElementResult(int enum_type,IssmDouble* values,int step,IssmDouble time);
 		~TriaP1ElementResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -36,7 +36,7 @@
 		Object* copy();
 		/*}}}*/
-		/*ElementResult virtual functions definitions: {{{1*/
+		/*ElementResult virtual functions definitions: {{{*/
 		ElementResult* SpawnTriaElementResult(int* indices);
-		double  GetTime(void){return time;};
+		IssmDouble  GetTime(void){return time;};
 		int     GetStep(void){return step;};
 		void    ProcessUnits(Parameters* parameters);
@@ -44,5 +44,5 @@
 		void    PatchFill(int row, Patch* patch);
 		/*}}}*/
-		/*TriaP1ElementResult management: {{{1*/
+		/*TriaP1ElementResult management: {{{*/
 		int   InstanceEnum();
 		void GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs);
Index: /issm/trunk/src/c/objects/Elements/Element.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Element.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/Element.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Object.h"
 
@@ -38,11 +38,11 @@
 		virtual bool   IsFloating()=0; 
 		virtual bool   IsNodeOnShelf()=0; 
-		virtual bool   IsNodeOnShelfFromFlags(double* flags)=0; 
+		virtual bool   IsNodeOnShelfFromFlags(IssmDouble* flags)=0; 
 		virtual bool   IsOnBed()=0;
-		virtual void   GetInputListOnVertices(double* pvalue,int enumtype)=0;
-		virtual void   GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue)=0;
-		virtual void   GetInputValue(double* pvalue,Node* node,int enumtype)=0;
+		virtual void   GetInputListOnVertices(IssmDouble* pvalue,int enumtype)=0;
+		virtual void   GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue)=0;
+		virtual void   GetInputValue(IssmDouble* pvalue,Node* node,int enumtype)=0;
 		
-		virtual double SurfaceArea(void)=0;
+		virtual IssmDouble SurfaceArea(void)=0;
 		virtual void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum)=0;
 		virtual void   ComputeBasalStress(Vector* sigma_b)=0;
@@ -50,64 +50,65 @@
 		virtual void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes)=0;
 		virtual void   PatchFill(int* pcount, Patch* patch)=0;
-		virtual void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results)=0;
+		virtual void   ListResultsInfo(int** results_enums,int** results_size,IssmDouble** results_times,int** results_steps,int* num_results)=0;
 		virtual void   DeleteResults(void)=0;
 		virtual void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type)=0;
-		virtual void   InputToResult(int enum_type,int step,double time)=0;
+		virtual void   InputToResult(int enum_type,int step,IssmDouble time)=0;
 		virtual void   InputDuplicate(int original_enum,int new_enum)=0;
-		virtual void   InputCreate(double scalar,int name,int code)=0;
-		virtual void   InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code)=0;
+		virtual void   InputCreate(IssmDouble scalar,int name,int code)=0;
+		virtual void   InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code)=0;
 		virtual void   ProcessResultsUnits(void)=0;
-		virtual void   RequestedOutput(int output_enum,int step,double time)=0;
+		virtual void   RequestedOutput(int output_enum,int step,IssmDouble time)=0;
 		
-		virtual int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units)=0;
-		virtual void   InputScale(int enum_type,double scale_factor)=0;
+		virtual int    NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units)=0;
+		virtual void   InputScale(int enum_type,IssmDouble scale_factor)=0;
 		virtual void   GetVectorFromInputs(Vector* vector, int name_enum)=0;
 		virtual void   GetVectorFromResults(Vector* vector,int id,int enum_in,int interp)=0;
-		virtual void   InputArtificialNoise(int enum_type,double min,double max)=0;
-		virtual bool   InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums)=0;
-		virtual void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part)=0;
+		virtual void   InputArtificialNoise(int enum_type,IssmDouble min,IssmDouble max)=0;
+		virtual bool   InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums)=0;
+		virtual void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part)=0;
 		virtual int*   GetHorizontalNeighboorSids(void)=0;
-		virtual double TimeAdapt()=0;
-		virtual void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding)=0;
+		virtual IssmDouble TimeAdapt()=0;
+		virtual void   MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding)=0;
 		virtual void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding)=0;
-		virtual void   PositiveDegreeDay(double* pdds,double* pds,double signorm)=0;
-		virtual int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf)=0;
+		virtual void   PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm)=0;
+		virtual void   SmbGradients()=0;
+		virtual int    UpdatePotentialSheetUngrounding(IssmDouble* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf)=0;
 		virtual void   ResetCoordinateSystem()=0;
-		virtual void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius)=0;
+		virtual void   SmearFunction(Vector* smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius)=0;
 
 		#ifdef _HAVE_RESPONSES_
-		virtual void   MinVel(double* pminvel, bool process_units)=0;
-		virtual void   MaxVel(double* pmaxvel, bool process_units)=0;
-		virtual void   MinVx(double* pminvx, bool process_units)=0;
-		virtual void   MaxVx(double* pmaxvx, bool process_units)=0;
-		virtual void   MaxAbsVx(double* pmaxabsvx, bool process_units)=0;
-		virtual void   MinVy(double* pminvy, bool process_units)=0;
-		virtual void   MaxVy(double* pmaxvy, bool process_units)=0;
-		virtual void   MaxAbsVy(double* pmaxabsvy, bool process_units)=0;
-		virtual void   MinVz(double* pminvz, bool process_units)=0;
-		virtual void   MaxVz(double* pmaxvz, bool process_units)=0;
-		virtual void   MaxAbsVz(double* pmaxabsvz, bool process_units)=0;
-		virtual double MassFlux(double* segment,bool process_units)=0;
-		virtual void   ElementResponse(double* presponse,int response_enum,bool process_units)=0;
-		virtual double IceVolume(void)=0;
+		virtual void   MinVel(IssmDouble* pminvel, bool process_units)=0;
+		virtual void   MaxVel(IssmDouble* pmaxvel, bool process_units)=0;
+		virtual void   MinVx(IssmDouble* pminvx, bool process_units)=0;
+		virtual void   MaxVx(IssmDouble* pmaxvx, bool process_units)=0;
+		virtual void   MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units)=0;
+		virtual void   MinVy(IssmDouble* pminvy, bool process_units)=0;
+		virtual void   MaxVy(IssmDouble* pmaxvy, bool process_units)=0;
+		virtual void   MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units)=0;
+		virtual void   MinVz(IssmDouble* pminvz, bool process_units)=0;
+		virtual void   MaxVz(IssmDouble* pmaxvz, bool process_units)=0;
+		virtual void   MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units)=0;
+		virtual IssmDouble MassFlux(IssmDouble* segment,bool process_units)=0;
+		virtual void   ElementResponse(IssmDouble* presponse,int response_enum,bool process_units)=0;
+		virtual IssmDouble IceVolume(void)=0;
 		#endif
 
 		#ifdef _HAVE_CONTROL_
 		virtual void   Gradj(Vector* gradient,int control_type,int control_index)=0;
-		virtual double ThicknessAbsMisfit(bool process_units  ,int weight_index)=0;
-		virtual double SurfaceAbsVelMisfit(bool process_units ,int weight_index)=0;
-		virtual double SurfaceRelVelMisfit(bool process_units ,int weight_index)=0;
-		virtual double SurfaceLogVelMisfit(bool process_units ,int weight_index)=0;
-		virtual double SurfaceLogVxVyMisfit(bool process_units,int weight_index)=0;
-		virtual double SurfaceAverageVelMisfit(bool process_units,int weight_index)=0;
-		virtual double ThicknessAbsGradient(bool process_units,int weight_index)=0;
-		virtual double RheologyBbarAbsGradient(bool process_units,int weight_index)=0;
-		virtual double DragCoefficientAbsGradient(bool process_units,int weight_index)=0;
+		virtual IssmDouble ThicknessAbsMisfit(bool process_units  ,int weight_index)=0;
+		virtual IssmDouble SurfaceAbsVelMisfit(bool process_units ,int weight_index)=0;
+		virtual IssmDouble SurfaceRelVelMisfit(bool process_units ,int weight_index)=0;
+		virtual IssmDouble SurfaceLogVelMisfit(bool process_units ,int weight_index)=0;
+		virtual IssmDouble SurfaceLogVxVyMisfit(bool process_units,int weight_index)=0;
+		virtual IssmDouble SurfaceAverageVelMisfit(bool process_units,int weight_index)=0;
+		virtual IssmDouble ThicknessAbsGradient(bool process_units,int weight_index)=0;
+		virtual IssmDouble RheologyBbarAbsGradient(bool process_units,int weight_index)=0;
+		virtual IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index)=0;
 		virtual void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index)=0;
-		virtual void   ControlInputSetGradient(double* gradient,int enum_type,int control_index)=0;
-		virtual void   ControlInputScaleGradient(int enum_type, double scale)=0;
+		virtual void   ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index)=0;
+		virtual void   ControlInputScaleGradient(int enum_type, IssmDouble scale)=0;
 		virtual void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data)=0;
-		virtual void   SetControlInputsFromVector(double* vector,int control_enum,int control_index)=0;
-		virtual void   InputControlUpdate(double scalar,bool save_parameter)=0;
+		virtual void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index)=0;
+		virtual void   InputControlUpdate(IssmDouble scalar,bool save_parameter)=0;
 		#endif
 };
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -24,5 +24,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION Penta::Penta(){{{1*/
+/*FUNCTION Penta::Penta(){{{*/
 Penta::Penta(){
 
@@ -39,5 +39,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::~Penta(){{{1*/
+/*FUNCTION Penta::~Penta(){{{*/
 Penta::~Penta(){
 	delete inputs;
@@ -46,5 +46,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::Penta(int id, int index, IoModel* iomodel,int nummodels) {{{1*/
+/*FUNCTION Penta::Penta(int id, int index, IoModel* iomodel,int nummodels) {{{*/
 Penta::Penta(int penta_id, int penta_sid, int index, IoModel* iomodel,int nummodels)
 	:PentaRef(nummodels)
@@ -56,5 +56,5 @@
 
 	/*Checks in debugging mode*/
-	/*{{{2*/
+	/*{{{*/
 	_assert_(iomodel->Data(MeshUpperelementsEnum));
 	_assert_(iomodel->Data(MeshLowerelementsEnum));
@@ -66,7 +66,7 @@
 
 	/*Build neighbors list*/
-	if (isnan(iomodel->Data(MeshUpperelementsEnum)[index])) penta_elements_ids[1]=this->id; //upper penta is the same penta
+	if (xIsNan<IssmDouble>(iomodel->Data(MeshUpperelementsEnum)[index])) penta_elements_ids[1]=this->id; //upper penta is the same penta
 	else                                    penta_elements_ids[1]=(int)(iomodel->Data(MeshUpperelementsEnum)[index]);
-	if (isnan(iomodel->Data(MeshLowerelementsEnum)[index])) penta_elements_ids[0]=this->id; //lower penta is the same penta
+	if (xIsNan<IssmDouble>(iomodel->Data(MeshLowerelementsEnum)[index])) penta_elements_ids[0]=this->id; //lower penta is the same penta
 	else                                    penta_elements_ids[0]=(int)(iomodel->Data(MeshLowerelementsEnum)[index]);
 	this->InitHookNeighbors(penta_elements_ids);
@@ -90,5 +90,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::copy {{{1*/
+/*FUNCTION Penta::copy {{{*/
 Object* Penta::copy() {
 
@@ -100,5 +100,5 @@
 
 	//deal with PentaRef mother class
-	penta->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
+	penta->element_type_list=xNew<int>(this->numanalyses);
 	for(i=0;i<this->numanalyses;i++) penta->element_type_list[i]=this->element_type_list[i];
 
@@ -130,5 +130,5 @@
 
 	/*recover objects: */
-	penta->nodes=(Node**)xmalloc(6*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
+	penta->nodes=xNew<Node*>(6); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
 	for(i=0;i<6;i++)penta->nodes[i]=this->nodes[i];
 	penta->matice=(Matice*)penta->hmatice->delivers();
@@ -144,16 +144,16 @@
 
 /*Other*/
-/*FUNCTION Penta::AverageOntoPartition {{{1*/
-void  Penta::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part){
-	_error_("Not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Penta::BedNormal {{{1*/
-void Penta::BedNormal(double* bed_normal, double xyz_list[3][3]){
+/*FUNCTION Penta::AverageOntoPartition {{{*/
+void  Penta::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){
+	_error2_("Not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Penta::BedNormal {{{*/
+void Penta::BedNormal(IssmDouble* bed_normal, IssmDouble xyz_list[3][3]){
 
 	int i;
-	double v13[3],v23[3];
-	double normal[3];
-	double normal_norm;
+	IssmDouble v13[3],v23[3];
+	IssmDouble normal[3];
+	IssmDouble normal_norm;
 
 	for (i=0;i<3;i++){
@@ -173,5 +173,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::BasalFrictionCreateInput {{{1*/
+/*FUNCTION Penta::BasalFrictionCreateInput {{{*/
 void Penta::BasalFrictionCreateInput(void){
 
@@ -181,6 +181,6 @@
 	/*Intermediaries */
 	int    count,ig;
-	double basalfriction[NUMVERTICES]={0,0,0,0,0,0};
-	double alpha2,vx,vy;
+	IssmDouble basalfriction[NUMVERTICES]={0,0,0,0,0,0};
+	IssmDouble alpha2,vx,vy;
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
@@ -225,5 +225,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ComputeBasalStress {{{1*/
+/*FUNCTION Penta::ComputeBasalStress {{{*/
 void  Penta::ComputeBasalStress(Vector* sigma_b){
 
@@ -233,16 +233,16 @@
 	int         analysis_type,approximation;
 	int         doflist[NUMVERTICES];
-	double      xyz_list[NUMVERTICES][3];
-	double      xyz_list_tria[3][3];
-	double      rho_ice,gravity,stokesreconditioning;
-	double      pressure,viscosity,bed,Jdet2d;
-	double      bed_normal[3];
-	double      basalforce[3];
-	double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double      devstresstensor[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double      stresstensor[6]={0.0};
-	double      sigma_xx,sigma_yy,sigma_zz;
-	double      sigma_xy,sigma_xz,sigma_yz;
-	double      surface=0,value=0;
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      xyz_list_tria[3][3];
+	IssmDouble      rho_ice,gravity,stokesreconditioning;
+	IssmDouble      pressure,viscosity,bed,Jdet2d;
+	IssmDouble      bed_normal[3];
+	IssmDouble      basalforce[3];
+	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble      devstresstensor[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble      stresstensor[6]={0.0};
+	IssmDouble      sigma_xx,sigma_yy,sigma_zz;
+	IssmDouble      sigma_xy,sigma_xz,sigma_yz;
+	IssmDouble      surface=0,value=0;
 	GaussPenta* gauss;
 
@@ -252,6 +252,6 @@
 
 	/*Check analysis_types*/
-	if (analysis_type!=DiagnosticHorizAnalysisEnum) _error_("Not supported yet!");
-	if (approximation!=StokesApproximationEnum) _error_("Not supported yet!");
+	if (analysis_type!=DiagnosticHorizAnalysisEnum) _error2_("Not supported yet!");
+	if (approximation!=StokesApproximationEnum) _error2_("Not supported yet!");
 
 	/*retrieve some parameters: */
@@ -315,24 +315,24 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ComputeStrainRate {{{1*/
+/*FUNCTION Penta::ComputeStrainRate {{{*/
 void  Penta::ComputeStrainRate(Vector* eps){
 
-	_error_("Not implemented yet");
-
-}
-/*}}}*/
-/*FUNCTION Penta::ComputeStressTensor {{{1*/
+	_error2_("Not implemented yet");
+
+}
+/*}}}*/
+/*FUNCTION Penta::ComputeStressTensor {{{*/
 void  Penta::ComputeStressTensor(){
 
 	int         iv;
-	double      xyz_list[NUMVERTICES][3];
-	double      pressure,viscosity;
-	double      epsilon[6]; /* epsilon=[exx,eyy,exy];*/
-	double      sigma_xx[NUMVERTICES];
-	double		sigma_yy[NUMVERTICES];
-	double		sigma_zz[NUMVERTICES];
-	double      sigma_xy[NUMVERTICES];
-	double		sigma_xz[NUMVERTICES];
-	double		sigma_yz[NUMVERTICES];
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      pressure,viscosity;
+	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,exy];*/
+	IssmDouble      sigma_xx[NUMVERTICES];
+	IssmDouble		sigma_yy[NUMVERTICES];
+	IssmDouble		sigma_zz[NUMVERTICES];
+	IssmDouble      sigma_xy[NUMVERTICES];
+	IssmDouble		sigma_xz[NUMVERTICES];
+	IssmDouble		sigma_yz[NUMVERTICES];
 	GaussPenta* gauss=NULL;
 
@@ -377,5 +377,5 @@
 }
 /*}}}*/
-		/*FUNCTION Penta::Configure {{{1*/
+		/*FUNCTION Penta::Configure {{{*/
 void  Penta::Configure(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
 
@@ -409,5 +409,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrix {{{1*/
+/*FUNCTION Penta::CreateKMatrix {{{*/
 void  Penta::CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df){
 
@@ -418,5 +418,5 @@
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 
-	/*Checks in debugging {{{2*/
+	/*Checks in debugging {{{*/
 	_assert_(this->nodes && this->matice && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
 	/*}}}*/
@@ -464,5 +464,5 @@
 		#endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -479,5 +479,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixPrognostic {{{1*/
+/*FUNCTION Penta::CreateKMatrixPrognostic {{{*/
 ElementMatrix* Penta::CreateKMatrixPrognostic(void){
 
@@ -500,5 +500,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixSlope {{{1*/
+/*FUNCTION Penta::CreateKMatrixSlope {{{*/
 ElementMatrix* Penta::CreateKMatrixSlope(void){
 
@@ -513,5 +513,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVector {{{1*/
+/*FUNCTION Penta::CreatePVector {{{*/
 void  Penta::CreatePVector(Vector* pf){
 
@@ -521,5 +521,5 @@
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 
-	/*if debugging mode, check that all pointers exist {{{2*/
+	/*if debugging mode, check that all pointers exist {{{*/
 	_assert_(this->nodes && this->matice && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
 	/*}}}*/
@@ -569,5 +569,5 @@
 		#endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -579,5 +579,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorPrognostic {{{1*/
+/*FUNCTION Penta::CreatePVectorPrognostic {{{*/
 ElementVector* Penta::CreatePVectorPrognostic(void){
 
@@ -601,5 +601,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorSlope {{{1*/
+/*FUNCTION Penta::CreatePVectorSlope {{{*/
 ElementVector* Penta::CreatePVectorSlope(void){
 
@@ -615,5 +615,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateJacobianMatrix{{{1*/
+/*FUNCTION Penta::CreateJacobianMatrix{{{*/
 void  Penta::CreateJacobianMatrix(Matrix* Jff){
 
@@ -623,5 +623,5 @@
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 
-	/*Checks in debugging {{{2*/
+	/*Checks in debugging {{{*/
 	_assert_(this->nodes && this->matice && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
 	/*}}}*/
@@ -638,5 +638,5 @@
 #endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -648,11 +648,11 @@
 }
 /*}}}*/
-/*FUNCTION Penta::DeepEcho{{{1*/
+/*FUNCTION Penta::DeepEcho{{{*/
 void Penta::DeepEcho(void){
 
 	int i;
 	
-	printf("Penta:\n");
-	printf("   id: %i\n",id);
+	_printLine_("Penta:");
+	_printLine_("   id: " << id);
 	nodes[0]->DeepEcho();
 	nodes[1]->DeepEcho();
@@ -663,18 +663,18 @@
 	matice->DeepEcho();
 	matpar->DeepEcho();
-	printf("   neighbor ids: %i-%i\n",verticalneighbors[0]->Id(),verticalneighbors[1]->Id());
-	printf("   parameters\n");
+	_printLine_("   neighbor ids: " << verticalneighbors[0]->Id() << "-" << verticalneighbors[1]->Id());
+	_printLine_("   parameters");
 	parameters->DeepEcho();
-	printf("   inputs\n");
+	_printLine_("   inputs");
 	inputs->DeepEcho();
-	printf("   results\n");
+	_printLine_("   results");
 	results->DeepEcho();
-	printf("neighboor sids: \n");
-	printf(" %i %i %i\n",horizontalneighborsids[0],horizontalneighborsids[1],horizontalneighborsids[2]);
+	_printLine_("neighboor sids: ");
+	_printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]);
 
 	return;
 }
 /*}}}*/
-/*FUNCTION Penta::DeleteResults {{{1*/
+/*FUNCTION Penta::DeleteResults {{{*/
 void  Penta::DeleteResults(void){
 
@@ -685,5 +685,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::Echo{{{1*/
+/*FUNCTION Penta::Echo{{{*/
 
 void Penta::Echo(void){
@@ -691,5 +691,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ObjectEnum{{{1*/
+/*FUNCTION Penta::ObjectEnum{{{*/
 int Penta::ObjectEnum(void){
 
@@ -698,5 +698,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetBasalElement{{{1*/
+/*FUNCTION Penta::GetBasalElement{{{*/
 Penta* Penta::GetBasalElement(void){
 
@@ -719,5 +719,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetDofList {{{1*/
+/*FUNCTION Penta::GetDofList {{{*/
 void  Penta::GetDofList(int** pdoflist,int approximation_enum,int setenum){
 
@@ -730,5 +730,5 @@
 
 	/*Allocate: */
-	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+	doflist=xNew<int>(numberofdofs);
 
 	/*Populate: */
@@ -743,5 +743,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetDofList1 {{{1*/
+/*FUNCTION Penta::GetDofList1 {{{*/
 void  Penta::GetDofList1(int* doflist){
 
@@ -751,10 +751,10 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetConnectivityList {{{1*/
+/*FUNCTION Penta::GetConnectivityList {{{*/
 void  Penta::GetConnectivityList(int* connectivity){
 	for(int i=0;i<NUMVERTICES;i++) connectivity[i]=nodes[i]->GetConnectivity();
 }
 /*}}}*/
-/*FUNCTION Penta::GetElementType {{{1*/
+/*FUNCTION Penta::GetElementType {{{*/
 int Penta::GetElementType(){
 
@@ -763,10 +763,10 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetElementSizes{{{1*/
-void Penta::GetElementSizes(double* hx,double* hy,double* hz){
-
-	double xyz_list[NUMVERTICES][3];
-	double xmin,ymin,zmin;
-	double xmax,ymax,zmax;
+/*FUNCTION Penta::GetElementSizes{{{*/
+void Penta::GetElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){
+
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xmin,ymin,zmin;
+	IssmDouble xmax,ymax,zmax;
 
 	/*Get xyz list: */
@@ -790,5 +790,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetHorizontalNeighboorSids {{{1*/
+/*FUNCTION Penta::GetHorizontalNeighboorSids {{{*/
 int* Penta::GetHorizontalNeighboorSids(){
 
@@ -798,5 +798,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetLowerElement{{{1*/
+/*FUNCTION Penta::GetLowerElement{{{*/
 Penta* Penta::GetLowerElement(void){
 
@@ -808,5 +808,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetNodeIndex {{{1*/
+/*FUNCTION Penta::GetNodeIndex {{{*/
 int Penta::GetNodeIndex(Node* node){
 
@@ -816,18 +816,18 @@
 		 return i;
 	}
-	_error_("Node provided not found among element nodes");
-
-}
-/*}}}*/
-/*FUNCTION Penta::GetInputListOnVertices(double* pvalue,int enumtype) {{{1*/
-void Penta::GetInputListOnVertices(double* pvalue,int enumtype){
+	_error2_("Node provided not found among element nodes");
+
+}
+/*}}}*/
+/*FUNCTION Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype) {{{*/
+void Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){
 
 	/*Intermediaries*/
-	double     value[NUMVERTICES];
+	IssmDouble     value[NUMVERTICES];
 	GaussPenta *gauss              = NULL;
 
 	/*Recover input*/
 	Input* input=inputs->GetInput(enumtype);
-	if (!input) _error_("Input %s not found in element",EnumToStringx(enumtype));
+	if (!input) _error2_("Input " << EnumToStringx(enumtype) << " not found in element");
 
 	/*Checks in debugging mode*/
@@ -845,9 +845,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue) {{{1*/
-void Penta::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue){
+/*FUNCTION Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue) {{{*/
+void Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){
 
 	/*Intermediaries*/
-	double     value[NUMVERTICES];
+	IssmDouble     value[NUMVERTICES];
 	GaussPenta *gauss              = NULL;
 
@@ -874,9 +874,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetInputValue(double* pvalue,Node* node,int enumtype) {{{1*/
-void Penta::GetInputValue(double* pvalue,Node* node,int enumtype){
+/*FUNCTION Penta::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype) {{{*/
+void Penta::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){
 
 	Input* input=inputs->GetInput(enumtype);
-	if(!input) _error_("No input of type %s found in tria",EnumToStringx(enumtype));
+	if(!input) _error2_("No input of type " << EnumToStringx(enumtype) << " found in tria");
 
 	GaussPenta* gauss=new GaussPenta();
@@ -887,11 +887,11 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetPhi {{{1*/
-void Penta::GetPhi(double* phi, double*  epsilon, double viscosity){
+/*FUNCTION Penta::GetPhi {{{*/
+void Penta::GetPhi(IssmDouble* phi, IssmDouble*  epsilon, IssmDouble viscosity){
 	/*Compute deformational heating from epsilon and viscosity */
 
-	double epsilon_matrix[3][3];
-	double epsilon_eff;
-	double epsilon_sqr[3][3];
+	IssmDouble epsilon_matrix[3][3];
+	IssmDouble epsilon_eff;
+	IssmDouble epsilon_sqr[3][3];
 
 	/* Build epsilon matrix */
@@ -925,5 +925,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetSidList{{{1*/
+/*FUNCTION Penta::GetSidList{{{*/
 void  Penta::GetSidList(int* sidlist){
 
@@ -933,5 +933,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetSolutionFromInputs{{{1*/
+/*FUNCTION Penta::GetSolutionFromInputs{{{*/
 void  Penta::GetSolutionFromInputs(Vector* solution){
 
@@ -973,16 +973,16 @@
 	#endif
 	default:
-		_error_("analysis: %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::GetStabilizationParameter {{{1*/
-double Penta::GetStabilizationParameter(double u, double v, double w, double diameter, double kappa){
+		_error2_("analysis: " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::GetStabilizationParameter {{{*/
+IssmDouble Penta::GetStabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa){
 	/*Compute stabilization parameter*/
 	/*kappa=thermalconductivity/(rho_ice*hearcapacity) for thermal model*/
 	/*kappa=enthalpydiffusionparameter for enthalpy model*/
 
-	double normu;
-	double tau_parameter;
+	IssmDouble normu;
+	IssmDouble tau_parameter;
 
 	normu=pow(pow(u,2)+pow(v,2)+pow(w,2),0.5);
@@ -995,6 +995,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetStrainRate3dPattyn{{{1*/
-void Penta::GetStrainRate3dPattyn(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input){
+/*FUNCTION Penta::GetStrainRate3dPattyn{{{*/
+void Penta::GetStrainRate3dPattyn(IssmDouble* epsilon,IssmDouble* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input){
 	/*Compute the 3d Blatter/PattynStrain Rate (5 components):
 	 *
@@ -1008,10 +1008,10 @@
 
 	int i;
-	double epsilonvx[5];
-	double epsilonvy[5];
+	IssmDouble epsilonvx[5];
+	IssmDouble epsilonvy[5];
 
 	/*Check that both inputs have been found*/
 	if (!vx_input || !vy_input){
-		_error_("Input missing. Here are the input pointers we have for vx: %p, vy: %p\n",vx_input,vy_input);
+		_error2_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << "\n");
 	}
 
@@ -1024,6 +1024,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetStrainRate3d{{{1*/
-void Penta::GetStrainRate3d(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input){
+/*FUNCTION Penta::GetStrainRate3d{{{*/
+void Penta::GetStrainRate3d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input){
 	/*Compute the 3d Strain Rate (6 components):
 	 *
@@ -1032,11 +1032,11 @@
 
 	int i;
-	double epsilonvx[6];
-	double epsilonvy[6];
-	double epsilonvz[6];
+	IssmDouble epsilonvx[6];
+	IssmDouble epsilonvy[6];
+	IssmDouble epsilonvz[6];
 
 	/*Check that both inputs have been found*/
 	if (!vx_input || !vy_input || !vz_input){
-		_error_("Input missing. Here are the input pointers we have for vx: %p, vy: %p, vz: %p\n",vx_input,vy_input,vz_input);
+		_error2_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << ", vz: " << vz_input << "\n");
 	}
 
@@ -1050,5 +1050,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetUpperElement{{{1*/
+/*FUNCTION Penta::GetUpperElement{{{*/
 Penta* Penta::GetUpperElement(void){
 
@@ -1060,5 +1060,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetVectorFromInputs{{{1*/
+/*FUNCTION Penta::GetVectorFromInputs{{{*/
 void  Penta::GetVectorFromInputs(Vector* vector,int input_enum){
 
@@ -1073,5 +1073,5 @@
 	/*Get input (either in element or material)*/
 	Input* input=inputs->GetInput(input_enum);
-	if(!input) _error_("Input %s not found in element",EnumToStringx(input_enum));
+	if(!input) _error2_("Input " << EnumToStringx(input_enum) << " not found in element");
 
 	/*We found the enum.  Use its values to fill into the vector, using the vertices ids: */
@@ -1079,5 +1079,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetVectorFromResults{{{1*/
+/*FUNCTION Penta::GetVectorFromResults{{{*/
 void  Penta::GetVectorFromResults(Vector* vector,int offset,int enum_in,int interp){
 
@@ -1098,15 +1098,15 @@
 	}
 	else{
-		printf("Interpolation %s not supported\n",EnumToStringx(interp));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::GetZcoord {{{1*/
-double Penta::GetZcoord(GaussPenta* gauss){
+		_printLine_("Interpolation " << EnumToStringx(interp) << " not supported");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::GetZcoord {{{*/
+IssmDouble Penta::GetZcoord(GaussPenta* gauss){
 
 	int    i;
-	double z;
-	double xyz_list[NUMVERTICES][3];
-	double z_list[NUMVERTICES];
+	IssmDouble z;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble z_list[NUMVERTICES];
 
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
@@ -1117,5 +1117,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::Sid {{{1*/
+/*FUNCTION Penta::Sid {{{*/
 int    Penta::Sid(){
 	
@@ -1124,11 +1124,11 @@
 }
 /*}}}*/
-/*FUNCTION Penta::Id {{{1*/
+/*FUNCTION Penta::Id {{{*/
 int    Penta::Id(void){
 	return id; 
 }
 /*}}}*/
-/*FUNCTION Penta::InputArtificialNoise{{{1*/
-void  Penta::InputArtificialNoise(int enum_type,double min,double max){
+/*FUNCTION Penta::InputArtificialNoise{{{*/
+void  Penta::InputArtificialNoise(int enum_type,IssmDouble min,IssmDouble max){
 
 	Input* input=NULL;
@@ -1136,5 +1136,5 @@
 	/*Make a copy of the original input: */
 	input=(Input*)this->inputs->GetInput(enum_type);
-	if(!input)_error_(" could not find old input with enum: %s",EnumToStringx(enum_type));
+	if(!input)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
 
 	/*ArtificialNoise: */
@@ -1142,6 +1142,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputConvergence{{{1*/
-bool Penta::InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){
+/*FUNCTION Penta::InputConvergence{{{*/
+bool Penta::InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums){
 
 	int i;
@@ -1150,12 +1150,12 @@
 	Input** old_inputs=NULL;
 
-	new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs
-	old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs
+	new_inputs=xNew<Input*>(num_enums/2); //half the enums are for the new inputs
+	old_inputs=xNew<Input*>(num_enums/2); //half the enums are for the old inputs
 
 	for(i=0;i<num_enums/2;i++){
 		new_inputs[i]=(Input*)this->inputs->GetInput(enums[2*i+0]);
 		old_inputs[i]=(Input*)this->inputs->GetInput(enums[2*i+1]);
-		if(!new_inputs[i])_error_("%s%s"," could not find input with enum ",EnumToStringx(enums[2*i+0]));
-		if(!old_inputs[i])_error_("%s%s"," could not find input with enum ",EnumToStringx(enums[2*i+0]));
+		if(!new_inputs[i])_error2_("could not find input with enum " << EnumToStringx(enums[2*i+0]));
+		if(!old_inputs[i])_error2_("could not find input with enum " << EnumToStringx(enums[2*i+0]));
 	}
 
@@ -1167,6 +1167,6 @@
 
 	/*clean up*/
-	xfree((void**)&new_inputs);
-	xfree((void**)&old_inputs);
+	xDelete<Input*>(new_inputs);
+	xDelete<Input*>(old_inputs);
 
 	/*Return output*/
@@ -1174,6 +1174,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputCreate(double scalar,int enum,int code);{{{1*/
-void Penta::InputCreate(double scalar,int name,int code){
+/*FUNCTION Penta::InputCreate(IssmDouble scalar,int enum,int code);{{{*/
+void Penta::InputCreate(IssmDouble scalar,int name,int code){
 
 	/*Check that name is an element input*/
@@ -1186,13 +1186,13 @@
 		this->inputs->AddInput(new IntInput(name,(int)scalar));
 	}
-	else if ((code==7) || (code==3)){ //double
-		this->inputs->AddInput(new DoubleInput(name,(double)scalar));
-	}
-	else _error_("%s%i"," could not recognize nature of vector from code ",code);
-
-}
-/*}}}*/
-/*FUNCTION Penta::InputCreate(double* vector,int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{1*/
-void Penta::InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
+	else if ((code==7) || (code==3)){ //IssmDouble
+		this->inputs->AddInput(new DoubleInput(name,(IssmDouble)scalar));
+	}
+	else _error2_("could not recognize nature of vector from code " << code);
+
+}
+/*}}}*/
+/*FUNCTION Penta::InputCreate(IssmDouble* vector,int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{*/
+void Penta::InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
 
 	/*Intermediaries*/
@@ -1200,11 +1200,11 @@
 	int    penta_vertex_ids[6];
 	int    row;
-	double nodeinputs[6];
-	double time;
+	IssmDouble nodeinputs[6];
+	IssmDouble time;
 	TransientInput* transientinput=NULL;
 
 	int    numberofvertices;
 	int    numberofelements;
-	double yts;
+	IssmDouble yts;
 
 	/*Fetch parameters: */
@@ -1225,5 +1225,5 @@
 
 			/*create input values: */
-			for(i=0;i<6;i++)nodeinputs[i]=(double)vector[penta_vertex_ids[i]-1];
+			for(i=0;i<6;i++)nodeinputs[i]=(IssmDouble)vector[penta_vertex_ids[i]-1];
 
 			/*process units: */
@@ -1240,5 +1240,5 @@
 				for(i=0;i<6;i++){
 					row=penta_vertex_ids[i]-1;
-					nodeinputs[i]=(double)vector[N*row+t];
+					nodeinputs[i]=(IssmDouble)vector[N*row+t];
 				}
 
@@ -1247,5 +1247,5 @@
 
 				/*time? :*/
-				time=(double)vector[(M-1)*N+t]*yts;
+				time=(IssmDouble)vector[(M-1)*N+t]*yts;
 
 				if(t==0)transientinput=new TransientInput(vector_enum);
@@ -1254,5 +1254,5 @@
 			this->inputs->AddInput(transientinput);
 		}
-		else _error_("nodal vector is either numberofnodes (%i), or numberofnodes+1 long. Field provided is %i long. Enum %s",numberofvertices,M,EnumToStringx(vector_enum));
+		else _error2_("nodal vector is either numberofnodes (" << numberofvertices << "), or numberofnodes+1 long. Field provided is " << M << " long. Enum " << EnumToStringx(vector_enum));
 	}
 	else if(vector_type==2){ //element vector
@@ -1268,26 +1268,26 @@
 				this->inputs->AddInput(new IntInput(vector_enum,(int)vector[index]));
 			}
-			else if (code==7){ //double
-				this->inputs->AddInput(new DoubleInput(vector_enum,(double)vector[index]));
+			else if (code==7){ //IssmDouble
+				this->inputs->AddInput(new DoubleInput(vector_enum,(IssmDouble)vector[index]));
 			}
-			else _error_("%s%i"," could not recognize nature of vector from code ",code);
+			else _error2_("could not recognize nature of vector from code " << code);
 		}
 		else {
-			_error_("transient elementary inputs not supported yet!");
+			_error2_("transient elementary inputs not supported yet!");
 		}
 	}
 	else{
-		_error_("Cannot add input for vector type %i (not supported)",vector_type);
-	}
-
-}
-/*}}}*/
-/*FUNCTION Penta::InputDepthAverageAtBase{{{1*/
+		_error2_("Cannot add input for vector type " << vector_type << " (not supported)");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Penta::InputDepthAverageAtBase{{{*/
 void  Penta::InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum){
 
 	int  step,i;
-	double  xyz_list[NUMVERTICES][3];
-	double  Helem_list[NUMVERTICES];
-	double  zeros_list[NUMVERTICES]={0.0};
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  Helem_list[NUMVERTICES];
+	IssmDouble  zeros_list[NUMVERTICES]={0.0};
 	Penta* penta=NULL;
 	Input* original_input=NULL;
@@ -1317,6 +1317,6 @@
 		 original_input=(Input*)penta->matice->inputs->GetInput(enum_type);
 		else
-		 _error_("object %s not supported yet",EnumToStringx(object_enum));
-		if(!original_input) _error_("could not find input with enum %s",EnumToStringx(enum_type));
+		 _error2_("object " << EnumToStringx(object_enum) << " not supported yet");
+		if(!original_input) _error2_("could not find input with enum " << EnumToStringx(enum_type));
 
 		/*If first time, initialize total_integrated_input*/
@@ -1329,5 +1329,5 @@
 			 total_integrated_input=new DoubleInput(average_enum_type,0.0);
 			else
-			 _error_("object %s not supported yet",EnumToStringx(original_input->ObjectEnum()));
+			 _error2_("object " << EnumToStringx(original_input->ObjectEnum()) << " not supported yet");
 		}
 
@@ -1377,8 +1377,8 @@
 	 this->matice->inputs->AddInput((Input*)depth_averaged_input);
 	else
-	 _error_("object %s not supported yet",EnumToStringx(object_enum));
-}
-/*}}}*/
-/*FUNCTION Penta::InputDuplicate{{{1*/
+	 _error2_("object " << EnumToStringx(object_enum) << " not supported yet");
+}
+/*}}}*/
+/*FUNCTION Penta::InputDuplicate{{{*/
 void  Penta::InputDuplicate(int original_enum,int new_enum){
 
@@ -1388,5 +1388,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputExtrude {{{1*/
+/*FUNCTION Penta::InputExtrude {{{*/
 void  Penta::InputExtrude(int enum_type,int object_type){
 
@@ -1402,15 +1402,15 @@
 	if (object_type==ElementEnum){
 		num_inputs=1;
-		base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
+		base_inputs=xNew<Input*>(num_inputs);
 		base_inputs[0]=(Input*)this->inputs->GetInput(enum_type);
 	}
 	else if (object_type==MaterialsEnum){
 		num_inputs=1;
-		base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
+		base_inputs=xNew<Input*>(num_inputs);
 		base_inputs[0]=(Input*)matice->inputs->GetInput(enum_type);
 	}
 	else if (object_type==NodeEnum){
 		num_inputs=3; //only the three upper nodes
-		base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
+		base_inputs=xNew<Input*>(num_inputs);
 		for(i=0;i<num_inputs;i++){
 			base_inputs[i]=(Input*)this->nodes[i]->inputs->GetInput(enum_type);
@@ -1418,8 +1418,8 @@
 	}
 	else{
-		_error_("object of type %s not supported yet",EnumToStringx(object_type));
+		_error2_("object of type " << EnumToStringx(object_type) << " not supported yet");
 	}
 	for(i=0;i<num_inputs;i++){
-		if(!base_inputs[i]) _error_("could not find input with enum %s in object %s",EnumToStringx(enum_type),EnumToStringx(object_type));
+		if(!base_inputs[i]) _error2_("could not find input with enum " << EnumToStringx(enum_type) << " in object " << EnumToStringx(object_type));
 		base_inputs[i]->Extrude();
 	}
@@ -1448,5 +1448,5 @@
 			}
 			else{
-				_error_("object of type %s not supported yet",EnumToStringx(object_type));
+				_error2_("object of type " << EnumToStringx(object_type) << " not supported yet");
 			}
 		}
@@ -1457,9 +1457,9 @@
 
 	/*clean-up and return*/
-	xfree((void**)&base_inputs);
-}
-/*}}}*/
-/*FUNCTION Penta::InputScale{{{1*/
-void  Penta::InputScale(int enum_type,double scale_factor){
+	xDelete<Input*>(base_inputs);
+}
+/*}}}*/
+/*FUNCTION Penta::InputScale{{{*/
+void  Penta::InputScale(int enum_type,IssmDouble scale_factor){
 
 	Input* input=NULL;
@@ -1467,5 +1467,5 @@
 	/*Make a copy of the original input: */
 	input=(Input*)this->inputs->GetInput(enum_type);
-	if(!input)_error_(" could not find old input with enum: %s",EnumToStringx(enum_type));
+	if(!input)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
 
 	/*Scale: */
@@ -1473,6 +1473,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputToResult{{{1*/
-void  Penta::InputToResult(int enum_type,int step,double time){
+/*FUNCTION Penta::InputToResult{{{*/
+void  Penta::InputToResult(int enum_type,int step,IssmDouble time){
 
 	int    i;
@@ -1483,5 +1483,5 @@
 	if (enum_type==MaterialsRheologyBbarEnum) input=this->matice->inputs->GetInput(MaterialsRheologyBEnum);
 	else input=this->inputs->GetInput(enum_type);
-	//if (!input) _error_("Input %s not found in penta->inputs",EnumToStringx(enum_type)); why error out? if the requested input does not exist, we should still 
+	//if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found in penta->inputs"); why error out? if the requested input does not exist, we should still 
 	//try and output whatever we can instead of just failing.
 	if(!input)return;
@@ -1498,5 +1498,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputUpdateFromConstant(bool value, int name);{{{1*/
+/*FUNCTION Penta::InputUpdateFromConstant(bool value, int name);{{{*/
 void  Penta::InputUpdateFromConstant(bool constant, int name){
 
@@ -1508,6 +1508,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputUpdateFromConstant(double value, int name);{{{1*/
-void  Penta::InputUpdateFromConstant(double constant, int name){
+/*FUNCTION Penta::InputUpdateFromConstant(IssmDouble value, int name);{{{*/
+void  Penta::InputUpdateFromConstant(IssmDouble constant, int name){
 	/*Check that name is an element input*/
 	if (!IsInput(name)) return;
@@ -1517,5 +1517,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputUpdateFromConstant(int value, int name);{{{1*/
+/*FUNCTION Penta::InputUpdateFromConstant(int value, int name);{{{*/
 void  Penta::InputUpdateFromConstant(int constant, int name){
 	/*Check that name is an element input*/
@@ -1526,5 +1526,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputUpdateFromIoModel {{{1*/
+/*FUNCTION Penta::InputUpdateFromIoModel {{{*/
 void Penta::InputUpdateFromIoModel(int index,IoModel* iomodel){ 
 
@@ -1532,9 +1532,9 @@
 	IssmInt i,j;
 	int     penta_vertex_ids[6];
-	double  nodeinputs[6];
-	double  cmmininputs[6];
-	double  cmmaxinputs[6];
-
-	double  yts;
+	IssmDouble  nodeinputs[6];
+	IssmDouble  cmmininputs[6];
+	IssmDouble  cmmaxinputs[6];
+
+	IssmDouble  yts;
 	bool    control_analysis;
 	int     num_control_type;
@@ -1548,5 +1548,5 @@
 
 	/*Checks if debuging*/
-	/*{{{2*/
+	/*{{{*/
 	_assert_(iomodel->Data(MeshElementsEnum));
 	/*}}}*/
@@ -1597,5 +1597,5 @@
 					/*Matice will take care of it*/ break;
 				default:
-					_error_("Control %s not implemented yet",EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]));
+					_error2_("Control " << EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]) << " not implemented yet");
 			}
 		}
@@ -1630,5 +1630,5 @@
 		}
 		else{
-			_error_("Approximation type %s not supported yet",EnumToStringx((int)*(iomodel->Data(FlowequationElementEquationEnum)+index)));
+			_error2_("Approximation type " << EnumToStringx((int)*(iomodel->Data(FlowequationElementEquationEnum)+index)) << " not supported yet");
 		}
 	}
@@ -1649,6 +1649,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolution {{{1*/
-void  Penta::InputUpdateFromSolution(double* solution){
+/*FUNCTION Penta::InputUpdateFromSolution {{{*/
+void  Penta::InputUpdateFromSolution(IssmDouble* solution){
 
 	int analysis_type;
@@ -1714,10 +1714,10 @@
 	#endif
 	default: 
-		_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionPrognostic{{{1*/
-void  Penta::InputUpdateFromSolutionPrognostic(double* solution){
+		_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionPrognostic{{{*/
+void  Penta::InputUpdateFromSolutionPrognostic(IssmDouble* solution){
 
 	const int  numdof   = NDOF1*NUMVERTICES;
@@ -1726,11 +1726,11 @@
 	int    i,hydroadjustment;
 	int*   doflist = NULL;
-	double rho_ice,rho_water,minthickness;
-	double newthickness[numdof];
-	double newbed[numdof];
-	double newsurface[numdof];
-	double oldbed[NUMVERTICES];
-	double oldsurface[NUMVERTICES];
-	double oldthickness[NUMVERTICES];
+	IssmDouble rho_ice,rho_water,minthickness;
+	IssmDouble newthickness[numdof];
+	IssmDouble newbed[numdof];
+	IssmDouble newsurface[numdof];
+	IssmDouble oldbed[NUMVERTICES];
+	IssmDouble oldsurface[NUMVERTICES];
+	IssmDouble oldthickness[NUMVERTICES];
 	Penta  *penta   = NULL;
 
@@ -1745,5 +1745,5 @@
 	for(i=0;i<numdof2d;i++){
 		newthickness[i]=solution[doflist[i]];
-		if(isnan(newthickness[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(newthickness[i])) _error2_("NaN found in solution vector");
 		/*Constrain thickness to be at least 1m*/
 		if(newthickness[i]<minthickness) newthickness[i]=minthickness;
@@ -1778,5 +1778,5 @@
 				newbed[i]=oldbed[i]-rho_ice/rho_water*(newthickness[i]-oldthickness[i]); //bed = oldbed + di * dH
 			}
-			else _error_("Hydrostatic adjustment %i (%s) not supported yet",hydroadjustment,EnumToStringx(hydroadjustment));
+			else _error2_("Hydrostatic adjustment " << hydroadjustment << " (" << EnumToStringx(hydroadjustment) << ") not supported yet");
 		}
 	}
@@ -1798,13 +1798,13 @@
 	
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionOneDof{{{1*/
-void  Penta::InputUpdateFromSolutionOneDof(double* solution,int enum_type){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionOneDof{{{*/
+void  Penta::InputUpdateFromSolutionOneDof(IssmDouble* solution,int enum_type){
 
 	const int numdof = NDOF1*NUMVERTICES;
 
-	double values[numdof];
+	IssmDouble values[numdof];
 	int*   doflist=NULL;
 
@@ -1815,5 +1815,5 @@
 	for(int i=0;i<numdof;i++){
 		values[i]=solution[doflist[i]];
-		if(isnan(values[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -1822,14 +1822,14 @@
 	
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionOneDofCollpased{{{1*/
-void  Penta::InputUpdateFromSolutionOneDofCollapsed(double* solution,int enum_type){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionOneDofCollpased{{{*/
+void  Penta::InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int enum_type){
 
 	const int  numdof   = NDOF1*NUMVERTICES;
 	const int  numdof2d = NDOF1*NUMVERTICES2D;
 
-	double  values[numdof];
+	IssmDouble  values[numdof];
 	int*    doflist = NULL;
 	Penta  *penta   = NULL;
@@ -1845,5 +1845,5 @@
 		values[i]         =solution[doflist[i]];
 		values[i+numdof2d]=values[i];
-		if(isnan(values[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -1862,9 +1862,9 @@
 	
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromVector(double* vector, int name, int type);{{{1*/
-void  Penta::InputUpdateFromVector(double* vector, int name, int type){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromVector(IssmDouble* vector, int name, int type);{{{*/
+void  Penta::InputUpdateFromVector(IssmDouble* vector, int name, int type){
 
 	/*Check that name is an element input*/
@@ -1878,5 +1878,5 @@
 
 			/*New PentaVertexInpu*/
-			double values[6];
+			IssmDouble values[6];
 
 			/*Get values on the 6 vertices*/
@@ -1891,19 +1891,19 @@
 		default:
 
-			_error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromVector(int* vector, int name, int type);{{{1*/
+			_error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromVector(int* vector, int name, int type);{{{*/
 void  Penta::InputUpdateFromVector(int* vector, int name, int type){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromVector(bool* vector, int name, int type);{{{1*/
+	_error2_("not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromVector(bool* vector, int name, int type);{{{*/
 void  Penta::InputUpdateFromVector(bool* vector, int name, int type){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Penta::IsOnBed{{{1*/
+	_error2_("not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Penta::IsOnBed{{{*/
 bool Penta::IsOnBed(void){
 
@@ -1913,5 +1913,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::IsInput{{{1*/
+/*FUNCTION Penta::IsInput{{{*/
 bool Penta::IsInput(int name){
 	if (
@@ -1957,5 +1957,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::IsFloating{{{1*/
+/*FUNCTION Penta::IsFloating{{{*/
 bool   Penta::IsFloating(){
 
@@ -1965,5 +1965,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::IsNodeOnShelf {{{1*/
+/*FUNCTION Penta::IsNodeOnShelf {{{*/
 bool   Penta::IsNodeOnShelf(){
 
@@ -1980,6 +1980,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::IsNodeOnShelfFromFlags {{{1*/
-bool   Penta::IsNodeOnShelfFromFlags(double* flags){
+/*FUNCTION Penta::IsNodeOnShelfFromFlags {{{*/
+bool   Penta::IsNodeOnShelfFromFlags(IssmDouble* flags){
 
 	int  i;
@@ -1995,5 +1995,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::IsOnSurface{{{1*/
+/*FUNCTION Penta::IsOnSurface{{{*/
 bool Penta::IsOnSurface(void){
 
@@ -2003,5 +2003,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::IsOnWater {{{1*/
+/*FUNCTION Penta::IsOnWater {{{*/
 bool   Penta::IsOnWater(){
 
@@ -2012,5 +2012,5 @@
 /*}}}*/
 /*FUNCTION Penta::ListResultsInfo{{{*/
-void Penta::ListResultsInfo(int** in_resultsenums,int** in_resultssizes,double** in_resultstimes,int** in_resultssteps,int* in_num_results){
+void Penta::ListResultsInfo(int** in_resultsenums,int** in_resultssizes,IssmDouble** in_resultstimes,int** in_resultssteps,int* in_num_results){
 
 	/*Intermediaries*/
@@ -2019,5 +2019,5 @@
 	int     *resultsenums   = NULL;
 	int     *resultssizes   = NULL;
-	double  *resultstimes   = NULL;
+	IssmDouble  *resultstimes   = NULL;
 	int     *resultssteps   = NULL;
 
@@ -2034,8 +2034,8 @@
 
 		/*Allocate output*/
-		resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
-		resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
-		resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
-		resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
+		resultsenums=xNew<int>(numberofresults);
+		resultssizes=xNew<int>(numberofresults);
+		resultstimes=xNew<IssmDouble>(numberofresults);
+		resultssteps=xNew<int>(numberofresults);
 
 		/*populate enums*/
@@ -2062,13 +2062,13 @@
 
 }/*}}}*/
-/*FUNCTION Penta::MigrateGroundingLine{{{1*/
-void  Penta::MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding){
+/*FUNCTION Penta::MigrateGroundingLine{{{*/
+void  Penta::MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding){
 
 	int     i,migration_style,unground;
 	bool    elementonshelf = false;
-	double  bed_hydro,yts,gl_melting_rate;
-	double  rho_water,rho_ice,density;
-	double  melting[NUMVERTICES];
-	double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
+	IssmDouble  bed_hydro,yts,gl_melting_rate;
+	IssmDouble  rho_water,rho_ice,density;
+	IssmDouble  melting[NUMVERTICES];
+	IssmDouble  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
 
 	if(!IsOnBed()) return;
@@ -2145,12 +2145,12 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MinEdgeLength{{{1*/
-double Penta::MinEdgeLength(double xyz_list[6][3]){
+/*FUNCTION Penta::MinEdgeLength{{{*/
+IssmDouble Penta::MinEdgeLength(IssmDouble xyz_list[6][3]){
 	/*Return the minimum lenght of the nine egdes of the penta*/
 
 	int    i,node0,node1;
 	int    edges[9][2]={{0,1},{0,2},{1,2},{3,4},{3,5},{4,5},{0,3},{1,4},{2,5}}; //list of the nine edges
-	double length;
-	double minlength=-1;
+	IssmDouble length;
+	IssmDouble minlength=-1;
 
 	for(i=0;i<9;i++){
@@ -2167,5 +2167,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MyRank {{{1*/
+/*FUNCTION Penta::MyRank {{{*/
 int    Penta::MyRank(void){ 
 	extern int my_rank;
@@ -2173,10 +2173,10 @@
 }
 /*}}}*/
-/*FUNCTION Penta::NodalValue {{{1*/
-int    Penta::NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units){
+/*FUNCTION Penta::NodalValue {{{*/
+int    Penta::NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units){
 
 	int i;
 	int found=0;
-	double value;
+	IssmDouble value;
 	Input* data=NULL;
 	GaussPenta* gauss=NULL;
@@ -2204,5 +2204,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::PatchFill{{{1*/
+/*FUNCTION Penta::PatchFill{{{*/
 void  Penta::PatchFill(int* pcount, Patch* patch){
 
@@ -2231,5 +2231,5 @@
 	*pcount=count;
 }/*}}}*/
-/*FUNCTION Penta::PatchSize{{{1*/
+/*FUNCTION Penta::PatchSize{{{*/
 void  Penta::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes){
 
@@ -2255,11 +2255,11 @@
 }
 /*}}}*/
-/*FUNCTION Penta::PositiveDegreeDay{{{1*/
-void  Penta::PositiveDegreeDay(double* pdds,double* pds,double signorm){
-
-   double agd[NUMVERTICES];             // surface mass balance
-   double monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
-   double h[NUMVERTICES],s[NUMVERTICES]; // ,b
-   double rho_water,rho_ice;
+/*FUNCTION Penta::PositiveDegreeDay{{{*/
+void  Penta::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){
+
+   IssmDouble agd[NUMVERTICES];             // surface mass balance
+   IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
+   IssmDouble h[NUMVERTICES],s[NUMVERTICES]; // ,b
+   IssmDouble rho_water,rho_ice;
 
    /*Recover monthly temperatures and precipitation*/
@@ -2267,5 +2267,5 @@
    Input*     input2=inputs->GetInput(SurfaceforcingsPrecipitationEnum); _assert_(input2);
    GaussPenta* gauss=new GaussPenta();
-   double time,yts;
+   IssmDouble time,yts;
    this->parameters->FindParam(&time,TimeEnum);
    this->parameters->FindParam(&yts,ConstantsYtsEnum);
@@ -2299,11 +2299,11 @@
 }
 /*}}}*/
-/*FUNCTION Penta::PotentialSheetUngrounding{{{1*/
+/*FUNCTION Penta::PotentialSheetUngrounding{{{*/
 void  Penta::PotentialSheetUngrounding(Vector* potential_sheet_ungrounding){
 
 	int     i;
-	double  h[NUMVERTICES],ba[NUMVERTICES];
-	double  bed_hydro;
-	double  rho_water,rho_ice,density;
+	IssmDouble  h[NUMVERTICES],ba[NUMVERTICES];
+	IssmDouble  bed_hydro;
+	IssmDouble  rho_water,rho_ice,density;
 	bool    elementonshelf = false;
 
@@ -2328,5 +2328,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ProcessResultsUnits{{{1*/
+/*FUNCTION Penta::ProcessResultsUnits{{{*/
 void  Penta::ProcessResultsUnits(void){
 
@@ -2339,14 +2339,14 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ReduceMatrixStokes {{{1*/
-void Penta::ReduceMatrixStokes(double* Ke_reduced, double* Ke_temp){
+/*FUNCTION Penta::ReduceMatrixStokes {{{*/
+void Penta::ReduceMatrixStokes(IssmDouble* Ke_reduced, IssmDouble* Ke_temp){
 
 	int    i,j;
-	double Kii[24][24];
-	double Kib[24][3];
-	double Kbb[3][3];
-	double Kbi[3][24];
-	double Kbbinv[3][3];
-	double Kright[24][24];
+	IssmDouble Kii[24][24];
+	IssmDouble Kib[24][3];
+	IssmDouble Kbb[3][3];
+	IssmDouble Kbi[3][24];
+	IssmDouble Kbbinv[3][3];
+	IssmDouble Kright[24][24];
 
 	/*Create the four matrices used for reduction */
@@ -2381,14 +2381,14 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ReduceVectorStokes {{{1*/
-void Penta::ReduceVectorStokes(double* Pe_reduced, double* Ke_temp, double* Pe_temp){
+/*FUNCTION Penta::ReduceVectorStokes {{{*/
+void Penta::ReduceVectorStokes(IssmDouble* Pe_reduced, IssmDouble* Ke_temp, IssmDouble* Pe_temp){
 
 	int    i,j;
-	double Pi[24];
-	double Pb[3];
-	double Kbb[3][3];
-	double Kib[24][3];
-	double Kbbinv[3][3];
-	double Pright[24];
+	IssmDouble Pi[24];
+	IssmDouble Pb[3];
+	IssmDouble Kbb[3][3];
+	IssmDouble Kib[24][3];
+	IssmDouble Kbbinv[3][3];
+	IssmDouble Pright[24];
 
 	/*Create the four matrices used for reduction */
@@ -2416,6 +2416,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::RequestedOutput{{{1*/
-void Penta::RequestedOutput(int output_enum,int step,double time){
+/*FUNCTION Penta::RequestedOutput{{{*/
+void Penta::RequestedOutput(int output_enum,int step,IssmDouble time){
 			
 	if(IsInput(output_enum)){
@@ -2467,11 +2467,11 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ResetCoordinateSystem{{{1*/
+/*FUNCTION Penta::ResetCoordinateSystem{{{*/
 void  Penta::ResetCoordinateSystem(void){
 
 	int    approximation;
-	double slopex[NUMVERTICES];
-	double slopey[NUMVERTICES];
-	double xz_plane[6];
+	IssmDouble slopex[NUMVERTICES];
+	IssmDouble slopey[NUMVERTICES];
+	IssmDouble xz_plane[6];
 
 	/*For Stokes only: we want the CS to be tangential to the bedrock*/
@@ -2495,11 +2495,11 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SetClone {{{1*/
+/*FUNCTION Penta::SetClone {{{*/
 void  Penta::SetClone(int* minranks){
 
-	_error_("not implemented yet");
-}
-/*}}}1*/
-/*FUNCTION Penta::SetCurrentConfiguration {{{1*/
+	_error2_("not implemented yet");
+}
+/*}}}*/
+/*FUNCTION Penta::SetCurrentConfiguration {{{*/
 void  Penta::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
 
@@ -2517,5 +2517,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SpawnTria {{{1*/
+/*FUNCTION Penta::SpawnTria {{{*/
 Tria*  Penta::SpawnTria(int g0, int g1, int g2){
 
@@ -2560,9 +2560,64 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SurfaceArea {{{1*/
-double Penta::SurfaceArea(void){
+/*FUNCTION Penta::SmbGradients{{{*/
+void Penta::SmbGradients(void){
+
+	int i;
+
+	// input
+   IssmDouble h[NUMVERTICES];					// ice thickness (m)		
+	IssmDouble s[NUMVERTICES];					// surface elevation (m)
+	IssmDouble a_pos[NUMVERTICES];				// Hs-SMB relation parameter 
+	IssmDouble b_pos[NUMVERTICES];				// Hs-SMB relation parameter
+	IssmDouble a_neg[NUMVERTICES];				// Hs-SMB relation parameter
+	IssmDouble b_neg[NUMVERTICES];				// Hs-SMB relation paremeter
+	IssmDouble Hc[NUMVERTICES];					// elevation of transition between accumulation regime and ablation regime
+	IssmDouble smb_pos_max[NUMVERTICES];		// maximum SMB value in the accumulation regime
+	IssmDouble smb_pos_min[NUMVERTICES];		// minimum SMB value in the accumulation regime
+   IssmDouble rho_water;                   // density of fresh water
+	IssmDouble rho_ice;                     // density of ice
+
+	// output
+	IssmDouble smb[NUMVERTICES];					// surface mass balance (m/yr ice)
+
+	/*Recover SmbGradients*/
+	GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum);
+	GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum);
+	GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum);
+	GetInputListOnVertices(&a_pos[0],SurfaceforcingsAPosEnum);
+	GetInputListOnVertices(&b_pos[0],SurfaceforcingsBPosEnum);
+	GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum);
+	GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum);
+	
+   /*Recover surface elevatio at vertices: */
+	GetInputListOnVertices(&h[0],ThicknessEnum);
+	GetInputListOnVertices(&s[0],SurfaceEnum);
+
+   /*Get material parameters :*/
+   rho_ice=matpar->GetRhoIce();
+   rho_water=matpar->GetRhoFreshwater();
+			
+   // loop over all vertices
+   for(i=0;i<NUMVERTICES;i++){
+     if(s[i]>Hc[i]){
+	    smb[i]=a_pos[i]+b_pos[i]*s[i];
+		 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
+		 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
+	  }
+	  else{
+	    smb[i]=a_neg[i]+b_neg[i]*s[i];
+	  }
+	  smb[i]=smb[i]/rho_ice;      // SMB in m/y ice		
+	  
+	}  //end of the loop over the vertices
+	  /*Update inputs*/
+	  this->inputs->AddInput(new PentaP1Input(SurfaceforcingsMassBalanceEnum,&smb[0]));
+}
+/*}}}*/
+/*FUNCTION Penta::SurfaceArea {{{*/
+IssmDouble Penta::SurfaceArea(void){
 
 	int    approximation;
-	double S;
+	IssmDouble S;
 	Tria*  tria=NULL;
 
@@ -2597,11 +2652,11 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SurfaceNormal {{{1*/
-void Penta::SurfaceNormal(double* surface_normal, double xyz_list[3][3]){
+/*FUNCTION Penta::SurfaceNormal {{{*/
+void Penta::SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]){
 
 	int    i;
-	double v13[3],v23[3];
-	double normal[3];
-	double normal_norm;
+	IssmDouble v13[3],v23[3];
+	IssmDouble normal[3];
+	IssmDouble normal_norm;
 
 	for (i=0;i<3;i++){
@@ -2621,12 +2676,12 @@
 }
 /*}}}*/
-/*FUNCTION Penta::TimeAdapt{{{1*/
-double  Penta::TimeAdapt(void){
+/*FUNCTION Penta::TimeAdapt{{{*/
+IssmDouble  Penta::TimeAdapt(void){
 
 	int    i;
-	double C,dx,dy,dz,dt;
-	double maxabsvx,maxabsvy,maxabsvz;
-	double maxx,minx,maxy,miny,maxz,minz;
-	double xyz_list[NUMVERTICES][3];
+	IssmDouble C,dx,dy,dz,dt;
+	IssmDouble maxabsvx,maxabsvy,maxabsvz;
+	IssmDouble maxx,minx,maxy,miny,maxz,minz;
+	IssmDouble xyz_list[NUMVERTICES][3];
 
 	/*get CFL coefficient:*/
@@ -2664,6 +2719,6 @@
 
 	return dt;
-}
-/*FUNCTION Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type) {{{1*/
+}/*}}}*/
+/*FUNCTION Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type) {{{*/
 void Penta::Update(int index,IoModel* iomodel,int analysis_counter,int analysis_type){ 
 
@@ -2673,10 +2728,10 @@
 	int     penta_node_ids[6];
 	int     penta_vertex_ids[6];
-	double  nodeinputs[6];
-	double  yts;
+	IssmDouble  nodeinputs[6];
+	IssmDouble  yts;
 	int     stabilization;
 	bool    dakota_analysis;
 	bool    isstokes;
-	double  beta,heatcapacity,referencetemperature,meltingpoint,latentheat;
+	IssmDouble  beta,heatcapacity,referencetemperature,meltingpoint,latentheat;
 
 	/*Fetch parameters: */
@@ -2692,5 +2747,5 @@
 
 	/*Checks if debuging*/
-	/*{{{2*/
+	/*{{{*/
 	_assert_(iomodel->Data(MeshElementsEnum));
 	/*}}}*/
@@ -2810,5 +2865,5 @@
 				this->inputs->AddInput(new PentaP1Input(EnthalpyEnum,nodeinputs));
 			}
-			else _error_("temperature and waterfraction required for the enthalpy solution");
+			else _error2_("temperature and waterfraction required for the enthalpy solution");
 			break;
 
@@ -2819,6 +2874,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::UpdatePotentialSheetUngrounding{{{1*/
-int Penta::UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf){
+/*FUNCTION Penta::UpdatePotentialSheetUngrounding{{{*/
+int Penta::UpdatePotentialSheetUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){
 
 	int i;
@@ -2839,5 +2894,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ViscousHeatingCreateInput {{{1*/
+/*FUNCTION Penta::ViscousHeatingCreateInput {{{*/
 void Penta::ViscousHeatingCreateInput(void){
 
@@ -2847,10 +2902,10 @@
 	/*Intermediaries*/
 	int    iv;
-	double phi;
-	double viscosity;
-	double xyz_list[NUMVERTICES][3];
-	double epsilon[6];
-	double     viscousheating[NUMVERTICES]={0,0,0,0,0,0};
-	double     thickness;
+	IssmDouble phi;
+	IssmDouble viscosity;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble epsilon[6];
+	IssmDouble     viscousheating[NUMVERTICES]={0,0,0,0,0,0};
+	IssmDouble     thickness;
 	GaussPenta *gauss=NULL;
 
@@ -2887,17 +2942,17 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SmearFunction {{{1*/
-void  Penta::SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
-	_error_("not implemented yet");
-}
-/*}}}1*/
+/*FUNCTION Penta::SmearFunction {{{*/
+void  Penta::SmearFunction(Vector* smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius){
+	_error2_("not implemented yet");
+}
+/*}}}*/
 
 #ifdef _HAVE_RESPONSES_
-/*FUNCTION Penta::IceVolume {{{1*/
-double Penta::IceVolume(void){
+/*FUNCTION Penta::IceVolume {{{*/
+IssmDouble Penta::IceVolume(void){
 
 	/*The volume of a troncated prism is base * 1/3 sum(length of edges)*/
-	double base,height;
-	double xyz_list[NUMVERTICES][3];
+	IssmDouble base,height;
+	IssmDouble xyz_list[NUMVERTICES][3];
 
 	if(IsOnWater())return 0;
@@ -2917,9 +2972,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MinVel{{{1*/
-void  Penta::MinVel(double* pminvel, bool process_units){
+/*FUNCTION Penta::MinVel{{{*/
+void  Penta::MinVel(IssmDouble* pminvel, bool process_units){
 
 	/*Get minimum:*/
-	double minvel=this->inputs->Min(VelEnum);
+	IssmDouble minvel=this->inputs->Min(VelEnum);
 
 	/*process units if requested: */
@@ -2930,9 +2985,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MinVx{{{1*/
-void  Penta::MinVx(double* pminvx, bool process_units){
+/*FUNCTION Penta::MinVx{{{*/
+void  Penta::MinVx(IssmDouble* pminvx, bool process_units){
 
 	/*Get minimum:*/
-	double minvx=this->inputs->Min(VxEnum);
+	IssmDouble minvx=this->inputs->Min(VxEnum);
 
 	/*process units if requested: */
@@ -2943,9 +2998,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MinVy{{{1*/
-void  Penta::MinVy(double* pminvy, bool process_units){
+/*FUNCTION Penta::MinVy{{{*/
+void  Penta::MinVy(IssmDouble* pminvy, bool process_units){
 
 	/*Get minimum:*/
-	double minvy=this->inputs->Min(VyEnum);
+	IssmDouble minvy=this->inputs->Min(VyEnum);
 
 	/*process units if requested: */
@@ -2956,9 +3011,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MinVz{{{1*/
-void  Penta::MinVz(double* pminvz, bool process_units){
+/*FUNCTION Penta::MinVz{{{*/
+void  Penta::MinVz(IssmDouble* pminvz, bool process_units){
 
 	/*Get minimum:*/
-	double minvz=this->inputs->Min(VzEnum);
+	IssmDouble minvz=this->inputs->Min(VzEnum);
 
 	/*process units if requested: */
@@ -2969,8 +3024,8 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MassFlux {{{1*/
-double Penta::MassFlux( double* segment,bool process_units){
-
-	double mass_flux=0;
+/*FUNCTION Penta::MassFlux {{{*/
+IssmDouble Penta::MassFlux( IssmDouble* segment,bool process_units){
+
+	IssmDouble mass_flux=0;
 
 	if(!IsOnBed()) return mass_flux;
@@ -2993,9 +3048,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MaxAbsVx{{{1*/
-void  Penta::MaxAbsVx(double* pmaxabsvx, bool process_units){
+/*FUNCTION Penta::MaxAbsVx{{{*/
+void  Penta::MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units){
 
 	/*Get maximum:*/
-	double maxabsvx=this->inputs->MaxAbs(VxEnum);
+	IssmDouble maxabsvx=this->inputs->MaxAbs(VxEnum);
 
 	/*process units if requested: */
@@ -3006,9 +3061,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MaxAbsVy{{{1*/
-void  Penta::MaxAbsVy(double* pmaxabsvy, bool process_units){
+/*FUNCTION Penta::MaxAbsVy{{{*/
+void  Penta::MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units){
 
 	/*Get maximum:*/
-	double maxabsvy=this->inputs->MaxAbs(VyEnum);
+	IssmDouble maxabsvy=this->inputs->MaxAbs(VyEnum);
 
 	/*process units if requested: */
@@ -3019,9 +3074,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MaxAbsVz{{{1*/
-void  Penta::MaxAbsVz(double* pmaxabsvz, bool process_units){
+/*FUNCTION Penta::MaxAbsVz{{{*/
+void  Penta::MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units){
 
 	/*Get maximum:*/
-	double maxabsvz=this->inputs->MaxAbs(VzEnum);
+	IssmDouble maxabsvz=this->inputs->MaxAbs(VzEnum);
 
 	/*process units if requested: */
@@ -3032,9 +3087,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MaxVel{{{1*/
-void  Penta::MaxVel(double* pmaxvel, bool process_units){
+/*FUNCTION Penta::MaxVel{{{*/
+void  Penta::MaxVel(IssmDouble* pmaxvel, bool process_units){
 
 	/*Get maximum:*/
-	double maxvel=this->inputs->Max(VelEnum);
+	IssmDouble maxvel=this->inputs->Max(VelEnum);
 
 	/*process units if requested: */
@@ -3046,9 +3101,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MaxVx{{{1*/
-void  Penta::MaxVx(double* pmaxvx, bool process_units){
+/*FUNCTION Penta::MaxVx{{{*/
+void  Penta::MaxVx(IssmDouble* pmaxvx, bool process_units){
 
 	/*Get maximum:*/
-	double maxvx=this->inputs->Max(VxEnum);
+	IssmDouble maxvx=this->inputs->Max(VxEnum);
 
 	/*process units if requested: */
@@ -3059,9 +3114,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MaxVy{{{1*/
-void  Penta::MaxVy(double* pmaxvy, bool process_units){
+/*FUNCTION Penta::MaxVy{{{*/
+void  Penta::MaxVy(IssmDouble* pmaxvy, bool process_units){
 
 	/*Get maximum:*/
-	double maxvy=this->inputs->Max(VyEnum);
+	IssmDouble maxvy=this->inputs->Max(VyEnum);
 
 	/*process units if requested: */
@@ -3072,9 +3127,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::MaxVz{{{1*/
-void  Penta::MaxVz(double* pmaxvz, bool process_units){
+/*FUNCTION Penta::MaxVz{{{*/
+void  Penta::MaxVz(IssmDouble* pmaxvz, bool process_units){
 
 	/*Get maximum:*/
-	double maxvz=this->inputs->Max(VzEnum);
+	IssmDouble maxvz=this->inputs->Max(VzEnum);
 
 	/*process units if requested: */
@@ -3085,6 +3140,6 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ElementResponse{{{1*/
-void Penta::ElementResponse(double* presponse,int response_enum,bool process_units){
+/*FUNCTION Penta::ElementResponse{{{*/
+void Penta::ElementResponse(IssmDouble* presponse,int response_enum,bool process_units){
 
 	switch(response_enum){
@@ -3095,5 +3150,5 @@
 
 			/*Get input:*/
-			double vel;
+			IssmDouble vel;
 			Input* vel_input;
 
@@ -3107,5 +3162,5 @@
 			*presponse=vel;
 		default:  
-			_error_("Response type %s not supported yet!",EnumToStringx(response_enum));
+			_error2_("Response type " << EnumToStringx(response_enum) << " not supported yet!");
 	}
 
@@ -3115,5 +3170,5 @@
 
 #ifdef _HAVE_THERMAL_
-/*FUNCTION Penta::CreateKMatrixEnthalpy {{{1*/
+/*FUNCTION Penta::CreateKMatrixEnthalpy {{{*/
 ElementMatrix* Penta::CreateKMatrixEnthalpy(void){
 	
@@ -3129,5 +3184,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixEnthalpyVolume {{{1*/
+/*FUNCTION Penta::CreateKMatrixEnthalpyVolume {{{*/
 ElementMatrix* Penta::CreateKMatrixEnthalpyVolume(void){
 
@@ -3138,22 +3193,22 @@
 	int        stabilization;
 	int        i,j,ig,found=0;
-	double     Jdet,u,v,w,um,vm,wm;
-	double     h,hx,hy,hz,vx,vy,vz,vel;
-	double     gravity,rho_ice,rho_water;
-	double     epsvel=2.220446049250313e-16;
-	double     heatcapacity,thermalconductivity,dt;
-	double     pressure,enthalpy;
-	double     latentheat,kappa;
-	double     tau_parameter,diameter;
-	double     xyz_list[NUMVERTICES][3];
-	double     B_conduct[3][numdof];
-	double     B_advec[3][numdof];
-	double     Bprime_advec[3][numdof];
-	double     L[numdof];
-	double     dbasis[3][6];
-	double     D_scalar_conduct,D_scalar_advec;
-	double     D_scalar_trans,D_scalar_stab;
-	double     D[3][3];
-	double     K[3][3]={0.0};
+	IssmDouble     Jdet,u,v,w,um,vm,wm;
+	IssmDouble     h,hx,hy,hz,vx,vy,vz,vel;
+	IssmDouble     gravity,rho_ice,rho_water;
+	IssmDouble     epsvel=2.220446049250313e-16;
+	IssmDouble     heatcapacity,thermalconductivity,dt;
+	IssmDouble     pressure,enthalpy;
+	IssmDouble     latentheat,kappa;
+	IssmDouble     tau_parameter,diameter;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     B_conduct[3][numdof];
+	IssmDouble     B_advec[3][numdof];
+	IssmDouble     Bprime_advec[3][numdof];
+	IssmDouble     L[numdof];
+	IssmDouble     dbasis[3][6];
+	IssmDouble     D_scalar_conduct,D_scalar_advec;
+	IssmDouble     D_scalar_trans,D_scalar_stab;
+	IssmDouble     D[3][3];
+	IssmDouble     K[3][3]={0.0};
 	Tria*      tria=NULL;
 	GaussPenta *gauss=NULL;
@@ -3286,5 +3341,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixEnthalpyShelf {{{1*/
+/*FUNCTION Penta::CreateKMatrixEnthalpyShelf {{{*/
 ElementMatrix* Penta::CreateKMatrixEnthalpyShelf(void){
 
@@ -3294,11 +3349,11 @@
 	/*Intermediaries */
 	int       i,j,ig;
-	double    mixed_layer_capacity,thermal_exchange_velocity;
-	double    rho_ice,rho_water,heatcapacity;
-	double    Jdet2d,dt;
-	double    xyz_list[NUMVERTICES][3];
-	double	 xyz_list_tria[NUMVERTICES2D][3];
-	double    basis[NUMVERTICES];
-	double    D_scalar;
+	IssmDouble    mixed_layer_capacity,thermal_exchange_velocity;
+	IssmDouble    rho_ice,rho_water,heatcapacity;
+	IssmDouble    Jdet2d,dt;
+	IssmDouble    xyz_list[NUMVERTICES][3];
+	IssmDouble	 xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble    basis[NUMVERTICES];
+	IssmDouble    D_scalar;
 	GaussPenta *gauss=NULL;
 
@@ -3340,5 +3395,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixMelting {{{1*/
+/*FUNCTION Penta::CreateKMatrixMelting {{{*/
 ElementMatrix* Penta::CreateKMatrixMelting(void){
 
@@ -3352,5 +3407,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixThermal {{{1*/
+/*FUNCTION Penta::CreateKMatrixThermal {{{*/
 ElementMatrix* Penta::CreateKMatrixThermal(void){
 	
@@ -3366,5 +3421,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixThermalVolume {{{1*/
+/*FUNCTION Penta::CreateKMatrixThermalVolume {{{*/
 ElementMatrix* Penta::CreateKMatrixThermalVolume(void){
 
@@ -3375,19 +3430,19 @@
 	int        stabilization;
 	int        i,j,ig,found=0;
-	double     Jdet,u,v,w,um,vm,wm,vel;
-	double     h,hx,hy,hz,vx,vy,vz;
-	double     gravity,rho_ice,rho_water,kappa;
-	double     heatcapacity,thermalconductivity,dt;
-	double     tau_parameter,diameter;
-	double     xyz_list[NUMVERTICES][3];
-	double     B_conduct[3][numdof];
-	double     B_advec[3][numdof];
-	double     Bprime_advec[3][numdof];
-	double     L[numdof];
-	double     dbasis[3][6];
-	double     D_scalar_conduct,D_scalar_advec;
-	double     D_scalar_trans,D_scalar_stab;
-	double     D[3][3];
-	double     K[3][3]={0.0};
+	IssmDouble     Jdet,u,v,w,um,vm,wm,vel;
+	IssmDouble     h,hx,hy,hz,vx,vy,vz;
+	IssmDouble     gravity,rho_ice,rho_water,kappa;
+	IssmDouble     heatcapacity,thermalconductivity,dt;
+	IssmDouble     tau_parameter,diameter;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     B_conduct[3][numdof];
+	IssmDouble     B_advec[3][numdof];
+	IssmDouble     Bprime_advec[3][numdof];
+	IssmDouble     L[numdof];
+	IssmDouble     dbasis[3][6];
+	IssmDouble     D_scalar_conduct,D_scalar_advec;
+	IssmDouble     D_scalar_trans,D_scalar_stab;
+	IssmDouble     D[3][3];
+	IssmDouble     K[3][3]={0.0};
 	Tria*      tria=NULL;
 	GaussPenta *gauss=NULL;
@@ -3518,5 +3573,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixThermalShelf {{{1*/
+/*FUNCTION Penta::CreateKMatrixThermalShelf {{{*/
 ElementMatrix* Penta::CreateKMatrixThermalShelf(void){
 
@@ -3527,11 +3582,11 @@
 	/*Intermediaries */
 	int       i,j,ig;
-	double    mixed_layer_capacity,thermal_exchange_velocity;
-	double    rho_ice,rho_water,heatcapacity;
-	double    Jdet2d,dt;
-	double    xyz_list[NUMVERTICES][3];
-	double	 xyz_list_tria[NUMVERTICES2D][3];
-	double    basis[NUMVERTICES];
-	double    D_scalar;
+	IssmDouble    mixed_layer_capacity,thermal_exchange_velocity;
+	IssmDouble    rho_ice,rho_water,heatcapacity;
+	IssmDouble    Jdet2d,dt;
+	IssmDouble    xyz_list[NUMVERTICES][3];
+	IssmDouble	 xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble    basis[NUMVERTICES];
+	IssmDouble    D_scalar;
 	GaussPenta *gauss=NULL;
 
@@ -3573,5 +3628,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorEnthalpy {{{1*/
+/*FUNCTION Penta::CreatePVectorEnthalpy {{{*/
 ElementVector* Penta::CreatePVectorEnthalpy(void){
 
@@ -3589,5 +3644,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorEnthalpyVolume {{{1*/
+/*FUNCTION Penta::CreatePVectorEnthalpyVolume {{{*/
 ElementVector* Penta::CreatePVectorEnthalpyVolume(void){
 
@@ -3598,17 +3653,17 @@
 	int    i,j,ig,found=0;
 	int    friction_type,stabilization;
-	double Jdet,phi,dt;
-	double rho_ice,heatcapacity;
-	double thermalconductivity,kappa;
-	double viscosity,pressure;
-	double enthalpy,enthalpypicard;
-	double tau_parameter,diameter;
-	double u,v,w;
-	double scalar_def,scalar_transient;
-	double temperature_list[NUMVERTICES];
-	double xyz_list[NUMVERTICES][3];
-	double L[numdof];
-	double dbasis[3][6];
-	double epsilon[6];
+	IssmDouble Jdet,phi,dt;
+	IssmDouble rho_ice,heatcapacity;
+	IssmDouble thermalconductivity,kappa;
+	IssmDouble viscosity,pressure;
+	IssmDouble enthalpy,enthalpypicard;
+	IssmDouble tau_parameter,diameter;
+	IssmDouble u,v,w;
+	IssmDouble scalar_def,scalar_transient;
+	IssmDouble temperature_list[NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble L[numdof];
+	IssmDouble dbasis[3][6];
+	IssmDouble epsilon[6];
 	GaussPenta *gauss=NULL;
 
@@ -3685,5 +3740,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorEnthalpyShelf {{{1*/
+/*FUNCTION Penta::CreatePVectorEnthalpyShelf {{{*/
 ElementVector* Penta::CreatePVectorEnthalpyShelf(void){
 
@@ -3693,11 +3748,11 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     Jdet2d;
-	double     heatcapacity,h_pmp;
-	double     mixed_layer_capacity,thermal_exchange_velocity;
-	double     rho_ice,rho_water,pressure,dt,scalar_ocean;
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3];
-	double     basis[NUMVERTICES];
+	IssmDouble     Jdet2d;
+	IssmDouble     heatcapacity,h_pmp;
+	IssmDouble     mixed_layer_capacity,thermal_exchange_velocity;
+	IssmDouble     rho_ice,rho_water,pressure,dt,scalar_ocean;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble     basis[NUMVERTICES];
 	GaussPenta* gauss=NULL;
 
@@ -3742,5 +3797,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorEnthalpySheet {{{1*/
+/*FUNCTION Penta::CreatePVectorEnthalpySheet {{{*/
 ElementVector* Penta::CreatePVectorEnthalpySheet(void){
 
@@ -3751,12 +3806,12 @@
 	int        i,j,ig;
 	int        analysis_type;
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	double     Jdet2d,dt;
-	double     rho_ice,heatcapacity,geothermalflux_value;
-	double     basalfriction,alpha2,vx,vy;
-	double     scalar,enthalpy,enthalpyup;
-	double     pressure,pressureup;
-	double     basis[NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble     Jdet2d,dt;
+	IssmDouble     rho_ice,heatcapacity,geothermalflux_value;
+	IssmDouble     basalfriction,alpha2,vx,vy;
+	IssmDouble     scalar,enthalpy,enthalpyup;
+	IssmDouble     pressure,pressureup;
+	IssmDouble     basis[NUMVERTICES];
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
@@ -3831,10 +3886,10 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorMelting {{{1*/
+/*FUNCTION Penta::CreatePVectorMelting {{{*/
 ElementVector* Penta::CreatePVectorMelting(void){
 	return NULL;
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorThermal {{{1*/
+/*FUNCTION Penta::CreatePVectorThermal {{{*/
 ElementVector* Penta::CreatePVectorThermal(void){
 
@@ -3852,5 +3907,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorThermalVolume {{{1*/
+/*FUNCTION Penta::CreatePVectorThermalVolume {{{*/
 ElementVector* Penta::CreatePVectorThermalVolume(void){
 
@@ -3861,16 +3916,16 @@
 	int    i,j,ig,found=0;
 	int    friction_type,stabilization;
-	double Jdet,phi,dt;
-	double rho_ice,heatcapacity;
-	double thermalconductivity,kappa;
-	double viscosity,temperature;
-	double tau_parameter,diameter;
-	double u,v,w;
-	double scalar_def,scalar_transient;
-	double temperature_list[NUMVERTICES];
-	double xyz_list[NUMVERTICES][3];
-	double L[numdof];
-	double dbasis[3][6];
-	double epsilon[6];
+	IssmDouble Jdet,phi,dt;
+	IssmDouble rho_ice,heatcapacity;
+	IssmDouble thermalconductivity,kappa;
+	IssmDouble viscosity,temperature;
+	IssmDouble tau_parameter,diameter;
+	IssmDouble u,v,w;
+	IssmDouble scalar_def,scalar_transient;
+	IssmDouble temperature_list[NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble L[numdof];
+	IssmDouble dbasis[3][6];
+	IssmDouble epsilon[6];
 	GaussPenta *gauss=NULL;
 
@@ -3939,5 +3994,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorThermalShelf {{{1*/
+/*FUNCTION Penta::CreatePVectorThermalShelf {{{*/
 ElementVector* Penta::CreatePVectorThermalShelf(void){
 
@@ -3947,11 +4002,11 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     Jdet2d;
-	double     mixed_layer_capacity,thermal_exchange_velocity;
-	double     rho_ice,rho_water,pressure,dt,scalar_ocean;
-	double     heatcapacity,t_pmp;
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3];
-	double     basis[NUMVERTICES];
+	IssmDouble     Jdet2d;
+	IssmDouble     mixed_layer_capacity,thermal_exchange_velocity;
+	IssmDouble     rho_ice,rho_water,pressure,dt,scalar_ocean;
+	IssmDouble     heatcapacity,t_pmp;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble     basis[NUMVERTICES];
 	GaussPenta* gauss=NULL;
 
@@ -3996,5 +4051,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorThermalSheet {{{1*/
+/*FUNCTION Penta::CreatePVectorThermalSheet {{{*/
 ElementVector* Penta::CreatePVectorThermalSheet(void){
 
@@ -4005,11 +4060,11 @@
 	int        i,j,ig;
 	int        analysis_type;
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	double     Jdet2d,dt;
-	double     rho_ice,heatcapacity,geothermalflux_value;
-	double     basalfriction,alpha2,vx,vy;
-	double     basis[NUMVERTICES];
-	double     scalar;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble     Jdet2d,dt;
+	IssmDouble     rho_ice,heatcapacity,geothermalflux_value;
+	IssmDouble     basalfriction,alpha2,vx,vy;
+	IssmDouble     basis[NUMVERTICES];
+	IssmDouble     scalar;
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
@@ -4063,5 +4118,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetSolutionFromInputsThermal{{{1*/
+/*FUNCTION Penta::GetSolutionFromInputsThermal{{{*/
 void  Penta::GetSolutionFromInputsThermal(Vector* solution){
 
@@ -4070,6 +4125,6 @@
 	int          i;
 	int*         doflist=NULL;
-	double       values[numdof];
-	double       temp;
+	IssmDouble       values[numdof];
+	IssmDouble       temp;
 	GaussPenta   *gauss=NULL;
 
@@ -4091,8 +4146,8 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::GetSolutionFromInputsEnthalpy{{{1*/
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::GetSolutionFromInputsEnthalpy{{{*/
 void  Penta::GetSolutionFromInputsEnthalpy(Vector* solution){
 
@@ -4101,6 +4156,6 @@
 	int          i;
 	int*         doflist=NULL;
-	double       values[numdof];
-	double       enthalpy;
+	IssmDouble       values[numdof];
+	IssmDouble       enthalpy;
 	GaussPenta   *gauss=NULL;
 
@@ -4122,9 +4177,9 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionThermal {{{1*/
-void  Penta::InputUpdateFromSolutionThermal(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionThermal {{{*/
+void  Penta::InputUpdateFromSolutionThermal(IssmDouble* solution){
 
 	const int    numdof=NDOF1*NUMVERTICES;
@@ -4132,10 +4187,10 @@
 	bool   converged;
 	int    i,rheology_law;
-	double xyz_list[NUMVERTICES][3];
-	double values[numdof];
-	double B[numdof];
-	double B_average,s_average;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble values[numdof];
+	IssmDouble B[numdof];
+	IssmDouble B_average,s_average;
 	int*   doflist=NULL;
-	//double pressure[numdof];
+	//IssmDouble pressure[numdof];
 
 	/*Get dof list: */
@@ -4150,7 +4205,7 @@
 
 		/*Check solution*/
-		if(isnan(values[i])) _error_("NaN found in solution vector");
-		//if(values[i]<0)      printf("temperature < 0°K found in solution vector\n");
-		//if(values[i]>275)    printf("temperature > 275°K found in solution vector (Paterson's rheology associated is negative)\n");
+		if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
+		//if(values[i]<0)      _printLine_("temperature < 0°K found in solution vector");
+		//if(values[i]>275)    _printLine_("temperature > 275°K found in solution vector (Paterson's rheology associated is negative)");
 	}
 
@@ -4184,5 +4239,5 @@
 				break;
 			default:
-				_error_("Rheology law %s not supported yet",EnumToStringx(rheology_law));
+				_error2_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet");
 
 		}
@@ -4193,9 +4248,9 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionEnthalpy {{{1*/
-void  Penta::InputUpdateFromSolutionEnthalpy(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionEnthalpy {{{*/
+void  Penta::InputUpdateFromSolutionEnthalpy(IssmDouble* solution){
 
 	const int    numdof=NDOF1*NUMVERTICES;
@@ -4203,11 +4258,11 @@
 	bool   converged=false;
 	int    i,rheology_law;
-	double xyz_list[NUMVERTICES][3];
-	double values[numdof];
-	double pressure[NUMVERTICES];
-	double temperatures[numdof];
-	double waterfraction[numdof];
-	double B[numdof];
-	double B_average,s_average;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble values[numdof];
+	IssmDouble pressure[NUMVERTICES];
+	IssmDouble temperatures[numdof];
+	IssmDouble waterfraction[numdof];
+	IssmDouble B[numdof];
+	IssmDouble B_average,s_average;
 	int*   doflist=NULL;
 
@@ -4220,5 +4275,5 @@
 
 		/*Check solution*/
-		if(isnan(values[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -4233,6 +4288,6 @@
 		for(i=0;i<numdof;i++){
 			matpar->EnthalpyToThermal(&temperatures[i],&waterfraction[i],values[i],pressure[i]);
-			if(waterfraction[i]<0) _error_("Negative water fraction found in solution vector");
-			//if(waterfraction[i]>1) _error_("Water fraction >1 found in solution vector");
+			if(waterfraction[i]<0) _error2_("Negative water fraction found in solution vector");
+			//if(waterfraction[i]>1) _error2_("Water fraction >1 found in solution vector");
 		}
 			
@@ -4262,5 +4317,5 @@
 				break;
 			default:
-				_error_("Rheology law %s not supported yet",EnumToStringx(rheology_law));
+				_error2_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet");
 
 		}
@@ -4271,5 +4326,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -4277,5 +4332,5 @@
 
 #ifdef _HAVE_CONTROL_
-/*FUNCTION Penta::ControlInputGetGradient{{{1*/
+/*FUNCTION Penta::ControlInputGetGradient{{{*/
 void Penta::ControlInputGetGradient(Vector* gradient,int enum_type,int control_index){
 
@@ -4290,6 +4345,6 @@
 		input=inputs->GetInput(enum_type);
 	}
-	if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
-	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
+	if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
+	if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
 	GradientIndexing(&doflist1[0],control_index);
@@ -4297,6 +4352,6 @@
 
 }/*}}}*/
-/*FUNCTION Penta::ControlInputScaleGradient{{{1*/
-void Penta::ControlInputScaleGradient(int enum_type,double scale){
+/*FUNCTION Penta::ControlInputScaleGradient{{{*/
+void Penta::ControlInputScaleGradient(int enum_type,IssmDouble scale){
 
 	Input* input=NULL;
@@ -4308,14 +4363,14 @@
 		input=inputs->GetInput(enum_type);
 	}
-	if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
-	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
+	if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
+	if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
 	((ControlInput*)input)->ScaleGradient(scale);
 }/*}}}*/
-/*FUNCTION Penta::ControlInputSetGradient{{{1*/
-void Penta::ControlInputSetGradient(double* gradient,int enum_type,int control_index){
+/*FUNCTION Penta::ControlInputSetGradient{{{*/
+void Penta::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){
 
 	int    doflist1[NUMVERTICES];
-	double grad_list[NUMVERTICES];
+	IssmDouble grad_list[NUMVERTICES];
 	Input* grad_input=NULL;
 	Input* input=NULL;
@@ -4327,6 +4382,6 @@
 		input=inputs->GetInput(enum_type);
 	}
-	if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
-	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
+	if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
+	if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
 	GradientIndexing(&doflist1[0],control_index);
@@ -4336,5 +4391,5 @@
 
 }/*}}}*/
-/*FUNCTION Penta::CreateKMatrixAdjointHoriz{{{1*/
+/*FUNCTION Penta::CreateKMatrixAdjointHoriz{{{*/
 ElementMatrix* Penta::CreateKMatrixAdjointHoriz(void){
 
@@ -4352,9 +4407,9 @@
 			return NULL;
 		default:
-			_error_("Approximation %s not supported yet",EnumToStringx(approximation));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::CreateKMatrixAdjointMacAyeal2d{{{1*/
+			_error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::CreateKMatrixAdjointMacAyeal2d{{{*/
 ElementMatrix* Penta::CreateKMatrixAdjointMacAyeal2d(void){
 
@@ -4379,5 +4434,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixAdjointPattyn{{{1*/
+/*FUNCTION Penta::CreateKMatrixAdjointPattyn{{{*/
 ElementMatrix* Penta::CreateKMatrixAdjointPattyn(void){
 
@@ -4388,13 +4443,13 @@
 	int        i,j,ig;
 	bool       incomplete_adjoint;
-	double     xyz_list[NUMVERTICES][3];
-	double     Jdet;
-	double     eps1dotdphii,eps1dotdphij;
-	double     eps2dotdphii,eps2dotdphij;
-	double     mu_prime;
-	double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	double     eps1[3],eps2[3];
-	double     phi[NUMVERTICES];
-	double     dphi[3][NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jdet;
+	IssmDouble     eps1dotdphii,eps1dotdphij;
+	IssmDouble     eps2dotdphii,eps2dotdphij;
+	IssmDouble     mu_prime;
+	IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble     eps1[3],eps2[3];
+	IssmDouble     phi[NUMVERTICES];
+	IssmDouble     dphi[3][NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
@@ -4447,5 +4502,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixAdjointStokes{{{1*/
+/*FUNCTION Penta::CreateKMatrixAdjointStokes{{{*/
 ElementMatrix* Penta::CreateKMatrixAdjointStokes(void){
 
@@ -4456,14 +4511,14 @@
 	int        i,j,ig;
 	bool       incomplete_adjoint;
-	double     xyz_list[NUMVERTICES][3];
-	double     Jdet;
-	double     eps1dotdphii,eps1dotdphij;
-	double     eps2dotdphii,eps2dotdphij;
-	double     eps3dotdphii,eps3dotdphij;
-	double     mu_prime;
-	double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	double     eps1[3],eps2[3],eps3[3];
-	double     phi[NUMVERTICES];
-	double     dphi[3][NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jdet;
+	IssmDouble     eps1dotdphii,eps1dotdphij;
+	IssmDouble     eps2dotdphii,eps2dotdphij;
+	IssmDouble     eps3dotdphii,eps3dotdphij;
+	IssmDouble     mu_prime;
+	IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble     eps1[3],eps2[3],eps3[3];
+	IssmDouble     phi[NUMVERTICES];
+	IssmDouble     dphi[3][NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
@@ -4526,5 +4581,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorAdjointHoriz{{{1*/
+/*FUNCTION Penta::CreatePVectorAdjointHoriz{{{*/
 ElementVector* Penta::CreatePVectorAdjointHoriz(void){
 
@@ -4542,9 +4597,9 @@
 			return CreatePVectorAdjointStokes();
 		default:
-			_error_("Approximation %s not supported yet",EnumToStringx(approximation));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::CreatePVectorAdjointMacAyeal{{{1*/
+			_error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::CreatePVectorAdjointMacAyeal{{{*/
 ElementVector* Penta::CreatePVectorAdjointMacAyeal(){
 
@@ -4560,5 +4615,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorAdjointPattyn{{{1*/
+/*FUNCTION Penta::CreatePVectorAdjointPattyn{{{*/
 ElementVector* Penta::CreatePVectorAdjointPattyn(void){
 
@@ -4574,5 +4629,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorAdjointStokes{{{1*/
+/*FUNCTION Penta::CreatePVectorAdjointStokes{{{*/
 ElementVector* Penta::CreatePVectorAdjointStokes(void){
 
@@ -4588,5 +4643,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GradientIndexing{{{1*/
+/*FUNCTION Penta::GradientIndexing{{{*/
 void Penta::GradientIndexing(int* indexing,int control_index){
 
@@ -4602,5 +4657,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::Gradj {{{1*/
+/*FUNCTION Penta::Gradj {{{*/
 void  Penta::Gradj(Vector* gradient,int control_type,int control_index){
 	/*dJ/dalpha = ∂L/∂alpha = ∂J/∂alpha + ∂/∂alpha(KU-F)*/
@@ -4631,5 +4686,5 @@
 					break;
 				default:
-					_error_("approximation %s not supported yet",EnumToStringx(approximation));
+					_error2_("approximation " << EnumToStringx(approximation) << " not supported yet");
 			}
 			break;
@@ -4651,10 +4706,10 @@
 					break;
 				default:
-					_error_("approximation %s not supported yet",EnumToStringx(approximation));
+					_error2_("approximation " << EnumToStringx(approximation) << " not supported yet");
 			}
 			break;
 
 		default:
-			_error_("control type %s not supported yet: ",EnumToStringx(control_type));
+			_error2_("control type " << EnumToStringx(control_type) << " not supported yet: ");
 	}
 
@@ -4688,10 +4743,10 @@
 			break;
 		default:
-			_error_("response %s not supported yet",EnumToStringx(responses[resp]));
-	}
-	xfree((void**)&responses);
-}
-/*}}}*/
-/*FUNCTION Penta::GradjDragMacAyeal {{{1*/
+			_error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
+	}
+	xDelete<int>(responses);
+}
+/*}}}*/
+/*FUNCTION Penta::GradjDragMacAyeal {{{*/
 void  Penta::GradjDragMacAyeal(Vector* gradient,int control_index){
 
@@ -4705,5 +4760,5 @@
 
 } /*}}}*/
-/*FUNCTION Penta::GradjDragPattyn {{{1*/
+/*FUNCTION Penta::GradjDragPattyn {{{*/
 void  Penta::GradjDragPattyn(Vector* gradient,int control_index){
 
@@ -4711,12 +4766,12 @@
 	int        analysis_type;
 	int        doflist1[NUMVERTICES];
-	double     vx,vy,lambda,mu,alpha_complement,Jdet;
-	double     bed,thickness,Neff,drag;
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	double     dk[NDOF3]; 
-	double     grade_g[NUMVERTICES]={0.0};
-	double     grade_g_gaussian[NUMVERTICES];
-	double     basis[6];
+	IssmDouble     vx,vy,lambda,mu,alpha_complement,Jdet;
+	IssmDouble     bed,thickness,Neff,drag;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble     dk[NDOF3]; 
+	IssmDouble     grade_g[NUMVERTICES]={0.0};
+	IssmDouble     grade_g_gaussian[NUMVERTICES];
+	IssmDouble     basis[6];
 	Friction*  friction=NULL;
 	GaussPenta  *gauss=NULL;
@@ -4765,5 +4820,5 @@
 		/*Add gradje_g_gaussian vector to gradje_g: */
 		for(i=0;i<NUMVERTICES;i++){
-			_assert_(!isnan(grade_g[i]));
+			_assert_(!xIsNan<IssmDouble>(grade_g[i]));
 			grade_g[i]+=grade_g_gaussian[i];
 		}
@@ -4776,5 +4831,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GradjDragStokes {{{1*/
+/*FUNCTION Penta::GradjDragStokes {{{*/
 void  Penta::GradjDragStokes(Vector* gradient,int control_index){
 
@@ -4782,14 +4837,14 @@
 	int        analysis_type;
 	int        doflist1[NUMVERTICES];
-	double     bed,thickness,Neff;
-	double     lambda,mu,xi,Jdet,vx,vy,vz;
-	double     alpha_complement,drag;
-	double     surface_normal[3],bed_normal[3];
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	double     dk[NDOF3]; 
-	double     basis[6];
-	double     grade_g[NUMVERTICES]={0.0};
-	double     grade_g_gaussian[NUMVERTICES];
+	IssmDouble     bed,thickness,Neff;
+	IssmDouble     lambda,mu,xi,Jdet,vx,vy,vz;
+	IssmDouble     alpha_complement,drag;
+	IssmDouble     surface_normal[3],bed_normal[3];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble     dk[NDOF3]; 
+	IssmDouble     basis[6];
+	IssmDouble     grade_g[NUMVERTICES]={0.0};
+	IssmDouble     grade_g_gaussian[NUMVERTICES];
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
@@ -4868,5 +4923,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GradjBbarMacAyeal {{{1*/
+/*FUNCTION Penta::GradjBbarMacAyeal {{{*/
 void  Penta::GradjBbarMacAyeal(Vector* gradient,int control_index){
 
@@ -4886,5 +4941,5 @@
 
 } /*}}}*/
-/*FUNCTION Penta::GradjBbarPattyn {{{1*/
+/*FUNCTION Penta::GradjBbarPattyn {{{*/
 void  Penta::GradjBbarPattyn(Vector* gradient,int control_index){
 
@@ -4903,5 +4958,5 @@
 	this->matice->inputs->DeleteInput(MaterialsRheologyBbarEnum);
 } /*}}}*/
-/*FUNCTION Penta::GradjBbarStokes {{{1*/
+/*FUNCTION Penta::GradjBbarStokes {{{*/
 void  Penta::GradjBbarStokes(Vector* gradient,int control_index){
 
@@ -4920,6 +4975,6 @@
 	this->matice->inputs->DeleteInput(MaterialsRheologyBbarEnum);
 } /*}}}*/
-/*FUNCTION Penta::InputControlUpdate{{{1*/
-void  Penta::InputControlUpdate(double scalar,bool save_parameter){
+/*FUNCTION Penta::InputControlUpdate{{{*/
+void  Penta::InputControlUpdate(IssmDouble scalar,bool save_parameter){
 
 	/*Intermediary*/
@@ -4942,5 +4997,5 @@
 		}
 
-		if (input->ObjectEnum()!=ControlInputEnum) _error_("input %s is not a ControlInput",EnumToStringx(control_type[i]));
+		if (input->ObjectEnum()!=ControlInputEnum) _error2_("input " << EnumToStringx(control_type[i]) << " is not a ControlInput");
 
 		((ControlInput*)input)->UpdateValue(scalar);
@@ -4955,18 +5010,18 @@
 	/*Clean up and return*/
 cleanup_and_return:
-	xfree((void**)&control_type);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionAdjointStokes {{{1*/
-void  Penta::InputUpdateFromSolutionAdjointStokes(double* solution){
+	xDelete<int>(control_type);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionAdjointStokes {{{*/
+void  Penta::InputUpdateFromSolutionAdjointStokes(IssmDouble* solution){
 
 	const int    numdof=NDOF4*NUMVERTICES;
 
 	int    i;
-	double values[numdof];
-	double lambdax[NUMVERTICES];
-	double lambday[NUMVERTICES];
-	double lambdaz[NUMVERTICES];
-	double lambdap[NUMVERTICES];
+	IssmDouble values[numdof];
+	IssmDouble lambdax[NUMVERTICES];
+	IssmDouble lambday[NUMVERTICES];
+	IssmDouble lambdaz[NUMVERTICES];
+	IssmDouble lambdap[NUMVERTICES];
 	int*   doflist=NULL;
 
@@ -4985,8 +5040,8 @@
 
 		/*Check solution*/
-		if(isnan(lambdax[i])) _error_("NaN found in solution vector");
-		if(isnan(lambday[i])) _error_("NaN found in solution vector");
-		if(isnan(lambdaz[i])) _error_("NaN found in solution vector");
-		if(isnan(lambdap[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambdax[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambday[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambdaz[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambdap[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -4998,16 +5053,16 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionAdjointHoriz {{{1*/
-void  Penta::InputUpdateFromSolutionAdjointHoriz(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionAdjointHoriz {{{*/
+void  Penta::InputUpdateFromSolutionAdjointHoriz(IssmDouble* solution){
 
 	const int numdof=NDOF2*NUMVERTICES;
 
 	int    i;
-	double values[numdof];
-	double lambdax[NUMVERTICES];
-	double lambday[NUMVERTICES];
+	IssmDouble values[numdof];
+	IssmDouble lambdax[NUMVERTICES];
+	IssmDouble lambday[NUMVERTICES];
 	int*   doflist=NULL;
 
@@ -5024,6 +5079,6 @@
 
 		/*Check solution*/
-		if(isnan(lambdax[i]))       _error_("NaN found in solution vector");
-		if(isnan(lambday[i]))       _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambdax[i]))       _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambday[i]))       _error2_("NaN found in solution vector");
 	}
 
@@ -5033,12 +5088,12 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::SurfaceAverageVelMisfit {{{1*/
-double Penta::SurfaceAverageVelMisfit(bool process_units,int weight_index){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::SurfaceAverageVelMisfit {{{*/
+IssmDouble Penta::SurfaceAverageVelMisfit(bool process_units,int weight_index){
 
 	int    approximation;
-	double J;
+	IssmDouble J;
 	Tria*  tria=NULL;
 
@@ -5073,9 +5128,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SurfaceAbsVelMisfit {{{1*/
-double Penta::SurfaceAbsVelMisfit(bool process_units,int weight_index){
+/*FUNCTION Penta::SurfaceAbsVelMisfit {{{*/
+IssmDouble Penta::SurfaceAbsVelMisfit(bool process_units,int weight_index){
 
 	int    approximation;
-	double J;
+	IssmDouble J;
 	Tria*  tria=NULL;
 
@@ -5110,9 +5165,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SurfaceLogVelMisfit {{{1*/
-double Penta::SurfaceLogVelMisfit(bool process_units,int weight_index){
+/*FUNCTION Penta::SurfaceLogVelMisfit {{{*/
+IssmDouble Penta::SurfaceLogVelMisfit(bool process_units,int weight_index){
 
 	int    approximation;
-	double J;
+	IssmDouble J;
 	Tria*  tria=NULL;
 
@@ -5147,8 +5202,8 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SurfaceLogVxVyMisfit {{{1*/
-double Penta::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
-
-	double J;
+/*FUNCTION Penta::SurfaceLogVxVyMisfit {{{*/
+IssmDouble Penta::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
+
+	IssmDouble J;
 	Tria* tria=NULL;
 
@@ -5186,9 +5241,9 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SurfaceRelVelMisfit {{{1*/
-double Penta::SurfaceRelVelMisfit(bool process_units,int weight_index){
+/*FUNCTION Penta::SurfaceRelVelMisfit {{{*/
+IssmDouble Penta::SurfaceRelVelMisfit(bool process_units,int weight_index){
 
 	int    approximation;
-	double J;
+	IssmDouble J;
 	Tria*  tria=NULL;
 
@@ -5223,15 +5278,15 @@
 }
 /*}}}*/
-/*FUNCTION Penta::ThicknessAbsGradient{{{1*/
-double Penta::ThicknessAbsGradient(bool process_units,int weight_index){
-
-	_error_("Not implemented yet");
-}
-/*}}}*/
-/*FUNCTION Penta::ThicknessAbsMisfit {{{1*/
-double Penta::ThicknessAbsMisfit(bool process_units,int weight_index){
+/*FUNCTION Penta::ThicknessAbsGradient{{{*/
+IssmDouble Penta::ThicknessAbsGradient(bool process_units,int weight_index){
+
+	_error2_("Not implemented yet");
+}
+/*}}}*/
+/*FUNCTION Penta::ThicknessAbsMisfit {{{*/
+IssmDouble Penta::ThicknessAbsMisfit(bool process_units,int weight_index){
 
 	int    approximation;
-	double J;
+	IssmDouble J;
 	Tria*  tria=NULL;
 
@@ -5241,5 +5296,5 @@
 	/*If on water, return 0: */
 	if(IsOnWater())return 0;
-	_error_("Not implemented yet");
+	_error2_("Not implemented yet");
 
 	tria=(Tria*)SpawnTria(0,1,2);
@@ -5249,8 +5304,8 @@
 }
 /*}}}*/
-/*FUNCTION Penta::DragCoefficientAbsGradient{{{1*/
-double Penta::DragCoefficientAbsGradient(bool process_units,int weight_index){
-
-	double J;
+/*FUNCTION Penta::DragCoefficientAbsGradient{{{*/
+IssmDouble Penta::DragCoefficientAbsGradient(bool process_units,int weight_index){
+
+	IssmDouble J;
 	Tria*  tria=NULL;
 
@@ -5264,8 +5319,8 @@
 }
 /*}}}*/
-/*FUNCTION Penta::RheologyBbarAbsGradient{{{1*/
-double Penta::RheologyBbarAbsGradient(bool process_units,int weight_index){
-
-	double J;
+/*FUNCTION Penta::RheologyBbarAbsGradient{{{*/
+IssmDouble Penta::RheologyBbarAbsGradient(bool process_units,int weight_index){
+
+	IssmDouble J;
 	Tria*  tria=NULL;
 
@@ -5279,5 +5334,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetVectorFromControlInputs{{{1*/
+/*FUNCTION Penta::GetVectorFromControlInputs{{{*/
 void  Penta::GetVectorFromControlInputs(Vector* vector,int control_enum,int control_index,const char* data){
 
@@ -5292,9 +5347,9 @@
 	/*Get input (either in element or material)*/
 	Input* input=inputs->GetInput(control_enum);
-	if(!input) _error_("Input %s not found in element",EnumToStringx(control_enum));
+	if(!input) _error2_("Input " << EnumToStringx(control_enum) << " not found in element");
 
 	/*Check that it is a ControlInput*/
 	if (input->ObjectEnum()!=ControlInputEnum){
-		_error_("input %s is not a ControlInput",EnumToStringx(control_enum));
+		_error2_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
 	}
 
@@ -5302,8 +5357,8 @@
 }
 /*}}}*/
-/*FUNCTION Penta::SetControlInputsFromVector{{{1*/
-void  Penta::SetControlInputsFromVector(double* vector,int control_enum,int control_index){
-
-	double  values[NUMVERTICES];
+/*FUNCTION Penta::SetControlInputsFromVector{{{*/
+void  Penta::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){
+
+	IssmDouble  values[NUMVERTICES];
 	int     doflist1[NUMVERTICES];
 	Input  *input     = NULL;
@@ -5331,5 +5386,5 @@
 
 	if (input->ObjectEnum()!=ControlInputEnum){
-		_error_("input %s is not a ControlInput",EnumToStringx(control_enum));
+		_error2_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
 	}
 
@@ -5340,6 +5395,6 @@
 
 #ifdef _HAVE_DAKOTA_
-/*FUNCTION Penta::InputUpdateFromVectorDakota(double* vector, int name, int type);{{{1*/
-void  Penta::InputUpdateFromVectorDakota(double* vector, int name, int type){
+/*FUNCTION Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/
+void  Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
 	
 	int i,j;
@@ -5353,5 +5408,5 @@
 
 			/*New PentaP1Input*/
-			double values[6];
+			IssmDouble values[6];
 
 			/*Get values on the 6 vertices*/
@@ -5363,10 +5418,10 @@
 			switch(name){
 				case ThicknessEnum:
-					/*Update thickness + surface: assume bed is constant. On ice shelves, takes hydrostatic equilibrium {{{2*/
-					double  thickness[6];
-					double  thickness_init[6];
-					double  hydrostatic_ratio[6];
-					double  surface[6];
-					double  bed[6];
+					/*Update thickness + surface: assume bed is constant. On ice shelves, takes hydrostatic equilibrium {{{*/
+					IssmDouble  thickness[6];
+					IssmDouble  thickness_init[6];
+					IssmDouble  hydrostatic_ratio[6];
+					IssmDouble  surface[6];
+					IssmDouble  bed[6];
 					
 					/*retrieve inputs: */
@@ -5382,5 +5437,5 @@
 					if (this->IsFloating()){
 						/*hydrostatic equilibrium: */
-						double rho_ice,rho_water,di;
+						IssmDouble rho_ice,rho_water,di;
 						rho_ice=this->matpar->GetRhoIce();
 						rho_water=this->matpar->GetRhoWater();
@@ -5437,28 +5492,28 @@
 
 		default:
-			_error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
-	}
-
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromVectorDakota(int* vector, int name, int type);{{{1*/
+			_error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromVectorDakota(int* vector, int name, int type);{{{*/
 void  Penta::InputUpdateFromVectorDakota(int* vector, int name, int type){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromVectorDakota(bool* vector, int name, int type);{{{1*/
+	_error2_("not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromVectorDakota(bool* vector, int name, int type);{{{*/
 void  Penta::InputUpdateFromVectorDakota(bool* vector, int name, int type){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type);{{{1*/
-void  Penta::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
+	_error2_("not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/
+void  Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
 	
 	int i,j,t;
 	TransientInput* transientinput=NULL;
-	double values[6];
-	double time;
+	IssmDouble values[6];
+	IssmDouble time;
 	int row;
-	double yts;
+	IssmDouble yts;
 
 	/*Check that name is an element input*/
@@ -5478,9 +5533,9 @@
 				for(i=0;i<6;i++){
 					row=this->nodes[i]->GetSidList();
-					values[i]=(double)matrix[ncols*row+t];
+					values[i]=(IssmDouble)matrix[ncols*row+t];
 				}
 
 				/*time? :*/
-				time=(double)matrix[(nrows-1)*ncols+t]*yts;
+				time=(IssmDouble)matrix[(nrows-1)*ncols+t]*yts;
 
 				if(t==0) transientinput=new TransientInput(name);
@@ -5492,5 +5547,5 @@
 
 		default:
-			_error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
+			_error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
 	}
 
@@ -5500,5 +5555,5 @@
 
 #ifdef _HAVE_DIAGNOSTIC_
-/*FUNCTION Penta::CreateDVectorDiagnosticHoriz {{{1*/
+/*FUNCTION Penta::CreateDVectorDiagnosticHoriz {{{*/
 ElementVector* Penta::CreateDVectorDiagnosticHoriz(void){
 
@@ -5514,5 +5569,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateDVectorDiagnosticStokes{{{1*/
+/*FUNCTION Penta::CreateDVectorDiagnosticStokes{{{*/
 ElementVector* Penta::CreateDVectorDiagnosticStokes(void){
 
@@ -5539,5 +5594,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{1*/
+/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{*/
 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattyn(void){
 	
@@ -5553,5 +5608,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynViscous{{{1*/
+/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynViscous{{{*/
 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattynViscous(void){
 
@@ -5564,14 +5619,14 @@
 	/*Intermediaries */
 	int         i,j,ig;
-	double      Jdet;
-	double      viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
-	double      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	double      xyz_list[NUMVERTICES][3];
-	double      B[3][numdofp];
-	double      Bprime[3][numdofm];
-	double      D[3][3]={0.0};            // material matrix, simple scalar matrix.
-	double      D_scalar;
-	double      Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix 
-	double      Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point.
+	IssmDouble      Jdet;
+	IssmDouble      viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
+	IssmDouble      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      B[3][numdofp];
+	IssmDouble      Bprime[3][numdofm];
+	IssmDouble      D[3][3]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble      D_scalar;
+	IssmDouble      Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix 
+	IssmDouble      Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point.
 	GaussPenta *gauss=NULL;
 	GaussTria  *gauss_tria=NULL;
@@ -5646,5 +5701,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynFriction{{{1*/
+/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattynFriction{{{*/
 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattynFriction(void){
 
@@ -5656,15 +5711,15 @@
 	/*Intermediaries */
 	int       i,j,ig,analysis_type;
-	double    Jdet2d,slope_magnitude,alpha2;
-	double    xyz_list[NUMVERTICES][3];
-	double    xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	double    slope[3]={0.0,0.0,0.0};
-	double    MAXSLOPE=.06; // 6 %
-	double    MOUNTAINKEXPONENT=10;
-	double    L[2][numdof];
-	double    DL[2][2]                  ={{ 0,0 },{0,0}}; //for basal drag
-	double    DL_scalar;
-	double    Ke_gg[numdof][numdof]     ={0.0};
-	double    Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
+	IssmDouble    Jdet2d,slope_magnitude,alpha2;
+	IssmDouble    xyz_list[NUMVERTICES][3];
+	IssmDouble    xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble    slope[3]={0.0,0.0,0.0};
+	IssmDouble    MAXSLOPE=.06; // 6 %
+	IssmDouble    MOUNTAINKEXPONENT=10;
+	IssmDouble    L[2][numdof];
+	IssmDouble    DL[2][2]                  ={{ 0,0 },{0,0}}; //for basal drag
+	IssmDouble    DL_scalar;
+	IssmDouble    Ke_gg[numdof][numdof]     ={0.0};
+	IssmDouble    Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
 	Friction  *friction = NULL;
 	GaussPenta *gauss=NULL;
@@ -5714,5 +5769,5 @@
 
 		if (slope_magnitude>MAXSLOPE){
-			alpha2=pow((double)10,MOUNTAINKEXPONENT);
+			alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT);
 		}
 
@@ -5744,5 +5799,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokes{{{1*/
+/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokes{{{*/
 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealStokes(void){
 
@@ -5758,5 +5813,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokesViscous{{{1*/
+/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokesViscous{{{*/
 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealStokesViscous(void){
 
@@ -5769,19 +5824,19 @@
 	/*Intermediaries */
 	int         i,j,ig;
-	double      Jdet;
-	double      viscosity,stokesreconditioning; //viscosity
-	double      epsilon[6]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	double      xyz_list[NUMVERTICES][3];
-	double      B[4][numdofs+3];
-	double      Bprime[4][numdofm];
-	double      B2[3][numdofm];
-	double      Bprime2[3][numdofs+3];
-	double      D[4][4]={0.0};            // material matrix, simple scalar matrix.
-	double      D2[3][3]={0.0};            // material matrix, simple scalar matrix.
-	double      D_scalar;
-	double      Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix 
-	double      Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix 
-	double      Ke_gg_gaussian[numdofs+3][numdofm]; //stiffness matrix evaluated at the gaussian point.
-	double      Ke_gg_gaussian2[numdofm][numdofs+3]; //stiffness matrix evaluated at the gaussian point.
+	IssmDouble      Jdet;
+	IssmDouble      viscosity,stokesreconditioning; //viscosity
+	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      B[4][numdofs+3];
+	IssmDouble      Bprime[4][numdofm];
+	IssmDouble      B2[3][numdofm];
+	IssmDouble      Bprime2[3][numdofs+3];
+	IssmDouble      D[4][4]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble      D2[3][3]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble      D_scalar;
+	IssmDouble      Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix 
+	IssmDouble      Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix 
+	IssmDouble      Ke_gg_gaussian[numdofs+3][numdofm]; //stiffness matrix evaluated at the gaussian point.
+	IssmDouble      Ke_gg_gaussian2[numdofm][numdofs+3]; //stiffness matrix evaluated at the gaussian point.
 	GaussPenta *gauss=NULL;
 	GaussTria  *gauss_tria=NULL;
@@ -5862,5 +5917,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokesFriction {{{1*/
+/*FUNCTION Penta::CreateKMatrixCouplingMacAyealStokesFriction {{{*/
 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealStokesFriction(void){
 
@@ -5876,18 +5931,18 @@
 	int        i,j,ig;
 	int        analysis_type,approximation;
-	double     stokesreconditioning;
-	double     viscosity,alpha2_gauss,Jdet2d;
-	double	  bed_normal[3];
-	double     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double     xyz_list[NUMVERTICES][3];
-	double	  xyz_list_tria[NUMVERTICES2D][3];
-	double     LMacAyealStokes[8][numdof2dm];
-	double     LprimeMacAyealStokes[8][numdof2d];
-	double     DLMacAyealStokes[8][8]={0.0};
-	double     LStokesMacAyeal[4][numdof2d];
-	double     LprimeStokesMacAyeal[4][numdof2dm];
-	double     DLStokesMacAyeal[4][4]={0.0};
-	double     Ke_drag_gaussian[numdof2dm][numdof2d];
-	double     Ke_drag_gaussian2[numdof2d][numdof2dm];
+	IssmDouble     stokesreconditioning;
+	IssmDouble     viscosity,alpha2_gauss,Jdet2d;
+	IssmDouble	  bed_normal[3];
+	IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble	  xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble     LMacAyealStokes[8][numdof2dm];
+	IssmDouble     LprimeMacAyealStokes[8][numdof2d];
+	IssmDouble     DLMacAyealStokes[8][8]={0.0};
+	IssmDouble     LStokesMacAyeal[4][numdof2d];
+	IssmDouble     LprimeStokesMacAyeal[4][numdof2dm];
+	IssmDouble     DLStokesMacAyeal[4][4]={0.0};
+	IssmDouble     Ke_drag_gaussian[numdof2dm][numdof2d];
+	IssmDouble     Ke_drag_gaussian2[numdof2d][numdof2dm];
 	Friction*  friction=NULL;
 	GaussPenta *gauss=NULL;
@@ -5978,5 +6033,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixCouplingPattynStokes{{{1*/
+/*FUNCTION Penta::CreateKMatrixCouplingPattynStokes{{{*/
 ElementMatrix* Penta::CreateKMatrixCouplingPattynStokes(void){
 
@@ -6027,5 +6082,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticHoriz {{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticHoriz {{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticHoriz(void){
 
@@ -6051,9 +6106,9 @@
 			return CreateKMatrixDiagnosticPattynStokes();
 		default:
-			_error_("Approximation %s not supported yet",EnumToStringx(approximation));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticHutter{{{1*/
+			_error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticHutter{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticHutter(void){
 
@@ -6064,5 +6119,5 @@
 	int       connectivity[2];
 	int       i,i0,i1,j0,j1;
-	double    one0,one1;
+	IssmDouble    one0,one1;
 
 	/*Initialize Element matrix*/
@@ -6081,6 +6136,6 @@
 		connectivity[0]=nodes[i]->GetConnectivity();
 		connectivity[1]=nodes[i+3]->GetConnectivity();
-		one0=1/(double)connectivity[0];
-		one1=1/(double)connectivity[1];
+		one0=1/(IssmDouble)connectivity[0];
+		one1=1/(IssmDouble)connectivity[1];
 
 		/*Create matrix for these two nodes*/
@@ -6117,6 +6172,6 @@
 	/*Clean up and return*/
 	return Ke;
-}
-/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal2d{{{1*/
+}/*}}}*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal2d{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal2d(void){
 
@@ -6141,5 +6196,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3d{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3d{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal3d(void){
 
@@ -6155,5 +6210,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3dViscous{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3dViscous{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal3dViscous(void){
 
@@ -6163,14 +6218,14 @@
 	/*Intermediaries */
 	int         i,j,ig,approximation;
-	double      Jdet;
-	double      viscosity, oldviscosity, newviscosity, viscosity_overshoot;
-	double      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	double      epsilons[6]; //6 for stokes
-	double      xyz_list[NUMVERTICES][3];
-	double      B[3][numdof2d];
-	double      Bprime[3][numdof2d];
-	double      D[3][3]={0.0};            // material matrix, simple scalar matrix.
-	double      D_scalar;
-	double      Ke_gg_gaussian[numdof2d][numdof2d]; //stiffness matrix evaluated at the gaussian point.
+	IssmDouble      Jdet;
+	IssmDouble      viscosity, oldviscosity, newviscosity, viscosity_overshoot;
+	IssmDouble      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble      epsilons[6]; //6 for stokes
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      B[3][numdof2d];
+	IssmDouble      Bprime[3][numdof2d];
+	IssmDouble      D[3][3]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble      D_scalar;
+	IssmDouble      Ke_gg_gaussian[numdof2d][numdof2d]; //stiffness matrix evaluated at the gaussian point.
 	Tria*       tria=NULL;
 	Penta*      pentabase=NULL;
@@ -6219,5 +6274,5 @@
 			matice->GetViscosity3dStokes(&newviscosity,&epsilons[0]);
 		}
-		else _error_("approximation %i (%s) not supported yet",approximation,EnumToStringx(approximation));
+		else _error2_("approximation " << approximation << " (" << EnumToStringx(approximation) << ") not supported yet");
 
 		D_scalar=2*newviscosity*gauss->weight*Jdet;
@@ -6243,5 +6298,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3dFriction{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3dFriction{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyeal3dFriction(void){
 
@@ -6260,5 +6315,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyealPattyn{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyealPattyn{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyealPattyn(void){
 
@@ -6276,5 +6331,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyealStokes{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyealStokes{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticMacAyealStokes(void){
 
@@ -6292,5 +6347,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticPattyn{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticPattyn{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticPattyn(void){
 
@@ -6307,5 +6362,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticPattynViscous{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticPattynViscous{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticPattynViscous(void){
 
@@ -6316,12 +6371,12 @@
 	int        i,j,ig;
 	int        approximation;
-	double     xyz_list[NUMVERTICES][3];
-	double     Jdet;
-	double     viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
-	double     epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	double     D_scalar;
-	double     D[5][5]={0.0};            // material matrix, simple scalar matrix.
-	double     B[5][numdof];
-	double     Bprime[5][numdof];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jdet;
+	IssmDouble     viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
+	IssmDouble     epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble     D_scalar;
+	IssmDouble     D[5][5]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble     B[5][numdof];
+	IssmDouble     Bprime[5][numdof];
 	Tria*      tria=NULL;
 	GaussPenta *gauss=NULL;
@@ -6372,5 +6427,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticPattynFriction{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticPattynFriction{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticPattynFriction(void){
 
@@ -6381,13 +6436,13 @@
 	int       i,j,ig;
 	int       analysis_type;
-	double    xyz_list[NUMVERTICES][3];
-	double    xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	double    slope_magnitude,alpha2,Jdet;
-	double    slope[3]={0.0,0.0,0.0};
-	double    MAXSLOPE=.06; // 6 %
-	double    MOUNTAINKEXPONENT=10;
-	double    L[2][numdof];
-	double    DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
-	double    DL_scalar;
+	IssmDouble    xyz_list[NUMVERTICES][3];
+	IssmDouble    xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble    slope_magnitude,alpha2,Jdet;
+	IssmDouble    slope[3]={0.0,0.0,0.0};
+	IssmDouble    MAXSLOPE=.06; // 6 %
+	IssmDouble    MOUNTAINKEXPONENT=10;
+	IssmDouble    L[2][numdof];
+	IssmDouble    DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
+	IssmDouble    DL_scalar;
 	Friction  *friction = NULL;
 	GaussPenta *gauss=NULL;
@@ -6426,5 +6481,5 @@
 		//velocity should be = 0. To achieve this result, we set alpha2_list to a very high value: */
 		if (slope_magnitude>MAXSLOPE){
-			alpha2=pow((double)10,MOUNTAINKEXPONENT);
+			alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT);
 		}
 		
@@ -6447,5 +6502,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticPattynStokes{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticPattynStokes{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticPattynStokes(void){
 
@@ -6463,5 +6518,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticStokes{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticStokes{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticStokes(void){
 
@@ -6477,17 +6532,17 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticStokesViscous {{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticStokesViscous {{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticStokesViscous(void){
 
 	/*Intermediaries */
 	int        i,j,ig,approximation;
-	double     Jdet,viscosity,stokesreconditioning;
-	double     xyz_list[NUMVERTICES][3];
-	double     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double     B[8][27];
-	double     B_prime[8][27];
-	double     D_scalar;
-	double     D[8][8]={0.0};
-	double     Ke_temp[27][27]={0.0}; //for the six nodes and the bubble 
+	IssmDouble     Jdet,viscosity,stokesreconditioning;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble     B[8][27];
+	IssmDouble     B_prime[8][27];
+	IssmDouble     D_scalar;
+	IssmDouble     D[8][8]={0.0};
+	IssmDouble     Ke_temp[27][27]={0.0}; //for the six nodes and the bubble 
 	GaussPenta *gauss=NULL;
 
@@ -6538,5 +6593,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticStokesFriction{{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticStokesFriction{{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticStokesFriction(void){
 
@@ -6548,12 +6603,12 @@
 	int        i,j,ig;
 	int        analysis_type,approximation;
-	double     alpha2,Jdet2d;
-	double     stokesreconditioning,viscosity;
-	double     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double     xyz_list[NUMVERTICES][3];
-	double	  xyz_list_tria[NUMVERTICES2D][3];
-	double     LStokes[2][numdof2d];
-	double     DLStokes[2][2]={0.0};
-	double     Ke_drag_gaussian[numdof2d][numdof2d];
+	IssmDouble     alpha2,Jdet2d;
+	IssmDouble     stokesreconditioning,viscosity;
+	IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble	  xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble     LStokes[2][numdof2d];
+	IssmDouble     DLStokes[2][2]={0.0};
+	IssmDouble     Ke_drag_gaussian[numdof2d][numdof2d];
 	Friction*  friction=NULL;
 	GaussPenta *gauss=NULL;
@@ -6610,5 +6665,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticVert {{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticVert {{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticVert(void){
 	
@@ -6625,5 +6680,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticVertVolume {{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticVertVolume {{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticVertVolume(void){
 
@@ -6633,9 +6688,9 @@
 	/*Intermediaries */
 	int         i,j,ig;
-	double      Jdet;
-	double      xyz_list[NUMVERTICES][3];
-	double      B[NDOF1][NUMVERTICES];
-	double      Bprime[NDOF1][NUMVERTICES];
-	double      DL_scalar;
+	IssmDouble      Jdet;
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      B[NDOF1][NUMVERTICES];
+	IssmDouble      Bprime[NDOF1][NUMVERTICES];
+	IssmDouble      DL_scalar;
 	GaussPenta  *gauss=NULL;
 
@@ -6669,5 +6724,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateKMatrixDiagnosticVertSurface {{{1*/
+/*FUNCTION Penta::CreateKMatrixDiagnosticVertSurface {{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticVertSurface(void){
 
@@ -6679,9 +6734,9 @@
 	/*Intermediaries */
 	int       i,j,ig;
-	double    xyz_list[NUMVERTICES][3];
-	double    xyz_list_tria[NUMVERTICES2D][3];
-	double    surface_normal[3];
-	double    Jdet2d,DL_scalar;
-	double    basis[NUMVERTICES];
+	IssmDouble    xyz_list[NUMVERTICES][3];
+	IssmDouble    xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble    surface_normal[3];
+	IssmDouble    Jdet2d,DL_scalar;
+	IssmDouble    basis[NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
@@ -6716,5 +6771,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokes {{{1*/
+/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokes {{{*/
 ElementVector* Penta::CreatePVectorCouplingMacAyealStokes(void){
 
@@ -6730,5 +6785,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokesViscous {{{1*/
+/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokesViscous {{{*/
 ElementVector* Penta::CreatePVectorCouplingMacAyealStokesViscous(void){
 
@@ -6739,11 +6794,11 @@
 	int         i,j,ig;
 	int         approximation;
-	double      viscosity,Jdet;
-	double      stokesreconditioning;
-	double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double      dw[3];
-	double      xyz_list[NUMVERTICES][3];
-	double      basis[6]; //for the six nodes of the penta
-	double      dbasis[3][6]; //for the six nodes of the penta
+	IssmDouble      viscosity,Jdet;
+	IssmDouble      stokesreconditioning;
+	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble      dw[3];
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      basis[6]; //for the six nodes of the penta
+	IssmDouble      dbasis[3][6]; //for the six nodes of the penta
 	GaussPenta *gauss=NULL;
 
@@ -6792,5 +6847,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokesFriction{{{1*/
+/*FUNCTION Penta::CreatePVectorCouplingMacAyealStokesFriction{{{*/
 ElementVector* Penta::CreatePVectorCouplingMacAyealStokesFriction(void){
 
@@ -6801,13 +6856,13 @@
 	int         i,j,ig;
 	int         approximation,analysis_type;
-	double      Jdet,Jdet2d;
-	double      stokesreconditioning;
-	double	   bed_normal[3];
-	double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double      viscosity, w, alpha2_gauss;
-	double      dw[3];
-	double	   xyz_list_tria[NUMVERTICES2D][3];
-	double      xyz_list[NUMVERTICES][3];
-	double      basis[6]; //for the six nodes of the penta
+	IssmDouble      Jdet,Jdet2d;
+	IssmDouble      stokesreconditioning;
+	IssmDouble	   bed_normal[3];
+	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble      viscosity, w, alpha2_gauss;
+	IssmDouble      dw[3];
+	IssmDouble	   xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      basis[6]; //for the six nodes of the penta
 	Tria*       tria=NULL;
 	Friction*   friction=NULL;
@@ -6867,5 +6922,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorCouplingPattynStokes {{{1*/
+/*FUNCTION Penta::CreatePVectorCouplingPattynStokes {{{*/
 ElementVector* Penta::CreatePVectorCouplingPattynStokes(void){
 
@@ -6881,5 +6936,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorCouplingPattynStokesViscous {{{1*/
+/*FUNCTION Penta::CreatePVectorCouplingPattynStokesViscous {{{*/
 ElementVector* Penta::CreatePVectorCouplingPattynStokesViscous(void){
 
@@ -6890,11 +6945,11 @@
 	int         i,j,ig;
 	int         approximation;
-	double      viscosity,Jdet;
-	double      stokesreconditioning;
-	double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double      dw[3];
-	double      xyz_list[NUMVERTICES][3];
-	double      basis[6]; //for the six nodes of the penta
-	double      dbasis[3][6]; //for the six nodes of the penta
+	IssmDouble      viscosity,Jdet;
+	IssmDouble      stokesreconditioning;
+	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble      dw[3];
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      basis[6]; //for the six nodes of the penta
+	IssmDouble      dbasis[3][6]; //for the six nodes of the penta
 	GaussPenta *gauss=NULL;
 
@@ -6943,5 +6998,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorCouplingPattynStokesFriction{{{1*/
+/*FUNCTION Penta::CreatePVectorCouplingPattynStokesFriction{{{*/
 ElementVector* Penta::CreatePVectorCouplingPattynStokesFriction(void){
 
@@ -6952,13 +7007,13 @@
 	int         i,j,ig;
 	int         approximation,analysis_type;
-	double      Jdet,Jdet2d;
-	double      stokesreconditioning;
-	double	   bed_normal[3];
-	double      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double      viscosity, w, alpha2_gauss;
-	double      dw[3];
-	double	   xyz_list_tria[NUMVERTICES2D][3];
-	double      xyz_list[NUMVERTICES][3];
-	double      basis[6]; //for the six nodes of the penta
+	IssmDouble      Jdet,Jdet2d;
+	IssmDouble      stokesreconditioning;
+	IssmDouble	   bed_normal[3];
+	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble      viscosity, w, alpha2_gauss;
+	IssmDouble      dw[3];
+	IssmDouble	   xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      basis[6]; //for the six nodes of the penta
 	Tria*       tria=NULL;
 	Friction*   friction=NULL;
@@ -7018,5 +7073,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticHoriz{{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticHoriz{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticHoriz(void){
 
@@ -7042,9 +7097,9 @@
 			return CreatePVectorDiagnosticPattynStokes();
 		default:
-			_error_("Approximation %s not supported yet",EnumToStringx(approximation));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticMacAyealPattyn{{{1*/
+			_error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::CreatePVectorDiagnosticMacAyealPattyn{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticMacAyealPattyn(void){
 
@@ -7060,5 +7115,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticMacAyealStokes{{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticMacAyealStokes{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticMacAyealStokes(void){
 
@@ -7076,5 +7131,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticPattynStokes{{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticPattynStokes{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticPattynStokes(void){
 
@@ -7092,5 +7147,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticHutter{{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticHutter{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticHutter(void){
 
@@ -7102,12 +7157,12 @@
 	int          node0,node1;
 	int          connectivity[2];
-	double       Jdet;
-	double       xyz_list[NUMVERTICES][3];
-	double       xyz_list_segment[2][3];
-	double       z_list[NUMVERTICES];
-	double       z_segment[2],slope[2];
-	double       slope2,constant_part;
-	double       rho_ice,gravity,n,B;
-	double       ub,vb,z_g,surface,thickness;
+	IssmDouble       Jdet;
+	IssmDouble       xyz_list[NUMVERTICES][3];
+	IssmDouble       xyz_list_segment[2][3];
+	IssmDouble       z_list[NUMVERTICES];
+	IssmDouble       z_segment[2],slope[2];
+	IssmDouble       slope2,constant_part;
+	IssmDouble       rho_ice,gravity,n,B;
+	IssmDouble       ub,vb,z_g,surface,thickness;
 	GaussPenta*  gauss=NULL;
 
@@ -7157,8 +7212,8 @@
 
 			if (IsOnSurface()){
-				for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight/(double)connectivity[1];
+				for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight/(IssmDouble)connectivity[1];
 			}
 			else{//connectivity is too large, should take only half on it
-				for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight*2/(double)connectivity[1];
+				for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight*2/(IssmDouble)connectivity[1];
 			}
 		}
@@ -7167,10 +7222,10 @@
 		//Deal with lower surface
 		if (IsOnBed()){
-			constant_part=-1.58*pow((double)10.0,-(double)10.0)*rho_ice*gravity*thickness;
+			constant_part=-1.58*pow((IssmDouble)10.0,-(IssmDouble)10.0)*rho_ice*gravity*thickness;
 			ub=constant_part*slope[0];
 			vb=constant_part*slope[1];
 
-			pe->values[2*node0]+=ub/(double)connectivity[0];
-			pe->values[2*node0+1]+=vb/(double)connectivity[0];
+			pe->values[2*node0]+=ub/(IssmDouble)connectivity[0];
+			pe->values[2*node0+1]+=vb/(IssmDouble)connectivity[0];
 		}
 	}
@@ -7180,5 +7235,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticMacAyeal{{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticMacAyeal{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticMacAyeal(void){
 
@@ -7194,5 +7249,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticPattyn{{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticPattyn{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticPattyn(void){
 
@@ -7202,9 +7257,9 @@
 	/*Intermediaries*/
 	int         i,j,ig;
-	double      Jdet;
-	double      slope[3]; //do not put 2! this goes into GetInputDerivativeValue, which addresses slope[3] also!
-	double      driving_stress_baseline,thickness;
-	double      xyz_list[NUMVERTICES][3];
-	double      basis[6];
+	IssmDouble      Jdet;
+	IssmDouble      slope[3]; //do not put 2! this goes into GetInputDerivativeValue, which addresses slope[3] also!
+	IssmDouble      driving_stress_baseline,thickness;
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      basis[6];
 	GaussPenta  *gauss=NULL;
 
@@ -7242,5 +7297,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticStokes {{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticStokes {{{*/
 ElementVector* Penta::CreatePVectorDiagnosticStokes(void){
 
@@ -7256,5 +7311,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticStokesViscous {{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticStokesViscous {{{*/
 ElementVector* Penta::CreatePVectorDiagnosticStokesViscous(void){
 
@@ -7265,17 +7320,17 @@
 	int        i,j,ig;
 	int        approximation;
-	double     Jdet,viscosity;
-	double     gravity,rho_ice,stokesreconditioning;
-	double     xyz_list[NUMVERTICES][3];
-	double     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	double     l1l7[7]; //for the six nodes and the bubble 
-	double     B[8][numdofbubble];
-	double     B_prime[8][numdofbubble];
-	double     B_prime_bubble[8][3];
-	double     D[8][8]={0.0};
-	double     D_scalar;
-	double     Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble 
-	double     Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble 
-	double     Ke_gaussian[numdofbubble][3];
+	IssmDouble     Jdet,viscosity;
+	IssmDouble     gravity,rho_ice,stokesreconditioning;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble     l1l7[7]; //for the six nodes and the bubble 
+	IssmDouble     B[8][numdofbubble];
+	IssmDouble     B_prime[8][numdofbubble];
+	IssmDouble     B_prime_bubble[8][3];
+	IssmDouble     D[8][8]={0.0};
+	IssmDouble     D_scalar;
+	IssmDouble     Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble 
+	IssmDouble     Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble 
+	IssmDouble     Ke_gaussian[numdofbubble][3];
 	GaussPenta *gauss=NULL;
 
@@ -7336,5 +7391,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticStokesShelf{{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticStokesShelf{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticStokesShelf(void){
 
@@ -7342,12 +7397,12 @@
 	int         i,j,ig;
 	int         approximation,shelf_dampening;
-	double      gravity,rho_water,bed,water_pressure;
-	double      damper,normal_vel,vx,vy,vz,dt;
-	double		xyz_list_tria[NUMVERTICES2D][3];
-	double      xyz_list[NUMVERTICES][3];
-	double		bed_normal[3];
-	double      dz[3];
-	double      basis[6]; //for the six nodes of the penta
-	double      Jdet2d;
+	IssmDouble      gravity,rho_water,bed,water_pressure;
+	IssmDouble      damper,normal_vel,vx,vy,vz,dt;
+	IssmDouble		xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble		bed_normal[3];
+	IssmDouble      dz[3];
+	IssmDouble      basis[6]; //for the six nodes of the penta
+	IssmDouble      Jdet2d;
 	GaussPenta  *gauss=NULL;
 
@@ -7404,5 +7459,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticVert {{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticVert {{{*/
 ElementVector* Penta::CreatePVectorDiagnosticVert(void){
 
@@ -7418,5 +7473,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticVertVolume {{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticVertVolume {{{*/
 ElementVector* Penta::CreatePVectorDiagnosticVertVolume(void){
 
@@ -7427,9 +7482,9 @@
 	int        i,ig;
 	int        approximation;
-	double     Jdet;
-	double     xyz_list[NUMVERTICES][3];
-	double     dudx,dvdy,dwdz;
-	double     du[3],dv[3],dw[3];
-	double     basis[6];
+	IssmDouble     Jdet;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     dudx,dvdy,dwdz;
+	IssmDouble     du[3],dv[3],dw[3];
+	IssmDouble     basis[6];
 	GaussPenta *gauss=NULL;
 
@@ -7474,5 +7529,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorDiagnosticVertBase {{{1*/
+/*FUNCTION Penta::CreatePVectorDiagnosticVertBase {{{*/
 ElementVector* Penta::CreatePVectorDiagnosticVertBase(void){
 
@@ -7484,10 +7539,10 @@
 	int        i,j,ig;
 	int        approximation;
-	double     xyz_list[NUMVERTICES][3];
-	double     xyz_list_tria[NUMVERTICES2D][3];
-	double     Jdet2d;
-	double     vx,vy,vz,dbdx,dbdy,basalmeltingvalue;
-	double     slope[3];
-	double     basis[NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble     Jdet2d;
+	IssmDouble     vx,vy,vz,dbdx,dbdy,basalmeltingvalue;
+	IssmDouble     slope[3];
+	IssmDouble     basis[NUMVERTICES];
 	GaussPenta* gauss=NULL;
 
@@ -7539,5 +7594,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateJacobianDiagnosticHoriz{{{1*/
+/*FUNCTION Penta::CreateJacobianDiagnosticHoriz{{{*/
 ElementMatrix* Penta::CreateJacobianDiagnosticHoriz(void){
 
@@ -7555,9 +7610,9 @@
 			return NULL;
 		default:
-			_error_("Approximation %s not supported yet",EnumToStringx(approximation));
-	}
-}
-/*}}}*/
-/*FUNCTION Penta::CreateJacobianDiagnosticMacayeal2d{{{1*/
+			_error2_("Approximation " << EnumToStringx(approximation) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::CreateJacobianDiagnosticMacayeal2d{{{*/
 ElementMatrix* Penta::CreateJacobianDiagnosticMacayeal2d(void){
 
@@ -7582,5 +7637,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateJacobianDiagnosticPattyn{{{1*/
+/*FUNCTION Penta::CreateJacobianDiagnosticPattyn{{{*/
 ElementMatrix* Penta::CreateJacobianDiagnosticPattyn(void){
 
@@ -7590,13 +7645,13 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     xyz_list[NUMVERTICES][3];
-	double     Jdet;
-	double     eps1dotdphii,eps1dotdphij;
-	double     eps2dotdphii,eps2dotdphij;
-	double     mu_prime;
-	double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	double     eps1[3],eps2[3];
-	double     phi[NUMVERTICES];
-	double     dphi[3][NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jdet;
+	IssmDouble     eps1dotdphii,eps1dotdphij;
+	IssmDouble     eps2dotdphii,eps2dotdphij;
+	IssmDouble     mu_prime;
+	IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble     eps1[3],eps2[3];
+	IssmDouble     phi[NUMVERTICES];
+	IssmDouble     dphi[3][NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
@@ -7647,5 +7702,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreateJacobianDiagnosticStokes{{{1*/
+/*FUNCTION Penta::CreateJacobianDiagnosticStokes{{{*/
 ElementMatrix* Penta::CreateJacobianDiagnosticStokes(void){
 
@@ -7655,14 +7710,14 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     xyz_list[NUMVERTICES][3];
-	double     Jdet;
-	double     eps1dotdphii,eps1dotdphij;
-	double     eps2dotdphii,eps2dotdphij;
-	double     eps3dotdphii,eps3dotdphij;
-	double     mu_prime;
-	double     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	double     eps1[3],eps2[3],eps3[3];
-	double     phi[NUMVERTICES];
-	double     dphi[3][NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jdet;
+	IssmDouble     eps1dotdphii,eps1dotdphij;
+	IssmDouble     eps2dotdphii,eps2dotdphij;
+	IssmDouble     eps3dotdphii,eps3dotdphij;
+	IssmDouble     mu_prime;
+	IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble     eps1[3],eps2[3],eps3[3];
+	IssmDouble     phi[NUMVERTICES];
+	IssmDouble     dphi[3][NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
@@ -7723,5 +7778,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::GetSolutionFromInputsDiagnosticHoriz{{{1*/
+/*FUNCTION Penta::GetSolutionFromInputsDiagnosticHoriz{{{*/
 void  Penta::GetSolutionFromInputsDiagnosticHoriz(Vector* solution){
 
@@ -7731,6 +7786,6 @@
 	int          approximation;
 	int*         doflist=NULL;
-	double       vx,vy;
-	double       values[numdof];
+	IssmDouble       vx,vy;
+	IssmDouble       values[numdof];
 	GaussPenta*  gauss;
 
@@ -7762,8 +7817,8 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::GetSolutionFromInputsDiagnosticHutter{{{1*/
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::GetSolutionFromInputsDiagnosticHutter{{{*/
 void  Penta::GetSolutionFromInputsDiagnosticHutter(Vector* solution){
 
@@ -7772,6 +7827,6 @@
 	int          i;
 	int*         doflist=NULL;
-	double       vx,vy;
-	double       values[numdof];
+	IssmDouble       vx,vy;
+	IssmDouble       values[numdof];
 	GaussPenta*  gauss=NULL;
 
@@ -7798,8 +7853,8 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::GetSolutionFromInputsDiagnosticVert{{{1*/
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::GetSolutionFromInputsDiagnosticVert{{{*/
 void  Penta::GetSolutionFromInputsDiagnosticVert(Vector* solution){
 
@@ -7808,6 +7863,6 @@
 	int          i;
 	int*         doflist=NULL;
-	double       vz;
-	double       values[numdof];
+	IssmDouble       vz;
+	IssmDouble       values[numdof];
 	GaussPenta*  gauss=NULL;
 
@@ -7831,8 +7886,8 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::GetSolutionFromInputsDiagnosticStokes{{{1*/
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::GetSolutionFromInputsDiagnosticStokes{{{*/
 void  Penta::GetSolutionFromInputsDiagnosticStokes(Vector* solution){
 
@@ -7841,7 +7896,7 @@
 	int          i;
 	int*         doflist=NULL;
-	double       vx,vy,vz,p;
-	double       stokesreconditioning;
-	double       values[numdof];
+	IssmDouble       vx,vy,vz,p;
+	IssmDouble       stokesreconditioning;
+	IssmDouble       values[numdof];
 	GaussPenta   *gauss;
 
@@ -7876,9 +7931,9 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHoriz {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticHoriz(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHoriz {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticHoriz(IssmDouble* solution){
 
 	int  approximation;
@@ -7915,19 +7970,19 @@
 }
 /*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyeal {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticMacAyeal(double* solution){
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyeal {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticMacAyeal(IssmDouble* solution){
 
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	int     i;
-	double  rho_ice,g;
-	double  values[numdof];
-	double  vx[NUMVERTICES];
-	double  vy[NUMVERTICES];
-	double  vz[NUMVERTICES];
-	double  vel[NUMVERTICES];
-	double  pressure[NUMVERTICES];
-	double  surface[NUMVERTICES];
-	double  xyz_list[NUMVERTICES][3];
+	IssmDouble  rho_ice,g;
+	IssmDouble  values[numdof];
+	IssmDouble  vx[NUMVERTICES];
+	IssmDouble  vy[NUMVERTICES];
+	IssmDouble  vz[NUMVERTICES];
+	IssmDouble  vel[NUMVERTICES];
+	IssmDouble  pressure[NUMVERTICES];
+	IssmDouble  surface[NUMVERTICES];
+	IssmDouble  xyz_list[NUMVERTICES][3];
 	int    *doflist = NULL;
 	Penta  *penta   = NULL;
@@ -7950,6 +8005,6 @@
 
 		/*Check solution*/
-		if(isnan(vx[i])) _error_("NaN found in solution vector");
-		if(isnan(vy[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -7993,9 +8048,9 @@
 	
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealPattyn {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticMacAyealPattyn(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealPattyn {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticMacAyealPattyn(IssmDouble* solution){
 
 	const int    numdof=NDOF2*NUMVERTICES;
@@ -8003,14 +8058,14 @@
 
 	int     i;
-	double  rho_ice,g;
-	double  macayeal_values[numdof];
-	double  pattyn_values[numdof];
-	double  vx[NUMVERTICES];
-	double  vy[NUMVERTICES];
-	double  vz[NUMVERTICES];
-	double  vel[NUMVERTICES];
-	double  pressure[NUMVERTICES];
-	double  surface[NUMVERTICES];
-	double  xyz_list[NUMVERTICES][3];
+	IssmDouble  rho_ice,g;
+	IssmDouble  macayeal_values[numdof];
+	IssmDouble  pattyn_values[numdof];
+	IssmDouble  vx[NUMVERTICES];
+	IssmDouble  vy[NUMVERTICES];
+	IssmDouble  vz[NUMVERTICES];
+	IssmDouble  vel[NUMVERTICES];
+	IssmDouble  pressure[NUMVERTICES];
+	IssmDouble  surface[NUMVERTICES];
+	IssmDouble  xyz_list[NUMVERTICES][3];
 	int*    doflistp = NULL;
 	int*    doflistm = NULL;
@@ -8048,6 +8103,6 @@
 
 		/*Check solution*/
-		if(isnan(vx[i])) _error_("NaN found in solution vector");
-		if(isnan(vy[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -8076,10 +8131,10 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflistp);
-	xfree((void**)&doflistm);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes(double* solution){
+	xDelete<int>(doflistp);
+	xDelete<int>(doflistm);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes(IssmDouble* solution){
 
 	const int    numdofm=NDOF2*NUMVERTICES;
@@ -8088,15 +8143,15 @@
 
 	int     i;
-	double  stokesreconditioning;
-	double  macayeal_values[numdofm];
-	double  stokes_values[numdofs];
-	double  vx[NUMVERTICES];
-	double  vy[NUMVERTICES];
-	double  vz[NUMVERTICES];
-	double  vzmacayeal[NUMVERTICES];
-	double  vzstokes[NUMVERTICES];
-	double  vel[NUMVERTICES];
-	double  pressure[NUMVERTICES];
-	double  xyz_list[NUMVERTICES][3];
+	IssmDouble  stokesreconditioning;
+	IssmDouble  macayeal_values[numdofm];
+	IssmDouble  stokes_values[numdofs];
+	IssmDouble  vx[NUMVERTICES];
+	IssmDouble  vy[NUMVERTICES];
+	IssmDouble  vz[NUMVERTICES];
+	IssmDouble  vzmacayeal[NUMVERTICES];
+	IssmDouble  vzstokes[NUMVERTICES];
+	IssmDouble  vel[NUMVERTICES];
+	IssmDouble  pressure[NUMVERTICES];
+	IssmDouble  xyz_list[NUMVERTICES][3];
 	int*    doflistm        = NULL;
 	int*    doflists        = NULL;
@@ -8136,8 +8191,8 @@
 
 		/*Check solution*/
-		if(isnan(vx[i]))       _error_("NaN found in solution vector");
-		if(isnan(vy[i]))       _error_("NaN found in solution vector");
-		if(isnan(vzstokes[i])) _error_("NaN found in solution vector");
-		if(isnan(pressure[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i]))       _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i]))       _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vzstokes[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(pressure[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -8146,10 +8201,10 @@
 	if (vzmacayeal_input){
 		if (vzmacayeal_input->ObjectEnum()!=PentaP1InputEnum){
-			_error_("Cannot compute Vel as VzMacAyeal is of type %s",EnumToStringx(vzmacayeal_input->ObjectEnum()));
+			_error2_("Cannot compute Vel as VzMacAyeal is of type " << EnumToStringx(vzmacayeal_input->ObjectEnum()));
 		}
 		GetInputListOnVertices(&vzmacayeal[0],VzMacAyealEnum);
 	}
 	else{
-		_error_("Cannot update solution as VzMacAyeal is not present");
+		_error2_("Cannot update solution as VzMacAyeal is not present");
 	}
 
@@ -8176,23 +8231,23 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflistm);
-	xfree((void**)&doflists);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattyn {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticPattyn(double* solution){
+	xDelete<int>(doflistm);
+	xDelete<int>(doflists);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattyn {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticPattyn(IssmDouble* solution){
 	
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	int    i;
-	double rho_ice,g;
-	double values[numdof];
-	double vx[NUMVERTICES];
-	double vy[NUMVERTICES];
-	double vz[NUMVERTICES];
-	double vel[NUMVERTICES];
-	double pressure[NUMVERTICES];
-	double surface[NUMVERTICES];
-	double xyz_list[NUMVERTICES][3];
+	IssmDouble rho_ice,g;
+	IssmDouble values[numdof];
+	IssmDouble vx[NUMVERTICES];
+	IssmDouble vy[NUMVERTICES];
+	IssmDouble vz[NUMVERTICES];
+	IssmDouble vel[NUMVERTICES];
+	IssmDouble pressure[NUMVERTICES];
+	IssmDouble surface[NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
 	int*   doflist = NULL;
 
@@ -8215,6 +8270,6 @@
 
 		/*Check solution*/
-		if(isnan(vx[i])) _error_("NaN found in solution vector");
-		if(isnan(vy[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -8251,9 +8306,9 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattynStokes {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticPattynStokes(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattynStokes {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticPattynStokes(IssmDouble* solution){
 
 	const int    numdofp=NDOF2*NUMVERTICES;
@@ -8261,15 +8316,15 @@
 
 	int    i;
-	double pattyn_values[numdofp];
-	double stokes_values[numdofs];
-	double vx[NUMVERTICES];
-	double vy[NUMVERTICES];
-	double vz[NUMVERTICES];
-	double vzpattyn[NUMVERTICES];
-	double vzstokes[NUMVERTICES];
-	double vel[NUMVERTICES];
-	double pressure[NUMVERTICES];
-	double xyz_list[NUMVERTICES][3];
-	double stokesreconditioning;
+	IssmDouble pattyn_values[numdofp];
+	IssmDouble stokes_values[numdofs];
+	IssmDouble vx[NUMVERTICES];
+	IssmDouble vy[NUMVERTICES];
+	IssmDouble vz[NUMVERTICES];
+	IssmDouble vzpattyn[NUMVERTICES];
+	IssmDouble vzstokes[NUMVERTICES];
+	IssmDouble vel[NUMVERTICES];
+	IssmDouble pressure[NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble stokesreconditioning;
 	int*   doflistp      = NULL;
 	int*   doflists      = NULL;
@@ -8304,8 +8359,8 @@
 
 		/*Check solution*/
-		if(isnan(vx[i]))       _error_("NaN found in solution vector");
-		if(isnan(vy[i]))       _error_("NaN found in solution vector");
-		if(isnan(vzstokes[i])) _error_("NaN found in solution vector");
-		if(isnan(pressure[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i]))       _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i]))       _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vzstokes[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(pressure[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -8314,10 +8369,10 @@
 	if (vzpattyn_input){
 		if (vzpattyn_input->ObjectEnum()!=PentaP1InputEnum){
-			_error_("Cannot compute Vel as VzPattyn is of type %s",EnumToStringx(vzpattyn_input->ObjectEnum()));
+			_error2_("Cannot compute Vel as VzPattyn is of type " << EnumToStringx(vzpattyn_input->ObjectEnum()));
 		}
 		GetInputListOnVertices(&vzpattyn[0],VzPattynEnum);
 	}
 	else{
-		_error_("Cannot update solution as VzPattyn is not present");
+		_error2_("Cannot update solution as VzPattyn is not present");
 	}
 
@@ -8344,23 +8399,23 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflistp);
-	xfree((void**)&doflists);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHutter {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticHutter(double* solution){
+	xDelete<int>(doflistp);
+	xDelete<int>(doflists);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHutter {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){
 	
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	int     i;
-	double  rho_ice,g;
-	double  values[numdof];
-	double  vx[NUMVERTICES];
-	double  vy[NUMVERTICES];
-	double  vz[NUMVERTICES];
-	double  vel[NUMVERTICES];
-	double  pressure[NUMVERTICES];
-	double  surface[NUMVERTICES];
-	double  xyz_list[NUMVERTICES][3];
+	IssmDouble  rho_ice,g;
+	IssmDouble  values[numdof];
+	IssmDouble  vx[NUMVERTICES];
+	IssmDouble  vy[NUMVERTICES];
+	IssmDouble  vz[NUMVERTICES];
+	IssmDouble  vel[NUMVERTICES];
+	IssmDouble  pressure[NUMVERTICES];
+	IssmDouble  surface[NUMVERTICES];
+	IssmDouble  xyz_list[NUMVERTICES][3];
 	int*    doflist = NULL;
 
@@ -8380,6 +8435,6 @@
 
 		/*Check solution*/
-		if(isnan(vx[i])) _error_("NaN found in solution vector");
-		if(isnan(vy[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -8408,9 +8463,9 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticVert {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticVert(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticVert {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticVert(IssmDouble* solution){
 
 	const int numdof=NDOF1*NUMVERTICES;
@@ -8418,16 +8473,16 @@
 	int      i;
 	int      approximation;
-	double   rho_ice,g;
-	double   values[numdof];
-	double   vx[NUMVERTICES];
-	double   vy[NUMVERTICES];
-	double   vz[NUMVERTICES];
-	double   vzmacayeal[NUMVERTICES];
-	double   vzpattyn[NUMVERTICES];
-	double   vzstokes[NUMVERTICES];
-	double   vel[NUMVERTICES];
-	double   pressure[NUMVERTICES];
-	double   surface[NUMVERTICES];
-	double   xyz_list[NUMVERTICES][3];
+	IssmDouble   rho_ice,g;
+	IssmDouble   values[numdof];
+	IssmDouble   vx[NUMVERTICES];
+	IssmDouble   vy[NUMVERTICES];
+	IssmDouble   vz[NUMVERTICES];
+	IssmDouble   vzmacayeal[NUMVERTICES];
+	IssmDouble   vzpattyn[NUMVERTICES];
+	IssmDouble   vzstokes[NUMVERTICES];
+	IssmDouble   vel[NUMVERTICES];
+	IssmDouble   pressure[NUMVERTICES];
+	IssmDouble   surface[NUMVERTICES];
+	IssmDouble   xyz_list[NUMVERTICES][3];
 	int*     doflist      = NULL;
 
@@ -8449,5 +8504,5 @@
 
 		/*Check solution*/
-		if(isnan(vz[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vz[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -8460,8 +8515,8 @@
 		Input* vzstokes_input=inputs->GetInput(VzStokesEnum);
 		if (vzstokes_input){
-			if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum()));
+			if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error2_("Cannot compute Vel as VzStokes is of type " << EnumToStringx(vzstokes_input->ObjectEnum()));
 			GetInputListOnVertices(&vzstokes[0],VzStokesEnum);
 		}
-		else _error_("Cannot compute Vz as VzStokes in not present in PattynStokes element");
+		else _error2_("Cannot compute Vz as VzStokes in not present in PattynStokes element");
 		for(i=0;i<NUMVERTICES;i++){
 			vzpattyn[i]=vz[i];
@@ -8472,8 +8527,8 @@
 		Input* vzstokes_input=inputs->GetInput(VzStokesEnum);
 		if (vzstokes_input){
-			if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error_("Cannot compute Vel as VzStokes is of type %s",EnumToStringx(vzstokes_input->ObjectEnum()));
+			if (vzstokes_input->ObjectEnum()!=PentaP1InputEnum) _error2_("Cannot compute Vel as VzStokes is of type " << EnumToStringx(vzstokes_input->ObjectEnum()));
 			GetInputListOnVertices(&vzstokes[0],VzStokesEnum);
 		}
-		else _error_("Cannot compute Vz as VzStokes in not present in MacAyealStokes element");
+		else _error2_("Cannot compute Vz as VzStokes in not present in MacAyealStokes element");
 		for(i=0;i<NUMVERTICES;i++){
 			vzmacayeal[i]=vz[i];
@@ -8512,20 +8567,20 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{1*/
-void  Penta::InputUpdateFromSolutionDiagnosticStokes(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{*/
+void  Penta::InputUpdateFromSolutionDiagnosticStokes(IssmDouble* solution){
 	
 	const int numdof=NDOF4*NUMVERTICES;
 
 	int     i;
-	double  values[numdof];
-	double  vx[NUMVERTICES];
-	double  vy[NUMVERTICES];
-	double  vz[NUMVERTICES];
-	double  vel[NUMVERTICES];
-	double  pressure[NUMVERTICES];
-	double  stokesreconditioning;
+	IssmDouble  values[numdof];
+	IssmDouble  vx[NUMVERTICES];
+	IssmDouble  vy[NUMVERTICES];
+	IssmDouble  vz[NUMVERTICES];
+	IssmDouble  vel[NUMVERTICES];
+	IssmDouble  pressure[NUMVERTICES];
+	IssmDouble  stokesreconditioning;
 	int*    doflist=NULL;
 
@@ -8547,8 +8602,8 @@
 
 		/*Check solution*/
-		if(isnan(vx[i]))       _error_("NaN found in solution vector");
-		if(isnan(vy[i]))       _error_("NaN found in solution vector");
-		if(isnan(vz[i]))       _error_("NaN found in solution vector");
-		if(isnan(pressure[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i]))       _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i]))       _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vz[i]))       _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(pressure[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -8573,5 +8628,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -8579,5 +8634,5 @@
 
 #ifdef _HAVE_BALANCED_
-/*FUNCTION Penta::CreateKMatrixBalancethickness {{{1*/
+/*FUNCTION Penta::CreateKMatrixBalancethickness {{{*/
 ElementMatrix* Penta::CreateKMatrixBalancethickness(void){
 
@@ -8604,5 +8659,5 @@
 }
 /*}}}*/
-/*FUNCTION Penta::CreatePVectorBalancethickness {{{1*/
+/*FUNCTION Penta::CreatePVectorBalancethickness {{{*/
 ElementVector* Penta::CreatePVectorBalancethickness(void){
 
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Element.h"
 #include "./PentaHook.h"
@@ -44,10 +44,10 @@
 		Results      *results;
 
-		/*Penta constructors and destructor: {{{1*/
+		/*Penta constructors and destructor: {{{*/
 		Penta();
 		Penta(int penta_id,int penta_sid,int i, IoModel* iomodel,int nummodels);
 		~Penta();
 		/*}}}*/
-		/*Object virtual functions definitions: {{{1*/
+		/*Object virtual functions definitions: {{{*/
 		Object*   copy();
 		void	  DeepEcho();
@@ -57,22 +57,22 @@
 		int		  MyRank();
 		/*}}}*/
-		/*Update virtual functions definitions: {{{1*/
+		/*Update virtual functions definitions: {{{*/
 		void  InputUpdateFromConstant(bool constant, int name);
-		void  InputUpdateFromConstant(double constant, int name);
+		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
-		void  InputUpdateFromSolution(double* solutiong);
+		void  InputUpdateFromSolution(IssmDouble* solutiong);
 		void  InputUpdateFromVector(bool* vector, int name, int type);
-		void  InputUpdateFromVector(double* vector, int name, int type);
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVector(int* vector, int name, int type);
 		#ifdef _HAVE_DAKOTA_
 		void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
-		void  InputUpdateFromVectorDakota(double* vector, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(int* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(double* matrix, int nows, int ncols, int name, int type);
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
 		#endif
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel);
 		/*}}}*/
-		/*Element virtual functions definitions: {{{1*/
-		void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part);
+		/*Element virtual functions definitions: {{{*/
+		void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part);
 		void   BasalFrictionCreateInput(void);
 		void   ComputeBasalStress(Vector* sigma_b);
@@ -87,55 +87,56 @@
 		int    GetNodeIndex(Node* node);
 		void   GetSolutionFromInputs(Vector* solution);
-		double GetZcoord(GaussPenta* gauss);
+		IssmDouble GetZcoord(GaussPenta* gauss);
 		void   GetVectorFromInputs(Vector* vector,int name_enum);
 		void   GetVectorFromResults(Vector* vector,int offset,int name_enum,int interp);
 		
 		int    Sid();
-		void   InputArtificialNoise(int enum_type,double min, double max);
-		bool   InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums);
-		void   InputCreate(double scalar,int name,int code);
-		void   InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);
+		void   InputArtificialNoise(int enum_type,IssmDouble min, IssmDouble max);
+		bool   InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums);
+		void   InputCreate(IssmDouble scalar,int name,int code);
+		void   InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);
 		void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum=MeshElementsEnum);
 		void   InputDuplicate(int original_enum,int new_enum);
-		void   InputScale(int enum_type,double scale_factor);
+		void   InputScale(int enum_type,IssmDouble scale_factor);
 		
-		void   InputToResult(int enum_type,int step,double time);
-		void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding);
+		void   InputToResult(int enum_type,int step,IssmDouble time);
+		void   MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding);
 		void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding);
-		void   RequestedOutput(int output_enum,int step,double time);
-		void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results);
+		void   RequestedOutput(int output_enum,int step,IssmDouble time);
+		void   ListResultsInfo(int** results_enums,int** results_size,IssmDouble** results_times,int** results_steps,int* num_results);
 		void   PatchFill(int* pcount, Patch* patch);
 		void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes);
-		void   PositiveDegreeDay(double* pdds,double* pds,double signorm);
+		void   PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm);
 		void   ProcessResultsUnits(void);
 		void   ResetCoordinateSystem(void);
-		double SurfaceArea(void);
+		void   SmbGradients();
+		IssmDouble SurfaceArea(void);
 		void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type);
-		int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
-		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
-		double TimeAdapt();
+		int    UpdatePotentialSheetUngrounding(IssmDouble* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf);
+		int    NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units);
+		IssmDouble TimeAdapt();
 		int*   GetHorizontalNeighboorSids(void);
 		void   ViscousHeatingCreateInput(void);
-		void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
+		void   SmearFunction(Vector* smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius);
 
 		 #ifdef _HAVE_RESPONSES_
-		double IceVolume(void);
-		void   MinVel(double* pminvel, bool process_units);
-		void   MinVx(double* pminvx, bool process_units);
-		void   MinVy(double* pminvy, bool process_units);
-		void   MinVz(double* pminvz, bool process_units);
-		double MassFlux(double* segment,bool process_units);
-		void   MaxAbsVx(double* pmaxabsvx, bool process_units);
-		void   MaxAbsVy(double* pmaxabsvy, bool process_units);
-		void   MaxAbsVz(double* pmaxabsvz, bool process_units);
-		void   MaxVel(double* pmaxvel, bool process_units);
-		void   ElementResponse(double* presponse,int response_enum,bool process_units);
-		void   MaxVx(double* pmaxvx, bool process_units);
-		void   MaxVy(double* pmaxvy, bool process_units);
-		void   MaxVz(double* pmaxvz, bool process_units);
+		IssmDouble IceVolume(void);
+		void   MinVel(IssmDouble* pminvel, bool process_units);
+		void   MinVx(IssmDouble* pminvx, bool process_units);
+		void   MinVy(IssmDouble* pminvy, bool process_units);
+		void   MinVz(IssmDouble* pminvz, bool process_units);
+		IssmDouble MassFlux(IssmDouble* segment,bool process_units);
+		void   MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units);
+		void   MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units);
+		void   MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units);
+		void   MaxVel(IssmDouble* pmaxvel, bool process_units);
+		void   ElementResponse(IssmDouble* presponse,int response_enum,bool process_units);
+		void   MaxVx(IssmDouble* pmaxvx, bool process_units);
+		void   MaxVy(IssmDouble* pmaxvy, bool process_units);
+		void   MaxVz(IssmDouble* pmaxvz, bool process_units);
 		#endif
 
 		#ifdef _HAVE_CONTROL_
-		double DragCoefficientAbsGradient(bool process_units,int weight_index);
+		IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index);
 		void   GradientIndexing(int* indexing,int control_index);
 		void   Gradj(Vector* gradient,int control_type,int control_index);
@@ -147,21 +148,21 @@
 		void   GradjBbarStokes(Vector* gradient,int control_index);
 		void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data);
-		void   SetControlInputsFromVector(double* vector,int control_enum,int control_index);
+		void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);
 		void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index);
-		void   ControlInputScaleGradient(int enum_type,double scale);
-		void   ControlInputSetGradient(double* gradient,int enum_type,int control_index);
-		double RheologyBbarAbsGradient(bool process_units,int weight_index);
-		double ThicknessAbsMisfit(     bool process_units,int weight_index);
-		double SurfaceAbsVelMisfit(    bool process_units,int weight_index);
-		double SurfaceRelVelMisfit(    bool process_units,int weight_index);
-		double SurfaceLogVelMisfit(    bool process_units,int weight_index);
-		double SurfaceLogVxVyMisfit(   bool process_units,int weight_index);
-		double SurfaceAverageVelMisfit(bool process_units,int weight_index);
-		double ThicknessAbsGradient(bool process_units,int weight_index);
-		void   InputControlUpdate(double scalar,bool save_parameter);
-		#endif
-		/*}}}*/
-		/*Penta specific routines:{{{1*/
-		void	  BedNormal(double* bed_normal, double xyz_list[3][3]);
+		void   ControlInputScaleGradient(int enum_type,IssmDouble scale);
+		void   ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index);
+		IssmDouble RheologyBbarAbsGradient(bool process_units,int weight_index);
+		IssmDouble ThicknessAbsMisfit(     bool process_units,int weight_index);
+		IssmDouble SurfaceAbsVelMisfit(    bool process_units,int weight_index);
+		IssmDouble SurfaceRelVelMisfit(    bool process_units,int weight_index);
+		IssmDouble SurfaceLogVelMisfit(    bool process_units,int weight_index);
+		IssmDouble SurfaceLogVxVyMisfit(   bool process_units,int weight_index);
+		IssmDouble SurfaceAverageVelMisfit(bool process_units,int weight_index);
+		IssmDouble ThicknessAbsGradient(bool process_units,int weight_index);
+		void   InputControlUpdate(IssmDouble scalar,bool save_parameter);
+		#endif
+		/*}}}*/
+		/*Penta specific routines:{{{*/
+		void	  BedNormal(IssmDouble* bed_normal, IssmDouble xyz_list[3][3]);
 		ElementMatrix* CreateKMatrixPrognostic(void);
 		ElementMatrix* CreateKMatrixSlope(void);
@@ -173,20 +174,20 @@
 		void    GetConnectivityList(int* connectivity);
 		int     GetElementType(void);
-		void    GetElementSizes(double* hx,double* hy,double* hz);
-		void    GetInputListOnVertices(double* pvalue,int enumtype);
-		void    GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue);
-		void    GetInputValue(double* pvalue,Node* node,int enumtype);
-		void	  GetPhi(double* phi, double*  epsilon, double viscosity);
+		void    GetElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz);
+		void    GetInputListOnVertices(IssmDouble* pvalue,int enumtype);
+		void    GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue);
+		void    GetInputValue(IssmDouble* pvalue,Node* node,int enumtype);
+		void	  GetPhi(IssmDouble* phi, IssmDouble*  epsilon, IssmDouble viscosity);
 		void	  GetSolutionFromInputsEnthalpy(Vector* solutiong);
-		double  GetStabilizationParameter(double u, double v, double w, double diameter, double kappa);
-		void    GetStrainRate3dPattyn(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input);
-		void    GetStrainRate3d(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input);
+		IssmDouble  GetStabilizationParameter(IssmDouble u, IssmDouble v, IssmDouble w, IssmDouble diameter, IssmDouble kappa);
+		void    GetStrainRate3dPattyn(IssmDouble* epsilon,IssmDouble* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input);
+		void    GetStrainRate3d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input, Input* vz_input);
 		Penta*  GetUpperElement(void);
 		Penta*  GetLowerElement(void);
 		Penta*  GetBasalElement(void);
 		void	  InputExtrude(int enum_type,int object_type);
-		void    InputUpdateFromSolutionPrognostic(double* solutiong);
-		void    InputUpdateFromSolutionOneDof(double* solutiong,int enum_type);
-		void    InputUpdateFromSolutionOneDofCollapsed(double* solutiong,int enum_type);
+		void    InputUpdateFromSolutionPrognostic(IssmDouble* solutiong);
+		void    InputUpdateFromSolutionOneDof(IssmDouble* solutiong,int enum_type);
+		void    InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solutiong,int enum_type);
 		bool	  IsInput(int name);
 		bool	  IsOnSurface(void);
@@ -194,12 +195,12 @@
 		bool    IsFloating(void); 
 		bool    IsNodeOnShelf(); 
-		bool    IsNodeOnShelfFromFlags(double* flags);
+		bool    IsNodeOnShelfFromFlags(IssmDouble* flags);
 		bool    IsOnWater(void); 
-		double  MinEdgeLength(double xyz_list[6][3]);
-		void	  ReduceMatrixStokes(double* Ke_reduced, double* Ke_temp);
-		void	  ReduceVectorStokes(double* Pe_reduced, double* Ke_temp, double* Pe_temp);
+		IssmDouble  MinEdgeLength(IssmDouble xyz_list[6][3]);
+		void	  ReduceMatrixStokes(IssmDouble* Ke_reduced, IssmDouble* Ke_temp);
+		void	  ReduceVectorStokes(IssmDouble* Pe_reduced, IssmDouble* Ke_temp, IssmDouble* Pe_temp);
 		void	  SetClone(int* minranks);
 		Tria*	  SpawnTria(int g0, int g1, int g2);
-		void	  SurfaceNormal(double* surface_normal, double xyz_list[3][3]);
+		void	  SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]);
 
 		#ifdef _HAVE_DIAGNOSTIC_
@@ -236,13 +237,13 @@
 		ElementMatrix* CreateJacobianDiagnosticPattyn(void);
 		ElementMatrix* CreateJacobianDiagnosticStokes(void);
-		void           InputUpdateFromSolutionDiagnosticHoriz( double* solutiong);
-		void           InputUpdateFromSolutionDiagnosticMacAyeal( double* solutiong);
-		void           InputUpdateFromSolutionDiagnosticMacAyealPattyn( double* solutiong);
-		void           InputUpdateFromSolutionDiagnosticMacAyealStokes( double* solutiong);
-		void           InputUpdateFromSolutionDiagnosticPattyn( double* solutiong);
-		void           InputUpdateFromSolutionDiagnosticPattynStokes( double* solutiong);
-		void           InputUpdateFromSolutionDiagnosticHutter( double* solutiong);
-		void           InputUpdateFromSolutionDiagnosticVert( double* solutiong);
-		void           InputUpdateFromSolutionDiagnosticStokes( double* solutiong);
+		void           InputUpdateFromSolutionDiagnosticHoriz( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionDiagnosticMacAyeal( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionDiagnosticMacAyealPattyn( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionDiagnosticMacAyealStokes( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionDiagnosticPattyn( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionDiagnosticPattynStokes( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionDiagnosticHutter( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionDiagnosticVert( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionDiagnosticStokes( IssmDouble* solutiong);
 		void	         GetSolutionFromInputsDiagnosticHoriz(Vector* solutiong);
 		void	         GetSolutionFromInputsDiagnosticHutter(Vector* solutiong);
@@ -278,6 +279,6 @@
 		ElementVector* CreatePVectorAdjointPattyn(void);
 		ElementVector* CreatePVectorAdjointStokes(void);
-		void    InputUpdateFromSolutionAdjointHoriz( double* solutiong);
-		void    InputUpdateFromSolutionAdjointStokes( double* solutiong);
+		void    InputUpdateFromSolutionAdjointHoriz( IssmDouble* solutiong);
+		void    InputUpdateFromSolutionAdjointStokes( IssmDouble* solutiong);
 		#endif
 
@@ -303,6 +304,6 @@
 		ElementVector* CreatePVectorThermalSheet(void);
 		void	       GetSolutionFromInputsThermal(Vector* solutiong);
-		void           InputUpdateFromSolutionThermal( double* solutiong);
-		void           InputUpdateFromSolutionEnthalpy( double* solutiong);
+		void           InputUpdateFromSolutionThermal( IssmDouble* solutiong);
+		void           InputUpdateFromSolutionEnthalpy( IssmDouble* solutiong);
 		#endif
 		#ifdef _HAVE_BALANCED_
Index: /issm/trunk/src/c/objects/Elements/PentaHook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaHook.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/PentaHook.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION PentaHook::PentaHook(){{{1*/
+/*FUNCTION PentaHook::PentaHook(){{{*/
 PentaHook::PentaHook(){
 	numanalyses=UNDEF;
@@ -30,5 +30,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaHook::~PentaHook(){{{1*/
+/*FUNCTION PentaHook::~PentaHook(){{{*/
 PentaHook::~PentaHook(){
 
@@ -44,5 +44,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaHook::PentaHook(int in_numanalyses,int matice_id, int matpar_id){{{1*/
+/*FUNCTION PentaHook::PentaHook(int in_numanalyses,int matice_id, int matpar_id){{{*/
 PentaHook::PentaHook(int in_numanalyses,int matice_id, IoModel* iomodel){
 
@@ -67,5 +67,5 @@
 /*}}}*/
 
-/*FUNCTION PentaHook::SetHookNodes{{{1*/
+/*FUNCTION PentaHook::SetHookNodes{{{*/
 void PentaHook::SetHookNodes(int* node_ids,int analysis_counter){
 	this->hnodes[analysis_counter]= new Hook(node_ids,6);
@@ -73,5 +73,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaHook::InitHookNeighbors{{{1*/
+/*FUNCTION PentaHook::InitHookNeighbors{{{*/
 void PentaHook::InitHookNeighbors(int* element_ids){
 	this->hneighbors=new Hook(element_ids,2);
@@ -79,5 +79,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaHook::SpawnTriaHook{{{1*/
+/*FUNCTION PentaHook::SpawnTriaHook{{{*/
 void PentaHook::SpawnTriaHook(TriaHook* triahook,int* indices){
 
Index: /issm/trunk/src/c/objects/Elements/PentaHook.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaHook.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/PentaHook.h	(revision 12706)
@@ -19,5 +19,5 @@
 		Hook*  hneighbors; // 2 elements, first down, second up
 
-		/*FUNCTION constructors, destructors {{{1*/
+		/*FUNCTION constructors, destructors {{{*/
 		PentaHook();
 		PentaHook(int in_numanalyses,int matice_id, IoModel* iomodel);
Index: /issm/trunk/src/c/objects/Elements/PentaRef.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaRef.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/PentaRef.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -26,25 +26,25 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION PentaRef::PentaRef(){{{1*/
+/*FUNCTION PentaRef::PentaRef(){{{*/
 PentaRef::PentaRef(){
 	this->element_type_list=NULL;
 }
 /*}}}*/
-/*FUNCTION PentaRef::PentaRef(int* types,int nummodels){{{1*/
+/*FUNCTION PentaRef::PentaRef(int* types,int nummodels){{{*/
 PentaRef::PentaRef(const int nummodels){
 
 	/*Only allocate pointer*/
-	element_type_list=(int*)xmalloc(nummodels*sizeof(int));
-
-}
-/*}}}*/
-/*FUNCTION PentaRef::~PentaRef(){{{1*/
+	element_type_list=xNew<int>(nummodels);
+
+}
+/*}}}*/
+/*FUNCTION PentaRef::~PentaRef(){{{*/
 PentaRef::~PentaRef(){
-	xfree((void**)&element_type_list);
+	xDelete<int>(element_type_list);
 }
 /*}}}*/
 
 /*Management*/
-/*FUNCTION PentaRef::SetElementType{{{1*/
+/*FUNCTION PentaRef::SetElementType{{{*/
 void PentaRef::SetElementType(int type,int type_counter){
 
@@ -57,6 +57,6 @@
 
 /*Reference Element numerics*/
-/*FUNCTION PentaRef::GetBMacAyealPattyn {{{1*/
-void PentaRef::GetBMacAyealPattyn(double* B, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBMacAyealPattyn {{{*/
+void PentaRef::GetBMacAyealPattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2. 
 	 * For node i, Bi can be expressed in the actual coordinate system
@@ -70,5 +70,5 @@
 	 */
 
-	double dbasis[3][NUMNODESP1];
+	IssmDouble dbasis[3][NUMNODESP1];
 
 	/*Get dbasis in actual coordinate system: */
@@ -88,6 +88,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBMacAyealStokes{{{1*/
-void PentaRef::GetBMacAyealStokes(double* B, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBMacAyealStokes{{{*/
+void PentaRef::GetBMacAyealStokes(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2. 
 	 * For node i, Bi can be expressed in the actual coordinate system
@@ -103,6 +103,6 @@
 
 	int    i;
-	double dh1dh7[3][NUMNODESMINI];
-	double l1l6[NUMNODESP1];
+	IssmDouble dh1dh7[3][NUMNODESMINI];
+	IssmDouble l1l6[NUMNODESP1];
 
 	/*Get dh1dh6 in actual coordinate system: */
@@ -134,6 +134,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBPattyn {{{1*/
-void PentaRef::GetBPattyn(double* B, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBPattyn {{{*/
+void PentaRef::GetBPattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2. 
 	 * For node i, Bi can be expressed in the actual coordinate system
@@ -149,5 +149,5 @@
 	 */
 
-	double dbasis[3][NUMNODESP1];
+	IssmDouble dbasis[3][NUMNODESP1];
 
 	/*Get dbasis in actual coordinate system: */
@@ -174,6 +174,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBprimePattyn {{{1*/
-void PentaRef::GetBprimePattyn(double* B, double* xyz_list, GaussPenta* gauss_coord){
+/*FUNCTION PentaRef::GetBprimePattyn {{{*/
+void PentaRef::GetBprimePattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss_coord){
 	/*Compute B  prime matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2. 
 	 * For node i, Bi can be expressed in the actual coordinate system
@@ -188,5 +188,5 @@
 	 * We assume B has been allocated already, of size: 5x(NDOF2*NUMNODESP1)
 	 */
-	double dbasis[3][NUMNODESP1];
+	IssmDouble dbasis[3][NUMNODESP1];
 
 	/*Get dbasis in actual coordinate system: */
@@ -212,6 +212,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBprimeMacAyealStokes{{{1*/
-void PentaRef::GetBprimeMacAyealStokes(double* Bprime, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBprimeMacAyealStokes{{{*/
+void PentaRef::GetBprimeMacAyealStokes(IssmDouble* Bprime, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Compute Bprime  matrix. Bprime=[Bprime1 Bprime2 Bprime3 Bprime4 Bprime5 Bprime6] where Bprimei is of size 5*NDOF2. 
 	 * For node i, Bprimei can be expressed in the actual coordinate system
@@ -226,5 +226,5 @@
 
 	int    i;
-	double dh1dh7[3][NUMNODESMINI];
+	IssmDouble dh1dh7[3][NUMNODESMINI];
 
 	/*Get dh1dh6 in actual coordinate system: */
@@ -252,6 +252,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBStokes {{{1*/
-void PentaRef::GetBStokes(double* B, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBStokes {{{*/
+void PentaRef::GetBStokes(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
 
 	/*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 3*NDOF4. 
@@ -271,6 +271,6 @@
 	int i;
 
-	double dh1dh7[3][NUMNODESMINI];
-	double l1l6[NUMNODESP1];
+	IssmDouble dh1dh7[3][NUMNODESMINI];
+	IssmDouble l1l6[NUMNODESP1];
 
 	/*Get dh1dh7 in actual coordinate system: */
@@ -319,6 +319,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBprimeStokes {{{1*/
-void PentaRef::GetBprimeStokes(double* B_prime, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBprimeStokes {{{*/
+void PentaRef::GetBprimeStokes(IssmDouble* B_prime, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*	Compute B'  matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2. 
 	 *	For node i, Bi' can be expressed in the actual coordinate system
@@ -338,6 +338,6 @@
 
 	int i;
-	double dh1dh7[3][NUMNODESMINI];
-	double l1l6[NUMNODESP1];
+	IssmDouble dh1dh7[3][NUMNODESMINI];
+	IssmDouble l1l6[NUMNODESP1];
 
 	/*Get dh1dh7 in actual coordinate system: */
@@ -386,6 +386,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBAdvec{{{1*/
-void PentaRef::GetBAdvec(double* B_advec, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBAdvec{{{*/
+void PentaRef::GetBAdvec(IssmDouble* B_advec, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 
 	 * For node i, Bi' can be expressed in the actual coordinate system
@@ -400,5 +400,5 @@
 
 	/*Same thing in the actual coordinate system: */
-	double l1l6[6];
+	IssmDouble l1l6[6];
 
 	/*Get dh1dh2dh3 in actual coordinates system : */
@@ -413,6 +413,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBConduct{{{1*/
-void PentaRef::GetBConduct(double* B_conduct, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBConduct{{{*/
+void PentaRef::GetBConduct(IssmDouble* B_conduct, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 
 	 * For node i, Bi' can be expressed in the actual coordinate system
@@ -427,5 +427,5 @@
 
 	/*Same thing in the actual coordinate system: */
-	double dh1dh6[3][NUMNODESP1];
+	IssmDouble dh1dh6[3][NUMNODESP1];
 
 	/*Get dh1dh2dh3 in actual coordinates system : */
@@ -440,11 +440,11 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBVert{{{1*/
-void PentaRef::GetBVert(double* B, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBVert{{{*/
+void PentaRef::GetBVert(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*	Compute B  matrix. B=[dh1/dz dh2/dz dh3/dz dh4/dz dh5/dz dh6/dz];
 		where hi is the interpolation function for node i.*/
 
 	int i;
-	double dh1dh6[3][NUMNODESP1];
+	IssmDouble dh1dh6[3][NUMNODESP1];
 
 	/*Get dh1dh6 in actual coordinate system: */
@@ -458,6 +458,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBprimeAdvec{{{1*/
-void PentaRef::GetBprimeAdvec(double* Bprime_advec, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBprimeAdvec{{{*/
+void PentaRef::GetBprimeAdvec(IssmDouble* Bprime_advec, IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 
 	 * For node i, Bi' can be expressed in the actual coordinate system
@@ -472,5 +472,5 @@
 
 	/*Same thing in the actual coordinate system: */
-	double dh1dh6[3][NUMNODESP1];
+	IssmDouble dh1dh6[3][NUMNODESP1];
 
 	/*Get dh1dh2dh3 in actual coordinates system : */
@@ -485,6 +485,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetBprimeVert{{{1*/
-void PentaRef::GetBprimeVert(double* B, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetBprimeVert{{{*/
+void PentaRef::GetBprimeVert(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss){
 	/* Compute Bprime  matrix. Bprime=[L1 L2 L3 L4 L5 L6] where Li is the nodal function for node i*/
 
@@ -493,6 +493,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetL{{{1*/
-void PentaRef::GetL(double* L, GaussPenta* gauss, int numdof){
+/*FUNCTION PentaRef::GetL{{{*/
+void PentaRef::GetL(IssmDouble* L, GaussPenta* gauss, int numdof){
 	/*Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof. 
 	 ** For node i, Li can be expressed in the actual coordinate system
@@ -509,5 +509,5 @@
 
 	int i;
-	double l1l6[6];
+	IssmDouble l1l6[6];
 
 	/*Get l1l6 in actual coordinate system: */
@@ -530,6 +530,6 @@
 } 
 /*}}}*/
-/*FUNCTION PentaRef::GetLStokes{{{1*/
-void PentaRef::GetLStokes(double* LStokes, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetLStokes{{{*/
+void PentaRef::GetLStokes(IssmDouble* LStokes, GaussPenta* gauss){
 	/*
 	 * Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof. 
@@ -544,5 +544,5 @@
 
 	const int num_dof=4;
-	double l1l2l3[NUMNODESP1_2d];
+	IssmDouble l1l2l3[NUMNODESP1_2d];
 
 	/*Get l1l2l3 in actual coordinate system: */
@@ -565,6 +565,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetLprimeStokes {{{1*/
-void PentaRef::GetLprimeStokes(double* LprimeStokes, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetLprimeStokes {{{*/
+void PentaRef::GetLprimeStokes(IssmDouble* LprimeStokes, IssmDouble* xyz_list, GaussPenta* gauss){
 
 	/*
@@ -606,6 +606,6 @@
 	int num_dof=4;
 
-	double l1l2l3[NUMNODESP1_2d];
-	double dh1dh6[3][NUMNODESP1];
+	IssmDouble l1l2l3[NUMNODESP1_2d];
+	IssmDouble dh1dh6[3][NUMNODESP1];
 
 	/*Get l1l2l3 in actual coordinate system: */
@@ -677,6 +677,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetLMacAyealStokes {{{1*/
-void PentaRef::GetLMacAyealStokes(double* LStokes, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetLMacAyealStokes {{{*/
+void PentaRef::GetLMacAyealStokes(IssmDouble* LStokes, GaussPenta* gauss){
 	/*
 	 * Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof. 
@@ -697,5 +697,5 @@
 	int num_dof=2;
 
-	double l1l2l3[NUMNODESP1_2d];
+	IssmDouble l1l2l3[NUMNODESP1_2d];
 
 
@@ -727,6 +727,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetLprimeMacAyealStokes {{{1*/
-void PentaRef::GetLprimeMacAyealStokes(double* LprimeStokes, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetLprimeMacAyealStokes {{{*/
+void PentaRef::GetLprimeMacAyealStokes(IssmDouble* LprimeStokes, IssmDouble* xyz_list, GaussPenta* gauss){
 
 	/*
@@ -747,6 +747,6 @@
 	int num_dof=4;
 
-	double l1l2l3[NUMNODESP1_2d];
-	double dh1dh6[3][NUMNODESP1];
+	IssmDouble l1l2l3[NUMNODESP1_2d];
+	IssmDouble dh1dh6[3][NUMNODESP1];
 
 	/*Get l1l2l3 in actual coordinate system: */
@@ -794,6 +794,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetLStokesMacAyeal {{{1*/
-void PentaRef::GetLStokesMacAyeal(double* LStokes, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetLStokesMacAyeal {{{*/
+void PentaRef::GetLStokesMacAyeal(IssmDouble* LStokes, GaussPenta* gauss){
 	/*
 	 * Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof. 
@@ -810,5 +810,5 @@
 	int num_dof=4;
 
-	double l1l2l3[NUMNODESP1_2d];
+	IssmDouble l1l2l3[NUMNODESP1_2d];
 
 
@@ -840,6 +840,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetLprimeStokesMacAyeal {{{1*/
-void PentaRef::GetLprimeStokesMacAyeal(double* LprimeStokes, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetLprimeStokesMacAyeal {{{*/
+void PentaRef::GetLprimeStokesMacAyeal(IssmDouble* LprimeStokes, IssmDouble* xyz_list, GaussPenta* gauss){
 
 	/*
@@ -856,6 +856,6 @@
 	int num_dof=2;
 
-	double l1l2l3[NUMNODESP1_2d];
-	double dh1dh6[3][NUMNODESP1];
+	IssmDouble l1l2l3[NUMNODESP1_2d];
+	IssmDouble dh1dh6[3][NUMNODESP1];
 
 	/*Get l1l2l3 in actual coordinate system: */
@@ -879,6 +879,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetJacobian {{{1*/
-void PentaRef::GetJacobian(double* J, double* xyz_list,GaussPenta* gauss){
+/*FUNCTION PentaRef::GetJacobian {{{*/
+void PentaRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussPenta* gauss){
 
 	int i,j;
@@ -887,10 +887,10 @@
 	 * J is assumed to have been allocated of size NDOF2xNDOF2.*/
 
-	double A1,A2,A3; //area coordinates
-	double xi,eta,zi; //parametric coordinates
-
-	double x1,x2,x3,x4,x5,x6;
-	double y1,y2,y3,y4,y5,y6;
-	double z1,z2,z3,z4,z5,z6;
+	IssmDouble A1,A2,A3; //area coordinates
+	IssmDouble xi,eta,zi; //parametric coordinates
+
+	IssmDouble x1,x2,x3,x4,x5,x6;
+	IssmDouble y1,y2,y3,y4,y5,y6;
+	IssmDouble z1,z2,z3,z4,z5,z6;
 
 	/*Figure out xi,eta and zi (parametric coordinates), for this gaussian point: */
@@ -938,9 +938,9 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetJacobianDeterminant {{{1*/
-void PentaRef::GetJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss){
+/*FUNCTION PentaRef::GetJacobianDeterminant {{{*/
+void PentaRef::GetJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss){
 	/*On a penta, Jacobian varies according to coordinates. We need to get the Jacobian, and take 
 	 * the determinant of it: */
-	double J[3][3];
+	IssmDouble J[3][3];
 
 	/*Get Jacobian*/
@@ -949,14 +949,14 @@
 	/*Get Determinant*/
 	Matrix3x3Determinant(Jdet,&J[0][0]);
-	if(*Jdet<0) _error_("negative jacobian determinant!");
-
-}
-/*}}}*/
-/*FUNCTION PentaRef::GetTriaJacobianDeterminant{{{1*/
-void PentaRef::GetTriaJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss){
+	if(*Jdet<0) _error2_("negative jacobian determinant!");
+
+}
+/*}}}*/
+/*FUNCTION PentaRef::GetTriaJacobianDeterminant{{{*/
+void PentaRef::GetTriaJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss){
 	/*The Jacobian determinant is constant over the element, discard the gaussian points. 
 	 * J is assumed to have been allocated of size NDOF2xNDOF2.*/
 
-	double x1,x2,x3,y1,y2,y3,z1,z2,z3;
+	IssmDouble x1,x2,x3,y1,y2,y3,z1,z2,z3;
 
 	x1=*(xyz_list+3*0+0);
@@ -972,13 +972,13 @@
 	/*Jdet = norm( AB ^ AC ) / (2 * area of the reference triangle), with areaRef=sqrt(3) */
 	*Jdet=SQRT3/6.0*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2.0)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2.0)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2.0),0.5);
-	if(*Jdet<0) _error_("negative jacobian determinant!");
-}
-/*}}}*/
-/*FUNCTION PentaRef::GetSegmentJacobianDeterminant{{{1*/
-void PentaRef::GetSegmentJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss){
+	if(*Jdet<0) _error2_("negative jacobian determinant!");
+}
+/*}}}*/
+/*FUNCTION PentaRef::GetSegmentJacobianDeterminant{{{*/
+void PentaRef::GetSegmentJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss){
 	/*The Jacobian determinant is constant over the element, discard the gaussian points. 
 	 * J is assumed to have been allocated of size NDOF2xNDOF2.*/
 
-	double x1,x2,y1,y2,z1,z2;
+	IssmDouble x1,x2,y1,y2,z1,z2;
 
 	x1=*(xyz_list+3*0+0);
@@ -990,13 +990,13 @@
 
 	*Jdet=1.0/2.0*sqrt(pow(x2-x1,2.) + pow(y2-y1,2.) + pow(z2-z1,2.));
-	if(*Jdet<0) _error_("negative jacobian determinant!");
-
-}
-/*}}}*/
-/*FUNCTION PentaRef::GetJacobianInvert {{{1*/
-void PentaRef::GetJacobianInvert(double* Jinv, double* xyz_list,GaussPenta* gauss){
+	if(*Jdet<0) _error2_("negative jacobian determinant!");
+
+}
+/*}}}*/
+/*FUNCTION PentaRef::GetJacobianInvert {{{*/
+void PentaRef::GetJacobianInvert(IssmDouble* Jinv, IssmDouble* xyz_list,GaussPenta* gauss){
 
 	/*Jacobian*/
-	double J[3][3];
+	IssmDouble J[3][3];
 
 	/*Call Jacobian routine to get the jacobian:*/
@@ -1007,6 +1007,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetNodalFunctionsMINI{{{1*/
-void PentaRef::GetNodalFunctionsMINI(double* l1l7, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetNodalFunctionsMINI{{{*/
+void PentaRef::GetNodalFunctionsMINI(IssmDouble* l1l7, GaussPenta* gauss){
 	/*This routine returns the values of the nodal functions  at the gaussian point.*/
 
@@ -1021,6 +1021,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetNodalFunctionsMINIDerivatives{{{1*/
-void PentaRef::GetNodalFunctionsMINIDerivatives(double* dh1dh7,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetNodalFunctionsMINIDerivatives{{{*/
+void PentaRef::GetNodalFunctionsMINIDerivatives(IssmDouble* dh1dh7,IssmDouble* xyz_list, GaussPenta* gauss){
 
 	/*This routine returns the values of the nodal functions derivatives  (with respect to the 
@@ -1028,6 +1028,6 @@
 
 	int       i;
-	double    dh1dh7_ref[3][NUMNODESMINI];
-	double    Jinv[3][3];
+	IssmDouble    dh1dh7_ref[3][NUMNODESMINI];
+	IssmDouble    Jinv[3][3];
 
 	/*Get derivative values with respect to parametric coordinate system: */
@@ -1052,12 +1052,12 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetNodalFunctionsMINIDerivativesReference{{{1*/
-void PentaRef::GetNodalFunctionsMINIDerivativesReference(double* dl1dl7,GaussPenta* gauss){
+/*FUNCTION PentaRef::GetNodalFunctionsMINIDerivativesReference{{{*/
+void PentaRef::GetNodalFunctionsMINIDerivativesReference(IssmDouble* dl1dl7,GaussPenta* gauss){
 
 	/*This routine returns the values of the nodal functions derivatives  (with respect to the 
 	 * natural coordinate system) at the gaussian point. */
-	double r=gauss->coord2-gauss->coord1;
-	double s=-3.0/SQRT3*(gauss->coord1+gauss->coord2-2.0/3.0);
-	double zeta=gauss->coord4;
+	IssmDouble r=gauss->coord2-gauss->coord1;
+	IssmDouble s=-3.0/SQRT3*(gauss->coord1+gauss->coord2-2.0/3.0);
+	IssmDouble zeta=gauss->coord4;
 
 	/*First nodal function: */
@@ -1098,6 +1098,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetNodalFunctionsP1 {{{1*/
-void PentaRef::GetNodalFunctionsP1(double* l1l6, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetNodalFunctionsP1 {{{*/
+void PentaRef::GetNodalFunctionsP1(IssmDouble* l1l6, GaussPenta* gauss){
 	/*This routine returns the values of the nodal functions  at the gaussian point.*/
 
@@ -1111,11 +1111,11 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetNodalFunctionsP1Derivatives {{{1*/
-void PentaRef::GetNodalFunctionsP1Derivatives(double* dh1dh6,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetNodalFunctionsP1Derivatives {{{*/
+void PentaRef::GetNodalFunctionsP1Derivatives(IssmDouble* dh1dh6,IssmDouble* xyz_list, GaussPenta* gauss){
 
 	/*This routine returns the values of the nodal functions derivatives  (with respect to the 
 	 * actual coordinate system): */
-	double    dh1dh6_ref[NDOF3][NUMNODESP1];
-	double    Jinv[NDOF3][NDOF3];
+	IssmDouble    dh1dh6_ref[NDOF3][NUMNODESP1];
+	IssmDouble    Jinv[NDOF3][NDOF3];
 
 	/*Get derivative values with respect to parametric coordinate system: */
@@ -1140,11 +1140,11 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetNodalFunctionsP1DerivativesReference {{{1*/
-void PentaRef::GetNodalFunctionsP1DerivativesReference(double* dl1dl6,GaussPenta* gauss){
+/*FUNCTION PentaRef::GetNodalFunctionsP1DerivativesReference {{{*/
+void PentaRef::GetNodalFunctionsP1DerivativesReference(IssmDouble* dl1dl6,GaussPenta* gauss){
 
 	/*This routine returns the values of the nodal functions derivatives  (with respect to the 
 	 * natural coordinate system) at the gaussian point. Those values vary along xi,eta,z */
 
-	double A1,A2,A3,z;
+	IssmDouble A1,A2,A3,z;
 
 	A1=gauss->coord1; _assert_(A1>=0 && A1<=1);//first area coordinate value. In term of xi and eta: A1=(1-xi)/2-eta/(2*SQRT3);
@@ -1184,9 +1184,9 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetQuadNodalFunctions {{{1*/
-void PentaRef::GetQuadNodalFunctions(double* l1l4,GaussPenta* gauss,int index1,int index2,int index3,int index4){
+/*FUNCTION PentaRef::GetQuadNodalFunctions {{{*/
+void PentaRef::GetQuadNodalFunctions(IssmDouble* l1l4,GaussPenta* gauss,int index1,int index2,int index3,int index4){
 	/*This routine returns the values of the nodal functions  at the gaussian point.*/
 
-	double BasisFunctions[6];
+	IssmDouble BasisFunctions[6];
 
 	GetNodalFunctionsP1(&BasisFunctions[0],gauss);
@@ -1204,9 +1204,9 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetQuadJacobianDeterminant{{{1*/
-void PentaRef::GetQuadJacobianDeterminant(double* Jdet,double xyz_list[4][3],GaussPenta* gauss){
+/*FUNCTION PentaRef::GetQuadJacobianDeterminant{{{*/
+void PentaRef::GetQuadJacobianDeterminant(IssmDouble* Jdet,IssmDouble xyz_list[4][3],GaussPenta* gauss){
 	/*This routine returns the values of the nodal functions  at the gaussian point.*/
 
-	double x1,x2,x3,x4,y1,y2,y3,y4,z1,z2,z3,z4;
+	IssmDouble x1,x2,x3,x4,y1,y2,y3,y4,z1,z2,z3,z4;
 
 	x1=xyz_list[0][0];
@@ -1226,14 +1226,14 @@
 	/*Area of a trabezoid = altitude * (base1 + base2)/2 */
 	*Jdet= pow(pow(x2-x1,2.) + pow(y2-y1,2.),0.5) * (z4-z1 + z3-z2)/8;
-	if(*Jdet<0) _error_("negative jacobian determinant!");
-
-}
-/*}}}*/
-/*FUNCTION PentaRef::GetInputValue{{{1*/
-void PentaRef::GetInputValue(double* pvalue,double* plist,GaussPenta* gauss){
+	if(*Jdet<0) _error2_("negative jacobian determinant!");
+
+}
+/*}}}*/
+/*FUNCTION PentaRef::GetInputValue{{{*/
+void PentaRef::GetInputValue(IssmDouble* pvalue,IssmDouble* plist,GaussPenta* gauss){
 	/*P1 interpolation on Gauss point*/
 
 	/*intermediary*/
-	double l1l6[6];
+	IssmDouble l1l6[6];
 
 	/*nodal functions: */
@@ -1245,6 +1245,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaRef::GetInputDerivativeValue{{{1*/
-void PentaRef::GetInputDerivativeValue(double* p, double* plist,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaRef::GetInputDerivativeValue{{{*/
+void PentaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussPenta* gauss){
 	/*From node values of parameter p (p_list[0], p_list[1], p_list[2], p_list[3], p_list[4] and p_list[4]), return parameter derivative value at gaussian point specified by gauss_coord:
 	 *   dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx;
@@ -1254,5 +1254,5 @@
 	 *   p is a vector of size 3x1 already allocated.
 	 */
-	double dh1dh6[3][NUMNODESP1];
+	IssmDouble dh1dh6[3][NUMNODESP1];
 
 	/*Get nodal funnctions derivatives in actual coordinate system: */
Index: /issm/trunk/src/c/objects/Elements/PentaRef.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaRef.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/PentaRef.h	(revision 12706)
@@ -23,40 +23,40 @@
 
 		/*Numerics*/
-		void GetNodalFunctionsP1(double* l1l6, GaussPenta* gauss);
-		void GetNodalFunctionsMINI(double* l1l7, GaussPenta* gauss);
-		void GetNodalFunctionsP1Derivatives(double* dh1dh6,double* xyz_list, GaussPenta* gauss);
-		void GetNodalFunctionsMINIDerivatives(double* dh1dh7,double* xyz_list, GaussPenta* gauss);
-		void GetNodalFunctionsP1DerivativesReference(double* dl1dl6,GaussPenta* gauss);
-		void GetNodalFunctionsMINIDerivativesReference(double* dl1dl7,GaussPenta* gauss);
-		void GetQuadNodalFunctions(double* l1l4,GaussPenta* gauss,int index1,int index2,int index3,int index4);
-		void GetQuadJacobianDeterminant(double*  Jdet, double xyz_list[4][3],GaussPenta* gauss);
-		void GetJacobian(double* J, double* xyz_list,GaussPenta* gauss);
-		void GetJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss);
-		void GetTriaJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss);
-		void GetSegmentJacobianDeterminant(double*  Jdet, double* xyz_list,GaussPenta* gauss);
-		void GetJacobianInvert(double*  Jinv, double* xyz_list,GaussPenta* gauss);
-		void GetBMacAyealPattyn(double* B, double* xyz_list, GaussPenta* gauss);
-		void GetBMacAyealStokes(double* B, double* xyz_list, GaussPenta* gauss);
-		void GetBPattyn(double* B, double* xyz_list, GaussPenta* gauss);
-		void GetBStokes(double* B, double* xyz_list, GaussPenta* gauss);
-		void GetBprimeMacAyealStokes(double* Bprime, double* xyz_list, GaussPenta* gauss);
-		void GetBprimePattyn(double* B, double* xyz_list, GaussPenta* gauss);
-		void GetBprimeStokes(double* B_prime, double* xyz_list, GaussPenta* gauss);
-		void GetBprimeVert(double* B, double* xyz_list, GaussPenta* gauss);
-		void GetBAdvec(double* B_advec, double* xyz_list, GaussPenta* gauss);
-		void GetBConduct(double* B_conduct, double* xyz_list, GaussPenta* gauss);
-		void GetBVert(double* B, double* xyz_list, GaussPenta* gauss);
-		void GetBprimeAdvec(double* Bprime_advec, double* xyz_list, GaussPenta* gauss);
-		void GetL(double* L, GaussPenta* gauss,int numdof);
-		void GetLStokes(double* LStokes, GaussPenta* gauss);
-		void GetLprimeStokes(double* LprimeStokes, double* xyz_list, GaussPenta* gauss);
-		void GetLMacAyealStokes(double* LMacAyealStokes, GaussPenta* gauss);
-		void GetLprimeMacAyealStokes(double* LprimeMacAyealStokes, double* xyz_list, GaussPenta* gauss);
-		void GetLStokesMacAyeal(double* LStokesMacAyeal, GaussPenta* gauss);
-		void GetLprimeStokesMacAyeal(double* LprimeStokesMacAyeal, double* xyz_list, GaussPenta* gauss);
-		void GetInputValue(double* pvalue,double* plist, GaussPenta* gauss);
-		void GetInputValue(double* pvalue,double* plist,GaussTria* gauss){_error_("only PentaGauss are supported");};
-		void GetInputDerivativeValue(double* pvalues, double* plist,double* xyz_list, GaussPenta* gauss);
-		void GetInputDerivativeValue(double* pvalues, double* plist,double* xyz_list, GaussTria* gauss){_error_("only PentaGauss are supported");};
+		void GetNodalFunctionsP1(IssmDouble* l1l6, GaussPenta* gauss);
+		void GetNodalFunctionsMINI(IssmDouble* l1l7, GaussPenta* gauss);
+		void GetNodalFunctionsP1Derivatives(IssmDouble* dh1dh6,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetNodalFunctionsMINIDerivatives(IssmDouble* dh1dh7,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetNodalFunctionsP1DerivativesReference(IssmDouble* dl1dl6,GaussPenta* gauss);
+		void GetNodalFunctionsMINIDerivativesReference(IssmDouble* dl1dl7,GaussPenta* gauss);
+		void GetQuadNodalFunctions(IssmDouble* l1l4,GaussPenta* gauss,int index1,int index2,int index3,int index4);
+		void GetQuadJacobianDeterminant(IssmDouble*  Jdet, IssmDouble xyz_list[4][3],GaussPenta* gauss);
+		void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussPenta* gauss);
+		void GetJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss);
+		void GetTriaJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss);
+		void GetSegmentJacobianDeterminant(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussPenta* gauss);
+		void GetJacobianInvert(IssmDouble*  Jinv, IssmDouble* xyz_list,GaussPenta* gauss);
+		void GetBMacAyealPattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBMacAyealStokes(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBPattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBStokes(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBprimeMacAyealStokes(IssmDouble* Bprime, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBprimePattyn(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBprimeStokes(IssmDouble* B_prime, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBprimeVert(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBAdvec(IssmDouble* B_advec, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBConduct(IssmDouble* B_conduct, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBVert(IssmDouble* B, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetBprimeAdvec(IssmDouble* Bprime_advec, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetL(IssmDouble* L, GaussPenta* gauss,int numdof);
+		void GetLStokes(IssmDouble* LStokes, GaussPenta* gauss);
+		void GetLprimeStokes(IssmDouble* LprimeStokes, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetLMacAyealStokes(IssmDouble* LMacAyealStokes, GaussPenta* gauss);
+		void GetLprimeMacAyealStokes(IssmDouble* LprimeMacAyealStokes, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetLStokesMacAyeal(IssmDouble* LStokesMacAyeal, GaussPenta* gauss);
+		void GetLprimeStokesMacAyeal(IssmDouble* LprimeStokesMacAyeal, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetInputValue(IssmDouble* pvalue,IssmDouble* plist, GaussPenta* gauss);
+		void GetInputValue(IssmDouble* pvalue,IssmDouble* plist,GaussTria* gauss){_error2_("only PentaGauss are supported");};
+		void GetInputDerivativeValue(IssmDouble* pvalues, IssmDouble* plist,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetInputDerivativeValue(IssmDouble* pvalues, IssmDouble* plist,IssmDouble* xyz_list, GaussTria* gauss){_error2_("only PentaGauss are supported");};
 
 };
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -23,5 +23,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION Tria::Tria(){{{1*/
+/*FUNCTION Tria::Tria(){{{*/
 Tria::Tria(){
 
@@ -38,5 +38,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::Tria(int id, int sid,int index, IoModel* iomodel,int nummodels){{{1*/
+/*FUNCTION Tria::Tria(int id, int sid,int index, IoModel* iomodel,int nummodels){{{*/
 Tria::Tria(int tria_id, int tria_sid, int index, IoModel* iomodel,int nummodels)
 	:TriaRef(nummodels)
@@ -66,5 +66,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::~Tria(){{{1*/
+/*FUNCTION Tria::~Tria(){{{*/
 Tria::~Tria(){
 	delete inputs;
@@ -73,5 +73,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::copy {{{1*/
+/*FUNCTION Tria::copy {{{*/
 Object* Tria::copy() {
 
@@ -82,5 +82,5 @@
 
 	//deal with TriaRef mother class
-	tria->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
+	tria->element_type_list=xNew<int>(this->numanalyses);
 	for(i=0;i<this->numanalyses;i++) tria->element_type_list[i]=this->element_type_list[i];
 
@@ -111,5 +111,5 @@
 
 	/*recover objects: */
-	tria->nodes=(Node**)xmalloc(3*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
+	tria->nodes=xNew<Node*>(3); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
 	for(i=0;i<3;i++)tria->nodes[i]=this->nodes[i];
 	tria->matice=(Matice*)tria->hmatice->delivers();
@@ -124,6 +124,6 @@
 
 /*Other*/
-/*FUNCTION Tria::AverageOntoPartition {{{1*/
-void  Tria::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part){
+/*FUNCTION Tria::AverageOntoPartition {{{*/
+void  Tria::AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){
 
 	bool      already=false;
@@ -132,7 +132,7 @@
 	int       offsetsid[NUMVERTICES];
 	int       offsetdof[NUMVERTICES];
-	double    area;
-	double    mean;
-	double    values[3];
+	IssmDouble    area;
+	IssmDouble    mean;
+	IssmDouble    values[3];
 
 	/*First, get the area: */
@@ -144,5 +144,5 @@
 	mean=0;
 	for(i=0;i<NUMVERTICES;i++){
-		partition[i]=(int)qmu_part[offsetsid[i]];
+		partition[i]=reCast<int>(qmu_part[offsetsid[i]]);
 		mean=mean+1.0/NUMVERTICES*vertex_response[offsetdof[i]];
 	}
@@ -164,5 +164,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrix {{{1*/
+/*FUNCTION Tria::CreateKMatrix {{{*/
 void  Tria::CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df){
 
@@ -172,5 +172,5 @@
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 
-	/*Checks in debugging mode{{{2*/
+	/*Checks in debugging mode{{{*/
 	_assert_(this->nodes && this->matice && this->matpar && this->parameters && this->inputs);
 	/*}}}*/
@@ -214,5 +214,5 @@
 		#endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -224,5 +224,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixMelting {{{1*/
+/*FUNCTION Tria::CreateKMatrixMelting {{{*/
 ElementMatrix* Tria::CreateKMatrixMelting(void){
 
@@ -232,8 +232,8 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     heatcapacity,latentheat;
-	double     Jdet,D_scalar;
-	double     xyz_list[NUMVERTICES][3];
-	double     L[3];
+	IssmDouble     heatcapacity,latentheat;
+	IssmDouble     Jdet,D_scalar;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     L[3];
 	GaussTria *gauss=NULL;
 
@@ -268,5 +268,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixPrognostic {{{1*/
+/*FUNCTION Tria::CreateKMatrixPrognostic {{{*/
 ElementMatrix* Tria::CreateKMatrixPrognostic(void){
 
@@ -277,10 +277,10 @@
 			return CreateKMatrixPrognostic_DG();
 		default:
-			_error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
-	}
-
-}
-/*}}}*/
-/*FUNCTION Tria::CreateKMatrixPrognostic_CG {{{1*/
+			_error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Tria::CreateKMatrixPrognostic_CG {{{*/
 ElementMatrix* Tria::CreateKMatrixPrognostic_CG(void){
 
@@ -291,16 +291,16 @@
 	int        stabilization;
 	int        i,j,ig,dim;
-	double     Jdettria,DL_scalar,dt,h;
-	double     vel,vx,vy,dvxdx,dvydy;
-	double     dvx[2],dvy[2];
-	double     v_gauss[2]={0.0};
-	double     xyz_list[NUMVERTICES][3];
-	double     L[NUMVERTICES];
-	double     B[2][NUMVERTICES];
-	double     Bprime[2][NUMVERTICES];
-	double     K[2][2]                        ={0.0};
-	double     KDL[2][2]                      ={0.0};
-	double     DL[2][2]                        ={0.0};
-	double     DLprime[2][2]                   ={0.0};
+	IssmDouble     Jdettria,DL_scalar,dt,h;
+	IssmDouble     vel,vx,vy,dvxdx,dvydy;
+	IssmDouble     dvx[2],dvy[2];
+	IssmDouble     v_gauss[2]={0.0};
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     L[NUMVERTICES];
+	IssmDouble     B[2][NUMVERTICES];
+	IssmDouble     Bprime[2][NUMVERTICES];
+	IssmDouble     K[2][2]                        ={0.0};
+	IssmDouble     KDL[2][2]                      ={0.0};
+	IssmDouble     DL[2][2]                        ={0.0};
+	IssmDouble     DLprime[2][2]                   ={0.0};
 	GaussTria *gauss=NULL;
 
@@ -402,5 +402,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixPrognostic_DG {{{1*/
+/*FUNCTION Tria::CreateKMatrixPrognostic_DG {{{*/
 ElementMatrix* Tria::CreateKMatrixPrognostic_DG(void){
 
@@ -410,12 +410,12 @@
 	/*Intermediaries */
 	int        i,j,ig,dim;
-	double     xyz_list[NUMVERTICES][3];
-	double     Jdettria,dt,vx,vy;
-	double     L[NUMVERTICES];
-	double     B[2][NUMVERTICES];
-	double     Bprime[2][NUMVERTICES];
-	double     DL[2][2]={0.0};
-	double     DLprime[2][2]={0.0};
-	double     DL_scalar;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jdettria,dt,vx,vy;
+	IssmDouble     L[NUMVERTICES];
+	IssmDouble     B[2][NUMVERTICES];
+	IssmDouble     Bprime[2][NUMVERTICES];
+	IssmDouble     DL[2][2]={0.0};
+	IssmDouble     DLprime[2][2]={0.0};
+	IssmDouble     DL_scalar;
 	GaussTria  *gauss=NULL;
 
@@ -477,5 +477,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixSlope {{{1*/
+/*FUNCTION Tria::CreateKMatrixSlope {{{*/
 ElementMatrix* Tria::CreateKMatrixSlope(void){
 
@@ -485,7 +485,7 @@
 	/* Intermediaries */
 	int        i,j,ig;
-	double     DL_scalar,Jdet;
-	double     xyz_list[NUMVERTICES][3];
-	double     L[1][3];
+	IssmDouble     DL_scalar,Jdet;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     L[1][3];
 	GaussTria *gauss = NULL;
 
@@ -517,5 +517,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVector {{{1*/
+/*FUNCTION Tria::CreatePVector {{{*/
 void  Tria::CreatePVector(Vector* pf){
 
@@ -568,5 +568,5 @@
 		#endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -578,5 +578,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorPrognostic{{{1*/
+/*FUNCTION Tria::CreatePVectorPrognostic{{{*/
 ElementVector* Tria::CreatePVectorPrognostic(void){
 
@@ -587,9 +587,9 @@
 			return CreatePVectorPrognostic_DG();
 		default:
-			_error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
-	}
-}
-/*}}}*/
-/*FUNCTION Tria::CreatePVectorPrognostic_CG {{{1*/
+			_error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Tria::CreatePVectorPrognostic_CG {{{*/
 ElementVector* Tria::CreatePVectorPrognostic_CG(void){
 
@@ -599,8 +599,8 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     Jdettria,dt;
-	double     surface_mass_balance_g,basal_melting_g,basal_melting_correction_g,thickness_g;
-	double     xyz_list[NUMVERTICES][3];
-	double     L[NUMVERTICES];
+	IssmDouble     Jdettria,dt;
+	IssmDouble     surface_mass_balance_g,basal_melting_g,basal_melting_correction_g,thickness_g;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     L[NUMVERTICES];
 	GaussTria* gauss=NULL;
 
@@ -642,5 +642,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorPrognostic_DG {{{1*/
+/*FUNCTION Tria::CreatePVectorPrognostic_DG {{{*/
 ElementVector* Tria::CreatePVectorPrognostic_DG(void){
 
@@ -650,8 +650,8 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     Jdettria,dt;
-	double     surface_mass_balance_g,basal_melting_g,thickness_g;
-	double     xyz_list[NUMVERTICES][3];
-	double     L[NUMVERTICES];
+	IssmDouble     Jdettria,dt;
+	IssmDouble     surface_mass_balance_g,basal_melting_g,thickness_g;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     L[NUMVERTICES];
 	GaussTria* gauss=NULL;
 
@@ -687,5 +687,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorSlope {{{1*/
+/*FUNCTION Tria::CreatePVectorSlope {{{*/
 ElementVector* Tria::CreatePVectorSlope(void){
 
@@ -696,8 +696,8 @@
 	int        i,j,ig;
 	int        analysis_type;
-	double     Jdet;
-	double     xyz_list[NUMVERTICES][3];
-	double     slope[2];
-	double     basis[3];
+	IssmDouble     Jdet;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     slope[2];
+	IssmDouble     basis[3];
 	GaussTria* gauss=NULL;
 
@@ -740,5 +740,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateJacobianMatrix{{{1*/
+/*FUNCTION Tria::CreateJacobianMatrix{{{*/
 void  Tria::CreateJacobianMatrix(Matrix* Jff){
 
@@ -748,5 +748,5 @@
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 
-	/*Checks in debugging {{{2*/
+	/*Checks in debugging {{{*/
 	_assert_(this->nodes && this->matice && this->matpar && this->parameters && this->inputs);
 	/*}}}*/
@@ -763,5 +763,5 @@
 #endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -773,27 +773,27 @@
 }
 /*}}}*/
-/*FUNCTION Tria::ComputeBasalStress {{{1*/
+/*FUNCTION Tria::ComputeBasalStress {{{*/
 void  Tria::ComputeBasalStress(Vector* eps){
-	_error_("Not Implemented yet");
-}
-/*}}}*/
-/*FUNCTION Tria::ComputeStrainRate {{{1*/
+	_error2_("Not Implemented yet");
+}
+/*}}}*/
+/*FUNCTION Tria::ComputeStrainRate {{{*/
 void  Tria::ComputeStrainRate(Vector* eps){
-	_error_("Not Implemented yet");
-}
-/*}}}*/
-/*FUNCTION Tria::ComputeStressTensor {{{1*/
+	_error2_("Not Implemented yet");
+}
+/*}}}*/
+/*FUNCTION Tria::ComputeStressTensor {{{*/
 void  Tria::ComputeStressTensor(){
 
 	int         iv;
-	double      xyz_list[NUMVERTICES][3];
-	double      pressure,viscosity;
-	double      epsilon[3]; /* epsilon=[exx,eyy,exy];*/
-	double      sigma_xx[NUMVERTICES];
-	double		sigma_yy[NUMVERTICES];
-	double		sigma_zz[NUMVERTICES]={0,0,0};
-	double      sigma_xy[NUMVERTICES];
-	double		sigma_xz[NUMVERTICES]={0,0,0};
-	double		sigma_yz[NUMVERTICES]={0,0,0};
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      pressure,viscosity;
+	IssmDouble      epsilon[3]; /* epsilon=[exx,eyy,exy];*/
+	IssmDouble      sigma_xx[NUMVERTICES];
+	IssmDouble		sigma_yy[NUMVERTICES];
+	IssmDouble		sigma_zz[NUMVERTICES]={0,0,0};
+	IssmDouble      sigma_xy[NUMVERTICES];
+	IssmDouble		sigma_xz[NUMVERTICES]={0,0,0};
+	IssmDouble		sigma_yz[NUMVERTICES]={0,0,0};
 	GaussTria* gauss=NULL;
 
@@ -834,5 +834,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::Configure {{{1*/
+/*FUNCTION Tria::Configure {{{*/
 void  Tria::Configure(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
 	
@@ -864,9 +864,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::DeepEcho{{{1*/
+/*FUNCTION Tria::DeepEcho{{{*/
 void Tria::DeepEcho(void){
 
-	printf("Tria:\n");
-	printf("   id: %i\n",id);
+	_printLine_("Tria:");
+	_printLine_("   id: " << id);
 	if(nodes){
 		nodes[0]->DeepEcho();
@@ -874,30 +874,30 @@
 		nodes[2]->DeepEcho();
 	}
-	else printf("nodes = NULL\n");
+	else _printLine_("nodes = NULL");
 
 	if (matice) matice->DeepEcho();
-	else printf("matice = NULL\n");
+	else _printLine_("matice = NULL");
 
 	if (matpar) matpar->DeepEcho();
-	else printf("matpar = NULL\n");
-
-	printf("   parameters\n");
+	else _printLine_("matpar = NULL");
+
+	_printLine_("   parameters");
 	if (parameters) parameters->DeepEcho();
-	else printf("parameters = NULL\n");
-
-	printf("   inputs\n");
+	else _printLine_("parameters = NULL");
+
+	_printLine_("   inputs");
 	if (inputs) inputs->DeepEcho();
-	else printf("inputs=NULL\n");
+	else _printLine_("inputs=NULL");
 
 	if (results) results->DeepEcho();
-	else printf("results=NULL\n");
-
-	printf("neighboor sids: \n");
-	printf(" %i %i %i\n",horizontalneighborsids[0],horizontalneighborsids[1],horizontalneighborsids[2]);
+	else _printLine_("results=NULL");
+
+	_printLine_("neighboor sids: ");
+	_printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]);
 	
 	return;
 }
 /*}}}*/
-/*FUNCTION Tria::DeleteResults {{{1*/
+/*FUNCTION Tria::DeleteResults {{{*/
 void  Tria::DeleteResults(void){
 
@@ -908,8 +908,8 @@
 }
 /*}}}*/
-/*FUNCTION Tria::Echo{{{1*/
+/*FUNCTION Tria::Echo{{{*/
 void Tria::Echo(void){
-	printf("Tria:\n");
-	printf("   id: %i\n",id);
+	_printLine_("Tria:");
+	_printLine_("   id: " << id);
 	if(nodes){
 		nodes[0]->Echo();
@@ -917,28 +917,28 @@
 		nodes[2]->Echo();
 	}
-	else printf("nodes = NULL\n");
+	else _printLine_("nodes = NULL");
 
 	if (matice) matice->Echo();
-	else printf("matice = NULL\n");
+	else _printLine_("matice = NULL");
 
 	if (matpar) matpar->Echo();
-	else printf("matpar = NULL\n");
-
-	printf("   parameters\n");
+	else _printLine_("matpar = NULL");
+
+	_printLine_("   parameters");
 	if (parameters) parameters->Echo();
-	else printf("parameters = NULL\n");
-
-	printf("   inputs\n");
+	else _printLine_("parameters = NULL");
+
+	_printLine_("   inputs");
 	if (inputs) inputs->Echo();
-	else printf("inputs=NULL\n");
+	else _printLine_("inputs=NULL");
 
 	if (results) results->Echo();
-	else printf("results=NULL\n");
-
-	printf("neighboor sids: \n");
-	printf(" %i %i %i\n",horizontalneighborsids[0],horizontalneighborsids[1],horizontalneighborsids[2]);
-}
-/*}}}*/
-/*FUNCTION Tria::ObjectEnum{{{1*/
+	else _printLine_("results=NULL");
+
+	_printLine_("neighboor sids: ");
+	_printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]);
+}
+/*}}}*/
+/*FUNCTION Tria::ObjectEnum{{{*/
 int Tria::ObjectEnum(void){
 
@@ -947,10 +947,10 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetArea {{{1*/
-double Tria::GetArea(void){
-
-	double area=0;
-	double xyz_list[NUMVERTICES][3];
-	double x1,y1,x2,y2,x3,y3;
+/*FUNCTION Tria::GetArea {{{*/
+IssmDouble Tria::GetArea(void){
+
+	IssmDouble area=0;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble x1,y1,x2,y2,x3,y3;
 
 	/*Get xyz list: */
@@ -964,5 +964,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetDofList {{{1*/
+/*FUNCTION Tria::GetDofList {{{*/
 void  Tria::GetDofList(int** pdoflist, int approximation_enum,int setenum){
 
@@ -974,5 +974,5 @@
 	/*First, figure out size of doflist and create it: */
 	for(i=0;i<3;i++) numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
-	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+	doflist=xNew<int>(numberofdofs);
 
 	/*Populate: */
@@ -987,5 +987,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetDofList1 {{{1*/
+/*FUNCTION Tria::GetDofList1 {{{*/
 void  Tria::GetDofList1(int* doflist){
 
@@ -995,5 +995,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetElementType {{{1*/
+/*FUNCTION Tria::GetElementType {{{*/
 int Tria::GetElementType(){
 
@@ -1003,5 +1003,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetHorizontalNeighboorSids {{{1*/
+/*FUNCTION Tria::GetHorizontalNeighboorSids {{{*/
 int* Tria::GetHorizontalNeighboorSids(){
 
@@ -1011,5 +1011,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetNodeIndex {{{1*/
+/*FUNCTION Tria::GetNodeIndex {{{*/
 int Tria::GetNodeIndex(Node* node){
 
@@ -1019,17 +1019,17 @@
 		 return i;
 	}
-	_error_("Node provided not found among element nodes");
-}
-/*}}}*/
-/*FUNCTION Tria::GetInputListOnVertices(double* pvalue,int enumtype) {{{1*/
-void Tria::GetInputListOnVertices(double* pvalue,int enumtype){
+	_error2_("Node provided not found among element nodes");
+}
+/*}}}*/
+/*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype) {{{*/
+void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){
 
 	/*Intermediaries*/
-	double     value[NUMVERTICES];
+	IssmDouble     value[NUMVERTICES];
 	GaussTria *gauss              = NULL;
 
 	/*Recover input*/
 	Input* input=inputs->GetInput(enumtype);
-	if (!input) _error_("Input %s not found in element",EnumToStringx(enumtype));
+	if (!input) _error2_("Input " << EnumToStringx(enumtype) << " not found in element");
 
 	/*Checks in debugging mode*/
@@ -1047,8 +1047,8 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue) {{{1*/
-void Tria::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue){
-
-	double     value[NUMVERTICES];
+/*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue) {{{*/
+void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){
+
+	IssmDouble     value[NUMVERTICES];
 	GaussTria *gauss = NULL;
 	Input     *input = inputs->GetInput(enumtype);
@@ -1073,8 +1073,8 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue,int index) TO BE REMOVED{{{1*/
-void Tria::GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue,int index){
-
-	double     value[NUMVERTICES];
+/*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index) TO BE REMOVED{{{*/
+void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index){
+
+	IssmDouble     value[NUMVERTICES];
 	GaussTria *gauss = NULL;
 	Input     *input = inputs->GetInput(enumtype);
@@ -1099,9 +1099,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetInputValue(double* pvalue,Node* node,int enumtype) {{{1*/
-void Tria::GetInputValue(double* pvalue,Node* node,int enumtype){
+/*FUNCTION Tria::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype) {{{*/
+void Tria::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype){
 
 	Input* input=inputs->GetInput(enumtype);
-	if(!input) _error_("No input of type %s found in tria",EnumToStringx(enumtype));
+	if(!input) _error2_("No input of type " << EnumToStringx(enumtype) << " found in tria");
 
 	GaussTria* gauss=new GaussTria();
@@ -1112,15 +1112,15 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetSidList {{{1*/
+/*FUNCTION Tria::GetSidList {{{*/
 void  Tria::GetSidList(int* sidlist){
 	for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetSidList();
 }
 /*}}}*/
-/*FUNCTION Tria::GetConnectivityList {{{1*/
+/*FUNCTION Tria::GetConnectivityList {{{*/
 void  Tria::GetConnectivityList(int* connectivity){
 	for(int i=0;i<NUMVERTICES;i++) connectivity[i]=nodes[i]->GetConnectivity();
 }
 /*}}}*/
-/*FUNCTION Tria::GetSolutionFromInputs{{{1*/
+/*FUNCTION Tria::GetSolutionFromInputs{{{*/
 void  Tria::GetSolutionFromInputs(Vector* solution){
 
@@ -1145,21 +1145,21 @@
 	#endif
 	default:
-		_error_("analysis: %s not supported yet",EnumToStringx(analysis_type));
-	}
-
-}
-/*}}}*/
-/*FUNCTION Tria::GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input){{{1*/
-void Tria::GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input){
+		_error2_("analysis: " << EnumToStringx(analysis_type) << " not supported yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Tria::GetStrainRate2d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input){{{*/
+void Tria::GetStrainRate2d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input){
 	/*Compute the 2d Strain Rate (3 components):
 	 * epsilon=[exx eyy exy] */
 
 	int i;
-	double epsilonvx[3];
-	double epsilonvy[3];
+	IssmDouble epsilonvx[3];
+	IssmDouble epsilonvy[3];
 
 	/*Check that both inputs have been found*/
 	if (!vx_input || !vy_input){
-		_error_("Input missing. Here are the input pointers we have for vx: %p, vy: %p\n",vx_input,vy_input);
+		_error2_("Input missing. Here are the input pointers we have for vx: " << vx_input << ", vy: " << vy_input << "\n");
 	}
 
@@ -1172,5 +1172,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetVectorFromInputs{{{1*/
+/*FUNCTION Tria::GetVectorFromInputs{{{*/
 void  Tria::GetVectorFromInputs(Vector* vector,int input_enum){
 
@@ -1185,5 +1185,5 @@
 	/*Get input (either in element or material)*/
 	Input* input=inputs->GetInput(input_enum);
-	if(!input) _error_("Input %s not found in element",EnumToStringx(input_enum));
+	if(!input) _error2_("Input " << EnumToStringx(input_enum) << " not found in element");
 
 	/*We found the enum.  Use its values to fill into the vector, using the vertices ids: */
@@ -1191,5 +1191,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetVectorFromResults{{{1*/
+/*FUNCTION Tria::GetVectorFromResults{{{*/
 void  Tria::GetVectorFromResults(Vector* vector,int offset,int enum_in,int interp){
 
@@ -1210,9 +1210,9 @@
 	}
 	else{
-		printf("Interpolation %s not supported\n",EnumToStringx(interp));
-	}
-}
-/*}}}*/
-/*FUNCTION Tria::Id {{{1*/
+		_printLine_("Interpolation " << EnumToStringx(interp) << " not supported");
+	}
+}
+/*}}}*/
+/*FUNCTION Tria::Id {{{*/
 int    Tria::Id(){
 	
@@ -1221,5 +1221,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::Sid {{{1*/
+/*FUNCTION Tria::Sid {{{*/
 int    Tria::Sid(){
 	
@@ -1228,6 +1228,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputArtificialNoise{{{1*/
-void  Tria::InputArtificialNoise(int enum_type,double min,double max){
+/*FUNCTION Tria::InputArtificialNoise{{{*/
+void  Tria::InputArtificialNoise(int enum_type,IssmDouble min,IssmDouble max){
 
 	Input* input=NULL;
@@ -1235,5 +1235,5 @@
 	/*Make a copy of the original input: */
 	input=(Input*)this->inputs->GetInput(enum_type);
-	if(!input)_error_(" could not find old input with enum: %s",EnumToStringx(enum_type));
+	if(!input)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
 
 	/*ArtificialNoise: */
@@ -1241,6 +1241,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputConvergence{{{1*/
-bool Tria::InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums){
+/*FUNCTION Tria::InputConvergence{{{*/
+bool Tria::InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums){
 
 	bool    converged=true;
@@ -1249,12 +1249,12 @@
 	Input** old_inputs=NULL;
 
-	new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs
-	old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs
+	new_inputs=xNew<Input*>(num_enums/2); //half the enums are for the new inputs
+	old_inputs=xNew<Input*>(num_enums/2); //half the enums are for the old inputs
 
 	for(i=0;i<num_enums/2;i++){
 		new_inputs[i]=(Input*)this->inputs->GetInput(enums[2*i+0]);
 		old_inputs[i]=(Input*)this->inputs->GetInput(enums[2*i+1]);
-		if(!new_inputs[i])_error_("%s%s"," could not find input with enum ",EnumToStringx(enums[2*i+0]));
-		if(!old_inputs[i])_error_("%s%s"," could not find input with enum ",EnumToStringx(enums[2*i+0]));
+		if(!new_inputs[i])_error2_("could not find input with enum " << EnumToStringx(enums[2*i+0]));
+		if(!old_inputs[i])_error2_("could not find input with enum " << EnumToStringx(enums[2*i+0]));
 	}
 
@@ -1266,10 +1266,10 @@
 
 	/*clean up and return*/
-	xfree((void**)&new_inputs);
-	xfree((void**)&old_inputs);
+	xDelete<Input*>(new_inputs);
+	xDelete<Input*>(old_inputs);
 	return converged;
 }
 /*}}}*/
-/*FUNCTION Tria::InputDepthAverageAtBase {{{1*/
+/*FUNCTION Tria::InputDepthAverageAtBase {{{*/
 void  Tria::InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum){
 
@@ -1284,6 +1284,6 @@
 	 oldinput=(Input*)this->matice->inputs->GetInput(enum_type);
 	else
-	 _error_("object %s not supported yet",EnumToStringx(object_enum));
-	if(!oldinput)_error_("%s%s"," could not find old input with enum: ",EnumToStringx(enum_type));
+	 _error2_("object " << EnumToStringx(object_enum) << " not supported yet");
+	if(!oldinput)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
 	newinput=(Input*)oldinput->copy();
 
@@ -1297,8 +1297,8 @@
 	 this->matice->inputs->AddInput((Input*)newinput);
 	else
-	 _error_("object %s not supported yet",EnumToStringx(object_enum));
-}
-/*}}}*/
-/*FUNCTION Tria::InputDuplicate{{{1*/
+	 _error2_("object " << EnumToStringx(object_enum) << " not supported yet");
+}
+/*}}}*/
+/*FUNCTION Tria::InputDuplicate{{{*/
 void  Tria::InputDuplicate(int original_enum,int new_enum){
 
@@ -1308,6 +1308,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputScale{{{1*/
-void  Tria::InputScale(int enum_type,double scale_factor){
+/*FUNCTION Tria::InputScale{{{*/
+void  Tria::InputScale(int enum_type,IssmDouble scale_factor){
 
 	Input* input=NULL;
@@ -1315,5 +1315,5 @@
 	/*Make a copy of the original input: */
 	input=(Input*)this->inputs->GetInput(enum_type);
-	if(!input)_error_(" could not find old input with enum: %s",EnumToStringx(enum_type));
+	if(!input)_error2_("could not find old input with enum: " << EnumToStringx(enum_type));
 
 	/*Scale: */
@@ -1321,6 +1321,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputToResult{{{1*/
-void  Tria::InputToResult(int enum_type,int step,double time){
+/*FUNCTION Tria::InputToResult{{{*/
+void  Tria::InputToResult(int enum_type,int step,IssmDouble time){
 
 	int    i;
@@ -1330,5 +1330,5 @@
 	if (enum_type==MaterialsRheologyBbarEnum) input=this->matice->inputs->GetInput(enum_type);
 	else input=this->inputs->GetInput(enum_type);
-	//if (!input) _error_("Input %s not found in tria->inputs",EnumToStringx(enum_type));
+	//if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found in tria->inputs");
 	if(!input)return;
 
@@ -1344,5 +1344,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputUpdateFromConstant(int value, int name);{{{1*/
+/*FUNCTION Tria::InputUpdateFromConstant(int value, int name);{{{*/
 void  Tria::InputUpdateFromConstant(int constant, int name){
 	/*Check that name is an element input*/
@@ -1353,6 +1353,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputUpdateFromConstant(double value, int name);{{{1*/
-void  Tria::InputUpdateFromConstant(double constant, int name){
+/*FUNCTION Tria::InputUpdateFromConstant(IssmDouble value, int name);{{{*/
+void  Tria::InputUpdateFromConstant(IssmDouble constant, int name){
 	/*Check that name is an element input*/
 	if (!IsInput(name)) return;
@@ -1362,5 +1362,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputUpdateFromConstant(bool value, int name);{{{1*/
+/*FUNCTION Tria::InputUpdateFromConstant(bool value, int name);{{{*/
 void  Tria::InputUpdateFromConstant(bool constant, int name){
 	/*Check that name is an element input*/
@@ -1371,5 +1371,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputUpdateFromIoModel{{{1*/
+/*FUNCTION Tria::InputUpdateFromIoModel{{{*/
 void Tria::InputUpdateFromIoModel(int index, IoModel* iomodel){ //i is the element index
 
@@ -1377,10 +1377,10 @@
 	int    i,j;
 	int    tria_vertex_ids[3];
-	double nodeinputs[3];
-	double cmmininputs[3];
-	double cmmaxinputs[3];
+	IssmDouble nodeinputs[3];
+	IssmDouble cmmininputs[3];
+	IssmDouble cmmaxinputs[3];
 	bool   control_analysis=false;
 	int    num_control_type;
-	double yts;
+	IssmDouble yts;
 	int    num_cm_responses;
    
@@ -1393,5 +1393,5 @@
 	/*Recover vertices ids needed to initialize inputs*/
 	for(i=0;i<3;i++){ 
-		tria_vertex_ids[i]=(int)iomodel->Data(MeshElementsEnum)[3*index+i]; //ids for vertices are in the elements array from Matlab
+		tria_vertex_ids[i]=reCast<int>(iomodel->Data(MeshElementsEnum)[3*index+i]); //ids for vertices are in the elements array from Matlab
 	}
 
@@ -1436,5 +1436,5 @@
 					/*Matice will take care of it*/ break;
 				default:
-					_error_("Control %s not implemented yet",EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]));
+					_error2_("Control " << EnumToStringx((int)iomodel->Data(InversionControlParametersEnum)[i]) << " not implemented yet");
 			}
 		}
@@ -1457,6 +1457,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputUpdateFromSolution {{{1*/
-void  Tria::InputUpdateFromSolution(double* solution){
+/*FUNCTION Tria::InputUpdateFromSolution {{{*/
+void  Tria::InputUpdateFromSolution(IssmDouble* solution){
 
 	/*retrive parameters: */
@@ -1508,15 +1508,15 @@
 			break;
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
-	}
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromSolutionOneDof{{{1*/
-void  Tria::InputUpdateFromSolutionOneDof(double* solution,int enum_type){
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromSolutionOneDof{{{*/
+void  Tria::InputUpdateFromSolutionOneDof(IssmDouble* solution,int enum_type){
 
 	const int numdof          = NDOF1*NUMVERTICES;
 
 	int*      doflist=NULL;
-	double    values[numdof];
+	IssmDouble    values[numdof];
 
 	/*Get dof list: */
@@ -1526,5 +1526,5 @@
 	for(int i=0;i<numdof;i++){
 		values[i]=solution[doflist[i]];
-		if(isnan(values[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -1533,9 +1533,9 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromSolutionPrognostic{{{1*/
-void  Tria::InputUpdateFromSolutionPrognostic(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromSolutionPrognostic{{{*/
+void  Tria::InputUpdateFromSolutionPrognostic(IssmDouble* solution){
 
 	/*Intermediaries*/
@@ -1544,11 +1544,11 @@
 	int       i,hydroadjustment;
 	int*      doflist=NULL;
-	double    rho_ice,rho_water,minthickness;
-	double    newthickness[numdof];
-	double    newbed[numdof];
-	double    newsurface[numdof];
-	double    oldbed[NUMVERTICES];
-	double    oldsurface[NUMVERTICES];
-	double    oldthickness[NUMVERTICES];
+	IssmDouble    rho_ice,rho_water,minthickness;
+	IssmDouble    newthickness[numdof];
+	IssmDouble    newbed[numdof];
+	IssmDouble    newsurface[numdof];
+	IssmDouble    oldbed[NUMVERTICES];
+	IssmDouble    oldsurface[NUMVERTICES];
+	IssmDouble    oldthickness[NUMVERTICES];
 
 	/*Get dof list: */
@@ -1559,5 +1559,5 @@
 	for(i=0;i<numdof;i++){
 		newthickness[i]=solution[doflist[i]];
-		if(isnan(newthickness[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(newthickness[i])) _error2_("NaN found in solution vector");
 		/*Constrain thickness to be at least 1m*/
 		if(newthickness[i]<minthickness) newthickness[i]=minthickness;
@@ -1590,5 +1590,5 @@
 				newbed[i]=oldbed[i]-rho_ice/rho_water*(newthickness[i]-oldthickness[i]); //bed = oldbed + di * dH
 			}
-			else _error_("Hydrostatic adjustment %i (%s) not supported yet",hydroadjustment,EnumToStringx(hydroadjustment));
+			else _error2_("Hydrostatic adjustment " << hydroadjustment << " (" << EnumToStringx(hydroadjustment) << ") not supported yet");
 		}
 	}
@@ -1600,9 +1600,9 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromVector(double* vector, int name, int type);{{{1*/
-void  Tria::InputUpdateFromVector(double* vector, int name, int type){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromVector(IssmDouble* vector, int name, int type);{{{*/
+void  Tria::InputUpdateFromVector(IssmDouble* vector, int name, int type){
 
 	/*Check that name is an element input*/
@@ -1611,8 +1611,8 @@
 	switch(type){
 
-		case VertexEnum:
+		case VertexEnum: {
 
 			/*New TriaP1Input*/
-			double values[3];
+			IssmDouble values[3];
 
 			/*Get values on the 3 vertices*/
@@ -1629,22 +1629,22 @@
 			}
 			return;
-
+		}
 		default:
-			_error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
-	}
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromVector(int* vector, int name, int type);{{{1*/
+			_error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromVector(int* vector, int name, int type);{{{*/
 void  Tria::InputUpdateFromVector(int* vector, int name, int type){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromVector(bool* vector, int name, int type);{{{1*/
+	_error2_("not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromVector(bool* vector, int name, int type);{{{*/
 void  Tria::InputUpdateFromVector(bool* vector, int name, int type){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Tria::InputCreate(double scalar,int enum,int code);{{{1*/
-void Tria::InputCreate(double scalar,int name,int code){
+	_error2_("not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::InputCreate(IssmDouble scalar,int enum,int code);{{{*/
+void Tria::InputCreate(IssmDouble scalar,int name,int code){
 
 	/*Check that name is an element input*/
@@ -1652,18 +1652,18 @@
 	
 	if ((code==5) || (code==1)){ //boolean
-		this->inputs->AddInput(new BoolInput(name,(bool)scalar));
+		this->inputs->AddInput(new BoolInput(name,reCast<bool>(scalar)));
 	}
 	else if ((code==6) || (code==2)){ //integer
-		this->inputs->AddInput(new IntInput(name,(int)scalar));
-	}
-	else if ((code==7) || (code==3)){ //double
-		this->inputs->AddInput(new DoubleInput(name,(int)scalar));
-	}
-	else _error_("%s%i"," could not recognize nature of vector from code ",code);
-
-}
-/*}}}*/
-/*FUNCTION Tria::InputCreate(double* vector,int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{1*/
-void Tria::InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
+		this->inputs->AddInput(new IntInput(name,reCast<int>(scalar)));
+	}
+	else if ((code==7) || (code==3)){ //IssmDouble
+		this->inputs->AddInput(new DoubleInput(name,reCast<int>(scalar)));
+	}
+	else _error2_("could not recognize nature of vector from code " << code);
+
+}
+/*}}}*/
+/*FUNCTION Tria::InputCreate(IssmDouble* vector,int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){{{*/
+void Tria::InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
 
 	/*Intermediaries*/
@@ -1671,10 +1671,10 @@
 	int    tria_vertex_ids[3];
 	int    row;
-	double nodeinputs[3];
-	double time;
+	IssmDouble nodeinputs[3];
+	IssmDouble time;
 	TransientInput* transientinput=NULL;
 	int    numberofvertices;
 	int    numberofelements;
-	double yts;
+	IssmDouble yts;
 
 
@@ -1689,5 +1689,5 @@
 		/*Recover vertices ids needed to initialize inputs*/
 		for(i=0;i<3;i++){ 
-			tria_vertex_ids[i]=(int)iomodel->Data(MeshElementsEnum)[3*index+i]; //ids for vertices are in the elements array from Matlab
+			tria_vertex_ids[i]=reCast<int>(iomodel->Data(MeshElementsEnum)[3*index+i]); //ids for vertices are in the elements array from Matlab
 		}
 
@@ -1696,5 +1696,5 @@
 
 			/*create input values: */
-			for(i=0;i<3;i++)nodeinputs[i]=(double)vector[tria_vertex_ids[i]-1];
+			for(i=0;i<3;i++)nodeinputs[i]=(IssmDouble)vector[tria_vertex_ids[i]-1];
 
 			/*process units: */
@@ -1711,5 +1711,5 @@
 				for(i=0;i<3;i++){
 					row=tria_vertex_ids[i]-1;
-					nodeinputs[i]=(double)vector[N*row+t];
+					nodeinputs[i]=(IssmDouble)vector[N*row+t];
 				}
 
@@ -1718,5 +1718,5 @@
 
 				/*time? :*/
-				time=(double)vector[(M-1)*N+t]*yts;
+				time=(IssmDouble)vector[(M-1)*N+t]*yts;
 
 				if(t==0) transientinput=new TransientInput(vector_enum);
@@ -1725,5 +1725,5 @@
 			this->inputs->AddInput(transientinput);
 		}
-		else _error_("nodal vector is either numberofnodes or numberofnodes+1 long. Field provided (%s) is %i long",EnumToStringx(vector_enum),M);
+		else _error2_("nodal vector is either numberofnodes or numberofnodes+1 long. Field provided (" << EnumToStringx(vector_enum) << ") is " << M << " long");
 	}
 	else if(vector_type==2){ //element vector
@@ -1734,25 +1734,25 @@
 
 			if (code==5){ //boolean
-				this->inputs->AddInput(new BoolInput(vector_enum,(bool)vector[index]));
+				this->inputs->AddInput(new BoolInput(vector_enum,reCast<bool>(vector[index])));
 			}
 			else if (code==6){ //integer
-				this->inputs->AddInput(new IntInput(vector_enum,(int)vector[index]));
+				this->inputs->AddInput(new IntInput(vector_enum,reCast<int>(vector[index])));
 			}
-			else if (code==7){ //double
-				this->inputs->AddInput(new DoubleInput(vector_enum,(double)vector[index]));
+			else if (code==7){ //IssmDouble
+				this->inputs->AddInput(new DoubleInput(vector_enum,vector[index]));
 			}
-			else _error_("%s%i"," could not recognize nature of vector from code ",code);
+			else _error2_("could not recognize nature of vector from code " << code);
 		}
 		else {
-			_error_("transient elementary inputs not supported yet!");
+			_error2_("transient elementary inputs not supported yet!");
 		}
 	}
 	else{
-		_error_("Cannot add input for vector type %i (not supported)",vector_type);
-	}
-
-}
-/*}}}*/
-/*FUNCTION Tria::IsInput{{{1*/
+		_error2_("Cannot add input for vector type " << vector_type << " (not supported)");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Tria::IsInput{{{*/
 bool Tria::IsInput(int name){
 	if (
@@ -1788,5 +1788,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::IsOnBed {{{1*/
+/*FUNCTION Tria::IsOnBed {{{*/
 bool Tria::IsOnBed(){
 	
@@ -1796,5 +1796,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::IsFloating {{{1*/
+/*FUNCTION Tria::IsFloating {{{*/
 bool   Tria::IsFloating(){
 
@@ -1804,5 +1804,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::IsNodeOnShelf {{{1*/
+/*FUNCTION Tria::IsNodeOnShelf {{{*/
 bool   Tria::IsNodeOnShelf(){
 
@@ -1819,6 +1819,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::IsNodeOnShelfFromFlags {{{1*/
-bool   Tria::IsNodeOnShelfFromFlags(double* flags){
+/*FUNCTION Tria::IsNodeOnShelfFromFlags {{{*/
+bool   Tria::IsNodeOnShelfFromFlags(IssmDouble* flags){
 
 	int  i;
@@ -1826,5 +1826,5 @@
 
 	for(i=0;i<NUMVERTICES;i++){
-		if (flags[nodes[i]->Sid()]){
+		if (reCast<bool>(flags[nodes[i]->Sid()])){
 			shelf=true;
 			break;
@@ -1834,5 +1834,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::IsOnWater {{{1*/
+/*FUNCTION Tria::IsOnWater {{{*/
 bool   Tria::IsOnWater(){
 
@@ -1843,5 +1843,5 @@
 /*}}}*/
 /*FUNCTION Tria::ListResultsInfo{{{*/
-void Tria::ListResultsInfo(int** in_resultsenums,int** in_resultssizes,double** in_resultstimes,int** in_resultssteps,int* in_num_results){
+void Tria::ListResultsInfo(int** in_resultsenums,int** in_resultssizes,IssmDouble** in_resultstimes,int** in_resultssteps,int* in_num_results){
 
 	/*Intermediaries*/
@@ -1850,5 +1850,5 @@
 	int     *resultsenums   = NULL;
 	int     *resultssizes   = NULL;
-	double  *resultstimes   = NULL;
+	IssmDouble  *resultstimes   = NULL;
 	int     *resultssteps   = NULL;
 
@@ -1865,8 +1865,8 @@
 
 		/*Allocate output*/
-		resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
-		resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
-		resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
-		resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
+		resultsenums=xNew<int>(numberofresults);
+		resultssizes=xNew<int>(numberofresults);
+		resultstimes=xNew<IssmDouble>(numberofresults);
+		resultssteps=xNew<int>(numberofresults);
 
 		/*populate enums*/
@@ -1893,13 +1893,13 @@
 
 }/*}}}*/
-/*FUNCTION Tria::MigrateGroundingLine{{{1*/
-void  Tria::MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding){
+/*FUNCTION Tria::MigrateGroundingLine{{{*/
+void  Tria::MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding){
 
 	int     i,migration_style,unground;
 	bool    elementonshelf = false;
-	double  bed_hydro,yts,gl_melting_rate;
-	double  rho_water,rho_ice,density;
-	double  melting[NUMVERTICES];
-	double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
+	IssmDouble  bed_hydro,yts,gl_melting_rate;
+	IssmDouble  rho_water,rho_ice,density;
+	IssmDouble  melting[NUMVERTICES];
+	IssmDouble  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
 
 	/*Recover info at the vertices: */
@@ -1917,5 +1917,5 @@
 	for(i=0;i<NUMVERTICES;i++){
 		/*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */
-		if(old_floating_ice[nodes[i]->Sid()]){
+		if(reCast<bool>(old_floating_ice[nodes[i]->Sid()])){
 			if(b[i]<=ba[i]){ 
 				b[i]=ba[i];
@@ -1937,5 +1937,5 @@
 					nodes[i]->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,false));
 				}
-				else if(migration_style==SoftMigrationEnum && sheet_ungrounding[nodes[i]->Sid()]){
+				else if(migration_style==SoftMigrationEnum && reCast<bool>(sheet_ungrounding[nodes[i]->Sid()])){
 					s[i]=(1-density)*h[i];
 					b[i]=-density*h[i];
@@ -1969,5 +1969,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MyRank {{{1*/
+/*FUNCTION Tria::MyRank {{{*/
 int    Tria::MyRank(void){ 
 	extern int my_rank;
@@ -1975,10 +1975,10 @@
 }
 /*}}}*/
-/*FUNCTION Tria::NodalValue {{{1*/
-int    Tria::NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units){
+/*FUNCTION Tria::NodalValue {{{*/
+int    Tria::NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units){
 
 	int i;
 	int found=0;
-	double value;
+	IssmDouble value;
 	Input* data=NULL;
 	GaussTria *gauss                            = NULL;
@@ -2006,5 +2006,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::PatchFill{{{1*/
+/*FUNCTION Tria::PatchFill{{{*/
 void  Tria::PatchFill(int* prow, Patch* patch){
 
@@ -2033,5 +2033,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::PatchSize{{{1*/
+/*FUNCTION Tria::PatchSize{{{*/
 void  Tria::PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes){
 
@@ -2057,11 +2057,11 @@
 }
 /*}}}*/
-/*FUNCTION Tria::PotentialSheetUngrounding{{{1*/
+/*FUNCTION Tria::PotentialSheetUngrounding{{{*/
 void  Tria::PotentialSheetUngrounding(Vector* potential_sheet_ungrounding){
 
 	int     i;
-	double  h[NUMVERTICES],ba[NUMVERTICES];
-	double  bed_hydro;
-	double  rho_water,rho_ice,density;
+	IssmDouble  h[NUMVERTICES],ba[NUMVERTICES];
+	IssmDouble  bed_hydro;
+	IssmDouble  rho_water,rho_ice,density;
 	bool    elementonshelf = false;
 
@@ -2086,11 +2086,11 @@
 }
 /*}}}*/
-/*FUNCTION Tria::PositiveDegreeDay{{{1*/
-void  Tria::PositiveDegreeDay(double* pdds,double* pds,double signorm){
-
-   double agd[NUMVERTICES];             // surface mass balance
-   double monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
-   double h[NUMVERTICES],s[NUMVERTICES]; // ,b
-   double rho_water,rho_ice;
+/*FUNCTION Tria::PositiveDegreeDay{{{*/
+void  Tria::PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){
+
+   IssmDouble agd[NUMVERTICES];             // surface mass balance
+   IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
+   IssmDouble h[NUMVERTICES],s[NUMVERTICES]; // ,b
+   IssmDouble rho_water,rho_ice;
 
    /*Recover monthly temperatures and precipitation*/
@@ -2098,5 +2098,5 @@
    Input*     input2=inputs->GetInput(SurfaceforcingsPrecipitationEnum); _assert_(input2);
    GaussTria* gauss=new GaussTria();
-   double time,yts;
+   IssmDouble time,yts;
    this->parameters->FindParam(&time,TimeEnum);
    this->parameters->FindParam(&yts,ConstantsYtsEnum);
@@ -2129,5 +2129,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::ProcessResultsUnits{{{1*/
+/*FUNCTION Tria::ProcessResultsUnits{{{*/
 void  Tria::ProcessResultsUnits(void){
 
@@ -2140,6 +2140,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::RequestedOutput{{{1*/
-void Tria::RequestedOutput(int output_enum,int step,double time){
+/*FUNCTION Tria::RequestedOutput{{{*/
+void Tria::RequestedOutput(int output_enum,int step,IssmDouble time){
 
 	if(IsInput(output_enum)){
@@ -2168,17 +2168,71 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SetClone {{{1*/
+/*FUNCTION Tria::SetClone {{{*/
 void  Tria::SetClone(int* minranks){
 
-	_error_("not implemented yet");
-}
-/*}}}1*/
-/*FUNCTION Tria::SmearFunction {{{1*/
-void  Tria::SmearFunction(Vector*  smearedvector,double (*WeightFunction)(double distance,double radius),double radius){
-	_error_("not implemented yet");
-
-}
-/*}}}1*/
-/*FUNCTION Tria::SetCurrentConfiguration {{{1*/
+	_error2_("not implemented yet");
+}
+/*}}}*/
+/*FUNCTION Tria::SmearFunction {{{*/
+void  Tria::SmearFunction(Vector*  smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius){
+	_error2_("not implemented yet");
+
+}
+/*}}}*/
+/*FUNCTION Tria::SmbGradients{{{*/
+void Tria::SmbGradients(void){
+
+	int i;
+
+	// input
+   IssmDouble h[NUMVERTICES];					// ice thickness (m)		
+	IssmDouble s[NUMVERTICES];					// surface elevation (m)
+	IssmDouble a_pos[NUMVERTICES];				// Hs-SMB relation parameter 
+	IssmDouble b_pos[NUMVERTICES];				// Hs-SMB relation parameter
+	IssmDouble a_neg[NUMVERTICES];				// Hs-SMB relation parameter
+	IssmDouble b_neg[NUMVERTICES];				// Hs-SMB relation paremeter
+	IssmDouble Hc[NUMVERTICES];					// elevation of transition between accumulation regime and ablation regime
+	IssmDouble smb_pos_max[NUMVERTICES];		// maximum SMB value in the accumulation regime
+	IssmDouble smb_pos_min[NUMVERTICES];		// minimum SMB value in the accumulation regime
+   IssmDouble rho_water;                   // density of fresh water
+	IssmDouble rho_ice;                     // density of ice
+
+	// output
+	IssmDouble smb[NUMVERTICES];					// surface mass balance (m/yr ice)
+
+	/*Recover SmbGradients*/
+	GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum);
+	GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum);
+	GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum);
+	GetInputListOnVertices(&a_pos[0],SurfaceforcingsAPosEnum);
+	GetInputListOnVertices(&b_pos[0],SurfaceforcingsBPosEnum);
+	GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum);
+	GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum);
+	
+   /*Recover surface elevatio at vertices: */
+	GetInputListOnVertices(&h[0],ThicknessEnum);
+	GetInputListOnVertices(&s[0],SurfaceEnum);
+
+   /*Get material parameters :*/
+   rho_ice=matpar->GetRhoIce();
+   rho_water=matpar->GetRhoFreshwater();
+			
+   // loop over all vertices
+   for(i=0;i<NUMVERTICES;i++){
+     if(s[i]>Hc[i]){
+	    smb[i]=a_pos[i]+b_pos[i]*s[i];
+		 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
+		 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
+	  }
+	  else{
+	    smb[i]=a_neg[i]+b_neg[i]*s[i];
+	  }
+	  smb[i]=smb[i]/rho_ice;      // SMB in m/y ice		
+	}  //end of the loop over the vertices
+	  /*Update inputs*/
+	  this->inputs->AddInput(new TriaP1Input(SurfaceforcingsMassBalanceEnum,&smb[0]));
+}
+/*}}}*/
+/*FUNCTION Tria::SetCurrentConfiguration {{{*/
 void  Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
 	
@@ -2196,12 +2250,12 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SurfaceArea {{{1*/
-double Tria::SurfaceArea(void){
+/*FUNCTION Tria::SurfaceArea {{{*/
+IssmDouble Tria::SurfaceArea(void){
 
 	int    i;
-	double S;
-	double normal[3];
-	double v13[3],v23[3];
-	double xyz_list[NUMVERTICES][3];
+	IssmDouble S;
+	IssmDouble normal[3];
+	IssmDouble v13[3],v23[3];
+	IssmDouble xyz_list[NUMVERTICES][3];
 
 	/*If on water, return 0: */
@@ -2219,5 +2273,5 @@
 	normal[2]=v13[0]*v23[1]-v13[1]*v23[0];
 
-	S = 0.5 * sqrt(pow(normal[0],(double)2)+pow(normal[1],(double)2)+pow(normal[2],(double)2));
+	S = 0.5 * sqrt(pow(normal[0],(IssmDouble)2)+pow(normal[1],(IssmDouble)2)+pow(normal[2],(IssmDouble)2));
 
 	/*Return: */
@@ -2225,11 +2279,11 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SurfaceNormal{{{1*/
-void Tria::SurfaceNormal(double* surface_normal, double xyz_list[3][3]){
+/*FUNCTION Tria::SurfaceNormal{{{*/
+void Tria::SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]){
 
 	int i;
-	double v13[3],v23[3];
-	double normal[3];
-	double normal_norm;
+	IssmDouble v13[3],v23[3];
+	IssmDouble normal[3];
+	IssmDouble normal_norm;
 
 	for (i=0;i<3;i++){
@@ -2242,5 +2296,5 @@
 	normal[2]=v13[0]*v23[1]-v13[1]*v23[0];
 
-	normal_norm=sqrt( pow(normal[0],(double)2)+pow(normal[1],(double)2)+pow(normal[2],(double)2) );
+	normal_norm=sqrt( pow(normal[0],(IssmDouble)2)+pow(normal[1],(IssmDouble)2)+pow(normal[2],(IssmDouble)2) );
 
 	*(surface_normal)=normal[0]/normal_norm;
@@ -2249,15 +2303,15 @@
 }
 /*}}}*/
-/*FUNCTION Tria::TimeAdapt{{{1*/
-double  Tria::TimeAdapt(void){
+/*FUNCTION Tria::TimeAdapt{{{*/
+IssmDouble  Tria::TimeAdapt(void){
 
 	/*intermediary: */
 	int    i;
-	double C,dt;
-	double dx,dy;
-	double maxx,minx;
-	double maxy,miny;
-	double maxabsvx,maxabsvy;
-	double xyz_list[NUMVERTICES][3];
+	IssmDouble C,dt;
+	IssmDouble dx,dy;
+	IssmDouble maxx,minx;
+	IssmDouble maxy,miny;
+	IssmDouble maxabsvx,maxabsvy;
+	IssmDouble xyz_list[NUMVERTICES][3];
 
 	/*get CFL coefficient:*/
@@ -2269,5 +2323,5 @@
 	this->MaxAbsVy(&maxabsvy,false);
 	#else
-		_error_("ISSM was not compiled with responses compiled in, exiting!");
+		_error2_("ISSM was not compiled with responses compiled in, exiting!");
 	#endif
 
@@ -2295,5 +2349,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type){{{1*/
+/*FUNCTION Tria::Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type){{{*/
 void Tria::Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type){ //i is the element index
 
@@ -2303,11 +2357,11 @@
 	int    tria_vertex_ids[3];
 	int    tria_type;
-	double nodeinputs[3];
-	double yts;
+	IssmDouble nodeinputs[3];
+	IssmDouble yts;
 	int    progstabilization,balancestabilization;
 	bool   dakota_analysis;
 
 	/*Checks if debuging*/
-	/*{{{2*/
+	/*{{{*/
 	_assert_(iomodel->Data(MeshElementsEnum));
 	/*}}}*/
@@ -2332,5 +2386,5 @@
 	/*Recover vertices ids needed to initialize inputs*/
 	for(i=0;i<3;i++){ 
-		tria_vertex_ids[i]=(int)iomodel->Data(MeshElementsEnum)[3*index+i]; //ids for vertices are in the elements array from Matlab
+		tria_vertex_ids[i]=reCast<int>(iomodel->Data(MeshElementsEnum)[3*index+i]); //ids for vertices are in the elements array from Matlab
 	}
 
@@ -2345,5 +2399,5 @@
 		/*Continuous Galerkin*/
 		for(i=0;i<3;i++){ 
-			tria_node_ids[i]=iomodel->nodecounter+(int)*(iomodel->Data(MeshElementsEnum)+3*index+i); //ids for vertices are in the elements array from Matlab
+			tria_node_ids[i]=iomodel->nodecounter+reCast<int,IssmDouble>(*(iomodel->Data(MeshElementsEnum)+3*index+i)); //ids for vertices are in the elements array from Matlab
 		}
 	}
@@ -2395,6 +2449,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::UpdatePotentialSheetUngrounding{{{1*/
-int Tria::UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf){
+/*FUNCTION Tria::UpdatePotentialSheetUngrounding{{{*/
+int Tria::UpdatePotentialSheetUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){
 
 	int i;
@@ -2403,5 +2457,5 @@
 	/*Go through nodes, and whoever is on the potential_sheet_ungrounding, ends up in nodes_on_iceshelf: */
 	for(i=0;i<3;i++){
-		if (vertices_potentially_ungrounding[nodes[i]->Sid()]){
+		if (reCast<bool>(vertices_potentially_ungrounding[nodes[i]->Sid()])){
 			vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL);
 		
@@ -2417,10 +2471,10 @@
 
 #ifdef _HAVE_RESPONSES_
-/*FUNCTION Tria::IceVolume {{{1*/
-double Tria::IceVolume(void){
+/*FUNCTION Tria::IceVolume {{{*/
+IssmDouble Tria::IceVolume(void){
 
 	/*The volume of a troncated prism is base * 1/3 sum(length of edges)*/
-	double base,surface,bed;
-	double xyz_list[NUMVERTICES][3];
+	IssmDouble base,surface,bed;
+	IssmDouble xyz_list[NUMVERTICES][3];
 
 	if(IsOnWater())return 0;
@@ -2443,16 +2497,16 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MassFlux {{{1*/
-double Tria::MassFlux( double* segment,bool process_units){
+/*FUNCTION Tria::MassFlux {{{*/
+IssmDouble Tria::MassFlux( IssmDouble* segment,bool process_units){
 
 	const int    numdofs=2;
 
 	int        i,dim;
-	double     mass_flux=0;
-	double     xyz_list[NUMVERTICES][3];
-	double     normal[2];
-	double     length,rho_ice;
-	double     x1,y1,x2,y2,h1,h2;
-	double     vx1,vx2,vy1,vy2;
+	IssmDouble     mass_flux=0;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     normal[2];
+	IssmDouble     length,rho_ice;
+	IssmDouble     x1,y1,x2,y2,h1,h2;
+	IssmDouble     vx1,vx2,vy1,vy2;
 	GaussTria* gauss_1=NULL;
 	GaussTria* gauss_2=NULL;
@@ -2462,5 +2516,5 @@
 
 	/*First off, check that this segment belongs to this element: */
-	if ((int)*(segment+4)!=this->id)_error_("%s%i%s%i","error message: segment with id ",(int)*(segment+4)," does not belong to element with id:",this->id);
+	if ((int)*(segment+4)!=this->id)_error2_("error message: segment with id " << (int)*(segment+4) << " does not belong to element with id:" << this->id);
 
 	/*Recover segment node locations: */
@@ -2515,9 +2569,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MaxAbsVx{{{1*/
-void  Tria::MaxAbsVx(double* pmaxabsvx, bool process_units){
+/*FUNCTION Tria::MaxAbsVx{{{*/
+void  Tria::MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units){
 
 	/*Get maximum:*/
-	double maxabsvx=this->inputs->MaxAbs(VxEnum);
+	IssmDouble maxabsvx=this->inputs->MaxAbs(VxEnum);
 
 	/*process units if requested: */
@@ -2528,9 +2582,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MaxAbsVy{{{1*/
-void  Tria::MaxAbsVy(double* pmaxabsvy, bool process_units){
+/*FUNCTION Tria::MaxAbsVy{{{*/
+void  Tria::MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units){
 
 	/*Get maximum:*/
-	double maxabsvy=this->inputs->MaxAbs(VyEnum);
+	IssmDouble maxabsvy=this->inputs->MaxAbs(VyEnum);
 
 	/*process units if requested: */
@@ -2541,9 +2595,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MaxAbsVz{{{1*/
-void  Tria::MaxAbsVz(double* pmaxabsvz, bool process_units){
+/*FUNCTION Tria::MaxAbsVz{{{*/
+void  Tria::MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units){
 
 	/*Get maximum:*/
-	double maxabsvz=this->inputs->MaxAbs(VzEnum);
+	IssmDouble maxabsvz=this->inputs->MaxAbs(VzEnum);
 
 	/*process units if requested: */
@@ -2554,9 +2608,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MaxVel{{{1*/
-void  Tria::MaxVel(double* pmaxvel, bool process_units){
+/*FUNCTION Tria::MaxVel{{{*/
+void  Tria::MaxVel(IssmDouble* pmaxvel, bool process_units){
 
 	/*Get maximum:*/
-	double maxvel=this->inputs->Max(VelEnum);
+	IssmDouble maxvel=this->inputs->Max(VelEnum);
 
 	/*process units if requested: */
@@ -2567,9 +2621,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MaxVx{{{1*/
-void  Tria::MaxVx(double* pmaxvx, bool process_units){
+/*FUNCTION Tria::MaxVx{{{*/
+void  Tria::MaxVx(IssmDouble* pmaxvx, bool process_units){
 
 	/*Get maximum:*/
-	double maxvx=this->inputs->Max(VxEnum);
+	IssmDouble maxvx=this->inputs->Max(VxEnum);
 
 	/*process units if requested: */
@@ -2580,9 +2634,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MaxVy{{{1*/
-void  Tria::MaxVy(double* pmaxvy, bool process_units){
+/*FUNCTION Tria::MaxVy{{{*/
+void  Tria::MaxVy(IssmDouble* pmaxvy, bool process_units){
 
 	/*Get maximum:*/
-	double maxvy=this->inputs->Max(VyEnum);
+	IssmDouble maxvy=this->inputs->Max(VyEnum);
 
 	/*process units if requested: */
@@ -2594,9 +2648,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MaxVz{{{1*/
-void  Tria::MaxVz(double* pmaxvz, bool process_units){
+/*FUNCTION Tria::MaxVz{{{*/
+void  Tria::MaxVz(IssmDouble* pmaxvz, bool process_units){
 
 	/*Get maximum:*/
-	double maxvz=this->inputs->Max(VzEnum);
+	IssmDouble maxvz=this->inputs->Max(VzEnum);
 
 	/*process units if requested: */
@@ -2607,9 +2661,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MinVel{{{1*/
-void  Tria::MinVel(double* pminvel, bool process_units){
+/*FUNCTION Tria::MinVel{{{*/
+void  Tria::MinVel(IssmDouble* pminvel, bool process_units){
 
 	/*Get minimum:*/
-	double minvel=this->inputs->Min(VelEnum);
+	IssmDouble minvel=this->inputs->Min(VelEnum);
 
 	/*process units if requested: */
@@ -2620,9 +2674,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MinVx{{{1*/
-void  Tria::MinVx(double* pminvx, bool process_units){
+/*FUNCTION Tria::MinVx{{{*/
+void  Tria::MinVx(IssmDouble* pminvx, bool process_units){
 
 	/*Get minimum:*/
-	double minvx=this->inputs->Min(VxEnum);
+	IssmDouble minvx=this->inputs->Min(VxEnum);
 
 	/*process units if requested: */
@@ -2633,9 +2687,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MinVy{{{1*/
-void  Tria::MinVy(double* pminvy, bool process_units){
+/*FUNCTION Tria::MinVy{{{*/
+void  Tria::MinVy(IssmDouble* pminvy, bool process_units){
 
 	/*Get minimum:*/
-	double minvy=this->inputs->Min(VyEnum);
+	IssmDouble minvy=this->inputs->Min(VyEnum);
 
 	/*process units if requested: */
@@ -2646,9 +2700,9 @@
 }
 /*}}}*/
-/*FUNCTION Tria::MinVz{{{1*/
-void  Tria::MinVz(double* pminvz, bool process_units){
+/*FUNCTION Tria::MinVz{{{*/
+void  Tria::MinVz(IssmDouble* pminvz, bool process_units){
 
 	/*Get minimum:*/
-	double minvz=this->inputs->Min(VzEnum);
+	IssmDouble minvz=this->inputs->Min(VzEnum);
 
 	/*process units if requested: */
@@ -2659,6 +2713,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::ElementResponse{{{1*/
-void Tria::ElementResponse(double* presponse,int response_enum,bool process_units){
+/*FUNCTION Tria::ElementResponse{{{*/
+void Tria::ElementResponse(IssmDouble* presponse,int response_enum,bool process_units){
 
 	switch(response_enum){
@@ -2669,5 +2723,5 @@
 
 			/*Get input:*/
-			double vel;
+			IssmDouble vel;
 			Input* vel_input;
 
@@ -2681,5 +2735,5 @@
 			*presponse=vel;
 		default:  
-			_error_("Response type %s not supported yet!",EnumToStringx(response_enum));
+			_error2_("Response type " << EnumToStringx(response_enum) << " not supported yet!");
 	}
 
@@ -2689,5 +2743,5 @@
 
 #ifdef _HAVE_DIAGNOSTIC_
-/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyeal {{{1*/
+/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyeal {{{*/
 ElementMatrix* Tria::CreateKMatrixDiagnosticMacAyeal(void){
 
@@ -2703,5 +2757,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealViscous{{{1*/
+/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealViscous{{{*/
 ElementMatrix* Tria::CreateKMatrixDiagnosticMacAyealViscous(void){
 
@@ -2711,12 +2765,12 @@
 	/*Intermediaries*/
 	int        i,j,ig;
-	double     xyz_list[NUMVERTICES][3];
-	double     viscosity,newviscosity,oldviscosity;
-	double     viscosity_overshoot,thickness,Jdet;
-	double     epsilon[3],oldepsilon[3];    /* epsilon=[exx,eyy,exy];    */
-	double     B[3][numdof];
-	double     Bprime[3][numdof];
-	double     D[3][3]   = {0.0};
-	double     D_scalar;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     viscosity,newviscosity,oldviscosity;
+	IssmDouble     viscosity_overshoot,thickness,Jdet;
+	IssmDouble     epsilon[3],oldepsilon[3];    /* epsilon=[exx,eyy,exy];    */
+	IssmDouble     B[3][numdof];
+	IssmDouble     Bprime[3][numdof];
+	IssmDouble     D[3][3]   = {0.0};
+	IssmDouble     D_scalar;
 	GaussTria *gauss = NULL;
 
@@ -2767,5 +2821,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealFriction {{{1*/
+/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealFriction {{{*/
 ElementMatrix* Tria::CreateKMatrixDiagnosticMacAyealFriction(void){
 
@@ -2776,13 +2830,13 @@
 	int        i,j,ig;
 	int        analysis_type;
-	double     MAXSLOPE  = .06; // 6 %
-	double     MOUNTAINKEXPONENT = 10;
-	double     slope_magnitude,alpha2;
-	double     Jdet;
-	double     L[2][numdof];
-	double     DL[2][2]  = {{ 0,0 },{0,0}};
-	double     DL_scalar;
-	double     slope[2]  = {0.0,0.0};
-	double     xyz_list[NUMVERTICES][3];
+	IssmDouble     MAXSLOPE  = .06; // 6 %
+	IssmDouble     MOUNTAINKEXPONENT = 10;
+	IssmDouble     slope_magnitude,alpha2;
+	IssmDouble     Jdet;
+	IssmDouble     L[2][numdof];
+	IssmDouble     DL[2][2]  = {{ 0,0 },{0,0}};
+	IssmDouble     DL_scalar;
+	IssmDouble     slope[2]  = {0.0,0.0};
+	IssmDouble     xyz_list[NUMVERTICES][3];
 	Friction  *friction = NULL;
 	GaussTria *gauss    = NULL;
@@ -2813,5 +2867,5 @@
 		surface_input->GetInputDerivativeValue(&slope[0],&xyz_list[0][0],gauss);
 		slope_magnitude=sqrt(pow(slope[0],2)+pow(slope[1],2));
-		if(slope_magnitude>MAXSLOPE) alpha2=pow((double)10,MOUNTAINKEXPONENT);
+		if(slope_magnitude>MAXSLOPE) alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT);
 		else friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum);
 
@@ -2836,5 +2890,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixDiagnosticHutter{{{1*/
+/*FUNCTION Tria::CreateKMatrixDiagnosticHutter{{{*/
 ElementMatrix* Tria::CreateKMatrixDiagnosticHutter(void){
 
@@ -2849,6 +2903,6 @@
 	for(i=0;i<NUMVERTICES;i++){
 		connectivity=nodes[i]->GetConnectivity();
-		Ke->values[(2*i)*numdof  +(2*i)  ]=1/(double)connectivity;
-		Ke->values[(2*i+1)*numdof+(2*i+1)]=1/(double)connectivity;
+		Ke->values[(2*i)*numdof  +(2*i)  ]=1/(IssmDouble)connectivity;
+		Ke->values[(2*i+1)*numdof+(2*i+1)]=1/(IssmDouble)connectivity;
 	}
 
@@ -2857,5 +2911,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorDiagnosticMacAyeal {{{1*/
+/*FUNCTION Tria::CreatePVectorDiagnosticMacAyeal {{{*/
 ElementVector* Tria::CreatePVectorDiagnosticMacAyeal(){
 
@@ -2865,10 +2919,10 @@
 	/*Intermediaries */
 	int            i,j,ig;
-	double         driving_stress_baseline,thickness;
-	double         Jdet;
-	double         xyz_list[NUMVERTICES][3];
-	double         slope[2];
-	double         basis[3];
-	double         pe_g_gaussian[numdof];
+	IssmDouble         driving_stress_baseline,thickness;
+	IssmDouble         Jdet;
+	IssmDouble         xyz_list[NUMVERTICES][3];
+	IssmDouble         slope[2];
+	IssmDouble         basis[3];
+	IssmDouble         pe_g_gaussian[numdof];
 	GaussTria*     gauss=NULL;
 
@@ -2911,13 +2965,13 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorDiagnosticHutter{{{1*/
+/*FUNCTION Tria::CreatePVectorDiagnosticHutter{{{*/
 ElementVector* Tria::CreatePVectorDiagnosticHutter(void){
 
 	/*Intermediaries */
 	int        i,connectivity;
-	double     constant_part,ub,vb;
-	double     rho_ice,gravity,n,B;
-	double     slope2,thickness;
-	double     slope[2];
+	IssmDouble     constant_part,ub,vb;
+	IssmDouble     rho_ice,gravity,n,B;
+	IssmDouble     slope2,thickness;
+	IssmDouble     slope[2];
 	GaussTria* gauss=NULL;
 
@@ -2949,9 +3003,9 @@
 		constant_part=-2*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2));
 
-		ub=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*thickness*slope[0];
-		vb=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*thickness*slope[1];
-
-		pe->values[2*i]  =(ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0])/(double)connectivity;
-		pe->values[2*i+1]=(vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1])/(double)connectivity;
+		ub=-1.58*pow((IssmDouble)10.0,(IssmDouble)-10.0)*rho_ice*gravity*thickness*slope[0];
+		vb=-1.58*pow((IssmDouble)10.0,(IssmDouble)-10.0)*rho_ice*gravity*thickness*slope[1];
+
+		pe->values[2*i]  =(ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0])/(IssmDouble)connectivity;
+		pe->values[2*i+1]=(vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1])/(IssmDouble)connectivity;
 	}
 
@@ -2961,5 +3015,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateJacobianDiagnosticMacayeal{{{1*/
+/*FUNCTION Tria::CreateJacobianDiagnosticMacayeal{{{*/
 ElementMatrix* Tria::CreateJacobianDiagnosticMacayeal(void){
 
@@ -2969,13 +3023,13 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     xyz_list[NUMVERTICES][3];
-	double     Jdet,thickness;
-	double     eps1dotdphii,eps1dotdphij;
-	double     eps2dotdphii,eps2dotdphij;
-	double     mu_prime;
-	double     epsilon[3];/* epsilon=[exx,eyy,exy];*/
-	double     eps1[2],eps2[2];
-	double     phi[NUMVERTICES];
-	double     dphi[2][NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jdet,thickness;
+	IssmDouble     eps1dotdphii,eps1dotdphij;
+	IssmDouble     eps2dotdphii,eps2dotdphij;
+	IssmDouble     mu_prime;
+	IssmDouble     epsilon[3];/* epsilon=[exx,eyy,exy];*/
+	IssmDouble     eps1[2],eps2[2];
+	IssmDouble     phi[NUMVERTICES];
+	IssmDouble     dphi[2][NUMVERTICES];
 	GaussTria *gauss=NULL;
 
@@ -3027,5 +3081,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetSolutionFromInputsDiagnosticHoriz{{{1*/
+/*FUNCTION Tria::GetSolutionFromInputsDiagnosticHoriz{{{*/
 void  Tria::GetSolutionFromInputsDiagnosticHoriz(Vector* solution){
 
@@ -3034,6 +3088,6 @@
 	int          i;
 	int*         doflist=NULL;
-	double       vx,vy;
-	double       values[numdof];
+	IssmDouble       vx,vy;
+	IssmDouble       values[numdof];
 	GaussTria*   gauss=NULL;
 
@@ -3063,8 +3117,8 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Tria::GetSolutionFromInputsDiagnosticHutter{{{1*/
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Tria::GetSolutionFromInputsDiagnosticHutter{{{*/
 void  Tria::GetSolutionFromInputsDiagnosticHutter(Vector* solution){
 
@@ -3072,6 +3126,6 @@
 
 	int        i;
-	double     vx,vy;
-	double     values[numdof];
+	IssmDouble     vx,vy;
+	IssmDouble     values[numdof];
 	int       *doflist = NULL;
 	GaussTria *gauss   = NULL;
@@ -3102,9 +3156,9 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHoriz {{{1*/
-void  Tria::InputUpdateFromSolutionDiagnosticHoriz(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHoriz {{{*/
+void  Tria::InputUpdateFromSolutionDiagnosticHoriz(IssmDouble* solution){
 	
 	const int numdof=NDOF2*NUMVERTICES;
@@ -3112,12 +3166,12 @@
 	int       i;
 	int*      doflist=NULL;
-	double    rho_ice,g;
-	double    values[numdof];
-	double    vx[NUMVERTICES];
-	double    vy[NUMVERTICES];
-	double    vz[NUMVERTICES];
-	double    vel[NUMVERTICES];
-	double    pressure[NUMVERTICES];
-	double    thickness[NUMVERTICES];
+	IssmDouble    rho_ice,g;
+	IssmDouble    values[numdof];
+	IssmDouble    vx[NUMVERTICES];
+	IssmDouble    vy[NUMVERTICES];
+	IssmDouble    vz[NUMVERTICES];
+	IssmDouble    vel[NUMVERTICES];
+	IssmDouble    pressure[NUMVERTICES];
+	IssmDouble    thickness[NUMVERTICES];
 	
 	/*Get dof list: */
@@ -3136,6 +3190,6 @@
 
 		/*Check solution*/
-		if(isnan(vx[i])) _error_("NaN found in solution vector");
-		if(isnan(vy[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -3164,10 +3218,10 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHutter {{{1*/
-void  Tria::InputUpdateFromSolutionDiagnosticHutter(double* solution){
+	xDelete<int>(doflist);
+
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHutter {{{*/
+void  Tria::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){
 	
 	const int numdof=NDOF2*NUMVERTICES;
@@ -3175,12 +3229,12 @@
 	int       i;
 	int*      doflist=NULL;
-	double    rho_ice,g;
-	double    values[numdof];
-	double    vx[NUMVERTICES];
-	double    vy[NUMVERTICES];
-	double    vz[NUMVERTICES];
-	double    vel[NUMVERTICES];
-	double    pressure[NUMVERTICES];
-	double    thickness[NUMVERTICES];
+	IssmDouble    rho_ice,g;
+	IssmDouble    values[numdof];
+	IssmDouble    vx[NUMVERTICES];
+	IssmDouble    vy[NUMVERTICES];
+	IssmDouble    vz[NUMVERTICES];
+	IssmDouble    vel[NUMVERTICES];
+	IssmDouble    pressure[NUMVERTICES];
+	IssmDouble    thickness[NUMVERTICES];
 	
 	/*Get dof list: */
@@ -3196,6 +3250,6 @@
 
 		/*Check solution*/
-		if(isnan(vx[i])) _error_("NaN found in solution vector");
-		if(isnan(vy[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vx[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(vy[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -3224,5 +3278,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -3230,6 +3284,6 @@
 
 #ifdef _HAVE_CONTROL_
-/*FUNCTION Tria::InputControlUpdate{{{1*/
-void  Tria::InputControlUpdate(double scalar,bool save_parameter){
+/*FUNCTION Tria::InputControlUpdate{{{*/
+void  Tria::InputControlUpdate(IssmDouble scalar,bool save_parameter){
 
 	/*Intermediary*/
@@ -3252,5 +3306,5 @@
 
 		if (input->ObjectEnum()!=ControlInputEnum){
-			_error_("input %s is not a ControlInput",EnumToStringx(control_type[i]));
+			_error2_("input " << EnumToStringx(control_type[i]) << " is not a ControlInput");
 		}
 
@@ -3262,8 +3316,8 @@
 
 	/*Clean up and return*/
-	xfree((void**)&control_type);
-}
-/*}}}*/
-/*FUNCTION Tria::ControlInputGetGradient{{{1*/
+	xDelete<int>(control_type);
+}
+/*}}}*/
+/*FUNCTION Tria::ControlInputGetGradient{{{*/
 void Tria::ControlInputGetGradient(Vector* gradient,int enum_type,int control_index){
 
@@ -3277,6 +3331,6 @@
 		input=inputs->GetInput(enum_type);
 	}
-	if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
-	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
+	if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
+	if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
 	GradientIndexing(&doflist1[0],control_index);
@@ -3284,6 +3338,6 @@
 
 }/*}}}*/
-/*FUNCTION Tria::ControlInputScaleGradient{{{1*/
-void Tria::ControlInputScaleGradient(int enum_type,double scale){
+/*FUNCTION Tria::ControlInputScaleGradient{{{*/
+void Tria::ControlInputScaleGradient(int enum_type,IssmDouble scale){
 
 	Input* input=NULL;
@@ -3295,14 +3349,14 @@
 		input=inputs->GetInput(enum_type);
 	}
-	if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
-	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
+	if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
+	if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
 	((ControlInput*)input)->ScaleGradient(scale);
 }/*}}}*/
-/*FUNCTION Tria::ControlInputSetGradient{{{1*/
-void Tria::ControlInputSetGradient(double* gradient,int enum_type,int control_index){
+/*FUNCTION Tria::ControlInputSetGradient{{{*/
+void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){
 
 	int    doflist1[NUMVERTICES];
-	double grad_list[NUMVERTICES];
+	IssmDouble grad_list[NUMVERTICES];
 	Input* grad_input=NULL;
 	Input* input=NULL;
@@ -3314,6 +3368,6 @@
 		input=inputs->GetInput(enum_type);
 	}
-	if (!input) _error_("Input %s not found",EnumToStringx(enum_type));
-	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input %s is not a ControlInput",EnumToStringx(enum_type));
+	if (!input) _error2_("Input " << EnumToStringx(enum_type) << " not found");
+	if (input->ObjectEnum()!=ControlInputEnum) _error2_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
 	GradientIndexing(&doflist1[0],control_index);
@@ -3324,5 +3378,5 @@
 
 }/*}}}*/
-/*FUNCTION Tria::Gradj {{{1*/
+/*FUNCTION Tria::Gradj {{{*/
 void  Tria::Gradj(Vector* gradient,int control_type,int control_index){
 	/*dJ/dalpha = ∂L/∂alpha = ∂J/∂alpha + ∂/∂alpha(KU-F)*/
@@ -3349,5 +3403,5 @@
 			break;
 		default:
-			_error_("%s%i","control type not supported yet: ",control_type);
+			_error2_("control type not supported yet: " << control_type);
 	}
 
@@ -3377,20 +3431,20 @@
 			break;
 		default:
-			_error_("response %s not supported yet",EnumToStringx(responses[resp]));
-	}
-
-	xfree((void**)&responses);
-}
-/*}}}*/
-/*FUNCTION Tria::GradjBGradient{{{1*/
+			_error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
+	}
+
+	xDelete<int>(responses);
+}
+/*}}}*/
+/*FUNCTION Tria::GradjBGradient{{{*/
 void  Tria::GradjBGradient(Vector* gradient,int weight_index,int control_index){
 
 	int        i,ig;
 	int        doflist1[NUMVERTICES];
-	double     Jdet,weight;
-	double     xyz_list[NUMVERTICES][3];
-	double     dbasis[NDOF2][NUMVERTICES];
-	double     dk[NDOF2]; 
-	double     grade_g[NUMVERTICES]={0.0};
+	IssmDouble     Jdet,weight;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     dbasis[NDOF2][NUMVERTICES];
+	IssmDouble     dk[NDOF2]; 
+	IssmDouble     grade_g[NUMVERTICES]={0.0};
 	GaussTria  *gauss=NULL;
 
@@ -3423,5 +3477,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GradjBMacAyeal{{{1*/
+/*FUNCTION Tria::GradjBMacAyeal{{{*/
 void  Tria::GradjBMacAyeal(Vector* gradient,int control_index){
 
@@ -3429,10 +3483,10 @@
 	int        i,ig;
 	int        doflist[NUMVERTICES];
-	double     vx,vy,lambda,mu,thickness,Jdet;
-	double     viscosity_complement;
-	double     dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dB[NDOF2]; 
-	double     xyz_list[NUMVERTICES][3];
-	double     basis[3],epsilon[3];
-	double     grad[NUMVERTICES]={0.0};
+	IssmDouble     vx,vy,lambda,mu,thickness,Jdet;
+	IssmDouble     viscosity_complement;
+	IssmDouble     dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dB[NDOF2]; 
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     basis[3],epsilon[3];
+	IssmDouble     grad[NUMVERTICES]={0.0};
 	GaussTria *gauss = NULL;
 
@@ -3480,5 +3534,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GradjDragMacAyeal {{{1*/
+/*FUNCTION Tria::GradjDragMacAyeal {{{*/
 void  Tria::GradjDragMacAyeal(Vector* gradient,int control_index){
 
@@ -3487,12 +3541,12 @@
 	int        doflist1[NUMVERTICES];
 	int        connectivity[NUMVERTICES];
-	double     vx,vy,lambda,mu,alpha_complement,Jdet;
-	double     bed,thickness,Neff,drag;
-	double     xyz_list[NUMVERTICES][3];
-	double     dk[NDOF2]; 
-	double     grade_g[NUMVERTICES]={0.0};
-	double     grade_g_gaussian[NUMVERTICES];
-	double     basis[3];
-	double     epsilon[3]; /* epsilon=[exx,eyy,exy];*/
+	IssmDouble     vx,vy,lambda,mu,alpha_complement,Jdet;
+	IssmDouble     bed,thickness,Neff,drag;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     dk[NDOF2]; 
+	IssmDouble     grade_g[NUMVERTICES]={0.0};
+	IssmDouble     grade_g_gaussian[NUMVERTICES];
+	IssmDouble     basis[3];
+	IssmDouble     epsilon[3]; /* epsilon=[exx,eyy,exy];*/
 	Friction*  friction=NULL;
 	GaussTria  *gauss=NULL;
@@ -3542,5 +3596,5 @@
 		/*Add gradje_g_gaussian vector to gradje_g: */
 		for(i=0;i<NUMVERTICES;i++){
-			_assert_(!isnan(grade_g[i]));
+			_assert_(!xIsNan<IssmDouble>(grade_g[i]));
 			grade_g[i]+=grade_g_gaussian[i];
 		}
@@ -3557,5 +3611,5 @@
 	//	vx_input->GetInputValue(&vx,gauss);
 	//	vy_input->GetInputValue(&vy,gauss);
-	//	grade_g[iv] = -2*1.e+7*drag*alpha_complement*(lambda*vx+mu*vy)/((double)connectivity[iv]);
+	//	grade_g[iv] = -2*1.e+7*drag*alpha_complement*(lambda*vx+mu*vy)/((IssmDouble)connectivity[iv]);
 	//}
 	/*End Analytical gradient*/
@@ -3568,14 +3622,14 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GradjDragGradient{{{1*/
+/*FUNCTION Tria::GradjDragGradient{{{*/
 void  Tria::GradjDragGradient(Vector* gradient, int weight_index,int control_index){
 
 	int        i,ig;
 	int        doflist1[NUMVERTICES];
-	double     Jdet,weight;
-	double     xyz_list[NUMVERTICES][3];
-	double     dbasis[NDOF2][NUMVERTICES];
-	double     dk[NDOF2]; 
-	double     grade_g[NUMVERTICES]={0.0};
+	IssmDouble     Jdet,weight;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     dbasis[NDOF2][NUMVERTICES];
+	IssmDouble     dk[NDOF2]; 
+	IssmDouble     grade_g[NUMVERTICES]={0.0};
 	GaussTria  *gauss=NULL;
 
@@ -3603,5 +3657,5 @@
 		for (i=0;i<NUMVERTICES;i++){
 			grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]);
-			_assert_(!isnan(grade_g[i]));
+			_assert_(!xIsNan<IssmDouble>(grade_g[i]));
 		}
 	}
@@ -3612,11 +3666,11 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GradjDhDtBalancedthickness{{{1*/
+/*FUNCTION Tria::GradjDhDtBalancedthickness{{{*/
 void  Tria::GradjDhDtBalancedthickness(Vector* gradient,int control_index){
 
 	/*Intermediaries*/
 	int    doflist1[NUMVERTICES];
-	double lambda[NUMVERTICES];
-	double gradient_g[NUMVERTICES];
+	IssmDouble lambda[NUMVERTICES];
+	IssmDouble gradient_g[NUMVERTICES];
 
 	/*Compute Gradient*/
@@ -3628,5 +3682,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GradjVxBalancedthickness{{{1*/
+/*FUNCTION Tria::GradjVxBalancedthickness{{{*/
 void  Tria::GradjVxBalancedthickness(Vector* gradient,int control_index){
 
@@ -3634,9 +3688,9 @@
 	int        i,ig;
 	int        doflist1[NUMVERTICES];
-	double     thickness,Jdet;
-	double     basis[3];
-	double     Dlambda[2],dp[2];
-	double     xyz_list[NUMVERTICES][3];
-	double     grade_g[NUMVERTICES] = {0.0};
+	IssmDouble     thickness,Jdet;
+	IssmDouble     basis[3];
+	IssmDouble     Dlambda[2],dp[2];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     grade_g[NUMVERTICES] = {0.0};
 	GaussTria *gauss                = NULL;
 
@@ -3671,5 +3725,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GradjVyBalancedthickness{{{1*/
+/*FUNCTION Tria::GradjVyBalancedthickness{{{*/
 void  Tria::GradjVyBalancedthickness(Vector* gradient,int control_index){
 
@@ -3677,9 +3731,9 @@
 	int        i,ig;
 	int        doflist1[NUMVERTICES];
-	double     thickness,Jdet;
-	double     basis[3];
-	double     Dlambda[2],dp[2];
-	double     xyz_list[NUMVERTICES][3];
-	double     grade_g[NUMVERTICES] = {0.0};
+	IssmDouble     thickness,Jdet;
+	IssmDouble     basis[3];
+	IssmDouble     Dlambda[2],dp[2];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     grade_g[NUMVERTICES] = {0.0};
 	GaussTria *gauss                = NULL;
 
@@ -3713,5 +3767,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GradientIndexing{{{1*/
+/*FUNCTION Tria::GradientIndexing{{{*/
 void  Tria::GradientIndexing(int* indexing,int control_index){
 
@@ -3727,14 +3781,14 @@
 }
 /*}}}*/
-/*FUNCTION Tria::RheologyBbarAbsGradient{{{1*/
-double Tria::RheologyBbarAbsGradient(bool process_units,int weight_index){
+/*FUNCTION Tria::RheologyBbarAbsGradient{{{*/
+IssmDouble Tria::RheologyBbarAbsGradient(bool process_units,int weight_index){
 
 	/* Intermediaries */
 	int        ig;
-	double     Jelem = 0;
-	double     weight;
-	double     Jdet;
-	double     xyz_list[NUMVERTICES][3];
-	double     dp[NDOF2];
+	IssmDouble     Jelem = 0;
+	IssmDouble     weight;
+	IssmDouble     Jdet;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     dp[NDOF2];
 	GaussTria *gauss = NULL;
 
@@ -3771,14 +3825,14 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SurfaceAverageVelMisfit {{{1*/
-double Tria::SurfaceAverageVelMisfit(bool process_units,int weight_index){
+/*FUNCTION Tria::SurfaceAverageVelMisfit {{{*/
+IssmDouble Tria::SurfaceAverageVelMisfit(bool process_units,int weight_index){
 
 	const int    numdof=2*NUMVERTICES;
 
 	int        i,ig;
-	double     Jelem=0,S,Jdet;
-	double     misfit;
-	double     vx,vy,vxobs,vyobs,weight;
-	double     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jelem=0,S,Jdet;
+	IssmDouble     misfit;
+	IssmDouble     vx,vy,vxobs,vyobs,weight;
+	IssmDouble     xyz_list[NUMVERTICES][3];
 	GaussTria *gauss=NULL;
 
@@ -3832,17 +3886,17 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SurfaceLogVelMisfit {{{1*/
-double Tria::SurfaceLogVelMisfit(bool process_units,int weight_index){
+/*FUNCTION Tria::SurfaceLogVelMisfit {{{*/
+IssmDouble Tria::SurfaceLogVelMisfit(bool process_units,int weight_index){
 
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	int        i,ig;
-	double     Jelem=0;
-	double     misfit,Jdet;
-	double     epsvel=2.220446049250313e-16;
-	double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
-	double     velocity_mag,obs_velocity_mag;
-	double     xyz_list[NUMVERTICES][3];
-	double     vx,vy,vxobs,vyobs,weight;
+	IssmDouble     Jelem=0;
+	IssmDouble     misfit,Jdet;
+	IssmDouble     epsvel=2.220446049250313e-16;
+	IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
+	IssmDouble     velocity_mag,obs_velocity_mag;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     vx,vy,vxobs,vyobs,weight;
 	GaussTria *gauss=NULL;
 
@@ -3897,6 +3951,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SurfaceLogVxVyMisfit {{{1*/
-double Tria::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
+/*FUNCTION Tria::SurfaceLogVxVyMisfit {{{*/
+IssmDouble Tria::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
 
 	const int    numdof=NDOF2*NUMVERTICES;
@@ -3904,10 +3958,10 @@
 	int        i,ig;
 	int        fit=-1;
-	double     Jelem=0, S=0;
-	double     epsvel=2.220446049250313e-16;
-	double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
-	double     misfit, Jdet;
-	double     vx,vy,vxobs,vyobs,weight;
-	double     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jelem=0, S=0;
+	IssmDouble     epsvel=2.220446049250313e-16;
+	IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
+	IssmDouble     misfit, Jdet;
+	IssmDouble     vx,vy,vxobs,vyobs,weight;
+	IssmDouble     xyz_list[NUMVERTICES][3];
 	GaussTria *gauss=NULL;
 
@@ -3963,14 +4017,14 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SurfaceAbsVelMisfit {{{1*/
-double Tria::SurfaceAbsVelMisfit(bool process_units,int weight_index){
+/*FUNCTION Tria::SurfaceAbsVelMisfit {{{*/
+IssmDouble Tria::SurfaceAbsVelMisfit(bool process_units,int weight_index){
 
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	int        i,ig;
-	double     Jelem=0;
-	double     misfit,Jdet;
-	double     vx,vy,vxobs,vyobs,weight;
-	double     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jelem=0;
+	IssmDouble     misfit,Jdet;
+	IssmDouble     vx,vy,vxobs,vyobs,weight;
+	IssmDouble     xyz_list[NUMVERTICES][3];
 	GaussTria *gauss=NULL;
 
@@ -4024,16 +4078,16 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SurfaceRelVelMisfit {{{1*/
-double Tria::SurfaceRelVelMisfit(bool process_units,int weight_index){
+/*FUNCTION Tria::SurfaceRelVelMisfit {{{*/
+IssmDouble Tria::SurfaceRelVelMisfit(bool process_units,int weight_index){
 	const int  numdof=2*NUMVERTICES;
 
 	int        i,ig;
-	double     Jelem=0;
-	double     scalex=1,scaley=1;
-	double     misfit,Jdet;
-	double     epsvel=2.220446049250313e-16;
-	double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
-	double     vx,vy,vxobs,vyobs,weight;
-	double     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jelem=0;
+	IssmDouble     scalex=1,scaley=1;
+	IssmDouble     misfit,Jdet;
+	IssmDouble     epsvel=2.220446049250313e-16;
+	IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
+	IssmDouble     vx,vy,vxobs,vyobs,weight;
+	IssmDouble     xyz_list[NUMVERTICES][3];
 	GaussTria *gauss=NULL;
 
@@ -4088,14 +4142,14 @@
 }
 /*}}}*/
-/*FUNCTION Tria::ThicknessAbsGradient{{{1*/
-double Tria::ThicknessAbsGradient(bool process_units,int weight_index){
+/*FUNCTION Tria::ThicknessAbsGradient{{{*/
+IssmDouble Tria::ThicknessAbsGradient(bool process_units,int weight_index){
 
 	/* Intermediaries */
 	int        ig;
-	double     Jelem = 0;
-	double     weight;
-	double     Jdet;
-	double     xyz_list[NUMVERTICES][3];
-	double     dp[NDOF2];
+	IssmDouble     Jelem = 0;
+	IssmDouble     weight;
+	IssmDouble     Jdet;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     dp[NDOF2];
 	GaussTria *gauss = NULL;
 
@@ -4132,15 +4186,15 @@
 }
 /*}}}*/
-/*FUNCTION Tria::ThicknessAbsMisfit {{{1*/
-double Tria::ThicknessAbsMisfit(bool process_units,int weight_index){
+/*FUNCTION Tria::ThicknessAbsMisfit {{{*/
+IssmDouble Tria::ThicknessAbsMisfit(bool process_units,int weight_index){
 
 	/*Intermediaries*/
 	int        i,ig;
-	double     thickness,thicknessobs,weight;
-	double     Jdet;
-	double     Jelem = 0;
-	double     xyz_list[NUMVERTICES][3];
+	IssmDouble     thickness,thicknessobs,weight;
+	IssmDouble     Jdet;
+	IssmDouble     Jelem = 0;
+	IssmDouble     xyz_list[NUMVERTICES][3];
 	GaussTria *gauss = NULL;
-	double     dH[2];
+	IssmDouble     dH[2];
 
 	/*If on water, return 0: */
@@ -4177,5 +4231,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorAdjointBalancethickness{{{1*/
+/*FUNCTION Tria::CreatePVectorAdjointBalancethickness{{{*/
 ElementVector* Tria::CreatePVectorAdjointBalancethickness(void){
 
@@ -4185,12 +4239,12 @@
 	/*Intermediaries */
 	int         i,ig,resp;
-	double      Jdet;
-	double      thickness,thicknessobs,weight;
+	IssmDouble      Jdet;
+	IssmDouble      thickness,thicknessobs,weight;
 	int        *responses = NULL;
 	int         num_responses;
-	double      xyz_list[NUMVERTICES][3];
-	double      basis[3];
-	double      dbasis[NDOF2][NUMVERTICES];
-	double      dH[2];
+	IssmDouble      xyz_list[NUMVERTICES][3];
+	IssmDouble      basis[3];
+	IssmDouble      dbasis[NDOF2][NUMVERTICES];
+	IssmDouble      dH[2];
 	GaussTria*  gauss=NULL;
 
@@ -4233,5 +4287,5 @@
 				break;
 			default:
-				_error_("response %s not supported yet",EnumToStringx(responses[resp]));
+				_error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
 		}
 	}
@@ -4239,9 +4293,9 @@
 	/*Clean up and return*/
 	delete gauss;
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 	return pe;
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorAdjointHoriz{{{1*/
+/*FUNCTION Tria::CreatePVectorAdjointHoriz{{{*/
 ElementVector* Tria::CreatePVectorAdjointHoriz(void){
 
@@ -4253,13 +4307,13 @@
 	int       *responses=NULL;
 	int        num_responses;
-	double     Jdet;
-	double     obs_velocity_mag,velocity_mag;
-	double     dux,duy;
-	double     epsvel=2.220446049250313e-16;
-	double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
-	double     scalex=0,scaley=0,scale=0,S=0;
-	double     vx,vy,vxobs,vyobs,weight;
-	double     xyz_list[NUMVERTICES][3];
-	double     basis[3];
+	IssmDouble     Jdet;
+	IssmDouble     obs_velocity_mag,velocity_mag;
+	IssmDouble     dux,duy;
+	IssmDouble     epsvel=2.220446049250313e-16;
+	IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
+	IssmDouble     scalex=0,scaley=0,scale=0,S=0;
+	IssmDouble     vx,vy,vxobs,vyobs,weight;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     basis[3];
 	GaussTria* gauss=NULL;
 
@@ -4411,5 +4465,5 @@
 					break;
 				default:
-					_error_("response %s not supported yet",EnumToStringx(responses[resp]));
+					_error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
 			}
 		}
@@ -4418,9 +4472,9 @@
 	/*Clean up and return*/
 	delete gauss;
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 	return pe;
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorAdjointStokes{{{1*/
+/*FUNCTION Tria::CreatePVectorAdjointStokes{{{*/
 ElementVector* Tria::CreatePVectorAdjointStokes(void){
 
@@ -4429,13 +4483,13 @@
 	int       *responses=NULL;
 	int        num_responses;
-	double     Jdet;
-	double     obs_velocity_mag,velocity_mag;
-	double     dux,duy;
-	double     epsvel=2.220446049250313e-16;
-	double     meanvel=3.170979198376458e-05; /*1000 m/yr*/
-	double     scalex=0,scaley=0,scale=0,S=0;
-	double     vx,vy,vxobs,vyobs,weight;
-	double     xyz_list[NUMVERTICES][3];
-	double     basis[3];
+	IssmDouble     Jdet;
+	IssmDouble     obs_velocity_mag,velocity_mag;
+	IssmDouble     dux,duy;
+	IssmDouble     epsvel=2.220446049250313e-16;
+	IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
+	IssmDouble     scalex=0,scaley=0,scale=0,S=0;
+	IssmDouble     vx,vy,vxobs,vyobs,weight;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     basis[3];
 	GaussTria* gauss=NULL;
 
@@ -4588,5 +4642,5 @@
 					break;
 				default:
-					_error_("response %s not supported yet",EnumToStringx(responses[resp]));
+					_error2_("response " << EnumToStringx(responses[resp]) << " not supported yet");
 			}
 		}
@@ -4595,18 +4649,18 @@
 	/*Clean up and return*/
 	delete gauss;
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 	return pe;
 }
 /*}}}*/
-/*FUNCTION Tria::DragCoefficientAbsGradient{{{1*/
-double Tria::DragCoefficientAbsGradient(bool process_units,int weight_index){
+/*FUNCTION Tria::DragCoefficientAbsGradient{{{*/
+IssmDouble Tria::DragCoefficientAbsGradient(bool process_units,int weight_index){
 
 	/* Intermediaries */
 	int        ig;
-	double     Jelem = 0;
-	double     weight;
-	double     Jdet;
-	double     xyz_list[NUMVERTICES][3];
-	double     dp[NDOF2];
+	IssmDouble     Jelem = 0;
+	IssmDouble     weight;
+	IssmDouble     Jdet;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     dp[NDOF2];
 	GaussTria *gauss = NULL;
 
@@ -4643,5 +4697,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixAdjointBalancethickness {{{1*/
+/*FUNCTION Tria::CreateKMatrixAdjointBalancethickness {{{*/
 ElementMatrix* Tria::CreateKMatrixAdjointBalancethickness(void){
 
@@ -4657,5 +4711,5 @@
 			break;
 		default:
-			_error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
+			_error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
 	}
 
@@ -4665,5 +4719,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixAdjointMacAyeal{{{1*/
+/*FUNCTION Tria::CreateKMatrixAdjointMacAyeal{{{*/
 ElementMatrix* Tria::CreateKMatrixAdjointMacAyeal(void){
 
@@ -4674,13 +4728,13 @@
 	int        i,j,ig;
 	bool       incomplete_adjoint;
-	double     xyz_list[NUMVERTICES][3];
-	double     Jdet,thickness;
-	double     eps1dotdphii,eps1dotdphij;
-	double     eps2dotdphii,eps2dotdphij;
-	double     mu_prime;
-	double     epsilon[3];/* epsilon=[exx,eyy,exy];*/
-	double     eps1[2],eps2[2];
-	double     phi[NUMVERTICES];
-	double     dphi[2][NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     Jdet,thickness;
+	IssmDouble     eps1dotdphii,eps1dotdphij;
+	IssmDouble     eps2dotdphii,eps2dotdphij;
+	IssmDouble     mu_prime;
+	IssmDouble     epsilon[3];/* epsilon=[exx,eyy,exy];*/
+	IssmDouble     eps1[2],eps2[2];
+	IssmDouble     phi[NUMVERTICES];
+	IssmDouble     dphi[2][NUMVERTICES];
 	GaussTria *gauss=NULL;
 
@@ -4735,6 +4789,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria::InputUpdateFromSolutionAdjointHoriz {{{1*/
-void  Tria::InputUpdateFromSolutionAdjointHoriz(double* solution){
+/*FUNCTION Tria::InputUpdateFromSolutionAdjointHoriz {{{*/
+void  Tria::InputUpdateFromSolutionAdjointHoriz(IssmDouble* solution){
 
 	const int numdof=NDOF2*NUMVERTICES;
@@ -4742,7 +4796,7 @@
 	int       i;
 	int*      doflist=NULL;
-	double    values[numdof];
-	double    lambdax[NUMVERTICES];
-	double    lambday[NUMVERTICES];
+	IssmDouble    values[numdof];
+	IssmDouble    lambdax[NUMVERTICES];
+	IssmDouble    lambday[NUMVERTICES];
 
 	/*Get dof list: */
@@ -4758,6 +4812,6 @@
 
 		/*Check solution*/
-		if(isnan(lambdax[i])) _error_("NaN found in solution vector");
-		if(isnan(lambday[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambdax[i])) _error2_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambday[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -4767,10 +4821,9 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-
-/*FUNCTION Tria::InputUpdateFromSolutionAdjointBalancethickness {{{1*/
-void  Tria::InputUpdateFromSolutionAdjointBalancethickness(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromSolutionAdjointBalancethickness {{{*/
+void  Tria::InputUpdateFromSolutionAdjointBalancethickness(IssmDouble* solution){
 
 	const int numdof=NDOF1*NUMVERTICES;
@@ -4778,6 +4831,6 @@
 	int       i;
 	int*      doflist=NULL;
-	double    values[numdof];
-	double    lambda[NUMVERTICES];
+	IssmDouble    values[numdof];
+	IssmDouble    lambda[NUMVERTICES];
 
 	/*Get dof list: */
@@ -4790,5 +4843,5 @@
 	for(i=0;i<numdof;i++){
 		lambda[i]=values[i];
-		if(isnan(lambda[i])) _error_("NaN found in solution vector");
+		if(xIsNan<IssmDouble>(lambda[i])) _error2_("NaN found in solution vector");
 	}
 
@@ -4797,8 +4850,8 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Tria::GetVectorFromControlInputs{{{1*/
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Tria::GetVectorFromControlInputs{{{*/
 void  Tria::GetVectorFromControlInputs(Vector* vector,int control_enum,int control_index,const char* data){
 
@@ -4822,5 +4875,5 @@
 	/*Check that it is a ControlInput*/
 	if (input->ObjectEnum()!=ControlInputEnum){
-		_error_("input %s is not a ControlInput",EnumToStringx(control_enum));
+		_error2_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
 	}
 
@@ -4828,8 +4881,8 @@
 }
 /*}}}*/
-/*FUNCTION Tria::SetControlInputsFromVector{{{1*/
-void  Tria::SetControlInputsFromVector(double* vector,int control_enum,int control_index){
-
-	double  values[NUMVERTICES];
+/*FUNCTION Tria::SetControlInputsFromVector{{{*/
+void  Tria::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){
+
+	IssmDouble  values[NUMVERTICES];
 	int     doflist1[NUMVERTICES];
 	Input  *input     = NULL;
@@ -4856,5 +4909,5 @@
 
 	if (input->ObjectEnum()!=ControlInputEnum){
-		_error_("input %s is not a ControlInput",EnumToStringx(control_enum));
+		_error2_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
 	}
 
@@ -4865,16 +4918,16 @@
 
 #ifdef _HAVE_HYDROLOGY_
-/*FUNCTION Tria::CreateHydrologyWaterVelocityInput {{{1*/
+/*FUNCTION Tria::CreateHydrologyWaterVelocityInput {{{*/
 void Tria::CreateHydrologyWaterVelocityInput(void){
 
 	/*material parameters: */
-	double mu_water;
-	double VelocityFactor;  // This factor represents the number 12 in laminar flow velocity which can vary by differnt hydrology.CR
-	double n_man,CR;
-	double w;
-	double rho_ice, rho_water, g;
-	double dsdx,dsdy,dbdx,dbdy;
-	double vx[NUMVERTICES];
-	double vy[NUMVERTICES];
+	IssmDouble mu_water;
+	IssmDouble VelocityFactor;  // This factor represents the number 12 in laminar flow velocity which can vary by differnt hydrology.CR
+	IssmDouble n_man,CR;
+	IssmDouble w;
+	IssmDouble rho_ice, rho_water, g;
+	IssmDouble dsdx,dsdy,dbdx,dbdy;
+	IssmDouble vx[NUMVERTICES];
+	IssmDouble vy[NUMVERTICES];
 	GaussTria *gauss = NULL;
 
@@ -4920,5 +4973,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixHydrology{{{1*/
+/*FUNCTION Tria::CreateKMatrixHydrology{{{*/
 ElementMatrix* Tria::CreateKMatrixHydrology(void){
 
@@ -4927,18 +4980,18 @@
 
 	/*Intermediaries */
-	double     diffusivity;
+	IssmDouble     diffusivity;
 	int        i,j,ig;
-	double     Jdettria,DL_scalar,dt,h;
-	double     vx,vy,vel,dvxdx,dvydy;
-	double     dvx[2],dvy[2];
-	double     v_gauss[2]={0.0};
-	double     xyz_list[NUMVERTICES][3];
-	double     L[NUMVERTICES];
-	double     B[2][NUMVERTICES];
-	double     Bprime[2][NUMVERTICES];
-	double     K[2][2]                        ={0.0};
-	double     KDL[2][2]                      ={0.0};
-	double     DL[2][2]                        ={0.0};
-	double     DLprime[2][2]                   ={0.0};
+	IssmDouble     Jdettria,DL_scalar,dt,h;
+	IssmDouble     vx,vy,vel,dvxdx,dvydy;
+	IssmDouble     dvx[2],dvy[2];
+	IssmDouble     v_gauss[2]={0.0};
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     L[NUMVERTICES];
+	IssmDouble     B[2][NUMVERTICES];
+	IssmDouble     Bprime[2][NUMVERTICES];
+	IssmDouble     K[2][2]                        ={0.0};
+	IssmDouble     KDL[2][2]                      ={0.0};
+	IssmDouble     DL[2][2]                        ={0.0};
+	IssmDouble     DLprime[2][2]                   ={0.0};
 	GaussTria *gauss=NULL;
 
@@ -5025,5 +5078,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorHydrology {{{1*/
+/*FUNCTION Tria::CreatePVectorHydrology {{{*/
 ElementVector* Tria::CreatePVectorHydrology(void){
 
@@ -5033,9 +5086,9 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     Jdettria,dt;
-	double     basal_melting_g;
-	double     old_watercolumn_g;
-	double     xyz_list[NUMVERTICES][3];
-	double     basis[numdof];
+	IssmDouble     Jdettria,dt;
+	IssmDouble     basal_melting_g;
+	IssmDouble     old_watercolumn_g;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     basis[numdof];
 	GaussTria* gauss=NULL;
 
@@ -5074,5 +5127,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::GetSolutionFromInputsHydrology{{{1*/
+/*FUNCTION Tria::GetSolutionFromInputsHydrology{{{*/
 void  Tria::GetSolutionFromInputsHydrology(Vector* solution){
 
@@ -5081,6 +5134,6 @@
 	int i;
 	int*         doflist=NULL;
-	double       watercolumn;
-	double       values[numdof];
+	IssmDouble       watercolumn;
+	IssmDouble       values[numdof];
 	GaussTria*   gauss=NULL;
 
@@ -5107,9 +5160,9 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromSolutionHydrology{{{1*/
-void  Tria::InputUpdateFromSolutionHydrology(double* solution){
+	xDelete<int>(doflist);
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromSolutionHydrology{{{*/
+void  Tria::InputUpdateFromSolutionHydrology(IssmDouble* solution){
 
 	/*Intermediaries*/
@@ -5118,5 +5171,5 @@
 	int       i;
 	int*      doflist=NULL;
-	double    values[numdof];
+	IssmDouble    values[numdof];
 
 	/*Get dof list: */
@@ -5126,6 +5179,6 @@
 	for(i=0;i<numdof;i++){
 		values[i]=solution[doflist[i]];
-		if(isnan(values[i])) _error_("NaN found in solution vector");
-		if (values[i]<pow((double)10,(double)-10))values[i]=pow((double)10,(double)-10); //correcting the water column to positive values
+		if(xIsNan<IssmDouble>(values[i])) _error2_("NaN found in solution vector");
+		if (values[i]<pow((IssmDouble)10,(IssmDouble)-10))values[i]=pow((IssmDouble)10,(IssmDouble)-10); //correcting the water column to positive values
  
 	}
@@ -5135,5 +5188,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -5141,6 +5194,6 @@
 
 #ifdef _HAVE_DAKOTA_
-/*FUNCTION Tria::InputUpdateFromVectorDakota(double* vector, int name, int type);{{{1*/
-void  Tria::InputUpdateFromVectorDakota(double* vector, int name, int type){
+/*FUNCTION Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/
+void  Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
 	
 	int i,j;
@@ -5154,5 +5207,5 @@
 
 			/*New TriaP1Input*/
-			double values[3];
+			IssmDouble values[3];
 
 			/*Get values on the 3 vertices*/
@@ -5164,10 +5217,9 @@
 			switch(name){
 				case ThicknessEnum:
-					/*Update thickness + surface: assume bed is constant. On ice shelves, takes hydrostatic equilibrium {{{2*/
-					double  thickness[3];
-					double  thickness_init[3];
-					double  hydrostatic_ratio[3];
-					double  surface[3];
-					double  bed[3];
+					IssmDouble  thickness[3];
+					IssmDouble  thickness_init[3];
+					IssmDouble  hydrostatic_ratio[3];
+					IssmDouble  surface[3];
+					IssmDouble  bed[3];
 					
 					/*retrieve inputs: */
@@ -5177,43 +5229,33 @@
 					GetInputListOnVertices(&surface[0],SurfaceEnum);
 
-					/*build new thickness: */
-//					for(j=0;j<3;j++)thickness[j]=values[j];
-
 					/*build new bed and surface: */
 					if (this->IsFloating()){
 						/*hydrostatic equilibrium: */
-						double rho_ice,rho_water,di;
-						rho_ice=this->matpar->GetRhoIce();
-						rho_water=this->matpar->GetRhoWater();
-
-						di=rho_ice/rho_water;
+						IssmDouble rho_ice,rho_water,di;
+						rho_ice   = this->matpar->GetRhoIce();
+						rho_water = this->matpar->GetRhoWater();
+						di        = rho_ice/rho_water;
 
 						/*build new thickness: */
 						for (j=0; j<3; j++) {
-						/*  for observed/interpolated/hydrostatic thickness, remove scaling from any hydrostatic thickness  */
-							if     (hydrostatic_ratio[j] >= 0.)
+							/*  for observed/interpolated/hydrostatic thickness, remove scaling from any hydrostatic thickness  */
+							if (hydrostatic_ratio[j] >= 0.)
 								thickness[j]=values[j]-(values[j]/thickness_init[j]-1.)*hydrostatic_ratio[j]*surface[j]/(1.-di);
-						/*  for minimum thickness, don't scale  */
+							/*  for minimum thickness, don't scale  */
 							else
 								thickness[j]=thickness_init[j];
 
-						/*  check the computed thickness and update bed  */
-							if (thickness[j] < 0.)
-								thickness[j]=1./(1.-di);
+							/*  check the computed thickness and update bed*/
+							if (thickness[j] < 0.) thickness[j]=1./(1.-di);
 							bed[j]=surface[j]-thickness[j];
 						}
-
-//						for(j=0;j<3;j++){
-//							surface[j]=(1-di)*thickness[j];
-//							bed[j]=-di*thickness[j];
-//						}
 					}
 					else{
 						/*build new thickness: */
 						for (j=0; j<3; j++) {
-						/*  for observed thickness, use scaled value  */
+							/*  for observed thickness, use scaled value  */
 							if (hydrostatic_ratio[j] >= 0.)
 								thickness[j]=values[j];
-						/*  for minimum thickness, don't scale  */
+							/*  for minimum thickness, don't scale  */
 							else
 								thickness[j]=thickness_init[j];
@@ -5221,5 +5263,4 @@
 
 						/*update bed on grounded ice: */
-//						for(j=0;j<3;j++)surface[j]=bed[j]+thickness[j];
 						for(j=0;j<3;j++)bed[j]=surface[j]-thickness[j];
 					}
@@ -5230,5 +5271,4 @@
 					this->inputs->AddInput(new TriaP1Input(SurfaceEnum,surface));
 
-					/*}}}*/
 					break;
 				default:
@@ -5238,28 +5278,28 @@
 
 		default:
-			_error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
-	}
-
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromVectorDakota(int* vector, int name, int type);{{{1*/
+			_error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromVectorDakota(int* vector, int name, int type);{{{*/
 void  Tria::InputUpdateFromVectorDakota(int* vector, int name, int type){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromVectorDakota(bool* vector, int name, int type);{{{1*/
+	_error2_("not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromVectorDakota(bool* vector, int name, int type);{{{*/
 void  Tria::InputUpdateFromVectorDakota(bool* vector, int name, int type){
-	_error_(" not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Tria::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type);{{{1*/
-void  Tria::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
+	_error2_("not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/
+void  Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
 	
 	int i,j,t;
 	TransientInput* transientinput=NULL;
-	double values[3];
-	double time;
+	IssmDouble values[3];
+	IssmDouble time;
 	int row;
-	double yts;
+	IssmDouble yts;
 
 	/*Check that name is an element input*/
@@ -5278,9 +5318,9 @@
 				for(i=0;i<3;i++){
 					row=this->nodes[i]->GetSidList();
-					values[i]=(double)matrix[ncols*row+t];
+					values[i]=(IssmDouble)matrix[ncols*row+t];
 				}
 
 				/*time? :*/
-				time=(double)matrix[(nrows-1)*ncols+t]*yts;
+				time=(IssmDouble)matrix[(nrows-1)*ncols+t]*yts;
 
 				if(t==0) transientinput=new TransientInput(name);
@@ -5292,5 +5332,5 @@
 
 		default:
-			_error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
+			_error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
 	}
 
@@ -5300,5 +5340,5 @@
 
 #ifdef _HAVE_BALANCED_
-/*FUNCTION Tria::CreateKMatrixBalancethickness {{{1*/
+/*FUNCTION Tria::CreateKMatrixBalancethickness {{{*/
 ElementMatrix* Tria::CreateKMatrixBalancethickness(void){
 
@@ -5309,10 +5349,10 @@
 			return CreateKMatrixBalancethickness_DG();
 		default:
-			_error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
-	}
-
-}
-/*}}}*/
-/*FUNCTION Tria::CreateKMatrixBalancethickness_CG {{{1*/
+			_error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Tria::CreateKMatrixBalancethickness_CG {{{*/
 ElementMatrix* Tria::CreateKMatrixBalancethickness_CG(void){
 
@@ -5323,15 +5363,15 @@
 	int        stabilization;
 	int        i,j,ig,dim;
-	double     Jdettria,vx,vy,dvxdx,dvydy,vel,h;
-	double     dvx[2],dvy[2];
-	double     xyz_list[NUMVERTICES][3];
-	double     L[NUMVERTICES];
-	double     B[2][NUMVERTICES];
-	double     Bprime[2][NUMVERTICES];
-	double     K[2][2]                          = {0.0};
-	double     KDL[2][2]                        = {0.0};
-	double     DL[2][2]                         = {0.0};
-	double     DLprime[2][2]                    = {0.0};
-	double     DL_scalar;
+	IssmDouble     Jdettria,vx,vy,dvxdx,dvydy,vel,h;
+	IssmDouble     dvx[2],dvy[2];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     L[NUMVERTICES];
+	IssmDouble     B[2][NUMVERTICES];
+	IssmDouble     Bprime[2][NUMVERTICES];
+	IssmDouble     K[2][2]                          = {0.0};
+	IssmDouble     KDL[2][2]                        = {0.0};
+	IssmDouble     DL[2][2]                         = {0.0};
+	IssmDouble     DLprime[2][2]                    = {0.0};
+	IssmDouble     DL_scalar;
 	GaussTria *gauss                            = NULL;
 
@@ -5424,5 +5464,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreateKMatrixBalancethickness_DG {{{1*/
+/*FUNCTION Tria::CreateKMatrixBalancethickness_DG {{{*/
 ElementMatrix* Tria::CreateKMatrixBalancethickness_DG(void){
 
@@ -5432,10 +5472,10 @@
 	/*Intermediaries*/
 	int        i,j,ig,dim;
-	double     vx,vy,Jdettria;
-	double     xyz_list[NUMVERTICES][3];
-	double     B[2][NUMVERTICES];
-	double     Bprime[2][NUMVERTICES];
-	double     DL[2][2]={0.0};
-	double     DL_scalar;
+	IssmDouble     vx,vy,Jdettria;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     B[2][NUMVERTICES];
+	IssmDouble     Bprime[2][NUMVERTICES];
+	IssmDouble     DL[2][2]={0.0};
+	IssmDouble     DL_scalar;
 	GaussTria  *gauss=NULL;
 
@@ -5478,5 +5518,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorBalancethickness{{{1*/
+/*FUNCTION Tria::CreatePVectorBalancethickness{{{*/
 ElementVector* Tria::CreatePVectorBalancethickness(void){
 
@@ -5488,9 +5528,9 @@
 			return CreatePVectorBalancethickness_DG();
 		default:
-			_error_("Element type %s not supported yet",EnumToStringx(GetElementType()));
-	}
-}
-/*}}}*/
-/*FUNCTION Tria::CreatePVectorBalancethickness_CG{{{1*/
+			_error2_("Element type " << EnumToStringx(GetElementType()) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Tria::CreatePVectorBalancethickness_CG{{{*/
 ElementVector* Tria::CreatePVectorBalancethickness_CG(void){
 
@@ -5500,7 +5540,7 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     xyz_list[NUMVERTICES][3];
-	double     dhdt_g,basal_melting_g,surface_mass_balance_g,Jdettria;
-	double     L[NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     dhdt_g,basal_melting_g,surface_mass_balance_g,Jdettria;
+	IssmDouble     L[NUMVERTICES];
 	GaussTria* gauss=NULL;
 
@@ -5535,5 +5575,5 @@
 }
 /*}}}*/
-/*FUNCTION Tria::CreatePVectorBalancethickness_DG {{{1*/
+/*FUNCTION Tria::CreatePVectorBalancethickness_DG {{{*/
 ElementVector* Tria::CreatePVectorBalancethickness_DG(void){
 
@@ -5543,7 +5583,7 @@
 	/*Intermediaries */
 	int        i,j,ig;
-	double     xyz_list[NUMVERTICES][3];
-	double     basal_melting_g,surface_mass_balance_g,dhdt_g,Jdettria;
-	double     L[NUMVERTICES];
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     basal_melting_g,surface_mass_balance_g,dhdt_g,Jdettria;
+	IssmDouble     L[NUMVERTICES];
 	GaussTria* gauss=NULL;
 
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Element.h"
 #include "./TriaHook.h"
@@ -41,10 +41,10 @@
 		Results    *results;
 
-		/*Tria constructors, destructors {{{1*/
+		/*Tria constructors, destructors {{{*/
 		Tria();
 		Tria(int tria_id,int tria_sid,int i, IoModel* iomodel,int nummodels);
 		~Tria();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -54,22 +54,22 @@
 		Object* copy();
 		/*}}}*/
-		/*Update virtual functions resolution: {{{1*/
-		void  InputUpdateFromSolution(double* solutiong);
-		void  InputUpdateFromVector(double* vector, int name, int type);
+		/*Update virtual functions resolution: {{{*/
+		void  InputUpdateFromSolution(IssmDouble* solutiong);
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVector(int* vector, int name, int type);
 		void  InputUpdateFromVector(bool* vector, int name, int type);
 		#ifdef _HAVE_DAKOTA_
-		void  InputUpdateFromVectorDakota(double* vector, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(int* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(double* matrix, int nows, int ncols, int name, int type);
-		#endif
-		void  InputUpdateFromConstant(double constant, int name);
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
+		#endif
+		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel);
 		/*}}}*/
-		/*Element virtual functions definitions: {{{1*/
-		void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,double* vertex_response,double* qmu_part);
+		/*Element virtual functions definitions: {{{*/
+		void   AverageOntoPartition(Vector* partition_contributions,Vector* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part);
 		void   ComputeBasalStress(Vector* sigma_b);
 		void   ComputeStrainRate(Vector* eps);
@@ -85,56 +85,57 @@
 		bool   IsFloating(); 
 		bool   IsNodeOnShelf(); 
-		bool   IsNodeOnShelfFromFlags(double* flags);
+		bool   IsNodeOnShelfFromFlags(IssmDouble* flags);
 		bool   IsOnWater(); 
 		void   GetSolutionFromInputs(Vector* solution);
 		void   GetVectorFromInputs(Vector* vector, int name_enum);
 		void   GetVectorFromResults(Vector* vector,int offset,int enum_in,int interp);
-		void   InputArtificialNoise(int enum_type,double min, double max);
-		bool   InputConvergence(double* eps, int* enums,int num_enums,int* criterionenums,double* criterionvalues,int num_criterionenums);
-		void   InputCreate(double scalar,int name,int code);
-		void   InputCreate(double* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);
+		void   InputArtificialNoise(int enum_type,IssmDouble min, IssmDouble max);
+		bool   InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums);
+		void   InputCreate(IssmDouble scalar,int name,int code);
+		void   InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code);
 		void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum=MeshElementsEnum);
 		void   InputDuplicate(int original_enum,int new_enum);
-		void   InputScale(int enum_type,double scale_factor);
-		void   InputToResult(int enum_type,int step,double time);
+		void   InputScale(int enum_type,IssmDouble scale_factor);
+		void   InputToResult(int enum_type,int step,IssmDouble time);
 		void   DeleteResults(void);
-		void   MaterialUpdateFromTemperature(void){_error_("not implemented yet");};
-		void   MigrateGroundingLine(double* oldfloating,double* sheet_ungrounding);
-		int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
+		void   MaterialUpdateFromTemperature(void){_error2_("not implemented yet");};
+		void   MigrateGroundingLine(IssmDouble* oldfloating,IssmDouble* sheet_ungrounding);
+		int    NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units);
 		void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding);
-		void   PositiveDegreeDay(double* pdds,double* pds,double signorm);
-		void   RequestedOutput(int output_enum,int step,double time);
-		void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results);
+		void   PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm);
+		void   RequestedOutput(int output_enum,int step,IssmDouble time);
+		void   ListResultsInfo(int** results_enums,int** results_size,IssmDouble** results_times,int** results_steps,int* num_results);
 		void   PatchFill(int* pcount, Patch* patch);
 		void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes);
 		void   ProcessResultsUnits(void);
-		void   ResetCoordinateSystem(void){_error_("not implemented yet");};
-		double SurfaceArea(void);
+		void   ResetCoordinateSystem(void){_error2_("not implemented yet");};
+		void	 SmbGradients();
+		IssmDouble SurfaceArea(void);
 		void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type);
-		int    UpdatePotentialSheetUngrounding(double* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf);
-		double TimeAdapt();
+		int    UpdatePotentialSheetUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf);
+		IssmDouble TimeAdapt();
 		int*   GetHorizontalNeighboorSids(void);
-		void   SmearFunction(Vector* smearedvector,double (*WeightFunction)(double distance,double radius),double radius);
+		void   SmearFunction(Vector* smearedvector,IssmDouble (*WeightFunction)(IssmDouble distance,IssmDouble radius),IssmDouble radius);
 
 		#ifdef _HAVE_RESPONSES_
-		double IceVolume(void);
-		void   MinVel(double* pminvel, bool process_units);
-		void   MinVx(double* pminvx, bool process_units);
-		void   MinVy(double* pminvy, bool process_units);
-		void   MinVz(double* pminvz, bool process_units);
-		double MassFlux(double* segment,bool process_units);
-		void   MaxAbsVx(double* pmaxabsvx, bool process_units);
-		void   MaxAbsVy(double* pmaxabsvy, bool process_units);
-		void   MaxAbsVz(double* pmaxabsvz, bool process_units);
-		void   ElementResponse(double* presponse,int response_enum,bool process_units);
-		void   MaxVel(double* pmaxvel, bool process_units);
-		void   MaxVx(double* pmaxvx, bool process_units);
-		void   MaxVy(double* pmaxvy, bool process_units);
-		void   MaxVz(double* pmaxvz, bool process_units);
+		IssmDouble IceVolume(void);
+		void   MinVel(IssmDouble* pminvel, bool process_units);
+		void   MinVx(IssmDouble* pminvx, bool process_units);
+		void   MinVy(IssmDouble* pminvy, bool process_units);
+		void   MinVz(IssmDouble* pminvz, bool process_units);
+		IssmDouble MassFlux(IssmDouble* segment,bool process_units);
+		void   MaxAbsVx(IssmDouble* pmaxabsvx, bool process_units);
+		void   MaxAbsVy(IssmDouble* pmaxabsvy, bool process_units);
+		void   MaxAbsVz(IssmDouble* pmaxabsvz, bool process_units);
+		void   ElementResponse(IssmDouble* presponse,int response_enum,bool process_units);
+		void   MaxVel(IssmDouble* pmaxvel, bool process_units);
+		void   MaxVx(IssmDouble* pmaxvx, bool process_units);
+		void   MaxVy(IssmDouble* pmaxvy, bool process_units);
+		void   MaxVz(IssmDouble* pmaxvz, bool process_units);
 		#endif
 
 
 		#ifdef _HAVE_CONTROL_
-		double DragCoefficientAbsGradient(bool process_units,int weight_index);
+		IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index);
 		void   GradientIndexing(int* indexing,int control_index);
 		void   Gradj(Vector* gradient,int control_type,int control_index);
@@ -148,21 +149,21 @@
 		void   GradjVyBalancedthickness(Vector* gradient,int control_index);
 		void   GetVectorFromControlInputs(Vector* gradient,int control_enum,int control_index,const char* data);
-		void   SetControlInputsFromVector(double* vector,int control_enum,int control_index);
+		void   SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index);
 		void   ControlInputGetGradient(Vector* gradient,int enum_type,int control_index);
-		void   ControlInputScaleGradient(int enum_type,double scale);
-		void   ControlInputSetGradient(double* gradient,int enum_type,int control_index);
-		double RheologyBbarAbsGradient(bool process_units,int weight_index);
-		double ThicknessAbsMisfit(     bool process_units,int weight_index);
-		double SurfaceAbsVelMisfit(    bool process_units,int weight_index);
-		double ThicknessAbsGradient(bool process_units,int weight_index);
-		double SurfaceRelVelMisfit(    bool process_units,int weight_index);
-		double SurfaceLogVelMisfit(    bool process_units,int weight_index);
-		double SurfaceLogVxVyMisfit(   bool process_units,int weight_index);
-		double SurfaceAverageVelMisfit(bool process_units,int weight_index);
-		void   InputControlUpdate(double scalar,bool save_parameter);
-		#endif
-
-		/*}}}*/
-		/*Tria specific routines:{{{1*/
+		void   ControlInputScaleGradient(int enum_type,IssmDouble scale);
+		void   ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index);
+		IssmDouble RheologyBbarAbsGradient(bool process_units,int weight_index);
+		IssmDouble ThicknessAbsMisfit(     bool process_units,int weight_index);
+		IssmDouble SurfaceAbsVelMisfit(    bool process_units,int weight_index);
+		IssmDouble ThicknessAbsGradient(bool process_units,int weight_index);
+		IssmDouble SurfaceRelVelMisfit(    bool process_units,int weight_index);
+		IssmDouble SurfaceLogVelMisfit(    bool process_units,int weight_index);
+		IssmDouble SurfaceLogVxVyMisfit(   bool process_units,int weight_index);
+		IssmDouble SurfaceAverageVelMisfit(bool process_units,int weight_index);
+		void   InputControlUpdate(IssmDouble scalar,bool save_parameter);
+		#endif
+
+		/*}}}*/
+		/*Tria specific routines:{{{*/
 		ElementMatrix* CreateKMatrixBalancethickness(void);
 		ElementMatrix* CreateKMatrixBalancethickness_DG(void);
@@ -180,5 +181,5 @@
 		ElementVector* CreatePVectorPrognostic_DG(void);
 		ElementVector* CreatePVectorSlope(void);
-		double         GetArea(void);
+		IssmDouble         GetArea(void);
 		int            GetElementType(void);
 		void	         GetDofList(int** pdoflist,int approximation_enum,int setenum);
@@ -186,14 +187,14 @@
 		void           GetSidList(int* sidlist);
 		void           GetConnectivityList(int* connectivity);
-		void           GetInputListOnVertices(double* pvalue,int enumtype);
-		void           GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue);
-		void           GetInputListOnVertices(double* pvalue,int enumtype,double defaultvalue,int index); //TO BE REMOVED
-		void           GetInputValue(double* pvalue,Node* node,int enumtype);
-		void           GetStrainRate2d(double* epsilon,double* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input);
-		void	         InputUpdateFromSolutionOneDof(double* solution,int enum_type);
-		void	         InputUpdateFromSolutionPrognostic(double* solution);
+		void           GetInputListOnVertices(IssmDouble* pvalue,int enumtype);
+		void           GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue);
+		void           GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index); //TO BE REMOVED
+		void           GetInputValue(IssmDouble* pvalue,Node* node,int enumtype);
+		void           GetStrainRate2d(IssmDouble* epsilon,IssmDouble* xyz_list, GaussTria* gauss, Input* vx_input, Input* vy_input);
+		void	         InputUpdateFromSolutionOneDof(IssmDouble* solution,int enum_type);
+		void	         InputUpdateFromSolutionPrognostic(IssmDouble* solution);
 		bool	         IsInput(int name);
 		void	         SetClone(int* minranks);
-		void	         SurfaceNormal(double* surface_normal, double xyz_list[3][3]);
+		void	         SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]);
 		
 		#ifdef _HAVE_DIAGNOSTIC_
@@ -207,6 +208,6 @@
 		void	  GetSolutionFromInputsDiagnosticHoriz(Vector* solution);
 		void	  GetSolutionFromInputsDiagnosticHutter(Vector* solution);
-		void	  InputUpdateFromSolutionDiagnosticHoriz( double* solution);
-		void	  InputUpdateFromSolutionDiagnosticHutter( double* solution);
+		void	  InputUpdateFromSolutionDiagnosticHoriz( IssmDouble* solution);
+		void	  InputUpdateFromSolutionDiagnosticHutter( IssmDouble* solution);
 		#endif
 
@@ -217,6 +218,6 @@
 		ElementVector* CreatePVectorAdjointStokes(void);
 		ElementVector* CreatePVectorAdjointBalancethickness(void);
-		void	  InputUpdateFromSolutionAdjointBalancethickness( double* solution);
-		void	  InputUpdateFromSolutionAdjointHoriz( double* solution);
+		void	  InputUpdateFromSolutionAdjointBalancethickness( IssmDouble* solution);
+		void	  InputUpdateFromSolutionAdjointHoriz( IssmDouble* solution);
 		#endif
 
@@ -226,5 +227,5 @@
 		void      CreateHydrologyWaterVelocityInput(void);
 		void	  GetSolutionFromInputsHydrology(Vector* solution);
-		void	  InputUpdateFromSolutionHydrology(double* solution);
+		void	  InputUpdateFromSolutionHydrology(IssmDouble* solution);
 		#endif
 		#ifdef _HAVE_BALANCED_
Index: /issm/trunk/src/c/objects/Elements/TriaHook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaHook.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/TriaHook.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION TriaHook::TriaHook(){{{1*/
+/*FUNCTION TriaHook::TriaHook(){{{*/
 TriaHook::TriaHook(){
 	numanalyses=UNDEF;
@@ -29,5 +29,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaHook::~TriaHook(){{{1*/
+/*FUNCTION TriaHook::~TriaHook(){{{*/
 TriaHook::~TriaHook(){
 	int i;
@@ -42,5 +42,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaHook::TriaHook(int in_numanalyses,int matice_id, int matpar_id){{{1*/
+/*FUNCTION TriaHook::TriaHook(int in_numanalyses,int matice_id, int matpar_id){{{*/
 TriaHook::TriaHook(int in_numanalyses,int matice_id, IoModel* iomodel){
 
@@ -64,5 +64,5 @@
 /*}}}*/
 
-/*FUNCTION TriaHook::SetHookNodes{{{1*/
+/*FUNCTION TriaHook::SetHookNodes{{{*/
 void TriaHook::SetHookNodes(int* node_ids,int analysis_counter){
 
Index: /issm/trunk/src/c/objects/Elements/TriaHook.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaHook.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/TriaHook.h	(revision 12706)
@@ -18,5 +18,5 @@
 
 
-		/*FUNCTION constructors, destructors {{{1*/
+		/*FUNCTION constructors, destructors {{{*/
 		TriaHook();
 		TriaHook(int in_numanalyses,int matice_id, IoModel* iomodel);
Index: /issm/trunk/src/c/objects/Elements/TriaRef.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaRef.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/TriaRef.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -24,26 +24,26 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION TriaRef::TriaRef(){{{1*/
+/*FUNCTION TriaRef::TriaRef(){{{*/
 TriaRef::TriaRef(){
 	this->element_type_list=NULL;
 }
 /*}}}*/
-/*FUNCTION TriaRef::TriaRef(int* types,int nummodels){{{1*/
+/*FUNCTION TriaRef::TriaRef(int* types,int nummodels){{{*/
 
 TriaRef::TriaRef(const int nummodels){
 
 	/*Only allocate pointer*/
-	element_type_list=(int*)xmalloc(nummodels*sizeof(int));
-
-}
-/*}}}*/
-/*FUNCTION TriaRef::~TriaRef(){{{1*/
+	element_type_list=xNew<int>(nummodels);
+
+}
+/*}}}*/
+/*FUNCTION TriaRef::~TriaRef(){{{*/
 TriaRef::~TriaRef(){
-	xfree((void**)&element_type_list);
+	xDelete<int>(element_type_list);
 }
 /*}}}*/
 
 /*Management*/
-/*FUNCTION TriaRef::SetElementType{{{1*/
+/*FUNCTION TriaRef::SetElementType{{{*/
 void TriaRef::SetElementType(int type,int type_counter){
 
@@ -56,6 +56,6 @@
 
 /*Reference Element numerics*/
-/*FUNCTION TriaRef::GetBMacAyeal {{{1*/
-void TriaRef::GetBMacAyeal(double* B, double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaRef::GetBMacAyeal {{{*/
+void TriaRef::GetBMacAyeal(IssmDouble* B, IssmDouble* xyz_list, GaussTria* gauss){
 	/*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 
 	 * For node i, Bi can be expressed in the actual coordinate system
@@ -70,5 +70,5 @@
 
 	int i;
-	double dbasis[NDOF2][NUMNODES];
+	IssmDouble dbasis[NDOF2][NUMNODES];
 
 	/*Get dh1dh2dh3 in actual coordinate system: */
@@ -86,6 +86,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetBMacAyealStokes {{{1*/
-void TriaRef::GetBMacAyealStokes(double* B, double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaRef::GetBMacAyealStokes {{{*/
+void TriaRef::GetBMacAyealStokes(IssmDouble* B, IssmDouble* xyz_list, GaussTria* gauss){
 
 	/*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 
@@ -101,5 +101,5 @@
 
 	/*Same thing in the actual coordinate system: */
-	double dbasis[NDOF2][NUMNODES];
+	IssmDouble dbasis[NDOF2][NUMNODES];
 
 	/*Get dh1dh2dh3 in actual coordinates system : */
@@ -117,6 +117,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetSegmentBFlux{{{1*/
-void TriaRef::GetSegmentBFlux(double* B,GaussTria* gauss, int index1,int index2){
+/*FUNCTION TriaRef::GetSegmentBFlux{{{*/
+void TriaRef::GetSegmentBFlux(IssmDouble* B,GaussTria* gauss, int index1,int index2){
 	/*Compute B  matrix. B=[phi1 phi2 -phi3 -phi4]
 	 *
@@ -126,5 +126,5 @@
 	 */
 
-	double l1l3[NUMNODES];
+	IssmDouble l1l3[NUMNODES];
 
 	GetNodalFunctions(&l1l3[0],gauss);
@@ -136,6 +136,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetSegmentBprimeFlux{{{1*/
-void TriaRef::GetSegmentBprimeFlux(double* Bprime,GaussTria* gauss, int index1,int index2){
+/*FUNCTION TriaRef::GetSegmentBprimeFlux{{{*/
+void TriaRef::GetSegmentBprimeFlux(IssmDouble* Bprime,GaussTria* gauss, int index1,int index2){
 	/*Compute Bprime  matrix. Bprime=[phi1 phi2 phi3 phi4]
 	 *
@@ -145,5 +145,5 @@
 	 */
 
-	double l1l3[NUMNODES];
+	IssmDouble l1l3[NUMNODES];
 
 	GetNodalFunctions(&l1l3[0],gauss);
@@ -155,6 +155,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetBPrognostic{{{1*/
-void TriaRef::GetBPrognostic(double* B_prog, double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaRef::GetBPrognostic{{{*/
+void TriaRef::GetBPrognostic(IssmDouble* B_prog, IssmDouble* xyz_list, GaussTria* gauss){
 	/*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 
 	 * For node i, Bi can be expressed in the actual coordinate system
@@ -167,5 +167,5 @@
 	 */
 
-	double basis[NUMNODES];
+	IssmDouble basis[NUMNODES];
 
 	/*Get dh1dh2dh3 in actual coordinate system: */
@@ -179,6 +179,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetBprimeMacAyeal {{{1*/
-void TriaRef::GetBprimeMacAyeal(double* Bprime, double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaRef::GetBprimeMacAyeal {{{*/
+void TriaRef::GetBprimeMacAyeal(IssmDouble* Bprime, IssmDouble* xyz_list, GaussTria* gauss){
 
 	/*Compute B'  matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 
@@ -194,5 +194,5 @@
 
 	/*Same thing in the actual coordinate system: */
-	double dbasis[NDOF2][NUMNODES];
+	IssmDouble dbasis[NDOF2][NUMNODES];
 
 	/*Get dh1dh2dh3 in actual coordinates system : */
@@ -210,6 +210,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetBprimeMacAyealStokes {{{1*/
-void TriaRef::GetBprimeMacAyealStokes(double* Bprime, double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaRef::GetBprimeMacAyealStokes {{{*/
+void TriaRef::GetBprimeMacAyealStokes(IssmDouble* Bprime, IssmDouble* xyz_list, GaussTria* gauss){
 
 	/*Compute Bprime  matrix. Bprime=[Bprime1 Bprime2 Bprime3] where Bprimei is of size 3*NDOF2. 
@@ -226,5 +226,5 @@
 
 	/*Same thing in the actual coordinate system: */
-	double dbasis[NDOF2][NUMNODES];
+	IssmDouble dbasis[NDOF2][NUMNODES];
 
 	/*Get dh1dh2dh3 in actual coordinates system : */
@@ -244,6 +244,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetBprimePrognostic{{{1*/
-void TriaRef::GetBprimePrognostic(double* Bprime_prog, double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaRef::GetBprimePrognostic{{{*/
+void TriaRef::GetBprimePrognostic(IssmDouble* Bprime_prog, IssmDouble* xyz_list, GaussTria* gauss){
 	/*Compute B'  matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 
 	 * For node i, Bi' can be expressed in the actual coordinate system
@@ -257,5 +257,5 @@
 
 	/*Same thing in the actual coordinate system: */
-	double dbasis[NDOF2][NUMNODES];
+	IssmDouble dbasis[NDOF2][NUMNODES];
 
 	/*Get dh1dh2dh3 in actual coordinates system : */
@@ -269,6 +269,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetL{{{1*/
-void TriaRef::GetL(double* L, double* xyz_list,GaussTria* gauss,int numdof){
+/*FUNCTION TriaRef::GetL{{{*/
+void TriaRef::GetL(IssmDouble* L, IssmDouble* xyz_list,GaussTria* gauss,int numdof){
 	/*Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof. 
 	 * For node i, Li can be expressed in the actual coordinate system
@@ -285,5 +285,5 @@
 
 	int i;
-	double basis[3];
+	IssmDouble basis[3];
 
 	/*Get basis in actual coordinate system: */
@@ -306,9 +306,9 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetJacobian{{{1*/
-void TriaRef::GetJacobian(double* J, double* xyz_list,GaussTria* gauss){
+/*FUNCTION TriaRef::GetJacobian{{{*/
+void TriaRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussTria* gauss){
 	/*The Jacobian is constant over the element, discard the gaussian points. 
 	 * J is assumed to have been allocated of size NDOF2xNDOF2.*/
-	double x1,y1,x2,y2,x3,y3;
+	IssmDouble x1,y1,x2,y2,x3,y3;
 
 	x1=*(xyz_list+NUMNODES*0+0);
@@ -326,9 +326,9 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetSegmentJacobianDeterminant{{{1*/
-void TriaRef::GetSegmentJacobianDeterminant(double* Jdet, double* xyz_list,GaussTria* gauss){
+/*FUNCTION TriaRef::GetSegmentJacobianDeterminant{{{*/
+void TriaRef::GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss){
 	/*The Jacobian determinant is constant over the element, discard the gaussian points. 
 	 * J is assumed to have been allocated*/
-	double x1,y1,x2,y2;
+	IssmDouble x1,y1,x2,y2;
 
 	x1=*(xyz_list+3*0+0);
@@ -338,13 +338,13 @@
 
 	*Jdet=1.0/2.0*sqrt(pow(x2-x1,2.) + pow(y2-y1,2.));
-	if(*Jdet<0) _error_("negative jacobian determinant!");
-
-}
-/*}}}*/
-/*FUNCTION TriaRef::GetJacobianDeterminant2d{{{1*/
-void TriaRef::GetJacobianDeterminant2d(double* Jdet, double* xyz_list,GaussTria* gauss){
+	if(*Jdet<0) _error2_("negative jacobian determinant!");
+
+}
+/*}}}*/
+/*FUNCTION TriaRef::GetJacobianDeterminant2d{{{*/
+void TriaRef::GetJacobianDeterminant2d(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss){
 	/*The Jacobian determinant is constant over the element, discard the gaussian points. 
 	 * J is assumed to have been allocated of size NDOF2xNDOF2.*/
-	double J[2][2];
+	IssmDouble J[2][2];
 
 	/*Get Jacobian*/
@@ -353,14 +353,14 @@
 	/*Get Determinant*/
 	Matrix2x2Determinant(Jdet,&J[0][0]);
-	if(*Jdet<0) _error_("negative jacobian determinant!");
-
-}
-/*}}}*/
-/*FUNCTION TriaRef::GetJacobianDeterminant3d {{{1*/
-void TriaRef::GetJacobianDeterminant3d(double*  Jdet, double* xyz_list,GaussTria* gauss){
+	if(*Jdet<0) _error2_("negative jacobian determinant!");
+
+}
+/*}}}*/
+/*FUNCTION TriaRef::GetJacobianDeterminant3d {{{*/
+void TriaRef::GetJacobianDeterminant3d(IssmDouble*  Jdet, IssmDouble* xyz_list,GaussTria* gauss){
 	/*The Jacobian determinant is constant over the element, discard the gaussian points. 
 	 * J is assumed to have been allocated of size NDOF2xNDOF2.*/
 
-	double x1,x2,x3,y1,y2,y3,z1,z2,z3;
+	IssmDouble x1,x2,x3,y1,y2,y3,z1,z2,z3;
 
 	x1=*(xyz_list+3*0+0);
@@ -375,13 +375,13 @@
 
 	*Jdet=SQRT3/6.0*pow(pow(((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)),2.0)+pow(((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1)),2.0)+pow(((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)),2.0),0.5);
-	if(*Jdet<0) _error_("negative jacobian determinant!");
-
-}
-/*}}}*/
-/*FUNCTION TriaRef::GetJacobianInvert{{{1*/
-void TriaRef::GetJacobianInvert(double*  Jinv, double* xyz_list,GaussTria* gauss){
+	if(*Jdet<0) _error2_("negative jacobian determinant!");
+
+}
+/*}}}*/
+/*FUNCTION TriaRef::GetJacobianInvert{{{*/
+void TriaRef::GetJacobianInvert(IssmDouble*  Jinv, IssmDouble* xyz_list,GaussTria* gauss){
 
 	/*Jacobian*/
-	double J[2][2];
+	IssmDouble J[2][2];
 
 	/*Call Jacobian routine to get the jacobian:*/
@@ -393,6 +393,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetNodalFunctions{{{1*/
-void TriaRef::GetNodalFunctions(double* basis,GaussTria* gauss){
+/*FUNCTION TriaRef::GetNodalFunctions{{{*/
+void TriaRef::GetNodalFunctions(IssmDouble* basis,GaussTria* gauss){
 	/*This routine returns the values of the nodal functions  at the gaussian point.*/
 
@@ -403,9 +403,9 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetSegmentNodalFunctions{{{1*/
-void TriaRef::GetSegmentNodalFunctions(double* basis,GaussTria* gauss,int index1,int index2){
+/*FUNCTION TriaRef::GetSegmentNodalFunctions{{{*/
+void TriaRef::GetSegmentNodalFunctions(IssmDouble* basis,GaussTria* gauss,int index1,int index2){
 	/*This routine returns the values of the nodal functions  at the gaussian point.*/
 
-	double BasisFunctions[3];
+	IssmDouble BasisFunctions[3];
 
 	GetNodalFunctions(&BasisFunctions[0],gauss);
@@ -417,12 +417,12 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetNodalFunctionsDerivatives{{{1*/
-void TriaRef::GetNodalFunctionsDerivatives(double* dbasis,double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaRef::GetNodalFunctionsDerivatives{{{*/
+void TriaRef::GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list, GaussTria* gauss){
 
 	/*This routine returns the values of the nodal functions derivatives  (with respect to the 
 	 * actual coordinate system): */
 	int       i;
-	double    dbasis_ref[NDOF2][NUMNODES];
-	double    Jinv[NDOF2][NDOF2];
+	IssmDouble    dbasis_ref[NDOF2][NUMNODES];
+	IssmDouble    Jinv[NDOF2][NDOF2];
 
 	/*Get derivative values with respect to parametric coordinate system: */
@@ -444,6 +444,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetNodalFunctionsDerivativesReference{{{1*/
-void TriaRef::GetNodalFunctionsDerivativesReference(double* dl1dl3,GaussTria* gauss){
+/*FUNCTION TriaRef::GetNodalFunctionsDerivativesReference{{{*/
+void TriaRef::GetNodalFunctionsDerivativesReference(IssmDouble* dl1dl3,GaussTria* gauss){
 	/*This routine returns the values of the nodal functions derivatives  (with respect to the 
 	 * natural coordinate system) at the gaussian point. */
@@ -463,6 +463,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetInputDerivativeValue{{{1*/
-void TriaRef::GetInputDerivativeValue(double* p, double* plist,double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaRef::GetInputDerivativeValue{{{*/
+void TriaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, GaussTria* gauss){
 
 	/*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter derivative value at gaussian 
@@ -475,5 +475,5 @@
 
 	/*Nodal Derivatives*/
-	double dbasis[2][3]; //nodal derivative functions in actual coordinate system.
+	IssmDouble dbasis[2][3]; //nodal derivative functions in actual coordinate system.
 
 	/*Get dh1dh2dh3 in actual coordinate system: */
@@ -486,6 +486,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaRef::GetInputValue{{{1*/
-void TriaRef::GetInputValue(double* p, double* plist, GaussTria* gauss){
+/*FUNCTION TriaRef::GetInputValue{{{*/
+void TriaRef::GetInputValue(IssmDouble* p, IssmDouble* plist, GaussTria* gauss){
 
 	/*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter value at gaussian 
@@ -493,5 +493,5 @@
 
 	/*nodal functions annd output: */
-	double basis[3];
+	IssmDouble basis[3];
 
 	/*Get nodal functions*/
Index: /issm/trunk/src/c/objects/Elements/TriaRef.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaRef.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Elements/TriaRef.h	(revision 12706)
@@ -25,24 +25,24 @@
 
 		/*Numerics*/
-		void GetBMacAyeal(double* B, double* xyz_list, GaussTria* gauss);
-		void GetBMacAyealStokes(double* B , double* xyz_list, GaussTria* gauss);
-		void GetBprimeMacAyeal(double* Bprime, double* xyz_list, GaussTria* gauss);
-		void GetBprimeMacAyealStokes(double* Bprime, double* xyz_list, GaussTria* gauss);
-		void GetBprimePrognostic(double* Bprime_prog, double* xyz_list, GaussTria* gauss);
-		void GetBPrognostic(double* B_prog, double* xyz_list, GaussTria* gauss);
-		void GetL(double* L, double* xyz_list,GaussTria* gauss,int numdof);
-		void GetJacobian(double* J, double* xyz_list,GaussTria* gauss);
-		void GetSegmentJacobianDeterminant(double* Jdet, double* xyz_list,GaussTria* gauss);
-		void GetJacobianDeterminant2d(double* Jdet, double* xyz_list,GaussTria* gauss);
-		void GetJacobianDeterminant3d(double* Jdet, double* xyz_list,GaussTria* gauss);
-		void GetJacobianInvert(double*  Jinv, double* xyz_list,GaussTria* gauss);
-		void GetNodalFunctions(double* l1l2l3,GaussTria* gauss);
-		void GetSegmentNodalFunctions(double* l1l2l3,GaussTria* gauss, int index1,int index2);
-		void GetSegmentBFlux(double* B,GaussTria* gauss, int index1,int index2);
-		void GetSegmentBprimeFlux(double* Bprime,GaussTria* gauss, int index1,int index2);
-		void GetNodalFunctionsDerivatives(double* l1l2l3,double* xyz_list, GaussTria* gauss);
-		void GetNodalFunctionsDerivativesReference(double* dl1dl3,GaussTria* gauss);
-		void GetInputValue(double* pp, double* plist, GaussTria* gauss);
-		void GetInputDerivativeValue(double* pp, double* plist,double* xyz_list, GaussTria* gauss);
+		void GetBMacAyeal(IssmDouble* B, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetBMacAyealStokes(IssmDouble* B , IssmDouble* xyz_list, GaussTria* gauss);
+		void GetBprimeMacAyeal(IssmDouble* Bprime, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetBprimeMacAyealStokes(IssmDouble* Bprime, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetBprimePrognostic(IssmDouble* Bprime_prog, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetBPrognostic(IssmDouble* B_prog, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetL(IssmDouble* L, IssmDouble* xyz_list,GaussTria* gauss,int numdof);
+		void GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussTria* gauss);
+		void GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss);
+		void GetJacobianDeterminant2d(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss);
+		void GetJacobianDeterminant3d(IssmDouble* Jdet, IssmDouble* xyz_list,GaussTria* gauss);
+		void GetJacobianInvert(IssmDouble*  Jinv, IssmDouble* xyz_list,GaussTria* gauss);
+		void GetNodalFunctions(IssmDouble* l1l2l3,GaussTria* gauss);
+		void GetSegmentNodalFunctions(IssmDouble* l1l2l3,GaussTria* gauss, int index1,int index2);
+		void GetSegmentBFlux(IssmDouble* B,GaussTria* gauss, int index1,int index2);
+		void GetSegmentBprimeFlux(IssmDouble* Bprime,GaussTria* gauss, int index1,int index2);
+		void GetNodalFunctionsDerivatives(IssmDouble* l1l2l3,IssmDouble* xyz_list, GaussTria* gauss);
+		void GetNodalFunctionsDerivativesReference(IssmDouble* dl1dl3,GaussTria* gauss);
+		void GetInputValue(IssmDouble* pp, IssmDouble* plist, GaussTria* gauss);
+		void GetInputDerivativeValue(IssmDouble* pp, IssmDouble* plist,IssmDouble* xyz_list, GaussTria* gauss);
 
 };
Index: /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,11 +21,11 @@
 
 /*BoolExternalResult constructors and destructor*/
-/*FUNCTION BoolExternalResult::BoolExternalResult(){{{1*/
+/*FUNCTION BoolExternalResult::BoolExternalResult(){{{*/
 BoolExternalResult::BoolExternalResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION BoolExternalResult::BoolExternalResult(int enum_type,bool value){{{1*/
-BoolExternalResult::BoolExternalResult(int in_id, int in_enum_type,bool in_value,int in_step, double in_time){
+/*FUNCTION BoolExternalResult::BoolExternalResult(int enum_type,bool value){{{*/
+BoolExternalResult::BoolExternalResult(int in_id, int in_enum_type,bool in_value,int in_step, IssmDouble in_time){
 
 	id=in_id;
@@ -36,5 +36,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolExternalResult::~BoolExternalResult(){{{1*/
+/*FUNCTION BoolExternalResult::~BoolExternalResult(){{{*/
 BoolExternalResult::~BoolExternalResult(){
 	return;
@@ -43,24 +43,24 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION BoolExternalResult::Echo {{{1*/
+/*FUNCTION BoolExternalResult::Echo {{{*/
 void BoolExternalResult::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION BoolExternalResult::DeepEcho{{{1*/
+/*FUNCTION BoolExternalResult::DeepEcho{{{*/
 void BoolExternalResult::DeepEcho(void){
 
-	printf("BoolExternalResult:\n");
-	printf("   id: %i\n",this->id);
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %s\n",this->value?"true":"false");
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("BoolExternalResult:");
+	_printLine_("   id: " << this->id);
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " <<(this->value?"true":"false"));
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 }
 /*}}}*/
-/*FUNCTION BoolExternalResult::Id{{{1*/
+/*FUNCTION BoolExternalResult::Id{{{*/
 int    BoolExternalResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION BoolExternalResult::MyRank{{{1*/
+/*FUNCTION BoolExternalResult::MyRank{{{*/
 int    BoolExternalResult::MyRank(void){ 
 	extern int my_rank;
@@ -68,5 +68,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolExternalResult::ObjectEnum{{{1*/
+/*FUNCTION BoolExternalResult::ObjectEnum{{{*/
 int BoolExternalResult::ObjectEnum(void){
 
@@ -75,5 +75,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolExternalResult::copy{{{1*/
+/*FUNCTION BoolExternalResult::copy{{{*/
 Object* BoolExternalResult::copy() {
 	
@@ -84,5 +84,5 @@
 
 /*BoolExternalResult management: */
-/*FUNCTION BoolExternalResult::WriteData{{{1*/
+/*FUNCTION BoolExternalResult::WriteData{{{*/
 void   BoolExternalResult::WriteData(FILE* fid,bool io_gather){
 
@@ -90,5 +90,5 @@
 	int     type;
 	int     size;
-	double  boolean;
+	IssmPDouble  passiveDouble;
 	extern  int my_rank;
 	char*   name = NULL;
@@ -102,28 +102,28 @@
 	fwrite(&length,sizeof(int),1,fid);
 	fwrite(name,length,1,fid);
-	xfree((void**)&name);
+	xDelete<char>(name);
 
 	/*Now write time and step: */
-	fwrite(&time,sizeof(double),1,fid);
+	passiveDouble=reCast<IssmPDouble>(time);
+	fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
 	fwrite(&step,sizeof(int),1,fid);
 
-	/*Now write bool, after casting it: */
-	boolean=(double)this->value;
-
-	/*writing a double, type is 1, size is 1: */
+	/*writing a IssmDouble, type is 1, size is 1: */
 	type=1;
 	size=1;
 	fwrite(&type,sizeof(int),1,fid);
 	fwrite(&size,sizeof(int),1,fid);
-	fwrite(&boolean,size*sizeof(double),1,fid);
+        /*Now write bool, after casting it: */
+        passiveDouble=reCast<IssmPDouble>(this->value);
+        fwrite(&passiveDouble,size*sizeof(IssmPDouble),1,fid);
 
 }
-/*}}}1*/
-/*FUNCTION BoolExternalResult::GetResultName{{{1*/
+/*}}}*/
+/*FUNCTION BoolExternalResult::GetResultName{{{*/
 void BoolExternalResult::GetResultName(char** pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION BoolExternalResult::GetStep{{{1*/
+/*FUNCTION BoolExternalResult::GetStep{{{*/
 int BoolExternalResult::GetStep(void){
 
Index: /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/BoolExternalResult.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -30,12 +30,12 @@
 		bool   value;
 		int    step;
-		double time;
+		IssmDouble time;
 
-		/*BoolExternalResult constructors, destructors: {{{1*/
+		/*BoolExternalResult constructors, destructors: {{{*/
 		BoolExternalResult();
-		BoolExternalResult(int id, int enum_type,bool value,int step,double time);
+		BoolExternalResult(int id, int enum_type,bool value,int step,IssmDouble time);
 		~BoolExternalResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -45,5 +45,5 @@
 		Object* copy();
 		/*}}}*/
-		/*ExternalResult management: {{{1*/
+		/*ExternalResult management: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  WriteData(FILE* fid,bool io_gather);
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,11 +21,11 @@
 
 /*DoubleExternalResult constructors and destructor*/
-/*FUNCTION DoubleExternalResult::DoubleExternalResult(){{{1*/
+/*FUNCTION DoubleExternalResult::DoubleExternalResult(){{{*/
 DoubleExternalResult::DoubleExternalResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::DoubleExternalResult(int enum_type,double value){{{1*/
-DoubleExternalResult::DoubleExternalResult(int in_id, int in_enum_type,double in_value,int in_step, double in_time){
+/*FUNCTION DoubleExternalResult::DoubleExternalResult(int enum_type,IssmDouble value){{{*/
+DoubleExternalResult::DoubleExternalResult(int in_id, int in_enum_type,IssmDouble in_value,int in_step, IssmDouble in_time){
 
 	id=in_id;
@@ -36,5 +36,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::~DoubleExternalResult(){{{1*/
+/*FUNCTION DoubleExternalResult::~DoubleExternalResult(){{{*/
 DoubleExternalResult::~DoubleExternalResult(){
 	return;
@@ -43,24 +43,24 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION DoubleExternalResult::Echo {{{1*/
+/*FUNCTION DoubleExternalResult::Echo {{{*/
 void DoubleExternalResult::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::DeepEcho{{{1*/
+/*FUNCTION DoubleExternalResult::DeepEcho{{{*/
 void DoubleExternalResult::DeepEcho(void){
 
-	printf("DoubleExternalResult:\n");
-	printf("   id: %i\n",this->id);
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %g\n",this->value);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("DoubleExternalResult:");
+	_printLine_("   id: " << this->id);
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::Id{{{1*/
+/*FUNCTION DoubleExternalResult::Id{{{*/
 int    DoubleExternalResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::MyRank{{{1*/
+/*FUNCTION DoubleExternalResult::MyRank{{{*/
 int    DoubleExternalResult::MyRank(void){ 
 	extern int my_rank;
@@ -68,5 +68,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::ObjectEnum{{{1*/
+/*FUNCTION DoubleExternalResult::ObjectEnum{{{*/
 int DoubleExternalResult::ObjectEnum(void){
 
@@ -75,5 +75,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::copy{{{1*/
+/*FUNCTION DoubleExternalResult::copy{{{*/
 Object* DoubleExternalResult::copy() {
 	
@@ -84,5 +84,5 @@
 
 /*DoubleExternalResult management: */
-/*FUNCTION DoubleExternalResult::WriteData{{{1*/
+/*FUNCTION DoubleExternalResult::WriteData{{{*/
 void   DoubleExternalResult::WriteData(FILE* fid,bool io_gather){
 
@@ -92,4 +92,5 @@
 	char   *name    = NULL;
 	extern  int my_rank;
+	IssmPDouble passiveDouble;
 
 	/*return if now on cpu 0: */
@@ -101,25 +102,27 @@
 	fwrite(&length,sizeof(int),1,fid);
 	fwrite(name,length,1,fid);
-	xfree((void**)&name);
+	xDelete<char>(name);
 
 	/*Now write time and step: */
-	fwrite(&time,sizeof(double),1,fid);
+	passiveDouble=reCast<IssmPDouble>(time);
+	fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
 	fwrite(&step,sizeof(int),1,fid);
 
-	/*writing a double, type is 1, size is 1: */
+	/*writing a IssmDouble, type is 1, size is 1: */
 	type=1;
 	size=1;
 	fwrite(&type,sizeof(int),1,fid);
 	fwrite(&size,sizeof(int),1,fid);
-	fwrite(&this->value,size*sizeof(double),1,fid);
+        passiveDouble=reCast<IssmPDouble>(this->value);
+	fwrite(&passiveDouble,size*sizeof(IssmPDouble),1,fid);
 
 }
-/*}}}1*/
-/*FUNCTION DoubleExternalResult::GetResultName{{{1*/
+/*}}}*/
+/*FUNCTION DoubleExternalResult::GetResultName{{{*/
 void DoubleExternalResult::GetResultName(char** pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION DoubleExternalResult::GetStep{{{1*/
+/*FUNCTION DoubleExternalResult::GetStep{{{*/
 int DoubleExternalResult::GetStep(void){
 
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleExternalResult.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -29,15 +29,15 @@
 		int    id;
 		int    enum_type;
-		double value;
+		IssmDouble value;
 		int    step;
-		double time;
+		IssmDouble time;
 
 
-		/*DoubleExternalResult constructors, destructors: {{{1*/
+		/*DoubleExternalResult constructors, destructors: {{{*/
 		DoubleExternalResult();
-		DoubleExternalResult(int id,int enum_type,double value,int step,double time);
+		DoubleExternalResult(int id,int enum_type,IssmDouble value,int step,IssmDouble time);
 		~DoubleExternalResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -47,5 +47,5 @@
 		Object* copy();
 		/*}}}*/
-		/*ExternalResult management: {{{1*/
+		/*ExternalResult management: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  WriteData(FILE* fid,bool io_gather);
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,11 +21,11 @@
 
 /*DoubleMatExternalResult constructors and destructor*/
-/*FUNCTION DoubleMatExternalResult::DoubleMatExternalResult(){{{1*/
+/*FUNCTION DoubleMatExternalResult::DoubleMatExternalResult(){{{*/
 DoubleMatExternalResult::DoubleMatExternalResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::DoubleMatExternalResult(int in_id, int enum_type,IssmDoubleMat values,int M,int N,int in_step,double in_time){{{1*/
-DoubleMatExternalResult::DoubleMatExternalResult(int in_id, int in_enum_type,double* in_values, int in_M,int in_N,int in_step,double in_time){
+/*FUNCTION DoubleMatExternalResult::DoubleMatExternalResult(int in_id, int enum_type,IssmDoubleMat values,int M,int N,int in_step,IssmDouble in_time){{{*/
+DoubleMatExternalResult::DoubleMatExternalResult(int in_id, int in_enum_type,IssmDouble* in_values, int in_M,int in_N,int in_step,IssmDouble in_time){
 
 	id=in_id;
@@ -36,6 +36,6 @@
 	/*Copy result in values*/
 	if(M*N){
-		values=(double*)xmalloc(M*N*sizeof(double));
-		memcpy(values,in_values,M*N*sizeof(double));
+		values=xNew<IssmDouble>(M*N);
+		xMemCpy<IssmDouble>(values,in_values,M*N);
 	}
 	else values=NULL;
@@ -45,8 +45,8 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::~DoubleMatExternalResult(){{{1*/
+/*FUNCTION DoubleMatExternalResult::~DoubleMatExternalResult(){{{*/
 DoubleMatExternalResult::~DoubleMatExternalResult(){
 
-	xfree((void**)&this->values);
+	xDelete<IssmDouble>(this->values);
 	return;
 }
@@ -54,41 +54,40 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION DoubleMatExternalResult::Echo {{{1*/
+/*FUNCTION DoubleMatExternalResult::Echo {{{*/
 void DoubleMatExternalResult::Echo(void){
 
-	printf("DoubleMatExternalResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
-	printf("   matrix size: %i-%i\n",this->M,this->N);
+	_printLine_("DoubleMatExternalResult:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
+	_printLine_("   matrix size: " << this->M << "-" << this->N);
 
 }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::DeepEcho{{{1*/
+/*FUNCTION DoubleMatExternalResult::DeepEcho{{{*/
 void DoubleMatExternalResult::DeepEcho(void){
 
 	int i,j;
 	
-	printf("DoubleMatExternalResult:\n");
-	printf("   id: %i\n",this->id);
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
-	printf("   matrix size: %i-%i\n",this->M,this->N);
+	_printLine_("DoubleMatExternalResult:");
+	_printLine_("   id: " << this->id);
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
+	_printLine_("   matrix size: " << this->M << "-" << this->N);
 	for (i=0;i<this->M;i++){  
-		printf("   [ ");
+		_printString_("   [ ");
 		for (j=0;j<this->N;j++){
-			printf(" %12.6g ",this->values[i*this->N+j]);
+			_printString_( " " << setw(11) << setprecision (5) << this->values[i*this->N+j]);
 		}  
-		printf(" ]\n");
+		_printLine_(" ]");
 	}  
-	printf("\n");
 
 }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::Id{{{1*/
+/*FUNCTION DoubleMatExternalResult::Id{{{*/
 int    DoubleMatExternalResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::MyRank{{{1*/
+/*FUNCTION DoubleMatExternalResult::MyRank{{{*/
 int    DoubleMatExternalResult::MyRank(void){ 
 	extern int my_rank;
@@ -96,5 +95,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::ObjectEnum{{{1*/
+/*FUNCTION DoubleMatExternalResult::ObjectEnum{{{*/
 int DoubleMatExternalResult::ObjectEnum(void){
 
@@ -103,5 +102,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::copy{{{1*/
+/*FUNCTION DoubleMatExternalResult::copy{{{*/
 Object* DoubleMatExternalResult::copy() {
 	
@@ -112,5 +111,5 @@
 
 /*DoubleMatExternalResult management: */
-/*FUNCTION DoubleMatExternalResult::WriteData{{{1*/
+/*FUNCTION DoubleMatExternalResult::WriteData{{{*/
 void   DoubleMatExternalResult::WriteData(FILE* fid,bool io_gather){
 
@@ -120,4 +119,6 @@
 	char   *name    = NULL;
 	extern  int my_rank;
+	IssmPDouble *passiveDouble_p=NULL;
+	IssmPDouble passiveDouble;
 
 	if(io_gather){
@@ -126,4 +127,6 @@
 	}
 
+	passiveDouble_p=xNew<IssmPDouble>(M*N);
+
 	/*First write enum: */
 	EnumToStringx(&name,this->enum_type);
@@ -131,11 +134,12 @@
 	fwrite(&length,sizeof(int),1,fid);
 	fwrite(name,length,1,fid);
-	xfree((void**)&name);
+	xDelete<char>(name);
 
 	/*Now write time and step: */
-	fwrite(&time,sizeof(double),1,fid);
+	passiveDouble=reCast<IssmPDouble>(time);
+	fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
 	fwrite(&step,sizeof(int),1,fid);
 
-	/*writing a double array, type is 3:*/
+	/*writing a IssmDouble array, type is 3:*/
 	type=3;
 	fwrite(&type,sizeof(int),1,fid);
@@ -144,14 +148,16 @@
 	cols=this->N;
 	fwrite(&cols,sizeof(int),1,fid);
-	fwrite(this->values,cols*rows*sizeof(double),1,fid);
+	for (int i=0; i<N*M; ++i) passiveDouble_p[i]=reCast<IssmPDouble>(values[i]);
+	fwrite(passiveDouble_p,cols*rows*sizeof(IssmPDouble),1,fid);
+	xDelete(passiveDouble_p);
 
 }
-/*}}}1*/
-/*FUNCTION DoubleMatExternalResult::GetResultName{{{1*/
+/*}}}*/
+/*FUNCTION DoubleMatExternalResult::GetResultName{{{*/
 void DoubleMatExternalResult::GetResultName(char** pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION DoubleMatExternalResult::GetStep{{{1*/
+/*FUNCTION DoubleMatExternalResult::GetStep{{{*/
 int DoubleMatExternalResult::GetStep(void){
 
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleMatExternalResult.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -27,17 +27,17 @@
 		int id;
 		int enum_type;
-		double* values;
+		IssmDouble* values;
 		int M;
 		int N;
 		int step;
-		double time;
+		IssmDouble time;
 
 	public:
-		/*DoubleMatExternalResult constructors, destructors: {{{1*/
+		/*DoubleMatExternalResult constructors, destructors: {{{*/
 		DoubleMatExternalResult();
-		DoubleMatExternalResult(int id,int enum_type,double* values,int M,int N,int step, double time);
+		DoubleMatExternalResult(int id,int enum_type,IssmDouble* values,int M,int N,int step, IssmDouble time);
 		~DoubleMatExternalResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -47,5 +47,5 @@
 		Object* copy();
 		/*}}}*/
-		/*ExternalResult managemnet: {{{1*/
+		/*ExternalResult managemnet: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  WriteData(FILE* fid,bool io_gather);
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,11 +21,11 @@
 
 /*DoubleVecExternalResult constructors and destructor*/
-/*FUNCTION DoubleVecExternalResult::DoubleVecExternalResult(){{{1*/
+/*FUNCTION DoubleVecExternalResult::DoubleVecExternalResult(){{{*/
 DoubleVecExternalResult::DoubleVecExternalResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::DoubleVecExternalResult(int enum_type,IssmDoubleVec values,int M,int in_step,double in_time){{{1*/
-DoubleVecExternalResult::DoubleVecExternalResult(int in_id, int in_enum_type,double* in_values, int in_M,int in_step,double in_time){
+/*FUNCTION DoubleVecExternalResult::DoubleVecExternalResult(int enum_type,IssmDoubleVec values,int M,int in_step,IssmDouble in_time){{{*/
+DoubleVecExternalResult::DoubleVecExternalResult(int in_id, int in_enum_type,IssmDouble* in_values, int in_M,int in_step,IssmDouble in_time){
 
 	id=in_id;
@@ -34,6 +34,6 @@
 
 	if(M){
-		values=(double*)xmalloc(M*sizeof(double));
-		memcpy(values,in_values,M*sizeof(double));
+		values=xNew<IssmDouble>(M);
+		xMemCpy<IssmDouble>(values,in_values,M);
 	}
 	else values=NULL;
@@ -43,7 +43,7 @@
 }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::~DoubleVecExternalResult(){{{1*/
+/*FUNCTION DoubleVecExternalResult::~DoubleVecExternalResult(){{{*/
 DoubleVecExternalResult::~DoubleVecExternalResult(){
-	xfree((void**)&values);
+	xDelete<IssmDouble>(values);
 	return;
 }
@@ -51,35 +51,35 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION DoubleVecExternalResult::Echo {{{1*/
+/*FUNCTION DoubleVecExternalResult::Echo {{{*/
 void DoubleVecExternalResult::Echo(void){
 
-	printf("DoubleVecExternalResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   vector size: %i\n",this->M);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("DoubleVecExternalResult:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   vector size: " << this->M);
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 
 }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::DeepEcho{{{1*/
+/*FUNCTION DoubleVecExternalResult::DeepEcho{{{*/
 void DoubleVecExternalResult::DeepEcho(void){
 
 	int i;
 	
-	printf("DoubleVecExternalResult:\n");
-	printf("   id: %i\n",this->id);
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   vector size: %i\n",this->M);
+	_printLine_("DoubleVecExternalResult:");
+	_printLine_("   id: " << this->id);
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   vector size: " << this->M);
 	for(i=0;i<this->M;i++){
-		printf("%i %g\n",i,this->values[i]);
+		_printLine_(i << " " << this->values[i]);
 	}
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::Id{{{1*/
+/*FUNCTION DoubleVecExternalResult::Id{{{*/
 int    DoubleVecExternalResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::MyRank{{{1*/
+/*FUNCTION DoubleVecExternalResult::MyRank{{{*/
 int    DoubleVecExternalResult::MyRank(void){ 
 	extern int my_rank;
@@ -87,5 +87,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::ObjectEnum{{{1*/
+/*FUNCTION DoubleVecExternalResult::ObjectEnum{{{*/
 int DoubleVecExternalResult::ObjectEnum(void){
 
@@ -94,5 +94,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::copy{{{1*/
+/*FUNCTION DoubleVecExternalResult::copy{{{*/
 Object* DoubleVecExternalResult::copy() {
 	
@@ -103,5 +103,5 @@
 
 /*DoubleVecExternalResult management: */
-/*FUNCTION DoubleVecExternalResult::WriteData{{{1*/
+/*FUNCTION DoubleVecExternalResult::WriteData{{{*/
 void   DoubleVecExternalResult::WriteData(FILE* fid,bool io_gather){
 
@@ -111,8 +111,11 @@
 	char   *name    = NULL;
 	extern  int my_rank;
+	IssmPDouble *passiveDouble_p=NULL;
+	IssmPDouble passiveDouble;
 
 	/*return if now on cpu 0: */
 	if(my_rank)return;
 
+	passiveDouble_p=xNew<IssmPDouble>(M);
 	/*First write enum: */
 	EnumToStringx(&name,this->enum_type);
@@ -120,25 +123,27 @@
 	fwrite(&length,sizeof(int),1,fid);
 	fwrite(name,length,1,fid);
-	xfree((void**)&name);
+	xDelete<char>(name);
 
 	/*Now write time and step: */
-	fwrite(&time,sizeof(double),1,fid);
+        passiveDouble=reCast<IssmPDouble>(time);
+	fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
 	fwrite(&step,sizeof(int),1,fid);
 
-	/*writing a double, type is 1, size is 1: */
+	/*writing a IssmDouble, type is 1, size is 1: */
 	type=1;
 	size=this->M;
 	fwrite(&type,sizeof(int),1,fid);
 	fwrite(&size,sizeof(int),1,fid);
-	fwrite(this->values,size*sizeof(double),1,fid);
-
+        for (int i=0; i<M; ++i) passiveDouble_p[i]=reCast<IssmPDouble>(values[i]);
+	fwrite(passiveDouble_p,size*sizeof(IssmPDouble),1,fid);
+        xDelete(passiveDouble_p);
 }
-/*}}}1*/
-/*FUNCTION DoubleVecExternalResult::GetResultName{{{1*/
+/*}}}*/
+/*FUNCTION DoubleVecExternalResult::GetResultName{{{*/
 void DoubleVecExternalResult::GetResultName(char** pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION DoubleVecExternalResult::GetStep{{{1*/
+/*FUNCTION DoubleVecExternalResult::GetStep{{{*/
 int DoubleVecExternalResult::GetStep(void){
 
Index: /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/DoubleVecExternalResult.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -27,16 +27,16 @@
 		int id;
 		int enum_type;
-		double* values;
+		IssmDouble* values;
 		int M;
 		int step;
-		double time;
+		IssmDouble time;
 
 	public:
-		/*DoubleVecExternalResult constructors, destructors: {{{1*/
+		/*DoubleVecExternalResult constructors, destructors: {{{*/
 		DoubleVecExternalResult();
-		DoubleVecExternalResult(int id,int enum_type,double* values,int M,int step, double time);
+		DoubleVecExternalResult(int id,int enum_type,IssmDouble* values,int M,int step, IssmDouble time);
 		~DoubleVecExternalResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -46,5 +46,5 @@
 		Object* copy();
 		/*}}}*/
-		/*ExternalResult management: {{{1*/
+		/*ExternalResult management: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  WriteData(FILE* fid,bool io_gather);
Index: /issm/trunk/src/c/objects/ExternalResults/ExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/ExternalResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/ExternalResult.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -25,5 +25,5 @@
 		
 		virtual        ~ExternalResult(){};
-		/*Virtual functions:{{{1*/
+		/*Virtual functions:{{{*/
 		virtual int   InstanceEnum()=0;
 		virtual void  WriteData(FILE* fid,bool io_gather)=0;
Index: /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,11 +21,11 @@
 
 /*IntExternalResult constructors and destructor*/
-/*FUNCTION IntExternalResult::IntExternalResult(){{{1*/
+/*FUNCTION IntExternalResult::IntExternalResult(){{{*/
 IntExternalResult::IntExternalResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION IntExternalResult::IntExternalResult(int in_id, int in_enum_type,int in_value,int in_step, double in_time){{{1*/
-IntExternalResult::IntExternalResult(int in_id, int in_enum_type,int in_value,int in_step, double in_time){
+/*FUNCTION IntExternalResult::IntExternalResult(int in_id, int in_enum_type,int in_value,int in_step, IssmDouble in_time){{{*/
+IntExternalResult::IntExternalResult(int in_id, int in_enum_type,int in_value,int in_step, IssmDouble in_time){
 
 	id=in_id;
@@ -36,5 +36,5 @@
 }
 /*}}}*/
-/*FUNCTION IntExternalResult::~IntExternalResult(){{{1*/
+/*FUNCTION IntExternalResult::~IntExternalResult(){{{*/
 IntExternalResult::~IntExternalResult(){
 	return;
@@ -43,24 +43,24 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION IntExternalResult::Echo {{{1*/
+/*FUNCTION IntExternalResult::Echo {{{*/
 void IntExternalResult::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION IntExternalResult::DeepEcho{{{1*/
+/*FUNCTION IntExternalResult::DeepEcho{{{*/
 void IntExternalResult::DeepEcho(void){
 
-	printf("IntExternalResult:\n");
-	printf("   id: %i\n",this->id);
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %i\n",this->value);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("IntExternalResult:");
+	_printLine_("   id: " << this->id);
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 }
 /*}}}*/
-/*FUNCTION IntExternalResult::Id{{{1*/
+/*FUNCTION IntExternalResult::Id{{{*/
 int    IntExternalResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntExternalResult::MyRank{{{1*/
+/*FUNCTION IntExternalResult::MyRank{{{*/
 int    IntExternalResult::MyRank(void){ 
 	extern int my_rank;
@@ -68,5 +68,5 @@
 }
 /*}}}*/
-/*FUNCTION IntExternalResult::ObjectEnum{{{1*/
+/*FUNCTION IntExternalResult::ObjectEnum{{{*/
 int IntExternalResult::ObjectEnum(void){
 
@@ -75,5 +75,5 @@
 }
 /*}}}*/
-/*FUNCTION IntExternalResult::copy{{{1*/
+/*FUNCTION IntExternalResult::copy{{{*/
 Object* IntExternalResult::copy() {
 	
@@ -84,5 +84,5 @@
 
 /*IntExternalResult management: */
-/*FUNCTION IntExternalResult::WriteData{{{1*/
+/*FUNCTION IntExternalResult::WriteData{{{*/
 void   IntExternalResult::WriteData(FILE* fid,bool io_gather){
 
@@ -91,5 +91,5 @@
 	int     size;
 	char   *name    = NULL;
-	double  integer;
+	IssmPDouble  passiveDouble;
 	extern  int my_rank;
 
@@ -102,28 +102,28 @@
 	fwrite(&length,sizeof(int),1,fid);
 	fwrite(name,length,1,fid);
-	xfree((void**)&name);
+	xDelete<char>(name);
 
 	/*Now write time and step: */
-	fwrite(&time,sizeof(double),1,fid);
+        passiveDouble=reCast<IssmPDouble>(time);
+	fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
 	fwrite(&step,sizeof(int),1,fid);
 
-	/*cast to a double: */
-	integer=(double)this->value;
-
-	/*writing a double, type is 1, size is 1: */
+	/*writing a IssmPDouble, type is 1, size is 1: */
 	type=1;
 	size=1;
 	fwrite(&type,sizeof(int),1,fid);
 	fwrite(&size,sizeof(int),1,fid);
-	fwrite(&integer,size*sizeof(double),1,fid);
+        /*cast to a IssmPDouble: */
+        passiveDouble=reCast<IssmPDouble>(value);
+	fwrite(&passiveDouble,size*sizeof(IssmPDouble),1,fid);
 
 }
-/*}}}1*/
-/*FUNCTION IntExternalResult::GetResultName{{{1*/
+/*}}}*/
+/*FUNCTION IntExternalResult::GetResultName{{{*/
 void IntExternalResult::GetResultName(char** pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION IntExternalResult::GetStep{{{1*/
+/*FUNCTION IntExternalResult::GetStep{{{*/
 int IntExternalResult::GetStep(void){
 
Index: /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/IntExternalResult.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -28,14 +28,14 @@
 		int    value;
 		int    step;
-		double time;
+		IssmDouble time;
 
 
-		/*IntExternalResult constructors, destructors: {{{1*/
+		/*IntExternalResult constructors, destructors: {{{*/
 		IntExternalResult();
-		IntExternalResult(int id,int enum_type,int value,int step,double time);
+		IntExternalResult(int id,int enum_type,int value,int step,IssmDouble time);
 		~IntExternalResult();
 
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -45,5 +45,5 @@
 		Object* copy();
 		/*}}}*/
-		/*ExternalResult managemnet: {{{1*/
+		/*ExternalResult managemnet: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  WriteData(FILE* fid,bool io_gather);
Index: /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,11 +21,11 @@
 
 /*PetscVecExternalResult constructors and destructor*/
-/*FUNCTION PetscVecExternalResult::PetscVecExternalResult(){{{1*/
+/*FUNCTION PetscVecExternalResult::PetscVecExternalResult(){{{*/
 PetscVecExternalResult::PetscVecExternalResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::PetscVecExternalResult(int enum_type,IssmPetscVec value){{{1*/
-PetscVecExternalResult::PetscVecExternalResult(int in_id, int in_enum_type,Vector* in_value,int in_step, double in_time){
+/*FUNCTION PetscVecExternalResult::PetscVecExternalResult(int enum_type,IssmPetscVec value){{{*/
+PetscVecExternalResult::PetscVecExternalResult(int in_id, int in_enum_type,Vector* in_value,int in_step, IssmDouble in_time){
 
 	id=in_id;
@@ -44,5 +44,5 @@
 }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::~PetscVecExternalResult(){{{1*/
+/*FUNCTION PetscVecExternalResult::~PetscVecExternalResult(){{{*/
 PetscVecExternalResult::~PetscVecExternalResult(){
 	VecFree(&value);
@@ -51,28 +51,28 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION PetscVecExternalResult::Echo {{{1*/
+/*FUNCTION PetscVecExternalResult::Echo {{{*/
 void PetscVecExternalResult::Echo(void){
 
-	printf("PetscVecExternalResult:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	_printLine_("PetscVecExternalResult:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 
 }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::DeepEcho{{{1*/
+/*FUNCTION PetscVecExternalResult::DeepEcho{{{*/
 void PetscVecExternalResult::DeepEcho(void){
 
 	int i;
-	printf("PetscVecExternalResult:\n");
-	printf("   id: %i\n",this->id);
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("PetscVecExternalResult:");
+	_printLine_("   id: " << this->id);
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 	VecView(value,PETSC_VIEWER_STDOUT_WORLD);
 }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::Id{{{1*/
+/*FUNCTION PetscVecExternalResult::Id{{{*/
 int    PetscVecExternalResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::MyRank{{{1*/
+/*FUNCTION PetscVecExternalResult::MyRank{{{*/
 int    PetscVecExternalResult::MyRank(void){ 
 	extern int my_rank;
@@ -80,5 +80,5 @@
 }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::ObjectEnum{{{1*/
+/*FUNCTION PetscVecExternalResult::ObjectEnum{{{*/
 int PetscVecExternalResult::ObjectEnum(void){
 
@@ -87,5 +87,5 @@
 }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::copy{{{1*/
+/*FUNCTION PetscVecExternalResult::copy{{{*/
 Object* PetscVecExternalResult::copy() {
 	
@@ -96,5 +96,5 @@
 
 /*PetscVecExternalResult management: */
-/*FUNCTION PetscVecExternalResult::WriteData{{{1*/
+/*FUNCTION PetscVecExternalResult::WriteData{{{*/
 void   PetscVecExternalResult::WriteData(FILE* fid,bool io_gather){
 
@@ -103,6 +103,7 @@
 	int     size;
 	char   *name      = NULL;
-	double *serialvec = NULL;
+	IssmPDouble *serialvec = NULL;
 	extern int my_rank;
+	IssmPDouble passiveDouble;
 
 	/*serialize: */
@@ -118,27 +119,28 @@
 	fwrite(&length,sizeof(int),1,fid);
 	fwrite(name,length,1,fid);
-	xfree((void**)&name);
+	xDelete<char>(name);
 
 	/*Now write time and step: */
-	fwrite(&time,sizeof(double),1,fid);
+        passiveDouble=reCast<IssmPDouble>(time);
+	fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
 	fwrite(&step,sizeof(int),1,fid);
 
-	/*writing a double, type is 1, size is 1: */
+	/*writing a IssmDouble, type is 1, size is 1: */
 	type=1;
 	
 	fwrite(&type,sizeof(int),1,fid);
 	fwrite(&size,sizeof(int),1,fid);
-	fwrite(serialvec,size*sizeof(double),1,fid);
+	fwrite(serialvec,size*sizeof(IssmPDouble),1,fid);
 
 	/*Free ressources:*/
-	xfree((void**)&serialvec);
+	xDelete<IssmPDouble>(serialvec);
 }
-/*}}}1*/
-/*FUNCTION PetscVecExternalResult::GetResultName{{{1*/
+/*}}}*/
+/*FUNCTION PetscVecExternalResult::GetResultName{{{*/
 void PetscVecExternalResult::GetResultName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION PetscVecExternalResult::GetStep{{{1*/
+/*FUNCTION PetscVecExternalResult::GetStep{{{*/
 int PetscVecExternalResult::GetStep(void){
 
Index: /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/PetscVecExternalResult.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -30,13 +30,13 @@
 		Vector* value;
 		int step;
-		double time;
+		IssmDouble time;
 
 	public:
-		/*PetscVecExternalResult constructors, destructors: {{{1*/
+		/*PetscVecExternalResult constructors, destructors: {{{*/
 		PetscVecExternalResult();
-		PetscVecExternalResult(int id,int enum_type,Vector* value, int step, double time);
+		PetscVecExternalResult(int id,int enum_type,Vector* value, int step, IssmDouble time);
 		~PetscVecExternalResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -46,5 +46,5 @@
 		Object* copy();
 		/*}}}*/
-		/*ExternalResult management: {{{1*/
+		/*ExternalResult management: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  WriteData(FILE* fid,bool io_gather);
Index: /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.cpp
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,17 +21,16 @@
 
 /*StringExternalResult constructors and destructor*/
-/*FUNCTION StringExternalResult::StringExternalResult(){{{1*/
+/*FUNCTION StringExternalResult::StringExternalResult(){{{*/
 StringExternalResult::StringExternalResult(){
 	return;
 }
 /*}}}*/
-/*FUNCTION StringExternalResult::StringExternalResult(int enum_type,IssmString value){{{1*/
-StringExternalResult::StringExternalResult(int in_id, int in_enum_type,char* in_value,int in_step, double in_time){
+/*FUNCTION StringExternalResult::StringExternalResult(int enum_type,IssmString value){{{*/
+StringExternalResult::StringExternalResult(int in_id, int in_enum_type,char* in_value,int in_step, IssmDouble in_time){
 
 	id=in_id;
 	enum_type=in_enum_type;
-	value=(char*)xmalloc((strlen(in_value)+1)*sizeof(char));
-	memcpy(value,in_value,(strlen(in_value)+1)*sizeof(char));
-
+	value=xNew<char>(strlen(in_value)+1);
+	xMemCpy<char>(value,in_value,(strlen(in_value)+1));
 	step=in_step;
 	time=in_time;
@@ -39,31 +38,31 @@
 }
 /*}}}*/
-/*FUNCTION StringExternalResult::~StringExternalResult(){{{1*/
+/*FUNCTION StringExternalResult::~StringExternalResult(){{{*/
 StringExternalResult::~StringExternalResult(){
-	xfree((void**)&value);
+	xDelete<char>(value);
 }
 /*}}}*/
 
 /*Object virtual functions definitions:*/
-/*FUNCTION StringExternalResult::Echo {{{1*/
+/*FUNCTION StringExternalResult::Echo {{{*/
 void StringExternalResult::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION StringExternalResult::DeepEcho{{{1*/
+/*FUNCTION StringExternalResult::DeepEcho{{{*/
 void StringExternalResult::DeepEcho(void){
 
-	printf("StringExternalResult:\n");
-	printf("   id: %i\n",this->id);
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %s\n",this->value);
-	printf("   step: %i\n",this->step);
-	printf("   time: %g\n",this->time);
+	_printLine_("StringExternalResult:");
+	_printLine_("   id: " << this->id);
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
+	_printLine_("   step: " << this->step);
+	_printLine_("   time: " << this->time);
 }
 /*}}}*/
-/*FUNCTION StringExternalResult::Id{{{1*/
+/*FUNCTION StringExternalResult::Id{{{*/
 int    StringExternalResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION StringExternalResult::MyRank{{{1*/
+/*FUNCTION StringExternalResult::MyRank{{{*/
 int    StringExternalResult::MyRank(void){ 
 	extern int my_rank;
@@ -71,5 +70,5 @@
 }
 /*}}}*/
-/*FUNCTION StringExternalResult::ObjectEnum{{{1*/
+/*FUNCTION StringExternalResult::ObjectEnum{{{*/
 int StringExternalResult::ObjectEnum(void){
 
@@ -78,5 +77,5 @@
 }
 /*}}}*/
-/*FUNCTION StringExternalResult::copy{{{1*/
+/*FUNCTION StringExternalResult::copy{{{*/
 Object* StringExternalResult::copy() {
 	
@@ -87,5 +86,5 @@
 
 /*StringExternalResult management: */
-/*FUNCTION StringExternalResult::WriteData{{{1*/
+/*FUNCTION StringExternalResult::WriteData{{{*/
 void   StringExternalResult::WriteData(FILE* fid,bool io_gather){
 
@@ -94,4 +93,5 @@
 	char   *name      = NULL;
 	extern  int my_rank;
+        IssmPDouble passiveDouble;
 
 	/*return if now on cpu 0: */
@@ -103,8 +103,9 @@
 	fwrite(&length,sizeof(int),1,fid);
 	fwrite(name,length,1,fid);
-	xfree((void**)&name);
+	xDelete<char>(name);
 
 	/*Now write time and step: */
-	fwrite(&time,sizeof(double),1,fid);
+        passiveDouble=reCast<IssmPDouble>(time);
+	fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
 	fwrite(&step,sizeof(int),1,fid);
 
@@ -118,11 +119,11 @@
 
 }
-/*}}}1*/
-/*FUNCTION StringExternalResult::GetResultName{{{1*/
+/*}}}*/
+/*FUNCTION StringExternalResult::GetResultName{{{*/
 void StringExternalResult::GetResultName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION StringExternalResult::GetStep{{{1*/
+/*FUNCTION StringExternalResult::GetStep{{{*/
 int StringExternalResult::GetStep(void){
 
Index: /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.h
===================================================================
--- /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.h	(revision 12705)
+++ /issm/trunk/src/c/objects/ExternalResults/StringExternalResult.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -30,13 +30,13 @@
 		char*  value;
 		int    step;
-		double time;
+		IssmDouble time;
 
 	public:
-		/*StringExternalResult constructors, destructors: {{{1*/
+		/*StringExternalResult constructors, destructors: {{{*/
 		StringExternalResult();
-		StringExternalResult(int id,int enum_type,char* value,int step, double time);
+		StringExternalResult(int id,int enum_type,char* value,int step, IssmDouble time);
 		~StringExternalResult();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -46,5 +46,5 @@
 		Object* copy();
 		/*}}}*/
-		/*ExternalResult management: {{{1*/
+		/*ExternalResult management: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  WriteData(FILE* fid,bool io_gather);
Index: /issm/trunk/src/c/objects/FemModel.cpp
===================================================================
--- /issm/trunk/src/c/objects/FemModel.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/FemModel.cpp	(revision 12706)
@@ -20,15 +20,15 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION FemModel::constructor {{{1*/
+/*FUNCTION FemModel::constructor {{{*/
 FemModel::FemModel(char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){
 
 	/*intermediary*/
-	int i;
-	int analysis_type;
-	FILE* IOMODEL;
-	extern int my_rank;
+	int         i;
+	int         analysis_type;
+	FILE       *IOMODEL = NULL;
+	extern int  my_rank;
 
 	/*Open input file on cpu 0: */
-	if(my_rank==0) IOMODEL= pfopen(inputfilename ,"rb");
+	if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb");
 
 	/*Initialize internal data: */
@@ -39,5 +39,5 @@
 	
 	/*Dynamically allocate whatever is a list of length nummodels: */
-	analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
+	analysis_type_list=xNew<int>(nummodels);
 
 	/*Initialize: */
@@ -50,20 +50,20 @@
 	for(i=0;i<nummodels;i++){
 
-		_printf_(VerboseMProcessor(),"   Processing finite element model of analysis %s:\n",EnumToStringx(analysis_type_list[i]));
+		if(VerboseMProcessor()) _pprintLine_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":");
 		analysis_type=analysis_type_list[i];
 		this->SetCurrentConfiguration(analysis_type);
 	
 		if(i==0){
-			_printf_(VerboseMProcessor(),"      creating vertex degrees of freedom\n");
+			if(VerboseMProcessor()) _pprintLine_("      creating vertex degrees of freedom");
 			VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
 		}
 
-		_printf_(VerboseMProcessor(),"      resolving node constraints\n");
+		if(VerboseMProcessor()) _pprintLine_("      resolving node constraints");
 		SpcNodesx(nodes,constraints,parameters,analysis_type); 
 
-		_printf_(VerboseMProcessor(),"      creating nodal degrees of freedom\n");
+		if(VerboseMProcessor()) _pprintLine_("      creating nodal degrees of freedom");
 		NodesDofx(nodes,parameters,analysis_type);
 	
-		_printf_(VerboseMProcessor(),"      configuring element and loads\n");
+		if(VerboseMProcessor()) _pprintLine_("      configuring element and loads");
 		ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
 	}
@@ -77,6 +77,6 @@
 }
 
-/*}}}1*/
-/*FUNCTION FemModel::destructor {{{1*/
+/*}}}*/
+/*FUNCTION FemModel::destructor {{{*/
 FemModel::~FemModel(){
 
@@ -85,5 +85,5 @@
 
 	/*Delete all the datasets: */
-	xfree((void**)&analysis_type_list);
+	xDelete<int>(analysis_type_list);
 	delete elements;
 	delete nodes;
@@ -96,16 +96,16 @@
 
 }
-/*}}}1*/
+/*}}}*/
 
 /*Object management*/
-/*FUNCTION FemModel::Echo {{{1*/
+/*FUNCTION FemModel::Echo {{{*/
 void FemModel::Echo(void){
 
-	printf("FemModel echo: \n");
-	printf("   number of fem models: %i\n",nummodels);
-	printf("   analysis_type_list: \n");
-	for(int i=0;i<nummodels;i++)printf("     %i: %s\n",i,EnumToStringx(analysis_type_list[i]));
-	printf("   current analysis_type: \n");
-	printf("     %i: %s\n",analysis_counter,EnumToStringx(analysis_type_list[analysis_counter]));
+	_printLine_("FemModel echo: ");
+	_printLine_("   number of fem models: " << nummodels);
+	_printLine_("   analysis_type_list: ");
+	for(int i=0;i<nummodels;i++)_printLine_("     " << i << ": " << EnumToStringx(analysis_type_list[i]));
+	_printLine_("   current analysis_type: ");
+	_printLine_("     " << analysis_counter << ": " << EnumToStringx(analysis_type_list[analysis_counter]));
 
 }
@@ -113,5 +113,5 @@
 
 /*Numerics: */
-/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{1*/
+/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{*/
 void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
 
@@ -129,5 +129,5 @@
 	}
 	if(found!=-1) analysis_counter=found;
-	else _error_("Could not find alias for analysis_type %s in list of FemModel analyses",EnumToStringx(configuration_type));
+	else _error2_("Could not find alias for analysis_type " << EnumToStringx(configuration_type) << " in list of FemModel analyses");
 
 	/*Now, plug analysis_counter and analysis_type inside the parameters: */
@@ -145,11 +145,11 @@
 	if(this->parameters->Exist(PetscOptionsStringsEnum)){
 		PetscOptionsFromAnalysis(this->parameters,analysis_type);
-		_printf_(VerboseSolver(),"      petsc Options set for analysis type: %s\n",EnumToStringx(analysis_type));
+		if(VerboseSolver()) _pprintLine_("      petsc Options set for analysis type: " << EnumToStringx(analysis_type));
 	}
 	#endif
 
 }
-/*}}}1*/
-/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{1*/
+/*}}}*/
+/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{*/
 void FemModel::SetCurrentConfiguration(int configuration_type){
 
@@ -157,3 +157,3 @@
 	this->SetCurrentConfiguration(configuration_type,configuration_type);
 }
-/*}}}1*/
+/*}}}*/
Index: /issm/trunk/src/c/objects/FemModel.h
===================================================================
--- /issm/trunk/src/c/objects/FemModel.h	(revision 12705)
+++ /issm/trunk/src/c/objects/FemModel.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Object.h"
 #include "../toolkits/toolkits.h"
Index: /issm/trunk/src/c/objects/Gauss/GaussPenta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Gauss/GaussPenta.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Gauss/GaussPenta.cpp	(revision 12706)
@@ -3,10 +3,10 @@
  */
 
-/*Include files: {{{1*/
+/*Include files: {{{*/
 #include "./../objects.h"
 /*}}}*/
 
 /*GaussPenta constructors and destructors:*/
-/*FUNCTION GaussPenta::GaussPenta() {{{1*/
+/*FUNCTION GaussPenta::GaussPenta() {{{*/
 GaussPenta::GaussPenta(){
 
@@ -26,5 +26,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussPenta::GaussPenta(int order_horiz,int order_vert) {{{1*/
+/*FUNCTION GaussPenta::GaussPenta(int order_horiz,int order_vert) {{{*/
 GaussPenta::GaussPenta(int order_horiz,int order_vert){
 
@@ -47,9 +47,9 @@
 	/*Allocate GaussPenta fields*/
 	numgauss=numgauss_horiz*numgauss_vert;
-	coords1=(double*)xmalloc(numgauss*sizeof(double));
-	coords2=(double*)xmalloc(numgauss*sizeof(double));
-	coords3=(double*)xmalloc(numgauss*sizeof(double));
-	coords4=(double*)xmalloc(numgauss*sizeof(double));
-	weights=(double*)xmalloc(numgauss*sizeof(double));
+	coords1=xNew<double>(numgauss);
+	coords2=xNew<double>(numgauss);
+	coords3=xNew<double>(numgauss);
+	coords4=xNew<double>(numgauss);
+	weights=xNew<double>(numgauss);
 
 	/*Combine Horizontal and vertical points*/
@@ -72,13 +72,13 @@
 
 	/*Clean up*/
-	xfree((void**)&coords1_horiz);
-	xfree((void**)&coords2_horiz);
-	xfree((void**)&coords3_horiz);
-	xfree((void**)&coords_vert);
-	xfree((void**)&weights_horiz);
-	xfree((void**)&weights_vert);
-}
-/*}}}*/
-/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int order){{{1*/
+	xDelete<double>(coords1_horiz);
+	xDelete<double>(coords2_horiz);
+	xDelete<double>(coords3_horiz);
+	xDelete<double>(coords_vert);
+	xDelete<double>(weights_horiz);
+	xDelete<double>(weights_vert);
+}
+/*}}}*/
+/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int order){{{*/
 GaussPenta::GaussPenta(int index1, int index2,int order){
 
@@ -93,9 +93,9 @@
 
 	/*Allocate GaussPenta fields*/
-	coords1=(double*)xmalloc(numgauss*sizeof(double));
-	coords2=(double*)xmalloc(numgauss*sizeof(double));
-	coords3=(double*)xmalloc(numgauss*sizeof(double));
-	coords4=(double*)xmalloc(numgauss*sizeof(double));
-	weights=(double*)xmalloc(numgauss*sizeof(double));
+	coords1=xNew<double>(numgauss);
+	coords2=xNew<double>(numgauss);
+	coords3=xNew<double>(numgauss);
+	coords4=xNew<double>(numgauss);
+	weights=xNew<double>(numgauss);
 
 	if(index1==0 && index2==3){
@@ -121,5 +121,5 @@
 	}
 	else{
-		_error_("Penta not supported yet");
+		_error2_("Penta not supported yet");
 	}
 
@@ -132,10 +132,10 @@
 
 	/*clean up*/
-	xfree((void**)&seg_coords);
-	xfree((void**)&seg_weights);
-
-}
-/*}}}*/
-/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int index3, int order){{{1*/
+	xDelete<double>(seg_coords);
+	xDelete<double>(seg_weights);
+
+}
+/*}}}*/
+/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int index3, int order){{{*/
 GaussPenta::GaussPenta(int index1, int index2, int index3, int order){
 
@@ -147,5 +147,5 @@
 
 		/*compute z coordinate*/
-		coords4=(double*)xmalloc(numgauss*sizeof(double));
+		coords4=xNew<double>(numgauss);
 		for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
 	}
@@ -157,14 +157,14 @@
 
 		/*compute z coordinate*/
-		coords4=(double*)xmalloc(numgauss*sizeof(double));
+		coords4=xNew<double>(numgauss);
 		for(int i=0;i<numgauss;i++) coords4[i]=1.0;
 	}
 	else{
-		_error_("Tria not supported yet");
-	}
-
-}
-/*}}}*/
-/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int index3, int index4,int order_horiz,int order_vert){{{1*/
+		_error2_("Tria not supported yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION GaussPenta::GaussPenta(int index1, int index2, int index3, int index4,int order_horiz,int order_vert){{{*/
 GaussPenta::GaussPenta(int index1, int index2, int index3, int index4,int order_horiz,int order_vert){
 
@@ -182,9 +182,9 @@
 	/*Allocate GaussPenta fields*/
 	numgauss=order_horiz*order_vert;
-	coords1=(double*)xmalloc(numgauss*sizeof(double));
-	coords2=(double*)xmalloc(numgauss*sizeof(double));
-	coords3=(double*)xmalloc(numgauss*sizeof(double));
-	coords4=(double*)xmalloc(numgauss*sizeof(double));
-	weights=(double*)xmalloc(numgauss*sizeof(double));
+	coords1=xNew<double>(numgauss);
+	coords2=xNew<double>(numgauss);
+	coords3=xNew<double>(numgauss);
+	coords4=xNew<double>(numgauss);
+	weights=xNew<double>(numgauss);
 
 	/*Quads: get the gauss points using the product of two line rules  */
@@ -223,71 +223,71 @@
 	}
 	else{
-		_error_("Tria not supported yet (user provided indices %i %i %i %i)",index1,index2,index3,index4);
+		_error2_("Tria not supported yet (user provided indices " << index1 << " " << index2 << " " << index3 << " " << index4 << ")");
 	}
 
 	/*clean-up*/
-	xfree((void**)&seg_horiz_coords);
-	xfree((void**)&seg_horiz_weights);
-	xfree((void**)&seg_vert_coords);
-	xfree((void**)&seg_vert_weights);
-}
-/*}}}*/
-/*FUNCTION GaussPenta::~GaussPenta(){{{1*/
+	xDelete<double>(seg_horiz_coords);
+	xDelete<double>(seg_horiz_weights);
+	xDelete<double>(seg_vert_coords);
+	xDelete<double>(seg_vert_weights);
+}
+/*}}}*/
+/*FUNCTION GaussPenta::~GaussPenta(){{{*/
 GaussPenta::~GaussPenta(){
-	xfree((void**)&weights);
-	xfree((void**)&coords1);
-	xfree((void**)&coords2);
-	xfree((void**)&coords3);
-	xfree((void**)&coords4);
+	xDelete<double>(weights);
+	xDelete<double>(coords1);
+	xDelete<double>(coords2);
+	xDelete<double>(coords3);
+	xDelete<double>(coords4);
 }
 /*}}}*/
 
 /*Methods*/
-/*FUNCTION GaussPenta::Echo{{{1*/
+/*FUNCTION GaussPenta::Echo{{{*/
 void GaussPenta::Echo(void){
 
-	printf("GaussPenta:\n");
-	printf("   numgauss: %i\n",numgauss);
+	_printLine_("GaussPenta:");
+	_printLine_("   numgauss: " << numgauss);
 
 	if (weights){
-	 printf("   weights = ["); 
-	 for(int i=0;i<numgauss;i++) printf(" %g\n",weights[i]);
-	 printf("]\n");
-	}
-	else printf("weights = NULL\n");
+	 _printString_("   weights = ["); 
+	 for(int i=0;i<numgauss;i++) _printLine_(" " << weights[i]);
+	 _printLine_("]");
+	}
+	else _printLine_("weights = NULL");
 	if (coords1){
-	 printf("   coords1 = ["); 
-	 for(int i=0;i<numgauss;i++) printf(" %g\n",coords1[i]);
-	 printf("]\n");
-	}
-	else printf("coords1 = NULL\n");
+	 _printString_("   coords1 = ["); 
+	 for(int i=0;i<numgauss;i++) _printLine_(" " << coords1[i]);
+	 _printLine_("]");
+	}
+	else _printLine_("coords1 = NULL");
 	if (coords2){
-	 printf("   coords2 = ["); 
-	 for(int i=0;i<numgauss;i++) printf(" %g\n",coords2[i]);
-	 printf("]\n");
-	}
-	else printf("coords2 = NULL\n");
+	 _printString_("   coords2 = ["); 
+	 for(int i=0;i<numgauss;i++) _printLine_(" " << coords2[i]);
+	 _printLine_("]");
+	}
+	else _printLine_("coords2 = NULL");
 	if (coords3){
-	 printf("   coords3 = ["); 
-	 for(int i=0;i<numgauss;i++) printf(" %g\n",coords3[i]);
-	 printf("]\n");
-	}
-	else printf("coords3 = NULL\n");
+	 _printString_("   coords3 = ["); 
+	 for(int i=0;i<numgauss;i++) _printLine_(" " << coords3[i]);
+	 _printLine_("]");
+	}
+	else _printLine_("coords3 = NULL");
 	if (coords4){
-		printf("   coords4 = ["); 
-		for(int i=0;i<numgauss;i++) printf(" %g\n",coords4[i]);
-		printf("]\n");
-	}
-	else printf("coords4 = NULL\n");
-
-	printf("   weight = %g\n",weight);
-	printf("   coord1 = %g\n",coord1);
-	printf("   coord2 = %g\n",coord2);
-	printf("   coord3 = %g\n",coord3);
-	printf("   coord4 = %g\n",coord4);
-
-}
-/*}}}*/
-/*FUNCTION GaussPenta::GaussCenter{{{1*/
+		_printString_("   coords4 = ["); 
+		for(int i=0;i<numgauss;i++) _printLine_(" " << coords4[i]);
+		_printLine_("]");
+	}
+	else _printLine_("coords4 = NULL");
+
+	_printLine_("   weight = " << weight);
+	_printLine_("   coord1 = " << coord1);
+	_printLine_("   coord2 = " << coord2);
+	_printLine_("   coord3 = " << coord3);
+	_printLine_("   coord4 = " << coord4);
+
+}
+/*}}}*/
+/*FUNCTION GaussPenta::GaussCenter{{{*/
 void GaussPenta::GaussCenter(void){
 
@@ -300,5 +300,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussPenta::GaussPoint{{{1*/
+/*FUNCTION GaussPenta::GaussPoint{{{*/
 void GaussPenta::GaussPoint(int ig){
 
@@ -315,5 +315,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussPenta::GaussVertex{{{1*/
+/*FUNCTION GaussPenta::GaussVertex{{{*/
 void GaussPenta::GaussVertex(int iv){
 
@@ -342,11 +342,11 @@
 			break;
 		default:
-			_error_("vertex index should be in [0 5]");
-
-	}
-
-}
-/*}}}*/
-/*FUNCTION GaussPenta::GaussFaceTria{{{1*/
+			_error2_("vertex index should be in [0 5]");
+
+	}
+
+}
+/*}}}*/
+/*FUNCTION GaussPenta::GaussFaceTria{{{*/
 void GaussPenta::GaussFaceTria(int index1, int index2, int index3, int order){
 
@@ -357,14 +357,14 @@
 	if(index1==0 && index2==1 && index3==2){
 		GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
-		coords4=(double*)xmalloc(numgauss*sizeof(double));
+		coords4=xNew<double>(numgauss);
 		for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
 	}
 	else{
-		_error_("Tria not supported yet");
-	}
-
-}
-/*}}}*/
-/*FUNCTION GaussPenta::begin{{{1*/
+		_error2_("Tria not supported yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION GaussPenta::begin{{{*/
 int GaussPenta::begin(void){
 
@@ -381,5 +381,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussPenta::end{{{1*/
+/*FUNCTION GaussPenta::end{{{*/
 int GaussPenta::end(void){
 
@@ -396,5 +396,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussPenta::SynchronizeGaussTria{{{1*/
+/*FUNCTION GaussPenta::SynchronizeGaussTria{{{*/
 void GaussPenta::SynchronizeGaussTria(GaussTria* gauss_tria){
 
Index: /issm/trunk/src/c/objects/Gauss/GaussPenta.h
===================================================================
--- /issm/trunk/src/c/objects/Gauss/GaussPenta.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Gauss/GaussPenta.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./../../shared/shared.h"
 class GaussTria;
Index: /issm/trunk/src/c/objects/Gauss/GaussTria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Gauss/GaussTria.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Gauss/GaussTria.cpp	(revision 12706)
@@ -3,10 +3,10 @@
  */
 
-/*Include files: {{{1*/
+/*Include files: {{{*/
 #include "./../objects.h"
 /*}}}*/
 
 /*GaussTria constructors and destructors:*/
-/*FUNCTION GaussTria::GaussTria() {{{1*/
+/*FUNCTION GaussTria::GaussTria() {{{*/
 GaussTria::GaussTria(){
 
@@ -24,5 +24,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussTria::GaussTria(int order) {{{1*/
+/*FUNCTION GaussTria::GaussTria(int order) {{{*/
 GaussTria::GaussTria(int order){
 
@@ -38,10 +38,10 @@
 }
 /*}}}*/
-/*FUNCTION GaussTria::GaussTria(int index1,int index2,int order) {{{1*/
+/*FUNCTION GaussTria::GaussTria(int index1,int index2,int order) {{{*/
 GaussTria::GaussTria(int index1,int index2,int order){
 
 	/*Intermediaties*/
-	double *seg_coords  = NULL;
-	double *seg_weights = NULL;
+	IssmPDouble *seg_coords  = NULL;
+	IssmPDouble *seg_weights = NULL;
 	int     i,index3;
 
@@ -51,8 +51,8 @@
 
 	/*Allocate GaussTria fields*/
-	coords1=(double*)xmalloc(numgauss*sizeof(double));
-	coords2=(double*)xmalloc(numgauss*sizeof(double));
-	coords3=(double*)xmalloc(numgauss*sizeof(double));
-	weights=(double*)xmalloc(numgauss*sizeof(double));
+	coords1=xNew<IssmPDouble>(numgauss);
+	coords2=xNew<IssmPDouble>(numgauss);
+	coords3=xNew<IssmPDouble>(numgauss);
+	weights=xNew<IssmPDouble>(numgauss);
 
 	/*Reverse index1 and 2 if necessary*/
@@ -71,5 +71,5 @@
 	else if (index1==0 && index2==2){
 		for(i=0;i<numgauss;i++) coords1[i]=  0.5*(1-seg_coords[i]);
-		for(i=0;i<numgauss;i++) coords2[i]=0;
+		for(i=0;i<numgauss;i++) coords2[i]= 0 ;
 		for(i=0;i<numgauss;i++) coords3[i]=1-0.5*(1.-seg_coords[i]);
 		for(i=0;i<numgauss;i++) weights[i]=seg_weights[i];
@@ -82,5 +82,5 @@
 	}
 	else
-	 _error_("The 2 indices provided are not supported yet (user provided %i and %i)",index1,index2);
+	 _error2_("The 2 indices provided are not supported yet (user provided " << index1 << " and " << index2 << ")");
 
 	/*Initialize static fields as undefined*/
@@ -91,57 +91,57 @@
 
 	/*clean up*/
-	xfree((void**)&seg_coords);
-	xfree((void**)&seg_weights);
-}
-/*}}}*/
-/*FUNCTION GaussTria::~GaussTria(){{{1*/
+	xDelete<double>(seg_coords);
+	xDelete<double>(seg_weights);
+}
+/*}}}*/
+/*FUNCTION GaussTria::~GaussTria(){{{*/
 GaussTria::~GaussTria(){
-	xfree((void**)&weights);
-	xfree((void**)&coords1);
-	xfree((void**)&coords2);
-	xfree((void**)&coords3);
+	xDelete<IssmPDouble>(weights);
+	xDelete<IssmPDouble>(coords1);
+	xDelete<IssmPDouble>(coords2);
+	xDelete<IssmPDouble>(coords3);
 }
 /*}}}*/
 
 /*Methods*/
-/*FUNCTION GaussTria::Echo{{{1*/
+/*FUNCTION GaussTria::Echo{{{*/
 void GaussTria::Echo(void){
 
-	printf("GaussTria:\n");
-	printf("   numgauss: %i\n",numgauss);
+	_printLine_("GaussTria:");
+	_printLine_("   numgauss: " << numgauss);
 
 	if (weights){
-	 printf("   weights = ["); 
-	 for(int i=0;i<numgauss;i++) printf(" %g\n",weights[i]);
-	 printf("]\n");
-	}
-	else printf("weights = NULL\n");
+	 _printString_("   weights = ["); 
+	 for(int i=0;i<numgauss;i++) _printLine_(" " << weights[i]);
+	 _printLine_("]");
+	}
+	else _printLine_("weights = NULL");
 	if (coords1){
-	 printf("   coords1 = ["); 
-	 for(int i=0;i<numgauss;i++) printf(" %g\n",coords1[i]);
-	 printf("]\n");
-	}
-	else printf("coords1 = NULL\n");
+	 _printString_("   coords1 = ["); 
+	 for(int i=0;i<numgauss;i++) _printLine_(" " << coords1[i]);
+	 _printLine_("]");
+	}
+	else _printLine_("coords1 = NULL");
 	if (coords2){
-	 printf("   coords2 = ["); 
-	 for(int i=0;i<numgauss;i++) printf(" %g\n",coords2[i]);
-	 printf("]\n");
-	}
-	else printf("coords2 = NULL\n");
+	 _printString_("   coords2 = ["); 
+	 for(int i=0;i<numgauss;i++) _printLine_(" " << coords2[i]);
+	 _printLine_("]");
+	}
+	else _printLine_("coords2 = NULL");
 	if (coords3){
-	 printf("   coords3 = ["); 
-	 for(int i=0;i<numgauss;i++) printf(" %g\n",coords3[i]);
-	 printf("]\n");
-	}
-	else printf("coords3 = NULL\n");
-
-	printf("   weight = %g\n",weight);
-	printf("   coord1 = %g\n",coord1);
-	printf("   coord2 = %g\n",coord2);
-	printf("   coord3 = %g\n",coord3);
-
-}
-/*}}}*/
-/*FUNCTION GaussTria::GaussCenter{{{1*/
+	 _printString_("   coords3 = ["); 
+	 for(int i=0;i<numgauss;i++) _printLine_(" " << coords3[i]);
+	 _printLine_("]");
+	}
+	else _printLine_("coords3 = NULL");
+
+	_printLine_("   weight = " << weight);
+	_printLine_("   coord1 = " << coord1);
+	_printLine_("   coord2 = " << coord2);
+	_printLine_("   coord3 = " << coord3);
+
+}
+/*}}}*/
+/*FUNCTION GaussTria::GaussCenter{{{*/
 void GaussTria::GaussCenter(void){
 
@@ -153,5 +153,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussTria::GaussEdgeCenter{{{1*/
+/*FUNCTION GaussTria::GaussEdgeCenter{{{*/
 void GaussTria::GaussEdgeCenter(int index1,int index2){
 
@@ -180,9 +180,9 @@
 	}
 	else
-	 _error_("The 2 indices provided are not supported yet (user provided %i and %i)",index1,index2);
-
-}
-/*}}}*/
-/*FUNCTION GaussTria::GaussPoint{{{1*/
+	 _error2_("The 2 indices provided are not supported yet (user provided " << index1 << " and " << index2 << ")");
+
+}
+/*}}}*/
+/*FUNCTION GaussTria::GaussPoint{{{*/
 void GaussTria::GaussPoint(int ig){
 
@@ -198,10 +198,10 @@
 }
 /*}}}*/
-/*FUNCTION GaussTria::GaussFromCoords{{{1*/
-void GaussTria::GaussFromCoords(double x,double y,double* xyz_list){
+/*FUNCTION GaussTria::GaussFromCoords{{{*/
+void GaussTria::GaussFromCoords(IssmPDouble x,IssmPDouble y,IssmPDouble* xyz_list){
 
 	/*Intermediaries*/
-	double    area = 0;
-	double    x1,y1,x2,y2,x3,y3;
+	IssmPDouble    area = 0;
+	IssmPDouble    x1,y1,x2,y2,x3,y3;
 
 	/*in debugging mode: check that the default constructor has been called*/
@@ -225,5 +225,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussTria::GaussVertex{{{1*/
+/*FUNCTION GaussTria::GaussVertex{{{*/
 void GaussTria::GaussVertex(int iv){
 
@@ -243,11 +243,11 @@
 			break;
 		default:
-			_error_("vertex index should be in [0 2]");
-
-	}
-
-}
-/*}}}*/
-/*FUNCTION GaussTria::begin{{{1*/
+			_error2_("vertex index should be in [0 2]");
+
+	}
+
+}
+/*}}}*/
+/*FUNCTION GaussTria::begin{{{*/
 int GaussTria::begin(void){
 
@@ -263,5 +263,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussTria::end{{{1*/
+/*FUNCTION GaussTria::end{{{*/
 int GaussTria::end(void){
 
Index: /issm/trunk/src/c/objects/Gauss/GaussTria.h
===================================================================
--- /issm/trunk/src/c/objects/Gauss/GaussTria.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Gauss/GaussTria.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./../../shared/shared.h"
 /*}}}*/
@@ -15,14 +15,14 @@
 	private:
 		int numgauss;
-		double* weights;
-		double* coords1;
-		double* coords2;
-		double* coords3;
+		IssmPDouble* weights;
+		IssmPDouble* coords1;
+		IssmPDouble* coords2;
+		IssmPDouble* coords3;
 
 	public:
-		double weight;
-		double coord1;
-		double coord2;
-		double coord3;
+		IssmPDouble weight;
+		IssmPDouble coord1;
+		IssmPDouble coord2;
+		IssmPDouble coord3;
 		
 	public:
@@ -38,5 +38,5 @@
 		int  end(void);
 		void Echo(void);
-		void GaussFromCoords(double x1,double y1,double* xyz_list);
+		void GaussFromCoords(IssmPDouble x1,IssmPDouble y1,IssmPDouble* xyz_list);
 		void GaussPoint(int ig);
 		void GaussVertex(int iv);
Index: /issm/trunk/src/c/objects/Hook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Hook.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Hook.cpp	(revision 12706)
@@ -20,5 +20,5 @@
 
 /*Constructor/Destructors*/
-/*FUNCTION Hook::Hook(){{{1*/
+/*FUNCTION Hook::Hook(){{{*/
 Hook::Hook(){
 	this->num=0;
@@ -29,5 +29,5 @@
 }
 /*}}}*/
-/*FUNCTION Hook::Hook(int* ids, int num){{{1*/
+/*FUNCTION Hook::Hook(int* ids, int num){{{*/
 Hook::Hook(int* in_ids, int in_num){
 
@@ -47,7 +47,7 @@
 	else{
 		/*Allocate: */
-		this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
-		this->ids=(int*)xmalloc(this->num*sizeof(int));
-		this->offsets=(int*)xmalloc(this->num*sizeof(int));
+		this->objects=xNew<Object*>(this->num);
+		this->ids=xNew<int>(this->num);
+		this->offsets=xNew<int>(this->num);
 
 		/*Copy ids: */
@@ -60,10 +60,10 @@
 }
 /*}}}*/
-/*FUNCTION Hook::~Hook(){{{1*/
+/*FUNCTION Hook::~Hook(){{{*/
 Hook::~Hook(){
 	/*deallocate: */
-	xfree((void**)&this->objects);
-	xfree((void**)&this->ids);
-	xfree((void**)&this->offsets);
+	xDelete<Object*>(this->objects);
+	xDelete<int>(this->ids);
+	xDelete<int>(this->offsets);
 	return;
 }
@@ -71,52 +71,52 @@
 
 /*Some of the Object functionality: */
-/*FUNCTION Hook::Echo{{{1*/
+/*FUNCTION Hook::Echo{{{*/
 void Hook::Echo(void){
 
 	int i;
 	if (num){
-		printf("   Hook: \n");
-		printf("      num=%i\n",this->num);
-		printf("      ids: ");
-		for (i=0;i<this->num;i++) printf("%i ",this->ids[i]);
-		printf("\n");
-		printf("      offsets: ");
-		for (i=0;i<this->num;i++) printf("%i ",this->offsets[i]);
-		printf("\n");
+		_printLine_("   Hook: ");
+		_printLine_("      num=" << this->num);
+		_printString_("      ids: ");
+		for (i=0;i<this->num;i++) _printString_(this->ids[i] << " ");
+		_printLine_("");
+		_printString_("      offsets: ");
+		for (i=0;i<this->num;i++) _printString_(this->offsets[i] << " ");
+		_printLine_("");
 	}
 	else{
-		printf("   Hook: num=0 \n");
-	}
-}
-/*}}}*/
-/*FUNCTION Hook::DeepEcho{{{1*/
+		_printLine_("   Hook: num=0 ");
+	}
+}
+/*}}}*/
+/*FUNCTION Hook::DeepEcho{{{*/
 void Hook::DeepEcho(void){
 
 	int i;
 	if (num){
-		printf("   Hook: \n");
-		printf("      num=%i\n",this->num);
-		printf("      ids: ");
-		for (i=0;i<this->num;i++) printf("%i ",this->ids[i]);
-		printf("\n");
-		printf("      offsets: ");
-		for (i=0;i<this->num;i++) printf("%i ",this->offsets[i]);
-		printf("\n");
-		if (!objects) printf("      warning: object not hooked yet\n");
+		_printLine_("   Hook: ");
+		_printLine_("      num=" << this->num);
+		_printString_("      ids: ");
+		for (i=0;i<this->num;i++) _printString_(this->ids[i] << " ");
+		_printLine_("");
+		_printString_("      offsets: ");
+		for (i=0;i<this->num;i++) _printString_(this->offsets[i] << " ");
+		_printLine_("");
+		if (!objects) _printLine_("      warning: object not hooked yet");
 		else{
-			printf("      objects:\n   ");
+			_printString_("      objects:\n   ");
 			for (i=0;i<this->num;i++){
-				printf("         object %i\n",i);
+				_printLine_("         object " << i);
 				if(objects[i]) objects[i]->DeepEcho();
-				else           printf("            no object hooked yet (not configured)\n");
+				else           _printLine_("            no object hooked yet (not configured)");
 			}
 		}
 	}
 	else{
-		printf("   Hook: num=0 \n");
-	}
-}
-/*}}}*/
-/*FUNCTION Hook::copy {{{1*/
+		_printLine_("   Hook: num=0 ");
+	}
+}
+/*}}}*/
+/*FUNCTION Hook::copy {{{*/
 Object* Hook::copy(void){
 
@@ -132,7 +132,7 @@
 	output->num=this->num;
 	if(output->num){
-		output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
-		output->ids=(int*)xmalloc(output->num*sizeof(int));
-		output->offsets=(int*)xmalloc(output->num*sizeof(int));
+		output->objects=xNew<Object*>(output->num);
+		output->ids=xNew<int>(output->num);
+		output->offsets=xNew<int>(output->num);
 	}
 	
@@ -148,5 +148,5 @@
 
 /*Hook management: */
-/*FUNCTION Hook::configure{{{1*/
+/*FUNCTION Hook::configure{{{*/
 void Hook::configure(DataSet* dataset){
 
@@ -185,17 +185,17 @@
 			this->objects[i]=(Object*)dataset->GetObjectById(this->offsets+i,this->ids[i]); //remember the offset for later on.
 			/*check the id is correct!: */
-			if (this->objects[i]->Id()!=this->ids[i]) _error_("%s%i%s%i%s"," wrong id: ",this->objects[i]->Id()," vs ",this->ids[i],"  in resolved pointer!");
-		}
-	}
-}
-/*}}}*/
-/*FUNCTION Hook::delivers{{{1*/
+			if (this->objects[i]->Id()!=this->ids[i]) _error2_("wrong id: " << this->objects[i]->Id() << " vs " << this->ids[i] << "  in resolved pointer!");
+		}
+	}
+}
+/*}}}*/
+/*FUNCTION Hook::delivers{{{*/
 Object* Hook::delivers(void){
 	
 	/*first, check that we only have one T object in our object list: */
-	if (this->num!=1) _error_("%s%i%s\n"," trying to delivery a single hook object when hook holds ",this->num," objects");
+	if (this->num!=1) _error2_("trying to delivery a single hook object when hook holds " << this->num << " objects" << "\n");
 
 	/*check NULL: */
-	if (this->objects==NULL) _error_("hook is not pointing to any object, objects pointer is NULL");
+	if (this->objects==NULL) _error2_("hook is not pointing to any object, objects pointer is NULL");
 
 	return *objects;
@@ -203,30 +203,30 @@
 
 /*}}}*/
-/*FUNCTION Hook::deliverp{{{1*/
+/*FUNCTION Hook::deliverp{{{*/
 Object** Hook::deliverp(void){
 	return objects;
 }
 /*}}}*/
-/*FUNCTION Hook::Ids{{{1*/
+/*FUNCTION Hook::Ids{{{*/
 int* Hook::Ids(void){
 	return this->ids;
 }
 /*}}}*/
-/*FUNCTION Hook::GetNum{{{1*/
+/*FUNCTION Hook::GetNum{{{*/
 int Hook::GetNum(void){
 	return this->num;
 }
 /*}}}*/
-/*FUNCTION Hook::GetObjects{{{1*/
+/*FUNCTION Hook::GetObjects{{{*/
 Object** Hook::GetObjects(void){
 	return this->objects;
 }
 /*}}}*/
-/*FUNCTION Hook::GetOffsets{{{1*/
+/*FUNCTION Hook::GetOffsets{{{*/
 int* Hook::GetOffsets(void){
 	return this->offsets;
 }
 /*}}}*/
-/*FUNCTION Hook::Spawn{{{1*/
+/*FUNCTION Hook::Spawn{{{*/
 Hook* Hook::Spawn(int* indices, int numindices){
 
@@ -246,13 +246,13 @@
 
 	/*Else, check that we are requesting a half of num*/
-	if (numindices>this->num) _error_("Cannot spawn hook with %i objects from a Hook of %i objects",numindices,this->num);
+	if (numindices>this->num) _error2_("Cannot spawn hook with " << numindices << " objects from a Hook of " << this->num << " objects");
 
 	/*go pickup the correct objects, ids and offsets :*/
 	output->num=numindices;
-	if(output->num<1) _error_("Trying to spawn an empty ElementProperties!");
-
-	output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
-	output->ids=(int*)xmalloc(output->num*sizeof(int));
-	output->offsets=(int*)xmalloc(output->num*sizeof(int));
+	if(output->num<1) _error2_("Trying to spawn an empty ElementProperties!");
+
+	output->objects=xNew<Object*>(output->num);
+	output->ids=xNew<int>(output->num);
+	output->offsets=xNew<int>(output->num);
 
 	for(i=0;i<output->num;i++){
Index: /issm/trunk/src/c/objects/Hook.h
===================================================================
--- /issm/trunk/src/c/objects/Hook.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Hook.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Object.h"
 class DataSet;
@@ -31,10 +31,10 @@
 		~Hook();
 		/*}}}*/
-		/*Object like functionality:{{{1*/
+		/*Object like functionality:{{{*/
 		void       Echo(void);
 		void       DeepEcho(void);
 		Object*    copy(void);
 		/*}}}*/
-		/*Hook management: {{{1*/
+		/*Hook management: {{{*/
 		Object*    delivers(void); //single object deliver
 		Object**   deliverp(void); //deliver all objects
Index: /issm/trunk/src/c/objects/Inputs/BoolInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BoolInput.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/BoolInput.cpp	(revision 12706)
@@ -18,10 +18,10 @@
 
 /*BoolInput constructors and destructor*/
-/*FUNCTION BoolInput::BoolInput(){{{1*/
+/*FUNCTION BoolInput::BoolInput(){{{*/
 BoolInput::BoolInput(){
 	return;
 }
 /*}}}*/
-/*FUNCTION BoolInput::BoolInput(double* values){{{1*/
+/*FUNCTION BoolInput::BoolInput(IssmDouble* values){{{*/
 BoolInput::BoolInput(int in_enum_type,IssmBool in_value){
 
@@ -30,5 +30,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolInput::~BoolInput(){{{1*/
+/*FUNCTION BoolInput::~BoolInput(){{{*/
 BoolInput::~BoolInput(){
 	return;
@@ -37,21 +37,21 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION BoolInput::Echo {{{1*/
+/*FUNCTION BoolInput::Echo {{{*/
 void BoolInput::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION BoolInput::DeepEcho{{{1*/
+/*FUNCTION BoolInput::DeepEcho{{{*/
 void BoolInput::DeepEcho(void){
 
-	printf("BoolInput:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %s\n",value?"true":"false");
+	_printLine_("BoolInput:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " <<(value?"true":"false"));
 }
 /*}}}*/
-/*FUNCTION BoolInput::Id{{{1*/
+/*FUNCTION BoolInput::Id{{{*/
 int    BoolInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION BoolInput::MyRank{{{1*/
+/*FUNCTION BoolInput::MyRank{{{*/
 int    BoolInput::MyRank(void){ 
 	extern int my_rank;
@@ -59,5 +59,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolInput::ObjectEnum{{{1*/
+/*FUNCTION BoolInput::ObjectEnum{{{*/
 int BoolInput::ObjectEnum(void){
 
@@ -66,5 +66,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolInput::copy{{{1*/
+/*FUNCTION BoolInput::copy{{{*/
 Object* BoolInput::copy() {
 	
@@ -75,5 +75,5 @@
 	
 /*BoolInput management*/
-/*FUNCTION BoolInput::InstanceEnum{{{1*/
+/*FUNCTION BoolInput::InstanceEnum{{{*/
 int BoolInput::InstanceEnum(void){
 
@@ -82,5 +82,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolInput::SpawnTriaInput{{{1*/
+/*FUNCTION BoolInput::SpawnTriaInput{{{*/
 Input* BoolInput::SpawnTriaInput(int* indices){
 
@@ -97,6 +97,6 @@
 }
 /*}}}*/
-/*FUNCTION BoolInput::SpawnResult{{{1*/
-ElementResult* BoolInput::SpawnResult(int step, double time){
+/*FUNCTION BoolInput::SpawnResult{{{*/
+ElementResult* BoolInput::SpawnResult(int step, IssmDouble time){
 	
 	return new BoolElementResult(this->enum_type,this->value,step,time);
@@ -106,45 +106,45 @@
 
 /*Object functions*/
-/*FUNCTION BoolInput::GetInputValue(bool* pvalue) {{{1*/
+/*FUNCTION BoolInput::GetInputValue(bool* pvalue) {{{*/
 void BoolInput::GetInputValue(bool* pvalue){
 	*pvalue=value;
 }
 /*}}}*/
-/*FUNCTION BoolInput::GetInputValue(int* pvalue){{{1*/
-void BoolInput::GetInputValue(int* pvalue){_error_(" not supported yet!");}
+/*FUNCTION BoolInput::GetInputValue(int* pvalue){{{*/
+void BoolInput::GetInputValue(int* pvalue){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION BoolInput::GetInputValue(double* pvalue){{{1*/
-void BoolInput::GetInputValue(double* pvalue){_error_(" not supported yet!");}
+/*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue){{{*/
+void BoolInput::GetInputValue(IssmDouble* pvalue){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION BoolInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
-void BoolInput::GetInputValue(double* pvalue,GaussTria* gauss){_error_(" not supported yet!");}
+/*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
+void BoolInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION BoolInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
-void BoolInput::GetInputValue(double* pvalue,GaussPenta* gauss){_error_(" not supported yet!");}
+/*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
+void BoolInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
-void BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_(" not supported yet!");}
+/*FUNCTION BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
+void BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
-void BoolInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_(" not supported yet!");}
+/*FUNCTION BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION BoolInput::ChangeEnum{{{1*/
+/*FUNCTION BoolInput::ChangeEnum{{{*/
 void BoolInput::ChangeEnum(int newenumtype){
 	this->enum_type=newenumtype;
 }
 /*}}}*/
-/*FUNCTION BoolInput::SquareMin{{{1*/
-void BoolInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
+/*FUNCTION BoolInput::SquareMin{{{*/
+void BoolInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
 	/*square of a bool is the bool itself: */
 	*psquaremin=value;
 }
 /*}}}*/
-/*FUNCTION BoolInput::Scale{{{1*/
-void BoolInput::Scale(double scale_factor){
+/*FUNCTION BoolInput::Scale{{{*/
+void BoolInput::Scale(IssmDouble scale_factor){
 	/*a bool cannot be scaled: */
 }
 /*}}}*/
-/*FUNCTION BoolInput::AXPY{{{1*/
-void BoolInput::AXPY(Input* xinput,double scalar){
+/*FUNCTION BoolInput::AXPY{{{*/
+void BoolInput::AXPY(Input* xinput,IssmDouble scalar){
 
 	BoolInput*  xboolinput=NULL;
@@ -157,22 +157,14 @@
 
 		case BoolInputEnum:
-			this->value=(bool)(this->value+scalar*xboolinput->value);
+			this->value=reCast<bool,IssmDouble>(this->value+scalar*xboolinput->value);
 			return;
 
 		default:
-			_error_("not implemented yet");
+			_error2_("not implemented yet");
 	}
 
 }
 /*}}}*/
-/*FUNCTION BoolInput::Constrain{{{1*/
-void BoolInput::Constrain(double cm_min, double cm_max){
-
-	if(!isnan(cm_min)) if (this->value<cm_min)this->value=cm_min;
-	if(!isnan(cm_max)) if (this->value>cm_max)this->value=cm_max;
-
-}
-/*}}}*/
-/*FUNCTION BoolInput::Extrude{{{1*/
+/*FUNCTION BoolInput::Extrude{{{*/
 void BoolInput::Extrude(void){
 
@@ -181,19 +173,19 @@
 }
 /*}}}*/
-/*FUNCTION BoolInput::GetVectorFromInputs{{{1*/
+/*FUNCTION BoolInput::GetVectorFromInputs{{{*/
 void BoolInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
-	_error_(" not supporte yet!");
+	_error2_("not supporte yet!");
 
 }
 /*}}}*/
-/*FUNCTION BoolInput::GetValuesPtr{{{1*/
-void BoolInput::GetValuesPtr(double** pvalues,int* pnum_values){
+/*FUNCTION BoolInput::GetValuesPtr{{{*/
+void BoolInput::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
 
-	_error_(" not supported yet!");
+	_error2_("not supported yet!");
 
 }
 /*}}}*/
-/*FUNCTION BoolInput::Configure{{{1*/
+/*FUNCTION BoolInput::Configure{{{*/
 void BoolInput::Configure(Parameters* parameters){
 	/*do nothing: */
Index: /issm/trunk/src/c/objects/Inputs/BoolInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/BoolInput.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/BoolInput.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Input.h"
 #include "../../include/include.h"
@@ -21,10 +21,10 @@
 		IssmBool value;
 
-		/*BoolInput constructors, destructors: {{{1*/
+		/*BoolInput constructors, destructors: {{{*/
 		BoolInput();
 		BoolInput(int enum_type,IssmBool value);
 		~BoolInput();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -34,50 +34,50 @@
 		Object* copy();
 		/*}}}*/
-		/*BoolInput management: {{{1*/
+		/*BoolInput management: {{{*/
 		int   InstanceEnum();
 		Input* SpawnTriaInput(int* indices);
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
-		ElementResult* SpawnResult(int step, double time);
+		Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
+		Input* PointwiseMin(Input* inputB){_error2_("not implemented yet");};
+		Input* PointwiseMax(Input* inputB){_error2_("not implemented yet");};
+		ElementResult* SpawnResult(int step, IssmDouble time);
 		void Configure(Parameters* parameters);
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void GetInputValue(bool* pvalue);
 		void GetInputValue(int* pvalue);
-		void GetInputValue(double* pvalue);
-		void GetInputValue(double* pvalue,GaussTria* gauss);
-		void GetInputValue(double* pvalue,GaussPenta* gauss);
-		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
-		void GetInputAverage(double* pvalue){_error_("not implemented yet");};
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetInputAverage(IssmDouble* pvalue){_error2_("not implemented yet");};
+		void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
 		void ChangeEnum(int newenumtype);
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
-		void ConstrainMin(double minimum){_error_("not implemented yet");};
-		double InfinityNorm(void){_error_("InfinityNorm not implemented for booleans");};
-		double Max(void){_error_("Max not implemented for booleans");};
-		double MaxAbs(void){_error_("Max not implemented for booleans");};
-		double Min(void){_error_("Min not implemented for booleans");};
-		double MinAbs(void){_error_("Min not implemented for booleans");};
-		void Scale(double scale_factor);
-		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
-		void AXPY(Input* xinput,double scalar);
-		void Constrain(double cm_min, double cm_max);
+		void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
+		void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
+		IssmDouble InfinityNorm(void){_error2_("InfinityNorm not implemented for booleans");};
+		IssmDouble Max(void){_error2_("Max not implemented for booleans");};
+		IssmDouble MaxAbs(void){_error2_("Max not implemented for booleans");};
+		IssmDouble Min(void){_error2_("Min not implemented for booleans");};
+		IssmDouble MinAbs(void){_error2_("Min not implemented for booleans");};
+		void Scale(IssmDouble scale_factor);
+		void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error2_("Constrain not implemented for booleans");};
 		void Extrude(void);
-		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
+		void VerticallyIntegrate(Input* thickness_input){_error2_("not supported yet");};
 		void GetVectorFromInputs(Vector* vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values);
+		void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Inputs/ControlInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/ControlInput.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/ControlInput.cpp	(revision 12706)
@@ -18,5 +18,5 @@
 
 /*ControlInput constructors and destructor*/
-/*FUNCTION ControlInput::ControlInput(){{{1*/
+/*FUNCTION ControlInput::ControlInput(){{{*/
 ControlInput::ControlInput(){
 	control_id  = 0;
@@ -28,6 +28,6 @@
 }
 /*}}}*/
-/*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id){{{1*/
-ControlInput::ControlInput(int in_enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id){
+/*FUNCTION ControlInput::ControlInput(int enum_type,int enum_input,IssmDouble* pvalues,IssmDouble* pmin,IssmDouble* pmax,int id){{{*/
+ControlInput::ControlInput(int in_enum_type,int enum_input,IssmDouble* pvalues,IssmDouble* pmin,IssmDouble* pmax,int id){
 
 	control_id=id;
@@ -48,10 +48,10 @@
 			break;
 		default:
-			_error_("Input of Enum %s not supported yet by ControlInput",EnumToStringx(enum_input));
+			_error2_("Input of Enum " << EnumToStringx(enum_input) << " not supported yet by ControlInput");
 	}
 	gradient   =NULL;
 }
 /*}}}*/
-/*FUNCTION ControlInput::~ControlInput(){{{1*/
+/*FUNCTION ControlInput::~ControlInput(){{{*/
 ControlInput::~ControlInput(){
 	delete values;
@@ -64,25 +64,25 @@
 
 /*Object virtual functions definitions:*/
-		/*FUNCTION ControlInput::Echo {{{1*/
+		/*FUNCTION ControlInput::Echo {{{*/
 void ControlInput::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION ControlInput::DeepEcho{{{1*/
+/*FUNCTION ControlInput::DeepEcho{{{*/
 void ControlInput::DeepEcho(void){
 
-	printf("ControlInput:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("---values: \n");     if (values)      values->Echo();
-	printf("---savedvalues: \n");if (savedvalues) savedvalues->Echo();
-	printf("---minvalues: \n");  if (minvalues)   minvalues->Echo();
-	printf("---maxvalues: \n");  if (maxvalues)   maxvalues->Echo();
-	printf("---gradient: \n");   if (gradient)    gradient->Echo();
-}
-/*}}}*/
-/*FUNCTION ControlInput::Id{{{1*/
+	_printLine_("ControlInput:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("---values: ");     if (values)      values->Echo();
+	_printLine_("---savedvalues: ");if (savedvalues) savedvalues->Echo();
+	_printLine_("---minvalues: ");  if (minvalues)   minvalues->Echo();
+	_printLine_("---maxvalues: ");  if (maxvalues)   maxvalues->Echo();
+	_printLine_("---gradient: ");   if (gradient)    gradient->Echo();
+}
+/*}}}*/
+/*FUNCTION ControlInput::Id{{{*/
 int    ControlInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION ControlInput::MyRank{{{1*/
+/*FUNCTION ControlInput::MyRank{{{*/
 int    ControlInput::MyRank(void){ 
 	extern int my_rank;
@@ -90,5 +90,5 @@
 }
 /*}}}*/
-/*FUNCTION ControlInput::ObjectEnum{{{1*/
+/*FUNCTION ControlInput::ObjectEnum{{{*/
 int ControlInput::ObjectEnum(void){
 
@@ -97,5 +97,5 @@
 }
 /*}}}*/
-/*FUNCTION ControlInput::copy{{{1*/
+/*FUNCTION ControlInput::copy{{{*/
 Object* ControlInput::copy() {
 	
@@ -117,5 +117,5 @@
 	
 /*ControlInput management*/
-/*FUNCTION ControlInput::InstanceEnum{{{1*/
+/*FUNCTION ControlInput::InstanceEnum{{{*/
 int ControlInput::InstanceEnum(void){
 
@@ -126,5 +126,5 @@
 
 /*Object functions*/
-/*FUNCTION ControlInput::Constrain(){{{1*/
+/*FUNCTION ControlInput::Constrain(){{{*/
 void ControlInput::Constrain(void){
 
@@ -136,9 +136,9 @@
 	delete values; this->values=newvalues;
 }/*}}}*/
-/*FUNCTION ControlInput::Constrain(double min, double max){{{1*/
-void ControlInput::Constrain(double min, double max){
+/*FUNCTION ControlInput::Constrain(IssmDouble min, IssmDouble max){{{*/
+void ControlInput::Constrain(IssmDouble min, IssmDouble max){
 	   values->Constrain(min,max);
 }/*}}}*/
-/*FUNCTION ControlInput::Extrude{{{1*/
+/*FUNCTION ControlInput::Extrude{{{*/
 void ControlInput::Extrude(void){
 	values->Extrude();
@@ -146,14 +146,14 @@
 	//gradient->Extrude();
 }/*}}}*/
-/*FUNCTION ControlInput::GetGradient{{{1*/
+/*FUNCTION ControlInput::GetGradient{{{*/
 void ControlInput::GetGradient(Vector* gradient_vec,int* doflist){
 	if(gradient) gradient->GetVectorFromInputs(gradient_vec,doflist);
 }/*}}}*/
-/*FUNCTION ControlInput::ScaleGradient{{{1*/
-void ControlInput::ScaleGradient(double scaling_factor){
-	if(!gradient) _error_("Gradient of ControlInput %s not found",EnumToStringx(enum_type));
+/*FUNCTION ControlInput::ScaleGradient{{{*/
+void ControlInput::ScaleGradient(IssmDouble scaling_factor){
+	if(!gradient) _error2_("Gradient of ControlInput " << EnumToStringx(enum_type) << " not found");
 	gradient->Scale(scaling_factor);
 }/*}}}*/
-/*FUNCTION ControlInput::SetGradient{{{1*/
+/*FUNCTION ControlInput::SetGradient{{{*/
 void ControlInput::SetGradient(Input* gradient_in){
 
@@ -170,5 +170,5 @@
 			break;
 		default:
-			_error_("more than 3 controls not implemented yet (Gradient %i was requested). EnumDefinitions.h needs to be updated.",this->control_id);
+			_error2_("more than 3 controls not implemented yet (Gradient " << this->control_id << " was requested). EnumDefinitions.h needs to be updated.");
 	}
 
@@ -178,5 +178,5 @@
 
 }/*}}}*/
-/*FUNCTION ControlInput::SetInput{{{1*/
+/*FUNCTION ControlInput::SetInput{{{*/
 void ControlInput::SetInput(Input* in_input){
 
@@ -185,22 +185,22 @@
 
 }/*}}}*/
-/*FUNCTION ControlInput::SpawnResult{{{1*/
-ElementResult* ControlInput::SpawnResult(int step, double time){
+/*FUNCTION ControlInput::SpawnResult{{{*/
+ElementResult* ControlInput::SpawnResult(int step, IssmDouble time){
 	return savedvalues->SpawnResult(step,time);
 }/*}}}*/
-/*FUNCTION ControlInput::SpawnTriaInput{{{1*/
+/*FUNCTION ControlInput::SpawnTriaInput{{{*/
 Input* ControlInput::SpawnTriaInput(int* indices){
 	return values->SpawnTriaInput(indices);
 }/*}}}*/
-/*FUNCTION ControlInput::SpawnGradient{{{1*/
-ElementResult* ControlInput::SpawnGradient(int step, double time){
+/*FUNCTION ControlInput::SpawnGradient{{{*/
+ElementResult* ControlInput::SpawnGradient(int step, IssmDouble time){
 	_assert_(gradient);
 	return gradient->SpawnResult(step,time);
 }/*}}}*/
-/*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist){{{1*/
+/*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist){{{*/
 void ControlInput::GetVectorFromInputs(Vector* vector,int* doflist){
 	values->GetVectorFromInputs(vector,doflist);
 }/*}}}*/
-/*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist,const char* data){{{1*/
+/*FUNCTION ControlInput::GetVectorFromInputs(Vector* vector,int* doflist,const char* data){{{*/
 void ControlInput::GetVectorFromInputs(Vector* vector,int* doflist,const char* data){
 	 if(strcmp(data,"value")==0){
@@ -221,50 +221,50 @@
 	 }
 	 else{
-		 _error_("Data %s not supported yet",data);
-	 }
-}/*}}}*/
-/*FUNCTION ControlInput::GetInputAverage(double* pvalue){{{1*/
-void ControlInput::GetInputAverage(double* pvalue){
+		 _error2_("Data " << data << " not supported yet");
+	 }
+}/*}}}*/
+/*FUNCTION ControlInput::GetInputAverage(IssmDouble* pvalue){{{*/
+void ControlInput::GetInputAverage(IssmDouble* pvalue){
 	values->GetInputAverage(pvalue);
 }/*}}}*/
-/*FUNCTION ControlInput::GetInputValue(bool* pvalue){{{1*/
+/*FUNCTION ControlInput::GetInputValue(bool* pvalue){{{*/
 void ControlInput::GetInputValue(bool* pvalue){
 	values->GetInputValue(pvalue);
 }/*}}}*/
-/*FUNCTION ControlInput::GetInputValue(int* pvalue){{{1*/
+/*FUNCTION ControlInput::GetInputValue(int* pvalue){{{*/
 void ControlInput::GetInputValue(int* pvalue){
 	values->GetInputValue(pvalue);
 }/*}}}*/
-/*FUNCTION ControlInput::GetInputValue(double* pvalue){{{1*/
-void ControlInput::GetInputValue(double* pvalue){
+/*FUNCTION ControlInput::GetInputValue(IssmDouble* pvalue){{{*/
+void ControlInput::GetInputValue(IssmDouble* pvalue){
 	values->GetInputValue(pvalue);
 }/*}}}*/
-/*FUNCTION ControlInput::GetInputValue(double* pvalue){{{1*/
-void ControlInput::GetInputValue(double* pvalue,GaussTria* gauss){
+/*FUNCTION ControlInput::GetInputValue(IssmDouble* pvalue){{{*/
+void ControlInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){
 	values->GetInputValue(pvalue,gauss);
 }/*}}}*/
-/*FUNCTION ControlInput::GetInputValue(double* pvalue){{{1*/
-void ControlInput::GetInputValue(double* pvalue,GaussPenta* gauss){
+/*FUNCTION ControlInput::GetInputValue(IssmDouble* pvalue){{{*/
+void ControlInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){
 	values->GetInputValue(pvalue,gauss);
 }/*}}}*/
-/*FUNCTION ControlInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
-void ControlInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){
+/*FUNCTION ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
+void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){
 	values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss);
 }/*}}}*/
-/*FUNCTION ControlInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
-void ControlInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){
 	values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss);
 }/*}}}*/
-/*FUNCTION ControlInput::SaveValue{{{1*/
+/*FUNCTION ControlInput::SaveValue{{{*/
 void ControlInput::SaveValue(void){
-	if(!values) _error_("Values of %s not found",EnumToStringx(this->enum_type));
+	if(!values) _error2_("Values of " << EnumToStringx(this->enum_type) << " not found");
 
 	if(savedvalues) delete this->savedvalues;
 	this->savedvalues=(Input*)this->values->copy();
 }/*}}}*/
-/*FUNCTION ControlInput::UpdateValue{{{1*/
-void ControlInput::UpdateValue(double scalar){
-	if(!gradient)    _error_("Gradient of %s not found",EnumToStringx(this->enum_type));
-	if(!savedvalues) _error_("Values of %s not found",EnumToStringx(this->enum_type));
+/*FUNCTION ControlInput::UpdateValue{{{*/
+void ControlInput::UpdateValue(IssmDouble scalar){
+	if(!gradient)    _error2_("Gradient of " << EnumToStringx(this->enum_type) << " not found");
+	if(!savedvalues) _error2_("Values of " << EnumToStringx(this->enum_type) << " not found");
 
 	if(values) delete this->values;
@@ -272,9 +272,9 @@
 	this->values->AXPY(gradient,scalar);
 }/*}}}*/
-/*FUNCTION ControlInput::VerticallyIntegrate{{{1*/
+/*FUNCTION ControlInput::VerticallyIntegrate{{{*/
 void ControlInput::VerticallyIntegrate(Input* thickness_input){
 	values->VerticallyIntegrate(thickness_input);
 }/*}}}*/
-/*FUNCTION ControlInput::Configure{{{1*/
+/*FUNCTION ControlInput::Configure{{{*/
 void ControlInput::Configure(Parameters* parameters){
 	/*do nothing: */
Index: /issm/trunk/src/c/objects/Inputs/ControlInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/ControlInput.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/ControlInput.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Input.h"
 #include "../../include/include.h"
@@ -25,10 +25,10 @@
 		Input* gradient;
 
-		/*ControlInput constructors, destructors: {{{1*/
+		/*ControlInput constructors, destructors: {{{*/
 		ControlInput();
-		ControlInput(int enum_type,int enum_input,double* pvalues,double* pmin,double* pmax,int id);
+		ControlInput(int enum_type,int enum_input,IssmDouble* pvalues,IssmDouble* pmin,IssmDouble* pmax,int id);
 		~ControlInput();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -38,58 +38,58 @@
 		Object* copy();
 		/*}}}*/
-		/*ControlInput management: {{{1*/
+		/*ControlInput management: {{{*/
 		int    InstanceEnum();
 		Input* SpawnTriaInput(int* indices);
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
-		ElementResult* SpawnResult(int step, double time);
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
+		Input* PointwiseMin(Input* inputB){_error2_("not implemented yet");};
+		Input* PointwiseMax(Input* inputB){_error2_("not implemented yet");};
+		ElementResult* SpawnResult(int step, IssmDouble time);
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
 		void Configure(Parameters* parameters);
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void SetInput(Input* in_input);
 		void GetInputValue(bool* pvalue);
 		void GetInputValue(int* pvalue);
-		void GetInputValue(double* pvalue);
-		void GetInputValue(double* pvalue,GaussTria* gauss);
-		void GetInputValue(double* pvalue,GaussPenta* gauss);
-		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
-		void GetInputAverage(double* pvalue);
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype){_error_("not implemented yet");};
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters){_error_("not implemented yet");};
-		void ConstrainMin(double minimum){_error_("not implemented yet");};
-		void Scale(double scale_factor){_error_("not implemented yet");};
-		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
-		void AXPY(Input* xinput,double scalar){_error_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void ChangeEnum(int newenumtype){_error2_("not implemented yet");};
+		void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){_error2_("not implemented yet");};
+		void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
+		void Scale(IssmDouble scale_factor){_error2_("not implemented yet");};
+		void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
+		void AXPY(Input* xinput,IssmDouble scalar){_error2_("not implemented yet");};
 		void Constrain(void);
-		void Constrain(double min,double max);
-		double InfinityNorm(void){_error_("not implemented yet");};
-		double Max(void){_error_("not implemented yet");};
-		double MaxAbs(void){_error_("not implemented yet");};
-		double Min(void){_error_("not implemented yet");};
-		double MinAbs(void){_error_("not implemented yet");};
+		void Constrain(IssmDouble min,IssmDouble max);
+		IssmDouble InfinityNorm(void){_error2_("not implemented yet");};
+		IssmDouble Max(void){_error2_("not implemented yet");};
+		IssmDouble MaxAbs(void){_error2_("not implemented yet");};
+		IssmDouble Min(void){_error2_("not implemented yet");};
+		IssmDouble MinAbs(void){_error2_("not implemented yet");};
 		void Extrude(void);
 		void VerticallyIntegrate(Input* thickness_input);
 		void GetVectorFromInputs(Vector* vector,int* doflist,const char* data);
 		void GetVectorFromInputs(Vector* vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not implemented yet");};
-		ElementResult* SpawnGradient(int step, double time);
+		void GetValuesPtr(IssmDouble** pvalues,int* pnum_values){_error2_("not implemented yet");};
+		ElementResult* SpawnGradient(int step, IssmDouble time);
 		void GetGradient(Vector* gradient_vec,int* doflist);
-		void ScaleGradient(double scale);
+		void ScaleGradient(IssmDouble scale);
 		void SetGradient(Input* gradient_in);
-		void UpdateValue(double scalar);
+		void UpdateValue(IssmDouble scalar);
 		void SaveValue(void);
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Inputs/DatasetInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DatasetInput.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/DatasetInput.cpp	(revision 12706)
@@ -2,5 +2,5 @@
  * \brief: implementation of the datasetinput object
  */
-/*Headers{{{1*/
+/*Headers{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -19,5 +19,5 @@
 
 /*DatasetInput constructors and destructor*/
-/*FUNCTION DatasetInput::DatasetInput(){{{1*/
+/*FUNCTION DatasetInput::DatasetInput(){{{*/
 DatasetInput::DatasetInput(){
 	enum_type=UNDEF;
@@ -25,5 +25,5 @@
 }
 /*}}}*/
-/*FUNCTION DatasetInput::DatasetInput(int in_enum_type) {{{1*/
+/*FUNCTION DatasetInput::DatasetInput(int in_enum_type) {{{*/
 DatasetInput::DatasetInput(int in_enum_type){
 
@@ -32,5 +32,5 @@
 }
 /*}}}*/
-/*FUNCTION DatasetInput::~DatasetInput(){{{1*/
+/*FUNCTION DatasetInput::~DatasetInput(){{{*/
 DatasetInput::~DatasetInput(){
 	delete inputs;
@@ -39,21 +39,21 @@
 
 /*Object virtual functions definitions:*/
-		/*FUNCTION DatasetInput::Echo {{{1*/
+		/*FUNCTION DatasetInput::Echo {{{*/
 void DatasetInput::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION DatasetInput::DeepEcho{{{1*/
+/*FUNCTION DatasetInput::DeepEcho{{{*/
 void DatasetInput::DeepEcho(void){
 
-	printf("DatasetInput:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("---inputs: \n"); inputs->Echo();
+	_printLine_("DatasetInput:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("---inputs: "); inputs->Echo();
 }
 /*}}}*/
-/*FUNCTION DatasetInput::Id{{{1*/
+/*FUNCTION DatasetInput::Id{{{*/
 int    DatasetInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DatasetInput::MyRank{{{1*/
+/*FUNCTION DatasetInput::MyRank{{{*/
 int    DatasetInput::MyRank(void){ 
 	extern int my_rank;
@@ -61,5 +61,5 @@
 }
 /*}}}*/
-/*FUNCTION DatasetInput::ObjectEnum{{{1*/
+/*FUNCTION DatasetInput::ObjectEnum{{{*/
 int DatasetInput::ObjectEnum(void){
 
@@ -68,5 +68,5 @@
 }
 /*}}}*/
-/*FUNCTION DatasetInput::copy{{{1*/
+/*FUNCTION DatasetInput::copy{{{*/
 Object* DatasetInput::copy() {
 	
@@ -80,5 +80,5 @@
 }
 /*}}}*/
-/*FUNCTION DatasetInput::SpawnTriaInput{{{1*/
+/*FUNCTION DatasetInput::SpawnTriaInput{{{*/
 Input* DatasetInput::SpawnTriaInput(int* indices){
 
@@ -97,5 +97,5 @@
 	
 /*DatasetInput management*/
-/*FUNCTION DatasetInput::InstanceEnum{{{1*/
+/*FUNCTION DatasetInput::InstanceEnum{{{*/
 int DatasetInput::InstanceEnum(void){
 
@@ -106,14 +106,14 @@
 
 /*Object functions*/
-/*FUNCTION DatasetInput::Configure{{{1*/
+/*FUNCTION DatasetInput::Configure{{{*/
 void DatasetInput::Configure(Parameters* parameters){
 	/*do nothing: */
 }
 /*}}}*/
-/*FUNCTION DatasetInput::GetInputValue(double* pvalue,GaussTria* gauss,int index){{{1*/
-void DatasetInput::GetInputValue(double* pvalue,GaussTria* gauss,int index){
+/*FUNCTION DatasetInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int index){{{*/
+void DatasetInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int index){
 
 	/*Get requested input within dataset*/
-	if(index<0 || index > inputs->Size()-1) _error_("index requested (%i) exceeds dataset size (%i)",index,inputs->Size());
+	if(index<0 || index > inputs->Size()-1) _error2_("index requested (" << index << ") exceeds dataset size (" << inputs->Size() << ")");
 	Input* input=(Input*)this->inputs->GetObjectByOffset(index);
 	
Index: /issm/trunk/src/c/objects/Inputs/DatasetInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DatasetInput.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/DatasetInput.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Input.h"
 #include "../../include/include.h"
@@ -21,10 +21,10 @@
 		Inputs*     inputs;
 
-		/*DatasetInput constructors, destructors: {{{1*/
+		/*DatasetInput constructors, destructors: {{{*/
 		DatasetInput();
 		DatasetInput(int enum_type);
 		~DatasetInput();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -34,57 +34,57 @@
 		Object* copy();
 		/*}}}*/
-		/*DatasetInput management: {{{1*/
+		/*DatasetInput management: {{{*/
 		int    InstanceEnum();
 		Input* SpawnTriaInput(int* indices);
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
-		ElementResult* SpawnResult(int step, double time){_error_("not implemented yet");};
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
+		Input* PointwiseMin(Input* inputB){_error2_("not implemented yet");};
+		Input* PointwiseMax(Input* inputB){_error2_("not implemented yet");};
+		ElementResult* SpawnResult(int step, IssmDouble time){_error2_("not implemented yet");};
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
 		void Configure(Parameters* parameters);
 		/*}}}*/
-		/*numeriics: {{{1*/
-		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
-		void GetInputValue(int* pvalue){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index);
-		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetInputAverage(double* pvalue){_error_("not implemented yet");};
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype){_error_("not implemented yet");};
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters){_error_("not implemented yet");};
-		void ConstrainMin(double minimum){_error_("not implemented yet");};
-		void Scale(double scale_factor){_error_("not implemented yet");};
-		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
-		void AXPY(Input* xinput,double scalar){_error_("not implemented yet");};
-		void Constrain(void){_error_("not implemented yet");};
-		void Constrain(double min,double max){_error_("not implemented yet");};
-		double InfinityNorm(void){_error_("not implemented yet");};
-		double Max(void){_error_("not implemented yet");};
-		double MaxAbs(void){_error_("not implemented yet");};
-		double Min(void){_error_("not implemented yet");};
-		double MinAbs(void){_error_("not implemented yet");};
-		void Extrude(void){_error_("not implemented yet");};
-		void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");};
-		void GetVectorFromInputs(Vector* vector,int* doflist){_error_("not implemented yet");};
-		void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not implemented yet");};
-		ElementResult* SpawnGradient(int step, double time){_error_("not implemented yet");};
-		void GetGradient(Vector* gradient_vec,int* doflist){_error_("not implemented yet");};
-		void ScaleGradient(double scale){_error_("not implemented yet");};
-		void SetGradient(Input* gradient_in){_error_("not implemented yet");};
-		void UpdateValue(double scalar){_error_("not implemented yet");};
-		void SaveValue(void){_error_("not implemented yet");};
+		/*numerics: {{{*/
+		void GetInputValue(bool* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(int* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index);
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue){_error2_("not implemented yet");};
+		void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void ChangeEnum(int newenumtype){_error2_("not implemented yet");};
+		void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){_error2_("not implemented yet");};
+		void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
+		void Scale(IssmDouble scale_factor){_error2_("not implemented yet");};
+		void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
+		void AXPY(Input* xinput,IssmDouble scalar){_error2_("not implemented yet");};
+		void Constrain(void){_error2_("not implemented yet");};
+		void Constrain(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
+		IssmDouble InfinityNorm(void){_error2_("not implemented yet");};
+		IssmDouble Max(void){_error2_("not implemented yet");};
+		IssmDouble MaxAbs(void){_error2_("not implemented yet");};
+		IssmDouble Min(void){_error2_("not implemented yet");};
+		IssmDouble MinAbs(void){_error2_("not implemented yet");};
+		void Extrude(void){_error2_("not implemented yet");};
+		void VerticallyIntegrate(Input* thickness_input){_error2_("not implemented yet");};
+		void GetVectorFromInputs(Vector* vector,int* doflist){_error2_("not implemented yet");};
+		void GetValuesPtr(IssmDouble** pvalues,int* pnum_values){_error2_("not implemented yet");};
+		ElementResult* SpawnGradient(int step, IssmDouble time){_error2_("not implemented yet");};
+		void GetGradient(Vector* gradient_vec,int* doflist){_error2_("not implemented yet");};
+		void ScaleGradient(IssmDouble scale){_error2_("not implemented yet");};
+		void SetGradient(Input* gradient_in){_error2_("not implemented yet");};
+		void UpdateValue(IssmDouble scalar){_error2_("not implemented yet");};
+		void SaveValue(void){_error2_("not implemented yet");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/DoubleInput.cpp	(revision 12706)
@@ -18,10 +18,10 @@
 
 /*DoubleInput constructors and destructor*/
-/*FUNCTION DoubleInput::DoubleInput(){{{1*/
+/*FUNCTION DoubleInput::DoubleInput(){{{*/
 DoubleInput::DoubleInput(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::DoubleInput(double value){{{1*/
+/*FUNCTION DoubleInput::DoubleInput(IssmDouble value){{{*/
 DoubleInput::DoubleInput(int in_enum_type,IssmDouble in_value){
 
@@ -30,5 +30,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::~DoubleInput(){{{1*/
+/*FUNCTION DoubleInput::~DoubleInput(){{{*/
 DoubleInput::~DoubleInput(){
 	return;
@@ -37,21 +37,21 @@
 
 /*Object virtual functions definitions:*/
-		/*FUNCTION DoubleInput::Echo {{{1*/
+		/*FUNCTION DoubleInput::Echo {{{*/
 void DoubleInput::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION DoubleInput::DeepEcho{{{1*/
+/*FUNCTION DoubleInput::DeepEcho{{{*/
 void DoubleInput::DeepEcho(void){
 
-	printf("DoubleInput:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %g\n",this->value);
-}
-/*}}}*/
-/*FUNCTION DoubleInput::Id{{{1*/
+	_printLine_("DoubleInput:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
+}
+/*}}}*/
+/*FUNCTION DoubleInput::Id{{{*/
 int    DoubleInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleInput::MyRank{{{1*/
+/*FUNCTION DoubleInput::MyRank{{{*/
 int    DoubleInput::MyRank(void){ 
 	extern int my_rank;
@@ -59,5 +59,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::ObjectEnum{{{1*/
+/*FUNCTION DoubleInput::ObjectEnum{{{*/
 int DoubleInput::ObjectEnum(void){
 
@@ -66,5 +66,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::copy{{{1*/
+/*FUNCTION DoubleInput::copy{{{*/
 Object* DoubleInput::copy() {
 	
@@ -75,5 +75,5 @@
 	
 /*DoubleInput management*/
-/*FUNCTION DoubleInput::InstanceEnum{{{1*/
+/*FUNCTION DoubleInput::InstanceEnum{{{*/
 int DoubleInput::InstanceEnum(void){
 
@@ -82,5 +82,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::SpawnTriaInput{{{1*/
+/*FUNCTION DoubleInput::SpawnTriaInput{{{*/
 Input* DoubleInput::SpawnTriaInput(int* indices){
 
@@ -97,6 +97,6 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::SpawnResult{{{1*/
-ElementResult* DoubleInput::SpawnResult(int step, double time){
+/*FUNCTION DoubleInput::SpawnResult{{{*/
+ElementResult* DoubleInput::SpawnResult(int step, IssmDouble time){
 
 	return new DoubleElementResult(this->enum_type,this->value,step,time);
@@ -106,18 +106,18 @@
 
 /*Object functions*/
-/*FUNCTION DoubleInput::GetInputValue(bool* pvalue) {{{1*/
+/*FUNCTION DoubleInput::GetInputValue(bool* pvalue) {{{*/
 void DoubleInput::GetInputValue(bool* pvalue){
-	_error_("Double input of enum %s cannot return a boolean",EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION DoubleInput::GetInputValue(int* pvalue){{{1*/
+	_error2_("Double input of enum " << EnumToStringx(enum_type) << " cannot return a boolean");
+
+}
+/*}}}*/
+/*FUNCTION DoubleInput::GetInputValue(int* pvalue){{{*/
 void DoubleInput::GetInputValue(int* pvalue){
-	_error_("Double input of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));
-
-}
-/*}}}*/
-/*FUNCTION DoubleInput::GetInputValue(double* pvalue){{{1*/
-void DoubleInput::GetInputValue(double* pvalue){
+	_error2_("Double input of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");
+
+}
+/*}}}*/
+/*FUNCTION DoubleInput::GetInputValue(IssmDouble* pvalue){{{*/
+void DoubleInput::GetInputValue(IssmDouble* pvalue){
 
 	/*return value*/
@@ -125,87 +125,87 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
-void DoubleInput::GetInputValue(double* pvalue,GaussTria* gauss){*pvalue=this->value;}
-/*}}}*/
-/*FUNCTION DoubleInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
-void DoubleInput::GetInputValue(double* pvalue,GaussPenta* gauss){*pvalue=this->value;}
-/*}}}*/
-/*FUNCTION DoubleInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
-void DoubleInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_(" not supported yet!");}
-/*}}}*/
-/*FUNCTION DoubleInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
-void DoubleInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_(" not supported yet!");}
-/*}}}*/
-/*FUNCTION DoubleInput::GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){{{1*/
-void DoubleInput::GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){
+/*FUNCTION DoubleInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
+void DoubleInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){*pvalue=this->value;}
+/*}}}*/
+/*FUNCTION DoubleInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
+void DoubleInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){*pvalue=this->value;}
+/*}}}*/
+/*FUNCTION DoubleInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
+void DoubleInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not supported yet!");}
+/*}}}*/
+/*FUNCTION DoubleInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void DoubleInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not supported yet!");}
+/*}}}*/
+/*FUNCTION DoubleInput::GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){{{*/
+void DoubleInput::GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){
 	/*Epsilon is zero as vx is constant over the element*/
 	for(int i=0;i<3;i++) epsilonvx[i]=0;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){{{1*/
-void DoubleInput::GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){
+/*FUNCTION DoubleInput::GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){{{*/
+void DoubleInput::GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){
 	/*Epsilon is zero as vy is constant over the element*/
 	for(int i=0;i<3;i++) epsilonvy[i]=0;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){{{1*/
-void DoubleInput::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION DoubleInput::GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void DoubleInput::GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Epsilon is zero as vx is constant over the element*/
 	for(int i=0;i<6;i++) epsilonvx[i]=0;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){{{1*/
-void DoubleInput::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION DoubleInput::GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void DoubleInput::GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Epsilon is zero as vy is constant over the element*/
 	for(int i=0;i<6;i++) epsilonvy[i]=0;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){{{1*/
-void DoubleInput::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION DoubleInput::GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void DoubleInput::GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Epsilon is zero as vz is constant over the element*/
 	for(int i=0;i<6;i++) epsilonvz[i]=0;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){{{1*/
-void DoubleInput::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION DoubleInput::GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void DoubleInput::GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Epsilon is zero as vx is constant over the element*/
 	for(int i=0;i<5;i++) epsilonvx[i]=0;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){{{1*/
-void DoubleInput::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION DoubleInput::GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void DoubleInput::GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
 	/*Epsilon is zero as vy is constant over the element*/
 	for(int i=0;i<5;i++) epsilonvy[i]=0;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::ChangeEnum{{{1*/
+/*FUNCTION DoubleInput::ChangeEnum{{{*/
 void DoubleInput::ChangeEnum(int newenumtype){
 	this->enum_type=newenumtype;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::SquareMin{{{1*/
-void DoubleInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
-
-	/*square min of a double is the square of the double itself: */
+/*FUNCTION DoubleInput::SquareMin{{{*/
+void DoubleInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
+
+	/*square min of a IssmDouble is the square of the IssmDouble itself: */
 	*psquaremin=pow(value,2);
 }
 /*}}}*/
-/*FUNCTION DoubleInput::Scale{{{1*/
-void DoubleInput::Scale(double scale_factor){
+/*FUNCTION DoubleInput::Scale{{{*/
+void DoubleInput::Scale(IssmDouble scale_factor){
 	value=value*scale_factor;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::ConstrainMin{{{1*/
-void DoubleInput::ConstrainMin(double minimum){
+/*FUNCTION DoubleInput::ConstrainMin{{{*/
+void DoubleInput::ConstrainMin(IssmDouble minimum){
 	if (value<minimum) value=minimum;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::AXPY{{{1*/
-void DoubleInput::AXPY(Input* xinput,double scalar){
-
-	DoubleInput*  xdoubleinput=NULL;
+/*FUNCTION DoubleInput::AXPY{{{*/
+void DoubleInput::AXPY(Input* xinput,IssmDouble scalar){
+
+	DoubleInput*  xIssmDoubleinput=NULL;
 
 	/*xinput is of the same type, so cast it: */
-	xdoubleinput=(DoubleInput*)xinput;
+	xIssmDoubleinput=(DoubleInput*)xinput;
 
 	/*Carry out the AXPY operation depending on type:*/
@@ -213,68 +213,68 @@
 
 		case DoubleInputEnum:
-			this->value=this->value+scalar*xdoubleinput->value;
+			this->value=this->value+scalar*xIssmDoubleinput->value;
 			return;
 
 		default:
-			_error_("not implemented yet");
+			_error2_("not implemented yet");
 	}
 
 }
 /*}}}*/
-/*FUNCTION DoubleInput::Constrain{{{1*/
-void DoubleInput::Constrain(double cm_min, double cm_max){
-
-	if(!isnan(cm_min)) if (this->value<cm_min)this->value=cm_min;
-	if(!isnan(cm_max)) if (this->value>cm_max)this->value=cm_max;
-
-}
-/*}}}*/
-/*FUNCTION DoubleInput::Max{{{1*/
-double DoubleInput::Max(void){
+/*FUNCTION DoubleInput::Constrain{{{*/
+void DoubleInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){
+
+	if(!xIsNan<IssmDouble>(cm_min)) if (this->value<cm_min)this->value=cm_min;
+	if(!xIsNan<IssmDouble>(cm_max)) if (this->value>cm_max)this->value=cm_max;
+
+}
+/*}}}*/
+/*FUNCTION DoubleInput::Max{{{*/
+IssmDouble DoubleInput::Max(void){
 	return this->value;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::MaxAbs{{{1*/
-double DoubleInput::MaxAbs(void){
+/*FUNCTION DoubleInput::MaxAbs{{{*/
+IssmDouble DoubleInput::MaxAbs(void){
 	return fabs(this->value);
 }
 /*}}}*/
-/*FUNCTION DoubleInput::Min{{{1*/
-double DoubleInput::Min(void){
+/*FUNCTION DoubleInput::Min{{{*/
+IssmDouble DoubleInput::Min(void){
 	return this->value;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::MinAbs{{{1*/
-double DoubleInput::MinAbs(void){
+/*FUNCTION DoubleInput::MinAbs{{{*/
+IssmDouble DoubleInput::MinAbs(void){
 	return fabs(this->value);
 }
 /*}}}*/
-/*FUNCTION DoubleInput::GetVectorFromInputs{{{1*/
+/*FUNCTION DoubleInput::GetVectorFromInputs{{{*/
 void DoubleInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
-	_error_(" not supporte yet!");
-
-}
-/*}}}*/
-/*FUNCTION DoubleInput::GetValuesPtr{{{1*/
-void DoubleInput::GetValuesPtr(double** pvalues,int* pnum_values){
-
-	_error_(" not supported yet!");
-
-}
-/*}}}*/
-/*FUNCTION DoubleInput::GetInputAverage{{{1*/
-void DoubleInput::GetInputAverage(double* pvalue){
+	_error2_("not supporte yet!");
+
+}
+/*}}}*/
+/*FUNCTION DoubleInput::GetValuesPtr{{{*/
+void DoubleInput::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
+
+	_error2_("not supported yet!");
+
+}
+/*}}}*/
+/*FUNCTION DoubleInput::GetInputAverage{{{*/
+void DoubleInput::GetInputAverage(IssmDouble* pvalue){
 	*pvalue=value;
 }
 /*}}}*/
-/*FUNCTION DoubleInput::VerticallyIntegrate{{{1*/
+/*FUNCTION DoubleInput::VerticallyIntegrate{{{*/
 void DoubleInput::VerticallyIntegrate(Input* thickness_input){
 
 	/*Intermediaries*/
-	double thickness_value;
+	IssmDouble thickness_value;
 
 	/*Check that input provided is a thickness*/
-	if (thickness_input->InstanceEnum()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is %s)",EnumToStringx(thickness_input->InstanceEnum()));
+	if (thickness_input->InstanceEnum()!=ThicknessEnum) _error2_("Input provided is not a Thickness (enum_type is " << EnumToStringx(thickness_input->InstanceEnum()) << ")");
 
 	/*vertically integrate depending on type:*/
@@ -287,9 +287,9 @@
 
 		default:
-			_error_("not implemented yet");
+			_error2_("not implemented yet");
 	}
 }
 /*}}}*/
-/*FUNCTION DoubleInput::PointwiseDivide{{{1*/
+/*FUNCTION DoubleInput::PointwiseDivide{{{*/
 Input* DoubleInput::PointwiseDivide(Input* inputB){
 
@@ -298,5 +298,5 @@
 
 	/*Intermediaries*/
-	double       Bvalue;
+	IssmDouble       Bvalue;
 
 	/*Check that inputB is of the same type*/
@@ -311,5 +311,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::PointwiseMin{{{1*/
+/*FUNCTION DoubleInput::PointwiseMin{{{*/
 Input* DoubleInput::PointwiseMin(Input* input){
 
@@ -318,5 +318,5 @@
 
 	/*Intermediaries*/
-	double       min;
+	IssmDouble       min;
 
 	/*Check that inputB is of the same type*/
@@ -332,5 +332,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::PointwiseMax{{{1*/
+/*FUNCTION DoubleInput::PointwiseMax{{{*/
 Input* DoubleInput::PointwiseMax(Input* input){
 
@@ -339,5 +339,5 @@
 
 	/*Intermediaries*/
-	double       max;
+	IssmDouble       max;
 
 	/*Check that inputB is of the same type*/
@@ -353,5 +353,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleInput::Configure{{{1*/
+/*FUNCTION DoubleInput::Configure{{{*/
 void DoubleInput::Configure(Parameters* parameters){
 	/*do nothing: */
Index: /issm/trunk/src/c/objects/Inputs/DoubleInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/DoubleInput.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/DoubleInput.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Input.h"
 #include "../../include/include.h"
@@ -18,12 +18,12 @@
 	public:
 		int    enum_type;
-		double value;
+		IssmDouble value;
 
-		/*DoubleInput constructors, destructors: {{{1*/
+		/*DoubleInput constructors, destructors: {{{*/
 		DoubleInput();
 		DoubleInput(int enum_type,IssmDouble value);
 		~DoubleInput();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -33,5 +33,5 @@
 		Object* copy();
 		/*}}}*/
-		/*DoubleInput management: {{{1*/
+		/*DoubleInput management: {{{*/
 		int   InstanceEnum();
 		Input* SpawnTriaInput(int* indices);
@@ -39,44 +39,44 @@
 		Input* PointwiseMin(Input* inputB);
 		Input* PointwiseMax(Input* inputB);
-		ElementResult* SpawnResult(int step, double time);
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		ElementResult* SpawnResult(int step, IssmDouble time);
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
 		void Configure(Parameters* parameters);
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void GetInputValue(bool* pvalue);
 		void GetInputValue(int* pvalue);
-		void GetInputValue(double* pvalue);
-		void GetInputValue(double* pvalue,GaussTria* gauss);
-		void GetInputValue(double* pvalue,GaussPenta* gauss);
-		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
-		void GetInputAverage(double* pvalue);
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss);
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss);
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss);
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
+		void GetInputValue(IssmDouble* pvalue);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss);
+		void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss);
+		void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss);
 		void ChangeEnum(int newenumtype);
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
-		void ConstrainMin(double minimum);
-		void Scale(double scale_factor);
-		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
-		void AXPY(Input* xinput,double scalar);
-		void Constrain(double cm_min, double cm_max);
-		double InfinityNorm(void){_error_("not implemented yet");};
-		double Max(void);
-		double MaxAbs(void);
-		double Min(void);
-		double MinAbs(void);
-		void Extrude(void){_error_("not supported yet");};
+		void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
+		void ConstrainMin(IssmDouble minimum);
+		void Scale(IssmDouble scale_factor);
+		void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		IssmDouble InfinityNorm(void){_error2_("not implemented yet");};
+		IssmDouble Max(void);
+		IssmDouble MaxAbs(void);
+		IssmDouble Min(void);
+		IssmDouble MinAbs(void);
+		void Extrude(void){_error2_("not supported yet");};
 		void VerticallyIntegrate(Input* thickness_input);
 		void GetVectorFromInputs(Vector* vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values);
+		void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Inputs/Input.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/Input.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/Input.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Object.h"
 class Node;
@@ -21,42 +21,43 @@
 		
 		virtual        ~Input(){};
+
 		virtual int  InstanceEnum()=0; 
 		virtual void GetInputValue(bool* pvalue)=0;
 		virtual void GetInputValue(int* pvalue)=0;
-		virtual void GetInputValue(double* pvalue)=0;
-		virtual void GetInputValue(double* pvalue,GaussTria* gauss)=0;
-		virtual void GetInputValue(double* pvalue,GaussPenta* gauss)=0;
-		virtual void GetInputValue(double* pvalue,GaussTria* gauss,double time)=0;
-		virtual void GetInputValue(double* pvalue,GaussPenta* gauss,double time)=0;
-		virtual void GetInputValue(double* pvalue,GaussTria* gauss ,int index)=0;
-		virtual void GetInputValue(double* pvalue,GaussPenta* gauss,int index)=0;
-		virtual void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss)=0;
-		virtual void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss)=0;
-		virtual void GetInputAverage(double* pvalue)=0;
-		virtual void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss)=0;
-		virtual void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss)=0;
-		virtual void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss)=0;
-		virtual void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss)=0;
-		virtual void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss)=0;
-		virtual void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss)=0;
-		virtual void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss)=0;
+		virtual void GetInputValue(IssmDouble* pvalue)=0;
+		virtual void GetInputValue(IssmDouble* pvalue,GaussTria* gauss)=0;
+		virtual void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss)=0;
+		virtual void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time)=0;
+		virtual void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time)=0;
+		virtual void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index)=0;
+		virtual void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,int index)=0;
+		virtual void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss)=0;
+		virtual void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss)=0;
+		virtual void GetInputAverage(IssmDouble* pvalue)=0;
+		virtual void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss)=0;
+		virtual void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss)=0;
+		virtual void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss)=0;
+		virtual void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss)=0;
+		virtual void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss)=0;
+		virtual void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss)=0;
+		virtual void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss)=0;
 		virtual void ChangeEnum(int newenumtype)=0;
 		virtual void Configure(Parameters* parameters)=0;
 
-		virtual void   SquareMin(double* psquaremin, bool process_units,Parameters* parameters)=0;
-		virtual void   ConstrainMin(double minimum)=0;
-		virtual double InfinityNorm(void)=0;
-		virtual double MaxAbs(void)=0;
-		virtual double MinAbs(void)=0;
-		virtual double Max(void)=0;
-		virtual double Min(void)=0;
-		virtual void   Scale(double scale_factor)=0;
-		virtual void   ArtificialNoise(double min,double max)=0;
-		virtual void   AXPY(Input* xinput,double scalar)=0;
-		virtual void   Constrain(double cm_min, double cm_max)=0;
+		virtual void   SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters)=0;
+		virtual void   ConstrainMin(IssmDouble minimum)=0;
+		virtual IssmDouble InfinityNorm(void)=0;
+		virtual IssmDouble MaxAbs(void)=0;
+		virtual IssmDouble MinAbs(void)=0;
+		virtual IssmDouble Max(void)=0;
+		virtual IssmDouble Min(void)=0;
+		virtual void   Scale(IssmDouble scale_factor)=0;
+		virtual void   ArtificialNoise(IssmDouble min,IssmDouble max)=0;
+		virtual void   AXPY(Input* xinput,IssmDouble scalar)=0;
+		virtual void   Constrain(IssmDouble cm_min, IssmDouble cm_max)=0;
 		virtual void   VerticallyIntegrate(Input* thickness_input)=0;
 		virtual void   Extrude()=0;
 		virtual void   GetVectorFromInputs(Vector* vector,int* doflist)=0;
-		virtual void   GetValuesPtr(double** pvalues,int* pnum_values)=0;
+		virtual void   GetValuesPtr(IssmDouble** pvalues,int* pnum_values)=0;
 		
 		virtual Input* SpawnTriaInput(int* indices)=0;
@@ -64,5 +65,5 @@
 		virtual Input* PointwiseMax(Input* inputmax)=0;
 		virtual Input* PointwiseMin(Input* inputmin)=0;
-		virtual ElementResult* SpawnResult(int step, double time)=0;
+		virtual ElementResult* SpawnResult(int step, IssmDouble time)=0;
 };
 #endif
Index: /issm/trunk/src/c/objects/Inputs/IntInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/IntInput.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/IntInput.cpp	(revision 12706)
@@ -18,10 +18,10 @@
 
 /*IntInput constructors and destructor*/
-/*FUNCTION IntInput::IntInput(){{{1*/
+/*FUNCTION IntInput::IntInput(){{{*/
 IntInput::IntInput(){
 	return;
 }
 /*}}}*/
-/*FUNCTION IntInput::IntInput(double* values){{{1*/
+/*FUNCTION IntInput::IntInput(IssmDouble* values){{{*/
 IntInput::IntInput(int in_enum_type,IssmInt in_value){
 
@@ -30,5 +30,5 @@
 }
 /*}}}*/
-/*FUNCTION IntInput::~IntInput(){{{1*/
+/*FUNCTION IntInput::~IntInput(){{{*/
 IntInput::~IntInput(){
 	return;
@@ -37,16 +37,16 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION IntInput::DeepEcho{{{1*/
+/*FUNCTION IntInput::DeepEcho{{{*/
 void IntInput::DeepEcho(void){
 
-	printf("IntInput:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %i\n",(int)this->value);
+	_printLine_("IntInput:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << (int)this->value);
 }
 /*}}}*/
-/*FUNCTION IntInput::Id{{{1*/
+/*FUNCTION IntInput::Id{{{*/
 int    IntInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntInput::MyRank{{{1*/
+/*FUNCTION IntInput::MyRank{{{*/
 int    IntInput::MyRank(void){ 
 	extern int my_rank;
@@ -54,5 +54,5 @@
 }
 /*}}}*/
-/*FUNCTION IntInput::ObjectEnum{{{1*/
+/*FUNCTION IntInput::ObjectEnum{{{*/
 int IntInput::ObjectEnum(void){
 
@@ -61,5 +61,5 @@
 }
 /*}}}*/
-/*FUNCTION IntInput::copy{{{1*/
+/*FUNCTION IntInput::copy{{{*/
 Object* IntInput::copy() {
 	
@@ -70,10 +70,10 @@
 
 /*IntInput management*/
-/*FUNCTION IntInput::Echo {{{1*/
+/*FUNCTION IntInput::Echo {{{*/
 void IntInput::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION IntInput::InstanceEnum{{{1*/
+/*FUNCTION IntInput::InstanceEnum{{{*/
 int IntInput::InstanceEnum(void){
 
@@ -82,5 +82,5 @@
 }
 /*}}}*/
-/*FUNCTION IntInput::SpawnTriaInput{{{1*/
+/*FUNCTION IntInput::SpawnTriaInput{{{*/
 Input* IntInput::SpawnTriaInput(int* indices){
 
@@ -96,8 +96,8 @@
 }
 /*}}}*/
-/*FUNCTION IntInput::SpawnResult{{{1*/
-ElementResult* IntInput::SpawnResult(int step, double time){
+/*FUNCTION IntInput::SpawnResult{{{*/
+ElementResult* IntInput::SpawnResult(int step, IssmDouble time){
 	
-	_error_(" not supported yet!");
+	_error2_("not supported yet!");
 
 }
@@ -105,51 +105,51 @@
 
 /*Object functions*/
-/*FUNCTION IntInput::GetInputValue(bool* pvalue) {{{1*/
-void IntInput::GetInputValue(bool* pvalue){_error_(" not supported yet!");}
+/*FUNCTION IntInput::GetInputValue(bool* pvalue) {{{*/
+void IntInput::GetInputValue(bool* pvalue){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION IntInput::GetInputValue(int* pvalue){{{1*/
+/*FUNCTION IntInput::GetInputValue(int* pvalue){{{*/
 void IntInput::GetInputValue(int* pvalue){
 	*pvalue=value;
 }
 /*}}}*/
-/*FUNCTION IntInput::GetInputValue(double* pvalue){{{1*/
-void IntInput::GetInputValue(double* pvalue){
-	_error_("IntInput cannot return a double in parallel");
+/*FUNCTION IntInput::GetInputValue(IssmDouble* pvalue){{{*/
+void IntInput::GetInputValue(IssmDouble* pvalue){
+	_error2_("IntInput cannot return a IssmDouble in parallel");
 }
 /*}}}*/
-/*FUNCTION IntInput::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
-void IntInput::GetInputValue(double* pvalue,GaussTria* gauss){_error_(" not supported yet!");}
+/*FUNCTION IntInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
+void IntInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION IntInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
-void IntInput::GetInputValue(double* pvalue,GaussPenta* gauss){_error_(" not supported yet!");}
+/*FUNCTION IntInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
+void IntInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION IntInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){{{1*/
-void IntInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_(" not supported yet!");}
+/*FUNCTION IntInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
+void IntInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION IntInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){{{1*/
-void IntInput::GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_(" not supported yet!");}
+/*FUNCTION IntInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void IntInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not supported yet!");}
 /*}}}*/
-/*FUNCTION IntInput::ChangeEnum{{{1*/
+/*FUNCTION IntInput::ChangeEnum{{{*/
 void IntInput::ChangeEnum(int newenumtype){
 	this->enum_type=newenumtype;
 }
 /*}}}*/
-/*FUNCTION IntInput::SquareMin{{{1*/
-void IntInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
+/*FUNCTION IntInput::SquareMin{{{*/
+void IntInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
 
 	/*square min of an integer is the square of the integer itself: */
-	*psquaremin=pow((double)value,2);
+	*psquaremin=pow((IssmDouble)value,2);
 }
 /*}}}*/
-/*FUNCTION IntInput::Scale{{{1*/
-void IntInput::Scale(double scale_factor){
-	double dvalue=(double)value*scale_factor;
-	value=(int)dvalue;
+/*FUNCTION IntInput::Scale{{{*/
+void IntInput::Scale(IssmDouble scale_factor){
+	IssmDouble dvalue=(IssmDouble)value*scale_factor;
+	value=reCast<int>(dvalue);
 }
 /*}}}*/
-/*FUNCTION IntInput::AXPY{{{1*/
-void IntInput::AXPY(Input* xinput,double scalar){
+/*FUNCTION IntInput::AXPY{{{*/
+void IntInput::AXPY(Input* xinput,IssmDouble scalar){
 
-	double dvalue;
+	IssmDouble dvalue;
 	IntInput*  xintinput=NULL;
 
@@ -161,37 +161,37 @@
 
 		case IntInputEnum:
-			dvalue=(double)this->value+scalar*(double)xintinput->value;
-			this->value=(int)dvalue;
+			dvalue=(IssmDouble)this->value+scalar*(IssmDouble)xintinput->value;
+			this->value=reCast<int>(dvalue);
 			return;
 
 		default:
-			_error_("not implemented yet");
+			_error2_("not implemented yet");
 	}
 
 }
 /*}}}*/
-/*FUNCTION IntInput::Constrain{{{1*/
-void IntInput::Constrain(double cm_min, double cm_max){
+/*FUNCTION IntInput::Constrain{{{*/
+void IntInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){
 
-	if(!isnan(cm_min)) if (this->value<cm_min)this->value=(int)cm_min;
-	if(!isnan(cm_max)) if (this->value>cm_max)this->value=(int)cm_max;
+	if(!xIsNan<IssmDouble>(cm_min)) if (this->value<cm_min)this->value=reCast<int>(cm_min);
+	if(!xIsNan<IssmDouble>(cm_max)) if (this->value>cm_max)this->value=reCast<int>(cm_max);
 
 }
 /*}}}*/
-/*FUNCTION IntInput::GetVectorFromInputs{{{1*/
+/*FUNCTION IntInput::GetVectorFromInputs{{{*/
 void IntInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
-	_error_(" not supporte yet!");
+	_error2_("not supporte yet!");
 
 }
 /*}}}*/
-/*FUNCTION IntInput::GetValuesPtr{{{1*/
-void IntInput::GetValuesPtr(double** pvalues,int* pnum_values){
+/*FUNCTION IntInput::GetValuesPtr{{{*/
+void IntInput::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
 
-	_error_(" not supported yet!");
+	_error2_("not supported yet!");
 
 }
 /*}}}*/
-/*FUNCTION IntInput::Configure{{{1*/
+/*FUNCTION IntInput::Configure{{{*/
 void IntInput::Configure(Parameters* parameters){
 	/*do nothing: */
Index: /issm/trunk/src/c/objects/Inputs/IntInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/IntInput.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/IntInput.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Input.h"
 #include "../../include/include.h"
@@ -21,10 +21,10 @@
 		IssmInt value;
 
-		/*IntInput constructors, destructors: {{{1*/
+		/*IntInput constructors, destructors: {{{*/
 		IntInput();
 		IntInput(int enum_type,IssmInt value);
 		~IntInput();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -34,50 +34,50 @@
 		Object* copy();
 		/*}}}*/
-		/*IntInput management: {{{1*/
+		/*IntInput management: {{{*/
 		int   InstanceEnum();
 		Input* SpawnTriaInput(int* indices);
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
-		ElementResult* SpawnResult(int step, double time);
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
+		Input* PointwiseMin(Input* inputB){_error2_("not implemented yet");};
+		Input* PointwiseMax(Input* inputB){_error2_("not implemented yet");};
+		ElementResult* SpawnResult(int step, IssmDouble time);
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
 		void Configure(Parameters* parameters);
 		/*}}}*/
-		/*numerics: {{{1*/
+		/*numerics: {{{*/
 		void GetInputValue(bool* pvalue);
 		void GetInputValue(int* pvalue);
-		void GetInputValue(double* pvalue);
-		void GetInputValue(double* pvalue,GaussTria* gauss);
-		void GetInputValue(double* pvalue,GaussPenta* gauss);
-		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
-		void GetInputAverage(double* pvalue){_error_("not implemented yet");};
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetInputAverage(IssmDouble* pvalue){_error2_("not implemented yet");};
+		void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
 		void ChangeEnum(int newenumtype);
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
-		void ConstrainMin(double minimum){_error_("not implemented yet");};
-		void Scale(double scale_factor);
-		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
-		void AXPY(Input* xinput,double scalar);
-		void Constrain(double cm_min, double cm_max);
-		double InfinityNorm(void){_error_("InfinityNorm not implemented for integers");};
-		double Max(void){_error_("Max not implemented for integers");};
-		double MaxAbs(void){_error_("Max not implemented for integers");};
-		double Min(void){_error_("Min not implemented for integers");};
-		double MinAbs(void){_error_("Min not implemented for integers");};
-		void Extrude(void){_error_("not supported yet");};
-		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
+		void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
+		void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
+		void Scale(IssmDouble scale_factor);
+		void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		IssmDouble InfinityNorm(void){_error2_("InfinityNorm not implemented for integers");};
+		IssmDouble Max(void){_error2_("Max not implemented for integers");};
+		IssmDouble MaxAbs(void){_error2_("Max not implemented for integers");};
+		IssmDouble Min(void){_error2_("Min not implemented for integers");};
+		IssmDouble MinAbs(void){_error2_("Min not implemented for integers");};
+		void Extrude(void){_error2_("not supported yet");};
+		void VerticallyIntegrate(Input* thickness_input){_error2_("not supported yet");};
 		void GetVectorFromInputs(Vector* vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values);
+		void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Inputs/PentaP1Input.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaP1Input.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/PentaP1Input.cpp	(revision 12706)
@@ -18,11 +18,11 @@
 
 /*PentaP1Input constructors and destructor*/
-/*FUNCTION PentaP1Input::PentaP1Input(){{{1*/
+/*FUNCTION PentaP1Input::PentaP1Input(){{{*/
 PentaP1Input::PentaP1Input(){
 	return;
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::PentaP1Input(int in_enum_type,double* values){{{1*/
-PentaP1Input::PentaP1Input(int in_enum_type,double* in_values)
+/*FUNCTION PentaP1Input::PentaP1Input(int in_enum_type,IssmDouble* values){{{*/
+PentaP1Input::PentaP1Input(int in_enum_type,IssmDouble* in_values)
 		:PentaRef(1)
 {
@@ -41,5 +41,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::~PentaP1Input(){{{1*/
+/*FUNCTION PentaP1Input::~PentaP1Input(){{{*/
 PentaP1Input::~PentaP1Input(){
 	return;
@@ -48,21 +48,21 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION PentaP1Input::Echo {{{1*/
+/*FUNCTION PentaP1Input::Echo {{{*/
 void PentaP1Input::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::DeepEcho{{{1*/
+/*FUNCTION PentaP1Input::DeepEcho{{{*/
 void PentaP1Input::DeepEcho(void){
 
-	printf("PentaP1Input:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
-}
-/*}}}*/
-/*FUNCTION PentaP1Input::Id{{{1*/
+	_printLine_("PentaP1Input:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << " " << this->values[3] << " " << this->values[4] << " " << this->values[5] << "]");
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Id{{{*/
 int    PentaP1Input::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION PentaP1Input::MyRank{{{1*/
+/*FUNCTION PentaP1Input::MyRank{{{*/
 int    PentaP1Input::MyRank(void){ 
 	extern int my_rank;
@@ -70,5 +70,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::ObjectEnum{{{1*/
+/*FUNCTION PentaP1Input::ObjectEnum{{{*/
 int PentaP1Input::ObjectEnum(void){
 
@@ -79,5 +79,5 @@
 	
 /*PentaP1Input management*/
-/*FUNCTION PentaP1Input::copy{{{1*/
+/*FUNCTION PentaP1Input::copy{{{*/
 Object* PentaP1Input::copy() {
 	
@@ -86,5 +86,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::InstanceEnum{{{1*/
+/*FUNCTION PentaP1Input::InstanceEnum{{{*/
 int PentaP1Input::InstanceEnum(void){
 
@@ -93,10 +93,10 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::SpawnTriaInput{{{1*/
+/*FUNCTION PentaP1Input::SpawnTriaInput{{{*/
 Input* PentaP1Input::SpawnTriaInput(int* indices){
 
 	/*output*/
 	TriaP1Input* outinput=NULL;
-	double newvalues[3];
+	IssmDouble newvalues[3];
 
 	/*Loop over the new indices*/
@@ -118,6 +118,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::SpawnResult{{{1*/
-ElementResult* PentaP1Input::SpawnResult(int step, double time){
+/*FUNCTION PentaP1Input::SpawnResult{{{*/
+ElementResult* PentaP1Input::SpawnResult(int step, IssmDouble time){
 
 	return new PentaP1ElementResult(this->enum_type,this->values,step,time);
@@ -127,6 +127,6 @@
 
 /*Object functions*/
-/*FUNCTION PentaP1Input::GetInputValue(double* pvalue,GaussPenta* gauss){{{1*/
-void PentaP1Input::GetInputValue(double* pvalue,GaussPenta* gauss){
+/*FUNCTION PentaP1Input::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
+void PentaP1Input::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){
 
 	/*Call PentaRef function*/
@@ -135,6 +135,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){{{1*/
-void PentaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
+void PentaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussPenta* gauss){
 
 	/*Call PentaRef function*/
@@ -142,13 +142,13 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::GetVxStrainRate3d{{{1*/
-void PentaP1Input::GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaP1Input::GetVxStrainRate3d{{{*/
+void PentaP1Input::GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
 	int i,j;
 
 	const int numnodes=6;
 	const int DOFVELOCITY=3;
-	double B[8][27];
-	double B_reduced[6][DOFVELOCITY*numnodes];
-	double velocity[numnodes][DOFVELOCITY];
+	IssmDouble B[8][27];
+	IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
+	IssmDouble velocity[numnodes][DOFVELOCITY];
 
 	/*Get B matrix: */
@@ -187,13 +187,13 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::GetVyStrainRate3d{{{1*/
-void PentaP1Input::GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaP1Input::GetVyStrainRate3d{{{*/
+void PentaP1Input::GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
 	int i,j;
 
 	const int numnodes=6;
 	const int DOFVELOCITY=3;
-	double B[8][27];
-	double B_reduced[6][DOFVELOCITY*numnodes];
-	double velocity[numnodes][DOFVELOCITY];
+	IssmDouble B[8][27];
+	IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
+	IssmDouble velocity[numnodes][DOFVELOCITY];
 
 	/*Get B matrix: */
@@ -232,13 +232,13 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::GetVzStrainRate3d{{{1*/
-void PentaP1Input::GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){
+/*FUNCTION PentaP1Input::GetVzStrainRate3d{{{*/
+void PentaP1Input::GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){
 	int i,j;
 
 	const int numnodes=6;
 	const int DOFVELOCITY=3;
-	double B[8][27];
-	double B_reduced[6][DOFVELOCITY*numnodes];
-	double velocity[numnodes][DOFVELOCITY];
+	IssmDouble B[8][27];
+	IssmDouble B_reduced[6][DOFVELOCITY*numnodes];
+	IssmDouble velocity[numnodes][DOFVELOCITY];
 
 	/*Get B matrix: */
@@ -278,11 +278,11 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::GetVxStrainRate3dPattyn{{{1*/
-void PentaP1Input::GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){
-
-	int i;
-	const int numnodes=6;
-	double B[5][NDOF2*numnodes];
-	double velocity[numnodes][NDOF2];
+/*FUNCTION PentaP1Input::GetVxStrainRate3dPattyn{{{*/
+void PentaP1Input::GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){
+
+	int i;
+	const int numnodes=6;
+	IssmDouble B[5][NDOF2*numnodes];
+	IssmDouble velocity[numnodes][NDOF2];
 
 	/*Get B matrix: */
@@ -302,11 +302,11 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::GetVyStrainRate3dPattyn{{{1*/
-void PentaP1Input::GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){
-
-	int i;
-	const int numnodes=6;
-	double B[5][NDOF2*numnodes];
-	double velocity[numnodes][NDOF2];
+/*FUNCTION PentaP1Input::GetVyStrainRate3dPattyn{{{*/
+void PentaP1Input::GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){
+
+	int i;
+	const int numnodes=6;
+	IssmDouble B[5][NDOF2*numnodes];
+	IssmDouble velocity[numnodes][NDOF2];
 
 	/*Get B matrix: */
@@ -326,11 +326,11 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::ChangeEnum{{{1*/
+/*FUNCTION PentaP1Input::ChangeEnum{{{*/
 void PentaP1Input::ChangeEnum(int newenumtype){
 	this->enum_type=newenumtype;
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::GetInputAverage{{{1*/
-void PentaP1Input::GetInputAverage(double* pvalue){
+/*FUNCTION PentaP1Input::GetInputAverage{{{*/
+void PentaP1Input::GetInputAverage(IssmDouble* pvalue){
 	*pvalue=1./6.*(values[0]+values[1]+values[2]+values[3]+values[4]+values[5]);
 }
@@ -338,11 +338,11 @@
 
 /*Intermediary*/
-/*FUNCTION PentaP1Input::SquareMin{{{1*/
-void PentaP1Input::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
-
-	int i;
-	const int numnodes=6;
-	double valuescopy[numnodes];
-	double squaremin;
+/*FUNCTION PentaP1Input::SquareMin{{{*/
+void PentaP1Input::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
+
+	int i;
+	const int numnodes=6;
+	IssmDouble valuescopy[numnodes];
+	IssmDouble squaremin;
 
 	/*First,  copy values, to process units if requested: */
@@ -361,6 +361,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::ConstrainMin{{{1*/
-void PentaP1Input::ConstrainMin(double minimum){
+/*FUNCTION PentaP1Input::ConstrainMin{{{*/
+void PentaP1Input::ConstrainMin(IssmDouble minimum){
 	
 	int i;
@@ -370,10 +370,10 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::InfinityNorm{{{1*/
-double PentaP1Input::InfinityNorm(void){
+/*FUNCTION PentaP1Input::InfinityNorm{{{*/
+IssmDouble PentaP1Input::InfinityNorm(void){
 
 	/*Output*/
 	const int numnodes=6;
-	double norm=0;
+	IssmDouble norm=0;
 
 	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
@@ -381,9 +381,9 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::Max{{{1*/
-double PentaP1Input::Max(void){
-
-	const int numnodes=6;
-	double    max=values[0];
+/*FUNCTION PentaP1Input::Max{{{*/
+IssmDouble PentaP1Input::Max(void){
+
+	const int numnodes=6;
+	IssmDouble    max=values[0];
 
 	for(int i=1;i<numnodes;i++){
@@ -393,9 +393,9 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::MaxAbs{{{1*/
-double PentaP1Input::MaxAbs(void){
-
-	const int numnodes=6;
-	double    max=fabs(values[0]);
+/*FUNCTION PentaP1Input::MaxAbs{{{*/
+IssmDouble PentaP1Input::MaxAbs(void){
+
+	const int numnodes=6;
+	IssmDouble    max=fabs(values[0]);
 
 	for(int i=1;i<numnodes;i++){
@@ -405,9 +405,9 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::Min{{{1*/
-double PentaP1Input::Min(void){
-
-	const int numnodes=6;
-	double    min=values[0];
+/*FUNCTION PentaP1Input::Min{{{*/
+IssmDouble PentaP1Input::Min(void){
+
+	const int numnodes=6;
+	IssmDouble    min=values[0];
 
 	for(int i=1;i<numnodes;i++){
@@ -417,9 +417,9 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::MinAbs{{{1*/
-double PentaP1Input::MinAbs(void){
-
-	const int numnodes=6;
-	double    min=fabs(values[0]);
+/*FUNCTION PentaP1Input::MinAbs{{{*/
+IssmDouble PentaP1Input::MinAbs(void){
+
+	const int numnodes=6;
+	IssmDouble    min=fabs(values[0]);
 
 	for(int i=1;i<numnodes;i++){
@@ -429,6 +429,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::Scale{{{1*/
-void PentaP1Input::Scale(double scale_factor){
+/*FUNCTION PentaP1Input::Scale{{{*/
+void PentaP1Input::Scale(IssmDouble scale_factor){
 	
 	int i;
@@ -438,6 +438,6 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::AXPY{{{1*/
-void PentaP1Input::AXPY(Input* xinput,double scalar){
+/*FUNCTION PentaP1Input::AXPY{{{*/
+void PentaP1Input::AXPY(Input* xinput,IssmDouble scalar){
 
 	int i;
@@ -455,26 +455,26 @@
 		case ControlInputEnum:{
 			ControlInput* cont_input=(ControlInput*)xinput;
-			if(cont_input->values->ObjectEnum()!=PentaP1InputEnum) _error_("not supported yet");
+			if(cont_input->values->ObjectEnum()!=PentaP1InputEnum) _error2_("not supported yet");
 			PentaP1Input* cast_input=(PentaP1Input*)cont_input->values;
 			for(i=0;i<numnodes;i++)this->values[i]=this->values[i]+scalar*(cast_input->values[i]);}
 			return;
 		default:
-			_error_("not implemented yet");
-	}
-
-}
-/*}}}*/
-/*FUNCTION PentaP1Input::Constrain{{{1*/
-void PentaP1Input::Constrain(double cm_min, double cm_max){
+			_error2_("not implemented yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Constrain{{{*/
+void PentaP1Input::Constrain(IssmDouble cm_min, IssmDouble cm_max){
 
 	int i;
 	const int numnodes=6;
 		
-	if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
-	if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
-
-}
-/*}}}*/
-/*FUNCTION PentaP1Input::Extrude{{{1*/
+	if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
+	if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
+
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::Extrude{{{*/
 void PentaP1Input::Extrude(void){
 
@@ -485,5 +485,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::VerticallyIntegrate{{{1*/
+/*FUNCTION PentaP1Input::VerticallyIntegrate{{{*/
 void PentaP1Input::VerticallyIntegrate(Input* thickness_input){
 
@@ -492,8 +492,8 @@
 	const int  numnodes = 6;
 	int        num_thickness_values;
-	double    *thickness_values = NULL;
+	IssmDouble    *thickness_values = NULL;
 
 	/*Check that input provided is a thickness*/
-	if (thickness_input->InstanceEnum()!=ThicknessEnum) _error_("Input provided is not a Thickness (enum_type is %s)",EnumToStringx(thickness_input->InstanceEnum()));
+	if (thickness_input->InstanceEnum()!=ThicknessEnum) _error2_("Input provided is not a Thickness (enum_type is " << EnumToStringx(thickness_input->InstanceEnum()) << ")");
 
 	/*Get Thickness value pointer*/
@@ -511,9 +511,9 @@
 
 		default:
-			_error_("not implemented yet");
-	}
-}
-/*}}}*/
-/*FUNCTION PentaP1Input::PointwiseDivide{{{1*/
+			_error2_("not implemented yet");
+	}
+}
+/*}}}*/
+/*FUNCTION PentaP1Input::PointwiseDivide{{{*/
 Input* PentaP1Input::PointwiseDivide(Input* inputB){
 
@@ -526,8 +526,8 @@
 	int               B_numvalues;
 	const int         numnodes    = 6;
-	double            AdotBvalues[numnodes];
+	IssmDouble            AdotBvalues[numnodes];
 
 	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
 	xinputB=(PentaP1Input*)inputB;
 
@@ -546,5 +546,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::PointwiseMin{{{1*/
+/*FUNCTION PentaP1Input::PointwiseMin{{{*/
 Input* PentaP1Input::PointwiseMin(Input* inputB){
 
@@ -557,8 +557,8 @@
 	int               B_numvalues;
 	const int         numnodes    = 6;
-	double            minvalues[numnodes];
+	IssmDouble            minvalues[numnodes];
 
 	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
 	xinputB=(PentaP1Input*)inputB;
 
@@ -577,5 +577,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::PointwiseMax{{{1*/
+/*FUNCTION PentaP1Input::PointwiseMax{{{*/
 Input* PentaP1Input::PointwiseMax(Input* inputB){
 
@@ -588,8 +588,8 @@
 	int               B_numvalues;
 	const int         numnodes    = 6;
-	double            maxvalues[numnodes];
+	IssmDouble            maxvalues[numnodes];
 
 	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
 	xinputB=(PentaP1Input*)inputB;
 
@@ -608,5 +608,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::GetVectorFromInputs{{{1*/
+/*FUNCTION PentaP1Input::GetVectorFromInputs{{{*/
 void PentaP1Input::GetVectorFromInputs(Vector* vector,int* doflist){
 
@@ -615,6 +615,6 @@
 
 } /*}}}*/
-/*FUNCTION PentaP1Input::GetValuesPtr{{{1*/
-void PentaP1Input::GetValuesPtr(double** pvalues,int* pnum_values){
+/*FUNCTION PentaP1Input::GetValuesPtr{{{*/
+void PentaP1Input::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
 
 	*pvalues=this->values;
@@ -623,5 +623,5 @@
 }
 /*}}}*/
-/*FUNCTION PentaP1Input::Configure{{{1*/
+/*FUNCTION PentaP1Input::Configure{{{*/
 void PentaP1Input::Configure(Parameters* parameters){
 	/*do nothing: */
Index: /issm/trunk/src/c/objects/Inputs/PentaP1Input.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/PentaP1Input.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/PentaP1Input.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Input.h"
 #include "../Elements/PentaRef.h"
@@ -19,12 +19,12 @@
 		/*just hold 6 values for 6 vertices: */
 		int    enum_type;
-		double values[6];
+		IssmDouble values[6];
 
-		/*PentaP1Input constructors, destructors: {{{1*/
+		/*PentaP1Input constructors, destructors: {{{*/
 		PentaP1Input();
-		PentaP1Input(int enum_type,double* values);
+		PentaP1Input(int enum_type,IssmDouble* values);
 		~PentaP1Input();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -34,5 +34,5 @@
 		Object* copy();
 		/*}}}*/
-		/*PentaP1Input management: {{{1*/
+		/*PentaP1Input management: {{{*/
 		int   InstanceEnum();
 		Input* SpawnTriaInput(int* indices);
@@ -40,45 +40,45 @@
 		Input* PointwiseMin(Input* inputB);
 		Input* PointwiseMax(Input* inputB);
-		ElementResult* SpawnResult(int step, double time);
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		ElementResult* SpawnResult(int step, IssmDouble time);
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
 		void Configure(Parameters* parameters);
 		/*}}}*/
-		/*numerics: {{{1*/
-		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
-		void GetInputValue(int* pvalue){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss);
-		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss);
-		void GetInputAverage(double* pvalue);
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss);
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss);
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss);
+		/*numerics: {{{*/
+		void GetInputValue(bool* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(int* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss);
+		void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss);
 		void ChangeEnum(int newenumtype);
 
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
-		void ConstrainMin(double minimum);
-		void Scale(double scale_factor);
-		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
-		void AXPY(Input* xinput,double scalar);
-		void Constrain(double cm_min, double cm_max);
-		double InfinityNorm(void);
-		double Max(void);
-		double MaxAbs(void);
-		double Min(void);
-		double MinAbs(void);
+		void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
+		void ConstrainMin(IssmDouble minimum);
+		void Scale(IssmDouble scale_factor);
+		void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		IssmDouble InfinityNorm(void);
+		IssmDouble Max(void);
+		IssmDouble MaxAbs(void);
+		IssmDouble Min(void);
+		IssmDouble MinAbs(void);
 		void Extrude(void);
 		void VerticallyIntegrate(Input* thickness_input);
 		void GetVectorFromInputs(Vector* vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values);
+		void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Inputs/TransientInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TransientInput.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/TransientInput.cpp	(revision 12706)
@@ -46,5 +46,5 @@
 /*FUNCTION TransientInput::~TransientInput{{{*/
 TransientInput::~TransientInput(){
-	xfree((void**)&this->timesteps);
+	xDelete<IssmDouble>(this->timesteps);
 	this->timesteps=NULL;
 	this->numtimesteps=0;
@@ -66,10 +66,10 @@
 	int i;
 
-	printf("TransientInput:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   numtimesteps: %i\n",this->numtimesteps);
-	printf("---inputs: \n"); 
+	_printLine_("TransientInput:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   numtimesteps: " << this->numtimesteps);
+	_printLine_("---inputs: "); 
 	for(i=0;i<this->numtimesteps;i++){
-		printf("   time: %g  \n",this->timesteps[i]);
+		_printLine_("   time: " << this->timesteps[i] << "  ");
 		((Input*)this->inputs->GetObjectByOffset(i))->Echo();
 	}
@@ -100,6 +100,6 @@
 	output->enum_type=this->enum_type;
 	output->numtimesteps=this->numtimesteps;
-	output->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
-   memcpy(output->timesteps,this->timesteps,this->numtimesteps*sizeof(double));
+	output->timesteps=xNew<IssmDouble>(this->numtimesteps);
+   memcpy(output->timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble));
 	output->inputs=(Inputs*)this->inputs->Copy();
 	output->parameters=this->parameters;
@@ -128,6 +128,6 @@
 	outinput->enum_type=this->enum_type;
 	outinput->numtimesteps=this->numtimesteps;
-	outinput->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
-	memcpy(outinput->timesteps,this->timesteps,this->numtimesteps*sizeof(double));
+	outinput->timesteps=xNew<IssmDouble>(this->numtimesteps);
+	memcpy(outinput->timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble));
 	outinput->inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices);
 	outinput->parameters=this->parameters;
@@ -139,5 +139,5 @@
 /*}}}*/
 /*FUNCTION TransientInput::SpawnResult{{{*/
-ElementResult* TransientInput::SpawnResult(int step, double time){
+ElementResult* TransientInput::SpawnResult(int step, IssmDouble time){
 
 	ElementResult* elementresult=NULL;
@@ -156,7 +156,7 @@
 
 /*Object functions*/
-/*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussTria* gauss){{{*/
-void TransientInput::GetInputValue(double* pvalue,GaussTria* gauss){
-	double time;
+/*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
+void TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){
+	IssmDouble time;
 
 	/*First, recover current time from parameters: */
@@ -172,7 +172,7 @@
 }
 /*}}}*/
-/*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussPenta* gauss){{{*/
-void TransientInput::GetInputValue(double* pvalue,GaussPenta* gauss){
-	double time;
+/*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
+void TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){
+	IssmDouble time;
 
 	/*First, recover current time from parameters: */
@@ -188,6 +188,6 @@
 }
 /*}}}*/
-/*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussTria* gauss,double time){{{*/
-void TransientInput::GetInputValue(double* pvalue,GaussTria* gauss,double time){
+/*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){{{*/
+void TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){
 
 	/*Retrieve interpolated values for this time step: */
@@ -200,6 +200,6 @@
 }
 /*}}}*/
-/*FUNCTION TransientInput::GetInputValue(double* pvalue,GaussPenta* gauss,double time){{{*/
-void TransientInput::GetInputValue(double* pvalue,GaussPenta* gauss,double time){
+/*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){{{*/
+void TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){
 
 	/*Retrieve interpolated values for this time step: */
@@ -212,8 +212,8 @@
 }
 /*}}}*/
-/*FUNCTION TransientInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){{{*/
-void TransientInput::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){
-
-	double time;
+/*FUNCTION TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){{{*/
+void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){
+
+	IssmDouble time;
 
 	/*First, recover current time from parameters: */
@@ -236,7 +236,7 @@
 /*}}}*/
 /*FUNCTION TransientInput::GetInputAverage{{{*/
-void TransientInput::GetInputAverage(double* pvalue){
+void TransientInput::GetInputAverage(IssmDouble* pvalue){
 	
-	double time;
+	IssmDouble time;
 
 	/*First, recover current time from parameters: */
@@ -256,5 +256,5 @@
 /*Intermediary*/
 /*FUNCTION TransientInput::AddTimeInput{{{*/
-void TransientInput::AddTimeInput(Input* input,double time){
+void TransientInput::AddTimeInput(Input* input,IssmDouble time){
 
 	/*insert values at time step: */
@@ -262,18 +262,18 @@
 
 	//copy timesteps, add the new time, delete previous timesteps, and add the new input: inputs->AddObject(input);
-	double* old_timesteps=NULL;
+	IssmDouble* old_timesteps=NULL;
 
 	if (this->numtimesteps > 0){
-		old_timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
-		memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(double));
-		xfree((void**)&this->timesteps); 
+		old_timesteps=xNew<IssmDouble>(this->numtimesteps);
+		memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble));
+		xDelete<IssmDouble>(this->timesteps); 
 	}
 
 	this->numtimesteps=this->numtimesteps+1;
-	this->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
+	this->timesteps=xNew<IssmDouble>(this->numtimesteps);
 
 	if (this->numtimesteps > 1){
-		memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(double));
-		xfree((void**)&old_timesteps);
+		memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(IssmDouble));
+		xDelete<IssmDouble>(old_timesteps);
 	}
 
@@ -285,7 +285,7 @@
 /*}}}*/
 /*FUNCTION TransientInput::SquareMin{{{*/
-void TransientInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
-
-	double time;
+void TransientInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
+
+	IssmDouble time;
 
 	/*First, recover current time from parameters: */
@@ -303,8 +303,8 @@
 /*}}}*/
 /*FUNCTION TransientInput::InfinityNorm{{{*/
-double TransientInput::InfinityNorm(void){
-
-	double time;
-	double infnorm;
+IssmDouble TransientInput::InfinityNorm(void){
+
+	IssmDouble time;
+	IssmDouble infnorm;
 
 	/*First, recover current time from parameters: */
@@ -323,8 +323,8 @@
 /*}}}*/
 /*FUNCTION TransientInput::Max{{{*/
-double TransientInput::Max(void){
-
-	double time;
-	double max;
+IssmDouble TransientInput::Max(void){
+
+	IssmDouble time;
+	IssmDouble max;
 
 	/*First, recover current time from parameters: */
@@ -343,8 +343,8 @@
 /*}}}*/
 /*FUNCTION TransientInput::MaxAbs{{{*/
-double TransientInput::MaxAbs(void){
-
-	double time;
-	double maxabs;
+IssmDouble TransientInput::MaxAbs(void){
+
+	IssmDouble time;
+	IssmDouble maxabs;
 
 	/*First, recover current time from parameters: */
@@ -364,8 +364,8 @@
 /*}}}*/
 /*FUNCTION TransientInput::Min{{{*/
-double TransientInput::Min(void){
-
-	double time;
-	double min;
+IssmDouble TransientInput::Min(void){
+
+	IssmDouble time;
+	IssmDouble min;
 
 	/*First, recover current time from parameters: */
@@ -385,8 +385,8 @@
 /*}}}*/
 /*FUNCTION TransientInput::MinAbs{{{*/
-double TransientInput::MinAbs(void){
-
-	double time;
-	double minabs;
+IssmDouble TransientInput::MinAbs(void){
+
+	IssmDouble time;
+	IssmDouble minabs;
 
 	/*First, recover current time from parameters: */
@@ -407,5 +407,5 @@
 void TransientInput::GetVectorFromInputs(Vector* vector,int* doflist){
 
-	double time;
+	IssmDouble time;
 
 	/*First, recover current time from parameters: */
@@ -422,9 +422,9 @@
 } /*}}}*/
 /*FUNCTION TransientInput::GetTimeInput{{{*/
-Input* TransientInput::GetTimeInput(double intime){
+Input* TransientInput::GetTimeInput(IssmDouble intime){
 
 	int     i,j;
-	double  deltat;
-	double  alpha1,alpha2;
+	IssmDouble  deltat;
+	IssmDouble  alpha1,alpha2;
 	bool    found=false;
 	Input*  input=NULL;
@@ -474,5 +474,5 @@
 		}
 	}
-	if(!found)_error_("did not find time interval on which to interpolate forcing values!");
+	if(!found)_error2_("did not find time interval on which to interpolate forcing values!");
 
 	/*Assign output pointer*/
Index: /issm/trunk/src/c/objects/Inputs/TransientInput.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TransientInput.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/TransientInput.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Input.h"
 class GaussTria;
@@ -20,14 +20,14 @@
 		int     numtimesteps;
 		Inputs* inputs;
-		double* timesteps;
+		IssmDouble* timesteps;
 		Parameters* parameters; //to find current time.
 
-		/*TransientInput constructors, destructors: {{{1*/
+		/*TransientInput constructors, destructors: {{{*/
 		TransientInput();
 		TransientInput(int enum_type);
 		~TransientInput();
-		void AddTimeInput(Input* input,double time);
+		void AddTimeInput(Input* input,IssmDouble time);
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -37,52 +37,52 @@
 		Object* copy();
 		/*}}}*/
-		/*TransientInput management: {{{1*/
+		/*TransientInput management: {{{*/
 		int    InstanceEnum();
 		Input* SpawnTriaInput(int* indices);
-		Input* PointwiseDivide(Input* forcingB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* forcingB){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* forcingB){_error_("not implemented yet");};
-		ElementResult* SpawnResult(int step, double time);
+		Input* PointwiseDivide(Input* forcingB){_error2_("not implemented yet");};
+		Input* PointwiseMin(Input* forcingB){_error2_("not implemented yet");};
+		Input* PointwiseMax(Input* forcingB){_error2_("not implemented yet");};
+		ElementResult* SpawnResult(int step, IssmDouble time);
 		void Configure(Parameters* parameters);
 		/*}}}*/
-		/*numerics: {{{1*/
-		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
-		void GetInputValue(int* pvalue){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss);
-		void GetInputValue(double* pvalue,GaussPenta* gauss);
-		void GetInputValue(double* pvalue,GaussTria* gauss,double time);
-		void GetInputValue(double* pvalue,GaussPenta* gauss,double time);
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetInputAverage(double* pvalue);
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		/*numerics: {{{*/
+		void GetInputValue(bool* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(int* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time);
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
 		void ChangeEnum(int newenumtype);
 
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
-		void ConstrainMin(double minimum){_error_("not implemented yet");};
-		void Scale(double scale_factor){_error_("not implemented yet");};
-		void ArtificialNoise(double min,double max){_error_("not implemented yet");};
-		void AXPY(Input* xforcing,double scalar){_error_("not implemented yet");};
-		void Constrain(double cm_min, double cm_max){_error_("not implemented yet");};
-		double InfinityNorm(void);
-		double Max(void);
-		double MaxAbs(void);
-		double Min(void);
-		double MinAbs(void);
-		void Extrude(void){_error_("not supported yet");}
-		void VerticallyIntegrate(Input* thickness_forcing){_error_("not supported yet");};
+		void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
+		void ConstrainMin(IssmDouble minimum){_error2_("not implemented yet");};
+		void Scale(IssmDouble scale_factor){_error2_("not implemented yet");};
+		void ArtificialNoise(IssmDouble min,IssmDouble max){_error2_("not implemented yet");};
+		void AXPY(Input* xforcing,IssmDouble scalar){_error2_("not implemented yet");};
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error2_("not implemented yet");};
+		IssmDouble InfinityNorm(void);
+		IssmDouble Max(void);
+		IssmDouble MaxAbs(void);
+		IssmDouble Min(void);
+		IssmDouble MinAbs(void);
+		void Extrude(void){_error2_("not supported yet");}
+		void VerticallyIntegrate(Input* thickness_forcing){_error2_("not supported yet");};
 		void GetVectorFromInputs(Vector* vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values){_error_("not supported yet");};
-      void GetTimeValues(double* values,double time){_error_("not implemented yet");};
-		Input* GetTimeInput(double time);
+		void GetValuesPtr(IssmDouble** pvalues,int* pnum_values){_error2_("not supported yet");};
+      void GetTimeValues(IssmDouble* values,IssmDouble time){_error2_("not implemented yet");};
+		Input* GetTimeInput(IssmDouble time);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Inputs/TriaP1Input.cpp
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaP1Input.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/TriaP1Input.cpp	(revision 12706)
@@ -18,11 +18,11 @@
 
 /*TriaP1Input constructors and destructor*/
-/*FUNCTION TriaP1Input::TriaP1Input(){{{1*/
+/*FUNCTION TriaP1Input::TriaP1Input(){{{*/
 TriaP1Input::TriaP1Input(){
 	return;
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::TriaP1Input(int in_enum_type,double* values){{{1*/
-TriaP1Input::TriaP1Input(int in_enum_type,double* in_values)
+/*FUNCTION TriaP1Input::TriaP1Input(int in_enum_type,IssmDouble* values){{{*/
+TriaP1Input::TriaP1Input(int in_enum_type,IssmDouble* in_values)
 	:TriaRef(1)
 {
@@ -41,5 +41,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::~TriaP1Input(){{{1*/
+/*FUNCTION TriaP1Input::~TriaP1Input(){{{*/
 TriaP1Input::~TriaP1Input(){
 	return;
@@ -48,21 +48,21 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION TriaP1Input::Echo {{{1*/
+/*FUNCTION TriaP1Input::Echo {{{*/
 void TriaP1Input::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::DeepEcho{{{1*/
+/*FUNCTION TriaP1Input::DeepEcho{{{*/
 void TriaP1Input::DeepEcho(void){
 
-	printf("TriaP1Input:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   values: [%g %g %g]\n",this->values[0],this->values[1],this->values[2]);
-}
-/*}}}*/
-/*FUNCTION TriaP1Input::Id{{{1*/
+	_printLine_("TriaP1Input:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << "]");
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Id{{{*/
 int    TriaP1Input::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION TriaP1Input::MyRank{{{1*/
+/*FUNCTION TriaP1Input::MyRank{{{*/
 int    TriaP1Input::MyRank(void){ 
 	extern int my_rank;
@@ -70,5 +70,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::ObjectEnum{{{1*/
+/*FUNCTION TriaP1Input::ObjectEnum{{{*/
 int TriaP1Input::ObjectEnum(void){
 
@@ -77,5 +77,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::copy{{{1*/
+/*FUNCTION TriaP1Input::copy{{{*/
 Object* TriaP1Input::copy() {
 	
@@ -86,5 +86,5 @@
 	
 /*TriaP1Input management*/
-/*FUNCTION TriaP1Input::InstanceEnum{{{1*/
+/*FUNCTION TriaP1Input::InstanceEnum{{{*/
 int TriaP1Input::InstanceEnum(void){
 
@@ -93,5 +93,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::SpawnTriaInput{{{1*/
+/*FUNCTION TriaP1Input::SpawnTriaInput{{{*/
 Input* TriaP1Input::SpawnTriaInput(int* indices){
 
@@ -107,6 +107,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::SpawnResult{{{1*/
-ElementResult* TriaP1Input::SpawnResult(int step, double time){
+/*FUNCTION TriaP1Input::SpawnResult{{{*/
+ElementResult* TriaP1Input::SpawnResult(int step, IssmDouble time){
 
 	return new TriaP1ElementResult(this->enum_type,this->values,step,time);
@@ -116,6 +116,6 @@
 
 /*Object functions*/
-/*FUNCTION TriaP1Input::GetInputValue(double* pvalue,GaussTria* gauss){{{1*/
-void TriaP1Input::GetInputValue(double* pvalue,GaussTria* gauss){
+/*FUNCTION TriaP1Input::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
+void TriaP1Input::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){
 
 	/*Call TriaRef function*/
@@ -124,6 +124,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){{{1*/
-void TriaP1Input::GetInputDerivativeValue(double* p, double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){{{*/
+void TriaP1Input::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){
 
 	/*Call TriaRef function*/
@@ -131,12 +131,12 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::GetVxStrainRate2d{{{1*/
-void TriaP1Input::GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaP1Input::GetVxStrainRate2d{{{*/
+void TriaP1Input::GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss){
 
 	/*Intermediary*/
 	int       i;
 	const int numnodes=3;
-	double B[3][NDOF2*numnodes];
-	double velocity[3][NDOF2];
+	IssmDouble B[3][NDOF2*numnodes];
+	IssmDouble velocity[3][NDOF2];
 
 	/*Get B matrix: */
@@ -154,12 +154,12 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::GetVyStrainRate2d{{{1*/
-void TriaP1Input::GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss){
+/*FUNCTION TriaP1Input::GetVyStrainRate2d{{{*/
+void TriaP1Input::GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss){
 
 	/*Intermediary*/
 	int       i;
 	const int numnodes=3;
-	double B[3][NDOF2*numnodes];
-	double velocity[3][NDOF2];
+	IssmDouble B[3][NDOF2*numnodes];
+	IssmDouble velocity[3][NDOF2];
 
 	/*Get B matrix: */
@@ -177,11 +177,11 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::ChangeEnum{{{1*/
+/*FUNCTION TriaP1Input::ChangeEnum{{{*/
 void TriaP1Input::ChangeEnum(int newenumtype){
 	this->enum_type=newenumtype;
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::GetInputAverage{{{1*/
-void TriaP1Input::GetInputAverage(double* pvalue){
+/*FUNCTION TriaP1Input::GetInputAverage{{{*/
+void TriaP1Input::GetInputAverage(IssmDouble* pvalue){
 	*pvalue=1./3.*(values[0]+values[1]+values[2]);
 }
@@ -189,11 +189,11 @@
 
 /*Intermediary*/
-/*FUNCTION TriaP1Input::SquareMin{{{1*/
-void TriaP1Input::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
-
-	int i;
-	const int numnodes=3;
-	double valuescopy[numnodes];
-	double squaremin;
+/*FUNCTION TriaP1Input::SquareMin{{{*/
+void TriaP1Input::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
+
+	int i;
+	const int numnodes=3;
+	IssmDouble valuescopy[numnodes];
+	IssmDouble squaremin;
 
 	/*First,  copy values, to process units if requested: */
@@ -212,6 +212,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::ContrainMin{{{1*/
-void TriaP1Input::ConstrainMin(double minimum){
+/*FUNCTION TriaP1Input::ContrainMin{{{*/
+void TriaP1Input::ConstrainMin(IssmDouble minimum){
 	
 	int i;
@@ -221,9 +221,9 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::InfinityNorm{{{1*/
-double TriaP1Input::InfinityNorm(void){
+/*FUNCTION TriaP1Input::InfinityNorm{{{*/
+IssmDouble TriaP1Input::InfinityNorm(void){
 
 	/*Output*/
-	double norm=0;
+	IssmDouble norm=0;
 	const int numnodes=3;
 
@@ -232,9 +232,9 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::Max{{{1*/
-double TriaP1Input::Max(void){
-
-	const int numnodes=3;
-	double    max=values[0];
+/*FUNCTION TriaP1Input::Max{{{*/
+IssmDouble TriaP1Input::Max(void){
+
+	const int numnodes=3;
+	IssmDouble    max=values[0];
 
 	for(int i=1;i<numnodes;i++){
@@ -244,9 +244,9 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::MaxAbs{{{1*/
-double TriaP1Input::MaxAbs(void){
-
-	const int numnodes=3;
-	double    max=fabs(values[0]);
+/*FUNCTION TriaP1Input::MaxAbs{{{*/
+IssmDouble TriaP1Input::MaxAbs(void){
+
+	const int numnodes=3;
+	IssmDouble    max=fabs(values[0]);
 
 	for(int i=1;i<numnodes;i++){
@@ -256,9 +256,9 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::Min{{{1*/
-double TriaP1Input::Min(void){
-
-	const int numnodes=3;
-	double    min=values[0];
+/*FUNCTION TriaP1Input::Min{{{*/
+IssmDouble TriaP1Input::Min(void){
+
+	const int numnodes=3;
+	IssmDouble    min=values[0];
 
 	for(int i=1;i<numnodes;i++){
@@ -268,9 +268,9 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::MinAbs{{{1*/
-double TriaP1Input::MinAbs(void){
-
-	const int numnodes=3;
-	double    min=fabs(values[0]);
+/*FUNCTION TriaP1Input::MinAbs{{{*/
+IssmDouble TriaP1Input::MinAbs(void){
+
+	const int numnodes=3;
+	IssmDouble    min=fabs(values[0]);
 
 	for(int i=1;i<numnodes;i++){
@@ -280,6 +280,6 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::Scale{{{1*/
-void TriaP1Input::Scale(double scale_factor){
+/*FUNCTION TriaP1Input::Scale{{{*/
+void TriaP1Input::Scale(IssmDouble scale_factor){
 	
 	int i;
@@ -289,22 +289,22 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::ArtificialNoise{{{1*/
-void TriaP1Input::ArtificialNoise(double min,double max){
-
-	int i;
-	const int numnodes=3;
-	double noise;
+/*FUNCTION TriaP1Input::ArtificialNoise{{{*/
+void TriaP1Input::ArtificialNoise(IssmDouble min,IssmDouble max){
+
+	int i;
+	const int numnodes=3;
+	IssmDouble noise;
 
 	/*Compute random number between bounds:
 	 * rand() outputs an integer in [0 RAND_MAX]
-	 * (double)rand()/RAND_MAX is in [0 1]
+	 * (IssmDouble)rand()/RAND_MAX is in [0 1]
 	 */
-	 noise=min+(max-min)*(double)rand()/RAND_MAX;
+	 noise=min+(max-min)*(IssmDouble)rand()/RAND_MAX;
 
 	for(i=0;i<numnodes;i++)values[i]=values[i]+noise;
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::AXPY{{{1*/
-void TriaP1Input::AXPY(Input* xinput,double scalar){
+/*FUNCTION TriaP1Input::AXPY{{{*/
+void TriaP1Input::AXPY(Input* xinput,IssmDouble scalar){
 
 	int i;
@@ -323,21 +323,21 @@
 
 		default :
-			_error_("not implemented yet");
-	}
-
-}
-/*}}}*/
-/*FUNCTION TriaP1Input::Constrain{{{1*/
-void TriaP1Input::Constrain(double cm_min, double cm_max){
+			_error2_("not implemented yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::Constrain{{{*/
+void TriaP1Input::Constrain(IssmDouble cm_min, IssmDouble cm_max){
 
 	int i;
 	const int numnodes=3;
 		
-	if(!isnan(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
-	if(!isnan(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
-
-}
-/*}}}*/
-/*FUNCTION TriaP1Input::GetVectorFromInputs{{{1*/
+	if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
+	if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
+
+}
+/*}}}*/
+/*FUNCTION TriaP1Input::GetVectorFromInputs{{{*/
 void TriaP1Input::GetVectorFromInputs(Vector* vector,int* doflist){
 
@@ -346,6 +346,6 @@
 
 } /*}}}*/
-/*FUNCTION TriaP1Input::GetValuesPtr{{{1*/
-void TriaP1Input::GetValuesPtr(double** pvalues,int* pnum_values){
+/*FUNCTION TriaP1Input::GetValuesPtr{{{*/
+void TriaP1Input::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
 
 	*pvalues=this->values;
@@ -354,5 +354,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::PointwiseMin{{{1*/
+/*FUNCTION TriaP1Input::PointwiseMin{{{*/
 Input* TriaP1Input::PointwiseMin(Input* inputB){
 
@@ -365,8 +365,8 @@
 	int               B_numvalues;
 	const int         numnodes    = 3;
-	double            minvalues[numnodes];
+	IssmDouble            minvalues[numnodes];
 
 	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=TriaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	if (inputB->ObjectEnum()!=TriaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
 	xinputB=(TriaP1Input*)inputB;
 
@@ -385,5 +385,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::PointwiseMax{{{1*/
+/*FUNCTION TriaP1Input::PointwiseMax{{{*/
 Input* TriaP1Input::PointwiseMax(Input* inputB){
 
@@ -396,8 +396,8 @@
 	int               B_numvalues;
 	const int         numnodes    = 3;
-	double            maxvalues[numnodes];
+	IssmDouble            maxvalues[numnodes];
 
 	/*Check that inputB is of the same type*/
-	if (inputB->ObjectEnum()!=TriaP1InputEnum) _error_("Operation not permitted because inputB is of type %s",EnumToStringx(inputB->ObjectEnum()));
+	if (inputB->ObjectEnum()!=TriaP1InputEnum) _error2_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
 	xinputB=(TriaP1Input*)inputB;
 
@@ -416,5 +416,5 @@
 }
 /*}}}*/
-/*FUNCTION TriaP1Input::Configure{{{1*/
+/*FUNCTION TriaP1Input::Configure{{{*/
 void TriaP1Input::Configure(Parameters* parameters){
 	/*do nothing: */
Index: /issm/trunk/src/c/objects/Inputs/TriaP1Input.h
===================================================================
--- /issm/trunk/src/c/objects/Inputs/TriaP1Input.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Inputs/TriaP1Input.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Input.h"
 #include "../Elements/TriaRef.h"
@@ -19,12 +19,12 @@
 		/*just hold 3 values for 3 vertices: */
 		int    enum_type;
-		double values[3];
+		IssmDouble values[3];
 
-		/*TriaP1Input constructors, destructors: {{{1*/
+		/*TriaP1Input constructors, destructors: {{{*/
 		TriaP1Input();
-		TriaP1Input(int enum_type,double* values);
+		TriaP1Input(int enum_type,IssmDouble* values);
 		~TriaP1Input();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -34,51 +34,51 @@
 		Object* copy();
 		/*}}}*/
-		/*TriaP1Input management: {{{1*/
+		/*TriaP1Input management: {{{*/
 		int   InstanceEnum();
 		Input* SpawnTriaInput(int* indices);
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
+		Input* PointwiseDivide(Input* inputB){_error2_("not implemented yet");};
 		Input* PointwiseMin(Input* inputB);
 		Input* PointwiseMax(Input* inputB);
-		ElementResult* SpawnResult(int step, double time);
-		void AddTimeValues(double* values,int step,double time){_error_("not supported yet");};
+		ElementResult* SpawnResult(int step, IssmDouble time);
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error2_("not supported yet");};
 		void Configure(Parameters* parameters);
 		/*}}}*/
-		/*numerics: {{{1*/
-		void GetInputValue(bool* pvalue){_error_("not implemented yet");}
-		void GetInputValue(int* pvalue){_error_("not implemented yet");}
-		void GetInputValue(double* pvalue){_error_("not implemented yet");}
-		void GetInputValue(double* pvalue,GaussTria* gauss);
-		void GetInputValue(double* pvalue,GaussPenta* gauss){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,double time){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussTria* gauss ,int index){_error_("not implemented yet");};
-		void GetInputValue(double* pvalue,GaussPenta* gauss,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussTria* gauss);
-		void GetInputDerivativeValue(double* derivativevalues, double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetInputAverage(double* pvalue);
-		void GetVxStrainRate2d(double* epsilonvx,double* xyz_list, GaussTria* gauss);
-		void GetVyStrainRate2d(double* epsilonvy,double* xyz_list, GaussTria* gauss);
-		void GetVxStrainRate3d(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3d(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVzStrainRate3d(double* epsilonvz,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVxStrainRate3dPattyn(double* epsilonvx,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
-		void GetVyStrainRate3dPattyn(double* epsilonvy,double* xyz_list, GaussPenta* gauss){_error_("not implemented yet");};
+		/*numerics: {{{*/
+		void GetInputValue(bool* pvalue){_error2_("not implemented yet");}
+		void GetInputValue(int* pvalue){_error2_("not implemented yet");}
+		void GetInputValue(IssmDouble* pvalue){_error2_("not implemented yet");}
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss);
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussTria* gauss ,int index){_error2_("not implemented yet");};
+		void GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,int index){_error2_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss);
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetVxStrainRate2d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussTria* gauss);
+		void GetVyStrainRate2d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussTria* gauss);
+		void GetVxStrainRate3d(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3d(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVzStrainRate3d(IssmDouble* epsilonvz,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVxStrainRate3dPattyn(IssmDouble* epsilonvx,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
+		void GetVyStrainRate3dPattyn(IssmDouble* epsilonvy,IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not implemented yet");};
 		void ChangeEnum(int newenumtype);
 
-		void SquareMin(double* psquaremin, bool process_units,Parameters* parameters);
-		void ConstrainMin(double minimum);
-		void Scale(double scale_factor);
-		void ArtificialNoise(double min,double max);
-		void AXPY(Input* xinput,double scalar);
-		void Constrain(double cm_min, double cm_max);
-		double InfinityNorm(void);
-		double Max(void);
-		double MaxAbs(void);
-		double Min(void);
-		double MinAbs(void);
-		void Extrude(void){_error_("not supported yet");};
-		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
+		void SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters);
+		void ConstrainMin(IssmDouble minimum);
+		void Scale(IssmDouble scale_factor);
+		void ArtificialNoise(IssmDouble min,IssmDouble max);
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		IssmDouble InfinityNorm(void);
+		IssmDouble Max(void);
+		IssmDouble MaxAbs(void);
+		IssmDouble Min(void);
+		IssmDouble MinAbs(void);
+		void Extrude(void){_error2_("not supported yet");};
+		void VerticallyIntegrate(Input* thickness_input){_error2_("not supported yet");};
 		void GetVectorFromInputs(Vector* vector,int* doflist);
-		void GetValuesPtr(double** pvalues,int* pnum_values);
+		void GetValuesPtr(IssmDouble** pvalues,int* pnum_values);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/IoModel.cpp
===================================================================
--- /issm/trunk/src/c/objects/IoModel.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/IoModel.cpp	(revision 12706)
@@ -22,5 +22,5 @@
 #include "../include/include.h"
 
-/*FUNCTION IoModel::IoModel(){{{1*/
+/*FUNCTION IoModel::IoModel(){{{*/
 IoModel::IoModel(){
 	this->fid=NULL;
@@ -39,5 +39,5 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::IoModel(FILE*  iomodel_handle){{{1*/
+/*FUNCTION IoModel::IoModel(FILE*  iomodel_handle){{{*/
 IoModel::IoModel(FILE* iomodel_handle){
 	
@@ -50,8 +50,8 @@
 	/*Initialize and read constants:*/
 	this->constants=new Parameters();
-	this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, doubles and strings only, nothing memory intensive*/
+	this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, IssmDoubles and strings only, nothing memory intensive*/
 
 	/*Initialize data: */
-	this->data=(double**)xmalloc(MaximumNumberOfEnums*sizeof(double*));
+	this->data=xNew<IssmDouble*>(MaximumNumberOfEnums);
 	for(int i=0;i<MaximumNumberOfEnums;i++) this->data[i]=NULL;
 	
@@ -68,29 +68,30 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::~IoModel(){{{1*/
+/*FUNCTION IoModel::~IoModel(){{{*/
 IoModel::~IoModel(){
 
-	delete this->constants;
+	if(this->constants) delete this->constants;
 
 	/*Some checks in debugging mode*/
 	#ifdef _ISSM_DEBUG_
-	for(int i=0;i<MaximumNumberOfEnums;i++){
-		if(this->data[i]){
-			_printf_("Info: previous pointer of %s has not been freed (DeleteData has not been called)",EnumToStringx(i));
+	if(this->data){
+		for(int i=0;i<MaximumNumberOfEnums;i++){
+			if(this->data[i]){
+				_pprintLine_("Info: previous pointer of " << EnumToStringx(i) << " has not been freed (DeleteData has not been called)");
+			}
 		}
 	}
 	#endif
 
-	xfree((void**)&this->data);
-
-	xfree((void**)&this->my_elements);
-	xfree((void**)&this->my_nodes);
-	xfree((void**)&this->my_vertices);
-	xfree((void**)&this->singlenodetoelementconnectivity);
-	xfree((void**)&this->numbernodetoelementconnectivity);
-}
-/*}}}*/
-
-/*FUNCTION IoModel::CheckEnumSync{{{1*/
+	xDelete<IssmDouble*>(this->data);
+	xDelete<bool>(this->my_elements);
+	xDelete<bool>(this->my_nodes);
+	xDelete<int>(this->my_vertices);
+	xDelete<int>(this->singlenodetoelementconnectivity);
+	xDelete<int>(this->numbernodetoelementconnectivity);
+}
+/*}}}*/
+
+/*FUNCTION IoModel::CheckEnumSync{{{*/
 void  IoModel::CheckEnumSync(void){
 
@@ -98,9 +99,7 @@
 	int record_enum = 0;
 
-
 	/*Check that some fields have been allocated*/
 	_assert_(this->fid || my_rank);
 
-
 	/*Go find in the binary file, the position of the data we want to fetch: */
 	if(my_rank==0){ //cpu 0
@@ -111,29 +110,29 @@
 		/*Get first Enum*/
 		if(fread(&record_enum,sizeof(int),1,this->fid)==0){
-			_error_("Marshalled file is empty");
+			_error2_("Marshalled file is empty");
 		}
 		else{
 			if(record_enum!=MaximumNumberOfEnums){
-				printf("\n");
-				printf("=========================================================================\n");
-				printf(" Enums in marshalled file are not compatible with compiled code          \n");
-				printf("                                                                         \n");
-				printf("   * If you are running ISSM on a remote cluster:                        \n");
-				printf("     make sure that you are using the same version of ISSM on your local \n");
-				printf("     machine and remote cluster (you might need to run svn update)       \n");
-				printf("   * If you are running ISSM on your local machine:                      \n");
-				printf("     make sure that all the code is compiled (modules and executables)   \n");
-				printf("   * If you are a developer and just added a new Enum:                   \n");
-				printf("     you might need to run ./Synchronize.sh in src/c/EnumDefinitions     \n");
-				printf("     and recompile                                                       \n");
-				printf("=========================================================================\n");
-				printf("\n");
-				_error_("Enums not consistent (See error message above)");
-			}
-		}
-	}
-}
-/*}}}*/
-/*FUNCTION IoModel::Constant(bool* poutput,int constant_enum){{{1*/
+				_printLine_("");
+				_printLine_("=========================================================================");
+				_printLine_(" Enums in marshalled file are not compatible with compiled code          ");
+				_printLine_("                                                                         ");
+				_printLine_("   * If you are running ISSM on a remote cluster:                        ");
+				_printLine_("     make sure that you are using the same version of ISSM on your local ");
+				_printLine_("     machine and remote cluster (you might need to run svn update)       ");
+				_printLine_("   * If you are running ISSM on your local machine:                      ");
+				_printLine_("     make sure that all the code is compiled (modules and executables)   ");
+				_printLine_("   * If you are a developer and just added a new Enum:                   ");
+				_printLine_("     you might need to run ./Synchronize.sh in src/c/EnumDefinitions     ");
+				_printLine_("     and recompile                                                       ");
+				_printLine_("=========================================================================");
+				_printLine_("");
+				_error2_("Enums not consistent (See error message above)");
+			}
+		}
+	}
+}
+/*}}}*/
+/*FUNCTION IoModel::Constant(bool* poutput,int constant_enum){{{*/
 void IoModel::Constant(bool* poutput,int constant_enum){
 
@@ -144,5 +143,5 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::Constant(int* poutput,int constant_enum){{{1*/
+/*FUNCTION IoModel::Constant(int* poutput,int constant_enum){{{*/
 void IoModel::Constant(int* poutput,int constant_enum){
 
@@ -153,6 +152,6 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::Constant(double* poutput,int constant_enum){{{1*/
-void IoModel::Constant(double* poutput,int constant_enum){
+/*FUNCTION IoModel::Constant(IssmDouble* poutput,int constant_enum){{{*/
+void IoModel::Constant(IssmDouble* poutput,int constant_enum){
 
 	_assert_(constant_enum>=0);
@@ -162,5 +161,5 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::Constant(char** poutput,int constant_enum){{{1*/
+/*FUNCTION IoModel::Constant(char** poutput,int constant_enum){{{*/
 void IoModel::Constant(char** poutput,int constant_enum){
 
@@ -171,5 +170,5 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::CopyConstantObject{{{1*/
+/*FUNCTION IoModel::CopyConstantObject{{{*/
 Param* IoModel::CopyConstantObject(int constant_enum){
 
@@ -178,11 +177,11 @@
 	/*Find constant*/
 	Param* param=(Param*)this->constants->FindParamObject(constant_enum);
-	if(!param) _error_("Constant %s not found in iomodel",EnumToStringx(constant_enum));
+	if(!param) _error2_("Constant " << EnumToStringx(constant_enum) << " not found in iomodel");
 
 	return (Param*)param->copy();
 }
 /*}}}*/
-/*FUNCTION IoModel::Data{{{1*/
-double* IoModel::Data(int data_enum){
+/*FUNCTION IoModel::Data{{{*/
+IssmDouble* IoModel::Data(int data_enum){
 
 	_assert_(data_enum<MaximumNumberOfEnums);
@@ -192,5 +191,5 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::DeleteData{{{1*/
+/*FUNCTION IoModel::DeleteData{{{*/
 void  IoModel::DeleteData(int num,...){
 
@@ -206,9 +205,9 @@
 		dataenum=va_arg(ap, int);
 		_assert_(dataenum<MaximumNumberOfEnums);
-		xfree((void**)&this->data[dataenum]);
+		xDelete<IssmDouble>(this->data[dataenum]);
 	}
 	va_end(ap);
 } /*}}}*/
-/*FUNCTION IoModel::FetchConstants{{{1*/
+/*FUNCTION IoModel::FetchConstants{{{*/
 void  IoModel::FetchConstants(void){
 
@@ -224,5 +223,5 @@
 	int  booleanint=0;
 	int  integer=0;
-	double scalar=0;
+	IssmPDouble scalar=0;
 	char* string=NULL;
 	int   string_size;
@@ -233,10 +232,10 @@
 
 	/*Go find in the binary file, the position of the data we want to fetch: */
-	if(my_rank==0){ //cpu 0{{{2
+	if(my_rank==0){ //cpu 0{{{
 	
 		/*First set FILE* position to the beginning of the file: */
 		fseek(this->fid,0,SEEK_SET);
 
-		/*Now march through file looking for the correct data identifiers (bool,int,double or string): */
+		/*Now march through file looking for the correct data identifiers (bool,int,IssmDouble or string): */
 		for(;;){
 			if(fread(&record_enum,sizeof(int),1,this->fid)==0){
@@ -267,5 +266,5 @@
 					case 1: 
 						/*Read the boolean and broadcast it to other cpus:*/
-						if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error_(" could not read boolean ");
+						if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error2_("could not read boolean ");
 						#ifdef _HAVE_MPI_
 						MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 
@@ -278,5 +277,5 @@
 					case 2:
 						/*Read the integer and broadcast it to other cpus:*/
-						if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_(" could not read integer ");
+						if(fread(&integer,sizeof(int),1,this->fid)!=1) _error2_("could not read integer ");
 						#ifdef _HAVE_MPI_
 						MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
@@ -289,5 +288,5 @@
 					case 3:
 						/*Read the scalar and broadcast it to other cpus:*/
-						if(fread(&scalar,sizeof(double),1,this->fid)!=1) _error_(" could not read scalar ");
+						if(fread(&scalar,sizeof(IssmPDouble),1,this->fid)!=1) _error2_("could not read scalar ");
 						#ifdef _HAVE_MPI_
 						MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
@@ -300,5 +299,5 @@
 					case 4: 
 						/*We have to read a string from disk. First read the dimensions of the string, then the string: */
-						if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error_(" could not read length of string ");
+						if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error2_("could not read length of string ");
 						#ifdef _HAVE_MPI_
 						MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
@@ -306,9 +305,9 @@
 
 						if(string_size){
-							string=(char*)xmalloc((string_size+1)*sizeof(char));
+							string=xNew<char>(string_size+1);
 							string[string_size]='\0';
 
 							/*Read string, then broadcast: */
-							if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error_("  could not read string ");
+							if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error2_(" could not read string ");
 							#ifdef _HAVE_MPI_
 							MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
@@ -316,5 +315,5 @@
 						}
 						else{
-							string=(char*)xmalloc(sizeof(char));
+							string=xNew<char>(1);
 							string[0]='\0';
 						}
@@ -324,5 +323,5 @@
 
 						/*Free string*/
-						xfree((void**)&string);
+						xDelete<char>(string);
 
 						break;
@@ -361,5 +360,5 @@
 
 					default: 
-						_error_("%s%i","unknown record type:",record_code); 
+						_error2_("unknown record type:" << record_code); 
 						break;;
 				}
@@ -368,5 +367,5 @@
 	} //}}}
 	#ifdef _HAVE_MPI_
-	else{ //cpu ~0 {{{2
+	else{ //cpu ~0 {{{
 		for(;;){ //wait on cpu 0
 			MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*get from cpu 0 what we are going to do: */
@@ -405,5 +404,5 @@
 					MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
 					if(string_size){
-						string=(char*)xmalloc((string_size+1)*sizeof(char));
+						string=xNew<char>((string_size+1));
 						string[string_size]='\0';
 
@@ -412,5 +411,5 @@
 					}
 					else{
-						string=(char*)xmalloc(sizeof(char));
+						string=xNew<char>(1);
 						string[0]='\0';
 					}
@@ -419,5 +418,5 @@
 
 					/*Free string*/
-					xfree((void**)&string);
+					xDelete<char>(string);
 
 					break;
@@ -429,5 +428,5 @@
 
 				default: 
-					_error_("%s%i","unknown record type:",record_code); 
+					_error2_("unknown record type:" << record_code); 
 					break;;
 				}
@@ -440,5 +439,5 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchData(bool*     pbool,int data_enum){{{1*/
+/*FUNCTION IoModel::FetchData(bool*     pbool,int data_enum){{{*/
 void  IoModel::FetchData(bool* pboolean,int data_enum){
 
@@ -454,9 +453,9 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 
-	if(code!=1)_error_("expecting a boolean for enum %s",EnumToStringx(data_enum));
+	if(code!=1)_error2_("expecting a boolean for enum " << EnumToStringx(data_enum));
 	
 	/*We have to read a boolean from disk. */
 	if(my_rank==0){  
-		if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_(" could not read boolean ");
+		if(fread(&booleanint,sizeof(int),1,fid)!=1) _error2_("could not read boolean ");
 	}
 	#ifdef _HAVE_MPI_
@@ -470,10 +469,9 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchData(int*      pinteger,int data_enum){{{1*/
+/*FUNCTION IoModel::FetchData(int*      pinteger,int data_enum){{{*/
 void  IoModel::FetchData(int* pinteger,int data_enum){
 
 	extern int my_rank;
 	extern int num_procs;
-	
 
 	/*output: */
@@ -484,9 +482,9 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	
-	if(code!=2)_error_("expecting an integer for enum %s",EnumToStringx(data_enum));
+	if(code!=2)_error2_("expecting an integer for enum " << EnumToStringx(data_enum));
 	
 	/*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
 	if(my_rank==0){  
-		if(fread(&integer,sizeof(int),1,fid)!=1) _error_(" could not read integer ");
+		if(fread(&integer,sizeof(int),1,fid)!=1) _error2_("could not read integer ");
 	}
 
@@ -497,9 +495,8 @@
 	/*Assign output pointers: */
 	*pinteger=integer;
-
-}
-/*}}}*/
-/*FUNCTION IoModel::FetchData(double*   pscalar,int data_enum){{{1*/
-void  IoModel::FetchData(double* pscalar,int data_enum){
+}
+/*}}}*/
+/*FUNCTION IoModel::FetchData(IssmDouble*   pscalar,int data_enum){{{*/
+void  IoModel::FetchData(IssmDouble* pscalar,int data_enum){
 
 
@@ -509,5 +506,5 @@
 
 	/*output: */
-	double   scalar;
+	IssmPDouble   scalar;
 	int      code;
 	
@@ -515,9 +512,9 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	
-	if(code!=3)_error_("expecting a double for enum %s",EnumToStringx(data_enum));
+	if(code!=3)_error2_("expecting a IssmDouble for enum " << EnumToStringx(data_enum));
 	
 	/*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
 	if(my_rank==0){
-		if(fread(&scalar,sizeof(double),1,fid)!=1)_error_(" could not read scalar ");
+		if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1)_error2_("could not read scalar ");
 	}
 	#ifdef _HAVE_MPI_
@@ -530,5 +527,5 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchData(char**    pstring,int data_enum){{{1*/
+/*FUNCTION IoModel::FetchData(char**    pstring,int data_enum){{{*/
 void  IoModel::FetchData(char** pstring,int data_enum){
 
@@ -545,5 +542,5 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	
-	if(code!=4)_error_("expecting a string for enum %s",EnumToStringx(data_enum));
+	if(code!=4)_error2_("expecting a string for enum " << EnumToStringx(data_enum));
 	
 	/*Now fetch: */
@@ -551,5 +548,5 @@
 	/*We have to read a string from disk. First read the dimensions of the string, then the string: */
 	if(my_rank==0){  
-		if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
+		if(fread(&string_size,sizeof(int),1,fid)!=1) _error2_("could not read length of string ");
 	}
 
@@ -560,10 +557,10 @@
 	/*Now allocate string: */
 	if(string_size){
-		string=(char*)xmalloc((string_size+1)*sizeof(char));
+		string=xNew<char>((string_size+1));
 		string[string_size]='\0';
 
 		/*Read string on node 0, then broadcast: */
 		if(my_rank==0){  
-			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
+			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error2_(" could not read string ");
 		}
 		#ifdef _HAVE_MPI_
@@ -572,5 +569,5 @@
 	}
 	else{
-		string=(char*)xmalloc(sizeof(char));
+		string=xNew<char>(1);
 		string[0]='\0';
 	}
@@ -581,5 +578,5 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchData(int**  pintegerematrix,int* pM,int* pN,int data_enum){{{1*/
+/*FUNCTION IoModel::FetchData(int**     pintegerematrix,int* pM,int* pN,int data_enum){{{*/
 void  IoModel::FetchData(int** pmatrix,int* pM,int* pN,int data_enum){
 
@@ -590,5 +587,5 @@
 	/*output: */
 	int M,N;
-	double* matrix=NULL;
+	IssmPDouble* matrix=NULL;
 	int*    integer_matrix=NULL;
 	int code=0;
@@ -599,5 +596,5 @@
 	fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
 
-	if((code!=5) && (code!=6) && (code!=7))_error_("expecting a double, integer or boolean matrix for enum %s",EnumToStringx(data_enum));
+	if((code!=5) && (code!=6) && (code!=7))_error2_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum));
 	
 	/*Now fetch: */
@@ -606,5 +603,5 @@
 	/*numberofelements: */
 	if(my_rank==0){  
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
+		if(fread(&M,sizeof(int),1,fid)!=1) _error2_("could not read number of rows for matrix ");
 	}
 
@@ -614,5 +611,5 @@
 
 	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
+		if(fread(&N,sizeof(int),1,fid)!=1) _error2_("could not read number of columns for matrix ");
 	}
 	#ifdef _HAVE_MPI_
@@ -622,9 +619,9 @@
 	/*Now allocate matrix: */
 	if(M*N){
-		matrix=(double*)xmalloc(M*N*sizeof(double));
+		matrix=xNew<IssmPDouble>(M*N);
 
 		/*Read matrix on node 0, then broadcast: */
 		if(my_rank==0){  
-			if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
+			if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error2_("could not read matrix ");
 		}
 		
@@ -636,5 +633,5 @@
 	/*Now cast to integer: */
 	if(M*N){
-		integer_matrix=(int*)xmalloc(M*N*sizeof(int));
+		integer_matrix=xNew<int>(M*N);
 		for (i=0;i<M;i++){
 			for (j=0;j<N;j++){
@@ -647,5 +644,5 @@
 	}
 	/*Free ressources:*/
-	xfree((void**)&matrix);
+	xDelete<IssmPDouble>(matrix);
 
 	/*Assign output pointers: */
@@ -656,6 +653,6 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchData(double**  pdoublematrix,int* pM,int* pN,int data_enum){{{1*/
-void  IoModel::FetchData(double** pmatrix,int* pM,int* pN,int data_enum){
+/*FUNCTION IoModel::FetchData(IssmDouble**  pIssmDoublematrix,int* pM,int* pN,int data_enum){{{*/
+void  IoModel::FetchData(IssmDouble** pmatrix,int* pM,int* pN,int data_enum){
 
 	extern int my_rank;
@@ -664,5 +661,5 @@
 	/*output: */
 	int M,N;
-	double* matrix=NULL;
+	IssmPDouble* matrix=NULL;
 	int code=0;
 	int vector_type=0;
@@ -670,5 +667,5 @@
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
-	if((code!=5) && (code!=6) && (code!=7))_error_("expecting a double, integer or boolean matrix for enum %s",EnumToStringx(data_enum));
+	if((code!=5) && (code!=6) && (code!=7))_error2_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum));
 	
 	/*Now fetch: */
@@ -677,5 +674,5 @@
 	/*numberofelements: */
 	if(my_rank==0){  
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
+		if(fread(&M,sizeof(int),1,fid)!=1) _error2_("could not read number of rows for matrix ");
 	}
 	#ifdef _HAVE_MPI_
@@ -684,5 +681,5 @@
 
 	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
+		if(fread(&N,sizeof(int),1,fid)!=1) _error2_("could not read number of columns for matrix ");
 	}
 	#ifdef _HAVE_MPI_
@@ -692,22 +689,25 @@
 	/*Now allocate matrix: */
 	if(M*N){
-		matrix=(double*)xmalloc(M*N*sizeof(double));
+		matrix=xNew<IssmPDouble>(M*N);
 
 		/*Read matrix on node 0, then broadcast: */
 		if(my_rank==0){  
-			if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
+			if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error2_("could not read matrix ");
 		}
 		#ifdef _HAVE_MPI_
 		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
 		#endif
-	}
-
+	        *pmatrix=xNew<IssmDouble>(M*N);
+	        for (int i=0;i<M*N;++i) (*pmatrix)[i]=matrix[i];
+	        xDelete<IssmPDouble>(matrix);
+	}
+	else
+	  *pmatrix=NULL;
 	/*Assign output pointers: */
-	*pmatrix=matrix;
 	if (pM)*pM=M;
 	if (pN)*pN=N;
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchData(char***   pstrings,int* pnumstrings,int data_enum){{{1*/
+/*FUNCTION IoModel::FetchData(char***   pstrings,int* pnumstrings,int data_enum){{{*/
 void  IoModel::FetchData(char*** pstrings,int* pnumstrings,int data_enum){
 
@@ -729,9 +729,9 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	
-	if(code!=9)_error_("expecting a string array for enum %s",EnumToStringx(data_enum));
+	if(code!=9)_error2_("expecting a string array for enum " << EnumToStringx(data_enum));
 	
 	/*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */
 	if(my_rank==0){  
-		if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_(" could not read length of string array");
+		if(fread(&numstrings,sizeof(int),1,fid)!=1) _error2_("could not read length of string array");
 	}
 	#ifdef _HAVE_MPI_
@@ -741,5 +741,5 @@
 	/*Now allocate string array: */
 	if(numstrings){
-		strings=(char**)xmalloc(numstrings*sizeof(char*));
+		strings=xNew<char*>(numstrings);
 		for(i=0;i<numstrings;i++)strings[i]=NULL;
 
@@ -748,5 +748,5 @@
 			
 			if(my_rank==0){  
-				if(fread(&string_size,sizeof(int),1,fid)!=1) _error_(" could not read length of string ");
+				if(fread(&string_size,sizeof(int),1,fid)!=1) _error2_("could not read length of string ");
 			}
 			#ifdef _HAVE_MPI_
@@ -754,10 +754,10 @@
 			#endif
 			if(string_size){
-				string=(char*)xmalloc((string_size+1)*sizeof(char));
+				string=xNew<char>((string_size+1));
 				string[string_size]='\0';
 
 				/*Read string on node 0, then broadcast: */
 				if(my_rank==0){  
-					if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_("  could not read string ");
+					if(fread(string,string_size*sizeof(char),1,fid)!=1)_error2_(" could not read string ");
 				}
 				#ifdef _HAVE_MPI_
@@ -766,5 +766,5 @@
 			}
 			else{
-				string=(char*)xmalloc(sizeof(char));
+				string=xNew<char>(1);
 				string[0]='\0';
 			}
@@ -779,6 +779,6 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchData(double*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{1*/
-void  IoModel::FetchData(double*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){
+/*FUNCTION IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{*/
+void  IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){
 
 	int i;
@@ -788,5 +788,5 @@
 
 	/*output: */
-	double** matrices=NULL;
+	IssmDouble** matrices=NULL;
 	int*     mdims=NULL;
 	int*     ndims=NULL;
@@ -795,14 +795,14 @@
 	/*intermediary: */
 	int     M, N;
-	double *matrix = NULL;
+	IssmPDouble *matrix = NULL;
 	int     code;
 	
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
-	if(code!=8)_error_("expecting a double mat array for enum %s",EnumToStringx(data_enum));
+	if(code!=8)_error2_("expecting a IssmDouble mat array for enum " << EnumToStringx(data_enum));
 	
 	/*Now fetch: */
 	if(my_rank==0){  
-		if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array ");
+		if(fread(&numrecords,sizeof(int),1,fid)!=1) _error2_("could not read number of records in matrix array ");
 	}
 	#ifdef _HAVE_MPI_
@@ -813,7 +813,7 @@
 
 		/*Allocate matrices :*/
-		matrices=(double**)xmalloc(numrecords*sizeof(double*));
-		mdims=(int*)xmalloc(numrecords*sizeof(int));
-		ndims=(int*)xmalloc(numrecords*sizeof(int));
+		matrices=xNew<IssmDouble*>(numrecords);
+		mdims=xNew<int>(numrecords);
+		ndims=xNew<int>(numrecords);
 
 		for(i=0;i<numrecords;i++){
@@ -827,5 +827,5 @@
 
 			if(my_rank==0){  
-				if(fread(&M,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of rows in ",i,"th matrix of matrix array");
+				if(fread(&M,sizeof(int),1,fid)!=1) _error2_("could not read number of rows in " << i << "th matrix of matrix array");
 			}
 			#ifdef _HAVE_MPI_
@@ -834,5 +834,5 @@
 
 			if(my_rank==0){  
-				if(fread(&N,sizeof(int),1,fid)!=1) _error_("%s%i%s","could not read number of columns in ",i,"th matrix of matrix array");
+				if(fread(&N,sizeof(int),1,fid)!=1) _error2_("could not read number of columns in " << i << "th matrix of matrix array");
 			}
 			#ifdef _HAVE_MPI_
@@ -842,9 +842,9 @@
 			/*Now allocate matrix: */
 			if(M*N){
-				matrix=(double*)xmalloc(M*N*sizeof(double));
+				matrix=xNew<IssmPDouble>(M*N);
 
 				/*Read matrix on node 0, then broadcast: */
 				if(my_rank==0){  
-					if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
+					if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error2_("could not read matrix ");
 				}
 
@@ -852,8 +852,11 @@
 				MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
 				#endif
-			}
-
+				matrices[i]=xNew<IssmDouble>(M*N);
+				for (int j=0;j<M*N;++j) {matrices[i][j]=matrix[j];}
+				xDelete<IssmPDouble>(matrix);
+			}
+			else
+			  matrices[i]=NULL;
 			/*Assign: */
-			matrices[i]=matrix;
 			mdims[i]=M;
 			ndims[i]=N;
@@ -868,15 +871,63 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchData(int num,...){{{1*/
+/*FUNCTION IoModel::FetchData(Option**  poption,int data_enum){{{*/
+void  IoModel::FetchData(Option** poption,int index){
+
+	extern int my_rank;
+	extern int num_procs;
+
+	/*output: */
+	int     code;
+	Option *option      = NULL;
+	char   *name        = NULL;
+
+	/*First get option name*/
+	this->FetchData(&name,index);
+
+	/*Get option value*/
+	fid=this->SetFilePointerToData(&code,NULL,index+1);
+	switch(code){
+		case 3: {//IssmDouble
+			  IssmDouble *value = NULL;
+			  value=xNew<IssmDouble>(1);
+			  FetchData(value,index+1);
+			  option = new OptionDouble();
+			  ((OptionDouble*)option)->values = value;
+			  option->name  = name;
+			  option->numel = 1;
+			  option->ndims = 1;
+			  option->size  = NULL;
+			  break;
+			  }
+		case 4: {//char
+			  char* value = NULL;
+			  FetchData(&value,index+1);
+			  option = new OptionChar();
+			  ((OptionChar*)option)->values = value;
+			  option->name  = name;
+			  option->numel = 1;
+			  option->ndims = 1;
+			  option->size  = NULL;
+			  break;
+			  }
+		default:
+			  _error2_("Option of format " << code << " not supported yet");
+	}
+
+	/*Assign output pointers: */
+	*poption=option;
+}
+/*}}}*/
+/*FUNCTION IoModel::FetchData(int num,...){{{*/
 void  IoModel::FetchData(int num,...){
 
 	va_list ap;
 	int     dataenum;
-	double* matrix=NULL;
+	IssmDouble* matrix=NULL;
 	int     M,N;
 	int     i;
 
 	/*Go through the entire list of enums and fetch the corresponding data. Add it to the iomodel->data dataset. Everything
-	 *we fetch is a double* : */
+	 *we fetch is a IssmDouble* : */
 	
 	va_start(ap,num);
@@ -890,5 +941,5 @@
 		_assert_(dataenum<MaximumNumberOfEnums);
 		if(this->data[dataenum]){
-			_error_("Info: trying to fetch %s but previous pointer has not been freed (DeleteData has not been called)",EnumToStringx(dataenum));
+			_error2_("Info: trying to fetch " << EnumToStringx(dataenum) << " but previous pointer has not been freed (DeleteData has not been called)");
 		}
 		#endif
@@ -903,6 +954,6 @@
 }
 /*}}}*/
-/*FUNCTION IoModel::FetchDataToInput{{{1*/
-void IoModel::FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum,double default_value){
+/*FUNCTION IoModel::FetchDataToInput{{{*/
+void IoModel::FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum,IssmDouble default_value){
 
 	/*intermediary: */
@@ -923,7 +974,7 @@
 	bool    boolean;
 	int     integer;
-	double  scalar;
+	IssmDouble  scalar;
 	char   *string        = NULL;
-	double *doublevector  = NULL;
+	IssmDouble *IssmDoublevector  = NULL;
 	int     M,N;
 
@@ -935,5 +986,5 @@
 
 	switch(code){
-		case 1: //boolean constant.  {{{2
+		case 1: //boolean constant.  {{{
 			this->FetchData(&boolean,vector_enum);
 
@@ -943,10 +994,10 @@
 				if(this->my_elements[i]){
 					Element* element=(Element*)elements->GetObjectByOffset(counter);
-					element->InputCreate((double)boolean,vector_enum,code); 
+					element->InputCreate((IssmDouble)boolean,vector_enum,code);
 					counter++;
 				}
 			}
 			break; /*}}}*/
-		case 2: //integer constant.  {{{2
+		case 2: //integer constant.  {{{
 			this->FetchData(&integer,vector_enum);
 
@@ -956,13 +1007,13 @@
 				if(this->my_elements[i]){
 					Element* element=(Element*)elements->GetObjectByOffset(counter);
-					element->InputCreate((double)integer,vector_enum,code); 
+					element->InputCreate((IssmDouble)integer,vector_enum,code);
 					counter++;
 				}
 			}
 			break; /*}}}*/
-		case 3: //double constant.  {{{2
+		case 3: //IssmDouble constant.  {{{
 			this->FetchData(&scalar,vector_enum);
 
-			/*Add double constant input to all elements: */
+			/*Add IssmDouble constant input to all elements: */
 			counter=0;
 			for (i=0;i<numberofelements;i++){
@@ -974,10 +1025,10 @@
 			}
 			break; /*}}}*/
-		case 5: //boolean vector.  {{{2
+		case 5: //boolean vector.  {{{
 
 			/*Fetch vector:*/
-			this->FetchData(&doublevector,&M,&N,vector_enum); //we still have a doublevector, because it might include times in transient mode
+			this->FetchData(&IssmDoublevector,&M,&N,vector_enum); //we still have a IssmDoublevector, because it might include times in transient mode
 			/*Check we got something, otherwise fetch default: */
-			if(doublevector){ 
+			if(IssmDoublevector){
 				defaulting=false;  //we are not defaulting, because  we do have a vector
 			}
@@ -986,6 +1037,6 @@
 				if(default_vector_enum!=NoneEnum){
 					/*yes. fetch it: */
-					this->FetchData(&doublevector,&M,&N,default_vector_enum);
-					if(doublevector){
+					this->FetchData(&IssmDoublevector,&M,&N,default_vector_enum);
+					if(IssmDoublevector){
 						defaulting=false;  //we are not defaulting, because  we do have a vector
 					}
@@ -1007,15 +1058,15 @@
 					Element* element=(Element*)elements->GetObjectByOffset(counter);
 					if(defaulting) element->InputCreate(default_value,vector_enum,code); 
-					else           element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
+					else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 					counter++;
 				}
 			}
 			break; /*}}}*/
-		case 6: //int vector.  {{{2
+		case 6: //int vector{{{
 
 			/*Fetch vector:*/
-			this->FetchData(&doublevector,&M,&N,vector_enum); //we still have a doublevector, because it might include times in transient mode
+			this->FetchData(&IssmDoublevector,&M,&N,vector_enum); //we still have a IssmDoublevector, because it might include times in transient mode
 			/*Check we got something, otherwise fetch default: */
-			if(doublevector){ 
+			if(IssmDoublevector){
 				defaulting=false;  //we are not defaulting, because  we do have a vector
 			}
@@ -1024,6 +1075,6 @@
 				if(default_vector_enum!=NoneEnum){
 					/*yes. fetch it: */
-					this->FetchData(&doublevector,&M,&N,default_vector_enum);
-					if(doublevector){
+					this->FetchData(&IssmDoublevector,&M,&N,default_vector_enum);
+					if(IssmDoublevector){
 						defaulting=false;  //we are not defaulting, because  we do have a vector
 					}
@@ -1045,15 +1096,15 @@
 					Element* element=(Element*)elements->GetObjectByOffset(counter);
 					if(defaulting) element->InputCreate(default_value,vector_enum,code); 
-					else           element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
+					else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 					counter++;
 				}
 			}
 			break; /*}}}*/
-		case 7: //double vector.  {{{2
+		case 7: //IssmDouble vector{{{
 
 			/*Fetch vector:*/
-			this->FetchData(&doublevector,&M,&N,vector_enum);
+			this->FetchData(&IssmDoublevector,&M,&N,vector_enum);
 			/*Check we got something, otherwise fetch default: */
-			if(doublevector){ 
+			if(IssmDoublevector){
 				defaulting=false;  //we are not defaulting, because  we do have a vector
 			}
@@ -1062,6 +1113,6 @@
 				if(default_vector_enum!=NoneEnum){
 					/*yes. fetch it: */
-					this->FetchData(&doublevector,&M,&N,default_vector_enum);
-					if(doublevector){
+					this->FetchData(&IssmDoublevector,&M,&N,default_vector_enum);
+					if(IssmDoublevector){
 						defaulting=false;  //we are not defaulting, because  we do have a vector
 					}
@@ -1083,5 +1134,5 @@
 					Element* element=(Element*)elements->GetObjectByOffset(counter);
 					if(defaulting) element->InputCreate(default_value,vector_enum,code); 
-					else           element->InputCreate(doublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
+					else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 					counter++;
 				}
@@ -1089,19 +1140,54 @@
 
 			break; /*}}}*/
-		default: /*{{{2*/
-			_error_("%s%i%s","data code ",code," not supported yet!");
+		default: /*{{{*/
+			_error2_("data code " << code << " not supported yet!");
 			break;
 			/*}}}*/
 	}
 	/*Free ressources:*/
-	xfree((void**)&doublevector);
-	xfree((void**)&string);
-}
-/*FUNCTION IoModel::SetFilePointerToData{{{1*/
+	xDelete<IssmDouble>(IssmDoublevector);
+	xDelete<char>(string);
+}
+/*FUNCTION IoModel::LastIndex{{{*/
+void IoModel::LastIndex(int *pindex){
+
+	extern int my_rank;
+	int        lastindex,index;
+	int        record_length;
+
+	/*Go find in the binary file, the position of the data we want to fetch: */
+	if(my_rank==0){
+
+		/*First set FILE* position to the beginning of the file: */
+		fseek(fid,0,SEEK_SET);
+
+		/*Now march through file looking for the correct data identifier: */
+		for(;;){
+			/*Read enum for this size of first string name: */
+			if(fread(&index,sizeof(int),1,fid)==0){
+				/*Ok, we have reached the end of the file. break: */
+				break;
+			}
+
+			/*read the record length, and use it to skip this record: */
+			fread(&record_length,sizeof(int),1,fid);
+			fseek(fid,record_length,SEEK_CUR);
+			lastindex=index;
+		}
+	}
+	/*Broadcast code and vector type: */
+#ifdef _HAVE_MPI_
+	MPI_Bcast(&lastindex,1,MPI_INT,0,MPI_COMM_WORLD); 
+#endif
+
+	/*Assign output pointers:*/
+	*pindex=lastindex;
+}
+/*FUNCTION IoModel::SetFilePointerToData{{{*/
 FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){
 
 	extern int my_rank;
 	extern int num_procs;
-	
+
 	int found=0;
 	int record_enum;
@@ -1109,8 +1195,8 @@
 	int record_code; //1 to 7 number
 	int vector_type; //nodal or elementary
- 
+
 	/*Go find in the binary file, the position of the data we want to fetch: */
 	if(my_rank==0){
-	
+
 		/*First set FILE* position to the beginning of the file: */
 		fseek(fid,0,SEEK_SET);
@@ -1124,5 +1210,5 @@
 				break;
 			}
-			
+
 			/*Is this the record sought for? : */
 			if (data_enum==record_enum){
@@ -1144,15 +1230,15 @@
 		}
 	}
-	#ifdef _HAVE_MPI_
+#ifdef _HAVE_MPI_
 	MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(!found)_error_("%s %s ","could not find data with name",EnumToStringx(data_enum));
-	#endif
+	if(!found)_error2_("could not find data with name" << " " << EnumToStringx(data_enum) << " ");
+#endif
 
 	/*Broadcast code and vector type: */
-	#ifdef _HAVE_MPI_
+#ifdef _HAVE_MPI_
 	MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD); 
 	MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
 	if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
-	#endif
+#endif
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/objects/IoModel.h
===================================================================
--- /issm/trunk/src/c/objects/IoModel.h	(revision 12705)
+++ /issm/trunk/src/c/objects/IoModel.h	(revision 12706)
@@ -13,15 +13,15 @@
 class Elements;
 class Param;
-
+class Option;
 
 class IoModel {
 
 	private: 
-		FILE        *fid;         //pointer to input file
-		IssmDouble     **data;        //this dataset holds temporary data, memory intensive.
+		IssmDouble **data;        //this dataset holds temporary data, memory intensive.
 		Parameters  *constants;   //this dataset holds all IssmDouble, int, bool and char *parameters read in from the input file.*
 
 	public:
 		/*This data needs to stay memory resident at all time, even if it's memory intensive: */
+		FILE *fid;         //pointer to input file
 		bool *my_elements;
 		bool *my_nodes;
@@ -41,24 +41,26 @@
 
 		/*Input/Output*/
-		void    CheckEnumSync(void);
-		void    Constant(bool   *poutput,int constant_enum);
-		void    Constant(int    *poutput,int constant_enum);
-		void    Constant(IssmDouble *poutput,int constant_enum);
-		void    Constant(char  **poutput,int constant_enum);
-		Param  *CopyConstantObject(int constant_enum);
+		void        CheckEnumSync(void);
+		void        Constant(bool *poutput,int constant_enum);
+		void        Constant(int *poutput,int constant_enum);
+		void        Constant(IssmDouble *poutput,int constant_enum);
+		void        Constant(char **poutput,int constant_enum);
+		Param      *CopyConstantObject(int constant_enum);
 		IssmDouble *Data(int dataenum);
-		void    DeleteData(int num,...);
-		void    FetchConstants(void);
-		void    FetchData(bool*     pboolean,int data_enum);
-		void    FetchData(int*      pinteger,int data_enum);
-		void    FetchData(IssmDouble*   pscalar,int data_enum);
-		void    FetchData(char**    pstring,int data_enum);
-		void    FetchData(int** pmatrix,int* pM,int* pN,int data_enum);
-		void    FetchData(IssmDouble**  pscalarmatrix,int* pM,int* pN,int data_enum);
-		void    FetchData(char***   pstringarray,int* pnumstrings,int data_enum);
-		void    FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
-		void    FetchData(int num,...);
-		void    FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,IssmDouble default_value=0);
-		FILE*   SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
+		void        DeleteData(int num,...);
+		void        FetchConstants(void);
+		void        FetchData(bool* pboolean,int data_enum);
+		void        FetchData(int* pinteger,int data_enum);
+		void        FetchData(IssmDouble* pscalar,int data_enum);
+		void        FetchData(char** pstring,int data_enum);
+		void        FetchData(int** pmatrix,int* pM,int* pN,int data_enum);
+		void        FetchData(IssmDouble**  pscalarmatrix,int* pM,int* pN,int data_enum);
+		void        FetchData(char***   pstringarray,int* pnumstrings,int data_enum);
+		void        FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
+		void        FetchData(Option **poption,int data_enum);
+		void        FetchData(int num,...);
+		void        FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,IssmDouble default_value=0);
+		void        LastIndex(int *pindex);
+		FILE*       SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
 };
 
Index: /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,5 +20,5 @@
 /*}}}*/
 
-/*FUNCTION  KMLFileToken(FILE* fid,int* pncom=NULL,char*** ppcom=NULL) {{{1*/
+/*FUNCTION  KMLFileToken(FILE* fid,int* pncom=NULL,char*** ppcom=NULL) {{{*/
 char* KMLFileToken(FILE* fid,
 				   int* pncom=NULL,char*** ppcom=NULL){
@@ -127,8 +127,8 @@
 
 //	if      (itag)
-//		_printf_(true,"tag buffer (length=%d):\n",ibuf);
+//		_pprintLine_("tag buffer (length=" << ibuf << "):");
 //	else if (ifield)
-//		_printf_(true,"field buffer (length=%d):\n",ibuf);
-//	_printf_(true,"%s\n",buffer);
+//		_pprintLine_("field buffer (length=" << ibuf << "):");
+//	_pprintLine_(buffer);
 
 	if (!ibuf)
@@ -138,6 +138,5 @@
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenComment(FILE* fid) {{{1*/
+/*FUNCTION  KMLFileTokenComment(FILE* fid) {{{*/
 char* KMLFileTokenComment(FILE* fid){
 
@@ -194,6 +193,6 @@
 		}
 
-//	_printf_(true,"comment buffer (length=%d):\n",ibuf);
-//	_printf_(true,"%s\n",buffer);
+//	_pprintLine_("comment buffer (length=" << ibuf << "):");
+//	_pprintLine_(buffer);
 
 	if (!ibuf)
@@ -203,6 +202,5 @@
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenBuffer {{{1*/
+/*FUNCTION  KMLFileTokenBuffer {{{*/
 void KMLFileTokenBuffer(char** pbuffer,int* pibuf,int* pbuflen,
 						int c,
@@ -228,6 +226,5 @@
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTagName {{{1*/
+/*FUNCTION  KMLFileTagName {{{*/
 char* KMLFileTagName(char* pname,
 					 char* ktag){
@@ -237,6 +234,5 @@
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTagName {{{1*/
+/*FUNCTION  KMLFileTagName {{{*/
 char* KMLFileTagName(char* pname,int *m,int maxlen,
 					 char* ktag){
@@ -248,5 +244,5 @@
 
 	if (strncmp(&ktag[0],"<"        ,1) || strncmp(&ktag[strlen(ktag)-1],">",1))
-		_error_("KMLFileTagName -- Missing tag delimiters in %s.\n",ktag);
+		_error2_("KMLFileTagName -- Missing tag delimiters in " << ktag << ".\n");
 
 /*  strtok modifies ktag, so work on copy  */
@@ -258,5 +254,5 @@
 
 	ktokn=strtok(ktagi,"< >");
-//	_printf_(true,"KMLFileTagName -- initial token=\"%s\".\n",ktokn);
+//	_pprintLine_("KMLFileTagName -- initial token=\"" << ktokn << "\".");
 
 	if (!pname) {
@@ -268,6 +264,6 @@
 
 	if (maxlen && (maxlen < strlen(ktokn))) {
-		_printf_(true,"KMLFileTagName -- string field too short for %s.\n",ktag);
-		_printf_(true,"KMLFileTagName -- \"%s\" truncated to %d characters.\n",ktokn,maxlen);
+		_pprintLine_("KMLFileTagName -- string field too short for " << ktag << ".");
+		_pprintLine_("KMLFileTagName -- \"" << ktokn << "\" truncated to " << maxlen << " characters.");
 		strncpy(pname,ktokn,maxlen);
 	}
@@ -283,6 +279,5 @@
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTagAttrib {{{1*/
+/*FUNCTION  KMLFileTagAttrib {{{*/
 int KMLFileTagAttrib(KML_Object* kobj,
 					 char* ktag){
@@ -305,5 +300,5 @@
 	/*  return first non blank and move past subsequent blank  */
 	ktokn=strtok(ktagi," ");
-//	_printf_(true,"KMLFileTagAttrib -- initial token=\"%s\".\n",ktokn);
+//	_pprintLine_("KMLFileTagAttrib -- initial token=\"" << ktokn << "\".");
 
 	/*  return next non " =?/>" and move past subsequent " =?/>"  */
@@ -312,5 +307,5 @@
 		/*  return next non quote and move past subsequent quote  */
 		ktokv=strtok(NULL,quote);
-//		_printf_(true,"KMLFileTagAttrib -- attribute %s=\"%s\".\n",ktokn,ktokv);
+//		_pprintLine_("KMLFileTagAttrib -- attribute " << ktokn << "=\"" << ktokv << "\".");
 
 /*  add the attribute to the dataset  */
@@ -328,11 +323,10 @@
 		(!strncmp(&ktag[0],"<"        ,1) && !strncmp(&ktag[strlen(ktag)-2],"/>",2)))
 		isolo=1;
-//	_printf_(true,"KMLFileTagAttrib -- isolo=%d.\n",isolo);
+//	_pprintLine_("KMLFileTagAttrib -- isolo=" << isolo << ".");
 
 	return(isolo);
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenParse {{{1*/
+/*FUNCTION  KMLFileTokenParse {{{*/
 int KMLFileTokenParse(int* pival,
 					  char* ktag,
@@ -346,5 +340,5 @@
 							NULL,NULL)) ||
 		(kstr[0] == '<'))
-		_error_("KMLFileTokenParse -- Missing integer field for %s.\n",ktag);
+		_error2_("KMLFileTokenParse -- Missing integer field for " << ktag << ".\n");
 
 	sscanf(kstr,"%d",pival);
@@ -359,18 +353,15 @@
 			(kstr[1] != '/') ||
 			(strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
-			_error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
+		  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
 		else
 			xfree((void**)&kstr);
 
-//	_printf_(true,"KMLFileTokenParse -- %s=%d.\n",ktag,*pival);
+//	_pprintLine_("KMLFileTokenParse -- " << ktag << "=" << *pival << ".");
 
 	return(0);
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenParse {{{1*/
-int KMLFileTokenParse(bool* pbval,
-					  char* ktag,
-					  FILE* fid){
+/*FUNCTION  KMLFileTokenParse {{{*/
+int KMLFileTokenParse(bool* pbval, char* ktag, FILE* fid){
 
 	int     ival;
@@ -382,5 +373,5 @@
 							NULL,NULL)) ||
 		(kstr[0] == '<'))
-		_error_("KMLFileTokenParse -- Missing bool field for %s.\n",ktag);
+	  {_error2_("KMLFileTokenParse -- Missing bool field for " << ktag << ".\n");}
 
 	sscanf(kstr,"%d",&ival);
@@ -396,15 +387,14 @@
 			(kstr[1] != '/') ||
 			(strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
-			_error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
+		  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
 		else
 			xfree((void**)&kstr);
 
-//	_printf_(true,"KMLFileTokenParse -- %s=%s.\n",ktag,(*pbval ? "true" : "false"));
+//	_pprintLine_("KMLFileTokenParse -- " << ktag << "=" << (*pbval ? "true" : "false") << ".");
 
 	return(0);
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenParse {{{1*/
+/*FUNCTION  KMLFileTokenParse {{{*/
 char* KMLFileTokenParse(char* pstr,
 						char* ktag,
@@ -416,6 +406,5 @@
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenParse {{{1*/
+/*FUNCTION  KMLFileTokenParse {{{*/
 char* KMLFileTokenParse(char* pstr,int *m,int maxlen,
 						char* ktag,
@@ -429,5 +418,5 @@
 							NULL,NULL)) ||
 		(kstr[0] == '<'))
-		_error_("KMLFileTokenParse -- Missing string field for %s.\n",ktag);
+		_error2_("KMLFileTokenParse -- Missing string field for " << ktag << ".\n");
 
 	if (!pstr) {
@@ -439,6 +428,6 @@
 
 	if (maxlen && (maxlen < strlen(kstr))) {
-		_printf_(true,"KMLFileTokenParse -- string field too short for %s.\n",ktag);
-		_printf_(true,"KMLFileTokenParse -- \"%s\" truncated to %d characters.\n",kstr,maxlen);
+		_pprintLine_("KMLFileTokenParse -- string field too short for " << ktag << ".");
+		_pprintLine_("KMLFileTokenParse -- \"" << kstr << "\" truncated to " << maxlen << " characters.");
 		strncpy(pstr,kstr,maxlen);
 	}
@@ -459,15 +448,14 @@
 			(kstr[1] != '/') ||
 			(strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
-			_error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
+		  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
 		else
 			xfree((void**)&kstr);
 
-//	_printf_(true,"KMLFileTokenParse -- %s=\"%s\".\n",ktag,pstr);
+//	_pprintLine_("KMLFileTokenParse -- " << ktag << "=\"" << pstr << "\".");
 
 	return(pstr);
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenParse {{{1*/
+/*FUNCTION  KMLFileTokenParse {{{*/
 int KMLFileTokenParse(float* pfval,
 					  char* ktag,
@@ -481,5 +469,5 @@
 							NULL,NULL)) ||
 		(kstr[0] == '<'))
-		_error_("KMLFileTokenParse -- Missing integer field for %s.\n",ktag);
+	  {_error2_("KMLFileTokenParse -- Missing integer field for " << ktag << ".\n");}
 
 	sscanf(kstr,"%g",pfval);
@@ -494,15 +482,14 @@
 			(kstr[1] != '/') ||
 			(strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
-			_error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
+		  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
 		else
 			xfree((void**)&kstr);
 
-//	_printf_(true,"KMLFileTokenParse -- %s=%g.\n",ktag,*pfval);
+//	_pprintLine_("KMLFileTokenParse -- " << ktag << "=" << *pfval << ".");
 
 	return(0);
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenParse {{{1*/
+/*FUNCTION  KMLFileTokenParse {{{*/
 int KMLFileTokenParse(double* pdval,
 					  char* ktag,
@@ -516,5 +503,5 @@
 							NULL,NULL)) ||
 		(kstr[0] == '<'))
-		_error_("KMLFileTokenParse -- Missing integer field for %s.\n",ktag);
+		_error2_("KMLFileTokenParse -- Missing integer field for " << ktag << ".\n");
 
 	sscanf(kstr,"%lg",pdval);
@@ -529,15 +516,14 @@
 			(kstr[1] != '/') ||
 			(strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
-			_error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
+		  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
 		else
 			xfree((void**)&kstr);
 
-//	_printf_(true,"KMLFileTokenParse -- %s=%g.\n",ktag,*pdval);
+//	_pprintLine_("KMLFileTokenParse -- " << ktag << "=" << *pdval << ".");
 
 	return(0);
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenParse {{{1*/
+/*FUNCTION  KMLFileTokenParse {{{*/
 int KMLFileTokenParse(double **pdval,int* m,int maxlen,
 					  char* ktag,
@@ -554,5 +540,5 @@
 							NULL,NULL)) ||
 		(kstr[0] == '<'))
-		_error_("KMLFileTokenParse -- Missing double [m] field for %s.\n",ktag);
+		_error2_("KMLFileTokenParse -- Missing double [m] field for " << ktag << ".\n");
 
 	if (!*pdval)
@@ -568,5 +554,5 @@
 		i++;
 		if (maxlen && (maxlen < i+1))
-			_error_("KMLFileTokenParse -- Double [m] field too short for %s.\n",ktag);
+			_error2_("KMLFileTokenParse -- Double [m] field too short for " << ktag << ".\n");
 		sscanf(ktok,"%lg",&((*pdval)[i]));
 		ktok=strtok(NULL,delim);
@@ -588,17 +574,16 @@
 			(kstr[1] != '/') ||
 			(strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
-			_error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
+		  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
 		else
 			xfree((void**)&kstr);
 
-//	_printf_(true,"KMLFileTokenParse -- %s=...\n",ktag);
+//	_pprintLine_("KMLFileTokenParse -- " << ktag << "=...");
 //	for (j=0; j<=i; j++)
-//		_printf_(true,"   [%d]: %lg\n",j,(*pdval)[j]);
+//		_pprintLine_("   [" << j << "]: " << (*pdval)[j] << "g");
 
 	return(0);
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTokenParse {{{1*/
+/*FUNCTION  KMLFileTokenParse {{{*/
 int KMLFileTokenParse(double (**pdval3)[3],int* m,int maxlen,
 					  char* ktag,
@@ -615,5 +600,5 @@
 							NULL,NULL)) ||
 		(kstr[0] == '<'))
-		_error_("KMLFileTokenParse -- Missing double [m x 3] field for %s.\n",ktag);
+		_error2_("KMLFileTokenParse -- Missing double [m x 3] field for " << ktag << ".\n");
 
 	if (!*pdval3)
@@ -632,5 +617,5 @@
 			j=0;
 			if (maxlen && (maxlen < i+1))
-				_error_("KMLFileTokenParse -- Double [m x 3] field too short for %s.\n",ktag);
+				_error2_("KMLFileTokenParse -- Double [m x 3] field too short for " << ktag << ".\n");
 		}
 		sscanf(ktok,"%lg",&((*pdval3)[i][j]));
@@ -646,5 +631,5 @@
 
 	if (j != 2)
-		_printf_(true,"KMLFileTokenParse -- Double [m x 3] field for %s does not have multiple of 3 values.\n",ktag);
+		_pprintLine_("KMLFileTokenParse -- Double [m x 3] field for " << ktag << " does not have multiple of 3 values.");
 
 /*  get additional token and compare to closing tag  */
@@ -656,17 +641,16 @@
 			(kstr[1] != '/') ||
 			(strncmp(&(kstr[2]),&(ktag[1]),strlen(ktag)-1)))
-			_error_("KMLFileTokenParse -- Missing closing tag for %s.\n",ktag);
+		  {_error2_("KMLFileTokenParse -- Missing closing tag for " << ktag << ".\n");}
 		else
 			xfree((void**)&kstr);
 
-//	_printf_(true,"KMLFileTokenParse -- %s=...\n",ktag);
+//	_pprintLine_("KMLFileTokenParse -- " << ktag << "=...");
 //	for (j=0; j<=i; j++)
-//		_printf_(true,"   [%d][0-2]: %lg,%lg,%lg\n",j,(*pdval3)[j][0],(*pdval3)[j][1],(*pdval3)[j][2]);
+//		_pprintLine_("   [" << j << "][0-2]: " << (*pdval3)[j][0] << "g," << (*pdval3)[j][1] << "g," << (*pdval3)[j][2] << "g");
 
 	return(0);
 }
 /*}}}*/
-
-/*FUNCTION  KMLFileTagSkip {{{1*/
+/*FUNCTION  KMLFileTagSkip {{{*/
 int KMLFileTagSkip(char* ktag,
 				   FILE* fid){
@@ -677,5 +661,5 @@
 	opening tag, must find corresponding closing tag  */
 
-	_printf_(true,"KMLFileTagSkip -- input tag %s.\n",ktag);
+	_pprintLine_("KMLFileTagSkip -- input tag " << ktag << ".");
 
 /*  if next token is a closing tag, compare to input  */
@@ -686,5 +670,5 @@
 				 (kstr[1] == '/') &&
 				 (!strncmp(&(kstr[2]),&(ktag[1]),(strcspn(ktag," >")-1)/sizeof(char)))) {
-			_printf_(true,"KMLFileTagSkip -- closing tag %s.\n",kstr);
+			_pprintLine_("KMLFileTagSkip -- closing tag " << kstr << ".");
 			xfree((void**)&kstr);
 			return(0);
@@ -695,5 +679,5 @@
 		else if ((kstr[0] == '<') &&
 				 (kstr[1] != '/')) {
-			_printf_(true,"KMLFileTagSkip -- opening tag %s.\n",kstr);
+			_pprintLine_("KMLFileTagSkip -- opening tag " << kstr << ".");
 			KMLFileTagSkip(kstr,
 						   fid);
@@ -704,5 +688,5 @@
 		else if ((kstr[0] == '<') &&
 				 (kstr[1] == '/')) {
-			_error_("KMLFileTagSkip -- Unexpected closing tag %s.\n",kstr);
+			_error2_("KMLFileTagSkip -- Unexpected closing tag " << kstr << ".\n");
 		}
 
@@ -710,8 +694,7 @@
 	}
 
-	_error_("KMLFileTokenParse -- Corresponding closing tag for %s not found.\n",ktag);
+	_error2_("KMLFileTokenParse -- Corresponding closing tag for " << ktag << " not found.\n");
 
 	return(0);
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _KMLFILEREADUTILS_H
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
Index: /issm/trunk/src/c/objects/KML/KML_Attribute.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Attribute.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Attribute.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Attribute::KML_Attribute(){{{1*/
+/*FUNCTION KML_Attribute::KML_Attribute(){{{*/
 KML_Attribute::KML_Attribute(){
 
@@ -29,5 +29,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Attribute::~KML_Attribute(){{{1*/
+/*FUNCTION KML_Attribute::~KML_Attribute(){{{*/
 KML_Attribute::~KML_Attribute(){
 
@@ -39,5 +39,5 @@
 
 /*Other*/
-/*FUNCTION KML_Attribute::Echo {{{1*/
+/*FUNCTION KML_Attribute::Echo {{{*/
 void  KML_Attribute::Echo(){
 
@@ -45,13 +45,13 @@
 	bool  flag=true;
 
-	_printf_(flag,"    ");
+	if(flag) _pprintString_("    ");
 	for (i=0;i<10-strlen(name);i++)
-		_printf_(flag," ");
-	_printf_(flag,"%s: \"%s\"\n",name,value);
+		if(flag) _pprintString_(" ");
+	if(flag) _pprintLine_(name << ": \"" << value << "\"");
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Attribute::DeepEcho {{{1*/
+/*FUNCTION KML_Attribute::DeepEcho {{{*/
 void  KML_Attribute::DeepEcho(){
 
@@ -63,5 +63,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Attribute::DeepEcho {{{1*/
+/*FUNCTION KML_Attribute::DeepEcho {{{*/
 void  KML_Attribute::DeepEcho(const char* indent){
 
@@ -69,13 +69,13 @@
 	bool  flag=true;
 
-	_printf_(flag,"%s    ",indent);
+	if(flag) _pprintString_(indent << "    ");
 	for (i=0;i<10-strlen(name);i++)
-		_printf_(flag," ");
-	_printf_(flag,"%s: \"%s\"\n",name,value);
+		if(flag) _pprintString_(" ");
+	if(flag) _pprintLine_(name << ": \"" << value << "\"");
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Attribute::Write {{{1*/
+/*FUNCTION KML_Attribute::Write {{{*/
 void  KML_Attribute::Write(FILE* filout,const char* indent){
 
@@ -87,5 +87,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Attribute::Read {{{1*/
+/*FUNCTION KML_Attribute::Read {{{*/
 void  KML_Attribute::Read(FILE* fid,char* kstr){
 
@@ -97,5 +97,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Attribute::Alloc {{{1*/
+/*FUNCTION KML_Attribute::Alloc {{{*/
 void  KML_Attribute::Alloc(const char* namei,const char* valuei){
 
@@ -109,5 +109,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Attribute::Add {{{1*/
+/*FUNCTION KML_Attribute::Add {{{*/
 void  KML_Attribute::Add(DataSet* attrib){
 
@@ -117,5 +117,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Attribute::Get {{{1*/
+/*FUNCTION KML_Attribute::Get {{{*/
 void  KML_Attribute::Get(char** pvalueo,char* deflt){
 
Index: /issm/trunk/src/c/objects/KML/KML_Attribute.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Attribute.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Attribute.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _KML_ATTRIBUTE_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -22,19 +22,19 @@
 		char* value;
 
-		/*KML_Attribute constructors, destructors {{{1*/
+		/*KML_Attribute constructors, destructors {{{*/
 		KML_Attribute();
 		~KML_Attribute();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		virtual void  Echo();
 		virtual void  DeepEcho();
 		virtual void  DeepEcho(const char* indent);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_ColorStyle.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_ColorStyle.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_ColorStyle.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_ColorStyle::KML_ColorStyle(){{{1*/
+/*FUNCTION KML_ColorStyle::KML_ColorStyle(){{{*/
 KML_ColorStyle::KML_ColorStyle(){
 
@@ -29,5 +29,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_ColorStyle::~KML_ColorStyle(){{{1*/
+/*FUNCTION KML_ColorStyle::~KML_ColorStyle(){{{*/
 KML_ColorStyle::~KML_ColorStyle(){
 
@@ -38,5 +38,5 @@
 
 /*Other*/
-/*FUNCTION KML_ColorStyle::Echo {{{1*/
+/*FUNCTION KML_ColorStyle::Echo {{{*/
 void  KML_ColorStyle::Echo(){
 
@@ -45,11 +45,11 @@
 	KML_SubStyle::Echo();
 
-	_printf_(flag,"         color: %s\n"          ,color);
-	_printf_(flag,"     colormode: %s\n"          ,colormode);
+	if(flag) _pprintLine_("         color: " << color);
+	if(flag) _pprintLine_("     colormode: " << colormode);
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_ColorStyle::DeepEcho {{{1*/
+/*FUNCTION KML_ColorStyle::DeepEcho {{{*/
 void  KML_ColorStyle::DeepEcho(){
 
@@ -61,5 +61,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_ColorStyle::DeepEcho {{{1*/
+/*FUNCTION KML_ColorStyle::DeepEcho {{{*/
 void  KML_ColorStyle::DeepEcho(const char* indent){
 
@@ -68,11 +68,9 @@
 	KML_SubStyle::DeepEcho(indent);
 
-	_printf_(flag,"%s         color: %s\n"          ,indent,color);
-	_printf_(flag,"%s     colormode: %s\n"          ,indent,colormode);
-
-	return;
+	if(flag) _pprintLine_(indent << "         color: " << color);
+	if(flag) _pprintLine_(indent << "     colormode: " << colormode);
 }
 /*}}}*/
-/*FUNCTION KML_ColorStyle::Write {{{1*/
+/*FUNCTION KML_ColorStyle::Write {{{*/
 void  KML_ColorStyle::Write(FILE* filout,const char* indent){
 
@@ -87,5 +85,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_ColorStyle::Read {{{1*/
+/*FUNCTION KML_ColorStyle::Read {{{*/
 void  KML_ColorStyle::Read(FILE* fid,char* kstr){
 
@@ -95,16 +93,12 @@
 		return;
 	else if (!strncmp(kstr,"</",2))
-		_error_("KML_ColorStyle::Read -- Unexpected closing tag %s.\n",kstr);
+	  {_error2_("KML_ColorStyle::Read -- Unexpected closing tag " << kstr);}
 	else if (strncmp(kstr,"<",1))
-		_error_("KML_ColorStyle::Read -- Unexpected field \"%s\".\n",kstr);
+	  {_error2_("KML_ColorStyle::Read -- Unexpected field \"" << kstr << "\"");}
 
 	else if (!strcmp(kstr,"<color>"))
-		KMLFileTokenParse( color     ,NULL,KML_COLORSTYLE_COLOR_LENGTH,
-						  kstr,
-						  fid);
+		KMLFileTokenParse( color     ,NULL,KML_COLORSTYLE_COLOR_LENGTH, kstr, fid);
 	else if (!strcmp(kstr,"<colorMode>"))
-		KMLFileTokenParse( colormode ,NULL,KML_COLORSTYLE_COLORMODE_LENGTH,
-						  kstr,
-						  fid);
+		KMLFileTokenParse( colormode ,NULL,KML_COLORSTYLE_COLORMODE_LENGTH, kstr, fid);
 
 	else if (!strncmp(kstr,"<",1))
Index: /issm/trunk/src/c/objects/KML/KML_ColorStyle.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_ColorStyle.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_ColorStyle.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -25,9 +25,9 @@
 		char  colormode[KML_COLORSTYLE_COLORMODE_LENGTH+1];
 
-		/*KML_ColorStyle constructors, destructors {{{1*/
+		/*KML_ColorStyle constructors, destructors {{{*/
 		KML_ColorStyle();
 		~KML_ColorStyle();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -35,11 +35,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Comment.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Comment.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Comment.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Comment::KML_Comment(){{{1*/
+/*FUNCTION KML_Comment::KML_Comment(){{{*/
 KML_Comment::KML_Comment(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Comment::~KML_Comment(){{{1*/
+/*FUNCTION KML_Comment::~KML_Comment(){{{*/
 KML_Comment::~KML_Comment(){
 
@@ -37,16 +37,16 @@
 
 /*Other*/
-/*FUNCTION KML_Comment::Echo {{{1*/
+/*FUNCTION KML_Comment::Echo {{{*/
 void  KML_Comment::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"    ");
-	_printf_(flag,"%s\n",value);
+	if(flag) _pprintString_("    ");
+	if(flag) _pprintLine_(value);
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Comment::DeepEcho {{{1*/
+/*FUNCTION KML_Comment::DeepEcho {{{*/
 void  KML_Comment::DeepEcho(){
 
@@ -58,16 +58,16 @@
 }
 /*}}}*/
-/*FUNCTION KML_Comment::DeepEcho {{{1*/
+/*FUNCTION KML_Comment::DeepEcho {{{*/
 void  KML_Comment::DeepEcho(const char* indent){
 
 	bool  flag=true;
 
-	_printf_(flag,"%s    ",indent);
-	_printf_(flag,"%s\n",value);
+	if(flag) _pprintString_(indent << "    ");
+	if(flag) _pprintLine_(value);
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Comment::Write {{{1*/
+/*FUNCTION KML_Comment::Write {{{*/
 void  KML_Comment::Write(FILE* filout,const char* indent){
 
@@ -81,5 +81,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Comment::Read {{{1*/
+/*FUNCTION KML_Comment::Read {{{*/
 void  KML_Comment::Read(FILE* fid,char* kstr){
 
@@ -91,5 +91,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Comment::Alloc {{{1*/
+/*FUNCTION KML_Comment::Alloc {{{*/
 void  KML_Comment::Alloc(const char* valuei){
 
@@ -100,5 +100,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Comment::Add {{{1*/
+/*FUNCTION KML_Comment::Add {{{*/
 void  KML_Comment::Add(DataSet* commnt){
 
@@ -108,5 +108,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Comment::Get {{{1*/
+/*FUNCTION KML_Comment::Get {{{*/
 void  KML_Comment::Get(char** pvalueo){
 
Index: /issm/trunk/src/c/objects/KML/KML_Comment.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Comment.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Comment.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _KML_COMMENT_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -22,19 +22,19 @@
 		char* value;
 
-		/*KML_Comment constructors, destructors {{{1*/
+		/*KML_Comment constructors, destructors {{{*/
 		KML_Comment();
 		~KML_Comment();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		virtual void  Echo();
 		virtual void  DeepEcho();
 		virtual void  DeepEcho(const char* indent);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Container.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Container.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Container.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Container::KML_Container(){{{1*/
+/*FUNCTION KML_Container::KML_Container(){{{*/
 KML_Container::KML_Container(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Container::~KML_Container(){{{1*/
+/*FUNCTION KML_Container::~KML_Container(){{{*/
 KML_Container::~KML_Container(){
 
@@ -40,5 +40,5 @@
 
 /*Other*/
-/*FUNCTION KML_Container::Echo {{{1*/
+/*FUNCTION KML_Container::Echo {{{*/
 void  KML_Container::Echo(){
 
@@ -47,10 +47,10 @@
 	KML_Feature::Echo();
 
-	_printf_(flag,"       feature: (size=%d)\n" ,feature->Size());
+	if(flag) _pprintLine_("       feature: (size=" << feature->Size() << ")");
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Container::DeepEcho {{{1*/
+/*FUNCTION KML_Container::DeepEcho {{{*/
 void  KML_Container::DeepEcho(){
 
@@ -62,5 +62,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Container::DeepEcho {{{1*/
+/*FUNCTION KML_Container::DeepEcho {{{*/
 void  KML_Container::DeepEcho(const char* indent){
 
@@ -78,15 +78,15 @@
 	if (feature->Size())
 		for (i=0; i<feature->Size(); i++) {
-			_printf_(flag,"%s       feature: -------- begin [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "       feature: -------- begin [" << i << "] --------");
 			((KML_Feature *)feature->GetObjectByOffset(i))->DeepEcho(indent2);
-			_printf_(flag,"%s       feature: --------  end  [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "       feature: --------  end  [" << i << "] --------");
 		}
 	else
-		_printf_(flag,"%s       feature: [empty]\n"    ,indent);
+		if(flag) _pprintLine_(indent << "       feature: [empty]");
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Container::Write {{{1*/
+/*FUNCTION KML_Container::Write {{{*/
 void  KML_Container::Write(FILE* filout,const char* indent){
 
@@ -108,5 +108,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Container::Read {{{1*/
+/*FUNCTION KML_Container::Read {{{*/
 void  KML_Container::Read(FILE* fid,char* kstr){
 
@@ -120,7 +120,7 @@
 	}
 	else if (!strncmp(kstr,"</",2))
-		_error_("KML_Container::Read -- Unexpected closing tag %s.\n",kstr);
+	  {_error2_("KML_Container::Read -- Unexpected closing tag " << kstr );}
 	else if (strncmp(kstr,"<",1))
-		_error_("KML_Container::Read -- Unexpected field \"%s\".\n",kstr);
+	  {_error2_("KML_Container::Read -- Unexpected field \"" << kstr << "\"");}
 
 	else if (!strncmp(kstr,"<Placemark",10)) {
@@ -154,5 +154,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Container::WriteExp {{{1*/
+/*FUNCTION KML_Container::WriteExp {{{*/
 void  KML_Container::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
Index: /issm/trunk/src/c/objects/KML/KML_Container.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Container.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Container.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -22,9 +22,9 @@
 		DataSet* feature;
 
-		/*KML_Container constructors, destructors {{{1*/
+		/*KML_Container constructors, destructors {{{*/
 		KML_Container();
 		~KML_Container();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -33,11 +33,11 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Document.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Document.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Document.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Document::KML_Document(){{{1*/
+/*FUNCTION KML_Document::KML_Document(){{{*/
 KML_Document::KML_Document(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Document::~KML_Document(){{{1*/
+/*FUNCTION KML_Document::~KML_Document(){{{*/
 KML_Document::~KML_Document(){
 
@@ -37,10 +37,10 @@
 
 /*Other*/
-/*FUNCTION KML_Document::Echo {{{1*/
+/*FUNCTION KML_Document::Echo {{{*/
 void  KML_Document::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Document:\n");
+	if(flag) _pprintLine_("KML_Document:");
 	KML_Container::Echo();
 
@@ -49,5 +49,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Document::DeepEcho {{{1*/
+/*FUNCTION KML_Document::DeepEcho {{{*/
 void  KML_Document::DeepEcho(){
 
@@ -60,10 +60,10 @@
 /*}}}*/
 
-/*FUNCTION KML_Document::DeepEcho {{{1*/
+/*FUNCTION KML_Document::DeepEcho {{{*/
 void  KML_Document::DeepEcho(const char* indent){
 
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_Document:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_Document:");
 	KML_Container::DeepEcho(indent);
 
@@ -72,5 +72,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Document::Write {{{1*/
+/*FUNCTION KML_Document::Write {{{*/
 void  KML_Document::Write(FILE* filout,const char* indent){
 
@@ -88,5 +88,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Document::Read {{{1*/
+/*FUNCTION KML_Document::Read {{{*/
 void  KML_Document::Read(FILE* fid,char* kstr){
 
@@ -110,7 +110,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_Document::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_Document::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_Document::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_Document::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strncmp(kstri,"<",1))
Index: /issm/trunk/src/c/objects/KML/KML_Document.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Document.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Document.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -20,9 +20,9 @@
 	public:
 
-		/*KML_Document constructors, destructors {{{1*/
+		/*KML_Document constructors, destructors {{{*/
 		KML_Document();
 		~KML_Document();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -30,11 +30,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Feature.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Feature.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Feature.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Feature::KML_Feature(){{{1*/
+/*FUNCTION KML_Feature::KML_Feature(){{{*/
 KML_Feature::KML_Feature(){
 
@@ -35,5 +35,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Feature::~KML_Feature(){{{1*/
+/*FUNCTION KML_Feature::~KML_Feature(){{{*/
 KML_Feature::~KML_Feature(){
 
@@ -47,5 +47,5 @@
 
 /*Other*/
-/*FUNCTION KML_Feature::Echo {{{1*/
+/*FUNCTION KML_Feature::Echo {{{*/
 void  KML_Feature::Echo(){
 
@@ -54,17 +54,16 @@
 	KML_Object::Echo();
 
-	_printf_(flag,"          name: \"%s\"\n"    ,name);
-	_printf_(flag,"    visibility: %s\n"        ,(visibility ? "true" : "false"));
-	_printf_(flag,"          open: %s\n"        ,(open ? "true" : "false"));
-	_printf_(flag,"       snippet: \"%s\"\n"    ,snippet);
-	_printf_(flag,"      descript: \"%s\"\n"    ,descript);
-	_printf_(flag,"      styleurl: \"%s\"\n"    ,styleurl);
-	_printf_(flag,"         style: (size=%d)\n" ,style->Size());
+	if(flag) _pprintLine_("          name: \"" << name << "\"");
+	if(flag) _pprintLine_("    visibility: " << (visibility ? "true" : "false"));
+	if(flag) _pprintLine_("          open: " << (open ? "true" : "false"));
+	if(flag) _pprintLine_("       snippet: \"" << snippet << "\"");
+	if(flag) _pprintLine_("      descript: \"" << descript << "\"");
+	if(flag) _pprintLine_("      styleurl: \"" << styleurl << "\"");
+	if(flag) _pprintLine_("         style: (size=" << style->Size() << ")");
 
 	return;
 }
 /*}}}*/
-
-/*FUNCTION KML_Feature::DeepEcho {{{1*/
+/*FUNCTION KML_Feature::DeepEcho {{{*/
 void  KML_Feature::DeepEcho(){
 
@@ -76,6 +75,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_Feature::DeepEcho {{{1*/
+/*FUNCTION KML_Feature::DeepEcho {{{*/
 void  KML_Feature::DeepEcho(const char* indent){
 
@@ -86,10 +84,10 @@
 	KML_Object::DeepEcho(indent);
 
-	_printf_(flag,"%s          name: \"%s\"\n"      ,indent,name);
-	_printf_(flag,"%s    visibility: %s\n"          ,indent,(visibility ? "true" : "false"));
-	_printf_(flag,"%s          open: %s\n"          ,indent,(open ? "true" : "false"));
-	_printf_(flag,"%s       snippet: \"%s\"\n"      ,indent,snippet);
-	_printf_(flag,"%s      descript: \"%s\"\n"      ,indent,descript);
-	_printf_(flag,"%s      styleurl: \"%s\"\n"      ,indent,styleurl);
+	if(flag) _pprintLine_(indent << "          name: \"" << name << "\"");
+	if(flag) _pprintLine_(indent << "    visibility: " << (visibility ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "          open: " << (open ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "       snippet: \"" << snippet << "\"");
+	if(flag) _pprintLine_(indent << "      descript: \"" << descript << "\"");
+	if(flag) _pprintLine_(indent << "      styleurl: \"" << styleurl << "\"");
 
 /*  loop over any styles for the feature  */
@@ -100,16 +98,15 @@
 	if (style->Size())
 		for (i=0; i<style->Size(); i++) {
-			_printf_(flag,"%s         style: -------- begin [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "         style: -------- begin [" << i << "] --------");
 			((KML_Style *)style->GetObjectByOffset(i))->DeepEcho(indent2);
-			_printf_(flag,"%s         style: --------  end  [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "         style: --------  end  [" << i << "] --------");
 		}
 	else
-		_printf_(flag,"%s         style: [empty]\n"    ,indent);
+		if(flag) _pprintLine_(indent << "         style: [empty]");
 
 	return;
 }
 /*}}}*/
-
-/*FUNCTION KML_Feature::Write {{{1*/
+/*FUNCTION KML_Feature::Write {{{*/
 void  KML_Feature::Write(FILE* filout,const char* indent){
 
@@ -142,6 +139,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_Feature::Read {{{1*/
+/*FUNCTION KML_Feature::Read {{{*/
 void  KML_Feature::Read(FILE* fid,char* kstr){
 
@@ -153,7 +149,7 @@
 		return;
 	else if (!strncmp(kstr,"</",2))
-		_error_("KML_Feature::Read -- Unexpected closing tag %s.\n",kstr);
+	  {_error2_("KML_Feature::Read -- Unexpected closing tag " << kstr);}
 	else if (strncmp(kstr,"<",1))
-		_error_("KML_Feature::Read -- Unexpected field \"%s\".\n",kstr);
+	  {_error2_("KML_Feature::Read -- Unexpected field \"" << kstr << "\"");}
 
 	else if (!strncmp(kstr,"<Style", 6)) {
@@ -164,27 +160,15 @@
 
 	else if (!strcmp(kstr,"<name>"))
-		KMLFileTokenParse( name      ,NULL,KML_FEATURE_NAME_LENGTH,
-						  kstr,
-						  fid);
+		KMLFileTokenParse( name      ,NULL,KML_FEATURE_NAME_LENGTH, kstr, fid);
 	else if (!strcmp(kstr,"<visibility>"))
-		KMLFileTokenParse(&visibility,
-						  kstr,
-						  fid);
+		KMLFileTokenParse(&visibility, kstr, fid);
 	else if (!strcmp(kstr,"<open>"))
-		KMLFileTokenParse(&open      ,
-						  kstr,
-						  fid);
+		KMLFileTokenParse(&open      , kstr, fid);
 	else if (!strncmp(kstr,"<snippet", 8))
-		KMLFileTokenParse( snippet   ,NULL,KML_FEATURE_SNIPPET_LENGTH,
-						  kstr,
-						  fid);
+		KMLFileTokenParse( snippet   ,NULL,KML_FEATURE_SNIPPET_LENGTH, kstr, fid);
 	else if (!strcmp(kstr,"<description>"))
-		KMLFileTokenParse( descript  ,NULL,KML_FEATURE_DESCRIPT_LENGTH,
-						  kstr,
-						  fid);
+		KMLFileTokenParse( descript  ,NULL,KML_FEATURE_DESCRIPT_LENGTH, kstr, fid);
 	else if (!strcmp(kstr,"<styleUrl>"))
-		KMLFileTokenParse( styleurl  ,NULL,KML_FEATURE_STYLEURL_LENGTH,
-						  kstr,
-						  fid);
+		KMLFileTokenParse( styleurl  ,NULL,KML_FEATURE_STYLEURL_LENGTH, kstr, fid);
 
 	else if (!strncmp(kstr,"<",1))
@@ -194,3 +178,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_Feature.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Feature.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Feature.h	(revision 12706)
@@ -12,5 +12,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -34,9 +34,9 @@
 		DataSet* style;
 
-		/*KML_Feature constructors, destructors {{{1*/
+		/*KML_Feature constructors, destructors {{{*/
 		KML_Feature();
 		~KML_Feature();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -44,11 +44,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_File.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_File.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_File.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_File::KML_File(){{{1*/
+/*FUNCTION KML_File::KML_File(){{{*/
 KML_File::KML_File(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_File::~KML_File(){{{1*/
+/*FUNCTION KML_File::~KML_File(){{{*/
 KML_File::~KML_File(){
 
@@ -37,10 +37,10 @@
 
 /*Other*/
-/*FUNCTION KML_File::Echo {{{1*/
+/*FUNCTION KML_File::Echo {{{*/
 void  KML_File::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_File:\n");
+	if(flag) _pprintLine_("KML_File:");
 	KML_Object::Echo();
 
@@ -48,5 +48,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_File::DeepEcho {{{1*/
+/*FUNCTION KML_File::DeepEcho {{{*/
 void  KML_File::DeepEcho(){
 
@@ -58,10 +58,10 @@
 }
 /*}}}*/
-/*FUNCTION KML_File::DeepEcho {{{1*/
+/*FUNCTION KML_File::DeepEcho {{{*/
 void  KML_File::DeepEcho(const char* indent){
 
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_File:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_File:");
 	KML_Object::DeepEcho(indent);
 
@@ -69,5 +69,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_File::Write {{{1*/
+/*FUNCTION KML_File::Write {{{*/
 void  KML_File::Write(FILE* filout,const char* indent){
 
@@ -84,5 +84,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_File::Read {{{1*/
+/*FUNCTION KML_File::Read {{{*/
 void  KML_File::Read(FILE* fid,char* kstr){
 
@@ -107,7 +107,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_File::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_File::Read -- Unexpected closing tag " << kstri << ".");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_File::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_File::Read -- Unexpected field \"" << kstri << "\"");}
 
 		else if (!strncmp(kstri,"<",1))
@@ -126,5 +126,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_File::WriteExp {{{1*/
+/*FUNCTION KML_File::WriteExp {{{*/
 void  KML_File::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
Index: /issm/trunk/src/c/objects/KML/KML_File.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_File.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_File.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -20,9 +20,9 @@
 	public:
 
-		/*KML_File constructors, destructors {{{1*/
+		/*KML_File constructors, destructors {{{*/
 		KML_File();
 		~KML_File();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -31,11 +31,11 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Folder.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Folder.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Folder.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Folder::KML_Folder(){{{1*/
+/*FUNCTION KML_Folder::KML_Folder(){{{*/
 KML_Folder::KML_Folder(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Folder::~KML_Folder(){{{1*/
+/*FUNCTION KML_Folder::~KML_Folder(){{{*/
 KML_Folder::~KML_Folder(){
 
@@ -37,10 +37,10 @@
 
 /*Other*/
-/*FUNCTION KML_Folder::Echo {{{1*/
+/*FUNCTION KML_Folder::Echo {{{*/
 void  KML_Folder::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Folder:\n");
+	if(flag) _pprintLine_("KML_Folder:");
 	KML_Container::Echo();
 
@@ -49,5 +49,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Folder::DeepEcho {{{1*/
+/*FUNCTION KML_Folder::DeepEcho {{{*/
 void  KML_Folder::DeepEcho(){
 
@@ -60,10 +60,10 @@
 /*}}}*/
 
-/*FUNCTION KML_Folder::DeepEcho {{{1*/
+/*FUNCTION KML_Folder::DeepEcho {{{*/
 void  KML_Folder::DeepEcho(const char* indent){
 
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_Folder:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_Folder:");
 	KML_Container::DeepEcho(indent);
 
@@ -72,5 +72,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Folder::Write {{{1*/
+/*FUNCTION KML_Folder::Write {{{*/
 void  KML_Folder::Write(FILE* filout,const char* indent){
 
@@ -88,5 +88,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Folder::Read {{{1*/
+/*FUNCTION KML_Folder::Read {{{*/
 void  KML_Folder::Read(FILE* fid,char* kstr){
 
@@ -110,7 +110,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_Folder::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_Folder::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_Folder::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_Folder::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strncmp(kstri,"<",1))
Index: /issm/trunk/src/c/objects/KML/KML_Folder.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Folder.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Folder.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -20,9 +20,9 @@
 	public:
 
-		/*KML_Folder constructors, destructors {{{1*/
+		/*KML_Folder constructors, destructors {{{*/
 		KML_Folder();
 		~KML_Folder();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -30,11 +30,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Geometry.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Geometry.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Geometry.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,5 +20,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Geometry::KML_Geometry(){{{1*/
+/*FUNCTION KML_Geometry::KML_Geometry(){{{*/
 KML_Geometry::KML_Geometry(){
 
@@ -27,5 +27,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Geometry::~KML_Geometry(){{{1*/
+/*FUNCTION KML_Geometry::~KML_Geometry(){{{*/
 KML_Geometry::~KML_Geometry(){
 
@@ -36,5 +36,5 @@
 
 /*Other*/
-/*FUNCTION KML_Geometry::Echo {{{1*/
+/*FUNCTION KML_Geometry::Echo {{{*/
 void  KML_Geometry::Echo(){
 
@@ -45,5 +45,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Geometry::DeepEcho {{{1*/
+/*FUNCTION KML_Geometry::DeepEcho {{{*/
 void  KML_Geometry::DeepEcho(){
 
@@ -56,5 +56,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Geometry::DeepEcho {{{1*/
+/*FUNCTION KML_Geometry::DeepEcho {{{*/
 void  KML_Geometry::DeepEcho(const char* indent){
 
@@ -65,5 +65,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Geometry::Write {{{1*/
+/*FUNCTION KML_Geometry::Write {{{*/
 void  KML_Geometry::Write(FILE* filout,const char* indent){
 
@@ -74,5 +74,5 @@
 /*}}}*/
 
-/*FUNCTION KML_Geometry::Read {{{1*/
+/*FUNCTION KML_Geometry::Read {{{*/
 void  KML_Geometry::Read(FILE* fid,char* kstr){
 
@@ -82,7 +82,7 @@
 		return;
 	else if (!strncmp(kstr,"</",2))
-		_error_("KML_Geometry::Read -- Unexpected closing tag %s.\n",kstr);
+	  {_error2_("KML_Geometry::Read -- Unexpected closing tag " << kstr << ".\n");}
 	else if (strncmp(kstr,"<",1))
-		_error_("KML_Geometry::Read -- Unexpected field \"%s\".\n",kstr);
+	  {_error2_("KML_Geometry::Read -- Unexpected field \"" << kstr << "\".\n");}
 
 	else if (!strncmp(kstr,"<",1))
Index: /issm/trunk/src/c/objects/KML/KML_Geometry.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Geometry.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Geometry.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -19,9 +19,9 @@
 	public:
 
-		/*KML_Geometry constructors, destructors {{{1*/
+		/*KML_Geometry constructors, destructors {{{*/
 		KML_Geometry();
 		~KML_Geometry();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -29,11 +29,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_GroundOverlay.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_GroundOverlay.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_GroundOverlay.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_GroundOverlay::KML_GroundOverlay(){{{1*/
+/*FUNCTION KML_GroundOverlay::KML_GroundOverlay(){{{*/
 KML_GroundOverlay::KML_GroundOverlay(){
 
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_GroundOverlay::~KML_GroundOverlay(){{{1*/
+/*FUNCTION KML_GroundOverlay::~KML_GroundOverlay(){{{*/
 KML_GroundOverlay::~KML_GroundOverlay(){
 
@@ -43,21 +43,16 @@
 
 /*Other*/
-/*FUNCTION KML_GroundOverlay::Echo {{{1*/
+/*FUNCTION KML_GroundOverlay::Echo {{{*/
 void  KML_GroundOverlay::Echo(){
 
-	bool  flag=true;
-
-	_printf_(flag,"KML_GroundOverlay:\n");
+	_printLine_("KML_GroundOverlay:");
 	KML_Overlay::Echo();
 
-	_printf_(flag,"      altitude: %0.16g\n"      ,altitude);
-	_printf_(flag,"       altmode: \"%s\"\n"      ,altmode);
-	_printf_(flag,"         llbox: %p\n"          ,llbox);
-
-	return;
+	_printLine_("         altitude: " << altitude);
+	_printLine_("          altmode: " << altmode);
+	_printLine_("            llbox: " << llbox);
 }
 /*}}}*/
-
-/*FUNCTION KML_GroundOverlay::DeepEcho {{{1*/
+/*FUNCTION KML_GroundOverlay::DeepEcho {{{*/
 void  KML_GroundOverlay::DeepEcho(){
 
@@ -69,12 +64,10 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_GroundOverlay::DeepEcho {{{1*/
+/*FUNCTION KML_GroundOverlay::DeepEcho {{{*/
 void  KML_GroundOverlay::DeepEcho(const char* indent){
 
 	char  indent2[81];
-	bool  flag=true;
 
-	_printf_(flag,"%sKML_GroundOverlay:\n",indent);
+	_printLine_(indent << "KML_GroundOverlay:");
 	KML_Overlay::DeepEcho(indent);
 
@@ -82,16 +75,13 @@
 	strcat(indent2,"  ");
 
-	_printf_(flag,"%s      altitude: %0.16g\n"      ,indent,altitude);
-	_printf_(flag,"%s       altmode: \"%s\"\n"      ,indent,altmode);
+	_printLine_(indent<<"      altitude: " << altitude);
+	_printLine_(indent<<"       altmode: " << altmode);
 	if (llbox)
-		llbox->DeepEcho(indent2);
+	 llbox->DeepEcho(indent2);
 	else
-		_printf_(flag,"%s         llbox: %p\n"          ,indent,llbox);
-
-	return;
+	 _printLine_(indent<<"         llbox: " << llbox);
 }
 /*}}}*/
-
-/*FUNCTION KML_GroundOverlay::Write {{{1*/
+/*FUNCTION KML_GroundOverlay::Write {{{*/
 void  KML_GroundOverlay::Write(FILE* filout,const char* indent){
 
@@ -119,6 +109,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_GroundOverlay::Read {{{1*/
+/*FUNCTION KML_GroundOverlay::Read {{{*/
 void  KML_GroundOverlay::Read(FILE* fid,char* kstr){
 
@@ -142,7 +131,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_GroundOverlay::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_GroundOverlay::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_GroundOverlay::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_GroundOverlay::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<altitude>"))
@@ -174,3 +163,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_GroundOverlay.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_GroundOverlay.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_GroundOverlay.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -26,9 +26,9 @@
 		KML_LatLonBox* llbox;
 
-		/*KML_GroundOverlay constructors, destructors {{{1*/
+		/*KML_GroundOverlay constructors, destructors {{{*/
 		KML_GroundOverlay();
 		~KML_GroundOverlay();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -36,11 +36,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Icon.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Icon.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Icon.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Icon::KML_Icon(){{{1*/
+/*FUNCTION KML_Icon::KML_Icon(){{{*/
 KML_Icon::KML_Icon(){
 
@@ -35,5 +35,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Icon::~KML_Icon(){{{1*/
+/*FUNCTION KML_Icon::~KML_Icon(){{{*/
 KML_Icon::~KML_Icon(){
 
@@ -44,26 +44,25 @@
 
 /*Other*/
-/*FUNCTION KML_Icon::Echo {{{1*/
+/*FUNCTION KML_Icon::Echo {{{*/
 void  KML_Icon::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Icon:\n");
+	if(flag) _pprintLine_("KML_Icon:");
 	KML_Object::Echo();
 
-	_printf_(flag,"          href: \"%s\"\n"    ,href);
-	_printf_(flag,"       refmode: \"%s\"\n"    ,refmode);
-	_printf_(flag,"        refint: %g\n"        ,refint);
-	_printf_(flag,"      vrefmode: \"%s\"\n"    ,vrefmode);
-	_printf_(flag,"      vreftime: %g\n"        ,vreftime);
-	_printf_(flag,"      vboundsc: %g\n"        ,vboundsc);
-	_printf_(flag,"       vformat: \"%s\"\n"    ,vformat);
-	_printf_(flag,"        hquery: \"%s\"\n"    ,hquery);
+	if(flag) _pprintLine_("          href: \"" << href << "\"");
+	if(flag) _pprintLine_("       refmode: \"" << refmode << "\"");
+	if(flag) _pprintLine_("        refint: " << refint);
+	if(flag) _pprintLine_("      vrefmode: \"" << vrefmode << "\"");
+	if(flag) _pprintLine_("      vreftime: " << vreftime);
+	if(flag) _pprintLine_("      vboundsc: " << vboundsc);
+	if(flag) _pprintLine_("       vformat: \"" << vformat << "\"");
+	if(flag) _pprintLine_("        hquery: \"" << hquery << "\"");
 
 	return;
 }
 /*}}}*/
-
-/*FUNCTION KML_Icon::DeepEcho {{{1*/
+/*FUNCTION KML_Icon::DeepEcho {{{*/
 void  KML_Icon::DeepEcho(){
 
@@ -75,27 +74,25 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_Icon::DeepEcho {{{1*/
+/*FUNCTION KML_Icon::DeepEcho {{{*/
 void  KML_Icon::DeepEcho(const char* indent){
 
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_Icon:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_Icon:");
 	KML_Object::DeepEcho(indent);
 
-	_printf_(flag,"%s          href: \"%s\"\n"    ,indent,href);
-	_printf_(flag,"%s       refmode: \"%s\"\n"    ,indent,refmode);
-	_printf_(flag,"%s        refint: %g\n"        ,indent,refint);
-	_printf_(flag,"%s      vrefmode: \"%s\"\n"    ,indent,vrefmode);
-	_printf_(flag,"%s      vreftime: %g\n"        ,indent,vreftime);
-	_printf_(flag,"%s      vboundsc: %g\n"        ,indent,vboundsc);
-	_printf_(flag,"%s       vformat: \"%s\"\n"    ,indent,vformat);
-	_printf_(flag,"%s        hquery: \"%s\"\n"    ,indent,hquery);
+	if(flag) _pprintLine_(indent << "          href: \"" << href << "\"");
+	if(flag) _pprintLine_(indent << "       refmode: \"" << refmode << "\"");
+	if(flag) _pprintLine_(indent << "        refint: " << refint);
+	if(flag) _pprintLine_(indent << "      vrefmode: \"" << vrefmode << "\"");
+	if(flag) _pprintLine_(indent << "      vreftime: " << vreftime);
+	if(flag) _pprintLine_(indent << "      vboundsc: " << vboundsc);
+	if(flag) _pprintLine_(indent << "       vformat: \"" << vformat << "\"");
+	if(flag) _pprintLine_(indent << "        hquery: \"" << hquery << "\"");
 
 	return;
 }
 /*}}}*/
-
-/*FUNCTION KML_Icon::Write {{{1*/
+/*FUNCTION KML_Icon::Write {{{*/
 void  KML_Icon::Write(FILE* filout,const char* indent){
 
@@ -126,6 +123,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_Icon::Read {{{1*/
+/*FUNCTION KML_Icon::Read {{{*/
 void  KML_Icon::Read(FILE* fid,char* kstr){
 
@@ -149,40 +145,24 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_Icon::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_Icon::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_Icon::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_Icon::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<href>"))
-			KMLFileTokenParse( href      ,NULL,KML_ICON_HREF_LENGTH,
-							  kstri,
-							  fid);
+			KMLFileTokenParse( href      ,NULL,KML_ICON_HREF_LENGTH, kstri, fid);
 		else if (!strcmp(kstri,"<refreshMode>"))
-			KMLFileTokenParse( refmode   ,NULL,KML_ICON_REFMODE_LENGTH,
-							  kstri,
-							  fid);
+			KMLFileTokenParse( refmode   ,NULL,KML_ICON_REFMODE_LENGTH, kstri, fid);
 		else if (!strcmp(kstri,"<refreshInterval>"))
-			KMLFileTokenParse(&refint    ,
-							  kstri,
-							  fid);
+			KMLFileTokenParse(&refint    , kstri, fid);
 		else if (!strcmp(kstri,"<viewRefreshMode>"))
-			KMLFileTokenParse( vrefmode  ,NULL,KML_ICON_VREFMODE_LENGTH,
-							  kstri,
-							  fid);
+			KMLFileTokenParse( vrefmode  ,NULL,KML_ICON_VREFMODE_LENGTH, kstri, fid);
 		else if (!strcmp(kstri,"<viewRefreshTime>"))
-			KMLFileTokenParse(&vreftime  ,
-							  kstri,
-							  fid);
+			KMLFileTokenParse(&vreftime  , kstri, fid);
 		else if (!strcmp(kstri,"<viewBoundScale>"))
-			KMLFileTokenParse(&vboundsc  ,
-							  kstri,
-							  fid);
+			KMLFileTokenParse(&vboundsc  , kstri, fid);
 		else if (!strcmp(kstri,"<viewFormat>"))
-			KMLFileTokenParse( vformat   ,NULL,KML_ICON_VFORMAT_LENGTH,
-							  kstri,
-							  fid);
+			KMLFileTokenParse( vformat   ,NULL,KML_ICON_VFORMAT_LENGTH, kstri, fid);
 		else if (!strcmp(kstri,"<httpQuery>"))
-			KMLFileTokenParse( hquery    ,NULL,KML_ICON_HQUERY_LENGTH,
-							  kstri,
-							  fid);
+			KMLFileTokenParse( hquery    ,NULL,KML_ICON_HQUERY_LENGTH, kstri, fid);
 
 		else if (!strncmp(kstri,"<",1))
@@ -201,3 +181,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_Icon.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Icon.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Icon.h	(revision 12706)
@@ -13,5 +13,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -34,9 +34,9 @@
 		char  hquery[KML_ICON_HQUERY_LENGTH+1];
 
-		/*KML_Icon constructors, destructors {{{1*/
+		/*KML_Icon constructors, destructors {{{*/
 		KML_Icon();
 		~KML_Icon();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -44,11 +44,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_LatLonBox.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_LatLonBox.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_LatLonBox.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_LatLonBox::KML_LatLonBox(){{{1*/
+/*FUNCTION KML_LatLonBox::KML_LatLonBox(){{{*/
 KML_LatLonBox::KML_LatLonBox(){
 
@@ -32,5 +32,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_LatLonBox::~KML_LatLonBox(){{{1*/
+/*FUNCTION KML_LatLonBox::~KML_LatLonBox(){{{*/
 KML_LatLonBox::~KML_LatLonBox(){
 
@@ -41,23 +41,19 @@
 
 /*Other*/
-/*FUNCTION KML_LatLonBox::Echo {{{1*/
+/*FUNCTION KML_LatLonBox::Echo {{{*/
 void  KML_LatLonBox::Echo(){
 
-	bool  flag=true;
 
-	_printf_(flag,"KML_LatLonBox:\n");
+	_printLine_("KML_LatLonBox:");
 	KML_Object::Echo();
 
-	_printf_(flag,"         north: %0.16g\n"    ,north);
-	_printf_(flag,"         south: %0.16g\n"    ,south);
-	_printf_(flag,"          east: %0.16g\n"    ,east);
-	_printf_(flag,"          west: %0.16g\n"    ,west);
-	_printf_(flag,"      rotation: %0.16g\n"    ,rotation);
-
-	return;
+	_printLine_("         north: " << north);
+	_printLine_("         south: " << south);
+	_printLine_("          east: " << east);
+	_printLine_("          west: " << west);
+	_printLine_("      rotation: " << rotation);
 }
 /*}}}*/
-
-/*FUNCTION KML_LatLonBox::DeepEcho {{{1*/
+/*FUNCTION KML_LatLonBox::DeepEcho {{{*/
 void  KML_LatLonBox::DeepEcho(){
 
@@ -69,24 +65,18 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_LatLonBox::DeepEcho {{{1*/
+/*FUNCTION KML_LatLonBox::DeepEcho {{{*/
 void  KML_LatLonBox::DeepEcho(const char* indent){
 
-	bool  flag=true;
-
-	_printf_(flag,"%sKML_LatLonBox:\n",indent);
+	_printLine_(indent << "KML_LatLonBox:");
 	KML_Object::DeepEcho(indent);
 
-	_printf_(flag,"%s         north: %0.16g\n"    ,indent,north);
-	_printf_(flag,"%s         south: %0.16g\n"    ,indent,south);
-	_printf_(flag,"%s          east: %0.16g\n"    ,indent,east);
-	_printf_(flag,"%s          west: %0.16g\n"    ,indent,west);
-	_printf_(flag,"%s      rotation: %0.16g\n"    ,indent,rotation);
-
-	return;
+	_printLine_("         north: " << north);
+	_printLine_("         south: " << south);
+	_printLine_("          east: " << east);
+	_printLine_("          west: " << west);
+	_printLine_("      rotation: " << rotation);
 }
 /*}}}*/
-
-/*FUNCTION KML_LatLonBox::Write {{{1*/
+/*FUNCTION KML_LatLonBox::Write {{{*/
 void  KML_LatLonBox::Write(FILE* filout,const char* indent){
 
@@ -109,6 +99,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_LatLonBox::Read {{{1*/
+/*FUNCTION KML_LatLonBox::Read {{{*/
 void  KML_LatLonBox::Read(FILE* fid,char* kstr){
 
@@ -132,7 +121,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_LatLonBox::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_LatLonBox::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_LatLonBox::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_LatLonBox::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<north>"))
@@ -172,3 +161,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_LatLonBox.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_LatLonBox.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_LatLonBox.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -25,9 +25,9 @@
 		double rotation;
 
-		/*KML_LatLonBox constructors, destructors {{{1*/
+		/*KML_LatLonBox constructors, destructors {{{*/
 		KML_LatLonBox();
 		~KML_LatLonBox();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -35,11 +35,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_LineString.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_LineString.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_LineString.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -22,5 +22,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_LineString::KML_LineString(){{{1*/
+/*FUNCTION KML_LineString::KML_LineString(){{{*/
 KML_LineString::KML_LineString(){
 
@@ -34,8 +34,8 @@
 }
 /*}}}*/
-/*FUNCTION KML_LineString::~KML_LineString(){{{1*/
+/*FUNCTION KML_LineString::~KML_LineString(){{{*/
 KML_LineString::~KML_LineString(){
 
-	if (coords) xfree((void**)&coords);
+	if (coords) xDelete<double>(coords);
 
 	coords    =NULL;
@@ -46,21 +46,21 @@
 
 /*Other*/
-/*FUNCTION KML_LineString::Echo {{{1*/
+/*FUNCTION KML_LineString::Echo {{{*/
 void  KML_LineString::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_LineString:\n");
+	if(flag) _pprintLine_("KML_LineString:");
 	KML_Geometry::Echo();
 
-	_printf_(flag,"       extrude: %s\n"          ,(extrude ? "true" : "false"));
-	_printf_(flag,"    tessellate: %s\n"          ,(tessellate ? "true" : "false"));
-	_printf_(flag,"       altmode: \"%s\"\n"      ,altmode);
-	_printf_(flag,"        coords: (ncoord=%d)\n" ,ncoord);
-
-	return;
-}
-/*}}}*/
-/*FUNCTION KML_LineString::DeepEcho {{{1*/
+	if(flag) _pprintLine_("       extrude: " << (extrude ? "true" : "false"));
+	if(flag) _pprintLine_("    tessellate: " << (tessellate ? "true" : "false"));
+	if(flag) _pprintLine_("       altmode: \"" << altmode << "\"");
+	if(flag) _pprintLine_("        coords: (ncoord=" << ncoord << ")");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_LineString::DeepEcho {{{*/
 void  KML_LineString::DeepEcho(){
 
@@ -72,5 +72,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_LineString::DeepEcho {{{1*/
+/*FUNCTION KML_LineString::DeepEcho {{{*/
 void  KML_LineString::DeepEcho(const char* indent){
 
@@ -78,19 +78,18 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_LineString:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_LineString:");
 	KML_Geometry::DeepEcho(indent);
 
-	_printf_(flag,"%s       extrude: %s\n"          ,indent,(extrude ? "true" : "false"));
-	_printf_(flag,"%s    tessellate: %s\n"          ,indent,(tessellate ? "true" : "false"));
-	_printf_(flag,"%s       altmode: \"%s\"\n"      ,indent,altmode);
-	_printf_(flag,"%s        coords: (ncoord=%d)\n" ,indent,ncoord);
+	if(flag) _pprintLine_(indent << "       extrude: " << (extrude ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "    tessellate: " << (tessellate ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "       altmode: \"" << altmode << "\"");
+	if(flag) _pprintLine_(indent << "        coords: (ncoord=" << ncoord << ")");
 	for (i=0; i<ncoord; i++)
-		_printf_(flag,"%s                (%g,%g,%g)\n" ,indent,
-				coords[i][0],coords[i][1],coords[i][2]);
-
-	return;
-}
-/*}}}*/
-/*FUNCTION KML_LineString::Write {{{1*/
+		if(flag) _pprintLine_(indent << "                (" << coords[3*i+0] << "," << coords[3*i+1] << "," << coords[3*i+2] << ")");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_LineString::Write {{{*/
 void  KML_LineString::Write(FILE* filout,const char* indent){
 
@@ -112,6 +111,5 @@
 
 	for (i=0; i<ncoord; i++)
-		fprintf(filout,"%s    %0.16g,%0.16g,%0.16g\n",indent,
-				coords[i][0],coords[i][1],coords[i][2]);
+		fprintf(filout,"%s    %0.16g,%0.16g,%0.16g\n",indent, coords[3*i+0],coords[3*i+1],coords[3*i+2]);
 
 	fprintf(filout,"%s  </coordinates>\n",indent);
@@ -121,5 +119,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_LineString::Read {{{1*/
+/*FUNCTION KML_LineString::Read {{{*/
 void  KML_LineString::Read(FILE* fid,char* kstr){
 
@@ -143,7 +141,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_LineString::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_LineString::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_LineString::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_LineString::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<extrude>"))
@@ -179,5 +177,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_LineString::WriteExp {{{1*/
+/*FUNCTION KML_LineString::WriteExp {{{*/
 void  KML_LineString::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
@@ -191,6 +189,6 @@
 	lon=(double *) xmalloc(ncoord*sizeof(double));
 	for (i=0; i<ncoord; i++) {
-		lon[i]=coords[i][0];
-		lat[i]=coords[i][1];
+		lon[i]=coords[3*i+0];
+		lat[i]=coords[3*i+1];
 	}
 
Index: /issm/trunk/src/c/objects/KML/KML_LineString.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_LineString.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_LineString.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -21,15 +21,15 @@
 	public:
 
-		bool  extrude;
-		bool  tessellate;
-		char  altmode[KML_LINESTRING_ALTMODE_LENGTH+1];
-        int   ncoord;
-		double (*coords)[3];
+		bool    extrude;
+		bool    tessellate;
+		char    altmode[KML_LINESTRING_ALTMODE_LENGTH+1];
+		int     ncoord;
+		double *coords;
 
-		/*KML_LineString constructors, destructors {{{1*/
+		/*KML_LineString constructors, destructors {{{*/
 		KML_LineString();
 		~KML_LineString();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -38,11 +38,11 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_LineStyle.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_LineStyle.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_LineStyle.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_LineStyle::KML_LineStyle(){{{1*/
+/*FUNCTION KML_LineStyle::KML_LineStyle(){{{*/
 KML_LineStyle::KML_LineStyle(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_LineStyle::~KML_LineStyle(){{{1*/
+/*FUNCTION KML_LineStyle::~KML_LineStyle(){{{*/
 KML_LineStyle::~KML_LineStyle(){
 
@@ -37,19 +37,18 @@
 
 /*Other*/
-/*FUNCTION KML_LineStyle::Echo {{{1*/
+/*FUNCTION KML_LineStyle::Echo {{{*/
 void  KML_LineStyle::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_LineStyle:\n");
+	if(flag) _pprintLine_("KML_LineStyle:");
 	KML_ColorStyle::Echo();
 
-	_printf_(flag,"         width: %g\n"          ,width);
+	if(flag) _pprintLine_("         width: " << width);
 
 	return;
 }
 /*}}}*/
-
-/*FUNCTION KML_LineStyle::DeepEcho {{{1*/
+/*FUNCTION KML_LineStyle::DeepEcho {{{*/
 void  KML_LineStyle::DeepEcho(){
 
@@ -61,6 +60,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_LineStyle::DeepEcho {{{1*/
+/*FUNCTION KML_LineStyle::DeepEcho {{{*/
 void  KML_LineStyle::DeepEcho(const char* indent){
 
@@ -68,14 +66,13 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_LineStyle:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_LineStyle:");
 	KML_ColorStyle::DeepEcho(indent);
 
-	_printf_(flag,"%s         width: %g\n"          ,indent,width);
+	if(flag) _pprintLine_(indent << "         width: " << width);
 
 	return;
 }
 /*}}}*/
-
-/*FUNCTION KML_LineStyle::Write {{{1*/
+/*FUNCTION KML_LineStyle::Write {{{*/
 void  KML_LineStyle::Write(FILE* filout,const char* indent){
 
@@ -94,6 +91,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_LineStyle::Read {{{1*/
+/*FUNCTION KML_LineStyle::Read {{{*/
 void  KML_LineStyle::Read(FILE* fid,char* kstr){
 
@@ -117,7 +113,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_LineStyle::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_LineStyle::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_LineStyle::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_LineStyle::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<width>"))
@@ -141,3 +137,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_LineStyle.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_LineStyle.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_LineStyle.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -21,9 +21,9 @@
 		float width;
 
-		/*KML_LineStyle constructors, destructors {{{1*/
+		/*KML_LineStyle constructors, destructors {{{*/
 		KML_LineStyle();
 		~KML_LineStyle();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -31,11 +31,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_LinearRing.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_LinearRing.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_LinearRing.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -22,5 +22,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_LinearRing::KML_LinearRing(){{{1*/
+/*FUNCTION KML_LinearRing::KML_LinearRing(){{{*/
 KML_LinearRing::KML_LinearRing(){
 
@@ -34,8 +34,8 @@
 }
 /*}}}*/
-/*FUNCTION KML_LinearRing::~KML_LinearRing(){{{1*/
+/*FUNCTION KML_LinearRing::~KML_LinearRing(){{{*/
 KML_LinearRing::~KML_LinearRing(){
 
-	if (coords) xfree((void**)&coords);
+	if (coords) xDelete<double>(coords);
 
 	coords    =NULL;
@@ -46,22 +46,21 @@
 
 /*Other*/
-/*FUNCTION KML_LinearRing::Echo {{{1*/
+/*FUNCTION KML_LinearRing::Echo {{{*/
 void  KML_LinearRing::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_LinearRing:\n");
+	if(flag) _pprintLine_("KML_LinearRing:");
 	KML_Geometry::Echo();
 
-	_printf_(flag,"       extrude: %s\n"          ,(extrude ? "true" : "false"));
-	_printf_(flag,"    tessellate: %s\n"          ,(tessellate ? "true" : "false"));
-	_printf_(flag,"       altmode: \"%s\"\n"      ,altmode);
-	_printf_(flag,"        coords: (ncoord=%d)\n" ,ncoord);
-
-	return;
-}
-/*}}}*/
-
-/*FUNCTION KML_LinearRing::DeepEcho {{{1*/
+	if(flag) _pprintLine_("       extrude: " << (extrude ? "true" : "false"));
+	if(flag) _pprintLine_("    tessellate: " << (tessellate ? "true" : "false"));
+	if(flag) _pprintLine_("       altmode: \"" << altmode << "\"");
+	if(flag) _pprintLine_("        coords: (ncoord=" << ncoord << ")");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_LinearRing::DeepEcho {{{*/
 void  KML_LinearRing::DeepEcho(){
 
@@ -73,6 +72,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_LinearRing::DeepEcho {{{1*/
+/*FUNCTION KML_LinearRing::DeepEcho {{{*/
 void  KML_LinearRing::DeepEcho(const char* indent){
 
@@ -80,20 +78,19 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_LinearRing:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_LinearRing:");
 	KML_Geometry::DeepEcho(indent);
 
-	_printf_(flag,"%s       extrude: %s\n"          ,indent,(extrude ? "true" : "false"));
-	_printf_(flag,"%s    tessellate: %s\n"          ,indent,(tessellate ? "true" : "false"));
-	_printf_(flag,"%s       altmode: \"%s\"\n"      ,indent,altmode);
-	_printf_(flag,"%s        coords: (ncoord=%d)\n" ,indent,ncoord);
+	if(flag) _pprintLine_(indent << "       extrude: " << (extrude ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "    tessellate: " << (tessellate ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "       altmode: \"" << altmode << "\"");
+	if(flag) _pprintLine_(indent << "        coords: (ncoord=" << ncoord << ")");
 	for (i=0; i<ncoord; i++)
-		_printf_(flag,"%s                (%g,%g,%g)\n" ,indent,
-				coords[i][0],coords[i][1],coords[i][2]);
-
-	return;
-}
-/*}}}*/
-
-/*FUNCTION KML_LinearRing::Write {{{1*/
+		_printf_(flag,"%s                (%g,%g,%g)\n",indent,
+				coords[3*i+0],coords[3*i+1],coords[3*i+2]);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_LinearRing::Write {{{*/
 void  KML_LinearRing::Write(FILE* filout,const char* indent){
 
@@ -115,6 +112,5 @@
 
 	for (i=0; i<ncoord; i++)
-		fprintf(filout,"%s    %0.16g,%0.16g,%0.16g\n",indent,
-				coords[i][0],coords[i][1],coords[i][2]);
+		fprintf(filout,"%s    %0.16g,%0.16g,%0.16g\n",indent,coords[3*i+0],coords[3*i+1],coords[3*i+2]);
 
 	fprintf(filout,"%s  </coordinates>\n",indent);
@@ -124,65 +120,50 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_LinearRing::Read {{{1*/
+/*FUNCTION KML_LinearRing::Read {{{*/
 void  KML_LinearRing::Read(FILE* fid,char* kstr){
 
-	char*        kstri;
-	int          ncom=0;
-	char**       pcom=NULL;
+	char  *kstri = NULL;
+	int    ncom  = 0;
+	char **pcom  = NULL;
 
 /*  get object attributes and check for solo tag  */
 
-	if (KMLFileTagAttrib(this,
-						 kstr))
-		return;
+	if (KMLFileTagAttrib(this,kstr)) return;
 
 /*  loop over and process fields within opening and closing tags  */
 
-	while (kstri=KMLFileToken(fid,
-							  &ncom,&pcom)) {
-		if      (!strncmp(kstri,"</LinearRing",12)) {
-			xfree((void**)&kstri);
+	while (kstri=KMLFileToken(fid,&ncom,&pcom)){
+		if (!strncmp(kstri,"</LinearRing",12)){
+			xDelete<char>(kstri);
 			break;
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_LinearRing::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_LinearRing::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_LinearRing::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_LinearRing::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<extrude>"))
-			KMLFileTokenParse(&extrude   ,
-							  kstri,
-							  fid);
+			KMLFileTokenParse(&extrude,kstri,fid);
 		else if (!strcmp(kstri,"<tessellate>"))
-			KMLFileTokenParse(&tessellate,
-							  kstri,
-							  fid);
+			KMLFileTokenParse(&tessellate,kstri,fid);
 		else if (!strcmp(kstri,"<altitudeMode>"))
-			KMLFileTokenParse( altmode   ,NULL,KML_LINEARRING_ALTMODE_LENGTH,
-							  kstri,
-							  fid);
+			KMLFileTokenParse(altmode,NULL,KML_LINEARRING_ALTMODE_LENGTH,kstri,fid);
 		else if (!strcmp(kstri,"<coordinates>"))
-			KMLFileTokenParse(&coords    ,&ncoord    ,0,
-							  kstri,
-							  fid);
-
+			KMLFileTokenParse(&coords,&ncoord,0,kstri,fid);
 		else if (!strncmp(kstri,"<",1))
 			KML_Geometry::Read(fid,kstri);
 
-		xfree((void**)&kstri);
+		xDelete<char>(kstri);
 	}
 
 	this->AddCommnt(ncom,pcom);
 
-	for (ncom; ncom>0; ncom--)
-		xfree((void**)&(pcom[ncom-1]));
-	xfree((void**)&pcom);
-
-	return;
-}
-/*}}}*/
-
-/*FUNCTION KML_LinearRing::WriteExp {{{1*/
+	for(ncom;ncom>0;ncom--) xDelete<char>((pcom[ncom-1]));
+	xDelete<char*>(pcom);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_LinearRing::WriteExp {{{*/
 void  KML_LinearRing::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
@@ -193,15 +174,15 @@
 /*  extract latitude and longitude into vectors  */
 
-	lat=(double *) xmalloc(ncoord*sizeof(double));
-	lon=(double *) xmalloc(ncoord*sizeof(double));
+	lat=xNew<double>(ncoord);
+	lon=xNew<double>(ncoord);
 	for (i=0; i<ncoord; i++) {
-		lon[i]=coords[i][0];
-		lat[i]=coords[i][1];
+		lon[i]=coords[3*i+0];
+		lat[i]=coords[3*i+1];
 	}
 
 /*  convert latitude and longitude to x and y  */
 
-	x  =(double *) xmalloc(ncoord*sizeof(double));
-	y  =(double *) xmalloc(ncoord*sizeof(double));
+	x  =xNew<double>(ncoord);
+	y  =xNew<double>(ncoord);
 	Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
 
@@ -233,11 +214,10 @@
 	fprintf(fid,"\n");
 
-	xfree((void**)&y);
-	xfree((void**)&x);
-	xfree((void**)&lon);
-	xfree((void**)&lat);
-
-	return;
-}
-/*}}}*/
-
+	xDelete<double>(y);
+	xDelete<double>(x);
+	xDelete<double>(lon);
+	xDelete<double>(lat);
+
+	return;
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/KML/KML_LinearRing.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_LinearRing.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_LinearRing.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -21,15 +21,15 @@
 	public:
 
-		bool  extrude;
-		bool  tessellate;
-		char  altmode[KML_LINEARRING_ALTMODE_LENGTH+1];
-        int   ncoord;
-		double (*coords)[3];
+		bool     extrude;
+		bool     tessellate;
+		char     altmode[KML_LINEARRING_ALTMODE_LENGTH+1];
+		int      ncoord;
+		double  *coords;
 
-		/*KML_LinearRing constructors, destructors {{{1*/
+		/*KML_LinearRing constructors, destructors {{{*/
 		KML_LinearRing();
 		~KML_LinearRing();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -38,11 +38,11 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_MultiGeometry::KML_MultiGeometry(){{{1*/
+/*FUNCTION KML_MultiGeometry::KML_MultiGeometry(){{{*/
 KML_MultiGeometry::KML_MultiGeometry(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_MultiGeometry::~KML_MultiGeometry(){{{1*/
+/*FUNCTION KML_MultiGeometry::~KML_MultiGeometry(){{{*/
 KML_MultiGeometry::~KML_MultiGeometry(){
 
@@ -40,19 +40,18 @@
 
 /*Other*/
-/*FUNCTION KML_MultiGeometry::Echo {{{1*/
+/*FUNCTION KML_MultiGeometry::Echo {{{*/
 void  KML_MultiGeometry::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Multigeometry:\n");
+	if(flag) _pprintLine_("KML_Multigeometry:");
 	KML_Geometry::Echo();
 
-	_printf_(flag,"      geometry: (size=%d)\n" ,geometry->Size());
-
-	return;
-}
-/*}}}*/
-
-/*FUNCTION KML_MultiGeometry::DeepEcho {{{1*/
+	if(flag) _pprintLine_("      geometry: (size=" << geometry->Size() << ")");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_MultiGeometry::DeepEcho {{{*/
 void  KML_MultiGeometry::DeepEcho(){
 
@@ -64,6 +63,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_MultiGeometry::DeepEcho {{{1*/
+/*FUNCTION KML_MultiGeometry::DeepEcho {{{*/
 void  KML_MultiGeometry::DeepEcho(const char* indent){
 
@@ -72,5 +70,5 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_Multigeometry:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_Multigeometry:");
 	KML_Geometry::DeepEcho(indent);
 
@@ -82,16 +80,15 @@
 	if (geometry->Size())
 		for (i=0; i<geometry->Size(); i++) {
-			_printf_(flag,"%s      geometry: -------- begin [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "      geometry: -------- begin [" << i << "] --------");
 			((KML_Geometry *)geometry->GetObjectByOffset(i))->DeepEcho(indent2);
-			_printf_(flag,"%s      geometry: --------  end  [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "      geometry: --------  end  [" << i << "] --------");
 		}
 	else
-		_printf_(flag,"%s      geometry: [empty]\n"    ,indent);
-
-	return;
-}
-/*}}}*/
-
-/*FUNCTION KML_MultiGeometry::Write {{{1*/
+		if(flag) _pprintLine_(indent << "      geometry: [empty]");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_MultiGeometry::Write {{{*/
 void  KML_MultiGeometry::Write(FILE* filout,const char* indent){
 
@@ -120,6 +117,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_MultiGeometry::Read {{{1*/
+/*FUNCTION KML_MultiGeometry::Read {{{*/
 void  KML_MultiGeometry::Read(FILE* fid,char* kstr){
 
@@ -144,7 +140,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_MultiGeometry::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_MultiGeometry::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_MultiGeometry::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_MultiGeometry::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strncmp(kstri,"<Point", 6)) {
@@ -193,6 +189,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_MultiGeometry::WriteExp {{{1*/
+/*FUNCTION KML_MultiGeometry::WriteExp {{{*/
 void  KML_MultiGeometry::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
@@ -207,3 +202,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_MultiGeometry.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_MultiGeometry.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_MultiGeometry.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -23,9 +23,9 @@
 		DataSet* geometry;
 
-		/*KML_MultiGeometry constructors, destructors {{{1*/
+		/*KML_MultiGeometry constructors, destructors {{{*/
 		KML_MultiGeometry();
 		~KML_MultiGeometry();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -34,11 +34,11 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Object.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Object.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Object.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Object::KML_Object(){{{1*/
+/*FUNCTION KML_Object::KML_Object(){{{*/
 KML_Object::KML_Object(){
 
@@ -30,5 +30,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::~KML_Object(){{{1*/
+/*FUNCTION KML_Object::~KML_Object(){{{*/
 KML_Object::~KML_Object(){
 
@@ -50,17 +50,17 @@
 
 /*Other*/
-/*FUNCTION KML_Object::Echo {{{1*/
+/*FUNCTION KML_Object::Echo {{{*/
 void  KML_Object::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"        attrib: (size=%d)\n" ,attrib->Size());
-	_printf_(flag,"        commnt: (size=%d)\n" ,commnt->Size());
-	_printf_(flag,"        kmlobj: (size=%d)\n" ,kmlobj->Size());
-
-	return;
-}
-/*}}}*/
-/*FUNCTION KML_Object::DeepEcho {{{1*/
+	if(flag) _pprintLine_("        attrib: (size=" << attrib->Size() << ")");
+	if(flag) _pprintLine_("        commnt: (size=" << commnt->Size() << ")");
+	if(flag) _pprintLine_("        kmlobj: (size=" << kmlobj->Size() << ")");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Object::DeepEcho {{{*/
 void  KML_Object::DeepEcho(){
 
@@ -72,5 +72,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::DeepEcho {{{1*/
+/*FUNCTION KML_Object::DeepEcho {{{*/
 void  KML_Object::DeepEcho(const char* indent){
 
@@ -86,5 +86,5 @@
 		}
 	else
-		_printf_(flag,"%s        attrib: [empty]\n"    ,indent);
+		if(flag) _pprintLine_(indent << "        attrib: [empty]");
 
 /*  loop over the comments for the object  */
@@ -95,5 +95,5 @@
 		}
 	else
-		_printf_(flag,"%s        commnt: [empty]\n"    ,indent);
+		if(flag) _pprintLine_(indent << "        commnt: [empty]");
 
 /*  loop over the unknown objects for the object  */
@@ -104,15 +104,15 @@
 	if (kmlobj->Size())
 		for (i=0; i<kmlobj->Size(); i++) {
-            _printf_(flag,"%s        kmlobj: -------- begin [%d] --------\n" ,indent,i);
+            if(flag) _pprintLine_(indent << "        kmlobj: -------- begin [" << i << "] --------");
 			((KML_Unknown *)kmlobj->GetObjectByOffset(i))->DeepEcho(indent2);
-            _printf_(flag,"%s        kmlobj: --------  end  [%d] --------\n" ,indent,i);
+            if(flag) _pprintLine_(indent << "        kmlobj: --------  end  [" << i << "] --------");
 		}
 	else
-		_printf_(flag,"%s        kmlobj: [empty]\n"    ,indent);
-
-	return;
-}
-/*}}}*/
-/*FUNCTION KML_Object::Write {{{1*/
+		if(flag) _pprintLine_(indent << "        kmlobj: [empty]");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Object::Write {{{*/
 void  KML_Object::Write(FILE* filout,const char* indent){
 
@@ -136,5 +136,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::Read {{{1*/
+/*FUNCTION KML_Object::Read {{{*/
 void  KML_Object::Read(FILE* fid,char* kstr){
 
@@ -146,7 +146,7 @@
 		return;
 	else if (!strncmp(kstr,"</",2))
-		_error_("KML_Object::Read -- Unexpected closing tag %s.\n",kstr);
+	  {_error2_("KML_Object::Read -- Unexpected closing tag " << kstr << ".\n");}
 	else if (strncmp(kstr,"<",1))
-		_error_("KML_Object::Read -- Unexpected field \"%s\".\n",kstr);
+	  {_error2_("KML_Object::Read -- Unexpected field \"" << kstr << "\".\n");}
 
 	else if (!strncmp(kstr,"<Placemark",10)) {
@@ -253,5 +253,5 @@
 
 	else if (!strncmp(kstr,"<",1)) {
-		_printf_(true,"KML_Object::Read -- Unrecognized opening tag %s.\n",kstr);
+		_pprintLine_("KML_Object::Read -- Unrecognized opening tag " << kstr << ".");
 //		KMLFileTagSkip(kstr,
 //					   fid);
@@ -264,5 +264,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::WriteExp {{{1*/
+/*FUNCTION KML_Object::WriteExp {{{*/
 void  KML_Object::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
@@ -272,5 +272,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::AddAttrib {{{1*/
+/*FUNCTION KML_Object::AddAttrib {{{*/
 void  KML_Object::AddAttrib(const char* name,const char* value){
 
@@ -284,5 +284,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::FindAttrib {{{1*/
+/*FUNCTION KML_Object::FindAttrib {{{*/
 void  KML_Object::FindAttrib(char** pvalue,char* name,char* deflt){
 
@@ -311,5 +311,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::WriteAttrib {{{1*/
+/*FUNCTION KML_Object::WriteAttrib {{{*/
 void  KML_Object::WriteAttrib(FILE* filout,const char* indent){
 
@@ -325,5 +325,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::AddCommnt {{{1*/
+/*FUNCTION KML_Object::AddCommnt {{{*/
 void  KML_Object::AddCommnt(int ncom,char** pcom){
 
@@ -340,5 +340,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::AddCommnt {{{1*/
+/*FUNCTION KML_Object::AddCommnt {{{*/
 void  KML_Object::AddCommnt(char* value){
 
@@ -352,5 +352,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::FindCommnt {{{1*/
+/*FUNCTION KML_Object::FindCommnt {{{*/
 void  KML_Object::FindCommnt(char** pvalue,int inum){
 
@@ -370,5 +370,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Object::WriteCommnt {{{1*/
+/*FUNCTION KML_Object::WriteCommnt {{{*/
 void  KML_Object::WriteCommnt(FILE* filout,const char* indent){
 
Index: /issm/trunk/src/c/objects/KML/KML_Object.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Object.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Object.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _KML_OBJECT_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -23,19 +23,19 @@
 		DataSet* kmlobj;
 
-		/*KML_Object constructors, destructors {{{1*/
+		/*KML_Object constructors, destructors {{{*/
 		KML_Object();
 		~KML_Object();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		virtual void  Echo();
 		virtual void  DeepEcho();
 		virtual void  DeepEcho(const char* indent);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Overlay.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Overlay.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Overlay.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Overlay::KML_Overlay(){{{1*/
+/*FUNCTION KML_Overlay::KML_Overlay(){{{*/
 KML_Overlay::KML_Overlay(){
 
@@ -32,5 +32,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Overlay::~KML_Overlay(){{{1*/
+/*FUNCTION KML_Overlay::~KML_Overlay(){{{*/
 KML_Overlay::~KML_Overlay(){
 
@@ -44,20 +44,14 @@
 
 /*Other*/
-/*FUNCTION KML_Overlay::Echo {{{1*/
+/*FUNCTION KML_Overlay::Echo {{{*/
 void  KML_Overlay::Echo(){
 
-	bool  flag=true;
-
 	KML_Feature::Echo();
-
-	_printf_(flag,"         color: \"%s\"\n" ,color);
-	_printf_(flag,"       draword: %d\n"     ,draword);
-	_printf_(flag,"          icon: %p\n"     ,icon);
-
-	return;
+	_pprintLine_("         color: \"" << color << "\"");
+	_pprintLine_("       draword: " << draword);
+	_pprintLine_("          icon: " << icon);
 }
 /*}}}*/
-
-/*FUNCTION KML_Overlay::DeepEcho {{{1*/
+/*FUNCTION KML_Overlay::DeepEcho {{{*/
 void  KML_Overlay::DeepEcho(){
 
@@ -69,11 +63,8 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_Overlay::DeepEcho {{{1*/
+/*FUNCTION KML_Overlay::DeepEcho {{{*/
 void  KML_Overlay::DeepEcho(const char* indent){
 
 	char  indent2[81];
-	bool  flag=true;
-
 	KML_Feature::DeepEcho(indent);
 
@@ -81,16 +72,13 @@
 	strcat(indent2,"  ");
 
-	_printf_(flag,"%s         color: %s\n"          ,indent,color);
-	_printf_(flag,"%s       draword: %d\n"          ,indent,draword);
+	_pprintLine_(indent << "         color: " << color);
+	_pprintLine_(indent << "       draword: " << draword);
 	if (icon)
 		icon->DeepEcho(indent2);
 	else
-		_printf_(flag,"%s          icon: %p\n"          ,indent,icon);
-
-	return;
+		_pprintLine_(indent << "          icon: " << icon);
 }
 /*}}}*/
-
-/*FUNCTION KML_Overlay::Write {{{1*/
+/*FUNCTION KML_Overlay::Write {{{*/
 void  KML_Overlay::Write(FILE* filout,const char* indent){
 
@@ -112,6 +100,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_Overlay::Read {{{1*/
+/*FUNCTION KML_Overlay::Read {{{*/
 void  KML_Overlay::Read(FILE* fid,char* kstr){
 
@@ -123,7 +110,7 @@
 	}
 	else if (!strncmp(kstr,"</",2))
-		_error_("KML_Overlay::Read -- Unexpected closing tag %s.\n",kstr);
+	  {_error2_("KML_Overlay::Read -- Unexpected closing tag " << kstr << ".\n");}
 	else if (strncmp(kstr,"<",1))
-		_error_("KML_Overlay::Read -- Unexpected field \"%s\".\n",kstr);
+	  {_error2_("KML_Overlay::Read -- Unexpected field \"" << kstr << "\".\n");}
 
 	else if (!strcmp(kstr,"<color>"))
@@ -147,3 +134,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_Overlay.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Overlay.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Overlay.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -26,9 +26,9 @@
 		KML_Icon* icon;
 
-		/*KML_Overlay constructors, destructors {{{1*/
+		/*KML_Overlay constructors, destructors {{{*/
 		KML_Overlay();
 		~KML_Overlay();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -36,11 +36,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Placemark.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Placemark.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Placemark.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Placemark::KML_Placemark(){{{1*/
+/*FUNCTION KML_Placemark::KML_Placemark(){{{*/
 KML_Placemark::KML_Placemark(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Placemark::~KML_Placemark(){{{1*/
+/*FUNCTION KML_Placemark::~KML_Placemark(){{{*/
 KML_Placemark::~KML_Placemark(){
 
@@ -40,18 +40,18 @@
 
 /*Other*/
-/*FUNCTION KML_Placemark::Echo {{{1*/
+/*FUNCTION KML_Placemark::Echo {{{*/
 void  KML_Placemark::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Placemark:\n");
+	if(flag) _pprintLine_("KML_Placemark:");
 	KML_Feature::Echo();
 
-	_printf_(flag,"      geometry: (size=%d)\n" ,geometry->Size());
-
-	return;
-}
-/*}}}*/
-/*FUNCTION KML_Placemark::DeepEcho {{{1*/
+	if(flag) _pprintLine_("      geometry: (size=" << geometry->Size() << ")");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Placemark::DeepEcho {{{*/
 void  KML_Placemark::DeepEcho(){
 
@@ -63,5 +63,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Placemark::DeepEcho {{{1*/
+/*FUNCTION KML_Placemark::DeepEcho {{{*/
 void  KML_Placemark::DeepEcho(const char* indent){
 
@@ -70,5 +70,5 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_Placemark:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_Placemark:");
 	KML_Feature::DeepEcho(indent);
 
@@ -80,15 +80,15 @@
 	if (geometry->Size())
 		for (i=0; i<geometry->Size(); i++) {
-			_printf_(flag,"%s      geometry: -------- begin [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "      geometry: -------- begin [" << i << "] --------");
 			((KML_Geometry *)geometry->GetObjectByOffset(i))->DeepEcho(indent2);
-			_printf_(flag,"%s      geometry: --------  end  [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "      geometry: --------  end  [" << i << "] --------");
 		}
 	else
-		_printf_(flag,"%s      geometry: [empty]\n"    ,indent);
-
-	return;
-}
-/*}}}*/
-/*FUNCTION KML_Placemark::Write {{{1*/
+		if(flag) _pprintLine_(indent << "      geometry: [empty]");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Placemark::Write {{{*/
 void  KML_Placemark::Write(FILE* filout,const char* indent){
 
@@ -117,5 +117,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Placemark::Read {{{1*/
+/*FUNCTION KML_Placemark::Read {{{*/
 void  KML_Placemark::Read(FILE* fid,char* kstr){
 
@@ -140,7 +140,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_Placemark::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_Placemark::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_Placemark::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_Placemark::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strncmp(kstri,"<Point", 6)) {
@@ -189,5 +189,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Placemark::WriteExp {{{1*/
+/*FUNCTION KML_Placemark::WriteExp {{{*/
 void  KML_Placemark::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
Index: /issm/trunk/src/c/objects/KML/KML_Placemark.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Placemark.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Placemark.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -23,9 +23,9 @@
 		DataSet* geometry;
 
-		/*KML_Placemark constructors, destructors {{{1*/
+		/*KML_Placemark constructors, destructors {{{*/
 		KML_Placemark();
 		~KML_Placemark();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -34,11 +34,11 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Point.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Point.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Point.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -22,5 +22,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Point::KML_Point(){{{1*/
+/*FUNCTION KML_Point::KML_Point(){{{*/
 KML_Point::KML_Point(){
 
@@ -34,5 +34,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Point::~KML_Point(){{{1*/
+/*FUNCTION KML_Point::~KML_Point(){{{*/
 KML_Point::~KML_Point(){
 
@@ -43,20 +43,20 @@
 
 /*Other*/
-/*FUNCTION KML_Point::Echo {{{1*/
+/*FUNCTION KML_Point::Echo {{{*/
 void  KML_Point::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Point:\n");
+	if(flag) _pprintLine_("KML_Point:");
 	KML_Geometry::Echo();
 
-	_printf_(flag,"       extrude: %s\n"         ,(extrude ? "true" : "false"));
-	_printf_(flag,"       altmode: \"%s\"\n"     ,altmode);
-	_printf_(flag,"        coords: (%g,%g,%g)\n" ,coords[0],coords[1],coords[2]);
+	if(flag) _pprintLine_("       extrude: " << (extrude ? "true" : "false"));
+	if(flag) _pprintLine_("       altmode: \"" << altmode << "\"");
+	if(flag) _pprintLine_("        coords: (" << coords[0] << "," << coords[1] << "," << coords[2] << ")");
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Point::DeepEcho {{{1*/
+/*FUNCTION KML_Point::DeepEcho {{{*/
 void  KML_Point::DeepEcho(){
 
@@ -68,20 +68,20 @@
 }
 /*}}}*/
-/*FUNCTION KML_Point::DeepEcho {{{1*/
+/*FUNCTION KML_Point::DeepEcho {{{*/
 void  KML_Point::DeepEcho(const char* indent){
 
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_Point:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_Point:");
 	KML_Geometry::DeepEcho(indent);
 
-	_printf_(flag,"%s       extrude: %s\n"         ,indent,(extrude ? "true" : "false"));
-	_printf_(flag,"%s       altmode: \"%s\"\n"     ,indent,altmode);
-	_printf_(flag,"%s        coords: (%g,%g,%g)\n" ,indent,coords[0],coords[1],coords[2]);
+	if(flag) _pprintLine_(indent << "       extrude: " << (extrude ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "       altmode: \"" << altmode << "\"");
+	if(flag) _pprintLine_(indent << "        coords: (" << coords[0] << "," << coords[1] << "," << coords[2] << ")");
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Point::Write {{{1*/
+/*FUNCTION KML_Point::Write {{{*/
 void  KML_Point::Write(FILE* filout,const char* indent){
 
@@ -103,5 +103,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Point::Read {{{1*/
+/*FUNCTION KML_Point::Read {{{*/
 void  KML_Point::Read(FILE* fid,char* kstr){
 
@@ -126,20 +126,14 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_Point::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_Point::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_Point::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_Point::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<extrude>"))
-			KMLFileTokenParse(&extrude   ,
-							  kstri,
-							  fid);
+			KMLFileTokenParse(&extrude   , kstri, fid);
 		else if (!strcmp(kstri,"<altitudeMode>"))
-			KMLFileTokenParse( altmode   ,NULL,KML_POINT_ALTMODE_LENGTH,
-							  kstri,
-							  fid);
+			KMLFileTokenParse( altmode   ,NULL,KML_POINT_ALTMODE_LENGTH, kstri, fid);
 		else if (!strcmp(kstri,"<coordinates>"))
-			KMLFileTokenParse(&pcoords   ,NULL,3,
-							  kstri,
-							  fid);
+			KMLFileTokenParse(&pcoords   ,NULL,3, kstri, fid);
 
 		else if (!strncmp(kstri,"<",1))
@@ -158,5 +152,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Point::WriteExp {{{1*/
+/*FUNCTION KML_Point::WriteExp {{{*/
 void  KML_Point::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
Index: /issm/trunk/src/c/objects/KML/KML_Point.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Point.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Point.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -25,9 +25,9 @@
 		double coords[3];
 
-		/*KML_Point constructors, destructors {{{1*/
+		/*KML_Point constructors, destructors {{{*/
 		KML_Point();
 		~KML_Point();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -36,11 +36,11 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_PolyStyle.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_PolyStyle.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_PolyStyle.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_PolyStyle::KML_PolyStyle(){{{1*/
+/*FUNCTION KML_PolyStyle::KML_PolyStyle(){{{*/
 KML_PolyStyle::KML_PolyStyle(){
 
@@ -29,5 +29,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_PolyStyle::~KML_PolyStyle(){{{1*/
+/*FUNCTION KML_PolyStyle::~KML_PolyStyle(){{{*/
 KML_PolyStyle::~KML_PolyStyle(){
 
@@ -38,20 +38,19 @@
 
 /*Other*/
-/*FUNCTION KML_PolyStyle::Echo {{{1*/
+/*FUNCTION KML_PolyStyle::Echo {{{*/
 void  KML_PolyStyle::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_PolyStyle:\n");
+	if(flag) _pprintLine_("KML_PolyStyle:");
 	KML_ColorStyle::Echo();
 
-	_printf_(flag,"          fill: %d\n"          ,fill);
-	_printf_(flag,"       outline: %d\n"          ,outline);
+	if(flag) _pprintLine_("          fill: " << fill);
+	if(flag) _pprintLine_("       outline: " << outline);
 
 	return;
 }
 /*}}}*/
-
-/*FUNCTION KML_PolyStyle::DeepEcho {{{1*/
+/*FUNCTION KML_PolyStyle::DeepEcho {{{*/
 void  KML_PolyStyle::DeepEcho(){
 
@@ -63,6 +62,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_PolyStyle::DeepEcho {{{1*/
+/*FUNCTION KML_PolyStyle::DeepEcho {{{*/
 void  KML_PolyStyle::DeepEcho(const char* indent){
 
@@ -70,15 +68,14 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_PolyStyle:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_PolyStyle:");
 	KML_ColorStyle::DeepEcho(indent);
 
-	_printf_(flag,"%s          fill: %d\n"          ,indent,fill);
-	_printf_(flag,"%s       outline: %d\n"          ,indent,outline);
+	if(flag) _pprintLine_(indent << "          fill: " << fill);
+	if(flag) _pprintLine_(indent << "       outline: " << outline);
 
 	return;
 }
 /*}}}*/
-
-/*FUNCTION KML_PolyStyle::Write {{{1*/
+/*FUNCTION KML_PolyStyle::Write {{{*/
 void  KML_PolyStyle::Write(FILE* filout,const char* indent){
 
@@ -98,6 +95,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_PolyStyle::Read {{{1*/
+/*FUNCTION KML_PolyStyle::Read {{{*/
 void  KML_PolyStyle::Read(FILE* fid,char* kstr){
 
@@ -121,7 +117,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_PolyStyle::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_PolyStyle::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_PolyStyle::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_PolyStyle::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<fill>"))
@@ -149,3 +145,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_PolyStyle.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_PolyStyle.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_PolyStyle.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -22,9 +22,9 @@
 		int   outline;
 
-		/*KML_PolyStyle constructors, destructors {{{1*/
+		/*KML_PolyStyle constructors, destructors {{{*/
 		KML_PolyStyle();
 		~KML_PolyStyle();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -32,11 +32,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Polygon.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Polygon.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Polygon.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Polygon::KML_Polygon(){{{1*/
+/*FUNCTION KML_Polygon::KML_Polygon(){{{*/
 KML_Polygon::KML_Polygon(){
 
@@ -33,5 +33,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Polygon::~KML_Polygon(){{{1*/
+/*FUNCTION KML_Polygon::~KML_Polygon(){{{*/
 KML_Polygon::~KML_Polygon(){
 
@@ -50,22 +50,22 @@
 
 /*Other*/
-/*FUNCTION KML_Polygon::Echo {{{1*/
+/*FUNCTION KML_Polygon::Echo {{{*/
 void  KML_Polygon::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Polygon:\n");
+	if(flag) _pprintLine_("KML_Polygon:");
 	KML_Geometry::Echo();
 
-	_printf_(flag,"       extrude: %s\n"          ,(extrude ? "true" : "false"));
-	_printf_(flag,"    tessellate: %s\n"          ,(tessellate ? "true" : "false"));
-	_printf_(flag,"       altmode: \"%s\"\n"      ,altmode);
-	_printf_(flag,"         outer: (size=%d)\n"   ,outer->Size());
-	_printf_(flag,"         inner: (size=%d)\n"   ,inner->Size());
-
-	return;
-}
-/*}}}*/
-/*FUNCTION KML_Polygon::DeepEcho {{{1*/
+	if(flag) _pprintLine_("       extrude: " << (extrude ? "true" : "false"));
+	if(flag) _pprintLine_("    tessellate: " << (tessellate ? "true" : "false"));
+	if(flag) _pprintLine_("       altmode: \"" << altmode << "\"");
+	if(flag) _pprintLine_("         outer: (size=" << outer->Size() << ")");
+	if(flag) _pprintLine_("         inner: (size=" << inner->Size() << ")");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Polygon::DeepEcho {{{*/
 void  KML_Polygon::DeepEcho(){
 
@@ -77,5 +77,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Polygon::DeepEcho {{{1*/
+/*FUNCTION KML_Polygon::DeepEcho {{{*/
 void  KML_Polygon::DeepEcho(const char* indent){
 
@@ -84,10 +84,10 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_Polygon:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_Polygon:");
 	KML_Geometry::DeepEcho(indent);
 
-	_printf_(flag,"%s       extrude: %s\n"          ,indent,(extrude ? "true" : "false"));
-	_printf_(flag,"%s    tessellate: %s\n"          ,indent,(tessellate ? "true" : "false"));
-	_printf_(flag,"%s       altmode: \"%s\"\n"      ,indent,altmode);
+	if(flag) _pprintLine_(indent << "       extrude: " << (extrude ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "    tessellate: " << (tessellate ? "true" : "false"));
+	if(flag) _pprintLine_(indent << "       altmode: \"" << altmode << "\"");
 
 	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
@@ -96,24 +96,24 @@
 	if (outer->Size())
 		for (i=0; i<outer->Size(); i++) {
-			_printf_(flag,"%s         outer: -------- begin [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "         outer: -------- begin [" << i << "] --------");
 			((KML_LinearRing *)outer->GetObjectByOffset(i))->DeepEcho(indent2);
-			_printf_(flag,"%s         outer: --------  end  [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "         outer: --------  end  [" << i << "] --------");
 		}
 	else
-		_printf_(flag,"%s         outer: [empty]\n"    ,indent);
+		if(flag) _pprintLine_(indent << "         outer: [empty]");
 
 	if (inner->Size())
 		for (i=0; i<inner->Size(); i++) {
-			_printf_(flag,"%s         inner: -------- begin [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "         inner: -------- begin [" << i << "] --------");
 			((KML_LinearRing *)inner->GetObjectByOffset(i))->DeepEcho(indent2);
-			_printf_(flag,"%s         inner: --------  end  [%d] --------\n" ,indent,i);
+			if(flag) _pprintLine_(indent << "         inner: --------  end  [" << i << "] --------");
 		}
 	else
-		_printf_(flag,"%s         inner: [empty]\n"    ,indent);
-
-	return;
-}
-/*}}}*/
-/*FUNCTION KML_Polygon::Write {{{1*/
+		if(flag) _pprintLine_(indent << "         inner: [empty]");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Polygon::Write {{{*/
 void  KML_Polygon::Write(FILE* filout,const char* indent){
 
@@ -155,5 +155,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Polygon::Read {{{1*/
+/*FUNCTION KML_Polygon::Read {{{*/
 void  KML_Polygon::Read(FILE* fid,char* kstr){
 
@@ -179,7 +179,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_Polygon::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_Polygon::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 		else if (!strcmp(kstri,"<extrude>"))
@@ -207,7 +207,7 @@
 				}
 				else if (!strncmp(kstrj,"</",2))
-					_error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstrj);
+				  {_error2_("KML_Polygon::Read -- Unexpected closing tag " << kstrj << ".\n");}
 				else if (strncmp(kstrj,"<",1))
-					_error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstrj);
+				  {_error2_("KML_Polygon::Read -- Unexpected field \"" << kstrj << "\".\n");}
 
 				else if (!strncmp(kstrj,"<LinearRing",11)) {
@@ -234,7 +234,7 @@
 				}
 				else if (!strncmp(kstrj,"</",2))
-					_error_("KML_Polygon::Read -- Unexpected closing tag %s.\n",kstrj);
+				  {_error2_("KML_Polygon::Read -- Unexpected closing tag " << kstrj << ".\n");}
 				else if (strncmp(kstrj,"<",1))
-					_error_("KML_Polygon::Read -- Unexpected field \"%s\".\n",kstrj);
+				  {_error2_("KML_Polygon::Read -- Unexpected field \"" << kstrj << "\".\n");}
 
 				else if (!strncmp(kstrj,"<LinearRing",11)) {
@@ -266,5 +266,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Polygon::WriteExp {{{1*/
+/*FUNCTION KML_Polygon::WriteExp {{{*/
 void  KML_Polygon::WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp){
 
Index: /issm/trunk/src/c/objects/KML/KML_Polygon.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Polygon.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Polygon.h	(revision 12706)
@@ -9,5 +9,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -29,9 +29,9 @@
 		DataSet* inner;
 
-		/*KML_Polygon constructors, destructors {{{1*/
+		/*KML_Polygon constructors, destructors {{{*/
 		KML_Polygon();
 		~KML_Polygon();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -40,11 +40,11 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Style.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Style.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Style.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Style::KML_Style(){{{1*/
+/*FUNCTION KML_Style::KML_Style(){{{*/
 KML_Style::KML_Style(){
 
@@ -33,5 +33,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Style::~KML_Style(){{{1*/
+/*FUNCTION KML_Style::~KML_Style(){{{*/
 KML_Style::~KML_Style(){
 
@@ -69,24 +69,23 @@
 
 /*Other*/
-/*FUNCTION KML_Style::Echo {{{1*/
+/*FUNCTION KML_Style::Echo {{{*/
 void  KML_Style::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Style:\n");
+	if(flag) _pprintLine_("KML_Style:");
 	KML_StyleSelector::Echo();
 
-	_printf_(flag,"          icon: %p\n"          ,icon);
-	_printf_(flag,"         label: %p\n"          ,label);
-	_printf_(flag,"          line: %p\n"          ,line);
-	_printf_(flag,"          poly: %p\n"          ,poly);
-	_printf_(flag,"       balloon: %p\n"          ,balloon);
-	_printf_(flag,"          list: %p\n"          ,list);
-
-	return;
-}
-/*}}}*/
-
-/*FUNCTION KML_Style::DeepEcho {{{1*/
+	if(flag) _pprintLine_("          icon: " << icon);
+	if(flag) _pprintLine_("         label: " << label);
+	if(flag) _pprintLine_("          line: " << line);
+	if(flag) _pprintLine_("          poly: " << poly);
+	if(flag) _pprintLine_("       balloon: " << balloon);
+	if(flag) _pprintLine_("          list: " << list);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Style::DeepEcho {{{*/
 void  KML_Style::DeepEcho(){
 
@@ -98,6 +97,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_Style::DeepEcho {{{1*/
+/*FUNCTION KML_Style::DeepEcho {{{*/
 void  KML_Style::DeepEcho(const char* indent){
 
@@ -105,5 +103,5 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sKML_Style:\n",indent);
+	if(flag) _pprintLine_(indent << "KML_Style:");
 	KML_StyleSelector::DeepEcho(indent);
 
@@ -114,31 +112,30 @@
 //		icon->DeepEcho(indent2);
 //	else
-		_printf_(flag,"%s          icon: %p\n"          ,indent,icon);
+		if(flag) _pprintLine_(indent << "          icon: " << icon);
 //	if (label)
 //		label->DeepEcho(indent2);
 //	else
-		_printf_(flag,"%s         label: %p\n"          ,indent,label);
+		if(flag) _pprintLine_(indent << "         label: " << label);
 	if (line)
 		line->DeepEcho(indent2);
 	else
-		_printf_(flag,"%s          line: %p\n"          ,indent,line);
+		if(flag) _pprintLine_(indent << "          line: " << line);
 	if (poly)
 		poly->DeepEcho(indent2);
 	else
-		_printf_(flag,"%s          poly: %p\n"          ,indent,poly);
+		if(flag) _pprintLine_(indent << "          poly: " << poly);
 //	if (balloon)
 //		balloon->DeepEcho(indent2);
 //	else
-		_printf_(flag,"%s       balloon: %p\n"          ,indent,balloon);
+		if(flag) _pprintLine_(indent << "       balloon: " << balloon);
 //	if (list)
 //		list->DeepEcho(indent2);
 //	else
-		_printf_(flag,"%s          list: %p\n"          ,indent,list);
-
-	return;
-}
-/*}}}*/
-
-/*FUNCTION KML_Style::Write {{{1*/
+		if(flag) _pprintLine_(indent << "          list: " << list);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION KML_Style::Write {{{*/
 void  KML_Style::Write(FILE* filout,const char* indent){
 
@@ -174,6 +171,5 @@
 }
 /*}}}*/
-
-/*FUNCTION KML_Style::Read {{{1*/
+/*FUNCTION KML_Style::Read {{{*/
 void  KML_Style::Read(FILE* fid,char* kstr){
 
@@ -197,7 +193,7 @@
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_Style::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_Style::Read -- Unexpected closing tag " << kstri << ".\n");}
 		else if (strncmp(kstri,"<",1))
-			_error_("KML_Style::Read -- Unexpected field \"%s\".\n",kstri);
+		  {_error2_("KML_Style::Read -- Unexpected field \"" << kstri << "\".\n");}
 
 //		else if (!strncmp(kstri,"<IconStyle",10)) {
@@ -246,3 +242,2 @@
 }
 /*}}}*/
-
Index: /issm/trunk/src/c/objects/KML/KML_Style.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Style.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Style.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -28,9 +28,9 @@
 		void* list;
 
-		/*KML_Style constructors, destructors {{{1*/
+		/*KML_Style constructors, destructors {{{*/
 		KML_Style();
 		~KML_Style();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -38,11 +38,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_StyleSelector.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_StyleSelector.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_StyleSelector.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,5 +20,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_StyleSelector::KML_StyleSelector(){{{1*/
+/*FUNCTION KML_StyleSelector::KML_StyleSelector(){{{*/
 KML_StyleSelector::KML_StyleSelector(){
 
@@ -27,5 +27,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_StyleSelector::~KML_StyleSelector(){{{1*/
+/*FUNCTION KML_StyleSelector::~KML_StyleSelector(){{{*/
 KML_StyleSelector::~KML_StyleSelector(){
 
@@ -36,5 +36,5 @@
 
 /*Other*/
-/*FUNCTION KML_StyleSelector::Echo {{{1*/
+/*FUNCTION KML_StyleSelector::Echo {{{*/
 void  KML_StyleSelector::Echo(){
 
@@ -45,5 +45,5 @@
 /*}}}*/
 
-/*FUNCTION KML_StyleSelector::DeepEcho {{{1*/
+/*FUNCTION KML_StyleSelector::DeepEcho {{{*/
 void  KML_StyleSelector::DeepEcho(){
 
@@ -56,5 +56,5 @@
 /*}}}*/
 
-/*FUNCTION KML_StyleSelector::DeepEcho {{{1*/
+/*FUNCTION KML_StyleSelector::DeepEcho {{{*/
 void  KML_StyleSelector::DeepEcho(const char* indent){
 
@@ -65,5 +65,5 @@
 /*}}}*/
 
-/*FUNCTION KML_StyleSelector::Write {{{1*/
+/*FUNCTION KML_StyleSelector::Write {{{*/
 void  KML_StyleSelector::Write(FILE* filout,const char* indent){
 
@@ -74,5 +74,5 @@
 /*}}}*/
 
-/*FUNCTION KML_StyleSelector::Read {{{1*/
+/*FUNCTION KML_StyleSelector::Read {{{*/
 void  KML_StyleSelector::Read(FILE* fid,char* kstr){
 
@@ -82,7 +82,7 @@
 		return;
 	else if (!strncmp(kstr,"</",2))
-		_error_("KML_StyleSelector::Read -- Unexpected closing tag %s.\n",kstr);
+	  {_error2_("KML_StyleSelector::Read -- Unexpected closing tag " << kstr << ".\n");}
 	else if (strncmp(kstr,"<",1))
-		_error_("KML_StyleSelector::Read -- Unexpected field \"%s\".\n",kstr);
+	  {_error2_("KML_StyleSelector::Read -- Unexpected field \"" << kstr << "\".\n");}
 
 	else if (!strncmp(kstr,"<",1))
Index: /issm/trunk/src/c/objects/KML/KML_StyleSelector.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_StyleSelector.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_StyleSelector.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -19,9 +19,9 @@
 	public:
 
-		/*KML_StyleSelector constructors, destructors {{{1*/
+		/*KML_StyleSelector constructors, destructors {{{*/
 		KML_StyleSelector();
 		~KML_StyleSelector();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -29,11 +29,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_SubStyle.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_SubStyle.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_SubStyle.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,5 +20,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_SubStyle::KML_SubStyle(){{{1*/
+/*FUNCTION KML_SubStyle::KML_SubStyle(){{{*/
 KML_SubStyle::KML_SubStyle(){
 
@@ -27,5 +27,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_SubStyle::~KML_SubStyle(){{{1*/
+/*FUNCTION KML_SubStyle::~KML_SubStyle(){{{*/
 KML_SubStyle::~KML_SubStyle(){
 
@@ -36,5 +36,5 @@
 
 /*Other*/
-/*FUNCTION KML_SubStyle::Echo {{{1*/
+/*FUNCTION KML_SubStyle::Echo {{{*/
 void  KML_SubStyle::Echo(){
 
@@ -45,5 +45,5 @@
 /*}}}*/
 
-/*FUNCTION KML_SubStyle::DeepEcho {{{1*/
+/*FUNCTION KML_SubStyle::DeepEcho {{{*/
 void  KML_SubStyle::DeepEcho(){
 
@@ -56,5 +56,5 @@
 /*}}}*/
 
-/*FUNCTION KML_SubStyle::DeepEcho {{{1*/
+/*FUNCTION KML_SubStyle::DeepEcho {{{*/
 void  KML_SubStyle::DeepEcho(const char* indent){
 
@@ -65,5 +65,5 @@
 /*}}}*/
 
-/*FUNCTION KML_SubStyle::Write {{{1*/
+/*FUNCTION KML_SubStyle::Write {{{*/
 void  KML_SubStyle::Write(FILE* filout,const char* indent){
 
@@ -74,5 +74,5 @@
 /*}}}*/
 
-/*FUNCTION KML_SubStyle::Read {{{1*/
+/*FUNCTION KML_SubStyle::Read {{{*/
 void  KML_SubStyle::Read(FILE* fid,char* kstr){
 
@@ -82,7 +82,7 @@
 		return;
 	else if (!strncmp(kstr,"</",2))
-		_error_("KML_SubStyle::Read -- Unexpected closing tag %s.\n",kstr);
+	  {_error2_("KML_SubStyle::Read -- Unexpected closing tag " << kstr << ".\n");}
 	else if (strncmp(kstr,"<",1))
-		_error_("KML_SubStyle::Read -- Unexpected field \"%s\".\n",kstr);
+	  {_error2_("KML_SubStyle::Read -- Unexpected field \"" << kstr << "\".\n");}
 
 	else if (!strncmp(kstr,"<",1))
Index: /issm/trunk/src/c/objects/KML/KML_SubStyle.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_SubStyle.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_SubStyle.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -19,9 +19,9 @@
 	public:
 
-		/*KML_SubStyle constructors, destructors {{{1*/
+		/*KML_SubStyle constructors, destructors {{{*/
 		KML_SubStyle();
 		~KML_SubStyle();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -29,11 +29,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/KML/KML_Unknown.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Unknown.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Unknown.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION KML_Unknown::KML_Unknown(){{{1*/
+/*FUNCTION KML_Unknown::KML_Unknown(){{{*/
 KML_Unknown::KML_Unknown(){
 
@@ -29,5 +29,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Unknown::~KML_Unknown(){{{1*/
+/*FUNCTION KML_Unknown::~KML_Unknown(){{{*/
 KML_Unknown::~KML_Unknown(){
 
@@ -39,21 +39,21 @@
 
 /*Other*/
-/*FUNCTION KML_Unknown::Echo {{{1*/
+/*FUNCTION KML_Unknown::Echo {{{*/
 void  KML_Unknown::Echo(){
 
 	bool  flag=true;
 
-	_printf_(flag,"KML_Unknown %s:\n",name);
+	if(flag) _pprintLine_("KML_Unknown " << name << ":");
 	KML_Object::Echo();
 
 	if (value     )
-		_printf_(flag,"         value: \"%s\"\n"     ,value);
+		if(flag) _pprintLine_("         value: \"" << value << "\"");
     else
-        _printf_(flag,"         value: [none]\n"     );
+        if(flag) _pprintLine_("         value: [none]");
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Unknown::DeepEcho {{{1*/
+/*FUNCTION KML_Unknown::DeepEcho {{{*/
 void  KML_Unknown::DeepEcho(){
 
@@ -65,5 +65,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Unknown::DeepEcho {{{1*/
+/*FUNCTION KML_Unknown::DeepEcho {{{*/
 void  KML_Unknown::DeepEcho(const char* indent){
 
@@ -73,5 +73,5 @@
 	bool         flag=true;
 
-	_printf_(flag,"%sKML_Unknown %s:\n",indent,name);
+	if(flag) _pprintLine_(indent << "KML_Unknown " << name << ":");
 	KML_Object::DeepEcho(indent);
 
@@ -81,19 +81,19 @@
         
 		vtoken=strtok(valuei,nl);
-		_printf_(flag,"%s         value: \"%s"     ,indent,vtoken);
+		if(flag) _pprintString_(indent << "         value: \"" << vtoken);
     
 		while (vtoken=strtok(NULL,nl))
-			_printf_(flag,"\n%s                 %s"     ,indent,vtoken);
-		_printf_(flag,"\"\n");
+			if(flag) _pprintString_("\n" << indent << "                 " << vtoken);
+		if(flag) _pprintLine_("\"");
 
 		xfree((void**)&valuei);
 	}
     else
-        _printf_(flag,"%s         value: [none]\n"     ,indent);
+        if(flag) _pprintLine_(indent << "         value: [none]");
 
 	return;
 }
 /*}}}*/
-/*FUNCTION KML_Unknown::Write {{{1*/
+/*FUNCTION KML_Unknown::Write {{{*/
 void  KML_Unknown::Write(FILE* filout,const char* indent){
 
@@ -127,5 +127,5 @@
 }
 /*}}}*/
-/*FUNCTION KML_Unknown::Read {{{1*/
+/*FUNCTION KML_Unknown::Read {{{*/
 void  KML_Unknown::Read(FILE* fid,char* kstr){
 
@@ -139,5 +139,5 @@
 	name=KMLFileTagName(NULL,
 						kstr);
-//	_printf_(true,"KML_Unknown::Read -- opening name=%s.\n",name);
+//	_pprintLine_("KML_Unknown::Read -- opening name=" << name << ".");
 
 /*  get object attributes and check for solo tag  */
@@ -151,13 +151,13 @@
 	while (kstri=KMLFileToken(fid,
 							  &ncom,&pcom)) {
-//		_printf_(true,"KML_Unknown::Read -- kstri=%s.\n",kstri);
+//		_pprintLine_("KML_Unknown::Read -- kstri=" << kstri << ".");
 		if      (!strncmp(&kstri[0],"</", 2) &&
 				 !strncmp(&kstri[2],name,strlen(name))) {
-//			_printf_(true,"KML_Unknown::Read -- closing name=%s.\n",name);
+//			_pprintLine_("KML_Unknown::Read -- closing name=" << name << ".");
 			xfree((void**)&kstri);
 			break;
 		}
 		else if (!strncmp(kstri,"</",2))
-			_error_("KML_Unknown::Read -- Unexpected closing tag %s.\n",kstri);
+		  {_error2_("KML_Unknown::Read -- Unexpected closing tag " << kstri << ".\n");}
 
 		else if (strncmp(kstri,"<",1)) {
Index: /issm/trunk/src/c/objects/KML/KML_Unknown.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KML_Unknown.h	(revision 12705)
+++ /issm/trunk/src/c/objects/KML/KML_Unknown.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -22,9 +22,9 @@
 		char* value;
 
-		/*KML_Unknown constructors, destructors {{{1*/
+		/*KML_Unknown constructors, destructors {{{*/
 		KML_Unknown();
 		~KML_Unknown();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
@@ -32,11 +32,11 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
-		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   ObjectEnum(){_error_("Not implemented yet.");};
-		Object* copy(){_error_("Not implemented yet.");};
+		int   Id(){_error2_("Not implemented yet.");};
+		int   MyRank(){_error2_("Not implemented yet.");};
+		void  Marshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   MarshallSize(){_error2_("Not implemented yet.");};
+		void  Demarshall(char** pmarshalled_dataset){_error2_("Not implemented yet.");};
+		int   ObjectEnum(){_error2_("Not implemented yet.");};
+		Object* copy(){_error2_("Not implemented yet.");};
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Kriging/ExponentialVariogram.cpp
===================================================================
--- /issm/trunk/src/c/objects/Kriging/ExponentialVariogram.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/ExponentialVariogram.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 
 /*ExponentialVariogram constructors and destructor*/
-/*FUNCTION ExponentialVariogram::ExponentialVariogram(){{{1*/
+/*FUNCTION ExponentialVariogram::ExponentialVariogram(){{{*/
 ExponentialVariogram::ExponentialVariogram(){
 	this->nugget = 0.2;
@@ -25,5 +25,5 @@
 }
 /*}}}*/
-/*FUNCTION ExponentialVariogram::ExponentialVariogram(Options* options){{{1*/
+/*FUNCTION ExponentialVariogram::ExponentialVariogram(Options* options){{{*/
 ExponentialVariogram::ExponentialVariogram(Options* options){
 
@@ -39,8 +39,8 @@
 
 	/*Checks*/
-	if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
+	if(nugget==sill) _error2_("nugget and sill cannot be equal (constant semivariogram not allowed)");
 }
 /*}}}*/
-/*FUNCTION ExponentialVariogram::~ExponentialVariogram(){{{1*/
+/*FUNCTION ExponentialVariogram::~ExponentialVariogram(){{{*/
 ExponentialVariogram::~ExponentialVariogram(){
 	return;
@@ -49,15 +49,15 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION ExponentialVariogram::Echo {{{1*/
+/*FUNCTION ExponentialVariogram::Echo {{{*/
 void ExponentialVariogram::Echo(void){
-	printf("ExponentialVariogram\n");
-	printf("   nugget: %g\n",this->nugget);
-	printf("   sill  : %g\n",this->sill);
-	printf("   range : %g\n",this->range);
+	_printLine_("ExponentialVariogram");
+	_printLine_("   nugget: " << this->nugget);
+	_printLine_("   sill  : " << this->sill);
+	_printLine_("   range : " << this->range);
 }
 /*}}}*/
 
 /*Variogram function*/
-/*FUNCTION ExponentialVariogram::Covariance{{{1*/
+/*FUNCTION ExponentialVariogram::Covariance{{{*/
 double ExponentialVariogram::Covariance(double deltax,double deltay){
 	/*The covariance can be deduced from the variogram from the following
@@ -71,5 +71,8 @@
 	h=sqrt(pow(deltax,2.)+pow(deltay,2.));
 
-	/*return covariance*/
+	/*If h is too small, return sill*/
+	if(h<0.0000001) return sill;
+
+	/*compute covariance*/
 	a     = 1./3.;
 	cova = (sill-nugget)*exp(-h/(a*range));
@@ -77,5 +80,5 @@
 }
 /*}}}*/
-/*FUNCTION ExponentialVariogram::SemiVariogram{{{1*/
+/*FUNCTION ExponentialVariogram::SemiVariogram{{{*/
 double ExponentialVariogram::SemiVariogram(double deltax,double deltay){
 	/*http://en.wikipedia.org/wiki/Variogram*/
Index: /issm/trunk/src/c/objects/Kriging/ExponentialVariogram.h
===================================================================
--- /issm/trunk/src/c/objects/Kriging/ExponentialVariogram.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/ExponentialVariogram.h	(revision 12706)
@@ -23,9 +23,9 @@
 		/*Object virtual functions definitions*/
 		void  Echo();
-		void  DeepEcho(){_error_("Not implemented yet");};
-		int   Id(){_error_("Not implemented yet");}; 
-		int   MyRank(){_error_("Not implemented yet");};
-		int   ObjectEnum(){_error_("Not implemented yet");};
-		Object* copy(){_error_("Not implemented yet");};
+		void  DeepEcho(){_error2_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");}; 
+		int   MyRank(){_error2_("Not implemented yet");};
+		int   ObjectEnum(){_error2_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 
 		/*Variogram functions*/
Index: /issm/trunk/src/c/objects/Kriging/GaussianVariogram.cpp
===================================================================
--- /issm/trunk/src/c/objects/Kriging/GaussianVariogram.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/GaussianVariogram.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 
 /*GaussianVariogram constructors and destructor*/
-/*FUNCTION GaussianVariogram::GaussianVariogram(){{{1*/
+/*FUNCTION GaussianVariogram::GaussianVariogram(){{{*/
 GaussianVariogram::GaussianVariogram(){
 	this->nugget = 0.2;
@@ -25,5 +25,5 @@
 }
 /*}}}*/
-/*FUNCTION GaussianVariogram::GaussianVariogram(Options* options){{{1*/
+/*FUNCTION GaussianVariogram::GaussianVariogram(Options* options){{{*/
 GaussianVariogram::GaussianVariogram(Options* options){
 
@@ -39,8 +39,8 @@
 
 	/*Checks*/
-	if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
+	if(nugget==sill) _error2_("nugget and sill cannot be equal (constant semivariogram not allowed)");
 }
 /*}}}*/
-/*FUNCTION GaussianVariogram::~GaussianVariogram(){{{1*/
+/*FUNCTION GaussianVariogram::~GaussianVariogram(){{{*/
 GaussianVariogram::~GaussianVariogram(){
 	return;
@@ -49,15 +49,15 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION GaussianVariogram::Echo {{{1*/
+/*FUNCTION GaussianVariogram::Echo {{{*/
 void GaussianVariogram::Echo(void){
-	printf("GaussianVariogram\n");
-	printf("   nugget: %g\n",this->nugget);
-	printf("   sill  : %g\n",this->sill);
-	printf("   range : %g\n",this->range);
+	_printLine_("GaussianVariogram");
+	_printLine_("   nugget: " << this->nugget);
+	_printLine_("   sill  : " << this->sill);
+	_printLine_("   range : " << this->range);
 }
 /*}}}*/
 
 /*Variogram function*/
-/*FUNCTION GaussianVariogram::Covariance{{{1*/
+/*FUNCTION GaussianVariogram::Covariance{{{*/
 double GaussianVariogram::Covariance(double deltax,double deltay){
 	/*The covariance can be deduced from the variogram from the following
@@ -71,14 +71,15 @@
 	h2=pow(deltax,2.)+pow(deltay,2.);
 
-	/*return covariance*/
+	/*If h is too small, return sill*/
+	if(h2<0.0000001) return sill;
+
+	/*compute covariance*/
 	a     = 1./3.;
 	cova = (sill-nugget)*exp(-h2/(a*range*range));
-
-	if(h2<0.0000001) cova = sill;
 
 	return cova;
 }
 /*}}}*/
-/*FUNCTION GaussianVariogram::SemiVariogram{{{1*/
+/*FUNCTION GaussianVariogram::SemiVariogram{{{*/
 double GaussianVariogram::SemiVariogram(double deltax,double deltay){
 	/*http://en.wikipedia.org/wiki/Variogram*/
@@ -92,6 +93,6 @@
 	gamma = (sill-nugget)*(1.-exp(-h2/(a*range*range))) + nugget;
 
-	//if(h2>1000*1000) printf("gamma = %g h= %g\n",gamma,sqrt(h2));
-	printf("h = %g gamma = %g\n",sqrt(h2),gamma);
+	//if(h2>1000*1000) _printLine_("gamma = " << gamma << " h= " << sqrt(h2));
+	_printLine_("h = " << sqrt(h2) << " gamma = " << gamma);
 	return gamma;
 }
Index: /issm/trunk/src/c/objects/Kriging/GaussianVariogram.h
===================================================================
--- /issm/trunk/src/c/objects/Kriging/GaussianVariogram.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/GaussianVariogram.h	(revision 12706)
@@ -23,9 +23,9 @@
 		/*Object virtual functions definitions*/
 		void  Echo();
-		void  DeepEcho(){_error_("Not implemented yet");};
-		int   Id(){_error_("Not implemented yet");}; 
-		int   MyRank(){_error_("Not implemented yet");};
-		int   ObjectEnum(){_error_("Not implemented yet");};
-		Object* copy(){_error_("Not implemented yet");};
+		void  DeepEcho(){_error2_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");}; 
+		int   MyRank(){_error2_("Not implemented yet");};
+		int   ObjectEnum(){_error2_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 
 		/*Variogram functions*/
Index: /issm/trunk/src/c/objects/Kriging/Observation.cpp
===================================================================
--- /issm/trunk/src/c/objects/Kriging/Observation.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/Observation.cpp	(revision 12706)
@@ -7,10 +7,10 @@
 
 /*Observation constructors and destructor*/
-/*FUNCTION Observation::Observation(){{{1*/
+/*FUNCTION Observation::Observation(){{{*/
 Observation::Observation(){
 	return;
 }
 /*}}}*/
-/*FUNCTION Observation::Observation(double x,double y,int xi,int yi,int index,double value){{{1*/
+/*FUNCTION Observation::Observation(double x,double y,int xi,int yi,int index,double value){{{*/
 Observation::Observation(double x_in,double y_in,int xi_in,int yi_in,int index_in,double value_in){
 
@@ -25,5 +25,5 @@
 }
 /*}}}*/
-/*FUNCTION Observation::~Observation(){{{1*/
+/*FUNCTION Observation::~Observation(){{{*/
 Observation::~Observation(){
 	return;
@@ -32,22 +32,22 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Observation::Echo {{{1*/
+/*FUNCTION Observation::Echo {{{*/
 void Observation::Echo(void){
 
 	int  bit;
 
-	printf("Observation\n");
-	printf("   index : %i\n",this->index);
-	printf("   x     : %g\n",this->x);
-	printf("   y     : %g\n",this->y);
-	printf("   xi    : "); printbinary(this->xi); printf("\n");
-	printf("   yi    : "); printbinary(this->yi); printf("\n");
-	printf("   weight: %g\n",this->weight);
-	printf("   value : %g\n",this->value);
+	_printLine_("Observation");
+	_printLine_("   index : " << this->index);
+	_printLine_("   x     : " << this->x);
+	_printLine_("   y     : " << this->y);
+	_printLine_("   xi    : "); printbinary(this->xi); _printLine_("");
+	_printLine_("   yi    : "); printbinary(this->yi); _printLine_("");
+	_printLine_("   weight: " << this->weight);
+	_printLine_("   value : " << this->value);
 }
 /*}}}*/
 
 /*Observations functions*/
-/*FUNCTION Observation::WriteXYObs(double* px,double* py,double* pobs){{{1*/
+/*FUNCTION Observation::WriteXYObs(double* px,double* py,double* pobs){{{*/
 void Observation::WriteXYObs(double* px,double* py,double* pobs){
 	*px   = this->x;
Index: /issm/trunk/src/c/objects/Kriging/Observation.h
===================================================================
--- /issm/trunk/src/c/objects/Kriging/Observation.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/Observation.h	(revision 12706)
@@ -24,9 +24,9 @@
 		/*Object virtual functions definitions*/
 		void    Echo();
-		void    DeepEcho()  {_error_("Not implemented yet"); };
-		int     Id()        {_error_("Not implemented yet"); };
-		int     MyRank()    {_error_("Not implemented yet"); };
-		int     ObjectEnum(){_error_("Not implemented yet"); };
-		Object *copy()      {_error_("Not implemented yet"); };
+		void    DeepEcho()  {_error2_("Not implemented yet"); };
+		int     Id()        {_error2_("Not implemented yet"); };
+		int     MyRank()    {_error2_("Not implemented yet"); };
+		int     ObjectEnum(){_error2_("Not implemented yet"); };
+		Object *copy()      {_error2_("Not implemented yet"); };
 
 		/*Management*/
Index: /issm/trunk/src/c/objects/Kriging/PowerVariogram.cpp
===================================================================
--- /issm/trunk/src/c/objects/Kriging/PowerVariogram.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/PowerVariogram.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 
 /*PowerVariogram constructors and destructor*/
-/*FUNCTION PowerVariogram::PowerVariogram(){{{1*/
+/*FUNCTION PowerVariogram::PowerVariogram(){{{*/
 PowerVariogram::PowerVariogram(){
 	this->nugget = 0.2;
@@ -25,5 +25,5 @@
 }
 /*}}}*/
-/*FUNCTION PowerVariogram::PowerVariogram(Options* options){{{1*/
+/*FUNCTION PowerVariogram::PowerVariogram(Options* options){{{*/
 PowerVariogram::PowerVariogram(Options* options){
 
@@ -39,9 +39,9 @@
 
 	/*Checks*/
-	if(power<=0 || power>=2) _error_("power must be betwwen 0 and 2 (0 < power < 2)");
-	if(slope<=0) _error_("slope must be positive");
+	if(power<=0 || power>=2) _error2_("power must be betwwen 0 and 2 (0 < power < 2)");
+	if(slope<=0) _error2_("slope must be positive");
 }
 /*}}}*/
-/*FUNCTION PowerVariogram::~PowerVariogram(){{{1*/
+/*FUNCTION PowerVariogram::~PowerVariogram(){{{*/
 PowerVariogram::~PowerVariogram(){
 	return;
@@ -50,15 +50,15 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION PowerVariogram::Echo {{{1*/
+/*FUNCTION PowerVariogram::Echo {{{*/
 void PowerVariogram::Echo(void){
-	printf("PowerVariogram\n");
-	printf("   nugget: %g\n",this->nugget);
-	printf("   slope : %g\n",this->slope);
-	printf("   power : %g\n",this->power);
+	_printLine_("PowerVariogram");
+	_printLine_("   nugget: " << this->nugget);
+	_printLine_("   slope : " << this->slope);
+	_printLine_("   power : " << this->power);
 }
 /*}}}*/
 
 /*Variogram function*/
-/*FUNCTION PowerVariogram::Covariance{{{1*/
+/*FUNCTION PowerVariogram::Covariance{{{*/
 double PowerVariogram::Covariance(double deltax,double deltay){
 	/*The covariance can be deduced from the variogram from the following
@@ -78,5 +78,5 @@
 }
 /*}}}*/
-/*FUNCTION PowerVariogram::SemiVariogram{{{1*/
+/*FUNCTION PowerVariogram::SemiVariogram{{{*/
 double PowerVariogram::SemiVariogram(double deltax,double deltay){
 	/*http://en.wikipedia.org/wiki/Variogram*/
@@ -89,5 +89,5 @@
 	gamma = this->nugget + this->slope*pow(h,this->power);
 
-	//if(h>1000) printf("gamma = %g h=%g\n",gamma,h);
+	//if(h>1000) _printLine_("gamma = " << gamma << " h=" << h);
 	return gamma;
 }
Index: /issm/trunk/src/c/objects/Kriging/PowerVariogram.h
===================================================================
--- /issm/trunk/src/c/objects/Kriging/PowerVariogram.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/PowerVariogram.h	(revision 12706)
@@ -23,9 +23,9 @@
 		/*Object virtual functions definitions*/
 		void  Echo();
-		void  DeepEcho(){_error_("Not implemented yet");};
-		int   Id(){_error_("Not implemented yet");}; 
-		int   MyRank(){_error_("Not implemented yet");};
-		int   ObjectEnum(){_error_("Not implemented yet");};
-		Object* copy(){_error_("Not implemented yet");};
+		void  DeepEcho(){_error2_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");}; 
+		int   MyRank(){_error2_("Not implemented yet");};
+		int   ObjectEnum(){_error2_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 
 		/*Variogram functions*/
Index: /issm/trunk/src/c/objects/Kriging/Quadtree.cpp
===================================================================
--- /issm/trunk/src/c/objects/Kriging/Quadtree.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/Quadtree.cpp	(revision 12706)
@@ -1,4 +1,5 @@
 #include "../objects.h"
-/*DOCUMENTATION What is a Quadtree? {{{1
+
+/*DOCUMENTATION What is a Quadtree? {{{
  * A Quadtree is a very simple way to group vertices according
  * to their locations. A square that holds all the points of the mesh
@@ -46,6 +47,6 @@
  * Using binaries is therefore very easy to locate a vertex in a box:
  * we just need to look at the bits from the left to the right (See ::Add)
- }}}1*/
-/*MACROS {{{1*/
+ }}}*/
+/*MACROS {{{*/
 /* 
  * 
@@ -80,11 +81,11 @@
 
 	/*Constructors/Destructors*/
-/*FUNCTION Quadtree::Quadtree(){{{1*/
+/*FUNCTION Quadtree::Quadtree(){{{*/
 Quadtree::Quadtree(){
-	_error_("Constructor not supported");
+	_error2_("Constructor not supported");
 
 }
-/*}}}1*/
-/*FUNCTION Quadtree::Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth){{{1*/
+/*}}}*/
+/*FUNCTION Quadtree::Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth){{{*/
 Quadtree::Quadtree(double xmin,double xmax,double ymin,double ymax,int maxdepth){
 
@@ -104,6 +105,6 @@
 	this->root=NewQuadtreeBox(xmin+length/2,ymin+length/2,length);
 }
-/*}}}1*/
-	/*FUNCTION Quadtree::~Quadtree(){{{1*/
+/*}}}*/
+	/*FUNCTION Quadtree::~Quadtree(){{{*/
 	Quadtree::~Quadtree(){
 
@@ -112,8 +113,8 @@
 
 	}
-	/*}}}1*/
+	/*}}}*/
 
 	/*Methods*/
-/*FUNCTION Quadtree::Add{{{1*/
+/*FUNCTION Quadtree::Add{{{*/
 void  Quadtree::Add(Observation* observation){
 
@@ -198,5 +199,5 @@
 
 }/*}}}*/
-/*FUNCTION Quadtree::AddAndAverage{{{1*/
+/*FUNCTION Quadtree::AddAndAverage{{{*/
 void Quadtree::AddAndAverage(double x,double y,double value){
 
@@ -247,8 +248,8 @@
 	}
 	else{
-		_error_("Box is not full");
-	}
-}/*}}}*/
-/*FUNCTION Quadtree::ClosestObs{{{1*/
+		_error2_("Box is not full");
+	}
+}/*}}}*/
+/*FUNCTION Quadtree::ClosestObs{{{*/
 void Quadtree::ClosestObs(int *pindex,double x,double y){
 
@@ -293,26 +294,26 @@
 	*pindex=index;
 }/*}}}*/
-/*FUNCTION Quadtree::Echo{{{1*/
+/*FUNCTION Quadtree::Echo{{{*/
 void  Quadtree::Echo(void){
 
-	printf("Quadtree:\n");
-	printf("   MaxDepth      = %i\n",this->MaxDepth);
-	printf("   NbQuadtreeBox = %i\n",this->NbQuadtreeBox);
-	printf("   NbObs         = %i\n",this->NbObs);
-	printf("   root          = %p\n",this->root);
-
-}/*}}}*/
-/*FUNCTION Quadtree::DeepEcho{{{1*/
+	_printLine_("Quadtree:");
+	_printLine_("   MaxDepth      = " << this->MaxDepth);
+	_printLine_("   NbQuadtreeBox = " << this->NbQuadtreeBox);
+	_printLine_("   NbObs         = " << this->NbObs);
+	_printLine_("   root          = " << this->root);
+
+}/*}}}*/
+/*FUNCTION Quadtree::DeepEcho{{{*/
 void  Quadtree::DeepEcho(void){
 
-	printf("Quadtree:\n");
-	printf("   MaxDepth      = %i\n",this->MaxDepth);
-	printf("   NbQuadtreeBox = %i\n",this->NbQuadtreeBox);
-	printf("   NbObs         = %i\n",this->NbObs);
-	printf("   root          = %p\n",this->root);
+	_printLine_("Quadtree:");
+	_printLine_("   MaxDepth      = " << this->MaxDepth);
+	_printLine_("   NbQuadtreeBox = " << this->NbQuadtreeBox);
+	_printLine_("   NbObs         = " << this->NbObs);
+	_printLine_("   root          = " << this->root);
 	boxcontainer->Echo();
 
 }/*}}}*/
-/*FUNCTION Quadtree::IntergerCoordinates{{{1*/
+/*FUNCTION Quadtree::IntergerCoordinates{{{*/
 void  Quadtree::IntergerCoordinates(int *xi,int *yi,double x,double y){
 
@@ -338,5 +339,5 @@
 	*yi=int(coefficient*(y - ymin));
 }/*}}}*/
-/*FUNCTION Quadtree::NewQuadtreeBox(double xcenter,double ycenter,double length){{{1*/
+/*FUNCTION Quadtree::NewQuadtreeBox(double xcenter,double ycenter,double length){{{*/
 Quadtree::QuadtreeBox* Quadtree::NewQuadtreeBox(double xcenter,double ycenter,double length){
 
@@ -362,5 +363,5 @@
 	return newbox;
 }/*}}}*/
-/*FUNCTION Quadtree::NewQuadtreeBox(QuadtreeBox* master,int index) {{{1*/
+/*FUNCTION Quadtree::NewQuadtreeBox(QuadtreeBox* master,int index) {{{*/
 Quadtree::QuadtreeBox* Quadtree::NewQuadtreeBox(QuadtreeBox* master,int index){
 
@@ -396,5 +397,5 @@
 			break;
 		default:
-			_error_("Case %i not supported",index);
+			_error2_("Case " << index << " not supported");
 	}
 	newbox->length=master->length/2;
@@ -407,5 +408,5 @@
 	return newbox;
 }/*}}}*/
-/*FUNCTION Quadtree::QuadtreeDepth{{{1*/
+/*FUNCTION Quadtree::QuadtreeDepth{{{*/
 void Quadtree::QuadtreeDepth(int* A,int xi,int yi){
 
@@ -435,5 +436,5 @@
 	*A=level;
 }/*}}}*/
-/*FUNCTION Quadtree::QuadtreeDepth2{{{1*/
+/*FUNCTION Quadtree::QuadtreeDepth2{{{*/
 void Quadtree::QuadtreeDepth2(int* A,int xi,int yi){
 
@@ -488,5 +489,5 @@
 	*A=level;
 }/*}}}*/
-/*FUNCTION Quadtree::RangeSearch{{{1*/
+/*FUNCTION Quadtree::RangeSearch{{{*/
 void Quadtree::RangeSearch(int **pindices,int *pnobs,double x,double y,double range){
 
@@ -496,5 +497,5 @@
 
 	/*Allocate indices (maximum by default*/
-	if(this->NbObs) indices = (int*)xmalloc(this->NbObs*sizeof(int));
+	if(this->NbObs) indices = xNew<int>(this->NbObs);
 	nobs = 0;
 
@@ -508,15 +509,15 @@
 
 /*QuadtreeBox methos*/
-/*FUNCTION QuadtreeBox::Echo{{{1*/
+/*FUNCTION QuadtreeBox::Echo{{{*/
 void  Quadtree::QuadtreeBox::Echo(void){
 
-	printf("QuadtreeBox:\n");
-	printf("   nbitems = %i\n",this->nbitems);
-	printf("   xcenter = %g\n",this->xcenter);
-	printf("   ycenter = %g\n",this->ycenter);
-	printf("   length  = %g\n",this->length);
-
-}/*}}}*/
-/*FUNCTION QuadtreeBox::IsWithinRange{{{1*/
+	_printLine_("QuadtreeBox:");
+	_printLine_("   nbitems = " << this->nbitems);
+	_printLine_("   xcenter = " << this->xcenter);
+	_printLine_("   ycenter = " << this->ycenter);
+	_printLine_("   length  = " << this->length);
+
+}/*}}}*/
+/*FUNCTION QuadtreeBox::IsWithinRange{{{*/
 int Quadtree::QuadtreeBox::IsWithinRange(double x,double y,double range){
 
@@ -537,5 +538,5 @@
 
 }/*}}}*/
-/*FUNCTION QuadtreeBox::RangeSearch{{{1*/
+/*FUNCTION QuadtreeBox::RangeSearch{{{*/
 void Quadtree::QuadtreeBox::RangeSearch(int* indices,int *pnobs,double x,double y,double range){
 
@@ -573,5 +574,5 @@
 			break;
 		default:
-			_error_("Case %i not supported",this->IsWithinRange(x,y,range));
+			_error2_("Case " << this->IsWithinRange(x,y,range) << " not supported");
 	}
 
@@ -579,5 +580,5 @@
 	*pnobs=nobs;
 }/*}}}*/
-/*FUNCTION QuadtreeBox::WriteObservations{{{1*/
+/*FUNCTION QuadtreeBox::WriteObservations{{{*/
 void Quadtree::QuadtreeBox::WriteObservations(int* indices,int *pnobs){
 
Index: /issm/trunk/src/c/objects/Kriging/Quadtree.h
===================================================================
--- /issm/trunk/src/c/objects/Kriging/Quadtree.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/Quadtree.h	(revision 12706)
@@ -27,9 +27,9 @@
 				/*Object functions (Needed because the Quadtree uses a Container*/
 				void    Echo();
-				void    DeepEcho()  {_error_("not implemented yet"); };
-				int     Id()        {_error_("not implemented yet"); };
-				int     MyRank()    {_error_("not implemented yet"); };
-				int     ObjectEnum(){_error_("not implemented yet"); };
-				Object *copy()      {_error_("not implemented yet"); };
+				void    DeepEcho()  {_error2_("not implemented yet"); };
+				int     Id()        {_error2_("not implemented yet"); };
+				int     MyRank()    {_error2_("not implemented yet"); };
+				int     ObjectEnum(){_error2_("not implemented yet"); };
+				Object *copy()      {_error2_("not implemented yet"); };
 
 				/*Methods*/
@@ -46,6 +46,6 @@
 		int          MaxDepth;          // maximum number of subdivision
 		QuadtreeBox *root;              // main box
-		long         NbQuadtreeBox;     // total number of boxes
-		long         NbObs;             // number of points
+		int          NbQuadtreeBox;     // total number of boxes
+		int          NbObs;             // number of points
 
 		Quadtree();
Index: /issm/trunk/src/c/objects/Kriging/SphericalVariogram.cpp
===================================================================
--- /issm/trunk/src/c/objects/Kriging/SphericalVariogram.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/SphericalVariogram.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 
 /*SphericalVariogram constructors and destructor*/
-/*FUNCTION SphericalVariogram::SphericalVariogram(){{{1*/
+/*FUNCTION SphericalVariogram::SphericalVariogram(){{{*/
 SphericalVariogram::SphericalVariogram(){
 	this->nugget = 0.2;
@@ -25,5 +25,5 @@
 }
 /*}}}*/
-/*FUNCTION SphericalVariogram::SphericalVariogram(Options* options){{{1*/
+/*FUNCTION SphericalVariogram::SphericalVariogram(Options* options){{{*/
 SphericalVariogram::SphericalVariogram(Options* options){
 
@@ -39,8 +39,8 @@
 
 	/*Checks*/
-	if(nugget==sill) _error_("nugget and sill cannot be equal (constant semivariogram not allowed)");
+	if(nugget==sill) _error2_("nugget and sill cannot be equal (constant semivariogram not allowed)");
 }
 /*}}}*/
-/*FUNCTION SphericalVariogram::~SphericalVariogram(){{{1*/
+/*FUNCTION SphericalVariogram::~SphericalVariogram(){{{*/
 SphericalVariogram::~SphericalVariogram(){
 	return;
@@ -49,15 +49,15 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION SphericalVariogram::Echo {{{1*/
+/*FUNCTION SphericalVariogram::Echo {{{*/
 void SphericalVariogram::Echo(void){
-	printf("SphericalVariogram\n");
-	printf("   nugget: %g\n",this->nugget);
-	printf("   sill  : %g\n",this->sill);
-	printf("   range : %g\n",this->range);
+	_printLine_("SphericalVariogram");
+	_printLine_("   nugget: " << this->nugget);
+	_printLine_("   sill  : " << this->sill);
+	_printLine_("   range : " << this->range);
 }
 /*}}}*/
 
 /*Variogram function*/
-/*FUNCTION SphericalVariogram::Covariance{{{1*/
+/*FUNCTION SphericalVariogram::Covariance{{{*/
 double SphericalVariogram::Covariance(double deltax,double deltay){
 	/*The covariance can be deduced from the variogram from the following
@@ -80,5 +80,5 @@
 }
 /*}}}*/
-/*FUNCTION SphericalVariogram::SemiVariogram{{{1*/
+/*FUNCTION SphericalVariogram::SemiVariogram{{{*/
 double SphericalVariogram::SemiVariogram(double deltax,double deltay){
 	/*http://en.wikipedia.org/wiki/Variogram*/
Index: /issm/trunk/src/c/objects/Kriging/SphericalVariogram.h
===================================================================
--- /issm/trunk/src/c/objects/Kriging/SphericalVariogram.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Kriging/SphericalVariogram.h	(revision 12706)
@@ -23,9 +23,9 @@
 		/*Object virtual functions definitions*/
 		void  Echo();
-		void  DeepEcho(){_error_("Not implemented yet");};
-		int   Id(){_error_("Not implemented yet");}; 
-		int   MyRank(){_error_("Not implemented yet");};
-		int   ObjectEnum(){_error_("Not implemented yet");};
-		Object* copy(){_error_("Not implemented yet");};
+		void  DeepEcho(){_error2_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");}; 
+		int   MyRank(){_error2_("Not implemented yet");};
+		int   ObjectEnum(){_error2_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 
 		/*Variogram functions*/
Index: /issm/trunk/src/c/objects/Loads/Friction.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Friction.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Friction.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructors*/
-/*FUNCTION Friction::Friction() {{{1*/
+/*FUNCTION Friction::Friction() {{{*/
 Friction::Friction(){
 	this->element_type=NULL;
@@ -28,33 +28,33 @@
 }
 /*}}}*/
-/*FUNCTION Friction::Friction(const char* element_type, Inputs* inputs,Matpar* matpar,int analysis_type){{{1*/
+/*FUNCTION Friction::Friction(const char* element_type, Inputs* inputs,Matpar* matpar,int analysis_type){{{*/
 Friction::Friction(const char* element_type_in,Inputs* inputs_in,Matpar* matpar_in, int in_analysis_type){
 
 	this->analysis_type=in_analysis_type;
 	this->inputs=inputs_in;
-	this->element_type=(char*)xmalloc((strlen(element_type_in)+1)*sizeof(char));
-	memcpy(this->element_type,element_type_in,(strlen(element_type_in)+1)*sizeof(char));
+	this->element_type=xNew<char>(strlen(element_type_in)+1);
+	xMemCpy<char>(this->element_type,element_type_in,(strlen(element_type_in)+1));
 
 	this->matpar=matpar_in;
 }
 /*}}}*/
-/*FUNCTION Friction::~Friction() {{{1*/
+/*FUNCTION Friction::~Friction() {{{*/
 Friction::~Friction(){
-	xfree((void**)&element_type);
+	xDelete<char>(element_type);
 }
 /*}}}*/
 
 /*methods: */
-/*FUNCTION Friction::Echo {{{1*/
+/*FUNCTION Friction::Echo {{{*/
 void Friction::Echo(void){
-	printf("Friction:\n");
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
-	printf("   element_type: %s\n",this->element_type);
+	_printLine_("Friction:");
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
+	_printLine_("   element_type: " << this->element_type);
 	inputs->Echo();
 	matpar->Echo();
 }
 /*}}}*/
-/*FUNCTION Friction::GetAlpha2(double* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){{{1*/
-void Friction::GetAlpha2(double* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){
+/*FUNCTION Friction::GetAlpha2(IssmDouble* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){{{*/
+void Friction::GetAlpha2(IssmDouble* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum){
 
 	/*This routine calculates the basal friction coefficient 
@@ -62,12 +62,12 @@
 
 	/*diverse: */
-	double  r,s;
-	double  drag_p, drag_q;
-	double  gravity,rho_ice,rho_water;
-	double  Neff;
-	double  thickness,bed;
-	double  vx,vy,vz,vmag;
-	double  drag_coefficient;
-	double  alpha2;
+	IssmDouble  r,s;
+	IssmDouble  drag_p, drag_q;
+	IssmDouble  gravity,rho_ice,rho_water;
+	IssmDouble  Neff;
+	IssmDouble  thickness,bed;
+	IssmDouble  vx,vy,vz,vmag;
+	IssmDouble  drag_coefficient;
+	IssmDouble  alpha2;
 
 	/*Recover parameters: */
@@ -107,11 +107,11 @@
 		vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
 	}
-	else _error_("element_type %s not supported yet",element_type);
+	else _error2_("element_type "<< element_type << " not supported yet");
 
 	/*Checks that s-1>0 if v=0*/
-	if(vmag==0 && (s-1)<0) _error_("velocity is 0 ans (s-1)=%g<0, alpha_complement is Inf",s-1);
+        if(vmag==0 && (s-1)<0) _error2_("velocity is 0 and (s-1)=" << (s-1) << "<0, alpha_complement is Inf");
 
 	alpha2=pow(drag_coefficient,2)*pow(Neff,r)*pow(vmag,(s-1));
-	_assert_(!isnan(alpha2));
+	_assert_(!xIsNan<IssmDouble>(alpha2));
 
 	/*Assign output pointers:*/
@@ -119,6 +119,6 @@
 }
 /*}}}*/
-/*FUNCTION Friction::GetAlpha2(double* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){{{1*/
-void Friction::GetAlpha2(double* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){
+/*FUNCTION Friction::GetAlpha2(IssmDouble* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){{{*/
+void Friction::GetAlpha2(IssmDouble* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){
 
 	/*This routine calculates the basal friction coefficient 
@@ -126,12 +126,12 @@
 
 	/*diverse: */
-	double  r,s;
-	double  drag_p, drag_q;
-	double  gravity,rho_ice,rho_water;
-	double  Neff;
-	double  thickness,bed;
-	double  vx,vy,vz,vmag;
-	double  drag_coefficient;
-	double  alpha2;
+	IssmDouble  r,s;
+	IssmDouble  drag_p, drag_q;
+	IssmDouble  gravity,rho_ice,rho_water;
+	IssmDouble  Neff;
+	IssmDouble  thickness,bed;
+	IssmDouble  vx,vy,vz,vmag;
+	IssmDouble  drag_coefficient;
+	IssmDouble  alpha2;
 
 	/*Recover parameters: */
@@ -171,11 +171,11 @@
 		vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
 	}
-	else _error_("element_type %s not supported yet",element_type);
+	else _error2_("element_type "<< element_type << " not supported yet");
 
 	/*Checks that s-1>0 if v=0*/
-	if(vmag==0 && (s-1)<0) _error_("velocity is 0 ans (s-1)=%g<0, alpha_complement is Inf",s-1);
+	if(vmag==0 && (s-1)<0) _error2_("velocity is 0 and (s-1)=" << (s-1) << "<0, alpha_complement is Inf");
 
 	alpha2=pow(drag_coefficient,2)*pow(Neff,r)*pow(vmag,(s-1));
-	_assert_(!isnan(alpha2));
+	_assert_(!xIsNan<IssmDouble>(alpha2));
 
 	/*Assign output pointers:*/
@@ -183,6 +183,6 @@
 }
 /*}}}*/
-/*FUNCTION Friction::GetAlphaComplement(double* palpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum) {{{1*/
-void Friction::GetAlphaComplement(double* palpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum){
+/*FUNCTION Friction::GetAlphaComplement(IssmDouble* palpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum) {{{*/
+void Friction::GetAlphaComplement(IssmDouble* palpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum){
 
 	/* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p. 
@@ -192,12 +192,12 @@
 	/*diverse: */
 	int     i;
-	double  r,s;
-	double  vx,vy,vz,vmag;
-	double  drag_p,drag_q;
-	double  Neff;
-	double  drag_coefficient;
-	double  bed,thickness;
-	double  gravity,rho_ice,rho_water;
-	double  alpha_complement;
+	IssmDouble  r,s;
+	IssmDouble  vx,vy,vz,vmag;
+	IssmDouble  drag_p,drag_q;
+	IssmDouble  Neff;
+	IssmDouble  drag_coefficient;
+	IssmDouble  bed,thickness;
+	IssmDouble  gravity,rho_ice,rho_water;
+	IssmDouble  alpha_complement;
 
 	/*Recover parameters: */
@@ -238,10 +238,10 @@
 		vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
 	}
-	else _error_("element_type %s not supported yet",element_type);
+	else _error2_("element_type "<< element_type << " not supported yet");
 
 	/*Checks that s-1>0 if v=0*/
-	if(vmag==0 && (s-1)<0) _error_("velocity is 0 ans (s-1)=%g<0, alpha_complement is Inf",s-1);
-
-	alpha_complement=pow(Neff,r)*pow(vmag,(s-1));            _assert_(!isnan(alpha_complement));
+	if(vmag==0 && (s-1)<0) _error2_("velocity is 0 and (s-1)=" << (s-1) << "<0, alpha_complement is Inf");
+
+	alpha_complement=pow(Neff,r)*pow(vmag,(s-1));            _assert_(!xIsNan<IssmDouble>(alpha_complement));
 
 	/*Assign output pointers:*/
@@ -249,6 +249,6 @@
 }
 /*}}}*/
-/*FUNCTION Friction::GetAlphaComplement(double* palpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum) {{{1*/
-void Friction::GetAlphaComplement(double* palpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){
+/*FUNCTION Friction::GetAlphaComplement(IssmDouble* palpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum) {{{*/
+void Friction::GetAlphaComplement(IssmDouble* palpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum){
 
 	/* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p. 
@@ -258,12 +258,12 @@
 	/*diverse: */
 	int     i;
-	double  r,s;
-	double  vx,vy,vz,vmag;
-	double  drag_p,drag_q;
-	double  Neff;
-	double  drag_coefficient;
-	double  bed,thickness;
-	double  gravity,rho_ice,rho_water;
-	double  alpha_complement;
+	IssmDouble  r,s;
+	IssmDouble  vx,vy,vz,vmag;
+	IssmDouble  drag_p,drag_q;
+	IssmDouble  Neff;
+	IssmDouble  drag_coefficient;
+	IssmDouble  bed,thickness;
+	IssmDouble  gravity,rho_ice,rho_water;
+	IssmDouble  alpha_complement;
 
 	/*Recover parameters: */
@@ -304,10 +304,10 @@
 		vmag=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
 	}
-	else _error_("element_type %s not supported yet",element_type);
+	else _error2_("element_type "<< element_type << " not supported yet");
 
 	/*Checks that s-1>0 if v=0*/
-	if(vmag==0 && (s-1)<0) _error_("velocity is 0 ans (s-1)=%g<0, alpha_complement is Inf",s-1);
-
-	alpha_complement=pow(Neff,r)*pow(vmag,(s-1));            _assert_(!isnan(alpha_complement));
+	if(vmag==0 && (s-1)<0) _error2_("velocity is 0 and (s-1)=" << (s-1) << "<0, alpha_complement is Inf");
+
+	alpha_complement=pow(Neff,r)*pow(vmag,(s-1));            _assert_(!xIsNan<IssmDouble>(alpha_complement));
 
 	/*Assign output pointers:*/
@@ -315,18 +315,18 @@
 }
 /*}}}*/
-/*FUNCTION Friction::GetInputValue{{{1*/
-void Friction::GetInputValue(double* pvalue,GaussTria* gauss,int enum_type){
+/*FUNCTION Friction::GetInputValue{{{*/
+void Friction::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int enum_type){
 
 	Input* input=inputs->GetInput(enum_type);
-	if(!input) _error_("input %s not found",EnumToStringx(enum_type));
+	if(!input) _error2_("input " << EnumToStringx(enum_type) << " not found");
 	input->GetInputValue(pvalue,gauss);
 
 }
 /*}}}*/
-/*FUNCTION Friction::GetInputValue{{{1*/
-void Friction::GetInputValue(double* pvalue,GaussPenta* gauss,int enum_type){
+/*FUNCTION Friction::GetInputValue{{{*/
+void Friction::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,int enum_type){
 
 	Input* input=inputs->GetInput(enum_type);
-	if(!input) _error_("input %s not found",EnumToStringx(enum_type));
+	if(!input) _error2_("input " << EnumToStringx(enum_type) << " not found");
 	input->GetInputValue(pvalue,gauss);
 
Index: /issm/trunk/src/c/objects/Loads/Friction.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Friction.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Friction.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 class Inputs;
 class Matpar;
@@ -27,10 +27,10 @@
 	
 		void  Echo(void);
-		void  GetAlpha2(double* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
-		void  GetAlpha2(double* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);
-		void  GetAlphaComplement(double* alpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
-		void  GetAlphaComplement(double* alpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);
-		void  GetInputValue(double* pvalue,GaussTria* gauss,int enum_type);
-		void  GetInputValue(double* pvalue,GaussPenta* gauss,int enum_type);
+		void  GetAlpha2(IssmDouble* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
+		void  GetAlpha2(IssmDouble* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);
+		void  GetAlphaComplement(IssmDouble* alpha_complement, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
+		void  GetAlphaComplement(IssmDouble* alpha_complement, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);
+		void  GetInputValue(IssmDouble* pvalue,GaussTria* gauss,int enum_type);
+		void  GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,int enum_type);
 
 };
Index: /issm/trunk/src/c/objects/Loads/Icefront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -24,5 +24,5 @@
 
 /*Icefront constructors and destructor*/
-/*FUNCTION Icefront::Icefront() {{{1*/
+/*FUNCTION Icefront::Icefront() {{{*/
 Icefront::Icefront(){
 
@@ -38,5 +38,5 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::Icefront(int id, int i, IoModel* iomodel,int analysis_type) {{{1*/
+/*FUNCTION Icefront::Icefront(int id, int i, IoModel* iomodel,int analysis_type) {{{*/
 Icefront::Icefront(int icefront_id,int i, IoModel* iomodel,int in_icefront_type, int in_analysis_type){
 
@@ -65,21 +65,21 @@
 	}
 	_assert_(iomodel->Data(DiagnosticIcefrontEnum));
-	element=(int)(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+segment_width-2)-1); //element is in the penultimate column (node1 node2 ... elem fill)
+	element=reCast<int,IssmDouble>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+segment_width-2)-1); //element is in the penultimate column (node1 node2 ... elem fill)
 
 	/*Build ids for hook constructors: */
-	icefront_eid=(int) *(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+segment_width-2); //matlab indexing
+	icefront_eid=reCast<int,IssmDouble>( *(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+segment_width-2)); //matlab indexing
 	icefront_mparid=numberofelements+1; //matlab indexing
 
 	if (in_icefront_type==MacAyeal2dIceFrontEnum || in_icefront_type==MacAyeal3dIceFrontEnum){
-		icefront_node_ids[0]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+0);
-		icefront_node_ids[1]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+1);
+		icefront_node_ids[0]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+0));
+		icefront_node_ids[1]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+1));
 	}
 	else if (in_icefront_type==PattynIceFrontEnum || in_icefront_type==StokesIceFrontEnum){
-		icefront_node_ids[0]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+0);
-		icefront_node_ids[1]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+1);
-		icefront_node_ids[2]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+2);
-		icefront_node_ids[3]=iomodel->nodecounter+(int)*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+3);
-	}
-	else _error_("in_icefront_type %s not supported yet!",EnumToStringx(in_icefront_type));
+		icefront_node_ids[0]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+0));
+		icefront_node_ids[1]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+1));
+		icefront_node_ids[2]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+2));
+		icefront_node_ids[3]=iomodel->nodecounter+reCast<int>(*(iomodel->Data(DiagnosticIcefrontEnum)+segment_width*i+3));
+	}
+	else _error2_("in_icefront_type " << EnumToStringx(in_icefront_type) << " not supported yet!");
 
 	if (in_icefront_type==PattynIceFrontEnum || in_icefront_type==StokesIceFrontEnum)
@@ -89,5 +89,5 @@
 
 	/*Fill*/
-	icefront_fill=(int)iomodel->Data(DiagnosticIcefrontEnum)[segment_width*i+segment_width-1];
+	icefront_fill=reCast<int>(iomodel->Data(DiagnosticIcefrontEnum)[segment_width*i+segment_width-1]);
 	
 	/*Ok, we have everything to build the object: */
@@ -114,5 +114,5 @@
 
 /*}}}*/
-/*FUNCTION Icefront::~Icefront() {{{1*/
+/*FUNCTION Icefront::~Icefront() {{{*/
 Icefront::~Icefront(){
 	delete inputs;
@@ -125,37 +125,37 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Icefront::Echo {{{1*/
+/*FUNCTION Icefront::Echo {{{*/
 void Icefront::Echo(void){
-	printf("Icefront:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Icefront:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnodes->Echo();
 	helement->Echo();
 	hmatpar->Echo();
-	printf("   parameters: %p\n",parameters);
+	_printLine_("   parameters: " << parameters);
 	if(parameters)parameters->Echo();
-	printf("   inputs: %p\n",inputs);
+	_printLine_("   inputs: " << inputs);
 	if(inputs)inputs->Echo();
 }
 /*}}}*/
-/*FUNCTION Icefront::DeepEcho{{{1*/
+/*FUNCTION Icefront::DeepEcho{{{*/
 void Icefront::DeepEcho(void){
 
-	printf("Icefront:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Icefront:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnodes->DeepEcho();
 	helement->DeepEcho();
 	hmatpar->DeepEcho();
-	printf("   parameters: %p\n",parameters);
+	_printLine_("   parameters: " << parameters);
 	if(parameters)parameters->DeepEcho();
-	printf("   inputs: %p\n",inputs);
+	_printLine_("   inputs: " << inputs);
 	if(inputs)inputs->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION Icefront::Id {{{1*/
+/*FUNCTION Icefront::Id {{{*/
 int    Icefront::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Icefront::MyRank {{{1*/
+/*FUNCTION Icefront::MyRank {{{*/
 int    Icefront::MyRank(void){ 
 	extern int my_rank;
@@ -163,5 +163,5 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::ObjectEnum{{{1*/
+/*FUNCTION Icefront::ObjectEnum{{{*/
 int Icefront::ObjectEnum(void){
 
@@ -170,5 +170,5 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::copy {{{1*/
+/*FUNCTION Icefront::copy {{{*/
 Object* Icefront::copy() {
 	
@@ -205,5 +205,5 @@
 
 /*Load virtual functions definitions:*/
-/*FUNCTION Icefront::Configure {{{1*/
+/*FUNCTION Icefront::Configure {{{*/
 void  Icefront::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
@@ -223,9 +223,9 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::SetCurrentConfiguration {{{1*/
+/*FUNCTION Icefront::SetCurrentConfiguration {{{*/
 void  Icefront::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 }
 /*}}}*/
-/*FUNCTION Icefront::CreateKMatrix {{{1*/
+/*FUNCTION Icefront::CreateKMatrix {{{*/
 void  Icefront::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 
@@ -235,9 +235,9 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::CreatePVector {{{1*/
+/*FUNCTION Icefront::CreatePVector {{{*/
 void  Icefront::CreatePVector(Vector* pf){
 
 	/*Checks in debugging mode*/
-	/*{{{2*/
+	/*{{{*/
 	_assert_(nodes);
 	_assert_(element);
@@ -263,5 +263,5 @@
 		#endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -273,27 +273,27 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::CreateJacobianMatrix{{{1*/
+/*FUNCTION Icefront::CreateJacobianMatrix{{{*/
 void  Icefront::CreateJacobianMatrix(Matrix* Jff){
 	this->CreateKMatrix(Jff,NULL);
 }
-/*}}}1*/
-/*FUNCTION Icefront::PenaltyCreateKMatrix {{{1*/
-void  Icefront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, double kmax){
+/*}}}*/
+/*FUNCTION Icefront::PenaltyCreateKMatrix {{{*/
+void  Icefront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, IssmDouble kmax){
 	/*do nothing: */
 	return;
 }
 /*}}}*/
-/*FUNCTION Icefront::PenaltyCreatePVector{{{1*/
-void  Icefront::PenaltyCreatePVector(Vector* pf,double kmax){
+/*FUNCTION Icefront::PenaltyCreatePVector{{{*/
+void  Icefront::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
 	/*do nothing: */
 	return;
 }
 /*}}}*/
-/*FUNCTION Icefront::PenaltyCreateJacobianMatrix{{{1*/
-void  Icefront::PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){
+/*FUNCTION Icefront::PenaltyCreateJacobianMatrix{{{*/
+void  Icefront::PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){
 	this->PenaltyCreateKMatrix(Jff,NULL,kmax);
 }
-/*}}}1*/
-/*FUNCTION Icefront::InAnalysis{{{1*/
+/*}}}*/
+/*FUNCTION Icefront::InAnalysis{{{*/
 bool Icefront::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type)return true;
@@ -303,56 +303,56 @@
 
 /*Update virtual functions definitions:*/
-/*FUNCTION Icefront::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
-void  Icefront::InputUpdateFromVector(double* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Icefront::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
+/*FUNCTION Icefront::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
+void  Icefront::InputUpdateFromVector(IssmDouble* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Icefront::InputUpdateFromVector(int* vector, int name, int type) {{{*/
 void  Icefront::InputUpdateFromVector(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Icefront::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Icefront::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
 void  Icefront::InputUpdateFromVector(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Icefront::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type) {{{1*/
-void  Icefront::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Icefront::InputUpdateFromVectorDakota(double* vector, int name, int type) {{{1*/
-void  Icefront::InputUpdateFromVectorDakota(double* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Icefront::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{1*/
+/*FUNCTION Icefront::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type) {{{*/
+void  Icefront::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Icefront::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type) {{{*/
+void  Icefront::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Icefront::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{*/
 void  Icefront::InputUpdateFromVectorDakota(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Icefront::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Icefront::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{*/
 void  Icefront::InputUpdateFromVectorDakota(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Icefront::InputUpdateFromConstant(double constant, int name) {{{1*/
-void  Icefront::InputUpdateFromConstant(double constant, int name){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Icefront::InputUpdateFromConstant(int constant, int name) {{{1*/
+/*FUNCTION Icefront::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
+void  Icefront::InputUpdateFromConstant(IssmDouble constant, int name){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Icefront::InputUpdateFromConstant(int constant, int name) {{{*/
 void  Icefront::InputUpdateFromConstant(int constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Icefront::InputUpdateFromConstant(bool constant, int name) {{{1*/
+/*FUNCTION Icefront::InputUpdateFromConstant(bool constant, int name) {{{*/
 void  Icefront::InputUpdateFromConstant(bool constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Icefront::InputUpdateFromSolution{{{1*/
-void  Icefront::InputUpdateFromSolution(double* solution){
+/*FUNCTION Icefront::InputUpdateFromSolution{{{*/
+void  Icefront::InputUpdateFromSolution(IssmDouble* solution){
 	/*Nothing updated yet*/
 }
@@ -361,5 +361,5 @@
 /*Icefront numerics: */
 #ifdef _HAVE_DIAGNOSTIC_
-/*FUNCTION Icefront::CreatePVectorDiagnosticHoriz {{{1*/
+/*FUNCTION Icefront::CreatePVectorDiagnosticHoriz {{{*/
 ElementVector* Icefront::CreatePVectorDiagnosticHoriz(void){
 
@@ -379,9 +379,9 @@
 	    #endif
 		default:
-			_error_("Icefront type %s not supported yet",EnumToStringx(type));
-	}
-}
-/*}}}*/
-/*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal2d{{{1*/
+			_error2_("Icefront type " << EnumToStringx(type) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal2d{{{*/
 ElementVector* Icefront::CreatePVectorDiagnosticMacAyeal2d(void){
 
@@ -392,10 +392,10 @@
 	/*Intermediary*/
 	int        ig,index1,index2,fill;
-	double     Jdet;
-	double     thickness,bed,pressure,ice_pressure,rho_water,rho_ice,gravity;
-	double     water_pressure,air_pressure,surface_under_water,base_under_water;
-	double     xyz_list[numnodes][3];
-	double     normal[2];
-	double     L[2];
+	IssmDouble     Jdet;
+	IssmDouble     thickness,bed,pressure,ice_pressure,rho_water,rho_ice,gravity;
+	IssmDouble     water_pressure,air_pressure,surface_under_water,base_under_water;
+	IssmDouble     xyz_list[numnodes][3];
+	IssmDouble     normal[2];
+	IssmDouble     L[2];
 	GaussTria *gauss;
 
@@ -441,5 +441,5 @@
 				break;
 			default:
-				_error_("fill type %s not supported yet",EnumToStringx(fill));
+				_error2_("fill type " << EnumToStringx(fill) << " not supported yet");
 		}
 		ice_pressure=1.0/2.0*gravity*rho_ice*pow(thickness,2);
@@ -467,5 +467,5 @@
 
 #ifdef _HAVE_CONTROL_
-/*FUNCTION Icefront::CreatePVectorAdjointHoriz {{{1*/
+/*FUNCTION Icefront::CreatePVectorAdjointHoriz {{{*/
 ElementVector* Icefront::CreatePVectorAdjointHoriz(void){
 
@@ -476,5 +476,5 @@
 #endif
 #ifdef _HAVE_3D_
-/*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal3d{{{1*/
+/*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal3d{{{*/
 ElementVector* Icefront::CreatePVectorDiagnosticMacAyeal3d(void){
 
@@ -504,5 +504,5 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::CreatePVectorDiagnosticPattyn{{{1*/
+/*FUNCTION Icefront::CreatePVectorDiagnosticPattyn{{{*/
 ElementVector* Icefront::CreatePVectorDiagnosticPattyn(void){
 
@@ -513,10 +513,10 @@
 	int         i,j,ig,index1,index2,index3,index4;
 	int         fill;
-	double      surface,pressure,ice_pressure,rho_water,rho_ice,gravity;
-	double      water_pressure,air_pressure;
-	double      Jdet,z_g;
-	double      xyz_list[NUMVERTICESQUA][3];
-	double      normal[3];
-	double      l1l4[4];
+	IssmDouble      surface,pressure,ice_pressure,rho_water,rho_ice,gravity;
+	IssmDouble      water_pressure,air_pressure;
+	IssmDouble      Jdet,z_g;
+	IssmDouble      xyz_list[NUMVERTICESQUA][3];
+	IssmDouble      normal[3];
+	IssmDouble      l1l4[4];
 	GaussPenta *gauss = NULL;
 
@@ -543,6 +543,6 @@
 
 	/* Start  looping on the number of gaussian points: */
-	double zmax=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
-	double zmin=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
+	IssmDouble zmax=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
+	IssmDouble zmin=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
 	if(zmax>0 && zmin<0) gauss=new GaussPenta(index1,index2,index3,index4,3,10); //refined in vertical because of the sea level discontinuity
 	else                 gauss=new GaussPenta(index1,index2,index3,index4,3,3);
@@ -564,5 +564,5 @@
 				break;
 			default:
-				_error_("fill type %s not supported yet",EnumToStringx(fill));
+				_error2_("fill type " << EnumToStringx(fill) << " not supported yet");
 		}
 		ice_pressure=rho_ice*gravity*(surface-z_g);
@@ -581,5 +581,5 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::CreatePVectorDiagnosticStokes{{{1*/
+/*FUNCTION Icefront::CreatePVectorDiagnosticStokes{{{*/
 ElementVector* Icefront::CreatePVectorDiagnosticStokes(void){
 
@@ -590,10 +590,10 @@
 	int         i,j,ig,index1,index2,index3,index4;
 	int         fill;
-	double      pressure,rho_water,gravity;
-	double      water_pressure,air_pressure;
-	double      Jdet,z_g;
-	double      xyz_list[NUMVERTICESQUA][3];
-	double      normal[3];
-	double      l1l4[4];
+	IssmDouble      pressure,rho_water,gravity;
+	IssmDouble      water_pressure,air_pressure;
+	IssmDouble      Jdet,z_g;
+	IssmDouble      xyz_list[NUMVERTICESQUA][3];
+	IssmDouble      normal[3];
+	IssmDouble      l1l4[4];
 	GaussPenta *gauss = NULL;
 
@@ -618,6 +618,6 @@
 
 	/* Start  looping on the number of gaussian points: */
-	double zmax=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
-	double zmin=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
+	IssmDouble zmax=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]>zmax) zmax=xyz_list[i][2];
+	IssmDouble zmin=xyz_list[0][2]; for(i=1;i<NUMVERTICESQUA;i++) if(xyz_list[i][2]<zmin) zmin=xyz_list[i][2];
 	if(zmax>0 && zmin<0) gauss=new GaussPenta(index1,index2,index3,index4,3,30); //refined in vertical because of the sea level discontinuity
 	else                 gauss=new GaussPenta(index1,index2,index3,index4,3,3);
@@ -638,5 +638,5 @@
 				break;
 			default:
-				_error_("fill type %s not supported yet",EnumToStringx(fill));
+				_error2_("fill type " << EnumToStringx(fill) << " not supported yet");
 		}
 		air_pressure=0;
@@ -660,5 +660,5 @@
 /*}}}*/
 #endif
-/*FUNCTION Icefront::GetDofList {{{1*/
+/*FUNCTION Icefront::GetDofList {{{*/
 void  Icefront::GetDofList(int** pdoflist,int approximation_enum,int setenum){
 
@@ -691,5 +691,5 @@
 
 	/*Allocate: */
-	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+	doflist=xNew<int>(numberofdofs);
 
 	/*Populate: */
@@ -704,11 +704,11 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::GetSegmentNormal {{{1*/
-void Icefront:: GetSegmentNormal(double* normal,double xyz_list[4][3]){
+/*FUNCTION Icefront::GetSegmentNormal {{{*/
+void Icefront:: GetSegmentNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){
 
 	/*Build unit outward pointing vector*/
 	const int numnodes=NUMVERTICESSEG;
-	double vector[2];
-	double norm;
+	IssmDouble vector[2];
+	IssmDouble norm;
 
 	vector[0]=xyz_list[1][0] - xyz_list[0][0];
@@ -721,11 +721,11 @@
 }
 /*}}}*/
-/*FUNCTION Icefront::GetQuadNormal {{{1*/
-void Icefront:: GetQuadNormal(double* normal,double xyz_list[4][3]){
+/*FUNCTION Icefront::GetQuadNormal {{{*/
+void Icefront:: GetQuadNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){
 
 	/*Build unit outward pointing vector*/
-	double AB[3];
-	double AC[3];
-	double norm;
+	IssmDouble AB[3];
+	IssmDouble AC[3];
+	IssmDouble norm;
 
 	AB[0]=xyz_list[1][0] - xyz_list[0][0];
Index: /issm/trunk/src/c/objects/Loads/Icefront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Load.h"
 class Hook;
@@ -39,10 +39,10 @@
 		Parameters* parameters;
 
-		/*Icefront constructors, destructors: {{{1*/
+		/*Icefront constructors, destructors: {{{*/
 		Icefront();
 		Icefront(int icefront_id,int i, IoModel* iomodel,int in_icefront_type, int analysis_type);
 		~Icefront();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -52,19 +52,19 @@
 		Object* copy();
 		/*}}}*/
-		/*Update virtual functions definitions: {{{1*/
-		void  InputUpdateFromVector(double* vector, int name, int type);
+		/*Update virtual functions definitions: {{{*/
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVector(int* vector, int name, int type);
 		void  InputUpdateFromVector(bool* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(double* matrix,int ncols,int nrows, int name, int type);
-		void  InputUpdateFromVectorDakota(double* vector, int name, int type);
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix,int ncols,int nrows, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(int* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
-		void  InputUpdateFromConstant(double constant, int name);
+		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
-		void  InputUpdateFromSolution(double* solution);
-		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		void  InputUpdateFromSolution(IssmDouble* solution);
+		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
 		/*}}}*/
-		/*Load virtual functions definitions: {{{1*/
+		/*Load virtual functions definitions: {{{*/
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
@@ -72,13 +72,13 @@
 		void  CreatePVector(Vector* pf);
 		void  CreateJacobianMatrix(Matrix* Jff);
-		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
-		void  PenaltyCreatePVector(Vector*  pf, double kmax);
-		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax);
+		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, IssmDouble kmax);
+		void  PenaltyCreatePVector(Vector*  pf, IssmDouble kmax);
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
-		/*Load management: {{{1*/
+		/*Load management: {{{*/
 		void GetDofList(int** pdoflist,int approximation_enum,int setenum);
-		void GetSegmentNormal(double* normal,double xyz_list[2][3]);
-		void GetQuadNormal(double* normal,double xyz_list[4][3]);
+		void GetSegmentNormal(IssmDouble* normal,IssmDouble xyz_list[2][3]);
+		void GetQuadNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]);
 		#ifdef _HAVE_CONTROL_
 		ElementVector* CreatePVectorAdjointHoriz(void);
Index: /issm/trunk/src/c/objects/Loads/Load.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Load.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Load.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 class Object;
 class Matrix;
@@ -26,5 +26,5 @@
 		virtual       ~Load(){};
 		
-		/*Virtual functions: {{{1*/
+		/*Virtual functions: {{{*/
 		virtual void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
 		virtual void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
@@ -32,7 +32,7 @@
 		virtual void  CreatePVector(Vector* pf)=0;
 		virtual void  CreateJacobianMatrix(Matrix* Jff)=0;
-		virtual void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax)=0;
-		virtual void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, double kmax)=0;
-		virtual void  PenaltyCreatePVector(Vector* pf, double kmax)=0;
+		virtual void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax)=0;
+		virtual void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, IssmDouble kmax)=0;
+		virtual void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax)=0;
 		virtual bool  InAnalysis(int analysis_type)=0;
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Numericalflux.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Numericalflux.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Numericalflux.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -24,5 +24,5 @@
 
 /*Numericalflux constructors and destructor*/
-/*FUNCTION Numericalflux::Numericalflux(){{{1*/
+/*FUNCTION Numericalflux::Numericalflux(){{{*/
 Numericalflux::Numericalflux(){
 	this->inputs=NULL;
@@ -34,5 +34,5 @@
 }
 /*}}}*/
-/*}}}*//*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{1*/
+/*}}}*//*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/
 Numericalflux::Numericalflux(int numericalflux_id,int i, IoModel* iomodel, int in_analysis_type){
 
@@ -59,28 +59,28 @@
 	numericalflux_mparid=numberofelements+1; //matlab indexing
 
-	/*First, see wether this is an internal or boundary edge (if e2=NaN)*/
-	if (isnan((double)iomodel->Data(MeshEdgesEnum)[4*i+3])){ //edges are [node1 node2 elem1 elem2]
+	/*First, see wether this is an internal or boundary edge (if e2=-1)*/
+	if (iomodel->Data(MeshEdgesEnum)[4*i+3]==-1.){ //edges are [node1 node2 elem1 elem2]
 		/* Boundary edge, only one element */
-		e1=(int)iomodel->Data(MeshEdgesEnum)[4*i+2];
-		e2=(int)UNDEF;
+		e1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2]);
+		e2=reCast<int>(UNDEF);
 		num_elems=1;
 		num_nodes=2;
 		numericalflux_type=BoundaryEnum;
-		numericalflux_elem_ids[0]=(int)e1;
+		numericalflux_elem_ids[0]=e1;
 	}
 	else{
 		/* internal edge: connected to 2 elements */
-		e1=(int)iomodel->Data(MeshEdgesEnum)[4*i+2];
-		e2=(int)iomodel->Data(MeshEdgesEnum)[4*i+3];
+		e1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2]);
+		e2=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+3]);
 		num_elems=2;
 		num_nodes=4;
 		numericalflux_type=InternalEnum;
-		numericalflux_elem_ids[0]=(int)e1;
-		numericalflux_elem_ids[1]=(int)e2;
+		numericalflux_elem_ids[0]=e1;
+		numericalflux_elem_ids[1]=e2;
 	}
 
 	/*1: Get vertices ids*/
-	i1=(int)iomodel->Data(MeshEdgesEnum)[4*i+0];
-	i2=(int)iomodel->Data(MeshEdgesEnum)[4*i+1];
+	i1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+0]);
+	i2=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+1]);
 
 	if (numericalflux_type==InternalEnum){
@@ -139,5 +139,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::~Numericalflux(){{{1*/
+/*FUNCTION Numericalflux::~Numericalflux(){{{*/
 Numericalflux::~Numericalflux(){
 	delete inputs;
@@ -149,39 +149,39 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Numericalflux::Echo {{{1*/
+/*FUNCTION Numericalflux::Echo {{{*/
 void Numericalflux::Echo(void){
-	printf("Numericalflux:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Numericalflux:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnodes->Echo();
 	helement->Echo();
-	printf("   parameters: %p\n",parameters);
-	printf("   inputs: %p\n",inputs);
-}
-/*}}}*/
-/*FUNCTION Numericalflux::DeepEcho {{{1*/
+	_printLine_("   parameters: " << parameters);
+	_printLine_("   inputs: " << inputs);
+}
+/*}}}*/
+/*FUNCTION Numericalflux::DeepEcho {{{*/
 void Numericalflux::DeepEcho(void){
 
-	printf("Numericalflux:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Numericalflux:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnodes->DeepEcho();
 	helement->DeepEcho();
-	printf("   parameters\n");
+	_printLine_("   parameters");
 	if(parameters)
 	 parameters->DeepEcho();
 	else
-	 printf("      NULL\n");
-	printf("   inputs\n");
+	 _printLine_("      NULL");
+	_printLine_("   inputs");
 	inputs->DeepEcho();
 	
 }		
 /*}}}*/
-/*FUNCTION Numericalflux::Id {{{1*/
+/*FUNCTION Numericalflux::Id {{{*/
 int    Numericalflux::Id(void){
 	return id;
 }
 /*}}}*/
-/*FUNCTION Numericalflux::MyRank {{{1*/
+/*FUNCTION Numericalflux::MyRank {{{*/
 int    Numericalflux::MyRank(void){ 
 	extern int my_rank;
@@ -189,5 +189,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::ObjectEnum{{{1*/
+/*FUNCTION Numericalflux::ObjectEnum{{{*/
 int Numericalflux::ObjectEnum(void){
 
@@ -196,5 +196,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::copy {{{1*/
+/*FUNCTION Numericalflux::copy {{{*/
 Object* Numericalflux::copy() {
 	
@@ -228,5 +228,5 @@
 
 /*Load virtual functions definitions:*/
-/*FUNCTION Numericalflux::Configure {{{1*/
+/*FUNCTION Numericalflux::Configure {{{*/
 void  Numericalflux::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
@@ -245,10 +245,10 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::SetCurrentConfiguration {{{1*/
+/*FUNCTION Numericalflux::SetCurrentConfiguration {{{*/
 void  Numericalflux::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrix {{{1*/
+/*FUNCTION Numericalflux::CreateKMatrix {{{*/
 void  Numericalflux::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 
@@ -270,5 +270,5 @@
 			break;
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -281,5 +281,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreatePVector {{{1*/
+/*FUNCTION Numericalflux::CreatePVector {{{*/
 void  Numericalflux::CreatePVector(Vector* pf){
 
@@ -300,5 +300,5 @@
 			break;
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -311,6 +311,6 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{1*/
-void  Numericalflux::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
+/*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{*/
+void  Numericalflux::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
 
 	/*No stiffness loads applied, do nothing: */
@@ -319,6 +319,6 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::PenaltyCreatePVector{{{1*/
-void  Numericalflux::PenaltyCreatePVector(Vector* pf,double kmax){
+/*FUNCTION Numericalflux::PenaltyCreatePVector{{{*/
+void  Numericalflux::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
 
 	/*No penalty loads applied, do nothing: */
@@ -327,5 +327,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::InAnalysis{{{1*/
+/*FUNCTION Numericalflux::InAnalysis{{{*/
 bool Numericalflux::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type) return true;
@@ -335,5 +335,5 @@
 
 /*Numericalflux management*/
-/*FUNCTION Numericalflux::CreateKMatrixPrognostic{{{1*/
+/*FUNCTION Numericalflux::CreateKMatrixPrognostic{{{*/
 ElementMatrix* Numericalflux::CreateKMatrixPrognostic(void){
 
@@ -347,9 +347,9 @@
 			return CreateKMatrixPrognosticBoundary();
 		default:
-			_error_("type not supported yet");
-	}
-}
-/*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrixPrognosticInternal {{{1*/
+			_error2_("type not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Numericalflux::CreateKMatrixPrognosticInternal {{{*/
 ElementMatrix* Numericalflux::CreateKMatrixPrognosticInternal(void){
 
@@ -359,11 +359,11 @@
 	/* Intermediaries*/
 	int        i,j,ig,index1,index2;
-	double     DL1,DL2,Jdet,dt,vx,vy,UdotN;
-	double     xyz_list[NUMVERTICES_INTERNAL][3];
-	double     normal[2];
-	double     B[numdof];
-	double     Bprime[numdof];
-	double     Ke_g1[numdof][numdof];
-	double     Ke_g2[numdof][numdof];
+	IssmDouble     DL1,DL2,Jdet,dt,vx,vy,UdotN;
+	IssmDouble     xyz_list[NUMVERTICES_INTERNAL][3];
+	IssmDouble     normal[2];
+	IssmDouble     B[numdof];
+	IssmDouble     Bprime[numdof];
+	IssmDouble     Ke_g1[numdof][numdof];
+	IssmDouble     Ke_g2[numdof][numdof];
 	GaussTria *gauss;
 
@@ -416,5 +416,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrixPrognosticBoundary {{{1*/
+/*FUNCTION Numericalflux::CreateKMatrixPrognosticBoundary {{{*/
 ElementMatrix* Numericalflux::CreateKMatrixPrognosticBoundary(void){
 
@@ -424,9 +424,9 @@
 	/* Intermediaries*/
 	int        i,j,ig,index1,index2;
-	double     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN;
-	double     xyz_list[NUMVERTICES_BOUNDARY][3];
-	double     normal[2];
-	double     L[numdof];
-	double     Ke_g[numdof][numdof];
+	IssmDouble     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN;
+	IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
+	IssmDouble     normal[2];
+	IssmDouble     L[numdof];
+	IssmDouble     Ke_g[numdof][numdof];
 	GaussTria *gauss;
 
@@ -488,5 +488,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrixBalancethickness{{{1*/
+/*FUNCTION Numericalflux::CreateKMatrixBalancethickness{{{*/
 ElementMatrix* Numericalflux::CreateKMatrixBalancethickness(void){
 
@@ -500,9 +500,9 @@
 			return CreateKMatrixBalancethicknessBoundary();
 		default:
-			_error_("type not supported yet");
-	}
-}
-/*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrixBalancethicknessInternal {{{1*/
+			_error2_("type not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Numericalflux::CreateKMatrixBalancethicknessInternal {{{*/
 ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessInternal(void){
 
@@ -512,11 +512,11 @@
 	/* Intermediaries*/
 	int        i,j,ig,index1,index2;
-	double     DL1,DL2,Jdet,vx,vy,UdotN;
-	double     xyz_list[NUMVERTICES_INTERNAL][3];
-	double     normal[2];
-	double     B[numdof];
-	double     Bprime[numdof];
-	double     Ke_g1[numdof][numdof];
-	double     Ke_g2[numdof][numdof];
+	IssmDouble     DL1,DL2,Jdet,vx,vy,UdotN;
+	IssmDouble     xyz_list[NUMVERTICES_INTERNAL][3];
+	IssmDouble     normal[2];
+	IssmDouble     B[numdof];
+	IssmDouble     Bprime[numdof];
+	IssmDouble     Ke_g1[numdof][numdof];
+	IssmDouble     Ke_g2[numdof][numdof];
 	GaussTria *gauss;
 
@@ -568,5 +568,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrixBalancethicknessBoundary {{{1*/
+/*FUNCTION Numericalflux::CreateKMatrixBalancethicknessBoundary {{{*/
 ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessBoundary(void){
 
@@ -576,9 +576,9 @@
 	/* Intermediaries*/
 	int        i,j,ig,index1,index2;
-	double     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN;
-	double     xyz_list[NUMVERTICES_BOUNDARY][3];
-	double     normal[2];
-	double     L[numdof];
-	double     Ke_g[numdof][numdof];
+	IssmDouble     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN;
+	IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
+	IssmDouble     normal[2];
+	IssmDouble     L[numdof];
+	IssmDouble     Ke_g[numdof][numdof];
 	GaussTria *gauss;
 
@@ -639,5 +639,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethickness{{{1*/
+/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethickness{{{*/
 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethickness(void){
 
@@ -651,9 +651,9 @@
 			return CreateKMatrixAdjointBalancethicknessBoundary();
 		default:
-			_error_("type not supported yet");
-	}
-}
-/*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessInternal {{{1*/
+			_error2_("type not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessInternal {{{*/
 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessInternal(void){
 
@@ -663,5 +663,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary {{{1*/
+/*FUNCTION Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary {{{*/
 ElementMatrix* Numericalflux::CreateKMatrixAdjointBalancethicknessBoundary(void){
 
@@ -671,5 +671,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreatePVectorPrognostic{{{1*/
+/*FUNCTION Numericalflux::CreatePVectorPrognostic{{{*/
 ElementVector* Numericalflux::CreatePVectorPrognostic(void){
 
@@ -683,9 +683,9 @@
 			return CreatePVectorPrognosticBoundary();
 		default:
-			_error_("type not supported yet");
-	}
-}
-/*}}}*/
-/*FUNCTION Numericalflux::CreatePVectorPrognosticInternal{{{1*/
+			_error2_("type not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Numericalflux::CreatePVectorPrognosticInternal{{{*/
 ElementVector* Numericalflux::CreatePVectorPrognosticInternal(void){
 
@@ -695,5 +695,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreatePVectorPrognosticBoundary{{{1*/
+/*FUNCTION Numericalflux::CreatePVectorPrognosticBoundary{{{*/
 ElementVector* Numericalflux::CreatePVectorPrognosticBoundary(void){
 
@@ -703,8 +703,8 @@
 	/* Intermediaries*/
 	int        i,j,ig,index1,index2;
-	double     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness;
-	double     xyz_list[NUMVERTICES_BOUNDARY][3];
-	double     normal[2];
-	double     L[numdof];
+	IssmDouble     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness;
+	IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
+	IssmDouble     normal[2];
+	IssmDouble     L[numdof];
 	GaussTria *gauss;
 
@@ -751,5 +751,5 @@
 		vyaverage_input->GetInputValue(&vy,gauss);
 		spcthickness_input->GetInputValue(&thickness,gauss);
-		if(isnan(thickness)) _error_("Cannot weakly apply constraint because NaN was provided");
+		if(xIsNan<IssmDouble>(thickness)) _error2_("Cannot weakly apply constraint because NaN was provided");
 
 		UdotN=vx*normal[0]+vy*normal[1];
@@ -765,5 +765,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreatePVectorBalancethickness{{{1*/
+/*FUNCTION Numericalflux::CreatePVectorBalancethickness{{{*/
 ElementVector* Numericalflux::CreatePVectorBalancethickness(void){
 
@@ -777,9 +777,9 @@
 			return CreatePVectorBalancethicknessBoundary();
 		default:
-			_error_("type not supported yet");
-	}
-}
-/*}}}*/
-/*FUNCTION Numericalflux::CreatePVectorBalancethicknessInternal{{{1*/
+			_error2_("type not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Numericalflux::CreatePVectorBalancethicknessInternal{{{*/
 ElementVector* Numericalflux::CreatePVectorBalancethicknessInternal(void){
 
@@ -789,5 +789,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreatePVectorBalancethicknessBoundary{{{1*/
+/*FUNCTION Numericalflux::CreatePVectorBalancethicknessBoundary{{{*/
 ElementVector* Numericalflux::CreatePVectorBalancethicknessBoundary(void){
 
@@ -797,8 +797,8 @@
 	/* Intermediaries*/
 	int        i,j,ig,index1,index2;
-	double     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness;
-	double     xyz_list[NUMVERTICES_BOUNDARY][3];
-	double     normal[2];
-	double     L[numdof];
+	IssmDouble     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness;
+	IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
+	IssmDouble     normal[2];
+	IssmDouble     L[numdof];
 	GaussTria *gauss;
 
@@ -856,5 +856,5 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::CreatePVectorAdjointBalancethickness{{{1*/
+/*FUNCTION Numericalflux::CreatePVectorAdjointBalancethickness{{{*/
 ElementVector* Numericalflux::CreatePVectorAdjointBalancethickness(void){
 
@@ -863,10 +863,10 @@
 }
 /*}}}*/
-/*FUNCTION Numericalflux::GetNormal {{{1*/
-void Numericalflux:: GetNormal(double* normal,double xyz_list[4][3]){
+/*FUNCTION Numericalflux::GetNormal {{{*/
+void Numericalflux:: GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]){
 
 	/*Build unit outward pointing vector*/
-	double vector[2];
-	double norm;
+	IssmDouble vector[2];
+	IssmDouble norm;
 
 	vector[0]=xyz_list[1][0] - xyz_list[0][0];
Index: /issm/trunk/src/c/objects/Loads/Numericalflux.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Numericalflux.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Numericalflux.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Load.h"
 class Hook;
@@ -35,10 +35,10 @@
 
 
-		/*Numericalflux constructors,destructors {{{1*/
+		/*Numericalflux constructors,destructors {{{*/
 		Numericalflux();
 		Numericalflux(int numericalflux_id,int i, IoModel* iomodel,int analysis_type);
 		~Numericalflux();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -48,31 +48,31 @@
 		Object* copy();
 		/*}}}*/
-		/*Update virtual functions resolution: {{{1*/
-		void    InputUpdateFromVector(double* vector, int name, int type){/*Do nothing*/}
-		void    InputUpdateFromVector(int* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromVector(bool* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){/*Do nothing*/}
-		void    InputUpdateFromVectorDakota(double* vector, int name, int type){/*Do nothing*/}
-		void    InputUpdateFromVectorDakota(int* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromConstant(double constant, int name){/*Do nothing*/};
+		/*Update virtual functions resolution: {{{*/
+		void    InputUpdateFromVector(IssmDouble* vector, int name, int type){/*Do nothing*/}
+		void    InputUpdateFromVector(int* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromVector(bool* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*Do nothing*/}
+		void    InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*Do nothing*/}
+		void    InputUpdateFromVectorDakota(int* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromConstant(IssmDouble constant, int name){/*Do nothing*/};
 		void    InputUpdateFromConstant(int constant, int name){/*Do nothing*/};
-		void    InputUpdateFromConstant(bool constant, int name){_error_("Not implemented yet!");}
-		void    InputUpdateFromSolution(double* solution){_error_("Not implemented yet!");}
-		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		void    InputUpdateFromConstant(bool constant, int name){_error2_("Not implemented yet!");}
+		void    InputUpdateFromSolution(IssmDouble* solution){_error2_("Not implemented yet!");}
+		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
 		/*}}}*/
-		/*Load virtual functions definitions: {{{1*/
+		/*Load virtual functions definitions: {{{*/
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
 		void  CreatePVector(Vector* pf);
-		void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
-		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
-		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
-		void  PenaltyCreatePVector(Vector* pf, double kmax);
+		void  CreateJacobianMatrix(Matrix* Jff){_error2_("Not implemented yet");};
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){_error2_("Not implemented yet");};
+		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, IssmDouble kmax);
+		void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
-		/*Numericalflux management:{{{1*/
-		void  GetNormal(double* normal,double xyz_list[4][3]);
+		/*Numericalflux management:{{{*/
+		void  GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]);
 		ElementMatrix* CreateKMatrixPrognostic(void);
 		ElementMatrix* CreateKMatrixPrognosticInternal(void);
Index: /issm/trunk/src/c/objects/Loads/Pengrid.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Pengrid.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Pengrid.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -24,5 +24,5 @@
 
 /*Pengrid constructors and destructor*/
-/*FUNCTION Pengrid::Pengrid(){{{1*/
+/*FUNCTION Pengrid::Pengrid(){{{*/
 Pengrid::Pengrid(){
 	this->inputs=NULL;
@@ -40,6 +40,6 @@
 
 }
-/*}}}1*/
-/*FUNCTION Pengrid::Pengrid(int index, int id, IoModel* iomodel,int analysis_type){{{1*/
+/*}}}*/
+/*FUNCTION Pengrid::Pengrid(int index, int id, IoModel* iomodel,int analysis_type){{{*/
 Pengrid::Pengrid(int id, int index, IoModel* iomodel, int in_analysis_type){ //i is the element index
 
@@ -90,5 +90,5 @@
 }
 /*}}}*/
-/*FUNCTION Pengrid::~Pengrid(){{{1*/
+/*FUNCTION Pengrid::~Pengrid(){{{*/
 Pengrid::~Pengrid(){
 	delete inputs;
@@ -98,45 +98,45 @@
 	return;
 }
-/*}}}1*/
+/*}}}*/
 			
 /*Object virtual functions definitions:*/
-/*FUNCTION Pengrid::Echo {{{1*/
+/*FUNCTION Pengrid::Echo {{{*/
 void Pengrid::Echo(void){
 	this->DeepEcho();
 }
-/*}}}1*/
-/*FUNCTION Pengrid::DeepEcho{{{1*/
+/*}}}*/
+/*FUNCTION Pengrid::DeepEcho{{{*/
 void Pengrid::DeepEcho(void){
 
-	printf("Pengrid:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Pengrid:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnode->DeepEcho();
 	helement->DeepEcho();
 	hmatpar->DeepEcho();
-	printf("   active %i\n",this->active);
-	printf("   zigzag_counter %i\n",this->zigzag_counter);
-	printf("   parameters\n");
+	_printLine_("   active " << this->active);
+	_printLine_("   zigzag_counter " << this->zigzag_counter);
+	_printLine_("   parameters");
 	parameters->DeepEcho();
-	printf("   inputs\n");
+	_printLine_("   inputs");
 	inputs->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION Pengrid::Id {{{1*/
+/*FUNCTION Pengrid::Id {{{*/
 int    Pengrid::Id(void){ return id; }
-/*}}}1*/
-/*FUNCTION Pengrid::MyRank {{{1*/
+/*}}}*/
+/*FUNCTION Pengrid::MyRank {{{*/
 int    Pengrid::MyRank(void){ 
 	extern int my_rank;
 	return my_rank; 
 }
-/*}}}1*/
-/*FUNCTION Pengrid::ObjectEnum{{{1*/
+/*}}}*/
+/*FUNCTION Pengrid::ObjectEnum{{{*/
 int Pengrid::ObjectEnum(void){
 
 	return PengridEnum;
 }
-/*}}}1*/
-/*FUNCTION Icefront::copy {{{1*/
+/*}}}*/
+/*FUNCTION Icefront::copy {{{*/
 Object* Pengrid::copy() {
 	
@@ -177,5 +177,5 @@
 
 /*Load virtual functions definitions:*/
-/*FUNCTION Pengrid::Configure {{{1*/
+/*FUNCTION Pengrid::Configure {{{*/
 void  Pengrid::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
@@ -194,11 +194,11 @@
 	this->parameters=parametersin;
 }
-/*}}}1*/
-/*FUNCTION Pengrid::SetCurrentConfiguration {{{1*/
+/*}}}*/
+/*FUNCTION Pengrid::SetCurrentConfiguration {{{*/
 void  Pengrid::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
 }
-/*}}}1*/
-/*FUNCTION Pengrid::CreateKMatrix {{{1*/
+/*}}}*/
+/*FUNCTION Pengrid::CreateKMatrix {{{*/
 void  Pengrid::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 
@@ -207,6 +207,6 @@
 
 }
-/*}}}1*/
-/*FUNCTION Pengrid::CreatePVector {{{1*/
+/*}}}*/
+/*FUNCTION Pengrid::CreatePVector {{{*/
 void  Pengrid::CreatePVector(Vector* pf){
 
@@ -215,7 +215,7 @@
 
 }
-/*}}}1*/
-/*FUNCTION Pengrid::PenaltyCreateMatrix {{{1*/
-void  Pengrid::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
+/*}}}*/
+/*FUNCTION Pengrid::PenaltyCreateMatrix {{{*/
+void  Pengrid::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
 
 	/*Retrieve parameters: */
@@ -239,5 +239,5 @@
 		#endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -248,7 +248,7 @@
 	}
 }
-/*}}}1*/
-/*FUNCTION Pengrid::PenaltyCreatePVector {{{1*/
-void  Pengrid::PenaltyCreatePVector(Vector* pf,double kmax){
+/*}}}*/
+/*FUNCTION Pengrid::PenaltyCreatePVector {{{*/
+void  Pengrid::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
 
 	/*Retrieve parameters: */
@@ -271,5 +271,5 @@
 		#endif
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -280,6 +280,6 @@
 	}
 }
-/*}}}1*/
-/*FUNCTION Pengrid::InAnalysis{{{1*/
+/*}}}*/
+/*FUNCTION Pengrid::InAnalysis{{{*/
 bool Pengrid::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type)return true;
@@ -289,41 +289,41 @@
 
 /*Update virtual functions definitions:*/
-/*FUNCTION Pengrid::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
-void  Pengrid::InputUpdateFromVector(double* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
+/*FUNCTION Pengrid::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
+void  Pengrid::InputUpdateFromVector(IssmDouble* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Pengrid::InputUpdateFromVector(int* vector, int name, int type) {{{*/
 void  Pengrid::InputUpdateFromVector(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Pengrid::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
 void  Pengrid::InputUpdateFromVector(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromMatrixDakota(double* vector, int nrows, int ncols, int name, int type) {{{1*/
-void  Pengrid::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromVectorDakota(double* vector, int name, int type) {{{1*/
-void  Pengrid::InputUpdateFromVectorDakota(double* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{1*/
+/*FUNCTION Pengrid::InputUpdateFromMatrixDakota(IssmDouble* vector, int nrows, int ncols, int name, int type) {{{*/
+void  Pengrid::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Pengrid::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type) {{{*/
+void  Pengrid::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Pengrid::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{*/
 void  Pengrid::InputUpdateFromVectorDakota(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Pengrid::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{*/
 void  Pengrid::InputUpdateFromVectorDakota(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromConstant(double constant, int name) {{{1*/
-void  Pengrid::InputUpdateFromConstant(double constant, int name){
+/*FUNCTION Pengrid::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
+void  Pengrid::InputUpdateFromConstant(IssmDouble constant, int name){
 	switch(name){
 
@@ -335,10 +335,10 @@
 }
 /*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromConstant(int constant, int name) {{{1*/
+/*FUNCTION Pengrid::InputUpdateFromConstant(int constant, int name) {{{*/
 void  Pengrid::InputUpdateFromConstant(int constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromConstant(bool constant, int name) {{{1*/
+/*FUNCTION Pengrid::InputUpdateFromConstant(bool constant, int name) {{{*/
 void  Pengrid::InputUpdateFromConstant(bool constant, int name){
 
@@ -352,6 +352,6 @@
 }
 /*}}}*/
-/*FUNCTION Pengrid::InputUpdateFromSolution{{{1*/
-void  Pengrid::InputUpdateFromSolution(double* solution){
+/*FUNCTION Pengrid::InputUpdateFromSolution{{{*/
+void  Pengrid::InputUpdateFromSolution(IssmDouble* solution){
 	/*Nothing updated yet*/
 }
@@ -359,5 +359,5 @@
 
 /*Pengrid management:*/
-/*FUNCTION Pengrid::ConstraintActivate {{{1*/
+/*FUNCTION Pengrid::ConstraintActivate {{{*/
 void  Pengrid::ConstraintActivate(int* punstable){
 
@@ -379,10 +379,10 @@
 	}
 	else{
-		_error_("analysis: %s not supported yet",EnumToStringx(analysis_type));
-	}
-
-}
-/*}}}1*/
-/*FUNCTION Pengrid::ConstraintActivateThermal {{{1*/
+		_error2_("analysis: " << EnumToStringx(analysis_type) << " not supported yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Pengrid::ConstraintActivateThermal {{{*/
 void  Pengrid::ConstraintActivateThermal(int* punstable){
 
@@ -391,7 +391,7 @@
 	int    found=0;
 	const int numnodes=1;
-	double pressure;
-	double temperature;
-	double t_pmp;
+	IssmDouble pressure;
+	IssmDouble temperature;
+	IssmDouble t_pmp;
 	int    new_active;
 	int    unstable=0;
@@ -452,12 +452,12 @@
 	*punstable=unstable;
 }
-/*}}}1*/
+/*}}}*/
 #ifdef _HAVE_DIAGNOSTIC_
-/*FUNCTION Pengrid::PenaltyCreateKMatrixDiagnosticStokes {{{1*/
-ElementMatrix* Pengrid::PenaltyCreateKMatrixDiagnosticStokes(double kmax){
+/*FUNCTION Pengrid::PenaltyCreateKMatrixDiagnosticStokes {{{*/
+ElementMatrix* Pengrid::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){
 	
 	const int numdof = NUMVERTICES *NDOF4;
-	double    slope[2];
-	double    penalty_offset;
+	IssmDouble    slope[2];
+	IssmDouble    penalty_offset;
 	int       approximation;
 
@@ -475,7 +475,7 @@
 
 	/*Create elementary matrix: add penalty to constrain wb (wb=ub*db/dx+vb*db/dy)*/
-	Ke->values[2*NDOF4+0]=-slope[0]*kmax*pow((double)10.0,penalty_offset);
-	Ke->values[2*NDOF4+1]=-slope[1]*kmax*pow((double)10.0,penalty_offset);
-	Ke->values[2*NDOF4+2]= kmax*pow((double)10,penalty_offset);
+	Ke->values[2*NDOF4+0]=-slope[0]*kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[2*NDOF4+1]=-slope[1]*kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[2*NDOF4+2]= kmax*pow((IssmDouble)10,penalty_offset);
 
 	/*Transform Coordinate System*/
@@ -485,13 +485,13 @@
 	return Ke;
 }
-/*}}}1*/
+/*}}}*/
 #endif
 #ifdef _HAVE_THERMAL_
-/*FUNCTION Pengrid::PenaltyCreateKMatrixMelting {{{1*/
-ElementMatrix* Pengrid::PenaltyCreateKMatrixMelting(double kmax){
+/*FUNCTION Pengrid::PenaltyCreateKMatrixMelting {{{*/
+ElementMatrix* Pengrid::PenaltyCreateKMatrixMelting(IssmDouble kmax){
 
 	const int numdof=NUMVERTICES*NDOF1;
-	double pressure,temperature,t_pmp;
-	double penalty_factor;
+	IssmDouble pressure,temperature,t_pmp;
+	IssmDouble penalty_factor;
 
 	Penta* penta=(Penta*)element;
@@ -511,5 +511,5 @@
 	/*Add penalty load*/
 	if (temperature<t_pmp){ //If T<Tpmp, there must be no melting. Therefore, melting should be  constrained to 0 when T<Tpmp, instead of using spcs, use penalties
-		Ke->values[0]=kmax*pow((double)10,penalty_factor);
+		Ke->values[0]=kmax*pow((IssmDouble)10,penalty_factor);
 	}
 
@@ -517,10 +517,10 @@
 	return Ke;
 }
-/*}}}1*/
-/*FUNCTION Pengrid::PenaltyCreateKMatrixThermal {{{1*/
-ElementMatrix* Pengrid::PenaltyCreateKMatrixThermal(double kmax){
+/*}}}*/
+/*FUNCTION Pengrid::PenaltyCreateKMatrixThermal {{{*/
+ElementMatrix* Pengrid::PenaltyCreateKMatrixThermal(IssmDouble kmax){
 
 	const int numdof=NUMVERTICES*NDOF1;
-	double    penalty_factor;
+	IssmDouble    penalty_factor;
 
 	/*Initialize Element matrix and return if necessary*/
@@ -531,19 +531,19 @@
 	parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum);
 
-	Ke->values[0]=kmax*pow((double)10,penalty_factor);
+	Ke->values[0]=kmax*pow((IssmDouble)10,penalty_factor);
 
 	/*Clean up and return*/
 	return Ke;
 }
-/*}}}1*/
-/*FUNCTION Pengrid::PenaltyCreatePVectorMelting {{{1*/
-ElementVector* Pengrid::PenaltyCreatePVectorMelting(double kmax){
+/*}}}*/
+/*FUNCTION Pengrid::PenaltyCreatePVectorMelting {{{*/
+ElementVector* Pengrid::PenaltyCreatePVectorMelting(IssmDouble kmax){
 	
 	const int numdof=NUMVERTICES*NDOF1;
-	double pressure;
-	double temperature;
-	double melting_offset;
-	double t_pmp;
-	double dt,penalty_factor;
+	IssmDouble pressure;
+	IssmDouble temperature;
+	IssmDouble melting_offset;
+	IssmDouble t_pmp;
+	IssmDouble dt,penalty_factor;
 
 	/*recover pointers: */
@@ -572,6 +572,6 @@
 	}
 	else{
-		if (dt) pe->values[0]=melting_offset*pow((double)10,penalty_factor)*(temperature-t_pmp)/dt;
-		else    pe->values[0]=melting_offset*pow((double)10,penalty_factor)*(temperature-t_pmp);
+		if (dt) pe->values[0]=melting_offset*pow((IssmDouble)10,penalty_factor)*(temperature-t_pmp)/dt;
+		else    pe->values[0]=melting_offset*pow((IssmDouble)10,penalty_factor)*(temperature-t_pmp);
 	}
 
@@ -579,12 +579,12 @@
 	return pe;
 }
-/*}}}1*/
-/*FUNCTION Pengrid::PenaltyCreatePVectorThermal {{{1*/
-ElementVector* Pengrid::PenaltyCreatePVectorThermal(double kmax){
+/*}}}*/
+/*FUNCTION Pengrid::PenaltyCreatePVectorThermal {{{*/
+ElementVector* Pengrid::PenaltyCreatePVectorThermal(IssmDouble kmax){
 
 	const int numdof=NUMVERTICES*NDOF1;
-	double pressure;
-	double t_pmp;
-	double penalty_factor;
+	IssmDouble pressure;
+	IssmDouble t_pmp;
+	IssmDouble penalty_factor;
 
 	Penta* penta=(Penta*)element;
@@ -601,20 +601,20 @@
 	t_pmp=matpar->GetMeltingPoint()-matpar->GetBeta()*pressure;
 
-	pe->values[0]=kmax*pow((double)10,penalty_factor)*t_pmp;
+	pe->values[0]=kmax*pow((IssmDouble)10,penalty_factor)*t_pmp;
 
 	/*Clean up and return*/
 	return pe;
 }
-/*}}}1*/
+/*}}}*/
 #endif
-/*FUNCTION Pengrid::ResetConstraint {{{1*/
+/*FUNCTION Pengrid::ResetConstraint {{{*/
 void  Pengrid::ResetConstraint(void){
 	active=0;
 	zigzag_counter=0;
 }
-/*}}}1*/
-/*FUNCTION Pengrid::UpdateInputs {{{1*/
-void  Pengrid::UpdateInputs(double* solution){
-	_error_("not supported yet!");
-}
-/*}}}1*/
+/*}}}*/
+/*FUNCTION Pengrid::UpdateInputs {{{*/
+void  Pengrid::UpdateInputs(IssmDouble* solution){
+	_error2_("not supported yet!");
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Pengrid.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Pengrid.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Pengrid.h	(revision 12706)
@@ -6,5 +6,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Load.h"
 class Hook;
@@ -40,10 +40,10 @@
 	public:
 
-		/*Pengrid constructors, destructors {{{1*/
+		/*Pengrid constructors, destructors {{{*/
 		Pengrid();
 		Pengrid(int index, int id, IoModel* iomodel,int analysis_type);
 		~Pengrid();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -53,42 +53,42 @@
 		Object* copy();
 		/*}}}*/
-		/*Update virtual functions resolution: {{{1*/
-		void  InputUpdateFromVector(double* vector, int name, int type);
+		/*Update virtual functions resolution: {{{*/
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVector(int* vector, int name, int type);
 		void  InputUpdateFromVector(bool* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(double* matrix ,int nrows, int ncols, int name, int type);
-		void  InputUpdateFromVectorDakota(double* vector, int name, int type);
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(int* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
-		void  InputUpdateFromConstant(double constant, int name);
+		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
-		void  InputUpdateFromSolution(double* solution);
-		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		void  InputUpdateFromSolution(IssmDouble* solution);
+		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
 		/*}}}*/
-		/*Load virtual functions definitions: {{{1*/
+		/*Load virtual functions definitions: {{{*/
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
 		void  CreatePVector(Vector* pf);
-		void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
-		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
-		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
-		void  PenaltyCreatePVector(Vector* pf, double kmax);
+		void  CreateJacobianMatrix(Matrix* Jff){_error2_("Not implemented yet");};
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){_error2_("Not implemented yet");};
+		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, IssmDouble kmax);
+		void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
-		/*Pengrid management {{{1*/
+		/*Pengrid management {{{*/
 		#ifdef _HAVE_DIAGNOSTIC_
-		ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(double kmax);
+		ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax);
 		#endif
 		#ifdef _HAVE_THERMAL_
-		ElementMatrix* PenaltyCreateKMatrixThermal(double kmax);
-		ElementMatrix* PenaltyCreateKMatrixMelting(double kmax);
-		ElementVector* PenaltyCreatePVectorThermal(double kmax);
-		ElementVector* PenaltyCreatePVectorMelting(double kmax);
+		ElementMatrix* PenaltyCreateKMatrixThermal(IssmDouble kmax);
+		ElementMatrix* PenaltyCreateKMatrixMelting(IssmDouble kmax);
+		ElementVector* PenaltyCreatePVectorThermal(IssmDouble kmax);
+		ElementVector* PenaltyCreatePVectorMelting(IssmDouble kmax);
 		#endif
 		void  ConstraintActivate(int* punstable);
 		void  ConstraintActivateThermal(int* punstable);
-		void  UpdateInputs(double* solution);
+		void  UpdateInputs(IssmDouble* solution);
 		void  ResetConstraint(void);
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Penpair.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Penpair.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Penpair.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -23,5 +23,5 @@
 
 /*Penpair constructors and destructor*/
-/*FUNCTION Penpair::constructor {{{1*/
+/*FUNCTION Penpair::constructor {{{*/
 Penpair::Penpair(){
 
@@ -31,6 +31,6 @@
 	return;
 }
-/*}}}1*/
-/*FUNCTION Penpair::creation {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::creation {{{*/
 Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type){
 	
@@ -43,53 +43,53 @@
 	return;
 }
-/*}}}1*/
-/*FUNCTION Penpair::destructor {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::destructor {{{*/
 Penpair::~Penpair(){
 	delete hnodes;
 	return;
 }
-/*}}}1*/
+/*}}}*/
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Penpair::Echo {{{1*/
+/*FUNCTION Penpair::Echo {{{*/
 void Penpair::Echo(void){
 
 	int i;
 
-	printf("Penpair:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Penpair:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnodes->Echo();
 	
 	return;
 }
-/*}}}1*/
-/*FUNCTION Penpair::DeepEcho {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::DeepEcho {{{*/
 void Penpair::DeepEcho(void){
 
-	printf("Penpair:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Penpair:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnodes->DeepEcho();
 
 	return;
 }		
-/*}}}1*/
-/*FUNCTION Penpair::Id {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::Id {{{*/
 int    Penpair::Id(void){ return id; }
-/*}}}1*/
-/*FUNCTION Penpair::MyRank {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::MyRank {{{*/
 int    Penpair::MyRank(void){ 
 	extern int my_rank;
 	return my_rank; 
 }
-/*}}}1*/
-/*FUNCTION Penpair::ObjectEnum{{{1*/
+/*}}}*/
+/*FUNCTION Penpair::ObjectEnum{{{*/
 int Penpair::ObjectEnum(void){
 
 	return PenpairEnum;
 }
-/*}}}1*/
-/*FUNCTION Penpair::copy {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::copy {{{*/
 Object* Penpair::copy() {
 	
@@ -115,5 +115,5 @@
 		
 /*Load virtual functions definitions:*/
-/*FUNCTION Penpair::Configure {{{1*/
+/*FUNCTION Penpair::Configure {{{*/
 void  Penpair::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
@@ -129,11 +129,11 @@
 
 }
-/*}}}1*/
-/*FUNCTION Penpair::SetCurrentConfiguration {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::SetCurrentConfiguration {{{*/
 void  Penpair::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
 }
-/*}}}1*/
-/*FUNCTION Penpair::CreateKMatrix {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::CreateKMatrix {{{*/
 void  Penpair::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 	/*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/
@@ -142,6 +142,6 @@
 
 }
-/*}}}1*/
-/*FUNCTION Penpair::CreatePVector {{{1*/
+/*}}}*/
+/*FUNCTION Penpair::CreatePVector {{{*/
 void  Penpair::CreatePVector(Vector* pf){
 
@@ -150,12 +150,12 @@
 
 }
-/*}}}1*/
-/*FUNCTION Penpair::CreateJacobianMatrix{{{1*/
+/*}}}*/
+/*FUNCTION Penpair::CreateJacobianMatrix{{{*/
 void  Penpair::CreateJacobianMatrix(Matrix* Jff){
 	this->CreateKMatrix(Jff,NULL);
 }
-/*}}}1*/
-/*FUNCTION Penpair::PenaltyCreateKMatrix {{{1*/
-void  Penpair::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
+/*}}}*/
+/*FUNCTION Penpair::PenaltyCreateKMatrix {{{*/
+void  Penpair::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
 
 	/*Retrieve parameters: */
@@ -172,5 +172,5 @@
 			break;
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -181,17 +181,17 @@
 	}
 }
-/*}}}1*/
-/*FUNCTION Penpair::PenaltyCreatePVector {{{1*/
-void  Penpair::PenaltyCreatePVector(Vector* pf,double kmax){
+/*}}}*/
+/*FUNCTION Penpair::PenaltyCreatePVector {{{*/
+void  Penpair::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
 	/*No loads applied, do nothing: */
 	return;
 }
-/*}}}1*/
-/*FUNCTION Penpair::PenaltyCreateJacobianMatrix{{{1*/
-void  Penpair::PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){
+/*}}}*/
+/*FUNCTION Penpair::PenaltyCreateJacobianMatrix{{{*/
+void  Penpair::PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){
 	this->PenaltyCreateKMatrix(Jff,NULL,kmax);
 }
-/*}}}1*/
-/*FUNCTION Penpair::InAnalysis{{{1*/
+/*}}}*/
+/*FUNCTION Penpair::InAnalysis{{{*/
 bool Penpair::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type)return true;
@@ -201,30 +201,30 @@
 
 /*Update virtual functions definitions:*/
-/*FUNCTION Penpair::InputUpdateFromConstant(double constant, int name) {{{1*/
-void  Penpair::InputUpdateFromConstant(double constant, int name){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Penpair::InputUpdateFromConstant(int constant, int name) {{{1*/
+/*FUNCTION Penpair::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
+void  Penpair::InputUpdateFromConstant(IssmDouble constant, int name){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Penpair::InputUpdateFromConstant(int constant, int name) {{{*/
 void  Penpair::InputUpdateFromConstant(int constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Penpair::InputUpdateFromConstant(bool constant, int name) {{{1*/
+/*FUNCTION Penpair::InputUpdateFromConstant(bool constant, int name) {{{*/
 void  Penpair::InputUpdateFromConstant(bool constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Penpair::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
-void  Penpair::InputUpdateFromVector(double* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Penpair::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
+/*FUNCTION Penpair::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
+void  Penpair::InputUpdateFromVector(IssmDouble* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Penpair::InputUpdateFromVector(int* vector, int name, int type) {{{*/
 void  Penpair::InputUpdateFromVector(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Penpair::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Penpair::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
 void  Penpair::InputUpdateFromVector(bool* vector, int name, int type){
 	/*Nothing updated yet*/
@@ -233,6 +233,6 @@
 
 /*Penpair management:*/
-/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticHoriz{{{1*/
-ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticHoriz(double kmax){
+/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticHoriz{{{*/
+ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax){
 
 	int    approximation0=nodes[0]->GetApproximation();
@@ -244,5 +244,5 @@
 				case MacAyealApproximationEnum: return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax); 
 				case PattynApproximationEnum:   return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax); 
-				default: _error_("not supported yet");
+				default: _error2_("not supported yet");
 			}
 		case PattynApproximationEnum:
@@ -250,5 +250,5 @@
 				case MacAyealApproximationEnum: return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax); 
 				case PattynApproximationEnum:   return PenaltyCreateKMatrixDiagnosticMacAyealPattyn(kmax); 
-				default: _error_("not supported yet");
+				default: _error2_("not supported yet");
 			}
 		case StokesApproximationEnum:
@@ -256,5 +256,5 @@
 				case StokesApproximationEnum: return PenaltyCreateKMatrixDiagnosticStokes(kmax); 
 				case NoneApproximationEnum: return   PenaltyCreateKMatrixDiagnosticStokes(kmax); 
-				default: _error_("not supported yet");
+				default: _error2_("not supported yet");
 			}
 		case NoneApproximationEnum:
@@ -262,15 +262,15 @@
 				case StokesApproximationEnum: return PenaltyCreateKMatrixDiagnosticStokes(kmax); 
 				case NoneApproximationEnum: return   PenaltyCreateKMatrixDiagnosticStokes(kmax); 
-				default: _error_("not supported yet");
+				default: _error2_("not supported yet");
 			}
-		default: _error_("not supported yet");
+		default: _error2_("not supported yet");
 	}
 }
-/*}}}1*/
-/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn {{{1*/
-ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn(double kmax){
+/*}}}*/
+/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn {{{*/
+ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn(IssmDouble kmax){
 	
 	const int numdof=NUMVERTICES*NDOF2;
-	double penalty_offset;
+	IssmDouble penalty_offset;
 
 	/*Initialize Element vector and return if necessary*/
@@ -281,23 +281,23 @@
 
 	//Create elementary matrix: add penalty to 
-	Ke->values[0*numdof+0]=+kmax*pow((double)10.0,penalty_offset);
-	Ke->values[0*numdof+2]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[2*numdof+0]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[2*numdof+2]=+kmax*pow((double)10.0,penalty_offset);
-
-	Ke->values[1*numdof+1]=+kmax*pow((double)10.0,penalty_offset);
-	Ke->values[1*numdof+3]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[3*numdof+1]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[3*numdof+3]=+kmax*pow((double)10.0,penalty_offset);
+	Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[0*numdof+2]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[2*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[2*numdof+2]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+
+	Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[1*numdof+3]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[3*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[3*numdof+3]=+kmax*pow((IssmDouble)10.0,penalty_offset);
 
 	/*Clean up and return*/
 	return Ke;
 }
-/*}}}1*/
-/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticStokes {{{1*/
-ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticStokes(double kmax){
+/*}}}*/
+/*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticStokes {{{*/
+ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){
 	
 	const int numdof=NUMVERTICES*NDOF4;
-	double penalty_offset;
+	IssmDouble penalty_offset;
 
 	/*Initialize Element vector and return if necessary*/
@@ -308,33 +308,33 @@
 
 	//Create elementary matrix: add penalty to 
-	Ke->values[0*numdof+0]=+kmax*pow((double)10.0,penalty_offset);
-	Ke->values[0*numdof+4]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[4*numdof+0]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[4*numdof+4]=+kmax*pow((double)10.0,penalty_offset);
-
-	Ke->values[1*numdof+1]=+kmax*pow((double)10.0,penalty_offset);
-	Ke->values[1*numdof+5]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[5*numdof+1]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[5*numdof+5]=+kmax*pow((double)10.0,penalty_offset);
-	
-	Ke->values[2*numdof+2]=+kmax*pow((double)10.0,penalty_offset);
-	Ke->values[2*numdof+6]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[6*numdof+2]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[6*numdof+6]=+kmax*pow((double)10.0,penalty_offset);
-
-	Ke->values[3*numdof+3]=+kmax*pow((double)10.0,penalty_offset);
-	Ke->values[3*numdof+7]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[7*numdof+3]=-kmax*pow((double)10.0,penalty_offset);
-	Ke->values[7*numdof+7]=+kmax*pow((double)10.0,penalty_offset);
+	Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[0*numdof+4]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[4*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[4*numdof+4]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+
+	Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[1*numdof+5]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[5*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[5*numdof+5]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+	
+	Ke->values[2*numdof+2]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[2*numdof+6]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[6*numdof+2]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[6*numdof+6]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+
+	Ke->values[3*numdof+3]=+kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[3*numdof+7]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[7*numdof+3]=-kmax*pow((IssmDouble)10.0,penalty_offset);
+	Ke->values[7*numdof+7]=+kmax*pow((IssmDouble)10.0,penalty_offset);
 
 	/*Clean up and return*/
 	return Ke;
 }
-/*}}}1*/
-/*FUNCTION Penpair::PenaltyCreateKMatrixPrognostic {{{1*/
-ElementMatrix* Penpair::PenaltyCreateKMatrixPrognostic(double kmax){
+/*}}}*/
+/*FUNCTION Penpair::PenaltyCreateKMatrixPrognostic {{{*/
+ElementMatrix* Penpair::PenaltyCreateKMatrixPrognostic(IssmDouble kmax){
 
 	const int numdof=NUMVERTICES*NDOF1;
-	double penalty_factor;
+	IssmDouble penalty_factor;
 
 	/*Initialize Element vector and return if necessary*/
@@ -345,11 +345,11 @@
 
 	//Create elementary matrix: add penalty to 
-	Ke->values[0*numdof+0]=+kmax*pow((double)10.0,penalty_factor);
-	Ke->values[0*numdof+1]=-kmax*pow((double)10.0,penalty_factor);
-	Ke->values[1*numdof+0]=-kmax*pow((double)10.0,penalty_factor);
-	Ke->values[1*numdof+1]=+kmax*pow((double)10.0,penalty_factor);
+	Ke->values[0*numdof+0]=+kmax*pow((IssmDouble)10.0,penalty_factor);
+	Ke->values[0*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_factor);
+	Ke->values[1*numdof+0]=-kmax*pow((IssmDouble)10.0,penalty_factor);
+	Ke->values[1*numdof+1]=+kmax*pow((IssmDouble)10.0,penalty_factor);
 
 	/*Clean up and return*/
 	return Ke;
 }
-/*}}}1*/
+/*}}}*/
Index: /issm/trunk/src/c/objects/Loads/Penpair.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Penpair.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Penpair.h	(revision 12706)
@@ -6,5 +6,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Load.h"
 #include "../Node.h"
@@ -27,10 +27,10 @@
 	public:
 
-		/*Penpair constructors, destructors: {{{1*/
+		/*Penpair constructors, destructors: {{{*/
 		Penpair();
 		Penpair(int penpair_id,int* penpair_node_ids,int analysis_type);
 		~Penpair();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -40,19 +40,19 @@
 		Object* copy();
 		/*}}}*/
-		/*Update virtual functions resolution: {{{1*/
-		void  InputUpdateFromVector(double* vector, int name, int type);
+		/*Update virtual functions resolution: {{{*/
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVector(int* vector, int name, int type);
 		void  InputUpdateFromVector(bool* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(double* matrix, int nrow, int ncols,int name, int type){_error_("Not implemented yet!");}
-		void  InputUpdateFromVectorDakota(double* vector, int name, int type){_error_("Not implemented yet!");}
-		void  InputUpdateFromVectorDakota(int* vector, int name, int type){_error_("Not implemented yet!");}
-		void  InputUpdateFromVectorDakota(bool* vector, int name, int type){_error_("Not implemented yet!");}
-		void  InputUpdateFromConstant(double constant, int name);
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols,int name, int type){_error2_("Not implemented yet!");}
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error2_("Not implemented yet!");}
+		void  InputUpdateFromVectorDakota(int* vector, int name, int type){_error2_("Not implemented yet!");}
+		void  InputUpdateFromVectorDakota(bool* vector, int name, int type){_error2_("Not implemented yet!");}
+		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
-		void  InputUpdateFromSolution(double* solution){_error_("Not implemented yet!");}
-		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		void  InputUpdateFromSolution(IssmDouble* solution){_error2_("Not implemented yet!");}
+		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
 		/*}}}*/
-			/*Load virtual functions definitions: {{{1*/
+			/*Load virtual functions definitions: {{{*/
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
@@ -60,14 +60,14 @@
 		void  CreatePVector(Vector* pf);
 		void  CreateJacobianMatrix(Matrix* Jff);
-		void  PenaltyCreateKMatrix(Matrix* Kff,Matrix* Kfs,double kmax);
-		void  PenaltyCreatePVector(Vector* pf, double kmax);
-		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax);
+		void  PenaltyCreateKMatrix(Matrix* Kff,Matrix* Kfs,IssmDouble kmax);
+		void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax);
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
-			/*Penpair management: {{{1*/
-		ElementMatrix* PenaltyCreateKMatrixDiagnosticHoriz(double kmax);
-		ElementMatrix* PenaltyCreateKMatrixDiagnosticMacAyealPattyn(double kmax);
-		ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(double kmax);
-		ElementMatrix* PenaltyCreateKMatrixPrognostic(double kmax);
+			/*Penpair management: {{{*/
+		ElementMatrix* PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax);
+		ElementMatrix* PenaltyCreateKMatrixDiagnosticMacAyealPattyn(IssmDouble kmax);
+		ElementMatrix* PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax);
+		ElementMatrix* PenaltyCreateKMatrixPrognostic(IssmDouble kmax);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/Loads/Riftfront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -24,5 +24,5 @@
 
 /*Riftfront constructors and destructor*/
-/*FUNCTION Riftfront::Riftfront(){{{1*/
+/*FUNCTION Riftfront::Riftfront(){{{*/
 Riftfront::Riftfront(){
 	this->inputs=NULL;
@@ -36,5 +36,5 @@
 }
 /*}}}*/
-/*FUNCTION Riftfront::Riftfront(int id, int i, IoModel* iomodel,int analysis_type){{{1*/
+/*FUNCTION Riftfront::Riftfront(int id, int i, IoModel* iomodel,int analysis_type){{{*/
 Riftfront::Riftfront(int riftfront_id,int i, IoModel* iomodel,int riftfront_analysis_type){
 
@@ -45,6 +45,6 @@
 	int    riftfront_type;
 	int    riftfront_fill;
-	double riftfront_friction;
-	double riftfront_fractionincrement;
+	IssmDouble riftfront_friction;
+	IssmDouble riftfront_fractionincrement;
 	bool   riftfront_shelf;
 	int    numberofelements;
@@ -117,6 +117,6 @@
 		
 }
-/*}}}1*/
-/*FUNCTION Riftfront::~Riftfront(){{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::~Riftfront(){{{*/
 Riftfront::~Riftfront(){
 	delete inputs;
@@ -130,10 +130,10 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Riftfront::Echo {{{1*/
+/*FUNCTION Riftfront::Echo {{{*/
 void Riftfront::Echo(void){
 
 	Input* input=NULL;
 	int fill;
-	double friction,fractionincrement;
+	IssmDouble friction,fractionincrement;
 
 	
@@ -143,54 +143,54 @@
 	input=(Input*)this->inputs->GetInput(FractionIncrementEnum); input->GetInputValue(&fractionincrement);
 
-	printf("Riftfront:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
-	printf("   hnodes: %p\n",hnodes);
-	printf("   helements: %p\n",helements);
-	printf("   hmatpar: %p\n",hmatpar);
-	printf("   parameters: %p\n",parameters);
-	printf("   inputs: %p\n",inputs);
-	printf("   internal parameters: \n");
-	printf("   normal: %g|%g\n",normal[0],normal[1]);
-	printf("   length: %g\n",length);
-	printf("   penalty_lock: %i\n",penalty_lock);
-	printf("   active: %s\n",active ? "true":"false");
-	printf("   counter: %i\n",counter);
-	printf("   prestable: %s\n",prestable ? "true":"false");
-	printf("   material_converged: %s\n",material_converged ? "true":"false");
-	printf("   fill: %i\n",fill);
-	printf("   friction: %g\n",friction);
-	printf("   fraction: %g\n",fraction);
-	printf("   fractionincrement: %g\n",fractionincrement);
-	printf("   state: %i\n",state);
-	printf("   frozen: %s\n",frozen ? "true":"false");
+	_printLine_("Riftfront:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
+	_printLine_("   hnodes: " << hnodes);
+	_printLine_("   helements: " << helements);
+	_printLine_("   hmatpar: " << hmatpar);
+	_printLine_("   parameters: " << parameters);
+	_printLine_("   inputs: " << inputs);
+	_printLine_("   internal parameters: ");
+	_printLine_("   normal: " << normal[0] << "|" << normal[1]);
+	_printLine_("   length: " << length);
+	_printLine_("   penalty_lock: " << penalty_lock);
+	_printLine_("   active: " <<(active ? "true":"false"));
+	_printLine_("   counter: " << counter);
+	_printLine_("   prestable: " << (prestable ? "true":"false"));
+	_printLine_("   material_converged: " << (material_converged ? "true":"false"));
+	_printLine_("   fill: " << fill);
+	_printLine_("   friction: " << friction);
+	_printLine_("   fraction: " << fraction);
+	_printLine_("   fractionincrement: " << fractionincrement);
+	_printLine_("   state: " << state);
+	_printLine_("   frozen: " << (frozen ? "true":"false"));
 		
 }
-/*}}}1*/
-/*FUNCTION Riftfront::DeepEcho{{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::DeepEcho{{{*/
 void Riftfront::DeepEcho(void){
 
-	printf("Riftfront:\n");
-	printf("   id: %i\n",id);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Riftfront:");
+	_printLine_("   id: " << id);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnodes->DeepEcho();
 	helements->DeepEcho();
 	hmatpar->DeepEcho();
-	printf("   parameters\n");
+	_printLine_("   parameters");
 	if(parameters)parameters->DeepEcho();
-	printf("   inputs\n");
+	_printLine_("   inputs");
 	if(inputs)inputs->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION Riftfront::Id {{{1*/
+/*FUNCTION Riftfront::Id {{{*/
 int    Riftfront::Id(void){ return id; }
-/*}}}1*/
-/*FUNCTION Riftfront::MyRank {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::MyRank {{{*/
 int    Riftfront::MyRank(void){ 
 	extern int my_rank;
 	return my_rank; 
 }
-/*}}}1*/
-/*FUNCTION Riftfront::ObjectEnum{{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::ObjectEnum{{{*/
 int Riftfront::ObjectEnum(void){
 
@@ -198,6 +198,6 @@
 
 }
-/*}}}1*/
-/*FUNCTION Riftfront::copy {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::copy {{{*/
 Object* Riftfront::copy() {
 	
@@ -247,5 +247,5 @@
 		
 /*Update virtual functions definitions:*/
-/*FUNCTION Riftfront::InputUpdateFromConstant(bool constant,int name) {{{1*/
+/*FUNCTION Riftfront::InputUpdateFromConstant(bool constant,int name) {{{*/
 void  Riftfront::InputUpdateFromConstant(bool constant,int name){
 
@@ -258,6 +258,6 @@
 }
 /*}}}*/
-/*FUNCTION Riftfront::InputUpdateFromConstant(double constant,int name) {{{1*/
-void  Riftfront::InputUpdateFromConstant(double constant,int name){
+/*FUNCTION Riftfront::InputUpdateFromConstant(IssmDouble constant,int name) {{{*/
+void  Riftfront::InputUpdateFromConstant(IssmDouble constant,int name){
 
 	/*Check that name is a Riftfront input*/
@@ -269,6 +269,6 @@
 }
 /*}}}*/
-/*FUNCTION Riftfront::InputUpdateFromConstant(double* constant,int name) {{{1*/
-void    Riftfront::InputUpdateFromVector(double* vector, int name, int type){
+/*FUNCTION Riftfront::InputUpdateFromConstant(IssmDouble* constant,int name) {{{*/
+void    Riftfront::InputUpdateFromVector(IssmDouble* vector, int name, int type){
 
 	/*Check that name is a Riftfront input*/
@@ -276,5 +276,5 @@
 
 	/*update input*/
-	_error_("not implemented yet");
+	_error2_("not implemented yet");
 	//this->inputs->AddInput(new DoubleInput(name,constant));
 
@@ -284,5 +284,5 @@
 
 /*Load virtual functions definitions:*/
-/*FUNCTION Riftfront::Configure {{{1*/
+/*FUNCTION Riftfront::Configure {{{*/
 void  Riftfront::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
@@ -303,11 +303,11 @@
 }
 /*}}}*/
-/*FUNCTION Riftfront::SetCurrentConfiguration {{{1*/
+/*FUNCTION Riftfront::SetCurrentConfiguration {{{*/
 void  Riftfront::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
 }
 /*}}}*/
-/*FUNCTION Riftfront::PenaltyCreateKMatrix {{{1*/
-void  Riftfront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){
+/*FUNCTION Riftfront::PenaltyCreateKMatrix {{{*/
+void  Riftfront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,IssmDouble kmax){
 
 	/*Retrieve parameters: */
@@ -324,5 +324,5 @@
 			break;
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -333,7 +333,7 @@
 	}
 }
-/*}}}1*/
-/*FUNCTION Riftfront::PenaltyCreatePVector {{{1*/
-void  Riftfront::PenaltyCreatePVector(Vector* pf,double kmax){
+/*}}}*/
+/*FUNCTION Riftfront::PenaltyCreatePVector {{{*/
+void  Riftfront::PenaltyCreatePVector(Vector* pf,IssmDouble kmax){
 
 	/*Retrieve parameters: */
@@ -350,5 +350,5 @@
 			break;
 		default:
-			_error_("analysis %i (%s) not supported yet",analysis_type,EnumToStringx(analysis_type));
+			_error2_("analysis " << analysis_type << " (" << EnumToStringx(analysis_type) << ") not supported yet");
 	}
 
@@ -359,18 +359,18 @@
 	}
 }
-/*}}}1*/
-/*FUNCTION Riftfront::CreateKMatrix {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::CreateKMatrix {{{*/
 void  Riftfront::CreateKMatrix(Matrix* Kff, Matrix* Kfs){
 	/*do nothing: */
 	return;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::CreatePVector {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::CreatePVector {{{*/
 void  Riftfront::CreatePVector(Vector* pf){
 	/*do nothing: */
 	return;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::InAnalysis{{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::InAnalysis{{{*/
 bool Riftfront::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type) return true;
@@ -380,15 +380,15 @@
 
 /*Riftfront numerics*/
-/*FUNCTION Riftfront::PenaltyCreateKMatrixDiagnosticHoriz {{{1*/
-ElementMatrix* Riftfront::PenaltyCreateKMatrixDiagnosticHoriz(double kmax){
+/*FUNCTION Riftfront::PenaltyCreateKMatrixDiagnosticHoriz {{{*/
+ElementMatrix* Riftfront::PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax){
 
 	const int   numdof = NDOF2*NUMVERTICES;
 	int         i,j;
 	int         dofs[1]             = {0};
-	double      Ke_gg[4][4];
-	double      thickness;
-	double      h[2];
-	double      penalty_offset;
-	double      friction;
+	IssmDouble      Ke_gg[4][4];
+	IssmDouble      thickness;
+	IssmDouble      h[2];
+	IssmDouble      penalty_offset;
+	IssmDouble      friction;
 
 	/*Objects: */
@@ -397,5 +397,5 @@
 
 	/*enum of element? */
-	if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
+	if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
 	tria1=(Tria*)elements[0];
 	tria2=(Tria*)elements[1];
@@ -410,5 +410,5 @@
 	tria1->GetInputValue(&h[0],nodes[0],ThicknessEnum);
 	tria2->GetInputValue(&h[1],nodes[1],ThicknessEnum);
-	if (h[0]!=h[1])_error_(" different thicknesses not supported for rift fronts");
+	if (h[0]!=h[1])_error2_("different thicknesses not supported for rift fronts");
 	thickness=h[0];
 
@@ -462,22 +462,22 @@
 	return Ke;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::PenaltyCreatePVectorDiagnosticHoriz {{{1*/
-ElementVector* Riftfront::PenaltyCreatePVectorDiagnosticHoriz(double kmax){
+/*}}}*/
+/*FUNCTION Riftfront::PenaltyCreatePVectorDiagnosticHoriz {{{*/
+ElementVector* Riftfront::PenaltyCreatePVectorDiagnosticHoriz(IssmDouble kmax){
 
 	const int   numdof = NDOF2*NUMVERTICES;
 	int         i,j;
-	double      rho_ice;
-	double      rho_water;
-	double      gravity;
-	double      thickness;
-	double      h[2];
-	double      bed;
-	double      b[2];
-	double      pressure;
-	double      pressure_litho;
-	double      pressure_air;
-	double      pressure_melange;
-	double      pressure_water;
+	IssmDouble      rho_ice;
+	IssmDouble      rho_water;
+	IssmDouble      gravity;
+	IssmDouble      thickness;
+	IssmDouble      h[2];
+	IssmDouble      bed;
+	IssmDouble      b[2];
+	IssmDouble      pressure;
+	IssmDouble      pressure_litho;
+	IssmDouble      pressure_air;
+	IssmDouble      pressure_melange;
+	IssmDouble      pressure_water;
 	int         fill;
 	bool        shelf;
@@ -488,5 +488,5 @@
 
 	/*enum of element? */
-	if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
+	if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
 	tria1=(Tria*)elements[0];
 	tria2=(Tria*)elements[1];
@@ -504,9 +504,9 @@
 	tria1->GetInputValue(&h[0],nodes[0],ThicknessEnum);
 	tria2->GetInputValue(&h[1],nodes[1],ThicknessEnum);
-	if (h[0]!=h[1])_error_(" different thicknesses not supported for rift fronts");
+	if (h[0]!=h[1])_error2_("different thicknesses not supported for rift fronts");
 	thickness=h[0];
 	tria1->GetInputValue(&b[0],nodes[0],BedEnum);
 	tria2->GetInputValue(&b[1],nodes[1],BedEnum);
-	if (b[0]!=b[1])_error_(" different beds not supported for rift fronts");
+	if (b[0]!=b[1])_error2_("different beds not supported for rift fronts");
 	bed=b[0];
 
@@ -521,13 +521,13 @@
 		if(shelf){
 			/*We are on an ice shelf, hydrostatic equilibrium is used to determine the pressure for water fill: */
-			pressure=rho_ice*gravity*pow(thickness,(double)2)/(double)2  - rho_water*gravity*pow(bed,(double)2)/(double)2; 
+			pressure=rho_ice*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2  - rho_water*gravity*pow(bed,(IssmDouble)2)/(IssmDouble)2; 
 		}
 		else{
 			//We are on an icesheet, we assume the water column fills the entire front: */
-			pressure=rho_ice*gravity*pow(thickness,(double)2)/(double)2  - rho_water*gravity*pow(thickness,(double)2)/(double)2; 
+			pressure=rho_ice*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2  - rho_water*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2; 
 		}
 	}
 	else if(fill==AirEnum){
-		pressure=rho_ice*gravity*pow(thickness,(double)2)/(double)2;   //icefront on an ice sheet, pressure imbalance ice vs air.
+		pressure=rho_ice*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2;   //icefront on an ice sheet, pressure imbalance ice vs air.
 	}
 	else if(fill==IceEnum){ //icefront finding itself against another icefront (pressure imbalance is fully compensated, ice vs ice)
@@ -536,9 +536,9 @@
 	else if(fill==MelangeEnum){ //icefront finding itself against another icefront (pressure imbalance is fully compensated, ice vs ice)
 
-		if(!shelf) _error_("%s%i%s","fill type ",fill," not supported on ice sheets yet.");
-
-		pressure_litho=rho_ice*gravity*pow(thickness,(double)2)/(double)2;
+		if(!shelf) _error2_("fill type " << fill << " not supported on ice sheets yet.");
+
+		pressure_litho=rho_ice*gravity*pow(thickness,(IssmDouble)2)/(IssmDouble)2;
 		pressure_air=0;
-		pressure_melange=rho_ice*gravity*pow(fraction*thickness,(double)2)/(double)2;
+		pressure_melange=rho_ice*gravity*pow(fraction*thickness,(IssmDouble)2)/(IssmDouble)2;
 		pressure_water=1.0/2.0*rho_water*gravity*  ( pow(bed,2.0)-pow(rho_ice/rho_water*fraction*thickness,2.0) );
 
@@ -546,5 +546,5 @@
 	}
 	else{
-		_error_("%s%i%s","fill type ",fill," not supported yet.");
+		_error2_("fill type " << fill << " not supported yet.");
 	}
 
@@ -562,6 +562,6 @@
 	return pe;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::Constrain {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::Constrain {{{*/
 #define _ZIGZAGCOUNTER_
 
@@ -569,14 +569,14 @@
 
 	const int   numnodes        = 2;
-	double      max_penetration;
-	double      penetration;
+	IssmDouble      max_penetration;
+	IssmDouble      penetration;
 	int         activate;
 	int         found;
 	int         unstable;
-	double      vx1;
-	double      vy1;
-	double      vx2;
-	double      vy2;
-	double      fractionincrement;
+	IssmDouble      vx1;
+	IssmDouble      vy1;
+	IssmDouble      vx2;
+	IssmDouble      vy2;
+	IssmDouble      fractionincrement;
 
 	/*Objects: */
@@ -585,5 +585,5 @@
 
 	/*enum of element? */
-	if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
+	if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
 
 	/*recover elements on both side of rift: */
@@ -632,6 +632,6 @@
 		/*increase melange fraction: */
 		this->fraction+=fractionincrement;
-		if (this->fraction>1)this->fraction=(double)1.0;
-		//printf("riftfront %i fraction: %g\n",this->Id(),this->fraction);
+		if (this->fraction>1)this->fraction=(IssmDouble)1.0;
+		//_printLine_("riftfront " << this->Id() << " fraction: " << this->fraction);
 	}
 
@@ -648,5 +648,5 @@
 	this->active=activate;
 
-	//if ((penetration>0) && (this->active==1))printf("Riftfront %i wants to be released\n",Id());
+	//if ((penetration>0) && (this->active==1))_printLine_("Riftfront " << Id() << " wants to be released");
 
 	/*assign output pointer: */
@@ -654,6 +654,6 @@
 	return 1;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::FreezeConstraints{{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::FreezeConstraints{{{*/
 void   Riftfront::FreezeConstraints(void){
 
@@ -662,6 +662,6 @@
 
 }
-/*}}}1*/
-/*FUNCTION Riftfront::IsFrozen{{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::IsFrozen{{{*/
 bool   Riftfront::IsFrozen(void){
 
@@ -670,10 +670,10 @@
 	else return 0;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::IsMaterialStable {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::IsMaterialStable {{{*/
 int   Riftfront::IsMaterialStable(void){
 
 	int found=0;
-	double converged=0;
+	IssmDouble converged=0;
 
 	this->inputs->GetInputValue(&converged,ConvergedEnum);
@@ -688,16 +688,16 @@
 	return this->material_converged;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::MaxPenetration {{{1*/
-int   Riftfront::MaxPenetration(double* ppenetration){
+/*}}}*/
+/*FUNCTION Riftfront::MaxPenetration {{{*/
+int   Riftfront::MaxPenetration(IssmDouble* ppenetration){
 
 	const int     numnodes=2;
-	double        max_penetration;
-	double        penetration=0;
+	IssmDouble        max_penetration;
+	IssmDouble        penetration=0;
 	int           found;
-	double      vx1;
-	double      vy1;
-	double      vx2;
-	double      vy2;
+	IssmDouble      vx1;
+	IssmDouble      vy1;
+	IssmDouble      vx2;
+	IssmDouble      vy2;
 
 	/*Objects: */
@@ -706,5 +706,5 @@
 
 	/*enum of element? */
-	if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
+	if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
 
 	/*recover elements on both side of rift: */
@@ -734,14 +734,14 @@
 	return 1;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::Penetration {{{1*/
-int   Riftfront::Penetration(double* ppenetration){
-
-	double    vx1;
-	double    vy1;
-	double    vx2;
-	double    vy2;
-
-	double    penetration;
+/*}}}*/
+/*FUNCTION Riftfront::Penetration {{{*/
+int   Riftfront::Penetration(IssmDouble* ppenetration){
+
+	IssmDouble    vx1;
+	IssmDouble    vy1;
+	IssmDouble    vx2;
+	IssmDouble    vy2;
+
+	IssmDouble    penetration;
 	int       found;
 
@@ -751,5 +751,5 @@
 
 	/*enum of element? */
-	if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
+	if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
 
 	/*recover elements on both side of rift: */
@@ -773,19 +773,19 @@
 	return 1;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::PotentialUnstableConstraint {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::PotentialUnstableConstraint {{{*/
 int   Riftfront::PotentialUnstableConstraint(int* punstable){
 
 
 	const int   numnodes        = 2;
-	double      max_penetration;
-	double      penetration;
+	IssmDouble      max_penetration;
+	IssmDouble      penetration;
 	int         activate;
 	int         unstable;
 	int         found;
-	double      vx1;
-	double      vy1;
-	double      vx2;
-	double      vy2;
+	IssmDouble      vx1;
+	IssmDouble      vy1;
+	IssmDouble      vx2;
+	IssmDouble      vy2;
 
 	/*Objects: */
@@ -794,5 +794,5 @@
 
 	/*enum of element? */
-	if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
+	if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
 
 	/*recover elements on both side of rift: */
@@ -826,16 +826,16 @@
 	return 1;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::PreConstrain {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::PreConstrain {{{*/
 int   Riftfront::PreConstrain(int* punstable){
 
 	const int   numnodes    = 2;
-	double      penetration;
+	IssmDouble      penetration;
 	int         unstable;
 	int         found;
-	double      vx1;
-	double      vy1;
-	double      vx2;
-	double      vy2;
+	IssmDouble      vx1;
+	IssmDouble      vy1;
+	IssmDouble      vx2;
+	IssmDouble      vy2;
 
 	/*Objects: */
@@ -844,5 +844,5 @@
 
 	/*enum of element? */
-	if(elements[0]->ObjectEnum()!=TriaEnum)_error_(" only Tria element allowed for Riftfront load!");
+	if(elements[0]->ObjectEnum()!=TriaEnum)_error2_("only Tria element allowed for Riftfront load!");
 
 	/*recover elements on both side of rift: */
@@ -891,16 +891,16 @@
 	return 1;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::PreStable {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::PreStable {{{*/
 bool  Riftfront::PreStable(){
 	return prestable;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::SetPreStable {{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::SetPreStable {{{*/
 void Riftfront::SetPreStable(){
 	prestable=1;
 }
-/*}}}1*/
-/*FUNCTION Riftfront::IsInput{{{1*/
+/*}}}*/
+/*FUNCTION Riftfront::IsInput{{{*/
 bool Riftfront::IsInput(int name){
 	if (
Index: /issm/trunk/src/c/objects/Loads/Riftfront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Load.h"
 class Hook;
@@ -38,7 +38,7 @@
 		bool     prestable;
 		bool     material_converged;
-		double   normal[2];
-		double   length;
-		double   fraction;
+		IssmDouble   normal[2];
+		IssmDouble   length;
+		IssmDouble   fraction;
 		int      state;
 		
@@ -47,10 +47,10 @@
 
 
-		/*Riftfrontconstructors,destructors: {{{1*/
+		/*Riftfrontconstructors,destructors: {{{*/
 		Riftfront();
 		Riftfront(int riftfront_id,int i, IoModel* iomodel,int analysis_type);
 		~Riftfront();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -60,33 +60,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Update virtual functions resolution: {{{1*/
-		void    InputUpdateFromVector(double* vector, int name, int type);
-		void    InputUpdateFromVector(int* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromVector(bool* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromMatrixDakota(double* matrix, int nrows,int ncols, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromVectorDakota(double* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromVectorDakota(int* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error_("Not implemented yet!");}
-		void    InputUpdateFromConstant(double constant, int name);
-		void    InputUpdateFromConstant(int constant, int name){_error_("Not implemented yet!");}
+		/*Update virtual functions resolution: {{{*/
+		void    InputUpdateFromVector(IssmDouble* vector, int name, int type);
+		void    InputUpdateFromVector(int* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromVector(bool* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows,int ncols, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromVectorDakota(int* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromVectorDakota(bool* vector, int name, int type){_error2_("Not implemented yet!");}
+		void    InputUpdateFromConstant(IssmDouble constant, int name);
+		void    InputUpdateFromConstant(int constant, int name){_error2_("Not implemented yet!");}
 		void    InputUpdateFromConstant(bool constant, int name);
-		void    InputUpdateFromSolution(double* solution){_error_("Not implemented yet!");}
-		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		void    InputUpdateFromSolution(IssmDouble* solution){_error2_("Not implemented yet!");}
+		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
 		/*}}}*/
-		/*Load virtual functions definitions: {{{1*/
+		/*Load virtual functions definitions: {{{*/
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  CreateKMatrix(Matrix* Kff, Matrix* Kfs);
 		void  CreatePVector(Vector* pf);
-		void  CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");};
-		void  PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");};
-		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax);
-		void  PenaltyCreatePVector(Vector* pf, double kmax);
+		void  CreateJacobianMatrix(Matrix* Jff){_error2_("Not implemented yet");};
+		void  PenaltyCreateJacobianMatrix(Matrix* Jff,IssmDouble kmax){_error2_("Not implemented yet");};
+		void  PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, IssmDouble kmax);
+		void  PenaltyCreatePVector(Vector* pf, IssmDouble kmax);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
-		/*Riftfront specific routines: {{{1*/
+		/*Riftfront specific routines: {{{*/
 		bool  PreStable();
-		ElementMatrix* PenaltyCreateKMatrixDiagnosticHoriz(double kmax);
-		ElementVector* PenaltyCreatePVectorDiagnosticHoriz(double kmax);
+		ElementMatrix* PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax);
+		ElementVector* PenaltyCreatePVectorDiagnosticHoriz(IssmDouble kmax);
 		void  SetPreStable();
 		int   PreConstrain(int* punstable);
@@ -94,6 +94,6 @@
 		void  FreezeConstraints(void);
 		bool  IsFrozen(void);
-		int   Penetration(double* ppenetration);
-		int   MaxPenetration(double* ppenetration);
+		int   Penetration(IssmDouble* ppenetration);
+		int   MaxPenetration(IssmDouble* ppenetration);
 		int   PotentialUnstableConstraint(int* punstable);
 		int   IsMaterialStable(void);
Index: /issm/trunk/src/c/objects/Materials/Material.h
===================================================================
--- /issm/trunk/src/c/objects/Materials/Material.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Materials/Material.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 class Object;
 #include "../Object.h"
Index: /issm/trunk/src/c/objects/Materials/Matice.cpp
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matice.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Materials/Matice.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 		
 /*Matice constructors and destructor*/
-/*FUNCTION Matice::Matice(){{{1*/
+/*FUNCTION Matice::Matice(){{{*/
 Matice::Matice(){
 	this->inputs=NULL;
@@ -24,5 +24,5 @@
 }
 /*}}}*/
-/*FUNCTION Matice::Matice(int id, int index, IoModel* iomodel, int num_vertices){{{1*/
+/*FUNCTION Matice::Matice(int id, int index, IoModel* iomodel, int num_vertices){{{*/
 Matice::Matice(int matice_mid,int index, IoModel* iomodel){
 
@@ -48,5 +48,5 @@
 }
 /*}}}*/
-/*FUNCTION Matice::~Matice(){{{1*/
+/*FUNCTION Matice::~Matice(){{{*/
 Matice::~Matice(){
 	delete helement;
@@ -57,30 +57,30 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Matice::Echo {{{1*/
+/*FUNCTION Matice::Echo {{{*/
 void Matice::Echo(void){
 
-	printf("Matice:\n");
-	printf("   mid: %i\n",mid);
-	printf("   inputs:\n");
+	_printLine_("Matice:");
+	_printLine_("   mid: " << mid);
+	_printLine_("   inputs:");
 	inputs->Echo();
-	printf("   element:\n");
+	_printLine_("   element:");
 	helement->Echo();
 }
 /*}}}*/
-/*FUNCTION Matice::DeepEcho {{{1*/
+/*FUNCTION Matice::DeepEcho {{{*/
 void Matice::DeepEcho(void){
 
-	printf("Matice:\n");
-	printf("   mid: %i\n",mid);
-	printf("   inputs:\n");
+	_printLine_("Matice:");
+	_printLine_("   mid: " << mid);
+	_printLine_("   inputs:");
 	inputs->DeepEcho();
-	printf("   element:\n");
+	_printLine_("   element:");
 	helement->Echo();
 }		
 /*}}}*/
-/*FUNCTION Matice::Id {{{1*/
+/*FUNCTION Matice::Id {{{*/
 int    Matice::Id(void){ return mid; }
 /*}}}*/
-/*FUNCTION Matice::MyRank {{{1*/
+/*FUNCTION Matice::MyRank {{{*/
 int    Matice::MyRank(void){ 
 	extern int my_rank;
@@ -88,5 +88,5 @@
 }
 /*}}}*/
-/*FUNCTION Matice::ObjectEnum{{{1*/
+/*FUNCTION Matice::ObjectEnum{{{*/
 int Matice::ObjectEnum(void){
 
@@ -95,5 +95,5 @@
 }
 /*}}}*/
-/*FUNCTION Matice::copy {{{1*/
+/*FUNCTION Matice::copy {{{*/
 Object* Matice::copy() {
 
@@ -115,5 +115,5 @@
 
 /*Matice management*/
-/*FUNCTION Matice::Configure {{{1*/
+/*FUNCTION Matice::Configure {{{*/
 void  Matice::Configure(Elements* elementsin){
 
@@ -123,14 +123,14 @@
 }
 /*}}}*/
-/*FUNCTION Matice::SetCurrentConfiguration {{{1*/
+/*FUNCTION Matice::SetCurrentConfiguration {{{*/
 void  Matice::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
 }
 /*}}}*/
-/*FUNCTION Matice::GetB {{{1*/
-double Matice::GetB(){
+/*FUNCTION Matice::GetB {{{*/
+IssmDouble Matice::GetB(){
 
 	/*Output*/
-	double B;
+	IssmDouble B;
 
 	inputs->GetInputAverage(&B,MaterialsRheologyBEnum);
@@ -138,9 +138,9 @@
 }
 /*}}}*/
-/*FUNCTION Matice::GetBbar {{{1*/
-double Matice::GetBbar(){
+/*FUNCTION Matice::GetBbar {{{*/
+IssmDouble Matice::GetBbar(){
 
 	/*Output*/
-	double Bbar;
+	IssmDouble Bbar;
 
 	inputs->GetInputAverage(&Bbar,MaterialsRheologyBbarEnum);
@@ -148,9 +148,9 @@
 }
 /*}}}*/
-/*FUNCTION Matice::GetN {{{1*/
-double Matice::GetN(){
+/*FUNCTION Matice::GetN {{{*/
+IssmDouble Matice::GetN(){
 
 	/*Output*/
-	double n;
+	IssmDouble n;
 
 	inputs->GetInputAverage(&n,MaterialsRheologyNEnum);
@@ -158,5 +158,5 @@
 }
 /*}}}*/
-/*FUNCTION Matice::GetVectorFromInputs{{{1*/
+/*FUNCTION Matice::GetVectorFromInputs{{{*/
 void  Matice::GetVectorFromInputs(Vector* vector,int input_enum){
 
@@ -180,5 +180,5 @@
 			/*Get input (either in element or material)*/
 			Input* input=inputs->GetInput(input_enum);
-			if(!input) _error_("Input %s not found in material",EnumToStringx(input_enum));
+			if(!input) _error2_("Input " << EnumToStringx(input_enum) << " not found in material");
 
 			/*We found the enum.  Use its values to fill into the vector, using the vertices ids: */
@@ -186,10 +186,10 @@
 			break;
 
-		default: _error_("element %s not implemented yet",EnumToStringx(element->ObjectEnum()));
-	}
-}
-/*}}}*/
-/*FUNCTION Matice::GetViscosity2d {{{1*/
-void  Matice::GetViscosity2d(double* pviscosity, double* epsilon){
+		default: _error2_("element " << EnumToStringx(element->ObjectEnum()) << " not implemented yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Matice::GetViscosity2d {{{*/
+void  Matice::GetViscosity2d(IssmDouble* pviscosity, IssmDouble* epsilon){
 	/*From a string tensor and a material object, return viscosity, using Glen's flow law.
 												    B
@@ -205,12 +205,12 @@
 
 	/*output: */
-	double viscosity;
+	IssmDouble viscosity;
 
 	/*input strain rate: */
-	double exx,eyy,exy;
+	IssmDouble exx,eyy,exy;
 
 	/*Intermediary: */
-	double A,e;
-	double B,n;
+	IssmDouble A,e;
+	IssmDouble B,n;
 
 	/*Get B and n*/
@@ -224,5 +224,5 @@
 	else{
 		if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0)){
-			viscosity=0.5*pow((double)10,(double)14);
+			viscosity=0.5*pow((IssmDouble)10,(IssmDouble)14);
 		}
 		else{
@@ -236,5 +236,5 @@
 			if(A==0){
 				/*Maxiviscositym viscosity for 0 shear areas: */
-				viscosity=2.5*pow((double)10,(double)17);
+				viscosity=2.5*pow((IssmDouble)10,(IssmDouble)17);
 			}
 			else{
@@ -246,5 +246,5 @@
 
 	/*Checks in debugging mode*/
-	if(viscosity<=0) _error_("Negative viscosity");
+	if(viscosity<=0) _error2_("Negative viscosity");
 	_assert_(B>0);
 	_assert_(n>0);
@@ -254,6 +254,6 @@
 }
 /*}}}*/
-/*FUNCTION Matice::GetViscosity3d {{{1*/
-void  Matice::GetViscosity3d(double* pviscosity3d, double* epsilon){
+/*FUNCTION Matice::GetViscosity3d {{{*/
+void  Matice::GetViscosity3d(IssmDouble* pviscosity3d, IssmDouble* epsilon){
 
 	/*Return viscosity accounting for steady state power law creep [Thomas and MacAyeal, 1982]: 
@@ -271,12 +271,12 @@
 	
 	/*output: */
-	double viscosity3d;
+	IssmDouble viscosity3d;
 
 	/*input strain rate: */
-	double exx,eyy,exy,exz,eyz;
+	IssmDouble exx,eyy,exy,exz,eyz;
 
 	/*Intermediaries: */
-	double A,e;
-	double B,n;
+	IssmDouble A,e;
+	IssmDouble B,n;
 
 	/*Get B and n*/
@@ -291,5 +291,5 @@
 		if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) && 
 				(epsilon[3]==0) && (epsilon[4]==0)){
-			viscosity3d=0.5*pow((double)10,(double)14);
+			viscosity3d=0.5*pow((IssmDouble)10,(IssmDouble)14);
 		}
 		else{
@@ -306,5 +306,5 @@
 			if(A==0){
 				/*Maxiviscosity3dm viscosity for 0 shear areas: */
-				viscosity3d=2.25*pow((double)10,(double)17);
+				viscosity3d=2.25*pow((IssmDouble)10,(IssmDouble)17);
 			}
 			else{
@@ -317,5 +317,5 @@
 
 	/*Checks in debugging mode*/
-	if(viscosity3d<=0) _error_("Negative viscosity");
+	if(viscosity3d<=0) _error2_("Negative viscosity");
 	_assert_(B>0);
 	_assert_(n>0);
@@ -325,6 +325,6 @@
 }
 /*}}}*/
-/*FUNCTION Matice::GetViscosity3dStokes {{{1*/
-void  Matice::GetViscosity3dStokes(double* pviscosity3d, double* epsilon){
+/*FUNCTION Matice::GetViscosity3dStokes {{{*/
+void  Matice::GetViscosity3dStokes(IssmDouble* pviscosity3d, IssmDouble* epsilon){
 	/*Return viscosity accounting for steady state power law creep [Thomas and MacAyeal, 1982]: 
 	 *
@@ -341,16 +341,16 @@
 	
 	/*output: */
-	double viscosity3d;
+	IssmDouble viscosity3d;
 
 	/*input strain rate: */
-	double exx,eyy,exy,exz,eyz,ezz;
+	IssmDouble exx,eyy,exy,exz,eyz,ezz;
 
 	/*Intermediaries: */
-	double A,e;
-	double B,n;
-	double eps0;
+	IssmDouble A,e;
+	IssmDouble B,n;
+	IssmDouble eps0;
 
 	/*Get B and n*/
-	eps0=pow((double)10,(double)-27);
+	eps0=pow((IssmDouble)10,(IssmDouble)-27);
 	B=GetB();
 	n=GetN();
@@ -363,5 +363,5 @@
 		if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) && 
 				(epsilon[3]==0) && (epsilon[4]==0) && (epsilon[5]==0)){
-			viscosity3d=0.5*pow((double)10,(double)14);
+			viscosity3d=0.5*pow((IssmDouble)10,(IssmDouble)14);
 		}
 		else{
@@ -379,5 +379,5 @@
 			if(A==0){
 				/*Maxiviscosity3dm viscosity for 0 shear areas: */
-				viscosity3d=2.25*pow((double)10,(double)17);
+				viscosity3d=2.25*pow((IssmDouble)10,(IssmDouble)17);
 			}
 			else{
@@ -389,5 +389,5 @@
 
 	/*Checks in debugging mode*/
-	if(viscosity3d<=0) _error_("Negative viscosity");
+	if(viscosity3d<=0) _error2_("Negative viscosity");
 	_assert_(B>0);
 	_assert_(n>0);
@@ -397,6 +397,6 @@
 }
 /*}}}*/
-/*FUNCTION Matice::GetViscosityComplement {{{1*/
-void  Matice::GetViscosityComplement(double* pviscosity_complement, double* epsilon){
+/*FUNCTION Matice::GetViscosityComplement {{{*/
+void  Matice::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){
 	/*Return viscosity accounting for steady state power law creep [Thomas and MacAyeal, 1982]: 
 	 *
@@ -410,12 +410,12 @@
 	
 	/*output: */
-	double viscosity_complement;
+	IssmDouble viscosity_complement;
 
 	/*input strain rate: */
-	double exx,eyy,exy;
+	IssmDouble exx,eyy,exy;
 
 	/*Intermediary value A and exponent e: */
-	double A,e;
-	double B,n;
+	IssmDouble A,e;
+	IssmDouble B,n;
 
 	/*Get B and n*/
@@ -432,5 +432,5 @@
 		if(A==0){
 			/*Maximum viscosity_complement for 0 shear areas: */
-			viscosity_complement=2.25*pow((double)10,(double)17);
+			viscosity_complement=2.25*pow((IssmDouble)10,(IssmDouble)17);
 		}
 		else{
@@ -441,5 +441,5 @@
 	}
 	else{
-		viscosity_complement=4.5*pow((double)10,(double)17);
+		viscosity_complement=4.5*pow((IssmDouble)10,(IssmDouble)17);
 	}
 
@@ -453,13 +453,13 @@
 }
 /*}}}*/
-/*FUNCTION Matice::GetViscosityDerivativeEpsSquare{{{1*/
-void  Matice::GetViscosityDerivativeEpsSquare(double* pmu_prime, double* epsilon){
+/*FUNCTION Matice::GetViscosityDerivativeEpsSquare{{{*/
+void  Matice::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){
 
 	/*output: */
-	double mu_prime;
-	double mu,n,eff2;
+	IssmDouble mu_prime;
+	IssmDouble mu,n,eff2;
 
 	/*input strain rate: */
-	double exx,eyy,exy,exz,eyz;
+	IssmDouble exx,eyy,exy,exz,eyz;
 
 	/*Get visocisty and n*/
@@ -469,5 +469,5 @@
 	if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) && 
 				(epsilon[3]==0) && (epsilon[4]==0)){
-		mu_prime=0.5*pow((double)10,(double)14);
+		mu_prime=0.5*pow((IssmDouble)10,(IssmDouble)14);
 	}
 	else{
@@ -487,13 +487,13 @@
 }
 /*}}}*/
-/*FUNCTION Matice::GetViscosity2dDerivativeEpsSquare{{{1*/
-void  Matice::GetViscosity2dDerivativeEpsSquare(double* pmu_prime, double* epsilon){
+/*FUNCTION Matice::GetViscosity2dDerivativeEpsSquare{{{*/
+void  Matice::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){
 
 	/*output: */
-	double mu_prime;
-	double mu,n,eff2;
+	IssmDouble mu_prime;
+	IssmDouble mu,n,eff2;
 
 	/*input strain rate: */
-	double exx,eyy,exy,exz;
+	IssmDouble exx,eyy,exy,exz;
 
 	/*Get visocisty and n*/
@@ -502,5 +502,5 @@
 
 	if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0)){
-		mu_prime=0.5*pow((double)10,(double)14);
+		mu_prime=0.5*pow((IssmDouble)10,(IssmDouble)14);
 	}
 	else{
@@ -518,5 +518,5 @@
 }
 /*}}}*/
-/*FUNCTION Matice::InputDuplicate{{{1*/
+/*FUNCTION Matice::InputDuplicate{{{*/
 void  Matice::InputDuplicate(int original_enum,int new_enum){
 
@@ -526,6 +526,6 @@
 }
 /*}}}*/
-/*FUNCTION Matice::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
-void  Matice::InputUpdateFromVector(double* vector, int name, int type){
+/*FUNCTION Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
+void  Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type){
 
 	/*Intermediaries*/
@@ -544,28 +544,28 @@
 			switch(element->ObjectEnum()){
 
-				case TriaEnum:
-					double values[3];
+				case TriaEnum: {
+					IssmDouble values[3];
 					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexDof()];
 					this->inputs->AddInput(new TriaP1Input(name,values));
 					return;
-
-				default: _error_("element %s not implemented yet",EnumToStringx(element->ObjectEnum()));
-			}
-		default: _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
-	}
-}
-/*}}}*/
-/*FUNCTION Matice::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
+				}
+				default: _error2_("element " << EnumToStringx(element->ObjectEnum()) << " not implemented yet");
+			}
+		default: _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Matice::InputUpdateFromVector(int* vector, int name, int type) {{{*/
 void  Matice::InputUpdateFromVector(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matice::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Matice::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
 void  Matice::InputUpdateFromVector(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matice::InputUpdateFromVectorDakota(double* vector, int name, int type) {{{1*/
-void  Matice::InputUpdateFromVectorDakota(double* vector, int name, int type){
+/*FUNCTION Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type) {{{*/
+void  Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
 
 	/*Intermediaries*/
@@ -586,9 +586,9 @@
 			switch(element->ObjectEnum()){
 
-				case TriaEnum:
-					double values[3];
+				case TriaEnum: {
+					IssmDouble values[3];
 					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetSidList()]; //use sid list, to index into serial oriented vector 
 					this->inputs->AddInput(new TriaP1Input(name,values));
-					/*Special case for rheology B in 2D: Pourave land for this solution{{{2*/
+					/*Special case for rheology B in 2D: Pourave land for this solution{{{*/
 					if(name==MaterialsRheologyBEnum){
 						/*Are we in 2D?:*/
@@ -607,50 +607,50 @@
 					/*}}}*/
 					return;
-
-				default: _error_("element %s not implemented yet",EnumToStringx(element->ObjectEnum()));
-			}
-		default: _error_("type %i (%s) not implemented yet",type,EnumToStringx(type));
-	}
-
-
-
-}
-/*}}}*/
-/*FUNCTION Matice::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{1*/
-void  Matice::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols,int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matice::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{1*/
+				}
+				default: _error2_("element " << EnumToStringx(element->ObjectEnum()) << " not implemented yet");
+			}
+		default: _error2_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
+	}
+
+
+
+}
+/*}}}*/
+/*FUNCTION Matice::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{*/
+void  Matice::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matice::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{*/
 void  Matice::InputUpdateFromVectorDakota(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matice::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Matice::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{*/
 void  Matice::InputUpdateFromVectorDakota(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matice::InputUpdateFromConstant(double constant, int name) {{{1*/
-void  Matice::InputUpdateFromConstant(double constant, int name){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matice::InputUpdateFromConstant(int constant, int name) {{{1*/
+/*FUNCTION Matice::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
+void  Matice::InputUpdateFromConstant(IssmDouble constant, int name){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matice::InputUpdateFromConstant(int constant, int name) {{{*/
 void  Matice::InputUpdateFromConstant(int constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matice::InputUpdateFromConstant(bool constant, int name) {{{1*/
+/*FUNCTION Matice::InputUpdateFromConstant(bool constant, int name) {{{*/
 void  Matice::InputUpdateFromConstant(bool constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matice::InputUpdateFromSolution{{{1*/
-void  Matice::InputUpdateFromSolution(double* solution){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matice::InputUpdateFromIoModel{{{1*/
+/*FUNCTION Matice::InputUpdateFromSolution{{{*/
+void  Matice::InputUpdateFromSolution(IssmDouble* solution){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matice::InputUpdateFromIoModel{{{*/
 void Matice::InputUpdateFromIoModel(int index, IoModel* iomodel){
 
@@ -671,11 +671,11 @@
 		/*Intermediaries*/
 		const int num_vertices = 3; //Tria has 3 vertices
-		double    nodeinputs[num_vertices];
-		double    cmmininputs[num_vertices];
-		double    cmmaxinputs[num_vertices];
+		IssmDouble    nodeinputs[num_vertices];
+		IssmDouble    cmmininputs[num_vertices];
+		IssmDouble    cmmaxinputs[num_vertices];
 
 		/*Get B*/
 		if (iomodel->Data(MaterialsRheologyBEnum)) {
-			for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->Data(MaterialsRheologyBEnum)[int(iomodel->Data(MeshElementsEnum)[num_vertices*index+i]-1)];
+			for(i=0;i<num_vertices;i++) nodeinputs[i]=iomodel->Data(MaterialsRheologyBEnum)[reCast<int,IssmDouble>(iomodel->Data(MeshElementsEnum)[num_vertices*index+i]-1)];
 			this->inputs->AddInput(new TriaP1Input(MaterialsRheologyBbarEnum,nodeinputs));
 		}
@@ -713,7 +713,7 @@
 		/*Intermediaries*/
 		const int num_vertices = 6; //Penta has 6 vertices
-		double    nodeinputs[num_vertices];
-		double    cmmininputs[num_vertices];
-		double    cmmaxinputs[num_vertices];
+		IssmDouble    nodeinputs[num_vertices];
+		IssmDouble    cmmininputs[num_vertices];
+		IssmDouble    cmmaxinputs[num_vertices];
 
 		/*Get B*/
@@ -750,5 +750,5 @@
 	#endif
 	else{
-		_error_(" Mesh type not supported yet!");
+		_error2_("Mesh type not supported yet!");
 	}
 
@@ -756,5 +756,5 @@
 }
 /*}}}*/
-/*FUNCTION Matice::IsInput{{{1*/
+/*FUNCTION Matice::IsInput{{{*/
 bool Matice::IsInput(int name){
 	if (
Index: /issm/trunk/src/c/objects/Materials/Matice.h
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matice.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Materials/Matice.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Material.h"
 class IoModel;
@@ -25,10 +25,10 @@
 		Inputs*  inputs;
 
-		/*Matice constructors, destructors: {{{1*/
+		/*Matice constructors, destructors: {{{*/
 		Matice();
 		Matice(int mid,int i, IoModel* iomodel);
 		~Matice();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -38,34 +38,34 @@
 		Object* copy();
 		/*}}}*/
-		/*Update virtual functions definitions: {{{1*/
-		void  InputUpdateFromVector(double* vector, int name, int type);
+		/*Update virtual functions definitions: {{{*/
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVector(int* vector, int name, int type);
 		void  InputUpdateFromVector(bool* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(double* matrix, int nrow, int ncols, int name, int type);
-		void  InputUpdateFromVectorDakota(double* vector, int name, int type);
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(int* vector, int name, int type);
 		void  InputUpdateFromVectorDakota(bool* vector, int name, int type);
-		void  InputUpdateFromConstant(double constant, int name);
+		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
-		void  InputUpdateFromSolution(double* solution);
+		void  InputUpdateFromSolution(IssmDouble* solution);
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel);
 		/*}}}*/
-		/*Material virtual functions resolution: {{{1*/
+		/*Material virtual functions resolution: {{{*/
 		void   InputDuplicate(int original_enum,int new_enum);
 		void   Configure(Elements* elements);
 		void   GetVectorFromInputs(Vector* vector,int input_enum);
 		/*}}}*/
-		/*Matice Numerics: {{{1*/
+		/*Matice Numerics: {{{*/
 		void   SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin);
-		void   GetViscosity2d(double* pviscosity, double* pepsilon);
-		void   GetViscosity3d(double* pviscosity3d, double* pepsilon);
-		void   GetViscosity3dStokes(double* pviscosity3d, double* epsilon);
-		void   GetViscosityComplement(double* pviscosity_complement, double* pepsilon);
-		void   GetViscosityDerivativeEpsSquare(double* pmu_prime, double* pepsilon);
-		void   GetViscosity2dDerivativeEpsSquare(double* pmu_prime, double* pepsilon);
-		double GetB();
-		double GetBbar();
-		double GetN();
+		void   GetViscosity2d(IssmDouble* pviscosity, IssmDouble* pepsilon);
+		void   GetViscosity3d(IssmDouble* pviscosity3d, IssmDouble* pepsilon);
+		void   GetViscosity3dStokes(IssmDouble* pviscosity3d, IssmDouble* epsilon);
+		void   GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon);
+		void   GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
+		void   GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
+		IssmDouble GetB();
+		IssmDouble GetBbar();
+		IssmDouble GetN();
 		bool   IsInput(int name);
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Materials/Matpar.cpp
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matpar.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Materials/Matpar.cpp	(revision 12706)
@@ -17,10 +17,10 @@
 		
 /*Matpar constructors and destructor*/
-/*FUNCTION Matpar::Matpar() {{{1*/
+/*FUNCTION Matpar::Matpar() {{{*/
 Matpar::Matpar(){
 	return;
 }
-/*}}}1*/
-/*FUNCTION Matpar::Matpar(int matpar_mid,IoModel* iomodel){{{1*/
+/*}}}*/
+/*FUNCTION Matpar::Matpar(int matpar_mid,IoModel* iomodel){{{*/
 Matpar::Matpar(int matpar_mid, IoModel* iomodel){
 
@@ -46,49 +46,49 @@
 	iomodel->Constant(&this->hydro_q,HydrologyQEnum);
 }
-/*}}}1*/
-/*FUNCTION Matpar::~Matpar() {{{1*/
+/*}}}*/
+/*FUNCTION Matpar::~Matpar() {{{*/
 Matpar::~Matpar(){
 	return;
 }
-/*}}}1*/
+/*}}}*/
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Matpar::Echo {{{1*/
+/*FUNCTION Matpar::Echo {{{*/
 void Matpar::Echo(void){
 
-	printf("Matpar:\n");
-	printf("   mid: %i\n",mid);
-	printf("   rho_ice: %g\n",rho_ice);
-	printf("   rho_water: %g\n",rho_water);
-	printf("   rho_freshwater: %g\n",rho_freshwater);
-	printf("   mu_water: %g\n",mu_water);
-	printf("   heatcapacity: %g\n",heatcapacity);
-	printf("   thermalconductivity: %g\n",thermalconductivity);
-	printf("   latentheat: %g\n",latentheat);
-	printf("   beta: %g\n",beta);
-	printf("   meltingpoint: %g\n",meltingpoint);
-	printf("   referencetemperature: %g\n",referencetemperature);
-	printf("   mixed_layer_capacity: %g\n",mixed_layer_capacity);
-	printf("   thermal_exchange_velocity: %g\n",thermal_exchange_velocity);
-	printf("   g: %g\n",g);
+	_printLine_("Matpar:");
+	_printLine_("   mid: " << mid);
+	_printLine_("   rho_ice: " << rho_ice);
+	_printLine_("   rho_water: " << rho_water);
+	_printLine_("   rho_freshwater: " << rho_freshwater);
+	_printLine_("   mu_water: " << mu_water);
+	_printLine_("   heatcapacity: " << heatcapacity);
+	_printLine_("   thermalconductivity: " << thermalconductivity);
+	_printLine_("   latentheat: " << latentheat);
+	_printLine_("   beta: " << beta);
+	_printLine_("   meltingpoint: " << meltingpoint);
+	_printLine_("   referencetemperature: " << referencetemperature);
+	_printLine_("   mixed_layer_capacity: " << mixed_layer_capacity);
+	_printLine_("   thermal_exchange_velocity: " << thermal_exchange_velocity);
+	_printLine_("   g: " << g);
 	return;
 }
-/*}}}1*/
-/*FUNCTION Matpar::DeepEcho {{{1*/
+/*}}}*/
+/*FUNCTION Matpar::DeepEcho {{{*/
 void Matpar::DeepEcho(void){
 
 	this->Echo();
 }		
-/*}}}1*/
-/*FUNCTION Matpar::Id {{{1*/
+/*}}}*/
+/*FUNCTION Matpar::Id {{{*/
 int    Matpar::Id(void){ return mid; }
-/*}}}1*/
-/*FUNCTION Matpar::MyRank {{{1*/
+/*}}}*/
+/*FUNCTION Matpar::MyRank {{{*/
 int    Matpar::MyRank(void){ 
 	extern int my_rank;
 	return my_rank; 
 }
-/*}}}1*/
-/*FUNCTION Matpar::ObjectEnum{{{1*/
+/*}}}*/
+/*FUNCTION Matpar::ObjectEnum{{{*/
 int Matpar::ObjectEnum(void){
 
@@ -96,49 +96,49 @@
 
 }
-/*}}}1*/
-/*FUNCTION Matpar::copy {{{1*/
+/*}}}*/
+/*FUNCTION Matpar::copy {{{*/
 Object* Matpar::copy() {
 	return new Matpar(*this); 
 }
-/*}}}1*/
+/*}}}*/
 
 /*Update virtual functions definitions:*/
-/*FUNCTION Matpar::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
-void   Matpar::InputUpdateFromVector(double* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
+/*FUNCTION Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
+void   Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromVector(int* vector, int name, int type) {{{*/
 void   Matpar::InputUpdateFromVector(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matpar::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Matpar::InputUpdateFromVector(bool* vector, int name, int type) {{{*/
 void   Matpar::InputUpdateFromVector(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matpar::InputUpdateFromVectorDakota(double* vector, int name, int type) {{{1*/
-void   Matpar::InputUpdateFromVectorDakota(double* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{1*/
+/*FUNCTION Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type) {{{*/
+void   Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromVectorDakota(int* vector, int name, int type) {{{*/
 void   Matpar::InputUpdateFromVectorDakota(int* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matpar::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{1*/
+/*FUNCTION Matpar::InputUpdateFromVectorDakota(bool* vector, int name, int type) {{{*/
 void   Matpar::InputUpdateFromVectorDakota(bool* vector, int name, int type){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matpar::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{1*/
-void  Matpar::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols,int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromConstant(double constant, int name) {{{1*/
-void   Matpar::InputUpdateFromConstant(double constant, int name){
+/*FUNCTION Matpar::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{*/
+void  Matpar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
+void   Matpar::InputUpdateFromConstant(IssmDouble constant, int name){
 
 	switch(name){
@@ -188,16 +188,16 @@
 }
 /*}}}*/
-/*FUNCTION Matpar::InputUpdateFromConstant(int constant, int name) {{{1*/
+/*FUNCTION Matpar::InputUpdateFromConstant(int constant, int name) {{{*/
 void   Matpar::InputUpdateFromConstant(int constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matpar::InputUpdateFromConstant(bool constant, int name) {{{1*/
+/*FUNCTION Matpar::InputUpdateFromConstant(bool constant, int name) {{{*/
 void   Matpar::InputUpdateFromConstant(bool constant, int name){
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Matpar::InputUpdateFromSolution{{{1*/
-void   Matpar::InputUpdateFromSolution(double* solution){
+/*FUNCTION Matpar::InputUpdateFromSolution{{{*/
+void   Matpar::InputUpdateFromSolution(IssmDouble* solution){
 	/*Nothing updated yet*/
 }
@@ -205,5 +205,5 @@
 
 /*Matpar management: */
-/*FUNCTION Matpar::Configure {{{1*/
+/*FUNCTION Matpar::Configure {{{*/
 void  Matpar::Configure(Elements* elementsin){
 
@@ -212,107 +212,107 @@
 }
 /*}}}*/
-/*FUNCTION Matpar::GetBeta {{{1*/
-double Matpar::GetBeta(){
+/*FUNCTION Matpar::GetBeta {{{*/
+IssmDouble Matpar::GetBeta(){
 	return beta;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetG {{{1*/
-double Matpar::GetG(){
+/*}}}*/
+/*FUNCTION Matpar::GetG {{{*/
+IssmDouble Matpar::GetG(){
 	return g;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetHeatCapacity {{{1*/
-double Matpar::GetHeatCapacity(){
+/*}}}*/
+/*FUNCTION Matpar::GetHeatCapacity {{{*/
+IssmDouble Matpar::GetHeatCapacity(){
 	return heatcapacity;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetLatentHeat {{{1*/
-double Matpar::GetLatentHeat(){
+/*}}}*/
+/*FUNCTION Matpar::GetLatentHeat {{{*/
+IssmDouble Matpar::GetLatentHeat(){
 	return latentheat;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetMeltingPoint {{{1*/
-double Matpar::GetMeltingPoint(){
+/*}}}*/
+/*FUNCTION Matpar::GetMeltingPoint {{{*/
+IssmDouble Matpar::GetMeltingPoint(){
 	return meltingpoint;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetReferenceTemperature {{{1*/
-double Matpar::GetReferenceTemperature(){
+/*}}}*/
+/*FUNCTION Matpar::GetReferenceTemperature {{{*/
+IssmDouble Matpar::GetReferenceTemperature(){
 	return referencetemperature;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetMixedLayerCapacity {{{1*/
-double Matpar::GetMixedLayerCapacity(){
+/*}}}*/
+/*FUNCTION Matpar::GetMixedLayerCapacity {{{*/
+IssmDouble Matpar::GetMixedLayerCapacity(){
 	return mixed_layer_capacity;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetRhoIce {{{1*/
-double Matpar::GetRhoIce(){
+/*}}}*/
+/*FUNCTION Matpar::GetRhoIce {{{*/
+IssmDouble Matpar::GetRhoIce(){
 	
 	return rho_ice;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetRhoWater {{{1*/
-double Matpar::GetRhoWater(){
+/*}}}*/
+/*FUNCTION Matpar::GetRhoWater {{{*/
+IssmDouble Matpar::GetRhoWater(){
 	return rho_water;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetRhoFreshwater {{{1*/
-double Matpar::GetRhoFreshwater(){
+/*}}}*/
+/*FUNCTION Matpar::GetRhoFreshwater {{{*/
+IssmDouble Matpar::GetRhoFreshwater(){
 	return rho_freshwater;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetMuWater {{{1*/
-double Matpar::GetMuWater(){
+/*}}}*/
+/*FUNCTION Matpar::GetMuWater {{{*/
+IssmDouble Matpar::GetMuWater(){
 	return mu_water;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetThermalConductivity {{{1*/
-double Matpar::GetThermalConductivity(){
+/*}}}*/
+/*FUNCTION Matpar::GetThermalConductivity {{{*/
+IssmDouble Matpar::GetThermalConductivity(){
 	return thermalconductivity;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetThermalExchangeVelocity {{{1*/
-double Matpar::GetThermalExchangeVelocity(){
+/*}}}*/
+/*FUNCTION Matpar::GetThermalExchangeVelocity {{{*/
+IssmDouble Matpar::GetThermalExchangeVelocity(){
 	return thermal_exchange_velocity;
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetKn {{{1*/		 
-double Matpar::GetKn(){			 
+/*}}}*/
+/*FUNCTION Matpar::GetKn {{{*/		 
+IssmDouble Matpar::GetKn(){			 
 	return kn;		 
 }		 
-/*}}}1*/			 
-/*FUNCTION Matpar::GetHydrologyP {{{1*/			 
-double Matpar::GetHydrologyP(){		 
+/*}}}*/			 
+/*FUNCTION Matpar::GetHydrologyP {{{*/			 
+IssmDouble Matpar::GetHydrologyP(){		 
 	return hydro_p;			 
 }		 
-/*}}}1*/			 
-/*FUNCTION Matqar::GetHydrologyQ {{{1*/			 
-double Matpar::GetHydrologyQ(){		 
+/*}}}*/			 
+/*FUNCTION Matqar::GetHydrologyQ {{{*/			 
+IssmDouble Matpar::GetHydrologyQ(){		 
 	return hydro_q;			 
 }		 
-/*}}}1*/			 
-/*FUNCTION Matpar::GetHydrologyCR {{{1*/		 
-double Matpar::GetHydrologyCR(){		 
+/*}}}*/			 
+/*FUNCTION Matpar::GetHydrologyCR {{{*/		 
+IssmDouble Matpar::GetHydrologyCR(){		 
 	return hydro_CR;		 
 }		 
-/*}}}1*/			 
-/*FUNCTION Matpar::GetHydrologyN {{{1*/			 
-double Matpar::GetHydrologyN(){		 
+/*}}}*/			 
+/*FUNCTION Matpar::GetHydrologyN {{{*/			 
+IssmDouble Matpar::GetHydrologyN(){		 
 	return hydro_n;			 
 }		 
-/*}}}1*/ 
-/*FUNCTION Matpar::TMeltingPoint {{{1*/
-double Matpar::TMeltingPoint(double pressure){
+/*}}}*/ 
+/*FUNCTION Matpar::TMeltingPoint {{{*/
+IssmDouble Matpar::TMeltingPoint(IssmDouble pressure){
 	return meltingpoint-beta*pressure;
 }
-/*}}}1*/
-/*FUNCTION Matpar::PureIceEnthalpy{{{1*/
-double Matpar::PureIceEnthalpy(double pressure){
+/*}}}*/
+/*FUNCTION Matpar::PureIceEnthalpy{{{*/
+IssmDouble Matpar::PureIceEnthalpy(IssmDouble pressure){
 	return heatcapacity*(TMeltingPoint(pressure)-referencetemperature);
 }
-/*}}}1*/
-/*FUNCTION Matpar::GetEnthalpyDiffusionParameter{{{1*/
-double Matpar::GetEnthalpyDiffusionParameter(double enthalpy,double pressure){
+/*}}}*/
+/*FUNCTION Matpar::GetEnthalpyDiffusionParameter{{{*/
+IssmDouble Matpar::GetEnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){
 	if(enthalpy<PureIceEnthalpy(pressure)){
 		return thermalconductivity/(rho_ice*heatcapacity);
@@ -322,10 +322,10 @@
 	}
 }
-/*}}}1*/
-/*FUNCTION Matpar::EnthalpyToThermal {{{1*/
-void Matpar::EnthalpyToThermal(double* ptemperature,double* pwaterfraction,double enthalpy,double pressure){
+/*}}}*/
+/*FUNCTION Matpar::EnthalpyToThermal {{{*/
+void Matpar::EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure){
 
 	/*Ouput*/
-	double temperature,waterfraction;
+	IssmDouble temperature,waterfraction;
 	
 	if(enthalpy<PureIceEnthalpy(pressure)){
@@ -342,10 +342,10 @@
 	*ptemperature=temperature;
 }
-/*}}}1*/
-/*FUNCTION Matpar::ThermalToEnthalpy {{{1*/
-void Matpar::ThermalToEnthalpy(double * penthalpy,double temperature,double waterfraction,double pressure){
+/*}}}*/
+/*FUNCTION Matpar::ThermalToEnthalpy {{{*/
+void Matpar::ThermalToEnthalpy(IssmDouble * penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){
 
 	/*Ouput*/
-	double enthalpy;
+	IssmDouble enthalpy;
 	
 	if(temperature<TMeltingPoint(pressure)){
@@ -359,3 +359,3 @@
 	*penthalpy=enthalpy;
 }
-/*}}}1*/
+/*}}}*/
Index: /issm/trunk/src/c/objects/Materials/Matpar.h
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matpar.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Materials/Matpar.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Material.h"
 class IoModel;
@@ -16,24 +16,24 @@
 	private: 
 		int	  mid;
-		double  rho_ice; 
-		double  rho_water;
-		double  rho_freshwater;
-		double  mu_water;
-		double  heatcapacity;
-		double  thermalconductivity;
-		double  latentheat;
-		double  beta;
-		double  meltingpoint;
-		double  referencetemperature;
-		double  mixed_layer_capacity;
-		double  thermal_exchange_velocity;
-		double  g;
+		IssmDouble  rho_ice; 
+		IssmDouble  rho_water;
+		IssmDouble  rho_freshwater;
+		IssmDouble  mu_water;
+		IssmDouble  heatcapacity;
+		IssmDouble  thermalconductivity;
+		IssmDouble  latentheat;
+		IssmDouble  beta;
+		IssmDouble  meltingpoint;
+		IssmDouble  referencetemperature;
+		IssmDouble  mixed_layer_capacity;
+		IssmDouble  thermal_exchange_velocity;
+		IssmDouble  g;
 
 		/*hydrology: */		 
-		double  kn;			 
-		double  hydro_p;		 
-		double  hydro_q;		 
-		double  hydro_CR;			 
-		double  hydro_n; 
+		IssmDouble  kn;			 
+		IssmDouble  hydro_p;		 
+		IssmDouble  hydro_q;		 
+		IssmDouble  hydro_CR;			 
+		IssmDouble  hydro_n; 
 
 	public:
@@ -42,5 +42,5 @@
 		~Matpar();
 
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -50,47 +50,47 @@
 		Object* copy();
 		/*}}}*/
-		/*Update virtual functions resolution: {{{1*/
-		void   InputUpdateFromVector(double* vector, int name, int type);
+		/*Update virtual functions resolution: {{{*/
+		void   InputUpdateFromVector(IssmDouble* vector, int name, int type);
 		void   InputUpdateFromVector(int* vector, int name, int type);
 		void   InputUpdateFromVector(bool* vector, int name, int type);
-		void   InputUpdateFromMatrixDakota(double* matrix,int nrows,int ncols, int name, int type);
-		void   InputUpdateFromVectorDakota(double* vector, int name, int type);
+		void   InputUpdateFromMatrixDakota(IssmDouble* matrix,int nrows,int ncols, int name, int type);
+		void   InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void   InputUpdateFromVectorDakota(int* vector, int name, int type);
 		void   InputUpdateFromVectorDakota(bool* vector, int name, int type);
-		void   InputUpdateFromConstant(double constant, int name);
+		void   InputUpdateFromConstant(IssmDouble constant, int name);
 		void   InputUpdateFromConstant(int constant, int name);
 		void   InputUpdateFromConstant(bool constant, int name);
-		void   InputUpdateFromSolution(double* solution);
-		void   InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		void   InputUpdateFromSolution(IssmDouble* solution);
+		void   InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("not implemented yet");};
 		/*}}}*/
-		/*Material virtual functions resolution: {{{1*/
-		void   InputDuplicate(int original_enum,int new_enum){_error_("not implemented yet");};
+		/*Material virtual functions resolution: {{{*/
+		void   InputDuplicate(int original_enum,int new_enum){_error2_("not implemented yet");};
 		void   Configure(Elements* elements);
 		void   GetVectorFromInputs(Vector* vector,int input_enum){return;}
 		/*}}}*/
-		/*Numerics: {{{1*/
-		double GetG();
-		double GetRhoIce();
-		double GetRhoWater();
-		double GetRhoFreshwater();
-		double GetMuWater();
-		double GetMixedLayerCapacity();
-		double GetThermalExchangeVelocity();
-		double GetHeatCapacity();
-		double GetThermalConductivity();
-		double GetLatentHeat();
-		double GetBeta();
-		double GetMeltingPoint();
-		double GetReferenceTemperature();
-		double GetKn();
-		double GetHydrologyP();
-		double GetHydrologyQ();
-		double GetHydrologyCR();
-		double GetHydrologyN();
-		double TMeltingPoint(double pressure);
-		double PureIceEnthalpy(double pressure);
-		double GetEnthalpyDiffusionParameter(double enthalpy,double pressure);
-		void   EnthalpyToThermal(double* ptemperature,double* pwaterfraction,double enthalpy,double pressure);
-		void   ThermalToEnthalpy(double* penthalpy,double temperature,double waterfraction,double pressure);
+		/*Numerics: {{{*/
+		IssmDouble GetG();
+		IssmDouble GetRhoIce();
+		IssmDouble GetRhoWater();
+		IssmDouble GetRhoFreshwater();
+		IssmDouble GetMuWater();
+		IssmDouble GetMixedLayerCapacity();
+		IssmDouble GetThermalExchangeVelocity();
+		IssmDouble GetHeatCapacity();
+		IssmDouble GetThermalConductivity();
+		IssmDouble GetLatentHeat();
+		IssmDouble GetBeta();
+		IssmDouble GetMeltingPoint();
+		IssmDouble GetReferenceTemperature();
+		IssmDouble GetKn();
+		IssmDouble GetHydrologyP();
+		IssmDouble GetHydrologyQ();
+		IssmDouble GetHydrologyCR();
+		IssmDouble GetHydrologyN();
+		IssmDouble TMeltingPoint(IssmDouble pressure);
+		IssmDouble PureIceEnthalpy(IssmDouble pressure);
+		IssmDouble GetEnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure);
+		void   EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure);
+		void   ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Node.cpp
===================================================================
--- /issm/trunk/src/c/objects/Node.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Node.cpp	(revision 12706)
@@ -3,5 +3,5 @@
  */
 
-/*Include files: {{{1*/
+/*Include files: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Node constructors and destructors:*/
-/*FUNCTION Node::Node() default constructor {{{1*/
+/*FUNCTION Node::Node() default constructor {{{*/
 Node::Node(){
 		 this->inputs=NULL;
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::Node(int node_id,int node_sid,int vertex_id,int io_index, IoModel* iomodel,int analysis_type) {{{1*/
+/*FUNCTION Node::Node(int node_id,int node_sid,int vertex_id,int io_index, IoModel* iomodel,int analysis_type) {{{*/
 Node::Node(int node_id,int node_sid,int vertex_id,int io_index, IoModel* iomodel,int analysis_type){
 
@@ -58,19 +58,18 @@
 	this->inputs=new Inputs();
 	if (iomodel->Data(MeshVertexonbedEnum))
-	 this->inputs->AddInput(new BoolInput(MeshVertexonbedEnum,(IssmBool)iomodel->Data(MeshVertexonbedEnum)[io_index]));
+	 this->inputs->AddInput(new BoolInput(MeshVertexonbedEnum,reCast<IssmBool>(iomodel->Data(MeshVertexonbedEnum)[io_index])));
 	if (iomodel->Data(MeshVertexonsurfaceEnum))
-	 this->inputs->AddInput(new BoolInput(MeshVertexonsurfaceEnum,(IssmBool)iomodel->Data(MeshVertexonsurfaceEnum)[io_index]));
+	 this->inputs->AddInput(new BoolInput(MeshVertexonsurfaceEnum,reCast<IssmBool>(iomodel->Data(MeshVertexonsurfaceEnum)[io_index])));
 	if (iomodel->Data(MaskVertexonfloatingiceEnum))
-	 this->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,(IssmBool)iomodel->Data(MaskVertexonfloatingiceEnum)[io_index]));
+	 this->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,reCast<IssmBool>(iomodel->Data(MaskVertexonfloatingiceEnum)[io_index])));
 	if (iomodel->Data(MaskVertexongroundediceEnum))
-	 this->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,(IssmBool)iomodel->Data(MaskVertexongroundediceEnum)[io_index]));
+	  this->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,reCast<IssmBool>(iomodel->Data(MaskVertexongroundediceEnum)[io_index])));
 	if (analysis_type==DiagnosticHorizAnalysisEnum)
-	 this->inputs->AddInput(new IntInput(ApproximationEnum,(IssmInt)iomodel->Data(FlowequationVertexEquationEnum)[io_index]));
-	
+	 this->inputs->AddInput(new IntInput(ApproximationEnum,reCast<IssmInt>(iomodel->Data(FlowequationVertexEquationEnum)[io_index])));
 	/*set single point constraints: */
 
 	/*spc all nodes on water*/
-	if (!iomodel->Data(MaskVertexonwaterEnum)) _error_("iomodel->nodeonwater is NULL");
-	if (iomodel->Data(MaskVertexonwaterEnum)[io_index]){
+	if (!iomodel->Data(MaskVertexonwaterEnum)) _error2_("iomodel->nodeonwater is NULL");
+	if (reCast<IssmBool>(iomodel->Data(MaskVertexonwaterEnum)[io_index])){
 		for(k=1;k<=gsize;k++){
 			this->FreezeDof(k);
@@ -115,7 +114,7 @@
 	/*Diagnostic Hutter*/
 	if (analysis_type==DiagnosticHutterAnalysisEnum){
-		if (!iomodel->Data(FlowequationVertexEquationEnum)) _error_("iomodel->vertices_type is NULL");
+		if (!iomodel->Data(FlowequationVertexEquationEnum)) _error2_("iomodel->vertices_type is NULL");
 		/*Constrain all nodes that are not Hutter*/
-		if (!iomodel->Data(FlowequationVertexEquationEnum)[io_index]==HutterApproximationEnum){
+		if (reCast<int>(iomodel->Data(FlowequationVertexEquationEnum)[io_index])!=HutterApproximationEnum){
 			for(k=1;k<=gsize;k++){
 				this->FreezeDof(k);
@@ -135,5 +134,5 @@
 			/*On a 3d mesh, we may have collapsed elements, hence dead nodes. Freeze them out: */
 			_assert_(iomodel->Data(MeshVertexonbedEnum));
-			if (!iomodel->Data(MeshVertexonbedEnum)[io_index]){
+			if (!(reCast<IssmBool>(iomodel->Data(MeshVertexonbedEnum)[io_index]))){
 				for(k=1;k<=gsize;k++){
 					this->FreezeDof(k);
@@ -145,5 +144,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::~Node(){{{1*/
+/*FUNCTION Node::~Node(){{{*/
 Node::~Node(){
 	delete inputs;
@@ -154,37 +153,37 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Node::Echo{{{1*/
+/*FUNCTION Node::Echo{{{*/
 void Node::Echo(void){
 
-	printf("Node:\n");
-	printf("   id: %i\n",id);
-	printf("   sid: %i\n",sid);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Node:");
+	_printLine_("   id: " << id);
+	_printLine_("   sid: " << sid);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	indexing.Echo();
-	printf("   hvertex:     not displayed\n");
-	printf("   inputs:      %p\n",inputs);
-
-
-}
-/*}}}*/
-/*FUNCTION Node::DeepEcho{{{1*/
+	_printLine_("   hvertex:     not displayed");
+	_printLine_("   inputs:      " << inputs);
+
+
+}
+/*}}}*/
+/*FUNCTION Node::DeepEcho{{{*/
 void Node::DeepEcho(void){
 
-	printf("Node:\n");
-	printf("   id: %i\n",id);
-	printf("   sid: %i\n",sid);
-	printf("   analysis_type: %s\n",EnumToStringx(analysis_type));
+	_printLine_("Node:");
+	_printLine_("   id: " << id);
+	_printLine_("   sid: " << sid);
+	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	indexing.DeepEcho();
-	printf("Vertex:\n");
+	_printLine_("Vertex:");
 	hvertex->DeepEcho();
-	printf("   inputs\n");
-
-
-}
-/*}}}*/
-/*FUNCTION Node::Id{{{1*/
+	_printLine_("   inputs");
+
+
+}
+/*}}}*/
+/*FUNCTION Node::Id{{{*/
 int    Node::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Node::MyRank{{{1*/
+/*FUNCTION Node::MyRank{{{*/
 int    Node::MyRank(void){ 
 	extern int my_rank;
@@ -193,5 +192,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::ObjectEnum{{{1*/
+/*FUNCTION Node::ObjectEnum{{{*/
 int Node::ObjectEnum(void){
 
@@ -202,5 +201,5 @@
 
 /*Node management:*/
-/*FUNCTION Node::Configure {{{1*/
+/*FUNCTION Node::Configure {{{*/
 void  Node::Configure(DataSet* nodesin,Vertices* verticesin){
 
@@ -212,9 +211,9 @@
 
 }
-/*FUNCTION Node::SetCurrentConfiguration {{{1*/
+/*FUNCTION Node::SetCurrentConfiguration {{{*/
 void  Node::SetCurrentConfiguration(DataSet* nodesin,Vertices* verticesin){
 
 }
-/*FUNCTION Node::GetDof {{{1*/
+/*FUNCTION Node::GetDof {{{*/
 int   Node::GetDof(int dofindex,int setenum){
 
@@ -231,9 +230,9 @@
 		return indexing.sdoflist[dofindex];
 	}
-	else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
-
-}
-/*}}}*/
-/*FUNCTION Node::GetDofList1{{{1*/
+	else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+
+}
+/*}}}*/
+/*FUNCTION Node::GetDofList1{{{*/
 int  Node::GetDofList1(void){
 
@@ -245,5 +244,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetDofList{{{1*/
+/*FUNCTION Node::GetDofList{{{*/
 void  Node::GetDofList(int* outdoflist,int approximation_enum,int setenum){
 	int i;
@@ -303,9 +302,9 @@
 			else for(i=0;i<this->indexing.ssize;i++) outdoflist[i]=indexing.sdoflist[i];
 		}
-		else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
-	}
-}
-/*}}}*/
-/*FUNCTION Node::GetSidList{{{1*/
+		else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+	}
+}
+/*}}}*/
+/*FUNCTION Node::GetSidList{{{*/
 int  Node::GetSidList(void){
 
@@ -317,5 +316,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetLocalDofList{{{1*/
+/*FUNCTION Node::GetLocalDofList{{{*/
 void  Node::GetLocalDofList(int* outdoflist,int approximation_enum,int setenum){
 	int i;
@@ -343,5 +342,5 @@
 			}
 		}
-		else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
+		else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
 	}
 	else{
@@ -412,12 +411,12 @@
 			}
 		}
-		else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
-	}
-}
-/*}}}*/
-/*FUNCTION Node::Sid{{{1*/
+		else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+	}
+}
+/*}}}*/
+/*FUNCTION Node::Sid{{{*/
 int    Node::Sid(void){ return sid; }
 /*}}}*/
-/*FUNCTION Node::GetVertexId {{{1*/
+/*FUNCTION Node::GetVertexId {{{*/
 int   Node::GetVertexId(void){
 
@@ -428,5 +427,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetVertexDof {{{1*/
+/*FUNCTION Node::GetVertexDof {{{*/
 int   Node::GetVertexDof(void){
 
@@ -438,6 +437,6 @@
 /*}}}*/
 #ifdef _HAVE_DIAGNOSTIC_
-/*FUNCTION Node::GetCoordinateSystem{{{1*/
-void Node::GetCoordinateSystem(double* coord_system_out){
+/*FUNCTION Node::GetCoordinateSystem{{{*/
+void Node::GetCoordinateSystem(IssmDouble* coord_system_out){
 
 	/*Copy coord_system*/
@@ -447,5 +446,5 @@
 /*}}}*/
 #endif
-/*FUNCTION Node::SetVertexDof {{{1*/
+/*FUNCTION Node::SetVertexDof {{{*/
 void   Node::SetVertexDof(int in_dof){
 
@@ -457,5 +456,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::InAnalysis{{{1*/
+/*FUNCTION Node::InAnalysis{{{*/
 bool Node::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type) return true;
@@ -465,6 +464,6 @@
 
 /*Node numerics:*/
-/*FUNCTION Node::ApplyConstraints{{{1*/
-void  Node::ApplyConstraint(int dof,double value){
+/*FUNCTION Node::ApplyConstraints{{{*/
+void  Node::ApplyConstraint(int dof,IssmDouble value){
 
 	int index;
@@ -476,5 +475,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::RelaxConstraint{{{1*/
+/*FUNCTION Node::RelaxConstraint{{{*/
 void  Node::RelaxConstraint(int dof){
 
@@ -484,9 +483,9 @@
 }
 /*}}}*/
-/*FUNCTION Node::CreateVecSets {{{1*/
+/*FUNCTION Node::CreateVecSets {{{*/
 void  Node::CreateVecSets(Vector* pv_g,Vector* pv_f,Vector* pv_s){
 
-	double gvalue=1.0; //all nodes are in the g set;
-	double value;
+	IssmDouble gvalue=1.0; //all nodes are in the g set;
+	IssmDouble value;
 
 	int i;
@@ -498,9 +497,9 @@
 		
 		/*f set: */
-		value=(double)this->indexing.f_set[i];
+		value=(IssmDouble)this->indexing.f_set[i];
 		pv_f->SetValue(indexing.gdoflist[i],value,INS_VAL);
 
 		/*s set: */
-		value=(double)this->indexing.s_set[i];
+		value=(IssmDouble)this->indexing.s_set[i];
 		pv_s->SetValue(indexing.gdoflist[i],value,INS_VAL);
 
@@ -510,19 +509,19 @@
 }
 /*}}}*/
-/*FUNCTION Node::CreateNodalConstraints{{{1*/
+/*FUNCTION Node::CreateNodalConstraints{{{*/
 void  Node::CreateNodalConstraints(Vector* ys){
 
 	int i;
-	double* values=NULL;
+	IssmDouble* values=NULL;
 	int count;
 
 	/*Recover values for s set and plug them in constraints vector: */
 	if(this->indexing.ssize){
-		values=(double*)xmalloc(this->indexing.ssize*sizeof(double));
+		values=xNew<IssmDouble>(this->indexing.ssize);
 		count=0;
 		for(i=0;i<this->indexing.gsize;i++){
 			if(this->indexing.s_set[i]){
 				values[count]=this->indexing.svalues[i];
-				_assert_(!isnan(values[count]));
+				_assert_(!xIsNan<IssmDouble>(values[count]));
 				count++;
 			}
@@ -534,10 +533,10 @@
 
 	/*Free ressources:*/
-	xfree((void**)&values);
-
-
-}
-/*}}}*/
-/*FUNCTION Node::DofInSSet {{{1*/
+	xDelete<IssmDouble>(values);
+
+
+}
+/*}}}*/
+/*FUNCTION Node::DofInSSet {{{*/
 void  Node::DofInSSet(int dof){
 
@@ -549,5 +548,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::DofInFSet {{{1*/
+/*FUNCTION Node::DofInFSet {{{*/
 void  Node::DofInFSet(int dof){
 
@@ -559,5 +558,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::FreezeDof{{{1*/
+/*FUNCTION Node::FreezeDof{{{*/
 void  Node::FreezeDof(int dof){
 	
@@ -566,5 +565,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetApproximation {{{1*/
+/*FUNCTION Node::GetApproximation {{{*/
 int   Node::GetApproximation(){
 
@@ -577,5 +576,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetConnectivity {{{1*/
+/*FUNCTION Node::GetConnectivity {{{*/
 int Node::GetConnectivity(){
 
@@ -585,5 +584,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetNumberOfDofs{{{1*/
+/*FUNCTION Node::GetNumberOfDofs{{{*/
 int   Node::GetNumberOfDofs(int approximation_enum,int setenum){
 
@@ -598,5 +597,5 @@
 		else if (setenum==FsetEnum) numdofs=this->indexing.fsize;
 		else if (setenum==SsetEnum) numdofs=this->indexing.ssize;
-		else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
+		else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
 	}
 	else{
@@ -628,11 +627,11 @@
 			else numdofs=this->indexing.ssize;
 		}
-		else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
+		else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
 	}
 	return numdofs;
 }
 /*}}}*/
-/*FUNCTION Node::GetSigma {{{1*/
-double Node::GetSigma(){
+/*FUNCTION Node::GetSigma {{{*/
+IssmDouble Node::GetSigma(){
 	Vertex* vertex=NULL;
 
@@ -641,6 +640,6 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetX {{{1*/
-double Node::GetX(){
+/*FUNCTION Node::GetX {{{*/
+IssmDouble Node::GetX(){
 	Vertex* vertex=NULL;
 
@@ -649,6 +648,6 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetY {{{1*/
-double Node::GetY(){
+/*FUNCTION Node::GetY {{{*/
+IssmDouble Node::GetY(){
 	Vertex* vertex=NULL;
 
@@ -657,6 +656,6 @@
 }
 /*}}}*/
-/*FUNCTION Node::GetZ {{{1*/
-double Node::GetZ(){
+/*FUNCTION Node::GetZ {{{*/
+IssmDouble Node::GetZ(){
 	Vertex* vertex=NULL;
 
@@ -665,5 +664,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::IsClone {{{1*/
+/*FUNCTION Node::IsClone {{{*/
 int   Node::IsClone(){
 	
@@ -672,5 +671,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::IsOnBed {{{1*/
+/*FUNCTION Node::IsOnBed {{{*/
 int   Node::IsOnBed(){
 
@@ -683,5 +682,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::IsGrounded {{{1*/
+/*FUNCTION Node::IsGrounded {{{*/
 int   Node::IsGrounded(){
 
@@ -694,5 +693,5 @@
 }		
 /*}}}*/
-/*FUNCTION Node::IsFloating {{{1*/
+/*FUNCTION Node::IsFloating {{{*/
 int   Node::IsFloating(){
 	
@@ -705,5 +704,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::IsOnSurface {{{1*/
+/*FUNCTION Node::IsOnSurface {{{*/
 int   Node::IsOnSurface(){
 
@@ -716,11 +715,11 @@
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromVector(double* vector, int name, int type){{{1*/
-void  Node::InputUpdateFromVector(double* vector, int name, int type){
+/*FUNCTION Node::InputUpdateFromVector(IssmDouble* vector, int name, int type){{{*/
+void  Node::InputUpdateFromVector(IssmDouble* vector, int name, int type){
 
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromVector(int* vector, int name, int type){{{1*/
+/*FUNCTION Node::InputUpdateFromVector(int* vector, int name, int type){{{*/
 void  Node::InputUpdateFromVector(int* vector, int name, int type){
 
@@ -728,5 +727,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromVector(bool* vector, int name, int type){{{1*/
+/*FUNCTION Node::InputUpdateFromVector(bool* vector, int name, int type){{{*/
 void  Node::InputUpdateFromVector(bool* vector, int name, int type){
 
@@ -734,17 +733,17 @@
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromVectorDakota(double* vector, int name, int type){{{1*/
-void  Node::InputUpdateFromVectorDakota(double* vector, int name, int type){
+/*FUNCTION Node::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){{{*/
+void  Node::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
 
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){{{1*/
-void  Node::InputUpdateFromMatrixDakota(double* matrix, int nrows, int ncols, int name, int type){
+/*FUNCTION Node::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){{{*/
+void  Node::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
 
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromVectorDakota(int* vector, int name, int type){{{1*/
+/*FUNCTION Node::InputUpdateFromVectorDakota(int* vector, int name, int type){{{*/
 void  Node::InputUpdateFromVectorDakota(int* vector, int name, int type){
 
@@ -752,5 +751,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromVectorDakota(bool* vector, int name, int type){{{1*/
+/*FUNCTION Node::InputUpdateFromVectorDakota(bool* vector, int name, int type){{{*/
 void  Node::InputUpdateFromVectorDakota(bool* vector, int name, int type){
 
@@ -758,11 +757,11 @@
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromConstant(double constant, int name){{{1*/
-void  Node::InputUpdateFromConstant(double constant, int name){
+/*FUNCTION Node::InputUpdateFromConstant(IssmDouble constant, int name){{{*/
+void  Node::InputUpdateFromConstant(IssmDouble constant, int name){
 
 	/*Nothing updated yet*/
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromConstant(int constant, int name){{{1*/
+/*FUNCTION Node::InputUpdateFromConstant(int constant, int name){{{*/
 void  Node::InputUpdateFromConstant(int constant, int name){
 
@@ -770,5 +769,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::InputUpdateFromConstant(bool constant, int name){{{1*/
+/*FUNCTION Node::InputUpdateFromConstant(bool constant, int name){{{*/
 void  Node::InputUpdateFromConstant(bool constant, int name){
 
@@ -776,6 +775,6 @@
 }
 /*}}}*/
-/*FUNCTION Node::UpdateSpcs {{{1*/
-void   Node::UpdateSpcs(double* ys){
+/*FUNCTION Node::UpdateSpcs {{{*/
+void   Node::UpdateSpcs(IssmDouble* ys){
 
 	int     count=0;
@@ -791,8 +790,8 @@
 }
 /*}}}*/
-/*FUNCTION Node::VecMerge {{{1*/
-void   Node::VecMerge(Vector* ug, double* vector_serial,int setenum){
-
-	double* values=NULL;
+/*FUNCTION Node::VecMerge {{{*/
+void   Node::VecMerge(Vector* ug, IssmDouble* vector_serial,int setenum){
+
+	IssmDouble* values=NULL;
 	int*    indices=NULL;
 	int     count=0;
@@ -801,6 +800,6 @@
 	if(setenum==FsetEnum){
 		if(this->indexing.fsize){
-			indices=(int*)xmalloc(this->indexing.fsize*sizeof(int));
-			values=(double*)xmalloc(this->indexing.fsize*sizeof(double));
+			indices=xNew<int>(this->indexing.fsize);
+ 			values=xNew<IssmDouble>(this->indexing.fsize);
 
 			for(i=0;i<this->indexing.gsize;i++){
@@ -819,6 +818,6 @@
 	else if(setenum==SsetEnum){
 		if(this->indexing.ssize){
-			indices=(int*)xmalloc(this->indexing.ssize*sizeof(int));
-			values=(double*)xmalloc(this->indexing.ssize*sizeof(double));
+			indices=xNew<int>(this->indexing.ssize);
+			values=xNew<IssmDouble>(this->indexing.ssize);
 
 			for(i=0;i<this->indexing.gsize;i++){
@@ -835,15 +834,15 @@
 		}
 	}
-	else _error_("VecMerge can only merge from the s or f-set onto the g-set!");
+	else _error2_("VecMerge can only merge from the s or f-set onto the g-set!");
 
 	/*Free ressources:*/
-	xfree((void**)&values);
-	xfree((void**)&indices);
-}
-/*}}}*/
-/*FUNCTION Node::VecReduce {{{1*/
-void   Node::VecReduce(Vector* vector, double* ug_serial,int setenum){
-
-	double* values=NULL;
+	xDelete<IssmDouble>(values);
+	xDelete<int>(indices);
+}
+/*}}}*/
+/*FUNCTION Node::VecReduce {{{*/
+void   Node::VecReduce(Vector* vector, IssmDouble* ug_serial,int setenum){
+
+	IssmDouble* values=NULL;
 	int     count=0;
 	int     i;
@@ -851,5 +850,5 @@
 	if(setenum==FsetEnum){
 		if(this->indexing.fsize){
-			values=(double*)xmalloc(this->indexing.fsize*sizeof(double));
+ 			values=xNew<IssmDouble>(this->indexing.fsize);
 
 			for(i=0;i<this->indexing.gsize;i++){
@@ -867,5 +866,5 @@
 	else if(setenum==SsetEnum){
 		if(this->indexing.ssize){
-			values=(double*)xmalloc(this->indexing.ssize*sizeof(double));
+			values=xNew<IssmDouble>(this->indexing.ssize);
 
 			for(i=0;i<this->indexing.gsize;i++){
@@ -881,13 +880,13 @@
 		}
 	}
-	else _error_("VecReduce can only merge from the s or f-set onto the g-set!");
+	else _error2_("VecReduce can only merge from the s or f-set onto the g-set!");
 
 	/*Free ressources:*/
-	xfree((void**)&values);
+	xDelete<IssmDouble>(values);
 }
 /*}}}*/
 
 /* DofObject routines:*/
-/*FUNCTION Node::DistributeDofs{{{1*/
+/*FUNCTION Node::DistributeDofs{{{*/
 void  Node::DistributeDofs(int* pdofcount,int setenum){
 
@@ -928,5 +927,5 @@
 		dofcount+=this->indexing.ssize;
 	}
-	else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
+	else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
 
 
@@ -936,5 +935,5 @@
 }
 /*}}}*/
-/*FUNCTION Node::Off_setDofs{{{1*/
+/*FUNCTION Node::Off_setDofs{{{*/
 void  Node::OffsetDofs(int dofcount,int setenum){
 	
@@ -957,8 +956,8 @@
 		for(i=0;i<this->indexing.ssize;i++) indexing.sdoflist[i]+=dofcount;
 	}
-	else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
-}
-/*}}}*/
-/*FUNCTION Node::ShowTrueDofs{{{1*/
+	else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Node::ShowTrueDofs{{{*/
 void  Node::ShowTrueDofs(int* truedofs, int ncols,int setenum){
 
@@ -973,9 +972,9 @@
 	else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++)  *(truedofs+ncols*sid+j)=indexing.fdoflist[j];
 	else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++)  *(truedofs+ncols*sid+j)=indexing.sdoflist[j];
-	else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
-
-}
-/*}}}*/
-/*FUNCTION Node::UpdateCloneDofs{{{1*/
+	else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+
+}
+/*}}}*/
+/*FUNCTION Node::UpdateCloneDofs{{{*/
 void  Node::UpdateCloneDofs(int* alltruedofs,int ncols,int setenum){
 
@@ -992,9 +991,9 @@
 	else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++) indexing.fdoflist[j]=*(alltruedofs+ncols*sid+j);
 	else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++) indexing.sdoflist[j]=*(alltruedofs+ncols*sid+j);
-	else _error_("%s%s%s"," set of enum type ",EnumToStringx(setenum)," not supported yet!");
-
-}
-/*}}}*/
-/*FUNCTION Node::SetClone {{{1*/
+	else _error2_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+
+}
+/*}}}*/
+/*FUNCTION Node::SetClone {{{*/
 void  Node::SetClone(int* minranks){
 
Index: /issm/trunk/src/c/objects/Node.h
===================================================================
--- /issm/trunk/src/c/objects/Node.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Node.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Object.h"
 #include "../shared/shared.h"
@@ -34,10 +34,10 @@
 		IssmDouble         coord_system[3][3];
 
-		/*Node constructors, destructors {{{1*/
+		/*Node constructors, destructors {{{*/
 		Node();
 		Node(int node_id,int node_sid, int vertex_id,int io_index, IoModel* iomodel,int analysis_type);
 		~Node();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -45,7 +45,7 @@
 		int   MyRank();
 		int   ObjectEnum();
-		Object* copy(){_error_("Not implemented yet (similar to Elements)");};
+		Object* copy(){_error2_("Not implemented yet (similar to Elements)");};
 		/*}}}*/
-		/*Update virtual functions definitions: {{{1*/
+		/*Update virtual functions definitions: {{{*/
 		
 		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
@@ -59,8 +59,8 @@
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
-		void  InputUpdateFromSolution(IssmDouble* solution){_error_("Not implemented yet!");}
-		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("Not implemented yet!");}
+		void  InputUpdateFromSolution(IssmDouble* solution){_error2_("Not implemented yet!");}
+		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error2_("Not implemented yet!");}
 		/*}}}*/
-		/*Node numerical routines {{{1*/
+		/*Node numerical routines {{{*/
 		void   Configure(DataSet* nodes,Vertices* vertices);
 		void   CreateNodalConstraints(Vector* ys);
@@ -102,5 +102,5 @@
 		
 		/*}}}*/
-		/*Dof Object routines {{{1*/
+		/*Dof Object routines {{{*/
 		void  DistributeDofs(int* pdofcount,int setenum);
 		void  OffsetDofs(int dofcount,int setenum);
Index: /issm/trunk/src/c/objects/Numerics/ElementMatrix.cpp
===================================================================
--- /issm/trunk/src/c/objects/Numerics/ElementMatrix.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Numerics/ElementMatrix.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,5 +20,5 @@
 
 /*ElementMatrix constructors and destructor*/
-/*FUNCTION ElementMatrix::ElementMatrix(){{{1*/
+/*FUNCTION ElementMatrix::ElementMatrix(){{{*/
 ElementMatrix::ElementMatrix(){
 
@@ -44,13 +44,13 @@
 }
 /*}}}*/
-/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke){{{1*/
+/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke){{{*/
 ElementMatrix::ElementMatrix(ElementMatrix* Ke){
 
-	if(!Ke) _error_("Input Element Matrix is a NULL pointer");
+	if(!Ke) _error2_("Input Element Matrix is a NULL pointer");
 	this->Init(Ke);
 	return;
 }
 /*}}}*/
-/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2){{{1*/
+/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2){{{*/
 ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2){
 
@@ -63,5 +63,5 @@
 	/*If one of the two matrix is NULL, we copy the other one*/
 	if(!Ke1 && !Ke2){
-		_error_("Two input element matrices are NULL");
+		_error2_("Two input element matrices are NULL");
 	}
 	else if(!Ke1){
@@ -75,8 +75,8 @@
 
 	/*General Case: Ke1 and Ke2 are not empty*/
-	if(!Ke1->dofsymmetrical || !Ke2->dofsymmetrical) _error_("merging 2 non dofsymmetrical matrices not implemented yet");
+	if(!Ke1->dofsymmetrical || !Ke2->dofsymmetrical) _error2_("merging 2 non dofsymmetrical matrices not implemented yet");
 
 	/*Initialize itransformation matrix Ke[P[i]] = Ke2[i]*/
-	P=(int*)xmalloc(Ke2->nrows*sizeof(int));
+	P=xNew<int>(Ke2->nrows);
 
 	/*1: Get the new numbering of Ke2 and get size of the new matrix*/
@@ -100,6 +100,6 @@
 
 	/*Gset and values*/
-	this->gglobaldoflist=(int*)xmalloc(this->nrows*sizeof(int));
-	this->values=(double*)xcalloc(this->nrows*this->ncols,sizeof(double));
+	this->gglobaldoflist=xNew<int>(this->nrows);
+	this->values=xNewZeroInit<IssmDouble>(this->nrows*this->ncols);
 	for(i=0;i<Ke1->nrows;i++){
 		for(j=0;j<Ke1->ncols;j++){
@@ -122,6 +122,6 @@
 	this->row_fsize=fsize;
 	if(fsize){
-		this->row_flocaldoflist =(int*)xmalloc(fsize*sizeof(int));
-		this->row_fglobaldoflist=(int*)xmalloc(fsize*sizeof(int));
+		this->row_flocaldoflist =xNew<int>(fsize);
+		this->row_fglobaldoflist=xNew<int>(fsize);
 		for(i=0;i<Ke1->row_fsize;i++){
 			this->row_flocaldoflist[i] =Ke1->row_flocaldoflist[i];
@@ -149,6 +149,6 @@
 	this->row_ssize=ssize;
 	if(ssize){
-		this->row_slocaldoflist =(int*)xmalloc(ssize*sizeof(int));
-		this->row_sglobaldoflist=(int*)xmalloc(ssize*sizeof(int));
+		this->row_slocaldoflist =xNew<int>(ssize);
+		this->row_sglobaldoflist=xNew<int>(ssize);
 		for(i=0;i<Ke1->row_ssize;i++){
 			this->row_slocaldoflist[i] =Ke1->row_slocaldoflist[i];
@@ -178,8 +178,8 @@
 
 	/*clean-up*/
-	xfree((void**)&P);
-}
-/*}}}*/
-/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2,ElementMatrix* Ke3){{{1*/
+	xDelete<int>(P);
+}
+/*}}}*/
+/*FUNCTION ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2,ElementMatrix* Ke3){{{*/
 ElementMatrix::ElementMatrix(ElementMatrix* Ke1, ElementMatrix* Ke2,ElementMatrix* Ke3){
 
@@ -196,5 +196,5 @@
 }
 /*}}}*/
-/*FUNCTION ElementMatrix::ElementMatrix(Node** nodes,int numnodes,Parameters* parameters,int approximation){{{1*/
+/*FUNCTION ElementMatrix::ElementMatrix(Node** nodes,int numnodes,Parameters* parameters,int approximation){{{*/
 ElementMatrix::ElementMatrix(Node** nodes,int numnodes,Parameters* parameters,int approximation){
 
@@ -205,5 +205,5 @@
 
 	/*fill values with 0: */
-	this->values=(double*)xcalloc(this->nrows*this->ncols,sizeof(double));
+	this->values=xNewZeroInit<IssmDouble>(this->nrows*this->ncols);
 
 	/*g list*/
@@ -228,26 +228,26 @@
 }
 /*}}}*/
-/*FUNCTION ElementMatrix::~ElementMatrix(){{{1*/
+/*FUNCTION ElementMatrix::~ElementMatrix(){{{*/
 ElementMatrix::~ElementMatrix(){
 	
-	xfree((void**)&this->values);
-	xfree((void**)&this->gglobaldoflist);
-	xfree((void**)&this->row_flocaldoflist);
-	xfree((void**)&this->row_fglobaldoflist);
-	xfree((void**)&this->row_slocaldoflist);
-	xfree((void**)&this->row_sglobaldoflist);
-	xfree((void**)&this->col_flocaldoflist);
-	xfree((void**)&this->col_fglobaldoflist);
-	xfree((void**)&this->col_slocaldoflist);
-	xfree((void**)&this->col_sglobaldoflist);
+	xDelete<IssmDouble>(this->values);
+	xDelete<int>(this->gglobaldoflist);
+	xDelete<int>(this->row_flocaldoflist);
+	xDelete<int>(this->row_fglobaldoflist);
+	xDelete<int>(this->row_slocaldoflist);
+	xDelete<int>(this->row_sglobaldoflist);
+	xDelete<int>(this->col_flocaldoflist);
+	xDelete<int>(this->col_fglobaldoflist);
+	xDelete<int>(this->col_slocaldoflist);
+	xDelete<int>(this->col_sglobaldoflist);
 }
 /*}}}*/
 
 /*ElementMatrix specific routines: */
-/*FUNCTION ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){{{1*/
+/*FUNCTION ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){{{*/
 void ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){
 
 	int i,j;
-	double* localvalues=NULL;
+	IssmDouble* localvalues=NULL;
 
 	/*If Kfs is not provided, call the other function*/
@@ -265,5 +265,5 @@
 		if(this->row_fsize){
 			/*first, retrieve values that are in the f-set from the g-set values matrix: */
-			localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
+			localvalues=xNew<IssmDouble>(this->row_fsize*this->row_fsize);
 			for(i=0;i<this->row_fsize;i++){
 				for(j=0;j<this->row_fsize;j++){
@@ -275,5 +275,5 @@
 
 			/*Free ressources:*/
-			xfree((void**)&localvalues);
+			xDelete<IssmDouble>(localvalues);
 		}
 
@@ -281,5 +281,5 @@
 		if((this->row_ssize!=0) && (this->row_fsize!=0)){
 			/*first, retrieve values that are in the f and s-set from the g-set values matrix: */
-			localvalues=(double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double));
+			localvalues=xNew<IssmDouble>(this->row_fsize*this->row_ssize);
 			for(i=0;i<this->row_fsize;i++){
 				for(j=0;j<this->row_ssize;j++){
@@ -291,18 +291,18 @@
 
 			/*Free ressources:*/
-			xfree((void**)&localvalues);
-		}
-	}
-	else{
-		_error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
-	}
-
-}
-/*}}}*/
-/*FUNCTION ElementMatrix::AddToGlobal(Matrix* Jff){{{1*/
+			xDelete<IssmDouble>(localvalues);
+		}
+	}
+	else{
+		_error2_("non dofsymmetrical matrix AddToGlobal routine not support yet!");
+	}
+
+}
+/*}}}*/
+/*FUNCTION ElementMatrix::AddToGlobal(Matrix* Jff){{{*/
 void ElementMatrix::AddToGlobal(Matrix* Jff){
 
 	int i,j;
-	double* localvalues=NULL;
+	IssmDouble* localvalues=NULL;
 
 	/*Check that Jff is not NULL*/
@@ -317,5 +317,5 @@
 		if(this->row_fsize){
 			/*first, retrieve values that are in the f-set from the g-set values matrix: */
-			localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double));
+			localvalues=xNew<IssmDouble>(this->row_fsize*this->row_fsize);
 			for(i=0;i<this->row_fsize;i++){
 				for(j=0;j<this->row_fsize;j++){
@@ -327,15 +327,15 @@
 
 			/*Free ressources:*/
-			xfree((void**)&localvalues);
-		}
-
-	}
-	else{
-		_error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!");
-	}
-
-}
-/*}}}*/
-/*FUNCTION ElementMatrix::CheckConsistency{{{1*/
+			xDelete<IssmDouble>(localvalues);
+		}
+
+	}
+	else{
+		_error2_("non dofsymmetrical matrix AddToGlobal routine not support yet!");
+	}
+
+}
+/*}}}*/
+/*FUNCTION ElementMatrix::CheckConsistency{{{*/
 void ElementMatrix::CheckConsistency(void){
 	/*Check element matrix values, only in debugging mode*/
@@ -343,6 +343,6 @@
 	for (int i=0;i<this->nrows;i++){
 		for(int j=0;j<this->ncols;j++){
-			if (isnan(this->values[i*this->ncols+j])) _error_("NaN found in Element Matrix");
-			if (fabs(this->values[i*this->ncols+j])>1.e+50) _error_("Element Matrix values exceeds 1.e+50");
+			if (xIsNan<IssmDouble>(this->values[i*this->ncols+j])) _error2_("NaN found in Element Matrix");
+			if (fabs(this->values[i*this->ncols+j])>1.e+50) _error2_("Element Matrix values exceeds 1.e+50");
 		}
 	}
@@ -350,5 +350,5 @@
 }
 /*}}}*/
-/*FUNCTION ElementMatrix::Transpose{{{1*/
+/*FUNCTION ElementMatrix::Transpose{{{*/
 void ElementMatrix::Transpose(void){
 
@@ -365,5 +365,5 @@
 	/*Transpose indices*/
 	if(!dofsymmetrical){
-		_error_("not supported yet");
+		_error2_("not supported yet");
 	}
 
@@ -373,51 +373,51 @@
 }
 /*}}}*/
-/*FUNCTION ElementMatrix::Echo{{{1*/
+/*FUNCTION ElementMatrix::Echo{{{*/
 void ElementMatrix::Echo(void){
 
 	int i,j;
-	printf("Element Matrix echo: \n");
-	printf("   nrows: %i\n",nrows);
-	printf("   ncols: %i\n",ncols);
-	printf("   dofsymmetrical: %s\n",dofsymmetrical?"true":"false");
-
-	printf("   values: \n");
+	_printLine_("Element Matrix echo:");
+	_printLine_("   nrows: " << nrows);
+	_printLine_("   ncols: " << nrows);
+	_printLine_("   dofsymmetrical: " << (dofsymmetrical?"true":"false"));
+
+	_printLine_("   values:");
 	for(i=0;i<nrows;i++){
-		printf("      %i: ",i);
-		for(j=0;j<ncols;j++) printf("%10g ",*(values+ncols*i+j));
-		printf("\n");
-	}
-
-	printf("   gglobaldoflist (%p): ",gglobaldoflist);
-	if(gglobaldoflist) for(i=0;i<nrows;i++)printf("%i ",gglobaldoflist[i]); printf("\n");
-
-	printf("   row_fsize: %i\n",row_fsize);
-	printf("   row_flocaldoflist (%p): ",row_flocaldoflist);
-	if(row_flocaldoflist) for(i=0;i<row_fsize;i++)printf("%i ",row_flocaldoflist[i]); printf("\n");
-	printf("   row_fglobaldoflist (%p): ",row_fglobaldoflist);
-	if(row_fglobaldoflist)for(i=0;i<row_fsize;i++)printf("%i ",row_fglobaldoflist[i]); printf("\n");
-
-	printf("   row_ssize: %i\n",row_ssize);
-	printf("   row_slocaldoflist (%p): ",row_slocaldoflist);
-	if(row_slocaldoflist)for(i=0;i<row_ssize;i++)printf("%i ",row_slocaldoflist[i]); printf("\n");
-	printf("   row_sglobaldoflist (%p): ",row_sglobaldoflist);
-	if(row_sglobaldoflist)for(i=0;i<row_ssize;i++)printf("%i ",row_sglobaldoflist[i]); printf("\n");
+		_printString_(setw(4) << right << i << ": ");
+		for(j=0;j<ncols;j++) _printString_( " " << setw(11) << setprecision (5) << right << values[i*ncols+j]);
+		_printLine_("");
+	}
+
+	_printString_("   gglobaldoflist (" << gglobaldoflist << "): ");
+	if(gglobaldoflist) for(i=0;i<nrows;i++) _printString_(" " << gglobaldoflist[i]); _printLine_("");
+
+	_printLine_("   row_fsize: " << row_fsize);
+	_printString_("   row_flocaldoflist  (" << row_flocaldoflist << "): ");
+	if(row_flocaldoflist) for(i=0;i<row_fsize;i++) _printString_(" " << row_flocaldoflist[i]); _printLine_(" ");
+	_printString_("   row_fglobaldoflist  (" << row_fglobaldoflist << "): ");
+	if(row_fglobaldoflist) for(i=0;i<row_fsize;i++) _printString_(" " << row_fglobaldoflist[i]); _printLine_(" ");
+
+	_printLine_("   row_ssize: " << row_ssize);
+	_printString_("   row_slocaldoflist  (" << row_slocaldoflist << "): ");
+	if(row_slocaldoflist) for(i=0;i<row_ssize;i++) _printString_(" " << row_slocaldoflist[i]); _printLine_(" ");
+	_printString_("   row_sglobaldoflist  (" << row_sglobaldoflist << "): ");
+	if(row_sglobaldoflist) for(i=0;i<row_ssize;i++) _printString_(" " << row_sglobaldoflist[i]); _printLine_(" ");
 
 	if(!dofsymmetrical){
-		printf("   col_fsize: %i\n",col_fsize);
-		printf("   col_flocaldoflist (%p): ",col_flocaldoflist);
-		if(col_flocaldoflist)for(i=0;i<col_fsize;i++)printf("%i ",col_flocaldoflist[i]); printf("\n");
-		printf("   col_fglobaldoflist (%p): ",col_fglobaldoflist);
-		if(col_fglobaldoflist)for(i=0;i<col_fsize;i++)printf("%i ",col_fglobaldoflist[i]); printf("\n");
-
-		printf("   col_ssize: %i\n",col_ssize);
-		printf("   col_slocaldoflist (%p): ",col_slocaldoflist);
-		if(col_slocaldoflist)for(i=0;i<col_ssize;i++)printf("%i ",col_slocaldoflist[i]); printf("\n");
-		printf("   col_sglobaldoflist (%p): ",col_sglobaldoflist);
-		if(col_sglobaldoflist)for(i=0;i<col_ssize;i++)printf("%i ",col_sglobaldoflist[i]); printf("\n");
-	}
-}
-/*}}}*/
-/*FUNCTION ElementMatrix::Init{{{1*/
+		_printLine_("   col_fsize: " << col_fsize);
+		_printString_("   col_flocaldoflist  (" << col_flocaldoflist << "): ");
+		if(col_flocaldoflist) for(i=0;i<col_fsize;i++) _printString_(" " << col_flocaldoflist[i]); _printLine_(" ");
+		_printString_("   col_fglobaldoflist  (" << col_fglobaldoflist << "): ");
+		if(col_fglobaldoflist) for(i=0;i<col_fsize;i++) _printString_(" " << col_fglobaldoflist[i]); _printLine_(" ");
+
+		_printLine_("   col_ssize: " << col_ssize);
+		_printString_("   col_slocaldoflist  (" << col_slocaldoflist << "): ");
+		if(col_slocaldoflist) for(i=0;i<col_ssize;i++) _printString_(" " << col_slocaldoflist[i]); _printLine_(" ");
+		_printString_("   col_sglobaldoflist  (" << col_sglobaldoflist << "): ");
+		if(col_sglobaldoflist) for(i=0;i<col_ssize;i++) _printString_(" " << col_sglobaldoflist[i]); _printLine_(" ");
+	}
+}
+/*}}}*/
+/*FUNCTION ElementMatrix::Init{{{*/
 void ElementMatrix::Init(ElementMatrix* Ke){
 
@@ -428,16 +428,16 @@
 	this->dofsymmetrical=Ke->dofsymmetrical;
 
-	this->values=(double*)xmalloc(this->nrows*this->ncols*sizeof(double));
-	memcpy(this->values,Ke->values,this->nrows*this->ncols*sizeof(double));
-
-	this->gglobaldoflist=(int*)xmalloc(this->nrows*sizeof(int));
-	memcpy(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows*sizeof(int));
+	this->values=xNew<IssmDouble>(this->nrows*this->ncols);
+	xMemCpy<IssmDouble>(this->values,Ke->values,this->nrows*this->ncols);
+
+	this->gglobaldoflist=xNew<int>(this->nrows);
+	xMemCpy<int>(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows);
 
 	this->row_fsize=Ke->row_fsize;
 	if(this->row_fsize){
-		this->row_flocaldoflist=(int*)xmalloc(this->row_fsize*sizeof(int));
-		memcpy(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize*sizeof(int));
-		this->row_fglobaldoflist=(int*)xmalloc(this->row_fsize*sizeof(int));
-		memcpy(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize*sizeof(int));
+		this->row_flocaldoflist=xNew<int>(this->row_fsize);
+		xMemCpy<int>(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize);
+		this->row_fglobaldoflist=xNew<int>(this->row_fsize);
+		xMemCpy<int>(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize);
 	}
 	else{
@@ -448,8 +448,8 @@
 	this->row_ssize=Ke->row_ssize;
 	if(this->row_ssize){
-		this->row_slocaldoflist=(int*)xmalloc(this->row_ssize*sizeof(int));
-		memcpy(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize*sizeof(int));
-		this->row_sglobaldoflist=(int*)xmalloc(this->row_ssize*sizeof(int));
-		memcpy(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize*sizeof(int));
+		this->row_slocaldoflist=xNew<int>(this->row_ssize);
+		xMemCpy<int>(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize);
+		this->row_sglobaldoflist=xNew<int>(this->row_ssize);
+		xMemCpy<int>(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize);
 	}
 	else{
@@ -460,8 +460,8 @@
 	this->col_fsize=Ke->col_fsize;
 	if(this->col_fsize){
-		this->col_flocaldoflist=(int*)xmalloc(this->col_fsize*sizeof(int));
-		memcpy(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize*sizeof(int));
-		this->col_fglobaldoflist=(int*)xmalloc(this->col_fsize*sizeof(int));
-		memcpy(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize*sizeof(int));
+		this->col_flocaldoflist=xNew<int>(this->col_fsize);
+		xMemCpy<int>(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize);
+		this->col_fglobaldoflist=xNew<int>(this->col_fsize);
+		xMemCpy<int>(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize);
 	}
 	else{
@@ -472,8 +472,8 @@
 	this->col_ssize=Ke->col_ssize;
 	if(this->col_ssize){
-		this->col_slocaldoflist=(int*)xmalloc(this->col_ssize*sizeof(int));
-		memcpy(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize*sizeof(int));
-		this->col_sglobaldoflist=(int*)xmalloc(this->col_ssize*sizeof(int));
-		memcpy(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize*sizeof(int));
+		this->col_slocaldoflist=xNew<int>(this->col_ssize);
+		xMemCpy<int>(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize);
+		this->col_sglobaldoflist=xNew<int>(this->col_ssize);
+		xMemCpy<int>(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize);
 	}
 	else{
@@ -483,10 +483,10 @@
 }
 /*}}}*/
-/*FUNCTION ElementMatrix::SetDiag{{{1*/
-void ElementMatrix::SetDiag(double scalar){
+/*FUNCTION ElementMatrix::SetDiag{{{*/
+void ElementMatrix::SetDiag(IssmDouble scalar){
 
 	int i;
 
-	if(this->nrows!=this->ncols)_error_("need square matrix in input!");
+	if(this->nrows!=this->ncols)_error2_("need square matrix in input!");
 
 	for(i=0;i<this->nrows;i++){
Index: /issm/trunk/src/c/objects/Numerics/ElementMatrix.h
===================================================================
--- /issm/trunk/src/c/objects/Numerics/ElementMatrix.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Numerics/ElementMatrix.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Object.h"
 #include "../../toolkits/toolkits.h"
@@ -24,5 +24,5 @@
 		int      ncols;
 		bool     dofsymmetrical;
-		double*  values;
+		IssmDouble*  values;
 
 		//gset
@@ -49,5 +49,5 @@
 		int*     col_sglobaldoflist;
 
-		/*ElementMatrix constructors, destructors {{{1*/
+		/*ElementMatrix constructors, destructors {{{*/
 		ElementMatrix();
 		ElementMatrix(ElementMatrix* Ke);
@@ -57,5 +57,5 @@
 		~ElementMatrix();
 		/*}}}*/
-		/*ElementMatrix specific routines {{{1*/
+		/*ElementMatrix specific routines {{{*/
 		void AddToGlobal(Matrix* Kff, Matrix* Kfs);
 		void AddToGlobal(Matrix* Jff);
@@ -64,5 +64,5 @@
 		void Transpose(void);
 		void Init(ElementMatrix* Ke);
-		void SetDiag(double scalar);
+		void SetDiag(IssmDouble scalar);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/Numerics/ElementVector.cpp
===================================================================
--- /issm/trunk/src/c/objects/Numerics/ElementVector.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Numerics/ElementVector.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,5 +20,5 @@
 
 /*ElementVector constructors and destructor*/
-/*FUNCTION ElementVector::ElementVector(){{{1*/
+/*FUNCTION ElementVector::ElementVector(){{{*/
 ElementVector::ElementVector(){
 
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2){{{1*/
+/*FUNCTION ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2){{{*/
 ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2){
 
@@ -42,5 +42,5 @@
 	/*If one of the two matrix is NULL, we copy the other one*/
 	if(!pe1 && !pe2){
-		_error_("Two input element matrices are NULL");
+		_error2_("Two input element matrices are NULL");
 	}
 	else if(!pe1){
@@ -54,5 +54,5 @@
 
 	/*Initialize itransformation matrix pe[P[i]] = pe2[i]*/
-	P=(int*)xmalloc(pe2->nrows*sizeof(int));
+	P=xNew<int>(pe2->nrows);
 
 	/*1: Get the new numbering of pe2 and get size of the new matrix*/
@@ -74,6 +74,6 @@
 
 	/*Gset and values*/
-	this->gglobaldoflist=(int*)xmalloc(this->nrows*sizeof(int));
-	this->values=(double*)xcalloc(this->nrows,sizeof(double));
+	this->gglobaldoflist=xNew<int>(this->nrows);
+	this->values=xNewZeroInit<IssmDouble>(this->nrows);
 	for(i=0;i<pe1->nrows;i++){
 		this->values[i] += pe1->values[i];
@@ -92,6 +92,6 @@
 	this->fsize=fsize;
 	if(fsize){
-		this->flocaldoflist =(int*)xmalloc(fsize*sizeof(int));
-		this->fglobaldoflist=(int*)xmalloc(fsize*sizeof(int));
+		this->flocaldoflist =xNew<int>(fsize);
+		this->fglobaldoflist=xNew<int>(fsize);
 		for(i=0;i<pe1->fsize;i++){
 			this->flocaldoflist[i] =pe1->flocaldoflist[i];
@@ -113,8 +113,8 @@
 
 	/*clean-up*/
-	xfree((void**)&P);
-}
-/*}}}*/
-/*FUNCTION ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2,ElementVector* pe3){{{1*/
+	xDelete<int>(P);
+}
+/*}}}*/
+/*FUNCTION ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2,ElementVector* pe3){{{*/
 ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2,ElementVector* pe3){
 
@@ -131,5 +131,5 @@
 }
 /*}}}*/
-/*FUNCTION ElementVector::ElementVector(Node** nodes,int numnodes,Parameters* parameters,int approximation){{{1*/
+/*FUNCTION ElementVector::ElementVector(Node** nodes,int numnodes,Parameters* parameters,int approximation){{{*/
 ElementVector::ElementVector(Node** nodes,int numnodes,Parameters* parameters,int approximation){
 
@@ -138,5 +138,5 @@
 
 	/*fill values with 0: */
-	this->values=(double*)xcalloc(this->nrows,sizeof(double));
+	this->values=xNewZeroInit<IssmDouble>(this->nrows);
 	
 	/*g list*/
@@ -149,20 +149,20 @@
 }
 /*}}}*/
-/*FUNCTION ElementVector::~ElementVector(){{{1*/
+/*FUNCTION ElementVector::~ElementVector(){{{*/
 ElementVector::~ElementVector(){
 	
-	xfree((void**)&this->values);
-	xfree((void**)&this->gglobaldoflist);
-	xfree((void**)&this->flocaldoflist);
-	xfree((void**)&this->fglobaldoflist);
+	xDelete<IssmDouble>(this->values);
+	xDelete<int>(this->gglobaldoflist);
+	xDelete<int>(this->flocaldoflist);
+	xDelete<int>(this->fglobaldoflist);
 }
 /*}}}*/
 
 /*ElementVector specific routines: */
-/*FUNCTION ElementVector::AddToGlobal(Vector* pf){{{1*/
+/*FUNCTION ElementVector::AddToGlobal(Vector* pf){{{*/
 void ElementVector::AddToGlobal(Vector* pf){
 
 	int i;
-	double* localvalues=NULL;
+	IssmDouble* localvalues=NULL;
 
 	/*In debugging mode, check consistency (no NaN, and values not too big)*/
@@ -171,5 +171,5 @@
 	if(this->fsize){
 		/*first, retrieve values that are in the f-set from the g-set values vector: */
-		localvalues=(double*)xmalloc(this->fsize*sizeof(double));
+		localvalues=xNew<IssmDouble>(this->fsize);
 		for(i=0;i<this->fsize;i++){
 			localvalues[i]=this->values[this->flocaldoflist[i]];
@@ -179,18 +179,18 @@
 
 		/*Free ressources:*/
-		xfree((void**)&localvalues);
+		xDelete<IssmDouble>(localvalues);
 	}
 	
 }
 /*}}}*/
-/*FUNCTION ElementVector::InsertIntoGlobal(Vector* pf){{{1*/
+/*FUNCTION ElementVector::InsertIntoGlobal(Vector* pf){{{*/
 void ElementVector::InsertIntoGlobal(Vector* pf){
 
 	int i;
-	double* localvalues=NULL;
+	IssmDouble* localvalues=NULL;
 
 	if(this->fsize){
 		/*first, retrieve values that are in the f-set from the g-set values vector: */
-		localvalues=(double*)xmalloc(this->fsize*sizeof(double));
+		localvalues=xNew<IssmDouble>(this->fsize);
 		for(i=0;i<this->fsize;i++){
 			localvalues[i]=this->values[this->flocaldoflist[i]];
@@ -200,43 +200,45 @@
 
 		/*Free ressources:*/
-		xfree((void**)&localvalues);
-	}
-
-}
-/*}}}*/
-/*FUNCTION ElementVector::CheckConsistency{{{1*/
+		xDelete<IssmDouble>(localvalues);
+	}
+
+}
+/*}}}*/
+/*FUNCTION ElementVector::CheckConsistency{{{*/
 void ElementVector::CheckConsistency(void){
 	/*Check element matrix values, only in debugging mode*/
 #ifdef _ISSM_DEBUG_ 
 	for (int i=0;i<this->nrows;i++){
-		if (isnan(this->values[i])) _error_("NaN found in Element Vector");
-		if (fabs( this->values[i])>1.e+50) _error_("Element Vector values exceeds 1.e+50");
+		if (xIsNan<IssmDouble>(this->values[i])) _error2_("NaN found in Element Vector");
+		if (fabs( this->values[i])>1.e+50) _error2_("Element Vector values exceeds 1.e+50");
 	}
 #endif
 }
 /*}}}*/
-/*FUNCTION ElementVector::Echo{{{1*/
+/*FUNCTION ElementVector::Echo{{{*/
 void ElementVector::Echo(void){
 
 	int i,j;
-	printf("Element Vector echo: \n");
-	printf("   nrows: %i\n",nrows);
-
-	printf("   values: \n");
+	_printLine_("Element Vector echo:");
+	_printLine_("   nrows: " << nrows);
+	_printLine_("   values:");
 	for(i=0;i<nrows;i++){
-		printf("      %i: %10g\n",i,values[i]);
-	}
-
-	printf("   gglobaldoflist (%p): ",gglobaldoflist);
-	if(gglobaldoflist) for(i=0;i<nrows;i++)printf("%i ",gglobaldoflist[i]); printf("\n");
-
-	printf("   fsize: %i\n",fsize);
-	printf("   flocaldoflist (%p): ",flocaldoflist);
-	if(flocaldoflist) for(i=0;i<fsize;i++)printf("%i ",flocaldoflist[i]); printf("\n");
-	printf("   fglobaldoflist (%p): ",fglobaldoflist);
-	if(fglobaldoflist)for(i=0;i<fsize;i++)printf("%i ",fglobaldoflist[i]); printf("\n");
-}
-/*}}}*/
-/*FUNCTION ElementVector::Init{{{1*/
+		_printLine_(setw(4) << right << i << ": " << setw(10) << values[i]);
+	}
+
+	_printString_("   gglobaldoflist (" << gglobaldoflist << "): ");
+	if(gglobaldoflist) for(i=0;i<nrows;i++) _printString_(" " << gglobaldoflist[i] );
+	_printLine_(" ");
+
+	_printLine_("   fsize: " << fsize);
+	_printString_("   flocaldoflist  (" << flocaldoflist << "): ");
+	if(flocaldoflist) for(i=0;i<fsize;i++) _printString_(" " << flocaldoflist[i] );
+	_printLine_(" ");
+	_printString_("   fglobaldoflist (" << fglobaldoflist << "): ");
+	if(fglobaldoflist) for(i=0;i<fsize;i++) _printString_(" " << fglobaldoflist[i] );
+	_printLine_(" ");
+}
+/*}}}*/
+/*FUNCTION ElementVector::Init{{{*/
 void ElementVector::Init(ElementVector* pe){
 
@@ -245,16 +247,16 @@
 	this->nrows =pe->nrows;
 
-	this->values=(double*)xmalloc(this->nrows*sizeof(double));
-	memcpy(this->values,pe->values,this->nrows*sizeof(double));
-
-	this->gglobaldoflist=(int*)xmalloc(this->nrows*sizeof(int));
-	memcpy(this->gglobaldoflist,pe->gglobaldoflist,this->nrows*sizeof(int));
+	this->values=xNew<IssmDouble>(this->nrows);
+	xMemCpy<IssmDouble>(this->values,pe->values,this->nrows);
+
+	this->gglobaldoflist=xNew<int>(this->nrows);
+	xMemCpy<int>(this->gglobaldoflist,pe->gglobaldoflist,this->nrows);
 
 	this->fsize=pe->fsize;
 	if(this->fsize){
-		this->flocaldoflist=(int*)xmalloc(this->fsize*sizeof(int));
-		memcpy(this->flocaldoflist,pe->flocaldoflist,this->fsize*sizeof(int));
-		this->fglobaldoflist=(int*)xmalloc(this->fsize*sizeof(int));
-		memcpy(this->fglobaldoflist,pe->fglobaldoflist,this->fsize*sizeof(int));
+		this->flocaldoflist=xNew<int>(this->fsize);
+		xMemCpy<int>(this->flocaldoflist,pe->flocaldoflist,this->fsize);
+		this->fglobaldoflist=xNew<int>(this->fsize);
+		xMemCpy<int>(this->fglobaldoflist,pe->fglobaldoflist,this->fsize);
 	}
 	else{
@@ -264,6 +266,6 @@
 }
 /*}}}*/
-/*FUNCTION ElementVector::SetValue{{{1*/
-void ElementVector::SetValue(double scalar){
+/*FUNCTION ElementVector::SetValue{{{*/
+void ElementVector::SetValue(IssmDouble scalar){
 
 	int i;
Index: /issm/trunk/src/c/objects/Numerics/ElementVector.h
===================================================================
--- /issm/trunk/src/c/objects/Numerics/ElementVector.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Numerics/ElementVector.h	(revision 12706)
@@ -10,5 +10,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../Object.h"
 #include "../../toolkits/toolkits.h"
@@ -22,5 +22,5 @@
 	
 		int      nrows;
-		double*  values;
+		IssmDouble*  values;
 		
 		//gset
@@ -32,5 +32,5 @@
 		int*     fglobaldoflist;
 		
-		/*ElementVector constructors, destructors {{{1*/
+		/*ElementVector constructors, destructors {{{*/
 		ElementVector();
 		ElementVector(ElementVector* pe1,ElementVector* pe2);
@@ -39,5 +39,5 @@
 		~ElementVector();
 		/*}}}*/
-		/*ElementVector specific routines {{{1*/
+		/*ElementVector specific routines {{{*/
 		void AddToGlobal(Vector* pf);
 		void InsertIntoGlobal(Vector* pf);
@@ -45,5 +45,5 @@
 		void CheckConsistency(void);
 		void Init(ElementVector* pe);
-		void SetValue(double scalar);
+		void SetValue(IssmDouble scalar);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/Numerics/Matrix.cpp
===================================================================
--- /issm/trunk/src/c/objects/Numerics/Matrix.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Numerics/Matrix.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -23,5 +23,5 @@
 
 /*Matrix constructors and destructor*/
-/*FUNCTION Matrix::Matrix(){{{1*/
+/*FUNCTION Matrix::Matrix(){{{*/
 Matrix::Matrix(){
 
@@ -36,5 +36,5 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::Matrix(int M,int N){{{1*/
+/*FUNCTION Matrix::Matrix(int M,int N){{{*/
 Matrix::Matrix(int M,int N){
 
@@ -45,10 +45,10 @@
 	#endif
 	#ifdef _HAVE_ADOLC_
-	this->amatrix=(adouble*)xmalloc(M*N*sizeof(adouble));
-	#endif
-}
-/*}}}*/
-/*FUNCTION Matrix::Matrix(int M,int N,double sparsity){{{1*/
-Matrix::Matrix(int M,int N,double sparsity){
+	this->amatrix=xNew<IssmDouble>(M*N);
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::Matrix(int M,int N,IssmDouble sparsity){{{*/
+Matrix::Matrix(int M,int N,IssmDouble sparsity){
 
 	#ifdef _HAVE_PETSC_
@@ -58,10 +58,10 @@
 	#endif
 	#ifdef _HAVE_ADOLC_
-	this->amatrix=(adouble*)xmalloc(M*N*sizeof(adouble));
-	#endif
-}
-/*}}}*/
-/*FUNCTION Matrix::Matrix(double* serial_mat, int M,int N,double sparsity){{{1*/
-Matrix::Matrix(double* serial_mat, int M,int N,double sparsity){
+ 	this->amatrix=xNew<IssmDouble>(M*N);
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::Matrix(IssmDouble* serial_mat, int M,int N,IssmDouble sparsity){{{*/
+Matrix::Matrix(IssmDouble* serial_mat, int M,int N,IssmDouble sparsity){
 
 	#ifdef _HAVE_PETSC_
@@ -69,6 +69,6 @@
 
 
-	int* idxm=(int*)xmalloc(M*sizeof(int));
-	int* idxn=(int*)xmalloc(N*sizeof(int));
+	int* idxm=xNew<int>(M);
+	int* idxn=xNew<int>(N);
 	for(i=0;i<M;i++)idxm[i]=i;
 	for(i=0;i<N;i++)idxn[i]=i;
@@ -79,15 +79,15 @@
 	MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY);
 
-	xfree((void**)&idxm);
-	xfree((void**)&idxn);
+	xDelete<int>(idxm);
+	xDelete<int>(idxn);
 	#else
 	this->matrix=new SeqMat(serial_mat,M,N,sparsity);
 	#endif
 	#ifdef _HAVE_ADOLC_
-	this->amatrix=(adouble*)xmalloc(M*N*sizeof(adouble));
-	#endif
-}
-/*}}}*/
-/*FUNCTION Matrix::Matrix(int M,int N,int connectivity,int numberofdofspernode){{{1*/
+	this->amatrix=xNew<IssmDouble>(M*N);
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::Matrix(int M,int N,int connectivity,int numberofdofspernode){{{*/
 Matrix::Matrix(int M,int N,int connectivity,int numberofdofspernode){
 	
@@ -98,9 +98,9 @@
 	#endif
 	#ifdef _HAVE_ADOLC_
-	this->amatrix=(adouble*)xmalloc(M*N*sizeof(adouble));
-	#endif
-}
-/*}}}*/
-/*FUNCTION Matrix::~Matrix(){{{1*/
+	this->amatrix=xNew<IssmDouble>(M*N);
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::~Matrix(){{{*/
 Matrix::~Matrix(){
 
@@ -111,5 +111,5 @@
 	#endif
 	#ifdef _HAVE_ADOLC_
-	xfree((void**)&this->amatrix);
+	xDelete<IssmDouble>(this->amatrix);
 	#endif
 }
@@ -117,5 +117,5 @@
 
 /*Matrix specific routines: */
-/*FUNCTION Matrix::Echo{{{1*/
+/*FUNCTION Matrix::Echo{{{*/
 void Matrix::Echo(void){
 
@@ -130,15 +130,15 @@
 	#ifdef _HAVE_ADOLC_
 	/*Not sure about that one. Should we use the overloaded operator >>?*/
-	printf("ADOLC Matrix equivalent:" );
-	for(i=0;i<M;i++){
-		for(j=0;j<N;j++){
-			printf("%g ",*(amatrix+N*i+j));
-		}
-		printf("\n");
-	}
-	#endif
-}
-/*}}}*/
-/*FUNCTION Matrix::Assemble{{{1*/
+	_printString_("ADOLC Matrix equivalent:" );
+//	for(i=0;i<M;i++){
+//		for(j=0;j<N;j++){
+//			_printString_(*(amatrix+N*i+j) << " ");
+//		}
+//		_printLine_("");
+//	}
+	#endif
+}
+/*}}}*/
+/*FUNCTION Matrix::Assemble{{{*/
 void Matrix::Assemble(void){
 	#ifdef _HAVE_PETSC_
@@ -155,8 +155,8 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::Norm{{{1*/
-double Matrix::Norm(NormMode norm_type){
-	
-	double norm=0;
+/*FUNCTION Matrix::Norm{{{*/
+IssmDouble Matrix::Norm(NormMode norm_type){
+	
+	IssmDouble norm=0;
 	#ifdef _HAVE_PETSC_
 		_assert_(this->matrix);
@@ -168,5 +168,5 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::GetSize{{{1*/
+/*FUNCTION Matrix::GetSize{{{*/
 void Matrix::GetSize(int* pM,int* pN){
 	
@@ -179,5 +179,5 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::GetLocalSize{{{1*/
+/*FUNCTION Matrix::GetLocalSize{{{*/
 void Matrix::GetLocalSize(int* pM,int* pN){
 	
@@ -190,5 +190,5 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::MatMult{{{1*/
+/*FUNCTION Matrix::MatMult{{{*/
 void Matrix::MatMult(Vector* X,Vector* AX){
 
@@ -202,5 +202,5 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::Duplicate{{{1*/
+/*FUNCTION Matrix::Duplicate{{{*/
 Matrix* Matrix::Duplicate(void){
 
@@ -219,8 +219,8 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::ToSerial{{{1*/
-double* Matrix::ToSerial(void){
-
-	double* output=NULL;
+/*FUNCTION Matrix::ToSerial{{{*/
+IssmDouble* Matrix::ToSerial(void){
+
+	IssmDouble* output=NULL;
 
 	#ifdef _HAVE_PETSC_
@@ -232,6 +232,6 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::SetValues{{{1*/
-void Matrix::SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode){
+/*FUNCTION Matrix::SetValues{{{*/
+void Matrix::SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode){
 
 	#ifdef _HAVE_PETSC_
@@ -242,5 +242,5 @@
 }
 /*}}}*/
-/*FUNCTION Matrix::Convert{{{1*/
+/*FUNCTION Matrix::Convert{{{*/
 void Matrix::Convert(MatrixType type){
 
Index: /issm/trunk/src/c/objects/Numerics/Matrix.h
===================================================================
--- /issm/trunk/src/c/objects/Numerics/Matrix.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Numerics/Matrix.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -16,8 +16,4 @@
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
-
-#ifdef _HAVE_ADOLC_
-#include "adolc.h"
-#endif
 
 class Vector;
@@ -35,25 +31,25 @@
 		#endif
 		#ifdef _HAVE_ADOLC_
-		adouble* amatrix;
+		IssmDouble* amatrix;
 		#endif
 
-		/*Matrix constructors, destructors {{{1*/
+		/*Matrix constructors, destructors {{{*/
 		Matrix();
 		Matrix(int M,int N);
-		Matrix(int M,int N,double sparsity);
-		Matrix(double* serial_mat,int M,int N,double sparsity);
+		Matrix(int M,int N,IssmDouble sparsity);
+		Matrix(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity);
 		Matrix(int M,int N,int connectivity,int numberofdofspernode);
 		~Matrix();
 		/*}}}*/
-		/*Matrix specific routines {{{1*/
+		/*Matrix specific routines {{{*/
 		void Echo(void);
 		void Assemble(void);
-		double Norm(NormMode norm_type);
+		IssmDouble Norm(NormMode norm_type);
 		void GetSize(int* pM,int* pN);
 		void GetLocalSize(int* pM,int* pN);
 		void MatMult(Vector* X,Vector* AX);
 		Matrix* Duplicate(void);
-		double* ToSerial(void);
-		void SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode);
+		IssmDouble* ToSerial(void);
+		void SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode);
 		void Convert(MatrixType type);
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Numerics/Vector.cpp
===================================================================
--- /issm/trunk/src/c/objects/Numerics/Vector.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Numerics/Vector.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -22,5 +22,5 @@
 
 /*Vector constructors and destructor*/
-/*FUNCTION Vector::Vector(){{{1*/
+/*FUNCTION Vector::Vector(){{{*/
 Vector::Vector(){
 
@@ -35,5 +35,5 @@
 }
 /*}}}*/
-/*FUNCTION Vector::Vector(int M,bool fromlocalsize){{{1*/
+/*FUNCTION Vector::Vector(int M,bool fromlocalsize){{{*/
 Vector::Vector(int pM,bool fromlocalsize){
 
@@ -44,13 +44,13 @@
 	#endif
 	#ifdef _HAVE_ADOLC_
-	this->avector=(adouble*)xmalloc(pM*sizeof(adouble));
-	#endif
-}
-/*}}}*/
-/*FUNCTION Vector::Vector(double* serial_vec,int M){{{1*/
-Vector::Vector(double* serial_vec,int M){
-
-	#ifdef _HAVE_PETSC_
-		int* idxm=(int*)xmalloc(M*sizeof(int));
+	this->avector=xNew<IssmDouble>(pM);
+	#endif
+}
+/*}}}*/
+/*FUNCTION Vector::Vector(IssmDouble* serial_vec,int M){{{*/
+Vector::Vector(IssmDouble* serial_vec,int M){
+
+	#ifdef _HAVE_PETSC_
+		int* idxm=xNew<int>(M);
 		for(int i=0;i<M;i++) idxm[i]=i;
 
@@ -60,15 +60,15 @@
 		VecAssemblyEnd(this->vector);
 
-		xfree((void**)&idxm);
+		xDelete<int>(idxm);
 	#else
 		this->vector=new SeqVec(serial_vec,M);
 	#endif
 	#ifdef _HAVE_ADOLC_
-		this->avector=(adouble*)xmalloc(M*sizeof(adouble));
+		this->avector=xNew<IssmDouble>(M);
 	#endif
 }
 /*}}}*/
 #ifdef _HAVE_PETSC_
-/*FUNCTION Vector::Vector(Vec petsc_vec){{{1*/
+/*FUNCTION Vector::Vector(Vec petsc_vec){{{*/
 Vector::Vector(Vec petsc_vec){
 
@@ -86,5 +86,5 @@
 #endif
 #if defined(_HAVE_GSL_) && !defined(_HAVE_PETSC_)
-/*FUNCTION Vector::Vector(SeqVec* seq_vec){{{1*/
+/*FUNCTION Vector::Vector(SeqVec* seq_vec){{{*/
 Vector::Vector(SeqVec*  seq_vec){
 
@@ -100,5 +100,5 @@
 #endif
 
-		/*FUNCTION Vector::~Vector(){{{1*/
+		/*FUNCTION Vector::~Vector(){{{*/
 Vector::~Vector(){
 
@@ -109,5 +109,5 @@
 	#endif
 	#ifdef _HAVE_ADOLC_
-	xfree((void**)&this->avector);
+	xDelete<IssmDouble>(this->avector);
 	#endif
 }
@@ -115,5 +115,5 @@
 
 /*Vector specific routines: */
-/*FUNCTION Vector::Echo{{{1*/
+/*FUNCTION Vector::Echo{{{*/
 void Vector::Echo(void){
 
@@ -132,5 +132,5 @@
 }
 /*}}}*/
-/*FUNCTION Vector::Assemble{{{1*/
+/*FUNCTION Vector::Assemble{{{*/
 void Vector::Assemble(void){
 		
@@ -145,6 +145,6 @@
 }
 /*}}}*/
-/*FUNCTION Vector::SetValues{{{1*/
-void Vector::SetValues(int ssize, int* list, double* values, InsMode mode){
+/*FUNCTION Vector::SetValues{{{*/
+void Vector::SetValues(int ssize, int* list, IssmDouble* values, InsMode mode){
 		
 		
@@ -158,6 +158,6 @@
 }
 /*}}}*/
-/*FUNCTION Vector::SetValue{{{1*/
-void Vector::SetValue(int dof, double value, InsMode mode){
+/*FUNCTION Vector::SetValue{{{*/
+void Vector::SetValue(int dof, IssmDouble value, InsMode mode){
 		
 	#ifdef _HAVE_PETSC_
@@ -170,6 +170,6 @@
 }
 /*}}}*/
-/*FUNCTION Vector::GetValue{{{1*/
-void Vector::GetValue(double* pvalue,int dof){
+/*FUNCTION Vector::GetValue{{{*/
+void Vector::GetValue(IssmDouble* pvalue,int dof){
 		
 	#ifdef _HAVE_PETSC_
@@ -181,5 +181,5 @@
 }
 /*}}}*/
-/*FUNCTION Vector::GetSize{{{1*/
+/*FUNCTION Vector::GetSize{{{*/
 void Vector::GetSize(int* pM){
 		
@@ -193,5 +193,5 @@
 }
 /*}}}*/
-/*FUNCTION Vector::IsEmpty{{{1*/
+/*FUNCTION Vector::IsEmpty{{{*/
 bool Vector::IsEmpty(void){
 
@@ -207,5 +207,5 @@
 }
 /*}}}*/
-/*FUNCTION Vector::GetLocalSize{{{1*/
+/*FUNCTION Vector::GetLocalSize{{{*/
 void Vector::GetLocalSize(int* pM){
 		
@@ -219,5 +219,5 @@
 }
 /*}}}*/
-/*FUNCTION Vector::Duplicate{{{1*/
+/*FUNCTION Vector::Duplicate{{{*/
 Vector* Vector::Duplicate(void){
 	
@@ -237,6 +237,6 @@
 }
 /*}}}*/
-/*FUNCTION Vector::Set{{{1*/
-void Vector::Set(double value){
+/*FUNCTION Vector::Set{{{*/
+void Vector::Set(IssmDouble value){
 	
 	#ifdef _HAVE_PETSC_
@@ -249,6 +249,6 @@
 }
 /*}}}*/
-/*FUNCTION Vector::AXPY{{{1*/
-void Vector::AXPY(Vector* X, double a){
+/*FUNCTION Vector::AXPY{{{*/
+void Vector::AXPY(Vector* X, IssmDouble a){
 	
 	#ifdef _HAVE_PETSC_
@@ -260,6 +260,6 @@
 }
 /*}}}*/
-/*FUNCTION Vector::AYPX{{{1*/
-void Vector::AYPX(Vector* X, double a){
+/*FUNCTION Vector::AYPX{{{*/
+void Vector::AYPX(Vector* X, IssmDouble a){
 	
 	#ifdef _HAVE_PETSC_
@@ -272,8 +272,8 @@
 }
 /*}}}*/
-/*FUNCTION Vector::ToMPISerial{{{1*/
-double* Vector::ToMPISerial(void){
-
-	double* vec_serial=NULL;
+/*FUNCTION Vector::ToMPISerial{{{*/
+IssmDouble* Vector::ToMPISerial(void){
+
+	IssmDouble* vec_serial=NULL;
 
 	#ifdef _HAVE_PETSC_
@@ -287,5 +287,5 @@
 }
 /*}}}*/
-/*FUNCTION Vector::Copy{{{1*/
+/*FUNCTION Vector::Copy{{{*/
 void Vector::Copy(Vector* to){
 
@@ -298,8 +298,8 @@
 }
 /*}}}*/
-/*FUNCTION Vector::Norm{{{1*/
-double Vector::Norm(NormMode norm_type){
-	
-	double norm=0;
+/*FUNCTION Vector::Norm{{{*/
+IssmDouble Vector::Norm(NormMode norm_type){
+	
+	IssmDouble norm=0;
 	#ifdef _HAVE_PETSC_
 		_assert_(this->vector);
@@ -311,6 +311,6 @@
 }
 /*}}}*/
-/*FUNCTION Vector::Scale{{{1*/
-void Vector::Scale(double scale_factor){
+/*FUNCTION Vector::Scale{{{*/
+void Vector::Scale(IssmDouble scale_factor){
 	
 	#ifdef _HAVE_PETSC_
@@ -322,8 +322,8 @@
 }
 /*}}}*/
-/*FUNCTION Vector::Dot{{{1*/
-double Vector::Dot(Vector* vector){
-
-	double dot;
+/*FUNCTION Vector::Dot{{{*/
+IssmDouble Vector::Dot(Vector* vector){
+
+	IssmDouble dot;
 	#ifdef _HAVE_PETSC_
 		_assert_(this->vector);
@@ -335,5 +335,5 @@
 }
 /*}}}*/
-/*FUNCTION Vector::PointwiseDivide{{{1*/
+/*FUNCTION Vector::PointwiseDivide{{{*/
 void Vector::PointwiseDivide(Vector* x,Vector* y){
 
Index: /issm/trunk/src/c/objects/Numerics/Vector.h
===================================================================
--- /issm/trunk/src/c/objects/Numerics/Vector.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Numerics/Vector.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -17,8 +17,4 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-#ifdef _HAVE_ADOLC_
-#include "adolc.h"
-#endif
-		
 /*}}}*/
 
@@ -33,11 +29,11 @@
 		#endif
 		#ifdef _HAVE_ADOLC_
-			adouble* avector;
+			IssmDouble* avector;
 		#endif
 
-		/*Vector constructors, destructors {{{1*/
+		/*Vector constructors, destructors {{{*/
 		Vector();
 		Vector(int M,bool fromlocalsize=false);
-		Vector(double* serial_vec,int pM);
+		Vector(IssmDouble* serial_vec,int pM);
 		#ifdef _HAVE_PETSC_
 		Vector(Vec petsc_vec);
@@ -48,23 +44,23 @@
 		~Vector();
 		/*}}}*/
-		/*Vector specific routines {{{1*/
+		/*Vector specific routines {{{*/
 		void Echo(void);
-		void    AXPY(Vector *X, double a);
-		void    AYPX(Vector *X, double a);
+		void    AXPY(Vector *X, IssmDouble a);
+		void    AYPX(Vector *X, IssmDouble a);
 		void    Assemble(void);
 		void    Copy(Vector *to);
-		double  Dot(Vector *vector);
+		IssmDouble  Dot(Vector *vector);
 		Vector *Duplicate(void);
-		void    GetValue(double *pvalue, int dof);
+		void    GetValue(IssmDouble *pvalue, int dof);
 		void    GetSize(int *pM);
 		void    GetLocalSize(int *pM);
 		bool    IsEmpty(void);
-		double  Norm(NormMode norm_type);
+		IssmDouble  Norm(NormMode norm_type);
 		void    PointwiseDivide(Vector  *x,Vector*y);
-		void    Scale(double scale_factor);
-		void    Set(double value);
-		void    SetValues(int ssize, int *list, double*values, InsMode mode);
-		void    SetValue(int dof, double value, InsMode mode);
-		double *ToMPISerial(void);
+		void    Scale(IssmDouble scale_factor);
+		void    Set(IssmDouble value);
+		void    SetValues(int ssize, int *list, IssmDouble*values, InsMode mode);
+		void    SetValue(int dof, IssmDouble value, InsMode mode);
+		IssmDouble *ToMPISerial(void);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/Options/Option.cpp
===================================================================
--- /issm/trunk/src/c/objects/Options/Option.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/Option.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION Option::Option(){{{1*/
+/*FUNCTION Option::Option(){{{*/
 Option::Option(){
 
@@ -31,9 +31,9 @@
 }
 /*}}}*/
-/*FUNCTION Option::~Option(){{{1*/
+/*FUNCTION Option::~Option(){{{*/
 Option::~Option(){
 
-	if(size) xfree((void**)&size);
-	if(name) xfree((void**)&name);
+	if(size) xDelete<int>(size);
+	if(name) xDelete<char>(name);
 
 }
@@ -41,5 +41,5 @@
 
 /*Other*/
-/*FUNCTION Option::Echo {{{1*/
+/*FUNCTION Option::Echo {{{*/
 void  Option::Echo(){
 
@@ -47,15 +47,15 @@
 	bool  flag=true;
 
-	_printf_(flag,"          name: \"%s\"\n" ,name);
-	_printf_(flag,"         numel: %d\n"     ,numel);
-	_printf_(flag,"         ndims: %d\n"     ,ndims);
+	if(flag) _pprintLine_("          name: \"" << name << "\"");
+	if(flag) _pprintLine_("         numel: " << numel);
+	if(flag) _pprintLine_("         ndims: " << ndims);
 	if(size){
 		StringFromSize(cstr,size,ndims);
-		_printf_(flag,"          size: %s\n" ,cstr);
+		if(flag) _pprintLine_("          size: " << cstr);
 	}
-	else _printf_(flag,"          size: [empty]\n" );
+	else if(flag) _pprintLine_("          size: [empty]");
 }
 /*}}}*/
-/*FUNCTION Option::DeepEcho() {{{1*/
+/*FUNCTION Option::DeepEcho() {{{*/
 void  Option::DeepEcho(){
 
@@ -67,5 +67,5 @@
 }
 /*}}}*/
-/*FUNCTION Option::DeepEcho(char* indent) {{{1*/
+/*FUNCTION Option::DeepEcho(char* indent) {{{*/
 void  Option::DeepEcho(char* indent){
 
@@ -73,15 +73,15 @@
 	bool  flag=true;
 
-	_printf_(flag,"%s          name: \"%s\"\n" ,indent,name);
-	_printf_(flag,"%s         numel: %d\n"     ,indent,numel);
-	_printf_(flag,"%s         ndims: %d\n"     ,indent,ndims);
+	if(flag) _pprintLine_(indent << "          name: \"" << name << "\"");
+	if(flag) _pprintLine_(indent << "         numel: " << numel);
+	if(flag) _pprintLine_(indent << "         ndims: " << ndims);
 	if(size){
 		StringFromSize(cstr,size,ndims);
-		_printf_(flag,"%s          size: %s\n" ,indent,cstr);
+		if(flag) _pprintLine_(indent << "          size: " << cstr);
 	}
-	else _printf_(flag,"%s          size: [empty]\n" ,indent);
+	else if(flag) _pprintLine_(indent << "          size: [empty]");
 }
 /*}}}*/
-/*FUNCTION Option::Name {{{1*/
+/*FUNCTION Option::Name {{{*/
 char* Option::Name(){
 
@@ -89,5 +89,5 @@
 }
 /*}}}*/
-/*FUNCTION Option::NumEl {{{1*/
+/*FUNCTION Option::NumEl {{{*/
 int   Option::NumEl(){
 
@@ -95,5 +95,5 @@
 }
 /*}}}*/
-/*FUNCTION Option::NDims {{{1*/
+/*FUNCTION Option::NDims {{{*/
 int   Option::NDims(){
 
@@ -101,5 +101,5 @@
 }
 /*}}}*/
-/*FUNCTION Option::Size {{{1*/
+/*FUNCTION Option::Size {{{*/
 int*  Option::Size(){
 
@@ -107,5 +107,5 @@
 }
 /*}}}*/
-/*FUNCTION Option::Get {{{1*/
+/*FUNCTION Option::Get {{{*/
 //void* Option::Get(){
 
Index: /issm/trunk/src/c/objects/Options/Option.h
===================================================================
--- /issm/trunk/src/c/objects/Options/Option.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/Option.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _OPTIONOBJECT_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -23,16 +23,16 @@
 		int*  size;
 
-		/*Option constructors, destructors {{{1*/
+		/*Option constructors, destructors {{{*/
 		Option();
 		~Option();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		virtual void  Echo();
 		virtual void  DeepEcho();
 		virtual void  DeepEcho(char* indent);
-		int   Id(){_error_("Not implemented yet");};
-		int   MyRank(){_error_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");};
+		int   MyRank(){_error2_("Not implemented yet");};
 		int   ObjectEnum(){return OptionEnum;};
-		Object* copy(){_error_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 		/*}}}*/
 
@@ -43,9 +43,9 @@
 		virtual int*  Size()=0;
 		virtual void  Get(int* pvalue)=0;
-		virtual void  Get(double* pvalue)=0;
+		virtual void  Get(IssmDouble* pvalue)=0;
 		virtual void  Get(bool* pvalue)=0;
 		virtual void  Get(char** pvalue)=0;
 		virtual void  Get(char*** ppvalue,int *pnumel)=0;
-		virtual void  Get(double** pvalue,int *pnumel)=0;
+		virtual void  Get(IssmDouble** pvalue,int *pnumel)=0;
 		virtual void  Get(Options** pvalue)=0;
 		virtual void  Get(Options*** ppvalue,int *pnumel)=0;
Index: /issm/trunk/src/c/objects/Options/OptionCell.cpp
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionCell.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionCell.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION OptionCell::OptionCell(){{{1*/
+/*FUNCTION OptionCell::OptionCell(){{{*/
 OptionCell::OptionCell(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionCell::~OptionCell(){{{1*/
+/*FUNCTION OptionCell::~OptionCell(){{{*/
 OptionCell::~OptionCell(){
 
@@ -40,5 +40,5 @@
 
 /*Other*/
-/*FUNCTION OptionCell::Echo {{{1*/
+/*FUNCTION OptionCell::Echo {{{*/
 void  OptionCell::Echo(){
 
@@ -46,15 +46,15 @@
 	bool flag     = true;
 
-	_printf_(flag,"OptionCell Echo:\n");
+	if(flag) _pprintLine_("OptionCell Echo:");
 	Option::Echo();
 
 	if (values && size) {
 		StringFromSize(cstr,size,ndims);
-		_printf_(flag,"        values: %s %s\n" ,cstr,"cell");
+		if(flag) _pprintLine_("        values: " << cstr << " " << "cell");
 	}
-	else _printf_(flag,"        values: [empty]\n" );
+	else if(flag) _pprintLine_("        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionCell::DeepEcho() {{{1*/
+/*FUNCTION OptionCell::DeepEcho() {{{*/
 void  OptionCell::DeepEcho(){
 
@@ -66,5 +66,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionCell::DeepEcho(char* indent) {{{1*/
+/*FUNCTION OptionCell::DeepEcho(char* indent) {{{*/
 void  OptionCell::DeepEcho(char* indent){
 
@@ -75,25 +75,25 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sOptionCell DeepEcho:\n",indent);
+	if(flag) _pprintLine_(indent << "OptionCell DeepEcho:");
 	Option::DeepEcho(indent);
 
-	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
+	xMemCpy<char>(indent2,indent,(strlen(indent)+1));
 	strcat(indent2,"  ");
 
 	if (values->Size()) {
-		dims=(int *) xmalloc(ndims*sizeof(int));
+		dims=xNew<int>(ndims);
 		for (i=0; i<values->Size(); i++) {
 			ColumnWiseDimsFromIndex(dims,i,size,ndims);
 			StringFromDims(cstr,dims,ndims);
-			_printf_(flag,"%s        values: -------- begin %s --------\n" ,indent,cstr);
+			if(flag) _pprintLine_(indent << "        values: -------- begin " << cstr << " --------");
 			((Option *)values->GetObjectByOffset(i))->DeepEcho(indent2);
-			_printf_(flag,"%s        values: --------  end  %s --------\n" ,indent,cstr);
+			if(flag) _pprintLine_(indent << "        values: --------  end  " << cstr << " --------");
 		}
-		xfree((void**)&dims);
+		xDelete<int>(dims);
 	}
-	else _printf_(flag,"%s        values: [empty]\n" ,indent);
+	else if(flag) _pprintLine_(indent << "        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionCell::Name {{{1*/
+/*FUNCTION OptionCell::Name {{{*/
 char* OptionCell::Name(){
 
@@ -101,5 +101,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionCell::NumEl {{{1*/
+/*FUNCTION OptionCell::NumEl {{{*/
 int   OptionCell::NumEl(){
 
@@ -107,5 +107,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionCell::NDims {{{1*/
+/*FUNCTION OptionCell::NDims {{{*/
 int   OptionCell::NDims(){
 
@@ -113,5 +113,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionCell::Size {{{1*/
+/*FUNCTION OptionCell::Size {{{*/
 int*  OptionCell::Size(){
 
@@ -119,5 +119,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionCell::Get(Options** pvalue) {{{1*/
+/*FUNCTION OptionCell::Get(Options** pvalue) {{{*/
 void OptionCell::Get(Options** pvalue){
 
Index: /issm/trunk/src/c/objects/Options/OptionCell.h
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionCell.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionCell.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _OPTIONCELL_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -20,16 +20,16 @@
 		Options* values;
 
-		/*OptionCell constructors, destructors {{{1*/
+		/*OptionCell constructors, destructors {{{*/
 		OptionCell();
 		~OptionCell();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
 		void  DeepEcho(char* indent);
-		int   Id(){_error_("Not implemented yet");};
-		int   MyRank(){_error_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");};
+		int   MyRank(){_error2_("Not implemented yet");};
 		int   ObjectEnum(){return OptionCellEnum;};
-		Object* copy(){_error_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 		/*}}}*/
 
@@ -39,12 +39,12 @@
 		int   NDims();
 		int*  Size();
-		void  Get(int* pvalue){_error_("An OptionCell object cannot return a int");};
-		void  Get(double* pvalue){_error_("An OptionCell object cannot return a double");};
-		void  Get(bool* pvalue){  _error_("An OptionCell object cannot return a bool");};
-		void  Get(char** pvalue){ _error_("An OptionCell object cannot return a string");};
-		void  Get(char*** ppvalue,int *pnumel){ _error_("An OptionCell object cannot return a string vec");};
-		void  Get(double** pvalue,int *pnumel){ _error_("An OptionCell object cannot return a double vec");};
+		void  Get(int* pvalue){_error2_("An OptionCell object cannot return a int");};
+		void  Get(IssmDouble* pvalue){_error2_("An OptionCell object cannot return a IssmDouble");};
+		void  Get(bool* pvalue){  _error2_("An OptionCell object cannot return a bool");};
+		void  Get(char** pvalue){ _error2_("An OptionCell object cannot return a string");};
+		void  Get(char*** ppvalue,int *pnumel){ _error2_("An OptionCell object cannot return a string vec");};
+		void  Get(IssmDouble** pvalue,int *pnumel){ _error2_("An OptionCell object cannot return a IssmDouble vec");};
 		void  Get(Options** pvalue);
-		void  Get(Options*** ppvalue,int *pnumel){ _error_("An OptionCell object cannot return an Options DataSet vec");};
+		void  Get(Options*** ppvalue,int *pnumel){ _error2_("An OptionCell object cannot return an Options DataSet vec");};
 
 };
Index: /issm/trunk/src/c/objects/Options/OptionChar.cpp
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionChar.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionChar.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION OptionChar::OptionChar(){{{1*/
+/*FUNCTION OptionChar::OptionChar(){{{*/
 OptionChar::OptionChar(){
 
@@ -28,8 +28,8 @@
 }
 /*}}}*/
-/*FUNCTION OptionChar::~OptionChar(){{{1*/
+/*FUNCTION OptionChar::~OptionChar(){{{*/
 OptionChar::~OptionChar(){
 
-	if (values) xfree((void**)&values);
+	if (values) xDelete<char>(values);
 
 }
@@ -37,5 +37,5 @@
 
 /*Other*/
-/*FUNCTION OptionChar::Echo {{{1*/
+/*FUNCTION OptionChar::Echo {{{*/
 void  OptionChar::Echo(){
 
@@ -43,5 +43,5 @@
 	bool  flag=true;
 
-	_printf_(flag,"OptionChar Echo:\n");
+	if(flag) _pprintLine_("OptionChar Echo:");
 	Option::Echo();
 
@@ -49,16 +49,16 @@
 //		if (numel == 1) {
 		if (1) {
-//			_printf_(flag,"        values: \"%s\"\n" ,values[0]);
-			_printf_(flag,"        values: \"%s\"\n" ,values);
+//			if(flag) _pprintLine_("        values: \"" << values[0] << "\"");
+			if(flag) _pprintLine_("        values: \"" << values << "\"");
 		}
 		else {
 			StringFromSize(cstr,size,ndims);
-			_printf_(flag,"        values: %s %s\n" ,cstr,"char");
+			if(flag) _pprintLine_("        values: " << cstr << " " << "char");
 		}
 	}
-	else _printf_(flag,"        values: [empty]\n" );
+	else if(flag) _pprintLine_("        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionChar::DeepEcho() {{{1*/
+/*FUNCTION OptionChar::DeepEcho() {{{*/
 void  OptionChar::DeepEcho(){
 
@@ -70,5 +70,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionChar::DeepEcho(char* indent) {{{1*/
+/*FUNCTION OptionChar::DeepEcho(char* indent) {{{*/
 void  OptionChar::DeepEcho(char* indent){
 
@@ -79,13 +79,13 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sOptionChar DeepEcho:\n",indent);
+	if(flag) _pprintLine_(indent << "OptionChar DeepEcho:");
 	Option::DeepEcho(indent);
 
-	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
+	xMemCpy<char>(indent2,indent,(strlen(indent)+1));
 	strcat(indent2,"  ");
 
 	if (values) {
 		if (ndims == 2 && size[0] == 1) {
-			_printf_(flag,"%s        values: \"%s\"\n" ,indent,values);
+			if(flag) _pprintLine_(indent << "        values: \"" << values << "\"");
 		}
 		else {
@@ -93,18 +93,18 @@
 			for (i=2; i<ndims; i++) nstr*=size[i];
 
-			dims=(int *) xmalloc(ndims*sizeof(int));
+			dims=xNew<int>(ndims);
 			for (i=0; i<nstr; i++) {
 				RowWiseDimsFromIndex(dims,ipt,size,ndims);
 				StringFromDims(cstr,dims,ndims);
-				_printf_(flag,"%s        values%s: \"%.*s\"\n" ,indent,cstr,size[1],&(values[ipt]));
+				if(flag) _pprintLine_(indent << "        values" << cstr << ": \"" << size[1] << "*s\"");
 				ipt+=size[1];
 			}
-			xfree((void**)&dims);
+			xDelete<int>(dims);
 		}
 	}
-	else _printf_(flag,"%s        values: [empty]\n" ,indent);
+	else if(flag) _pprintLine_(indent << "        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionChar::Name {{{1*/
+/*FUNCTION OptionChar::Name {{{*/
 char* OptionChar::Name(){
 
@@ -112,5 +112,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionChar::NumEl {{{1*/
+/*FUNCTION OptionChar::NumEl {{{*/
 int   OptionChar::NumEl(){
 
@@ -118,5 +118,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionChar::NDims {{{1*/
+/*FUNCTION OptionChar::NDims {{{*/
 int   OptionChar::NDims(){
 
@@ -124,5 +124,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionChar::Size {{{1*/
+/*FUNCTION OptionChar::Size {{{*/
 int*  OptionChar::Size(){
 
@@ -130,5 +130,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionChar::Get(char** pvalue) {{{1*/
+/*FUNCTION OptionChar::Get(char** pvalue) {{{*/
 void OptionChar::Get(char** pvalue){
 
@@ -138,11 +138,11 @@
 	stringsize=strlen(this->values)+1;
 
-	outstring=(char*)xmalloc(stringsize*sizeof(char));
-	memcpy(outstring,this->values,stringsize*sizeof(char));
+	outstring=xNew<char>(stringsize);
+	xMemCpy<char>(outstring,this->values,stringsize);
 
 	*pvalue=outstring;
 }
 /*}}}*/
-/*FUNCTION OptionChar::Get(char*** ppvalue,int *pnumel) {{{1*/
+/*FUNCTION OptionChar::Get(char*** ppvalue,int *pnumel) {{{*/
 void OptionChar::Get(char*** ppvalue,int *pnumel){
 
@@ -153,5 +153,5 @@
 	/*We should first check that the size is at least one*/
 	if(this->NumEl()<=0){
-		_error_("option \"%s\" is empty and cannot return a string vector",this->name);
+		_error2_("option \"" << this->name << "\" is empty and cannot return a string vector");
 	}
 
@@ -162,8 +162,8 @@
 
 	/*Break concatenated string into individual strings*/
-	*ppvalue=(char **) xmalloc(nstr*sizeof(char *));
+	*ppvalue=xNew<char*>(nstr);
 	for (i=0; i<nstr; i++) {
-		outstring=(char*)xmalloc(stringsize*sizeof(char));
-		memcpy(outstring,&(this->values[ipt]),(stringsize-1)*sizeof(char));
+		outstring=xNew<char>(stringsize);
+		xMemCpy<char>(outstring,&(this->values[ipt]),(stringsize-1));
 		outstring[stringsize-1]='\0';
 		(*ppvalue)[i]=outstring;
Index: /issm/trunk/src/c/objects/Options/OptionChar.h
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionChar.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionChar.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _OPTIONCHAR_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -20,16 +20,16 @@
 		char* values;
 
-		/*OptionChar constructors, destructors {{{1*/
+		/*OptionChar constructors, destructors {{{*/
 		OptionChar();
 		~OptionChar();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
 		void  DeepEcho(char* indent);
-		int   Id(){_error_("Not implemented yet");};
-		int   MyRank(){_error_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");};
+		int   MyRank(){_error2_("Not implemented yet");};
 		int   ObjectEnum(){return OptionCharEnum;};
-		Object* copy(){_error_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 		/*}}}*/
 
@@ -39,12 +39,12 @@
 		int   NDims();
 		int*  Size();
-		void  Get(int* pvalue){_error_("An OptionChar object cannot return a int");};
-		void  Get(double* pvalue){_error_("An OptionChar object cannot return a double");};
-		void  Get(bool* pvalue){  _error_("An OptionChar object cannot return a bool");};
+		void  Get(int* pvalue){_error2_("An OptionChar object cannot return a int");};
+		void  Get(IssmDouble* pvalue){_error2_("An OptionChar object cannot return a IssmDouble");};
+		void  Get(bool* pvalue){  _error2_("An OptionChar object cannot return a bool");};
 		void  Get(char** pvalue);
 		void  Get(char*** ppvalue,int *pnumel);
-		void  Get(double** pvalue,int *pnumel){ _error_("An OptionChar object cannot return a double vec");};
-		void  Get(Options** pvalue){ _error_("An OptionChar object cannot return an Options DataSet");};
-		void  Get(Options*** ppvalue,int *pnumel){ _error_("An OptionChar object cannot return an Options DataSet vec");};
+		void  Get(IssmDouble** pvalue,int *pnumel){ _error2_("An OptionChar object cannot return a IssmDouble vec");};
+		void  Get(Options** pvalue){ _error2_("An OptionChar object cannot return an Options DataSet");};
+		void  Get(Options*** ppvalue,int *pnumel){ _error2_("An OptionChar object cannot return an Options DataSet vec");};
 
 };
Index: /issm/trunk/src/c/objects/Options/OptionDouble.cpp
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionDouble.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionDouble.cpp	(revision 12706)
@@ -1,8 +1,8 @@
 /*!\file OptionDouble.cpp
- * \brief: implementation of the optionsdouble object
+ * \brief: implementation of the optionsIssmDouble object
  */
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION OptionDouble::OptionDouble(){{{1*/
+/*FUNCTION OptionDouble::OptionDouble(){{{*/
 OptionDouble::OptionDouble(){
 
@@ -28,8 +28,8 @@
 }
 /*}}}*/
-/*FUNCTION OptionDouble::~OptionDouble(){{{1*/
+/*FUNCTION OptionDouble::~OptionDouble(){{{*/
 OptionDouble::~OptionDouble(){
 
-	if (values) xfree((void**)&values);
+	if (values) xDelete<IssmDouble>(values);
 
 }
@@ -37,5 +37,5 @@
 
 /*Other*/
-/*FUNCTION OptionDouble::Echo {{{1*/
+/*FUNCTION OptionDouble::Echo {{{*/
 void  OptionDouble::Echo(){
 
@@ -43,18 +43,18 @@
 	bool  flag=true;
 
-	_printf_(flag,"OptionDouble Echo:\n");
+	if(flag) _pprintLine_("OptionDouble Echo:");
 	Option::Echo();
 
 	if (values && size) {
-		if(numel == 1) _printf_(flag,"        values: %g\n" ,values[0]);
+		if(numel == 1) if(flag) _pprintLine_("        values: " << values[0]);
 		else {
 			StringFromSize(cstr,size,ndims);
-			_printf_(flag,"        values: %s %s\n" ,cstr,"double");
+			if(flag) _pprintLine_("        values: " << cstr << " " << "IssmDouble");
 		}
 	}
-	else _printf_(flag,"        values: [empty]\n" );
+	else if(flag) _pprintLine_("        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionDouble::DeepEcho() {{{1*/
+/*FUNCTION OptionDouble::DeepEcho() {{{*/
 void  OptionDouble::DeepEcho(){
 
@@ -66,5 +66,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionDouble::DeepEcho(char* indent) {{{1*/
+/*FUNCTION OptionDouble::DeepEcho(char* indent) {{{*/
 void  OptionDouble::DeepEcho(char* indent){
 
@@ -75,26 +75,26 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sOptionDouble DeepEcho:\n",indent);
+	if(flag) _pprintLine_(indent << "OptionDouble DeepEcho:");
 	Option::DeepEcho(indent);
 
-	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
+	xMemCpy<char>(indent2,indent,(strlen(indent)+1));
 	strcat(indent2,"  ");
 
 	if (values) {
-		dims=(int *) xmalloc(ndims*sizeof(int));
-		if(numel==1) _printf_(flag,"%s        values: %g\n" ,indent,values[0]);
+		dims=xNew<int>(ndims);
+		if(numel==1) if(flag) _pprintLine_(indent << "        values: " << values[0]);
 		else{
 			for (i=0; i<numel; i++) {
 				RowWiseDimsFromIndex(dims,i,size,ndims);
 				StringFromDims(cstr,dims,ndims);
-				_printf_(flag,"%s        values%s: %g\n" ,indent,cstr,values[i]);
+				if(flag) _pprintLine_(indent << "        values" << cstr << ": " << values[i]);
 			}
 		}
-		xfree((void**)&dims);
+		xDelete<int>(dims);
 	}
-	else _printf_(flag,"%s        values: [empty]\n" ,indent);
+	else if(flag) _pprintLine_(indent << "        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionDouble::Name {{{1*/
+/*FUNCTION OptionDouble::Name {{{*/
 char* OptionDouble::Name(){
 
@@ -102,5 +102,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionDouble::NumEl {{{1*/
+/*FUNCTION OptionDouble::NumEl {{{*/
 int   OptionDouble::NumEl(){
 
@@ -108,5 +108,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionDouble::NDims {{{1*/
+/*FUNCTION OptionDouble::NDims {{{*/
 int   OptionDouble::NDims(){
 
@@ -114,5 +114,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionDouble::Size {{{1*/
+/*FUNCTION OptionDouble::Size {{{*/
 int*  OptionDouble::Size(){
 
@@ -120,22 +120,22 @@
 }
 /*}}}*/
-/*FUNCTION OptionDouble::Get(int* pvalue) {{{1*/
+/*FUNCTION OptionDouble::Get(int* pvalue) {{{*/
 void OptionDouble::Get(int* pvalue){
 
 	/*We should first check that the size is one*/
 	if(this->NumEl()!=1){
-		_error_("option \"%s\" has %i elements and cannot return a single int",this->name,this->NumEl());
+		_error2_("option \"" << this->name << "\" has " << this->NumEl() << " elements and cannot return a single int");
 	}
 
 	/*Assign output pointer*/
-	*pvalue=(int)this->values[0];
+	*pvalue=reCast<int>(values[0]);
 }
 /*}}}*/
-/*FUNCTION OptionDouble::Get(double* pvalue) {{{1*/
-void OptionDouble::Get(double* pvalue){
+/*FUNCTION OptionDouble::Get(IssmDouble* pvalue) {{{*/
+void OptionDouble::Get(IssmDouble* pvalue){
 
 	/*We should first check that the size is one*/
 	if(this->NumEl()!=1){
-		_error_("option \"%s\" has %i elements and cannot return a single double",this->name,this->NumEl());
+		_error2_("option \"" << this->name << "\" has " << this->NumEl() << " elements and cannot return a single IssmDouble");
 	}
 
@@ -144,14 +144,14 @@
 }
 /*}}}*/
-/*FUNCTION OptionDouble::Get(double** pvalue,int* numel) {{{1*/
-void OptionDouble::Get(double** pvalue,int* numel){
+/*FUNCTION OptionDouble::Get(IssmDouble** pvalue,int* numel) {{{*/
+void OptionDouble::Get(IssmDouble** pvalue,int* numel){
 
 	/*We should first check that the size is at least one*/
 	if(this->NumEl()<=0){
-		_error_("option \"%s\" is empty and cannot return a double vector",this->name);
+		_error2_("option \"" << this->name << "\" is empty and cannot return a IssmDouble vector");
 	}
 
 	/*Copy vector*/
-	double* outvalue=(double*)xmalloc(this->NumEl()*sizeof(double));
+	IssmDouble* outvalue=xNew<IssmDouble>(this->NumEl());
 	for(int i=0;i<this->NumEl();i++) outvalue[i]=this->values[i];
 
Index: /issm/trunk/src/c/objects/Options/OptionDouble.h
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionDouble.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionDouble.h	(revision 12706)
@@ -1,4 +1,4 @@
 /*! \file OptionDouble.h 
- *  \brief: header file for optiondouble object
+ *  \brief: header file for optionIssmDouble object
  */
 
@@ -6,5 +6,5 @@
 #define _OPTIONDOUBLE_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -18,18 +18,18 @@
 	public:
 
-		double* values;
+		IssmDouble* values;
 
-		/*OptionDouble constructors, destructors {{{1*/
+		/*OptionDouble constructors, destructors {{{*/
 		OptionDouble();
 		~OptionDouble();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
 		void  DeepEcho(char* indent);
-		int   Id(){_error_("Not implemented yet");};
-		int   MyRank(){_error_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");};
+		int   MyRank(){_error2_("Not implemented yet");};
 		int   ObjectEnum(){return OptionDoubleEnum;};
-		Object* copy(){_error_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 		/*}}}*/
 
@@ -40,11 +40,11 @@
 		int*  Size();
 		void  Get(int* pvalue);
-		void  Get(double* pvalue);
-		void  Get(bool* pvalue){  _error_("An OptionDouble object cannot return a bool");};
-		void  Get(char** pvalue){ _error_("An OptionDouble object cannot return a string");};
-		void  Get(char*** ppvalue,int *pnumel){ _error_("An OptionDouble object cannot return a string vec");};
-		void  Get(double** pvalue,int* pnumel);
-		void  Get(Options** pvalue){ _error_("An OptionDouble object cannot return an Options DataSet");};
-		void  Get(Options*** ppvalue,int *pnumel){ _error_("An OptionDouble object cannot return an Options DataSet vec");};
+		void  Get(IssmDouble* pvalue);
+		void  Get(bool* pvalue){  _error2_("An OptionDouble object cannot return a bool");};
+		void  Get(char** pvalue){ _error2_("An OptionDouble object cannot return a string");};
+		void  Get(char*** ppvalue,int *pnumel){ _error2_("An OptionDouble object cannot return a string vec");};
+		void  Get(IssmDouble** pvalue,int* pnumel);
+		void  Get(Options** pvalue){ _error2_("An OptionDouble object cannot return an Options DataSet");};
+		void  Get(Options*** ppvalue,int *pnumel){ _error2_("An OptionDouble object cannot return an Options DataSet vec");};
 
 };
Index: /issm/trunk/src/c/objects/Options/OptionLogical.cpp
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionLogical.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionLogical.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION OptionLogical::OptionLogical(){{{1*/
+/*FUNCTION OptionLogical::OptionLogical(){{{*/
 OptionLogical::OptionLogical(){
 
@@ -28,8 +28,8 @@
 }
 /*}}}*/
-/*FUNCTION OptionLogical::~OptionLogical(){{{1*/
+/*FUNCTION OptionLogical::~OptionLogical(){{{*/
 OptionLogical::~OptionLogical(){
 
-	if (values) xfree((void**)&values);
+	if (values) xDelete<bool>(values);
 
 }
@@ -37,5 +37,5 @@
 
 /*Other*/
-/*FUNCTION OptionLogical::Echo {{{1*/
+/*FUNCTION OptionLogical::Echo {{{*/
 void  OptionLogical::Echo(){
 
@@ -43,18 +43,18 @@
 	bool  flag=true;
 
-	_printf_(flag,"OptionLogical Echo:\n");
+	if(flag) _pprintLine_("OptionLogical Echo:");
 	Option::Echo();
 
 	if (values && size) {
-		if(numel == 1) _printf_(flag,"        values: %s\n" ,(values[0] ? "true" : "false"));
+		if(numel == 1) if(flag) _pprintLine_("        values: " << (values[0] ? "true" : "false"));
 		else{
 			StringFromSize(cstr,size,ndims);
-			_printf_(flag,"        values: %s %s\n" ,cstr,"logical");
+			if(flag) _pprintLine_("        values: " << cstr << " " << "logical");
 		}
 	}
-	else _printf_(flag,"        values: [empty]\n" );
+	else if(flag) _pprintLine_("        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionLogical::DeepEcho() {{{1*/
+/*FUNCTION OptionLogical::DeepEcho() {{{*/
 void  OptionLogical::DeepEcho(){
 
@@ -66,5 +66,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionLogical::DeepEcho(char* indent) {{{1*/
+/*FUNCTION OptionLogical::DeepEcho(char* indent) {{{*/
 void  OptionLogical::DeepEcho(char* indent){
 
@@ -75,26 +75,26 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sOptionLogical DeepEcho:\n",indent);
+	if(flag) _pprintLine_(indent << "OptionLogical DeepEcho:");
 	Option::DeepEcho(indent);
 
-	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
+	xMemCpy<char>(indent2,indent,(strlen(indent)+1));
 	strcat(indent2,"  ");
 
 	if (values) {
-		if(numel==1) _printf_(flag,"%s        values: %s\n" ,indent,(values[0] ? "true" : "false"));
+		if(numel==1) if(flag) _pprintLine_(indent << "        values: " << (values[0] ? "true" : "false"));
 		else{
-			dims=(int *) xmalloc(ndims*sizeof(int));
+			dims=xNew<int>(ndims);
 			for (i=0; i<numel; i++) {
 				RowWiseDimsFromIndex(dims,i,size,ndims);
 				StringFromDims(cstr,dims,ndims);
-				_printf_(flag,"%s        values%s: %s\n" ,indent,cstr,(values[i] ? "true" : "false"));
+				if(flag) _pprintLine_(indent << "        values" << cstr << ": " << (values[i] ? "true" : "false"));
 			}
-			xfree((void**)&dims);
+			xDelete<int>(dims);
 		}
 	}
-	else _printf_(flag,"%s        values: [empty]\n" ,indent);
+	else if(flag) _pprintLine_(indent << "        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionLogical::Name {{{1*/
+/*FUNCTION OptionLogical::Name {{{*/
 char* OptionLogical::Name(){
 
@@ -102,5 +102,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionLogical::NumEl {{{1*/
+/*FUNCTION OptionLogical::NumEl {{{*/
 int   OptionLogical::NumEl(){
 
@@ -108,5 +108,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionLogical::NDims {{{1*/
+/*FUNCTION OptionLogical::NDims {{{*/
 int   OptionLogical::NDims(){
 
@@ -114,5 +114,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionLogical::Size {{{1*/
+/*FUNCTION OptionLogical::Size {{{*/
 int*  OptionLogical::Size(){
 
@@ -120,10 +120,10 @@
 }
 /*}}}*/
-/*FUNCTION OptionLogical::Get(bool* pvalue) {{{1*/
+/*FUNCTION OptionLogical::Get(bool* pvalue) {{{*/
 void OptionLogical::Get(bool* pvalue){
 
 	/*We should first check that the size is one*/
 	if(this->NumEl()!=1){
-		_error_("option \"%s\" has %i elements and cannot return a single bool",this->name,this->NumEl());
+		_error2_("option \"" << this->name << "\" has " << this->NumEl() << " elements and cannot return a single bool");
 	}
 
Index: /issm/trunk/src/c/objects/Options/OptionLogical.h
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionLogical.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionLogical.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _OPTIONLOGICAL_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -20,16 +20,16 @@
 		bool* values;
 
-		/*OptionLogical constructors, destructors {{{1*/
+		/*OptionLogical constructors, destructors {{{*/
 		OptionLogical();
 		~OptionLogical();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
 		void  DeepEcho(char* indent);
-		int   Id(){_error_("Not implemented yet");};
-		int   MyRank(){_error_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");};
+		int   MyRank(){_error2_("Not implemented yet");};
 		int   ObjectEnum(){return OptionLogicalEnum;};
-		Object* copy(){_error_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 		/*}}}*/
 
@@ -39,12 +39,12 @@
 		int   NDims();
 		int*  Size();
-		void  Get(int* pvalue){_error_("An OptionLogical object cannot return a int");};
-		void  Get(double* pvalue){_error_("An OptionLogical object cannot return a double");};
+		void  Get(int* pvalue){_error2_("An OptionLogical object cannot return a int");};
+		void  Get(IssmDouble* pvalue){_error2_("An OptionLogical object cannot return a IssmDouble");};
 		void  Get(bool* pvalue);
-		void  Get(char** pvalue){ _error_("An OptionLogical object cannot return a string");};
-		void  Get(char*** ppvalue,int *pnumel){ _error_("An OptionLogical object cannot return a string vec");};
-		void  Get(double** pvalue,int *pnumel){ _error_("An OptionLogical object cannot return a double vec");};
-		void  Get(Options** pvalue){ _error_("An OptionLogical object cannot return an Options DataSet");};
-		void  Get(Options*** ppvalue,int *pnumel){ _error_("An OptionLogical object cannot return an Options DataSet vec");};
+		void  Get(char** pvalue){ _error2_("An OptionLogical object cannot return a string");};
+		void  Get(char*** ppvalue,int *pnumel){ _error2_("An OptionLogical object cannot return a string vec");};
+		void  Get(IssmDouble** pvalue,int *pnumel){ _error2_("An OptionLogical object cannot return a IssmDouble vec");};
+		void  Get(Options** pvalue){ _error2_("An OptionLogical object cannot return an Options DataSet");};
+		void  Get(Options*** ppvalue,int *pnumel){ _error2_("An OptionLogical object cannot return an Options DataSet vec");};
 
 };
Index: /issm/trunk/src/c/objects/Options/OptionStruct.cpp
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionStruct.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionStruct.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,5 +21,5 @@
 
 /*Constructors/destructor/copy*/
-/*FUNCTION OptionStruct::OptionStruct(){{{1*/
+/*FUNCTION OptionStruct::OptionStruct(){{{*/
 OptionStruct::OptionStruct(){
 
@@ -28,5 +28,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionStruct::~OptionStruct(){{{1*/
+/*FUNCTION OptionStruct::~OptionStruct(){{{*/
 OptionStruct::~OptionStruct(){
 
@@ -38,5 +38,5 @@
 			values[i] =NULL;
 		}
-		xfree((void**)&values);
+		xDelete<Options*>(values);
 	}
 
@@ -45,5 +45,5 @@
 
 /*Other*/
-/*FUNCTION OptionStruct::Echo {{{1*/
+/*FUNCTION OptionStruct::Echo {{{*/
 void  OptionStruct::Echo(){
 
@@ -51,15 +51,15 @@
 	bool  flag=true;
 
-	_printf_(flag,"OptionStruct Echo:\n");
+	if(flag) _pprintLine_("OptionStruct Echo:");
 	Option::Echo();
 
 	if (values && size) {
 		StringFromSize(cstr,size,ndims);
-		_printf_(flag,"        values: %s %s\n" ,cstr,"struct");
+		if(flag) _pprintLine_("        values: " << cstr << " " << "struct");
 	}
-	else _printf_(flag,"        values: [empty]\n" );
+	else if(flag) _pprintLine_("        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionStruct::DeepEcho() {{{1*/
+/*FUNCTION OptionStruct::DeepEcho() {{{*/
 void  OptionStruct::DeepEcho(){
 
@@ -71,5 +71,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionStruct::DeepEcho(char* indent) {{{1*/
+/*FUNCTION OptionStruct::DeepEcho(char* indent) {{{*/
 void  OptionStruct::DeepEcho(char* indent){
 
@@ -80,28 +80,28 @@
 	bool  flag=true;
 
-	_printf_(flag,"%sOptionStruct DeepEcho:\n",indent);
+	if(flag) _pprintLine_(indent << "OptionStruct DeepEcho:");
 	Option::DeepEcho(indent);
 
-	memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
+	xMemCpy<char>(indent2,indent,(strlen(indent)+1));
 	strcat(indent2,"  ");
 
 	if (values) {
-		dims=(int *)xmalloc(ndims*sizeof(int));
+		dims=xNew<int>(ndims);
 		for (i=0; i<numel; i++) {
 			ColumnWiseDimsFromIndex(dims,i,size,ndims);
 			StringFromDims(cstr,dims,ndims);
 			if (values[i]->Size()){
-				_printf_(flag,"%s        values: -------- begin %s --------\n" ,indent,cstr);
+				if(flag) _pprintLine_(indent << "        values: -------- begin " << cstr << " --------");
 				for (j=0; j<values[i]->Size(); j++) ((Option *)values[i]->GetObjectByOffset(j))->DeepEcho(indent2);
-				_printf_(flag,"%s        values: --------  end  %s --------\n" ,indent,cstr);
+				if(flag) _pprintLine_(indent << "        values: --------  end  " << cstr << " --------");
 			}
-			else _printf_(flag,"%s        values: %s [empty]\n" ,indent,cstr);
+			else if(flag) _pprintLine_(indent << "        values: " << cstr << " [empty]");
 		}
-		xfree((void**)&dims);
+		xDelete<int>(dims);
 	}
-	else _printf_(flag,"%s        values: [empty]\n" ,indent);
+	else if(flag) _pprintLine_(indent << "        values: [empty]");
 }
 /*}}}*/
-/*FUNCTION OptionStruct::Name {{{1*/
+/*FUNCTION OptionStruct::Name {{{*/
 char* OptionStruct::Name(){
 
@@ -109,5 +109,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionStruct::NumEl {{{1*/
+/*FUNCTION OptionStruct::NumEl {{{*/
 int   OptionStruct::NumEl(){
 
@@ -115,5 +115,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionStruct::NDims {{{1*/
+/*FUNCTION OptionStruct::NDims {{{*/
 int   OptionStruct::NDims(){
 
@@ -121,5 +121,5 @@
 }
 /*}}}*/
-/*FUNCTION OptionStruct::Size {{{1*/
+/*FUNCTION OptionStruct::Size {{{*/
 int*  OptionStruct::Size(){
 
@@ -127,10 +127,10 @@
 }
 /*}}}*/
-/*FUNCTION OptionStruct::Get(Options** pvalue) {{{1*/
+/*FUNCTION OptionStruct::Get(Options** pvalue) {{{*/
 void OptionStruct::Get(Options** pvalue){
 
 	/*We should first check that the size is one*/
 	if(this->NumEl()!=1){
-		_error_("option \"%s\" has %i elements and cannot return a single options dataset",this->name,this->NumEl());
+		_error2_("option \"" << this->name << "\" has " << this->NumEl() << " elements and cannot return a single options dataset");
 	}
 
@@ -139,10 +139,10 @@
 }
 /*}}}*/
-/*FUNCTION OptionStruct::Get(Options*** ppvalue,int* numel) {{{1*/
+/*FUNCTION OptionStruct::Get(Options*** ppvalue,int* numel) {{{*/
 void OptionStruct::Get(Options*** ppvalue,int* numel){
 
 	/*We should first check that the size is at least one*/
 	if(this->NumEl()<=0){
-		_error_("option \"%s\" is empty and cannot return an options dataset vector",this->name);
+		_error2_("option \"" << this->name << "\" is empty and cannot return an options dataset vector");
 	}
 
Index: /issm/trunk/src/c/objects/Options/OptionStruct.h
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionStruct.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionStruct.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _OPTIONSTRUCT_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
@@ -20,16 +20,16 @@
 		Options** values;
 
-		/*OptionStruct constructors, destructors {{{1*/
+		/*OptionStruct constructors, destructors {{{*/
 		OptionStruct();
 		~OptionStruct();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1*/
+		/*Object virtual functions definitions:{{{*/
 		void  Echo();
 		void  DeepEcho();
 		void  DeepEcho(char* indent);
-		int   Id(){_error_("Not implemented yet");};
-		int   MyRank(){_error_("Not implemented yet");};
+		int   Id(){_error2_("Not implemented yet");};
+		int   MyRank(){_error2_("Not implemented yet");};
 		int   ObjectEnum(){return OptionStructEnum;};
-		Object* copy(){_error_("Not implemented yet");};
+		Object* copy(){_error2_("Not implemented yet");};
 		/*}}}*/
 
@@ -39,10 +39,10 @@
 		int   NDims();
 		int*  Size();
-		void  Get(int* pvalue){_error_("An OptionStruct object cannot return a int");};
-		void  Get(double* pvalue){_error_("An OptionStruct object cannot return a double");};
-		void  Get(bool* pvalue){  _error_("An OptionStruct object cannot return a bool");};
-		void  Get(char** pvalue){ _error_("An OptionStruct object cannot return a string");};
-		void  Get(char*** ppvalue,int *pnumel){ _error_("An OptionStruct object cannot return a string vec");};
-		void  Get(double** pvalue,int *pnumel){ _error_("An OptionStruct object cannot return a double vec");};
+		void  Get(int* pvalue){_error2_("An OptionStruct object cannot return a int");};
+		void  Get(IssmDouble* pvalue){_error2_("An OptionStruct object cannot return a IssmDouble");};
+		void  Get(bool* pvalue){  _error2_("An OptionStruct object cannot return a bool");};
+		void  Get(char** pvalue){ _error2_("An OptionStruct object cannot return a string");};
+		void  Get(char*** ppvalue,int *pnumel){ _error2_("An OptionStruct object cannot return a string vec");};
+		void  Get(IssmDouble** pvalue,int *pnumel){ _error2_("An OptionStruct object cannot return a IssmDouble vec");};
 		void  Get(Options** pvalue);
 		void  Get(Options*** ppvalue,int *pnumel);
Index: /issm/trunk/src/c/objects/Options/OptionUtilities.cpp
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionUtilities.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionUtilities.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -19,5 +19,5 @@
 /*}}}*/
 
-/*FUNCTION ColumnWiseDimsFromIndex{{{1*/
+/*FUNCTION ColumnWiseDimsFromIndex{{{*/
 int ColumnWiseDimsFromIndex(int* dims,int index,int* size,int ndims){
 
@@ -27,10 +27,10 @@
 	/*check for index too large  */
 	for (i=0;i<ndims;i++) aprod*=size[i];
-	if (index >= aprod) _error_("Index %d exceeds number of elements %d.",index,aprod);
+	if (index >= aprod) _error2_("Index " << index << " exceeds number of elements " << aprod << ".");
 
 	/*calculate the dimensions (being careful of integer division)  */
 	for (i=ndims-1; i>=0; i--) {
-		aprod=(int)(((double)aprod+0.5)/(double)size[i]);
-		dims[i]=(int)floor(((double)index+0.5)/(double)aprod);
+		aprod=reCast<int>(((IssmPDouble)aprod+0.5)/(IssmPDouble)size[i]);
+		dims[i]=(int)floor(((IssmPDouble)index+0.5)/(IssmPDouble)aprod);
 		index-=dims[i]*aprod;
 	}
@@ -38,5 +38,5 @@
 	return(0);
 }/*}}}*/
-/*FUNCTION IndexFromColumnWiseDims{{{1*/
+/*FUNCTION IndexFromColumnWiseDims{{{*/
 int IndexFromColumnWiseDims(int* dims, int* size, int ndims) {
 
@@ -46,5 +46,5 @@
 	/*check for any dimension too large  */
 	for (i=0;i<ndims;i++){
-		if (dims[i] >= size[i]) _error_("Dimension %d of %d exceeds size of %d.",i,dims[i],size[i]);
+		if (dims[i] >= size[i]) _error2_("Dimension " << i << " of " << dims[i] << " exceeds size of " << size[i] << ".");
 	}
 
@@ -57,5 +57,5 @@
 	return(index);
 }/*}}}*/
-/*FUNCTION RowWiseDimsFromIndex{{{1*/
+/*FUNCTION RowWiseDimsFromIndex{{{*/
 int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims) {
 
@@ -65,10 +65,10 @@
 	/*check for index too large  */
 	for (i=0; i<ndims; i++) aprod*=size[i];
-	if (index >= aprod) _error_("Index %d exceeds number of elements %d.",index,aprod);
+	if (index >= aprod) _error2_("Index " << index << " exceeds number of elements " << aprod << ".");
 
 	/*calculate the dimensions (being careful of integer division)  */
 	for (i=0; i<ndims; i++) {
-		aprod=(int)(((double)aprod+0.5)/(double)size[i]);
-		dims[i]=(int)floor(((double)index+0.5)/(double)aprod);
+		aprod=(int)(((IssmPDouble)aprod+0.5)/(IssmPDouble)size[i]);
+		dims[i]=(int)floor(((IssmPDouble)index+0.5)/(IssmPDouble)aprod);
 		index-=dims[i]*aprod;
 	}
@@ -76,5 +76,5 @@
 	return(0);
 }/*}}}*/
-/*FUNCTION IndexFromRowWiseDims{{{1*/
+/*FUNCTION IndexFromRowWiseDims{{{*/
 int IndexFromRowWiseDims(int* dims, int* size, int ndims) {
 
@@ -84,5 +84,5 @@
 	/*check for any dimension too large  */
 	for (i=0; i<ndims; i++){
-		if (dims[i] >= size[i]) _error_("Dimension %d of %d exceeds size of %d.",i,dims[i],size[i]);
+		if (dims[i] >= size[i]) _error2_("Dimension " << i << " of " << dims[i] << " exceeds size of " << size[i] << ".");
 	}
 
@@ -95,5 +95,5 @@
 	return(index);
 }/*}}}*/
-/*FUNCTION StringFromDims{{{1*/
+/*FUNCTION StringFromDims{{{*/
 int StringFromDims(char* cstr, int* dims, int ndims) {
 
@@ -104,5 +104,5 @@
 	return(0);
 }/*}}}*/
-/*FUNCTION StringFromSize{{{1*/
+/*FUNCTION StringFromSize{{{*/
 int StringFromSize(char* cstr, int* size, int ndims) {
 
Index: /issm/trunk/src/c/objects/Options/OptionUtilities.h
===================================================================
--- /issm/trunk/src/c/objects/Options/OptionUtilities.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Options/OptionUtilities.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _OPTIONUTILITIES_H_
 
-/*Headers:{{{1*/
+/*Headers:{{{*/
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
Index: /issm/trunk/src/c/objects/Params/BoolParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/BoolParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/BoolParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,10 +21,10 @@
 
 /*BoolParam constructors and destructor*/
-/*FUNCTION BoolParam::BoolParam(){{{1*/
+/*FUNCTION BoolParam::BoolParam(){{{*/
 BoolParam::BoolParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION BoolParam::BoolParam(int enum_type,IssmBool value){{{1*/
+/*FUNCTION BoolParam::BoolParam(int enum_type,IssmBool value){{{*/
 BoolParam::BoolParam(int in_enum_type,IssmBool in_value){
 
@@ -33,5 +33,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolParam::~BoolParam(){{{1*/
+/*FUNCTION BoolParam::~BoolParam(){{{*/
 BoolParam::~BoolParam(){
 	return;
@@ -40,21 +40,21 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION BoolParam::Echo {{{1*/
+/*FUNCTION BoolParam::Echo {{{*/
 void BoolParam::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION BoolParam::DeepEcho{{{1*/
+/*FUNCTION BoolParam::DeepEcho{{{*/
 void BoolParam::DeepEcho(void){
 
-	printf("BoolParam:\n");
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %s\n",this->value?"true":"false");
+	_printLine_("BoolParam:");
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " <<(this->value?"true":"false"));
 }
 /*}}}*/
-/*FUNCTION BoolParam::Id{{{1*/
+/*FUNCTION BoolParam::Id{{{*/
 int    BoolParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION BoolParam::MyRank{{{1*/
+/*FUNCTION BoolParam::MyRank{{{*/
 int    BoolParam::MyRank(void){ 
 	extern int my_rank;
@@ -62,5 +62,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolParam::ObjectEnum{{{1*/
+/*FUNCTION BoolParam::ObjectEnum{{{*/
 int BoolParam::ObjectEnum(void){
 
@@ -69,5 +69,5 @@
 }
 /*}}}*/
-/*FUNCTION BoolParam::copy{{{1*/
+/*FUNCTION BoolParam::copy{{{*/
 Object* BoolParam::copy() {
 	
@@ -78,10 +78,10 @@
 
 /*BoolParam virtual functions definitions: */
-/*FUNCTION BoolParam::GetParameterName{{{1*/
+/*FUNCTION BoolParam::GetParameterName{{{*/
 void BoolParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION BoolParam::UnitConversion{{{1*/
+/*FUNCTION BoolParam::UnitConversion{{{*/
 void  BoolParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/BoolParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/BoolParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/BoolParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -27,10 +27,10 @@
 		IssmBool value;
 
-		/*BoolParam constructors, destructors: {{{1*/
+		/*BoolParam constructors, destructors: {{{*/
 		BoolParam();
 		BoolParam(int enum_type,IssmBool value);
 		~BoolParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -40,33 +40,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){*pbool=value;}
-		void  GetParameterValue(int* pinteger){_error_("Bool param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("Bool param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Bool param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("Bool param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("Bool param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Bool param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Bool param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Bool param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("Bool param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("Bool param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("Bool param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int* pinteger){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
 		void  SetValue(bool boolean){this->value=boolean;}
-		void  SetValue(int integer){this->value=(bool)integer;}
-		void  SetValue(double scalar){this->value=(bool)scalar;}
-		void  SetValue(char* string){_error_("Bool param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("Bool param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("Bool param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("Bool param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("Bool param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("Bool param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("Bool param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("Bool param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("Bool param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Bool param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int integer){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an int");}
+		void  SetValue(IssmDouble scalar){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an IssmPDouble");}
+		void  SetValue(char* string){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(int* intarray,int M){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(int* pintarray,int M,int N){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(Vector* vec){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 		
Index: /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,14 +21,14 @@
 
 /*DoubleMatArrayParam constructors and destructor*/
-/*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(){{{1*/
+/*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(){{{*/
 DoubleMatArrayParam::DoubleMatArrayParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(int enum_type,double** array, int M, int* mdim_array, int* ndim_array){{{1*/
-DoubleMatArrayParam::DoubleMatArrayParam(int in_enum_type,double** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
+/*FUNCTION DoubleMatArrayParam::DoubleMatArrayParam(int enum_type,IssmDouble** array, int M, int* mdim_array, int* ndim_array){{{*/
+DoubleMatArrayParam::DoubleMatArrayParam(int in_enum_type,IssmDouble** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
 
 	int i;
-	double* matrix=NULL;
+	IssmDouble* matrix=NULL;
 	int     m,n;
 
@@ -36,7 +36,7 @@
 	M=in_M;
 	if(M){
-		array=(double**)xmalloc(M*sizeof(double*));
-		mdim_array=(int*)xmalloc(M*sizeof(int));
-		ndim_array=(int*)xmalloc(M*sizeof(int));
+		array=xNew<IssmDouble*>(M);
+		mdim_array=xNew<int>(M);
+		ndim_array=xNew<int>(M);
 
 		for(i=0;i<M;i++){
@@ -48,6 +48,6 @@
 
 			if(m*n){
-				matrix=(double*)xmalloc(m*n*sizeof(double));
-				memcpy(matrix,in_array[i],m*n*sizeof(double));
+				matrix=xNew<IssmDouble>(m*n);
+				xMemCpy<IssmDouble>(matrix,in_array[i],m*n);
 			}
 			else{
@@ -64,19 +64,19 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::~DoubleMatArrayParam(){{{1*/
+/*FUNCTION DoubleMatArrayParam::~DoubleMatArrayParam(){{{*/
 DoubleMatArrayParam::~DoubleMatArrayParam(){
 
 	int i;
-	double* matrix=NULL;
-
-	xfree((void**)&mdim_array);
-	xfree((void**)&ndim_array);
+	IssmDouble* matrix=NULL;
+
+	xDelete<int>(mdim_array);
+	xDelete<int>(ndim_array);
 
 	for(i=0;i<M;i++){
 		matrix=array[i];
-		xfree((void**)&matrix);
-	}
-	
-	xfree((void**)&array);
+		xDelete<IssmDouble>(matrix);
+	}
+	
+	xDelete<IssmDouble*>(array);
 	return;
 }
@@ -84,26 +84,26 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION DoubleMatArrayParam::Echo {{{1*/
+/*FUNCTION DoubleMatArrayParam::Echo {{{*/
 void DoubleMatArrayParam::Echo(void){
 
-	printf("DoubleMatArrayParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   array size: %i\n",this->M);
-	printf("   array pointer: %p\n",this->array);
-
-}
-/*}}}*/
-/*FUNCTION DoubleMatArrayParam::DeepEcho{{{1*/
+	_printLine_("DoubleMatArrayParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   array size: " << this->M);
+	_printLine_("   array pointer: " << this->array);
+
+}
+/*}}}*/
+/*FUNCTION DoubleMatArrayParam::DeepEcho{{{*/
 void DoubleMatArrayParam::DeepEcho(void){
 
 	int i,j,k;
 	int m,n;
-	double* matrix=NULL;
-	
-	printf("DoubleMatArrayParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   array size: %i\n",this->M);
-	for(i=0;i<M;i++){
-		printf("   array %i (%ix%i):\n",i,mdim_array[i],ndim_array[i]);
+	IssmDouble* matrix=NULL;
+	
+	_printLine_("DoubleMatArrayParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   array size: " << this->M);
+	for(i=0;i<M;i++){
+		_printLine_("   array " << i << " (" << mdim_array[i] << "x" << ndim_array[i] << "):");
 		matrix=array[i];
 		m=mdim_array[i];
@@ -111,15 +111,15 @@
 
 		for(j=0;j<m;j++){
-			printf("   ");
-			for(k=0;k<n;k++)printf("%g ",*(matrix+n*j+k));
-			printf("\n");
+			_printString_("   ");
+			for(k=0;k<n;k++)_printString_(*(matrix+n*j+k) << " ");
+			_printLine_("");
 		}
 	}
 }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::Id{{{1*/
+/*FUNCTION DoubleMatArrayParam::Id{{{*/
 int    DoubleMatArrayParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::MyRank{{{1*/
+/*FUNCTION DoubleMatArrayParam::MyRank{{{*/
 int    DoubleMatArrayParam::MyRank(void){ 
 	extern int my_rank;
@@ -127,5 +127,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::ObjectEnum{{{1*/
+/*FUNCTION DoubleMatArrayParam::ObjectEnum{{{*/
 int DoubleMatArrayParam::ObjectEnum(void){
 
@@ -134,5 +134,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::copy{{{1*/
+/*FUNCTION DoubleMatArrayParam::copy{{{*/
 Object* DoubleMatArrayParam::copy() {
 	
@@ -143,13 +143,13 @@
 
 /*DoubleMatArrayParam virtual functions definitions: */
-/*FUNCTION DoubleMatArrayParam::GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){{{1*/
-void  DoubleMatArrayParam::GetParameterValue(double*** pout_array, int* pout_M,int** pout_mdim_array, int** pout_ndim_array){
+/*FUNCTION DoubleMatArrayParam::GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){{{*/
+void  DoubleMatArrayParam::GetParameterValue(IssmDouble*** pout_array, int* pout_M,int** pout_mdim_array, int** pout_ndim_array){
 
 	int i,m,n;
-	double* matrix=NULL;
-	double* out_matrix=NULL;
+	IssmDouble* matrix=NULL;
+	IssmDouble* out_matrix=NULL;
 
 	/*output: */
-	double** out_array=NULL;
+	IssmDouble** out_array=NULL;
 	int      out_M;
 	int*     out_mdim_array=NULL;
@@ -159,10 +159,10 @@
 	out_M=this->M;
 	if(out_M){
-		out_array=(double**)xmalloc(M*sizeof(double*));
-		out_mdim_array=(int*)xmalloc(M*sizeof(int));
-		out_ndim_array=(int*)xmalloc(M*sizeof(int));
-
-		memcpy(out_mdim_array,this->mdim_array,M*sizeof(int));
-		memcpy(out_ndim_array,this->ndim_array,M*sizeof(int));
+		out_array=xNew<IssmDouble*>(M);
+		out_mdim_array=xNew<int>(M);
+		out_ndim_array=xNew<int>(M);
+
+		xMemCpy<int>(out_mdim_array,this->mdim_array,M);
+		xMemCpy<int>(out_ndim_array,this->ndim_array,M);
 
 		for(i=0;i<this->M;i++){
@@ -172,6 +172,6 @@
 
 			if(m*n){
-				out_matrix=(double*)xmalloc(m*n*sizeof(double));
-				memcpy(out_matrix,matrix,m*n*sizeof(double));
+				out_matrix=xNew<IssmDouble>(m*n);
+				xMemCpy<IssmDouble>(out_matrix,matrix,m*n);
 			}
 			else{
@@ -196,33 +196,33 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::GetParameterName{{{1*/
+/*FUNCTION DoubleMatArrayParam::GetParameterName{{{*/
 void DoubleMatArrayParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::SetValue(double** array, int M, int* mdim_array, int* ndim_array){{{1*/
-void  DoubleMatArrayParam::SetValue(double** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
+/*FUNCTION DoubleMatArrayParam::SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){{{*/
+void  DoubleMatArrayParam::SetValue(IssmDouble** in_array, int in_M, int* in_mdim_array, int* in_ndim_array){
 
 	int i,m,n;
-	double* in_matrix=NULL;
-	double* matrix=NULL;
+	IssmDouble* in_matrix=NULL;
+	IssmDouble* matrix=NULL;
 
 	/*avoid leak: */
-	xfree((void**)&mdim_array);
-	xfree((void**)&ndim_array);
+	xDelete<int>(mdim_array);
+	xDelete<int>(ndim_array);
 	for(i=0;i<M;i++){
 		matrix=array[i];
-		xfree((void**)&matrix);
-	}
-	xfree((void**)&array);
+		xDelete<IssmDouble>(matrix);
+	}
+	xDelete<IssmDouble*>(array);
 
 	/*copy data: */
 	this->M=in_M;
-	this->array=(double**)xmalloc(M*sizeof(double*));
-	this->mdim_array=(int*)xmalloc(M*sizeof(int));
-	this->ndim_array=(int*)xmalloc(M*sizeof(int));
-	
-	memcpy(this->mdim_array,in_mdim_array,M*sizeof(double));
-	memcpy(this->ndim_array,in_ndim_array,M*sizeof(double));
+	this->array=xNew<IssmDouble*>(M);
+	this->mdim_array=xNew<int>(M);
+	this->ndim_array=xNew<int>(M);
+	
+	xMemCpy<int>(this->mdim_array,in_mdim_array,M);
+	xMemCpy<int>(this->ndim_array,in_ndim_array,M);
 
 	for(i=0;i<M;i++){
@@ -231,6 +231,6 @@
 		n=in_ndim_array[i];
 
-		matrix=(double*)xmalloc(m*n*sizeof(double));
-		memcpy(matrix,in_matrix,m*n*sizeof(double));
+		matrix=xNew<IssmDouble>(m*n);
+		xMemCpy<IssmDouble>(matrix,in_matrix,m*n);
 
 		this->array[i]=matrix;
@@ -239,9 +239,9 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::UnitConversion{{{1*/
+/*FUNCTION DoubleMatArrayParam::UnitConversion{{{*/
 void  DoubleMatArrayParam::UnitConversion(int direction_enum){
 	/*go through all matrices and convert: */
 	for (int i=0;i<this->M;i++){
-		double* matrix=this->array[i];
+		IssmDouble* matrix=this->array[i];
 		int     m=this->mdim_array[i];
 		int     n=this->ndim_array[i];
Index: /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleMatArrayParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -24,5 +24,5 @@
 	private: 
 		int      enum_type;
-		double** array; //array of matrices
+		IssmDouble** array; //array of matrices
 		int      M; //size of array
 		int*     mdim_array; //m-dimensions of matrices in the array
@@ -30,10 +30,10 @@
 
 	public:
-		/*DoubleMatArrayParam constructors, destructors: {{{1*/
+		/*DoubleMatArrayParam constructors, destructors: {{{*/
 		DoubleMatArrayParam();
-		DoubleMatArrayParam(int enum_type,double** array, int M, int* mdim_array, int* ndim_array);
+		DoubleMatArrayParam(int enum_type,IssmDouble** array, int M, int* mdim_array, int* ndim_array);
 		~DoubleMatArrayParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -43,33 +43,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("DoubleMatArray param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("DoubleMatArray param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("DoubleMatArray param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("DoubleMatArray param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("DoubleMatArray param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("DoubleMatArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims);
-		void  GetParameterValue(Vector** pvec){_error_("DoubleMatArray param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("DoubleMatArray param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("DoubleMatArray param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims);
+		void  GetParameterValue(Vector** pvec){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("DoubleMatArray param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("DoubleMatArray param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("DoubleMatArray param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("DoubleMatArray param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("DoubleMatArray param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("DoubleMatArray param of enum %i (%s) cannot hold a double vec array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M,int N){_error_("DoubleMatArray param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("DoubleMatArray param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M,int N){_error_("DoubleMatArray param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("DoubleMatArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("DoubleMatArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("Bool param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array);
+		void  SetValue(bool boolean){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
+		void  SetValue(char* string){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble vec array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M,int N){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble mat array");}
+		void  SetValue(int* intarray,int M){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int vec array");}
+		void  SetValue(int* intarray,int M,int N){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");}
+		void  SetValue(Vector* vec){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("DoubleMatArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array);
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Params/DoubleMatParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleMatParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,11 +21,11 @@
 
 /*DoubleMatParam constructors and destructor*/
-/*FUNCTION DoubleMatParam::DoubleMatParam(){{{1*/
+/*FUNCTION DoubleMatParam::DoubleMatParam(){{{*/
 DoubleMatParam::DoubleMatParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::DoubleMatParam(int enum_type,IssmDoubleMat value){{{1*/
-DoubleMatParam::DoubleMatParam(int in_enum_type,double* in_value, int in_M,int in_N){
+/*FUNCTION DoubleMatParam::DoubleMatParam(int enum_type,IssmDoubleMat value){{{*/
+DoubleMatParam::DoubleMatParam(int in_enum_type,IssmDouble* in_value, int in_M,int in_N){
 
 	enum_type=in_enum_type;
@@ -33,11 +33,11 @@
 	N=in_N;
 
-	value=(double*)xmalloc(M*N*sizeof(double));
-	memcpy(value,in_value,M*N*sizeof(double));
+	value=xNew<IssmDouble>(M*N);
+	xMemCpy<IssmDouble>(value,in_value,M*N);
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::~DoubleMatParam(){{{1*/
+/*FUNCTION DoubleMatParam::~DoubleMatParam(){{{*/
 DoubleMatParam::~DoubleMatParam(){
-	xfree((void**)&value);
+	xDelete<IssmDouble>(value);
 	return;
 }
@@ -45,32 +45,32 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION DoubleMatParam::Echo {{{1*/
+/*FUNCTION DoubleMatParam::Echo {{{*/
 void DoubleMatParam::Echo(void){
 
-	printf("DoubleMatParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   matrix size: %ix%i\n",this->M,this->N);
+	_printLine_("DoubleMatParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   matrix size: " << this->M << "x" << this->N);
 
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::DeepEcho{{{1*/
+/*FUNCTION DoubleMatParam::DeepEcho{{{*/
 void DoubleMatParam::DeepEcho(void){
 
 	int i,j;
 	
-	printf("DoubleMatParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   matrix size: %ix%i\n",this->M,this->N);
+	_printLine_("DoubleMatParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   matrix size: " << this->M << "x" << this->N);
 	for(i=0;i<this->M;i++){
 		for(i=0;i<this->N;i++){
-			printf("%i %i %g\n",i,j,*(this->value+N*i+j));
+			_printLine_(i << " " << j << " " << *(this->value+N*i+j));
 		}
 	}
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::Id{{{1*/
+/*FUNCTION DoubleMatParam::Id{{{*/
 int    DoubleMatParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleMatParam::MyRank{{{1*/
+/*FUNCTION DoubleMatParam::MyRank{{{*/
 int    DoubleMatParam::MyRank(void){ 
 	extern int my_rank;
@@ -78,5 +78,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::ObjectEnum{{{1*/
+/*FUNCTION DoubleMatParam::ObjectEnum{{{*/
 int DoubleMatParam::ObjectEnum(void){
 
@@ -85,5 +85,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::copy{{{1*/
+/*FUNCTION DoubleMatParam::copy{{{*/
 Object* DoubleMatParam::copy() {
 	
@@ -94,35 +94,35 @@
 
 /*DoubleMatParam virtual functions definitions: */
-/*FUNCTION DoubleMatParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){{{1*/
-void  DoubleMatParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){
-	double* output=NULL;
+/*FUNCTION DoubleMatParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){{{*/
+void  DoubleMatParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){
+	IssmDouble* output=NULL;
 
-	output=(double*)xmalloc((int)(M*N*sizeof(double)));
-	memcpy(output,value,M*N*sizeof(double));
+	output=xNew<IssmDouble>(M*N);
+	xMemCpy<IssmDouble>(output,value,M*N);
 
 	/*Assign output pointers:*/
 	if(pM) *pM=M;
 	if(pN) *pN=N;
-	*pdoublearray=output;
+	*pIssmDoublearray=output;
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{1*/
+/*FUNCTION DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{*/
 void  DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
-	_error_("DoubleMat of enum %i (%s) cannot return an array of int",enum_type,EnumToStringx(enum_type));
+	_error2_("DoubleMat of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of int");
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::GetParameterName{{{1*/
+/*FUNCTION DoubleMatParam::GetParameterName{{{*/
 void DoubleMatParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::SetValue{{{1*/
-void  DoubleMatParam::SetValue(double* doublearray,int in_M,int in_N){
+/*FUNCTION DoubleMatParam::SetValue{{{*/
+void  DoubleMatParam::SetValue(IssmDouble* IssmDoublearray,int in_M,int in_N){
 
 	/*avoid leak: */
-	xfree((void**)&this->value);
+	xDelete<IssmDouble>(this->value);
 
-	this->value=(double*)xmalloc(in_M*in_N*sizeof(double));
-	memcpy(this->value,doublearray,in_M*in_N*sizeof(double));
+	this->value=xNew<IssmDouble>(in_M*in_N);
+	xMemCpy<IssmDouble>(this->value,IssmDoublearray,in_M*in_N);
 
 	this->M=in_M;
@@ -130,5 +130,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleMatParam::UnitConversion{{{1*/
+/*FUNCTION DoubleMatParam::UnitConversion{{{*/
 void  DoubleMatParam::UnitConversion(int direction_enum){
 	::UnitConversion(this->value,this->M*this->N,direction_enum,this->enum_type);
@@ -137,6 +137,6 @@
 		
 /*diverse: */
-/*FUNCTION DoubleMatParam::GetPointer{{{1*/
-double* DoubleMatParam::GetPointer(void){
+/*FUNCTION DoubleMatParam::GetPointer{{{*/
+IssmDouble* DoubleMatParam::GetPointer(void){
 	return this->value;
 }
Index: /issm/trunk/src/c/objects/Params/DoubleMatParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleMatParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleMatParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -24,15 +24,15 @@
 	protected: 
 		int enum_type;
-		double* value;
+		IssmDouble* value;
 		int M;
 		int N;
 
 	public:
-		/*DoubleMatParam constructors, destructors: {{{1*/
+		/*DoubleMatParam constructors, destructors: {{{*/
 		DoubleMatParam();
 		DoubleMatParam(int enum_type,IssmDouble* value,int M,int N);
 		~DoubleMatParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -42,35 +42,35 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("DoubleMat param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("DoubleMat param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
 		void  GetParameterValue(int** pintarray,int* pM,int* pN);
-		void  GetParameterValue(double* pdouble){_error_("DoubleMat param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("DoubleMat param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("DoubleMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM,int* pN);
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("DoubleMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("DoubleMat param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("DoubleMat param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("DoubleMat param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN);
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("DoubleMat param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("DoubleMat param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("DoubleMat param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("DoubleMat param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("DoubleMat param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("DoubleMat param of enum %i (%s) cannot hold a double vec array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M,int N);
-		void  SetValue(int* intarray,int M){_error_("DoubleMat param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M,int N){_error_("DoubleMat param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));};
-		void  SetValue(Vector* vec){_error_("DoubleMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("DoubleMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("DoubleMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("DoubleMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
+		void  SetValue(char* string){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble vec array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M,int N);
+		void  SetValue(int* intarray,int M){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int vec array");}
+		void  SetValue(int* intarray,int M,int N){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");};
+		void  SetValue(Vector* vec){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("DoubleMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
-		double* GetPointer(void);
+		IssmDouble* GetPointer(void);
 
 		void GetParameterName(char**pname);
Index: /issm/trunk/src/c/objects/Params/DoubleParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleParam.cpp	(revision 12706)
@@ -18,10 +18,10 @@
 
 /*DoubleParam constructors and destructor*/
-/*FUNCTION DoubleParam::DoubleParam(){{{1*/
+/*FUNCTION DoubleParam::DoubleParam(){{{*/
 DoubleParam::DoubleParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleParam::DoubleParam(int enum_type,IssmDouble value){{{1*/
+/*FUNCTION DoubleParam::DoubleParam(int enum_type,IssmDouble value){{{*/
 DoubleParam::DoubleParam(int in_enum_type,IssmDouble in_value){
 
@@ -30,5 +30,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleParam::~DoubleParam(){{{1*/
+/*FUNCTION DoubleParam::~DoubleParam(){{{*/
 DoubleParam::~DoubleParam(){
 	return;
@@ -37,21 +37,21 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION DoubleParam::Echo {{{1*/
+/*FUNCTION DoubleParam::Echo {{{*/
 void DoubleParam::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION DoubleParam::DeepEcho{{{1*/
+/*FUNCTION DoubleParam::DeepEcho{{{*/
 void DoubleParam::DeepEcho(void){
 
-	printf("DoubleParam:\n");
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %g\n",this->value);
+	_printLine_("DoubleParam:");
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
 }
 /*}}}*/
-/*FUNCTION DoubleParam::Id{{{1*/
+/*FUNCTION DoubleParam::Id{{{*/
 int    DoubleParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleParam::MyRank{{{1*/
+/*FUNCTION DoubleParam::MyRank{{{*/
 int    DoubleParam::MyRank(void){ 
 	extern int my_rank;
@@ -59,5 +59,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleParam::ObjectEnum{{{1*/
+/*FUNCTION DoubleParam::ObjectEnum{{{*/
 int DoubleParam::ObjectEnum(void){
 
@@ -66,5 +66,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleParam::copy{{{1*/
+/*FUNCTION DoubleParam::copy{{{*/
 Object* DoubleParam::copy() {
 	
@@ -75,40 +75,40 @@
 
 /*DoubleParam virtual functions definitions: */
-/*FUNCTION DoubleParam::GetParameterName{{{1*/
+/*FUNCTION DoubleParam::GetParameterName{{{*/
 void DoubleParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION DoubleParam::GetParameterValue(int* pinteger){{{1*/
+/*FUNCTION DoubleParam::GetParameterValue(int* pinteger){{{*/
 void DoubleParam::GetParameterValue(int* pinteger){
-	_error_("Double param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));
+	_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");
 }
 /*}}}*/
-/*FUNCTION DoubleParam::GetParameterValue(bool* pbool){{{1*/
+/*FUNCTION DoubleParam::GetParameterValue(bool* pbool){{{*/
 void DoubleParam::GetParameterValue(bool* pbool){
-	_error_("Double param of enum %i (%s) cannot return an bool",enum_type,EnumToStringx(enum_type));
+	_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an bool");
 }
 /*}}}*/
-/*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM){{{1*/
+/*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM){{{*/
 void DoubleParam::GetParameterValue(int** pintarray,int* pM){
-	_error_("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));
+	_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");
 }
 /*}}}*/
-/*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{1*/
+/*FUNCTION DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){{{*/
 void DoubleParam::GetParameterValue(int** pintarray,int* pM,int* pN){
-	_error_("Double param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));
+	_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");
 }
 /*}}}*/
-/*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/
-void DoubleParam::GetParameterValue(double** pdoublearray,int* pM){
-	_error_("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToStringx(enum_type));
+/*FUNCTION DoubleParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){{{*/
+void DoubleParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){
+	_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of IssmDouble");
 }
 /*}}}*/
-/*FUNCTION DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){{{1*/
-void DoubleParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){
-	_error_("Double param of enum %i (%s) cannot return an array of double",enum_type,EnumToStringx(enum_type));
+/*FUNCTION DoubleParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){{{*/
+void DoubleParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){
+	_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of IssmDouble");
 }
 /*}}}*/
-/*FUNCTION DoubleParam::UnitConversion{{{1*/
+/*FUNCTION DoubleParam::UnitConversion{{{*/
 void  DoubleParam::UnitConversion(int direction_enum){
 	::UnitConversion(&this->value,1,direction_enum,this->enum_type);
Index: /issm/trunk/src/c/objects/Params/DoubleParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -28,10 +28,10 @@
 
 	public:
-		/*DoubleParam constructors, destructors: {{{1*/
+		/*DoubleParam constructors, destructors: {{{*/
 		DoubleParam();
 		DoubleParam(int enum_type,IssmDouble value);
 		~DoubleParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -41,5 +41,5 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool);
@@ -47,27 +47,27 @@
 		void  GetParameterValue(int** pintarray,int* pM);
 		void  GetParameterValue(int** pintarray,int* pM,int* pN);
-		void  GetParameterValue(double* pdouble){*pdouble=value;}
-		void  GetParameterValue(char** pstring){_error_("Double param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Double param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM);
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN);
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Double param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("Double param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("Double param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("Double param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(IssmDouble* pIssmDouble){*pIssmDouble=value;}
+		void  GetParameterValue(char** pstring){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM);
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN);
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){this->value=(double)boolean;}
-		void  SetValue(int integer){this->value=(double)integer;}
-		void  SetValue(double scalar){this->value=(double)scalar;}
-		void  SetValue(char* string){_error_("Double param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("Double param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("Double param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("Double param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("Double param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("Double param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("Double param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("Double param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("Double param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Double param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){this->value=(IssmDouble)boolean;}
+		void  SetValue(int integer){this->value=(IssmDouble)integer;}
+		void  SetValue(IssmDouble scalar){this->value=(IssmDouble)scalar;}
+		void  SetValue(char* string){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(int* intarray,int M){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(int* pintarray,int M,int N){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(Vector* vec){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Double param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Params/DoubleTransientMatParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleTransientMatParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleTransientMatParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,10 +20,10 @@
 /*}}}*/
 
-/*FUNCTION DoubleTransientMatParam::DoubleTransientMatParam(int enum_type,IssmDoubleMat value){{{1*/
-DoubleTransientMatParam::DoubleTransientMatParam(int in_enum_type,double* in_value, int in_M,int in_N):DoubleMatParam(in_enum_type,in_value,in_M,in_N){
+/*FUNCTION DoubleTransientMatParam::DoubleTransientMatParam(int enum_type,IssmDoubleMat value){{{*/
+DoubleTransientMatParam::DoubleTransientMatParam(int in_enum_type,IssmDouble* in_value, int in_M,int in_N):DoubleMatParam(in_enum_type,in_value,in_M,in_N){
 }
 /*}}}*/
 
-/*FUNCTION DoubleTransientMatParam::UnitConversion{{{1*/
+/*FUNCTION DoubleTransientMatParam::UnitConversion{{{*/
 void  DoubleTransientMatParam::UnitConversion(int direction_enum){
 	::UnitConversion(this->value,(this->M-1)*this->N,direction_enum,this->enum_type);
Index: /issm/trunk/src/c/objects/Params/DoubleTransientMatParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleTransientMatParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleTransientMatParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -23,8 +23,8 @@
 
 	public:
-		/*DoubleTransientMatParam constructors, destructors: {{{1*/
+		/*DoubleTransientMatParam constructors, destructors: {{{*/
 		DoubleTransientMatParam(int enum_type,IssmDouble* value,int M,int N);
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		void  UnitConversion(int direction_enum);
 		/*}}}*/
Index: /issm/trunk/src/c/objects/Params/DoubleVecParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleVecParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleVecParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,22 +21,22 @@
 
 /*DoubleVecParam constructors and destructor*/
-/*FUNCTION DoubleVecParam::DoubleVecParam(){{{1*/
+/*FUNCTION DoubleVecParam::DoubleVecParam(){{{*/
 DoubleVecParam::DoubleVecParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::DoubleVecParam(int enum_type,IssmDoubleVec values,int M){{{1*/
-DoubleVecParam::DoubleVecParam(int in_enum_type,double* in_values, int in_M){
+/*FUNCTION DoubleVecParam::DoubleVecParam(int enum_type,IssmDoubleVec values,int M){{{*/
+DoubleVecParam::DoubleVecParam(int in_enum_type,IssmDouble* in_values, int in_M){
 
 	enum_type=in_enum_type;
 	M=in_M;
 
-	values=(double*)xmalloc(M*sizeof(double));
-	memcpy(values,in_values,M*sizeof(double));
+	values=xNew<IssmDouble>(M);
+	xMemCpy<IssmDouble>(values,in_values,M);
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::~DoubleVecParam(){{{1*/
+/*FUNCTION DoubleVecParam::~DoubleVecParam(){{{*/
 DoubleVecParam::~DoubleVecParam(){
-	xfree((void**)&values);
+	xDelete<IssmDouble>(values);
 	return;
 }
@@ -44,30 +44,30 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION DoubleVecParam::Echo {{{1*/
+/*FUNCTION DoubleVecParam::Echo {{{*/
 void DoubleVecParam::Echo(void){
 
-	printf("DoubleVecParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   vector size: %i\n",this->M);
+	_printLine_("DoubleVecParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   vector size: " << this->M);
 
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::DeepEcho{{{1*/
+/*FUNCTION DoubleVecParam::DeepEcho{{{*/
 void DoubleVecParam::DeepEcho(void){
 
 	int i;
 	
-	printf("DoubleVecParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   vector size: %i\n",this->M);
+	_printLine_("DoubleVecParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   vector size: " << this->M);
 	for(i=0;i<this->M;i++){
-		printf("%i %g\n",i,this->values[i]);
+		_printLine_(i << " " << this->values[i]);
 	}
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::Id{{{1*/
+/*FUNCTION DoubleVecParam::Id{{{*/
 int    DoubleVecParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleVecParam::MyRank{{{1*/
+/*FUNCTION DoubleVecParam::MyRank{{{*/
 int    DoubleVecParam::MyRank(void){ 
 	extern int my_rank;
@@ -75,5 +75,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::ObjectEnum{{{1*/
+/*FUNCTION DoubleVecParam::ObjectEnum{{{*/
 int DoubleVecParam::ObjectEnum(void){
 
@@ -82,5 +82,5 @@
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::copy{{{1*/
+/*FUNCTION DoubleVecParam::copy{{{*/
 Object* DoubleVecParam::copy() {
 	
@@ -91,21 +91,21 @@
 
 /*DoubleVecParam virtual functions definitions: */
-/*FUNCTION DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/
-void  DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM){
-	double* output=NULL;
+/*FUNCTION DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){{{*/
+void  DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){
+	IssmDouble* output=NULL;
 	int M;
 
 	M=this->M;
-	output=(double*)xmalloc(M*sizeof(double));
-	memcpy(output,values,M*sizeof(double));
+	output=xNew<IssmDouble>(M);
+	xMemCpy<IssmDouble>(output,values,M);
 
 	/*Assign output pointers:*/
 	if(pM) *pM=M;
-	*pdoublearray=output;
+	*pIssmDoublearray=output;
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM){{{1*/
-void  DoubleVecParam::GetParameterValue(double** pdoublearray,int* pM,int* pN){
-	double* output=NULL;
+/*FUNCTION DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){{{*/
+void  DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){
+	IssmDouble* output=NULL;
 	int M;
 	int N;
@@ -113,36 +113,36 @@
 	N=1;
 	M=this->M;
-	output=(double*)xmalloc(M*sizeof(double));
-	memcpy(output,values,M*sizeof(double));
+	output=xNew<IssmDouble>(M);
+	xMemCpy<IssmDouble>(output,values,M);
 
 	/*Assign output pointers:*/
 	if(pM) *pM=M;
 	if(pN) *pN=N;
-	*pdoublearray=output;
+	*pIssmDoublearray=output;
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::GetParameterValue(int** pintarray,int* pM){{{1*/
+/*FUNCTION DoubleVecParam::GetParameterValue(int** pintarray,int* pM){{{*/
 void  DoubleVecParam::GetParameterValue(int** pintarray,int* pM){
-	_error_("DoubleVec param of enum %i (%s) cannot return an array of int",enum_type,EnumToStringx(enum_type));
+	_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of int");
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::GetParameterName{{{1*/
+/*FUNCTION DoubleVecParam::GetParameterName{{{*/
 void DoubleVecParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::SetValue{{{1*/
-void  DoubleVecParam::SetValue(double* doublearray,int in_M){
+/*FUNCTION DoubleVecParam::SetValue{{{*/
+void  DoubleVecParam::SetValue(IssmDouble* IssmDoublearray,int in_M){
 
 	/*avoid leak: */
-	xfree((void**)&this->values);
+	xDelete<IssmDouble>(this->values);
 
-	this->values=(double*)xmalloc(in_M*sizeof(double));
-	memcpy(this->values,doublearray,in_M*sizeof(double));
+	this->values=xNew<IssmDouble>(in_M);
+	xMemCpy<IssmDouble>(this->values,IssmDoublearray,in_M);
 
 	this->M=in_M;
 }
 /*}}}*/
-/*FUNCTION DoubleVecParam::UnitConversion{{{1*/
+/*FUNCTION DoubleVecParam::UnitConversion{{{*/
 void  DoubleVecParam::UnitConversion(int direction_enum){
 	::UnitConversion(this->values,this->M,direction_enum,this->enum_type);
Index: /issm/trunk/src/c/objects/Params/DoubleVecParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/DoubleVecParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/DoubleVecParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -28,10 +28,10 @@
 
 	public:
-		/*DoubleVecParam constructors, destructors: {{{1*/
+		/*DoubleVecParam constructors, destructors: {{{*/
 		DoubleVecParam();
 		DoubleVecParam(int enum_type,IssmDouble* values,int M);
 		~DoubleVecParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -41,33 +41,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param virtual functions definitions: {{{1*/
+		/*Param virtual functions definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("DoubleVec param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("DoubleVec param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
 		void  GetParameterValue(int** pintarray,int* pM);
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("DoubleVec param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));};
-		void  GetParameterValue(double* pdouble){_error_("DoubleVec param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("DoubleVec param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("DoubleVec param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM);
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN);
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("DoubleVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("DoubleVec param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("DoubleVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("DoubleVec param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");};
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM);
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN);
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("DoubleVec param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("DoubleVec param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("DoubleVec param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("DoubleVec param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("DoubleVec param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M);
-		void  SetValue(double* pdoublearray,int M,int N){_error_("DoubleVec param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("DoubleVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));};
-		void  SetValue(int* pintarray,int M,int N){_error_("DoubleVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("DoubleVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("DoubleVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("DoubleVec param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("DoubleVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
+		void  SetValue(char* string){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M);
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble mat array");}
+		void  SetValue(int* intarray,int M){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");};
+		void  SetValue(int* pintarray,int M,int N){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");}
+		void  SetValue(Vector* vec){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("DoubleVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 		
Index: /issm/trunk/src/c/objects/Params/FileParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/FileParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/FileParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,10 +21,10 @@
 
 /*FileParam constructors and destructor*/
-/*FUNCTION FileParam::FileParam(){{{1*/
+/*FUNCTION FileParam::FileParam(){{{*/
 FileParam::FileParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION FileParam::FileParam(int enum_type,FILE *value){{{1*/
+/*FUNCTION FileParam::FileParam(int enum_type,FILE *value){{{*/
 FileParam::FileParam(int in_enum_type,FILE* in_value){
 
@@ -33,5 +33,5 @@
 }
 /*}}}*/
-/*FUNCTION FileParam::~FileParam(){{{1*/
+/*FUNCTION FileParam::~FileParam(){{{*/
 FileParam::~FileParam(){
 	return;
@@ -40,21 +40,21 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION FileParam::Echo {{{1*/
+/*FUNCTION FileParam::Echo {{{*/
 void FileParam::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION FileParam::DeepEcho{{{1*/
+/*FUNCTION FileParam::DeepEcho{{{*/
 void FileParam::DeepEcho(void){
 
-	printf("FileParam:\n");
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %p\n",this->value);
+	_printLine_("FileParam:");
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
 }
 /*}}}*/
-/*FUNCTION FileParam::Id{{{1*/
+/*FUNCTION FileParam::Id{{{*/
 int    FileParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION FileParam::MyRank{{{1*/
+/*FUNCTION FileParam::MyRank{{{*/
 int    FileParam::MyRank(void){ 
 	extern int my_rank;
@@ -62,5 +62,5 @@
 }
 /*}}}*/
-/*FUNCTION FileParam::ObjectEnum{{{1*/
+/*FUNCTION FileParam::ObjectEnum{{{*/
 int FileParam::ObjectEnum(void){
 
@@ -69,5 +69,5 @@
 }
 /*}}}*/
-/*FUNCTION FileParam::copy{{{1*/
+/*FUNCTION FileParam::copy{{{*/
 Object* FileParam::copy() {
 	
@@ -78,10 +78,10 @@
 
 /*FileParam virtual functions definitions: */
-/*FUNCTION FileParam::GetParameterName{{{1*/
+/*FUNCTION FileParam::GetParameterName{{{*/
 void FileParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION FileParam::UnitConversion{{{1*/
+/*FUNCTION FileParam::UnitConversion{{{*/
 void  FileParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/FileParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/FileParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/FileParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -27,10 +27,10 @@
 
 	public:
-		/*FileParam constructors, destructors: {{{1*/
+		/*FileParam constructors, destructors: {{{*/
 		FileParam();
 		FileParam(int enum_type,FILE* fid);
 		~FileParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -40,33 +40,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){  _error_("FileParam of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("FileParam of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("FileParam of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("FileParam of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("FileParam of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("FileParam of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("File param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("FileParam of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("FileParam of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){  _error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){*pfid=value;};
 
-		void  SetValue(bool boolean){_error_("FileParam of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("FileParam of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("FileParam of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("FileParam of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("FileParam of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("FileParam of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("FileParam of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("FileParam of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("FileParam of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("FileParam of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("FileParam of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("File param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("File param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(int integer){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(IssmDouble scalar){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char* string){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(int* intarray,int M){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(int* pintarray,int M,int N){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(Vector* vec){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("FileParam of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Params/IntMatParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/IntMatParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/IntMatParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,10 +21,10 @@
 
 /*IntMatParam constructors and destructor*/
-/*FUNCTION IntMatParam::IntMatParam(){{{1*/
+/*FUNCTION IntMatParam::IntMatParam(){{{*/
 IntMatParam::IntMatParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{1*/
+/*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{*/
 IntMatParam::IntMatParam(int in_enum_type,int* in_value, int in_M,int in_N){
 
@@ -33,11 +33,11 @@
 	N=in_N;
 
-	value=(int*)xmalloc(M*N*sizeof(int));
-	memcpy(value,in_value,M*N*sizeof(int));
+	value=xNew<int>(M*N);
+	xMemCpy<int>(value,in_value,M*N);
 }
 /*}}}*/
-/*FUNCTION IntMatParam::~IntMatParam(){{{1*/
+/*FUNCTION IntMatParam::~IntMatParam(){{{*/
 IntMatParam::~IntMatParam(){
-	xfree((void**)&value);
+	xDelete<int>(value);
 	return;
 }
@@ -45,32 +45,32 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION IntMatParam::Echo {{{1*/
+/*FUNCTION IntMatParam::Echo {{{*/
 void IntMatParam::Echo(void){
 
-	printf("IntMatParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   matrix size: %ix%i\n",this->M,this->N);
+	_printLine_("IntMatParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   matrix size: " << this->M << "x" << this->N);
 
 }
 /*}}}*/
-/*FUNCTION IntMatParam::DeepEcho{{{1*/
+/*FUNCTION IntMatParam::DeepEcho{{{*/
 void IntMatParam::DeepEcho(void){
 
 	int i,j;
 	
-	printf("IntMatParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   matrix size: %ix%i\n",this->M,this->N);
+	_printLine_("IntMatParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   matrix size: " << this->M << "x" << this->N);
 	for(i=0;i<this->M;i++){
 		for(i=0;i<this->N;i++){
-			printf("(%i,%i) %i\n",i,j,*(this->value+N*i+j));
+			_printLine_("(" << i << "," << j << ") " << *(this->value+N*i+j));
 		}
 	}
 }
 /*}}}*/
-/*FUNCTION IntMatParam::Id{{{1*/
+/*FUNCTION IntMatParam::Id{{{*/
 int    IntMatParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntMatParam::MyRank{{{1*/
+/*FUNCTION IntMatParam::MyRank{{{*/
 int    IntMatParam::MyRank(void){ 
 	extern int my_rank;
@@ -78,5 +78,5 @@
 }
 /*}}}*/
-/*FUNCTION IntMatParam::ObjectEnum{{{1*/
+/*FUNCTION IntMatParam::ObjectEnum{{{*/
 int IntMatParam::ObjectEnum(void){
 
@@ -85,5 +85,5 @@
 }
 /*}}}*/
-/*FUNCTION IntMatParam::copy{{{1*/
+/*FUNCTION IntMatParam::copy{{{*/
 Object* IntMatParam::copy() {
 	
@@ -94,10 +94,10 @@
 
 /*IntMatParam virtual functions definitions: */
-/*FUNCTION IntMatParam::GetParameterValue{{{1*/
+/*FUNCTION IntMatParam::GetParameterValue{{{*/
 void  IntMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
 	int* output=NULL;
 
-	output=(int*)xmalloc((int)(M*N*sizeof(int)));
-	memcpy(output,value,M*N*sizeof(int));
+	output=xNew<int>(M*N);
+	xMemCpy<int>(output,value,M*N);
 
 	/*Assign output pointers:*/
@@ -107,17 +107,17 @@
 }
 /*}}}*/
-/*FUNCTION IntMatParam::GetParameterName{{{1*/
+/*FUNCTION IntMatParam::GetParameterName{{{*/
 void IntMatParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION IntMatParam::SetValue{{{1*/
+/*FUNCTION IntMatParam::SetValue{{{*/
 void  IntMatParam::SetValue(int* intarray,int in_M,int in_N){
 
 	/*avoid leak: */
-	xfree((void**)&this->value);
+	xDelete<int>(this->value);
 
-	this->value=(int*)xmalloc(in_M*in_N*sizeof(int));
-	memcpy(this->value,intarray,in_M*in_N*sizeof(int));
+	this->value=xNew<int>(in_M*in_N);
+	xMemCpy<int>(this->value,intarray,in_M*in_N);
 
 	this->M=in_M;
@@ -125,5 +125,5 @@
 }
 /*}}}*/
-/*FUNCTION IntMatParam::UnitConversion{{{1*/
+/*FUNCTION IntMatParam::UnitConversion{{{*/
 void  IntMatParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/IntMatParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/IntMatParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/IntMatParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -29,10 +29,10 @@
 
 	public:
-		/*IntMatParam constructors, destructors: {{{1*/
+		/*IntMatParam constructors, destructors: {{{*/
 		IntMatParam();
 		IntMatParam(int enum_type,int* value,int M,int N);
 		~IntMatParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -42,33 +42,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("IntMat param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("IntMat param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("IntMat param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
 		void  GetParameterValue(int** pintarray,int* pM,int* pN);
-		void  GetParameterValue(double* pdouble){_error_("IntMat param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("IntMat param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("IntMat param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("IntMat param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM,int* pN){_error_("IntMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));};
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("IntMat param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("IntMat param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("IntMat param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("IntMat param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");};
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("IntMat param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("IntMat param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("IntMat param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("IntMat param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("IntMat param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("IntMat param of enum %i (%s) cannot hold a double vec array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M,int N){_error_("IntMat param of enum %i (%s) cannot hold a double vec array",enum_type,EnumToStringx(enum_type));};
-		void  SetValue(int* intarray,int M){_error_("IntMat param of enum %i (%s) cannot hold a int vec array",enum_type,EnumToStringx(enum_type));};
+		void  SetValue(bool boolean){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
+		void  SetValue(char* string){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble vec array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M,int N){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble vec array");};
+		void  SetValue(int* intarray,int M){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int vec array");};
 		void  SetValue(int* intarray,int M,int N);
-		void  SetValue(Vector* vec){_error_("IntMat param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("IntMat param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("IntMat param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("IntMat param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Vector* vec){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("IntMat param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Params/IntParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/IntParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/IntParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,10 +21,10 @@
 
 /*IntParam constructors and destructor*/
-/*FUNCTION IntParam::IntParam(){{{1*/
+/*FUNCTION IntParam::IntParam(){{{*/
 IntParam::IntParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION IntParam::IntParam(int enum_type,IssmInt value){{{1*/
+/*FUNCTION IntParam::IntParam(int enum_type,IssmInt value){{{*/
 IntParam::IntParam(int in_enum_type,IssmInt in_value){
 
@@ -33,5 +33,5 @@
 }
 /*}}}*/
-/*FUNCTION IntParam::~IntParam(){{{1*/
+/*FUNCTION IntParam::~IntParam(){{{*/
 IntParam::~IntParam(){
 	return;
@@ -40,21 +40,21 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION IntParam::Echo {{{1*/
+/*FUNCTION IntParam::Echo {{{*/
 void IntParam::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION IntParam::DeepEcho{{{1*/
+/*FUNCTION IntParam::DeepEcho{{{*/
 void IntParam::DeepEcho(void){
 
-	printf("IntParam:\n");
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %i\n",this->value);
+	_printLine_("IntParam:");
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
 }
 /*}}}*/
-/*FUNCTION IntParam::Id{{{1*/
+/*FUNCTION IntParam::Id{{{*/
 int    IntParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntParam::MyRank{{{1*/
+/*FUNCTION IntParam::MyRank{{{*/
 int    IntParam::MyRank(void){ 
 	extern int my_rank;
@@ -62,5 +62,5 @@
 }
 /*}}}*/
-/*FUNCTION IntParam::ObjectEnum{{{1*/
+/*FUNCTION IntParam::ObjectEnum{{{*/
 int IntParam::ObjectEnum(void){
 
@@ -69,5 +69,5 @@
 }
 /*}}}*/
-/*FUNCTION IntParam::copy{{{1*/
+/*FUNCTION IntParam::copy{{{*/
 Object* IntParam::copy() {
 	
@@ -78,10 +78,10 @@
 
 /*IntParam virtual functions definitions: */
-/*FUNCTION IntParam::GetParameterName{{{1*/
+/*FUNCTION IntParam::GetParameterName{{{*/
 void IntParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION IntParam::UnitConversion{{{1*/
+/*FUNCTION IntParam::UnitConversion{{{*/
 void  IntParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/IntParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/IntParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/IntParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -28,10 +28,10 @@
 
 	public:
-		/*IntParam constructors, destructors: {{{1*/
+		/*IntParam constructors, destructors: {{{*/
 		IntParam();
 		IntParam(int enum_type,IssmInt value);
 		~IntParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -41,33 +41,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("Int param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
 		void  GetParameterValue(int* pinteger){*pinteger=value;}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("Int param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Int param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("Int param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("Int param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Int param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("Int param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Int param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Int param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("Int param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("Int param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("Int param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){this->value=(int)boolean;}
+		void  SetValue(bool boolean){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a bool");}
 		void  SetValue(int integer){this->value=integer;}
-		void  SetValue(int* intarray,int M){_error_("Int param of enum %i (%s) cannot hold an int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M,int N){_error_("Int param of enum %i (%s) cannot hold an int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){this->value=(int)scalar;}
-		void  SetValue(char* string){_error_("Int param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("Int param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("Int param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("Int param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("Int param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("Int param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("Int param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Int param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int* intarray,int M){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an int array");}
+		void  SetValue(int* intarray,int M,int N){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an int array");}
+		void  SetValue(IssmDouble scalar){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an IssmDouble");}
+		void  SetValue(char* string){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(Vector* vec){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Int param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Params/IntVecParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/IntVecParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/IntVecParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,10 +21,10 @@
 
 /*IntVecParam constructors and destructor*/
-/*FUNCTION IntVecParam::IntVecParam(){{{1*/
+/*FUNCTION IntVecParam::IntVecParam(){{{*/
 IntVecParam::IntVecParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION IntVecParam::IntVecParam(int enum_type,int* values,int M){{{1*/
+/*FUNCTION IntVecParam::IntVecParam(int enum_type,int* values,int M){{{*/
 IntVecParam::IntVecParam(int in_enum_type,int* in_values, int in_M){
 
@@ -33,12 +33,12 @@
 
 	if(M){
-		values=(int*)xmalloc(M*sizeof(int));
-		memcpy(values,in_values,M*sizeof(int));
+		values=xNew<int>(M);
+		xMemCpy<int>(values,in_values,M);
 	}
 	else values=NULL;
 }
 /*}}}*/
-/*FUNCTION IntVecParam::IntVecParam(int enum_type,double* values,int M){{{1*/
-IntVecParam::IntVecParam(int in_enum_type,double* in_values, int in_M){
+/*FUNCTION IntVecParam::IntVecParam(int enum_type,IssmDouble* values,int M){{{*/
+IntVecParam::IntVecParam(int in_enum_type,IssmDouble* in_values, int in_M){
 
 	enum_type=in_enum_type;
@@ -46,13 +46,13 @@
 
 	if(M){
-		values=(int*)xmalloc(M*sizeof(int));
-		for(int i=0;i<in_M;i++) values[i]=(int)in_values[i];
+		values=xNew<int>(M);
+		for(int i=0;i<in_M;i++) values[i]=reCast<int>(in_values[i]);
 	}
 	else values=NULL;
 }
 /*}}}*/
-/*FUNCTION IntVecParam::~IntVecParam(){{{1*/
+/*FUNCTION IntVecParam::~IntVecParam(){{{*/
 IntVecParam::~IntVecParam(){
-	xfree((void**)&values);
+	xDelete<int>(values);
 	return;
 }
@@ -60,30 +60,30 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION IntVecParam::Echo {{{1*/
+/*FUNCTION IntVecParam::Echo {{{*/
 void IntVecParam::Echo(void){
 
-	printf("IntVecParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   vector size: %i\n",this->M);
+	_printLine_("IntVecParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   vector size: " << this->M);
 
 }
 /*}}}*/
-/*FUNCTION IntVecParam::DeepEcho{{{1*/
+/*FUNCTION IntVecParam::DeepEcho{{{*/
 void IntVecParam::DeepEcho(void){
 
 	int i;
 	
-	printf("IntVecParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   vector size: %i\n",this->M);
+	_printLine_("IntVecParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   vector size: " << this->M);
 	for(i=0;i<this->M;i++){
-		printf("%i %i\n",i,this->values[i]);
+		_printLine_(i << " " << this->values[i]);
 	}
 }
 /*}}}*/
-/*FUNCTION IntVecParam::Id{{{1*/
+/*FUNCTION IntVecParam::Id{{{*/
 int    IntVecParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntVecParam::MyRank{{{1*/
+/*FUNCTION IntVecParam::MyRank{{{*/
 int    IntVecParam::MyRank(void){ 
 	extern int my_rank;
@@ -91,5 +91,5 @@
 }
 /*}}}*/
-/*FUNCTION IntVecParam::ObjectEnum{{{1*/
+/*FUNCTION IntVecParam::ObjectEnum{{{*/
 int IntVecParam::ObjectEnum(void){
 
@@ -98,5 +98,5 @@
 }
 /*}}}*/
-/*FUNCTION IntVecParam::copy{{{1*/
+/*FUNCTION IntVecParam::copy{{{*/
 Object* IntVecParam::copy() {
 	
@@ -107,11 +107,11 @@
 
 /*IntVecParam virtual functions definitions: */
-/*FUNCTION IntVecParam::GetParameterValue{{{1*/
+/*FUNCTION IntVecParam::GetParameterValue{{{*/
 void  IntVecParam::GetParameterValue(int** pintarray,int* pM){
 	int* output=NULL;
 
 	if(M){
-		output=(int*)xmalloc(M*sizeof(int));
-		memcpy(output,values,M*sizeof(int));
+		output=xNew<int>(M);
+		xMemCpy<int>(output,values,M);
 	}
 
@@ -121,18 +121,18 @@
 }
 /*}}}*/
-/*FUNCTION IntVecParam::GetParameterName{{{1*/
+/*FUNCTION IntVecParam::GetParameterName{{{*/
 void IntVecParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION IntVecParam::SetValue{{{1*/
+/*FUNCTION IntVecParam::SetValue{{{*/
 void  IntVecParam::SetValue(int* intarray,int in_M){
 
 	/*avoid leak: */
-	xfree((void**)&this->values);
+	xDelete<int>(this->values);
 
 	if(in_M){
-		this->values=(int*)xmalloc(in_M*sizeof(int));
-		memcpy(this->values,intarray,in_M*sizeof(int));
+		this->values=xNew<int>(in_M);
+		xMemCpy<int>(this->values,intarray,in_M);
 	}
 	else this->values=NULL;
@@ -141,5 +141,5 @@
 }
 /*}}}*/
-/*FUNCTION IntVecParam::UnitConversion{{{1*/
+/*FUNCTION IntVecParam::UnitConversion{{{*/
 void  IntVecParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/IntVecParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/IntVecParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/IntVecParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -28,11 +28,11 @@
 
 	public:
-		/*IntVecParam constructors, destructors: {{{1*/
+		/*IntVecParam constructors, destructors: {{{*/
 		IntVecParam();
 		IntVecParam(int enum_type,int* values,int M);
-		IntVecParam(int enum_type,double* values,int M);
+		IntVecParam(int enum_type,IssmDouble* values,int M);
 		~IntVecParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -42,33 +42,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param virtual functions definitions: {{{1*/
+		/*Param virtual functions definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("IntVec param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("IntVec param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
 		void  GetParameterValue(int** pintarray,int* pM);
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("IntVec param of enum %i (%s) cannot return a matrix",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("IntVec param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("IntVec param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("IntVec param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("IntVec param of enum %i (%s) cannot return a double array (maybe in serial?)",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("IntVec param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("IntVec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("IntVec param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("IntVec param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("IntVec param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array (maybe in serial?)");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("IntVec param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("IntVec param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("IntVec param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("IntVec param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("IntVec param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("IntVec param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("IntVec param of enum %i (%s) cannot hold a double mat array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
+		void  SetValue(char* string){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble mat array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble mat array");}
 		void  SetValue(int* intarray,int M);
-		void  SetValue(int* pintarray,int M,int N){_error_("IntVec param of enum %i (%s) cannot hold a int mat array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("IntVec param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("IntVec param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("IntVec param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("IntVec param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(int* pintarray,int M,int N){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int mat array");}
+		void  SetValue(Vector* vec){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("IntVec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 		
Index: /issm/trunk/src/c/objects/Params/MatrixParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/MatrixParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/MatrixParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,10 +21,10 @@
 
 /*MatrixParam constructors and destructor*/
-/*FUNCTION MatrixParam::MatrixParam(){{{1*/
+/*FUNCTION MatrixParam::MatrixParam(){{{*/
 MatrixParam::MatrixParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION MatrixParam::MatrixParam(int enum_type,Matrix* value){{{1*/
+/*FUNCTION MatrixParam::MatrixParam(int enum_type,Matrix* value){{{*/
 MatrixParam::MatrixParam(int in_enum_type,Matrix* in_value){
 
@@ -37,5 +37,5 @@
 }
 /*}}}*/
-/*FUNCTION MatrixParam::~MatrixParam(){{{1*/
+/*FUNCTION MatrixParam::~MatrixParam(){{{*/
 MatrixParam::~MatrixParam(){
 	xdelete(&value);
@@ -44,25 +44,25 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION MatrixParam::Echo {{{1*/
+/*FUNCTION MatrixParam::Echo {{{*/
 void MatrixParam::Echo(void){
 
-	printf("MatrixParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	_printLine_("MatrixParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 
 }
 /*}}}*/
-/*FUNCTION MatrixParam::DeepEcho{{{1*/
+/*FUNCTION MatrixParam::DeepEcho{{{*/
 void MatrixParam::DeepEcho(void){
 
 	int i;
-	printf("MatrixParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	_printLine_("MatrixParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	this->value->Echo();
 }
 /*}}}*/
-/*FUNCTION MatrixParam::Id{{{1*/
+/*FUNCTION MatrixParam::Id{{{*/
 int    MatrixParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION MatrixParam::MyRank{{{1*/
+/*FUNCTION MatrixParam::MyRank{{{*/
 int    MatrixParam::MyRank(void){ 
 	extern int my_rank;
@@ -70,5 +70,5 @@
 }
 /*}}}*/
-/*FUNCTION MatrixParam::ObjectEnum{{{1*/
+/*FUNCTION MatrixParam::ObjectEnum{{{*/
 int MatrixParam::ObjectEnum(void){
 
@@ -77,5 +77,5 @@
 }
 /*}}}*/
-/*FUNCTION MatrixParam::copy{{{1*/
+/*FUNCTION MatrixParam::copy{{{*/
 Object* MatrixParam::copy() {
 	
@@ -86,5 +86,5 @@
 
 /*MatrixParam virtual functions definitions: */
-/*FUNCTION MatrixParam::GetParameterValue{{{1*/
+/*FUNCTION MatrixParam::GetParameterValue{{{*/
 void  MatrixParam::GetParameterValue(Matrix** poutput){
 	Matrix* output=NULL;
@@ -96,10 +96,10 @@
 }
 /*}}}*/
-/*FUNCTION MatrixParam::GetParameterName{{{1*/
+/*FUNCTION MatrixParam::GetParameterName{{{*/
 void MatrixParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION MatrixParam::SetValue{{{1*/
+/*FUNCTION MatrixParam::SetValue{{{*/
 void  MatrixParam::SetValue(Matrix* matrix){
 	
@@ -111,5 +111,5 @@
 }
 /*}}}*/
-/*FUNCTION MatrixParam::UnitConversion{{{1*/
+/*FUNCTION MatrixParam::UnitConversion{{{*/
 void  MatrixParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/MatrixParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/MatrixParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/MatrixParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -28,10 +28,10 @@
 
 	public:
-		/*MatrixParam constructors, destructors: {{{1*/
+		/*MatrixParam constructors, destructors: {{{*/
 		MatrixParam();
 		MatrixParam(int enum_type,Matrix* value);
 		~MatrixParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -41,33 +41,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("Matrix param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("Matrix param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("Matrix param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Matrix param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("Matrix param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("Matrix param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Matrix param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("Matrix param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Matrix param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Matrix param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("Matrix param of enum %i (%s) cannot return a vec",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a vec");}
 		void  GetParameterValue(Matrix** poutput);
-		void  GetParameterValue(FILE** pfid){_error_("Matrix param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(FILE** pfid){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("Matrix param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("Matrix param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("Matrix param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("Matrix param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("Matrix param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("Matrix param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("Matrix param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("Matrix param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("Matrix param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("Matrix param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
+		void  SetValue(char* string){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(int* intarray,int M){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(int* pintarray,int M,int N){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(Vector* vec){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
 		void  SetValue(Matrix* mat);
-		void  SetValue(FILE* fid){_error_("Matrix param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Matrix param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(FILE* fid){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Matrix param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Params/Param.h
===================================================================
--- /issm/trunk/src/c/objects/Params/Param.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/Param.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -31,10 +31,10 @@
 		virtual void  GetParameterValue(int** pintarray,int* pM)=0;
 		virtual void  GetParameterValue(int** pintarray,int* pM,int* pN)=0;
-		virtual void  GetParameterValue(double* pdouble)=0;
+		virtual void  GetParameterValue(IssmDouble* pIssmDouble)=0;
 		virtual void  GetParameterValue(char** pstring)=0;
 		virtual void  GetParameterValue(char*** pstringarray,int* pM)=0;
-		virtual void  GetParameterValue(double** pdoublearray,int* pM)=0;
-		virtual void  GetParameterValue(double** pdoublearray,int* pM,int* pN)=0;
-		virtual void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims)=0;
+		virtual void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM)=0;
+		virtual void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN)=0;
+		virtual void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims)=0;
 		virtual void  GetParameterValue(Vector** pvec)=0;
 		virtual void  GetParameterValue(Matrix** pmat)=0;
@@ -43,9 +43,9 @@
 		virtual void  SetValue(bool boolean)=0;
 		virtual void  SetValue(int integer)=0;
-		virtual void  SetValue(double scalar)=0;
+		virtual void  SetValue(IssmDouble scalar)=0;
 		virtual void  SetValue(char* string)=0;
 		virtual void  SetValue(char** stringarray,int M)=0;
-		virtual void  SetValue(double* doublearray,int M)=0;
-		virtual void  SetValue(double* pdoublearray,int M,int N)=0;
+		virtual void  SetValue(IssmDouble* IssmDoublearray,int M)=0;
+		virtual void  SetValue(IssmDouble* pIssmDoublearray,int M,int N)=0;
 		virtual void  SetValue(int* intarray,int M)=0;
 		virtual void  SetValue(int* pintarray,int M,int N)=0;
@@ -53,5 +53,5 @@
 		virtual void  SetValue(Matrix* mat)=0;
 		virtual void  SetValue(FILE* fid)=0;
-		virtual void  SetValue(double** array, int M, int* mdim_array, int* ndim_array)=0;
+		virtual void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array)=0;
 		virtual void  UnitConversion(int direction_enum)=0;
 		virtual void  GetParameterName(char**pname)=0;
Index: /issm/trunk/src/c/objects/Params/StringArrayParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/StringArrayParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/StringArrayParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,10 +21,10 @@
 
 /*StringArrayParam constructors and destructor*/
-/*FUNCTION StringArrayParam::StringArrayParam(){{{1*/
+/*FUNCTION StringArrayParam::StringArrayParam(){{{*/
 StringArrayParam::StringArrayParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::StringArrayParam(int enum_type,char** in_values,int in_numstrings){{{1*/
+/*FUNCTION StringArrayParam::StringArrayParam(int enum_type,char** in_values,int in_numstrings){{{*/
 StringArrayParam::StringArrayParam(int in_enum_type,char** in_values, int in_numstrings){
 
@@ -36,10 +36,10 @@
 
 	if(numstrings){
-		value=(char**)xmalloc(numstrings*sizeof(char*));
+		value=xNew<char*>(numstrings);
 		for(i=0;i<numstrings;i++){
 			char* string=NULL;
 			size=strlen(in_values[i])+1;
-			string=(char*)xmalloc(size*sizeof(char));
-			memcpy(string,in_values[i],size*sizeof(char));
+			string=xNew<char>(size);
+			xMemCpy<char>(string,in_values[i],size);
 			value[i]=string;
 		}
@@ -49,5 +49,5 @@
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::~StringArrayParam(){{{1*/
+/*FUNCTION StringArrayParam::~StringArrayParam(){{{*/
 StringArrayParam::~StringArrayParam(){
 		
@@ -57,17 +57,17 @@
 	for(i=0;i<this->numstrings;i++){
 		string=value[i];
-		xfree((void**)&string);
+		xDelete<char>(string);
 	}
-	xfree((void**)&value);
+	xDelete<char*>(value);
 }
 /*}}}*/
 
 /*Object virtual functions definitions:*/
-/*FUNCTION StringArrayParam::Echo {{{1*/
+/*FUNCTION StringArrayParam::Echo {{{*/
 void StringArrayParam::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::DeepEcho{{{1*/
+/*FUNCTION StringArrayParam::DeepEcho{{{*/
 void StringArrayParam::DeepEcho(void){
 
@@ -75,16 +75,16 @@
 	char* string=NULL;
 
-	printf("StringArrayParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	_printLine_("StringArrayParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	for(i=0;i<this->numstrings;i++){
 		string=this->value[i];
-		printf("   %i: %s\n",i,string);
+		_printLine_("   " << i << ": " << string);
 	}
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::Id{{{1*/
+/*FUNCTION StringArrayParam::Id{{{*/
 int    StringArrayParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION StringArrayParam::MyRank{{{1*/
+/*FUNCTION StringArrayParam::MyRank{{{*/
 int    StringArrayParam::MyRank(void){ 
 	extern int my_rank;
@@ -92,5 +92,5 @@
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::ObjectEnum{{{1*/
+/*FUNCTION StringArrayParam::ObjectEnum{{{*/
 int StringArrayParam::ObjectEnum(void){
 
@@ -99,5 +99,5 @@
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::copy{{{1*/
+/*FUNCTION StringArrayParam::copy{{{*/
 Object* StringArrayParam::copy() {
 	
@@ -108,5 +108,5 @@
 
 /*StringArrayParam virtual functions definitions: */
-/*FUNCTION StringArrayParam::GetParameterValue{{{1*/
+/*FUNCTION StringArrayParam::GetParameterValue{{{*/
 void  StringArrayParam::GetParameterValue(char*** pstringarray,int* pM){
 	
@@ -120,5 +120,5 @@
 	M=this->numstrings;
 	if(this->numstrings){
-		outstrings=(char**)xmalloc(this->numstrings*sizeof(char*));
+		outstrings=xNew<char*>(this->numstrings);
 
 		for(i=0;i<this->numstrings;i++){
@@ -126,6 +126,6 @@
 			stringsize=strlen(string)+1;
 
-			string2=(char*)xmalloc(stringsize*sizeof(char));
-			memcpy(string2,string,stringsize*sizeof(char));
+			string2=xNew<char>(stringsize);
+			xMemCpy<char>(string2,string,stringsize);
 
 			outstrings[i]=string2;
@@ -139,10 +139,10 @@
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::GetParameterName{{{1*/
+/*FUNCTION StringArrayParam::GetParameterName{{{*/
 void StringArrayParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::SetValue{{{1*/
+/*FUNCTION StringArrayParam::SetValue{{{*/
 void  StringArrayParam::SetValue(char** stringarray,int M){
 	
@@ -155,17 +155,17 @@
 	for(i=0;i<this->numstrings;i++){
 		string=this->value[i];
-		xfree((void**)&string);
+		xDelete<char>(string);
 	}
-	xfree((void**)&this->value);
+	xDelete<char*>(this->value);
 
 	/*copy: */
 	this->numstrings=M;
-	this->value=(char**)xmalloc(this->numstrings*sizeof(char*));
+	this->value=xNew<char*>(this->numstrings);
 	for(i=0;i<this->numstrings;i++){
 		string=stringarray[i];
 		stringsize=strlen(string)+1;
 
-		string2=(char*)xmalloc(stringsize*sizeof(char));
-		memcpy(string2,string,stringsize*sizeof(char));
+		string2=xNew<char>(stringsize);
+		xMemCpy<char>(string2,string,stringsize);
 
 		this->value[i]=string2;
@@ -173,5 +173,5 @@
 }
 /*}}}*/
-/*FUNCTION StringArrayParam::UnitConversion{{{1*/
+/*FUNCTION StringArrayParam::UnitConversion{{{*/
 void  StringArrayParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/StringArrayParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/StringArrayParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/StringArrayParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -30,10 +30,10 @@
 
 	public:
-		/*StringArrayParam constructors, destructors: {{{1*/
+		/*StringArrayParam constructors, destructors: {{{*/
 		StringArrayParam();
 		StringArrayParam(int enum_type,char** values, int numstrings);
 		~StringArrayParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -43,33 +43,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("StringArray param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("StringArray param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("StringArray param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("StringArray param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("StringArray param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("StringArray param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
 		void  GetParameterValue(char*** pstringarray,int* pM);
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("StringArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("StringArray param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Vec param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("StringArray param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("StringArray param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("StringArray param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Vec param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("StringArray param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("StringArray param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("StringArray param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("StringArray param of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
+		void  SetValue(char* string){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
 		void  SetValue(char** stringarray,int M);
-		void  SetValue(double* doublearray,int M){_error_("StringArray param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("StringArray param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("StringArray param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("StringArray param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("StringArray param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("StringArray param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("StringArray param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("StringArray param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(int* intarray,int M){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(int* pintarray,int M,int N){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(Vector* vec){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("StringArray param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Params/StringParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/StringParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/StringParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,42 +21,42 @@
 
 /*StringParam constructors and destructor*/
-/*FUNCTION StringParam::StringParam(){{{1*/
+/*FUNCTION StringParam::StringParam(){{{*/
 StringParam::StringParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION StringParam::StringParam(int enum_type,IssmString value){{{1*/
+/*FUNCTION StringParam::StringParam(int enum_type,IssmString value){{{*/
 StringParam::StringParam(int in_enum_type,char* in_value){
 
 	enum_type=in_enum_type;
-	value=(char*)xmalloc((strlen(in_value)+1)*sizeof(char));
-	memcpy(value,in_value,(strlen(in_value)+1)*sizeof(char));
+	value=xNew<char>(strlen(in_value)+1);
+	xMemCpy<char>(value,in_value,(strlen(in_value)+1));
 
 	
 }
 /*}}}*/
-/*FUNCTION StringParam::~StringParam(){{{1*/
+/*FUNCTION StringParam::~StringParam(){{{*/
 StringParam::~StringParam(){
-	xfree((void**)&value);
+	xDelete<char>(value);
 }
 /*}}}*/
 
 /*Object virtual functions definitions:*/
-/*FUNCTION StringParam::Echo {{{1*/
+/*FUNCTION StringParam::Echo {{{*/
 void StringParam::Echo(void){
 	this->DeepEcho();
 }
 /*}}}*/
-/*FUNCTION StringParam::DeepEcho{{{1*/
+/*FUNCTION StringParam::DeepEcho{{{*/
 void StringParam::DeepEcho(void){
-	printf("StringParam:\n");
-	printf("   enum:  %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
-	printf("   value: %s\n",this->value);
+	_printLine_("StringParam:");
+	_printLine_("   enum:  " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
+	_printLine_("   value: " << this->value);
 }
 /*}}}*/
-/*FUNCTION StringParam::Id{{{1*/
+/*FUNCTION StringParam::Id{{{*/
 int    StringParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION StringParam::MyRank{{{1*/
+/*FUNCTION StringParam::MyRank{{{*/
 int    StringParam::MyRank(void){ 
 	extern int my_rank;
@@ -64,5 +64,5 @@
 }
 /*}}}*/
-/*FUNCTION StringParam::ObjectEnum{{{1*/
+/*FUNCTION StringParam::ObjectEnum{{{*/
 int StringParam::ObjectEnum(void){
 
@@ -71,5 +71,5 @@
 }
 /*}}}*/
-/*FUNCTION StringParam::copy{{{1*/
+/*FUNCTION StringParam::copy{{{*/
 Object* StringParam::copy() {
 	
@@ -80,5 +80,5 @@
 
 /*StringParam virtual functions definitions: */
-/*FUNCTION StringParam::GetParameterValue{{{1*/
+/*FUNCTION StringParam::GetParameterValue{{{*/
 void  StringParam::GetParameterValue(char** pstring){
 	
@@ -88,6 +88,6 @@
 	stringsize=strlen(this->value)+1;
 
-	outstring=(char*)xmalloc(stringsize*sizeof(char));
-	memcpy(outstring,this->value,stringsize*sizeof(char));
+	outstring=xNew<char>(stringsize);
+	xMemCpy<char>(outstring,this->value,stringsize);
 
 	*pstring=outstring;
@@ -95,10 +95,10 @@
 }
 /*}}}*/
-/*FUNCTION StringParam::GetParameterName{{{1*/
+/*FUNCTION StringParam::GetParameterName{{{*/
 void StringParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION StringParam::SetValue{{{1*/
+/*FUNCTION StringParam::SetValue{{{*/
 void  StringParam::SetValue(char* string){
 	
@@ -106,14 +106,14 @@
 	
 	/*avoid leak: */
-	xfree((void**)&this->value);
+	xDelete<char>(this->value);
 
 	/*copy: */
 	stringsize=strlen(string)+1;
-	this->value=(char*)xmalloc(stringsize*sizeof(char));
-	memcpy(this->value,string,stringsize*sizeof(char));
+	this->value=xNew<char>(stringsize);
+	xMemCpy<char>(this->value,string,stringsize);
 
 }
 /*}}}*/
-/*FUNCTION StringParam::UnitConversion{{{1*/
+/*FUNCTION StringParam::UnitConversion{{{*/
 void  StringParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/StringParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/StringParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/StringParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -28,10 +28,10 @@
 
 	public:
-		/*StringParam constructors, destructors: {{{1*/
+		/*StringParam constructors, destructors: {{{*/
 		StringParam();
 		StringParam(int enum_type,char* value);
 		~StringParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -41,33 +41,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("String param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("String param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("String param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("String param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("String param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
 		void  GetParameterValue(char** pstring);
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("String param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("String param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("String param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("String param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Vector** pvec){_error_("String param of enum %i (%s) cannot return a Vec",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("String param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(FILE** pfid){_error_("Bool param of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Vector** pvec){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Vec");}
+		void  GetParameterValue(Matrix** pmat){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
+		void  GetParameterValue(FILE** pfid){_error2_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("String param of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("String param of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("String param of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
 		void  SetValue(char* string);
-		void  SetValue(char** stringarray,int M){_error_("String param of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("String param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("String param of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("String param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("String param of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Vector* vec){_error_("String param of enum %i (%s) cannot hold a Vec",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(Matrix* mat){_error_("String param of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("String param of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("String param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(char** stringarray,int M){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(int* intarray,int M){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(int* pintarray,int M,int N){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(Vector* vec){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Vec");}
+		void  SetValue(Matrix* mat){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("String param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Params/VectorParam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Params/VectorParam.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/VectorParam.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*header files: */
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -21,10 +21,10 @@
 
 /*VectorParam constructors and destructor*/
-/*FUNCTION VectorParam::VectorParam(){{{1*/
+/*FUNCTION VectorParam::VectorParam(){{{*/
 VectorParam::VectorParam(){
 	return;
 }
 /*}}}*/
-/*FUNCTION VectorParam::VectorParam(int enum_type,IssmVector value){{{1*/
+/*FUNCTION VectorParam::VectorParam(int enum_type,IssmVector value){{{*/
 VectorParam::VectorParam(int in_enum_type,Vector* in_value){
 
@@ -39,5 +39,5 @@
 }
 /*}}}*/
-/*FUNCTION VectorParam::~VectorParam(){{{1*/
+/*FUNCTION VectorParam::~VectorParam(){{{*/
 VectorParam::~VectorParam(){
 	xdelete(&value);
@@ -46,25 +46,25 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION VectorParam::Echo {{{1*/
+/*FUNCTION VectorParam::Echo {{{*/
 void VectorParam::Echo(void){
 
-	printf("VectorParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	_printLine_("VectorParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 
 }
 /*}}}*/
-/*FUNCTION VectorParam::DeepEcho{{{1*/
+/*FUNCTION VectorParam::DeepEcho{{{*/
 void VectorParam::DeepEcho(void){
 
 	int i;
-	printf("VectorParam:\n");
-	printf("   enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
+	_printLine_("VectorParam:");
+	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	value->Echo();
 }
 /*}}}*/
-/*FUNCTION VectorParam::Id{{{1*/
+/*FUNCTION VectorParam::Id{{{*/
 int    VectorParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION VectorParam::MyRank{{{1*/
+/*FUNCTION VectorParam::MyRank{{{*/
 int    VectorParam::MyRank(void){ 
 	extern int my_rank;
@@ -72,5 +72,5 @@
 }
 /*}}}*/
-/*FUNCTION VectorParam::ObjectEnum{{{1*/
+/*FUNCTION VectorParam::ObjectEnum{{{*/
 int VectorParam::ObjectEnum(void){
 
@@ -79,5 +79,5 @@
 }
 /*}}}*/
-/*FUNCTION VectorParam::copy{{{1*/
+/*FUNCTION VectorParam::copy{{{*/
 Object* VectorParam::copy() {
 	
@@ -88,5 +88,5 @@
 
 /*VectorParam virtual functions definitions: */
-/*FUNCTION VectorParam::GetParameterValue{{{1*/
+/*FUNCTION VectorParam::GetParameterValue{{{*/
 void  VectorParam::GetParameterValue(Vector** poutput){
 	Vector*  output=NULL;
@@ -99,10 +99,10 @@
 }
 /*}}}*/
-/*FUNCTION VectorParam::GetParameterName{{{1*/
+/*FUNCTION VectorParam::GetParameterName{{{*/
 void VectorParam::GetParameterName(char**pname){
 	EnumToStringx(pname,this->enum_type);
 }
 /*}}}*/
-/*FUNCTION VectorParam::SetValue{{{1*/
+/*FUNCTION VectorParam::SetValue{{{*/
 void  VectorParam::SetValue(Vector* vector){
 
@@ -115,5 +115,5 @@
 }
 /*}}}*/
-/*FUNCTION VectorParam::UnitConversion{{{1*/
+/*FUNCTION VectorParam::UnitConversion{{{*/
 void  VectorParam::UnitConversion(int direction_enum){
 	/*do nothing, no unit conversion*/
Index: /issm/trunk/src/c/objects/Params/VectorParam.h
===================================================================
--- /issm/trunk/src/c/objects/Params/VectorParam.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Params/VectorParam.h	(revision 12706)
@@ -8,5 +8,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -28,10 +28,10 @@
 
 	public:
-		/*VectorParam constructors, destructors: {{{1*/
+		/*VectorParam constructors, destructors: {{{*/
 		VectorParam();
 		VectorParam(int enum_type,Vector* value);
 		~VectorParam();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -41,33 +41,33 @@
 		Object* copy();
 		/*}}}*/
-		/*Param vritual function definitions: {{{1*/
+		/*Param vritual function definitions: {{{*/
 		int   InstanceEnum(){return enum_type;}
-		void  GetParameterValue(bool* pbool){_error_("Vector param of enum %i (%s) cannot return a bool",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int* pinteger){_error_("Vector param of enum %i (%s) cannot return an integer",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM){_error_("Vector param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Vector param of enum %i (%s) cannot return an array of integers",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double* pdouble){_error_("Vector param of enum %i (%s) cannot return a double",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char** pstring){_error_("Vector param of enum %i (%s) cannot return a string",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(char*** pstringarray,int* pM){_error_("Vector param of enum %i (%s) cannot return a string array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM){_error_("Vector param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double** pdoublearray,int* pM, int* pN){_error_("Vector param of enum %i (%s) cannot return a double array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(double*** parray, int* pM,int** pmdims, int** pndims){_error_("Vector param of enum %i (%s) cannot return a matrix array",enum_type,EnumToStringx(enum_type));}
-		void  GetParameterValue(Matrix** pmat){_error_("Vector param of enum %i (%s) cannot return a Mat",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(bool* pbool){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a bool");}
+		void  GetParameterValue(int* pinteger){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");}
+		void  GetParameterValue(int** pintarray,int* pM){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(int** pintarray,int* pM,int* pN){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of integers");}
+		void  GetParameterValue(IssmDouble* pIssmDouble){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble");}
+		void  GetParameterValue(char** pstring){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string");}
+		void  GetParameterValue(char*** pstringarray,int* pM){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a string array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, int* pN){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a IssmDouble array");}
+		void  GetParameterValue(IssmDouble*** parray, int* pM,int** pmdims, int** pndims){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a matrix array");}
+		void  GetParameterValue(Matrix** pmat){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a Mat");}
 		void  GetParameterValue(Vector** poutput);
-		void  GetParameterValue(FILE** pfid){_error_("Vector of enum %i (%s) cannot return a FILE",enum_type,EnumToStringx(enum_type));}
+		void  GetParameterValue(FILE** pfid){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 
-		void  SetValue(bool boolean){_error_("Vector of enum %i (%s) cannot hold a boolean",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int integer){_error_("Vector of enum %i (%s) cannot hold an integer",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double scalar){_error_("Vector of enum %i (%s) cannot hold a scalar",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char* string){_error_("Vector of enum %i (%s) cannot hold a string",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(char** stringarray,int M){_error_("Vector of enum %i (%s) cannot hold a string array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* doublearray,int M){_error_("Vector of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double* pdoublearray,int M,int N){_error_("Vector of enum %i (%s) cannot hold a double array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* intarray,int M){_error_("Vector of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(int* pintarray,int M,int N){_error_("Vector of enum %i (%s) cannot hold a int array",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(bool boolean){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
+		void  SetValue(int integer){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
+		void  SetValue(IssmDouble scalar){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a scalar");}
+		void  SetValue(char* string){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string");}
+		void  SetValue(char** stringarray,int M){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a string array");}
+		void  SetValue(IssmDouble* IssmDoublearray,int M){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a IssmDouble array");}
+		void  SetValue(int* intarray,int M){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
+		void  SetValue(int* pintarray,int M,int N){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a int array");}
 		void  SetValue(Vector* vec);
-		void  SetValue(Matrix* mat){_error_("Vector of enum %i (%s) cannot hold a Mat",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(FILE* fid){_error_("Vector of enum %i (%s) cannot hold a FILE",enum_type,EnumToStringx(enum_type));}
-		void  SetValue(double** array, int M, int* mdim_array, int* ndim_array){_error_("Vector param of enum %i (%s) cannot hold an array of matrices",enum_type,EnumToStringx(enum_type));}
+		void  SetValue(Matrix* mat){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a Mat");}
+		void  SetValue(FILE* fid){_error2_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
+		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error2_("Vector param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
 
Index: /issm/trunk/src/c/objects/Patch.cpp
===================================================================
--- /issm/trunk/src/c/objects/Patch.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Patch.cpp	(revision 12706)
@@ -3,5 +3,5 @@
  */
 
-/*Include files: {{{1*/
+/*Include files: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -22,5 +22,5 @@
 
 /*Object constructors and destructors:*/
-/*FUNCTION Patch::Patch() default constructor {{{1*/
+/*FUNCTION Patch::Patch() default constructor {{{*/
 Patch::Patch(){
 	this->numrows=0;
@@ -31,5 +31,5 @@
 }
 /*}}}*/
-/*FUNCTION Patch::Patch(int numrows, int maxvertices, int maxnodes){{{1*/
+/*FUNCTION Patch::Patch(int numrows, int maxvertices, int maxnodes){{{*/
 Patch::Patch(int in_numrows, int in_maxvertices, int in_maxnodes){
 
@@ -52,5 +52,5 @@
 	}
 	else{
-		this->values=(double*)xmalloc(this->numcols*this->numrows*sizeof(double));
+	        this->values=xNew<IssmDouble>(this->numcols*this->numrows);
 		for(i=0;i<this->numrows;i++){
 			for(j=0;j<this->numcols;j++){
@@ -62,16 +62,16 @@
 }
 /*}}}*/
-/*FUNCTION Patch::~Patch(){{{1*/
+/*FUNCTION Patch::~Patch(){{{*/
 Patch::~Patch(){
-	xfree((void**)&values);
+	xDelete<IssmDouble>(values);
 }
 /*}}}*/
 
 /*Object methods*/
-/*FUNCTION Patch::fillelementinfo{{{1*/
+/*FUNCTION Patch::fillelementinfo{{{*/
 void Patch::fillelementinfo(int count, int element_id, int* vertices_ids, int num_vertices){
 
 	int i;
-	double* row=NULL;
+	IssmDouble* row=NULL;
 
 	/*point to the start of the row: */
@@ -88,9 +88,9 @@
 }
 /*}}}*/
-/*FUNCTION Patch::fillresultinfo{{{1*/
-void Patch::fillresultinfo(int count,int enum_type,int step, double time, int interpolation, double* nodal_values, int num_nodes){
+/*FUNCTION Patch::fillresultinfo{{{*/
+void Patch::fillresultinfo(int count,int enum_type,int step, IssmDouble time, int interpolation, IssmDouble* nodal_values, int num_nodes){
 
 	int i;
-	double* row=NULL;
+	IssmDouble* row=NULL;
 
 	/*point to the start of the row: */
@@ -101,5 +101,5 @@
 	 */
 	row[0]=enum_type;
-	row[1]=(double)step;
+	row[1]=(IssmDouble)step;
 	row[2]=time;
 	row[4]=interpolation;
@@ -110,5 +110,5 @@
 }
 /*}}}*/
-/*FUNCTION Patch::Gather{{{1*/
+/*FUNCTION Patch::Gather{{{*/
 void Patch::Gather(void){
 
@@ -119,5 +119,5 @@
 	int         total_numrows;
 	int         node_numrows;
-	double     *total_values  = NULL;
+	IssmDouble     *total_values  = NULL;
 	#ifdef _HAVE_MPI_
 	MPI_Status  status;
@@ -136,10 +136,10 @@
 
 	/*Now, allocate buffer to holds all the values, on node 0: */
-	if(my_rank==0)total_values=(double*)xmalloc(this->numcols*total_numrows*sizeof(double));
+	if(my_rank==0)total_values=xNew<IssmDouble>(this->numcols*total_numrows);
 
 	/*Start by copying node 0 values onto total_values: */
 	if(my_rank==0){
 		count=0;
-		memcpy(total_values+count,this->values,this->numcols*this->numrows*sizeof(double));
+		xMemCpy<IssmDouble>(total_values+count,this->values,this->numcols*this->numrows);
 		count+=this->numrows*this->numcols;
 	}
@@ -164,5 +164,5 @@
 	if(my_rank==0){
 		this->numrows=total_numrows;
-		xfree((void**)&this->values);
+		xDelete<IssmDouble>(this->values);
 		this->values=total_values;
 	}
@@ -170,5 +170,5 @@
 	else{
 		this->numrows=0;
-		xfree((void**)&this->values);
+		xDelete<IssmDouble>(this->values);
 	}
 	#endif
Index: /issm/trunk/src/c/objects/Segment.cpp
===================================================================
--- /issm/trunk/src/c/objects/Segment.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Segment.cpp	(revision 12706)
@@ -3,5 +3,5 @@
  */
 
-/*Include files: {{{1*/
+/*Include files: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,5 +20,5 @@
 
 /*Segment constructors and destructors:*/
-/*FUNCTION Segment::Segment() default constructor {{{1*/
+/*FUNCTION Segment::Segment() default constructor {{{*/
 Segment::Segment(){
 	this->eid=UNDEF;
@@ -29,6 +29,6 @@
 }
 /*}}}*/
-/*FUNCTION Segment::Segment(int eid, double x1,double y1,double x2, double y2){{{1*/
-Segment::Segment(int segment_eid, double segment_x1,double segment_y1,double segment_x2, double segment_y2){
+/*FUNCTION Segment::Segment(int eid, IssmDouble x1,IssmDouble y1,IssmDouble x2, IssmDouble y2){{{*/
+Segment::Segment(int segment_eid, IssmDouble segment_x1,IssmDouble segment_y1,IssmDouble segment_x2, IssmDouble segment_y2){
 
 	this->eid=segment_eid;
@@ -40,5 +40,5 @@
 }
 /*}}}*/
-/*FUNCTION Segment::~Segment(){{{1*/
+/*FUNCTION Segment::~Segment(){{{*/
 Segment::~Segment(){
 }
@@ -46,23 +46,23 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Segment::Echo{{{1*/
+/*FUNCTION Segment::Echo{{{*/
 void Segment::Echo(void){
 
-	printf("Segment:\n");
-	printf("   eid: %i\n",eid);
-	printf("   node 1: %g|%g\n",this->x1,this->y1);
-	printf("   node 2: %g|%g\n",this->x2,this->y2);
+	_printLine_("Segment:");
+	_printLine_("   eid: " << eid);
+	_printLine_("   node 1: " << this->x1 << "|" << this->y1);
+	_printLine_("   node 2: " << this->x2 << "|" << this->y2);
 
 }
 /*}}}*/
-/*FUNCTION Segment::DeepEcho{{{1*/
+/*FUNCTION Segment::DeepEcho{{{*/
 void Segment::DeepEcho(void){
 	this->Echo();
 }
 /*}}}*/
-/*FUNCTION Segment::Id{{{1*/
+/*FUNCTION Segment::Id{{{*/
 int    Segment::Id(void){ return eid; }
 /*}}}*/
-/*FUNCTION Segment::MyRank{{{1*/
+/*FUNCTION Segment::MyRank{{{*/
 int    Segment::MyRank(void){ 
 	extern int my_rank;
@@ -71,5 +71,5 @@
 }
 /*}}}*/
-/*FUNCTION Segment::ObjectEnum{{{1*/
+/*FUNCTION Segment::ObjectEnum{{{*/
 int Segment::ObjectEnum(void){
 
@@ -78,5 +78,5 @@
 }
 /*}}}*/
-/*FUNCTION Segment::copy {{{1*/
+/*FUNCTION Segment::copy {{{*/
 Object* Segment::copy() {
 	return new Segment(this->eid,this->x1,this->y1,this->x2,this->y2);
Index: /issm/trunk/src/c/objects/Segment.h
===================================================================
--- /issm/trunk/src/c/objects/Segment.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Segment.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Object.h"
 /*}}}*/
@@ -20,10 +20,10 @@
 		IssmDouble y2;
 
-		/*Segment constructors, destructors {{{1*/
+		/*Segment constructors, destructors {{{*/
 		Segment();
 		Segment(int eid,IssmDouble x1,IssmDouble y1, IssmDouble x2, IssmDouble y2);
 		~Segment();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
Index: /issm/trunk/src/c/objects/Update.h
===================================================================
--- /issm/trunk/src/c/objects/Update.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Update.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "../shared/shared.h"
 /*}}}*/
Index: /issm/trunk/src/c/objects/Vertex.cpp
===================================================================
--- /issm/trunk/src/c/objects/Vertex.cpp	(revision 12705)
+++ /issm/trunk/src/c/objects/Vertex.cpp	(revision 12706)
@@ -3,5 +3,5 @@
  */
 
-/*Include files: {{{1*/
+/*Include files: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -18,15 +18,15 @@
 
 /*Vertex constructors and destructor:*/
-/*FUNCTION Vertex::Vertex() {{{1*/
+/*FUNCTION Vertex::Vertex() {{{*/
 Vertex::Vertex(){
 	return;
 }
 /*}}}*/
-/*FUNCTION Vertex::Vertex(int vertex_id, double vertex_x, double vertex_y, double vertex_z, double vertex_sigma){{{1*/
-Vertex::Vertex(int vertex_id, int vertex_sid,double vertex_x, double vertex_y, double vertex_z, double vertex_sigma,int vertex_connectivity){
+/*FUNCTION Vertex::Vertex(int vertex_id, IssmDouble vertex_x, IssmDouble vertex_y, IssmDouble vertex_z, IssmDouble vertex_sigma){{{*/
+Vertex::Vertex(int vertex_id, int vertex_sid,IssmDouble vertex_x, IssmDouble vertex_y, IssmDouble vertex_z, IssmDouble vertex_sigma,int vertex_connectivity){
 	this->Init(vertex_id, vertex_sid,vertex_x, vertex_y, vertex_z, vertex_sigma,vertex_connectivity);
 }
 /*}}}*/
-/*FUNCTION Vertex::Vertex(int vertex_id, int vertex_sid,int i, IoModel* iomodel) {{{1*/
+/*FUNCTION Vertex::Vertex(int vertex_id, int vertex_sid,int i, IoModel* iomodel) {{{*/
 Vertex::Vertex(int vertex_id, int vertex_sid,int i, IoModel* iomodel){
 
@@ -38,11 +38,11 @@
 }
 /*}}}*/
-/*FUNCTION Vertex::~Vertex() {{{1*/
+/*FUNCTION Vertex::~Vertex() {{{*/
 Vertex::~Vertex(){
 	return;
 }
 /*}}}*/
-/*FUNCTION Vertex::Init{{{1*/
-void Vertex::Init(int vertex_id, int vertex_sid,double vertex_x, double vertex_y, double vertex_z, double vertex_sigma,int vertex_connectivity){
+/*FUNCTION Vertex::Init{{{*/
+void Vertex::Init(int vertex_id, int vertex_sid,IssmDouble vertex_x, IssmDouble vertex_y, IssmDouble vertex_z, IssmDouble vertex_sigma,int vertex_connectivity){
 
 	/*all the initialization has been done by the initializer, just fill in the id: */
@@ -61,30 +61,30 @@
 
 /*Object virtual functions definitions:*/
-/*FUNCTION Vertex::Echo{{{1*/
+/*FUNCTION Vertex::Echo{{{*/
 void Vertex::Echo(void){
 
-	printf("Vertex:\n");
-	printf("   id: %i\n",id);
-	printf("   sid: %i\n",sid);
-	printf("   x: %g\n",x);
-	printf("   y: %g\n",y);
-	printf("   z: %g\n",z);
-	printf("   sigma: %g\n",sigma);
-	printf("   connectivity: %i\n",connectivity);
-	printf("   dof: %i\n",dof);
-	printf("   clone: %i\n",clone);
-
-	return;
-}
-/*}}}*/
-/*FUNCTION Vertex::DeepEcho{{{1*/
+	_printLine_("Vertex:");
+	_printLine_("   id: " << id);
+	_printLine_("   sid: " << sid);
+	_printLine_("   x: " << x);
+	_printLine_("   y: " << y);
+	_printLine_("   z: " << z);
+	_printLine_("   sigma: " << sigma);
+	_printLine_("   connectivity: " << connectivity);
+	_printLine_("   dof: " << dof);
+	_printLine_("   clone: " << clone);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION Vertex::DeepEcho{{{*/
 void Vertex::DeepEcho(void){
 	this->Echo();
 }
 /*}}}*/
-/*FUNCTION Vertex::Id{{{1*/
+/*FUNCTION Vertex::Id{{{*/
 int    Vertex::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Vertex::MyRank {{{1*/
+/*FUNCTION Vertex::MyRank {{{*/
 int    Vertex::MyRank(void){ 
 	extern int my_rank;
@@ -92,5 +92,5 @@
 }
 /*}}}*/
-/*FUNCTION Vertex::ObjectEnum{{{1*/
+/*FUNCTION Vertex::ObjectEnum{{{*/
 int Vertex::ObjectEnum(void){
 
@@ -99,5 +99,5 @@
 }
 /*}}}*/
-/*FUNCTION Vertex::copy {{{1*/
+/*FUNCTION Vertex::copy {{{*/
 Object* Vertex::copy() {
 
@@ -108,5 +108,5 @@
 
 /* DofObject routines: */
-/*FUNCTION Vertex::DistributeDofs{{{1*/
+/*FUNCTION Vertex::DistributeDofs{{{*/
 void  Vertex::DistributeDofs(int* pdofcount){
 
@@ -131,5 +131,5 @@
 }
 /*}}}*/
-/*FUNCTION Vertex::OffsetDofs{{{1*/
+/*FUNCTION Vertex::OffsetDofs{{{*/
 void  Vertex::OffsetDofs(int dofcount){
 	
@@ -146,5 +146,5 @@
 }
 /*}}}*/
-/*FUNCTION Vertex::ShowTrueDofs{{{1*/
+/*FUNCTION Vertex::ShowTrueDofs{{{*/
 void  Vertex::ShowTrueDofs(int* truedofs){
 
@@ -160,5 +160,5 @@
 }
 /*}}}*/
-/*FUNCTION Vertex::UpdateCloneDofs{{{1*/
+/*FUNCTION Vertex::UpdateCloneDofs{{{*/
 void  Vertex::UpdateCloneDofs(int* alltruedofs){
 
@@ -174,5 +174,5 @@
 }
 /*}}}*/
-/*FUNCTION Vertex::SetClone {{{1*/
+/*FUNCTION Vertex::SetClone {{{*/
 void  Vertex::SetClone(int* minranks){
 
@@ -192,15 +192,15 @@
 
 /*Vertex management: */
-/*FUNCTION Vertex::Connectivity{{{1*/
+/*FUNCTION Vertex::Connectivity{{{*/
 int    Vertex::Connectivity(void){return connectivity;}
 /*}}}*/
-/*FUNCTION Vertex::Sid{{{1*/
+/*FUNCTION Vertex::Sid{{{*/
 int    Vertex::Sid(void){ return sid; }
 /*}}}*/
-/*FUNCTION Vertex::UpdateVertexPosition {{{1*/
-void  Vertex::UpdatePosition(Vector* vz,Parameters* parameters,double* thickness,double* bed){
-
-	double oldz,newz;
-	double dt,velz;
+/*FUNCTION Vertex::UpdateVertexPosition {{{*/
+void  Vertex::UpdatePosition(Vector* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed){
+
+	IssmDouble oldz,newz;
+	IssmDouble dt,velz;
 
 	/*Get time stepping*/
Index: /issm/trunk/src/c/objects/Vertex.h
===================================================================
--- /issm/trunk/src/c/objects/Vertex.h	(revision 12705)
+++ /issm/trunk/src/c/objects/Vertex.h	(revision 12706)
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #include "./Object.h"
 class IoModel;
@@ -35,5 +35,5 @@
 		int    dof; //dof to recover values in a vertex indexed vector
 
-		/*Vertex constructors, destructors {{{1*/
+		/*Vertex constructors, destructors {{{*/
 		Vertex();
 		Vertex(int id, int sid,IssmDouble x, IssmDouble y, IssmDouble z, IssmDouble sigma, int connectivity); 
@@ -42,5 +42,5 @@
 		~Vertex();
 		/*}}}*/
-		/*Object virtual functions definitions:{{{1 */
+		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
@@ -50,5 +50,5 @@
 		Object* copy();
 		/*}}}*/
-		/*DofObject routines {{{1*/
+		/*DofObject routines {{{*/
 		void  DistributeDofs(int* pdofcount);
 		void  OffsetDofs(int dofcount);
@@ -57,5 +57,5 @@
 		void  SetClone(int* minranks);
 		/*}}}*/
-		/*Vertex management: {{{1*/
+		/*Vertex management: {{{*/
 		int   Sid(void); 
 		int   Connectivity(void); 
Index: /issm/trunk/src/c/python/include/python_macros.h
===================================================================
--- /issm/trunk/src/c/python/include/python_macros.h	(revision 12705)
+++ /issm/trunk/src/c/python/include/python_macros.h	(revision 12706)
@@ -6,5 +6,5 @@
 #define _PYTHON_MACROS_H_
 
-/*Header {{{1*/
+/*Header {{{*/
 
 #ifdef HAVE_CONFIG_H
@@ -16,5 +16,5 @@
 
 #ifdef _HAVE_PYTHON_
-/* MODULEBOOT/MODULEEND {{{1*/
+/* MODULEBOOT/MODULEEND {{{*/
 
 /*The following macros hide the error exception handling in a matlab module. Just put 
@@ -30,5 +30,5 @@
 //}}}
 #if _PYTHON_MAJOR_ >=3
-/* WRAPPER 3.2 {{{1*/
+/* WRAPPER 3.2 {{{*/
 #define WRAPPER(modulename,...)  \
 \
@@ -57,5 +57,5 @@
 /*}}}*/
 #else
-/* WRAPPER 2.7 {{{1*/
+/* WRAPPER 2.7 {{{*/
 #define WRAPPER(modulename,...)  \
 \
@@ -75,5 +75,5 @@
 /*}}}*/
 #endif
-/* CHECKARGUMENTS {{{1*/
+/* CHECKARGUMENTS {{{*/
 #define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)
 /*}}}*/
Index: /issm/trunk/src/c/python/io/CheckNumPythonArguments.cpp
===================================================================
--- /issm/trunk/src/c/python/io/CheckNumPythonArguments.cpp	(revision 12705)
+++ /issm/trunk/src/c/python/io/CheckNumPythonArguments.cpp	(revision 12706)
@@ -27,9 +27,9 @@
 	if (size==0){
 		function();
-		_error_("usage: see above");
+		_error2_("usage: see above");
 	}
 	else if (size!=NRHS ) {
 		function(); 
-		_error_("usage error.");
+		_error2_("usage error.");
 	}
 	return 1;
Index: /issm/trunk/src/c/python/io/FetchPythonData.cpp
===================================================================
--- /issm/trunk/src/c/python/io/FetchPythonData.cpp	(revision 12705)
+++ /issm/trunk/src/c/python/io/FetchPythonData.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 
 /*Primitive data types*/
-/*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{1*/
+/*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{*/
 void FetchData(double* pscalar,PyObject* py_float){
 
@@ -29,5 +29,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(int* pinteger,PyObject* py_long){{{1*/
+/*FUNCTION FetchData(int* pinteger,PyObject* py_long){{{*/
 void FetchData(int* pinteger, PyObject* py_long){
 
@@ -41,5 +41,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(bool* pboolean,PyObject* py_boolean){{{1*/
+/*FUNCTION FetchData(bool* pboolean,PyObject* py_boolean){{{*/
 void FetchData(bool* pboolean,PyObject* py_boolean){
 
@@ -47,5 +47,5 @@
 	
 	/*check this is indeed a subtype of long type: */
-	if(!PyBool_Check(py_boolean))_error_("expecting a boolean in input!");
+	if(!PyBool_Check(py_boolean))_error2_("expecting a boolean in input!");
 
 	/*extract boolean: */
@@ -57,5 +57,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(double** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{1*/
+/*FUNCTION FetchData(double** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{*/
 void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_matrix){
 
@@ -68,5 +68,5 @@
 	/*retrive dimensions: */
 	ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
-	if(ndim!=2)_error_("expecting an MxN matrix in input!");
+	if(ndim!=2)_error2_("expecting an MxN matrix in input!");
 	dims=PyArray_DIMS((PyArrayObject*)py_matrix);
 	M=dims[0]; N=dims[1];
@@ -81,5 +81,5 @@
 }
 /*}}}*/
-/*FUNCTION FetchData(double** pvector,int* pM, PyObject* py_vector){{{1*/
+/*FUNCTION FetchData(double** pvector,int* pM, PyObject* py_vector){{{*/
 void FetchData(double** pvector,int* pM,PyObject* py_vector){
 
@@ -92,5 +92,5 @@
 	/*retrive dimensions: */
 	ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
-	if(ndim!=1)_error_("expecting an Mx1 vector in input!");
+	if(ndim!=1)_error2_("expecting an Mx1 vector in input!");
 	dims=PyArray_DIMS((PyArrayObject*)py_vector);
 	M=dims[0]; 
@@ -107,5 +107,5 @@
 /*Python version dependent: */
 #if _PYTHON_MAJOR_ >= 3 
-/*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{1*/
+/*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{*/
 void FetchData(char** pstring,PyObject* py_unicode){
 
@@ -124,5 +124,5 @@
 /*}}}*/
 #else
-/*FUNCTION FetchData(char** pstring,PyObject* py_string){{{1*/
+/*FUNCTION FetchData(char** pstring,PyObject* py_string){{{*/
 void FetchData(char** pstring,PyObject* py_string){
 
Index: /issm/trunk/src/c/python/io/WritePythonData.cpp
===================================================================
--- /issm/trunk/src/c/python/io/WritePythonData.cpp	(revision 12705)
+++ /issm/trunk/src/c/python/io/WritePythonData.cpp	(revision 12706)
@@ -21,12 +21,11 @@
 
 
-/*FUNCTION WriteData(PyObject* py_tuple,int index,char* string){{{1*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index,char* string){{{*/
 void WriteData(PyObject* py_tuple, int index, char* string){
 	
 	PyTuple_SetItem(py_tuple, index, PyUnicode_FromString(string));
 
-}
-/*}}}*/
-/*FUNCTION WriteData(PyObject* tuple,int index,Matrix* matrix){{{1*/
+}/*}}}*/
+/*FUNCTION WriteData(PyObject* tuple,int index,Matrix* matrix){{{*/
 void WriteData(PyObject* tuple,int index,Matrix* matrix){
 	
@@ -45,6 +44,6 @@
 
 
-}
-/*FUNCTION WriteData(PyObject* py_tuple,int index,Vector* vector){{{1*/
+}/*}}}*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index,Vector* vector){{{*/
 void WriteData(PyObject* tuple,int index,Vector* vector){
 	
@@ -64,5 +63,5 @@
 }
 /*}}}*/
-/*FUNCTION WriteData(PyObject* py_tuple,int index, double* matrix, int M, int N){{{1*/
+/*FUNCTION WriteData(PyObject* py_tuple,int index, double* matrix, int M, int N){{{*/
 void WriteData(PyObject* tuple, int index, double* matrix, int M,int N){
 	
@@ -76,3 +75,3 @@
 	PyTuple_SetItem(tuple, index, array);
 
-}
+}/*}}}*/
Index: /issm/trunk/src/c/shared/Alloc/alloc.cpp
===================================================================
--- /issm/trunk/src/c/shared/Alloc/alloc.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Alloc/alloc.cpp	(revision 12706)
@@ -31,9 +31,9 @@
 	void* memptr=NULL;
 
-	if(!size)_error_(" attempting to 0 size allocation!");
+	if(!size)_error2_("attempting to 0 size allocation!");
 
 	/* Use the c library to do the allocation: */
 	memptr=malloc(size);
-	if(!memptr) _error_("memory allocation failed!");
+	if(!memptr) _error2_("memory allocation failed!");
 
 	return memptr;
@@ -44,9 +44,9 @@
 	void* memptr=NULL;
 	
-	if(!size)_error_("attempting to 0 size allocation!");
+	if(!size)_error2_("attempting to 0 size allocation!");
 
 	/* Use the c library to do the allocation: */
 	memptr=calloc(n,size);
-	if(!memptr) _error_("memory allocation failed!");
+	if(!memptr) _error2_("memory allocation failed!");
 
 	return memptr;
@@ -84,14 +84,13 @@
 }
 
-
 void* xrealloc( void* pv, int size){
 	
 	register void* value=NULL;
 	
-	if(!size)_error_("attempting to realloc to zero");
+	if(!size)_error2_("attempting to realloc to zero");
 	value = (void*)realloc(pv,size);
 
 	if (value == NULL) {
-		_error_("virtual memory exhausted");
+		_error2_("virtual memory exhausted");
 	}
 	return value;
Index: /issm/trunk/src/c/shared/Alloc/xNewDelete.h
===================================================================
--- /issm/trunk/src/c/shared/Alloc/xNewDelete.h	(revision 12705)
+++ /issm/trunk/src/c/shared/Alloc/xNewDelete.h	(revision 12706)
@@ -8,17 +8,89 @@
 #include <cassert>
 
+
+// memory management of types 
+// T with non-trivial constructors require 
+// C++ style memory management
+#define USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+// but for speed on may alternatively use C memory managment
+// but can do so safely only for T that are at most 
+// plain old data structures (POD)
+#ifndef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+#include <cstdlib>
+#endif 
+
 template <class T> 
 T* xNew(unsigned int size) {
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
   T* aT_p=new T[size];
   assert(aT_p);
   return aT_p;
-};
+#else
+  T* aT_p=(T*)malloc(size*sizeof(T));
+  assert(aT_p);
+  return aT_p;
+#endif  
+}
+
+template <class T> 
+T* xNewZeroInit(unsigned int size) {
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+  T* aT_p=xNew<T>(size);
+  for (unsigned int i=0; i<size;++i) 
+    aT_p[i]=(T)0;
+  return aT_p;
+#else
+  T* aT_p=(T*)calloc(size,sizeof(T));
+  assert(aT_p);
+  return aT_p;
+#endif
+}
 
 template <class T>
 void xDelete(T*& aT_p) { 
   if (aT_p) 
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
     delete []aT_p;
+#else
+    free((void*)aT_p);
+#endif
   aT_p=0;
-};
+}
+
+template <class T> 
+T* xReNew(T* old, unsigned int old_size, unsigned int size) {
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+  T* aT_p=0;
+  if (!old) { // no old memory
+    if (size)  
+      aT_p=xNew<T>(size); // according to realloc behavior in manual page 
+  }
+  else { // have old memory
+    if (!size)  // but 0 size
+      xDelete<T>(old); // according to realloc behavior in manual page
+    else { // non-zero size
+      assert(old_size); // have old memory - need to have old_size set or this call is bad
+      // allocate new, delete old; ; even for the case when size is 
+      // less than old_size we can't just keep the memory unchanged 
+      // because otherwise classes that have ctors/dtors with side-effects 
+      // may misbehave, for example classes with static instance/operations counters. 
+      aT_p=xNew<T>(size);
+      unsigned int iMax=(old_size<size)?old_size:size;
+      for (unsigned int i=0; i<iMax;++i) { 
+	// we need to copy the items by explicit assignments
+	aT_p[i]=old[i];
+      }
+      xDelete<T>(old);
+    }
+  }
+  return aT_p;
+#else
+  T* aT_p=0;
+  aT_p=(T*)realloc((void*)old,size*sizeof(T));
+  if (size) 
+    assert(aT_p); // according to realloc behavior in manual page
+  return aT_p;
+#endif 
+}
 
 #endif
Index: /issm/trunk/src/c/shared/Elements/Arrhenius.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/Arrhenius.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/Arrhenius.cpp	(revision 12706)
@@ -6,5 +6,5 @@
 #include <math.h>
 
-double Arrhenius(double temperature,double depth,double n){
+IssmDouble Arrhenius(IssmDouble temperature,IssmDouble depth,IssmDouble n){
 	/*Use EISMINT Parameterization for the rheology: Payne2000
 	 *
@@ -25,9 +25,9 @@
 
 	/*Some physical constants (Payne2000)*/
-	double beta=8.66*pow(10.,-4.);
-	double R=8.314;
+	IssmDouble beta=8.66*pow(10.,-4.);
+	IssmDouble R=8.314;
 
 	/*Intermediaries*/
-	double A,B,Tstar;
+	IssmDouble A,B,Tstar;
 
 	/*convert temperature to absolute temperature*/
Index: /issm/trunk/src/c/shared/Elements/CoordinateSystemTransform.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/CoordinateSystemTransform.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/CoordinateSystemTransform.cpp	(revision 12706)
@@ -5,12 +5,12 @@
 #include <math.h>
 
-void CoordinateSystemTransform(double** ptransform,Node** nodes,int numnodes,int* cs_array){
+void CoordinateSystemTransform(IssmDouble** ptransform,Node** nodes,int numnodes,int* cs_array){
 
 	int     i,counter;
 	int     numdofs           = 0;
-	double  norm;
-	double *transform         = NULL;
-	double *values            = NULL;
-	double  coord_system[3][3];
+	IssmDouble  norm;
+	IssmDouble *transform         = NULL;
+	IssmDouble *values            = NULL;
+	IssmDouble  coord_system[3][3];
 
 	/*Some checks in debugging mode*/
@@ -22,10 +22,10 @@
 			case XYEnum:   numdofs+=2; break;
 			case XYZPEnum: numdofs+=4; break;
-			default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
+			default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
 		}
 	}
 
 	/*Allocate and initialize transform matrix*/
-	transform=(double*)xmalloc(numdofs*numdofs*sizeof(double));
+	transform=xNew<IssmDouble>(numdofs*numdofs);
 	for(i=0;i<numdofs*numdofs;i++) transform[i]=0.0;
 
@@ -67,5 +67,5 @@
 				break;
 			default:
-				_error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
+				_error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
 		}
 	}
Index: /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp	(revision 12706)
@@ -14,5 +14,5 @@
 
 		/*Allocate:*/
-		ndof_list=(int*)xmalloc(numnodes*sizeof(int));
+		ndof_list=xNew<int>(numnodes);
 
 		/*First, figure out size of doflist: */
@@ -25,5 +25,5 @@
 		if(numdof){
 			/*Allocate: */
-			doflist=(int*)xmalloc(numdof*sizeof(int));
+			doflist=xNew<int>(numdof);
 
 			/*Populate: */
@@ -37,5 +37,5 @@
 	}
 	/*Free ressources:*/
-	xfree((void**)&ndof_list);
+	xDelete<int>(ndof_list);
 
 	return doflist;
Index: /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp	(revision 12706)
@@ -13,6 +13,6 @@
 	if(numnodes){
 		/*allocate: */
-		ndof_list=(int*)xmalloc(numnodes*sizeof(int));
-		ngdof_list_cumulative=(int*)xmalloc(numnodes*sizeof(int));
+		ndof_list=xNew<int>(numnodes);
+		ngdof_list_cumulative=xNew<int>(numnodes);
 
 
@@ -33,5 +33,5 @@
 		if(numdof){
 			/*Allocate: */
-			doflist=(int*)xmalloc(numdof*sizeof(int));
+			doflist=xNew<int>(numdof);
 
 			/*Populate: */
@@ -55,6 +55,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&ndof_list);
-	xfree((void**)&ngdof_list_cumulative);
+	xDelete<int>(ndof_list);
+	xDelete<int>(ngdof_list_cumulative);
 
 	/*CLean-up and return*/
Index: /issm/trunk/src/c/shared/Elements/GetVerticesCoordinates.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetVerticesCoordinates.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/GetVerticesCoordinates.cpp	(revision 12706)
@@ -5,5 +5,5 @@
 #include "./elements.h"
 
-void GetVerticesCoordinates(double* xyz,  Node** nodes, int numvertices){
+void GetVerticesCoordinates(IssmDouble* xyz,  Node** nodes, int numvertices){
 
 	/*In debugging mode, check that nodes is not a NULL pointer*/
Index: /issm/trunk/src/c/shared/Elements/Paterson.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/Paterson.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/Paterson.cpp	(revision 12706)
@@ -7,9 +7,11 @@
 #include <math.h>
 
-double Paterson(double temperature){
+#include "../../include/include.h"
+
+IssmDouble Paterson(IssmDouble temperature){
 	
 	/*output: */
-	double B;
-	double T;
+	IssmDouble B;
+	IssmDouble T;
 
 	/*Switch to celsius from Kelvin: */
@@ -30,39 +32,39 @@
 
 	if(T<=-45.0){
-		B=pow((double)10,(double)8)*(-0.000292866376675*pow(T+50,3)+ 0.011672640664130*pow(T+50,2)  -0.325004442485481*(T+50)+  6.524779401948101);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000292866376675*pow(T+50,3)+ 0.011672640664130*pow(T+50,2)  -0.325004442485481*(T+50)+  6.524779401948101);
 	}
 	else if((T>=-45.0) && (T<=-40.0)){
-		B=pow((double)10,(double)8)*(-0.000292866376675*pow(T+45,3)+ 0.007279645014004*pow(T+45,2)  -0.230243014094813*(T+45)+  5.154964909039554);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000292866376675*pow(T+45,3)+ 0.007279645014004*pow(T+45,2)  -0.230243014094813*(T+45)+  5.154964909039554);
 	}
 	else if((T>=-40.0) && (T<=-35.0)){
-		B=pow((double)10,(double)8)*(0.000072737147457*pow(T+40,3)+  0.002886649363879*pow(T+40,2)  -0.179411542205399*(T+40)+  4.149132666831214);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.000072737147457*pow(T+40,3)+  0.002886649363879*pow(T+40,2)  -0.179411542205399*(T+40)+  4.149132666831214);
 	}
 	else if((T>=-35.0) && (T<=-30.0)){
-		B=pow((double)10,(double)8)*(-0.000086144770023*pow(T+35,3)+ 0.003977706575736*pow(T+35,2)  -0.145089762507325*(T+35)+  3.333333333333331);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000086144770023*pow(T+35,3)+ 0.003977706575736*pow(T+35,2)  -0.145089762507325*(T+35)+  3.333333333333331);
 	}
 	else if((T>=-30.0) && (T<=-25.0)){
-		B=pow((double)10,(double)8)*(-0.000043984685769*pow(T+30,3)+ 0.002685535025386*pow(T+30,2)  -0.111773554501713*(T+30)+  2.696559088937191);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000043984685769*pow(T+30,3)+ 0.002685535025386*pow(T+30,2)  -0.111773554501713*(T+30)+  2.696559088937191);
 	}
 	else if((T>=-25.0) && (T<=-20.0)){
-		B=pow((double)10,(double)8)*(-0.000029799523463*pow(T+25,3)+ 0.002025764738854*pow(T+25,2)  -0.088217055680511*(T+25)+  2.199331606342181);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000029799523463*pow(T+25,3)+ 0.002025764738854*pow(T+25,2)  -0.088217055680511*(T+25)+  2.199331606342181);
 	}
 	else if((T>=-20.0) && (T<=-15.0)){
-		B=pow((double)10,(double)8)*(0.000136920904777*pow(T+20,3)+  0.001578771886910*pow(T+20,2)  -0.070194372551690*(T+20)+  1.805165505978111);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.000136920904777*pow(T+20,3)+  0.001578771886910*pow(T+20,2)  -0.070194372551690*(T+20)+  1.805165505978111);
 	}
 	else if((T>=-15.0) && (T<=-10.0)){
-		B=pow((double)10,(double)8)*(-0.000899763781026*pow(T+15,3)+ 0.003632585458564*pow(T+15,2)  -0.044137585824322*(T+15)+  1.510778053489523);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000899763781026*pow(T+15,3)+ 0.003632585458564*pow(T+15,2)  -0.044137585824322*(T+15)+  1.510778053489523);
 	}
 	else if((T>=-10.0) && (T<=-5.0)){
-		B=pow((double)10,(double)8)*(0.001676964325070*pow(T+10,3)-  0.009863871256831*pow(T+10,2)  -0.075294014815659*(T+10)+  1.268434288203714);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(0.001676964325070*pow(T+10,3)-  0.009863871256831*pow(T+10,2)  -0.075294014815659*(T+10)+  1.268434288203714);
 	}
 	else if((T>=-5.0) && (T<=-2.0)){
-		B=pow((double)10,(double)8)*(-0.003748937622487*pow(T+5,3)+0.015290593619213*pow(T+5,2)  -0.048160403003748*(T+5)+  0.854987973338348);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622487*pow(T+5,3)+0.015290593619213*pow(T+5,2)  -0.048160403003748*(T+5)+  0.854987973338348);
 	}
 	else if(T>=-2.0){
-		B=pow((double)10,(double)8)*(-0.003748937622488*pow(T+2,3)-0.018449844983174*pow(T+2,2)  -0.057638157095631*(T+2)+  0.746900791092860);
+		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622488*pow(T+2,3)-0.018449844983174*pow(T+2,2)  -0.057638157095631*(T+2)+  0.746900791092860);
 	}
 
 	/*B cannot be negative!*/
-	if(B<0) B=pow((double)10,(double)6);
+	if(B<0) B=pow((IssmPDouble)10,(IssmPDouble)6);
 
 	return B;
Index: /issm/trunk/src/c/shared/Elements/TransformInvStiffnessMatrixCoord.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/TransformInvStiffnessMatrixCoord.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/TransformInvStiffnessMatrixCoord.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 
 	/*All nodes have the same Coordinate System*/
-	cs_array=(int*)xmalloc(numnodes*sizeof(int));
+	cs_array=xNew<int>(numnodes);
 	for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
 
@@ -16,5 +16,5 @@
 
 	/*Clean-up*/
-	xfree((void**)&cs_array);
+	xDelete<int>(cs_array);
 }
 
@@ -23,6 +23,6 @@
 	int     i,j;
 	int     numdofs   = 0;
-	double *transform = NULL;
-	double *values    = NULL;
+	IssmDouble *transform = NULL;
+	IssmDouble *values    = NULL;
 
 	/*Get total number of dofs*/
@@ -31,10 +31,10 @@
 			case XYEnum:   numdofs+=2; break;
 			case XYZPEnum: numdofs+=4; break;
-			default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
+			default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
 		}
 	}
 
 	/*Copy current stiffness matrix*/
-	values=(double*)xmalloc(Ke->nrows*Ke->ncols*sizeof(double));
+	values=xNew<IssmDouble>(Ke->nrows*Ke->ncols);
 	for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j];
 
@@ -49,5 +49,5 @@
 
 	/*Free Matrix*/
-	xfree((void**)&transform);
-	xfree((void**)&values);
+	xDelete<IssmDouble>(transform);
+	xDelete<IssmDouble>(values);
 }
Index: /issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp	(revision 12706)
@@ -8,5 +8,5 @@
 
 	/*All nodes have the same Coordinate System*/
-	cs_array=(int*)xmalloc(numnodes*sizeof(int));
+	cs_array=xNew<int>(numnodes);
 	for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
 
@@ -15,5 +15,5 @@
 
 	/*Clean-up*/
-	xfree((void**)&cs_array);
+	xDelete<int>(cs_array);
 }
 
@@ -22,6 +22,6 @@
 	int     i,j;
 	int     numdofs   = 0;
-	double *transform = NULL;
-	double *values    = NULL;
+	IssmDouble *transform = NULL;
+	IssmDouble *values    = NULL;
 
 	/*Get total number of dofs*/
@@ -30,10 +30,10 @@
 			case XYEnum:   numdofs+=2; break;
 			case XYZPEnum: numdofs+=4; break;
-			default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
+			default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
 		}
 	}
 
 	/*Copy current load vector*/
-	values=(double*)xmalloc(pe->nrows*sizeof(double));
+	values=xNew<IssmDouble>(pe->nrows);
 	for(i=0;i<pe->nrows;i++) values[i]=pe->values[i];
 
@@ -46,6 +46,6 @@
 				&pe->values[0],0);
 
-	/*Free Matrix*/
-	xfree((void**)&transform);
-	xfree((void**)&values);
+	/*Free Matrices*/
+	xDelete<IssmDouble>(transform);
+	xDelete<IssmDouble>(values);
 }
Index: /issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp	(revision 12706)
@@ -4,10 +4,10 @@
 #include "./elements.h"
 
-void TransformSolutionCoord(double* solution,Node** nodes,int numnodes,int cs_enum){
+void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int cs_enum){
 
 	int* cs_array=NULL;
 
 	/*All nodes have the same Coordinate System*/
-	cs_array=(int*)xmalloc(numnodes*sizeof(int));
+	cs_array=xNew<int>(numnodes);
 	for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
 
@@ -16,13 +16,13 @@
 
 	/*Clean-up*/
-	xfree((void**)&cs_array);
+	xDelete<int>(cs_array);
 }
 
-void TransformSolutionCoord(double* solution,Node** nodes,int numnodes,int* cs_array){
+void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array){
 
 	int     i,j;
 	int     numdofs   = 0;
-	double *transform = NULL;
-	double *values    = NULL;
+	IssmDouble *transform = NULL;
+	IssmDouble *values    = NULL;
 
 	/*Get total number of dofs*/
@@ -31,10 +31,10 @@
 			case XYEnum:   numdofs+=2; break;
 			case XYZPEnum: numdofs+=4; break;
-			default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
+			default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
 		}
 	}
 
 	/*Copy current solution vector*/
-	values=(double*)xmalloc(numdofs*sizeof(double));
+	values=xNew<IssmDouble>(numdofs);
 	for(i=0;i<numdofs;i++) values[i]=solution[i];
 
@@ -47,6 +47,6 @@
 				&solution[0],0);
 
-	/*Free Matrix*/
-	xfree((void**)&transform);
-	xfree((void**)&values);
+	/*Free Matrices*/
+	xDelete<IssmDouble>(transform);
+	xDelete<IssmDouble>(values);
 }
Index: /issm/trunk/src/c/shared/Elements/TransformStiffnessMatrixCoord.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/TransformStiffnessMatrixCoord.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/TransformStiffnessMatrixCoord.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 
 	/*All nodes have the same Coordinate System*/
-	cs_array=(int*)xmalloc(numnodes*sizeof(int));
+	cs_array=xNew<int>(numnodes);
 	for(int i=0;i<numnodes;i++) cs_array[i]=cs_enum;
 
@@ -16,5 +16,5 @@
 
 	/*Clean-up*/
-	xfree((void**)&cs_array);
+	xDelete<int>(cs_array);
 }
 
@@ -23,6 +23,6 @@
 	int     i,j;
 	int     numdofs   = 0;
-	double *transform = NULL;
-	double *values    = NULL;
+	IssmDouble *transform = NULL;
+	IssmDouble *values    = NULL;
 
 	/*Get total number of dofs*/
@@ -31,10 +31,10 @@
 			case XYEnum:   numdofs+=2; break;
 			case XYZPEnum: numdofs+=4; break;
-			default: _error_("Coordinate system %s not supported yet",EnumToStringx(cs_array[i]));
+			default: _error2_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
 		}
 	}
 
 	/*Copy current stiffness matrix*/
-	values=(double*)xmalloc(Ke->nrows*Ke->ncols*sizeof(double));
+	values=xNew<IssmDouble>(Ke->nrows*Ke->ncols);
 	for(i=0;i<Ke->nrows;i++) for(j=0;j<Ke->ncols;j++) values[i*Ke->ncols+j]=Ke->values[i*Ke->ncols+j];
 
@@ -49,5 +49,5 @@
 
 	/*Free Matrix*/
-	xfree((void**)&transform);
-	xfree((void**)&values);
+	xDelete<IssmDouble>(transform);
+	xDelete<IssmDouble>(values);
 }
Index: /issm/trunk/src/c/shared/Elements/elements.h
===================================================================
--- /issm/trunk/src/c/shared/Elements/elements.h	(revision 12705)
+++ /issm/trunk/src/c/shared/Elements/elements.h	(revision 12706)
@@ -11,13 +11,19 @@
 class ElementVector;
 
+<<<<<<< .working
 double Paterson(double temperature);
 double Arrhenius(double temperature,double depth,double n);
 double PddSurfaceMassBlance(double* monthlytemperatures,  double* monthlyprec, double* pdds, double* pds, double signorm, double yts, double h, double s, double rho_ice, double rho_water);
 void   GetVerticesCoordinates(double* xyz,  Node** nodes, int numvertices);
+=======
+IssmDouble Paterson(IssmDouble temperature);
+IssmDouble Arrhenius(IssmDouble temperature,IssmDouble depth,IssmDouble n);
+void   GetVerticesCoordinates(IssmDouble* xyz,  Node** nodes, int numvertices);
+>>>>>>> .merge-right.r12703
 int    GetNumberOfDofs( Node** nodes,int numnodes,int setenum,int approximation_enum);
 int*   GetLocalDofList( Node** nodes,int numnodes,int setenum,int approximation_enum);
 int*   GetGlobalDofList(Node** nodes,int numnodes,int setenum,int approximation_enum);
 #ifdef _HAVE_DIAGNOSTIC_
-void   CoordinateSystemTransform(double** ptransform,Node** nodes,int numnodes,int* cs_array);
+void   CoordinateSystemTransform(IssmDouble** ptransform,Node** nodes,int numnodes,int* cs_array);
 void   TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int cs_enum);
 void   TransformInvStiffnessMatrixCoord(ElementMatrix* Ke,Node** nodes,int numnodes,int* cs_array);
@@ -26,34 +32,33 @@
 void   TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int cs_enum);
 void   TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int* cs_array);
-void   TransformSolutionCoord(double* solution,Node** nodes,int numnodes,int cs_enum);
-void   TransformSolutionCoord(double* solution,Node** nodes,int numnodes,int* cs_array);
+void   TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int cs_enum);
+void   TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array);
 #endif
 
-inline void printarray(double* array,int lines,int cols=1){
-	printf("\n");
+inline void printarray(IssmPDouble* array,int lines,int cols=1){
+	_printLine_("");
 	for(int i=0;i<lines;i++){  
-		printf("   [ ");
-		for(int j=0;j<cols;j++) printf(" %12.7g ",array[i*cols+j]);
-		printf(" ]\n");
+		_printString_("   [ ");
+		for(int j=0;j<cols;j++) _printString_( " " << setw(11) << setprecision (5) << array[i*cols+j]);
+		_printLine_(" ]");
 	}  
-	printf("\n");
+	_printLine_("");
 }
 inline void printarray(int* array,int lines,int cols=1){
-	printf("\n");
+	_printLine_("");
 	for(int i=0;i<lines;i++){  
-		printf("   [ ");
-		for(int j=0;j<cols;j++) printf(" %6i",array[i*cols+j]);
-		printf(" ]\n");
+		_printString_("   [ ");
+		for(int j=0;j<cols;j++) _printString_( " " << setw(11) << setprecision (5) << array[i*cols+j]);
+		_printLine_(" ]");
 	}  
-	printf("\n");
+	_printLine_("");
 }
 inline void printbinary(int n) {
 	unsigned int i=1L<<(sizeof(n)*8-1);
-
 	while (i>0) {
 		if (n&i)
-		 printf("1");
+		 _printString_("1");
 		else
-		 printf("0");
+		 _printString_("0");
 		i>>=1;
 	}
Index: /issm/trunk/src/c/shared/Exceptions/Exceptions.cpp
===================================================================
--- /issm/trunk/src/c/shared/Exceptions/Exceptions.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Exceptions/Exceptions.cpp	(revision 12706)
@@ -20,5 +20,5 @@
 }
 
-ErrorException::ErrorException(string what_file,string what_function,int what_line,string what_arg){
+ErrorException::ErrorException(const string& what_file, const string& what_function,int what_line, const string& what_arg){
 
 	what_str=what_arg;
@@ -44,14 +44,14 @@
 
 	if (function_name=="" || file_line==0){ //WINDOWS
-		printf("%s%s","Error message: ",what());
+		_printString_("Error message: " << what());
 	}
 	else{
 		if(num_procs==1){
-			printf("\n??? Error using ==> %s:%i\n",file_name.c_str(),file_line);
-			printf("%s error message: %s\n\n",function_name.c_str(),what());
+			_printLine_("\n??? Error using ==> " << file_name.c_str() << ":" << file_line);
+			_printLine_(function_name.c_str() << " error message: " << what() << "\n");
 		}
 		else{
-			printf("\n[%i] ??? Error using ==> %s:%i\n",my_rank,file_name.c_str(),file_line);
-			printf("[%i] %s error message: %s\n\n",my_rank,function_name.c_str(),what());
+			_printLine_("\n[" << my_rank << "] ??? Error using ==> " << file_name.c_str() << ":" << file_line);
+			_printLine_("[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n");
 		}
 	}
Index: /issm/trunk/src/c/shared/Exceptions/exceptions.h
===================================================================
--- /issm/trunk/src/c/shared/Exceptions/exceptions.h	(revision 12705)
+++ /issm/trunk/src/c/shared/Exceptions/exceptions.h	(revision 12706)
@@ -24,5 +24,5 @@
 	public:
 	ErrorException(const string &what_arg); //for windows
-	ErrorException(string what_file,string what_function,int what_line,string what_arg);//UNIX
+	ErrorException(const string&  what_file,const string& what_function,int what_line,const string& what_arg);//UNIX
 	~ErrorException() throw();
 	virtual const char *what() const throw();
Index: /issm/trunk/src/c/shared/Exceptions/exprintf.cpp
===================================================================
--- /issm/trunk/src/c/shared/Exceptions/exprintf.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Exceptions/exprintf.cpp	(revision 12706)
@@ -9,4 +9,5 @@
 #include <stdarg.h>
 #include <stdio.h>
+#include "../Alloc/xNewDelete.h"
 #include "../Alloc/alloc.h"
 
@@ -14,17 +15,37 @@
 
 	/*returned string: */
-	char* string=NULL;
+	char *buffer = NULL;
+	int   n,size = 100;
+	int   string_size;
 
-	/*Assum nobody will print more that 1024 characters!*/
-	string=(char*)xmalloc(1024*sizeof(char));//assume that nobody will print more than 1024 characters at once.
-                                                                                                                                                                                                     
 	//variable list of arguments
-	va_list ap;
+	va_list args;
 
-	//First use vsprintf to get the whole input string.
-	va_start(ap,format);
-	vsprintf(string,format,ap); //printf style coding 
-	va_end(ap); 
+	while(true){
 
-	return string;
+		/*allocate buffer for given string size*/
+		buffer=xNew<char>(size);
+
+		/* Try to print in the allocated space. */
+		va_start(args, format);
+#ifndef WIN32
+		n=vsnprintf(buffer,size,format,args);
+#else
+		n=vsnprintf(buffer,size,format,args);
+#endif
+		va_end(args);
+
+		/* If that worked, return the string. */
+		if(n>-1 && n<size) break;
+
+		/* Else try again with more space. */
+		if(n>-1)   /* glibc 2.1 */
+		 size=n+1; /* precisely what is needed */
+		else       /* glibc 2.0 */
+		 size*=2;  /* twice the old size */
+
+		xDelete<char>(buffer);
+	}
+
+	return buffer;
 }
Index: /issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp
===================================================================
--- /issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp	(revision 12706)
@@ -20,24 +20,24 @@
 
 	/*I/O: */
-	FILE* fid=NULL;
-	char chardummy[256];
+	FILE   *fid = NULL;
+	char    chardummy[256];
 	double  ddummy;
 
 	/*output: */
-	int nprof; //number of profiles in the domainname file
-	int* profnvertices=NULL; //array holding the number of vertices for the nprof profiles
-	double** pprofx=NULL; //array of profiles x coordinates
-	double** pprofy=NULL; //array of profiles y coordinates
-	bool* closed=NULL; //array holding closed flags for the nprof profiles
+	int      nprof;                //number of profiles in the domainname file
+	int     *profnvertices = NULL; //array holding the number of vertices for the nprof profiles
+	double **pprofx        = NULL; //array of profiles x coordinates
+	double **pprofy        = NULL; //array of profiles y coordinates
+	bool    *closed        = NULL; //array holding closed flags for the nprof profiles
 
 	/*For each profile: */
-	int n;
-	double* x=NULL;
-	double* y=NULL;
-	bool cl;
+	int     n;
+	double *x  = NULL;
+	double *y  = NULL;
+	bool    cl;
 
 	/*open domain outline file for reading: */
 	if ((fid=fopen(domainname,"r"))==NULL){
-		_error_("%s%s","could not find domain file ",domainname); 
+		_error2_("could not find domain file " << domainname); 
 	}
 
@@ -62,12 +62,12 @@
 	
 	/*Allocate and initialize all the profiles: */
-	profnvertices=(int*)xmalloc(nprof*sizeof(int));
-	pprofx=(double**)xmalloc(nprof*sizeof(double*));
-	pprofy=(double**)xmalloc(nprof*sizeof(double*));
+	profnvertices=xNew<int>(nprof);
+	pprofx=xNew<double*>(nprof);
+	pprofy=xNew<double*>(nprof);
 	for (i=0;i<nprof;i++){
 		pprofx[i]=NULL;
 		pprofy[i]=NULL;
 	}
-	closed=(bool*)xmalloc(nprof*sizeof(bool));
+	closed=xNew<bool>(nprof);
 
 	/*Reaset file pointer to beginning of file: */
@@ -89,8 +89,7 @@
 
 		/*Allocate vertices: */
-		x=(double*)xmalloc(n*sizeof(double));
-		y=(double*)xmalloc(n*sizeof(double));
+		x=xNew<double>(n);
+		y=xNew<double>(n);
 		
-
 		/*Read vertices: */
 		for (i=0;i<n;i++){
@@ -119,6 +118,8 @@
 	*ppprofx=pprofx;
 	*ppprofy=pprofy;
-	if(pclosed)*pclosed=closed;
-	else       xfree((void**)&closed);
+	if(pclosed)
+	 *pclosed=closed;
+	else
+	 xDelete<bool>(closed);
 }
 
Index: /issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp
===================================================================
--- /issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp	(revision 12706)
@@ -23,5 +23,5 @@
 	/*open domain outline file for writing: */
 	if ((fid=fopen(domainname,"w"))==NULL){
-		_error_("%s%s","could not open domain file ",domainname); 
+		_error2_("could not open domain file " << domainname); 
 		noerr=0; goto cleanupandreturn;
 	}
Index: /issm/trunk/src/c/shared/Exp/IsInPoly.cpp
===================================================================
--- /issm/trunk/src/c/shared/Exp/IsInPoly.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Exp/IsInPoly.cpp	(revision 12706)
@@ -14,5 +14,5 @@
 #endif
 
-/*IsInPoly {{{1*/
+/*IsInPoly {{{*/
 int IsInPoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
 
@@ -55,5 +55,5 @@
 	 return 1;
 }/*}}}*/
-/*IsOutsidePoly {{{1*/
+/*IsOutsidePoly {{{*/
 int IsOutsidePoly(Vector* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
 
@@ -96,5 +96,5 @@
 	return 1;
 }/*}}}*/
-/*pnpoly{{{1*/
+/*pnpoly{{{*/
 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue) {
 	int i, j, c = 0;
Index: /issm/trunk/src/c/shared/Matrix/MatrixUtils.cpp
===================================================================
--- /issm/trunk/src/c/shared/Matrix/MatrixUtils.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Matrix/MatrixUtils.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers*/
-/*{{{1*/
+/*{{{*/
 #include "./matrix.h"
 #include "../Exceptions/exceptions.h"
@@ -16,10 +16,10 @@
 /*}}}*/
 
-/*FUNCTION TripleMultiply {{{1*/
-int TripleMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int nrowc, int ncolc, int itrnc, double* d, int iaddd){
+/*FUNCTION TripleMultiply {{{*/
+int TripleMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int nrowc, int ncolc, int itrnc, IssmDouble* d, int iaddd){
 	/*TripleMultiply    Perform triple matrix product a*b*c+d.*/
 	
 	int idima,idimb,idimc,idimd;
-	double* dtemp;
+	IssmDouble* dtemp;
 
 /*  set up dimensions for triple product  */
@@ -36,5 +36,5 @@
 	if (!itrnb) {
 		if (nrowb != idimb) {
-			_error_("Matrix A and B inner vectors not equal size.");
+			_error2_("Matrix A and B inner vectors not equal size.");
 		}
 		idimc=ncolb;
@@ -42,5 +42,5 @@
 	else {
 		if (ncolb != idimb) {
-			_error_("Matrix A and B inner vectors not equal size.");
+			_error2_("Matrix A and B inner vectors not equal size.");
 		}
 		idimc=nrowb;
@@ -49,5 +49,5 @@
 	if (!itrnc) {
 		if (nrowc != idimc) {
-			_error_("Matrix B and C inner vectors not equal size.");
+			_error2_("Matrix B and C inner vectors not equal size.");
 		}
 		idimd=ncolc;
@@ -55,5 +55,5 @@
 	else {
 		if (ncolc != idimc) {
-			_error_("Matrix B and C inner vectors not equal size.");
+			_error2_("Matrix B and C inner vectors not equal size.");
 		}
 		idimd=nrowc;
@@ -62,6 +62,6 @@
 /*  perform the matrix triple product in the order that minimizes the
 	number of multiplies and the temporary space used, noting that
-	(a*b)*c requires ac(b+d) multiplies and ac doubles, and a*(b*c)
-	requires bd(a+c) multiplies and bd doubles (both are the same for
+	(a*b)*c requires ac(b+d) multiplies and ac IssmDoubles, and a*(b*c)
+	requires bd(a+c) multiplies and bd IssmDoubles (both are the same for
 	a symmetric triple product)  */
 
@@ -69,14 +69,9 @@
 
 	if (idima*idimc*(idimb+idimd) <= idimb*idimd*(idima+idimc)) {
-		dtemp=(double *) xmalloc(idima*idimc*sizeof(double));
-
-		MatrixMultiply(a    ,nrowa,ncola,itrna,
-				   b    ,nrowb,ncolb,itrnb,
-				   dtemp,0);
-		MatrixMultiply(dtemp,idima,idimc,0    ,
-				   c    ,nrowc,ncolc,itrnc,
-				   d    ,iaddd);
-
-		xfree((void **)&dtemp);
+		dtemp=xNew<IssmDouble>(idima*idimc);
+
+		MatrixMultiply(a,nrowa,ncola,itrna,b,nrowb,ncolb,itrnb,dtemp,0);
+		MatrixMultiply(dtemp,idima,idimc,0,c,nrowc,ncolc,itrnc,d,iaddd);
+		xDelete<IssmDouble>(dtemp);
 	}
 
@@ -84,20 +79,15 @@
 
 	else {
-		dtemp=(double *) xmalloc(idimb*idimd*sizeof(double));
-
-		MatrixMultiply(b    ,nrowb,ncolb,itrnb,
-				   c    ,nrowc,ncolc,itrnc,
-				   dtemp,0);
-		MatrixMultiply(a    ,nrowa,ncola,itrna,
-				   dtemp,idimb,idimd,0    ,
-				   d    ,iaddd);
-
-		xfree((void **)&dtemp);
+		dtemp=xNew<IssmDouble>(idimb*idimd);
+
+		MatrixMultiply(b,nrowb,ncolb,itrnb,c,nrowc,ncolc,itrnc,dtemp,0);
+		MatrixMultiply(a,nrowa,ncola,itrna,dtemp,idimb,idimd,0,d,iaddd);
+		xDelete<IssmDouble>(dtemp);
 	}
 
 	return 1;
 }/*}}}*/
-/*FUNCTION MatrixMuliply {{{1*/
-int MatrixMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int iaddc ){
+/*FUNCTION MatrixMuliply {{{*/
+int MatrixMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int iaddc ){
 	/*MatrixMultiply    Perform matrix multiplication a*b+c.*/
 	int noerr=1;
@@ -134,5 +124,5 @@
 
 	if (ntrma != ntrmb) {
-		_error_("Matrix A and B inner vectors not equal size");
+		_error2_("Matrix A and B inner vectors not equal size");
 	    noerr=0;	
 		return noerr;
@@ -167,6 +157,6 @@
 	return noerr;
 }/*}}}*/
-/*FUNCTION MatrixInverse {{{1*/
-int MatrixInverse( double* a, int ndim, int nrow, double* b, int nvec, double* pdet ){
+/*FUNCTION MatrixInverse {{{*/
+int MatrixInverse( IssmDouble* a, int ndim, int nrow, IssmDouble* b, int nvec, IssmDouble* pdet ){
 /* MatrixInverse    Perform matrix inversion and linear equation solution.
 
@@ -181,9 +171,9 @@
 	int noerr=1;
 	int i,j,k,ipt,jpt,irow,icol,ipiv,ncol;
-	int (*pivrc)[2],*pindx;
-	double pivot,det,dtemp;
+	int *pivrc1,*pivrc2,*pindx;
+	IssmDouble pivot,det,dtemp;
 
 	if (!b && nvec) {
-		_error_("No right-hand side for nvec=%d.",nvec);
+		_error2_("No right-hand side for nvec=" << nvec << ".");
 		noerr=0;
 		return noerr;
@@ -198,7 +188,7 @@
 	ncol=nrow;
 	det=1.;
-
-	pivrc = (int (*)[2]) xmalloc((nrow*2)*sizeof(int));
-	pindx = (int (*)   ) xcalloc( nrow   ,sizeof(int));
+	pivrc1 =xNew<int>(nrow);
+	pivrc2 =xNew<int>(nrow);
+	pindx =xNew<int>(nrow);
 
 /*  loop over the rows/columns of the matrix  */
@@ -221,13 +211,14 @@
 
 		if (fabs(pivot) < DBL_EPSILON) {
-			xfree((void **)&pivrc);
-			xfree((void **)&pindx);
-			_error_("Pivot %f less than machine epsilon",pivot);
+			xDelete<int>(pivrc1);
+			xDelete<int>(pivrc2);
+			xDelete<int>(pindx);
+			_error2_("Pivot " << pivot << " less than machine epsilon");
 			noerr=0;
 			return noerr;
 		}
 
-		pivrc[i][0]=irow;
-		pivrc[i][1]=icol;
+		pivrc1[i]=irow;
+		pivrc2[i]=icol;
 
 		ipiv=icol;
@@ -319,7 +310,7 @@
 		j=(nrow-1)-i;
 
-		if (pivrc[j][0] != pivrc[j][1]) {
-			irow=pivrc[j][0];
-			icol=pivrc[j][1];
+		if (pivrc1[j] != pivrc2[j]) {
+			irow=pivrc1[j];
+			icol=pivrc2[j];
 
 //			_printf_(true,"column switch back for j=%d: irow=%d, icol=%d\n",
@@ -336,14 +327,12 @@
 	}
 
-	if (pdet)
-		*pdet=det;
-
-	xfree((void **)&pivrc);
-	xfree((void **)&pindx);
-
+	if (pdet) *pdet=det;
+	xDelete<int>(pivrc1);
+	xDelete<int>(pivrc2);
+	xDelete<int>(pindx);
 	return noerr;
 }/*}}}*/
-/*FUNCTION Matrix2x2Determinant(double* Adet,double* A) {{{1*/
-void Matrix2x2Determinant(double* Adet,double* A){
+/*FUNCTION Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A) {{{*/
+void Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A){
 	/*Compute determinant of a 2x2 matrix*/
 
@@ -352,13 +341,13 @@
 }
 /*}}}*/
-/*FUNCTION Matrix2x2Invert(double* Ainv,double* A) {{{1*/
-void Matrix2x2Invert(double* Ainv,double* A){
+/*FUNCTION Matrix2x2Invert(IssmDouble* Ainv,IssmDouble* A) {{{*/
+void Matrix2x2Invert(IssmDouble* Ainv,IssmDouble* A){
 
 	/*Intermediaries*/
-	double det;
+	IssmDouble det;
 
 	/*Compute determinant*/
 	Matrix2x2Determinant(&det,A);
-	if (fabs(det) < DBL_EPSILON) _error_("Determinant smaller that machine epsilon");
+	if (fabs(det) < DBL_EPSILON) _error2_("Determinant smaller that machine epsilon");
 
 	/*Compute invert*/
@@ -369,6 +358,6 @@
 
 }/*}}}*/
-/*FUNCTION Matrix3x3Determinant(double* Adet,double* A) {{{1*/
-void Matrix3x3Determinant(double* Adet,double* A){
+/*FUNCTION Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A) {{{*/
+void Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A){
 	/*Compute determinant of a 3x3 matrix*/
 
@@ -377,13 +366,13 @@
 }
 /*}}}*/
-/*FUNCTION Matrix3x3Invert(double* Ainv,double* A) {{{1*/
-void Matrix3x3Invert(double* Ainv,double* A){
+/*FUNCTION Matrix3x3Invert(IssmDouble* Ainv,IssmDouble* A) {{{*/
+void Matrix3x3Invert(IssmDouble* Ainv,IssmDouble* A){
 
 	/*Intermediaries*/
-	double det;
+	IssmDouble det;
 
 	/*Compute determinant*/
 	Matrix3x3Determinant(&det,A);
-	if (fabs(det) < DBL_EPSILON) _error_("Determinant smaller that machine epsilon");
+	if (fabs(det) < DBL_EPSILON) _error2_("Determinant smaller that machine epsilon");
 
 	/*Compute invert*/
@@ -399,6 +388,6 @@
 
 }/*}}}*/
-/*FUNCTION MatrixTranspose(double* Adet,double* A) {{{1*/
-void MatrixTranspose(double* tA,double* A, int nrows, int ncols){
+/*FUNCTION MatrixTranspose(IssmDouble* Adet,IssmDouble* A) {{{*/
+void MatrixTranspose(IssmDouble* tA,IssmDouble* A, int nrows, int ncols){
 	/*Transpose a n*m matrix*/
 
Index: /issm/trunk/src/c/shared/Matrix/matrix.h
===================================================================
--- /issm/trunk/src/c/shared/Matrix/matrix.h	(revision 12705)
+++ /issm/trunk/src/c/shared/Matrix/matrix.h	(revision 12706)
@@ -6,12 +6,14 @@
 #define _MATRIXUTILS_H_
 
-int  TripleMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int nrowc, int ncolc, int itrnc, double* d, int iaddd);
-int  MatrixMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int iaddc );
-int  MatrixInverse( double* a, int ndim, int nrow, double* b, int nvec, double* pdet );
-void Matrix2x2Invert(double* Ainv, double* A);
-void Matrix2x2Determinant(double* Adet,double* A);
-void Matrix3x3Invert(double* Ainv, double* A);
-void Matrix3x3Determinant(double* Adet,double* A);
-void MatrixTranspose(double* tA,double* A,int nrows, int ncols);
+#include "../../include/include.h"
+
+int  TripleMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int nrowc, int ncolc, int itrnc, IssmDouble* d, int iaddd);
+int  MatrixMultiply( IssmDouble* a, int nrowa, int ncola, int itrna, IssmDouble* b, int nrowb, int ncolb, int itrnb, IssmDouble* c, int iaddc );
+int  MatrixInverse( IssmDouble* a, int ndim, int nrow, IssmDouble* b, int nvec, IssmDouble* pdet );
+void Matrix2x2Invert(IssmDouble* Ainv, IssmDouble* A);
+void Matrix2x2Determinant(IssmDouble* Adet,IssmDouble* A);
+void Matrix3x3Invert(IssmDouble* Ainv, IssmDouble* A);
+void Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A);
+void MatrixTranspose(IssmDouble* tA,IssmDouble* A,int nrows, int ncols);
 
 #endif //ifndef _MATRIXUTILS_H_
Index: /issm/trunk/src/c/shared/MemOps/xMemCpy.h
===================================================================
--- /issm/trunk/src/c/shared/MemOps/xMemCpy.h	(revision 12706)
+++ /issm/trunk/src/c/shared/MemOps/xMemCpy.h	(revision 12706)
@@ -0,0 +1,19 @@
+/* \file xMemCpy.h
+ * \brief: header file for templated memory operations
+ */
+
+#ifndef _XMEMCPY_H_
+#define _XMEMCPY_H_
+
+#include <cassert>
+
+template <class T> 
+T* xMemCpy(T* dest, const T* src, unsigned int size) {
+  assert(dest); assert(src);
+  for (int i=0; i<size;++i) 
+    dest[i]=src[i];
+  return dest;
+};
+
+#endif
+
Index: /issm/trunk/src/c/shared/Numerics/BrentSearch.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/BrentSearch.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/BrentSearch.cpp	(revision 12706)
@@ -15,6 +15,7 @@
 #include "../../shared/shared.h"
 #include <float.h>
-
-void BrentSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs){
+#include <iomanip>
+
+void BrentSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs){
 
 	/* This routine is optimizing a given function using Brent's method
@@ -22,15 +23,15 @@
 
 	/*Intermediary*/
-	double si,gold,intervalgold,oldintervalgold;
-	double parab_num,parab_den;
-	double distance,cm_jump;
-	double fxmax,fxmin,fxbest;
-	double fx,fx1,fx2;
-	double xmax,xmin,xbest;
-	double x,x1,x2,xm;
-	double tol1,tol2,seps;
-	double tolerance=1.e-4;
-	int    maxiter,iter;
-	bool   loop=true,goldenflag;
+	IssmDouble si,gold,intervalgold,oldintervalgold;
+	IssmDouble parab_num,parab_den;
+	IssmDouble distance,cm_jump;
+	IssmDouble fxmax,fxmin,fxbest;
+	IssmDouble fx,fx1,fx2;
+	IssmDouble xmax,xmin,xbest;
+	IssmDouble x,x1,x2,xm;
+	IssmDouble tol1,tol2,seps;
+	IssmDouble tolerance = 1.e-4;
+	int        maxiter ,iter;
+	bool       loop= true,goldenflag;
 
 	/*Recover parameters:*/
@@ -43,13 +44,16 @@
 	iter=0;
 	fxmin = (*f)(xmin,optargs);
-	if (isnan(fxmin)) _error_("Function evaluation returned NaN");
-	_printf_(VerboseControl(),"\n        Iteration         x           f(x)       Tolerance         Procedure\n\n");
-	_printf_(VerboseControl(),"        %s    %12.6g  %12.6g  %s","   N/A",xmin,fxmin,"         N/A         boundary\n");
+	if (xIsNan<IssmDouble>(fxmin)) _error2_("Function evaluation returned NaN");
+	cout<<setprecision(5);
+	if(VerboseControl()) _pprintLine_("");
+	if(VerboseControl()) _pprintLine_("       Iteration         x           f(x)       Tolerance         Procedure");
+	if(VerboseControl()) _pprintLine_("");
+	if(VerboseControl()) _pprintLine_("           N/A    "<<setw(12)<<xmin<<"  "<<setw(12)<<fxmin<<"           N/A         boundary");
 	fxmax = (*f)(xmax,optargs);
-	if (isnan(fxmax)) _error_("Function evaluation returned NaN");
-	_printf_(VerboseControl(),"        %s    %12.6g  %12.6g  %s","   N/A",xmax,fxmax,"         N/A         boundary\n");
+	if (xIsNan<IssmDouble>(fxmax)) _error2_("Function evaluation returned NaN");
+	if(VerboseControl()) _pprintLine_("           N/A    "<<setw(12)<<xmax<<"  "<<setw(12)<<fxmax<<"           N/A         boundary");
 
 	/*test if jump option activated and xmin==0*/
-	if (!isnan(cm_jump) && (xmin==0) && (fxmax/fxmin)<cm_jump){
+	if (!xIsNan<IssmDouble>(cm_jump) && (xmin==0) && (fxmax/fxmin)<cm_jump){
 		*psearch_scalar=xmax;
 		*pJ=fxmax;
@@ -58,5 +62,5 @@
 
 	/*initialize optimization variables*/
-	seps=sqrt(DBL_EPSILON);    //precision of a double
+	seps=sqrt(DBL_EPSILON);    //precision of a IssmDouble
 	distance=0.0;              //new_x=old_x + distance
 	gold=0.5*(3.0-sqrt(5.0));  //gold = 1 - golden ratio
@@ -71,5 +75,5 @@
 	/*2: call the function to be evaluated*/
 	fxbest = (*f)(x,optargs);
-	if(isnan(fxbest)) _error_("Function evaluation returned NaN");
+	if(xIsNan<IssmDouble>(fxbest)) _error2_("Function evaluation returned NaN");
 	iter=iter+1;
 
@@ -84,7 +88,8 @@
 
 	/*4: print result*/
-	_printf_(VerboseControl(),"         %5i    %12.6g  %12.6g  %12.6g  %s\n",iter,xbest,fxbest,pow(pow(xbest-xm,2),0.5),"       initial");
-	if (!isnan(cm_jump) && (xmin==0) && ((fxbest/fxmin)<cm_jump)){
-		_printf_(VerboseControl(),"      optimization terminated: current x satisfies criteria 'cm_jump'=%g\n",cm_jump);
+	if(VerboseControl())
+	 _pprintLine_("         "<<setw(5)<<iter<<"    "<<setw(12)<<xbest<<"  "<<setw(12)<<fxbest<<"  "<<setw(12)<<pow(pow(xbest-xm,2),0.5)<<"         initial");
+	if (!xIsNan<IssmDouble>(cm_jump) && (xmin==0) && ((fxbest/fxmin)<cm_jump)){
+		if(VerboseControl()) _pprintLine_("      optimization terminated: current x satisfies criteria 'cm_jump'=" << cm_jump);
 		loop=false;
 	}
@@ -154,5 +159,5 @@
 		//evaluate function on x
 		fx = (*f)(x,optargs);
-		if(isnan(fx)) _error_("Function evaluation returned NaN");
+		if(xIsNan<IssmDouble>(fx)) _error2_("Function evaluation returned NaN");
 		iter=iter+1;
 
@@ -179,17 +184,19 @@
 		tol1=seps*pow(pow(xbest,2),0.5)+tolerance/3.0;
 		tol2=2.0*tol1;
-		_printf_(VerboseControl(),"         %5i    %12.6g  %12.6g  %12.6g  %s\n",iter,x,fx,pow(pow(xbest-xm,2),0.5),goldenflag?"       golden":"       parabolic");
+		if(VerboseControl())
+		 _pprintLine_("         "<<setw(5)<<iter<<"    "<<setw(12)<<x<<"  "<<setw(12)<<fx<<"  "<<setw(12)<<pow(pow(xbest-xm,2),0.5)<<
+					 "         "<<(goldenflag?"golden":"parabolic"));
 
 		/*Stop the optimization?*/
 		if (sqrt(pow(xbest-xm,2)) < (tol2-0.5*(xmax-xmin))){
-			_printf_(VerboseControl(),"      optimization terminated: current x satisfies criteria 'tolx'=%g\n",tolerance);
+			if(VerboseControl()) _pprintLine_("      optimization terminated: current x satisfies criteria 'tolx'=" << tolerance);
 			loop=false;
 		}
 		else if (iter>=maxiter){
-			_printf_(VerboseControl(),"      exiting: Maximum number of iterations has been exceeded  ('maxiter'=%i)\n",maxiter);
+			if(VerboseControl()) _pprintLine_("      exiting: Maximum number of iterations has been exceeded  ('maxiter'=" << maxiter << ")");
 			loop=false;
 		}
-		else if (!isnan(cm_jump) && (xmin==0) && ((fxbest/fxmin)<cm_jump)){
-			_printf_(VerboseControl(),"      optimization terminated: current x satisfies criteria 'cm_jump'=%g\n",cm_jump);
+		else if (!xIsNan<IssmDouble>(cm_jump) && (xmin==0) && ((fxbest/fxmin)<cm_jump)){
+			if(VerboseControl()) _pprintLine_("      optimization terminated: current x satisfies criteria 'cm_jump'=" << cm_jump);
 			loop=false;
 		}
Index: /issm/trunk/src/c/shared/Numerics/GaussPoints.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/GaussPoints.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/GaussPoints.cpp	(revision 12706)
@@ -1,7 +1,7 @@
 /*  Gauss point structures and prototypes  */
 
+#include "../../include/include.h"
 #include "./GaussPoints.h"
 #include "../Alloc/alloc.h"
-#include "../../include/include.h"
 #include "../../io/io.h"
 #include "../Exceptions/exceptions.h"
@@ -10,6 +10,6 @@
 
 /*General Gauss points*/
-/*FUNCTION GaussLegendreLinear {{{1*/
-void GaussLegendreLinear( double** pxgaus, double** pxwgt, int ngaus){
+/*FUNCTION GaussLegendreLinear {{{*/
+void GaussLegendreLinear( IssmPDouble** pxgaus, IssmPDouble** pxwgt, int ngaus){
 	/* Gauss-Legendre quadrature points.
 
@@ -25,33 +25,33 @@
 	/*Intermediaries*/
 	int i;
-	double *alpha,*beta;
+	IssmPDouble *alpha,*beta;
 
 	/*p= 1, npoint= 1*/
-	static double wgt1[]={2.000000000000000};
-	static double xi1[]={0.000000000000000};
+	static IssmPDouble wgt1[]={2.000000000000000};
+	static IssmPDouble xi1[]={0.000000000000000};
 
 	/*p= 3, npoint= 2*/
-	static double wgt2[]={1.000000000000000, 1.000000000000000};
-	static double xi2[]={-0.577350269189626, 0.577350269189626};
+	static IssmPDouble wgt2[]={1.000000000000000, 1.000000000000000};
+	static IssmPDouble xi2[]={-0.577350269189626, 0.577350269189626};
 
 	/*p= 5, npoint= 3*/
-	static double wgt3[]={0.555555555555556, 0.888888888888889, 0.555555555555556};
-	static double xi3[]={-0.774596669241483, 0.000000000000000, 0.774596669241483};
+	static IssmPDouble wgt3[]={0.555555555555556, 0.888888888888889, 0.555555555555556};
+	static IssmPDouble xi3[]={-0.774596669241483, 0.000000000000000, 0.774596669241483};
 
 	/*p= 7, npoint= 4*/
-	static double wgt4[]={0.347854845137454, 0.652145154862546, 0.652145154862546, 0.347854845137454};
-	static double xi4[]={-0.861136311594053,-0.339981043584856, 0.339981043584856, 0.861136311594053};
-
-	static double* wgtp[MAX_LINE_GAUS_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 };
-	static double* xip [MAX_LINE_GAUS_PTS]={xi1  ,xi2  ,xi3  ,xi4  };
-
-	static int np[MAX_LINE_GAUS_PTS]={sizeof(wgt1 )/sizeof(double),
-		sizeof(wgt2 )/sizeof(double),
-		sizeof(wgt3 )/sizeof(double),
-		sizeof(wgt4 )/sizeof(double)};
-
-	//	_printf_(true,"Gauss-Legendre recurrence coefficients ngaus=%d\n",ngaus);
-	*pxgaus = (double *) xmalloc(ngaus*sizeof(double));
-	*pxwgt  = (double *) xmalloc(ngaus*sizeof(double));
+	static IssmPDouble wgt4[]={0.347854845137454, 0.652145154862546, 0.652145154862546, 0.347854845137454};
+	static IssmPDouble xi4[]={-0.861136311594053,-0.339981043584856, 0.339981043584856, 0.861136311594053};
+
+	static IssmPDouble* wgtp[MAX_LINE_GAUS_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 };
+	static IssmPDouble* xip [MAX_LINE_GAUS_PTS]={xi1  ,xi2  ,xi3  ,xi4  };
+
+	static int np[MAX_LINE_GAUS_PTS]={sizeof(wgt1 )/sizeof(IssmPDouble),
+		sizeof(wgt2 )/sizeof(IssmPDouble),
+		sizeof(wgt3 )/sizeof(IssmPDouble),
+		sizeof(wgt4 )/sizeof(IssmPDouble)};
+
+	//	_pprintLine_("Gauss-Legendre recurrence coefficients ngaus=" << ngaus);
+	*pxgaus =xNew<IssmPDouble>(ngaus);
+	*pxwgt  =xNew<IssmPDouble>(ngaus);
 
 	/*  check to see if Gauss points need to be calculated  */
@@ -70,6 +70,6 @@
 
 		/*  calculate the Gauss points using recurrence relations  */
-		alpha=(double *) xmalloc(ngaus*sizeof(double));
-		beta =(double *) xmalloc(ngaus*sizeof(double));
+		alpha=xNew<IssmPDouble>(ngaus);
+		beta =xNew<IssmPDouble>(ngaus);
 
 		/*  calculate the Legendre recurrence coefficients  */
@@ -84,10 +84,10 @@
 		/*  calculate the Gauss points  */
 		GaussRecur(*pxgaus, *pxwgt, ngaus, alpha, beta );
-		xfree((void **)&beta );
-		xfree((void **)&alpha);
+		xDelete<IssmPDouble>(beta);
+		xDelete<IssmPDouble>(alpha);
 	}
-}/*}}}1*/
-/*FUNCTION GaussLegendreTria{{{1*/
-void GaussLegendreTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord ) {
+}/*}}}*/
+/*FUNCTION GaussLegendreTria{{{*/
+void GaussLegendreTria( int* pngaus, IssmPDouble** pl1, IssmPDouble** pl2, IssmPDouble** pl3, IssmPDouble** pwgt, int iord ) {
 	/*Gauss quadrature points for the triangle.
 
@@ -98,98 +98,98 @@
 	/*Intermediaries*/
 	int i,j,ipt,nigaus;
-	double xi,eta;
-	double *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt;
+	IssmPDouble xi,eta;
+	IssmPDouble *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt;
 
 	/*Hardcoded Gauss points declaration*/
-	/*p= 1, npoint= 1{{{2*/
-	static double wgt1[]={
+	/*p= 1, npoint= 1{{{*/
+	static IssmPDouble wgt1[]={
 		1.732050807568877};
-	static double l11[]={
+	static IssmPDouble l11[]={
 		0.333333333333333};
-	static double l21[]={
+	static IssmPDouble l21[]={
 		0.333333333333333};
-	static double l31[]={
+	static IssmPDouble l31[]={
 		0.333333333333333};
-	/*}}}2*/
-	/*p= 2, npoint= 3  {{{2*/
-	static double wgt2[]={
+	/*}}}*/
+	/*p= 2, npoint= 3  {{{*/
+	static IssmPDouble wgt2[]={
 		0.577350269189625, 0.577350269189625, 0.577350269189625};
-	static double l12[]={
+	static IssmPDouble l12[]={
 		0.666666666666667, 0.166666666666667, 0.166666666666667};
-	static double l22[]={
+	static IssmPDouble l22[]={
 		0.166666666666667, 0.666666666666667, 0.166666666666667};
-	static double l32[]={
+	static IssmPDouble l32[]={
 		0.166666666666667, 0.166666666666667, 0.666666666666667};
-	/*}}}2*/
-	/*p= 3, npoint= 4  {{{2*/
-	static double wgt3[]={
+	/*}}}*/
+	/*p= 3, npoint= 4  {{{*/
+	static IssmPDouble wgt3[]={
 		-0.974278579257493, 0.902109795608790, 0.902109795608790, 
 		0.902109795608790};
-	static double l13[]={
+	static IssmPDouble l13[]={
 		0.333333333333333, 0.600000000000000, 0.200000000000000, 
 		0.200000000000000};
-	static double l23[]={
+	static IssmPDouble l23[]={
 		0.333333333333333, 0.200000000000000, 0.600000000000000, 
 		0.200000000000000};
-	static double l33[]={
+	static IssmPDouble l33[]={
 		0.333333333333333, 0.200000000000000, 0.200000000000000, 
 		0.600000000000000};
-	/*}}}2*/
-	/*p= 4, npoint= 6  {{{2*/
-	static double wgt4[]={
+	/*}}}*/
+	/*p= 4, npoint= 6  {{{*/
+	static IssmPDouble wgt4[]={
 		0.386908262797819, 0.386908262797819, 0.386908262797819, 
 		0.190442006391807, 0.190442006391807, 0.190442006391807};
-	static double l14[]={
+	static IssmPDouble l14[]={
 		0.108103018168070, 0.445948490915965, 0.445948490915965, 
 		0.816847572980459, 0.091576213509771, 0.091576213509771};
-	static double l24[]={
+	static IssmPDouble l24[]={
 		0.445948490915965, 0.108103018168070, 0.445948490915965, 
 		0.091576213509771, 0.816847572980459, 0.091576213509771};
-	static double l34[]={
+	static IssmPDouble l34[]={
 		0.445948490915965, 0.445948490915965, 0.108103018168070, 
 		0.091576213509771, 0.091576213509771, 0.816847572980459};
-	/*}}}2*/
-	/*p= 5, npoint= 7  {{{2*/
-	static double wgt5[]={
+	/*}}}*/
+	/*p= 5, npoint= 7  {{{*/
+	static IssmPDouble wgt5[]={
 		0.389711431702997, 0.229313399254729, 0.229313399254729, 
 		0.229313399254729, 0.218133059367230, 0.218133059367230, 
 		0.218133059367230};
-	static double l15[]={
+	static IssmPDouble l15[]={
 		0.333333333333333, 0.059715871789770, 0.470142064105115, 
 		0.470142064105115, 0.797426985353087, 0.101286507323456, 
 		0.101286507323456};
-	static double l25[]={
+	static IssmPDouble l25[]={
 		0.333333333333333, 0.470142064105115, 0.059715871789770, 
 		0.470142064105115, 0.101286507323456, 0.797426985353087, 
 		0.101286507323456};
-	static double l35[]={
+	static IssmPDouble l35[]={
 		0.333333333333333, 0.470142064105115, 0.470142064105115, 
 		0.059715871789770, 0.101286507323456, 0.101286507323456, 
 		0.797426985353087};
-	/*}}}2*/
-	/*p= 6, npoint=12  {{{2*/
-	static double wgt6[]={
+	/*}}}*/
+	/*p= 6, npoint=12  {{{*/
+	static IssmPDouble wgt6[]={
 		0.202279763184836, 0.202279763184836, 0.202279763184836, 
 		0.088065961139281, 0.088065961139281, 0.088065961139281, 
 		0.143502272432755, 0.143502272432755, 0.143502272432755, 
 		0.143502272432755, 0.143502272432755, 0.143502272432755};
-	static double l16[]={
+	static IssmPDouble l16[]={
 		0.501426509658179, 0.249286745170910, 0.249286745170910, 
 		0.873821971016996, 0.063089014491502, 0.063089014491502, 
 		0.053145049844817, 0.053145049844817, 0.310352451033784, 
 		0.636502499121399, 0.310352451033784, 0.636502499121399};
-	static double l26[]={
+	static IssmPDouble l26[]={
 		0.249286745170910, 0.501426509658179, 0.249286745170910, 
 		0.063089014491502, 0.873821971016996, 0.063089014491502, 
 		0.310352451033784, 0.636502499121399, 0.053145049844817, 
 		0.053145049844817, 0.636502499121399, 0.310352451033784};
-	static double l36[]={
+	static IssmPDouble l36[]={
 		0.249286745170910, 0.249286745170910, 0.501426509658179, 
 		0.063089014491502, 0.063089014491502, 0.873821971016996, 
 		0.636502499121399, 0.310352451033784, 0.636502499121399, 
 		0.310352451033784, 0.053145049844817, 0.053145049844817};
-	/*}}}2*/
-	/*p= 7, npoint=13  {{{2*/
-	static double wgt7[]={
+	/*}}}*/
+	/*p= 7, npoint=13  {{{*/
+	static IssmPDouble wgt7[]={
 		-0.259062916308362, 0.304174548458604, 0.304174548458604, 
 		0.304174548458604, 0.092400122517855, 0.092400122517855, 
@@ -197,5 +197,5 @@
 		0.133564951824643, 0.133564951824643, 0.133564951824643, 
 		0.133564951824643};
-	static double l17[]={
+	static IssmPDouble l17[]={
 		0.333333333333333, 0.479308067841920, 0.260345966079040, 
 		0.260345966079040, 0.869739794195568, 0.065130102902216, 
@@ -203,5 +203,5 @@
 		0.312865496004874, 0.638444188569810, 0.312865496004874, 
 		0.638444188569810};
-	static double l27[]={
+	static IssmPDouble l27[]={
 		0.333333333333333, 0.260345966079040, 0.479308067841920, 
 		0.260345966079040, 0.065130102902216, 0.869739794195568, 
@@ -209,5 +209,5 @@
 		0.048690315425316, 0.048690315425316, 0.638444188569810, 
 		0.312865496004874};
-	static double l37[]={
+	static IssmPDouble l37[]={
 		0.333333333333333, 0.260345966079040, 0.260345966079040, 
 		0.479308067841920, 0.065130102902216, 0.065130102902216, 
@@ -215,7 +215,7 @@
 		0.638444188569810, 0.312865496004874, 0.048690315425316, 
 		0.048690315425316};
-	/*}}}2*/
-	/*p= 8, npoint=16  {{{2*/
-	static double wgt8[]={
+	/*}}}*/
+	/*p= 8, npoint=16  {{{*/
+	static IssmPDouble wgt8[]={
 		0.249961964823104, 0.164703541925695, 0.164703541925695, 
 		0.164703541925695, 0.178777729989794, 0.178777729989794, 
@@ -224,5 +224,5 @@
 		0.047164287656184, 0.047164287656184, 0.047164287656184, 
 		0.047164287656184};
-	static double l18[]={
+	static IssmPDouble l18[]={
 		0.333333333333333, 0.081414823414554, 0.459292588292723, 
 		0.459292588292723, 0.658861384496480, 0.170569307751760, 
@@ -231,5 +231,5 @@
 		0.263112829634638, 0.728492392955404, 0.263112829634638, 
 		0.728492392955404};
-	static double l28[]={
+	static IssmPDouble l28[]={
 		0.333333333333333, 0.459292588292723, 0.081414823414554, 
 		0.459292588292723, 0.170569307751760, 0.658861384496480, 
@@ -238,5 +238,5 @@
 		0.008394777409958, 0.008394777409958, 0.728492392955404, 
 		0.263112829634638};
-	static double l38[]={
+	static IssmPDouble l38[]={
 		0.333333333333333, 0.459292588292723, 0.459292588292723, 
 		0.081414823414554, 0.170569307751760, 0.170569307751760, 
@@ -245,7 +245,7 @@
 		0.728492392955404, 0.263112829634638, 0.008394777409958, 
 		0.008394777409958};
-	/*}}}2*/
-	/*p= 9, npoint=19  {{{2*/
-	static double wgt9[]={
+	/*}}}*/
+	/*p= 9, npoint=19  {{{*/
+	static IssmPDouble wgt9[]={
 		0.168244134395468, 0.054273292833345, 0.054273292833345, 
 		0.054273292833345, 0.134801255248419, 0.134801255248419, 
@@ -255,5 +255,5 @@
 		0.074969289332873, 0.074969289332873, 0.074969289332873, 
 		0.074969289332873};
-	static double l19[]={
+	static IssmPDouble l19[]={
 		0.333333333333333, 0.020634961602525, 0.489682519198738, 
 		0.489682519198738, 0.125820817014127, 0.437089591492937, 
@@ -263,5 +263,5 @@
 		0.221962989160766, 0.741198598784498, 0.221962989160766, 
 		0.741198598784498};
-	static double l29[]={
+	static IssmPDouble l29[]={
 		0.333333333333333, 0.489682519198738, 0.020634961602525, 
 		0.489682519198738, 0.437089591492937, 0.125820817014127, 
@@ -271,5 +271,5 @@
 		0.036838412054736, 0.036838412054736, 0.741198598784498, 
 		0.221962989160766};
-	static double l39[]={
+	static IssmPDouble l39[]={
 		0.333333333333333, 0.489682519198738, 0.489682519198738, 
 		0.020634961602525, 0.437089591492937, 0.437089591492937, 
@@ -279,7 +279,7 @@
 		0.741198598784498, 0.221962989160766, 0.036838412054736, 
 		0.036838412054736};
-	/*}}}2*/
-	/*p=10, npoint=25  {{{2*/
-	static double wgt10[]={
+	/*}}}*/
+	/*p=10, npoint=25  {{{*/
+	static IssmPDouble wgt10[]={
 		0.157301373584232, 0.063611224790829, 0.063611224790829, 
 		0.063611224790829, 0.078498377595183, 0.078498377595183, 
@@ -291,5 +291,5 @@
 		0.016318805873179, 0.016318805873179, 0.016318805873179, 
 		0.016318805873179};
-	static double l110[]={
+	static IssmPDouble l110[]={
 		0.333333333333333, 0.028844733232685, 0.485577633383657, 
 		0.485577633383657, 0.781036849029926, 0.109481575485037, 
@@ -301,5 +301,5 @@
 		0.066803251012200, 0.923655933587500, 0.066803251012200, 
 		0.923655933587500};
-	static double l210[]={
+	static IssmPDouble l210[]={
 		0.333333333333333, 0.485577633383657, 0.028844733232685, 
 		0.485577633383657, 0.109481575485037, 0.781036849029926, 
@@ -311,5 +311,5 @@
 		0.009540815400299, 0.009540815400299, 0.923655933587500, 
 		0.066803251012200};
-	static double l310[]={
+	static IssmPDouble l310[]={
 		0.333333333333333, 0.485577633383657, 0.485577633383657, 
 		0.028844733232685, 0.109481575485037, 0.109481575485037, 
@@ -321,7 +321,7 @@
 		0.923655933587500, 0.066803251012200, 0.009540815400299, 
 		0.009540815400299};
-	/*}}}2*/
-	/*p=11, npoint=27  {{{2*/
-	static double wgt11[]={
+	/*}}}*/
+	/*p=11, npoint=27  {{{*/
+	static IssmPDouble wgt11[]={
 		0.001605622060698, 0.001605622060698, 0.001605622060698, 
 		0.133626914252765, 0.133626914252765, 0.133626914252765, 
@@ -333,5 +333,5 @@
 		0.035866718600836, 0.035866718600836, 0.035866718600836, 
 		0.035866718600836, 0.035866718600836, 0.035866718600836};
-	static double l111[]={
+	static IssmPDouble l111[]={
 		-0.069222096541517, 0.534611048270758, 0.534611048270758, 
 		0.202061394068290, 0.398969302965855, 0.398969302965855, 
@@ -343,5 +343,5 @@
 		0.021022016536166, 0.021022016536166, 0.171488980304042, 
 		0.807489003159792, 0.171488980304042, 0.807489003159792};
-	static double l211[]={
+	static IssmPDouble l211[]={
 		0.534611048270758,-0.069222096541517, 0.534611048270758, 
 		0.398969302965855, 0.202061394068290, 0.398969302965855, 
@@ -353,5 +353,5 @@
 		0.171488980304042, 0.807489003159792, 0.021022016536166, 
 		0.021022016536166, 0.807489003159792, 0.171488980304042};
-	static double l311[]={
+	static IssmPDouble l311[]={
 		0.534611048270758, 0.534611048270758,-0.069222096541517, 
 		0.398969302965855, 0.398969302965855, 0.202061394068290, 
@@ -363,7 +363,7 @@
 		0.807489003159792, 0.171488980304042, 0.807489003159792, 
 		0.171488980304042, 0.021022016536166, 0.021022016536166};
-	/*}}}2*/
-	/*p=12, npoint=33  {{{2*/
-	static double wgt12[]={
+	/*}}}*/
+	/*p=12, npoint=33  {{{*/
+	static IssmPDouble wgt12[]={
 		0.044567514407799, 0.044567514407799, 0.044567514407799, 
 		0.075677707051848, 0.075677707051848, 0.075677707051848, 
@@ -377,5 +377,5 @@
 		0.029992592075802, 0.029992592075802, 0.029992592075802, 
 		0.029992592075802, 0.029992592075802, 0.029992592075802};
-	static double l112[]={
+	static IssmPDouble l112[]={
 		0.023565220452390, 0.488217389773805, 0.488217389773805, 
 		0.120551215411079, 0.439724392294460, 0.439724392294460, 
@@ -389,5 +389,5 @@
 		0.025734050548330, 0.025734050548330, 0.116251915907597, 
 		0.858014033544073, 0.116251915907597, 0.858014033544073};
-	static double l212[]={
+	static IssmPDouble l212[]={
 		0.488217389773805, 0.023565220452390, 0.488217389773805, 
 		0.439724392294460, 0.120551215411079, 0.439724392294460, 
@@ -401,5 +401,5 @@
 		0.116251915907597, 0.858014033544073, 0.025734050548330, 
 		0.025734050548330, 0.858014033544073, 0.116251915907597};
-	static double l312[]={
+	static IssmPDouble l312[]={
 		0.488217389773805, 0.488217389773805, 0.023565220452390, 
 		0.439724392294460, 0.439724392294460, 0.120551215411079, 
@@ -413,7 +413,7 @@
 		0.858014033544073, 0.116251915907597, 0.858014033544073, 
 		0.116251915907597, 0.025734050548330, 0.025734050548330};
-	/*}}}2*/
-	/*  p=13, npoint=37  {{{2*/
-	static double wgt13[]={
+	/*}}}*/
+	/*  p=13, npoint=37  {{{*/
+	static IssmPDouble wgt13[]={
 		0.090968907790622, 0.019537784619314, 0.019537784619314, 
 		0.019537784619314, 0.054427130356344, 0.054427130356344, 
@@ -429,5 +429,5 @@
 		0.026884523429480, 0.026884523429480, 0.026884523429480, 
 		0.026884523429480};
-	static double l113[]={
+	static IssmPDouble l113[]={
 		0.333333333333333, 0.009903630120591, 0.495048184939705, 
 		0.495048184939705, 0.062566729780852, 0.468716635109574, 
@@ -443,5 +443,5 @@
 		0.126357385491669, 0.851409537834241, 0.126357385491669, 
 		0.851409537834241};
-	static double l213[]={
+	static IssmPDouble l213[]={
 		0.333333333333333, 0.495048184939705, 0.009903630120591, 
 		0.495048184939705, 0.468716635109574, 0.062566729780852, 
@@ -457,5 +457,5 @@
 		0.022233076674090, 0.022233076674090, 0.851409537834241, 
 		0.126357385491669};
-	static double l313[]={
+	static IssmPDouble l313[]={
 		0.333333333333333, 0.495048184939705, 0.495048184939705, 
 		0.009903630120591, 0.468716635109574, 0.468716635109574, 
@@ -471,7 +471,7 @@
 		0.851409537834241, 0.126357385491669, 0.022233076674090, 
 		0.022233076674090};
-	/*}}}2*/
-	/*p=14, npoint=42{{{2*/
-	static double wgt14[]={
+	/*}}}*/
+	/*p=14, npoint=42{{{*/
+	static IssmPDouble wgt14[]={
 		0.037903474783419, 0.037903474783419, 0.037903474783419, 
 		0.056791094234956, 0.056791094234956, 0.056791094234956, 
@@ -488,5 +488,5 @@
 		0.008677970905831, 0.008677970905831, 0.008677970905831, 
 		0.008677970905831, 0.008677970905831, 0.008677970905831};
-	static double l114[]={
+	static IssmPDouble l114[]={
 		0.022072179275643, 0.488963910362179, 0.488963910362179, 
 		0.164710561319092, 0.417644719340454, 0.417644719340454, 
@@ -503,5 +503,5 @@
 		0.001268330932872, 0.001268330932872, 0.118974497696957, 
 		0.879757171370171, 0.118974497696957, 0.879757171370171};
-	static double l214[]={
+	static IssmPDouble l214[]={
 		0.488963910362179, 0.022072179275643, 0.488963910362179, 
 		0.417644719340454, 0.164710561319092, 0.417644719340454, 
@@ -518,5 +518,5 @@
 		0.118974497696957, 0.879757171370171, 0.001268330932872, 
 		0.001268330932872, 0.879757171370171, 0.118974497696957};
-	static double l314[]={
+	static IssmPDouble l314[]={
 		0.488963910362179, 0.488963910362179, 0.022072179275643, 
 		0.417644719340454, 0.417644719340454, 0.164710561319092, 
@@ -533,7 +533,7 @@
 		0.879757171370171, 0.118974497696957, 0.879757171370171, 
 		0.118974497696957, 0.001268330932872, 0.001268330932872};
-	/*}}}2*/
-	/*p=15, npoint=48{{{2*/
-	static double wgt15[]={
+	/*}}}*/
+	/*p=15, npoint=48{{{*/
+	static IssmPDouble wgt15[]={
 		0.003320126005206, 0.003320126005206, 0.003320126005206, 
 		0.076641563419124, 0.076641563419124, 0.076641563419124, 
@@ -552,5 +552,5 @@
 		0.013291658531346, 0.013291658531346, 0.013291658531346, 
 		0.013291658531346, 0.013291658531346, 0.013291658531346};
-	static double l115[]={
+	static IssmPDouble l115[]={
 		-0.013945833716486, 0.506972916858243, 0.506972916858243, 
 		0.137187291433955, 0.431406354283023, 0.431406354283023, 
@@ -569,5 +569,5 @@
 		0.012459809331199, 0.012459809331199, 0.103575616576386, 
 		0.883964574092416, 0.103575616576386, 0.883964574092416};
-	static double l215[]={
+	static IssmPDouble l215[]={
 		0.506972916858243,-0.013945833716486, 0.506972916858243, 
 		0.431406354283023, 0.137187291433955, 0.431406354283023, 
@@ -586,5 +586,5 @@
 		0.103575616576386, 0.883964574092416, 0.012459809331199, 
 		0.012459809331199, 0.883964574092416, 0.103575616576386};
-	static double l315[]={
+	static IssmPDouble l315[]={
 		0.506972916858243, 0.506972916858243,-0.013945833716486, 
 		0.431406354283023, 0.431406354283023, 0.137187291433955, 
@@ -603,7 +603,7 @@
 		0.883964574092416, 0.103575616576386, 0.883964574092416, 
 		0.103575616576386, 0.012459809331199, 0.012459809331199};
-	/*}}}2*/
-	/*p=16, npoint=52  {{{2*/
-	static double wgt16[]={
+	/*}}}*/
+	/*p=16, npoint=52  {{{*/
+	static IssmPDouble wgt16[]={
 		0.081191089584902, 0.011095307165226, 0.011095307165226, 
 		0.011095307165226, 0.072244353151393, 0.072244353151393, 
@@ -624,5 +624,5 @@
 		0.011864642509229, 0.011864642509229, 0.011864642509229, 
 		0.011864642509229};
-	static double l116[]={
+	static IssmPDouble l116[]={
 		0.333333333333333, 0.005238916103123, 0.497380541948438, 
 		0.497380541948438, 0.173061122901295, 0.413469438549352, 
@@ -643,5 +643,5 @@
 		0.085283615682657, 0.900399064086661, 0.085283615682657, 
 		0.900399064086661};
-	static double l216[]={
+	static IssmPDouble l216[]={
 		0.333333333333333, 0.497380541948438, 0.005238916103123, 
 		0.497380541948438, 0.413469438549352, 0.173061122901295, 
@@ -662,5 +662,5 @@
 		0.014317320230681, 0.014317320230681, 0.900399064086661, 
 		0.085283615682657};
-	static double l316[]={
+	static IssmPDouble l316[]={
 		0.333333333333333, 0.497380541948438, 0.497380541948438, 
 		0.005238916103123, 0.413469438549352, 0.413469438549352, 
@@ -681,7 +681,7 @@
 		0.900399064086661, 0.085283615682657, 0.014317320230681, 
 		0.014317320230681};
-	/*}}}2*/
-	/*p=17, npoint=61{{{2*/
-	static double wgt17[]={
+	/*}}}*/
+	/*p=17, npoint=61{{{*/
+	static IssmPDouble wgt17[]={
 		0.057914928034477, 0.008822054327014, 0.008822054327014, 
 		0.008822054327014, 0.025410682752829, 0.025410682752829, 
@@ -705,5 +705,5 @@
 		0.011545213295771, 0.011545213295771, 0.011545213295771, 
 		0.011545213295771};
-	static double l117[]={
+	static IssmPDouble l117[]={
 		0.333333333333333, 0.005658918886452, 0.497170540556774, 
 		0.497170540556774, 0.035647354750751, 0.482176322624625, 
@@ -727,5 +727,5 @@
 		0.080711313679564, 0.904625504095608, 0.080711313679564, 
 		0.904625504095608};
-	static double l217[]={
+	static IssmPDouble l217[]={
 		0.333333333333333, 0.497170540556774, 0.005658918886452, 
 		0.497170540556774, 0.482176322624625, 0.035647354750751, 
@@ -749,5 +749,5 @@
 		0.014663182224828, 0.014663182224828, 0.904625504095608, 
 		0.080711313679564};
-	static double l317[]={
+	static IssmPDouble l317[]={
 		0.333333333333333, 0.497170540556774, 0.497170540556774, 
 		0.005658918886452, 0.482176322624625, 0.482176322624625, 
@@ -771,8 +771,8 @@
 		0.904625504095608, 0.080711313679564, 0.014663182224828, 
 		0.014663182224828};
-	/*}}}2*/
-	/*  p=18, npoint=70  {{{2*/
-
-	static double wgt18[]={
+	/*}}}*/
+	/*  p=18, npoint=70  {{{*/
+
+	static IssmPDouble wgt18[]={
 		0.053364381350150, 0.015713921277179, 0.015713921277179, 
 		0.015713921277179, 0.032495554156279, 0.032495554156279, 
@@ -799,5 +799,5 @@
 		0.000079999375178, 0.000079999375178, 0.000079999375178, 
 		0.000079999375178};
-	static double l118[]={
+	static IssmPDouble l118[]={
 		0.333333333333333, 0.013310382738157, 0.493344808630921, 
 		0.493344808630921, 0.061578811516086, 0.469210594241957, 
@@ -824,5 +824,5 @@
 		0.020874755282586, 1.014347260005363, 0.020874755282586, 
 		1.014347260005363};
-	static double l218[]={
+	static IssmPDouble l218[]={
 		0.333333333333333, 0.493344808630921, 0.013310382738157, 
 		0.493344808630921, 0.469210594241957, 0.061578811516086, 
@@ -849,5 +849,5 @@
 		-0.035222015287949,-0.035222015287949, 1.014347260005363, 
 		0.020874755282586};
-	static double l318[]={
+	static IssmPDouble l318[]={
 		0.333333333333333, 0.493344808630921, 0.493344808630921, 
 		0.013310382738157, 0.469210594241957, 0.469210594241957, 
@@ -874,8 +874,8 @@
 		1.014347260005363, 0.020874755282586,-0.035222015287949, 
 		-0.035222015287949};
-	/*}}}2*/
-	/*p=19, npoint=73  {{{2*/
-
-	static double wgt19[]={
+	/*}}}*/
+	/*p=19, npoint=73  {{{*/
+
+	static IssmPDouble wgt19[]={
 		0.056995437856306, 0.017893352515055, 0.017893352515055, 
 		0.017893352515055, 0.038775849701151, 0.038775849701151, 
@@ -903,5 +903,5 @@
 		0.006581669842530, 0.006581669842530, 0.006581669842530, 
 		0.006581669842530};
-	static double l119[]={
+	static IssmPDouble l119[]={
 		0.333333333333333, 0.020780025853987, 0.489609987073006, 
 		0.489609987073006, 0.090926214604215, 0.454536892697893, 
@@ -929,5 +929,5 @@
 		0.065494628082938, 0.924344252620784, 0.065494628082938, 
 		0.924344252620784};
-	static double l219[]={
+	static IssmPDouble l219[]={
 		0.333333333333333, 0.489609987073006, 0.020780025853987, 
 		0.489609987073006, 0.454536892697893, 0.090926214604215, 
@@ -955,5 +955,5 @@
 		0.010161119296278, 0.010161119296278, 0.924344252620784, 
 		0.065494628082938};
-	static double l319[]={
+	static IssmPDouble l319[]={
 		0.333333333333333, 0.489609987073006, 0.489609987073006, 
 		0.020780025853987, 0.454536892697893, 0.454536892697893, 
@@ -981,7 +981,7 @@
 		0.924344252620784, 0.065494628082938, 0.010161119296278, 
 		0.010161119296278};
-	/*}}}2*/
-	/*p=20, npoint=79 {{{2*/
-	static double wgt20[]={
+	/*}}}*/
+	/*p=20, npoint=79 {{{*/
+	static IssmPDouble wgt20[]={
 		0.057256499746719, 0.001501721280705, 0.001501721280705, 
 		0.001501721280705, 0.020195803723819, 0.020195803723819, 
@@ -1011,5 +1011,5 @@
 		0.006190192638113, 0.006190192638113, 0.006190192638113, 
 		0.006190192638113};
-	static double l120[]={
+	static IssmPDouble l120[]={
 		0.333333333333333,-0.001900928704400, 0.500950464352200, 
 		0.500950464352200, 0.023574084130543, 0.488212957934729, 
@@ -1039,5 +1039,5 @@
 		0.059696109149007, 0.929756171556853, 0.059696109149007, 
 		0.929756171556853};
-	static double l220[]={
+	static IssmPDouble l220[]={
 		0.333333333333333, 0.500950464352200,-0.001900928704400, 
 		0.500950464352200, 0.488212957934729, 0.023574084130543, 
@@ -1067,5 +1067,5 @@
 		0.010547719294141, 0.010547719294141, 0.929756171556853, 
 		0.059696109149007};
-	static double l320[]={
+	static IssmPDouble l320[]={
 		0.333333333333333, 0.500950464352200, 0.500950464352200, 
 		-0.001900928704400, 0.488212957934729, 0.488212957934729, 
@@ -1095,22 +1095,22 @@
 		0.929756171556853, 0.059696109149007, 0.010547719294141, 
 		0.010547719294141};
-	/*}}}2*/
-
-	static double* wgtp[MAX_TRIA_SYM_ORD]={
+	/*}}}*/
+
+	static IssmPDouble* wgtp[MAX_TRIA_SYM_ORD]={
 		wgt1 ,wgt2 ,wgt3 ,wgt4 ,wgt5 ,
 		wgt6 ,wgt7 ,wgt8 ,wgt9 ,wgt10,
 		wgt11,wgt12,wgt13,wgt14,wgt15,
 		wgt16,wgt17,wgt18,wgt19,wgt20};
-	static double* l1p [MAX_TRIA_SYM_ORD]={
+	static IssmPDouble* l1p [MAX_TRIA_SYM_ORD]={
 		l11  ,l12  ,l13  ,l14  ,l15  ,
 		l16  ,l17  ,l18  ,l19  ,l110 ,
 		l111 ,l112 ,l113 ,l114 ,l115 ,
 		l116 ,l117 ,l118 ,l119 ,l120 };
-	static double* l2p [MAX_TRIA_SYM_ORD]={
+	static IssmPDouble* l2p [MAX_TRIA_SYM_ORD]={
 		l21  ,l22  ,l23  ,l24  ,l25  ,
 		l26  ,l27  ,l28  ,l29  ,l210 ,
 		l211 ,l212 ,l213 ,l214 ,l215 ,
 		l216 ,l217 ,l218 ,l219 ,l220 };
-	static double* l3p [MAX_TRIA_SYM_ORD]={
+	static IssmPDouble* l3p [MAX_TRIA_SYM_ORD]={
 		l31  ,l32  ,l33  ,l34  ,l35  ,
 		l36  ,l37  ,l38  ,l39  ,l310 ,
@@ -1118,26 +1118,26 @@
 		l316 ,l317 ,l318 ,l319 ,l320 };
 
-	static int np[MAX_TRIA_SYM_ORD]={sizeof(wgt1 )/sizeof(double),
-		sizeof(wgt2 )/sizeof(double),
-		sizeof(wgt3 )/sizeof(double),
-		sizeof(wgt4 )/sizeof(double),
-		sizeof(wgt5 )/sizeof(double),
-		sizeof(wgt6 )/sizeof(double),
-		sizeof(wgt7 )/sizeof(double),
-		sizeof(wgt8 )/sizeof(double),
-		sizeof(wgt9 )/sizeof(double),
-		sizeof(wgt10)/sizeof(double),
-		sizeof(wgt11)/sizeof(double),
-		sizeof(wgt12)/sizeof(double),
-		sizeof(wgt13)/sizeof(double),
-		sizeof(wgt14)/sizeof(double),
-		sizeof(wgt15)/sizeof(double),
-		sizeof(wgt16)/sizeof(double),
-		sizeof(wgt17)/sizeof(double),
-		sizeof(wgt18)/sizeof(double),
-		sizeof(wgt19)/sizeof(double),
-		sizeof(wgt20)/sizeof(double)};
-
-	//	_printf_(true,"GaussLegendreTria: iord=%d\n",iord);
+	static int np[MAX_TRIA_SYM_ORD]={sizeof(wgt1 )/sizeof(IssmPDouble),
+		sizeof(wgt2 )/sizeof(IssmPDouble),
+		sizeof(wgt3 )/sizeof(IssmPDouble),
+		sizeof(wgt4 )/sizeof(IssmPDouble),
+		sizeof(wgt5 )/sizeof(IssmPDouble),
+		sizeof(wgt6 )/sizeof(IssmPDouble),
+		sizeof(wgt7 )/sizeof(IssmPDouble),
+		sizeof(wgt8 )/sizeof(IssmPDouble),
+		sizeof(wgt9 )/sizeof(IssmPDouble),
+		sizeof(wgt10)/sizeof(IssmPDouble),
+		sizeof(wgt11)/sizeof(IssmPDouble),
+		sizeof(wgt12)/sizeof(IssmPDouble),
+		sizeof(wgt13)/sizeof(IssmPDouble),
+		sizeof(wgt14)/sizeof(IssmPDouble),
+		sizeof(wgt15)/sizeof(IssmPDouble),
+		sizeof(wgt16)/sizeof(IssmPDouble),
+		sizeof(wgt17)/sizeof(IssmPDouble),
+		sizeof(wgt18)/sizeof(IssmPDouble),
+		sizeof(wgt19)/sizeof(IssmPDouble),
+		sizeof(wgt20)/sizeof(IssmPDouble)};
+
+	//	_pprintLine_("GaussLegendreTria: iord=" << iord);
 
 	/*  check to see if Gauss points need to be calculated  */
@@ -1150,8 +1150,8 @@
 		*pngaus=np[iord-1];
 
-		*pl1  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl2  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl3  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pwgt = (double *) xmalloc(*pngaus*sizeof(double));
+		*pl1  =xNew<IssmPDouble>(*pngaus);
+		*pl2  =xNew<IssmPDouble>(*pngaus);
+		*pl3  =xNew<IssmPDouble>(*pngaus);
+		*pwgt =xNew<IssmPDouble>(*pngaus);
 
 		for (i=0; i<*pngaus; i++) {
@@ -1168,8 +1168,8 @@
 		*pngaus=nigaus*nigaus;
 
-		*pl1  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl2  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl3  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pwgt = (double *) xmalloc(*pngaus*sizeof(double));
+		*pl1  =xNew<IssmPDouble>(*pngaus);
+		*pl2  =xNew<IssmPDouble>(*pngaus);
+		*pl3  =xNew<IssmPDouble>(*pngaus);
+		*pwgt =xNew<IssmPDouble>(*pngaus);
 
 		/*  get the gauss points in each direction  */
@@ -1195,9 +1195,9 @@
 			}
 		}
-		xfree((void **)&xwgt );
-		xfree((void **)&xgaus);
+		xDelete<IssmPDouble>(xwgt );
+		xDelete<IssmPDouble>(xgaus);
 	}
 
-	//	_printf_(true,"GaussLegendreTria - ngaus=%d\n",*pngaus);
+	//	_pprintLine_("GaussLegendreTria - ngaus=" << *pngaus);
 	//	for (i=0; i<*pngaus; i++)
 	//		_printf_(true,"i=%d: l1gaus=%f,l2gaus=%f,l3gaus=%f,wgt=%f\n",
@@ -1205,7 +1205,7 @@
 
 	return;
-}/*}}}1*/
-/*FUNCTION GaussLegendreTetra{{{1*/
-void GaussLegendreTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord ) {
+}/*}}}*/
+/*FUNCTION GaussLegendreTetra{{{*/
+void GaussLegendreTetra( int* pngaus, IssmPDouble** pl1, IssmPDouble** pl2, IssmPDouble** pl3, IssmPDouble** pl4, IssmPDouble** pwgt, int iord ) {
 	/* Gauss quadrature points for the tetrahedron.
 
@@ -1220,86 +1220,86 @@
 	/*Intermediaries*/
 	int i,j,k,ipt,nigaus;
-	double xi,eta,zeta;
-	double *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt,*zgaus,*zwgt;
+	IssmPDouble xi,eta,zeta;
+	IssmPDouble *xgaus=NULL,*xwgt=NULL,*egaus,*ewgt,*zgaus,*zwgt;
 
 	/*Hardcoded Gauss points definition*/
-	/*p= 1, npoint= 1  {{{2*/
-	static double wgt1[]={
+	/*p= 1, npoint= 1  {{{*/
+	static IssmPDouble wgt1[]={
 		1.000000000000000};
-	static double l11[]={
+	static IssmPDouble l11[]={
 		0.250000000000000};
-	static double l21[]={
+	static IssmPDouble l21[]={
 		0.250000000000000};
-	static double l31[]={
+	static IssmPDouble l31[]={
 		0.250000000000000};
-	static double l41[]={
+	static IssmPDouble l41[]={
 		0.250000000000000};
-	/*}}}2*/
-	/*p= 2, npoint= 4  {{{2*/
-
-	static double wgt2[]={
+	/*}}}*/
+	/*p= 2, npoint= 4  {{{*/
+
+	static IssmPDouble wgt2[]={
 		0.250000000000000, 0.250000000000000, 0.250000000000000,
 		0.250000000000000};
-	static double l12[]={
+	static IssmPDouble l12[]={
 		0.585410196624969, 0.138196601125011, 0.138196601125011,
 		0.138196601125011};
-	static double l22[]={
+	static IssmPDouble l22[]={
 		0.138196601125011, 0.585410196624969, 0.138196601125011,
 		0.138196601125011};
-	static double l32[]={
+	static IssmPDouble l32[]={
 		0.138196601125011, 0.138196601125011, 0.585410196624969,
 		0.138196601125011};
-	static double l42[]={
+	static IssmPDouble l42[]={
 		0.138196601125011, 0.138196601125011, 0.138196601125011,
 		0.585410196624969};
-	/*}}}2*/
-	/*p= 3, npoint= 5  {{{2*/
-	static double wgt3[]={
+	/*}}}*/
+	/*p= 3, npoint= 5  {{{*/
+	static IssmPDouble wgt3[]={
 		-0.800000000000000, 0.450000000000000, 0.450000000000000, 
 		0.450000000000000, 0.450000000000000};
-	static double l13[]={
+	static IssmPDouble l13[]={
 		0.250000000000000, 0.500000000000000, 0.166666666666667, 
 		0.166666666666667, 0.166666666666667};
-	static double l23[]={
+	static IssmPDouble l23[]={
 		0.250000000000000, 0.166666666666667, 0.500000000000000, 
 		0.166666666666667, 0.166666666666667};
-	static double l33[]={
+	static IssmPDouble l33[]={
 		0.250000000000000, 0.166666666666667, 0.166666666666667, 
 		0.500000000000000, 0.166666666666667};
-	static double l43[]={
+	static IssmPDouble l43[]={
 		0.250000000000000, 0.166666666666667, 0.166666666666667, 
 		0.166666666666667, 0.500000000000000};
-	/*}}}2*/
-	/*p= 4, npoint=11  {{{2*/
-
-	static double wgt4[]={
+	/*}}}*/
+	/*p= 4, npoint=11  {{{*/
+
+	static IssmPDouble wgt4[]={
 		-0.013155555555556, 0.007622222222222, 0.007622222222222, 
 		0.007622222222222, 0.007622222222222, 0.024888888888889,
 		0.024888888888889, 0.024888888888889, 0.024888888888889, 
 		0.024888888888889, 0.024888888888889};
-	static double l14[]={
+	static IssmPDouble l14[]={
 		0.250000000000000, 0.785714285714286, 0.071428571428571, 
 		0.071428571428571, 0.071428571428571, 0.399403576166799,
 		0.399403576166799, 0.399403576166799, 0.100596423833201, 
 		0.100596423833201, 0.100596423833201};
-	static double l24[]={
+	static IssmPDouble l24[]={
 		0.250000000000000, 0.071428571428571, 0.785714285714286, 
 		0.071428571428571, 0.071428571428571, 0.399403576166799,
 		0.100596423833201, 0.100596423833201, 0.399403576166799, 
 		0.399403576166799, 0.100596423833201};
-	static double l34[]={
+	static IssmPDouble l34[]={
 		0.250000000000000, 0.071428571428571, 0.071428571428571, 
 		0.785714285714286, 0.071428571428571, 0.100596423833201, 
 		0.399403576166799, 0.100596423833201, 0.399403576166799,
 		0.100596423833201, 0.399403576166799};
-	static double l44[]={
+	static IssmPDouble l44[]={
 		0.250000000000000, 0.071428571428571, 0.071428571428571, 
 		0.071428571428571, 0.785714285714286, 0.100596423833201, 
 		0.100596423833201, 0.399403576166799, 0.100596423833201,
 		0.399403576166799, 0.399403576166799};
-	/*}}}2*/
-	/*p= 5, npoint=15  {{{2*/
-
-	static double wgt5[]={
+	/*}}}*/
+	/*p= 5, npoint=15  {{{*/
+
+	static IssmPDouble wgt5[]={
 		0.030283678097089, 0.006026785714286, 0.006026785714286, 
 		0.006026785714286, 0.006026785714286, 0.011645249086029, 
@@ -1307,5 +1307,5 @@
 		0.010949141561386, 0.010949141561386, 0.010949141561386,
 		0.010949141561386, 0.010949141561386, 0.010949141561386};
-	static double l15[]={
+	static IssmPDouble l15[]={
 		0.250000000000000, 0.000000000000000, 0.333333333333333, 
 		0.333333333333333, 0.333333333333333, 0.727272727272727, 
@@ -1313,5 +1313,5 @@
 		0.066550153573664, 0.066550153573664, 0.066550153573664, 
 		0.433449846426336, 0.433449846426336, 0.433449846426336};
-	static double l25[]={
+	static IssmPDouble l25[]={
 		0.250000000000000, 0.333333333333333, 0.000000000000000, 
 		0.333333333333333, 0.333333333333333, 0.090909090909091, 
@@ -1319,5 +1319,5 @@
 		0.066550153573664, 0.433449846426336, 0.433449846426336, 
 		0.066550153573664, 0.066550153573664, 0.433449846426336};
-	static double l35[]={
+	static IssmPDouble l35[]={
 		0.250000000000000, 0.333333333333333, 0.333333333333333, 
 		0.000000000000000, 0.333333333333333, 0.090909090909091, 
@@ -1325,5 +1325,5 @@
 		0.433449846426336, 0.066550153573664, 0.433449846426336, 
 		0.066550153573664, 0.433449846426336, 0.066550153573664};
-	static double l45[]={
+	static IssmPDouble l45[]={
 		0.250000000000000, 0.333333333333333, 0.333333333333333, 
 		0.333333333333333, 0.000000000000000, 0.090909090909091, 
@@ -1331,8 +1331,8 @@
 		0.433449846426336, 0.433449846426336, 0.066550153573664, 
 		0.433449846426336, 0.066550153573664, 0.066550153573664};
-	/*}}}2*/
-	/*p= 6, npoint=24  {{{2*/
-
-	static double wgt6[]={
+	/*}}}*/
+	/*p= 6, npoint=24  {{{*/
+
+	static IssmPDouble wgt6[]={
 		0.006653791709695, 0.006653791709695, 0.006653791709695, 
 		0.006653791709695, 0.001679535175887, 0.001679535175887, 
@@ -1343,5 +1343,5 @@
 		0.008035714285714, 0.008035714285714, 0.008035714285714, 
 		0.008035714285714, 0.008035714285714, 0.008035714285714};
-	static double l16[]={
+	static IssmPDouble l16[]={
 		0.356191386222545, 0.214602871259152, 0.214602871259152, 
 		0.214602871259152, 0.877978124396166, 0.040673958534611, 
@@ -1353,5 +1353,5 @@
 		0.269672331458316, 0.603005664791649, 0.269672331458316, 
 		0.603005664791649, 0.269672331458316, 0.603005664791649};
-	static double l26[]={
+	static IssmPDouble l26[]={
 		0.214602871259152, 0.356191386222545, 0.214602871259152, 
 		0.214602871259152, 0.040673958534611, 0.877978124396166, 
@@ -1363,5 +1363,5 @@
 		0.063661001875018, 0.063661001875018, 0.063661001875018, 
 		0.063661001875018, 0.603005664791649, 0.269672331458316};
-	static double l36[]={
+	static IssmPDouble l36[]={
 		0.214602871259152, 0.214602871259152, 0.356191386222545, 
 		0.214602871259152, 0.040673958534611, 0.040673958534611, 
@@ -1373,5 +1373,5 @@
 		0.063661001875018, 0.063661001875018, 0.603005664791649, 
 		0.269672331458316, 0.063661001875018, 0.063661001875018};
-	static double l46[]={
+	static IssmPDouble l46[]={
 		0.214602871259152, 0.214602871259152, 0.214602871259152, 
 		0.356191386222545, 0.040673958534611, 0.040673958534611, 
@@ -1383,20 +1383,20 @@
 		0.603005664791649, 0.269672331458316, 0.063661001875018, 
 		0.063661001875018, 0.063661001875018, 0.063661001875018};
-	/*}}}2*/
-
-	static double* wgtp[MAX_TETRA_SYM_ORD]={wgt1,wgt2,wgt3,wgt4,wgt5,wgt6};
-	static double* l1p [MAX_TETRA_SYM_ORD]={l11 ,l12 ,l13 ,l14 ,l15 ,l16 };
-	static double* l2p [MAX_TETRA_SYM_ORD]={l21 ,l22 ,l32 ,l24 ,l25 ,l26 };
-	static double* l3p [MAX_TETRA_SYM_ORD]={l31 ,l32 ,l33 ,l34 ,l35 ,l36 };
-	static double* l4p [MAX_TETRA_SYM_ORD]={l41 ,l42 ,l43 ,l44 ,l45 ,l46 };
-
-	static int np[MAX_TETRA_SYM_ORD]={sizeof(wgt1 )/sizeof(double),
-		sizeof(wgt2 )/sizeof(double),
-		sizeof(wgt3 )/sizeof(double),
-		sizeof(wgt4 )/sizeof(double),
-		sizeof(wgt5 )/sizeof(double),
-		sizeof(wgt6 )/sizeof(double)};
-
-	//	_printf_(true,"GaussLegendreTetra: iord=%d\n",iord);
+	/*}}}*/
+
+	static IssmPDouble* wgtp[MAX_TETRA_SYM_ORD]={wgt1,wgt2,wgt3,wgt4,wgt5,wgt6};
+	static IssmPDouble* l1p [MAX_TETRA_SYM_ORD]={l11 ,l12 ,l13 ,l14 ,l15 ,l16 };
+	static IssmPDouble* l2p [MAX_TETRA_SYM_ORD]={l21 ,l22 ,l32 ,l24 ,l25 ,l26 };
+	static IssmPDouble* l3p [MAX_TETRA_SYM_ORD]={l31 ,l32 ,l33 ,l34 ,l35 ,l36 };
+	static IssmPDouble* l4p [MAX_TETRA_SYM_ORD]={l41 ,l42 ,l43 ,l44 ,l45 ,l46 };
+
+	static int np[MAX_TETRA_SYM_ORD]={sizeof(wgt1 )/sizeof(IssmPDouble),
+		sizeof(wgt2 )/sizeof(IssmPDouble),
+		sizeof(wgt3 )/sizeof(IssmPDouble),
+		sizeof(wgt4 )/sizeof(IssmPDouble),
+		sizeof(wgt5 )/sizeof(IssmPDouble),
+		sizeof(wgt6 )/sizeof(IssmPDouble)};
+
+	//	_pprintLine_("GaussLegendreTetra: iord=" << iord);
 
 	/*  check to see if Gauss points need to be calculated  */
@@ -1410,9 +1410,9 @@
 		*pngaus=np[iord-1];
 
-		*pl1  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl2  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl3  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl4  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pwgt = (double *) xmalloc(*pngaus*sizeof(double));
+		*pl1  =xNew<IssmPDouble>(*pngaus);
+		*pl2  =xNew<IssmPDouble>(*pngaus);
+		*pl3  =xNew<IssmPDouble>(*pngaus);
+		*pl4  =xNew<IssmPDouble>(*pngaus);
+		*pwgt =xNew<IssmPDouble>(*pngaus);
 
 		for (i=0; i<*pngaus; i++) {
@@ -1430,9 +1430,9 @@
 		*pngaus=nigaus*nigaus*nigaus;
 
-		*pl1  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl2  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl3  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pl4  = (double *) xmalloc(*pngaus*sizeof(double));
-		*pwgt = (double *) xmalloc(*pngaus*sizeof(double));
+		*pl1  =xNew<IssmPDouble>(*pngaus);
+		*pl2  =xNew<IssmPDouble>(*pngaus);
+		*pl3  =xNew<IssmPDouble>(*pngaus);
+		*pl4  =xNew<IssmPDouble>(*pngaus);
+		*pwgt =xNew<IssmPDouble>(*pngaus);
 
 		/*  get the gauss points in each direction  */
@@ -1467,10 +1467,10 @@
 			}
 		}
-		xfree((void **)&xwgt );
-		xfree((void **)&xgaus);
+		xDelete<IssmPDouble>(xwgt );
+		xDelete<IssmPDouble>(xgaus);
 	}
-}/*}}}1*/
-/*FUNCTION GaussLobatto{{{1*/
-void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus ) {
+}/*}}}*/
+/*FUNCTION GaussLobatto{{{*/
+void GaussLobatto( IssmPDouble** pxgaus, IssmPDouble** pxwgt, int ngaus ) {
 	/*Gauss-Lobatto quadrature points.
 
@@ -1488,40 +1488,40 @@
 
 	int i;
-	double *alpha,*beta;
-	double left=-1.,right= 1.;
-	double p0l=0.,p0r=0.,p1l=1.,p1r=1.,pm1l,pm1r,det;
+	IssmPDouble *alpha,*beta;
+	IssmPDouble left=-1.,right= 1.;
+	IssmPDouble p0l=0.,p0r=0.,p1l=1.,p1r=1.,pm1l,pm1r,det;
 
 	/*p= 1, npoint= 1 (Gauss-Legendre)*/
-	static double wgt1[]={2.000000000000000};
-	static double xi1[]={0.000000000000000};
+	static IssmPDouble wgt1[]={2.000000000000000};
+	static IssmPDouble xi1[]={0.000000000000000};
 
 	/*p= 1, npoint= 2*/
-	static double wgt2[]={1.000000000000000, 1.000000000000000};
-	static double xi2[]={-1.000000000000000, 1.000000000000000};
+	static IssmPDouble wgt2[]={1.000000000000000, 1.000000000000000};
+	static IssmPDouble xi2[]={-1.000000000000000, 1.000000000000000};
 
 	/*p= 3, npoint= 3*/
-	static double wgt3[]={0.333333333333333, 1.333333333333333, 0.333333333333333};
-	static double xi3[]={-1.000000000000000, 0.000000000000000, 1.000000000000000};
+	static IssmPDouble wgt3[]={0.333333333333333, 1.333333333333333, 0.333333333333333};
+	static IssmPDouble xi3[]={-1.000000000000000, 0.000000000000000, 1.000000000000000};
 
 	/*p= 5, npoint= 4*/
-	static double wgt4[]={0.166666666666667, 0.833333333333333, 0.833333333333333, 0.166666666666667};
-	static double xi4[]={-1.000000000000000,-0.447213595499958, 0.447213595499958, 1.000000000000000};
+	static IssmPDouble wgt4[]={0.166666666666667, 0.833333333333333, 0.833333333333333, 0.166666666666667};
+	static IssmPDouble xi4[]={-1.000000000000000,-0.447213595499958, 0.447213595499958, 1.000000000000000};
 
 	/*p= 7, npoint= 5*/
-	static double wgt5[]={0.100000000000000, 0.544444444444444, 0.711111111111111, 0.544444444444444, 0.100000000000000};
-	static double xi5[]={-1.000000000000000,-0.654653670707977, 0.000000000000000, 0.654653670707977, 1.000000000000000};
-
-	static double* wgtp[MAX_LINE_GLOB_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 ,wgt5 };
-	static double* xip [MAX_LINE_GLOB_PTS]={xi1  ,xi2  ,xi3  ,xi4  ,xi5  };
-
-	static int np[MAX_LINE_GLOB_PTS]={sizeof(wgt1 )/sizeof(double),
-		sizeof(wgt2 )/sizeof(double),
-		sizeof(wgt3 )/sizeof(double),
-		sizeof(wgt4 )/sizeof(double),
-		sizeof(wgt5 )/sizeof(double)};
-
-	//	_printf_(true,"Gauss-Lobatto recurrence coefficients ngaus=%d\n",ngaus);
-	*pxgaus = (double *) xmalloc(ngaus*sizeof(double));
-	*pxwgt  = (double *) xmalloc(ngaus*sizeof(double));
+	static IssmPDouble wgt5[]={0.100000000000000, 0.544444444444444, 0.711111111111111, 0.544444444444444, 0.100000000000000};
+	static IssmPDouble xi5[]={-1.000000000000000,-0.654653670707977, 0.000000000000000, 0.654653670707977, 1.000000000000000};
+
+	static IssmPDouble* wgtp[MAX_LINE_GLOB_PTS]={wgt1 ,wgt2 ,wgt3 ,wgt4 ,wgt5 };
+	static IssmPDouble* xip [MAX_LINE_GLOB_PTS]={xi1  ,xi2  ,xi3  ,xi4  ,xi5  };
+
+	static int np[MAX_LINE_GLOB_PTS]={sizeof(wgt1 )/sizeof(IssmPDouble),
+		sizeof(wgt2 )/sizeof(IssmPDouble),
+		sizeof(wgt3 )/sizeof(IssmPDouble),
+		sizeof(wgt4 )/sizeof(IssmPDouble),
+		sizeof(wgt5 )/sizeof(IssmPDouble)};
+
+	//	_pprintLine_("Gauss-Lobatto recurrence coefficients ngaus=" << ngaus);
+	*pxgaus =xNew<IssmPDouble>(ngaus);
+	*pxwgt  =xNew<IssmPDouble>(ngaus);
 
 	/*  check to see if Gauss points need to be calculated  */
@@ -1539,6 +1539,6 @@
 
 		/*  calculate the Gauss points using recurrence relations  */
-		alpha=(double *) xmalloc(ngaus*sizeof(double));
-		beta =(double *) xmalloc(ngaus*sizeof(double));
+		alpha=xNew<IssmPDouble>(ngaus);
+		beta =xNew<IssmPDouble>(ngaus);
 
 		/*  calculate the Legendre recurrence coefficients  */
@@ -1575,11 +1575,11 @@
 		/*  calculate the Gauss points  */
 		GaussRecur(*pxgaus, *pxwgt, ngaus, alpha, beta );
-		xfree((void **)&beta );
-		xfree((void **)&alpha);
+		xDelete<IssmPDouble>(beta );
+		xDelete<IssmPDouble>(alpha);
 	}
 
-}/*}}}1*/
-/*FUNCTION GaussRecur{{{1*/
-void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta ) {
+}/*}}}*/
+/*FUNCTION GaussRecur{{{*/
+void GaussRecur( IssmPDouble* zero, IssmPDouble* weight, int n, IssmPDouble* alpha, IssmPDouble* beta ) {
 	/*Gauss quadrature points from recursion coefficients.
 	 *
@@ -1589,6 +1589,6 @@
 	/*Intermediaries*/
 	int i,j,k,l,m,ii,mml,iter;
-	double p,g,r,s,c,f,b;
-	double* work;
+	IssmPDouble p,g,r,s,c,f,b;
+	IssmPDouble* work;
 
 	if (n==1){
@@ -1598,5 +1598,5 @@
 	}
 
-	work=(double*)xmalloc(n*sizeof(double));
+	work=xNew<IssmPDouble>(n);
 
 	zero[0]  =alpha[0];
@@ -1669,6 +1669,6 @@
 		} while (iter < MAX_GAUS_ITER);
 		if (iter >= MAX_GAUS_ITER) {
-			xfree((void **)&work);
-			_error_("%s%i"," Max iterations exceeded for l=",MAX_GAUS_ITER);
+			xDelete<IssmPDouble>(work);
+			_error2_("Max iterations exceeded for l=" << MAX_GAUS_ITER);
 		}
 	}
@@ -1698,11 +1698,11 @@
 
 	/*Cleanup*/
-	xfree((void **)&work);
-
-}/*}}}1*/
+	xDelete<IssmPDouble>(work);
+
+}/*}}}*/
 
 /*Element Gauss points TO BE REMOVED*/
-/*FUNCTION gaussQuad{{{1*/
-void gaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus ) { 
+/*FUNCTION gaussQuad{{{*/
+void gaussQuad( IssmPDouble** pxgaus, IssmPDouble** pxwgt, IssmPDouble** pegaus, IssmPDouble** pewgt, int nigaus, int njgaus ) {
 	/*Gauss quadrature points for the quadrilaterial.*/
 
@@ -1710,7 +1710,7 @@
 	GaussLegendreLinear(pxgaus, pxwgt, nigaus);
 	GaussLegendreLinear(pegaus, pewgt, njgaus);
-}/*}}}1*/
-/*FUNCTION gaussHexa{{{1*/
-void gaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus ) {
+}/*}}}*/
+/*FUNCTION gaussHexa{{{*/
+void gaussHexa( IssmPDouble** pxgaus, IssmPDouble** pxwgt, IssmPDouble** pegaus, IssmPDouble** pewgt, IssmPDouble** pzgaus, IssmPDouble ** pzwgt, int nigaus, int njgaus, int nkgaus ) {
 	/*Gauss quadrature points for the hexahedron.*/
 
@@ -1719,3 +1719,3 @@
 	GaussLegendreLinear(pegaus, pewgt, njgaus);
 	GaussLegendreLinear(pzgaus, pzwgt, nkgaus);
-}/*}}}1*/
+}/*}}}*/
Index: /issm/trunk/src/c/shared/Numerics/GaussPoints.h
===================================================================
--- /issm/trunk/src/c/shared/Numerics/GaussPoints.h	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/GaussPoints.h	(revision 12706)
@@ -3,20 +3,21 @@
  */ 
 
+#include "../../include/types.h"
 #ifndef _GAUSSPOINTS_H
 #define _GAUSSPOINTS_H
 
 #define MAX_LINE_GAUS_PTS    4
-void GaussLegendreLinear( double** pxgaus, double** pxwgt, int ngaus ); 
+void GaussLegendreLinear(IssmPDouble** pxgaus, IssmPDouble** pxwgt, int ngaus);
 #define MAX_TRIA_SYM_ORD    20
-void GaussLegendreTria( int* pngaus, double** pl1, double** pl2, double** pl3, double** pwgt, int iord );
+void GaussLegendreTria(int* pngaus, IssmPDouble** pl1, IssmPDouble** pl2, IssmPDouble** pl3, IssmPDouble** pwgt, int iord);
 #define MAX_TETRA_SYM_ORD    6
-void GaussLegendreTetra( int* pngaus, double** pl1, double** pl2, double** pl3, double** pl4, double** pwgt, int iord );
+void GaussLegendreTetra(int* pngaus, IssmPDouble** pl1, IssmPDouble** pl2, IssmPDouble** pl3, IssmPDouble** pl4, IssmPDouble** pwgt, int iord);
 #define MAX_LINE_GLOB_PTS    5
-void GaussLobatto( double** pxgaus, double** pxwgt, int ngaus ); 
+void GaussLobatto(IssmPDouble** pxgaus, IssmPDouble** pxwgt, int ngaus);
 #define MAX_GAUS_ITER   30
-void GaussRecur( double* zero, double* weight, int n, double* alpha, double* beta );
+void GaussRecur(IssmPDouble* zero, IssmPDouble* weight, int n, IssmPDouble* alpha, IssmPDouble* beta);
 
-void gaussQuad( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, int nigaus, int njgaus );
-void gaussHexa( double** pxgaus, double** pxwgt, double** pegaus, double** pewgt, double** pzgaus, double** pzwgt, int nigaus, int njgaus, int nkgaus );
+void gaussQuad(IssmPDouble** pxgaus, IssmPDouble** pxwgt, IssmPDouble** pegaus, IssmPDouble** pewgt, int nigaus, int njgaus);
+void gaussHexa(IssmPDouble** pxgaus, IssmPDouble** pxwgt, IssmPDouble** pegaus, IssmPDouble** pewgt, IssmPDouble** pzgaus, IssmPDouble ** pzwgt, int nigaus, int njgaus, int nkgaus);
 
 #endif
Index: /issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp	(revision 12706)
@@ -14,17 +14,17 @@
 #include "../../objects/objects.h"
 
-void IsInputConverged(double* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum){
+void IsInputConverged(IssmDouble* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum){
 
 	int i,j;
 
 	/*output: */
-	double eps;
+	IssmDouble eps;
 	
 	/*intermediary: */
-	double *newvalues     = NULL;
-	double *oldvalues     = NULL;
+	IssmDouble *newvalues     = NULL;
+	IssmDouble *oldvalues     = NULL;
 	int     num_values;
-	double  ndu        = 0;
-	double  nu         = 0;
+	IssmDouble  ndu        = 0;
+	IssmDouble  nu         = 0;
 
 	if(criterion_enum==RelativeEnum){
@@ -50,8 +50,8 @@
 
 		/*now, compute eps: */
-		if(nu)eps=ndu/nu;
+		if(reCast<bool>(nu))eps=ndu/nu;
 		else eps=0;
 	}
-	else _error_("%s%s%s"," convergence criterion ",EnumToStringx(criterion_enum)," not supported yet!");
+	else _error2_("convergence criterion " << EnumToStringx(criterion_enum) << " not supported yet!");
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp	(revision 12706)
@@ -16,15 +16,15 @@
 #include <float.h>
 
-void OptimalSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs){
+void OptimalSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs){
 
 	/* This routine is optimizing a given function*/
 
 	/*function values: */
-	double fx1,fx2,fxbest;
-	double x1,x2,xmin,xbest;
+	IssmDouble fx1,fx2,fxbest;
+	IssmDouble x1,x2,xmin,xbest;
 
 	/*tolerances: */
-	double seps;
-	double tolerance=1.e-4;
+	IssmDouble seps;
+	IssmDouble tolerance=1.e-4;
 	int    maxiter;
 
@@ -41,7 +41,10 @@
 	//get the value of the function at the first boundary
 	fx1= (*f)(x1,optargs);
-	if (isnan(fx1)) _error_("Function evaluation returned NaN");
-	_printf_(VerboseControl(),"\n        Iteration         x           f(x)       Tolerance\n\n");
-	_printf_(VerboseControl(),"        %s    %12.6g  %12.6g  %s","   N/A",x1,fx1,"         N/A\n");
+	if (xIsNan<IssmDouble>(fx1)) _error2_("Function evaluation returned NaN");
+	cout<<setprecision(5);
+	if(VerboseControl()) _pprintLine_("");
+	if(VerboseControl()) _pprintLine_("       Iteration         x           f(x)       Tolerance");
+	if(VerboseControl()) _pprintLine_("");
+	if(VerboseControl()) _pprintLine_("           N/A    "<<setw(12)<<x1<<"  "<<setw(12)<<fx1<<"           N/A");
 
 	//update tolerances
@@ -54,14 +57,15 @@
 		iter++;
 		fx2 = (*f)(x2,optargs);
-		if (isnan(fx2)) _error_("Function evaluation returned NaN");
-		_printf_(VerboseControl(),"         %5i    %12.6g  %12.6g  %12.6g\n",iter,x2,fx2,fabs(x2-x1)>fabs(fx2-fx1)?fabs(fx2-fx1):fabs(x2-x1));
+		if (xIsNan<IssmDouble>(fx2)) _error2_("Function evaluation returned NaN");
+		if(VerboseControl())
+		 _pprintLine_("         "<<setw(5)<<iter<<"    "<<setw(12)<<x2<<"  "<<setw(12)<<fx2<<"  "<<(fabs(x2-x1)>fabs(fx2-fx1)?fabs(fx2-fx1):fabs(x2-x1)));
 
 		//Stop the optimization?
 		if ((fabs(x2-x1)+seps)<tolerance || (fabs(fx2-fx1)+seps)<tolerance){
-			_printf_(VerboseControl(),"      %s%g\n","optimization terminated: the current x satisfies the termination criteria using 'tolx' of " ,tolerance);
+			if(VerboseControl()) _pprintLine_("      " << "optimization terminated: the current x satisfies the termination criteria using 'tolx' of "  << tolerance);
 			loop=false;
 		}
 		else if (iter>=maxiter){
-			_printf_(VerboseControl(),"      %s\n","exiting: Maximum number of iterations has been exceeded  - increase 'maxiter'\n");
+			if(VerboseControl()) _pprintLine_("      " << "exiting: Maximum number of iterations has been exceeded  - increase 'maxiter'");
 			loop=false;
 		}
Index: /issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp	(revision 12706)
@@ -22,5 +22,5 @@
 	/*intermediary: */
 	int     dummy;
-	double* analyses=NULL;
+	IssmDouble* analyses=NULL;
 	char**  strings=NULL;
 	char*   string=NULL;
@@ -57,20 +57,18 @@
 	if (found==-1){
 		/*ok, we did not find anything, this is not good! error out: */
-		_error_("%s%s","could find neither a default analysis  nor analysis ",EnumToStringx(analysis_type));
+		_error2_("could find neither a default analysis  nor analysis " << EnumToStringx(analysis_type));
 	}
 
 	/*ok, grab the option string: */
-	outstring=(char*)xmalloc((strlen(strings[found])+1)*sizeof(char));
+	outstring=xNew<char>(strlen(strings[found])+1);
 	strcpy(outstring,strings[found]);
 
 	/*Free ressources*/
-	xfree((void**)&analyses);
+	xDelete<IssmDouble>(analyses);
 	for(i=0;i<numanalyses;i++){
 		string=strings[i];
-		xfree((void**)&string);
+		xDelete<char>(string);
 	}
-	xfree((void**)&strings);
-
-
+	xDelete<char*>(strings);
 	return outstring;
 }
Index: /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp	(revision 12706)
@@ -39,4 +39,4 @@
 
 	/*Free ressources:*/
-	xfree((void**)&options);
+	xDelete<char>(options);
 }
Index: /issm/trunk/src/c/shared/Numerics/Synchronize.sh
===================================================================
--- /issm/trunk/src/c/shared/Numerics/Synchronize.sh	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/Synchronize.sh	(revision 12706)
@@ -8,5 +8,5 @@
 #Get all lines of Verbosity.cpp
 cat Verbosity.h |  grep "bool Verbose" | awk '{print $2}' | sed -e "s/(/ /" | awk '{print $1}' | awk '{ printf "%s %s\n", NR, $0 }' >temp
-#Build header of Verbosity.cpp {{{1
+#Build header of Verbosity.cpp {{{
 cat <<END > Verbosity.cpp
 /*
@@ -127,5 +127,5 @@
 done
 
-#Add footer of Verbosity.cpp{{{1
+#Add footer of Verbosity.cpp{{{
 cat <<END >> Verbosity.cpp
 
@@ -135,5 +135,5 @@
 void SetVerbosityLevel(int level){
 
-	if(level<0) _error_("vebosity level should be a positive integer (user provided %i)",level);
+	if(level<0) _error2_("vebosity level should be a positive integer (user provided " << level << ")");
 
 	verbositylevel = level;
@@ -147,5 +147,5 @@
 END
 #}}}
-#Complete verbose.m {{{1
+#Complete verbose.m {{{
 VERBOSEPATH="$ISSM_DIR/src/m/classes/verbose.m"
 cat $VERBOSEPATH  | sed "/%BEGINFIELDS/,$ d"  > temp_begin
Index: /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/UnitConversion.cpp	(revision 12706)
@@ -3,5 +3,5 @@
  */ 
 
-/*headers {{{1*/
+/*headers {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -15,10 +15,10 @@
 #include "../../shared/shared.h"
 
-double UnitConversionScaleFactor(int type_enum);
+IssmDouble UnitConversionScaleFactor(int type_enum);
 /*}}}*/
 
-void UnitConversion(double* values, int numvalues,int direction_enum, int type_enum){
+void UnitConversion(IssmDouble* values, int numvalues,int direction_enum, int type_enum){
 
-	double scale;
+	IssmDouble scale;
 	int i;
 
@@ -29,9 +29,9 @@
 	if(direction_enum==IuToExtEnum) for(i=0;i<numvalues;i++)values[i]=values[i]*scale; 
 	else if(direction_enum==ExtToIuEnum) for(i=0;i<numvalues;i++)values[i]=values[i]/scale; 
-	else _error_(" wrong direction for unit conversion, either IuToExtEnum or ExtToIuEnum. ");
+	else _error2_("wrong direction for unit conversion, either IuToExtEnum or ExtToIuEnum. ");
 
 }
 
-double UnitConversion(double value, int direction_enum, int type_enum){
+IssmDouble UnitConversion(IssmDouble value, int direction_enum, int type_enum){
 
 	UnitConversion(&value,1,direction_enum,type_enum);
@@ -41,9 +41,9 @@
 
 
-double UnitConversionScaleFactor(int type_enum){
+IssmDouble UnitConversionScaleFactor(int type_enum){
 
-	double yts=365.0*24.0*3600.0;
+	IssmDouble yts=365.0*24.0*3600.0;
 	
-	double scale;
+	IssmDouble scale;
 	switch(type_enum){
 		case TimesteppingStartTimeEnum:              scale=1.0/yts;break; //yr
@@ -66,6 +66,12 @@
 		case SurfaceforcingsPrecipitationEnum:       scale=yts;break; //m/yr
 		case SurfaceforcingsMassBalanceEnum:         scale=yts;break; //m/yr
+		case SurfaceforcingsSmbPosMaxEnum:				scale=yts;break; //m/yr
+		case SurfaceforcingsSmbPosMinEnum:				scale=yts;break; //m/yr
+		case SurfaceforcingsAPosEnum:						scale=yts;break; //m/yr
+		case SurfaceforcingsBPosEnum:						scale=yts;break; //m/yr
+		case SurfaceforcingsANegEnum:						scale=yts;break; //m/yr
+		case SurfaceforcingsBNegEnum:						scale=yts;break; //m/yr
 		case MisfitEnum:                             scale=pow(yts,2);break; //(m/yr)^2
-		case MassFluxEnum:                           scale=pow((double)10,-12)*yts;break; // (GigaTon/year)
+		case MassFluxEnum:                           scale=pow((IssmDouble)10,-12)*yts;break; // (GigaTon/year)
 		default: scale=1.0; break;
 	}
Index: /issm/trunk/src/c/shared/Numerics/Verbosity.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/Verbosity.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/Verbosity.cpp	(revision 12706)
@@ -34,5 +34,5 @@
 void SetVerbosityLevel(int level){
 
-	if(level<0) _error_("vebosity level should be a positive integer (user provided %i)",level);
+	if(level<0) _error2_("vebosity level should be a positive integer (user provided " << level << ")");
 
 	verbositylevel = level;
Index: /issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp	(revision 12706)
@@ -5,12 +5,12 @@
 #include <math.h>
 
-void XZvectorsToCoordinateSystem(double* T,double* xzvectors){
+void XZvectorsToCoordinateSystem(IssmDouble* T,IssmDouble* xzvectors){
 
 	int		i,j;
-	double	x[3],y[3],z[3];
-	double	x_norm, y_norm, z_norm;
+	IssmDouble	x[3],y[3],z[3];
+	IssmDouble	x_norm, y_norm, z_norm;
 
 	for(i=0;i<6;i++){
-		if(isnan(xzvectors[i])){
+		if(xIsNan<IssmDouble>(xzvectors[i])){
 			/*At least one NaN found: default to Id*/
 			T[0*3+0] = 1.0;	T[0*3+1] = 0.0;	T[0*3+2] = 0.0;
Index: /issm/trunk/src/c/shared/Numerics/cross.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/cross.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/cross.cpp	(revision 12706)
@@ -9,5 +9,7 @@
 #endif
 
-void cross(double* result,double* vector1,double* vector2){
+#include "../../include/include.h"
+
+void cross(IssmDouble* result,IssmDouble* vector1,IssmDouble* vector2){
 
 	/*result,vector1 and vector2 are all assumed to be of size 3: */
Index: /issm/trunk/src/c/shared/Numerics/extrema.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/extrema.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/extrema.cpp	(revision 12706)
@@ -9,6 +9,7 @@
 #endif
 
+#include "../../include/include.h"
 
-double min(double a,double b){
+IssmDouble min(IssmDouble a,IssmDouble b){
 	if (a<b)return a;
 	else return b;
@@ -18,5 +19,5 @@
 	else return b;
 }
-double max(double a,double b){
+IssmDouble max(IssmDouble a,IssmDouble b){
 	if (a>b)return a;
 	else return b;
Index: /issm/trunk/src/c/shared/Numerics/isnan.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/isnan.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/isnan.cpp	(revision 12706)
@@ -1,9 +1,10 @@
 /*This routine only used by Intel compler: */
-#ifdef _INTEL_WIN_
 
-int isnan(double x){
-	if (x!=x)return 1;
-	else return 0;
+#include "../../include/include.h"
+#include "isnan.h"
+
+#ifdef _HAVE_ADOLC_
+template <> int xIsNan<adouble> (const adouble& X) {
+  return isnan(X.getValue());
 }
 #endif
-
Index: /issm/trunk/src/c/shared/Numerics/isnan.h
===================================================================
--- /issm/trunk/src/c/shared/Numerics/isnan.h	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/isnan.h	(revision 12706)
@@ -3,11 +3,20 @@
  */ 
 
-#ifndef _ISNAN_INTEL_H_
-#define _ISNAN_INTEL_H_
+#ifndef _XISNAN_H_
+#define _XISNAN_H_
 
+#include <cmath>
+
+template <class T> int xIsNan(const T& X) {
 #ifdef _INTEL_WIN_
-int isnan(double X);
+		return (X!=X)?1:0;
+#else
+		return isnan(X);
+#endif
+}
+
+#ifdef _HAVE_ADOLC_
+template <> int xIsNan<adouble> (const adouble& X);
 #endif
 
 #endif
-
Index: /issm/trunk/src/c/shared/Numerics/numerics.h
===================================================================
--- /issm/trunk/src/c/shared/Numerics/numerics.h	(revision 12705)
+++ /issm/trunk/src/c/shared/Numerics/numerics.h	(revision 12706)
@@ -9,4 +9,5 @@
 #include "./GaussPoints.h"
 #include "./isnan.h"
+#include "./recast.h"
 
 class Input;
@@ -16,17 +17,17 @@
 struct OptPars;
 
-double min(double a,double b);
-double max(double a,double b);
+IssmDouble min(IssmDouble a,IssmDouble b);
+IssmDouble max(IssmDouble a,IssmDouble b);
 int    min(int a,int b);
 int    max(int a,int b);
-double OptFunc(double scalar, OptArgs* optargs);
-void   BrentSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs);
-void   OptimalSearch(double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs);
-void   cross(double* result,double* vector1,double* vector2);
-void   IsInputConverged(double* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum);
-void   UnitConversion(double* values, int numvalues,int direction_enum, int type_enum);
-double UnitConversion(double value, int direction_enum, int type_enum);
+IssmDouble OptFunc(IssmDouble scalar, OptArgs* optargs);
+void   BrentSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs);
+void   OptimalSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs);
+void   cross(IssmDouble* result,IssmDouble* vector1,IssmDouble* vector2);
+void   IsInputConverged(IssmDouble* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum);
+void   UnitConversion(IssmDouble* values, int numvalues,int direction_enum, int type_enum);
+IssmDouble UnitConversion(IssmDouble value, int direction_enum, int type_enum);
 char*  OptionsFromAnalysis(Parameters* parameters,int analysis_type);
-void   XZvectorsToCoordinateSystem(double* T,double* xzvectors);
+void   XZvectorsToCoordinateSystem(IssmDouble* T,IssmDouble* xzvectors);
 #ifdef _HAVE_PETSC_
 void   PetscOptionsFromAnalysis(Parameters* parameters,int analysis_type);
Index: /issm/trunk/src/c/shared/Numerics/recast.h
===================================================================
--- /issm/trunk/src/c/shared/Numerics/recast.h	(revision 12706)
+++ /issm/trunk/src/c/shared/Numerics/recast.h	(revision 12706)
@@ -0,0 +1,39 @@
+/*
+ * recast.h
+ *
+ *  Created on: Jun 26, 2012
+ *      Author: utke
+ */
+
+#ifndef _RECAST_H_
+#define _RECAST_H_
+
+#ifndef _HAVE_ADOLC_
+
+template<class To, class From>
+To reCast(const From& from) {
+    return (To)from;
+}
+
+#else
+
+template<class To, class From>
+struct ForPartialSpecialization {
+    static  To reCast(const From& from ) { return (To) from;}
+};
+
+template<class To, class From>
+To reCast(const From& from) {
+    return ForPartialSpecialization<To,From>::reCast(from);
+}
+/**
+ * partial specialization
+ */
+template<class To>
+struct ForPartialSpecialization<To,adouble> {
+    static  To reCast(const adouble& from ) { return (To) (from.getValue());}
+};
+
+#endif
+
+#endif
Index: /issm/trunk/src/c/shared/String/DescriptorIndex.cpp
===================================================================
--- /issm/trunk/src/c/shared/String/DescriptorIndex.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/String/DescriptorIndex.cpp	(revision 12706)
@@ -23,10 +23,10 @@
 	/*retrieve first token, separated by underscore: */
 	pch = strtok (descriptor,"_");
-	if(!pch)_error_("%s%s%s"," descriptor ",descriptor," is not correctly formatted!");
+	if(!pch)_error2_("descriptor " << descriptor << " is not correctly formatted!");
 
 	if (strncmp(pch,"scaled",6)==0){
 		/*we have a scaled variable. recover the root: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," scaled descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("scaled descriptor " << descriptor << " is not correctly formatted!");
 		memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
 
@@ -44,9 +44,9 @@
 		/*we have an indexed variable. recover the root: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," indexed descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("indexed descriptor " << descriptor << " is not correctly formatted!");
 		memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
 		/*now recover  the index: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," indexed descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("indexed descriptor " << descriptor << " is not correctly formatted!");
 		sscanf(pch,"%i",pindex);
 		return IndexedEnum;
@@ -55,9 +55,9 @@
 		/*we have an indexed variable. recover the root: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," nodal descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("nodal descriptor " << descriptor << " is not correctly formatted!");
 		memcpy(root,pch,(strlen(pch)+1)*sizeof(char));
 		/*now recover  the index: */
 		pch = strtok (NULL, "_");
-		if(!pch)_error_("%s%s%s"," nodal descriptor ",descriptor," is not correctly formatted!");
+		if(!pch)_error2_("nodal descriptor " << descriptor << " is not correctly formatted!");
 		sscanf(pch,"%i",pindex);
 		return NodalEnum;
Index: /issm/trunk/src/c/shared/Sys/ProfilingEnd.cpp
===================================================================
--- /issm/trunk/src/c/shared/Sys/ProfilingEnd.cpp	(revision 12706)
+++ /issm/trunk/src/c/shared/Sys/ProfilingEnd.cpp	(revision 12706)
@@ -0,0 +1,43 @@
+/*!\file:  ProfilingEnd.cpp
+ * \brief ProfilingEnd.c: finalize profiling after calling a routine. Needs to mirror a ProfilingStart routine.
+ */
+
+/*Include files: {{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+#include "../../include/macros.h"
+#include "../shared.h"
+#include "../../io/io.h"
+/*}}}*/
+
+void ProfilingEnd(double* pSolution_time, double* pMemory_use, double* pCurrent_flops, double Time_start, double Flops_start){
+
+	double Solution_time, Memory_use, Current_flops;
+	double Time_finish, Flops_finish, memUse;
+	
+	#ifdef _HAVE_PETSC_
+	PetscGetTime(&Time_finish);
+	PetscGetFlops(&Flops_finish);
+	PetscMemoryGetCurrentUsage(&memUse);
+	
+	Solution_time=Time_finish-Time_start;
+	Current_flops=Flops_finish-Flops_start;
+	_pprintLine_("PETSc elapsed time  : " << Solution_time << "  Seconds");
+	_pprintLine_("PETSc elapsed flops : " << Current_flops << "  Flops");
+	_pprintLine_("PETSc memory used   : " << memUse << "  Bytes");
+	#else
+		_error_("Profiling not supported under this numerical toolkit");
+	#endif
+
+	/*Assign pointers: */
+	*pSolution_time=Solution_time;
+	*pMemory_use=memUse;
+	*pCurrent_flops=Current_flops;
+	return;
+}
+
+
+
Index: /issm/trunk/src/c/shared/Sys/ProfilingStart.cpp
===================================================================
--- /issm/trunk/src/c/shared/Sys/ProfilingStart.cpp	(revision 12706)
+++ /issm/trunk/src/c/shared/Sys/ProfilingStart.cpp	(revision 12706)
@@ -0,0 +1,31 @@
+/*!\file:  ProfilingStart.cpp
+ * \brief ProfilingStart.c: initialize profiling before calling a routine
+ */
+
+
+/*Include files: {{{*/
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+#include "../../include/macros.h"
+#include "../shared.h"
+/*}}}*/
+
+void ProfilingStart(double* pTime_start, double* pFlops_start){
+	
+	double Time_start, Flops_start;
+	
+	#ifdef _HAVE_PETSC_
+		PetscGetTime(&Time_start);
+		PetscGetFlops(&Flops_start );
+	#else
+		_error_("Profiling not supported under this numerical toolkit");
+	#endif
+
+	/*Assign pointers: */
+	*pTime_start=Time_start;
+	*pFlops_start=Flops_start;
+	return;
+}
Index: /issm/trunk/src/c/shared/Sys/sys.h
===================================================================
--- /issm/trunk/src/c/shared/Sys/sys.h	(revision 12706)
+++ /issm/trunk/src/c/shared/Sys/sys.h	(revision 12706)
@@ -0,0 +1,12 @@
+/* \file sys.h
+ * \brief: header file for ISSM system routines (profiling, timing, etc ...)
+ */
+
+
+#ifndef _ISSM_SYS_H_
+#define _ISSM_SYS_H_
+
+void ProfilingEnd(double* pSolution_time, double* pMemory_use, double* pCurrent_flops, double Time_start, double Flops_start);
+void ProfilingStart(double* pTime_start, double* pFlops_start);
+
+#endif
Index: /issm/trunk/src/c/shared/Threads/LaunchThread.cpp
===================================================================
--- /issm/trunk/src/c/shared/Threads/LaunchThread.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/Threads/LaunchThread.cpp	(revision 12706)
@@ -20,5 +20,5 @@
 
 #include "./issm_threads.h"
-#include "../Alloc/alloc.h"
+#include "../Alloc/xNewDelete.h"
 #include "../Exceptions/exceptions.h"
 #include "../../include/include.h"
@@ -28,12 +28,11 @@
 	#ifdef _MULTITHREADING_
 	int i;
-	int* status=NULL;
-
-	pthread_t* threads=NULL;
-	pthread_handle* handles=NULL;
+	int            *status  = NULL;
+	pthread_t      *threads = NULL;
+	pthread_handle *handles = NULL;
 	
 	/*dynamically allocate: */
-	threads=(pthread_t*)xmalloc(num_threads*sizeof(pthread_t));
-	handles=(pthread_handle*)xmalloc(num_threads*sizeof(pthread_handle));
+	threads=xNew<pthread_t>(num_threads);
+	handles=xNew<pthread_handle>(num_threads);
 
 	for(i=0;i<num_threads;i++){
@@ -42,20 +41,19 @@
 		handles[i].num=num_threads;
 	}
-	
 	for(i=0;i<num_threads;i++){
 
 		if(pthread_create(threads+i,NULL,function,(void*)(handles+i))){
-			_error_(" pthread_create error");
+			_error2_("pthread_create error");
 		}
 	}
 	for(i=0;i<num_threads;i++){
 		if(pthread_join(threads[i],(void**)&status)){
-			_error_(" pthread_join error");
+			_error2_("pthread_join error");
 		}
 	}
 	
 	/*Free ressources:*/
-	xfree((void**)&threads);
-	xfree((void**)&handles);
+	xDelete<pthread_t>(threads);
+	xDelete<pthread_handle>(handles);
 
 	#else
Index: /issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 12706)
@@ -3,5 +3,5 @@
  */
 #include "./trimesh.h"
-
+#include "../Alloc/xNewDelete.h"
 #include "../Alloc/alloc.h"
 
@@ -52,5 +52,5 @@
 
 	/*Go through all nodes of the rift segments, and start splitting the mesh: */
-	flags=(int*)xcalloc(nods,sizeof(int)); //to make sure we don't split the same nodes twice!
+	flags=xNewZeroInit<int>(nods); //to make sure we don't split the same nodes twice!
 	for (i=0;i<nriftsegs;i++){
 		for (j=0;j<2;j++){
Index: /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 12705)
+++ /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 12706)
@@ -7,4 +7,5 @@
 #include "./trimesh.h"
 #include "../Exceptions/exceptions.h"
+#include "../Alloc/xNewDelete.h"
 #include "../Alloc/alloc.h"
 #include "../../include/include.h"
@@ -53,5 +54,5 @@
 	current_size=max_number_elements;
 	NumGridElements=0;
-	GridElements=(int*)xmalloc(max_number_elements*sizeof(int));
+	GridElements=xNew<int>(max_number_elements);
 
 	for (i=0;i<nel;i++){
@@ -65,5 +66,5 @@
 				else{
 					/*Reallocate another max_number_elements slots in the GridElements: */
-					GridElementsRealloc=(int*)xrealloc(GridElements,(current_size+max_number_elements)*sizeof(int));
+					GridElementsRealloc=xReNew<int>(GridElements,current_size,(current_size+max_number_elements));
 					if (!GridElementsRealloc){
 						noerr=0;
@@ -81,5 +82,5 @@
 	cleanup_and_return:
 	if(!noerr){
-		xfree((void**)&GridElements);
+		xDelete<int>(GridElements);
 	}
 	/*Allocate return pointers: */
@@ -128,5 +129,5 @@
 
 	/*Allocate segmentflags: */
-	riftsegments_uncompressed=(int*)xcalloc(nsegs*5,sizeof(int));
+	riftsegments_uncompressed=xNewZeroInit<int>(nsegs*5);
 
 	/*Find the segments that belong to a rift: they are the ones that see two elements. The other ones belong to a boundary 
@@ -165,5 +166,5 @@
 
 	/*Compress riftsegments_uncompressed:*/
-	riftsegments=(int*)xmalloc(nriftsegs*4*sizeof(int));
+	riftsegments=xNew<int>(nriftsegs*4);
 	counter=0;
 	for (i=0;i<nsegs;i++){
@@ -177,5 +178,5 @@
 	}
 
-	xfree((void**)&riftsegments_uncompressed);
+	xDelete<int>(riftsegments_uncompressed);
 	
 	/*Assign output pointers: */
@@ -202,5 +203,5 @@
 	/*Figure out the list of elements  that are on the same side of the rift. To do so, we start from one 
 	 * side of the rift and keep rotating in the same direction:*/
-	GridElementListOnOneSideOfRift=(int*)xmalloc(NumGridElements*sizeof(int));
+	GridElementListOnOneSideOfRift=xNew<int>(NumGridElements);
 	//bootstrap the GridElementListOnOneSideOfRift by filling elements from riftsegments: */
 	GridElementListOnOneSideOfRift[0]=*(riftsegments+4*segmentnumber+0); /*this one does not belong to the same side, but is just there 
@@ -241,5 +242,5 @@
 
 	/*Free ressources: */
-	xfree((void**)&GridElements);
+	xDelete<int>(GridElements);
 	/*Assign output pointers: */
 	*pNumGridElementListOnOneSideOfRift=NumGridElementListOnOneSideOfRift;
@@ -380,14 +381,14 @@
 
 	/*input: */
-	double* segments=NULL;
-	double* segmentmarkerlist=NULL;
+	double *segments          = NULL;
+	double *segmentmarkerlist = NULL;
 	int numsegs;
 	
 	/*output: */
-	int* riftsnumsegs=NULL;
-	double** riftssegments=NULL;
-	int new_numsegs;
-	double* new_segments=NULL;
-	double* new_segmentmarkers=NULL;
+	int      new_numsegs;
+	int     *riftsnumsegs       = NULL;
+	double **riftssegments      = NULL;
+	double  *new_segments       = NULL;
+	double  *new_segmentmarkers = NULL;
 
 	/*intermediary: */
@@ -406,6 +407,6 @@
 	/*Allocate new segments: */
 	new_numsegs=counter;
-	new_segments=(double*)xmalloc(new_numsegs*3*sizeof(double));
-	new_segmentmarkers=(double*)xmalloc(new_numsegs*sizeof(double));
+	new_segments=xNew<double>(new_numsegs*3);
+	new_segmentmarkers=xNew<double>(new_numsegs);
 
 	/*Copy new segments info : */
@@ -422,6 +423,6 @@
 
 	/*Now deal with rift segments: */
-	riftsnumsegs=(int*)xmalloc(numrifts*sizeof(int));
-	riftssegments=(double**)xmalloc(numrifts*sizeof(double*));
+	riftsnumsegs=xNew<int>(numrifts);
+	riftssegments=xNew<double*>(numrifts);
 	for (i=0;i<numrifts;i++){
 		/*Figure out how many segments for rift i: */
@@ -431,5 +432,5 @@
 		}
 		riftsnumsegs[i]=counter;
-		riftsegment=(double*)xmalloc(counter*3*sizeof(double));
+		riftsegment=xNew<double>(counter*3);
 		/*Copy new segments info :*/
 		counter=0;
@@ -446,5 +447,5 @@
 
 	/*Free ressources: */
-	xfree((void**)&segments);
+	xDelete<double>(segments);
 
 	/*Assign output pointers: */
@@ -465,6 +466,6 @@
 
 	/*output: */
-	int* riftsnumpairs=NULL;
-	double** riftspairs=NULL;
+	int     *riftsnumpairs = NULL;
+	double **riftspairs    = NULL;
 
 	/*intermediary :*/
@@ -474,11 +475,11 @@
 	int     node1,node2,node3,node4;
 
-	riftsnumpairs=(int*)xmalloc(numrifts*sizeof(int));
-	riftspairs=(double**)xmalloc(numrifts*sizeof(double*));
+	riftsnumpairs=xNew<int>(numrifts);
+	riftspairs=xNew<double*>(numrifts);
 	for (i=0;i<numrifts;i++){
 		segments=riftssegments[i];
 		numsegs=riftsnumsegments[i];
 		riftsnumpairs[i]=numsegs;
-		pairs=(double*)xmalloc(2*numsegs*sizeof(double));
+		pairs=xNew<double>(2*numsegs);
 		for (j=0;j<numsegs;j++){
 			*(pairs+2*j+0)=*(segments+3*j+2); //retrieve element to which this segment belongs.
@@ -500,9 +501,7 @@
 	}
 
-
 	/*Assign output pointers: */
 	*priftsnumpairs=riftsnumpairs;
 	*priftspairs=riftspairs;
-
 	return noerr;
 }/*}}}*/
@@ -522,17 +521,16 @@
 
 	/*intermediary: */
-	double* riftsegments=NULL;
-	double* riftpairs=NULL;
+	double *riftsegments = NULL;
+	double *riftpairs    = NULL;
 	int     node1,node2,node3,node4,temp_node;
 	double  el2;
 	int     newnods; //temporary # node counter.
 	double  xmin,ymin;
-	double* xreal=NULL;
-	double* yreal=NULL;
-	int* nodes=NULL;
-	int* mergingnodes=NULL;
+	double *xreal        = NULL;
+	double *yreal        = NULL;
+	int    *nodes        = NULL;
+	int    *mergingnodes = NULL;
 	int     max_size;
 	int     redundant;
-
 
 	/*Recover input: */
@@ -562,6 +560,6 @@
 		max_size+=rifts1numsegs[i];
 	}
-	nodes=(int*)xmalloc(max_size*sizeof(int));
-	mergingnodes=(int*)xmalloc(max_size*sizeof(int));
+	nodes=xNew<int>(max_size);
+	mergingnodes=xNew<int>(max_size);
 
 	/*Go through the rifts segments, and identify which node we are going to merge with its counterpart on the other side 
@@ -678,6 +676,6 @@
 		}
 	}
-	xfree((void**)&x); x=xreal;
-	xfree((void**)&y); y=yreal;
+	xDelete<double>(x); x=xreal;
+	xDelete<double>(y); y=yreal;
 
 	/*Assign output pointers:*/
@@ -688,5 +686,4 @@
 	*psegments=segments;
 	*pnumsegs=numsegs;
-
 	return noerr;
 }/*}}}*/
@@ -716,5 +713,4 @@
 	*priftflag=riftflag;
 	*pnumrifts=numrifts;
-
 	return noerr;
 }/*}}}*/
@@ -726,12 +722,12 @@
 
 	/*intermediary: */
-	double* riftsegments=NULL;
-	double* riftpairs=NULL;
+	double *riftsegments = NULL;
+	double *riftpairs    = NULL;
 	int numsegs;
 
 	/*ordering and copy: */
-	int*    order=NULL;
-	double* riftsegments_copy=NULL;
-	double* riftpairs_copy=NULL;
+	int    *order             = NULL;
+	double *riftsegments_copy = NULL;
+	double *riftpairs_copy    = NULL;
 
 	/*node and element manipulation: */
@@ -744,5 +740,5 @@
 
 	/*Allocate byproduct of this routine, riftstips: */
-	riftstips=(double*)xmalloc(numrifts*2*sizeof(double));
+	riftstips=xNew<double>(numrifts*2);
 
 	/*Go through all rifts: */
@@ -754,7 +750,7 @@
 		/*Allocate copy of riftsegments and riftpairs, 
 		 *as well as ordering vector: */
-		riftsegments_copy=(double*)xmalloc(numsegs*3*sizeof(double));
-		riftpairs_copy=(double*)xmalloc(numsegs*2*sizeof(double));
-		order=(int*)xmalloc(numsegs*sizeof(int));
+		riftsegments_copy=xNew<double>(numsegs*3);
+		riftpairs_copy=xNew<double>(numsegs*2);
+		order=xNew<int>(numsegs);
 
 		/*First find the tips, using the pairs. If a pair of elements has one node in common, this node is a rift tip: */
@@ -814,5 +810,4 @@
 		*(riftstips+2*i+0)=(double)tip1;
 		*(riftstips+2*i+1)=(double)tip2;
-
 
 		/*We have the two tips for this rift.  Go from tip1 to tip2, and figure out the order in which segments are sequential. 
@@ -865,7 +860,7 @@
 		}
 
-		xfree((void**)&order);
-		xfree((void**)&riftsegments_copy);
-		xfree((void**)&riftpairs_copy);
+		xDelete<int>(order);
+		xDelete<double>(riftsegments_copy);
+		xDelete<double>(riftpairs_copy);
 
 	}
@@ -887,7 +882,7 @@
 
 	/*output: */
-	double** riftspenaltypairs=NULL;
-	double*  riftpenaltypairs=NULL;
-	int*     riftsnumpenaltypairs=NULL;
+	double **riftspenaltypairs    = NULL;
+	double  *riftpenaltypairs     = NULL;
+	int     *riftsnumpenaltypairs = NULL;
 
 	/*intermediary: */
@@ -901,6 +896,6 @@
 
 	/*Allocate: */
-	riftspenaltypairs=(double**)xmalloc(numrifts*sizeof(double*));
-	riftsnumpenaltypairs=(int*)xmalloc(numrifts*sizeof(int));
+	riftspenaltypairs=xNew<double*>(numrifts);
+	riftsnumpenaltypairs=xNew<int>(numrifts);
 
 	for(i=0;i<numrifts;i++){
@@ -910,5 +905,5 @@
 
 		/*allocate riftpenaltypairs, and riftnumpenaltypairs: */
-		if((numsegs/2-1)!=0)riftpenaltypairs=(double*)xcalloc((numsegs/2-1)*RIFTPENALTYPAIRSWIDTH,sizeof(double));
+		if((numsegs/2-1)!=0)riftpenaltypairs=xNewZeroInit<double>((numsegs/2-1)*RIFTPENALTYPAIRSWIDTH);
 		
 		/*Go through only one flank of the rifts, not counting the tips: */
@@ -1006,11 +1001,8 @@
 		riftsnumpenaltypairs[i]=(numsegs/2-1);
 	}
-			
-
 
 	/*Assign output pointers: */
 	*priftspenaltypairs=riftspenaltypairs;
 	*priftsnumpenaltypairs=riftsnumpenaltypairs;
-
 	return noerr;
 }
@@ -1143,5 +1135,4 @@
 	*py=y;
 	*pnods=nods;
-
 	return noerr;
 }
Index: /issm/trunk/src/c/shared/shared.h
===================================================================
--- /issm/trunk/src/c/shared/shared.h	(revision 12705)
+++ /issm/trunk/src/c/shared/shared.h	(revision 12706)
@@ -6,17 +6,18 @@
 #define _SHARED_H_
 
-
 #include "Alloc/alloc.h"
 #include "Alloc/alloc_module.h"
+#include "Alloc/xNewDelete.h"
+#include "Bamg/shared.h"
+#include "Elements/elements.h"
 #include "Exceptions/exceptions.h"
 #include "Exp/exp.h"
+#include "Matrix/matrix.h"
+#include "MemOps/xMemCpy.h"
+#include "Numerics/numerics.h"
+#include "Sorting/sorting.h"
+#include "Sys/sys.h"
+#include "Threads/issm_threads.h"
 #include "TriMesh/trimesh.h"
-#include "Sorting/sorting.h"
-#include "Elements/elements.h"
-#include "Matrix/matrix.h"
-#include "Numerics/numerics.h"
-#include "Dofs/dofs.h"
-#include "Threads/issm_threads.h"
-#include "Bamg/shared.h"
 #include "Wrapper/wrappershared.h"
 
Index: /issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp
===================================================================
--- /issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp	(revision 12706)
@@ -35,5 +35,5 @@
 			break;
 		default:
-			_error_("No adjoint has been implemented for solution %s yet",EnumToStringx(solutiontype));
+			_error2_("No adjoint has been implemented for solution " << EnumToStringx(solutiontype) << " yet");
 			break;
 	}
Index: /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp
===================================================================
--- /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/AnalysisConfiguration.cpp	(revision 12706)
@@ -29,5 +29,5 @@
 		case DiagnosticSolutionEnum:
 			numanalyses=5;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=DiagnosticHorizAnalysisEnum;
 			analyses[1]=DiagnosticVertAnalysisEnum;
@@ -39,5 +39,5 @@
 		case SteadystateSolutionEnum:
 			numanalyses=8;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=DiagnosticHorizAnalysisEnum;
 			analyses[1]=DiagnosticVertAnalysisEnum;
@@ -52,5 +52,5 @@
 		case ThermalSolutionEnum:
 			numanalyses=2;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=ThermalAnalysisEnum;
 			analyses[1]=MeltingAnalysisEnum;
@@ -59,5 +59,5 @@
 		case EnthalpySolutionEnum:
 			numanalyses=1;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=EnthalpyAnalysisEnum;
 			break;
@@ -65,5 +65,5 @@
 		case HydrologySolutionEnum:
 			numanalyses=3;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=HydrologyAnalysisEnum;
 			analyses[1]=SurfaceSlopeAnalysisEnum;
@@ -73,5 +73,5 @@
 		case PrognosticSolutionEnum:
 			numanalyses=1;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=PrognosticAnalysisEnum;
 			break;
@@ -79,5 +79,5 @@
 		case BalancethicknessSolutionEnum:
 			numanalyses=1;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=BalancethicknessAnalysisEnum;
 			break;
@@ -85,5 +85,5 @@
 		case SurfaceSlopeSolutionEnum:
 			numanalyses=1;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=SurfaceSlopeAnalysisEnum;
 			break;
@@ -91,5 +91,5 @@
 		case BedSlopeSolutionEnum:
 			numanalyses=1;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=BedSlopeAnalysisEnum;
 			break;
@@ -97,5 +97,5 @@
 		case TransientSolutionEnum:
 			numanalyses=9;
-			analyses=(int*)xmalloc(numanalyses*sizeof(int));
+			analyses=xNew<int>(numanalyses);
 			analyses[0]=DiagnosticHorizAnalysisEnum;
 			analyses[1]=DiagnosticVertAnalysisEnum;
@@ -110,5 +110,5 @@
 		
 		default:
-			_error_("%s%s%s"," solution type: ",EnumToStringx(solutiontype)," not supported yet!");
+			_error2_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
 			break;
 	}
@@ -117,4 +117,4 @@
 	if(pnumanalyses) *pnumanalyses=numanalyses;
 	if(panalyses)    *panalyses=analyses;
-	else              xfree((void**)&analyses);
+	else              xDelete<int>(analyses);
 }
Index: /issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp
===================================================================
--- /issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp	(revision 12706)
@@ -29,5 +29,5 @@
 			solutioncore=&diagnostic_core;
 			#else
-			_error_("ISSM was not compiled with diagnostic capabilities. Exiting");
+			_error2_("ISSM was not compiled with diagnostic capabilities. Exiting");
 			#endif
 			break;
@@ -36,5 +36,5 @@
 			solutioncore=&steadystate_core;
 			#else
-			_error_("ISSM was not compiled with steady state capabilities. Exiting");
+			_error2_("ISSM was not compiled with steady state capabilities. Exiting");
 			#endif
 			break;
@@ -43,5 +43,5 @@
 			solutioncore=&thermal_core;
 			#else
-			_error_("ISSM was not compiled with thermal capabilities. Exiting");
+			_error2_("ISSM was not compiled with thermal capabilities. Exiting");
 			#endif
 			break;
@@ -50,5 +50,5 @@
 			solutioncore=&enthalpy_core;
 			#else
-			_error_("ISSM was not compiled with thermal capabilities. Exiting");
+			_error2_("ISSM was not compiled with thermal capabilities. Exiting");
 			#endif
 			break;
@@ -57,5 +57,5 @@
 			solutioncore=&balancethickness_core;
 			#else
-			_error_("ISSM was not compiled with balanced capabilities. Exiting");
+			_error2_("ISSM was not compiled with balanced capabilities. Exiting");
 			#endif
 			break;
@@ -64,5 +64,5 @@
 			solutioncore=&hydrology_core;
 			#else
-			_error_("ISSM was not compiled with hydrology capabilities. Exiting");
+			_error2_("ISSM was not compiled with hydrology capabilities. Exiting");
 			#endif
 			break;
@@ -71,5 +71,5 @@
 			solutioncore=&surfaceslope_core;
 			#else
-			_error_("ISSM was not compiled with slope capabilities. Exiting");
+			_error2_("ISSM was not compiled with slope capabilities. Exiting");
 			#endif
 			break;
@@ -78,5 +78,5 @@
 			solutioncore=&bedslope_core;
 			#else
-			_error_("ISSM was not compiled with slope capabilities. Exiting");
+			_error2_("ISSM was not compiled with slope capabilities. Exiting");
 			#endif
 			break;
@@ -85,5 +85,5 @@
 			solutioncore=&transient_core;
 			#else
-			_error_("ISSM was not compiled with transient capabilities. Exiting");
+			_error2_("ISSM was not compiled with transient capabilities. Exiting");
 			#endif
 			break;
@@ -92,9 +92,9 @@
 			solutioncore=&prognostic_core;
 			#else
-			_error_("ISSM was not compiled with prognostic capabilities. Exiting");
+			_error2_("ISSM was not compiled with prognostic capabilities. Exiting");
 			#endif
 			break;
 		default:
-			_error_("%s%s%s"," solution type: ",EnumToStringx(solutiontype)," not supported yet!");
+			_error2_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
 			break;
 	}
Index: /issm/trunk/src/c/solutions/ProcessArguments.cpp
===================================================================
--- /issm/trunk/src/c/solutions/ProcessArguments.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/ProcessArguments.cpp	(revision 12706)
@@ -17,12 +17,12 @@
 	char *lockfilename   = NULL;
 
-	if(argc<2)_error_("Usage error: no solution requested");
+	if(argc<2)_error2_("Usage error: no solution requested");
 	*solution_type=StringToEnumx(argv[1]);
-	if(argc<3)_error_("Usage error: missing model name");
+	if(argc<3)_error2_("Usage error: missing model name");
 	modelname=argv[3];
-	binfilename    = (char*)xmalloc((strlen(modelname)+strlen(".bin")   +1)*sizeof(char)); sprintf(binfilename,   "%s%s",modelname,".bin");
-	outbinfilename = (char*)xmalloc((strlen(modelname)+strlen(".outbin")+1)*sizeof(char)); sprintf(outbinfilename,"%s%s",modelname,".outbin");
-	petscfilename  = (char*)xmalloc((strlen(modelname)+strlen(".petsc") +1)*sizeof(char)); sprintf(petscfilename, "%s%s",modelname,".petsc");
-	lockfilename   = (char*)xmalloc((strlen(modelname)+strlen(".lock")  +1)*sizeof(char)); sprintf(lockfilename,  "%s%s",modelname,".lock");
+	binfilename    = xNew<char>(strlen(modelname)+strlen(".bin")   +1); sprintf(binfilename,   "%s%s",modelname,".bin");
+	outbinfilename = xNew<char>(strlen(modelname)+strlen(".outbin")+1); sprintf(outbinfilename,"%s%s",modelname,".outbin");
+	petscfilename  = xNew<char>(strlen(modelname)+strlen(".petsc") +1); sprintf(petscfilename, "%s%s",modelname,".petsc");
+	lockfilename   = xNew<char>(strlen(modelname)+strlen(".lock")  +1); sprintf(lockfilename,  "%s%s",modelname,".lock");
 
 	/*Clean up and assign output pointer*/
Index: /issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp
===================================================================
--- /issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp	(revision 12706)
@@ -15,5 +15,5 @@
 	int    i;
 
-	_printf_(VerboseSolution(),"%s\n","   updating boundary conditions...");
+	if(VerboseSolution()) _pprintLine_("   updating boundary conditions...");
 			
 	/*set current analysis: */
Index: /issm/trunk/src/c/solutions/WriteLockFile.cpp
===================================================================
--- /issm/trunk/src/c/solutions/WriteLockFile.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/WriteLockFile.cpp	(revision 12706)
@@ -17,8 +17,8 @@
 	if(my_rank==0){
 		fid=fopen(filename,"w");
-		if(fid==NULL) _error_("%s%s","error message: could not open lock file ",filename);
+		if(fid==NULL) _error2_("error message: could not open lock file " << filename);
 
 		/*Close file: */
-		if(fclose(fid)!=0) _error_("%s%s","could not close lock file ",filename);
+		if(fclose(fid)!=0) _error2_("could not close lock file " << filename);
 	}
 
Index: /issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp	(revision 12706)
@@ -22,5 +22,5 @@
 
 	/*compute thickness */
-	_printf_(VerboseSolution(),"%s\n","   computing thickness");
+	if(VerboseSolution()) _pprintLine_("   computing thickness");
 	femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum);
 	solver_linear(femmodel);
@@ -30,5 +30,5 @@
 
 	/*compute adjoint*/
-	_printf_(VerboseSolution(),"%s\n","   computing adjoint");
+	if(VerboseSolution()) _pprintLine_("   computing adjoint");
 	femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum,AdjointBalancethicknessAnalysisEnum);
 	solver_adjoint_linear(femmodel);
@@ -36,5 +36,5 @@
 	/*Save results*/
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,AdjointEnum);
 	}
Index: /issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp	(revision 12706)
@@ -25,5 +25,5 @@
 
 	/*Compute velocities*/
-	_printf_(VerboseSolution(),"%s\n","   computing velocities");
+	if(VerboseSolution()) _pprintLine_("   computing velocities");
 	femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum);
 	solver_nonlinear(femmodel,conserve_loads); 
@@ -33,5 +33,5 @@
 
 	/*Compute adjoint*/
-	_printf_(VerboseSolution(),"%s\n","   computing adjoint");
+	if(VerboseSolution()) _pprintLine_("   computing adjoint");
 	femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum,AdjointHorizAnalysisEnum);
 	solver_adjoint_linear(femmodel);
@@ -39,5 +39,5 @@
 	/*Save results*/
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,AdjointxEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,AdjointyEnum);
Index: /issm/trunk/src/c/solutions/balancethickness_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/balancethickness_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/balancethickness_core.cpp	(revision 12706)
@@ -24,9 +24,9 @@
 	femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
 
-	_printf_(VerboseSolution(),"call computational core:\n");
+	if(VerboseSolution()) _pprintLine_("call computational core:");
 	solver_linear(femmodel);
 
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum);
 	}
Index: /issm/trunk/src/c/solutions/bedslope_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/bedslope_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/bedslope_core.cpp	(revision 12706)
@@ -19,5 +19,5 @@
 	femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
 
-	_printf_(VerboseSolution(),"%s\n","   computing slope");
+	if(VerboseSolution()) _pprintLine_("   computing slope");
 
 	/*Call on core computations: */
@@ -28,5 +28,5 @@
 	
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeXEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeYEnum);
Index: /issm/trunk/src/c/solutions/control_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/control_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/control_core.cpp	(revision 12706)
@@ -20,5 +20,5 @@
 	int     num_controls,num_responses;
 	int     nsteps;
-	double  tol_cm;
+	IssmDouble  tol_cm;
 	bool    cm_gradient;
 	int     dim;
@@ -28,11 +28,11 @@
 
 	int*    control_type = NULL;
-	double* responses=NULL;
+	IssmDouble* responses=NULL;
 	int*    step_responses=NULL;
-	double* maxiter=NULL;
-	double* cm_jump=NULL;
+	IssmDouble* maxiter=NULL;
+	IssmDouble* cm_jump=NULL;
 		
 	/*intermediary: */
-	double  search_scalar=1;
+	IssmDouble  search_scalar=1;
 	OptArgs optargs;
 	OptPars optpars;
@@ -43,5 +43,5 @@
 
 	/*output: */
-	double* J=NULL;
+	IssmDouble* J=NULL;
 
 	/*Recover parameters used throughout the solution*/
@@ -66,10 +66,10 @@
 
 	/*Launch once a complete solution to set up all inputs*/
-	_printf_(VerboseControl(),"%s\n","   preparing initial solution");
+	if(VerboseControl()) _pprintLine_("   preparing initial solution");
 	if(isstokes) solutioncore(femmodel);
 
 	/*Initialize responses: */
-	J=(double*)xmalloc(nsteps*sizeof(double));
-	step_responses=(int*)xmalloc(num_responses*sizeof(int));
+	J=xNew<IssmDouble>(nsteps);
+	step_responses=xNew<int>(num_responses);
 		
 	/*Initialize some of the BrentSearch arguments: */
@@ -81,5 +81,5 @@
 
 		/*Display info*/
-		_printf_(VerboseControl(),"\n%s%i%s%i\n","   control method step ",n+1,"/",nsteps);
+		if(VerboseControl()) _pprintLine_("\n" << "   control method step " << n+1 << "/" << nsteps);
 		for(i=0;i<num_responses;i++) step_responses[i]=(int)responses[n*num_responses+i];
 		femmodel->parameters->SetParam(step_responses,1,num_responses,StepResponsesEnum);
@@ -88,5 +88,5 @@
 		if(solution_type==SteadystateSolutionEnum) solutioncore(femmodel);
 
-		_printf_(VerboseControl(),"%s\n","   compute adjoint state:");
+		if(VerboseControl()) _pprintLine_("   compute adjoint state:");
 		adjointcore(femmodel);
 		gradient_core(femmodel,n,search_scalar==0);
@@ -98,9 +98,9 @@
 		}
 
-		_printf_(VerboseControl(),"%s\n","   optimizing along gradient direction");
+		if(VerboseControl()) _pprintLine_("   optimizing along gradient direction");
 		optpars.maxiter=(int)maxiter[n]; optpars.cm_jump=cm_jump[n];
 		BrentSearch(&search_scalar,J+n,&optpars,&objectivefunction,&optargs);
 
-		_printf_(VerboseControl(),"%s\n","   updating parameter using optimized search scalar"); //true means update save controls
+		if(VerboseControl()) _pprintLine_("   updating parameter using optimized search scalar"); //true means update save controls
 		InputControlUpdatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,search_scalar,true);
 		
@@ -108,5 +108,5 @@
 	}
 
-	_printf_(VerboseControl(),"%s\n","   preparing final solution");
+	if(VerboseControl()) _pprintLine_("   preparing final solution");
 	femmodel->parameters->SetParam(true,SaveResultsEnum);
 	solutioncore(femmodel);
@@ -120,9 +120,9 @@
 	cleanup_and_return:
 	/*Free ressources: */
-	xfree((void**)&control_type);
-	xfree((void**)&responses);
-	xfree((void**)&step_responses);
-	xfree((void**)&maxiter);
-	xfree((void**)&cm_jump);
-	xfree((void**)&J);
+	xDelete<int>(control_type);
+	xDelete<int>(step_responses);
+	xDelete<IssmDouble>(maxiter);
+	xDelete<IssmDouble>(responses);
+	xDelete<IssmDouble>(cm_jump);
+	xDelete<IssmDouble>(J);
 }
Index: /issm/trunk/src/c/solutions/controlconvergence.cpp
===================================================================
--- /issm/trunk/src/c/solutions/controlconvergence.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/controlconvergence.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 #include "./solutions.h"
 
-bool controlconvergence(double J, double tol_cm){
+bool controlconvergence(IssmDouble J, IssmDouble tol_cm){
 
 	int i;
@@ -23,7 +23,7 @@
 
 	/*Has convergence been reached?*/
-	if (!isnan(tol_cm) && J<tol_cm){
+	if (!xIsNan<IssmDouble>(tol_cm) && J<tol_cm){
 		converged=true;
-		_printf_(VerboseConvergence(),"      Convergence criterion reached: J = %g < %g",J,tol_cm);
+		if(VerboseConvergence()) _pprintString_("      Convergence criterion reached: J = " << J << " < " << tol_cm);
 	}
 
Index: /issm/trunk/src/c/solutions/controlrestart.cpp
===================================================================
--- /issm/trunk/src/c/solutions/controlrestart.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/controlrestart.cpp	(revision 12706)
@@ -7,5 +7,5 @@
 #include "../EnumDefinitions/EnumDefinitions.h"
 
-void controlrestart(FemModel* femmodel,double* J){
+void controlrestart(FemModel* femmodel,IssmDouble* J){
 
 	int      num_controls;
@@ -33,4 +33,4 @@
 
 	/*Clean up and return*/
-	xfree((void**)&control_type);
+	xDelete<int>(control_type);
 }
Index: /issm/trunk/src/c/solutions/controltao_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/controltao_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/controltao_core.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 
 /*Local prototype*/
-int FormFunctionGradient(TaoSolver,Vec,double*,Vec,void*);
+int FormFunctionGradient(TaoSolver,Vec,IssmDouble*,Vec,void*);
 int IssmMonitor(TaoSolver,void*);
 typedef struct {
@@ -30,6 +30,6 @@
 	int        nsteps,maxiter;
 	AppCtx     user;
-	TaoSolver  tao;
-	double    *dummy          = NULL;
+	TaoSolver  tao = 0;
+	IssmDouble    *dummy          = NULL;
 	int       *control_list   = NULL;
 	Vector    *X              = NULL;
@@ -41,5 +41,5 @@
 	PetscGetArgs(&argc,&args);
 	ierr = TaoInitialize(&argc,&args,(char*)0,"");
-	if(ierr) _error_("Could not initialize Tao");
+	if(ierr) _error2_("Could not initialize Tao");
 
 	/*Recover some parameters*/
@@ -50,9 +50,9 @@
 	femmodel->parameters->FindParam(&dummy,NULL,NULL,InversionMaxiterPerStepEnum);
 	femmodel->parameters->SetParam(false,SaveResultsEnum);
-	maxiter=nsteps*(int)dummy[0]; xfree((void**)&dummy);
+	maxiter=nsteps*(int)dummy[0]; xDelete<IssmDouble>(dummy);
 
 	/*Initialize TAO*/
-	_printf_(VerboseControl(),"%s\n","   Initializing the Toolkit for Advanced Optimization (TAO)");
 	TaoCreate(PETSC_COMM_WORLD,&tao);
+	if(VerboseControl()) _pprintLine_("   Initializing the Toolkit for Advanced Optimization (TAO)");
 	TaoSetFromOptions(tao);
 	TaoSetType(tao,"tao_blmvm");
@@ -78,5 +78,5 @@
 
 	/*Solver optimization problem*/
-	_printf_(VerboseControl(),"%s\n","   Starting optimization");
+	if(VerboseControl()) _pprintLine_("   Starting optimization");
 	TaoSolve(tao);
 	TaoView(tao,PETSC_VIEWER_STDOUT_WORLD);
@@ -88,5 +88,5 @@
 
 	/*Finalize*/
-	_printf_(VerboseControl(),"%s\n","   preparing final solution");
+	if(VerboseControl()) _pprintLine_("   preparing final solution");
 	femmodel->parameters->SetParam(true,SaveResultsEnum);
 	void (*solutioncore)(FemModel*)=NULL;
@@ -95,10 +95,10 @@
 
 	/*Clean up and return*/
-	xfree((void**)&control_list);
+	xDelete<int>(control_list);
 	xdelete(&X);
 	TaoDestroy(&tao);
 	TaoFinalize();
 }
-int FormFunctionGradient(TaoSolver tao, Vec Xpetsc, double *fcn,Vec G,void *userCtx){
+int FormFunctionGradient(TaoSolver tao, Vec Xpetsc, IssmDouble *fcn,Vec G,void *userCtx){
 
 	/*Retreive arguments*/
@@ -107,5 +107,5 @@
 	FemModel *femmodel       = user->femmodel;
 	int      *cost_functions = NULL;
-	double   *cost_functionsd= NULL;
+	IssmDouble   *cost_functionsd= NULL;
 	Vector   *gradient       = NULL;
 	Vector   *X              = NULL;
@@ -125,5 +125,5 @@
 
 	/*Prepare objective function*/
-	cost_functions=(int*)xmalloc(num_cost_functions*sizeof(int));
+	cost_functions=xNew<int>(num_cost_functions);
 	for(int i=0;i<num_cost_functions;i++) cost_functions[i]=(int)cost_functionsd[i]; //FIXME
 	femmodel->parameters->SetParam(cost_functions,1,num_cost_functions,StepResponsesEnum);
@@ -146,6 +146,6 @@
 
 	/*Clean-up and return*/
-	xfree((void**)&cost_functions);
-	xfree((void**)&cost_functionsd);
+	xDelete<int>(cost_functions);
+	xDelete<IssmDouble>(cost_functionsd);
 	return 0;
 }
@@ -153,5 +153,5 @@
 
 	int       i,its,num_responses;
-	double    f,gnorm,cnorm,xdiff;
+	IssmDouble    f,gnorm,cnorm,xdiff;
 	AppCtx   *user      = (AppCtx *)userCtx;
 	FemModel *femmodel  = user->femmodel;
@@ -163,17 +163,17 @@
 
 	TaoGetSolutionStatus(tao, &its, &f, &gnorm, &cnorm, &xdiff, NULL);
-	if(its==0) _printf_(true,"Iter       Function      Residual  |  List of contributions\n");
-	if(its==0) _printf_(true,"-----------------------------------+-----------------------\n");
-	_printf_(true,"%4i   %12.7g  %12.7g  | ",its,f,gnorm);
+	if(its==0) _pprintLine_("Iter       Function      Residual  |  List of contributions");
+	if(its==0) _pprintLine_("-----------------------------------+-----------------------");
+	_pprintString_(setw(4)<<its<<"   "<<setw(12)<<setprecision(7)<<f<<"  "<<setw(12)<<setprecision(7)<<gnorm<<"  | ");
 
 	/*Retrieve objective functions independently*/
 	for(i=0;i<num_responses;i++){
 		Responsex(&f,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnumToStringx(responses[i]),false,i);
-		_printf_(true," %12.7g ","",f);
+		_pprintString_(" "<<setw(12)<<setprecision(7)<<f);
 	}
-	_printf_(true,"\n");
+	_pprintLine_("");
 
 	/*Clean-up and return*/
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 	return 0;
 }
@@ -181,5 +181,5 @@
 #else
 void controltao_core(FemModel* femmodel){
-	_error_("TAO not installed or PETSc version not supported");
+	_error2_("TAO not installed or PETSc version not supported");
 }
 #endif //_HAVE_TAO_ 
Index: /issm/trunk/src/c/solutions/convergence.cpp
===================================================================
--- /issm/trunk/src/c/solutions/convergence.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/convergence.cpp	(revision 12706)
@@ -19,15 +19,15 @@
 	Vector* KUoldF=NULL;
 	Vector* duf=NULL;
-	double ndu,nduinf,nu;
-	double nKUF;
-	double nKUoldF;
-	double nF;
-	double solver_residue,res;
+	IssmDouble ndu,nduinf,nu;
+	IssmDouble nKUF;
+	IssmDouble nKUoldF;
+	IssmDouble nF;
+	IssmDouble solver_residue,res;
 
 	/*convergence options*/
-	double eps_res;
-	double eps_rel;
-	double eps_abs;
-	double yts;
+	IssmDouble eps_res;
+	IssmDouble eps_rel;
+	IssmDouble eps_abs;
+	IssmDouble yts;
 
 	/*If uf is NULL in input, f-set is nil, model is fully constrained, therefore converged from 
@@ -55,5 +55,5 @@
 		nF=pf->Norm(NORM_TWO);
 		solver_residue=nKUF/nF;
-		_printf_(true,"\n%s%g\n","   solver residue: norm(KU-F)/norm(F)=",solver_residue);
+		_pprintLine_("\n" << "   solver residue: norm(KU-F)/norm(F)=" << solver_residue);
 
 		//clean up
@@ -70,7 +70,7 @@
 	nF=pf->Norm(NORM_TWO);
 	res=nKUoldF/nF;
-	if (isnan(res)){
-		_printf_(true,"norm nf = %lf and norm kuold = %lf\n",nF,nKUoldF);
-		_error_("mechanical equilibrium convergence criterion is NaN!");
+	if (xIsNan<IssmDouble>(res)){
+		_pprintLine_("norm nf = " << nF << "f and norm kuold = " << nKUoldF << "f");
+		_error2_("mechanical equilibrium convergence criterion is NaN!");
 	}
 
@@ -81,14 +81,14 @@
 	//print
 	if(res<eps_res){
-		_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   mechanical equilibrium convergence criterion",res*100," < ",eps_res*100," %");
+		if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   mechanical equilibrium convergence criterion" << res*100 << " < " << eps_res*100 << " %");
 		converged=true;
 	}
 	else{ 
-		_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   mechanical equilibrium convergence criterion",res*100," > ",eps_res*100," %");
+		if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   mechanical equilibrium convergence criterion" << res*100 << " > " << eps_res*100 << " %");
 		converged=false;
 	}
 
 	/*Relative criterion (optional)*/
-	if (!isnan(eps_rel) || (VerboseConvergence())){
+	if (!xIsNan<IssmDouble>(eps_rel) || (VerboseConvergence())){
 
 		//compute norm(du)/norm(u)
@@ -96,5 +96,5 @@
 		ndu=duf->Norm(NORM_TWO); nu=old_uf->Norm(NORM_TWO);
 
-		if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!");
+		if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error2_("convergence criterion is NaN!");
 
 		//clean up
@@ -102,24 +102,24 @@
 
 		//print
-		if (!isnan(eps_rel)){
+		if (!xIsNan<IssmDouble>(eps_rel)){
 			if((ndu/nu)<eps_rel){
-				_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: norm(du)/norm(u)",ndu/nu*100," < ",eps_rel*100," %");
+				if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " < " << eps_rel*100 << " %");
 			}
 			else{ 
-				_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: norm(du)/norm(u)",ndu/nu*100," > ",eps_rel*100," %");
+				if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " > " << eps_rel*100 << " %");
 				converged=false;
 			}
 		}
-		else _printf_(true,"%-50s%g%s\n","   Convergence criterion: norm(du)/norm(u)",ndu/nu*100," %");
+		else _pprintLine_(setw(50) << left << "   Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " %");
 
 	}
 
 	/*Absolute criterion (Optional) = max(du)*/
-	if (!isnan(eps_abs) || (VerboseConvergence())){
+	if (!xIsNan<IssmDouble>(eps_abs) || (VerboseConvergence())){
 
 		//compute max(du)
 		duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0);
 		ndu=duf->Norm(NORM_TWO); nduinf=duf->Norm(NORM_INF);
-		if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!");
+		if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error2_("convergence criterion is NaN!");
 
 		//clean up
@@ -127,14 +127,14 @@
 
 		//print
-		if (!isnan(eps_abs)){
+		if (!xIsNan<IssmDouble>(eps_abs)){
 			if ((nduinf*yts)<eps_abs){
-				_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: max(du)",nduinf*yts," < ",eps_abs," m/yr");
+				if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   Convergence criterion: max(du)" << nduinf*yts << " < " << eps_abs << " m/yr");
 			}
 			else{
-				_printf_(VerboseConvergence(),"%-50s%g%s%g%s\n","   Convergence criterion: max(du)",nduinf*yts," > ",eps_abs," m/yr");
+				if(VerboseConvergence()) _pprintLine_(setw(50) << left << "   Convergence criterion: max(du)" << nduinf*yts << " > " << eps_abs << " m/yr");
 				converged=false;
 			}
 		}
-		else  _printf_(true,"%-50s%g%s\n","   Convergence criterion: max(du)",nduinf*yts," m/yr");
+		else  _pprintLine_(setw(50) << left << "   Convergence criterion: max(du)" << nduinf*yts << " m/yr");
 
 	}
Index: /issm/trunk/src/c/solutions/diagnostic_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/diagnostic_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/diagnostic_core.cpp	(revision 12706)
@@ -59,5 +59,5 @@
 	if(ishutter){
 			
-		_printf_(VerboseSolution(),"%s\n","   computing hutter velocities");
+		if(VerboseSolution()) _pprintLine_("   computing hutter velocities");
 
 		//Take the last velocity into account so that the velocity on the MacAyeal domain is not zero
@@ -72,5 +72,5 @@
 	if (ismacayealpattyn ^ isstokes){ // ^ = xor
 		
-		_printf_(VerboseSolution(),"%s\n","   computing velocities");
+		if(VerboseSolution()) _pprintLine_("   computing velocities");
 		femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum);
 		if(isnewton)
@@ -82,5 +82,5 @@
 	if (ismacayealpattyn && isstokes){
 
-		_printf_(VerboseSolution(),"%s\n","   computing coupling macayealpattyn and stokes velocities and pressure ");
+		if(VerboseSolution()) _pprintLine_("   computing coupling macayealpattyn and stokes velocities and pressure ");
 		solver_stokescoupling_nonlinear(femmodel,conserve_loads);
 	}
@@ -88,5 +88,5 @@
 	if (dim==3 & (ishutter || ismacayealpattyn)){
 
-		_printf_(VerboseSolution(),"%s\n","   computing vertical velocities");
+		if(VerboseSolution()) _pprintLine_("   computing vertical velocities");
 		femmodel->SetCurrentConfiguration(DiagnosticVertAnalysisEnum);
 		solver_linear(femmodel);
@@ -95,5 +95,5 @@
 
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum);
@@ -105,4 +105,4 @@
 
 	/*Free ressources:*/
-	xfree((void**)&requested_outputs);
+	xDelete<int>(requested_outputs);
 }
Index: /issm/trunk/src/c/solutions/enthalpy_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/enthalpy_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/enthalpy_core.cpp	(revision 12706)
@@ -21,5 +21,5 @@
 	femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
 
-	_printf_(VerboseSolution(),"   computing enthalpy\n");
+	if(VerboseSolution()) _pprintLine_("   computing enthalpy");
 	femmodel->SetCurrentConfiguration(EnthalpyAnalysisEnum);
 	solver_nonlinear(femmodel,true);
@@ -29,5 +29,5 @@
 
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnthalpyEnum);
Index: /issm/trunk/src/c/solutions/gradient_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/gradient_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/gradient_core.cpp	(revision 12706)
@@ -16,6 +16,6 @@
 
 	/*Intermediaries*/
-	double  norm_inf;
-	double *norm_list    = NULL;
+	IssmDouble  norm_inf;
+	IssmDouble *norm_list    = NULL;
 	Vector*     new_gradient = NULL;
 	Vector*     gradient     = NULL;
@@ -23,9 +23,9 @@
 
 	/*Compute gradient*/
-	_printf_(VerboseControl(),"   compute cost function gradient\n");
+	if(VerboseControl()) _pprintLine_("   compute cost function gradient");
 	Gradjx(&gradient,&norm_list,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters);
 
 	if (orthogonalize){
-		_printf_(VerboseControl(),"   orthogonalization\n");
+		if(VerboseControl()) _pprintLine_("   orthogonalization");
 		ControlInputGetGradientx(&old_gradient,femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials,femmodel->parameters);
 		Orthx(&new_gradient,gradient,old_gradient); xdelete(&old_gradient); xdelete(&gradient);
@@ -37,6 +37,6 @@
 	/*Check that gradient is clean*/
 	norm_inf=new_gradient->Norm(NORM_INF);
-	if(norm_inf<=0)    _error_("||∂J/∂α||∞ = 0    gradient norm is zero");
-	if(isnan(norm_inf))_error_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
+	if(norm_inf<=0)    _error2_("||∂J/∂α||∞ = 0    gradient norm is zero");
+	if(xIsNan<IssmDouble>(norm_inf))_error2_("||∂J/∂α||∞ = NaN  gradient norm is NaN");
 
 	/*plug back into inputs: */
@@ -48,4 +48,4 @@
 
 	/*Clean up and return*/
-	xfree((void**)&norm_list);
+	xDelete<IssmDouble>(norm_list);
 }
Index: /issm/trunk/src/c/solutions/hydrology_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/hydrology_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/hydrology_core.cpp	(revision 12706)
@@ -17,8 +17,8 @@
 
 	/*intermediary*/
-	double time;
+	IssmDouble time;
 	int    nsteps;
-	double starttime,final_time;
-	double dt;
+	IssmDouble starttime,final_time;
+	IssmDouble dt;
 	bool   save_results;
 	int    output_frequency;
@@ -45,5 +45,5 @@
 	for(i=0;i<nsteps;i++){
 		
-		if(nsteps)_printf_(VerboseSolution(),"time step:%i/%i\n",i+1,nsteps);
+		if(nsteps)if(VerboseSolution()) _pprintLine_("time step:" << i+1 << "/" << nsteps);
 		time+=dt;
 		femmodel->parameters->SetParam(time,TimeEnum);
@@ -53,5 +53,5 @@
 
 		if(save_results && ((i+1)%output_frequency==0 || (i+1)==nsteps)){
-			_printf_(VerboseSolution(),"   saving results \n");
+			if(VerboseSolution()) _pprintLine_("   saving results ");
 			//InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,WatercolumnEnum,i+1,time);
 			//InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,HydrologyWaterVxEnum,i+1,time);
@@ -59,5 +59,5 @@
 			
 			/*unload results*/
-			_printf_(VerboseSolution(),"   saving temporary results\n");
+			if(VerboseSolution()) _pprintLine_("   saving temporary results");
 			OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
 		}
Index: /issm/trunk/src/c/solutions/hydrology_core_step.cpp
===================================================================
--- /issm/trunk/src/c/solutions/hydrology_core_step.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/hydrology_core_step.cpp	(revision 12706)
@@ -13,9 +13,9 @@
 #include "../solvers/solvers.h"
 
-void hydrology_core_step(FemModel* femmodel,int step, double time){
+void hydrology_core_step(FemModel* femmodel,int step, IssmDouble time){
 	
 	bool modify_loads=true;
 
-	_printf_(VerboseSolution(),"   computing water column\n");
+	if(VerboseSolution()) _pprintLine_("   computing water column");
 	femmodel->SetCurrentConfiguration(HydrologyAnalysisEnum);
 	solver_nonlinear(femmodel,modify_loads);
Index: /issm/trunk/src/c/solutions/issm.cpp
===================================================================
--- /issm/trunk/src/c/solutions/issm.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/issm.cpp	(revision 12706)
@@ -30,8 +30,13 @@
 
 	/*time*/
-	double   start, finish;
-	double   start_core, finish_core;
-	double   start_init, finish_init;
+	IssmPDouble   start, finish;
+	IssmPDouble   start_core, finish_core;
+	IssmPDouble   start_init, finish_init;
 	int      ierr;
+
+	/*profiling*/   
+	bool profiling = false;
+	IssmPDouble Time_start, Flops_start;
+	IssmPDouble Solution_time, Memory_use, Current_flops;
 
 	ISSMBOOT();
@@ -40,5 +45,5 @@
 	#ifdef _HAVE_PETSC_
 	ierr=PetscInitialize(&argc,&argv,(char*)0,"");  
-	if(ierr) _error_("Could not initialize Petsc");
+	if(ierr) _error2_("Could not initialize Petsc");
 	#else
 	#ifdef _HAVE_MPI_
@@ -50,5 +55,5 @@
 	MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
 	#else
-	start=(double)clock();
+	start=(IssmPDouble)clock();
 	#endif
 
@@ -60,8 +65,8 @@
 
 	/*First process inputs*/
-	_printf_(true,"\n");
-	_printf_(true,"Ice Sheet System Model (%s) version %s\n",PACKAGE_NAME,PACKAGE_VERSION);
-	_printf_(true,"(website: %s contact: %s)\n",PACKAGE_URL,PACKAGE_BUGREPORT);
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
+	_pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
+	_pprintLine_("");
 	ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,argc,argv);
 
@@ -73,5 +78,5 @@
 	MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
 	#else
-	start_init=(double)clock();
+	start_init=(IssmPDouble)clock();
 	#endif
 	femmodel=new FemModel(binfilename,outbinfilename,solution_type,analyses,numanalyses);
@@ -94,22 +99,26 @@
 	femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
 	femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum);
+	femmodel->parameters->FindParam(&profiling,DebugProfilingEnum); 
+
 	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
 	#else
-	finish_init=(double)clock();
-	#endif
-
-	_printf_(true,"call computational core:\n");
+	finish_init=(IssmPDouble)clock();
+	#endif
+
+	_pprintLine_("call computational core:");
 	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
 	#else
-	start_core=(double)clock();
-	#endif
-	
+	start_core=(IssmPDouble)clock();
+	#endif
+	
+	if(profiling)ProfilingStart(&Time_start,&Flops_start);
+
 	if(dakota_analysis){
 		#ifdef _HAVE_DAKOTA_
 		Dakotax(femmodel);
 		#else
-		_error_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!");
+		_error2_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!");
 		#endif
 	}
@@ -121,5 +130,5 @@
 		 control_core(femmodel);
 		#else
-		_error_("ISSM was not compiled with control support, cannot carry out dakota analysis!");
+		_error2_("ISSM was not compiled with control support, cannot carry out dakota analysis!");
 		#endif
 	}
@@ -127,11 +136,20 @@
 		solutioncore(femmodel);
 	}
+
+	if(profiling){
+		ProfilingEnd(&Solution_time,&Memory_use,&Current_flops,Time_start,Flops_start);
+		femmodel->results->AddObject(new DoubleExternalResult(femmodel->results->Size()+1, ProfilingSolutionTimeEnum, Solution_time, 1, 0));
+		femmodel->results->AddObject(new DoubleExternalResult(femmodel->results->Size()+1, ProfilingCurrentMemEnum, Memory_use, 1, 0));
+		femmodel->results->AddObject(new DoubleExternalResult(femmodel->results->Size()+1, ProfilingCurrentFlopsEnum, Current_flops, 1, 0));
+	}
+
+
 	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
 	#else
-	finish_core=(double)clock();
-	#endif
-	
-	_printf_(true,"write results to disk:\n");
+	finish_core=(IssmPDouble)clock();
+	#endif
+
+	_pprintLine_("write results to disk:");
 	OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
 
@@ -139,14 +157,14 @@
 	pfclose(output_fid,lockfilename);
 	if (waitonlock>0){
-		_printf_(true,"write lock file:\n");
+		_pprintLine_("write lock file:");
 		WriteLockFile(lockfilename);
 	}
 
-	/*Free ressources */
-	xfree((void**)&analyses);
-	xfree((void**)&lockfilename);
-	xfree((void**)&binfilename);
-	xfree((void**)&outbinfilename);
-	xfree((void**)&petscfilename);
+	/*Free resources */
+	xDelete<int>(analyses);
+	xDelete<char>(lockfilename);
+	xDelete<char>(binfilename);
+	xDelete<char>(outbinfilename);
+	xDelete<char>(petscfilename);
 	delete femmodel;
 
@@ -154,22 +172,29 @@
 	#ifdef _HAVE_MPI_
 	MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
-	_printf_(true,"\n   %-34s %f seconds  \n","FemModel initialization elapsed time:",finish_init-start_init);
-	_printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",finish_core-start_core);
-	_printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600),int(int(finish-start)%3600/60),int(finish-start)%60);
-	#else
-	finish=(double)clock();
-	_printf_(true,"\n   %-34s %f seconds  \n","FemModel initialization elapsed time:",(finish_init-start_init)/CLOCKS_PER_SEC);
-	_printf_(true,"   %-34s %f seconds  \n","Core solution elapsed time:",(finish_core-start_core)/CLOCKS_PER_SEC);
-	_printf_(true,"\n   %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600/CLOCKS_PER_SEC),int(int((finish-start)/CLOCKS_PER_SEC)%3600/60),(int(finish-start)/CLOCKS_PER_SEC)%60);
-	#endif
-	
-		
+	_pprintLine_("");
+	_pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<finish_init-start_init);
+	_pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<finish_core-start_core);
+	_pprintLine_("");
+	_pprintLine_("   Total elapsed time:"<<int((finish-start)/3600)<<" hrs "<<int(int(finish-start)%3600/60)<<" min "<<int(finish-start)%60<<" sec");
+	_pprintLine_("");
+	#else
+	finish=(IssmPDouble)clock();
+	_pprintLine_("");
+	_pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<(finish_init-start_init)/CLOCKS_PER_SEC);
+	_pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<(finish_core-start_core)/CLOCKS_PER_SEC);
+	_pprintLine_("");
+	_pprintLine_("   Total elapsed time:"
+				<<int((finish-start)/CLOCKS_PER_SEC/3600)<<" hrs "
+				<<int(int(finish-start)/CLOCKS_PER_SEC%3600/60)<<" min "
+				<<int(finish-start)/CLOCKS_PER_SEC%60<<" sec");
+	_pprintLine_("");
+	#endif
 	
 	#ifdef _HAVE_PETSC_
-	_printf_(true,"closing MPI and Petsc\n");
+	_pprintLine_("closing MPI and Petsc");
 	PetscFinalize(); 
 	#else
 	#ifdef _HAVE_MPI_
-	_printf_(true,"closing MPI and Petsc\n");
+	_pprintLine_("closing MPI and Petsc");
 	MPI_Finalize();
 	#endif
Index: /issm/trunk/src/c/solutions/kriging.cpp
===================================================================
--- /issm/trunk/src/c/solutions/kriging.cpp	(revision 12706)
+++ /issm/trunk/src/c/solutions/kriging.cpp	(revision 12706)
@@ -0,0 +1,177 @@
+/*!\file:  kriging.cpp
+ * \brief: kriging main parallel program
+ */ 
+
+#include "../issm.h"
+#include "../include/globals.h"
+
+/*Local prototypes*/
+void ProcessArguments2(char** pbinfilename,char** poutbinfilename,char** plockfilename,int argc,char **argv);
+void ProcessInputfile(IssmDouble **px,IssmDouble **py,IssmDouble **pdata,int *pnobs,IssmDouble **px_interp,IssmDouble **py_interp,int *pninterp,Options **poptions,FILE* fid);
+
+int main(int argc,char **argv){
+
+	/*I/O: */
+	FILE *output_fid = NULL;
+	FILE *input_fid  = NULL;
+	bool  waitonlock = false;
+
+	/*File names*/
+	char *lockfilename   = NULL;
+	char *binfilename    = NULL;
+	char *outbinfilename = NULL;
+
+	/*Input*/
+	int      ninterp,nobs;
+	IssmDouble  *x        = NULL;
+	IssmDouble  *y        = NULL;
+	IssmDouble  *data     = NULL;
+	IssmDouble  *x_interp = NULL;
+	IssmDouble  *y_interp = NULL;
+	Options *options  = NULL;
+
+	/*Output*/
+	IssmDouble *predictions = NULL;
+	IssmDouble *error       = NULL;
+
+	ISSMBOOT();
+
+	/*Initialize environments: Petsc, MPI, etc...: */
+#ifdef _HAVE_PETSC_
+	int ierr=PetscInitialize(&argc,&argv,(char*)0,"");  
+	if(ierr) _error2_("Could not initialize Petsc");
+#else
+#ifdef _HAVE_MPI_
+	MPI_Init(&argc,&argv);
+#endif
+#endif
+
+	/*Size and rank: */
+#ifdef _HAVE_MPI_
+	MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);  
+	MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 
+#endif
+
+	/*First process inputs*/
+	_pprintLine_("");
+	_pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
+	_pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
+	_pprintLine_("");
+	ProcessArguments2(&binfilename,&outbinfilename,&lockfilename,argc,argv);
+
+	/*Process input files*/
+	input_fid=pfopen(binfilename,"rb");
+	ProcessInputfile(&x,&y,&data,&nobs,&x_interp,&y_interp,&ninterp,&options,input_fid);
+	pfclose(input_fid,binfilename);
+
+	_pprintLine_("call computational core:");
+	pKrigingx(&predictions,&error,x,y,data,nobs,x_interp,y_interp,ninterp,options);
+
+	_pprintLine_("write results to disk:");
+	Results *results = new Results();
+	if(my_rank==0){
+		output_fid=pfopen(outbinfilename,"wb");
+		results->AddObject(new DoubleVecExternalResult(results->Size()+1,0,predictions,ninterp,1,0));
+		results->AddObject(new DoubleVecExternalResult(results->Size()+1,1,error,ninterp,1,0));
+		for(int i=0;i<results->Size();i++){
+			ExternalResult* result=(ExternalResult*)results->GetObjectByOffset(i);
+			result->WriteData(output_fid,1);
+		}
+		pfclose(output_fid,outbinfilename);
+	}
+
+	/*Close output and petsc options file and write lock file if requested*/
+	_pprintLine_("write lock file:");
+	WriteLockFile(lockfilename);
+
+	/*Free ressources */
+	xDelete<char>(lockfilename);
+	xDelete<char>(binfilename);
+	xDelete<char>(outbinfilename);
+	xDelete<IssmDouble>(x);
+	xDelete<IssmDouble>(y);
+	xDelete<IssmDouble>(data);
+	xDelete<IssmDouble>(x_interp);
+	xDelete<IssmDouble>(y_interp);
+	xDelete<IssmDouble>(predictions);
+	xDelete<IssmDouble>(error);
+	delete options;
+	delete results;
+
+#ifdef _HAVE_PETSC_
+	_pprintLine_("closing MPI and Petsc");
+	PetscFinalize(); 
+#else
+#ifdef _HAVE_MPI_
+	_pprintLine_("closing MPI and Petsc");
+	MPI_Finalize();
+#endif
+#endif
+
+	/*end module: */
+	ISSMEND();
+
+	return 0; //unix success return;
+}
+
+void ProcessArguments2(char** pbinfilename,char** poutbinfilename,char** plockfilename,int argc,char **argv){
+
+	char *modelname      = NULL;
+	char *binfilename    = NULL;
+	char *outbinfilename = NULL;
+	char *lockfilename   = NULL;
+
+	if(argc<2)_error2_("Usage error: missing model name");
+	modelname=argv[2];
+	binfilename    = xNew<char>((strlen(modelname)+strlen(".bin")   +1)); sprintf(binfilename,   "%s%s",modelname,".bin");
+	outbinfilename = xNew<char>((strlen(modelname)+strlen(".outbin")+1)); sprintf(outbinfilename,"%s%s",modelname,".outbin");
+	lockfilename   = xNew<char>((strlen(modelname)+strlen(".lock")  +1)); sprintf(lockfilename,  "%s%s",modelname,".lock");
+
+	/*Clean up and assign output pointer*/
+	*pbinfilename=binfilename;
+	*poutbinfilename=outbinfilename;
+	*plockfilename=lockfilename;
+}
+
+void ProcessInputfile(IssmDouble **px,IssmDouble **py,IssmDouble **pdata,int *pnobs,IssmDouble **px_interp,IssmDouble **py_interp,int *pninterp,Options **poptions,FILE* fid){
+
+	int      ninterp,nobs,numoptions;
+	IssmDouble  *x        = NULL;
+	IssmDouble  *y        = NULL;
+	IssmDouble  *data     = NULL;
+	IssmDouble  *x_interp = NULL;
+	IssmDouble  *y_interp = NULL;
+	Options *options  = NULL;
+	Option  *option   = NULL;
+
+	int dummy,M,N;
+	IoModel* iomodel = new IoModel();
+	iomodel->fid=fid;
+	iomodel->CheckEnumSync();
+	iomodel->FetchData(&x,&M,&N,0);        nobs=M*N;
+	iomodel->FetchData(&y,&M,&N,1);        _assert_(M*N==nobs);
+	iomodel->FetchData(&data,&M,&N,2);     _assert_(M*N==nobs);
+	iomodel->FetchData(&x_interp,&M,&N,3); ninterp=M*N;
+	iomodel->FetchData(&y_interp,&M,&N,4); _assert_(M*N==ninterp);
+
+	/*Read options*/
+	options = new Options();
+	iomodel->LastIndex(&N);
+	numoptions=(int)((N-4)/2);
+	for(int i=0;i<numoptions;i++){
+		iomodel->FetchData(&option,5+2*i);
+		options->AddOption(option);
+		option=NULL;
+	}
+
+	/*Assign output pointer*/
+	*px        = x;
+	*py        = y;
+	*pdata     = data;
+	*pnobs     = nobs;
+	*px_interp = x_interp;
+	*py_interp = y_interp;
+	*pninterp  = ninterp;
+	*poptions  = options;
+	delete iomodel;
+}
Index: /issm/trunk/src/c/solutions/objectivefunction.cpp
===================================================================
--- /issm/trunk/src/c/solutions/objectivefunction.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/objectivefunction.cpp	(revision 12706)
@@ -3,5 +3,5 @@
  */ 
 
-/*include files: {{{1*/
+/*include files: {{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -20,10 +20,10 @@
 /*}}}*/
 
-double objectivefunction(double search_scalar,OptArgs* optargs){
+IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs){
 
 	int i;  
 	
 	/*output: */
-	double J;
+	IssmDouble J;
 	
 	/*parameters: */
@@ -49,5 +49,5 @@
 	}
 	else{
-		_error_("Solution %s not implemented yet",EnumToStringx(solution_type));
+		_error2_("Solution " << EnumToStringx(solution_type) << " not implemented yet");
 	}
 
@@ -66,5 +66,5 @@
 	}
 	else{
-		_error_("Solution %s not implemented yet",EnumToStringx(solution_type));
+		_error2_("Solution " << EnumToStringx(solution_type) << " not implemented yet");
 	}
 
Index: /issm/trunk/src/c/solutions/prognostic_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/prognostic_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/prognostic_core.cpp	(revision 12706)
@@ -17,4 +17,5 @@
 	bool save_results;
 	bool ispdd;
+	bool issmbgradients;
 
 	/*activate formulation: */
@@ -24,15 +25,21 @@
 	femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
 	femmodel->parameters->FindParam(&ispdd,SurfaceforcingsIspddEnum);
+	femmodel->parameters->FindParam(&issmbgradients,SurfaceforcingsIssmbgradientsEnum);
 
 	if(ispdd){
-	  _printf_(VerboseSolution(),"   call positive degree day module\n");
+	  if(VerboseSolution()) _pprintLine_("   call positive degree day module");
 	  PositiveDegreeDayx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
-	}	
+	}
 
-	_printf_(VerboseSolution(),"   call computational core\n");
+	if(issmbgradients){
+	  _printf_(VerboseSolution(),"	call smb gradients module\n");
+	  SmbGradientsx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+	}
+
+	if(VerboseSolution()) _pprintLine_("   call computational core");
 	solver_linear(femmodel);
 	
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum);
 	}
Index: /issm/trunk/src/c/solutions/solutions.h
===================================================================
--- /issm/trunk/src/c/solutions/solutions.h	(revision 12705)
+++ /issm/trunk/src/c/solutions/solutions.h	(revision 12706)
@@ -18,5 +18,5 @@
 void diagnostic_core(FemModel* femmodel);
 void hydrology_core(FemModel* femmodel);
-void hydrology_core_step(FemModel* femmodel,int step, double time);
+void hydrology_core_step(FemModel* femmodel,int step, IssmDouble time);
 void thermal_core(FemModel* femmodel);
 void enthalpy_core(FemModel* femmodel);
@@ -30,18 +30,18 @@
 void steadystate_core(FemModel* femmodel);
 void transient_core(FemModel* femmodel);
-double objectivefunction(double search_scalar,OptArgs* optargs);
+IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs);
 
 //convergence:
 void convergence(bool* pconverged, Matrix* K_ff,Vector* p_f,Vector* u_f,Vector* u_f_old,Parameters* parameters);
-bool controlconvergence(double J,double tol_cm);
+bool controlconvergence(IssmDouble J,IssmDouble tol_cm);
 bool steadystateconvergence(FemModel* femmodel);
 
 //optimization
-int GradJSearch(double* search_vector,FemModel* femmodel,int step);
+int GradJSearch(IssmDouble* search_vector,FemModel* femmodel,int step);
 
 //diverse
 void ProcessArguments(int* solution,char** pbinname,char** poutbinname,char** ppetscname,char** plockname,int argc,char **argv);
 void WriteLockFile(char* filename);
-void controlrestart(FemModel* femmodel,double* J);
+void controlrestart(FemModel* femmodel,IssmDouble* J);
 void ResetBoundaryConditions(FemModel* femmodel, int analysis_type);
 
Index: /issm/trunk/src/c/solutions/steadystate_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/steadystate_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/steadystate_core.cpp	(revision 12706)
@@ -9,4 +9,5 @@
 #endif
 
+#include "../include/include.h"
 #include "../toolkits/toolkits.h"
 #include "../objects/objects.h"
@@ -16,5 +17,4 @@
 #include "./solutions.h"
 #include "../modules/modules.h"
-#include "../include/include.h"
 #include "../solvers/solvers.h"
 
@@ -43,5 +43,5 @@
 	for(;;){
 	
-		_printf_(VerboseSolution(),"%s%i\n","   computing temperature and velocity for step: ",step);
+		if(VerboseSolution()) _pprintLine_("   computing temperature and velocity for step: " << step);
 		#ifdef _HAVE_THERMAL_
 		if(isenthalpy==0){
@@ -52,20 +52,20 @@
 		}
 		#else
-		_error_("ISSM was not compiled with thermal capabilities. Exiting");
+		_error2_("ISSM was not compiled with thermal capabilities. Exiting");
 		#endif
 
-		_printf_(VerboseSolution(),"%s\n","   computing new velocity");
+		if(VerboseSolution()) _pprintLine_("   computing new velocity");
 		diagnostic_core(femmodel);
 
 		if (step>1){
-			_printf_(VerboseSolution(),"%s\n","   checking velocity, temperature and pressure convergence");
+			if(VerboseSolution()) _pprintLine_("   checking velocity, temperature and pressure convergence");
 			if(steadystateconvergence(femmodel)) break;
 		}
 		if(step>maxiter){
-			_printf_(VerboseSolution(),"%s%i%s\n","   maximum number steadystate iterations ",maxiter," reached");
+			if(VerboseSolution()) _pprintLine_("   maximum number steadystate iterations " << maxiter << " reached");
 			break;
 		}
 		
-		_printf_(VerboseSolution(),"%s\n","   saving velocity, temperature and pressure to check for convergence at next step");
+		if(VerboseSolution()) _pprintLine_("   saving velocity, temperature and pressure to check for convergence at next step");
 		InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum,VxPicardEnum);
 		InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum,VyPicardEnum);
@@ -79,5 +79,5 @@
 	
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum);
@@ -93,4 +93,4 @@
 
 	/*Free ressources:*/
-	xfree((void**)&requested_outputs);
+	xDelete<int>(requested_outputs);
 }
Index: /issm/trunk/src/c/solutions/steadystateconvergence.cpp
===================================================================
--- /issm/trunk/src/c/solutions/steadystateconvergence.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/steadystateconvergence.cpp	(revision 12706)
@@ -28,5 +28,5 @@
 	int temperatureenums[2]={TemperatureEnum,TemperatureOldEnum};
 	int convergencecriterion[1]={RelativeEnum}; //criterions for convergence, RelativeEnum or AbsoluteEnum 
-	double convergencecriterionvalue[1]; //value of criterion to be respected
+	IssmDouble convergencecriterionvalue[1]; //value of criterion to be respected
 
 	/*retrieve parameters: */
Index: /issm/trunk/src/c/solutions/surfaceslope_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/surfaceslope_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/surfaceslope_core.cpp	(revision 12706)
@@ -19,5 +19,5 @@
 	femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
 
-	_printf_(VerboseSolution(),"%s\n","computing slope...");
+	if(VerboseSolution()) _pprintLine_("computing slope...");
 
 	/*Call on core computations: */
@@ -28,5 +28,5 @@
 	
 	if(save_results){
-		_printf_(VerboseSolution(),"saving results:\n");
+		if(VerboseSolution()) _pprintLine_("saving results:");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeXEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeYEnum);
Index: /issm/trunk/src/c/solutions/thermal_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/thermal_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/thermal_core.cpp	(revision 12706)
@@ -16,5 +16,5 @@
 
 	/*intermediary*/
-	double melting_offset;
+	IssmDouble melting_offset;
 	bool   save_results;
 	bool   dakota_analysis  = false;
@@ -29,14 +29,14 @@
 	}
 
-	_printf_(VerboseSolution(),"   computing temperatures\n");
+	if(VerboseSolution()) _pprintLine_("   computing temperatures");
 	femmodel->SetCurrentConfiguration(ThermalAnalysisEnum);
 	solver_thermal_nonlinear(femmodel);
 
-	_printf_(VerboseSolution(),"   computing melting\n");
+	if(VerboseSolution()) _pprintLine_("   computing melting");
 	femmodel->SetCurrentConfiguration(MeltingAnalysisEnum);
 	solver_linear(femmodel);
 
 	if(save_results){
-		_printf_(VerboseSolution(),"   saving results\n");
+		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BasalforcingsMeltingRateEnum);
Index: /issm/trunk/src/c/solutions/transient_core.cpp
===================================================================
--- /issm/trunk/src/c/solutions/transient_core.cpp	(revision 12705)
+++ /issm/trunk/src/c/solutions/transient_core.cpp	(revision 12706)
@@ -23,5 +23,5 @@
 
 	/*parameters: */
-	double starttime,finaltime,dt,yts;
+	IssmDouble starttime,finaltime,dt,yts;
 	bool   isdiagnostic,isprognostic,isthermal,isgroundingline,isenthalpy;
 	bool   save_results,dakota_analysis;
@@ -34,5 +34,5 @@
 	/*intermediary: */
 	int    step;
-	double time;
+	IssmDouble time;
 
 	//first recover parameters common to all solutions
@@ -86,5 +86,5 @@
 		femmodel->parameters->SetParam(step,StepEnum);
 
-		_printf_(VerboseSolution(),"iteration %i/%g  time [yr]: %-7.3g (time step: %.2g)\n",step,floor((finaltime-time)/dt)+step,time/yts,dt/yts);
+		if(VerboseSolution()) _pprintLine_("iteration " << step << "/" << floor((finaltime-time)/dt)+step << "  time [yr]: " << time/yts << " (time step: " << dt/yts << ")");
 		if(step%output_frequency==0 || time==finaltime)
 		 save_results=true;
@@ -94,5 +94,5 @@
 
 		if(isthermal && dim==3){
-			_printf_(VerboseSolution(),"   computing temperatures\n");
+			if(VerboseSolution()) _pprintLine_("   computing temperatures");
 			#ifdef _HAVE_THERMAL_
 			if(isenthalpy==0){
@@ -103,30 +103,30 @@
 			}
 			#else
-			_error_("ISSM was not compiled with thermal capabilities. Exiting");
+			_error2_("ISSM was not compiled with thermal capabilities. Exiting");
 			#endif
 		}
 
 		if(isdiagnostic){
-			_printf_(VerboseSolution(),"   computing new velocity\n");
+			if(VerboseSolution()) _pprintLine_("   computing new velocity");
 			#ifdef _HAVE_DIAGNOSTIC_
 			diagnostic_core(femmodel);
 			#else
-			_error_("ISSM was not compiled with diagnostic capabilities. Exiting");
+			_error2_("ISSM was not compiled with diagnostic capabilities. Exiting");
 			#endif
 		}
 
 		if(isprognostic){
-			_printf_(VerboseSolution(),"   computing new thickness\n");
+			if(VerboseSolution()) _pprintLine_("   computing new thickness");
 			prognostic_core(femmodel);
-			_printf_(VerboseSolution(),"   updating vertices positions\n");
+			if(VerboseSolution()) _pprintLine_("   updating vertices positions");
 			UpdateVertexPositionsx(femmodel->elements, femmodel->nodes,femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters); 
 		}
 
 		if(isgroundingline){
-			_printf_(VerboseSolution(),"   computing new grounding line position\n");
+			if(VerboseSolution()) _pprintLine_("   computing new grounding line position");
 			#ifdef _HAVE_GROUNDINGLINE_
 			GroundinglineMigrationx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 			#else
-			_error_("ISSM was not compiled with grounding line migration capabilities. Exiting");
+			_error2_("ISSM was not compiled with grounding line migration capabilities. Exiting");
 			#endif
 		}
@@ -134,5 +134,5 @@
 		/*unload results*/
 		if(save_results){
-			_printf_(VerboseSolution(),"   saving transient results\n");
+			if(VerboseSolution()) _pprintLine_("   saving transient results");
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceEnum);
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedEnum);
@@ -141,5 +141,5 @@
 			RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);
 
-			_printf_(VerboseSolution(),"   saving temporary results\n");
+			if(VerboseSolution()) _pprintLine_("   saving temporary results");
 			OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
 		}
@@ -147,4 +147,4 @@
 
 	/*Free ressources:*/
-	xfree((void**)&requested_outputs);
+	xDelete<int>(requested_outputs);
 }
Index: /issm/trunk/src/c/solvers/solver_newton.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_newton.cpp	(revision 12705)
+++ /issm/trunk/src/c/solvers/solver_newton.cpp	(revision 12706)
@@ -17,5 +17,5 @@
 	int    num_unstable_constraints;
 	int    count;
-	double kmax;
+	IssmDouble kmax;
 	Matrix* Kff = NULL;
 	Matrix* Kfs    = NULL;
@@ -70,13 +70,13 @@
 			bool max_iteration_state=false;
 			int tempStep=1;
-			double tempTime=1.0;
+			IssmDouble tempTime=1.0;
 			femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime));
 			break;
 		}
 		if(count>=max_nonlinear_iterations){
-			_printf_(true,"   maximum number of Newton iterations (%i) exceeded\n",max_nonlinear_iterations); 
+			_pprintLine_("   maximum number of Newton iterations (" << max_nonlinear_iterations << ") exceeded"); 
 			bool max_iteration_state=true;
 			int tempStep=1;
-			double tempTime=1.0;
+			IssmDouble tempTime=1.0;
 			femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime));
 			break;
@@ -100,5 +100,5 @@
 	}
 
-	_printf_(VerboseConvergence(),"\n   total number of iterations: %i\n",count-1);
+	if(VerboseConvergence()) _pprintLine_("\n   total number of iterations: " << count-1);
 
 	/*clean-up*/
Index: /issm/trunk/src/c/solvers/solver_nonlinear.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_nonlinear.cpp	(revision 12705)
+++ /issm/trunk/src/c/solvers/solver_nonlinear.cpp	(revision 12706)
@@ -73,5 +73,5 @@
 
 		ConstraintsStatex(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);
-		_printf_(VerboseConvergence(),"   number of unstable constraints: %i\n",num_unstable_constraints);
+		if(VerboseConvergence()) _pprintLine_("   number of unstable constraints: " << num_unstable_constraints);
 
 		//rift convergence
@@ -88,10 +88,10 @@
 			bool max_iteration_state=false;
 			int tempStep=1;
-			double tempTime=1.0;
+			IssmDouble tempTime=1.0;
 			femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime));
 			break;
 		}
 		if(count>=max_nonlinear_iterations){
-			_printf_(true,"   maximum number of nonlinear iterations (%i) exceeded\n",max_nonlinear_iterations); 
+			_pprintLine_("   maximum number of nonlinear iterations (" << max_nonlinear_iterations << ") exceeded"); 
 			converged=true;
 			InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum);
@@ -99,5 +99,5 @@
 			bool max_iteration_state=true;
 			int tempStep=1;
-			double tempTime=1.0;
+			IssmDouble tempTime=1.0;
 			femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime));
 			break;
@@ -105,5 +105,5 @@
 	}
 
-	_printf_(VerboseConvergence(),"\n   total number of iterations: %i\n",count-1);
+	if(VerboseConvergence()) _pprintLine_("\n   total number of iterations: " << count-1);
 
 	/*clean-up*/
Index: /issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp	(revision 12705)
+++ /issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp	(revision 12706)
@@ -91,5 +91,5 @@
 		if(converged==true)break;
 		if(count>=max_nonlinear_iterations){
-			_printf_(true,"   maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations); 
+			_pprintLine_("   maximum number of iterations (" << max_nonlinear_iterations << ") exceeded"); 
 			break;
 		}
Index: /issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp
===================================================================
--- /issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp	(revision 12705)
+++ /issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp	(revision 12706)
@@ -16,5 +16,5 @@
 	Vector* tf_old=NULL; 
 	Vector* ys=NULL; 
-	double melting_offset;
+	IssmDouble melting_offset;
 
 	/*intermediary: */
@@ -47,5 +47,5 @@
 	converged=false;
 
-	_printf_(VerboseSolution(),"%s\n","starting direct shooting method");
+	if(VerboseSolution()) _pprintLine_("starting direct shooting method");
 	InputUpdateFromConstantx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,true,ResetPenaltiesEnum);
 	InputUpdateFromConstantx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,false,ConvergedEnum);
@@ -66,9 +66,9 @@
 
 		if (!converged){
-			_printf_(VerboseConvergence(),"%s%i\n","   #unstable constraints = ",num_unstable_constraints);
+			if(VerboseConvergence()) _pprintLine_("   #unstable constraints = " << num_unstable_constraints);
 			if (num_unstable_constraints <= thermal_penalty_threshold)converged=true;
 			if (count>=thermal_maxiter){
 				converged=true;
-				_printf_(true,"   maximum number of iterations (%i) exceeded\n",thermal_maxiter); 
+				_pprintLine_("   maximum number of iterations (" << thermal_maxiter << ") exceeded"); 
 			}
 		}
Index: /issm/trunk/src/c/toolkits/issm/SeqMat.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/issm/SeqMat.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/issm/SeqMat.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -19,5 +19,5 @@
 
 /*SeqMat constructors and destructor*/
-/*FUNCTION SeqMat::SeqMat(){{{1*/
+/*FUNCTION SeqMat::SeqMat(){{{*/
 SeqMat::SeqMat(){
 
@@ -27,5 +27,5 @@
 }
 /*}}}*/
-/*FUNCTION SeqMat::SeqMat(int M,int N){{{1*/
+/*FUNCTION SeqMat::SeqMat(int M,int N){{{*/
 SeqMat::SeqMat(int pM,int pN){
 
@@ -33,18 +33,18 @@
 	this->N=pN;
 	this->matrix=NULL;
-	if(M*N) this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
-}
-/*}}}*/
-/*FUNCTION SeqMat::SeqMat(int M,int N, double sparsity){{{1*/
-SeqMat::SeqMat(int pM,int pN, double sparsity){
-
-	this->M=pM;
-	this->N=pN;
-	this->matrix=NULL;
-	if(M*N) this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
-}
-/*}}}*/
-/*FUNCTION SeqMat(double* serial_mat,int M,int N,double sparsity){{{1*/
-SeqMat::SeqMat(double* serial_mat,int pM,int pN,double sparsity){
+	if(M*N) this->matrix=xNewZeroInit<IssmDouble>(pM*pN);
+}
+/*}}}*/
+/*FUNCTION SeqMat::SeqMat(int M,int N, IssmDouble sparsity){{{*/
+SeqMat::SeqMat(int pM,int pN, IssmDouble sparsity){
+
+	this->M=pM;
+	this->N=pN;
+	this->matrix=NULL;
+	if(M*N) this->matrix=xNewZeroInit<IssmDouble>(pM*pN);
+}
+/*}}}*/
+/*FUNCTION SeqMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity){{{*/
+SeqMat::SeqMat(IssmDouble* serial_mat,int pM,int pN,IssmDouble sparsity){
 
 	int i,j;
@@ -54,11 +54,11 @@
 	this->matrix=NULL;
 	if(M*N){
-		this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
-		memcpy(this->matrix,serial_mat,pM*pN*sizeof(double));
-	}
-
-}
-/*}}}*/
-/*FUNCTION SeqMat::SeqMat(int M,int N, int connectivity, int numberofdofspernode){{{1*/
+		this->matrix=xNewZeroInit<IssmDouble>(pM*pN);
+		xMemCpy<IssmDouble>(this->matrix,serial_mat,pM*pN);
+	}
+
+}
+/*}}}*/
+/*FUNCTION SeqMat::SeqMat(int M,int N, int connectivity, int numberofdofspernode){{{*/
 SeqMat::SeqMat(int pM,int pN, int connectivity,int numberofdofspernode){
 
@@ -66,11 +66,11 @@
 	this->N=pN;
 	this->matrix=NULL;
-	if(M*N)this->matrix=(double*)xcalloc(pM*pN,sizeof(double));
-}
-/*}}}*/
-/*FUNCTION SeqMat::~SeqMat(){{{1*/
+	if(M*N) this->matrix=xNewZeroInit<IssmDouble>(pM*pN);
+}
+/*}}}*/
+/*FUNCTION SeqMat::~SeqMat(){{{*/
 SeqMat::~SeqMat(){
 
-	xfree((void**)&this->matrix);
+	xDelete<IssmDouble>(this->matrix);
 	M=0;
 	N=0;
@@ -79,18 +79,18 @@
 
 /*SeqMat specific routines: */
-/*FUNCTION SeqMat::Echo{{{1*/
+/*FUNCTION SeqMat::Echo{{{*/
 void SeqMat::Echo(void){
 
 	int i,j;
-	printf("SeqMat size %i-%i\n",this->M,this->N);
+	_printLine_("SeqMat size " << this->M << "-" << this->N);
 	for(i=0;i<M;i++){
 		for(j=0;j<N;j++){
-			printf("%g ",this->matrix[N*i+j]);
+			_printString_(this->matrix[N*i+j] << " ");
 		}
-		printf("\n");
-	}
-}
-/*}}}*/
-/*FUNCTION SeqMat::Assemble{{{1*/
+		_printLine_("");
+	}
+}
+/*}}}*/
+/*FUNCTION SeqMat::Assemble{{{*/
 void SeqMat::Assemble(void){
 		
@@ -99,9 +99,9 @@
 }
 /*}}}*/
-/*FUNCTION SeqMat::Norm{{{1*/
-double SeqMat::Norm(NormMode mode){
-
-	double norm;
-	double absolute;
+/*FUNCTION SeqMat::Norm{{{*/
+IssmDouble SeqMat::Norm(NormMode mode){
+
+	IssmDouble norm;
+	IssmDouble absolute;
 	int i,j;
 
@@ -119,10 +119,10 @@
 			break;
 		default:
-			_error_("unknown norm !");
-			break;
-	}
-}
-/*}}}*/
-/*FUNCTION SeqMat::GetSize{{{1*/
+			_error2_("unknown norm !");
+			break;
+	}
+}
+/*}}}*/
+/*FUNCTION SeqMat::GetSize{{{*/
 void SeqMat::GetSize(int* pM,int* pN){
 
@@ -132,5 +132,5 @@
 }
 /*}}}*/
-/*FUNCTION SeqMat::GetLocalSize{{{1*/
+/*FUNCTION SeqMat::GetLocalSize{{{*/
 void SeqMat::GetLocalSize(int* pM,int* pN){
 	
@@ -140,16 +140,16 @@
 }
 /*}}}*/
-/*FUNCTION SeqMat::MatMult{{{1*/
+/*FUNCTION SeqMat::MatMult{{{*/
 void SeqMat::MatMult(SeqVec* X,SeqVec* AX){
 
 	int i,j;
 	int XM,AXM;
-	double dummy;
+	IssmDouble dummy;
 
 	X->GetSize(&XM);
 	AX->GetSize(&AXM);
 
-	if(M!=AXM)_error_("A and AX should have the same number of rows!");
-	if(N!=XM)_error_("A and X should have the same number of columns!");
+	if(M!=AXM)_error2_("A and AX should have the same number of rows!");
+	if(N!=XM)_error2_("A and X should have the same number of columns!");
 
 	for(i=0;i<M;i++){
@@ -163,8 +163,8 @@
 }
 /*}}}*/
-/*FUNCTION SeqMat::Duplicate{{{1*/
+/*FUNCTION SeqMat::Duplicate{{{*/
 SeqMat* SeqMat::Duplicate(void){
 
-	double dummy=0;
+	IssmDouble dummy=0;
 
 	return new SeqMat(this->matrix,this->M,this->N,dummy);
@@ -172,12 +172,12 @@
 }
 /*}}}*/
-/*FUNCTION SeqMat::ToSerial{{{1*/
-double* SeqMat::ToSerial(void){
-
-	double* buffer=NULL;
+/*FUNCTION SeqMat::ToSerial{{{*/
+IssmDouble* SeqMat::ToSerial(void){
+
+	IssmDouble* buffer=NULL;
 
 	if(this->M*this->N){
-		buffer=(double*)xmalloc(this->M*this->N*sizeof(double));
-		memcpy(buffer,this->matrix,this->M*this->N*sizeof(double));
+		buffer=xNew<IssmDouble>(this->M*this->N);
+		xMemCpy<IssmDouble>(buffer,this->matrix,this->M*this->N);
 	}
 	return buffer;
@@ -185,6 +185,6 @@
 }
 /*}}}*/
-/*FUNCTION SeqMat::SetValues{{{1*/
-void SeqMat::SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode){
+/*FUNCTION SeqMat::SetValues{{{*/
+void SeqMat::SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode){
 	
 	int i,j;
@@ -197,11 +197,11 @@
 			break;
 		default:
-			_error_("unknown insert mode!");
-			break;
-	}
-
-}
-/*}}}*/
-/*FUNCTION SeqMat::Convert{{{1*/
+			_error2_("unknown insert mode!");
+			break;
+	}
+
+}
+/*}}}*/
+/*FUNCTION SeqMat::Convert{{{*/
 void SeqMat::Convert(MatrixType type){
 
Index: /issm/trunk/src/c/toolkits/issm/SeqMat.h
===================================================================
--- /issm/trunk/src/c/toolkits/issm/SeqMat.h	(revision 12705)
+++ /issm/trunk/src/c/toolkits/issm/SeqMat.h	(revision 12706)
@@ -1,4 +1,4 @@
 /*!\file:  SeqMat.h
- * \brief wrapper to SeqMat objects, which are just wrappers to a simple double* buffer.
+ * \brief wrapper to SeqMat objects, which are just wrappers to a simple IssmDouble* buffer.
  */ 
 
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -24,24 +24,24 @@
 	
 		int M,N; 
-		double* matrix; 
+		IssmDouble* matrix; 
 
-		/*SeqMat constructors, destructors {{{1*/
+		/*SeqMat constructors, destructors {{{*/
 		SeqMat();
 		SeqMat(int M,int N);
-		SeqMat(int M,int N,double sparsity);
-		SeqMat(double* serial_mat,int M,int N,double sparsity);
+		SeqMat(int M,int N,IssmDouble sparsity);
+		SeqMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity);
 		SeqMat(int M,int N,int connectivity,int numberofdofspernode);
 		~SeqMat();
 		/*}}}*/
-		/*SeqMat specific routines {{{1*/
+		/*SeqMat specific routines {{{*/
 		void Echo(void);
 		void Assemble(void);
-		double Norm(NormMode norm_type);
+		IssmDouble Norm(NormMode norm_type);
 		void GetSize(int* pM,int* pN);
 		void GetLocalSize(int* pM,int* pN);
 		void MatMult(SeqVec* X,SeqVec* AX);
 		SeqMat* Duplicate(void);
-		double* ToSerial(void);
-		void SetValues(int m,int* idxm,int n,int* idxn,double* values,InsMode mode);
+		IssmDouble* ToSerial(void);
+		void SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode);
 		void Convert(MatrixType type);
 		/*}}}*/
Index: /issm/trunk/src/c/toolkits/issm/SeqVec.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/issm/SeqVec.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/issm/SeqVec.cpp	(revision 12706)
@@ -4,5 +4,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -19,5 +19,5 @@
 
 /*SeqVec constructors and destructor*/
-/*FUNCTION SeqVec::SeqVec(){{{1*/
+/*FUNCTION SeqVec::SeqVec(){{{*/
 SeqVec::SeqVec(){
 
@@ -26,14 +26,14 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::SeqVec(int M,bool fromlocalsize){{{1*/
+/*FUNCTION SeqVec::SeqVec(int M,bool fromlocalsize){{{*/
 SeqVec::SeqVec(int pM,bool fromlocalsize){
 
 	this->M=pM;
 	this->vector=NULL;
-	if(this->M) this->vector=(double*)xcalloc(pM,sizeof(double));
-}
-/*}}}*/
-/*FUNCTION SeqVec::SeqVec(double* serial_vec,int M){{{1*/
-SeqVec::SeqVec(double* buffer,int pM){
+	if(this->M) this->vector=xNewZeroInit<IssmDouble>(pM);
+}
+/*}}}*/
+/*FUNCTION SeqVec::SeqVec(IssmDouble* serial_vec,int M){{{*/
+SeqVec::SeqVec(IssmDouble* buffer,int pM){
 
 	int i,j;
@@ -42,12 +42,12 @@
 	this->vector=NULL;
 	if(this->M){
-		this->vector=(double*)xcalloc(pM,sizeof(double));
-		memcpy(this->vector,buffer,pM*sizeof(double));
-	}
-}
-/*}}}*/
-		/*FUNCTION SeqVec::~SeqVec(){{{1*/
+		this->vector=xNewZeroInit<IssmDouble>(pM);
+		xMemCpy<IssmDouble>(this->vector,buffer,pM);
+	}
+}
+/*}}}*/
+		/*FUNCTION SeqVec::~SeqVec(){{{*/
 SeqVec::~SeqVec(){
-	xfree((void**)&this->vector);
+	xDelete<IssmDouble>(this->vector);
 	M=0;
 }
@@ -55,16 +55,16 @@
 
 /*SeqVec specific routines: */
-/*FUNCTION SeqVec::Echo{{{1*/
+/*FUNCTION SeqVec::Echo{{{*/
 void SeqVec::Echo(void){
 
 	int i;
-	printf("SeqVec size %i\n",this->M);
+	_printLine_("SeqVec size " << this->M);
 	for(i=0;i<M;i++){
-		printf("%g\n ",vector[i]);
-	}
-}
-/*}}}*/
-
-/*FUNCTION SeqVec::Assemble{{{1*/
+		_printString_(vector[i] << "\n ");
+	}
+}
+/*}}}*/
+
+/*FUNCTION SeqVec::Assemble{{{*/
 void SeqVec::Assemble(void){
 		
@@ -73,6 +73,6 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::SetValues{{{1*/
-void SeqVec::SetValues(int ssize, int* list, double* values, InsMode mode){
+/*FUNCTION SeqVec::SetValues{{{*/
+void SeqVec::SetValues(int ssize, int* list, IssmDouble* values, InsMode mode){
 	
 	int i;
@@ -85,12 +85,12 @@
 			break;
 		default:
-			_error_("unknown insert mode!");
-			break;
-	}
-
-}
-/*}}}*/
-/*FUNCTION SeqVec::SetValue{{{1*/
-void SeqVec::SetValue(int dof, double value, InsMode mode){
+			_error2_("unknown insert mode!");
+			break;
+	}
+
+}
+/*}}}*/
+/*FUNCTION SeqVec::SetValue{{{*/
+void SeqVec::SetValue(int dof, IssmDouble value, InsMode mode){
 
 	switch(mode){
@@ -102,11 +102,11 @@
 			break;
 		default:
-			_error_("unknown insert mode!");
-			break;
-	}
-}
-/*}}}*/
-/*FUNCTION SeqVec::GetValue{{{1*/
-void SeqVec::GetValue(double* pvalue,int dof){
+			_error2_("unknown insert mode!");
+			break;
+	}
+}
+/*}}}*/
+/*FUNCTION SeqVec::GetValue{{{*/
+void SeqVec::GetValue(IssmDouble* pvalue,int dof){
 
 	*pvalue=this->vector[dof];
@@ -115,5 +115,5 @@
 /*}}}*/
 		
-/*FUNCTION SeqVec::GetSize{{{1*/
+/*FUNCTION SeqVec::GetSize{{{*/
 void SeqVec::GetSize(int* pM){
 
@@ -122,5 +122,5 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::GetLocalSize{{{1*/
+/*FUNCTION SeqVec::GetLocalSize{{{*/
 void SeqVec::GetLocalSize(int* pM){
 	
@@ -129,5 +129,5 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::Duplicate{{{1*/
+/*FUNCTION SeqVec::Duplicate{{{*/
 SeqVec* SeqVec::Duplicate(void){
 	
@@ -136,6 +136,6 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::Set{{{1*/
-void SeqVec::Set(double value){
+/*FUNCTION SeqVec::Set{{{*/
+void SeqVec::Set(IssmDouble value){
 
 	int i;
@@ -144,6 +144,6 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::AXPY{{{1*/
-void SeqVec::AXPY(SeqVec* X, double a){
+/*FUNCTION SeqVec::AXPY{{{*/
+void SeqVec::AXPY(SeqVec* X, IssmDouble a){
 
 	int i;
@@ -154,6 +154,6 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::AYPX{{{1*/
-void SeqVec::AYPX(SeqVec* X, double a){
+/*FUNCTION SeqVec::AYPX{{{*/
+void SeqVec::AYPX(SeqVec* X, IssmDouble a){
 	
 	int i;
@@ -164,12 +164,12 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::ToMPISerial{{{1*/
-double* SeqVec::ToMPISerial(void){
-
-	double* buffer=NULL;
+/*FUNCTION SeqVec::ToMPISerial{{{*/
+IssmDouble* SeqVec::ToMPISerial(void){
+
+	IssmDouble* buffer=NULL;
 
 	if(this->M){
-		buffer=(double*)xmalloc(this->M*sizeof(double));
-		memcpy(buffer,this->vector,this->M*sizeof(double));
+		buffer=xNew<IssmDouble>(this->M);
+		xMemCpy<IssmDouble>(buffer,this->vector,this->M);
 	}
 	return buffer;
@@ -177,5 +177,5 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::Copy{{{1*/
+/*FUNCTION SeqVec::Copy{{{*/
 void SeqVec::Copy(SeqVec* to){
 
@@ -187,8 +187,8 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::Norm{{{1*/
-double SeqVec::Norm(NormMode mode){
-
-	double norm;
+/*FUNCTION SeqVec::Norm{{{*/
+IssmDouble SeqVec::Norm(NormMode mode){
+
+	IssmDouble norm;
 	int i;
 
@@ -204,11 +204,11 @@
 			break;
 		default:
-			_error_("unknown norm !");
-			break;
-	}
-}
-/*}}}*/
-/*FUNCTION SeqVec::Scale{{{1*/
-void SeqVec::Scale(double scale_factor){
+			_error2_("unknown norm !");
+			break;
+	}
+}
+/*}}}*/
+/*FUNCTION SeqVec::Scale{{{*/
+void SeqVec::Scale(IssmDouble scale_factor){
 
 	int i;
@@ -217,10 +217,10 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::Dot{{{1*/
-double SeqVec::Dot(SeqVec* input){
-
-	int i;
-
-	double dot=0;
+/*FUNCTION SeqVec::Dot{{{*/
+IssmDouble SeqVec::Dot(SeqVec* input){
+
+	int i;
+
+	IssmDouble dot=0;
 	for(i=0;i<this->M;i++)dot+=this->vector[i]*input->vector[i];
 	return dot;
@@ -228,5 +228,5 @@
 }
 /*}}}*/
-/*FUNCTION SeqVec::PointwiseDivide{{{1*/
+/*FUNCTION SeqVec::PointwiseDivide{{{*/
 void SeqVec::PointwiseDivide(SeqVec* x,SeqVec* y){
 
Index: /issm/trunk/src/c/toolkits/issm/SeqVec.h
===================================================================
--- /issm/trunk/src/c/toolkits/issm/SeqVec.h	(revision 12705)
+++ /issm/trunk/src/c/toolkits/issm/SeqVec.h	(revision 12706)
@@ -1,4 +1,4 @@
 /*!\file:  SeqVec.h
- * \brief wrapper to our SeqVec object, which is just a wrapper to a double* 
+ * \brief wrapper to our SeqVec object, which is just a wrapper to a IssmDouble* 
  */ 
 
@@ -7,5 +7,5 @@
 
 /*Headers:*/
-/*{{{1*/
+/*{{{*/
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
@@ -22,31 +22,31 @@
 	public:
 	
-		double* vector;
+		IssmDouble* vector;
 		int M;
 
-		/*SeqVec constructors, destructors {{{1*/
+		/*SeqVec constructors, destructors {{{*/
 		SeqVec();
 		SeqVec(int M,bool fromlocalsize=false);
-		SeqVec(double* buffer, int M);
+		SeqVec(IssmDouble* buffer, int M);
 		~SeqVec();
 		/*}}}*/
-		/*SeqVec specific routines {{{1*/
+		/*SeqVec specific routines {{{*/
 		void Echo(void);
 		void Assemble(void);
-		void SetValues(int ssize, int* list, double* values, InsMode mode);
-		void SetValue(int dof, double value, InsMode  mode);
-		void GetValue(double* pvalue, int dof);
+		void SetValues(int ssize, int* list, IssmDouble* values, InsMode mode);
+		void SetValue(int dof, IssmDouble value, InsMode  mode);
+		void GetValue(IssmDouble* pvalue, int dof);
 		void GetSize(int* pM);
 		void GetLocalSize(int* pM);
 		SeqVec* Duplicate(void);
-		void Set(double value);
-		void AXPY(SeqVec* X, double a);
-		void AYPX(SeqVec* X, double a);
-		double* ToMPISerial(void);
+		void Set(IssmDouble value);
+		void AXPY(SeqVec* X, IssmDouble a);
+		void AYPX(SeqVec* X, IssmDouble a);
+		IssmDouble* ToMPISerial(void);
 		void Copy(SeqVec* to);
-		double Norm(NormMode norm_type);
-		void Scale(double scale_factor);
+		IssmDouble Norm(NormMode norm_type);
+		void Scale(IssmDouble scale_factor);
 		void PointwiseDivide(SeqVec* x,SeqVec* y);
-		double Dot(SeqVec* vector);
+		IssmDouble Dot(SeqVec* vector);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/toolkits/issm/issmtoolkit.h
===================================================================
--- /issm/trunk/src/c/toolkits/issm/issmtoolkit.h	(revision 12705)
+++ /issm/trunk/src/c/toolkits/issm/issmtoolkit.h	(revision 12706)
@@ -6,4 +6,6 @@
 #define _ISSM_TOOLKIT_H_
 
+#include "../../include/include.h"
+
 #include "./SeqMat.h"
 #include "./SeqVec.h"
Index: /issm/trunk/src/c/toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp	(revision 12706)
@@ -13,5 +13,5 @@
 	METIS_PartMeshNodal(pnumberofelements,pnumberofnodes, index, petype, pnumflag, pnum_procs, pedgecut, epart, npart); 
 	#elif _METIS_VERSION_ == 5
-	/*This interface is heavily changed. More options, different way of meshing, etc ...: */ 
+	/*This interface is heavily changed. More options, different ways of meshing, etc ...: */ 
 	int i;
 
@@ -21,6 +21,4 @@
 	idx_t  k=0;
 	real_t* tpwgts=NULL;
-
-
 
 	/*setup options: */
@@ -40,7 +38,6 @@
 	options[METIS_OPTION_NCUTS]   = 1;
 
-
 	/*create eptr: */
-	eptr=(idx_t*)xmalloc((*pnumberofelements+1)*sizeof(idx_t));
+	eptr=xNew<idx_t>((*pnumberofelements+1));
 	eptr[0]=0;
 	for(i=0;i<*pnumberofelements;i++){
@@ -49,19 +46,15 @@
 	}
 
-
 	/*create tpwgts: */
-	tpwgts=(real_t*)xmalloc(*pnum_procs*sizeof(real_t));
+	tpwgts=xNew<real_t>(*pnum_procs);
 	for(i=0;i<*pnum_procs;i++){
 		tpwgts[i]=1.0/(*pnum_procs);
 	}
 
-
 	METIS_PartMeshNodal(pnumberofelements,pnumberofnodes, eptr, index,
-			NULL, NULL, pnum_procs, tpwgts, options, &objval,
-			epart, npart);
-	
+			NULL, NULL, pnum_procs, tpwgts, options, &objval,epart, npart);
 
 	#else
-	_error_("METIS version not supported yet");
+	_error2_("METIS version not supported yet");
 	#endif
 }
Index: /issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp	(revision 12706)
@@ -5,6 +5,4 @@
 #include <stdio.h>
 #include <math.h>
-
-
 #include "../../../shared/shared.h"
 
@@ -24,8 +22,7 @@
 	
 	/*We are  not bound by any library, just use what seems most logical*/
-	num_local_rows=(int*)xmalloc(num_procs*sizeof(int));    
+	num_local_rows=xNew<int>(num_procs);    
 
 	for (i=0;i<num_procs;i++){
-
 		/*Here, we use floor. We under distribute rows. The rows 
 		  left  are then redistributed, therefore resulting in a 
@@ -39,9 +36,8 @@
 		num_local_rows[i]++;
 	}
-
 	local_size=num_local_rows[my_rank];
 	
 	/*free ressources: */
-	xfree((void**)&num_local_rows);
+	xDelete<int>(num_local_rows);
 
 	/*return size: */
Index: /issm/trunk/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp	(revision 12706)
@@ -20,7 +20,6 @@
 
 	/*Gather all range values into allranges, for all nodes*/
-	allranges=(int*)xmalloc(num_procs*sizeof(int));
+	allranges=xNew<int>(num_procs);
 	MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,MPI_COMM_WORLD);
-
 
 	/*From all ranges, get lower row and upper row*/
@@ -31,12 +30,9 @@
 		upper_row=upper_row+allranges[i];
 	}
-	
-	/*free: */
-	xfree((void**)&allranges);
 
 	/*Assign output pointers: */
+	xDelete<int>(allranges);
 	*plower_row=lower_row;
 	*pupper_row=upper_row;
-
 	return 1;
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp	(revision 12706)
@@ -28,5 +28,5 @@
 
 	/*Gather all range values into allranges, for all nodes*/
-	allranges=(int*)xmalloc(num_procs*sizeof(int));
+	allranges=xNew<int>(num_procs);
 	MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,MPI_COMM_WORLD);
 
@@ -42,7 +42,4 @@
 	*plower_row=lower_row;
 	*pupper_row=upper_row;
-
-	/*Free ressources:*/
-	xfree((void**)&allranges);
-
+	xDelete<int>(allranges);
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp	(revision 12706)
@@ -30,5 +30,5 @@
 			break;
 		default: 
-			_error_("unknown insert mode!");
+			_error2_("unknown insert mode!");
 			break;
 	}
Index: /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp	(revision 12706)
@@ -30,5 +30,5 @@
 			break;
 		default: 
-			_error_("unknown matrix type !");
+			_error2_("unknown matrix type !");
 			break;
 	}
Index: /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp	(revision 12706)
@@ -30,5 +30,5 @@
 			break;
 		default: 
-			_error_("unknown norm !");
+			_error2_("unknown norm !");
 			break;
 	}
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp	(revision 12706)
@@ -29,5 +29,5 @@
 	/*Some checks: */
 	MatGetSize(matrix,&M,&N);
-	if(M!=N) _error_("trying to invert a non square matrix!");
+	if(M!=N) _error2_("trying to invert a non square matrix!");
 
 	/*Create identitiy matrix: */
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp	(revision 12706)
@@ -64,5 +64,5 @@
 	}
 	else{
-		result=1;\
+		result=1;
 	}
 	return result;
@@ -89,6 +89,6 @@
 	range=upper_row-lower_row+1;
 	if (range){
-		index=(int*)xmalloc(range*sizeof(int));
-		values=(double*)xmalloc(range*sizeof(double));
+		index=xNew<int>(range);
+		values=xNew<double>(range);
 		for (int i=0;i<range;i++){
 			*(index+i)=lower_row+i;
@@ -103,6 +103,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&index);
-	xfree((void**)&values);	
+	xDelete<int>(index);
+	xDelete<double>(values);	
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 12706)
@@ -62,5 +62,5 @@
 		}
 		else{
-			_error_("MatType %s not supported yet",type);
+			_error2_("MatType " << type << " not supported yet");
 		}
 		/*Assemble*/
@@ -77,5 +77,5 @@
 		count=0;
 		if (range){
-			node_rows=(int*)xmalloc(range*sizeof(int)); //this is the maximum number of rows one node can extract.
+			node_rows=xNew<int>(range); //this is the maximum number of rows one node can extract.
 		
 			for (i=0;i<row_partition_vector_size;i++){
@@ -98,5 +98,5 @@
 		
 		/*Same deal for columns*/
-		node_cols=(int*)xmalloc(col_partition_vector_size*sizeof(int));
+		node_cols=xNew<int>(col_partition_vector_size);
 		for (i=0;i<col_partition_vector_size;i++){
 			*(node_cols+i)=(int)*(col_partition_vector+i)-1;
@@ -128,6 +128,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&node_rows);
-	xfree((void**)&node_cols);
+	xDelete<int>(node_rows);
+	xDelete<int>(node_cols);
 	ISFree(&col_index);
 	ISFree(&row_index);
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp	(revision 12706)
@@ -32,5 +32,4 @@
 	double* outmatrix=NULL;
 	
-	
 	/*get matrix size: */
 	MatGetSize(matrix,&M,&N);
@@ -42,10 +41,10 @@
 	
 	/*Local and global allocation*/
-	if (my_rank==0)outmatrix=(double*)xmalloc(M*N*sizeof(double));
+	if (my_rank==0)outmatrix=xNew<double>(M*N);
 	
 	if (range){
-		local_matrix=(double*)xmalloc(N*range*sizeof(double));
-		idxm=(int*)xmalloc(range*sizeof(int));  
-		idxn=(int*)xmalloc(N*sizeof(int));  
+		local_matrix=xNew<double>(N*range);
+		idxm=xNew<int>(range);  
+		idxn=xNew<int>(N);  
 	 
 		for (i=0;i<N;i++){
@@ -78,13 +77,10 @@
 		//Still have the local_matrix on node 0 to take care of.
 		memcpy(outmatrix,local_matrix,N*range*sizeof(double));
-
 	} 
 	
 	/*Assign output pointer: */
 	*poutmatrix=outmatrix;
-	
-	xfree((void**)&idxm);
-	xfree((void**)&idxn);
-	xfree((void**)&local_matrix);
-
+	xDelete<int>(idxm);
+	xDelete<int>(idxn);
+	xDelete<double>(local_matrix);
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 12706)
@@ -20,5 +20,5 @@
 #include "../../mpi/patches/mpipatches.h"
 
-/*NewMat(int M,int N){{{1*/
+/*NewMat(int M,int N){{{*/
 Mat NewMat(int M,int N){
 
@@ -48,5 +48,5 @@
 }
 /*}}}*/
-/*NewMat(int M,int N,double sparsity){{{1*/
+/*NewMat(int M,int N,double sparsity){{{*/
 Mat NewMat(int M,int N,double sparsity){
 
@@ -81,5 +81,5 @@
 }
 /*}}}*/
-/*NewMat(int M,int N,int connectivity,int numberofdofspernode){{{1*/
+/*NewMat(int M,int N,int connectivity,int numberofdofspernode){{{*/
 Mat NewMat(int M,int N,int connectivity,int numberofdofspernode){
 
Index: /issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp	(revision 12706)
@@ -36,12 +36,15 @@
 	MatGetSize(petsc_matrix,&rows,&cols);
 
-	idxm=(int*)xmalloc(rows*sizeof(int));
-	idxn=(int*)xmalloc(cols*sizeof(int));
+	idxm=xNew<int>(rows);
+	idxn=xNew<int>(cols);
 
 	for(i=0;i<rows;i++)idxm[i]=i;
 	for(i=0;i<cols;i++)idxn[i]=i;
 
-	matrix=(double*)xmalloc(rows*cols*sizeof(double));
+	matrix=xNew<double>(rows*cols);
 	MatGetValues(petsc_matrix,rows,idxm,cols,idxn,matrix);
+
+	xDelete<int>(idxm);
+	xDelete<int>(idxn);
 
 	/*Assign output pointers: */
Index: /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp	(revision 12706)
@@ -55,5 +55,5 @@
 			if(first[0]!='-'){
 				/*This is not good, the option does not have '-'! Get out*/
-				_error_("%s%s%s","Option ",first," should be preceded by '-'!");
+				_error2_("Option " << first << " should be preceded by '-'!");
 			}
 			/*Reduce first to bare option value*/
Index: /issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp	(revision 12706)
@@ -28,9 +28,9 @@
 		VecGetSize(petsc_vector,&rows);
 		if(rows){
-			idxm=(int*)xmalloc(rows*sizeof(int));
-			vector=(double*)xmalloc(rows*sizeof(double));
+			idxm=xNew<int>(rows);
+			vector=xNew<double>(rows);
 			for(i=0;i<rows;i++)idxm[i]=i;
-
 			VecGetValues(petsc_vector,rows,idxm,vector);
+			xDelete<int>(idxm);
 		}
 	}
Index: /issm/trunk/src/c/toolkits/petsc/patches/SerialToVec.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/SerialToVec.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/SerialToVec.cpp	(revision 12706)
@@ -38,6 +38,6 @@
 
 	if (range){
-		idxn=(int*)xmalloc(range*sizeof(int)); 
-		values=(double*)xmalloc(range*sizeof(double));
+		idxn=xNew<int>(range); 
+		values=xNew<double>(range);
 		for (i=0;i<range;i++){
 			idxn[i]=lower_row+i;
@@ -54,6 +54,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&idxn);
-	xfree((void**)&values);
+	xDelete<int>(idxn);
+	xDelete<double>(values);
 
 	return outvector;
Index: /issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp	(revision 12706)
@@ -35,5 +35,5 @@
 	/*If the dimension of the partitioning vector is not the same as that of vector B, we have a problem: */
 	if ( (row_partition_size !=MB) ){
-		_error_("Dimensions of partitioning vector incompatible with dimensions of input vector\n");
+		_error2_("Dimensions of partitioning vector incompatible with dimensions of input vector\n");
 	}
 
@@ -45,6 +45,6 @@
 	if (range){
 		/*This node owns rows of vector B, get them*/
-		idxm=(int*)xmalloc(range*sizeof(int));
-		values=(double*)xmalloc(range*sizeof(double));
+		idxm=xNew<int>(range);
+		values=xNew<double>(range);
 		for (i=0;i<range;i++){
 			*(idxm+i)=lower_row+i;
@@ -63,6 +63,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&idxm);
-	xfree((void**)&values);
-
+	xDelete<int>(idxm);
+	xDelete<double>(values);
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/VecPartition.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/VecPartition.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/VecPartition.cpp	(revision 12706)
@@ -56,5 +56,5 @@
 
 		if (range){
-			node_rows=(int*)xmalloc(range*sizeof(int)); //this is the maximum number of rows one node can extract.
+			node_rows=xNew<int>(range); //this is the maximum number of rows one node can extract.
 		
 			count=0;
@@ -71,8 +71,8 @@
 					
      	if (count){
-			values=(double*)xmalloc(count*sizeof(double)); //holder for the values to be extracted from vectorA
+			values=xNew<double>(count); //holder for the values to be extracted from vectorA
 		}
 		else{
-			xfree((void**)&node_rows); //count=0 means no values was condensed out for this node. null node_rows for use in VecGetValues.
+			xDelete<int>(node_rows); //count=0 means no values was condensed out for this node. null node_rows for use in VecGetValues.
 			values=NULL;
 		}
@@ -110,13 +110,9 @@
 		VecAssemblyBegin(outvector);
 		VecAssemblyEnd(outvector);
-		
 	}
 	
 	/*Assign output pointers:*/
 	*poutvector=outvector;
-
-	/*Free ressources:*/
-	xfree((void**)&node_rows);
-	xfree((void**)&values);
-
+	xDelete<int>(node_rows);
+	xDelete<double>(values);
 }
Index: /issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	(revision 12706)
@@ -42,5 +42,5 @@
 
 	/*Allocate gathered vector on all nodes .*/
-	gathered_vector=(double*)xmalloc(vector_size*sizeof(double));
+	gathered_vector=xNew<double>(vector_size);
 	
 	/*Allocate local vectors*/
@@ -50,9 +50,9 @@
 
 	if (range){
-		idxn=(int*)xmalloc(range*sizeof(int)); 
+		idxn=xNew<int>(range); 
 		for (i=0;i<range;i++){
 			*(idxn+i)=lower_row+i;
 		} 
-		local_vector=(double*)xmalloc(range*sizeof(double));
+		local_vector=xNew<double>(range);
 		/*Extract values from MPI vector to serial local_vector on each node*/
 		VecGetValues(vector,range,idxn,local_vector); 
@@ -87,6 +87,6 @@
 	
 	/*free ressources: */
-	xfree((void**)&idxn);
-	xfree((void**)&local_vector);
+	xDelete<int>(idxn);
+	xDelete<double>(local_vector);
 	
 	return 1;
Index: /issm/trunk/src/c/toolkits/petsc/patches/VecTranspose.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/VecTranspose.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/petsc/patches/VecTranspose.cpp	(revision 12706)
@@ -33,11 +33,11 @@
 
 	if (range){
-		idxm=(int*)xmalloc(range*sizeof(int)); 
-		tidxm=(int*)xmalloc(range*sizeof(int)); 
+		idxm=xNew<int>(range); 
+		tidxm=xNew<int>(range); 
 		for (i=0;i<range;i++){
 			*(idxm+i)=lower_row+i;
 		} 
-		values=(double*)xmalloc(range*sizeof(double));
-		tvalues=(double*)xmalloc(range*sizeof(double));
+		values=xNew<double>(range);
+		tvalues=xNew<double>(range);
 		
 		VecGetValues(vector,range,idxm,values);
@@ -56,8 +56,8 @@
 
 	/*Free ressources: */
-	xfree((void**)&idxm);
-	xfree((void**)&values);
-	xfree((void**)&tidxm);
-	xfree((void**)&tvalues);
+	xDelete<int>(idxm);
+	xDelete<double>(values);
+	xDelete<int>(tidxm);
+	xDelete<double>(tvalues);
 
 	/*Assign output pointers: */
Index: /issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp	(revision 12706)
@@ -44,5 +44,5 @@
 	int i;
 
-	decomp=xmalloc(input*sizeof(int));
+	decomp=xNew<int>(input);
 	*decomp=input;
 	for (i=0;i<input;i++){
@@ -57,5 +57,4 @@
 		}
 	}
-
 	*pdecomp=decomp;
 }
Index: /issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp	(revision 12706)
@@ -13,13 +13,11 @@
 #include "../../scalapack/FortranMapping.h"
 
-void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,
-		int** pidxnA,MPI_Comm* pcomm_2d);
+void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,int** pidxnA,MPI_Comm* pcomm_2d);
 	
 int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con){ 
-	/*inv_A does not yet exist, inv_A was just xmalloced, that's all*/
+	/*inv_A does not yet exist, inv_A was just allocated, that's all*/
 
 	/*Error management*/
 	int i,j;
-	
 
 	/*input*/
@@ -53,5 +51,5 @@
 
 	/*Some dimensions checks: */
-	if (mA!=nA) _error_(" trying to take the invert of a non-square matrix!");
+	if (mA!=nA) _error2_("trying to take the invert of a non-square matrix!");
 
 	/* Set default Plapack parameters */
@@ -94,5 +92,4 @@
 	/* Set the datatype */
 	datatype = MPI_DOUBLE;
-
 	
 	/* Copy A into a*/
@@ -104,6 +101,6 @@
 	upper_row--; 
 	range=upper_row-lower_row+1;
-	arrayA=xmalloc(nA*sizeof(double));
-	idxnA=xmalloc(nA*sizeof(int));
+	arrayA = xNew<double>(nA);
+	idxnA  = xNew<int>(nA);
 	for (i=0;i<nA;i++){
 		*(idxnA+i)=i;
@@ -128,10 +125,9 @@
 	PLA_Obj_free(&a);
 	PLA_Temp_free(&templ);
-	xfree((void**)&arrayA);
-	xfree((void**)&idxnA);
+	xDelete<double>(arrayA);
+	xDelete<int>(idxnA);
 	
 	/*Finalize PLAPACK*/
 	PLA_Finalize();
 	MPI_Comm_free(&comm_2d);
-
 }
Index: /issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp	(revision 12705)
+++ /issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp	(revision 12706)
@@ -45,6 +45,6 @@
 	
 	/*Vector physically based block cyclic distribution: */
-	row_nodes=xmalloc(mA*sizeof(int));
-	col_nodes=xmalloc(nA*sizeof(int));
+	row_nodes=xNew<int>(mA);
+	col_nodes=xNew<int>(nA);
 	for (i=0;i<mA;i++){
 		i0=i/nb;
@@ -60,5 +60,5 @@
 	PLA_Temp_comm_col_rank(templ,&myrow);
 
-	idxm=xmalloc(mA*sizeof(int));
+	idxm=xNew<int>(mA);
 	count=0;
 	for (i=0;i<mA;i++){
@@ -70,5 +70,5 @@
 	idxm_count=count;
 
-	idxn=xmalloc(nA*sizeof(int));
+	idxn=xNew<int>(nA);
 	count=0;
 	for (i=0;i<nA;i++){
@@ -92,7 +92,7 @@
 
 	/*Free ressources:*/
-	xfree((void**)&row_nodes);
-	xfree((void**)&col_nodes);
-	xfree((void**)&idxm);
-	xfree((void**)&idxn);
+	xDelete<int>(row_nodes);
+	xDelete<int>(col_nodes);
+	xDelete<int>(idxm);
+	xDelete<int>(idxn);
 }
Index: /issm/trunk/src/dox/issm.dox
===================================================================
--- /issm/trunk/src/dox/issm.dox	(revision 12705)
+++ /issm/trunk/src/dox/issm.dox	(revision 12706)
@@ -46,11 +46,11 @@
 </th>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">508</td><td  bgcolor=#FFFFFF style="text-align:right;">14595</td><td  bgcolor=#FFFFFF style="text-align:right;">16762</td><td  bgcolor=#FFFFFF style="text-align:right;">56034</td><td  bgcolor=#FFFFFF style="text-align:right;">87391</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">508</td><td  bgcolor=#FFFFFF style="text-align:right;">14595</td><td  bgcolor=#FFFFFF style="text-align:right;">16762</td><td  bgcolor=#FFFFFF style="text-align:right;">56036</td><td  bgcolor=#FFFFFF style="text-align:right;">87393</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">926</td><td  bgcolor=#C6E2FF style="text-align:right;">6911</td><td  bgcolor=#C6E2FF style="text-align:right;">13305</td><td  bgcolor=#C6E2FF style="text-align:right;">30623</td><td  bgcolor=#C6E2FF style="text-align:right;">50839</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">925</td><td  bgcolor=#C6E2FF style="text-align:right;">6851</td><td  bgcolor=#C6E2FF style="text-align:right;">13228</td><td  bgcolor=#C6E2FF style="text-align:right;">30468</td><td  bgcolor=#C6E2FF style="text-align:right;">50547</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">378</td><td  bgcolor=#FFFFFF style="text-align:right;">2754</td><td  bgcolor=#FFFFFF style="text-align:right;">2625</td><td  bgcolor=#FFFFFF style="text-align:right;">9801</td><td  bgcolor=#FFFFFF style="text-align:right;">15180</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">378</td><td  bgcolor=#FFFFFF style="text-align:right;">2758</td><td  bgcolor=#FFFFFF style="text-align:right;">2612</td><td  bgcolor=#FFFFFF style="text-align:right;">9818</td><td  bgcolor=#FFFFFF style="text-align:right;">15188</td>
 </tr>
 <tr>
@@ -58,5 +58,5 @@
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> Python </th><td  bgcolor=#FFFFFF style="text-align:right;">54</td><td  bgcolor=#FFFFFF style="text-align:right;">404</td><td  bgcolor=#FFFFFF style="text-align:right;">799</td><td  bgcolor=#FFFFFF style="text-align:right;">1435</td><td  bgcolor=#FFFFFF style="text-align:right;">2638</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> Python </th><td  bgcolor=#FFFFFF style="text-align:right;">53</td><td  bgcolor=#FFFFFF style="text-align:right;">400</td><td  bgcolor=#FFFFFF style="text-align:right;">610</td><td  bgcolor=#FFFFFF style="text-align:right;">1424</td><td  bgcolor=#FFFFFF style="text-align:right;">2434</td>
 </tr>
 <tr>
@@ -64,8 +64,8 @@
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#FFFFFF style="text-align:right;">6</td><td  bgcolor=#FFFFFF style="text-align:right;">47</td><td  bgcolor=#FFFFFF style="text-align:right;">73</td><td  bgcolor=#FFFFFF style="text-align:right;">241</td><td  bgcolor=#FFFFFF style="text-align:right;">361</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> Perl </th><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">21</td><td  bgcolor=#FFFFFF style="text-align:right;">23</td><td  bgcolor=#FFFFFF style="text-align:right;">240</td><td  bgcolor=#FFFFFF style="text-align:right;">284</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> Perl </th><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">21</td><td  bgcolor=#C6E2FF style="text-align:right;">23</td><td  bgcolor=#C6E2FF style="text-align:right;">240</td><td  bgcolor=#C6E2FF style="text-align:right;">284</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">5</td><td  bgcolor=#C6E2FF style="text-align:right;">47</td><td  bgcolor=#C6E2FF style="text-align:right;">75</td><td  bgcolor=#C6E2FF style="text-align:right;">239</td><td  bgcolor=#C6E2FF style="text-align:right;">361</td>
 </tr>
 <tr>
@@ -73,17 +73,8 @@
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> XML </th><td  bgcolor=#C6E2FF style="text-align:right;">8</td><td  bgcolor=#C6E2FF style="text-align:right;">37</td><td  bgcolor=#C6E2FF style="text-align:right;">121</td><td  bgcolor=#C6E2FF style="text-align:right;">85</td><td  bgcolor=#C6E2FF style="text-align:right;">243</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> C </th><td  bgcolor=#C6E2FF style="text-align:right;">1</td><td  bgcolor=#C6E2FF style="text-align:right;">2</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">6</td><td  bgcolor=#C6E2FF style="text-align:right;">11</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> Java </th><td  bgcolor=#FFFFFF style="text-align:right;">5</td><td  bgcolor=#FFFFFF style="text-align:right;">17</td><td  bgcolor=#FFFFFF style="text-align:right;">42</td><td  bgcolor=#FFFFFF style="text-align:right;">61</td><td  bgcolor=#FFFFFF style="text-align:right;">120</td>
-</tr>
-<tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> D </th><td  bgcolor=#C6E2FF style="text-align:right;">7</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">0</td><td  bgcolor=#C6E2FF style="text-align:right;">27</td><td  bgcolor=#C6E2FF style="text-align:right;">30</td>
-</tr>
-<tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C </th><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">4</td><td  bgcolor=#FFFFFF style="text-align:right;">35</td><td  bgcolor=#FFFFFF style="text-align:right;">21</td><td  bgcolor=#FFFFFF style="text-align:right;">60</td>
-</tr>
-<tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> SUM: </th><td  bgcolor=#C6E2FF style="text-align:right;">1915</td><td  bgcolor=#C6E2FF style="text-align:right;">25906</td><td  bgcolor=#C6E2FF style="text-align:right;">33869</td><td  bgcolor=#C6E2FF style="text-align:right;">107321</td><td  bgcolor=#C6E2FF style="text-align:right;">167096</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1890</td><td  bgcolor=#FFFFFF style="text-align:right;">25787</td><td  bgcolor=#FFFFFF style="text-align:right;">33397</td><td  bgcolor=#FFFFFF style="text-align:right;">106984</td><td  bgcolor=#FFFFFF style="text-align:right;">166168</td>
 </tr>
 </table>
Index: /issm/trunk/src/m/classes/autodiff.m
===================================================================
--- /issm/trunk/src/m/classes/autodiff.m	(revision 12705)
+++ /issm/trunk/src/m/classes/autodiff.m	(revision 12706)
@@ -22,5 +22,5 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 		end % }}}
Index: /issm/trunk/src/m/classes/balancethickness.m
===================================================================
--- /issm/trunk/src/m/classes/balancethickness.m	(revision 12705)
+++ /issm/trunk/src/m/classes/balancethickness.m	(revision 12706)
@@ -25,11 +25,11 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 			%Early return
 			if solution~=BalancethicknessSolutionEnum, return; end
 
-			checkfield(md,'balancethickness.spcthickness','forcing',1);
-			checkfield(md,'balancethickness.thickening_rate','size',[md.mesh.numberofvertices 1],'NaN',1);
-			checkfield(md,'balancethickness.stabilization','size',[1 1],'values',[0 1 2 3]);
+			md = checkfield(md,'balancethickness.spcthickness','forcing',1);
+			md = checkfield(md,'balancethickness.thickening_rate','size',[md.mesh.numberofvertices 1],'NaN',1);
+			md = checkfield(md,'balancethickness.stabilization','size',[1 1],'values',[0 1 2 3]);
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/bamggeom.m
===================================================================
--- /issm/trunk/src/m/classes/bamggeom.m	(revision 12705)
+++ /issm/trunk/src/m/classes/bamggeom.m	(revision 12706)
@@ -6,5 +6,5 @@
 classdef bamggeom
 	properties (SetAccess=public) 
-		% {{{1
+		% {{{
 		Vertices=[];
 		Edges=[];
@@ -18,5 +18,5 @@
 	end
 	methods
-		function bg = bamggeom(varargin)% {{{1
+		function bg = bamggeom(varargin)% {{{
 		%BAMGGEOM - constructor for bamggeom object
 		%
@@ -44,5 +44,5 @@
 			end
 		end%}}}
-		function display(bg)% {{{1
+		function display(bg)% {{{
 			disp(sprintf('\n%s = \n',inputname(1)));
 			disp(struct(bg))
Index: /issm/trunk/src/m/classes/bamgmesh.m
===================================================================
--- /issm/trunk/src/m/classes/bamgmesh.m	(revision 12705)
+++ /issm/trunk/src/m/classes/bamgmesh.m	(revision 12706)
@@ -6,5 +6,5 @@
 classdef bamgmesh
 	properties (SetAccess=public) 
-		% {{{1
+		% {{{
 		Vertices=[];
 		Edges=[];
@@ -26,5 +26,5 @@
 	end
 	methods
-		function bg = bamgmesh(varargin)% {{{1
+		function bg = bamgmesh(varargin)% {{{
 
 		switch nargin
@@ -48,5 +48,5 @@
 			end
 		end%}}}
-		function display(bm)% {{{1
+		function display(bm)% {{{
 			disp(sprintf('\n%s = \n',inputname(1)));
 			disp(struct(bm))
Index: /issm/trunk/src/m/classes/basalforcings.m
===================================================================
--- /issm/trunk/src/m/classes/basalforcings.m	(revision 12705)
+++ /issm/trunk/src/m/classes/basalforcings.m	(revision 12706)
@@ -22,15 +22,15 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			if ismember(PrognosticAnalysisEnum,analyses) & ~(solution==TransientSolutionEnum & md.transient.isprognostic==0),
-				checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
+				md = checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
 			end
 			if ismember(BalancethicknessAnalysisEnum,analyses),
-				checkfield(md,'basalforcings.melting_rate','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'basalforcings.melting_rate','NaN',1,'size',[md.mesh.numberofvertices 1]);
 			end
 			if ismember(ThermalAnalysisEnum,analyses) & ~(solution==TransientSolutionEnum & md.transient.isthermal==0),
-				checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
-				checkfield(md,'basalforcings.geothermalflux','NaN',1,'forcing',1,'>=',0);
+				md = checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
+				md = checkfield(md,'basalforcings.geothermalflux','NaN',1,'forcing',1,'>=',0);
 			end
 		end % }}}
Index: /issm/trunk/src/m/classes/clusters/acenet.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/acenet.m	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/acenet.m	(revision 12706)
@@ -8,5 +8,5 @@
 classdef acenet
     properties (SetAccess=public) 
-		 % {{{1
+		 % {{{
 		 name='glacdyn.ace-net.ca'
 		 %name='placentia.ace-net.ca'
@@ -23,5 +23,5 @@
 	 end
 	 methods
-		 function cluster=acenet(varargin) % {{{1
+		 function cluster=acenet(varargin) % {{{
 			 %use provided options to change fields
 			 options=pairoptions(varargin{:});
@@ -34,5 +34,5 @@
 		 end
 		 %}}}
-		 function disp(cluster) % {{{1
+		 function disp(cluster) % {{{
 			 %  display the object
 			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
@@ -47,5 +47,5 @@
 		 end
 		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 
 			 available_queues={'debug','shortq','longq'};
@@ -56,23 +56,15 @@
 		 end
 		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
 
-			 %retrieve parameters 
-			 modelname=md.miscellaneous.name; 
-			 solution=md.private.solution;
+			 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
+			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
 
-			 %open file for writing: 
+			 %write queuing script 
 			 fid=fopen([modelname '.queue'],'w');
-
-          %write instructions for launching a job on the cluster
-          % fprintf(fid,'#!/bin/sh\n');
 			 fprintf(fid,'#!/bin/bash\n');
-          %fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
-          %         cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
 			 fprintf(fid,'#$ -cwd\n');
           fprintf(fid,'#$ -N issm\n');
-          %fprintf(fid,'#$ -l h_rt=%i\n',cluster.time);
           fprintf(fid,'#$ -l h_rt=10:0:0\n');
-          %fprintf(fid,'#$ -l h_rt=1:0:0,test=true\n');
           fprintf(fid,'#$ -pe ompi* %i\n',cluster.np);
           fprintf(fid,'#$ -j y\n');
@@ -81,85 +73,37 @@
           fprintf(fid,'module load issm\n');
           fprintf(fid,'\n');
-          %fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
           fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
                    cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
-
-          % fprintf(fid,'#PBS -l select=%i:ncpus=1\n',cluster.np);
-			 % fprintf(fid,'#PBS -N %s\n',modelname);
-			 % fprintf(fid,'#PBS -l walltime=%i\n',time*60); %walltime is in seconds.
-			 % fprintf(fid,'#PBS -q %s\n',queue);
-			 % fprintf(fid,'#PBS -o %s.outlog \n',modelname);
-			 % fprintf(fid,'#PBS -e %s.errlog \n',modelname);
-			 % fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
-			 % fprintf(fid,'cd $PBS_O_WORKDIR\n');
-			 % fprintf(fid,'export OMP_NUM_THREADS=1\n');
-			 % fprintf(fid,'ulimit -s unlimited\n');
-			 % fprintf(fid,'ulimit -c 0\n');
-			 % fprintf(fid,'/opt/mpich/gm/intel10.1/bin/mpiexec -np %i %s/issm.exe %s %s %s',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-
-			 %close file
 			 fclose(fid);
 
 		 end
 		 %}}}
-		 function LaunchQueueJob(cluster,md,options)% {{{1
-			  %retrieve parameters 
-          modelname=md.miscellaneous.name;
-          solution=md.private.solution;
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
 
-			 %lauch command, to be executed via ssh
-			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' modelname '.queue '];
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
 
-			if ~strcmpi(options.batch,'yes'),
-				
-				%compress the files into one zip.
-				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-				if md.qmu.isdakota,
-					compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
-				end
-				system(compressstring);
-				
-				disp('uploading input file and queueing script');
-				issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
-				
-				disp('launching solution sequence on remote cluster');
-				issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
+			 disp('uploading input file and queueing script');
+			 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
 
-			else
-				disp('batch mode requested: not launching job interactively');
-				disp('launch solution sequence on remote cluster by hand');
-			end
+			 disp('launching solution sequence on remote cluster');
+			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+				 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end %}}}
+		 function Download(cluster,dirname,filelist)% {{{
 
-		 end
-		 %}}}
-		 function Download(cluster,md)% {{{1
+			 %copy files from cluster to current directory
+			 directory=[cluster.executionpath '/' dirname '/'];
+			 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
 
-			%some check
-			if isempty(md.private.runtimename),
-				error('pfe Download error message: supply runtime name for results to be loaded!');
-			end
-
-			%Figure out the  directory where all the files are in: 
-			directory=[cluster.executionpath '/' md.private.runtimename '/'];
-
-			%What packages are we picking up from remote cluster
-			packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-			%packages={};
-			if md.qmu.isdakota,
-				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-				if isfield(md.qmu.params,'tabular_graphics_data'),
-					if md.qmu.params.tabular_graphics_data==true,
-						packages{end+1}='dakota_tabular.dat'; 
-					end
-				end
-			else
-				packages{end+1}=[md.miscellaneous.name '.outbin'];
-			end
-
-			%copy files from cluster to present directory
-			issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-		end %}}}
+		 end %}}}
 	end
 end
Index: /issm/trunk/src/m/classes/clusters/castor.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/castor.m	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/castor.m	(revision 12706)
@@ -8,5 +8,5 @@
 classdef castor
     properties (SetAccess=public) 
-		 % {{{1
+		 % {{{
 		 name='castor'
 		 login='username';
@@ -20,9 +20,9 @@
 	 end
 	 methods
-		 function cluster=castor(varargin) % {{{1
+		 function cluster=castor(varargin) % {{{
 			 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
 		 end
 		 %}}}
-		 function disp(cluster) % {{{1
+		 function disp(cluster) % {{{
 			 %  display the object
 			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
@@ -37,5 +37,5 @@
 		 end
 		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 
 			 available_queues={'shortc','longc'};
@@ -46,13 +46,11 @@
 		 end
 		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
 
-			 %retrieve parameters 
-			 modelname=md.miscellaneous.name; 
-			 solution=md.private.solution;
+			 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
+			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
 
-			 %open file for writing: 
+			 %write queuing script 
 			 fid=fopen([modelname '.queue'],'w');
-
 			 fprintf(fid,'#!/bin/sh\n');
 			 fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
@@ -64,70 +62,39 @@
 			 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
 			 fprintf(fid,'#PBS -e %s.errlog \n',modelname);
-
 			 fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
 			 fprintf(fid,'cd $PBS_O_WORKDIR\n');
 			 fprintf(fid,'export OMP_NUM_THREADS=1\n');
 			 fprintf(fid,'dplace -s1 -c0-%i mpiexec -np %i %s/issm.exe %s %s %s',cluster.np-1,cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-
-			 %close file
 			 fclose(fid);
 
 		 end
 		 %}}}
-		 function LaunchQueueJob(cluster,md,options)% {{{1
-			 
-			 %lauch command, to be executed via ssh
-			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' modelname '.queue '];
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
 
-			if ~strcmpi(options.batch,'yes'),
-				
-				%compress the files into one zip.
-				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-				if md.qmu.isdakota,
-					compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
-				end
-				system(compressstring);
-				
-				disp('uploading input file and queueing script');
-				issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
-				
-				disp('launching solution sequence on remote cluster');
-				issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
 
-			else
-				disp('batch mode requested: not launching job interactively');
-				disp('launch solution sequence on remote cluster by hand');
-			end
+			 disp('uploading input file and queueing script');
+			 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
 
-		 end
-		 %}}}
-		 function Download(cluster,md)% {{{1
+			 disp('launching solution sequence on remote cluster');
+			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+				 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end %}}}
+		 function Download(cluster,dirname,filelist)% {{{
 
-			%some check
-			if isempty(md.private.runtimename),
-				error('pfe Download error message: supply runtime name for results to be loaded!');
-			end
+			 %copy files from cluster to current directory
+			 directory=[cluster.executionpath '/' dirname '/'];
+			 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
 
-			%Figure out the  directory where all the files are in: 
-			directory=[cluster.executionpath '/' md.private.runtimename '/'];
-
-			%What packages are we picking up from remote cluster
-			packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-			if md.qmu.isdakota,
-				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-				if isfield(md.qmu.params,'tabular_graphics_data'),
-					if md.qmu.params.tabular_graphics_data==true,
-						packages{end+1}='dakota_tabular.dat'; 
-					end
-				end
-			else
-				packages{end+1}=[md.miscellaneous.name '.outbin'];
-			end
-
-			%copy files from cluster to present directory
-			issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-		end %}}}
+		 end %}}}
 	end
 end
Index: /issm/trunk/src/m/classes/clusters/cosmos.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/cosmos.m	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/cosmos.m	(revision 12706)
@@ -8,5 +8,5 @@
 classdef cosmos
     properties (SetAccess=public) 
-		 % {{{1
+		 % {{{
 		 name='cosmos'
 		 login='username';
@@ -20,9 +20,9 @@
 	 end
 	 methods
-		 function cluster=cosmos(varargin) % {{{1
+		 function cluster=cosmos(varargin) % {{{
 			 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
 		 end
 		 %}}}
-		 function disp(cluster) % {{{1
+		 function disp(cluster) % {{{
 			 %  display the object
 			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
@@ -37,5 +37,5 @@
 		 end
 		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 
 			 available_queues={'debug','shortq','longq'};
@@ -46,13 +46,11 @@
 		 end
 		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
 
-			 %retrieve parameters 
-			 modelname=md.miscellaneous.name; 
-			 solution=md.private.solution;
+			 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
+			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
 
-			 %open file for writing: 
+			 %write queuing script 
 			 fid=fopen([modelname '.queue'],'w');
-
 			 fprintf(fid,'#!/bin/bash\n');
 			 fprintf(fid,'#PBS -l select=%i:ncpus=1\n',cluster.np);
@@ -68,65 +66,35 @@
 			 fprintf(fid,'ulimit -c 0\n');
 			 fprintf(fid,'/opt/mpich/gm/intel10.1/bin/mpiexec -np %i %s/issm.exe %s %s %s',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-
-			 %close file
 			 fclose(fid);
 
 		 end
 		 %}}}
-		 function LaunchQueueJob(cluster,md,options)% {{{1
-			 
-			 %lauch command, to be executed via ssh
-			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub -S/bin/sh ' modelname '.queue '];
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
 
-			if ~strcmpi(options.batch,'yes'),
-				
-				%compress the files into one zip.
-				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-				if md.qmu.isdakota,
-					compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
-				end
-				system(compressstring);
-				
-				disp('uploading input file and queueing script');
-				issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
-				
-				disp('launching solution sequence on remote cluster');
-				issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
 
-			else
-				disp('batch mode requested: not launching job interactively');
-				disp('launch solution sequence on remote cluster by hand');
-			end
+			 disp('uploading input file and queueing script');
+			 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
 
-		 end
-		 %}}}
-		 function Download(cluster,md)% {{{1
+			 disp('launching solution sequence on remote cluster');
+			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+				 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end %}}}
+		 function Download(cluster,dirname,filelist)% {{{
 
-			%some check
-			if isempty(md.private.runtimename),
-				error('pfe Download error message: supply runtime name for results to be loaded!');
-			end
+			 %copy files from cluster to current directory
+			 directory=[cluster.executionpath '/' dirname '/'];
+			 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
 
-			%Figure out the  directory where all the files are in: 
-			directory=[cluster.executionpath '/' md.private.runtimename '/'];
-
-			%What packages are we picking up from remote cluster
-			packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-			if md.qmu.isdakota,
-				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-				if isfield(md.qmu.params,'tabular_graphics_data'),
-					if md.qmu.params.tabular_graphics_data==true,
-						packages{end+1}='dakota_tabular.dat'; 
-					end
-				end
-			else
-				packages{end+1}=[md.miscellaneous.name '.outbin'];
-			end
-
-			%copy files from cluster to present directory
-			issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-		end %}}}
+		 end %}}}
 	end
 end
Index: /issm/trunk/src/m/classes/clusters/discover.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/discover.m	(revision 12706)
+++ /issm/trunk/src/m/classes/clusters/discover.m	(revision 12706)
@@ -0,0 +1,192 @@
+%PFE class definition
+%
+%   Usage:
+%      cluster=discover();
+%      cluster=discover('np',3);
+%      cluster=discover('np',3,'login','username');
+
+classdef discover 
+    properties (SetAccess=public)  
+		 % {{{
+		 name=oshostname();
+		 login='';
+		 numnodes=20;
+		 cpuspernode=8; 
+		 port=1025;
+		 queue='general';
+		 time=12*60;
+		 processor='west';
+		 codepath='';
+		 executionpath='';
+		 interactive=0;
+		 bbftp=0;
+		 numstreams=8;
+		 hyperthreading=0;
+	 end
+	 properties (SetAccess=private) 
+		 np=20*8;
+		 % }}}
+	 end
+	 methods
+		 function cluster=discover(varargin) % {{{
+
+			 %initialize cluster using default settings if provided
+			 if (exist('discover_settings')==2), discover_settings; end
+
+			 %use provided options to change fields
+			 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
+		 end
+		 %}}}
+		 function disp(cluster) % {{{
+			 %  display the object
+			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
+			 disp(sprintf('    name: %s',cluster.name));
+			 disp(sprintf('    login: %s',cluster.login));
+			 disp(sprintf('    port: %i',cluster.port));
+			 disp(sprintf('    numnodes: %i',cluster.numnodes));
+			 disp(sprintf('    cpuspernode: %i',cluster.cpuspernode));
+			 disp(sprintf('    np: %i',cluster.cpuspernode*cluster.numnodes));
+			 disp(sprintf('    queue: %s',cluster.queue));
+			 disp(sprintf('    time: %i',cluster.time));
+			 disp(sprintf('    processor: %s',cluster.processor));
+			 disp(sprintf('    codepath: %s',cluster.codepath));
+			 disp(sprintf('    executionpath: %s',cluster.executionpath));
+			 disp(sprintf('    interactive: %i',cluster.interactive));
+			 disp(sprintf('    hyperthreading: %i',cluster.hyperthreading));
+		 end
+		 %}}}
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
+
+			 available_queues={'general_long','general','general_small','debug'};
+			 queue_requirements_time=[24*60 12*60 12*60 60];
+			 queue_requirements_np=[516 1024 16 32];
+
+			 QueueRequirements(available_queues,queue_requirements_time,queue_requirements_np,cluster.queue,cluster.np,cluster.time)
+
+			 if ( strcmpi(cluster.queue,'general') & cluster.cpuspernode*cluster.numnodes < 17)
+				 md = checkmessage(md,'cpus must be great than 17 for general queue');
+			 end
+			 %now, check cluster.cpuspernode according to processor type
+			 if ( strcmpi(cluster.processor,'neha')),
+				 if ((cluster.cpuspernode>8 ) | (cluster.cpuspernode<1)),
+					 md = checkmessage(md,'cpuspernode should be between 1 and 8 for ''neha'' processors');
+				 end
+			 elseif strcmpi(cluster.processor,'west'),
+				 if ((cluster.cpuspernode>12 ) | (cluster.cpuspernode<1)),
+					 md = checkmessage(md,'cpuspernode should be between 1 and 12 for ''west'' processors');
+				 end
+			 else
+				 md = checkmessage(md,'unknown processor type, should be ''neha'' or ''west'' ');
+			 end
+
+			 %Miscelaneous
+			 if isempty(cluster.login), md = checkmessage(md,'login empty'); end
+			 if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
+			 if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
+
+		 end
+		 %}}}
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
+
+			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
+
+			 %compute number of processors
+			 cluster.np=cluster.numnodes*cluster.cpuspernode;
+
+			 %write queuing script 
+			 fid=fopen([modelname '.queue'],'w');
+			 fprintf(fid,'#PBS -S /bin/bash\n');
+%			 fprintf(fid,'#PBS -N %s\n',modelname);
+			 fprintf(fid,'#PBS -l select=%i:ncpus=%i:proc=%s\n',cluster.numnodes,cluster.cpuspernode,cluster.processor);
+			 fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
+			 fprintf(fid,'#PBS -q %s \n',cluster.queue);
+			 fprintf(fid,'#PBS -W group_list=s1010\n');
+			 fprintf(fid,'#PBS -m e\n');
+			 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
+			 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
+			 fprintf(fid,'. /usr/share/modules/init/bash\n\n');
+			 fprintf(fid,'module load comp/intel-10.1.023\n');
+			 fprintf(fid,'module load mpi/impi-3.2.2.006\n');
+			 fprintf(fid,'module load lib/mkl-10.1.2.024\n\n');
+			 fprintf(fid,'export PATH="$PATH:."\n\n');
+			 fprintf(fid,'export MPI_GROUP_MAX=64\n\n');
+			 fprintf(fid,'cd $PBS_O_WORKDIR\n\n');
+			 fprintf(fid,'mpirun -np %i %s/issm.exe %s $PBS_O_WORKDIR %s\n',cluster.np,cluster.codepath,EnumToString(solution),modelname);
+			 if ~io_gather, %concatenate the output files:
+				 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
+			 end
+			 fclose(fid);
+
+			 %in interactive mode, create a run file, and errlog and outlog file
+			 if cluster.interactive,
+				 fid=fopen([modelname '.run'],'w');
+				 if ~isvalgrind,
+					 fprintf(fid,'mpirun -np %i %s/issm.exe %s $PBS_O_WORKDIR %s\n',cluster.np,cluster.codepath,EnumToString(solution),modelname);
+				 else
+					 fprintf(fid,'mpirun -np %i valgrind --leak-check=full %s/issm.exe %s $PBS_O_WORKDIR %s\n',cluster.np,cluster.codepath,EnumToString(solution),modelname);
+				 end
+				 if ~io_gather, %concatenate the output files:
+					 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
+				 end
+				 fclose(fid);
+				 fid=fopen([modelname '.errlog'],'w');
+				 fclose(fid);
+				 fid=fopen([modelname '.outlog'],'w');
+				 fclose(fid);
+			 end
+		 end %}}}
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
+
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.run '  modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
+
+			 disp('uploading input file and queueing script');
+			 if cluster.interactive,
+				 directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
+			 else 
+				 directory=cluster.executionpath;
+			 end
+
+			 if ~cluster.bbftp,
+				 issmscpout(cluster.name,directory,cluster.login,cluster.port,{[dirname '.tar.gz']});
+			 else
+				 issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[dirname '.tar.gz']});
+			 end
+
+			 %lauch command, to be executed via ssh
+			 if ~cluster.interactive, 
+				 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+					 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
+			 else
+				 launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' dirname '.tar.gz'];
+			 end
+
+			 disp('launching solution sequence on remote cluster');
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end
+		 %}}}
+		 function Download(cluster,dirname,filelist)% {{{
+
+			 %copy files from cluster to current directory
+			 if ~cluster.interactive,
+				 directory=[cluster.executionpath '/' dirname '/'];
+			 else
+				 directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
+			 end
+
+			 if ~cluster.bbftp,
+				 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
+			 else
+				 issmbbftpin(cluster.name, cluster.login, cluster.port, cluster.numstreams, directory, filelist);
+			 end
+
+		 end %}}}
+	end
+end
Index: /issm/trunk/src/m/classes/clusters/gemini.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/gemini.m	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/gemini.m	(revision 12706)
@@ -8,5 +8,5 @@
 classdef gemini
     properties (SetAccess=public) 
-	% {{{1
+	% {{{
 		name='gemini'
 		login='username';
@@ -20,9 +20,9 @@
     end
     methods
-		 function cluster=gemini(varargin) % {{{1
+		 function cluster=gemini(varargin) % {{{
 			 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
 		 end
 		 %}}}
-		 function disp(cluster) % {{{1
+		 function disp(cluster) % {{{
 			 %  display the object
 			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
@@ -37,5 +37,5 @@
 		 end
 		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 
 			 available_queues={'debug','shortg','longg'};
@@ -46,13 +46,11 @@
 		 end
 		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
 
-			 %retrieve parameters 
-			 modelname=md.miscellaneous.name; 
-			 solution=md.private.solution;
+			 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
+			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
 
-			 %open file for writing: 
+			 %write queuing script 
 			 fid=fopen([modelname '.queue'],'w');
-
 			 fprintf(fid,'#!/bin/sh\n');
 			 fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
@@ -69,65 +67,35 @@
 			 fprintf(fid,'export OMP_NUM_THREADS=1\n');
 			 fprintf(fid,'dplace -s1 -c0-%i mpiexec -np %i %s/issm.exe %s %s %s',cluster.np-1,cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-
-			 %close file
 			 fclose(fid);
 
 		 end
 		 %}}}
-		 function LaunchQueueJob(cluster,md,options)% {{{1
-			 
-			 %lauch command, to be executed via ssh
-			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' modelname '.queue '];
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
 
-			if ~strcmpi(options.batch,'yes'),
-				
-				%compress the files into one zip.
-				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-				if md.qmu.isdakota,
-					compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
-				end
-				system(compressstring);
-				
-				disp('uploading input file and queueing script');
-				issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
-				
-				disp('launching solution sequence on remote cluster');
-				issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
 
-			else
-				disp('batch mode requested: not launching job interactively');
-				disp('launch solution sequence on remote cluster by hand');
-			end
+			 disp('uploading input file and queueing script');
+			 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
 
-		 end
-		 %}}}
-		 function Download(cluster,md)% {{{1
+			 disp('launching solution sequence on remote cluster');
+			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+				 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end %}}}
+		 function Download(cluster,dirname,filelist)% {{{
 
-			%some check
-			if isempty(md.private.runtimename),
-				error('pfe Download error message: supply runtime name for results to be loaded!');
-			end
+			 %copy files from cluster to current directory
+			 directory=[cluster.executionpath '/' dirname '/'];
+			 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
 
-			%Figure out the  directory where all the files are in: 
-			directory=[cluster.executionpath '/' md.private.runtimename '/'];
-
-			%What packages are we picking up from remote cluster
-			packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-			if md.qmu.isdakota,
-				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-				if isfield(md.qmu.params,'tabular_graphics_data'),
-					if md.qmu.params.tabular_graphics_data==true,
-						packages{end+1}='dakota_tabular.dat'; 
-					end
-				end
-			else
-				packages{end+1}=[md.miscellaneous.name '.outbin'];
-			end
-
-			%copy files from cluster to present directory
-			issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-		end %}}}
+		 end %}}}
 	end
 end
Index: /issm/trunk/src/m/classes/clusters/generic.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/generic.m	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/generic.m	(revision 12706)
@@ -7,5 +7,5 @@
 classdef generic
     properties (SetAccess=public) 
-		 % {{{1
+		 % {{{
 		 name='';
 		 login='';
@@ -21,5 +21,5 @@
 	 end
 	 methods
-		 function cluster=generic(varargin) % {{{1
+		 function cluster=generic(varargin) % {{{
 
 			 %use provided options to change fields
@@ -36,5 +36,5 @@
 		 end
 		 %}}}
-		 function disp(cluster) % {{{1
+		 function disp(cluster) % {{{
 			 %  display the object
 			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
@@ -50,7 +50,7 @@
 		 end
 		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 			 if cluster.np<1
-				 checkmessage(['number of processors should be at least 1']);
+				 md = checkmessage(md,['number of processors should be at least 1']);
 			 end
 			 if isnan(cluster.np),
@@ -59,72 +59,42 @@
 		 end
 		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
-		 
-			 %retrieve parameters
-			 modelname=md.miscellaneous.name;
-			 solution=md.private.solution;
-			 isvalgrind=md.debug.valgrind;
-			 isgprof=md.debug.gprof;
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
 
-			 %open file for writing: 
+			 %write queuing script 
 			 if ~ispc,
+
 				 fid=fopen([modelname '.queue'],'w');
-			 else
-				 fid=fopen([modelname '.bat'],'w');
-			 end
-
-			 %write instructions for launching a job on the cluster
-			 if ~ispc,
 				 fprintf(fid,'#!/bin/sh\n');
-			 else
-				 fprintf(fid,'@echo off\n');
-			 end
-			 
-			 if ~isvalgrind,
-				 if cluster.interactive
-					 if ~ispc,
+				 if ~isvalgrind,
+					 if cluster.interactive
 						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
 					 else
-						 fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
+						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
 					 end
+				 elseif isgprof,
+					 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
 				 else
-					 if ~ispc,
-						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
-					 else
-						 fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
-					 end
-				 end
-			 else
-				 if ~ispc,
 					 %Add --gen-suppressions=all to get suppression lines
 					 fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
 					 fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
-					 cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+						 cluster.np,cluster.valgrind,cluster.valgrindsup,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+				 end
+				 if ~io_gather, %concatenate the output files:
+					 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
+				 end
+				 fclose(fid);
+
+			 else % Windows
+
+				 fid=fopen([modelname '.bat'],'w');
+				 fprintf(fid,'@echo off\n');
+				 if cluster.interactive
+					 fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
 				 else
-					 error('valgrind not supported on windows platforms');
+					 fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog',...
+						 cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
 				 end
+				 fclose(fid);
 			 end
-
-			 if isgprof,
-				 if ~ispc,
-					 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
-				 else
-					 error('gprof not supported on windows platforms');
-				 end
-
-			 end
-
-			 if ~md.settings.io_gather,
-				 if ~ispc,
-					 %concatenate the output files:
-					 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
-				 else
-					 error('iogather not supported on windows platforms');
-				 end
-
-			 end
-			 
-			 %close file: 
-			 fclose(fid);
 
 			 %in interactive mode, create a run file, and errlog and outlog file
@@ -133,72 +103,82 @@
 				 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
 			 end
-
-
 		 end
 		 %}}}
-		 function LaunchQueueJob(cluster,md,options)% {{{1
-			 
+		 function BuildKrigingQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
+
+			 %write queuing script 
 			 if ~ispc,
-					 %lauch command, to be executed via ssh
-					 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-					 ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && source  ' md.miscellaneous.name '.queue '];
 
-					 if ~strcmpi(options.batch,'yes'),
+				 fid=fopen([modelname '.queue'],'w');
+				 fprintf(fid,'#!/bin/sh\n');
+				 if ~isvalgrind,
+					 if cluster.interactive
+						 fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s ',cluster.np,cluster.codepath,cluster.executionpath,modelname);
+					 else
+						 fprintf(fid,'mpiexec -np %i %s/kriging.exe %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,cluster.executionpath,modelname,modelname,modelname);
+					 end
+				 elseif isgprof,
+					 fprintf(fid,'\n gprof %s/kriging.exe gmon.out > %s.performance',cluster.codepath,modelname);
+				 else
+					 %Add --gen-suppressions=all to get suppression lines
+					 fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
+					 fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/kriging.exe %s %s 2> %s.errlog >%s.outlog ',...
+						 cluster.np,cluster.valgrind,cluster.valgrindsup,cluster.codepath,cluster.executionpath,modelname,modelname,modelname);
+				 end
+				 if ~io_gather, %concatenate the output files:
+					 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
+				 end
+				 fclose(fid);
 
-						 %compress the files into one zip.
-						 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-						 if md.qmu.isdakota,
-							 compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
-					end
-					if cluster.interactive,
-						compressstring=[compressstring ' ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
-					end
-					system(compressstring);
+			 else % Windows
 
-					disp('uploading input file and queueing script');
-					issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
+				 fid=fopen([modelname '.bat'],'w');
+				 fprintf(fid,'@echo off\n');
+				 if cluster.interactive
+					 fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
+				 else
+					 fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog',...
+						 cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
+				 end
+				 fclose(fid);
+			 end
 
-					disp('launching solution sequence on remote cluster');
-					issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
-				else
-					disp('batch mode requested: not launching job interactively');
-					disp('launch solution sequence on remote cluster by hand');
-				end
-			else
-				%launch right here, do not compress or archive.
-				system([md.miscellaneous.name '.bat']);
+			 %in interactive mode, create a run file, and errlog and outlog file
+			 if cluster.interactive,
+				 fid=fopen([modelname '.errlog'],'w'); fclose(fid);
+				 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
+			 end
+		 end
+		 %}}}
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
+
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
+
+			 disp('uploading input file and queueing script');
+			 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
+
+			 disp('launching solution sequence on remote cluster');
+			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+				 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && source  ' modelname '.queue '];
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end %}}}
+		 function Download(cluster,dirname,filelist)% {{{
+
+			if ispc,
+				%do nothing
+				return;
 			end
 
-		end %}}}
-		 function Download(cluster,md)% {{{1
-
-			if ~ispc,
-				%some check
-				if isempty(md.private.runtimename),
-					error('supply runtime name for results to be loaded!');
-				end
-
-				%Figure out the  directory where all the files are in: 
-				directory=[cluster.executionpath '/' md.private.runtimename '/'];
-
-				%What packages are we picking up from remote cluster
-				packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-				if md.qmu.isdakota,
-					packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-					packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-					if isfield(md.qmu.params,'tabular_graphics_data'),
-						if md.qmu.params.tabular_graphics_data==true,
-							packages{end+1}='dakota_tabular.dat'; 
-						end
-					end
-				else
-					packages{end+1}=[md.miscellaneous.name '.outbin'];
-				end
-
-				%copy files from cluster to present directory
-				issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-			else
-				%do nothing!
-			end
+			%copy files from cluster to current directory
+			directory=[cluster.executionpath '/' dirname '/'];
+			issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
 		end %}}}
 	end
Index: /issm/trunk/src/m/classes/clusters/generic.py
===================================================================
--- /issm/trunk/src/m/classes/clusters/generic.py	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/generic.py	(revision 12706)
@@ -36,182 +36,2 @@
 		return string
 		#}}}
-		
-
-#old matlab
-#		function cluster=generic(varargin) % {{{1
-#
-#			 %use provided options to change fields
-#			 options=pairoptions(varargin{:});
-#
-#			 %get name
-#			 if ~exist(options,'name'), error('option ''name'' has not been provided'); end
-#			 cluster.name=getfieldvalue(options,'name');
-#
-#			 %initialize cluster using user settings if provided
-#			 if (exist([cluster.name '_settings'])==2), eval([cluster.name '_settings']); end
-#
-#			 %OK get other fields
-#			 for i=1:size(options.list,1),
-#				 fieldname=options.list{i,1};
-#				 fieldvalue=options.list{i,2};
-#				 if ismember(fieldname,properties('generic')),
-#					 cluster.(fieldname)=fieldvalue;
-#				 else
-#					 disp(['''' fieldname ''' is not a property of cluster generic']);
-#				 end
-#			 end
-#		 end
-#		 %}}}
-#		 function checkconsistency(cluster,md,solution,analyses) % {{{1
-#			 if cluster.np<1
-#				 checkmessage(['number of processors should be at least 1']);
-#			 end
-#			 if isnan(cluster.np),
-#				 checkessage('number of processors should not be NaN!');
-#			 end
-#		 end
-#		 %}}}
-#		 function BuildQueueScript(cluster,md) % {{{1
-#		 
-#			 %retrieve parameters
-#			 modelname=md.miscellaneous.name;
-#			 solution=md.private.solution;
-#			 isvalgrind=md.debug.valgrind;
-#			 isgprof=md.debug.gprof;
-#
-#			 %open file for writing: 
-#			 if ~ispc,
-#				 fid=fopen([modelname '.queue'],'w');
-#			 else
-#				 fid=fopen([modelname '.bat'],'w');
-#			 end
-#
-#			 %write instructions for launching a job on the cluster
-#			 if ~ispc,
-#				 fprintf(fid,'#!/bin/sh\n');
-#			 else
-#				 fprintf(fid,'@echo off\n');
-#			 end
-#			 
-#			 if ~isvalgrind,
-#				 if cluster.interactive
-#					 if ~ispc,
-#						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-#					 else
-#						 fprintf(fid,'"%s/issm.exe" %s "%s" %s ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-#					 end
-#				 else
-#					 if ~ispc,
-#						 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
-#					 else
-#						 fprintf(fid,'"%s/issm.exe" %s "%s" %s 2> %s.errlog >%s.outlog ',cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
-#					 end
-#				 end
-#			 else
-#				 if ~ispc,
-#					 %Add --gen-suppressions=all to get suppression lines
-#					 fprintf(fid,'LD_PRELOAD=%s \\\n',cluster.valgrindlib);
-#					 fprintf(fid,'mpiexec -np %i %s --leak-check=full --suppressions=%s %s/issm.exe %s %s %s 2> %s.errlog >%s.outlog ',...
-#					 cluster.np,cluster.valgrind,cluster.valgrindsup, cluster.codepath,EnumToString(solution),cluster.executionpath,modelname,modelname,modelname);
-#				 else
-#					 error('valgrind not supported on windows platforms');
-#				 end
-#			 end
-#
-#			 if isgprof,
-#				 if ~ispc,
-#					 fprintf(fid,'\n gprof %s/issm.exe gmon.out > %s.performance',cluster.codepath,modelname);
-#				 else
-#					 error('gprof not supported on windows platforms');
-#				 end
-#
-#			 end
-#
-#			 if ~md.settings.io_gather,
-#				 if ~ispc,
-#					 %concatenate the output files:
-#					 fprintf(fid,'\ncat %s.outbin.* > %s.outbin',modelname,modelname);
-#				 else
-#					 error('iogather not supported on windows platforms');
-#				 end
-#
-#			 end
-#			 
-#			 %close file: 
-#			 fclose(fid);
-#
-#			 %in interactive mode, create a run file, and errlog and outlog file
-#			 if cluster.interactive,
-#				 fid=fopen([modelname '.errlog'],'w'); fclose(fid);
-#				 fid=fopen([modelname '.outlog'],'w'); fclose(fid);
-#			 end
-#
-#
-#		 end
-#		 %}}}
-#		 function LaunchQueueJob(cluster,md,options)% {{{1
-#			 
-#			 if ~ispc,
-#					 %lauch command, to be executed via ssh
-#					 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-#					 ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && source  ' md.miscellaneous.name '.queue '];
-#
-#					 if ~strcmpi(options.batch,'yes'),
-#
-#						 %compress the files into one zip.
-#						 compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-#						 if md.qmu.isdakota,
-#							 compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
-#					end
-#					if cluster.interactive,
-#						compressstring=[compressstring ' ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
-#					end
-#					system(compressstring);
-#
-#					disp('uploading input file and queueing script');
-#					issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
-#
-#					disp('launching solution sequence on remote cluster');
-#					issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
-#				else
-#					disp('batch mode requested: not launching job interactively');
-#					disp('launch solution sequence on remote cluster by hand');
-#				end
-#			else
-#				%launch right here, do not compress or archive.
-#				system([md.miscellaneous.name '.bat']);
-#			end
-#
-#		end %}}}
-#		 function Download(cluster,md)% {{{1
-#
-#			if ~ispc,
-#				%some check
-#				if isempty(md.private.runtimename),
-#					error('supply runtime name for results to be loaded!');
-#				end
-#
-#				%Figure out the  directory where all the files are in: 
-#				directory=[cluster.executionpath '/' md.private.runtimename '/'];
-#
-#				%What packages are we picking up from remote cluster
-#				packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-#				if md.qmu.isdakota,
-#					packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-#					packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-#					if isfield(md.qmu.params,'tabular_graphics_data'),
-#						if md.qmu.params.tabular_graphics_data==true,
-#							packages{end+1}='dakota_tabular.dat'; 
-#						end
-#					end
-#				else
-#					packages{end+1}=[md.miscellaneous.name '.outbin'];
-#				end
-#
-#				%copy files from cluster to present directory
-#				issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-#			else
-#				%do nothing!
-#			end
-#		end %}}}
-#
Index: /issm/trunk/src/m/classes/clusters/greenplanet.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/greenplanet.m	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/greenplanet.m	(revision 12706)
@@ -8,5 +8,5 @@
 classdef greenplanet
     properties (SetAccess=public)  
-		 % {{{1
+		 % {{{
 		 name='greenplanet'
 		 login='';
@@ -24,5 +24,5 @@
 	 end
 	 methods
-		 function cluster=greenplanet(varargin) % {{{1
+		 function cluster=greenplanet(varargin) % {{{
 
 			 %initialize cluster using default settings if provided
@@ -33,5 +33,5 @@
 		 end
 		 %}}}
-		 function disp(cluster) % {{{1
+		 function disp(cluster) % {{{
 			 %  display the object
 			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
@@ -48,5 +48,5 @@
 		 end
 		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 
 			 available_queues={'rignot','default'};
@@ -57,23 +57,20 @@
 
 			 %Miscelaneous
-			 if isempty(cluster.login), checkmessage('login empty'); end
-			 if isempty(cluster.codepath), checkmessage('codepath empty'); end
-			 if isempty(cluster.executionpath), checkmessage('executionpath empty'); end
+			 if isempty(cluster.login), md = checkmessage(md,'login empty'); end
+			 if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
+			 if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
 
 		 end
 		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
 
-			 %retrieve parameters 
-			 modelname=md.miscellaneous.name; 
-			 solution=md.private.solution;
-			 isvalgrind=md.debug.valgrind;
+			 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
+			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
 
 			 %compute number of processors
 			 cluster.np=cluster.numnodes*cluster.cpuspernode;
 
-			 %open file for writing: 
+			 %write queuing script 
 			 fid=fopen([modelname '.queue'],'w');
-
 			 fprintf(fid,'#PBS -S /bin/bash\n');
 			 fprintf(fid,'#PBS -N %s\n',modelname);
@@ -84,14 +81,9 @@
 			 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
 			 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
-
 			 fprintf(fid,'cd %s/%s\n\n',cluster.executionpath,md.private.runtimename);
 			 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-
-			 if ~md.settings.io_gather,
-				 %concatenate the output files:
+			 if ~io_gather, %concatenate the output files:
 				 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
 			 end
-
-			 %close file
 			 fclose(fid);
 
@@ -100,7 +92,5 @@
 				 fid=fopen([modelname '.run'],'w');
 				 fprintf(fid,'mpiexec -np %i %s/issm.exe %s %s %s\n',cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-
-				 if ~md.settings.io_gather,
-					 %concatenate the output files:
+				 if ~io_gather, %concatenate the output files:
 					 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
 				 end
@@ -112,82 +102,31 @@
 			 end
 		 end %}}}
-		 function LaunchQueueJob(cluster,md,options)% {{{1
-			 
-			 %lauch command, to be executed via ssh
-			 if ~cluster.interactive, 
-				launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' md.miscellaneous.name '.queue '];
-			else
-				launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' md.private.runtimename '.tar.gz'];
-			end
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
 
-			if ~strcmpi(options.batch,'yes'),
-				
-				%compress the files into one zip.
-				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-				if md.qmu.isdakota,
-					compressstring=[compressstring md.miscellaneous.name '.qmu.in '];
-				end
-				if cluster.interactive,
-					compressstring=[compressstring md.miscellaneous.name '.run ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
-				end
-				system(compressstring);
-				
-				disp('uploading input file and queueing script');
-				if cluster.interactive,
-					directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
-				else 
-					directory=cluster.executionpath;
-				end
-				
-				issmscpout(cluster.name,directory,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
-				
-				disp('launching solution sequence on remote cluster');
-				issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
 
-			else
-				disp('batch mode requested: not launching job interactively');
-				disp('launch solution sequence on remote cluster by hand');
-			end
-		 end
-		 %}}}
-		 function Download(cluster,md)% {{{1
+			 disp('uploading input file and queueing script');
+			 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
 
-			%some check
-			if isempty(md.private.runtimename),
-				if ~cluster.interactive,
-					error('greenplanet Download error message: supply runtime name for results to be loaded!');
-				end
-			end
+			 disp('launching solution sequence on remote cluster');
+			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+				 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end %}}}
+		 function Download(cluster,dirname,filelist)% {{{
 
-			%Figure out the  directory where all the files are in: 
-			if ~cluster.interactive,
-				directory=[cluster.executionpath '/' md.private.runtimename '/'];
-			else
-				directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
-			end
+			 %copy files from cluster to current directory
+			 directory=[cluster.executionpath '/' dirname '/'];
+			 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
 
-			%What packages are we picking up from remote cluster
-			if ~cluster.interactive,
-				packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-			else
-				packages={};
-			end
-			if md.qmu.isdakota,
-				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-				if isfield(md.qmu.params,'tabular_graphics_data'),
-					if md.qmu.params.tabular_graphics_data==true,
-						packages{end+1}='dakota_tabular.dat'; 
-					end
-				end
-			else
-				packages{end+1}=[md.miscellaneous.name '.outbin'];
-			end
-
-			%copy files from cluster to present directory
-			issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-
-		end %}}}
+		 end %}}}
 	end
 end
Index: sm/trunk/src/m/classes/clusters/none.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/none.m	(revision 12705)
+++ 	(revision )
@@ -1,18 +1,0 @@
-%NONE class definition
-%
-%   Usage:
-%      cluster=none();
-%      cluster=none('np',3);
-%      cluster=none('np',3,'login','username');
-
-classdef none
-    properties (SetAccess=public)
-		name='none'
-    end
-    methods
-		 function cluster=none(varargin) % {{{1
-			 error('Cannot assign md.cluster to ''none'': ISSM is not available in serial model anymore');
-		 end
-		 %}}}
-	end
-end
Index: sm/trunk/src/m/classes/clusters/none.py
===================================================================
--- /issm/trunk/src/m/classes/clusters/none.py	(revision 12705)
+++ 	(revision )
@@ -1,24 +1,0 @@
-#NONE cluster class definition
-#
-#   Usage:
-#      cluster=none();
-#      cluster=none('np',3);
-#      cluster=none('np',3,'login','username');
-
-class none:
-	#properties
-	def __init__(self):
-		# {{{ Properties
-		self.name='none'
-		#}}}
-	def __repr__(obj):
-		# {{{ Display
-		
-		string="class 'none' object:"
-		string="%s\n\n%s"%(string,"%s%s"%('    name: ',obj.name))
-		return string
-		#}}}
-	def checkconsistency(cluster,md,solution,analyses):
-		pass
-	def BuildQueueScript(cluster,md):
-			 raise RuntimeError('none.BuildQueueScript error message: serial cluster cannot build queue script')
Index: /issm/trunk/src/m/classes/clusters/pfe.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/pfe.m	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/pfe.m	(revision 12706)
@@ -8,5 +8,5 @@
 classdef pfe
     properties (SetAccess=public)  
-		 % {{{1
+		 % {{{
 		 name='pfe'
 		 login='';
@@ -29,5 +29,5 @@
 	 end
 	 methods
-		 function cluster=pfe(varargin) % {{{1
+		 function cluster=pfe(varargin) % {{{
 
 			 %initialize cluster using default settings if provided
@@ -38,5 +38,5 @@
 		 end
 		 %}}}
-		 function disp(cluster) % {{{1
+		 function disp(cluster) % {{{
 			 %  display the object
 			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
@@ -56,5 +56,5 @@
 		 end
 		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 
 			 available_queues={'long','normal','debug'};
@@ -68,9 +68,9 @@
 				 if cluster.hyperthreading,
 					 if ((cluster.cpuspernode>16 ) | (cluster.cpuspernode<1)),
-						 checkmessage('cpuspernode should be between 1 and 16 for ''neh'' and ''har'' processors in hyperthreading mode');
+						 md = checkmessage(md,'cpuspernode should be between 1 and 16 for ''neh'' and ''har'' processors in hyperthreading mode');
 					 end
 				 else
 					 if ((cluster.cpuspernode>8 ) | (cluster.cpuspernode<1)),
-						 checkmessage('cpuspernode should be between 1 and 8 for ''neh'' and ''har'' processors');
+						 md = checkmessage(md,'cpuspernode should be between 1 and 8 for ''neh'' and ''har'' processors');
 					 end
 				 end
@@ -78,35 +78,31 @@
 				 if cluster.hyperthreading,
 					 if ((cluster.cpuspernode>24 ) | (cluster.cpuspernode<1)),
-						 checkmessage('cpuspernode should be between 1 and 24 for ''wes'' processors in hyperthreading mode');
+						 md = checkmessage(md,'cpuspernode should be between 1 and 24 for ''wes'' processors in hyperthreading mode');
 					 end
 				 else
 					 if ((cluster.cpuspernode>12 ) | (cluster.cpuspernode<1)),
-						 checkmessage('cpuspernode should be between 1 and 12 for ''wes'' processors');
-					 end
-				 end
-			 else
-				 checkmessage('unknown processor type, should be ''neh'',''wes'' or ''har''');
+						 md = checkmessage(md,'cpuspernode should be between 1 and 12 for ''wes'' processors');
+					 end
+				 end
+			 else
+				 md = checkmessage(md,'unknown processor type, should be ''neh'',''wes'' or ''har''');
 			 end
 
 			 %Miscelaneous
-			 if isempty(cluster.login), checkmessage('login empty'); end
-			 if isempty(cluster.codepath), checkmessage('codepath empty'); end
-			 if isempty(cluster.executionpath), checkmessage('executionpath empty'); end
-
-		 end
-		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
-
-			 %retrieve parameters 
-			 modelname=md.miscellaneous.name; 
-			 solution=md.private.solution;
-			 isvalgrind=md.debug.valgrind;
+			 if isempty(cluster.login), md = checkmessage(md,'login empty'); end
+			 if isempty(cluster.codepath), md = checkmessage(md,'codepath empty'); end
+			 if isempty(cluster.executionpath), md = checkmessage(md,'executionpath empty'); end
+
+		 end
+		 %}}}
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
+
+			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
 
 			 %compute number of processors
 			 cluster.np=cluster.numnodes*cluster.cpuspernode;
 
-			 %open file for writing: 
+			 %write queuing script 
 			 fid=fopen([modelname '.queue'],'w');
-
 			 fprintf(fid,'#PBS -S /bin/bash\n');
 %			 fprintf(fid,'#PBS -N %s\n',modelname);
@@ -118,24 +114,15 @@
 			 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
 			 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
-
 			 fprintf(fid,'. /usr/share/modules/init/bash\n\n');
-
 			 fprintf(fid,'module load comp-intel/11.1.046\n');
 			 fprintf(fid,'module load mpi/mpt.1.25\n');
 			 fprintf(fid,'module load math/intel_mkl_64_10.0.011\n\n');
-
 			 fprintf(fid,'export PATH="$PATH:."\n\n');
 			 fprintf(fid,'export MPI_GROUP_MAX=64\n\n');
-
 			 fprintf(fid,'cd $PBS_O_WORKDIR\n\n');
-
 			 fprintf(fid,'mpiexec -np %i %s/issm.exe %s $PBS_O_WORKDIR %s\n',cluster.np,cluster.codepath,EnumToString(solution),modelname);
-
-			 if ~md.settings.io_gather,
-				 %concatenate the output files:
+			 if ~io_gather, %concatenate the output files:
 				 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
 			 end
-
-			 %close file
 			 fclose(fid);
 
@@ -148,7 +135,5 @@
 					 fprintf(fid,'mpiexec -np %i valgrind --leak-check=full %s/issm.exe %s $PBS_O_WORKDIR %s\n',cluster.np,cluster.codepath,EnumToString(solution),modelname);
 				 end
-
-				 if ~md.settings.io_gather,
-					 %concatenate the output files:
+				 if ~io_gather, %concatenate the output files:
 					 fprintf(fid,'cat %s.outbin.* > %s.outbin',modelname,modelname);
 				 end
@@ -160,90 +145,57 @@
 			 end
 		 end %}}}
-		 function LaunchQueueJob(cluster,md,options)% {{{1
-			 
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
+
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.run '  modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
+
+			 disp('uploading input file and queueing script');
+			 if cluster.interactive,
+				 directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
+			 else 
+				 directory=cluster.executionpath;
+			 end
+
+			 if ~cluster.bbftp,
+				 issmscpout(cluster.name,directory,cluster.login,cluster.port,{[dirname '.tar.gz']});
+			 else
+				 issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[dirname '.tar.gz']});
+			 end
+
 			 %lauch command, to be executed via ssh
 			 if ~cluster.interactive, 
-				launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' md.miscellaneous.name '.queue '];
-			else
-				launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' md.private.runtimename '.tar.gz'];
-			end
-
-			if ~strcmpi(options.batch,'yes'),
-				
-				%compress the files into one zip.
-				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-				if md.qmu.isdakota,
-					compressstring=[compressstring md.miscellaneous.name '.qmu.in '];
-				end
-				if cluster.interactive,
-					compressstring=[compressstring md.miscellaneous.name '.run ' md.miscellaneous.name '.errlog ' md.miscellaneous.name '.outlog '];
-				end
-				system(compressstring);
-				
-				disp('uploading input file and queueing script');
-				if cluster.interactive,
-					directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive)];
-				else 
-					directory=cluster.executionpath;
-				end
-				
-				if ~cluster.bbftp,
-					issmscpout(cluster.name,directory,cluster.login,cluster.port,{[md.private.runtimename '.tar.gz']});
-				else
-					issmbbftpout(cluster.name,directory,cluster.login,cluster.port,cluster.numstreams,{[md.private.runtimename '.tar.gz']});
-				end
-				
-				disp('launching solution sequence on remote cluster');
-				issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
-
-			else
-				disp('batch mode requested: not launching job interactively');
-				disp('launch solution sequence on remote cluster by hand');
-			end
-		 end
-		 %}}}
-		 function Download(cluster,md)% {{{1
-
-			%some check
-			if isempty(md.private.runtimename),
-				if ~cluster.interactive,
-					error('pfe Download error message: supply runtime name for results to be loaded!');
-				end
-			end
-
-			%Figure out the  directory where all the files are in: 
-			if ~cluster.interactive,
-				directory=[cluster.executionpath '/' md.private.runtimename '/'];
-			else
-				directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
-			end
-
-			%What packages are we picking up from remote cluster
-			if ~cluster.interactive,
-				packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-			else
-				packages={};
-			end
-			if md.qmu.isdakota,
-				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-				if isfield(md.qmu.params,'tabular_graphics_data'),
-					if md.qmu.params.tabular_graphics_data==true,
-						packages{end+1}='dakota_tabular.dat'; 
-					end
-				end
-			else
-				packages{end+1}=[md.miscellaneous.name '.outbin'];
-			end
-
-			%copy files from cluster to present directory
-			if ~cluster.bbftp,
-				issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-			else
-				issmbbftpin(cluster.name, cluster.login, cluster.port, cluster.numstreams, directory, packages);
-			end
-
-		end %}}}
+				 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+					 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
+			 else
+				 launchcommand=['cd ' cluster.executionpath '/Interactive' num2str(cluster.interactive) ' && tar -zxf ' dirname '.tar.gz'];
+			 end
+
+			 disp('launching solution sequence on remote cluster');
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end
+		 %}}}
+		 function Download(cluster,dirname,filelist)% {{{
+
+			 %copy files from cluster to current directory
+			 if ~cluster.interactive,
+				 directory=[cluster.executionpath '/' dirname '/'];
+			 else
+				 directory=[cluster.executionpath '/Interactive' num2str(cluster.interactive) '/'];
+			 end
+
+			 if ~cluster.bbftp,
+				 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
+			 else
+				 issmbbftpin(cluster.name, cluster.login, cluster.port, cluster.numstreams, directory, filelist);
+			 end
+
+		 end %}}}
 	end
 end
Index: /issm/trunk/src/m/classes/clusters/pollux.m
===================================================================
--- /issm/trunk/src/m/classes/clusters/pollux.m	(revision 12705)
+++ /issm/trunk/src/m/classes/clusters/pollux.m	(revision 12706)
@@ -8,5 +8,5 @@
 classdef pollux
     properties (SetAccess=public) 
-		 % {{{1
+		 % {{{
 		 name='pollux'
 		 login='username';
@@ -20,9 +20,9 @@
 	 end
 	 methods
-		 function cluster=pollux(varargin) % {{{1
+		 function cluster=pollux(varargin) % {{{
 			 cluster=AssignObjectFields(pairoptions(varargin{:}),cluster);
 		 end
 		 %}}}
-		 function disp(cluster) % {{{1
+		 function disp(cluster) % {{{
 			 %  display the object
 			 disp(sprintf('class ''%s'' object ''%s'' = ',class(cluster),inputname(1)));
@@ -37,5 +37,5 @@
 		 end
 		 %}}}
-		 function checkconsistency(cluster,md,solution,analyses) % {{{1
+		 function md = checkconsistency(cluster,md,solution,analyses) % {{{
 
 			 available_queues={'shortp','longp'};
@@ -46,13 +46,11 @@
 		 end
 		 %}}}
-		 function BuildQueueScript(cluster,md) % {{{1
+		 function BuildQueueScript(cluster,modelname,solution,io_gather,isvalgrind,isgprof) % {{{
 
-			 %retrieve parameters 
-			 modelname=md.miscellaneous.name; 
-			 solution=md.private.solution;
+			 if(isvalgrind), disp('valgrind not supported by cluster, ignoring...'); end
+			 if(isgprof),    disp('gprof not supported by cluster, ignoring...'); end
 
-			 %open file for writing: 
+			 %write queuing script 
 			 fid=fopen([modelname '.queue'],'w');
-
 			 fprintf(fid,'#!/bin/sh\n');
 			 fprintf(fid,'#PBS -l walltime=%i\n',cluster.time*60); %walltime is in seconds.
@@ -64,70 +62,39 @@
 			 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
 			 fprintf(fid,'#PBS -e %s.errlog \n',modelname);
-
 			 fprintf(fid,'export PBS_O_WORKDIR=%s\n',cluster.executionpath);
 			 fprintf(fid,'cd $PBS_O_WORKDIR\n');
 			 fprintf(fid,'export OMP_NUM_THREADS=1\n');
 			 fprintf(fid,'dplace -s1 -c0-%i mpiexec -np %i %s/issm.exe %s %s %s',cluster.np-1,cluster.np,cluster.codepath,EnumToString(solution),cluster.executionpath,modelname);
-
-			 %close file
 			 fclose(fid);
 
 		 end
 		 %}}}
-		 function LaunchQueueJob(cluster,md,options)% {{{1
-			 
-			 %lauch command, to be executed via ssh
-			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' md.private.runtimename ' && mkdir ' md.private.runtimename ...
-			                ' && cd ' md.private.runtimename ' && mv ../' md.private.runtimename '.tar.gz ./ && tar -zxf ' md.private.runtimename '.tar.gz  && qsub ' modelname '.queue '];
+		 function LaunchQueueJob(cluster,modelname,dirname,filelist)% {{{
 
-			if ~strcmpi(options.batch,'yes'),
-				
-				%compress the files into one zip.
-				compressstring=['tar -zcf ' md.private.runtimename '.tar.gz ' md.miscellaneous.name '.bin ' md.miscellaneous.name '.queue '  md.miscellaneous.name '.petsc '];
-				if md.qmu.isdakota,
-					compressstring=[compressstring md.miscellaneous.name '.qmu.in'];
-				end
-				system(compressstring);
-				
-				disp('uploading input file and queueing script');
-				issmscpout(md.cluster.name,md.cluster.executionpath,md.cluster.login,md.cluster.port,{[md.private.runtimename '.tar.gz']});
-				
-				disp('launching solution sequence on remote cluster');
-				issmssh(md.cluster.name,md.cluster.login,md.cluster.port,launchcommand);
+			 %compress the files into one zip.
+			 compressstring=['tar -zcf ' dirname '.tar.gz '];
+			 for i=1:numel(filelist),
+				 compressstring = [compressstring ' ' filelist{i}];
+			 end
+			 if cluster.interactive,
+				 compressstring = [compressstring ' ' modelname '.errlog ' modelname '.outlog '];
+			 end
+			 system(compressstring);
 
-			else
-				disp('batch mode requested: not launching job interactively');
-				disp('launch solution sequence on remote cluster by hand');
-			end
+			 disp('uploading input file and queueing script');
+			 issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
 
-		 end
-		 %}}}
-		 function Download(cluster,md)% {{{1
+			 disp('launching solution sequence on remote cluster');
+			 launchcommand=['cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+				 ' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && qsub ' modelname '.queue '];
+			 issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
+		 end %}}}
+		 function Download(cluster,dirname,filelist)% {{{
 
-			%some check
-			if isempty(md.private.runtimename),
-				error('pfe Download error message: supply runtime name for results to be loaded!');
-			end
+			 %copy files from cluster to current directory
+			 directory=[cluster.executionpath '/' dirname '/'];
+			 issmscpin(cluster.name,cluster.login,cluster.port,directory,filelist);
 
-			%Figure out the  directory where all the files are in: 
-			directory=[cluster.executionpath '/' md.private.runtimename '/'];
-
-			%What packages are we picking up from remote cluster
-			packages={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
-			if md.qmu.isdakota,
-				packages{end+1}=[md.miscellaneous.name '.qmu.err'];
-				packages{end+1}=[md.miscellaneous.name '.qmu.out'];
-				if isfield(md.qmu.params,'tabular_graphics_data'),
-					if md.qmu.params.tabular_graphics_data==true,
-						packages{end+1}='dakota_tabular.dat'; 
-					end
-				end
-			else
-				packages{end+1}=[md.miscellaneous.name '.outbin'];
-			end
-
-			%copy files from cluster to present directory
-			issmscpin(cluster.name, cluster.login, cluster.port, directory, packages);
-		end %}}}
+		 end %}}}
 	end
 end
Index: /issm/trunk/src/m/classes/constants.m
===================================================================
--- /issm/trunk/src/m/classes/constants.m	(revision 12705)
+++ /issm/trunk/src/m/classes/constants.m	(revision 12706)
@@ -31,9 +31,9 @@
 
 		end % }}}
-		function flag = checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-			checkfield(md,'constants.g','>',0,'size',[1 1]);
-			checkfield(md,'constants.yts','>',0,'size',[1 1]);
-			checkfield(md,'constants.referencetemperature','size',[1 1]);
+			md = checkfield(md,'constants.g','>',0,'size',[1 1]);
+			md = checkfield(md,'constants.yts','>',0,'size',[1 1]);
+			md = checkfield(md,'constants.referencetemperature','size',[1 1]);
 
 		end % }}}
Index: /issm/trunk/src/m/classes/debug.m
===================================================================
--- /issm/trunk/src/m/classes/debug.m	(revision 12705)
+++ /issm/trunk/src/m/classes/debug.m	(revision 12706)
@@ -8,5 +8,5 @@
 		valgrind = false;
 		gprof    = false;
-		petsc_profiling = false;
+		profiling = false;
 	end
 	methods
@@ -27,9 +27,9 @@
 			fielddisplay(obj,'valgrind','use Valgrind to debug (0 or 1)');
 			fielddisplay(obj,'gprof','use gnu-profiler to find out where the time is spent');
-			fielddisplay(obj,'petsc_profiling','enables PETSc profiling (memory, flops, time)');
+			fielddisplay(obj,'profiling','enables profiling (memory, flops, time)');
 
 		end % }}}
 		function marshall(obj,fid) % {{{
-			WriteData(fid,'object',obj,'fieldname','petsc_profiling','format','Boolean');
+			WriteData(fid,'object',obj,'fieldname','profiling','format','Boolean');
 		end % }}}
 	end
Index: /issm/trunk/src/m/classes/diagnostic.m
===================================================================
--- /issm/trunk/src/m/classes/diagnostic.m	(revision 12705)
+++ /issm/trunk/src/m/classes/diagnostic.m	(revision 12706)
@@ -64,5 +64,5 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
@@ -70,32 +70,32 @@
 			%if ~ismember(DiagnosticHorizAnalysisEnum,analyses) |  (solution==TransientSolutionEnum & md.transient.isdiagnostic==0), return; end
 
-			checkfield(md,'diagnostic.spcvx','forcing',1);
-			checkfield(md,'diagnostic.spcvy','forcing',1);
-			if md.mesh.dimension==3, checkfield(md,'diagnostic.spcvz','forcing',1); end
-			checkfield(md,'diagnostic.restol','size',[1 1],'>',0);
-			checkfield(md,'diagnostic.reltol','size',[1 1]);
-			checkfield(md,'diagnostic.abstol','size',[1 1]);
-			checkfield(md,'diagnostic.isnewton','numel',1,'values',[0 1]);
-			checkfield(md,'diagnostic.stokesreconditioning','size',[1 1],'NaN',1);
-			checkfield(md,'diagnostic.viscosity_overshoot','size',[1 1],'NaN',1);
+			md = checkfield(md,'diagnostic.spcvx','forcing',1);
+			md = checkfield(md,'diagnostic.spcvy','forcing',1);
+			if md.mesh.dimension==3, md = checkfield(md,'diagnostic.spcvz','forcing',1); end
+			md = checkfield(md,'diagnostic.restol','size',[1 1],'>',0);
+			md = checkfield(md,'diagnostic.reltol','size',[1 1]);
+			md = checkfield(md,'diagnostic.abstol','size',[1 1]);
+			md = checkfield(md,'diagnostic.isnewton','numel',1,'values',[0 1]);
+			md = checkfield(md,'diagnostic.stokesreconditioning','size',[1 1],'NaN',1);
+			md = checkfield(md,'diagnostic.viscosity_overshoot','size',[1 1],'NaN',1);
 			if md.mesh.dimension==2,
-				checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
+				md = checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
 			else
-				checkfield(md,'diagnostic.icefront','size',[NaN 6],'NaN',1);
+				md = checkfield(md,'diagnostic.icefront','size',[NaN 6],'NaN',1);
 			end
-			checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
-			checkfield(md,'diagnostic.maxiter','size',[1 1],'>=',1);
-			checkfield(md,'diagnostic.referential','size',[md.mesh.numberofvertices 6]);
+			md = checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
+			md = checkfield(md,'diagnostic.maxiter','size',[1 1],'>=',1);
+			md = checkfield(md,'diagnostic.referential','size',[md.mesh.numberofvertices 6]);
 			if ~isempty(md.diagnostic.requested_outputs),
-				checkfield(md,'diagnostic.requested_outputs','size',[NaN 1]);
+				md = checkfield(md,'diagnostic.requested_outputs','size',[NaN 1]);
 			end
 
 			%singular solution
 			if ~any((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy))==2),
-				checkmessage(['model ' md.miscellaneous.name ' is not well posed (singular). You need at least one node with fixed velocity!'])
+				md = checkmessage(md,['model is not well posed (singular). You need at least one node with fixed velocity!']);
 			end
 			%CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
 			if any(sum(isnan(md.diagnostic.referential),2)~=0 & sum(isnan(md.diagnostic.referential),2)~=6),
-				checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. Each line of diagnostic.referential should contain either only NaN values or no NaN values']);
+				md = checkmessage(md,['Each line of diagnostic.referential should contain either only NaN values or no NaN values']);
 			end
 			%CHECK THAT THE TWO VECTORS PROVIDED ARE ORTHOGONAL
@@ -103,5 +103,5 @@
 				pos=find(sum(isnan(md.diagnostic.referential),2)==0);
 				if any(abs(dot(md.diagnostic.referential(pos,1:3)',md.diagnostic.referential(pos,4:6)'))>eps),
-					checkmessage(['model ' md.miscellaneous.name ' has problem with referential. Vectors in diagnostic.referential (colums 1 to 3 and 4 to 6) must be orthogonal']);
+					md = checkmessage(md,['Vectors in diagnostic.referential (colums 1 to 3 and 4 to 6) must be orthogonal']);
 				end
 			end
@@ -110,5 +110,5 @@
 				pos=find(md.mask.vertexongroundedice & md.mesh.vertexonbed);
 				if any(~isnan(md.diagnostic.referential(pos,:))),
-					checkmessage(['no referential should be specified for basal vertices of grounded ice']);
+					md = checkmessage(md,['no referential should be specified for basal vertices of grounded ice']);
 				end
 			end
Index: /issm/trunk/src/m/classes/flaim.m
===================================================================
--- /issm/trunk/src/m/classes/flaim.m	(revision 12705)
+++ /issm/trunk/src/m/classes/flaim.m	(revision 12706)
@@ -32,14 +32,14 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
 			if solution~=FlaimSolutionEnum, return; end
 
-			checkfield(md,'flaim.tracks','file',1);
+			md = checkfield(md,'flaim.tracks','file',1);
 			if any(isnan(md.flaim.criterion)) || isempty(md.flaim.criterion)
-				checkfield(md,'flaim.targets','file',1);
+				md = checkfield(md,'flaim.targets','file',1);
 			else
-				checkfield(md,'flaim.criterion','numel',[md.mesh.numberofvertices md.mesh.numberofelements]);
+				md = checkfield(md,'flaim.criterion','numel',[md.mesh.numberofvertices md.mesh.numberofelements]);
 			end
 
Index: /issm/trunk/src/m/classes/flowequation.m
===================================================================
--- /issm/trunk/src/m/classes/flowequation.m	(revision 12705)
+++ /issm/trunk/src/m/classes/flowequation.m	(revision 12706)
@@ -27,28 +27,30 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			if ismember(DiagnosticHorizAnalysisEnum,analyses),
 
-				checkfield(md,'flowequation.ismacayealpattyn','numel',1,'values',[0 1]);
-				checkfield(md,'flowequation.ishutter','numel',1,'values',[0 1]);
-				checkfield(md,'flowequation.isstokes','numel',1,'values',[0 1]);
-				checkfield(md,'flowequation.bordermacayeal','size',[md.mesh.numberofvertices 1],'values',[0 1]);
-				checkfield(md,'flowequation.borderpattyn','size',[md.mesh.numberofvertices 1],'values',[0 1]);
-				checkfield(md,'flowequation.borderstokes','size',[md.mesh.numberofvertices 1],'values',[0 1]);
+				md = checkfield(md,'flowequation.ismacayealpattyn','numel',1,'values',[0 1]);
+				md = checkfield(md,'flowequation.ishutter','numel',1,'values',[0 1]);
+				md = checkfield(md,'flowequation.isstokes','numel',1,'values',[0 1]);
+				md = checkfield(md,'flowequation.bordermacayeal','size',[md.mesh.numberofvertices 1],'values',[0 1]);
+				md = checkfield(md,'flowequation.borderpattyn','size',[md.mesh.numberofvertices 1],'values',[0 1]);
+				md = checkfield(md,'flowequation.borderstokes','size',[md.mesh.numberofvertices 1],'values',[0 1]);
 				if (md.mesh.dimension==2),
-					checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[1:2]);
-					checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[1:2]);
+					md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[1:2]);
+					md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[1:2]);
 				else
-					checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[0:7]);
-					checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[0:7]);
+					md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[0:7]);
+					md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[0:7]);
 				end
 				if (md.flowequation.ismacayealpattyn==0 && md.flowequation.ishutter==0 && md.flowequation.isstokes==0),
-					checkmessage(['no element types set for this model. At least one of ismacayealpattyn, ishutter or isstokes need to be =1']);
+					md = checkmessage(md,['no element types set for this model. At least one of ismacayealpattyn, ishutter or isstokes need to be =1']);
 				end
 			end
 			if ismember(DiagnosticHutterAnalysisEnum,analyses),
-				if any(md.flowequation.element_equation==1 & md.mask.elementonfloatingice),
-					disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
+				if any(md.flowequation.element_equation==1),
+					if(md.flowequation.element_equation & md.mask.elementonfloatingice),
+						disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
+					end
 				end
 			end
Index: /issm/trunk/src/m/classes/friction.m
===================================================================
--- /issm/trunk/src/m/classes/friction.m	(revision 12705)
+++ /issm/trunk/src/m/classes/friction.m	(revision 12706)
@@ -22,12 +22,12 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
 			if ~ismember(DiagnosticHorizAnalysisEnum,analyses) & ~ismember(ThermalAnalysisEnum,analyses), return; end
 
-			checkfield(md,'friction.coefficient','NaN',1,'size',[md.mesh.numberofvertices 1]);
-			checkfield(md,'friction.q','NaN',1,'size',[md.mesh.numberofelements 1]);
-			checkfield(md,'friction.p','NaN',1,'size',[md.mesh.numberofelements 1]);
+			md = checkfield(md,'friction.coefficient','NaN',1,'size',[md.mesh.numberofvertices 1]);
+			md = checkfield(md,'friction.q','NaN',1,'size',[md.mesh.numberofelements 1]);
+			md = checkfield(md,'friction.p','NaN',1,'size',[md.mesh.numberofelements 1]);
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/geometry.m
===================================================================
--- /issm/trunk/src/m/classes/geometry.m	(revision 12705)
+++ /issm/trunk/src/m/classes/geometry.m	(revision 12706)
@@ -24,14 +24,14 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-			checkfield(md,'geometry.surface'  ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
-			checkfield(md,'geometry.bed'      ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
-			checkfield(md,'geometry.thickness','NaN',1,'size',[md.mesh.numberofvertices 1],'>',0);
+			md = checkfield(md,'geometry.surface'  ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
+			md = checkfield(md,'geometry.bed'      ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
+			md = checkfield(md,'geometry.thickness','NaN',1,'size',[md.mesh.numberofvertices 1],'>',0);
 			if any((obj.thickness-obj.surface+obj.bed)>10^-9),
-				checkmessage(['equality thickness=surface-bed violated']);
+				md = checkmessage(md,['equality thickness=surface-bed violated']);
 			end 
 			if solution==TransientSolutionEnum & md.transient.isgroundingline,
-				checkfield(md,'geometry.bathymetry','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'geometry.bathymetry','NaN',1,'size',[md.mesh.numberofvertices 1]);
 			end
 		end % }}}
Index: /issm/trunk/src/m/classes/groundingline.m
===================================================================
--- /issm/trunk/src/m/classes/groundingline.m	(revision 12705)
+++ /issm/trunk/src/m/classes/groundingline.m	(revision 12706)
@@ -28,19 +28,19 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-			checkfield(md,'groundingline.migration','values',{'None' 'AgressiveMigration' 'SoftMigration'});
+			md = checkfield(md,'groundingline.migration','values',{'None' 'AgressiveMigration' 'SoftMigration'});
 
 			if ~strcmp(obj.migration,'None'),
 				if isnan(md.geometry.bathymetry),
-					checkmessage(['requesting grounding line migration, but bathymetry is absent!']);
+					md = checkmessage(md,['requesting grounding line migration, but bathymetry is absent!']);
 				end
 				pos=find(md.mask.vertexongroundedice); 
 				if any(abs(md.geometry.bed(pos)-md.geometry.bathymetry(pos))>10^-10),
-					checkmessage(['bathymetry not equal to bed on grounded ice !']);
+					md = checkmessage(md,['bathymetry not equal to bed on grounded ice !']);
 				end
 				pos=find(md.mask.vertexonfloatingice); 
 				if any(md.geometry.bathymetry(pos)-md.geometry.bed(pos)>10^-9),
-					checkmessage(['bathymetry superior to bed on floating ice !']);
+					md = checkmessage(md,['bathymetry superior to bed on floating ice !']);
 				end
 			end
Index: /issm/trunk/src/m/classes/hydrology.m
===================================================================
--- /issm/trunk/src/m/classes/hydrology.m	(revision 12705)
+++ /issm/trunk/src/m/classes/hydrology.m	(revision 12706)
@@ -35,11 +35,11 @@
 			obj.stabilization=1;
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
 			if ~ismember(HydrologyAnalysisEnum,analyses), return; end
 
-			checkfield(md,'hydrology.spcwatercolumn','forcing',1);
-			checkfield(md,'hydrology.stabilization','>=',0);
+			md = checkfield(md,'hydrology.spcwatercolumn','forcing',1);
+			md = checkfield(md,'hydrology.stabilization','>=',0);
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/initialization.m
===================================================================
--- /issm/trunk/src/m/classes/initialization.m	(revision 12705)
+++ /issm/trunk/src/m/classes/initialization.m	(revision 12706)
@@ -27,34 +27,34 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 			if ismember(DiagnosticHorizAnalysisEnum,analyses)
 				if ~isnan(md.initialization.vx) & ~isnan(md.initialization.vy),
-					checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
-					checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
+					md = checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
+					md = checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
 				end
 			end
 			if ismember(PrognosticAnalysisEnum,analyses),
-				checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
-				checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
 			end
 			if ismember(HydrologyAnalysisEnum,analyses),
-				checkfield(md,'initialization.watercolumn','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.watercolumn','NaN',1,'size',[md.mesh.numberofvertices 1]);
 			end
 			if ismember(BalancethicknessAnalysisEnum,analyses),
-				checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
-				checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
 				%Triangle with zero velocity
 				if any(sum(abs(md.initialization.vx(md.mesh.elements)),2)==0 & sum(abs(md.initialization.vy(md.mesh.elements)),2)==0)
-					checkmessage('at least one triangle has all its vertices with a zero velocity');
+					md = checkmessage(md,'at least one triangle has all its vertices with a zero velocity');
 				end
 			end
 			if ismember(ThermalAnalysisEnum,analyses),
-				checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
-				checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
-				checkfield(md,'initialization.vz','NaN',1,'size',[md.mesh.numberofvertices 1]);
-				checkfield(md,'initialization.pressure','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.vx','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.vy','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.vz','NaN',1,'size',[md.mesh.numberofvertices 1]);
+				md = checkfield(md,'initialization.pressure','NaN',1,'size',[md.mesh.numberofvertices 1]);
 			end
-			if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy),
-				checkfield(md,'initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices 1]);
+			if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy) | solution==EnthalpySolutionEnum,
+				md = checkfield(md,'initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices 1]);
 			end
 		end % }}}
Index: /issm/trunk/src/m/classes/inversion.m
===================================================================
--- /issm/trunk/src/m/classes/inversion.m	(revision 12705)
+++ /issm/trunk/src/m/classes/inversion.m	(revision 12706)
@@ -75,5 +75,5 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
@@ -83,23 +83,23 @@
 			num_costfunc=size(md.inversion.cost_functions,2);
 
-			checkfield(md,'inversion.iscontrol','values',[0 1]);
-			checkfield(md,'inversion.tao','values',[0 1]);
-			checkfield(md,'inversion.incomplete_adjoint','values',[0 1]);
-			checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'Vx' 'Vy'});
-			checkfield(md,'inversion.nsteps','numel',1,'>=',1);
-			checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0);
-			checkfield(md,'inversion.step_threshold','size',[md.inversion.nsteps 1]);
-			checkfield(md,'inversion.cost_functions','size',[md.inversion.nsteps num_costfunc],'values',[101:105 201 501:503]);
-			checkfield(md,'inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
-			checkfield(md,'inversion.gradient_only','values',[0 1]);
-			checkfield(md,'inversion.gradient_scaling','size',[md.inversion.nsteps num_controls]);
-			checkfield(md,'inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
-			checkfield(md,'inversion.max_parameters','size',[md.mesh.numberofvertices num_controls]);
+			md = checkfield(md,'inversion.iscontrol','values',[0 1]);
+			md = checkfield(md,'inversion.tao','values',[0 1]);
+			md = checkfield(md,'inversion.incomplete_adjoint','values',[0 1]);
+			md = checkfield(md,'inversion.control_parameters','cell',1,'values',{'BalancethicknessThickeningRate' 'FrictionCoefficient' 'MaterialsRheologyBbar' 'Vx' 'Vy'});
+			md = checkfield(md,'inversion.nsteps','numel',1,'>=',1);
+			md = checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps 1],'>=',0);
+			md = checkfield(md,'inversion.step_threshold','size',[md.inversion.nsteps 1]);
+			md = checkfield(md,'inversion.cost_functions','size',[md.inversion.nsteps num_costfunc],'values',[101:105 201 501:503]);
+			md = checkfield(md,'inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);
+			md = checkfield(md,'inversion.gradient_only','values',[0 1]);
+			md = checkfield(md,'inversion.gradient_scaling','size',[md.inversion.nsteps num_controls]);
+			md = checkfield(md,'inversion.min_parameters','size',[md.mesh.numberofvertices num_controls]);
+			md = checkfield(md,'inversion.max_parameters','size',[md.mesh.numberofvertices num_controls]);
 
 			if solution==BalancethicknessSolutionEnum
-				checkfield(md,'inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
+				md = checkfield(md,'inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
 			else
-				checkfield(md,'inversion.vx_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
-				checkfield(md,'inversion.vy_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
+				md = checkfield(md,'inversion.vx_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
+				md = checkfield(md,'inversion.vy_obs','size',[md.mesh.numberofvertices 1],'NaN',1);
 			end
 		end % }}}
Index: /issm/trunk/src/m/classes/mask.m
===================================================================
--- /issm/trunk/src/m/classes/mask.m	(revision 12705)
+++ /issm/trunk/src/m/classes/mask.m	(revision 12706)
@@ -25,12 +25,12 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-			checkfield(md,'mask.elementonfloatingice','size',[md.mesh.numberofelements 1],'values',[0 1]);
-			checkfield(md,'mask.elementongroundedice','size',[md.mesh.numberofelements 1],'values',[0 1]);
-			checkfield(md,'mask.elementonwater'      ,'size',[md.mesh.numberofelements 1],'values',[0 1]);
-			checkfield(md,'mask.vertexonfloatingice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
-			checkfield(md,'mask.vertexongroundedice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
-			checkfield(md,'mask.vertexonwater'      ,'size',[md.mesh.numberofvertices 1],'values',[0 1]);
+			md = checkfield(md,'mask.elementonfloatingice','size',[md.mesh.numberofelements 1],'values',[0 1]);
+			md = checkfield(md,'mask.elementongroundedice','size',[md.mesh.numberofelements 1],'values',[0 1]);
+			md = checkfield(md,'mask.elementonwater'      ,'size',[md.mesh.numberofelements 1],'values',[0 1]);
+			md = checkfield(md,'mask.vertexonfloatingice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
+			md = checkfield(md,'mask.vertexongroundedice','size',[md.mesh.numberofvertices 1],'values',[0 1]);
+			md = checkfield(md,'mask.vertexonwater'      ,'size',[md.mesh.numberofvertices 1],'values',[0 1]);
 		end % }}}
 		function disp(obj) % {{{
Index: /issm/trunk/src/m/classes/materials.m
===================================================================
--- /issm/trunk/src/m/classes/materials.m	(revision 12705)
+++ /issm/trunk/src/m/classes/materials.m	(revision 12706)
@@ -69,12 +69,12 @@
 			obj.rheology_law='Paterson';
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
-			checkfield(md,'materials.rho_ice','>',0);
-			checkfield(md,'materials.rho_water','>',0);
-			checkfield(md,'materials.rho_freshwater','>',0);
-			checkfield(md,'materials.mu_water','>',0);
-			checkfield(md,'materials.rheology_B','>',0,'size',[md.mesh.numberofvertices 1]);
-			checkfield(md,'materials.rheology_n','>',0,'size',[md.mesh.numberofelements 1]);
-			checkfield(md,'materials.rheology_law','values',{'None' 'Paterson' 'Arrhenius'});
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
+			md = checkfield(md,'materials.rho_ice','>',0);
+			md = checkfield(md,'materials.rho_water','>',0);
+			md = checkfield(md,'materials.rho_freshwater','>',0);
+			md = checkfield(md,'materials.mu_water','>',0);
+			md = checkfield(md,'materials.rheology_B','>',0,'size',[md.mesh.numberofvertices 1]);
+			md = checkfield(md,'materials.rheology_n','>',0,'size',[md.mesh.numberofelements 1]);
+			md = checkfield(md,'materials.rheology_law','values',{'None' 'Paterson' 'Arrhenius'});
 		end % }}}
 		function disp(obj) % {{{
@@ -83,5 +83,5 @@
 			fielddisplay(obj,'rho_ice','ice density [kg/m^3]');
 			fielddisplay(obj,'rho_water','ocean water density [kg/m^3]');
-			fielddisplay(obj,'freshrho_water','fresh water density [kg/m^3]');
+			fielddisplay(obj,'rho_freshwater','fresh water density [kg/m^3]');
 			fielddisplay(obj,'mu_water','water viscosity [N s/m^2]');
 			fielddisplay(obj,'heatcapacity','heat capacity [J/kg/K]');
Index: /issm/trunk/src/m/classes/mesh.m
===================================================================
--- /issm/trunk/src/m/classes/mesh.m	(revision 12705)
+++ /issm/trunk/src/m/classes/mesh.m	(revision 12706)
@@ -64,33 +64,33 @@
 			obj.average_vertex_connectivity=25;
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-			checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]);
-			checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices 1]);
-			checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices 1]);
-			checkfield(md,'mesh.elements','NaN',1,'>',0,'values',1:md.mesh.numberofvertices);
+			md = checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]);
+			md = checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices 1]);
+			md = checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices 1]);
+			md = checkfield(md,'mesh.elements','NaN',1,'>',0,'values',1:md.mesh.numberofvertices);
 			if(md.mesh.dimension==2),
-				checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 3]);
+				md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 3]);
 			else
-				checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 6]);
+				md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 6]);
 			end
 			if any(~ismember(1:md.mesh.numberofvertices,sort(unique(md.mesh.elements(:)))));
-				checkmessage('orphan nodes have been found. Check the mesh outline');
+				md = checkmessage(md,'orphan nodes have been found. Check the mesh outline');
 			end
-			checkfield(md,'mesh.dimension','values',[2 3]);
-			checkfield(md,'mesh.numberoflayers','>=',0);
-			checkfield(md,'mesh.numberofelements','>',0);
-			checkfield(md,'mesh.numberofvertices','>',0);
+			md = checkfield(md,'mesh.dimension','values',[2 3]);
+			md = checkfield(md,'mesh.numberoflayers','>=',0);
+			md = checkfield(md,'mesh.numberofelements','>',0);
+			md = checkfield(md,'mesh.numberofvertices','>',0);
 			%no checks for numberofedges lat long and hemisphere
-			checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
-			checkfield(md,'mesh.elementonsurface','size',[md.mesh.numberofelements 1],'values',[0 1]);
-			checkfield(md,'mesh.vertexonbed','size',[md.mesh.numberofvertices 1],'values',[0 1]);
-			checkfield(md,'mesh.vertexonsurface','size',[md.mesh.numberofvertices 1],'values',[0 1]);
+			md = checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
+			md = checkfield(md,'mesh.elementonsurface','size',[md.mesh.numberofelements 1],'values',[0 1]);
+			md = checkfield(md,'mesh.vertexonbed','size',[md.mesh.numberofvertices 1],'values',[0 1]);
+			md = checkfield(md,'mesh.vertexonsurface','size',[md.mesh.numberofvertices 1],'values',[0 1]);
 			if (md.mesh.dimension==2),
-				checkfield(md,'mesh.average_vertex_connectivity','>=',9,'message','''mesh.average_vertex_connectivity'' should be at least 9 in 2d');
+				md = checkfield(md,'mesh.average_vertex_connectivity','>=',9,'message','''mesh.average_vertex_connectivity'' should be at least 9 in 2d');
 			else
-				checkfield(md,'mesh.average_vertex_connectivity','>=',24,'message','''mesh.average_vertex_connectivity'' should be at least 24 in 3d');
+				md = checkfield(md,'mesh.average_vertex_connectivity','>=',24,'message','''mesh.average_vertex_connectivity'' should be at least 24 in 3d');
 			end
-			checkfield(md,'mesh.elementconnectivity','size',[md.mesh.numberofelements 3],'NaN',1);
+			md = checkfield(md,'mesh.elementconnectivity','size',[md.mesh.numberofelements 3],'NaN',1);
 
 			%Solution specific checks
@@ -98,22 +98,22 @@
 				case PrognosticSolutionEnum,
 					if md.prognostic.stabilization==3,
-						checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
-						checkfield(md,'mesh.edges','size',[NaN 4]);
-						checkfield(md,'mesh.edges(:,1:3)','>',0);
+						md = checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
+						md = checkfield(md,'mesh.edges','size',[NaN 4]);
+						md = checkfield(md,'mesh.edges(:,1:3)','>',0);
 					end
 				case BalancethicknessSolutionEnum,
 					if md.balancethickness.stabilization==3,
-						checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
-						checkfield(md,'mesh.edges','size',[NaN 4]);
-						checkfield(md,'mesh.edges(:,1:3)','>',0);
+						md = checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
+						md = checkfield(md,'mesh.edges','size',[NaN 4]);
+						md = checkfield(md,'mesh.edges(:,1:3)','>',0);
 					end
 				case TransientSolutionEnum,
 					if md.transient.isprognostic & md.prognostic.stabilization==3,
-						checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
-						checkfield(md,'mesh.edges','size',[NaN 4]);
-						checkfield(md,'mesh.edges(:,1:3)','>',0);
+						md = checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
+						md = checkfield(md,'mesh.edges','size',[NaN 4]);
+						md = checkfield(md,'mesh.edges(:,1:3)','>',0);
 					end
 				case ThermalSolutionEnum,
-					checkfield(md,'mesh.dimension','values',3,'message','thermal solution only supported on 3d meshes');
+					md = checkfield(md,'mesh.dimension','values',3,'message','thermal solution only supported on 3d meshes');
 			end
 		end % }}}
Index: /issm/trunk/src/m/classes/miscellaneous.m
===================================================================
--- /issm/trunk/src/m/classes/miscellaneous.m	(revision 12705)
+++ /issm/trunk/src/m/classes/miscellaneous.m	(revision 12706)
@@ -19,7 +19,7 @@
 			end
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-			checkfield(md,'miscellaneous.name','empty',1);
+			md = checkfield(md,'miscellaneous.name','empty',1);
 
 		end % }}}
Index: sm/trunk/src/m/classes/model.py
===================================================================
--- /issm/trunk/src/m/classes/model.py	(revision 12705)
+++ 	(revision )
@@ -1,114 +1,0 @@
-#module imports {{{
-from mesh import mesh
-from mask import mask
-from geometry import geometry
-from constants import constants
-from surfaceforcings import surfaceforcings
-from basalforcings import basalforcings
-from materials import materials
-from friction import friction
-from flowequation import flowequation
-from timestepping import timestepping
-from initialization import initialization
-from rifts import rifts
-from debug import debug
-from verbose import verbose
-from settings import settings
-from solver import solver
-from none import none
-from balancethickness import balancethickness
-from diagnostic import diagnostic
-from groundingline import groundingline
-from hydrology import hydrology
-from prognostic import prognostic
-from thermal import thermal
-from steadystate import steadystate
-from transient import transient
-from autodiff import autodiff
-from flaim import flaim
-from inversion import inversion
-from qmu import qmu
-from radaroverlay import radaroverlay
-from miscellaneous import miscellaneous
-from private import private
-#}}}
-class model:
-	#properties
-	def __init__(self):
-		# {{{ Properties
-		self.mesh             = mesh()
-		self.mask             = mask()
-		self.geometry         = geometry()
-		self.constants        = constants()
-		self.surfaceforcings  = surfaceforcings()
-		self.basalforcings    = basalforcings()
-		self.materials        = materials()
-		self.friction         = friction()
-		self.flowequation     = flowequation()
-		self.timestepping     = timestepping()
-		self.initialization   = initialization()
-		self.rifts            = rifts()
-
-		self.debug            = debug()
-		self.verbose          = verbose()
-		self.settings         = settings()
-		self.solver           = solver()
-		self.cluster          = none()
-
-		self.balancethickness = balancethickness()
-		self.diagnostic       = diagnostic()
-		self.groundingline    = groundingline()
-		self.hydrology        = hydrology()
-		self.prognostic       = prognostic()
-		self.thermal          = thermal()
-		self.steadystate      = steadystate()
-		self.transient        = transient()
-
-		self.autodiff         = autodiff()
-		self.flaim            = flaim()
-		self.inversion        = inversion()
-		self.qmu              = qmu()
-
-		self.results          = [];
-		self.radaroverlay     = radaroverlay()
-		self.miscellaneous    = miscellaneous()
-		self.private          = private()
-		#}}}
-	def __repr__(obj):
-		# {{{ Display
-
-		#print "Here %s the number: %d" % ("is", 37)
-		string="%19s: %-22s -- %s" % ("mesh","[%s,%s]" % ("1x1",obj.mesh.__class__.__name__),"mesh properties")
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("mask","[%s,%s]" % ("1x1",obj.mask.__class__.__name__),"defines grounded and floating elements"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("geometry","[%s,%s]" % ("1x1",obj.geometry.__class__.__name__),"surface elevation, bedrock topography, ice thickness,..."))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("constants","[%s,%s]" % ("1x1",obj.constants.__class__.__name__),"physical constants"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("surfaceforcings","[%s,%s]" % ("1x1",obj.surfaceforcings.__class__.__name__),"surface forcings"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("basalforcings","[%s,%s]" % ("1x1",obj.basalforcings.__class__.__name__),"bed forcings"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("materials","[%s,%s]" % ("1x1",obj.materials.__class__.__name__),"material properties"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("friction","[%s,%s]" % ("1x1",obj.friction.__class__.__name__),"basal friction/drag properties"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("flowequation","[%s,%s]" % ("1x1",obj.flowequation.__class__.__name__),"flow equations"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("timestepping","[%s,%s]" % ("1x1",obj.timestepping.__class__.__name__),"time stepping for transient models"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("initialization","[%s,%s]" % ("1x1",obj.initialization.__class__.__name__),"initial guess/state"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("rifts","[%s,%s]" % ("1x1",obj.rifts.__class__.__name__),"rifts properties'"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("debug","[%s,%s]" % ("1x1",obj.debug.__class__.__name__),"debugging tools (valgrind, gprof"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("verbose","[%s,%s]" % ("1x1",obj.verbose.__class__.__name__),"verbosity level in solve"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("settings","[%s,%s]" % ("1x1",obj.settings.__class__.__name__),"settings properties"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("solver","[%s,%s]" % ("1x1",obj.solver.__class__.__name__),"PETSc options for each solution'"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("cluster","[%s,%s]" % ("1x1",obj.cluster.__class__.__name__),"cluster parameters (number of cpus...)"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("balancethickness","[%s,%s]" % ("1x1",obj.balancethickness.__class__.__name__),"parameters for balancethickness solution"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("diagnostic","[%s,%s]" % ("1x1",obj.diagnostic.__class__.__name__),"parameters for diagnostic solution"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("groundingline","[%s,%s]" % ("1x1",obj.groundingline.__class__.__name__),"parameters for groundingline solution"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("hydrology","[%s,%s]" % ("1x1",obj.hydrology.__class__.__name__),"parameters for hydrology solution"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("prognostic","[%s,%s]" % ("1x1",obj.prognostic.__class__.__name__),"parameters for prognostic solution"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("thermal","[%s,%s]" % ("1x1",obj.thermal.__class__.__name__),"parameters for thermal solution"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("steadystate","[%s,%s]" % ("1x1",obj.steadystate.__class__.__name__),"parameters for steadystate solution"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("transient","[%s,%s]" % ("1x1",obj.transient.__class__.__name__),"parameters for transient solution"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("autodiff","[%s,%s]" % ("1x1",obj.autodiff.__class__.__name__),"automatic differentiation parameters"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("flaim","[%s,%s]" % ("1x1",obj.flaim.__class__.__name__),"flaim parameters"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("inversion","[%s,%s]" % ("1x1",obj.inversion.__class__.__name__),"parameters for inverse methods"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("qmu","[%s,%s]" % ("1x1",obj.qmu.__class__.__name__),"dakota properties"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("results","[%s,%s]" % ("1x1",obj.results.__class__.__name__),"model results'"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("radaroverlay","[%s,%s]" % ("1x1",obj.radaroverlay.__class__.__name__),"radar image for plot overlay"))
-		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("miscellaneous","[%s,%s]" % ("1x1",obj.miscellaneous.__class__.__name__),"miscellaneous fields"))
-		return string;
-		 #}}}
Index: /issm/trunk/src/m/classes/model/model.m
===================================================================
--- /issm/trunk/src/m/classes/model/model.m	(revision 12705)
+++ /issm/trunk/src/m/classes/model/model.m	(revision 12706)
@@ -6,5 +6,5 @@
 classdef model
     properties (SetAccess=public) %Model fields
-		 % {{{1
+		 % {{{
 		 %Careful here: no other class should be used as default value this is a bug of matlab
 		 mesh             = 0;
@@ -75,5 +75,5 @@
 	 end
 	 methods
-		 function md = model(varargin) % {{{1
+		 function md = model(varargin) % {{{
 
 			 switch nargin
@@ -83,4 +83,10 @@
 					 error('model constructor error message: 0 of 1 argument only in input.');
 				 end
+		 end
+		 %}}}
+		 function md = checkmessage(md,string) % {{{
+			 if(nargout~=1) error('wrong usage, model must be an output'); end
+			 disp(['model not consistent: ' string]);
+			 md.private.isconsistent=false;
 		 end
 		 %}}}
@@ -242,8 +248,7 @@
 			 if isfield(structmd,'pressureload'), md.diagnostic.icefront=structmd.pressureload; end
 			 if isfield(structmd,'diagnostic_ref'), md.diagnostic.referential=structmd.diagnostic_ref; end
-
-
-
-
+			 if isfield(structmd,'npart'); md.qmu.numberofpartitions=structmd.npart; end
+			 if isfield(structmd,'part'); md.qmu.partition=structmd.part; end
+				 
 			 %Field changes
 			 if (isfield(structmd,'type') & ischar(structmd.type)), 
@@ -356,9 +361,7 @@
 				 md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6);
 			 end
-			 if isfield(structmd,'npart'); md.qmu.numberofpartitions=structmd.npart; end
-			 if isfield(structmd,'part'); md.qmu.partition=structmd.part; end
-				 
+
 		 end% }}}
-		 function md = setdefaultparameters(md) % {{{1
+		 function md = setdefaultparameters(md) % {{{
 
 			 %initialize subclasses
Index: /issm/trunk/src/m/classes/model/model.py
===================================================================
--- /issm/trunk/src/m/classes/model/model.py	(revision 12706)
+++ /issm/trunk/src/m/classes/model/model.py	(revision 12706)
@@ -0,0 +1,114 @@
+#module imports {{{
+from mesh import mesh
+from mask import mask
+from geometry import geometry
+from constants import constants
+from surfaceforcings import surfaceforcings
+from basalforcings import basalforcings
+from materials import materials
+from friction import friction
+from flowequation import flowequation
+from timestepping import timestepping
+from initialization import initialization
+from rifts import rifts
+from debug import debug
+from verbose import verbose
+from settings import settings
+from solver import solver
+from generic import generic
+from balancethickness import balancethickness
+from diagnostic import diagnostic
+from groundingline import groundingline
+from hydrology import hydrology
+from prognostic import prognostic
+from thermal import thermal
+from steadystate import steadystate
+from transient import transient
+from autodiff import autodiff
+from flaim import flaim
+from inversion import inversion
+from qmu import qmu
+from radaroverlay import radaroverlay
+from miscellaneous import miscellaneous
+from private import private
+#}}}
+class model:
+	#properties
+	def __init__(self):
+		# {{{ Properties
+		self.mesh             = mesh()
+		self.mask             = mask()
+		self.geometry         = geometry()
+		self.constants        = constants()
+		self.surfaceforcings  = surfaceforcings()
+		self.basalforcings    = basalforcings()
+		self.materials        = materials()
+		self.friction         = friction()
+		self.flowequation     = flowequation()
+		self.timestepping     = timestepping()
+		self.initialization   = initialization()
+		self.rifts            = rifts()
+
+		self.debug            = debug()
+		self.verbose          = verbose()
+		self.settings         = settings()
+		self.solver           = solver()
+		self.cluster          = generic()
+
+		self.balancethickness = balancethickness()
+		self.diagnostic       = diagnostic()
+		self.groundingline    = groundingline()
+		self.hydrology        = hydrology()
+		self.prognostic       = prognostic()
+		self.thermal          = thermal()
+		self.steadystate      = steadystate()
+		self.transient        = transient()
+
+		self.autodiff         = autodiff()
+		self.flaim            = flaim()
+		self.inversion        = inversion()
+		self.qmu              = qmu()
+
+		self.results          = [];
+		self.radaroverlay     = radaroverlay()
+		self.miscellaneous    = miscellaneous()
+		self.private          = private()
+		#}}}
+	def __repr__(obj):
+		# {{{ Display
+
+		#print "Here %s the number: %d" % ("is", 37)
+		string="%19s: %-22s -- %s" % ("mesh","[%s,%s]" % ("1x1",obj.mesh.__class__.__name__),"mesh properties")
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("mask","[%s,%s]" % ("1x1",obj.mask.__class__.__name__),"defines grounded and floating elements"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("geometry","[%s,%s]" % ("1x1",obj.geometry.__class__.__name__),"surface elevation, bedrock topography, ice thickness,..."))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("constants","[%s,%s]" % ("1x1",obj.constants.__class__.__name__),"physical constants"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("surfaceforcings","[%s,%s]" % ("1x1",obj.surfaceforcings.__class__.__name__),"surface forcings"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("basalforcings","[%s,%s]" % ("1x1",obj.basalforcings.__class__.__name__),"bed forcings"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("materials","[%s,%s]" % ("1x1",obj.materials.__class__.__name__),"material properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("friction","[%s,%s]" % ("1x1",obj.friction.__class__.__name__),"basal friction/drag properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("flowequation","[%s,%s]" % ("1x1",obj.flowequation.__class__.__name__),"flow equations"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("timestepping","[%s,%s]" % ("1x1",obj.timestepping.__class__.__name__),"time stepping for transient models"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("initialization","[%s,%s]" % ("1x1",obj.initialization.__class__.__name__),"initial guess/state"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("rifts","[%s,%s]" % ("1x1",obj.rifts.__class__.__name__),"rifts properties'"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("debug","[%s,%s]" % ("1x1",obj.debug.__class__.__name__),"debugging tools (valgrind, gprof"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("verbose","[%s,%s]" % ("1x1",obj.verbose.__class__.__name__),"verbosity level in solve"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("settings","[%s,%s]" % ("1x1",obj.settings.__class__.__name__),"settings properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("solver","[%s,%s]" % ("1x1",obj.solver.__class__.__name__),"PETSc options for each solution'"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("cluster","[%s,%s]" % ("1x1",obj.cluster.__class__.__name__),"cluster parameters (number of cpus...)"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("balancethickness","[%s,%s]" % ("1x1",obj.balancethickness.__class__.__name__),"parameters for balancethickness solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("diagnostic","[%s,%s]" % ("1x1",obj.diagnostic.__class__.__name__),"parameters for diagnostic solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("groundingline","[%s,%s]" % ("1x1",obj.groundingline.__class__.__name__),"parameters for groundingline solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("hydrology","[%s,%s]" % ("1x1",obj.hydrology.__class__.__name__),"parameters for hydrology solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("prognostic","[%s,%s]" % ("1x1",obj.prognostic.__class__.__name__),"parameters for prognostic solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("thermal","[%s,%s]" % ("1x1",obj.thermal.__class__.__name__),"parameters for thermal solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("steadystate","[%s,%s]" % ("1x1",obj.steadystate.__class__.__name__),"parameters for steadystate solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("transient","[%s,%s]" % ("1x1",obj.transient.__class__.__name__),"parameters for transient solution"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("autodiff","[%s,%s]" % ("1x1",obj.autodiff.__class__.__name__),"automatic differentiation parameters"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("flaim","[%s,%s]" % ("1x1",obj.flaim.__class__.__name__),"flaim parameters"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("inversion","[%s,%s]" % ("1x1",obj.inversion.__class__.__name__),"parameters for inverse methods"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("qmu","[%s,%s]" % ("1x1",obj.qmu.__class__.__name__),"dakota properties"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("results","[%s,%s]" % ("1x1",obj.results.__class__.__name__),"model results'"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("radaroverlay","[%s,%s]" % ("1x1",obj.radaroverlay.__class__.__name__),"radar image for plot overlay"))
+		string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("miscellaneous","[%s,%s]" % ("1x1",obj.miscellaneous.__class__.__name__),"miscellaneous fields"))
+		return string;
+		 #}}}
Index: /issm/trunk/src/m/classes/model/planet.m
===================================================================
--- /issm/trunk/src/m/classes/model/planet.m	(revision 12705)
+++ /issm/trunk/src/m/classes/model/planet.m	(revision 12706)
@@ -6,5 +6,5 @@
 classdef planet < model
     properties (SetAccess=public) %Planet fields
-		 % {{{1
+		 % {{{
 		 %Planet specific fields
 		 r=NaN;
@@ -14,5 +14,5 @@
 	 end
 	 methods
-		function md=planetmesh(md,varargin) % {{{1
+		function md=planetmesh(md,varargin) % {{{
 		%PLANETMESH: build 2d shell mesh
 		%
Index: /issm/trunk/src/m/classes/organizer.m
===================================================================
--- /issm/trunk/src/m/classes/organizer.m	(revision 12705)
+++ /issm/trunk/src/m/classes/organizer.m	(revision 12706)
@@ -16,5 +16,5 @@
 classdef organizer
     properties (SetAccess=private) 
-		 % {{{1
+		 % {{{
 		 currentstep   =0;
 	 end
@@ -28,5 +28,5 @@
 	 end
 	 methods
-		 function org=organizer(varargin) % {{{1
+		 function org=organizer(varargin) % {{{
 
 			 %process options
@@ -57,5 +57,5 @@
 		 end
 		 %}}}
-		 function disp(org) % {{{1
+		 function disp(org) % {{{
 			 disp(sprintf('   Repository: ''%s''',org.repository));
 			 disp(sprintf('   Prefix:     ''%s''',org.prefix));
@@ -69,5 +69,23 @@
 		 end
 		 %}}}
-		 function md=loadmodel(org,string),% {{{1
+		 function md=load(org,string),% {{{
+
+			 %Get model path
+			 if ~ischar(string), error('argument provided is not a string'); end
+			 path=[org.repository '/' org.prefix string];
+
+			 %figure out if the model is there
+			 if exist(path,'file'),
+				 struc=load(path,'-mat');
+				 name=char(fieldnames(struc));
+				 md=struc.(name);
+				 if nargout,
+					 varargout{1}=md;
+				 end
+			 else
+				 error(['Could not find ' path ]);
+			 end
+		 end%}}}
+		 function md=loadmodel(org,string),% {{{
 
 			 %Get model path
@@ -76,5 +94,5 @@
 
 			 %figure out if the model is there, otherwise, we have to use the default path supplied by user.
-			 if exist(path,'file'),
+			 if exist(path,'file') | exist([path '.mat'],'file'),
 				 md=loadmodel(path);
 				 return;
@@ -95,5 +113,5 @@
 			 end
 		 end%}}}
-		 function bool=perform(org,string) % {{{1
+		 function bool=perform(org,string) % {{{
 			 
 			 bool=false;
@@ -129,5 +147,5 @@
 
 		 end%}}}
-		 function savemodel(org,md) % {{{1
+		 function savemodel(org,md) % {{{
 
 			 %check
@@ -139,5 +157,5 @@
 			 
 			 %check that md is a model
-			 if ~isa(md,'model'),       error('savemodel error message: third argument is not a model'); end
+			 if ~isa(md,'model'), warning('third argument is not a model'); end
 			 if (org.currentstep>length(org.steps)), error(['organizer error message: element with id ' num2str(org.currentstep) ' not found']); end
 
Index: /issm/trunk/src/m/classes/pairoptions.m
===================================================================
--- /issm/trunk/src/m/classes/pairoptions.m	(revision 12705)
+++ /issm/trunk/src/m/classes/pairoptions.m	(revision 12706)
@@ -223,4 +223,23 @@
 			end
 		end % }}}
+		function marshall(obj,fid,firstindex)% {{{
+
+			for i=1:size(obj.list,1),
+				name  = obj.list{i,1};
+				value = obj.list{i,2};
+
+				%Write option name
+				WriteData(fid,'enum',(firstindex-1)+2*i-1,'data',name,'format','String');
+
+				%Write option value
+				if (isnumeric(value) & numel(value)==1),
+					WriteData(fid,'enum',(firstindex-1)+2*i,'data',value,'format','Double');
+				elseif ischar(value),
+					WriteData(fid,'enum',(firstindex-1)+2*i,'data',value,'format','String');
+				else
+					error(['Cannot marshall option ' name ': format not supported yet']);
+				end
+			end
+		end % }}}
 	end
 end
Index: /issm/trunk/src/m/classes/pairoptions.py
===================================================================
--- /issm/trunk/src/m/classes/pairoptions.py	(revision 12705)
+++ /issm/trunk/src/m/classes/pairoptions.py	(revision 12706)
@@ -1,38 +1,213 @@
-class pairoptions:
-	#properties
-	def __init__(self,*args):
-		# {{{ Properties
-		if len(args)%2==1:
-			raise RuntimeError('pairoption error message: an even number of options is required')
-
-		#create a pairoption object
-		if len(args)==0:
-			self.list=[]
-		else:
-			self.list=[]
-			for i in range(int(round(len(args)/2))):
-				if isinstance(args[2*i],str):
-					self.list.append([args[2*i],args[2*i+1]])
+"""
+PAIROPTIONS class definition
+ 
+    Usage:
+       pairoptions=pairoptions();
+       pairoptions=pairoptions('module',true,'solver',false);
+"""
+
+from WriteData import *
+
+class pairoptions(object):
+	def __init__(self,*arg):
+		self.functionname = ''
+		self.list         = {}
+
+		#get calling function name
+		import inspect
+		if len(inspect.stack()) > 1:
+			self.functionname=inspect.stack()[1][3]
+
+		#initialize list
+		if not len(arg):
+			pass    #Do nothing,
+		else:
+			self.buildlist(*arg)
+	# }}}
+
+	def buildlist(self,*arg):    # {{{
+		"""BUILDLIST - build list of objects from input"""
+
+		#check length of input
+		if len(arg) % 2:
+			raise TypeError('error: an even number of options is required') 
+		numoptions = len(arg)/2
+
+		#go through arg and build list of objects
+		for i in xrange(numoptions):
+			if isinstance(arg[2*i],str):
+				self.list[arg[2*i]] = arg[2*i+1];
+			else:
+				#option is not a string, ignore it
+				print "WARNING: option number %d '%s' is not a string and will be ignored." % (i+1,type(arg[2*i]))
+	# }}}
+
+	def addfield(self,field,value):    # {{{
+		"""ADDFIELD - add a field to an options list"""
+		if isinstance(field,str):
+			if field in self.list:
+				print "WARNING: field '%s' with value=%s exists and will be overwritten with value=%s." % (field,str(self.list[field]),str(value))
+			self.list[field] = value
+	# }}}
+
+	def addfielddefault(self,field,value):    # {{{
+		"""ADDFIELDDEFAULT - add a field to an options list if it does not exist"""
+		if isinstance(field,str):
+			if not field in self.list:
+				self.list[field] = value
+	# }}}
+
+	def AssignObjectFields(self,obj2):    # {{{
+		"""ASSIGNOBJECTFIELDS - assign object fields from options"""
+		for item in self.list.iteritems():
+			if item[0] in dir(obj2):
+				setattr(obj2,item[0],item[1])
+			else:
+				print "WARNING: field '%s' is not a property of '%s'." % (item[0],type(obj2))
+		return obj2
+	# }}}
+
+	def changefieldvalue(self,field,newvalue):    # {{{
+		"""CHANGEOPTIONVALUE - change the value of an option in an option list"""
+
+		self.list[field]=newvalue;
+	# }}}
+
+#	function obj = deleteduplicates(obj,warn) % {{{
+#	%DELETEDUPLICATES - delete duplicates in an option list
+#
+#		%track the first occurance of each option
+#		[dummy lines]=unique(obj.list(:,1),'first');
+#		clear dummy
+#
+#		%warn user if requested
+#		if warn,
+#			numoptions=size(obj.list,1);
+#			for i=1:numoptions,
+#				if ~ismember(i,lines),
+#					disp(['WARNING: option ' obj.list{i,1} ' appeared more than once. Only its first occurence will be kept'])
+#				end
+#			end
+#		end
+#
+#		%remove duplicates from the options list
+#		obj.list=obj.list(lines,:);
+#	end % }}}
+
+	def __repr__(self):    # {{{
+		s="   functionname: '%s'\n" % self.functionname
+		if self.list:
+			s+="   list: (%ix%i)\n\n" % (len(self.list),2)
+			for item in self.list.iteritems():
+				if   isinstance(item[1],str):
+					s+="     field: %-10s value: '%s'\n" % (item[0],item[1])
+				elif isinstance(item[1],(bool,int,long,float)):
+					s+="     field: %-10s value: %g\n" % (item[0],item[1])
 				else:
-					#option is not a string, ignore it
-					print("%s%i%s"%('buildlist info: option number ',i,' is not a string, it will be ignored'))
-					continue
-
-		#}}}
-	def __repr__(obj):
-		# {{{ Display
-		if not obj.list:
-			string='   list: empty'
-		else:
-			string="   list: (%i)"%(len(obj.list))
-			for i in range(len(obj.list)):
-				if isinstance(obj.list[i][1],str):
-					string2="     field: %-10s value: '%s'"%(obj.list[i][0],obj.list[i][1])
-				elif isinstance(obj.list[i][1],float):
-					string2="     field: %-10s value: %g"%(obj.list[i][0],obj.list[i][1])
-				elif isinstance(obj.list[i][1],int):
-					string2="     field: %-10s value: %i"%(obj.list[i][0],obj.list[i][1])
-				else:
-					string2="     field: %-10s value: (%i)"%(len(obj.list[i][1]))
-				string="%s\n%s"%(string,string2)
-		return string
+					s+="     field: %-10s value: %s\n" % (item[0],type(item[1]))
+		else:
+			s+="   list: empty\n"
+		return s
+	# }}}
+
+	def exist(self,field):    # {{{
+		"""EXIST - check if the option exist"""
+
+		#some argument checking: 
+		if field == None or field == '':
+			raise ValueError('exist error message: bad usage');
+		if not isinstance(field,str):
+			raise TypeError("exist error message: field '%s' should be a string." % str(field));
+
+		#Recover option
+		if field in self.list:
+			return True
+		else:
+			return False
+	# }}}
+
+#	function num = fieldoccurences(obj,field), % {{{
+#	%FIELDOCCURENCES - get number of occurence of a field
+#
+#		%check input 
+#		if ~ischar(field),
+#			error('fieldoccurences error message: field should be a string');
+#		end
+#
+#		%get number of occurence
+#		num=sum(strcmpi(field,obj.list(:,1)));
+#	end % }}}
+
+	def getfieldvalue(self,field,default=None):    # {{{
+		"""
+		GETOPTION - get the value of an option
+	
+		Usage:
+		   value=options.getfieldvalue(field,default)
+	 
+		Find an option value from a field. A default option
+		can be given in input if the field does not exist
+	 
+		Examples:
+		   value=options.getfieldvalue(options,'caxis')
+		   value=options.getfieldvalue(options,'caxis',[0 2])
+		"""
+
+		#some argument checking: 
+		if field == None or field == '':
+			raise ValueError('getfieldvalue error message: bad usage');
+		if not isinstance(field,str):
+			raise TypeError("getfieldvalue error message: field '%s' should be a string." % str(field));
+
+		#Recover option
+		if field in self.list:
+			value=self.list[field]
+		else:
+			if not default == None:
+				value=default
+			else:
+				raise KeyError("error message: field '%s' has not been provided by user (and no default value has been specified)." % field)
+
+		return value
+	# }}}
+
+	def removefield(self,field,warn):    # {{{
+		"""
+		REMOVEFIELD - delete a field in an option list
+	 
+		Usage:
+		   obj=removefield(self,field,warn)
+	 
+		if warn==1 display an info message to warn user that
+		some of his options have been removed.
+		"""
+
+		#check if field exist
+		if field in self.list:
+
+			#remove duplicates from the options list
+			del self.list[field]
+
+			#warn user if requested
+			if warn:
+				print "removefield info: option '%s' has been removed from the list of options." % field
+	# }}}
+
+	def marshall(self,fid,firstindex):    # {{{
+
+		for i,item in enumerate(self.list.iteritems()):
+			name  = item[0]
+			value = item[1]
+
+			#Write option name
+			WriteData(fid,'enum',(firstindex-1)+2*i+1,'data',name,'format','String')
+
+			#Write option value
+			if   isinstance(value,str):
+				WriteData(fid,'enum',(firstindex-1)+2*i+2,'data',value,'format','String')
+			elif isinstance(value,(bool,int,long,float)):
+				WriteData(fid,'enum',(firstindex-1)+2*i+2,'data',value,'format','Double')
+			else:
+				raise TypeError("Cannot marshall option '%s': format not supported yet." % name)
+	# }}}
+
Index: /issm/trunk/src/m/classes/plotoptions.m
===================================================================
--- /issm/trunk/src/m/classes/plotoptions.m	(revision 12705)
+++ /issm/trunk/src/m/classes/plotoptions.m	(revision 12706)
@@ -6,5 +6,5 @@
 classdef plotoptions
     properties (SetAccess=public) 
-		 % {{{1
+		 % {{{
 		 numberofplots = 0;
 		 figurenumber  = 1;
@@ -13,9 +13,9 @@
 	 end
 	 methods
-		 function opt=plotoptions(varargin) % {{{1
+		 function opt=plotoptions(varargin) % {{{
 			 opt=buildlist(opt,varargin{:});
 		 end
 		 %}}}
-		 function disp(opt) % {{{1
+		 function disp(opt) % {{{
 			 disp(sprintf('\n%s = \n',inputname(1)));
 			 disp(sprintf('   numberofplots: %i',opt.numberofplots));
@@ -41,5 +41,5 @@
 		 end
 		 %}}}
-		 function opt=buildlist(opt,varargin) % {{{1
+		 function opt=buildlist(opt,varargin) % {{{
 
 			 %check length of input
Index: /issm/trunk/src/m/classes/private.m
===================================================================
--- /issm/trunk/src/m/classes/private.m	(revision 12705)
+++ /issm/trunk/src/m/classes/private.m	(revision 12706)
@@ -6,7 +6,8 @@
 classdef private
 	properties (SetAccess=public) 
-		 runtimename = '';
-		 bamg        = struct();
-		 solution    = '';
+		isconsistent = true;
+		runtimename  = '';
+		bamg         = struct();
+		solution     = '';
 	end
 	methods
@@ -22,5 +23,5 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 		end % }}}
@@ -28,4 +29,5 @@
 			disp(sprintf('   private parameters: do not change'));
 
+			fielddisplay(obj,'isconsistent','is model self consistent');
 			fielddisplay(obj,'runtimename','name of the run launched');
 			fielddisplay(obj,'bamg','structure with mesh properties construced if bamg is used to mesh the domain');
Index: /issm/trunk/src/m/classes/prognostic.m
===================================================================
--- /issm/trunk/src/m/classes/prognostic.m	(revision 12705)
+++ /issm/trunk/src/m/classes/prognostic.m	(revision 12706)
@@ -36,13 +36,13 @@
 			obj.hydrostatic_adjustment='Absolute';
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return,
 			if ~ismember(PrognosticAnalysisEnum,analyses) |  (solution==TransientSolutionEnum & md.transient.isprognostic==0), return; end
 
-			checkfield(md,'prognostic.spcthickness','forcing',1);
-			checkfield(md,'prognostic.hydrostatic_adjustment','values',{'Absolute' 'Incremental'});
-			checkfield(md,'prognostic.stabilization','values',[0 1 2 3]);
-			checkfield(md,'prognostic.min_thickness','>',0);
+			md = checkfield(md,'prognostic.spcthickness','forcing',1);
+			md = checkfield(md,'prognostic.hydrostatic_adjustment','values',{'Absolute' 'Incremental'});
+			md = checkfield(md,'prognostic.stabilization','values',[0 1 2 3]);
+			md = checkfield(md,'prognostic.min_thickness','>',0);
 
 		end % }}}
Index: /issm/trunk/src/m/classes/qmu.m
===================================================================
--- /issm/trunk/src/m/classes/qmu.m	(revision 12705)
+++ /issm/trunk/src/m/classes/qmu.m	(revision 12706)
@@ -35,5 +35,5 @@
 	
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
@@ -41,27 +41,27 @@
 
 			if md.qmu.params.evaluation_concurrency~=1,
-				checkmessage(['concurrency should be set to 1 when running dakota in library mode']);
+				md = checkmessage(md,['concurrency should be set to 1 when running dakota in library mode']);
 			end
 			if ~isempty(md.qmu.partition),
 				if numel(md.qmu.partition)~=md.mesh.numberofvertices,
-					checkmessage(['user supplied partition for qmu analysis should have size md.mesh.numberofvertices x 1 ']);
+					md = checkmessage(md,['user supplied partition for qmu analysis should have size md.mesh.numberofvertices x 1 ']);
 				end
 				if find(md.qmu.partition)>=md.mesh.numberofvertices,
-					checkmessage(['user supplied partition should be indexed from 0 (c-convention)']);
+					md = checkmessage(md,['user supplied partition should be indexed from 0 (c-convention)']);
 				end
 				if min(md.qmu.partition)~=0,
-					checkmessage(['partition vector not indexed from 0 on']);
+					md = checkmessage(md,['partition vector not indexed from 0 on']);
 				end
 				if max(md.qmu.partition)>=md.mesh.numberofvertices,
-					checkmessage(['partition vector cannot have maximum index larger than number of nodes']);
+					md = checkmessage(md,['partition vector cannot have maximum index larger than number of nodes']);
 				end
 				if ~isempty(find(md.qmu.partition<0)),
-					checkmessage(['partition vector cannot have values less than 0']);
+					md = checkmessage(md,['partition vector cannot have values less than 0']);
 				end
 				if ~isempty(find(md.qmu.partition>=md.qmu.numberofpartitions)),
-					checkmessage(['partition vector cannot have values more than md.qmu.numberofpartitions-1']);
+					md = checkmessage(md,['partition vector cannot have values more than md.qmu.numberofpartitions-1']);
 				end
 				if max(md.qmu.partition)>=md.qmu.numberofpartitions,
-					checkmessage(['for qmu analysis, partitioning vector cannot go over npart, number of partition areas']);
+					md = checkmessage(md,['for qmu analysis, partitioning vector cannot go over npart, number of partition areas']);
 				end
 			end
@@ -69,5 +69,5 @@
 			if ~strcmpi(md.cluster.name,'none'),
 				if md.settings.waitonlock==0,
-					checkmessage(['waitonlock should be activated when running qmu in parallel mode!']);
+					md = checkmessage(md,['waitonlock should be activated when running qmu in parallel mode!']);
 				end
 			end
Index: /issm/trunk/src/m/classes/rifts.m
===================================================================
--- /issm/trunk/src/m/classes/rifts.m	(revision 12705)
+++ /issm/trunk/src/m/classes/rifts.m	(revision 12706)
@@ -21,5 +21,5 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 			if isempty(obj.riftstruct) | isnans(obj.riftstruct),
 				numrifts=0;
@@ -29,17 +29,17 @@
 			if numrifts,
 				if ~(md.mesh.dimension==2),
-					checkmessage(['models with rifts are only supported in 2d for now!']);
+					md = checkmessage(md,['models with rifts are only supported in 2d for now!']);
 				end
 				if ~isstruct(obj.riftstruct),
-					checkmessage(['rifts.riftstruct should be a structure!']);
+					md = checkmessage(md,['rifts.riftstruct should be a structure!']);
 				end
 				if ~isempty(find(md.mesh.segmentmarkers>=2)),
 					%We have segments with rift markers, but no rift structure!
-					checkmessage(['model should be processed for rifts (run meshprocessrifts)!']);
+					md = checkmessage(md,['model should be processed for rifts (run meshprocessrifts)!']);
 				end
-				checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
+				md = checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
 			else
 				if ~isnans(obj.riftstruct),
-					checkmessage(['riftstruct shoud be NaN since numrifts is 0!']);
+					md = checkmessage(md,['riftstruct shoud be NaN since numrifts is 0!']);
 				end
 			end
Index: /issm/trunk/src/m/classes/settings.m
===================================================================
--- /issm/trunk/src/m/classes/settings.m	(revision 12705)
+++ /issm/trunk/src/m/classes/settings.m	(revision 12706)
@@ -41,11 +41,11 @@
 			obj.waitonlock=Inf;
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-			checkfield(md,'settings.io_gather','numel',1,'values',[0 1]);
-			checkfield(md,'settings.lowmem','numel',1,'values',[0 1]);
-			checkfield(md,'settings.results_as_patches','numel',1,'values',[0 1]);
-			checkfield(md,'settings.output_frequency','numel',1,'>=',1);
-			checkfield(md,'settings.waitonlock','numel',1);
+			md = checkfield(md,'settings.io_gather','numel',1,'values',[0 1]);
+			md = checkfield(md,'settings.lowmem','numel',1,'values',[0 1]);
+			md = checkfield(md,'settings.results_as_patches','numel',1,'values',[0 1]);
+			md = checkfield(md,'settings.output_frequency','numel',1,'>=',1);
+			md = checkfield(md,'settings.waitonlock','numel',1);
 
 		end % }}}
Index: /issm/trunk/src/m/classes/solver.m
===================================================================
--- /issm/trunk/src/m/classes/solver.m	(revision 12705)
+++ /issm/trunk/src/m/classes/solver.m	(revision 12706)
@@ -18,5 +18,5 @@
 				 end
 			 end % }}}
-		 function obj = addoptions(obj,analysis,varargin) % {{{1
+		 function obj = addoptions(obj,analysis,varargin) % {{{
 		 % Usage example:
 		 %    md.solver=addoptions(md.solver,DiagnosticHorizAnalysisEnum,stokesoptions());
@@ -54,9 +54,9 @@
 			 end
 		 end % }}}
-		 function checkconsistency(obj,md,solution,analyses) % {{{
+		 function md = checkconsistency(obj,md,solution,analyses) % {{{
 			 analyses=properties(obj);
 			 for i=1:numel(analyses),
 				 if isempty(fieldnames(obj.(analyses{i})))
-					 checkmessage(['md.solver.' analyses{i} ' is empty']);
+					 md = checkmessage(md,['md.solver.' analyses{i} ' is empty']);
 				 end
 			 end
Index: /issm/trunk/src/m/classes/steadystate.m
===================================================================
--- /issm/trunk/src/m/classes/steadystate.m	(revision 12705)
+++ /issm/trunk/src/m/classes/steadystate.m	(revision 12706)
@@ -26,5 +26,5 @@
 			obj.reltol=0.01;
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
@@ -32,9 +32,9 @@
 
 			if md.timestepping.time_step~=0,
-				checkmessage(['for a steadystate computation, timestepping.time_step must be zero.']);
+				md = checkmessage(md,['for a steadystate computation, timestepping.time_step must be zero.']);
 			end
 
 			if isnan(md.diagnostic.reltol),
-				checkmessage(['for a steadystate computation, diagnostic.reltol (relative convergence criterion) must be defined!']);
+				md = checkmessage(md,['for a steadystate computation, diagnostic.reltol (relative convergence criterion) must be defined!']);
 			end
 		end % }}}
Index: /issm/trunk/src/m/classes/surfaceforcings.m
===================================================================
--- /issm/trunk/src/m/classes/surfaceforcings.m	(revision 12705)
+++ /issm/trunk/src/m/classes/surfaceforcings.m	(revision 12706)
@@ -9,4 +9,12 @@
 		mass_balance  = NaN;
 		ispdd = 0;
+		issmbgradients = 0;
+	   hc = NaN;
+		smb_pos_max = NaN;
+		smb_pos_min = NaN;
+		a_pos = NaN;
+		b_pos = NaN;
+		a_neg = NaN;
+		b_neg = NaN;
 		monthlytemperatures = NaN;
 	end
@@ -24,18 +32,28 @@
 		  %pdd method not used in default mode
 		  obj.ispdd=0;
+		  obj.issmbgradients=0;
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			if ismember(PrognosticAnalysisEnum,analyses),
-				checkfield(md,'surfaceforcings.ispdd','numel',1,'values',[0 1]);
+				md = checkfield(md,'surfaceforcings.ispdd','numel',1,'values',[0 1]);
+				checkfield(md,'surfaceforcings.issmbgradients','numel',1,'values',[0 1]);
 				if(obj.ispdd)
-					checkfield(md,'surfaceforcings.monthlytemperatures','forcing',1,'NaN',1);
+					md = checkfield(md,'surfaceforcings.monthlytemperatures','forcing',1,'NaN',1);
+				elseif(obj.issmbgradients)
+					checkfield(md,'surfaceforcings.hc','forcing',1,'NaN',1);
+					checkfield(md,'surfaceforcings.smb_pos_max','forcing',1,'NaN',1);
+					checkfield(md,'surfaceforcings.smb_pos_min','forcing',1,'NaN',1);
+					checkfield(md,'surfaceforcings.a_pos','forcing',1,'NaN',1);
+					checkfield(md,'surfaceforcings.b_pos','forcing',1,'NaN',1);
+					checkfield(md,'surfaceforcings.a_neg','forcing',1,'NaN',1);
+					checkfield(md,'surfaceforcings.b_neg','forcing',1,'NaN',1);
 				else
-					checkfield(md,'surfaceforcings.mass_balance','forcing',1,'NaN',1);
+					md = checkfield(md,'surfaceforcings.mass_balance','forcing',1,'NaN',1);
 				end
 			end
 			if ismember(BalancethicknessAnalysisEnum,analyses),
-				checkfield(md,'surfaceforcings.mass_balance','size',[md.mesh.numberofvertices 1],'NaN',1);
+				md = checkfield(md,'surfaceforcings.mass_balance','size',[md.mesh.numberofvertices 1],'NaN',1);
 			end
 		end % }}}
@@ -47,4 +65,12 @@
 			fielddisplay(obj,'ispdd','is pdd activated (0 or 1, default is 0)');
 			fielddisplay(obj,'monthlytemperatures','monthly surface temperatures required if pdd is activated');
+			fielddisplay(obj,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)');
+			fielddisplay(obj,'hc',' elevation of intersection between accumulation and ablation regime required if smb gradients is activated');
+			fielddisplay(obj,'smb_pos_max',' maximum value of positive smb required if smb gradients is activated');
+			fielddisplay(obj,'smb_pos_min',' minimum value of positive smb required if smb gradients is activated');
+			fielddisplay(obj,'a_pos',' intercept of hs - smb regression line for accumulation regime required if smb gradients is activated');
+			fielddisplay(obj,'b_pos',' slope of hs - smb regression line for accumulation regime required if smb gradients is activated');
+			fielddisplay(obj,'a_neg',' intercept of hs - smb regression line for ablation regime required if smb gradients is activated');
+			fielddisplay(obj,'b_neg',' slope of hs - smb regression line for ablation regime required if smb gradients is activated');
 
 		end % }}}
@@ -56,4 +82,14 @@
 				WriteData(fid,'object',obj,'fieldname','monthlytemperatures','format','DoubleMat','mattype',1);
 			end
+			WriteData(fid,'object',obj,'fieldname','issmbgradients','format','Boolean');
+			if obj.issmbgradients,
+				WriteData(fid,'object',obj,'fieldname','hc','format','DoubleMat','mattype',1);
+				WriteData(fid,'object',obj,'fieldname','smb_pos_max','format','DoubleMat','mattype',1);
+				WriteData(fid,'object',obj,'fieldname','smb_pos_min','format','DoubleMat','mattype',1);
+				WriteData(fid,'object',obj,'fieldname','a_pos','format','DoubleMat','mattype',1);
+				WriteData(fid,'object',obj,'fieldname','b_pos','format','DoubleMat','mattype',1);
+				WriteData(fid,'object',obj,'fieldname','a_neg','format','DoubleMat','mattype',1);
+				WriteData(fid,'object',obj,'fieldname','b_neg','format','DoubleMat','mattype',1);
+			end
 
 		end % }}}
Index: /issm/trunk/src/m/classes/thermal.m
===================================================================
--- /issm/trunk/src/m/classes/thermal.m	(revision 12705)
+++ /issm/trunk/src/m/classes/thermal.m	(revision 12706)
@@ -40,14 +40,14 @@
 			obj.isenthalpy=0;
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
 			if (~ismember(ThermalAnalysisEnum,analyses) & ~ismember(EnthalpyAnalysisEnum,analyses)) | (solution==TransientSolutionEnum & md.transient.isthermal==0), return; end
 
-			checkfield(md,'thermal.stabilization','numel',1,'values',[0 1 2]);
-			checkfield(md,'thermal.spctemperature','forcing',1);
-			if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy),
-			checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*md.geometry.thickness,'message','spctemperature should be below the adjusted melting point');
-			checkfield(md,'thermal.isenthalpy','numel',1,'values',[0 1]);
+			md = checkfield(md,'thermal.stabilization','numel',1,'values',[0 1 2]);
+			md = checkfield(md,'thermal.spctemperature','forcing',1);
+			if (ismember(EnthalpyAnalysisEnum,analyses) & md.thermal.isenthalpy & md.mesh.dimension==3),
+			md = checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*(md.geometry.surface-md.mesh.z),'message','spctemperature should be below the adjusted melting point');
+			md = checkfield(md,'thermal.isenthalpy','numel',1,'values',[0 1]);
 			end
 		end % }}}
Index: /issm/trunk/src/m/classes/timestepping.m
===================================================================
--- /issm/trunk/src/m/classes/timestepping.m	(revision 12705)
+++ /issm/trunk/src/m/classes/timestepping.m	(revision 12706)
@@ -33,13 +33,13 @@
 			obj.cfl_coefficient=.5;
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-			checkfield(md,'timestepping.start_time','numel',1,'NaN',1);
-			checkfield(md,'timestepping.final_time','numel',1,'NaN',1);
-			checkfield(md,'timestepping.time_step','numel',1,'>=',0,'NaN',1);
-			checkfield(md,'timestepping.time_adapt','numel',1,'values',[0 1]);
-			checkfield(md,'timestepping.cfl_coefficient','numel',1,'>',0,'<=',1);
+			md = checkfield(md,'timestepping.start_time','numel',1,'NaN',1);
+			md = checkfield(md,'timestepping.final_time','numel',1,'NaN',1);
+			md = checkfield(md,'timestepping.time_step','numel',1,'>=',0,'NaN',1);
+			md = checkfield(md,'timestepping.time_adapt','numel',1,'values',[0 1]);
+			md = checkfield(md,'timestepping.cfl_coefficient','numel',1,'>',0,'<=',1);
 			if obj.final_time-obj.start_time<0,
-				checkmessage('timestepping.final_time should be larger than timestepping.start_time');
+				md = checkmessage(md,'timestepping.final_time should be larger than timestepping.start_time');
 			end 
 		end % }}}
Index: /issm/trunk/src/m/classes/transient.m
===================================================================
--- /issm/trunk/src/m/classes/transient.m	(revision 12705)
+++ /issm/trunk/src/m/classes/transient.m	(revision 12706)
@@ -30,13 +30,13 @@
 
 		end % }}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 			%Early return
 			if solution~=TransientSolutionEnum, return; end
 
-			checkfield(md,'transient.isprognostic','numel',1,'values',[0 1]);
-			checkfield(md,'transient.isdiagnostic','numel',1,'values',[0 1]);
-			checkfield(md,'transient.isthermal','numel',1,'values',[0 1]);
-			checkfield(md,'transient.isgroundingline','numel',1,'values',[0 1]);
+			md = checkfield(md,'transient.isprognostic','numel',1,'values',[0 1]);
+			md = checkfield(md,'transient.isdiagnostic','numel',1,'values',[0 1]);
+			md = checkfield(md,'transient.isthermal','numel',1,'values',[0 1]);
+			md = checkfield(md,'transient.isgroundingline','numel',1,'values',[0 1]);
 
 		end % }}}
Index: /issm/trunk/src/m/classes/verbose.m
===================================================================
--- /issm/trunk/src/m/classes/verbose.m	(revision 12705)
+++ /issm/trunk/src/m/classes/verbose.m	(revision 12706)
@@ -21,5 +21,5 @@
 classdef verbose
 	properties (SetAccess=public) 
-		% {{{1
+		% {{{
 		%BEGINFIELDS
 		mprocessor  = false;
@@ -35,5 +35,5 @@
 	%}}}
 	methods
-		function verbose=verbose(varargin) % {{{1
+		function verbose=verbose(varargin) % {{{
 
 			switch(nargin),
@@ -70,5 +70,5 @@
 		end
 		%}}}
-		function binary=VerboseToBinary(verbose) % {{{1
+		function binary=VerboseToBinary(verbose) % {{{
 
 		%BEGINVERB2BIN
@@ -85,5 +85,5 @@
 		end
 		%}}}
-		function verbose=BinaryToVerbose(verbose,binary) % {{{1
+		function verbose=BinaryToVerbose(verbose,binary) % {{{
 
 		%BEGINBIN2VERB
@@ -99,8 +99,8 @@
 		end
 		%}}}
-		function checkconsistency(obj,md,solution,analyses) % {{{
+		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
 		end % }}}
-		function disp(verbose) % {{{1
+		function disp(verbose) % {{{
 			
 		%BEGINDISP
Index: sm/trunk/src/m/enum/DebugPetscProfilingEnum.m
===================================================================
--- /issm/trunk/src/m/enum/DebugPetscProfilingEnum.m	(revision 12705)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=DebugPetscProfilingEnum()
-%DEBUGPETSCPROFILINGENUM - Enum of DebugPetscProfiling
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
-%            Please read src/c/EnumDefinitions/README for more information
-%
-%   Usage:
-%      macro=DebugPetscProfilingEnum()
-
-macro=StringToEnum('DebugPetscProfiling');
Index: /issm/trunk/src/m/enum/DebugProfilingEnum.m
===================================================================
--- /issm/trunk/src/m/enum/DebugProfilingEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/DebugProfilingEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=DebugProfilingEnum()
+%DEBUGPROFILINGENUM - Enum of DebugProfiling
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=DebugProfilingEnum()
+
+macro=StringToEnum('DebugProfiling');
Index: /issm/trunk/src/m/enum/EnumDefinitions.py
===================================================================
--- /issm/trunk/src/m/enum/EnumDefinitions.py	(revision 12706)
+++ /issm/trunk/src/m/enum/EnumDefinitions.py	(revision 12706)
@@ -0,0 +1,4498 @@
+"""
+
+   WARNING: DO NOT MODIFY THIS FILE
+            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+            Please read src/c/EnumDefinitions/README for more information
+
+"""
+
+def AutodiffForwardEnum():
+	"""
+	AUTODIFFFORWARDENUM - Enum of AutodiffForward
+
+	   Usage:
+	      macro=AutodiffForwardEnum()
+	"""
+
+	return StringToEnum('AutodiffForward')
+
+def AutodiffIsautodiffEnum():
+	"""
+	AUTODIFFISAUTODIFFENUM - Enum of AutodiffIsautodiff
+
+	   Usage:
+	      macro=AutodiffIsautodiffEnum()
+	"""
+
+	return StringToEnum('AutodiffIsautodiff')
+
+def AutodiffReverseEnum():
+	"""
+	AUTODIFFREVERSEENUM - Enum of AutodiffReverse
+
+	   Usage:
+	      macro=AutodiffReverseEnum()
+	"""
+
+	return StringToEnum('AutodiffReverse')
+
+def BalancethicknessSpcthicknessEnum():
+	"""
+	BALANCETHICKNESSSPCTHICKNESSENUM - Enum of BalancethicknessSpcthickness
+
+	   Usage:
+	      macro=BalancethicknessSpcthicknessEnum()
+	"""
+
+	return StringToEnum('BalancethicknessSpcthickness')
+
+def BalancethicknessStabilizationEnum():
+	"""
+	BALANCETHICKNESSSTABILIZATIONENUM - Enum of BalancethicknessStabilization
+
+	   Usage:
+	      macro=BalancethicknessStabilizationEnum()
+	"""
+
+	return StringToEnum('BalancethicknessStabilization')
+
+def BalancethicknessThickeningRateEnum():
+	"""
+	BALANCETHICKNESSTHICKENINGRATEENUM - Enum of BalancethicknessThickeningRate
+
+	   Usage:
+	      macro=BalancethicknessThickeningRateEnum()
+	"""
+
+	return StringToEnum('BalancethicknessThickeningRate')
+
+def BasalforcingsGeothermalfluxEnum():
+	"""
+	BASALFORCINGSGEOTHERMALFLUXENUM - Enum of BasalforcingsGeothermalflux
+
+	   Usage:
+	      macro=BasalforcingsGeothermalfluxEnum()
+	"""
+
+	return StringToEnum('BasalforcingsGeothermalflux')
+
+def BasalforcingsMeltingRateCorrectionEnum():
+	"""
+	BASALFORCINGSMELTINGRATECORRECTIONENUM - Enum of BasalforcingsMeltingRateCorrection
+
+	   Usage:
+	      macro=BasalforcingsMeltingRateCorrectionEnum()
+	"""
+
+	return StringToEnum('BasalforcingsMeltingRateCorrection')
+
+def BasalforcingsMeltingRateEnum():
+	"""
+	BASALFORCINGSMELTINGRATEENUM - Enum of BasalforcingsMeltingRate
+
+	   Usage:
+	      macro=BasalforcingsMeltingRateEnum()
+	"""
+
+	return StringToEnum('BasalforcingsMeltingRate')
+
+def BathymetryEnum():
+	"""
+	BATHYMETRYENUM - Enum of Bathymetry
+
+	   Usage:
+	      macro=BathymetryEnum()
+	"""
+
+	return StringToEnum('Bathymetry')
+
+def BedEnum():
+	"""
+	BEDENUM - Enum of Bed
+
+	   Usage:
+	      macro=BedEnum()
+	"""
+
+	return StringToEnum('Bed')
+
+def ConstantsGEnum():
+	"""
+	CONSTANTSGENUM - Enum of ConstantsG
+
+	   Usage:
+	      macro=ConstantsGEnum()
+	"""
+
+	return StringToEnum('ConstantsG')
+
+def ConstantsReferencetemperatureEnum():
+	"""
+	CONSTANTSREFERENCETEMPERATUREENUM - Enum of ConstantsReferencetemperature
+
+	   Usage:
+	      macro=ConstantsReferencetemperatureEnum()
+	"""
+
+	return StringToEnum('ConstantsReferencetemperature')
+
+def ConstantsYtsEnum():
+	"""
+	CONSTANTSYTSENUM - Enum of ConstantsYts
+
+	   Usage:
+	      macro=ConstantsYtsEnum()
+	"""
+
+	return StringToEnum('ConstantsYts')
+
+def DiagnosticAbstolEnum():
+	"""
+	DIAGNOSTICABSTOLENUM - Enum of DiagnosticAbstol
+
+	   Usage:
+	      macro=DiagnosticAbstolEnum()
+	"""
+
+	return StringToEnum('DiagnosticAbstol')
+
+def DiagnosticIcefrontEnum():
+	"""
+	DIAGNOSTICICEFRONTENUM - Enum of DiagnosticIcefront
+
+	   Usage:
+	      macro=DiagnosticIcefrontEnum()
+	"""
+
+	return StringToEnum('DiagnosticIcefront')
+
+def DiagnosticIsnewtonEnum():
+	"""
+	DIAGNOSTICISNEWTONENUM - Enum of DiagnosticIsnewton
+
+	   Usage:
+	      macro=DiagnosticIsnewtonEnum()
+	"""
+
+	return StringToEnum('DiagnosticIsnewton')
+
+def DiagnosticMaxiterEnum():
+	"""
+	DIAGNOSTICMAXITERENUM - Enum of DiagnosticMaxiter
+
+	   Usage:
+	      macro=DiagnosticMaxiterEnum()
+	"""
+
+	return StringToEnum('DiagnosticMaxiter')
+
+def DiagnosticNumRequestedOutputsEnum():
+	"""
+	DIAGNOSTICNUMREQUESTEDOUTPUTSENUM - Enum of DiagnosticNumRequestedOutputs
+
+	   Usage:
+	      macro=DiagnosticNumRequestedOutputsEnum()
+	"""
+
+	return StringToEnum('DiagnosticNumRequestedOutputs')
+
+def DiagnosticPenaltyFactorEnum():
+	"""
+	DIAGNOSTICPENALTYFACTORENUM - Enum of DiagnosticPenaltyFactor
+
+	   Usage:
+	      macro=DiagnosticPenaltyFactorEnum()
+	"""
+
+	return StringToEnum('DiagnosticPenaltyFactor')
+
+def DiagnosticReferentialEnum():
+	"""
+	DIAGNOSTICREFERENTIALENUM - Enum of DiagnosticReferential
+
+	   Usage:
+	      macro=DiagnosticReferentialEnum()
+	"""
+
+	return StringToEnum('DiagnosticReferential')
+
+def DiagnosticReltolEnum():
+	"""
+	DIAGNOSTICRELTOLENUM - Enum of DiagnosticReltol
+
+	   Usage:
+	      macro=DiagnosticReltolEnum()
+	"""
+
+	return StringToEnum('DiagnosticReltol')
+
+def DiagnosticRequestedOutputsEnum():
+	"""
+	DIAGNOSTICREQUESTEDOUTPUTSENUM - Enum of DiagnosticRequestedOutputs
+
+	   Usage:
+	      macro=DiagnosticRequestedOutputsEnum()
+	"""
+
+	return StringToEnum('DiagnosticRequestedOutputs')
+
+def DiagnosticRestolEnum():
+	"""
+	DIAGNOSTICRESTOLENUM - Enum of DiagnosticRestol
+
+	   Usage:
+	      macro=DiagnosticRestolEnum()
+	"""
+
+	return StringToEnum('DiagnosticRestol')
+
+def DiagnosticRiftPenaltyLockEnum():
+	"""
+	DIAGNOSTICRIFTPENALTYLOCKENUM - Enum of DiagnosticRiftPenaltyLock
+
+	   Usage:
+	      macro=DiagnosticRiftPenaltyLockEnum()
+	"""
+
+	return StringToEnum('DiagnosticRiftPenaltyLock')
+
+def DiagnosticRiftPenaltyThresholdEnum():
+	"""
+	DIAGNOSTICRIFTPENALTYTHRESHOLDENUM - Enum of DiagnosticRiftPenaltyThreshold
+
+	   Usage:
+	      macro=DiagnosticRiftPenaltyThresholdEnum()
+	"""
+
+	return StringToEnum('DiagnosticRiftPenaltyThreshold')
+
+def DiagnosticShelfDampeningEnum():
+	"""
+	DIAGNOSTICSHELFDAMPENINGENUM - Enum of DiagnosticShelfDampening
+
+	   Usage:
+	      macro=DiagnosticShelfDampeningEnum()
+	"""
+
+	return StringToEnum('DiagnosticShelfDampening')
+
+def DiagnosticSpcvxEnum():
+	"""
+	DIAGNOSTICSPCVXENUM - Enum of DiagnosticSpcvx
+
+	   Usage:
+	      macro=DiagnosticSpcvxEnum()
+	"""
+
+	return StringToEnum('DiagnosticSpcvx')
+
+def DiagnosticSpcvyEnum():
+	"""
+	DIAGNOSTICSPCVYENUM - Enum of DiagnosticSpcvy
+
+	   Usage:
+	      macro=DiagnosticSpcvyEnum()
+	"""
+
+	return StringToEnum('DiagnosticSpcvy')
+
+def DiagnosticSpcvzEnum():
+	"""
+	DIAGNOSTICSPCVZENUM - Enum of DiagnosticSpcvz
+
+	   Usage:
+	      macro=DiagnosticSpcvzEnum()
+	"""
+
+	return StringToEnum('DiagnosticSpcvz')
+
+def DiagnosticStokesreconditioningEnum():
+	"""
+	DIAGNOSTICSTOKESRECONDITIONINGENUM - Enum of DiagnosticStokesreconditioning
+
+	   Usage:
+	      macro=DiagnosticStokesreconditioningEnum()
+	"""
+
+	return StringToEnum('DiagnosticStokesreconditioning')
+
+def DiagnosticVertexPairingEnum():
+	"""
+	DIAGNOSTICVERTEXPAIRINGENUM - Enum of DiagnosticVertexPairing
+
+	   Usage:
+	      macro=DiagnosticVertexPairingEnum()
+	"""
+
+	return StringToEnum('DiagnosticVertexPairing')
+
+def DiagnosticViscosityOvershootEnum():
+	"""
+	DIAGNOSTICVISCOSITYOVERSHOOTENUM - Enum of DiagnosticViscosityOvershoot
+
+	   Usage:
+	      macro=DiagnosticViscosityOvershootEnum()
+	"""
+
+	return StringToEnum('DiagnosticViscosityOvershoot')
+
+def FlowequationBordermacayealEnum():
+	"""
+	FLOWEQUATIONBORDERMACAYEALENUM - Enum of FlowequationBordermacayeal
+
+	   Usage:
+	      macro=FlowequationBordermacayealEnum()
+	"""
+
+	return StringToEnum('FlowequationBordermacayeal')
+
+def FlowequationBorderpattynEnum():
+	"""
+	FLOWEQUATIONBORDERPATTYNENUM - Enum of FlowequationBorderpattyn
+
+	   Usage:
+	      macro=FlowequationBorderpattynEnum()
+	"""
+
+	return StringToEnum('FlowequationBorderpattyn')
+
+def FlowequationBorderstokesEnum():
+	"""
+	FLOWEQUATIONBORDERSTOKESENUM - Enum of FlowequationBorderstokes
+
+	   Usage:
+	      macro=FlowequationBorderstokesEnum()
+	"""
+
+	return StringToEnum('FlowequationBorderstokes')
+
+def FlowequationElementEquationEnum():
+	"""
+	FLOWEQUATIONELEMENTEQUATIONENUM - Enum of FlowequationElementEquation
+
+	   Usage:
+	      macro=FlowequationElementEquationEnum()
+	"""
+
+	return StringToEnum('FlowequationElementEquation')
+
+def FlowequationIshutterEnum():
+	"""
+	FLOWEQUATIONISHUTTERENUM - Enum of FlowequationIshutter
+
+	   Usage:
+	      macro=FlowequationIshutterEnum()
+	"""
+
+	return StringToEnum('FlowequationIshutter')
+
+def FlowequationIsmacayealpattynEnum():
+	"""
+	FLOWEQUATIONISMACAYEALPATTYNENUM - Enum of FlowequationIsmacayealpattyn
+
+	   Usage:
+	      macro=FlowequationIsmacayealpattynEnum()
+	"""
+
+	return StringToEnum('FlowequationIsmacayealpattyn')
+
+def FlowequationIsstokesEnum():
+	"""
+	FLOWEQUATIONISSTOKESENUM - Enum of FlowequationIsstokes
+
+	   Usage:
+	      macro=FlowequationIsstokesEnum()
+	"""
+
+	return StringToEnum('FlowequationIsstokes')
+
+def FlowequationVertexEquationEnum():
+	"""
+	FLOWEQUATIONVERTEXEQUATIONENUM - Enum of FlowequationVertexEquation
+
+	   Usage:
+	      macro=FlowequationVertexEquationEnum()
+	"""
+
+	return StringToEnum('FlowequationVertexEquation')
+
+def FrictionCoefficientEnum():
+	"""
+	FRICTIONCOEFFICIENTENUM - Enum of FrictionCoefficient
+
+	   Usage:
+	      macro=FrictionCoefficientEnum()
+	"""
+
+	return StringToEnum('FrictionCoefficient')
+
+def FrictionPEnum():
+	"""
+	FRICTIONPENUM - Enum of FrictionP
+
+	   Usage:
+	      macro=FrictionPEnum()
+	"""
+
+	return StringToEnum('FrictionP')
+
+def FrictionQEnum():
+	"""
+	FRICTIONQENUM - Enum of FrictionQ
+
+	   Usage:
+	      macro=FrictionQEnum()
+	"""
+
+	return StringToEnum('FrictionQ')
+
+def GeometryHydrostaticRatioEnum():
+	"""
+	GEOMETRYHYDROSTATICRATIOENUM - Enum of GeometryHydrostaticRatio
+
+	   Usage:
+	      macro=GeometryHydrostaticRatioEnum()
+	"""
+
+	return StringToEnum('GeometryHydrostaticRatio')
+
+def HydrologyCREnum():
+	"""
+	HYDROLOGYCRENUM - Enum of HydrologyCR
+
+	   Usage:
+	      macro=HydrologyCREnum()
+	"""
+
+	return StringToEnum('HydrologyCR')
+
+def HydrologyKnEnum():
+	"""
+	HYDROLOGYKNENUM - Enum of HydrologyKn
+
+	   Usage:
+	      macro=HydrologyKnEnum()
+	"""
+
+	return StringToEnum('HydrologyKn')
+
+def HydrologyNEnum():
+	"""
+	HYDROLOGYNENUM - Enum of HydrologyN
+
+	   Usage:
+	      macro=HydrologyNEnum()
+	"""
+
+	return StringToEnum('HydrologyN')
+
+def HydrologyPEnum():
+	"""
+	HYDROLOGYPENUM - Enum of HydrologyP
+
+	   Usage:
+	      macro=HydrologyPEnum()
+	"""
+
+	return StringToEnum('HydrologyP')
+
+def HydrologyQEnum():
+	"""
+	HYDROLOGYQENUM - Enum of HydrologyQ
+
+	   Usage:
+	      macro=HydrologyQEnum()
+	"""
+
+	return StringToEnum('HydrologyQ')
+
+def HydrologySpcwatercolumnEnum():
+	"""
+	HYDROLOGYSPCWATERCOLUMNENUM - Enum of HydrologySpcwatercolumn
+
+	   Usage:
+	      macro=HydrologySpcwatercolumnEnum()
+	"""
+
+	return StringToEnum('HydrologySpcwatercolumn')
+
+def HydrologyStabilizationEnum():
+	"""
+	HYDROLOGYSTABILIZATIONENUM - Enum of HydrologyStabilization
+
+	   Usage:
+	      macro=HydrologyStabilizationEnum()
+	"""
+
+	return StringToEnum('HydrologyStabilization')
+
+def InversionControlParametersEnum():
+	"""
+	INVERSIONCONTROLPARAMETERSENUM - Enum of InversionControlParameters
+
+	   Usage:
+	      macro=InversionControlParametersEnum()
+	"""
+
+	return StringToEnum('InversionControlParameters')
+
+def InversionCostFunctionEnum():
+	"""
+	INVERSIONCOSTFUNCTIONENUM - Enum of InversionCostFunction
+
+	   Usage:
+	      macro=InversionCostFunctionEnum()
+	"""
+
+	return StringToEnum('InversionCostFunction')
+
+def InversionCostFunctionThresholdEnum():
+	"""
+	INVERSIONCOSTFUNCTIONTHRESHOLDENUM - Enum of InversionCostFunctionThreshold
+
+	   Usage:
+	      macro=InversionCostFunctionThresholdEnum()
+	"""
+
+	return StringToEnum('InversionCostFunctionThreshold')
+
+def InversionCostFunctionsCoefficientsEnum():
+	"""
+	INVERSIONCOSTFUNCTIONSCOEFFICIENTSENUM - Enum of InversionCostFunctionsCoefficients
+
+	   Usage:
+	      macro=InversionCostFunctionsCoefficientsEnum()
+	"""
+
+	return StringToEnum('InversionCostFunctionsCoefficients')
+
+def InversionCostFunctionsEnum():
+	"""
+	INVERSIONCOSTFUNCTIONSENUM - Enum of InversionCostFunctions
+
+	   Usage:
+	      macro=InversionCostFunctionsEnum()
+	"""
+
+	return StringToEnum('InversionCostFunctions')
+
+def InversionGradientOnlyEnum():
+	"""
+	INVERSIONGRADIENTONLYENUM - Enum of InversionGradientOnly
+
+	   Usage:
+	      macro=InversionGradientOnlyEnum()
+	"""
+
+	return StringToEnum('InversionGradientOnly')
+
+def InversionGradientScalingEnum():
+	"""
+	INVERSIONGRADIENTSCALINGENUM - Enum of InversionGradientScaling
+
+	   Usage:
+	      macro=InversionGradientScalingEnum()
+	"""
+
+	return StringToEnum('InversionGradientScaling')
+
+def InversionIscontrolEnum():
+	"""
+	INVERSIONISCONTROLENUM - Enum of InversionIscontrol
+
+	   Usage:
+	      macro=InversionIscontrolEnum()
+	"""
+
+	return StringToEnum('InversionIscontrol')
+
+def InversionTaoEnum():
+	"""
+	INVERSIONTAOENUM - Enum of InversionTao
+
+	   Usage:
+	      macro=InversionTaoEnum()
+	"""
+
+	return StringToEnum('InversionTao')
+
+def InversionIncompleteAdjointEnum():
+	"""
+	INVERSIONINCOMPLETEADJOINTENUM - Enum of InversionIncompleteAdjoint
+
+	   Usage:
+	      macro=InversionIncompleteAdjointEnum()
+	"""
+
+	return StringToEnum('InversionIncompleteAdjoint')
+
+def InversionMaxParametersEnum():
+	"""
+	INVERSIONMAXPARAMETERSENUM - Enum of InversionMaxParameters
+
+	   Usage:
+	      macro=InversionMaxParametersEnum()
+	"""
+
+	return StringToEnum('InversionMaxParameters')
+
+def InversionMaxiterPerStepEnum():
+	"""
+	INVERSIONMAXITERPERSTEPENUM - Enum of InversionMaxiterPerStep
+
+	   Usage:
+	      macro=InversionMaxiterPerStepEnum()
+	"""
+
+	return StringToEnum('InversionMaxiterPerStep')
+
+def InversionMinParametersEnum():
+	"""
+	INVERSIONMINPARAMETERSENUM - Enum of InversionMinParameters
+
+	   Usage:
+	      macro=InversionMinParametersEnum()
+	"""
+
+	return StringToEnum('InversionMinParameters')
+
+def InversionNstepsEnum():
+	"""
+	INVERSIONNSTEPSENUM - Enum of InversionNsteps
+
+	   Usage:
+	      macro=InversionNstepsEnum()
+	"""
+
+	return StringToEnum('InversionNsteps')
+
+def InversionNumControlParametersEnum():
+	"""
+	INVERSIONNUMCONTROLPARAMETERSENUM - Enum of InversionNumControlParameters
+
+	   Usage:
+	      macro=InversionNumControlParametersEnum()
+	"""
+
+	return StringToEnum('InversionNumControlParameters')
+
+def InversionNumCostFunctionsEnum():
+	"""
+	INVERSIONNUMCOSTFUNCTIONSENUM - Enum of InversionNumCostFunctions
+
+	   Usage:
+	      macro=InversionNumCostFunctionsEnum()
+	"""
+
+	return StringToEnum('InversionNumCostFunctions')
+
+def InversionStepThresholdEnum():
+	"""
+	INVERSIONSTEPTHRESHOLDENUM - Enum of InversionStepThreshold
+
+	   Usage:
+	      macro=InversionStepThresholdEnum()
+	"""
+
+	return StringToEnum('InversionStepThreshold')
+
+def InversionThicknessObsEnum():
+	"""
+	INVERSIONTHICKNESSOBSENUM - Enum of InversionThicknessObs
+
+	   Usage:
+	      macro=InversionThicknessObsEnum()
+	"""
+
+	return StringToEnum('InversionThicknessObs')
+
+def InversionVelObsEnum():
+	"""
+	INVERSIONVELOBSENUM - Enum of InversionVelObs
+
+	   Usage:
+	      macro=InversionVelObsEnum()
+	"""
+
+	return StringToEnum('InversionVelObs')
+
+def InversionVxObsEnum():
+	"""
+	INVERSIONVXOBSENUM - Enum of InversionVxObs
+
+	   Usage:
+	      macro=InversionVxObsEnum()
+	"""
+
+	return StringToEnum('InversionVxObs')
+
+def InversionVyObsEnum():
+	"""
+	INVERSIONVYOBSENUM - Enum of InversionVyObs
+
+	   Usage:
+	      macro=InversionVyObsEnum()
+	"""
+
+	return StringToEnum('InversionVyObs')
+
+def InversionVzObsEnum():
+	"""
+	INVERSIONVZOBSENUM - Enum of InversionVzObs
+
+	   Usage:
+	      macro=InversionVzObsEnum()
+	"""
+
+	return StringToEnum('InversionVzObs')
+
+def MaskElementonfloatingiceEnum():
+	"""
+	MASKELEMENTONFLOATINGICEENUM - Enum of MaskElementonfloatingice
+
+	   Usage:
+	      macro=MaskElementonfloatingiceEnum()
+	"""
+
+	return StringToEnum('MaskElementonfloatingice')
+
+def MaskElementongroundediceEnum():
+	"""
+	MASKELEMENTONGROUNDEDICEENUM - Enum of MaskElementongroundedice
+
+	   Usage:
+	      macro=MaskElementongroundediceEnum()
+	"""
+
+	return StringToEnum('MaskElementongroundedice')
+
+def MaskElementonwaterEnum():
+	"""
+	MASKELEMENTONWATERENUM - Enum of MaskElementonwater
+
+	   Usage:
+	      macro=MaskElementonwaterEnum()
+	"""
+
+	return StringToEnum('MaskElementonwater')
+
+def MaskVertexonfloatingiceEnum():
+	"""
+	MASKVERTEXONFLOATINGICEENUM - Enum of MaskVertexonfloatingice
+
+	   Usage:
+	      macro=MaskVertexonfloatingiceEnum()
+	"""
+
+	return StringToEnum('MaskVertexonfloatingice')
+
+def MaskVertexongroundediceEnum():
+	"""
+	MASKVERTEXONGROUNDEDICEENUM - Enum of MaskVertexongroundedice
+
+	   Usage:
+	      macro=MaskVertexongroundediceEnum()
+	"""
+
+	return StringToEnum('MaskVertexongroundedice')
+
+def MaskVertexonwaterEnum():
+	"""
+	MASKVERTEXONWATERENUM - Enum of MaskVertexonwater
+
+	   Usage:
+	      macro=MaskVertexonwaterEnum()
+	"""
+
+	return StringToEnum('MaskVertexonwater')
+
+def MaterialsBetaEnum():
+	"""
+	MATERIALSBETAENUM - Enum of MaterialsBeta
+
+	   Usage:
+	      macro=MaterialsBetaEnum()
+	"""
+
+	return StringToEnum('MaterialsBeta')
+
+def MaterialsHeatcapacityEnum():
+	"""
+	MATERIALSHEATCAPACITYENUM - Enum of MaterialsHeatcapacity
+
+	   Usage:
+	      macro=MaterialsHeatcapacityEnum()
+	"""
+
+	return StringToEnum('MaterialsHeatcapacity')
+
+def MaterialsLatentheatEnum():
+	"""
+	MATERIALSLATENTHEATENUM - Enum of MaterialsLatentheat
+
+	   Usage:
+	      macro=MaterialsLatentheatEnum()
+	"""
+
+	return StringToEnum('MaterialsLatentheat')
+
+def MaterialsMeltingpointEnum():
+	"""
+	MATERIALSMELTINGPOINTENUM - Enum of MaterialsMeltingpoint
+
+	   Usage:
+	      macro=MaterialsMeltingpointEnum()
+	"""
+
+	return StringToEnum('MaterialsMeltingpoint')
+
+def MaterialsMixedLayerCapacityEnum():
+	"""
+	MATERIALSMIXEDLAYERCAPACITYENUM - Enum of MaterialsMixedLayerCapacity
+
+	   Usage:
+	      macro=MaterialsMixedLayerCapacityEnum()
+	"""
+
+	return StringToEnum('MaterialsMixedLayerCapacity')
+
+def MaterialsRheologyBEnum():
+	"""
+	MATERIALSRHEOLOGYBENUM - Enum of MaterialsRheologyB
+
+	   Usage:
+	      macro=MaterialsRheologyBEnum()
+	"""
+
+	return StringToEnum('MaterialsRheologyB')
+
+def MaterialsRheologyBbarEnum():
+	"""
+	MATERIALSRHEOLOGYBBARENUM - Enum of MaterialsRheologyBbar
+
+	   Usage:
+	      macro=MaterialsRheologyBbarEnum()
+	"""
+
+	return StringToEnum('MaterialsRheologyBbar')
+
+def MaterialsRheologyLawEnum():
+	"""
+	MATERIALSRHEOLOGYLAWENUM - Enum of MaterialsRheologyLaw
+
+	   Usage:
+	      macro=MaterialsRheologyLawEnum()
+	"""
+
+	return StringToEnum('MaterialsRheologyLaw')
+
+def MaterialsRheologyNEnum():
+	"""
+	MATERIALSRHEOLOGYNENUM - Enum of MaterialsRheologyN
+
+	   Usage:
+	      macro=MaterialsRheologyNEnum()
+	"""
+
+	return StringToEnum('MaterialsRheologyN')
+
+def MaterialsRhoIceEnum():
+	"""
+	MATERIALSRHOICEENUM - Enum of MaterialsRhoIce
+
+	   Usage:
+	      macro=MaterialsRhoIceEnum()
+	"""
+
+	return StringToEnum('MaterialsRhoIce')
+
+def MaterialsRhoWaterEnum():
+	"""
+	MATERIALSRHOWATERENUM - Enum of MaterialsRhoWater
+
+	   Usage:
+	      macro=MaterialsRhoWaterEnum()
+	"""
+
+	return StringToEnum('MaterialsRhoWater')
+
+def MaterialsRhoFreshwaterEnum():
+	"""
+	MATERIALSRHOFRESHWATERENUM - Enum of MaterialsRhoFreshwater
+
+	   Usage:
+	      macro=MaterialsRhoFreshwaterEnum()
+	"""
+
+	return StringToEnum('MaterialsRhoFreshwater')
+
+def MaterialsMuWaterEnum():
+	"""
+	MATERIALSMUWATERENUM - Enum of MaterialsMuWater
+
+	   Usage:
+	      macro=MaterialsMuWaterEnum()
+	"""
+
+	return StringToEnum('MaterialsMuWater')
+
+def MaterialsThermalExchangeVelocityEnum():
+	"""
+	MATERIALSTHERMALEXCHANGEVELOCITYENUM - Enum of MaterialsThermalExchangeVelocity
+
+	   Usage:
+	      macro=MaterialsThermalExchangeVelocityEnum()
+	"""
+
+	return StringToEnum('MaterialsThermalExchangeVelocity')
+
+def MaterialsThermalconductivityEnum():
+	"""
+	MATERIALSTHERMALCONDUCTIVITYENUM - Enum of MaterialsThermalconductivity
+
+	   Usage:
+	      macro=MaterialsThermalconductivityEnum()
+	"""
+
+	return StringToEnum('MaterialsThermalconductivity')
+
+def MeshAverageVertexConnectivityEnum():
+	"""
+	MESHAVERAGEVERTEXCONNECTIVITYENUM - Enum of MeshAverageVertexConnectivity
+
+	   Usage:
+	      macro=MeshAverageVertexConnectivityEnum()
+	"""
+
+	return StringToEnum('MeshAverageVertexConnectivity')
+
+def MeshDimensionEnum():
+	"""
+	MESHDIMENSIONENUM - Enum of MeshDimension
+
+	   Usage:
+	      macro=MeshDimensionEnum()
+	"""
+
+	return StringToEnum('MeshDimension')
+
+def MeshEdgesEnum():
+	"""
+	MESHEDGESENUM - Enum of MeshEdges
+
+	   Usage:
+	      macro=MeshEdgesEnum()
+	"""
+
+	return StringToEnum('MeshEdges')
+
+def MeshElementconnectivityEnum():
+	"""
+	MESHELEMENTCONNECTIVITYENUM - Enum of MeshElementconnectivity
+
+	   Usage:
+	      macro=MeshElementconnectivityEnum()
+	"""
+
+	return StringToEnum('MeshElementconnectivity')
+
+def MeshElementonbedEnum():
+	"""
+	MESHELEMENTONBEDENUM - Enum of MeshElementonbed
+
+	   Usage:
+	      macro=MeshElementonbedEnum()
+	"""
+
+	return StringToEnum('MeshElementonbed')
+
+def MeshElementonsurfaceEnum():
+	"""
+	MESHELEMENTONSURFACEENUM - Enum of MeshElementonsurface
+
+	   Usage:
+	      macro=MeshElementonsurfaceEnum()
+	"""
+
+	return StringToEnum('MeshElementonsurface')
+
+def MeshElements2dEnum():
+	"""
+	MESHELEMENTS2DENUM - Enum of MeshElements2d
+
+	   Usage:
+	      macro=MeshElements2dEnum()
+	"""
+
+	return StringToEnum('MeshElements2d')
+
+def MeshElementsEnum():
+	"""
+	MESHELEMENTSENUM - Enum of MeshElements
+
+	   Usage:
+	      macro=MeshElementsEnum()
+	"""
+
+	return StringToEnum('MeshElements')
+
+def MeshLowerelementsEnum():
+	"""
+	MESHLOWERELEMENTSENUM - Enum of MeshLowerelements
+
+	   Usage:
+	      macro=MeshLowerelementsEnum()
+	"""
+
+	return StringToEnum('MeshLowerelements')
+
+def MeshNumberofedgesEnum():
+	"""
+	MESHNUMBEROFEDGESENUM - Enum of MeshNumberofedges
+
+	   Usage:
+	      macro=MeshNumberofedgesEnum()
+	"""
+
+	return StringToEnum('MeshNumberofedges')
+
+def MeshNumberofelements2dEnum():
+	"""
+	MESHNUMBEROFELEMENTS2DENUM - Enum of MeshNumberofelements2d
+
+	   Usage:
+	      macro=MeshNumberofelements2dEnum()
+	"""
+
+	return StringToEnum('MeshNumberofelements2d')
+
+def MeshNumberofelementsEnum():
+	"""
+	MESHNUMBEROFELEMENTSENUM - Enum of MeshNumberofelements
+
+	   Usage:
+	      macro=MeshNumberofelementsEnum()
+	"""
+
+	return StringToEnum('MeshNumberofelements')
+
+def MeshNumberoflayersEnum():
+	"""
+	MESHNUMBEROFLAYERSENUM - Enum of MeshNumberoflayers
+
+	   Usage:
+	      macro=MeshNumberoflayersEnum()
+	"""
+
+	return StringToEnum('MeshNumberoflayers')
+
+def MeshNumberofvertices2dEnum():
+	"""
+	MESHNUMBEROFVERTICES2DENUM - Enum of MeshNumberofvertices2d
+
+	   Usage:
+	      macro=MeshNumberofvertices2dEnum()
+	"""
+
+	return StringToEnum('MeshNumberofvertices2d')
+
+def MeshNumberofverticesEnum():
+	"""
+	MESHNUMBEROFVERTICESENUM - Enum of MeshNumberofvertices
+
+	   Usage:
+	      macro=MeshNumberofverticesEnum()
+	"""
+
+	return StringToEnum('MeshNumberofvertices')
+
+def MeshUpperelementsEnum():
+	"""
+	MESHUPPERELEMENTSENUM - Enum of MeshUpperelements
+
+	   Usage:
+	      macro=MeshUpperelementsEnum()
+	"""
+
+	return StringToEnum('MeshUpperelements')
+
+def MeshVertexonbedEnum():
+	"""
+	MESHVERTEXONBEDENUM - Enum of MeshVertexonbed
+
+	   Usage:
+	      macro=MeshVertexonbedEnum()
+	"""
+
+	return StringToEnum('MeshVertexonbed')
+
+def MeshVertexonsurfaceEnum():
+	"""
+	MESHVERTEXONSURFACEENUM - Enum of MeshVertexonsurface
+
+	   Usage:
+	      macro=MeshVertexonsurfaceEnum()
+	"""
+
+	return StringToEnum('MeshVertexonsurface')
+
+def MeshXEnum():
+	"""
+	MESHXENUM - Enum of MeshX
+
+	   Usage:
+	      macro=MeshXEnum()
+	"""
+
+	return StringToEnum('MeshX')
+
+def MeshYEnum():
+	"""
+	MESHYENUM - Enum of MeshY
+
+	   Usage:
+	      macro=MeshYEnum()
+	"""
+
+	return StringToEnum('MeshY')
+
+def MeshZEnum():
+	"""
+	MESHZENUM - Enum of MeshZ
+
+	   Usage:
+	      macro=MeshZEnum()
+	"""
+
+	return StringToEnum('MeshZ')
+
+def MiscellaneousNameEnum():
+	"""
+	MISCELLANEOUSNAMEENUM - Enum of MiscellaneousName
+
+	   Usage:
+	      macro=MiscellaneousNameEnum()
+	"""
+
+	return StringToEnum('MiscellaneousName')
+
+def PrognosticHydrostaticAdjustmentEnum():
+	"""
+	PROGNOSTICHYDROSTATICADJUSTMENTENUM - Enum of PrognosticHydrostaticAdjustment
+
+	   Usage:
+	      macro=PrognosticHydrostaticAdjustmentEnum()
+	"""
+
+	return StringToEnum('PrognosticHydrostaticAdjustment')
+
+def PrognosticMinThicknessEnum():
+	"""
+	PROGNOSTICMINTHICKNESSENUM - Enum of PrognosticMinThickness
+
+	   Usage:
+	      macro=PrognosticMinThicknessEnum()
+	"""
+
+	return StringToEnum('PrognosticMinThickness')
+
+def PrognosticPenaltyFactorEnum():
+	"""
+	PROGNOSTICPENALTYFACTORENUM - Enum of PrognosticPenaltyFactor
+
+	   Usage:
+	      macro=PrognosticPenaltyFactorEnum()
+	"""
+
+	return StringToEnum('PrognosticPenaltyFactor')
+
+def PrognosticSpcthicknessEnum():
+	"""
+	PROGNOSTICSPCTHICKNESSENUM - Enum of PrognosticSpcthickness
+
+	   Usage:
+	      macro=PrognosticSpcthicknessEnum()
+	"""
+
+	return StringToEnum('PrognosticSpcthickness')
+
+def PrognosticStabilizationEnum():
+	"""
+	PROGNOSTICSTABILIZATIONENUM - Enum of PrognosticStabilization
+
+	   Usage:
+	      macro=PrognosticStabilizationEnum()
+	"""
+
+	return StringToEnum('PrognosticStabilization')
+
+def PrognosticVertexPairingEnum():
+	"""
+	PROGNOSTICVERTEXPAIRINGENUM - Enum of PrognosticVertexPairing
+
+	   Usage:
+	      macro=PrognosticVertexPairingEnum()
+	"""
+
+	return StringToEnum('PrognosticVertexPairing')
+
+def QmuIsdakotaEnum():
+	"""
+	QMUISDAKOTAENUM - Enum of QmuIsdakota
+
+	   Usage:
+	      macro=QmuIsdakotaEnum()
+	"""
+
+	return StringToEnum('QmuIsdakota')
+
+def QmuMassFluxSegmentsEnum():
+	"""
+	QMUMASSFLUXSEGMENTSENUM - Enum of QmuMassFluxSegments
+
+	   Usage:
+	      macro=QmuMassFluxSegmentsEnum()
+	"""
+
+	return StringToEnum('QmuMassFluxSegments')
+
+def QmuNumberofpartitionsEnum():
+	"""
+	QMUNUMBEROFPARTITIONSENUM - Enum of QmuNumberofpartitions
+
+	   Usage:
+	      macro=QmuNumberofpartitionsEnum()
+	"""
+
+	return StringToEnum('QmuNumberofpartitions')
+
+def QmuNumberofresponsesEnum():
+	"""
+	QMUNUMBEROFRESPONSESENUM - Enum of QmuNumberofresponses
+
+	   Usage:
+	      macro=QmuNumberofresponsesEnum()
+	"""
+
+	return StringToEnum('QmuNumberofresponses')
+
+def QmuPartitionEnum():
+	"""
+	QMUPARTITIONENUM - Enum of QmuPartition
+
+	   Usage:
+	      macro=QmuPartitionEnum()
+	"""
+
+	return StringToEnum('QmuPartition')
+
+def QmuResponsedescriptorsEnum():
+	"""
+	QMURESPONSEDESCRIPTORSENUM - Enum of QmuResponsedescriptors
+
+	   Usage:
+	      macro=QmuResponsedescriptorsEnum()
+	"""
+
+	return StringToEnum('QmuResponsedescriptors')
+
+def QmuVariabledescriptorsEnum():
+	"""
+	QMUVARIABLEDESCRIPTORSENUM - Enum of QmuVariabledescriptors
+
+	   Usage:
+	      macro=QmuVariabledescriptorsEnum()
+	"""
+
+	return StringToEnum('QmuVariabledescriptors')
+
+def RiftsNumriftsEnum():
+	"""
+	RIFTSNUMRIFTSENUM - Enum of RiftsNumrifts
+
+	   Usage:
+	      macro=RiftsNumriftsEnum()
+	"""
+
+	return StringToEnum('RiftsNumrifts')
+
+def RiftsRiftstructEnum():
+	"""
+	RIFTSRIFTSTRUCTENUM - Enum of RiftsRiftstruct
+
+	   Usage:
+	      macro=RiftsRiftstructEnum()
+	"""
+
+	return StringToEnum('RiftsRiftstruct')
+
+def SettingsIoGatherEnum():
+	"""
+	SETTINGSIOGATHERENUM - Enum of SettingsIoGather
+
+	   Usage:
+	      macro=SettingsIoGatherEnum()
+	"""
+
+	return StringToEnum('SettingsIoGather')
+
+def SettingsLowmemEnum():
+	"""
+	SETTINGSLOWMEMENUM - Enum of SettingsLowmem
+
+	   Usage:
+	      macro=SettingsLowmemEnum()
+	"""
+
+	return StringToEnum('SettingsLowmem')
+
+def SettingsOutputFrequencyEnum():
+	"""
+	SETTINGSOUTPUTFREQUENCYENUM - Enum of SettingsOutputFrequency
+
+	   Usage:
+	      macro=SettingsOutputFrequencyEnum()
+	"""
+
+	return StringToEnum('SettingsOutputFrequency')
+
+def SettingsResultsAsPatchesEnum():
+	"""
+	SETTINGSRESULTSASPATCHESENUM - Enum of SettingsResultsAsPatches
+
+	   Usage:
+	      macro=SettingsResultsAsPatchesEnum()
+	"""
+
+	return StringToEnum('SettingsResultsAsPatches')
+
+def SettingsWaitonlockEnum():
+	"""
+	SETTINGSWAITONLOCKENUM - Enum of SettingsWaitonlock
+
+	   Usage:
+	      macro=SettingsWaitonlockEnum()
+	"""
+
+	return StringToEnum('SettingsWaitonlock')
+
+def DebugProfilingEnum():
+	"""
+	DEBUGPROFILINGENUM - Enum of DebugProfiling
+
+	   Usage:
+	      macro=DebugProfilingEnum()
+	"""
+
+	return StringToEnum('DebugProfiling')
+
+def ProfilingCurrentMemEnum():
+	"""
+	PROFILINGCURRENTMEMENUM - Enum of ProfilingCurrentMem
+
+	   Usage:
+	      macro=ProfilingCurrentMemEnum()
+	"""
+
+	return StringToEnum('ProfilingCurrentMem')
+
+def ProfilingCurrentFlopsEnum():
+	"""
+	PROFILINGCURRENTFLOPSENUM - Enum of ProfilingCurrentFlops
+
+	   Usage:
+	      macro=ProfilingCurrentFlopsEnum()
+	"""
+
+	return StringToEnum('ProfilingCurrentFlops')
+
+def ProfilingSolutionTimeEnum():
+	"""
+	PROFILINGSOLUTIONTIMEENUM - Enum of ProfilingSolutionTime
+
+	   Usage:
+	      macro=ProfilingSolutionTimeEnum()
+	"""
+
+	return StringToEnum('ProfilingSolutionTime')
+
+def MaxIterationConvergenceFlagEnum():
+	"""
+	MAXITERATIONCONVERGENCEFLAGENUM - Enum of MaxIterationConvergenceFlag
+
+	   Usage:
+	      macro=MaxIterationConvergenceFlagEnum()
+	"""
+
+	return StringToEnum('MaxIterationConvergenceFlag')
+
+def SteadystateMaxiterEnum():
+	"""
+	STEADYSTATEMAXITERENUM - Enum of SteadystateMaxiter
+
+	   Usage:
+	      macro=SteadystateMaxiterEnum()
+	"""
+
+	return StringToEnum('SteadystateMaxiter')
+
+def SteadystateNumRequestedOutputsEnum():
+	"""
+	STEADYSTATENUMREQUESTEDOUTPUTSENUM - Enum of SteadystateNumRequestedOutputs
+
+	   Usage:
+	      macro=SteadystateNumRequestedOutputsEnum()
+	"""
+
+	return StringToEnum('SteadystateNumRequestedOutputs')
+
+def SteadystateReltolEnum():
+	"""
+	STEADYSTATERELTOLENUM - Enum of SteadystateReltol
+
+	   Usage:
+	      macro=SteadystateReltolEnum()
+	"""
+
+	return StringToEnum('SteadystateReltol')
+
+def SteadystateRequestedOutputsEnum():
+	"""
+	STEADYSTATEREQUESTEDOUTPUTSENUM - Enum of SteadystateRequestedOutputs
+
+	   Usage:
+	      macro=SteadystateRequestedOutputsEnum()
+	"""
+
+	return StringToEnum('SteadystateRequestedOutputs')
+
+def SurfaceEnum():
+	"""
+	SURFACEENUM - Enum of Surface
+
+	   Usage:
+	      macro=SurfaceEnum()
+	"""
+
+	return StringToEnum('Surface')
+
+def SurfaceforcingsPrecipitationEnum():
+	"""
+	SURFACEFORCINGSPRECIPITATIONENUM - Enum of SurfaceforcingsPrecipitation
+
+	   Usage:
+	      macro=SurfaceforcingsPrecipitationEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsPrecipitation')
+
+def SurfaceforcingsMassBalanceEnum():
+	"""
+	SURFACEFORCINGSMASSBALANCEENUM - Enum of SurfaceforcingsMassBalance
+
+	   Usage:
+	      macro=SurfaceforcingsMassBalanceEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsMassBalance')
+
+def SurfaceforcingsIspddEnum():
+	"""
+	SURFACEFORCINGSISPDDENUM - Enum of SurfaceforcingsIspdd
+
+	   Usage:
+	      macro=SurfaceforcingsIspddEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsIspdd')
+
+def SurfaceforcingsIssmbgradientsEnum():
+	"""
+	SURFACEFORCINGSISSMBGRADIENTSENUM - Enum of SurfaceforcingsIssmbgradients
+
+	   Usage:
+	      macro=SurfaceforcingsIssmbgradientsEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsIssmbgradients')
+
+def SurfaceforcingsMonthlytemperaturesEnum():
+	"""
+	SURFACEFORCINGSMONTHLYTEMPERATURESENUM - Enum of SurfaceforcingsMonthlytemperatures
+
+	   Usage:
+	      macro=SurfaceforcingsMonthlytemperaturesEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsMonthlytemperatures')
+
+def SurfaceforcingsHcEnum():
+	"""
+	SURFACEFORCINGSHCENUM - Enum of SurfaceforcingsHc
+
+	   Usage:
+	      macro=SurfaceforcingsHcEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsHc')
+
+def SurfaceforcingsSmbPosMaxEnum():
+	"""
+	SURFACEFORCINGSSMBPOSMAXENUM - Enum of SurfaceforcingsSmbPosMax
+
+	   Usage:
+	      macro=SurfaceforcingsSmbPosMaxEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsSmbPosMax')
+
+def SurfaceforcingsSmbPosMinEnum():
+	"""
+	SURFACEFORCINGSSMBPOSMINENUM - Enum of SurfaceforcingsSmbPosMin
+
+	   Usage:
+	      macro=SurfaceforcingsSmbPosMinEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsSmbPosMin')
+
+def SurfaceforcingsAPosEnum():
+	"""
+	SURFACEFORCINGSAPOSENUM - Enum of SurfaceforcingsAPos
+
+	   Usage:
+	      macro=SurfaceforcingsAPosEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsAPos')
+
+def SurfaceforcingsBPosEnum():
+	"""
+	SURFACEFORCINGSBPOSENUM - Enum of SurfaceforcingsBPos
+
+	   Usage:
+	      macro=SurfaceforcingsBPosEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsBPos')
+
+def SurfaceforcingsANegEnum():
+	"""
+	SURFACEFORCINGSANEGENUM - Enum of SurfaceforcingsANeg
+
+	   Usage:
+	      macro=SurfaceforcingsANegEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsANeg')
+
+def SurfaceforcingsBNegEnum():
+	"""
+	SURFACEFORCINGSBNEGENUM - Enum of SurfaceforcingsBNeg
+
+	   Usage:
+	      macro=SurfaceforcingsBNegEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsBNeg')
+
+def ThermalMaxiterEnum():
+	"""
+	THERMALMAXITERENUM - Enum of ThermalMaxiter
+
+	   Usage:
+	      macro=ThermalMaxiterEnum()
+	"""
+
+	return StringToEnum('ThermalMaxiter')
+
+def ThermalPenaltyFactorEnum():
+	"""
+	THERMALPENALTYFACTORENUM - Enum of ThermalPenaltyFactor
+
+	   Usage:
+	      macro=ThermalPenaltyFactorEnum()
+	"""
+
+	return StringToEnum('ThermalPenaltyFactor')
+
+def ThermalPenaltyLockEnum():
+	"""
+	THERMALPENALTYLOCKENUM - Enum of ThermalPenaltyLock
+
+	   Usage:
+	      macro=ThermalPenaltyLockEnum()
+	"""
+
+	return StringToEnum('ThermalPenaltyLock')
+
+def ThermalPenaltyThresholdEnum():
+	"""
+	THERMALPENALTYTHRESHOLDENUM - Enum of ThermalPenaltyThreshold
+
+	   Usage:
+	      macro=ThermalPenaltyThresholdEnum()
+	"""
+
+	return StringToEnum('ThermalPenaltyThreshold')
+
+def ThermalSpctemperatureEnum():
+	"""
+	THERMALSPCTEMPERATUREENUM - Enum of ThermalSpctemperature
+
+	   Usage:
+	      macro=ThermalSpctemperatureEnum()
+	"""
+
+	return StringToEnum('ThermalSpctemperature')
+
+def ThermalStabilizationEnum():
+	"""
+	THERMALSTABILIZATIONENUM - Enum of ThermalStabilization
+
+	   Usage:
+	      macro=ThermalStabilizationEnum()
+	"""
+
+	return StringToEnum('ThermalStabilization')
+
+def ThermalIsenthalpyEnum():
+	"""
+	THERMALISENTHALPYENUM - Enum of ThermalIsenthalpy
+
+	   Usage:
+	      macro=ThermalIsenthalpyEnum()
+	"""
+
+	return StringToEnum('ThermalIsenthalpy')
+
+def ThicknessEnum():
+	"""
+	THICKNESSENUM - Enum of Thickness
+
+	   Usage:
+	      macro=ThicknessEnum()
+	"""
+
+	return StringToEnum('Thickness')
+
+def TimesteppingStartTimeEnum():
+	"""
+	TIMESTEPPINGSTARTTIMEENUM - Enum of TimesteppingStartTime
+
+	   Usage:
+	      macro=TimesteppingStartTimeEnum()
+	"""
+
+	return StringToEnum('TimesteppingStartTime')
+
+def TimesteppingFinalTimeEnum():
+	"""
+	TIMESTEPPINGFINALTIMEENUM - Enum of TimesteppingFinalTime
+
+	   Usage:
+	      macro=TimesteppingFinalTimeEnum()
+	"""
+
+	return StringToEnum('TimesteppingFinalTime')
+
+def TimesteppingCflCoefficientEnum():
+	"""
+	TIMESTEPPINGCFLCOEFFICIENTENUM - Enum of TimesteppingCflCoefficient
+
+	   Usage:
+	      macro=TimesteppingCflCoefficientEnum()
+	"""
+
+	return StringToEnum('TimesteppingCflCoefficient')
+
+def TimesteppingTimeAdaptEnum():
+	"""
+	TIMESTEPPINGTIMEADAPTENUM - Enum of TimesteppingTimeAdapt
+
+	   Usage:
+	      macro=TimesteppingTimeAdaptEnum()
+	"""
+
+	return StringToEnum('TimesteppingTimeAdapt')
+
+def TimesteppingTimeStepEnum():
+	"""
+	TIMESTEPPINGTIMESTEPENUM - Enum of TimesteppingTimeStep
+
+	   Usage:
+	      macro=TimesteppingTimeStepEnum()
+	"""
+
+	return StringToEnum('TimesteppingTimeStep')
+
+def TransientIsdiagnosticEnum():
+	"""
+	TRANSIENTISDIAGNOSTICENUM - Enum of TransientIsdiagnostic
+
+	   Usage:
+	      macro=TransientIsdiagnosticEnum()
+	"""
+
+	return StringToEnum('TransientIsdiagnostic')
+
+def TransientIsgroundinglineEnum():
+	"""
+	TRANSIENTISGROUNDINGLINEENUM - Enum of TransientIsgroundingline
+
+	   Usage:
+	      macro=TransientIsgroundinglineEnum()
+	"""
+
+	return StringToEnum('TransientIsgroundingline')
+
+def TransientIsprognosticEnum():
+	"""
+	TRANSIENTISPROGNOSTICENUM - Enum of TransientIsprognostic
+
+	   Usage:
+	      macro=TransientIsprognosticEnum()
+	"""
+
+	return StringToEnum('TransientIsprognostic')
+
+def TransientIsthermalEnum():
+	"""
+	TRANSIENTISTHERMALENUM - Enum of TransientIsthermal
+
+	   Usage:
+	      macro=TransientIsthermalEnum()
+	"""
+
+	return StringToEnum('TransientIsthermal')
+
+def TransientNumRequestedOutputsEnum():
+	"""
+	TRANSIENTNUMREQUESTEDOUTPUTSENUM - Enum of TransientNumRequestedOutputs
+
+	   Usage:
+	      macro=TransientNumRequestedOutputsEnum()
+	"""
+
+	return StringToEnum('TransientNumRequestedOutputs')
+
+def TransientRequestedOutputsEnum():
+	"""
+	TRANSIENTREQUESTEDOUTPUTSENUM - Enum of TransientRequestedOutputs
+
+	   Usage:
+	      macro=TransientRequestedOutputsEnum()
+	"""
+
+	return StringToEnum('TransientRequestedOutputs')
+
+def SolutionTypeEnum():
+	"""
+	SOLUTIONTYPEENUM - Enum of SolutionType
+
+	   Usage:
+	      macro=SolutionTypeEnum()
+	"""
+
+	return StringToEnum('SolutionType')
+
+def AnalysisTypeEnum():
+	"""
+	ANALYSISTYPEENUM - Enum of AnalysisType
+
+	   Usage:
+	      macro=AnalysisTypeEnum()
+	"""
+
+	return StringToEnum('AnalysisType')
+
+def ConfigurationTypeEnum():
+	"""
+	CONFIGURATIONTYPEENUM - Enum of ConfigurationType
+
+	   Usage:
+	      macro=ConfigurationTypeEnum()
+	"""
+
+	return StringToEnum('ConfigurationType')
+
+def AdjointBalancethicknessAnalysisEnum():
+	"""
+	ADJOINTBALANCETHICKNESSANALYSISENUM - Enum of AdjointBalancethicknessAnalysis
+
+	   Usage:
+	      macro=AdjointBalancethicknessAnalysisEnum()
+	"""
+
+	return StringToEnum('AdjointBalancethicknessAnalysis')
+
+def AdjointHorizAnalysisEnum():
+	"""
+	ADJOINTHORIZANALYSISENUM - Enum of AdjointHorizAnalysis
+
+	   Usage:
+	      macro=AdjointHorizAnalysisEnum()
+	"""
+
+	return StringToEnum('AdjointHorizAnalysis')
+
+def AdjointSolutionEnum():
+	"""
+	ADJOINTSOLUTIONENUM - Enum of AdjointSolution
+
+	   Usage:
+	      macro=AdjointSolutionEnum()
+	"""
+
+	return StringToEnum('AdjointSolution')
+
+def AnalysisCounterEnum():
+	"""
+	ANALYSISCOUNTERENUM - Enum of AnalysisCounter
+
+	   Usage:
+	      macro=AnalysisCounterEnum()
+	"""
+
+	return StringToEnum('AnalysisCounter')
+
+def BalancethicknessAnalysisEnum():
+	"""
+	BALANCETHICKNESSANALYSISENUM - Enum of BalancethicknessAnalysis
+
+	   Usage:
+	      macro=BalancethicknessAnalysisEnum()
+	"""
+
+	return StringToEnum('BalancethicknessAnalysis')
+
+def BalancethicknessSolutionEnum():
+	"""
+	BALANCETHICKNESSSOLUTIONENUM - Enum of BalancethicknessSolution
+
+	   Usage:
+	      macro=BalancethicknessSolutionEnum()
+	"""
+
+	return StringToEnum('BalancethicknessSolution')
+
+def BedSlopeAnalysisEnum():
+	"""
+	BEDSLOPEANALYSISENUM - Enum of BedSlopeAnalysis
+
+	   Usage:
+	      macro=BedSlopeAnalysisEnum()
+	"""
+
+	return StringToEnum('BedSlopeAnalysis')
+
+def BedSlopeSolutionEnum():
+	"""
+	BEDSLOPESOLUTIONENUM - Enum of BedSlopeSolution
+
+	   Usage:
+	      macro=BedSlopeSolutionEnum()
+	"""
+
+	return StringToEnum('BedSlopeSolution')
+
+def BedSlopeXAnalysisEnum():
+	"""
+	BEDSLOPEXANALYSISENUM - Enum of BedSlopeXAnalysis
+
+	   Usage:
+	      macro=BedSlopeXAnalysisEnum()
+	"""
+
+	return StringToEnum('BedSlopeXAnalysis')
+
+def BedSlopeYAnalysisEnum():
+	"""
+	BEDSLOPEYANALYSISENUM - Enum of BedSlopeYAnalysis
+
+	   Usage:
+	      macro=BedSlopeYAnalysisEnum()
+	"""
+
+	return StringToEnum('BedSlopeYAnalysis')
+
+def DiagnosticHorizAnalysisEnum():
+	"""
+	DIAGNOSTICHORIZANALYSISENUM - Enum of DiagnosticHorizAnalysis
+
+	   Usage:
+	      macro=DiagnosticHorizAnalysisEnum()
+	"""
+
+	return StringToEnum('DiagnosticHorizAnalysis')
+
+def DiagnosticHutterAnalysisEnum():
+	"""
+	DIAGNOSTICHUTTERANALYSISENUM - Enum of DiagnosticHutterAnalysis
+
+	   Usage:
+	      macro=DiagnosticHutterAnalysisEnum()
+	"""
+
+	return StringToEnum('DiagnosticHutterAnalysis')
+
+def DiagnosticSolutionEnum():
+	"""
+	DIAGNOSTICSOLUTIONENUM - Enum of DiagnosticSolution
+
+	   Usage:
+	      macro=DiagnosticSolutionEnum()
+	"""
+
+	return StringToEnum('DiagnosticSolution')
+
+def DiagnosticVertAnalysisEnum():
+	"""
+	DIAGNOSTICVERTANALYSISENUM - Enum of DiagnosticVertAnalysis
+
+	   Usage:
+	      macro=DiagnosticVertAnalysisEnum()
+	"""
+
+	return StringToEnum('DiagnosticVertAnalysis')
+
+def EnthalpyAnalysisEnum():
+	"""
+	ENTHALPYANALYSISENUM - Enum of EnthalpyAnalysis
+
+	   Usage:
+	      macro=EnthalpyAnalysisEnum()
+	"""
+
+	return StringToEnum('EnthalpyAnalysis')
+
+def EnthalpySolutionEnum():
+	"""
+	ENTHALPYSOLUTIONENUM - Enum of EnthalpySolution
+
+	   Usage:
+	      macro=EnthalpySolutionEnum()
+	"""
+
+	return StringToEnum('EnthalpySolution')
+
+def FlaimAnalysisEnum():
+	"""
+	FLAIMANALYSISENUM - Enum of FlaimAnalysis
+
+	   Usage:
+	      macro=FlaimAnalysisEnum()
+	"""
+
+	return StringToEnum('FlaimAnalysis')
+
+def FlaimSolutionEnum():
+	"""
+	FLAIMSOLUTIONENUM - Enum of FlaimSolution
+
+	   Usage:
+	      macro=FlaimSolutionEnum()
+	"""
+
+	return StringToEnum('FlaimSolution')
+
+def HydrologyAnalysisEnum():
+	"""
+	HYDROLOGYANALYSISENUM - Enum of HydrologyAnalysis
+
+	   Usage:
+	      macro=HydrologyAnalysisEnum()
+	"""
+
+	return StringToEnum('HydrologyAnalysis')
+
+def HydrologySolutionEnum():
+	"""
+	HYDROLOGYSOLUTIONENUM - Enum of HydrologySolution
+
+	   Usage:
+	      macro=HydrologySolutionEnum()
+	"""
+
+	return StringToEnum('HydrologySolution')
+
+def MeltingAnalysisEnum():
+	"""
+	MELTINGANALYSISENUM - Enum of MeltingAnalysis
+
+	   Usage:
+	      macro=MeltingAnalysisEnum()
+	"""
+
+	return StringToEnum('MeltingAnalysis')
+
+def NoneAnalysisEnum():
+	"""
+	NONEANALYSISENUM - Enum of NoneAnalysis
+
+	   Usage:
+	      macro=NoneAnalysisEnum()
+	"""
+
+	return StringToEnum('NoneAnalysis')
+
+def PrognosticAnalysisEnum():
+	"""
+	PROGNOSTICANALYSISENUM - Enum of PrognosticAnalysis
+
+	   Usage:
+	      macro=PrognosticAnalysisEnum()
+	"""
+
+	return StringToEnum('PrognosticAnalysis')
+
+def PrognosticSolutionEnum():
+	"""
+	PROGNOSTICSOLUTIONENUM - Enum of PrognosticSolution
+
+	   Usage:
+	      macro=PrognosticSolutionEnum()
+	"""
+
+	return StringToEnum('PrognosticSolution')
+
+def SteadystateSolutionEnum():
+	"""
+	STEADYSTATESOLUTIONENUM - Enum of SteadystateSolution
+
+	   Usage:
+	      macro=SteadystateSolutionEnum()
+	"""
+
+	return StringToEnum('SteadystateSolution')
+
+def SurfaceSlopeAnalysisEnum():
+	"""
+	SURFACESLOPEANALYSISENUM - Enum of SurfaceSlopeAnalysis
+
+	   Usage:
+	      macro=SurfaceSlopeAnalysisEnum()
+	"""
+
+	return StringToEnum('SurfaceSlopeAnalysis')
+
+def SurfaceSlopeSolutionEnum():
+	"""
+	SURFACESLOPESOLUTIONENUM - Enum of SurfaceSlopeSolution
+
+	   Usage:
+	      macro=SurfaceSlopeSolutionEnum()
+	"""
+
+	return StringToEnum('SurfaceSlopeSolution')
+
+def SurfaceSlopeXAnalysisEnum():
+	"""
+	SURFACESLOPEXANALYSISENUM - Enum of SurfaceSlopeXAnalysis
+
+	   Usage:
+	      macro=SurfaceSlopeXAnalysisEnum()
+	"""
+
+	return StringToEnum('SurfaceSlopeXAnalysis')
+
+def SurfaceSlopeYAnalysisEnum():
+	"""
+	SURFACESLOPEYANALYSISENUM - Enum of SurfaceSlopeYAnalysis
+
+	   Usage:
+	      macro=SurfaceSlopeYAnalysisEnum()
+	"""
+
+	return StringToEnum('SurfaceSlopeYAnalysis')
+
+def ThermalAnalysisEnum():
+	"""
+	THERMALANALYSISENUM - Enum of ThermalAnalysis
+
+	   Usage:
+	      macro=ThermalAnalysisEnum()
+	"""
+
+	return StringToEnum('ThermalAnalysis')
+
+def ThermalSolutionEnum():
+	"""
+	THERMALSOLUTIONENUM - Enum of ThermalSolution
+
+	   Usage:
+	      macro=ThermalSolutionEnum()
+	"""
+
+	return StringToEnum('ThermalSolution')
+
+def TransientSolutionEnum():
+	"""
+	TRANSIENTSOLUTIONENUM - Enum of TransientSolution
+
+	   Usage:
+	      macro=TransientSolutionEnum()
+	"""
+
+	return StringToEnum('TransientSolution')
+
+def ApproximationEnum():
+	"""
+	APPROXIMATIONENUM - Enum of Approximation
+
+	   Usage:
+	      macro=ApproximationEnum()
+	"""
+
+	return StringToEnum('Approximation')
+
+def HutterApproximationEnum():
+	"""
+	HUTTERAPPROXIMATIONENUM - Enum of HutterApproximation
+
+	   Usage:
+	      macro=HutterApproximationEnum()
+	"""
+
+	return StringToEnum('HutterApproximation')
+
+def MacAyealApproximationEnum():
+	"""
+	MACAYEALAPPROXIMATIONENUM - Enum of MacAyealApproximation
+
+	   Usage:
+	      macro=MacAyealApproximationEnum()
+	"""
+
+	return StringToEnum('MacAyealApproximation')
+
+def MacAyealPattynApproximationEnum():
+	"""
+	MACAYEALPATTYNAPPROXIMATIONENUM - Enum of MacAyealPattynApproximation
+
+	   Usage:
+	      macro=MacAyealPattynApproximationEnum()
+	"""
+
+	return StringToEnum('MacAyealPattynApproximation')
+
+def MacAyealStokesApproximationEnum():
+	"""
+	MACAYEALSTOKESAPPROXIMATIONENUM - Enum of MacAyealStokesApproximation
+
+	   Usage:
+	      macro=MacAyealStokesApproximationEnum()
+	"""
+
+	return StringToEnum('MacAyealStokesApproximation')
+
+def NoneApproximationEnum():
+	"""
+	NONEAPPROXIMATIONENUM - Enum of NoneApproximation
+
+	   Usage:
+	      macro=NoneApproximationEnum()
+	"""
+
+	return StringToEnum('NoneApproximation')
+
+def PattynApproximationEnum():
+	"""
+	PATTYNAPPROXIMATIONENUM - Enum of PattynApproximation
+
+	   Usage:
+	      macro=PattynApproximationEnum()
+	"""
+
+	return StringToEnum('PattynApproximation')
+
+def PattynStokesApproximationEnum():
+	"""
+	PATTYNSTOKESAPPROXIMATIONENUM - Enum of PattynStokesApproximation
+
+	   Usage:
+	      macro=PattynStokesApproximationEnum()
+	"""
+
+	return StringToEnum('PattynStokesApproximation')
+
+def StokesApproximationEnum():
+	"""
+	STOKESAPPROXIMATIONENUM - Enum of StokesApproximation
+
+	   Usage:
+	      macro=StokesApproximationEnum()
+	"""
+
+	return StringToEnum('StokesApproximation')
+
+def ConstraintsEnum():
+	"""
+	CONSTRAINTSENUM - Enum of Constraints
+
+	   Usage:
+	      macro=ConstraintsEnum()
+	"""
+
+	return StringToEnum('Constraints')
+
+def LoadsEnum():
+	"""
+	LOADSENUM - Enum of Loads
+
+	   Usage:
+	      macro=LoadsEnum()
+	"""
+
+	return StringToEnum('Loads')
+
+def MaterialsEnum():
+	"""
+	MATERIALSENUM - Enum of Materials
+
+	   Usage:
+	      macro=MaterialsEnum()
+	"""
+
+	return StringToEnum('Materials')
+
+def NodesEnum():
+	"""
+	NODESENUM - Enum of Nodes
+
+	   Usage:
+	      macro=NodesEnum()
+	"""
+
+	return StringToEnum('Nodes')
+
+def ParametersEnum():
+	"""
+	PARAMETERSENUM - Enum of Parameters
+
+	   Usage:
+	      macro=ParametersEnum()
+	"""
+
+	return StringToEnum('Parameters')
+
+def VerticesEnum():
+	"""
+	VERTICESENUM - Enum of Vertices
+
+	   Usage:
+	      macro=VerticesEnum()
+	"""
+
+	return StringToEnum('Vertices')
+
+def ResultsEnum():
+	"""
+	RESULTSENUM - Enum of Results
+
+	   Usage:
+	      macro=ResultsEnum()
+	"""
+
+	return StringToEnum('Results')
+
+def BoolInputEnum():
+	"""
+	BOOLINPUTENUM - Enum of BoolInput
+
+	   Usage:
+	      macro=BoolInputEnum()
+	"""
+
+	return StringToEnum('BoolInput')
+
+def BoolParamEnum():
+	"""
+	BOOLPARAMENUM - Enum of BoolParam
+
+	   Usage:
+	      macro=BoolParamEnum()
+	"""
+
+	return StringToEnum('BoolParam')
+
+def ContourEnum():
+	"""
+	CONTOURENUM - Enum of Contour
+
+	   Usage:
+	      macro=ContourEnum()
+	"""
+
+	return StringToEnum('Contour')
+
+def ControlInputEnum():
+	"""
+	CONTROLINPUTENUM - Enum of ControlInput
+
+	   Usage:
+	      macro=ControlInputEnum()
+	"""
+
+	return StringToEnum('ControlInput')
+
+def DatasetInputEnum():
+	"""
+	DATASETINPUTENUM - Enum of DatasetInput
+
+	   Usage:
+	      macro=DatasetInputEnum()
+	"""
+
+	return StringToEnum('DatasetInput')
+
+def DofIndexingEnum():
+	"""
+	DOFINDEXINGENUM - Enum of DofIndexing
+
+	   Usage:
+	      macro=DofIndexingEnum()
+	"""
+
+	return StringToEnum('DofIndexing')
+
+def DoubleInputEnum():
+	"""
+	DOUBLEINPUTENUM - Enum of DoubleInput
+
+	   Usage:
+	      macro=DoubleInputEnum()
+	"""
+
+	return StringToEnum('DoubleInput')
+
+def DoubleMatArrayParamEnum():
+	"""
+	DOUBLEMATARRAYPARAMENUM - Enum of DoubleMatArrayParam
+
+	   Usage:
+	      macro=DoubleMatArrayParamEnum()
+	"""
+
+	return StringToEnum('DoubleMatArrayParam')
+
+def DoubleMatParamEnum():
+	"""
+	DOUBLEMATPARAMENUM - Enum of DoubleMatParam
+
+	   Usage:
+	      macro=DoubleMatParamEnum()
+	"""
+
+	return StringToEnum('DoubleMatParam')
+
+def DoubleParamEnum():
+	"""
+	DOUBLEPARAMENUM - Enum of DoubleParam
+
+	   Usage:
+	      macro=DoubleParamEnum()
+	"""
+
+	return StringToEnum('DoubleParam')
+
+def DoubleVecParamEnum():
+	"""
+	DOUBLEVECPARAMENUM - Enum of DoubleVecParam
+
+	   Usage:
+	      macro=DoubleVecParamEnum()
+	"""
+
+	return StringToEnum('DoubleVecParam')
+
+def ElementEnum():
+	"""
+	ELEMENTENUM - Enum of Element
+
+	   Usage:
+	      macro=ElementEnum()
+	"""
+
+	return StringToEnum('Element')
+
+def ElementResultEnum():
+	"""
+	ELEMENTRESULTENUM - Enum of ElementResult
+
+	   Usage:
+	      macro=ElementResultEnum()
+	"""
+
+	return StringToEnum('ElementResult')
+
+def ExternalResultEnum():
+	"""
+	EXTERNALRESULTENUM - Enum of ExternalResult
+
+	   Usage:
+	      macro=ExternalResultEnum()
+	"""
+
+	return StringToEnum('ExternalResult')
+
+def FileParamEnum():
+	"""
+	FILEPARAMENUM - Enum of FileParam
+
+	   Usage:
+	      macro=FileParamEnum()
+	"""
+
+	return StringToEnum('FileParam')
+
+def HookEnum():
+	"""
+	HOOKENUM - Enum of Hook
+
+	   Usage:
+	      macro=HookEnum()
+	"""
+
+	return StringToEnum('Hook')
+
+def IcefrontEnum():
+	"""
+	ICEFRONTENUM - Enum of Icefront
+
+	   Usage:
+	      macro=IcefrontEnum()
+	"""
+
+	return StringToEnum('Icefront')
+
+def InputEnum():
+	"""
+	INPUTENUM - Enum of Input
+
+	   Usage:
+	      macro=InputEnum()
+	"""
+
+	return StringToEnum('Input')
+
+def IntInputEnum():
+	"""
+	INTINPUTENUM - Enum of IntInput
+
+	   Usage:
+	      macro=IntInputEnum()
+	"""
+
+	return StringToEnum('IntInput')
+
+def IntParamEnum():
+	"""
+	INTPARAMENUM - Enum of IntParam
+
+	   Usage:
+	      macro=IntParamEnum()
+	"""
+
+	return StringToEnum('IntParam')
+
+def IntVecParamEnum():
+	"""
+	INTVECPARAMENUM - Enum of IntVecParam
+
+	   Usage:
+	      macro=IntVecParamEnum()
+	"""
+
+	return StringToEnum('IntVecParam')
+
+def MacAyeal2dIceFrontEnum():
+	"""
+	MACAYEAL2DICEFRONTENUM - Enum of MacAyeal2dIceFront
+
+	   Usage:
+	      macro=MacAyeal2dIceFrontEnum()
+	"""
+
+	return StringToEnum('MacAyeal2dIceFront')
+
+def MacAyeal3dIceFrontEnum():
+	"""
+	MACAYEAL3DICEFRONTENUM - Enum of MacAyeal3dIceFront
+
+	   Usage:
+	      macro=MacAyeal3dIceFrontEnum()
+	"""
+
+	return StringToEnum('MacAyeal3dIceFront')
+
+def MaticeEnum():
+	"""
+	MATICEENUM - Enum of Matice
+
+	   Usage:
+	      macro=MaticeEnum()
+	"""
+
+	return StringToEnum('Matice')
+
+def MatparEnum():
+	"""
+	MATPARENUM - Enum of Matpar
+
+	   Usage:
+	      macro=MatparEnum()
+	"""
+
+	return StringToEnum('Matpar')
+
+def NodeEnum():
+	"""
+	NODEENUM - Enum of Node
+
+	   Usage:
+	      macro=NodeEnum()
+	"""
+
+	return StringToEnum('Node')
+
+def NumericalfluxEnum():
+	"""
+	NUMERICALFLUXENUM - Enum of Numericalflux
+
+	   Usage:
+	      macro=NumericalfluxEnum()
+	"""
+
+	return StringToEnum('Numericalflux')
+
+def ParamEnum():
+	"""
+	PARAMENUM - Enum of Param
+
+	   Usage:
+	      macro=ParamEnum()
+	"""
+
+	return StringToEnum('Param')
+
+def PattynIceFrontEnum():
+	"""
+	PATTYNICEFRONTENUM - Enum of PattynIceFront
+
+	   Usage:
+	      macro=PattynIceFrontEnum()
+	"""
+
+	return StringToEnum('PattynIceFront')
+
+def PengridEnum():
+	"""
+	PENGRIDENUM - Enum of Pengrid
+
+	   Usage:
+	      macro=PengridEnum()
+	"""
+
+	return StringToEnum('Pengrid')
+
+def PenpairEnum():
+	"""
+	PENPAIRENUM - Enum of Penpair
+
+	   Usage:
+	      macro=PenpairEnum()
+	"""
+
+	return StringToEnum('Penpair')
+
+def PentaEnum():
+	"""
+	PENTAENUM - Enum of Penta
+
+	   Usage:
+	      macro=PentaEnum()
+	"""
+
+	return StringToEnum('Penta')
+
+def PentaP1InputEnum():
+	"""
+	PENTAP1INPUTENUM - Enum of PentaP1Input
+
+	   Usage:
+	      macro=PentaP1InputEnum()
+	"""
+
+	return StringToEnum('PentaP1Input')
+
+def MatrixParamEnum():
+	"""
+	MATRIXPARAMENUM - Enum of MatrixParam
+
+	   Usage:
+	      macro=MatrixParamEnum()
+	"""
+
+	return StringToEnum('MatrixParam')
+
+def VectorParamEnum():
+	"""
+	VECTORPARAMENUM - Enum of VectorParam
+
+	   Usage:
+	      macro=VectorParamEnum()
+	"""
+
+	return StringToEnum('VectorParam')
+
+def RiftfrontEnum():
+	"""
+	RIFTFRONTENUM - Enum of Riftfront
+
+	   Usage:
+	      macro=RiftfrontEnum()
+	"""
+
+	return StringToEnum('Riftfront')
+
+def SegmentEnum():
+	"""
+	SEGMENTENUM - Enum of Segment
+
+	   Usage:
+	      macro=SegmentEnum()
+	"""
+
+	return StringToEnum('Segment')
+
+def SegmentRiftfrontEnum():
+	"""
+	SEGMENTRIFTFRONTENUM - Enum of SegmentRiftfront
+
+	   Usage:
+	      macro=SegmentRiftfrontEnum()
+	"""
+
+	return StringToEnum('SegmentRiftfront')
+
+def SpcDynamicEnum():
+	"""
+	SPCDYNAMICENUM - Enum of SpcDynamic
+
+	   Usage:
+	      macro=SpcDynamicEnum()
+	"""
+
+	return StringToEnum('SpcDynamic')
+
+def SpcStaticEnum():
+	"""
+	SPCSTATICENUM - Enum of SpcStatic
+
+	   Usage:
+	      macro=SpcStaticEnum()
+	"""
+
+	return StringToEnum('SpcStatic')
+
+def SpcTransientEnum():
+	"""
+	SPCTRANSIENTENUM - Enum of SpcTransient
+
+	   Usage:
+	      macro=SpcTransientEnum()
+	"""
+
+	return StringToEnum('SpcTransient')
+
+def StokesIceFrontEnum():
+	"""
+	STOKESICEFRONTENUM - Enum of StokesIceFront
+
+	   Usage:
+	      macro=StokesIceFrontEnum()
+	"""
+
+	return StringToEnum('StokesIceFront')
+
+def StringArrayParamEnum():
+	"""
+	STRINGARRAYPARAMENUM - Enum of StringArrayParam
+
+	   Usage:
+	      macro=StringArrayParamEnum()
+	"""
+
+	return StringToEnum('StringArrayParam')
+
+def StringParamEnum():
+	"""
+	STRINGPARAMENUM - Enum of StringParam
+
+	   Usage:
+	      macro=StringParamEnum()
+	"""
+
+	return StringToEnum('StringParam')
+
+def TriaEnum():
+	"""
+	TRIAENUM - Enum of Tria
+
+	   Usage:
+	      macro=TriaEnum()
+	"""
+
+	return StringToEnum('Tria')
+
+def TriaP1InputEnum():
+	"""
+	TRIAP1INPUTENUM - Enum of TriaP1Input
+
+	   Usage:
+	      macro=TriaP1InputEnum()
+	"""
+
+	return StringToEnum('TriaP1Input')
+
+def VertexEnum():
+	"""
+	VERTEXENUM - Enum of Vertex
+
+	   Usage:
+	      macro=VertexEnum()
+	"""
+
+	return StringToEnum('Vertex')
+
+def AirEnum():
+	"""
+	AIRENUM - Enum of Air
+
+	   Usage:
+	      macro=AirEnum()
+	"""
+
+	return StringToEnum('Air')
+
+def IceEnum():
+	"""
+	ICEENUM - Enum of Ice
+
+	   Usage:
+	      macro=IceEnum()
+	"""
+
+	return StringToEnum('Ice')
+
+def MelangeEnum():
+	"""
+	MELANGEENUM - Enum of Melange
+
+	   Usage:
+	      macro=MelangeEnum()
+	"""
+
+	return StringToEnum('Melange')
+
+def WaterEnum():
+	"""
+	WATERENUM - Enum of Water
+
+	   Usage:
+	      macro=WaterEnum()
+	"""
+
+	return StringToEnum('Water')
+
+def ClosedEnum():
+	"""
+	CLOSEDENUM - Enum of Closed
+
+	   Usage:
+	      macro=ClosedEnum()
+	"""
+
+	return StringToEnum('Closed')
+
+def FreeEnum():
+	"""
+	FREEENUM - Enum of Free
+
+	   Usage:
+	      macro=FreeEnum()
+	"""
+
+	return StringToEnum('Free')
+
+def OpenEnum():
+	"""
+	OPENENUM - Enum of Open
+
+	   Usage:
+	      macro=OpenEnum()
+	"""
+
+	return StringToEnum('Open')
+
+def AdjointpEnum():
+	"""
+	ADJOINTPENUM - Enum of Adjointp
+
+	   Usage:
+	      macro=AdjointpEnum()
+	"""
+
+	return StringToEnum('Adjointp')
+
+def AdjointxEnum():
+	"""
+	ADJOINTXENUM - Enum of Adjointx
+
+	   Usage:
+	      macro=AdjointxEnum()
+	"""
+
+	return StringToEnum('Adjointx')
+
+def AdjointyEnum():
+	"""
+	ADJOINTYENUM - Enum of Adjointy
+
+	   Usage:
+	      macro=AdjointyEnum()
+	"""
+
+	return StringToEnum('Adjointy')
+
+def AdjointzEnum():
+	"""
+	ADJOINTZENUM - Enum of Adjointz
+
+	   Usage:
+	      macro=AdjointzEnum()
+	"""
+
+	return StringToEnum('Adjointz')
+
+def BedSlopeXEnum():
+	"""
+	BEDSLOPEXENUM - Enum of BedSlopeX
+
+	   Usage:
+	      macro=BedSlopeXEnum()
+	"""
+
+	return StringToEnum('BedSlopeX')
+
+def BedSlopeYEnum():
+	"""
+	BEDSLOPEYENUM - Enum of BedSlopeY
+
+	   Usage:
+	      macro=BedSlopeYEnum()
+	"""
+
+	return StringToEnum('BedSlopeY')
+
+def BoundaryEnum():
+	"""
+	BOUNDARYENUM - Enum of Boundary
+
+	   Usage:
+	      macro=BoundaryEnum()
+	"""
+
+	return StringToEnum('Boundary')
+
+def ConstantEnum():
+	"""
+	CONSTANTENUM - Enum of Constant
+
+	   Usage:
+	      macro=ConstantEnum()
+	"""
+
+	return StringToEnum('Constant')
+
+def ConvergedEnum():
+	"""
+	CONVERGEDENUM - Enum of Converged
+
+	   Usage:
+	      macro=ConvergedEnum()
+	"""
+
+	return StringToEnum('Converged')
+
+def ExtToIuEnum():
+	"""
+	EXTTOIUENUM - Enum of ExtToIu
+
+	   Usage:
+	      macro=ExtToIuEnum()
+	"""
+
+	return StringToEnum('ExtToIu')
+
+def FillEnum():
+	"""
+	FILLENUM - Enum of Fill
+
+	   Usage:
+	      macro=FillEnum()
+	"""
+
+	return StringToEnum('Fill')
+
+def FractionIncrementEnum():
+	"""
+	FRACTIONINCREMENTENUM - Enum of FractionIncrement
+
+	   Usage:
+	      macro=FractionIncrementEnum()
+	"""
+
+	return StringToEnum('FractionIncrement')
+
+def FrictionEnum():
+	"""
+	FRICTIONENUM - Enum of Friction
+
+	   Usage:
+	      macro=FrictionEnum()
+	"""
+
+	return StringToEnum('Friction')
+
+def GroundinglineMeltingRateEnum():
+	"""
+	GROUNDINGLINEMELTINGRATEENUM - Enum of GroundinglineMeltingRate
+
+	   Usage:
+	      macro=GroundinglineMeltingRateEnum()
+	"""
+
+	return StringToEnum('GroundinglineMeltingRate')
+
+def InternalEnum():
+	"""
+	INTERNALENUM - Enum of Internal
+
+	   Usage:
+	      macro=InternalEnum()
+	"""
+
+	return StringToEnum('Internal')
+
+def IuToExtEnum():
+	"""
+	IUTOEXTENUM - Enum of IuToExt
+
+	   Usage:
+	      macro=IuToExtEnum()
+	"""
+
+	return StringToEnum('IuToExt')
+
+def MassFluxEnum():
+	"""
+	MASSFLUXENUM - Enum of MassFlux
+
+	   Usage:
+	      macro=MassFluxEnum()
+	"""
+
+	return StringToEnum('MassFlux')
+
+def MaxPenetrationEnum():
+	"""
+	MAXPENETRATIONENUM - Enum of MaxPenetration
+
+	   Usage:
+	      macro=MaxPenetrationEnum()
+	"""
+
+	return StringToEnum('MaxPenetration')
+
+def MeltingOffsetEnum():
+	"""
+	MELTINGOFFSETENUM - Enum of MeltingOffset
+
+	   Usage:
+	      macro=MeltingOffsetEnum()
+	"""
+
+	return StringToEnum('MeltingOffset')
+
+def MisfitEnum():
+	"""
+	MISFITENUM - Enum of Misfit
+
+	   Usage:
+	      macro=MisfitEnum()
+	"""
+
+	return StringToEnum('Misfit')
+
+def NumberNodeToElementConnectivityEnum():
+	"""
+	NUMBERNODETOELEMENTCONNECTIVITYENUM - Enum of NumberNodeToElementConnectivity
+
+	   Usage:
+	      macro=NumberNodeToElementConnectivityEnum()
+	"""
+
+	return StringToEnum('NumberNodeToElementConnectivity')
+
+def PressureEnum():
+	"""
+	PRESSUREENUM - Enum of Pressure
+
+	   Usage:
+	      macro=PressureEnum()
+	"""
+
+	return StringToEnum('Pressure')
+
+def PressurePicardEnum():
+	"""
+	PRESSUREPICARDENUM - Enum of PressurePicard
+
+	   Usage:
+	      macro=PressurePicardEnum()
+	"""
+
+	return StringToEnum('PressurePicard')
+
+def QmuPressureEnum():
+	"""
+	QMUPRESSUREENUM - Enum of QmuPressure
+
+	   Usage:
+	      macro=QmuPressureEnum()
+	"""
+
+	return StringToEnum('QmuPressure')
+
+def QmuVxEnum():
+	"""
+	QMUVXENUM - Enum of QmuVx
+
+	   Usage:
+	      macro=QmuVxEnum()
+	"""
+
+	return StringToEnum('QmuVx')
+
+def QmuVyEnum():
+	"""
+	QMUVYENUM - Enum of QmuVy
+
+	   Usage:
+	      macro=QmuVyEnum()
+	"""
+
+	return StringToEnum('QmuVy')
+
+def QmuVzEnum():
+	"""
+	QMUVZENUM - Enum of QmuVz
+
+	   Usage:
+	      macro=QmuVzEnum()
+	"""
+
+	return StringToEnum('QmuVz')
+
+def QmuThicknessEnum():
+	"""
+	QMUTHICKNESSENUM - Enum of QmuThickness
+
+	   Usage:
+	      macro=QmuThicknessEnum()
+	"""
+
+	return StringToEnum('QmuThickness')
+
+def QmuBedEnum():
+	"""
+	QMUBEDENUM - Enum of QmuBed
+
+	   Usage:
+	      macro=QmuBedEnum()
+	"""
+
+	return StringToEnum('QmuBed')
+
+def QmuSurfaceEnum():
+	"""
+	QMUSURFACEENUM - Enum of QmuSurface
+
+	   Usage:
+	      macro=QmuSurfaceEnum()
+	"""
+
+	return StringToEnum('QmuSurface')
+
+def QmuMeltingEnum():
+	"""
+	QMUMELTINGENUM - Enum of QmuMelting
+
+	   Usage:
+	      macro=QmuMeltingEnum()
+	"""
+
+	return StringToEnum('QmuMelting')
+
+def ResetPenaltiesEnum():
+	"""
+	RESETPENALTIESENUM - Enum of ResetPenalties
+
+	   Usage:
+	      macro=ResetPenaltiesEnum()
+	"""
+
+	return StringToEnum('ResetPenalties')
+
+def SegmentOnIceShelfEnum():
+	"""
+	SEGMENTONICESHELFENUM - Enum of SegmentOnIceShelf
+
+	   Usage:
+	      macro=SegmentOnIceShelfEnum()
+	"""
+
+	return StringToEnum('SegmentOnIceShelf')
+
+def SurfaceAbsVelMisfitEnum():
+	"""
+	SURFACEABSVELMISFITENUM - Enum of SurfaceAbsVelMisfit
+
+	   Usage:
+	      macro=SurfaceAbsVelMisfitEnum()
+	"""
+
+	return StringToEnum('SurfaceAbsVelMisfit')
+
+def SurfaceAreaEnum():
+	"""
+	SURFACEAREAENUM - Enum of SurfaceArea
+
+	   Usage:
+	      macro=SurfaceAreaEnum()
+	"""
+
+	return StringToEnum('SurfaceArea')
+
+def SurfaceAverageVelMisfitEnum():
+	"""
+	SURFACEAVERAGEVELMISFITENUM - Enum of SurfaceAverageVelMisfit
+
+	   Usage:
+	      macro=SurfaceAverageVelMisfitEnum()
+	"""
+
+	return StringToEnum('SurfaceAverageVelMisfit')
+
+def SurfaceLogVelMisfitEnum():
+	"""
+	SURFACELOGVELMISFITENUM - Enum of SurfaceLogVelMisfit
+
+	   Usage:
+	      macro=SurfaceLogVelMisfitEnum()
+	"""
+
+	return StringToEnum('SurfaceLogVelMisfit')
+
+def SurfaceLogVxVyMisfitEnum():
+	"""
+	SURFACELOGVXVYMISFITENUM - Enum of SurfaceLogVxVyMisfit
+
+	   Usage:
+	      macro=SurfaceLogVxVyMisfitEnum()
+	"""
+
+	return StringToEnum('SurfaceLogVxVyMisfit')
+
+def SurfaceRelVelMisfitEnum():
+	"""
+	SURFACERELVELMISFITENUM - Enum of SurfaceRelVelMisfit
+
+	   Usage:
+	      macro=SurfaceRelVelMisfitEnum()
+	"""
+
+	return StringToEnum('SurfaceRelVelMisfit')
+
+def SurfaceSlopeXEnum():
+	"""
+	SURFACESLOPEXENUM - Enum of SurfaceSlopeX
+
+	   Usage:
+	      macro=SurfaceSlopeXEnum()
+	"""
+
+	return StringToEnum('SurfaceSlopeX')
+
+def SurfaceSlopeYEnum():
+	"""
+	SURFACESLOPEYENUM - Enum of SurfaceSlopeY
+
+	   Usage:
+	      macro=SurfaceSlopeYEnum()
+	"""
+
+	return StringToEnum('SurfaceSlopeY')
+
+def TemperatureEnum():
+	"""
+	TEMPERATUREENUM - Enum of Temperature
+
+	   Usage:
+	      macro=TemperatureEnum()
+	"""
+
+	return StringToEnum('Temperature')
+
+def TemperatureOldEnum():
+	"""
+	TEMPERATUREOLDENUM - Enum of TemperatureOld
+
+	   Usage:
+	      macro=TemperatureOldEnum()
+	"""
+
+	return StringToEnum('TemperatureOld')
+
+def TemperaturePicardEnum():
+	"""
+	TEMPERATUREPICARDENUM - Enum of TemperaturePicard
+
+	   Usage:
+	      macro=TemperaturePicardEnum()
+	"""
+
+	return StringToEnum('TemperaturePicard')
+
+def ThicknessAbsMisfitEnum():
+	"""
+	THICKNESSABSMISFITENUM - Enum of ThicknessAbsMisfit
+
+	   Usage:
+	      macro=ThicknessAbsMisfitEnum()
+	"""
+
+	return StringToEnum('ThicknessAbsMisfit')
+
+def TypeEnum():
+	"""
+	TYPEENUM - Enum of Type
+
+	   Usage:
+	      macro=TypeEnum()
+	"""
+
+	return StringToEnum('Type')
+
+def VelEnum():
+	"""
+	VELENUM - Enum of Vel
+
+	   Usage:
+	      macro=VelEnum()
+	"""
+
+	return StringToEnum('Vel')
+
+def VelocityEnum():
+	"""
+	VELOCITYENUM - Enum of Velocity
+
+	   Usage:
+	      macro=VelocityEnum()
+	"""
+
+	return StringToEnum('Velocity')
+
+def VxAverageEnum():
+	"""
+	VXAVERAGEENUM - Enum of VxAverage
+
+	   Usage:
+	      macro=VxAverageEnum()
+	"""
+
+	return StringToEnum('VxAverage')
+
+def VxEnum():
+	"""
+	VXENUM - Enum of Vx
+
+	   Usage:
+	      macro=VxEnum()
+	"""
+
+	return StringToEnum('Vx')
+
+def VxPicardEnum():
+	"""
+	VXPICARDENUM - Enum of VxPicard
+
+	   Usage:
+	      macro=VxPicardEnum()
+	"""
+
+	return StringToEnum('VxPicard')
+
+def VyAverageEnum():
+	"""
+	VYAVERAGEENUM - Enum of VyAverage
+
+	   Usage:
+	      macro=VyAverageEnum()
+	"""
+
+	return StringToEnum('VyAverage')
+
+def VyEnum():
+	"""
+	VYENUM - Enum of Vy
+
+	   Usage:
+	      macro=VyEnum()
+	"""
+
+	return StringToEnum('Vy')
+
+def VyPicardEnum():
+	"""
+	VYPICARDENUM - Enum of VyPicard
+
+	   Usage:
+	      macro=VyPicardEnum()
+	"""
+
+	return StringToEnum('VyPicard')
+
+def VzEnum():
+	"""
+	VZENUM - Enum of Vz
+
+	   Usage:
+	      macro=VzEnum()
+	"""
+
+	return StringToEnum('Vz')
+
+def VzMacAyealEnum():
+	"""
+	VZMACAYEALENUM - Enum of VzMacAyeal
+
+	   Usage:
+	      macro=VzMacAyealEnum()
+	"""
+
+	return StringToEnum('VzMacAyeal')
+
+def VzPattynEnum():
+	"""
+	VZPATTYNENUM - Enum of VzPattyn
+
+	   Usage:
+	      macro=VzPattynEnum()
+	"""
+
+	return StringToEnum('VzPattyn')
+
+def VzPicardEnum():
+	"""
+	VZPICARDENUM - Enum of VzPicard
+
+	   Usage:
+	      macro=VzPicardEnum()
+	"""
+
+	return StringToEnum('VzPicard')
+
+def VzStokesEnum():
+	"""
+	VZSTOKESENUM - Enum of VzStokes
+
+	   Usage:
+	      macro=VzStokesEnum()
+	"""
+
+	return StringToEnum('VzStokes')
+
+def VxMeshEnum():
+	"""
+	VXMESHENUM - Enum of VxMesh
+
+	   Usage:
+	      macro=VxMeshEnum()
+	"""
+
+	return StringToEnum('VxMesh')
+
+def VyMeshEnum():
+	"""
+	VYMESHENUM - Enum of VyMesh
+
+	   Usage:
+	      macro=VyMeshEnum()
+	"""
+
+	return StringToEnum('VyMesh')
+
+def VzMeshEnum():
+	"""
+	VZMESHENUM - Enum of VzMesh
+
+	   Usage:
+	      macro=VzMeshEnum()
+	"""
+
+	return StringToEnum('VzMesh')
+
+def EnthalpyEnum():
+	"""
+	ENTHALPYENUM - Enum of Enthalpy
+
+	   Usage:
+	      macro=EnthalpyEnum()
+	"""
+
+	return StringToEnum('Enthalpy')
+
+def EnthalpyPicardEnum():
+	"""
+	ENTHALPYPICARDENUM - Enum of EnthalpyPicard
+
+	   Usage:
+	      macro=EnthalpyPicardEnum()
+	"""
+
+	return StringToEnum('EnthalpyPicard')
+
+def ThicknessAbsGradientEnum():
+	"""
+	THICKNESSABSGRADIENTENUM - Enum of ThicknessAbsGradient
+
+	   Usage:
+	      macro=ThicknessAbsGradientEnum()
+	"""
+
+	return StringToEnum('ThicknessAbsGradient')
+
+def StepResponsesEnum():
+	"""
+	STEPRESPONSESENUM - Enum of StepResponses
+
+	   Usage:
+	      macro=StepResponsesEnum()
+	"""
+
+	return StringToEnum('StepResponses')
+
+def IntMatParamEnum():
+	"""
+	INTMATPARAMENUM - Enum of IntMatParam
+
+	   Usage:
+	      macro=IntMatParamEnum()
+	"""
+
+	return StringToEnum('IntMatParam')
+
+def RheologyBbarAbsGradientEnum():
+	"""
+	RHEOLOGYBBARABSGRADIENTENUM - Enum of RheologyBbarAbsGradient
+
+	   Usage:
+	      macro=RheologyBbarAbsGradientEnum()
+	"""
+
+	return StringToEnum('RheologyBbarAbsGradient')
+
+def DragCoefficientAbsGradientEnum():
+	"""
+	DRAGCOEFFICIENTABSGRADIENTENUM - Enum of DragCoefficientAbsGradient
+
+	   Usage:
+	      macro=DragCoefficientAbsGradientEnum()
+	"""
+
+	return StringToEnum('DragCoefficientAbsGradient')
+
+def TransientInputEnum():
+	"""
+	TRANSIENTINPUTENUM - Enum of TransientInput
+
+	   Usage:
+	      macro=TransientInputEnum()
+	"""
+
+	return StringToEnum('TransientInput')
+
+def OutputfilenameEnum():
+	"""
+	OUTPUTFILENAMEENUM - Enum of Outputfilename
+
+	   Usage:
+	      macro=OutputfilenameEnum()
+	"""
+
+	return StringToEnum('Outputfilename')
+
+def WaterfractionEnum():
+	"""
+	WATERFRACTIONENUM - Enum of Waterfraction
+
+	   Usage:
+	      macro=WaterfractionEnum()
+	"""
+
+	return StringToEnum('Waterfraction')
+
+def WatercolumnEnum():
+	"""
+	WATERCOLUMNENUM - Enum of Watercolumn
+
+	   Usage:
+	      macro=WatercolumnEnum()
+	"""
+
+	return StringToEnum('Watercolumn')
+
+def BasalFrictionEnum():
+	"""
+	BASALFRICTIONENUM - Enum of BasalFriction
+
+	   Usage:
+	      macro=BasalFrictionEnum()
+	"""
+
+	return StringToEnum('BasalFriction')
+
+def ViscousHeatingEnum():
+	"""
+	VISCOUSHEATINGENUM - Enum of ViscousHeating
+
+	   Usage:
+	      macro=ViscousHeatingEnum()
+	"""
+
+	return StringToEnum('ViscousHeating')
+
+def QmuTemperatureEnum():
+	"""
+	QMUTEMPERATUREENUM - Enum of QmuTemperature
+
+	   Usage:
+	      macro=QmuTemperatureEnum()
+	"""
+
+	return StringToEnum('QmuTemperature')
+
+def HydrologyWaterVxEnum():
+	"""
+	HYDROLOGYWATERVXENUM - Enum of HydrologyWaterVx
+
+	   Usage:
+	      macro=HydrologyWaterVxEnum()
+	"""
+
+	return StringToEnum('HydrologyWaterVx')
+
+def HydrologyWaterVyEnum():
+	"""
+	HYDROLOGYWATERVYENUM - Enum of HydrologyWaterVy
+
+	   Usage:
+	      macro=HydrologyWaterVyEnum()
+	"""
+
+	return StringToEnum('HydrologyWaterVy')
+
+def StressTensorEnum():
+	"""
+	STRESSTENSORENUM - Enum of StressTensor
+
+	   Usage:
+	      macro=StressTensorEnum()
+	"""
+
+	return StringToEnum('StressTensor')
+
+def StressTensorxxEnum():
+	"""
+	STRESSTENSORXXENUM - Enum of StressTensorxx
+
+	   Usage:
+	      macro=StressTensorxxEnum()
+	"""
+
+	return StringToEnum('StressTensorxx')
+
+def StressTensorxyEnum():
+	"""
+	STRESSTENSORXYENUM - Enum of StressTensorxy
+
+	   Usage:
+	      macro=StressTensorxyEnum()
+	"""
+
+	return StringToEnum('StressTensorxy')
+
+def StressTensorxzEnum():
+	"""
+	STRESSTENSORXZENUM - Enum of StressTensorxz
+
+	   Usage:
+	      macro=StressTensorxzEnum()
+	"""
+
+	return StringToEnum('StressTensorxz')
+
+def StressTensoryyEnum():
+	"""
+	STRESSTENSORYYENUM - Enum of StressTensoryy
+
+	   Usage:
+	      macro=StressTensoryyEnum()
+	"""
+
+	return StringToEnum('StressTensoryy')
+
+def StressTensoryzEnum():
+	"""
+	STRESSTENSORYZENUM - Enum of StressTensoryz
+
+	   Usage:
+	      macro=StressTensoryzEnum()
+	"""
+
+	return StringToEnum('StressTensoryz')
+
+def StressTensorzzEnum():
+	"""
+	STRESSTENSORZZENUM - Enum of StressTensorzz
+
+	   Usage:
+	      macro=StressTensorzzEnum()
+	"""
+
+	return StringToEnum('StressTensorzz')
+
+def IceVolumeEnum():
+	"""
+	ICEVOLUMEENUM - Enum of IceVolume
+
+	   Usage:
+	      macro=IceVolumeEnum()
+	"""
+
+	return StringToEnum('IceVolume')
+
+def P0Enum():
+	"""
+	P0ENUM - Enum of P0
+
+	   Usage:
+	      macro=P0Enum()
+	"""
+
+	return StringToEnum('P0')
+
+def P1Enum():
+	"""
+	P1ENUM - Enum of P1
+
+	   Usage:
+	      macro=P1Enum()
+	"""
+
+	return StringToEnum('P1')
+
+def P1DGEnum():
+	"""
+	P1DGENUM - Enum of P1DG
+
+	   Usage:
+	      macro=P1DGEnum()
+	"""
+
+	return StringToEnum('P1DG')
+
+def SaveResultsEnum():
+	"""
+	SAVERESULTSENUM - Enum of SaveResults
+
+	   Usage:
+	      macro=SaveResultsEnum()
+	"""
+
+	return StringToEnum('SaveResults')
+
+def BoolElementResultEnum():
+	"""
+	BOOLELEMENTRESULTENUM - Enum of BoolElementResult
+
+	   Usage:
+	      macro=BoolElementResultEnum()
+	"""
+
+	return StringToEnum('BoolElementResult')
+
+def BoolExternalResultEnum():
+	"""
+	BOOLEXTERNALRESULTENUM - Enum of BoolExternalResult
+
+	   Usage:
+	      macro=BoolExternalResultEnum()
+	"""
+
+	return StringToEnum('BoolExternalResult')
+
+def DoubleElementResultEnum():
+	"""
+	DOUBLEELEMENTRESULTENUM - Enum of DoubleElementResult
+
+	   Usage:
+	      macro=DoubleElementResultEnum()
+	"""
+
+	return StringToEnum('DoubleElementResult')
+
+def DoubleExternalResultEnum():
+	"""
+	DOUBLEEXTERNALRESULTENUM - Enum of DoubleExternalResult
+
+	   Usage:
+	      macro=DoubleExternalResultEnum()
+	"""
+
+	return StringToEnum('DoubleExternalResult')
+
+def DoubleMatExternalResultEnum():
+	"""
+	DOUBLEMATEXTERNALRESULTENUM - Enum of DoubleMatExternalResult
+
+	   Usage:
+	      macro=DoubleMatExternalResultEnum()
+	"""
+
+	return StringToEnum('DoubleMatExternalResult')
+
+def DoubleVecExternalResultEnum():
+	"""
+	DOUBLEVECEXTERNALRESULTENUM - Enum of DoubleVecExternalResult
+
+	   Usage:
+	      macro=DoubleVecExternalResultEnum()
+	"""
+
+	return StringToEnum('DoubleVecExternalResult')
+
+def IntExternalResultEnum():
+	"""
+	INTEXTERNALRESULTENUM - Enum of IntExternalResult
+
+	   Usage:
+	      macro=IntExternalResultEnum()
+	"""
+
+	return StringToEnum('IntExternalResult')
+
+def JEnum():
+	"""
+	JENUM - Enum of J
+
+	   Usage:
+	      macro=JEnum()
+	"""
+
+	return StringToEnum('J')
+
+def PatchEnum():
+	"""
+	PATCHENUM - Enum of Patch
+
+	   Usage:
+	      macro=PatchEnum()
+	"""
+
+	return StringToEnum('Patch')
+
+def PatchNodesEnum():
+	"""
+	PATCHNODESENUM - Enum of PatchNodes
+
+	   Usage:
+	      macro=PatchNodesEnum()
+	"""
+
+	return StringToEnum('PatchNodes')
+
+def PatchVerticesEnum():
+	"""
+	PATCHVERTICESENUM - Enum of PatchVertices
+
+	   Usage:
+	      macro=PatchVerticesEnum()
+	"""
+
+	return StringToEnum('PatchVertices')
+
+def PentaP1ElementResultEnum():
+	"""
+	PENTAP1ELEMENTRESULTENUM - Enum of PentaP1ElementResult
+
+	   Usage:
+	      macro=PentaP1ElementResultEnum()
+	"""
+
+	return StringToEnum('PentaP1ElementResult')
+
+def PetscVecExternalResultEnum():
+	"""
+	PETSCVECEXTERNALRESULTENUM - Enum of PetscVecExternalResult
+
+	   Usage:
+	      macro=PetscVecExternalResultEnum()
+	"""
+
+	return StringToEnum('PetscVecExternalResult')
+
+def StringExternalResultEnum():
+	"""
+	STRINGEXTERNALRESULTENUM - Enum of StringExternalResult
+
+	   Usage:
+	      macro=StringExternalResultEnum()
+	"""
+
+	return StringToEnum('StringExternalResult')
+
+def StepEnum():
+	"""
+	STEPENUM - Enum of Step
+
+	   Usage:
+	      macro=StepEnum()
+	"""
+
+	return StringToEnum('Step')
+
+def TimeEnum():
+	"""
+	TIMEENUM - Enum of Time
+
+	   Usage:
+	      macro=TimeEnum()
+	"""
+
+	return StringToEnum('Time')
+
+def TriaP1ElementResultEnum():
+	"""
+	TRIAP1ELEMENTRESULTENUM - Enum of TriaP1ElementResult
+
+	   Usage:
+	      macro=TriaP1ElementResultEnum()
+	"""
+
+	return StringToEnum('TriaP1ElementResult')
+
+def WaterColumnOldEnum():
+	"""
+	WATERCOLUMNOLDENUM - Enum of WaterColumnOld
+
+	   Usage:
+	      macro=WaterColumnOldEnum()
+	"""
+
+	return StringToEnum('WaterColumnOld')
+
+def MinVelEnum():
+	"""
+	MINVELENUM - Enum of MinVel
+
+	   Usage:
+	      macro=MinVelEnum()
+	"""
+
+	return StringToEnum('MinVel')
+
+def MaxVelEnum():
+	"""
+	MAXVELENUM - Enum of MaxVel
+
+	   Usage:
+	      macro=MaxVelEnum()
+	"""
+
+	return StringToEnum('MaxVel')
+
+def MinVxEnum():
+	"""
+	MINVXENUM - Enum of MinVx
+
+	   Usage:
+	      macro=MinVxEnum()
+	"""
+
+	return StringToEnum('MinVx')
+
+def MaxVxEnum():
+	"""
+	MAXVXENUM - Enum of MaxVx
+
+	   Usage:
+	      macro=MaxVxEnum()
+	"""
+
+	return StringToEnum('MaxVx')
+
+def MaxAbsVxEnum():
+	"""
+	MAXABSVXENUM - Enum of MaxAbsVx
+
+	   Usage:
+	      macro=MaxAbsVxEnum()
+	"""
+
+	return StringToEnum('MaxAbsVx')
+
+def MinVyEnum():
+	"""
+	MINVYENUM - Enum of MinVy
+
+	   Usage:
+	      macro=MinVyEnum()
+	"""
+
+	return StringToEnum('MinVy')
+
+def MaxVyEnum():
+	"""
+	MAXVYENUM - Enum of MaxVy
+
+	   Usage:
+	      macro=MaxVyEnum()
+	"""
+
+	return StringToEnum('MaxVy')
+
+def MaxAbsVyEnum():
+	"""
+	MAXABSVYENUM - Enum of MaxAbsVy
+
+	   Usage:
+	      macro=MaxAbsVyEnum()
+	"""
+
+	return StringToEnum('MaxAbsVy')
+
+def MinVzEnum():
+	"""
+	MINVZENUM - Enum of MinVz
+
+	   Usage:
+	      macro=MinVzEnum()
+	"""
+
+	return StringToEnum('MinVz')
+
+def MaxVzEnum():
+	"""
+	MAXVZENUM - Enum of MaxVz
+
+	   Usage:
+	      macro=MaxVzEnum()
+	"""
+
+	return StringToEnum('MaxVz')
+
+def MaxAbsVzEnum():
+	"""
+	MAXABSVZENUM - Enum of MaxAbsVz
+
+	   Usage:
+	      macro=MaxAbsVzEnum()
+	"""
+
+	return StringToEnum('MaxAbsVz')
+
+def RelativeEnum():
+	"""
+	RELATIVEENUM - Enum of Relative
+
+	   Usage:
+	      macro=RelativeEnum()
+	"""
+
+	return StringToEnum('Relative')
+
+def AbsoluteEnum():
+	"""
+	ABSOLUTEENUM - Enum of Absolute
+
+	   Usage:
+	      macro=AbsoluteEnum()
+	"""
+
+	return StringToEnum('Absolute')
+
+def IncrementalEnum():
+	"""
+	INCREMENTALENUM - Enum of Incremental
+
+	   Usage:
+	      macro=IncrementalEnum()
+	"""
+
+	return StringToEnum('Incremental')
+
+def AgressiveMigrationEnum():
+	"""
+	AGRESSIVEMIGRATIONENUM - Enum of AgressiveMigration
+
+	   Usage:
+	      macro=AgressiveMigrationEnum()
+	"""
+
+	return StringToEnum('AgressiveMigration')
+
+def NoneEnum():
+	"""
+	NONEENUM - Enum of None
+
+	   Usage:
+	      macro=NoneEnum()
+	"""
+
+	return StringToEnum('None')
+
+def SoftMigrationEnum():
+	"""
+	SOFTMIGRATIONENUM - Enum of SoftMigration
+
+	   Usage:
+	      macro=SoftMigrationEnum()
+	"""
+
+	return StringToEnum('SoftMigration')
+
+def StokesSolverEnum():
+	"""
+	STOKESSOLVERENUM - Enum of StokesSolver
+
+	   Usage:
+	      macro=StokesSolverEnum()
+	"""
+
+	return StringToEnum('StokesSolver')
+
+def AdjointEnum():
+	"""
+	ADJOINTENUM - Enum of Adjoint
+
+	   Usage:
+	      macro=AdjointEnum()
+	"""
+
+	return StringToEnum('Adjoint')
+
+def ColinearEnum():
+	"""
+	COLINEARENUM - Enum of Colinear
+
+	   Usage:
+	      macro=ColinearEnum()
+	"""
+
+	return StringToEnum('Colinear')
+
+def ControlSteadyEnum():
+	"""
+	CONTROLSTEADYENUM - Enum of ControlSteady
+
+	   Usage:
+	      macro=ControlSteadyEnum()
+	"""
+
+	return StringToEnum('ControlSteady')
+
+def FsetEnum():
+	"""
+	FSETENUM - Enum of Fset
+
+	   Usage:
+	      macro=FsetEnum()
+	"""
+
+	return StringToEnum('Fset')
+
+def Gradient1Enum():
+	"""
+	GRADIENT1ENUM - Enum of Gradient1
+
+	   Usage:
+	      macro=Gradient1Enum()
+	"""
+
+	return StringToEnum('Gradient1')
+
+def Gradient2Enum():
+	"""
+	GRADIENT2ENUM - Enum of Gradient2
+
+	   Usage:
+	      macro=Gradient2Enum()
+	"""
+
+	return StringToEnum('Gradient2')
+
+def Gradient3Enum():
+	"""
+	GRADIENT3ENUM - Enum of Gradient3
+
+	   Usage:
+	      macro=Gradient3Enum()
+	"""
+
+	return StringToEnum('Gradient3')
+
+def GradientEnum():
+	"""
+	GRADIENTENUM - Enum of Gradient
+
+	   Usage:
+	      macro=GradientEnum()
+	"""
+
+	return StringToEnum('Gradient')
+
+def GroundinglineMigrationEnum():
+	"""
+	GROUNDINGLINEMIGRATIONENUM - Enum of GroundinglineMigration
+
+	   Usage:
+	      macro=GroundinglineMigrationEnum()
+	"""
+
+	return StringToEnum('GroundinglineMigration')
+
+def GsetEnum():
+	"""
+	GSETENUM - Enum of Gset
+
+	   Usage:
+	      macro=GsetEnum()
+	"""
+
+	return StringToEnum('Gset')
+
+def IndexEnum():
+	"""
+	INDEXENUM - Enum of Index
+
+	   Usage:
+	      macro=IndexEnum()
+	"""
+
+	return StringToEnum('Index')
+
+def IndexedEnum():
+	"""
+	INDEXEDENUM - Enum of Indexed
+
+	   Usage:
+	      macro=IndexedEnum()
+	"""
+
+	return StringToEnum('Indexed')
+
+def IntersectEnum():
+	"""
+	INTERSECTENUM - Enum of Intersect
+
+	   Usage:
+	      macro=IntersectEnum()
+	"""
+
+	return StringToEnum('Intersect')
+
+def NodalEnum():
+	"""
+	NODALENUM - Enum of Nodal
+
+	   Usage:
+	      macro=NodalEnum()
+	"""
+
+	return StringToEnum('Nodal')
+
+def OldGradientEnum():
+	"""
+	OLDGRADIENTENUM - Enum of OldGradient
+
+	   Usage:
+	      macro=OldGradientEnum()
+	"""
+
+	return StringToEnum('OldGradient')
+
+def OutputFilePointerEnum():
+	"""
+	OUTPUTFILEPOINTERENUM - Enum of OutputFilePointer
+
+	   Usage:
+	      macro=OutputFilePointerEnum()
+	"""
+
+	return StringToEnum('OutputFilePointer')
+
+def PetscOptionsAnalysesEnum():
+	"""
+	PETSCOPTIONSANALYSESENUM - Enum of PetscOptionsAnalyses
+
+	   Usage:
+	      macro=PetscOptionsAnalysesEnum()
+	"""
+
+	return StringToEnum('PetscOptionsAnalyses')
+
+def PetscOptionsStringsEnum():
+	"""
+	PETSCOPTIONSSTRINGSENUM - Enum of PetscOptionsStrings
+
+	   Usage:
+	      macro=PetscOptionsStringsEnum()
+	"""
+
+	return StringToEnum('PetscOptionsStrings')
+
+def QmuErrNameEnum():
+	"""
+	QMUERRNAMEENUM - Enum of QmuErrName
+
+	   Usage:
+	      macro=QmuErrNameEnum()
+	"""
+
+	return StringToEnum('QmuErrName')
+
+def QmuInNameEnum():
+	"""
+	QMUINNAMEENUM - Enum of QmuInName
+
+	   Usage:
+	      macro=QmuInNameEnum()
+	"""
+
+	return StringToEnum('QmuInName')
+
+def QmuOutNameEnum():
+	"""
+	QMUOUTNAMEENUM - Enum of QmuOutName
+
+	   Usage:
+	      macro=QmuOutNameEnum()
+	"""
+
+	return StringToEnum('QmuOutName')
+
+def RegularEnum():
+	"""
+	REGULARENUM - Enum of Regular
+
+	   Usage:
+	      macro=RegularEnum()
+	"""
+
+	return StringToEnum('Regular')
+
+def ScaledEnum():
+	"""
+	SCALEDENUM - Enum of Scaled
+
+	   Usage:
+	      macro=ScaledEnum()
+	"""
+
+	return StringToEnum('Scaled')
+
+def SeparateEnum():
+	"""
+	SEPARATEENUM - Enum of Separate
+
+	   Usage:
+	      macro=SeparateEnum()
+	"""
+
+	return StringToEnum('Separate')
+
+def SsetEnum():
+	"""
+	SSETENUM - Enum of Sset
+
+	   Usage:
+	      macro=SsetEnum()
+	"""
+
+	return StringToEnum('Sset')
+
+def VerboseEnum():
+	"""
+	VERBOSEENUM - Enum of Verbose
+
+	   Usage:
+	      macro=VerboseEnum()
+	"""
+
+	return StringToEnum('Verbose')
+
+def TriangleInterpEnum():
+	"""
+	TRIANGLEINTERPENUM - Enum of TriangleInterp
+
+	   Usage:
+	      macro=TriangleInterpEnum()
+	"""
+
+	return StringToEnum('TriangleInterp')
+
+def BilinearInterpEnum():
+	"""
+	BILINEARINTERPENUM - Enum of BilinearInterp
+
+	   Usage:
+	      macro=BilinearInterpEnum()
+	"""
+
+	return StringToEnum('BilinearInterp')
+
+def NearestInterpEnum():
+	"""
+	NEARESTINTERPENUM - Enum of NearestInterp
+
+	   Usage:
+	      macro=NearestInterpEnum()
+	"""
+
+	return StringToEnum('NearestInterp')
+
+def XYEnum():
+	"""
+	XYENUM - Enum of XY
+
+	   Usage:
+	      macro=XYEnum()
+	"""
+
+	return StringToEnum('XY')
+
+def XYZPEnum():
+	"""
+	XYZPENUM - Enum of XYZP
+
+	   Usage:
+	      macro=XYZPEnum()
+	"""
+
+	return StringToEnum('XYZP')
+
+def OptionEnum():
+	"""
+	OPTIONENUM - Enum of Option
+
+	   Usage:
+	      macro=OptionEnum()
+	"""
+
+	return StringToEnum('Option')
+
+def OptionCellEnum():
+	"""
+	OPTIONCELLENUM - Enum of OptionCell
+
+	   Usage:
+	      macro=OptionCellEnum()
+	"""
+
+	return StringToEnum('OptionCell')
+
+def OptionCharEnum():
+	"""
+	OPTIONCHARENUM - Enum of OptionChar
+
+	   Usage:
+	      macro=OptionCharEnum()
+	"""
+
+	return StringToEnum('OptionChar')
+
+def OptionStructEnum():
+	"""
+	OPTIONSTRUCTENUM - Enum of OptionStruct
+
+	   Usage:
+	      macro=OptionStructEnum()
+	"""
+
+	return StringToEnum('OptionStruct')
+
+def OptionDoubleEnum():
+	"""
+	OPTIONDOUBLEENUM - Enum of OptionDouble
+
+	   Usage:
+	      macro=OptionDoubleEnum()
+	"""
+
+	return StringToEnum('OptionDouble')
+
+def OptionLogicalEnum():
+	"""
+	OPTIONLOGICALENUM - Enum of OptionLogical
+
+	   Usage:
+	      macro=OptionLogicalEnum()
+	"""
+
+	return StringToEnum('OptionLogical')
+
+def PatersonEnum():
+	"""
+	PATERSONENUM - Enum of Paterson
+
+	   Usage:
+	      macro=PatersonEnum()
+	"""
+
+	return StringToEnum('Paterson')
+
+def ArrheniusEnum():
+	"""
+	ARRHENIUSENUM - Enum of Arrhenius
+
+	   Usage:
+	      macro=ArrheniusEnum()
+	"""
+
+	return StringToEnum('Arrhenius')
+
+def MaximumNumberOfEnums():
+	"""
+	MAXIMUMNUMBEROFENUMS - Enum of MaximumNumberOfEnums
+
+	   Usage:
+	      macro=MaximumNumberOfEnums()
+	"""
+
+	return 448
+
Index: /issm/trunk/src/m/enum/MaximumNumberOfEnums.m
===================================================================
--- /issm/trunk/src/m/enum/MaximumNumberOfEnums.m	(revision 12705)
+++ /issm/trunk/src/m/enum/MaximumNumberOfEnums.m	(revision 12706)
@@ -9,3 +9,3 @@
 %      macro=MaximumNumberOfEnums()
 
-macro=440;
+macro=448;
Index: sm/trunk/src/m/enum/PetscProfilingCurrentFlopsEnum.m
===================================================================
--- /issm/trunk/src/m/enum/PetscProfilingCurrentFlopsEnum.m	(revision 12705)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=PetscProfilingCurrentFlopsEnum()
-%PETSCPROFILINGCURRENTFLOPSENUM - Enum of PetscProfilingCurrentFlops
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
-%            Please read src/c/EnumDefinitions/README for more information
-%
-%   Usage:
-%      macro=PetscProfilingCurrentFlopsEnum()
-
-macro=StringToEnum('PetscProfilingCurrentFlops');
Index: sm/trunk/src/m/enum/PetscProfilingCurrentMemEnum.m
===================================================================
--- /issm/trunk/src/m/enum/PetscProfilingCurrentMemEnum.m	(revision 12705)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=PetscProfilingCurrentMemEnum()
-%PETSCPROFILINGCURRENTMEMENUM - Enum of PetscProfilingCurrentMem
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
-%            Please read src/c/EnumDefinitions/README for more information
-%
-%   Usage:
-%      macro=PetscProfilingCurrentMemEnum()
-
-macro=StringToEnum('PetscProfilingCurrentMem');
Index: sm/trunk/src/m/enum/PetscProfilingSolutionTimeEnum.m
===================================================================
--- /issm/trunk/src/m/enum/PetscProfilingSolutionTimeEnum.m	(revision 12705)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=PetscProfilingSolutionTimeEnum()
-%PETSCPROFILINGSOLUTIONTIMEENUM - Enum of PetscProfilingSolutionTime
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
-%            Please read src/c/EnumDefinitions/README for more information
-%
-%   Usage:
-%      macro=PetscProfilingSolutionTimeEnum()
-
-macro=StringToEnum('PetscProfilingSolutionTime');
Index: /issm/trunk/src/m/enum/ProfilingCurrentFlopsEnum.m
===================================================================
--- /issm/trunk/src/m/enum/ProfilingCurrentFlopsEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/ProfilingCurrentFlopsEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=ProfilingCurrentFlopsEnum()
+%PROFILINGCURRENTFLOPSENUM - Enum of ProfilingCurrentFlops
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=ProfilingCurrentFlopsEnum()
+
+macro=StringToEnum('ProfilingCurrentFlops');
Index: /issm/trunk/src/m/enum/ProfilingCurrentMemEnum.m
===================================================================
--- /issm/trunk/src/m/enum/ProfilingCurrentMemEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/ProfilingCurrentMemEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=ProfilingCurrentMemEnum()
+%PROFILINGCURRENTMEMENUM - Enum of ProfilingCurrentMem
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=ProfilingCurrentMemEnum()
+
+macro=StringToEnum('ProfilingCurrentMem');
Index: /issm/trunk/src/m/enum/ProfilingSolutionTimeEnum.m
===================================================================
--- /issm/trunk/src/m/enum/ProfilingSolutionTimeEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/ProfilingSolutionTimeEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=ProfilingSolutionTimeEnum()
+%PROFILINGSOLUTIONTIMEENUM - Enum of ProfilingSolutionTime
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=ProfilingSolutionTimeEnum()
+
+macro=StringToEnum('ProfilingSolutionTime');
Index: /issm/trunk/src/m/enum/SurfaceforcingsANegEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsANegEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/SurfaceforcingsANegEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsANegEnum()
+%SURFACEFORCINGSANEGENUM - Enum of SurfaceforcingsANeg
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SurfaceforcingsANegEnum()
+
+macro=StringToEnum('SurfaceforcingsANeg');
Index: /issm/trunk/src/m/enum/SurfaceforcingsAPosEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsAPosEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/SurfaceforcingsAPosEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsAPosEnum()
+%SURFACEFORCINGSAPOSENUM - Enum of SurfaceforcingsAPos
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SurfaceforcingsAPosEnum()
+
+macro=StringToEnum('SurfaceforcingsAPos');
Index: /issm/trunk/src/m/enum/SurfaceforcingsBNegEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsBNegEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/SurfaceforcingsBNegEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsBNegEnum()
+%SURFACEFORCINGSBNEGENUM - Enum of SurfaceforcingsBNeg
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SurfaceforcingsBNegEnum()
+
+macro=StringToEnum('SurfaceforcingsBNeg');
Index: /issm/trunk/src/m/enum/SurfaceforcingsBPosEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsBPosEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/SurfaceforcingsBPosEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsBPosEnum()
+%SURFACEFORCINGSBPOSENUM - Enum of SurfaceforcingsBPos
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SurfaceforcingsBPosEnum()
+
+macro=StringToEnum('SurfaceforcingsBPos');
Index: /issm/trunk/src/m/enum/SurfaceforcingsHcEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsHcEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/SurfaceforcingsHcEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsHcEnum()
+%SURFACEFORCINGSHCENUM - Enum of SurfaceforcingsHc
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SurfaceforcingsHcEnum()
+
+macro=StringToEnum('SurfaceforcingsHc');
Index: /issm/trunk/src/m/enum/SurfaceforcingsIssmbgradientsEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsIssmbgradientsEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/SurfaceforcingsIssmbgradientsEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsIssmbgradientsEnum()
+%SURFACEFORCINGSISSMBGRADIENTSENUM - Enum of SurfaceforcingsIssmbgradients
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SurfaceforcingsIssmbgradientsEnum()
+
+macro=StringToEnum('SurfaceforcingsIssmbgradients');
Index: /issm/trunk/src/m/enum/SurfaceforcingsSmbPosMaxEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsSmbPosMaxEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/SurfaceforcingsSmbPosMaxEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsSmbPosMaxEnum()
+%SURFACEFORCINGSSMBPOSMAXENUM - Enum of SurfaceforcingsSmbPosMax
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SurfaceforcingsSmbPosMaxEnum()
+
+macro=StringToEnum('SurfaceforcingsSmbPosMax');
Index: /issm/trunk/src/m/enum/SurfaceforcingsSmbPosMinEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SurfaceforcingsSmbPosMinEnum.m	(revision 12706)
+++ /issm/trunk/src/m/enum/SurfaceforcingsSmbPosMinEnum.m	(revision 12706)
@@ -0,0 +1,11 @@
+function macro=SurfaceforcingsSmbPosMinEnum()
+%SURFACEFORCINGSSMBPOSMINENUM - Enum of SurfaceforcingsSmbPosMin
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
+%            Please read src/c/EnumDefinitions/README for more information
+%
+%   Usage:
+%      macro=SurfaceforcingsSmbPosMinEnum()
+
+macro=StringToEnum('SurfaceforcingsSmbPosMin');
Index: /issm/trunk/src/m/model/MatlabFuncs.py
===================================================================
--- /issm/trunk/src/m/model/MatlabFuncs.py	(revision 12706)
+++ /issm/trunk/src/m/model/MatlabFuncs.py	(revision 12706)
@@ -0,0 +1,28 @@
+def strcmp(str1,str2):
+
+	if str1 == str2:
+		return True
+	else:
+		return False
+
+def strncmp(str1,str2,n):
+
+	if str1[0:n] == str2[0:n]:
+		return True
+	else:
+		return False
+
+def strcmpi(str1,str2):
+
+	if str1.lower() == str2.lower():
+		return True
+	else:
+		return False
+
+def strncmpi(str1,str2,n):
+
+	if str1.lower()[0:n] == str2.lower()[0:n]:
+		return True
+	else:
+		return False
+
Index: /issm/trunk/src/m/model/ProfileValues.m
===================================================================
--- /issm/trunk/src/m/model/ProfileValues.m	(revision 12706)
+++ /issm/trunk/src/m/model/ProfileValues.m	(revision 12706)
@@ -0,0 +1,21 @@
+function [Z,data_interp]=ProfileValues(md,data,xprof,yprof,resolution)
+%PROFILEVALUES - compute the value of a field on a vertical profile
+%
+%   This routine gets the value of a given field of the model on points
+%   given by filname (Argus type file)
+%
+%   Usage:
+%      [z,data]=ProfileValues(md,data,filename,resolution)
+%      [z,data]=ProfileValues(md,data,profile_structure,resolution)
+
+%Get bed and surface for each 2d point, offset to make sure that it is inside the glacier system
+offset=10^-3;
+bed=InterpFromMeshToMesh2d(md.mesh.elements2d,md.mesh.x2d,md.mesh.y2d,project2d(md,md.geometry.bed,1),xprof,yprof)+offset;
+surface=InterpFromMeshToMesh2d(md.mesh.elements2d,md.mesh.x2d,md.mesh.y2d,project2d(md,md.geometry.surface,1),xprof,yprof)-offset;
+
+%Some useful parameters
+layers=ceil(mean(md.geometry.thickness)/resolution);
+Z=(bed:resolution:surface)';
+X=xprof*ones(size(Z));
+Y=yprof*ones(size(Z));
+data_interp=InterpFromMeshToMesh3d(md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.z,data,X,Y,Z,NaN);
Index: /issm/trunk/src/m/model/SectionValues.m
===================================================================
--- /issm/trunk/src/m/model/SectionValues.m	(revision 12705)
+++ /issm/trunk/src/m/model/SectionValues.m	(revision 12706)
@@ -12,8 +12,8 @@
 if ischar(infile),
 	%read infile:
-	contempt=expread(infile);
-	nods=contempt.nods;
-	x=contempt.x;
-	y=contempt.y;
+	profile=expread(infile);
+	nods=profile.nods;
+	x=profile.x;
+	y=profile.y;
 else
 	%read infile:
Index: /issm/trunk/src/m/model/WriteData.m
===================================================================
--- /issm/trunk/src/m/model/WriteData.m	(revision 12705)
+++ /issm/trunk/src/m/model/WriteData.m	(revision 12706)
@@ -35,5 +35,5 @@
 %Step 2: write the data itself.
 if     strcmpi(format,'Boolean'),% {{{
-	if(numel(data)~=1), error(['field ' field ' cannot be marshalled as it has more than one element!']); end
+	if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
 
 	%first write length of record
@@ -59,5 +59,5 @@
 	% }}}
 elseif strcmpi(format,'Double'), % {{{
-	if(numel(data)~=1), error(['field ' field ' cannot be marshalled as it has more than one element!']); end
+	if(numel(data)~=1), error(['field ' EnumToString(enum) ' cannot be marshalled as it has more than one element!']); end
 
 	%first write length of record
@@ -233,5 +233,5 @@
 	enum=eval([string 'Enum();']); 
 end % }}}
-function code=FormatToCode(format) % {{{1
+function code=FormatToCode(format) % {{{
 %This routine takes the format string, and hardcodes it into an integer, which 
 %is passed along the record, in order to identify the nature of the dataset being 
Index: /issm/trunk/src/m/model/WriteData.py
===================================================================
--- /issm/trunk/src/m/model/WriteData.py	(revision 12706)
+++ /issm/trunk/src/m/model/WriteData.py	(revision 12706)
@@ -0,0 +1,274 @@
+"""
+WRITEDATA - write model field in binary file
+ 
+    Usage:
+       WriteData(fid,*args)
+"""
+
+import numpy
+import math
+import struct
+from MatlabFuncs import *
+
+def WriteData(fid,*args):
+	#process options
+	options=pairoptions(args)
+
+	#Get data properties
+	if options.exist('object'):
+		#This is an object field, construct enum and data
+		obj       = options.getfieldvalue('object')
+		fieldname = options.getfieldvalue('fieldname')
+		classname = type(obj)
+
+		enum      = BuildEnum(classname+'_'+fieldname)
+		data      = getattr(obj,fieldname)
+	else:
+		#No processing required
+		data = options.getfieldvalue('data')
+		enum = options.getfieldvalue('enum')
+	format  = options.getfieldvalue('format')
+	mattype = options.getfieldvalue('mattype',0)    #only required for matrices
+
+	#Process sparse matrices
+#	if issparse(data),
+#		data=full(data);
+#	end
+
+	#Step 1: write the enum to identify this record uniquely
+	fid.write(struct.pack('i',enum)) 
+
+	#Step 2: write the data itself.
+	if   strcmpi(format,'Boolean'):    # {{{
+		if len(data) !=1:
+			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4))  #1 bool (disguised as an int)+code
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write integer
+		fid.write(struct.pack('i',data))  #send an int, not easy to send a bool
+		# }}}
+
+	elif strcmpi(format,'Integer'):    # {{{
+		if len(data) !=1:
+			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4))  #1 integer + code
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write integer
+		fid.write(struct.pack('i',data)) 
+		# }}}
+
+	elif strcmpi(format,'Double'):    # {{{
+		if len(data) !=1:
+			raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum))
+
+		#first write length of record
+		fid.write(struct.pack('i',8+4))  #1 double+code
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write double
+		fid.write(struct.pack('d',data)) 
+		# }}}
+
+	elif strcmpi(format,'String'):    # {{{
+		#first write length of record
+		fid.write(struct.pack('i',len(data)+4+4))  #string + string size + code
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write string
+		fid.write(struct.pack('i',len(data))) 
+		fid.write(struct.pack('%ds' % len(data),data)) 
+		# }}}
+
+	elif strcmpi(format,'BooleanMat'):    # {{{
+
+		#Get size
+		s=data.shape
+		#if matrix = NaN, then do not write anything
+		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
+			s[0]=0
+			s[1]=0
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
+
+		#write data code and matrix type: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+		fid.write(struct.pack('i',mattype))
+
+		#now write matrix
+		fid.write(struct.pack('i',s[0])) 
+		fid.write(struct.pack('i',s[1])) 
+		for i in xrange(s[0]):
+			for j in xrange(s[1]):
+				fid.write(struct.pack('i',data[i][j]))    #get to the "c" convention, hence the transpose
+		# }}}
+
+	elif strcmpi(format,'IntMat'):    # {{{
+
+		#Get size
+		s=data.shape
+		#if matrix = NaN, then do not write anything
+		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
+			s[0]=0
+			s[1]=0
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
+
+		#write data code and matrix type: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+		fid.write(struct.pack('i',mattype))
+
+		#now write matrix
+		fid.write(struct.pack('i',s[0])) 
+		fid.write(struct.pack('i',s[1])) 
+		for i in xrange(s[0]):
+			for j in xrange(s[1]):
+				fid.write(struct.pack('i',data[i][j]))    #get to the "c" convention, hence the transpose
+		# }}}
+
+	elif strcmpi(format,'DoubleMat'):    # {{{
+
+		#Get size
+		s=data.shape
+		#if matrix = NaN, then do not write anything
+		if s[0]==1 and s[1]==1 and math.isnan(data[0][0]):
+			s[0]=0
+			s[1]=0
+
+		#first write length of record
+		fid.write(struct.pack('i',4+4+8*s[0]*s[1]+4+4))    #2 integers (32 bits) + the double matrix + code + matrix type
+
+		#write data code and matrix type: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+		fid.write(struct.pack('i',mattype))
+
+		#now write matrix
+		fid.write(struct.pack('i',s[0])) 
+		fid.write(struct.pack('i',s[1])) 
+		for i in xrange(s[0]):
+			for j in xrange(s[1]):
+				fid.write(struct.pack('d',data[i][j]))    #get to the "c" convention, hence the transpose
+		# }}}
+
+	elif strcmpi(format,'MatArray'):    # {{{
+
+		#first get length of record
+		recordlength=4+4    #number of records + code
+		for matrix in data:
+			s=matrix.shape
+			recordlength+=4*2+s[0]*s[1]*8    #row and col of matrix + matrix of doubles
+
+		#write length of record
+		fid.write(struct.pack('i',recordlength)) 
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#write data, first number of records
+		fid.write(struct.pack('i',len(data))) 
+
+		#write each matrix: 
+		for matrix in data:
+			s=matrix.shape
+			fid.write(struct.pack('i',s[0])) 
+			fid.write(struct.pack('i',s[1])) 
+			for i in xrange(s[0]):
+				for j in xrange(s[1]):
+					fid.write(struct.pack('d',matrix[i][j]))
+		# }}}
+
+	elif strcmpi(format,'StringArray'):    # {{{
+
+		#first get length of record
+		recordlength=4+4    #for length of array + code
+		for string in data:
+			recordlength+=4+len(string)    #for each string
+
+		#write length of record
+		fid.write(struct.pack('i',recordlength)) 
+
+		#write data code: 
+		fid.write(struct.pack('i',FormatToCode(format))) 
+
+		#now write length of string array
+		fid.write(struct.pack('i',len(data))) 
+
+		#now write the strings
+		for string in data:
+			fid.write(struct.pack('i',len(string))) 
+			fid.write(struct.pack('%ds' % len(string),string)) 
+		# }}}
+
+	else:    # {{{
+		raise TypeError('WriteData error message: data type: %d not supported yet! (%s)' % (format,EnumToString(enum)))
+	# }}}
+
+def BuildEnum(string): # {{{
+	"""
+	BUILDENUM - build enum out of string
+ 
+    Usage:
+       enum=BuildEnum(string)
+	"""
+
+	if '_' in string:
+		substrs=string.split('_')
+		string=''
+		for str in substrs:
+			string+=str[0].upper()+str[1:]
+	else:
+		#take first letter of string and make it uppercase: 
+		string=str[0].upper()+str[1:]
+
+	#Get Enum
+	exec('enum='+string+'Enum()',globals())
+
+	return enum
+# }}}
+
+def FormatToCode(format): # {{{
+	"""
+	This routine takes the format string, and hardcodes it into an integer, which 
+	is passed along the record, in order to identify the nature of the dataset being 
+	sent.
+	"""
+
+	if   strcmpi(format,'Boolean'):
+		code=1
+	elif strcmpi(format,'Integer'):
+		code=2
+	elif strcmpi(format,'Double'):
+		code=3
+	elif strcmpi(format,'String'):
+		code=4
+	elif strcmpi(format,'BooleanMat'):
+		code=5
+	elif strcmpi(format,'IntMat'):
+		code=6
+	elif strcmpi(format,'DoubleMat'):
+		code=7
+	elif strcmpi(format,'MatArray'):
+		code=8
+	elif strcmpi(format,'StringArray'):
+		code=9
+	else:
+		raise InputError('FormatToCode error message: data type not supported yet!')
+
+	return code
+# }}}
+
Index: /issm/trunk/src/m/model/averaging.m
===================================================================
--- /issm/trunk/src/m/model/averaging.m	(revision 12705)
+++ /issm/trunk/src/m/model/averaging.m	(revision 12706)
@@ -1,3 +1,3 @@
-function average=averaging(md,data,iterations)
+function average=averaging(md,data,iterations,varargin)
 %AVERAGING - smooths the input over the mesh
 %
@@ -8,33 +8,61 @@
 %   by taking the average of the element around a node weighted by the
 %   elements volume
+%   For 3d mesh, a last argument can be added to specify the layer to be averaged on.
 %
 %   Usage:
 %      smoothdata=averaging(md,data,iterations)
+%      smoothdata=averaging(md,data,iterations,layer)
 %
 %   Examples:
 %      velsmoothed=averaging(md,md.initialization.vel,4);
 %      pressure=averaging(md,md.initialization.pressure,0);
+%      temperature=averaging(md,md.initialization.temperature,1,1);
 
-if length(data)~=md.mesh.numberofelements & length(data)~=md.mesh.numberofvertices
+if ((nargin~=4) & (nargin~=3)),
+	error('averaging error message');
+end
+if (length(data)~=md.mesh.numberofelements & length(data)~=md.mesh.numberofvertices),
 	error('averaging error message: data not supported yet');
+end
+if md.mesh.dimension==3 & nargin==4,
+	if varargin{1}<=0 | varargin{1}>md.mesh.numberoflayers,
+		error('layer should be between 1 and md.mesh.numberoflayers');
+	end
+	layer=varargin{1};
+else
+	layer=0;
 end
 
 %initialization
-weights=zeros(md.mesh.numberofvertices,1);
-data=data(:);
+if layer==0,
+	weights=zeros(md.mesh.numberofvertices,1);
+	data=data(:);
+else 
+	weights=zeros(md.mesh.numberofvertices2d,1);
+	data=data((layer-1)*md.mesh.numberofvertices2d+1:layer*md.mesh.numberofvertices2d,:);
+end
 
-%load some variables (it is much faster if the variab;es are loaded from md once for all)
-index=md.mesh.elements;
-numberofnodes=md.mesh.numberofvertices;
-numberofelements=md.mesh.numberofelements;
+%load some variables (it is much faster if the variabes are loaded from md once for all)
+if layer==0,
+	index=md.mesh.elements;
+	numberofnodes=md.mesh.numberofvertices;
+	numberofelements=md.mesh.numberofelements;
+else
+	index=md.mesh.elements2d;
+	numberofnodes=md.mesh.numberofvertices2d;
+	numberofelements=md.mesh.numberofelements2d;
+end
 
 %build some variables
 line=index(:);
-if md.mesh.dimension==3
+if md.mesh.dimension==3 & layer==0,
 	rep=6;
 	areas=GetAreas(index,md.mesh.x,md.mesh.y,md.mesh.z);
+elseif md.mesh.dimension==2,
+	rep=3;
+	areas=GetAreas(index,md.mesh.x,md.mesh.y);
 else
 	rep=3;
-	areas=GetAreas(index,md.mesh.x,md.mesh.y);
+	areas=GetAreas(index,md.mesh.x2d,md.mesh.y2d);
 end
 summation=1/rep*ones(rep,1);
Index: /issm/trunk/src/m/model/collapse.m
===================================================================
--- /issm/trunk/src/m/model/collapse.m	(revision 12705)
+++ /issm/trunk/src/m/model/collapse.m	(revision 12706)
@@ -42,4 +42,5 @@
 if ~isnan(md.initialization.vz),md.initialization.vz=DepthAverage(md,md.initialization.vz);end;
 if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end;
+if ~isnan(md.initialization.temperature),md.initialization.temperature=DepthAverage(md,md.initialization.temperature);end;
 
 %bedinfo and surface info
@@ -91,4 +92,5 @@
 md.geometry.thickness=project2d(md,md.geometry.thickness,1);
 md.geometry.bed=project2d(md,md.geometry.bed,1);
+md.geometry.bathymetry=project2d(md,md.geometry.bathymetry,1);
 md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
 md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
Index: /issm/trunk/src/m/model/contourenvelope.m
===================================================================
--- /issm/trunk/src/m/model/contourenvelope.m	(revision 12705)
+++ /issm/trunk/src/m/model/contourenvelope.m	(revision 12706)
@@ -35,8 +35,8 @@
 %Now, build the connectivity tables for this mesh.
 %Computing connectivity
-if size(md.mesh.vertexconnectivity,1)~=md.mesh.numberofvertices,
+if (size(md.mesh.vertexconnectivity,1)~=md.mesh.numberofvertices & size(md.mesh.vertexconnectivity,1)~=md.mesh.numberofvertices2d),
 	md.mesh.vertexconnectivity=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices);
 end
-if size(md.mesh.elementconnectivity,1)~=md.mesh.numberofelements,
+if (size(md.mesh.elementconnectivity,1)~=md.mesh.numberofelements & size(md.mesh.elementconnectivity,1)~=md.mesh.numberofelements2d),
 	md.mesh.elementconnectivity=ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity);
 end
@@ -44,9 +44,24 @@
 %get nodes inside profile
 mesh.elementconnectivity=md.mesh.elementconnectivity;
+if md.mesh.dimension==2;
+	mesh.elements=md.mesh.elements;
+	mesh.x=md.mesh.x;
+	mesh.y=md.mesh.y;
+	mesh.numberofvertices=md.mesh.numberofvertices;
+	mesh.numberofelements=md.mesh.numberofelements;
+else
+	mesh.elements=md.mesh.elements2d;
+	mesh.x=md.mesh.x2d;
+	mesh.y=md.mesh.y2d;
+	mesh.numberofvertices=md.mesh.numberofvertices2d;
+	mesh.numberofelements=md.mesh.numberofelements2d;
+end
+
 if nargin==2,
+
 	if isfile,
 		%get flag list of elements and nodes inside the contour
-		nodein=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,file,'node',1);
-		elemin=(sum(nodein(md.mesh.elements),2)==size(md.mesh.elements,2));
+		nodein=ContourToMesh(mesh.elements,mesh.x,mesh.y,file,'node',1);
+		elemin=(sum(nodein(mesh.elements),2)==size(mesh.elements,2));
 		%modify element connectivity
 		elemout=find(~elemin);
@@ -55,10 +70,10 @@
 	else
 		%get flag list of elements and nodes inside the contour
-		nodein=zeros(md.mesh.numberofvertices,1); 
-		elemin=zeros(md.mesh.numberofelements,1); 
+		nodein=zeros(mesh.numberofvertices,1); 
+		elemin=zeros(mesh.numberofelements,1); 
 		
 		pos=find(flags); 
 		elemin(pos)=1;
-		nodein(md.mesh.elements(pos,:))=1;
+		nodein(mesh.elements(pos,:))=1;
 
 		%modify element connectivity
@@ -87,11 +102,11 @@
 	els2=mesh.elementconnectivity(el1,find(mesh.elementconnectivity(el1,:)));
 	if length(els2)>1,
-		flag=intersect(md.mesh.elements(els2(1),:),md.mesh.elements(els2(2),:));
-		nods1=md.mesh.elements(el1,:);
+		flag=intersect(mesh.elements(els2(1),:),mesh.elements(els2(2),:));
+		nods1=mesh.elements(el1,:);
 		nods1(find(nods1==flag))=[];
 		segments(count,:)=[nods1 el1];
 
-		ord1=find(nods1(1)==md.mesh.elements(el1,:));
-		ord2=find(nods1(2)==md.mesh.elements(el1,:));
+		ord1=find(nods1(1)==mesh.elements(el1,:));
+		ord2=find(nods1(2)==mesh.elements(el1,:));
 
 		%swap segment nodes if necessary
@@ -104,12 +119,12 @@
 		count=count+1;
 	else
-		nods1=md.mesh.elements(el1,:);
-		flag=setdiff(nods1,md.mesh.elements(els2,:));
+		nods1=mesh.elements(el1,:);
+		flag=setdiff(nods1,mesh.elements(els2,:));
 		for j=1:3,
 			nods=nods1; nods(j)=[];
 			if any(ismember(flag,nods)),
 				segments(count,:)=[nods el1];
-				ord1=find(nods(1)==md.mesh.elements(el1,:));
-				ord2=find(nods(2)==md.mesh.elements(el1,:));
+				ord1=find(nods(1)==mesh.elements(el1,:));
+				ord2=find(nods(2)==mesh.elements(el1,:));
 				if ( (ord1==1 & ord2==2) | (ord1==2 & ord2==3) | (ord1==3 & ord2==1) ),
 					temp=segments(count,1);
Index: /issm/trunk/src/m/model/ismodelselfconsistent.m
===================================================================
--- /issm/trunk/src/m/model/ismodelselfconsistent.m	(revision 12705)
+++ /issm/trunk/src/m/model/ismodelselfconsistent.m	(revision 12706)
@@ -6,5 +6,5 @@
 
 %initialize consistency as true
-modelconsistency(true);
+md.private.isconsistent=true;
 
 %Get solution and associated analyses
@@ -24,17 +24,17 @@
 	%Check that current field is an object
 	if ~isobject(md.(field))
-		checkmessage(['field ''' char(field) ''' is not an object']);
+		md=checkmessage(md,['field ''' char(field) ''' is not an object']);
 	end
 
 	%Check consistency of the object
 	if verLessThan('matlab', '7.6')
-		checkconsistency(md.(field),md,solution,analyses);
+		md=checkconsistency(md.(field),md,solution,analyses);
 	else
-		md.(field).checkconsistency(md,solution,analyses);
+		md=md.(field).checkconsistency(md,solution,analyses);
 	end
 end
 
 %error message if mode is not consistent
-if modelconsistency==false,
-	error(' ');
+if md.private.isconsistent==false,
+	error('Model not consistent, see messages above');
 end
Index: /issm/trunk/src/m/model/loadresultsfromcluster.m
===================================================================
--- /issm/trunk/src/m/model/loadresultsfromcluster.m	(revision 12705)
+++ /issm/trunk/src/m/model/loadresultsfromcluster.m	(revision 12706)
@@ -13,9 +13,17 @@
 
 %Download outputs from the cluster
-if verLessThan('matlab', '7.6');
-	Download(cluster,md);
+filelist={[md.miscellaneous.name '.outlog'],[md.miscellaneous.name '.errlog']};
+if md.qmu.isdakota,
+	filelist{end+1}=[md.miscellaneous.name '.qmu.err'];
+	filelist{end+1}=[md.miscellaneous.name '.qmu.out'];
+	if isfield(md.qmu.params,'tabular_graphics_data'),
+		if md.qmu.params.tabular_graphics_data==true,
+			filelist{end+1}='dakota_tabular.dat';
+		end
+	end
 else
-	cluster.Download(md);
+	filelist{end+1}=[md.miscellaneous.name '.outbin'];
 end
+Download(cluster,md.private.runtimename,filelist);
 
 %If we are here, no errors in the solution sequence, call loadresultsfromdisk.
Index: /issm/trunk/src/m/model/loadresultsfromdisk.m
===================================================================
--- /issm/trunk/src/m/model/loadresultsfromdisk.m	(revision 12705)
+++ /issm/trunk/src/m/model/loadresultsfromdisk.m	(revision 12706)
@@ -59,4 +59,3 @@
 	md=postqmu(md);
 	cd ..
-
 end
Index: /issm/trunk/src/m/model/marshall.m
===================================================================
--- /issm/trunk/src/m/model/marshall.m	(revision 12705)
+++ /issm/trunk/src/m/model/marshall.m	(revision 12706)
@@ -31,5 +31,5 @@
 	%Check that current field is an object
 	if ~isobject(md.(field))
-		checkmessage(['field ''' char(field) ''' is not an object']);
+		error(['field ''' char(field) ''' is not an object']);
 	end
 
Index: /issm/trunk/src/m/model/marshall.py
===================================================================
--- /issm/trunk/src/m/model/marshall.py	(revision 12706)
+++ /issm/trunk/src/m/model/marshall.py	(revision 12706)
@@ -0,0 +1,49 @@
+"""
+MARSHALL - outputs a compatible binary file from @model md, for certain solution type.
+
+    The routine creates a compatible binary file from @model md
+    This binary file will be used for parallel runs in JPL-package
+
+    Usage:
+       marshall(md)
+"""
+
+from WriteData import *
+
+def marshall(md):
+	print "marshalling file '%s.bin'." % md.miscellaneous.name
+
+	#open file for binary writing
+	try:
+		fid=open(md.miscellaneous.name+'.bin','wb');
+	except IOError as e:
+		print "marshall error message: could not open '%s.bin' file for binary writing." % md.miscellaneous.name
+		raise IOError(e)
+
+	#First, write MaximumNumberOfEnum to make sure that the Enums are synchronized
+	WriteData(fid,'enum',MaximumNumberOfEnums(),'data',true,'format','Boolean')
+
+	#Go through all model fields: check that it is a class and call checkconsistency
+	fields=vars(md)
+
+	for field in fields.interkeys():
+
+		#Some properties do not need to be marshalled
+		if field in ['results','radaroverlay','solver','cluster','flaim','private']:
+			continue
+
+		#Check that current field is an object
+		if not hasattr(getattr(md,field),'marshall'):
+			raise TypeError("field '%s' is not an object." % field)
+
+		#Marshall current object
+		#print "marshalling %s ..." % field
+		exec("md.%s.marshall(fid)" % field)
+
+	#close file
+	try:
+		f.close(fid)
+	except IOError as e:
+		print "marshall error message: could not close file '%s.bin'." % md.miscellaneous.name
+		raise IOError(e)
+
Index: /issm/trunk/src/m/model/mesh/bamg.m
===================================================================
--- /issm/trunk/src/m/model/mesh/bamg.m	(revision 12705)
+++ /issm/trunk/src/m/model/mesh/bamg.m	(revision 12706)
@@ -58,5 +58,5 @@
 bamg_mesh=bamgmesh;
 
-% Bamg Geometry parameters {{{1
+% Bamg Geometry parameters {{{
 if exist(options,'domain'),
 
@@ -259,5 +259,5 @@
 end
 %}}}
-% Bamg Mesh parameters {{{1
+% Bamg Mesh parameters {{{
 if (~exist(options,'domain') & md.mesh.numberofvertices~=0 & md.mesh.dimension==2),
 
@@ -274,5 +274,5 @@
 end
 %}}}
-% Bamg Options {{{1
+% Bamg Options {{{
 bamg_options.Crack=getfieldvalue(options,'Crack',0);
 bamg_options.anisomax=getfieldvalue(options,'anisomax',10^30);
Index: /issm/trunk/src/m/model/modelextract.m
===================================================================
--- /issm/trunk/src/m/model/modelextract.m	(revision 12705)
+++ /issm/trunk/src/m/model/modelextract.m	(revision 12706)
@@ -166,5 +166,5 @@
 	if size(md2.mesh.edges,2)>1, %do not use ~isnan because there are some NaNs...
 		%renumber first two columns
-		pos=find(~isnan(md2.mesh.edges(:,4)));
+		pos=find(md2.mesh.edges(:,4)~=-1);
 		md2.mesh.edges(:  ,1)=Pnode(md2.mesh.edges(:,1)); 
 		md2.mesh.edges(:  ,2)=Pnode(md2.mesh.edges(:,2)); 
@@ -173,18 +173,18 @@
 		%remove edges when the 2 vertices are not in the domain.
 		md2.mesh.edges=md2.mesh.edges(find(md2.mesh.edges(:,1) & md2.mesh.edges(:,2)),:);
-		%Replace all zeros by NaN in the last two columns;
+		%Replace all zeros by -1 in the last two columns;
 		pos=find(md2.mesh.edges(:,3)==0);
-		md2.mesh.edges(pos,3)=NaN;
+		md2.mesh.edges(pos,3)=-1;
 		pos=find(md2.mesh.edges(:,4)==0);
-		md2.mesh.edges(pos,4)=NaN;
-		%Invert NaN of the third column with last column (Also invert first two columns!!)
-		pos=find(isnan(md2.mesh.edges(:,3)));
+		md2.mesh.edges(pos,4)=-1;
+		%Invert -1 on the third column with last column (Also invert first two columns!!)
+		pos=find(md2.mesh.edges(:,3)==-1);
 		md2.mesh.edges(pos,3)=md2.mesh.edges(pos,4);
-		md2.mesh.edges(pos,4)=NaN;
+		md2.mesh.edges(pos,4)=-1;
 		values=md2.mesh.edges(pos,2);
 		md2.mesh.edges(pos,2)=md2.mesh.edges(pos,1);
 		md2.mesh.edges(pos,1)=values;
 		%Finally remove edges that do not belong to any element
-		pos=find(isnan(md2.mesh.edges(:,3)) & isnan(md2.mesh.edges(:,4)));
+		pos=find(md2.mesh.edges(:,3)==-1 & md2.mesh.edges(:,4)==-1);
 		md2.mesh.edges(pos,:)=[];
 	end
@@ -210,4 +210,14 @@
 		md2.mesh.segments=contourenvelope(md2);
 		md2.mesh.vertexonboundary=zeros(numberofvertices2,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1;
+	else
+		%First do the connectivity for the contourenvelope in 2d
+		md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements2d,md2.mesh.numberofvertices2d);
+		md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity);
+		md2.mesh.segments=contourenvelope(md2);
+		md2.mesh.vertexonboundary=zeros(numberofvertices2/md2.mesh.numberoflayers,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1;
+		md2.mesh.vertexonboundary=repmat(md2.mesh.vertexonboundary,md2.mesh.numberoflayers,1);
+		%Then do it for 3d as usual
+		md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices);
+		md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity);
 	end
 
Index: /issm/trunk/src/m/model/plot/applyoptions.m
===================================================================
--- /issm/trunk/src/m/model/plot/applyoptions.m	(revision 12705)
+++ /issm/trunk/src/m/model/plot/applyoptions.m	(revision 12706)
@@ -31,20 +31,16 @@
 end
 
-%xlabel
+%xlabel, ylabel and zlabel
 if exist(options,'xlabel');
 	xlabel(getfieldvalue(options,'xlabel'),'FontSize',fontsize,'FontWeight',fontweight);
 end
-
-%ylabel
 if exist(options,'ylabel');
 	ylabel(getfieldvalue(options,'ylabel'),'FontSize',fontsize,'FontWeight',fontweight);
 end
-
-%zlabel
 if exist(options,'zlabel');
 	zlabel(getfieldvalue(options,'zlabel'),'FontSize',fontsize,'FontWeight',fontweight);
 end
 
-%xtikcs
+%xticks, yticks and zticks
 if exist(options,'xtick'), set(gca,'XTick',getfieldvalue(options,'xtick')); end
 if exist(options,'ytick'), set(gca,'YTick',getfieldvalue(options,'ytick')); end
@@ -75,12 +71,13 @@
 end
 
-%xlim
+%xlim, ylim and zlim
 if exist(options,'xlim');
 	xlim(getfieldvalue(options,'xlim'));
 end
-
-%ylim
 if exist(options,'ylim');
 	ylim(getfieldvalue(options,'ylim'));
+end
+if exist(options,'zlim');
+	zlim(getfieldvalue(options,'zlim'));
 end
 
@@ -92,10 +89,4 @@
 end
 
-
-%zlim
-if exist(options,'zlim');
-	zlim(getfieldvalue(options,'zlim'));
-end
-
 %Basinzoom
 if exist(options,'basin');
@@ -107,5 +98,4 @@
 	showbasins(options);
 end
-
 
 %Caxis
@@ -127,51 +117,6 @@
 
 %colormap
-if exist(options,'colormap'),
-	cname=getfieldvalue(options,'colormap');
-	if strcmpi(cname,'Ala'),
-		c = jet(64);
-		c = c (32:end,:);
-	elseif strcmpi(cname,'redblue'),
-		%m = 30;
-		%n = fix(0.5*m);
-		%r = [(0:1:n-1)/n,ones(1,n)];
-		%g = [(0:n-1)/n, (n-1:-1:0)/n];
-		%b = [ones(1,n),(n-1:-1:0)/n];
-		%c = [r(:), g(:), b(:)]; 
-
-		c = hsv(64);
-		c = rgb2hsv(c);
-		c(:,2) = max(min( abs(c(:,1)-0.5)/0.5 ,1),0);
-		c(1:32,1)   = 0.7;
-		c(33:end,1) = 1;
-		c = hsv2rgb(c);
-
-	elseif strcmpi(cname,'Rignot'),
-		c = hsv;
-
-		%adjust saturation
-		c = rgb2hsv(c);
-		alpha=getfieldvalue(options,'alpha',1);
-		c(:,2) = max(min( (0.1+c(:,1)).^(1/alpha) ,1),0);
-		c = hsv2rgb(c);
-
-	elseif strcmpi(cname,'Rignot2'),
-		c = hsv;
-
-		%adjust saturation
-		c = rgb2hsv(c);
-		alpha=getfieldvalue(options,'alpha',1);
-		c(:,2) = max(min( (0.1+c(:,1)).^(1/alpha) ,1),0);
-		c = hsv2rgb(c);
-
-		c=flipud(c);
-
-	else
-		c = cname;
-	end
-	h=colormap(c);
-else
-	h=colormap(jet(60));
-end
+c = getcolormap(options);
+h = colormap(c);
 
 %wrapping
@@ -375,4 +320,8 @@
 			left=screen(1); bott=screen(2); widt=screen(3); heig=screen(4)-25;
 			set(gcf,'Position',fix([left bott widt/2 heig]));
+		elseif strcmpi(figposition,'square'),
+			screen=get(0,'ScreenSize');
+			left=screen(1); bott=screen(2); widt=min(screen(3)-25,screen(4)-25);
+			set(gcf,'Position',fix([left+(screen(3)-widt) bott widt widt]));
 		elseif strcmpi(figposition,'portrait'),
 			%reformat with letter paper size (8.5" x 11")
Index: /issm/trunk/src/m/model/plot/colormaps/getcolormap.m
===================================================================
--- /issm/trunk/src/m/model/plot/colormaps/getcolormap.m	(revision 12706)
+++ /issm/trunk/src/m/model/plot/colormaps/getcolormap.m	(revision 12706)
@@ -0,0 +1,55 @@
+function map = getcolormap(options)
+%GETCOLORMAP - get colormap from options
+%
+%   Usage:
+%      map = getcolormap(options)
+
+%default is jet(256)
+if ~exist(options,'colormap'),
+	map = jet(256);
+	return
+end
+
+map = getfieldvalue(options,'colormap');
+if isnumeric(map);
+	%user provided a full colormap
+	return;
+end
+
+%OK this is an in-house colormap
+if ~ischar(map), error('colormap format not supported'); end
+
+if strcmpi(map,'Ala'),
+	map = jet(256);
+	map = map(128:end,:);
+elseif strcmpi(map,'redblue'),
+	map = hsv(256);
+	map = rgb2hsv(map);
+	map(:,2)       = max(min( abs(map(:,1)-0.5)/0.5 ,1),0);
+	map(1:128,1)   = 0.7;
+	map(129:end,1) = 1;
+	map = hsv2rgb(map);
+elseif strcmpi(map,'Rignot'),
+	alpha=getfieldvalue(options,'alpha',1);
+	map = hsv(256);
+	map = rgb2hsv(map);
+	map(:,2) = max(min( (0.1+map(:,1)).^(1/alpha) ,1),0);
+	map = hsv2rgb(map);
+elseif strcmpi(map,'Rignot2'),
+	alpha=getfieldvalue(options,'alpha',1);
+	map = hsv(256);
+	map = rgb2hsv(map);
+	map(:,2) = max(min( (0.1+map(:,1)).^(1/alpha) ,1),0);
+	map = hsv2rgb(map);
+	map=flipud(map);
+elseif strcmpi(map,'Seroussi'),
+	alpha=getfieldvalue(options,'alpha',1);
+	map = hsv(256);
+	map = flipud(map);
+	map = map(1:floor(0.7*size(map,1)),:);
+	map = rgb2hsv(map);
+	map(:,2) = max(min( (0.1+map(:,1)).^(1/alpha) ,1),0);
+	map = hsv2rgb(map);
+else
+	eval(['map = ' map ';']);
+end
Index: /issm/trunk/src/m/model/plot/colormaps/haxby.m
===================================================================
--- /issm/trunk/src/m/model/plot/colormaps/haxby.m	(revision 12706)
+++ /issm/trunk/src/m/model/plot/colormaps/haxby.m	(revision 12706)
@@ -0,0 +1,36 @@
+function map = haxby(m);
+%HAXBY - Haxby color map
+%   HAXBY(M) returns an M-by-3 matrix containing a colormap with Haxby's
+%   colors, commonly used for displaying bathymetry data.
+%   HAXBY, by itself, is the same length as the current colormap.
+%
+%   Colormap is based on the colors used by W. F. Haxby's Gravity
+%   field of World's oceans, 1985, developed for geoid and gravity maps.
+%   The version used here is formed from a linear interpolation of
+%   the GMT color table used by MB-System by David W. Caress and Dale N. Chayes.
+%   <http://www.ldeo.columbia.edu/res/pi/MB-System>
+
+if nargin < 1, m = size(get(gcf,'colormap'),1); end
+
+ncolors=11;
+c=[...
+	37     57   175
+	40    127   251
+	50    190   255
+	106   235   255
+	138   236   174
+	205   255   162
+	240   236   121
+	255   189    87
+	255   161    68
+	255   186   133
+	255   255   255];
+
+pp=1:(m-1)/(ncolors-1):m;
+r=interp1(pp,c(:,1),1:m);
+g=interp1(pp,c(:,2),1:m);
+b=interp1(pp,c(:,3),1:m);
+map=[r' g' b']/255;
+
+%Fix bug of interp1 (M. Morlighem)
+map(find(map>1))=1;
Index: /issm/trunk/src/m/model/plot/colormaps/lbmap.m
===================================================================
--- /issm/trunk/src/m/model/plot/colormaps/lbmap.m	(revision 12706)
+++ /issm/trunk/src/m/model/plot/colormaps/lbmap.m	(revision 12706)
@@ -0,0 +1,109 @@
+function map = lbmap(n,scheme)
+%LBMAP Returns specified Light-Bertlein colormap.
+%
+%   LBMAP(N,SCHEME) returns an Nx3 colormap. SCHEME can be one of the
+%   following strings:
+%
+%       'Blue'       Single-hue progression to purlish-blue (default)
+%       'BlueGray'   Diverging progression from blue to gray
+%       'BrownBlue'  Orange-white-purple diverging scheme
+%       'RedBlue'    Modified spectral scheme
+%
+%   If N is not specified, the size of the colormap is determined by the
+%   current figure. If no figure exists, MATLAB creates one.
+%
+%Example 1: 7-color single-hue blue (default)
+%   load penny
+%   imagesc(P)
+%   colormap(lbmap(7))
+%   colorbar
+%
+%Example 2: 11-color modified spectrum
+%   load penny
+%   imagesc(P)
+%   colormap(lbmap(11,'RedBlue'))
+%   colorbar
+%
+%   See also HSV, GRAY, HOT, BONE, COPPER, PINK, FLAG, COLORMAP, RGBPLOT.
+
+% Reference:
+% A. Light & P.J. Bartlein, "The End of the Rainbow? Color Schemes for
+% Improved Data Graphics," Eos,Vol. 85, No. 40, 5 October 2004.
+% http://geography.uoregon.edu/datagraphics/EOS/Light&Bartlein_EOS2004.pdf
+
+% Copyright 2007-2010 The MathWorks, Inc.
+
+%defensive programming
+error(nargchk(0,2,nargin))
+error(nargoutchk(0,1,nargout))
+
+%defaults
+if nargin<2
+	scheme = 'Blue';
+end
+if nargin<1
+	n = size(get(gcf,'colormap'),1);
+end
+
+%valid schemes
+switch lower(scheme)
+	case 'blue'
+		baseMap = BlueMap;
+	case 'bluegray'
+		baseMap = BlueGrayMap;
+	case 'brownblue'
+		baseMap = BrownBlueMap;
+	case 'redblue'
+		baseMap = RedBlueMap;
+	otherwise
+		error(['Invalid scheme ' scheme])
+	end
+	idx1 = linspace(0,1,size(baseMap,1));
+	idx2 = linspace(0,1,n);
+	map = interp1(idx1,baseMap,idx2);
+
+function baseMap = BlueMap
+	baseMap = [243 246 248;
+	224 232 240;
+	171 209 236;
+	115 180 224;
+	35 157 213;
+	0 142 205;
+	0 122 192]/255;
+
+function baseMap = BlueGrayMap
+	%DivergingBlueGray
+	baseMap = [  0 170 227;
+	53 196 238;
+	133 212 234;
+	190 230 242;
+	217 224 230;
+	146 161 170;
+	109 122 129;
+	65  79  81]/255;
+
+function baseMap = BrownBlueMap
+	baseMap = [144 100  44;
+	187 120  54;
+	225 146  65;
+	248 184 139;
+	244 218 200;
+	241 244 245;
+	207 226 240;
+	160 190 225;
+	109 153 206;
+	70  99 174;
+	24  79 162]/255;
+
+function baseMap = RedBlueMap
+	baseMap = [175  53  71;
+	216  82  88;
+	239 133 122;
+	245 177 139;
+	249 216 168;
+	242 238 197;
+	216 236 241;
+	154 217 238;
+	68 199 239;
+	0 170 226;
+	0 116 188]/255;
Index: /issm/trunk/src/m/model/plot/plot_gridded.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_gridded.m	(revision 12705)
+++ /issm/trunk/src/m/model/plot/plot_gridded.m	(revision 12706)
@@ -6,6 +6,4 @@
 %
 %   See also: PLOTMODEL
-
-whitepos=getfieldvalue(options,'whitepos',2); %1: up, 2: down, else: none
 
 %process mesh and data
@@ -29,4 +27,10 @@
 end
 
+%Get and change colormap
+map    = getcolormap(options);
+lenmap = size(map,1);
+map    = [1 1 1; map];
+options=changefieldvalue(options,'colormap',map);
+
 %Process data_grid: add white in NaN and correct caxis accordingly
 if exist(options,'caxis'),
@@ -40,14 +44,8 @@
 	data_max=max(data_grid(:));
 end
-options=changefieldvalue(options,'cbYLim',[data_min data_max]);
-if whitepos==1,
-	white  =data_max + (data_max-data_min)/55;
-	options=changefieldvalue(options,'caxis',[data_min white]);
-	data_grid(isnan(data_grid))=white;
-elseif whitepos==2,
-	white  =data_min - (data_max-data_min)/55;
-	options=changefieldvalue(options,'caxis',[white data_max]);
-	data_grid(isnan(data_grid))=white;
-end
+options = changefieldvalue(options,'cbYLim',[data_min data_max]);
+white   = data_min - (data_max-data_min)/(lenmap);
+options = changefieldvalue(options,'caxis',[white data_max]);
+data_grid(isnan(data_grid))=white;
 
 %Select plot area 
@@ -56,11 +54,4 @@
 %shading interp;
 h=imagesc(xlim,ylim,data_grid);set(gca,'YDir','normal');
-map=getfieldvalue(options,'colormap',jet);
-if whitepos==1,
-	map(end,:)=[1 1 1];
-elseif whitepos==2,
-	map(1,:)=[1 1 1];
-end
-options=changefieldvalue(options,'colormap',map);
 
 %last step: mesh gridded?
Index: /issm/trunk/src/m/model/plot/plot_manager.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_manager.m	(revision 12705)
+++ /issm/trunk/src/m/model/plot/plot_manager.m	(revision 12706)
@@ -165,4 +165,10 @@
 if exist(options,'sectionvalue')
 	plot_section(md,data,options,nlines,ncols,i);
+	return;
+end
+
+%Figure out if this is a Profile plot
+if exist(options,'profile')
+	plot_profile(md,data,options,nlines,ncols,i);
 	return;
 end
Index: /issm/trunk/src/m/model/plot/plot_overlay.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_overlay.m	(revision 12705)
+++ /issm/trunk/src/m/model/plot/plot_overlay.m	(revision 12706)
@@ -41,4 +41,8 @@
 	md=radarpower(md,options);
 end
+contrast = getfieldvalue(options,'contrast',1);  
+radar = (md.radaroverlay.pwr).^(contrast);
+radar = radar./max(radar(:));
+%radar(find(radar==0))=1; %Change background from black to white
 
 %InterpFromMeshToGrid
@@ -50,8 +54,14 @@
 ncols =length(md.radaroverlay.x);
 disp('Interpolating data on grid...');
-[x_m y_m data_grid]=InterpFromMeshToGrid(elements,x/getfieldvalue(options,'unit',1),y/getfieldvalue(options,'unit',1),...
-	data,xmin,ymax,xspacing,yspacing,nlines,ncols,NaN);
+if radaronly,
+	x_m=xmin:xspacing:xmin+ncols*xspacing;
+	y_m=ymax-nlines*yspacing:yspacing:ymax;
+	data_grid=NaN*ones(nlines,ncols);
+else
+	[x_m y_m data_grid]=InterpFromMeshToGrid(elements,x/getfieldvalue(options,'unit',1),y/getfieldvalue(options,'unit',1),...
+		data,xmin,ymax,xspacing,yspacing,nlines,ncols,NaN);
+end
 
-%Process data_grid
+%Process data_grid (For processing, it is better not to have nan)
 pos=find(isinf(data_grid));
 if ~isempty(pos),
@@ -70,52 +80,54 @@
 end
 data_nan=find(isnan(data_grid));
-
-%Generate HSV image
-contrast=getfieldvalue(options,'contrast',1);  
-transparency=getfieldvalue(options,'alpha',1);
 data_grid(data_nan)=data_min; 
 
+%Special colormaps that require hsv treatment
 colorm=getfieldvalue(options,'colormap','Rignot');
-if strcmpi(colorm,'Rignot'),
-	%hue (H)
-	h_data=(data_grid-data_min)/(data_max-data_min+eps);
-	if radaronly, h_data(:)=0; end
-	%saturation (S)
-	s_data=max(min((0.1+h_data).^(1/transparency),1),0);
-elseif strcmpi(colorm,'Seroussi'),
-	%hue (H)
-	h_data=1-(data_grid-data_min)/(data_max-data_min+eps)*0.7;
-	%h_data=(data_grid-data_min)/(data_max-data_min)*2/3;
-	if radaronly, h_data(:)=0; end
-	%saturation (S)
-	s_data=max(min((0.1+h_data).^(1/transparency),1),0);
-elseif strcmpi(colorm,'redblue')
-	data_mean=data_min+(data_max-data_min)/2;
-	%hue (H)
-	%h_data=0.7*ones(size(data_grid));
-	%h_data(find(data_grid>data_mean))=1;
-	h_data=1*ones(size(data_grid));
-	h_data(find(data_grid<data_mean))=0.7;
-	%saturation (S)
-	s_data=max(min(abs(data_grid-data_mean)/(data_max-data_mean) ,1),0);
+if strcmpi(colorm,'Rignot') | strcmpi(colorm,'Seroussi') | strcmpi(colorm,'redblue')
+	if strcmpi(colorm,'Rignot'),
+		transparency=getfieldvalue(options,'alpha',1);
+		h=(data_grid-data_min)/(data_max-data_min+eps);
+		if radaronly, h(:)=0; end
+		s=max(min((0.1+h).^(1/transparency),1),0);
+	elseif strcmpi(colorm,'Seroussi'),
+		transparency=getfieldvalue(options,'alpha',1);
+		h=1-(data_grid-data_min)/(data_max-data_min+eps)*0.7;
+		if radaronly, h(:)=0; end
+		s=max(min((0.1+h).^(1/transparency),1),0);
+	elseif strcmpi(colorm,'redblue')
+		data_mean=data_min+(data_max-data_min)/2;
+		h=1*ones(size(data_grid));
+		h(find(data_grid<data_mean))=0.7;
+		s=max(min(abs(data_grid-data_mean)/(data_max-data_mean) ,1),0);
+	else
+		error('colormap not supported yet. (''Rignot'' and ''redblue'' are the only cupported colormaps)');
+	end
+	%(S) Saturation is 0 in NaNs
+	s(data_nan)=0;
+	%(V) intensity is based on radar image
+	v=radar; %use radar power as intensity
+
+	%Transform HSV to RGB
+	image_hsv=zeros(size(data_grid,1),size(data_grid,2),3);
+	image_hsv(:,:,1)=h; clear h;
+	image_hsv(:,:,2)=s; clear s;
+	image_hsv(:,:,3)=v; clear v;
+	image_rgb=hsv2rgb(image_hsv);
 else
-	error('colormap not supported yet. (''Rignot'' and ''redblue'' are the only cupported colormaps)');
+	colorm = getcolormap(options);
+	len    = size(colorm,1);
+
+	ind = ceil((len-1)*(data_grid-data_min)/(data_max - data_min + eps) +1);
+	ind(find(ind>len))=len;
+	image_rgb=zeros(size(data_grid,1),size(data_grid,2),3);
+	r=colorm(:,1); image_rgb(:,:,1)=r(ind); clear r;
+	g=colorm(:,2); image_rgb(:,:,2)=g(ind); clear g;
+	b=colorm(:,3); image_rgb(:,:,3)=b(ind); clear b;
+
+	%Now add radarmap
+	r = image_rgb(:,:,1).*radar;  r(data_nan) = radar(data_nan);  image_rgb(:,:,1) = r;  clear r;
+	g = image_rgb(:,:,2).*radar;  g(data_nan) = radar(data_nan);  image_rgb(:,:,2) = g;  clear g;
+	b = image_rgb(:,:,3).*radar;  b(data_nan) = radar(data_nan);  image_rgb(:,:,3) = b;  clear b;
 end
-
-%Saturation is 0 in NaNs
-s_data(data_nan)=0;
-%intensity (V)
-radar=(md.radaroverlay.pwr).^(contrast);
-v_data=radar/max(radar(:)); %use radar power as intensity
-
-%Change background from black to white
-%pos=find(v_data==0);v_data(pos)=1;
-
-%Transform HSV to RGB
-image_hsv=zeros(size(data_grid,1),size(data_grid,2),3);
-image_hsv(:,:,1)=h_data;
-image_hsv(:,:,2)=s_data;
-image_hsv(:,:,3)=v_data;
-image_rgb=hsv2rgb(image_hsv);
 
 %Select plot area 
@@ -134,9 +146,9 @@
 
 %Apply options, without colorbar and without grid
-options=changefieldvalue(options,'colormap',colorm);           %We used an HSV colorbar
+options=changefieldvalue(options,'colormap',colorm);              % We used an HSV colorbar
 if ~isnan(data_min),
-	options=changefieldvalue(options,'caxis',[data_min data_max]); %force caxis so that the colorbar is ready
+	options=changefieldvalue(options,'caxis',[data_min data_max]); % force caxis so that the colorbar is ready
 end
-options=addfielddefault(options,'axis','equal off');           %default axis
+options=addfielddefault(options,'axis','equal off');              % default axis
 applyoptions(md,data,options);
 drawnow
Index: /issm/trunk/src/m/model/plot/plot_profile.m
===================================================================
--- /issm/trunk/src/m/model/plot/plot_profile.m	(revision 12706)
+++ /issm/trunk/src/m/model/plot/plot_profile.m	(revision 12706)
@@ -0,0 +1,55 @@
+function plot_profile(md,data,options,nlines,ncols,ii)
+%PLOT_SECTION - plot a given field on a profile
+%
+%   Usage:
+%      plot_profile(md,data,options,nlines,ncols,i)
+%
+%   See also: PLOTMODEL
+
+%process model
+[x_m y_m z_m elements_m is2d isplanet]=processmesh(md,[],options);
+if is2d, error('only 3d model supported'); end
+
+%Get number of curves and generate random colors
+numcurves=size(data,2);
+colorm=getfieldvalue(options,'colormap','lines');
+color=eval([ colorm '(numcurves);']);
+options=removefield(options,'colormap',0); %back to default colormap
+
+%Get coordinates
+location=getfieldvalue(options,'profile');
+if ~isnumeric(location) | numel(location)~=2,
+	error('location provided not supported (should be [x y])');
+end
+xprof=location(1);
+yprof=location(2);
+
+%Loop over number of curves
+for i=1:numcurves,
+
+	%Process data
+	[datai datatype]=processdata(md,data(:,i),options);
+
+	%resolution
+	if exist(options,'resolution'),
+		resolution=getfieldvalue(options,'resolution');
+	else %Default resolution
+		resolution=[100];
+		disp(['plot_profile warning: no resolution specified, using default: ' num2str(resolution) ]);
+	end
+
+	%Compute profile value
+	[z,data_interp]=ProfileValues(md,datai,xprof,yprof,resolution);
+
+	%plot profile
+	subplot(nlines,ncols,ii)
+	plot(data_interp,z,'color',color(i,:),'LineWidth',getfieldvalue(options,'linewidth',1),'LineStyle','-');
+	hold on;
+end
+
+%apply options
+options=addfielddefault(options,'title','Profile');
+options=addfielddefault(options,'colorbar',0);
+options=addfielddefault(options,'ylabel','z');
+options=addfielddefault(options,'view',2);
+applyoptions(md,[],options);
Index: /issm/trunk/src/m/model/plot/plotdoc.m
===================================================================
--- /issm/trunk/src/m/model/plot/plotdoc.m	(revision 12705)
+++ /issm/trunk/src/m/model/plot/plotdoc.m	(revision 12706)
@@ -94,4 +94,5 @@
 disp('       ''showsection'': show section used by ''sectionvalue'' (string ''on'' or a number of labels)');
 disp('       ''sectionvalue'': give the value of data on a profile given by an Argus file (string ''Argusfile_name.exp'')');
+disp('       ''profile'': give the value of data along a vertical profile ([xlocation ylocation])');
 disp('       ''smooth'': smooth element data (string ''yes'' or integer)');
 disp('       ''title'': same as standard matlab option');
Index: /issm/trunk/src/m/model/plot/plotmodel.m
===================================================================
--- /issm/trunk/src/m/model/plot/plotmodel.m	(revision 12705)
+++ /issm/trunk/src/m/model/plot/plotmodel.m	(revision 12706)
@@ -48,5 +48,4 @@
 		for i=1:numberofplots,
 			plot_manager(getfieldvalue(options.list{i},'model',md),options.list{i},subplotwidth,nlines,ncols,i);
-			%cbfreeze;
 		end
 	catch me,
Index: /issm/trunk/src/m/model/plot/subplotmodel.m
===================================================================
--- /issm/trunk/src/m/model/plot/subplotmodel.m	(revision 12705)
+++ /issm/trunk/src/m/model/plot/subplotmodel.m	(revision 12706)
@@ -14,5 +14,4 @@
 hmargin = getfieldvalue(options,'hmargin',[.01 .01]);
 vmargin = getfieldvalue(options,'vmargin',[.01 .01]);
-
 
 height = (1-sum(vmargin)-(nlines-1)*gap(1))/nlines; 
Index: /issm/trunk/src/m/model/process_solve_options.py
===================================================================
--- /issm/trunk/src/m/model/process_solve_options.py	(revision 12706)
+++ /issm/trunk/src/m/model/process_solve_options.py	(revision 12706)
@@ -0,0 +1,48 @@
+"""
+DEFAULT_SOLVE_OPTIONS - set up default options for solve phase
+ 
+    Usage:
+       options=process_solve_options(options)
+ 
+    See also: SOLVE
+"""
+
+import os
+
+def process_solve_options(options):
+
+	outoptions={}
+
+	#solution_type: check on this option, error out otherwise
+	solution_type=options.getfieldvalue('solution_type')
+	if solution_type in (DiagnosticSolutionEnum,PrognosticSolutionEnum,ThermalSolutionEnum,\
+			SteadystateSolutionEnum,TransientSolutionEnum,EnthalpySolutionEnum,\
+			BalancethicknessSolutionEnum,BedSlopeSolutionEnum,SurfaceSlopeSolutionEnum,HydrologySolutionEnum,FlaimSolutionEnum):
+		raise ValueError("process_solve_options error message: solution_type '%s' not supported yet!" % EnumToString(solution_type))
+	outoptions['solution_type']=solution_type
+
+	outoptions['upload']=options.getfieldvalue('upload','off')
+	outoptions['batch']=options.getfieldvalue('batch','no')
+	outoptions['loadonly']=options.getfieldvalue('loadonly',False)
+	outoptions['directory']=options.getfieldvalue('directory','')
+
+	#  process qmu arguments
+	outoptions['qmudir']=options.getfieldvalue('qmudir','qmu'+str(os.getpid()))
+	outoptions['qmufile']=options.getfieldvalue('qmufile','qmu')    # qmufile cannot be changed unless ????script.sh is also changed
+	outoptions['overwrite']=options.getfieldvalue('overwrite','n')
+	outoptions['keep']=options.getfieldvalue('keep','n')
+	outoptions['ivar']=options.getfieldvalue('ivar',1)
+	outoptions['iresp']=options.getfieldvalue('iresp',1)
+	outoptions['imethod']=options.getfieldvalue('imethod',1)
+	outoptions['iparams']=options.getfieldvalue('iparams',1)
+	outoptions['runmpi']=options.getfieldvalue('runmpi',False)
+
+	#  process flaim arguments
+	outoptions['fmdir']=options.getfieldvalue('fmdir','fm'+str(os.getpid()))
+	outoptions['overwrite']=options.getfieldvalue('overwrite','n')
+	outoptions['keep']=options.getfieldvalue('keep','y')
+	outoptions['latsgn']=options.getfieldvalue('latsgn',0)
+	outoptions['cmap']=options.getfieldvalue('cmap',None)
+
+	return outoptions
+
Index: /issm/trunk/src/m/model/radarpower.m
===================================================================
--- /issm/trunk/src/m/model/radarpower.m	(revision 12705)
+++ /issm/trunk/src/m/model/radarpower.m	(revision 12706)
@@ -37,11 +37,14 @@
 			error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpg not found.']);
 		end
-		jpgim=[jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpg'];
-		geom=load([jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpgw'],'ascii');
+		name = 'mog150_greenland_map';
+		%name = 'mog100_hp1_v10';
+		%name = 'mog500_hp1_v10';
+		jpgim=[jplsvn() '/projects/ModelData/MOG/' name '.jpg'];
+		geom=load([jplsvn() '/projects/ModelData/MOG/' name '.jpgw'],'ascii');
 
 		%geom:   xposting nbcols nbrows yposting xmin ymax
 		xmin=max(geom(5),x0);
 		xmax=min(geom(5)+geom(1)*geom(2),x1);
-		ymin=max(geom(6)-geom(4)*geom(3),y0);
+		ymin=max(geom(6)-geom(3)*geom(4),y0);
 		ymax=min(geom(6),y1);
 
@@ -106,5 +109,4 @@
 	toplefty=floor((overlay_ylim(2)-y1)/overlay_yposting); % y max
 
-
 	%Read and crop file
 	disp('Warning: expecting coordinates in polar stereographic (Std Latitude: 70ºN Meridian: 45º)');
Index: /issm/trunk/src/m/model/regionaltransient2d.m
===================================================================
--- /issm/trunk/src/m/model/regionaltransient2d.m	(revision 12705)
+++ /issm/trunk/src/m/model/regionaltransient2d.m	(revision 12706)
@@ -106,5 +106,5 @@
 			thickness=PatchToVec(md1.results.TransientSolution(t).Thickness);
 			spcx=[spcx InterpFromMeshToMesh2d(md1.mesh.elements,md1.mesh.x,md1.mesh.y,vx,md2.mesh.x,md2.mesh.y)];
-			spcy=[spcy InterpFromMeshToMesh2d(md1.mesh.elements,md1.mesh.x,md1.mesh.y,vx,md2.mesh.x,md2.mesh.y)];
+			spcy=[spcy InterpFromMeshToMesh2d(md1.mesh.elements,md1.mesh.x,md1.mesh.y,vy,md2.mesh.x,md2.mesh.y)];
 			spct=[spct InterpFromMeshToMesh2d(md1.mesh.elements,md1.mesh.x,md1.mesh.y,thickness,md2.mesh.x,md2.mesh.y)];
 			steps=[steps t*md1.timestepping.time_step];
Index: /issm/trunk/src/m/model/setmask.m
===================================================================
--- /issm/trunk/src/m/model/setmask.m	(revision 12705)
+++ /issm/trunk/src/m/model/setmask.m	(revision 12706)
@@ -25,5 +25,5 @@
 elements=md.mesh.elements;
 
-%Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{1
+%Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
 elementonfloatingice=FlagElements(md,floatingicename);
 elementongroundedice=FlagElements(md,groundedicename);
Index: /issm/trunk/src/m/model/setmask.py
===================================================================
--- /issm/trunk/src/m/model/setmask.py	(revision 12705)
+++ /issm/trunk/src/m/model/setmask.py	(revision 12706)
@@ -22,5 +22,5 @@
 	elements = md.mesh.elements
 
-	#Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{1
+	#Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
 	elementonfloatingice = fe.FlagElements(md, floatingicename)
 	elementongroundedice = fe.FlagElements(md, groundedicename) 
Index: /issm/trunk/src/m/model/solve.m
===================================================================
--- /issm/trunk/src/m/model/solve.m	(revision 12705)
+++ /issm/trunk/src/m/model/solve.m	(revision 12706)
@@ -24,21 +24,20 @@
 %      md=solve(md,DiagnosticSolutionEnum);
 
-%recover options
+%recover and process solve options
 options=pairoptions(varargin{:},'solution_type',solutionenum);
-
-%add default options
 options=process_solve_options(options);
 
 %recover some fields
 md.private.solution=options.solution_type;
+cluster=md.cluster;
 
 %check model consistency
 disp('checking model consistency');
 if (solutionenum == FlaimSolutionEnum)
-	modelconsistency(true);
-	md.mesh.checkconsistency(md,solutionenum);
-	md.flaim.checkconsistency(md,solutionenum);
-	if ~modelconsistency()
-		error(' ');
+	md.private.isconsistent=true;
+	md=checkconsistency(md.mesh,md,solutionenum);
+	md=checkconsistency(md.flaim,md,solutionenum);
+	if md.private.isconsistent==false,
+		error('Model not consistent, see messages above');
 	end
 else
@@ -46,15 +45,16 @@
 end
 
-%if running qmu analysis, some preprocessing of dakota files using 
-%models fields needs to be carried out. 
+%First, build a runtime name that is unique
+c=clock;
+md.private.runtimename=sprintf('%s-%02i-%02i-%04i-%02i-%02i-%02i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
+
+%if running qmu analysis, some preprocessing of dakota files using models
+%fields needs to be carried out. 
 if md.qmu.isdakota,
 	md=preqmu(md,options);
 end
 
-%Save model as is (in case of a crash)
-assignin('base',inputname(1),md);
-
 %flaim analysis
-if (md.private.solution == FlaimSolutionEnum)
+if (options.solution_type == FlaimSolutionEnum)
 	md=flaim_sol(md,options);
 	md.private.solution=EnumToString(options.solution_type);
@@ -62,29 +62,58 @@
 end
 
-%Marshall model data into a binary file.
-marshall(md);
-
-%write a template file for issm to use, in parallel
-PetscFile(md.solver,[md.miscellaneous.name '.petsc']);
-
-%If running in parallel, we have a different way of launching the solution
-%sequences. 
-if ~strcmpi(md.cluster.name,'none'),
-	md=solveparallel(md,options);
+%Do we load results only?
+if options.loadonly,  
+	md=loadresultsfromcluster(md);
 	return;
 end
 
-%Launch correct solution sequence
-md=issm(md,md.private.solution);
+%Wite all input files
+marshall(md);                                          % bin file
+PetscFile(md.solver,[md.miscellaneous.name '.petsc']); % petsc file
+BuildQueueScript(cluster,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof); % queue file
+
+%we need to make sure we have PETSC support, otherwise, we run with only one cpu: 
+if ~ispetsc,
+	disp('PETSC support not included, running on 1 cpu only!');
+	cluster.np=1;
+end
+
+%Stop here if batch mode
+if strcmpi(options.batch,'yes')
+	disp('batch mode requested: not launching job interactively');
+	disp('launch solution sequence on remote cluster by hand');
+	return;
+end
+
+%Launch job
+modelname = md.miscellaneous.name;
+filelist  = {[modelname '.bin '] [modelname '.petsc '] [modelname '.queue ']};
+if md.qmu.isdakota,
+	filelist{end+1} = [modelname '.qmu.in'];
+end
+LaunchQueueJob(cluster,md.miscellaneous.name,md.private.runtimename,filelist);
+
+%did we even try to run? if so, wait on lock
+if strcmpi(options.upload,'on'),
+	disp('solve done uploading test decks');
+	return;
+end
+
+%wait on lock
+if md.settings.waitonlock>0,
+	%we wait for the done file
+	islock=waitonlock(md);
+	if islock==0, %no results to be loaded
+		disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
+	else          %load results
+		disp('loading results from cluster');
+		md=loadresultsfromcluster(md);
+	end
+end
 
 %post processes qmu results if necessary
 if md.qmu.isdakota,
-	md=postqmu(md);
-	cd ..
 	if ~strncmpi(options.keep,'y',1)
 		system(['rm -rf qmu' num2str(feature('GetPid'))]);
 	end
 end
-
-%convert analysis type to string finally
-md.private.solution=EnumToString(options.solution_type);
Index: sm/trunk/src/m/model/solveparallel.m
===================================================================
--- /issm/trunk/src/m/model/solveparallel.m	(revision 12705)
+++ 	(revision )
@@ -1,58 +1,0 @@
-function md=solveparallel(md,options)
-%SOLVEPARALLEL - solution sequence using a cluster in parallel mode
-%
-%   Usage:
-%      md=solveparallel(md);
-
-%retrieve cluster: otherwise, we can't call its methods (subsref bug)
-cluster=md.cluster;
-
-if options.loadonly,  
-	md=loadresultsfromcluster(md);
-else
-
-	%In parallel mode, we need to make sure we have PETSC support, otherwise, we run with only one cpu: 
-	if ~ispetsc,
-		disp('PETSC support not included, running on 1 cpu only!');
-		cluster.np=1;
-	end
-
-	%First, build a runtime name that is unique, that we will use to create 
-	%directories, name jobs, etc ...
-	c=clock; md.private.runtimename=sprintf('%s-%02i-%02i-%04i-%02i-%02i-%02i-%i',md.miscellaneous.name,c(2),c(3),c(1),c(4),c(5),floor(c(6)),feature('GetPid'));
-
-	if verLessThan('matlab', '7.6')
-		BuildQueueScript(cluster,md);
-		LaunchQueueJob(cluster,md,options);
-	else
-		cluster.BuildQueueScript(md);
-		cluster.LaunchQueueJob(md,options);
-	end
-
-	if ~strcmpi(options.upload,'on'), %did we even try to run? if so, wait on lock
-
-		%Do we return, or just wait for results?
-		if (md.settings.waitonlock>0 &  ~strcmpi(options.batch,'yes')),
-			%we wait for the done file
-			islock=waitonlock(md);
-			if islock==0,
-				%no results to be loaded
-				disp('The results must be loaded manually with md=loadresultsfromcluster(md).');
-			else
-				%load results
-				disp('loading results from cluster');
-				md=loadresultsfromcluster(md);
-			end
-		end
-
-		%post processes qmu results if necessary
-		if md.qmu.isdakota,
-			if ~strncmpi(options.keep,'y',1)
-				system(['rm -rf qmu' num2str(feature('GetPid'))]);
-			end
-		end
-	else
-		error('solveparallel done uploading test decks');
-	end
-
-end
Index: /issm/trunk/src/m/model/solvers/stokesoptions.m
===================================================================
--- /issm/trunk/src/m/model/solvers/stokesoptions.m	(revision 12705)
+++ /issm/trunk/src/m/model/solvers/stokesoptions.m	(revision 12706)
@@ -6,5 +6,5 @@
 
 %retrieve options provided in varargin
-arguments=pairoptions(varargin{:});
+options=pairoptions(varargin{:});
 stokes=struct();
 
Index: /issm/trunk/src/m/model/waitonlock.py
===================================================================
--- /issm/trunk/src/m/model/waitonlock.py	(revision 12706)
+++ /issm/trunk/src/m/model/waitonlock.py	(revision 12706)
@@ -0,0 +1,65 @@
+"""
+WAITONLOCK - wait for a file
+ 
+    This routine will return when a file named 'filename' is written to disk.
+    If the time limit given in input is exceeded, return 0
+ 
+    Usage:
+       flag=waitonlock(md,executionpath)
+"""
+
+import os
+import socket
+import time
+from MatlabFuncs import *
+
+def waitonlock(md,executionpath,login,port):
+
+	#Get filename (lock file) and options
+	executionpath=md.cluster.executionpath
+	cluster=md.cluster.name
+	login=md.cluster.login
+	port=md.cluster.port
+	timelimit=md.settings.waitonlock
+	filename=os.path.join(executionpath,md.private.runtimename,md.miscellaneous.name+'.lock')
+
+	#waitonlock will work if the lock is on the same machine only: 
+	if not strcmpi(socket.gethostname().lower().split('.')[0],cluster):
+
+		print 'solution launched on remote cluster. log in to detect job completion.'
+		choice=raw_input('Is the job successfully completed? (y/n) ')
+		if not strcmp(choice,'y'): 
+			print 'Results not loaded... exiting' 
+			flag=0
+		else:
+			flag=1
+
+	#job is running on the same machine
+	else:
+
+		if 'interactive' in vars(md.cluster) and md.cluster.interactive:
+			#We are in interactive mode, no need to check for job completion
+			flag=1
+			return flag
+		#initialize time and file presence test flag
+		etime=0
+		ispresent=0
+		print "waiting for '%s' hold on... (Ctrl+C to exit)" % filename
+
+		#loop till file .lock exist or time is up
+		while ispresent==0 and etime<timelimit:
+			ispresent=os.path.exist(filename)
+			time.sleep(1)
+			etime+=1/60
+
+		#build output
+		if etime>timelimit:
+			print 'Time limit exceeded. Increase md.settings.waitonlock'
+			print 'The results must be loaded manually with md=loadresultsfromcluster(md).'
+			raise RuntimeError('waitonlock error message: time limit exceeded.')
+			flag=0
+		else:
+			flag=1
+
+	return flag
+
Index: /issm/trunk/src/m/qmu/preqmu.m
===================================================================
--- /issm/trunk/src/m/qmu/preqmu.m	(revision 12705)
+++ /issm/trunk/src/m/qmu/preqmu.m	(revision 12706)
@@ -44,5 +44,5 @@
 responses=expandresponses(md,responses);
 
-%go through variables and responses, and check they don't have more than md.qmu.numberofpartitions values. Also determine numvariables and numresponses{{{1
+%go through variables and responses, and check they don't have more than md.qmu.numberofpartitions values. Also determine numvariables and numresponses{{{
 numvariables=0;
 variable_fieldnames=fieldnames(variables);
@@ -76,5 +76,5 @@
 system(['rm -rf ' md.miscellaneous.name '.m']);
 
-%build a list of variables and responses descriptors. the list is not expanded. {{{1
+%build a list of variables and responses descriptors. the list is not expanded. {{{
 variabledescriptors={};
 variable_fieldnames=fieldnames(md.qmu.variables(options.ivar));
Index: /issm/trunk/src/m/utils/Basins/basinzoom.m
===================================================================
--- /issm/trunk/src/m/utils/Basins/basinzoom.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Basins/basinzoom.m	(revision 12706)
@@ -38,5 +38,5 @@
 
 %Ok, find basin we are talking about: 
-load([issmdir '/projects/ModelData/Names/Names.mat']);
+load([jplsvn() '/projects/ModelData/Names/Names.mat']);
 		
 %Go through names: 
Index: /issm/trunk/src/m/utils/Basins/isbasin.m
===================================================================
--- /issm/trunk/src/m/utils/Basins/isbasin.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Basins/isbasin.m	(revision 12706)
@@ -9,5 +9,5 @@
 
 %First, load basin names:
-load([issmdir '/projects/ModelData/Names/Names.mat']);
+load([jplsvn '/projects/ModelData/Names/Names.mat']);
 
 
Index: /issm/trunk/src/m/utils/Basins/showbasins.m
===================================================================
--- /issm/trunk/src/m/utils/Basins/showbasins.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Basins/showbasins.m	(revision 12706)
@@ -45,5 +45,5 @@
 
 %Ok, find basin we are talking about: 
-load([issmdir '/projects/ModelData/Names/Names.mat']);
+load([jplsvn '/projects/ModelData/Names/Names.mat']);
 
 %Get xlim and ylim, and convert into lat,long: 
Index: /issm/trunk/src/m/utils/Cluster/parallelrange.py
===================================================================
--- /issm/trunk/src/m/utils/Cluster/parallelrange.py	(revision 12706)
+++ /issm/trunk/src/m/utils/Cluster/parallelrange.py	(revision 12706)
@@ -0,0 +1,26 @@
+#! /usr/bin/env python
+"""
+PARALLELRANGE - from a rank, and a number of processors, figure out a range, for parallel tasks.
+ 
+    Usage: 
+       i1,i2=parallelrange(rank,numprocs,globalsize)
+"""
+
+def parallelrange(rank,numprocs,globalsize):
+
+	#We use floor. we under distribute rows. The rows left are then redistributed, therefore resulting in a more even distribution.
+	num_local_rows=[int(globalsize/numprocs) for i in xrange(numprocs)]
+
+	#There may be some rows left. Distribute evenly.
+	row_rest=globalsize - numprocs*int(globalsize/numprocs)
+
+	for i in xrange(row_rest):
+		num_local_rows[i]=num_local_rows[i]+1
+
+	i1=0
+	for i in xrange(rank-1):
+		i1+=num_local_rows[i]
+	i2=i1+num_local_rows[rank-1]-1
+
+	return i1,i2
+
Index: /issm/trunk/src/m/utils/DataProcessing/pkriging.m
===================================================================
--- /issm/trunk/src/m/utils/DataProcessing/pkriging.m	(revision 12706)
+++ /issm/trunk/src/m/utils/DataProcessing/pkriging.m	(revision 12706)
@@ -0,0 +1,55 @@
+function [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin);
+%PKRIGING - parallel Kriging
+%
+%   Usage:
+%      [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin);
+
+options=pairoptions(varargin{:});
+cluster=getfieldvalue(options,'cluster',generic('np',10));
+options=removefield(options,'cluster',0);
+name   = ['krig' num2str(feature('GetPid'))];
+
+% =========================================   MARSHALL.m =================================================
+disp(['marshalling file ' name '.bin']);
+fid=fopen([name '.bin'],'wb');
+if fid==-1,
+	error(['marshall error message: could not open ' name '.bin file for binary writing']);
+end
+
+%First, write MaximumNumberOfEnum to make sure that the Enums are synchronized
+WriteData(fid,'enum',MaximumNumberOfEnums(),'data',true,'format','Boolean');
+
+%Write all data
+WriteData(fid,'enum',0,'data',x,'format','DoubleMat');
+WriteData(fid,'enum',1,'data',y,'format','DoubleMat');
+WriteData(fid,'enum',2,'data',observations,'format','DoubleMat');
+WriteData(fid,'enum',3,'data',x_interp,'format','DoubleMat');
+WriteData(fid,'enum',4,'data',y_interp,'format','DoubleMat');
+options.marshall(fid,5);
+st=fclose(fid);
+if st==-1,
+	error(['marshall error message: could not close file ' name '.bin']);
+end
+% =========================================   MARSHALL.m =================================================
+
+%Launch job on remote cluster
+BuildKrigingQueueScript(cluster,name,'',1,0,0); %gather, valgrind, gprof
+tic
+LaunchQueueJob(cluster,name,name,{[name '.bin'] [name '.queue']});
+toc
+choice=input('Is the job successfully completed? (y/n)','s');
+Download(cluster,name,{[name '.outbin']});
+structure=parseresultsfromdisk([name '.outbin'],0);
+delete([name '.outlog']);
+delete([name '.errlog']);
+delete([name '.outbin']);
+delete([name '.bin']);
+if ~ispc,
+	delete([name '.tar.gz']);
+end
+
+%Process results
+B=structure.AutodiffForward;
+B=reshape(B,size(x_interp,2),size(x_interp,1))';
+E=structure.AutodiffIsautodiff;
+E=reshape(E,size(x_interp,2),size(x_interp,1))';
Index: /issm/trunk/src/m/utils/Exp/expcoarsen.m
===================================================================
--- /issm/trunk/src/m/utils/Exp/expcoarsen.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Exp/expcoarsen.m	(revision 12706)
@@ -26,5 +26,5 @@
 %Get exp oldfile
 [path root ext ver]=fileparts(oldfile);
-A=expread(oldfile,1);
+A=expread(oldfile);
 numprofiles=size(A,2);
 
Index: /issm/trunk/src/m/utils/Exp/expcontract.m
===================================================================
--- /issm/trunk/src/m/utils/Exp/expcontract.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Exp/expcontract.m	(revision 12706)
@@ -8,5 +8,5 @@
 
 
-contour=expread(oldfile,1);
+contour=expread(oldfile);
 num=numel(contour.x);
 
Index: /issm/trunk/src/m/utils/Exp/expll2xy.m
===================================================================
--- /issm/trunk/src/m/utils/Exp/expll2xy.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Exp/expll2xy.m	(revision 12706)
@@ -27,5 +27,5 @@
 
 %read filename: 
-domain=expread(filename,1);
+domain=expread(filename);
 
 %change to x,y: 
Index: /issm/trunk/src/m/utils/Exp/expxy2ll.m
===================================================================
--- /issm/trunk/src/m/utils/Exp/expxy2ll.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Exp/expxy2ll.m	(revision 12706)
@@ -27,5 +27,5 @@
 
 %read filename: 
-domain=expread(filename,1);
+domain=expread(filename);
 
 %change to x,y: 
Index: /issm/trunk/src/m/utils/Exp/manipulation/cutarea.m
===================================================================
--- /issm/trunk/src/m/utils/Exp/manipulation/cutarea.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Exp/manipulation/cutarea.m	(revision 12706)
@@ -87,8 +87,10 @@
 									A(selection).x=x(1:p1);
 									A(selection).y=y(1:p1);
+									closed(selection)=0;
 									A(end+1).x=x(p2:end);
 									A(end).y=y(p2:end);
 									A(end).density=A(selection).density;
 									A(end).name=A(selection).name;
+									closed(end+1)=0;
 									numprofiles=numprofiles+1;
 									numpoints=numpoints-(p2-p1-1);
@@ -113,4 +115,5 @@
 								else
 									%cut in 2 profiles
+									closed(selection)=0;
 									A(selection).x=x(1:p2);
 									A(selection).y=y(1:p2);
@@ -119,4 +122,5 @@
 									A(end).density=A(selection).density;
 									A(end).name=A(selection).name;
+									closed(end+1)=0;
 									numprofiles=numprofiles+1;
 									numpoints=numpoints-(p1-p2-1);
Index: /issm/trunk/src/m/utils/Geometry/find_point.m
===================================================================
--- /issm/trunk/src/m/utils/Geometry/find_point.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Geometry/find_point.m	(revision 12706)
@@ -8,4 +8,7 @@
 %      f=find_point(tabx,taby,pointx,pointy)
 
+%Compute distance between point and cloud of points
 distance=sqrt((tabx-pointx).^2+(taby-pointy).^2);
-f=find(distance==min(min(distance)));
+
+%find index of the minimum distance and return the first one only
+f=find(distance==min(min(distance)),1);
Index: /issm/trunk/src/m/utils/Kml/exp2kml.m
===================================================================
--- /issm/trunk/src/m/utils/Kml/exp2kml.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Kml/exp2kml.m	(revision 12706)
@@ -8,5 +8,5 @@
 
 %First, read exp file
-domain=expread(input,1);
+domain=expread(input);
 
 
Index: /issm/trunk/src/m/utils/Miscellaneous/issmdoc.m
===================================================================
--- /issm/trunk/src/m/utils/Miscellaneous/issmdoc.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Miscellaneous/issmdoc.m	(revision 12706)
@@ -9,7 +9,7 @@
 disp(sprintf('%s','	   md=model;                                %creates a new empty model structure'));
 disp(sprintf('%s','	   md=triangle(md,''DomainOutline.exp'',50000);   %creates a mesh of the domain outline with a resolution of 50000m'));
-disp(sprintf('%s','	   md=geography(md,''all'','''');               %defines the glacier system as an ice shelf (no island)'));
+disp(sprintf('%s','	   md=setmask(md,''all'','''');               %defines the glacier system as an ice shelf (no island)'));
 disp(sprintf('%s','	   md=parameterize(md,''Square.par'');        %fills all the other fields of the model'));
-disp(sprintf('%s','	   md=setelementstype(md,''macayeal'',''all''); %defines all elements as MacAyeal''s'));
+disp(sprintf('%s','	   md=setflowequation(md,''macayeal'',''all''); %defines all elements as MacAyeal''s'));
 disp(sprintf('%s','	   md=solve(md,DiagnosticSolutionEnum);   %generate the velocity field'));
 disp(sprintf('%s','	   plotmodel(md,''data'',md.results.DiagnosticSolution.Vel);    %displays the velocity (type plotdoc for plotmodel help)'));
Index: /issm/trunk/src/m/utils/Model/loadmodel.m
===================================================================
--- /issm/trunk/src/m/utils/Model/loadmodel.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Model/loadmodel.m	(revision 12706)
@@ -12,6 +12,12 @@
 	error('loadmodel usage error: md=loadmodel(path)');
 end
+
 %check existence
-if ~exist(path)
+if exist(path,'file')
+	%do nothing
+elseif exist([path '.mat'],'file')
+	%add extension
+	path = [path '.mat'];
+else
 	error(['loadmodel error message: file ' path ' does not exist']);
 end
Index: /issm/trunk/src/m/utils/Numerics/cfl_step.m
===================================================================
--- /issm/trunk/src/m/utils/Numerics/cfl_step.m	(revision 12705)
+++ /issm/trunk/src/m/utils/Numerics/cfl_step.m	(revision 12706)
@@ -8,5 +8,5 @@
 %
 %   Example:
-%      dt=cfl_step(md,md,md.results.DiagnosticSolution.Vx,md.results.DiagnosticSolution.Vy)
+%      dt=cfl_step(md,md.results.DiagnosticSolution.Vx,md.results.DiagnosticSolution.Vy)
 
 %Check length of velocities 
Index: /issm/trunk/src/m/utils/consistency/checkfield.m
===================================================================
--- /issm/trunk/src/m/utils/consistency/checkfield.m	(revision 12705)
+++ /issm/trunk/src/m/utils/consistency/checkfield.m	(revision 12706)
@@ -1,3 +1,3 @@
-function checkfield(md,fieldname,varargin)
+function md = checkfield(md,fieldname,varargin)
 %CHECKFIELD - check field consistency
 %
@@ -19,10 +19,10 @@
 %
 %   Usage:
-%      checkfield(md,fieldname,options);
+%      md = checkfield(md,fieldname,options);
 %
 %   Example:
-%      checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
-%      checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
-%      checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
+%      md = checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
+%      md = checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
+%      md = checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
 
 %get options
@@ -35,5 +35,5 @@
 if exist(options,'empty')
 	if isempty(field),
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' is empty']));
 	end
@@ -45,15 +45,15 @@
 	if isnan(fieldsize(1)),
 		if (size(field,2)~=fieldsize(2)),
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' should have ' num2str(fieldsize(2)) ' columns']));
 		end
 	elseif isnan(fieldsize(2)),
 		if (size(field,1)~=fieldsize(1)),
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' should have ' num2str(fieldsize(1)) ' lines']));
 		end
 	else
 		if ((size(field)~=fieldsize(1)) |  (size(field,2)~=fieldsize(2)))
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' size should be ' num2str(fieldsize(1)) ' x ' num2str(fieldsize(2))]));
 		end
@@ -66,11 +66,11 @@
 	if ~ismember(numel(field),fieldnumel),
 		if length(fieldnumel)==1
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' size should be ' sprintf('%g ',fieldnumel) ]));
 		elseif length(fieldnumel)==2
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' size should be ' num2str(fieldnumel(1)) ' or ' num2str(fieldnumel(2)) ]));
 		else
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' size should be ' sprintf('%g, ',fieldnumel(1:end-1)) ' or ' num2str(fieldnumel(end)) ]));
 		end
@@ -82,5 +82,5 @@
 	field2=reshape(field,prod(size(field)),1);
 	if any(isnan(field2)),
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['NaN values found in field ''' fieldname '''']));
 	end
@@ -90,5 +90,5 @@
 if getfieldvalue(options,'cell',0);
 	if ~iscell(field),
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' should be a cell']));
 	end
@@ -102,16 +102,16 @@
 		if any(~ismember(field,fieldvalues)),
 			if length(fieldvalues)==1
-				checkmessage(getfieldvalue(options,'message',...
+				md = checkmessage(md,getfieldvalue(options,'message',...
 					['field ''' fieldname ''' value should be ' fieldvalues{1} ]));
 			elseif length(fieldvalues)==2
-				checkmessage(getfieldvalue(options,'message',...
+				md = checkmessage(md,getfieldvalue(options,'message',...
 					['field ''' fieldname ''' values should be ' fieldvalues{1} ' or ' fieldvalues{2} ]));
 			else
-				checkmessage(getfieldvalue(options,'message',...
+				md = checkmessage(md,getfieldvalue(options,'message',...
 					['field ''' fieldname ''' should have values in ' sprintf('''%s'', ',fieldvalues{1:end-1}) 'or ''' fieldvalues{end} '''']));
 			end
 		end
 	else
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' should be one of the following strings: ' sprintf('''%s'', ',fieldvalues{1:end-1}) 'or ''' fieldvalues{end} '''']));
 	end
@@ -120,9 +120,9 @@
 	if isnumeric(field),
 		if any(~ismember(field2,fieldvalues)),
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' should have values in [' num2str(fieldvalues) ']']));
 		end
 	else
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' should be a number in [' num2str(fieldvalues) ']']));
 	end
@@ -135,5 +135,5 @@
 	field2=reshape(field,prod(size(field)),1);
 	if any(field2<lowerbound),
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' should have values above ' num2str(lowerbound)]));
 	end
@@ -143,5 +143,5 @@
 	field2=reshape(field,prod(size(field)),1);
 	if any(field2<=lowerbound),
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' should have values above ' num2str(lowerbound)]));
 	end
@@ -153,5 +153,5 @@
 	field2=reshape(field,prod(size(field)),1);
 	if any(field2>upperbound),
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' should have values below ' num2str(upperbound)]));
 	end
@@ -161,5 +161,5 @@
 	field2=reshape(field,prod(size(field)),1);
 	if any(field2>=upperbound),
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' should have values below ' num2str(upperbound(1))]));
 	end
@@ -169,5 +169,5 @@
 if getfieldvalue(options,'file',0),
 	if ~exist(field,'file')
-		checkmessage(['file profided in ''' fieldname ''': ''' field ''' does not exist']);
+		md = checkmessage(md,['file profided in ''' fieldname ''': ''' field ''' does not exist']);
 	end
 end
@@ -177,18 +177,18 @@
 	if size(field,1)==md.mesh.numberofvertices,
 		if ~size(field,2)==1,
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' should have only one column as there are md.mesh.numberofvertices lines']));
 		end
 	elseif size(field,1)==md.mesh.numberofvertices+1
 		if any(field(end,:)~=sort(field(end,:))),
-			checkmessage(getfieldvalue(options,'message',...
-				['field ''' fieldname ''' columns should be chronological']));
+			md = checkmessage(md,getfieldvalue(options,'message',...
+				['field ''' fieldname ''' columns should be sorted chronologically']));
 		end
 		if any(field(end,1:end-1)==field(end,2:end)),
-			checkmessage(getfieldvalue(options,'message',...
+			md = checkmessage(md,getfieldvalue(options,'message',...
 				['field ''' fieldname ''' columns must not contain duplicate timesteps']));
 		end
 	else
-		checkmessage(getfieldvalue(options,'message',...
+		md = checkmessage(md,getfieldvalue(options,'message',...
 			['field ''' fieldname ''' should have md.mesh.numberofvertices or md.mesh.numberofvertices+1 lines']));
 	end
Index: sm/trunk/src/m/utils/consistency/checkmessage.m
===================================================================
--- /issm/trunk/src/m/utils/consistency/checkmessage.m	(revision 12705)
+++ 	(revision )
@@ -1,10 +1,0 @@
-function checkmessage(string)
-%CHECKMESSAGE - checkmessage
-%
-%   Used to check model consistency
-%
-%   Usage:
-%      checkmessage(string);
-
-disp(['model not consistent: ' string]);
-modelconsistency(false);
Index: sm/trunk/src/m/utils/consistency/modelconsistency.m
===================================================================
--- /issm/trunk/src/m/utils/consistency/modelconsistency.m	(revision 12705)
+++ 	(revision )
@@ -1,23 +1,0 @@
-function flag=modelconsistency(flag_in)
-%MODELCONSISTENCY - return flag for model consistency
-%
-%   Used to check model consistency
-%
-%   Usage:
-%      flag=modelconsistency(flag_in)
-
-persistent consistency;
-
-if nargin==1 & nargout==0,
-	%OK model is inconsistent, set flag as false
-	consistency=flag_in;
-elseif nargin==0 & nargout==1,
-	if isempty(consistency),
-		%modelinconsistent has never been called, model is consistent
-		consistency=true;
-	end
-else
-	message('Bad usage');
-end
-
-flag=consistency;
Index: /issm/trunk/src/modules/AverageFilter/AverageFilter.cpp
===================================================================
--- /issm/trunk/src/modules/AverageFilter/AverageFilter.cpp	(revision 12705)
+++ /issm/trunk/src/modules/AverageFilter/AverageFilter.cpp	(revision 12706)
@@ -53,10 +53,10 @@
 void AverageFilterUsage(void)
 {
-	printf("   AverageFilter usage:\n");
-	printf("   [image_out]=AverageFilter(image_in,pixels);\n\n");
-	printf("   where:\n");
-	printf("      image_in in double format\n");
-	printf("      pixels: characteristic size of smoothing\n");
-	printf("      image_out in double format\n");
-	printf("\n");
+	_printLine_("   AverageFilter usage:");
+	_printLine_("   [image_out]=AverageFilter(image_in,pixels);\n");
+	_printLine_("   where:");
+	_printLine_("      image_in in double format");
+	_printLine_("      pixels: characteristic size of smoothing");
+	_printLine_("      image_out in double format");
+	_printLine_("");
 }
Index: /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.cpp
===================================================================
--- /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.cpp	(revision 12705)
+++ /issm/trunk/src/modules/BamgConvertMesh/BamgConvertMesh.cpp	(revision 12706)
@@ -4,25 +4,17 @@
 #include "./BamgConvertMesh.h"
 
-void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
 
 	/*input: */
-	double* index=NULL;
-	int     index_rows;
-	double* x=NULL;
-	int     x_cols;
-	double* y=NULL;
-	int     y_rows;
-	int     y_cols;
+	int    *index      = NULL;
+	double *x          = NULL;
+	double *y          = NULL;
+	int     nods,nels,test1,test2;
 
 	/*Output*/
-	BamgMesh* bamgmesh=NULL;
-	BamgGeom* bamggeom=NULL;
-	mxArray* bamgmesh_mat=NULL;
-	mxArray* bamggeom_mat=NULL;
-
-	/*Intermediary*/
-	int nods;
-	int nels;
-	int verbose=0;
+	BamgMesh *bamgmesh     = NULL;
+	BamgGeom *bamggeom     = NULL;
+	mxArray  *bamgmesh_mat = NULL;
+	mxArray  *bamggeom_mat = NULL;
 
 	/*Boot module: */
@@ -37,28 +29,15 @@
 
 	/*Input datasets: */
-	if (verbose) printf("Fetching inputs\n");
-	FetchData(&index,&nels,&index_rows,INDEXHANDLE);
-	FetchData(&x,&nods,&x_cols,XHANDLE);
-	FetchData(&y,&y_rows,&y_cols,YHANDLE);
+	FetchData(&index,&nels,&test1,INDEXHANDLE);
+	FetchData(&x,&nods,XHANDLE);
+	FetchData(&y,&test2,YHANDLE);
 
 	/*Check inputs*/
-	if (nels<0){
-		_error_("Number of elements must be positive, check index number of lines");
-	}
-	if (nods<0){
-		_error_("Number of nods must be positive, check x and y sizes");
-	}
-	if (index_rows!=3){
-		_error_("index should have 3 columns");
-	}
-	if (y_rows!=nods){
-		_error_("x and y do not have the same length");
-	}
-	if (x_cols>1 || y_cols>1){
-		_error_("x and y should have only one column");
-	}
+	if(nels<0) _error2_("Number of elements must be positive, check index number of lines");
+	if(nods<0) _error2_("Number of nods must be positive, check x and y sizes");
+	if(test1!=3) _error2_("index should have 3 columns");
+	if(test2!=nods) _error2_("x and y do not have the same length");
 
 	/* Run core computations: */
-	if (verbose) printf("Call core\n");
 	BamgConvertMeshx(bamgmesh,bamggeom,index,x,y,nods,nels);
 
@@ -75,12 +54,11 @@
 }
 
-void BamgConvertMeshUsage(void)
-{
-	_printf_(true,"BAMGCONVERTMESH - convert [x y index] to a bamg geom and mesh geom");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [bamggeom bamgmesh]=BamgConvertMesh(index,x,y);\n");
-	_printf_(true,"      index: index of the mesh\n");
-	_printf_(true,"      x,y: coordinates of the nodes\n");
-	_printf_(true,"\n");
+void BamgConvertMeshUsage(void){
+	_pprintString_("BAMGCONVERTMESH - convert [x y index] to a bamg geom and mesh geom");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [bamggeom bamgmesh]=BamgConvertMesh(index,x,y);");
+	_pprintLine_("      index: index of the mesh");
+	_pprintLine_("      x,y: coordinates of the nodes");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/BamgMesher/BamgMesher.cpp
===================================================================
--- /issm/trunk/src/modules/BamgMesher/BamgMesher.cpp	(revision 12705)
+++ /issm/trunk/src/modules/BamgMesher/BamgMesher.cpp	(revision 12706)
@@ -51,6 +51,6 @@
 
 void BamgMesherUsage(void){
-	_printf_(true,"\n");
-	_printf_(true,"   usage: [bamgmesh,bamggeom]=%s(bamgmesh,bamggeom,bamgoptions);\n",__FUNCT__);
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("   usage: [bamgmesh,bamggeom]=" << __FUNCT__ << "(bamgmesh,bamggeom,bamgoptions);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.cpp
===================================================================
--- /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.cpp	(revision 12705)
+++ /issm/trunk/src/modules/BamgTriangulate/BamgTriangulate.cpp	(revision 12706)
@@ -27,15 +27,15 @@
 
 	/*Input datasets: */
-	if (verbose) printf("Fetching inputs\n");
+	if (verbose) _printLine_("Fetching inputs");
 	FetchData(&x,&nods,&x_cols,XHANDLE);
 	FetchData(&y,&y_rows,&y_cols,YHANDLE);
 
 	/*Check inputs*/
-	if(y_rows!=nods)         _error_("x and y do not have the same length");
-	if(x_cols>1 || y_cols>1) _error_("x and y should have only one column");
-	if(nods<3)               _error_("At least 3 points are required");
+	if(y_rows!=nods)         _error2_("x and y do not have the same length");
+	if(x_cols>1 || y_cols>1) _error2_("x and y should have only one column");
+	if(nods<3)               _error2_("At least 3 points are required");
 
 	/* Run core computations: */
-	if (verbose) printf("Call core\n");
+	if (verbose) _printLine_("Call core");
 	BamgTriangulatex(&index,&nels,x,y,nods);
 
@@ -49,10 +49,10 @@
 void BamgTriangulateUsage(void)
 {
-	_printf_(true,"BAMGTRIANGULATE - Delaunay Triangulation of a list of points");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      index=BamgTriangulate(x,y);\n");
-	_printf_(true,"      index: index of the triangulation\n");
-	_printf_(true,"      x,y: coordinates of the nodes\n");
-	_printf_(true,"\n");
+	_pprintString_("BAMGTRIANGULATE - Delaunay Triangulation of a list of points");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      index=BamgTriangulate(x,y);");
+	_pprintLine_("      index: index of the triangulation");
+	_pprintLine_("      x,y: coordinates of the nodes");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/Chaco/Chaco.cpp
===================================================================
--- /issm/trunk/src/modules/Chaco/Chaco.cpp	(revision 12705)
+++ /issm/trunk/src/modules/Chaco/Chaco.cpp	(revision 12706)
@@ -42,5 +42,5 @@
 
 	#ifndef _HAVE_CHACO_ //only works if dakota library has been compiled in.
-	_error_(" Chaco not available! Cannot carry out Chaco partitioning!");
+	_error2_("Chaco not available! Cannot carry out Chaco partitioning!");
 	#endif
 
@@ -82,22 +82,22 @@
 	/*Some debugging print: {{{*/
 	#ifdef _DEBUG_
-	printf("nvtxs: %i\n",nvtxs);
-	printf("options: [");
-	for(i=0;i<10;i++)printf("%g|",options[i]);
-	printf("]\n");
-	printf("start: \n");
-	for (i=0; i<nvtxs+1;i++)printf("%i ",start[i]);
-	printf("\n");
-	printf("adjacency: \n");
-	for (i=0; i<mxGetNzmax(A_IN);i++)printf("%i ",adjacency[i]);
-	printf("\n");
-	printf("nedges: %i %p\n",nedges,ewgts);
-	if(ewgts) for (i = 0; i < nedges; i++)printf("%g ",ewgts[i]);
-	printf("\n");
-	printf("vwgts:\n");
-	for (i = 0; i < nvtxs; i++)printf("%g ",vwgts[i]);
-	printf("\n");
-	printf("nparts: %i\n",nparts[0]);
-	printf("goal: %p\n",goal);
+	_printLine_("nvtxs: " << nvtxs);
+	_printString_("options: [");
+	for(i=0;i<10;i++)_printString_(options[i] << "|");
+	_printLine_("]");
+	_printLine_("start: ");
+	for (i=0; i<nvtxs+1;i++)_printString_(start[i] << " ");
+	_printLine_("");
+	_printLine_("adjacency: ");
+	for (i=0; i<mxGetNzmax(A_IN);i++)_printString_("" <<adjacency[i]<< " ");i++)
+	_printLine_("");
+	_printLine_("nedges: " << nedges << " " << ewgts);
+	if(ewgts) for (i = 0; i < nedges; i++)_printString_(ewgts[i] << " ");
+	_printLine_("");
+	_printLine_("vwgts:");
+	for (i = 0; i < nvtxs; i++)_printString_(vwgts[i] << " ");
+	_printLine_("");
+	_printLine_("nparts: " << nparts[0]);
+	_printLine_("goal: " << goal);
 	#endif
 	/*}}}*/
@@ -132,6 +132,6 @@
 
 void ChacoUsage(void){
-	_printf_(true,"\n");
-	_printf_(true,"Usage: [assgn] = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);\n");
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("Usage: [assgn] = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/trunk/src/modules/ContourToMesh/ContourToMesh.cpp	(revision 12705)
+++ /issm/trunk/src/modules/ContourToMesh/ContourToMesh.cpp	(revision 12706)
@@ -47,5 +47,5 @@
 	if(nlhs!=1 && nlhs!=2){
 		ContourToMeshUsage();
-		_error_(" usage. See above");
+		_error2_("usage. See above");
 	}
 	#endif
@@ -53,5 +53,5 @@
 	if(nrhs!=NRHS){
 		ContourToMeshUsage();
-		_error_(" usage. See above");
+		_error2_("usage. See above");
 	}
 
@@ -82,5 +82,5 @@
 		WriteData(PLHS1,in_elem);
 	}
-	else _error_(" wrong interpolation type");
+	else _error2_("wrong interpolation type");
 
 	/*end module: */
@@ -91,23 +91,23 @@
 void ContourToMeshUsage(void)//{{{1
 {
-	printf("CONTOURTOMESH - Flag the elements or nodes inside a contour\n");
-	printf("\n");
-	printf("      Usage: \n");
-	printf("         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n\n");
-	printf("\n");
-	printf("         index,x,y: mesh triangulation.\n");
-	printf("         contourname: name of .exp file containing the contours.\n");
-	printf("         interptype: string definining type of interpolation ('element', or 'node').\n");
-	printf("         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
-	printf("         in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node', \n");
-	printf("            or of size 0 otherwise.\n");
-	printf("         in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', \n");
-	printf("            or of size 0 otherwise.\n");
-	printf("\n");
-	printf("      Example: \n");
-	printf("         in_nod=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','node',1)\n");
-	printf("         in_elements=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element',0)\n");
-	printf("         [in_nodes,in_elements]=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element and node',0)\n");
-	printf("\n");
+	_printLine_("CONTOURTOMESH - Flag the elements or nodes inside a contour");
+	_printLine_("");
+	_printLine_("      Usage: ");
+	_printLine_("         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n");
+	_printLine_("");
+	_printLine_("         index,x,y: mesh triangulation.");
+	_printLine_("         contourname: name of .exp file containing the contours.");
+	_printLine_("         interptype: string definining type of interpolation ('element', or 'node').");
+	_printLine_("         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.");
+	_printLine_("         in_nod: vector of flags (0 or 1), of size nods if interptype is set to 'node' or 'element and node', ");
+	_printLine_("            or of size 0 otherwise.");
+	_printLine_("         in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', ");
+	_printLine_("            or of size 0 otherwise.");
+	_printLine_("");
+	_printLine_("      Example: ");
+	_printLine_("         in_nod=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','node',1)");
+	_printLine_("         in_elements=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element',0)");
+	_printLine_("         [in_nodes,in_elements]=ContourToMesh(md.elements,md.x,md.y,'Contour.exp','element and node',0)");
+	_printLine_("");
 }
 //}}}
Index: /issm/trunk/src/modules/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/trunk/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 12705)
+++ /issm/trunk/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 12706)
@@ -82,9 +82,9 @@
 	/* Debugging of contours :{{{1*/
 	/*for(i=0;i<numcontours;i++){
-		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		_printLine_("\nContour echo: contour number  " << i+1 << " / " << numcontours);
 		contouri=*(contours+i);
-		printf("   Number of nodes %i\n",contouri->nods);
+		_printLine_("   Number of nodes " << contouri->nods);
 		for (j=0;j<contouri->nods;j++){
-			printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+			_printLine_("   " << *(contouri->x+j) << "f " << *(contouri->y+j) << "f");
 		}
 	}*/
@@ -103,12 +103,12 @@
 
 void ContourToNodesUsage(void){
-	printf("   usage:\n");
-	printf("   [flags]=ContourToNodes(x,y,contourname,edgevalue);\n\n");
-	printf("   where:\n");
-	printf("      x,y: list of nodes.\n");
-	printf("      contourname: name of .exp file containing the contours, or resulting structure from call to expread.\n");
-	printf("      interptype: string definining type of interpolation ('element', or 'node').\n");
-	printf("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
-	printf("      flags: vector of flags (0 or 1), of size nods.\n");
-	printf("\n");
+	_printLine_("   usage:");
+	_printLine_("   [flags]=ContourToNodes(x,y,contourname,edgevalue);\n");
+	_printLine_("   where:");
+	_printLine_("      x,y: list of nodes.");
+	_printLine_("      contourname: name of .exp file containing the contours, or resulting structure from call to expread.");
+	_printLine_("      interptype: string definining type of interpolation ('element', or 'node').");
+	_printLine_("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.");
+	_printLine_("      flags: vector of flags (0 or 1), of size nods.");
+	_printLine_("");
 }
Index: /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.cpp
===================================================================
--- /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.cpp	(revision 12705)
+++ /issm/trunk/src/modules/ElementConnectivity/ElementConnectivity.cpp	(revision 12706)
@@ -37,6 +37,6 @@
 
 void ElementConnectivityUsage(void) {
-	_printf_(true,"\n");
-	_printf_(true,"   usage: elementconnectivity = %s(elements, nodeconnectivity);\n",__FUNCT__);
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("   usage: elementconnectivity = " << __FUNCT__ << "(elements, nodeconnectivity);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/EnumToString/EnumToString.cpp
===================================================================
--- /issm/trunk/src/modules/EnumToString/EnumToString.cpp	(revision 12705)
+++ /issm/trunk/src/modules/EnumToString/EnumToString.cpp	(revision 12706)
@@ -12,5 +12,5 @@
 	/*checks on arguments on the matlab side: */
 	if(nrhs!=NRHS){
-		EnumToStringUsage(); _error_(" usage. See above");
+		EnumToStringUsage(); _error2_("usage. See above");
 	}
 
@@ -27,6 +27,6 @@
 void EnumToStringUsage(void)
 {
-	_printf_(true,"\n");
-	_printf_(true,"   usage: %sstring = EnumToString(enum);\n",__FUNCT__);
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("   usage: " << __FUNCT__ << "string = EnumToString(enum);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/Exp2Kml/Exp2Kml.cpp
===================================================================
--- /issm/trunk/src/modules/Exp2Kml/Exp2Kml.cpp	(revision 12705)
+++ /issm/trunk/src/modules/Exp2Kml/Exp2Kml.cpp	(revision 12706)
@@ -25,8 +25,8 @@
 	/*checks on arguments on the matlab side: */
 	if (nlhs > NLHS) {
-		Exp2KmlUsage(); _error_("Exp2Kml usage error");
+		Exp2KmlUsage(); _error2_("Exp2Kml usage error");
 	}
 	if (nrhs < NRHS) {
-		Exp2KmlUsage(); _error_("Exp2Kml usage error");
+		Exp2KmlUsage(); _error2_("Exp2Kml usage error");
 	}
 
@@ -43,13 +43,13 @@
 	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
 		options->Get(&cm,"central_meridian");
-		if (verbose) printf("  cm=%g\n",cm);
+		if (verbose) _printLine_("  cm=" << cm);
 		options->Get(&sp,"standard_parallel");
-		if (verbose) printf("  sp=%g\n",sp);
+		if (verbose) _printLine_("  sp=" << sp);
 	}
 
 	/*some checks*/
-	if (sgn !=+1 && sgn !=-1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
-	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
-	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+	if (sgn !=+1 && sgn !=-1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
+	if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
+	if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
 
 	/* Run core computations: */
@@ -73,26 +73,26 @@
 
 void Exp2KmlUsage(void){
-	_printf_(true,"Exp2Kml - exp to kml file conversion module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module converts a file from exp to kml format.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [ret]=Exp2Kml(filexp,filkml,sgn,'param name',param,...);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      filexp      file name of exp file to be read (char)\n");
-	_printf_(true,"      filkml      file name of kml file to be written (char)\n");
-	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
-	_printf_(true,"\n");
-	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
-	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
-	_printf_(true,"      holes       flag for treatment of multiple profiles (char, optional, 'yes' for holes))\n");
-	_printf_(true,"\n");
-	_printf_(true,"      ret         return code (non-zero for warning)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Examples:\n");
-	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml', 1);\n");
-	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');\n");
-	_printf_(true,"      [ret]=Exp2Kml('file.exp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');\n");
-	_printf_(true,"\n");
+	_pprintLine_("Exp2Kml - exp to kml file conversion module:");
+	_pprintLine_("");
+	_pprintLine_("   This module converts a file from exp to kml format.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [ret]=Exp2Kml(filexp,filkml,sgn,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      filexp      file name of exp file to be read (char)");
+	_pprintLine_("      filkml      file name of kml file to be written (char)");
+	_pprintLine_("      sgn         sign for hemisphere (double, +1 (north) or -1 (south))");
+	_pprintLine_("");
+	_pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
+	_pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
+	_pprintLine_("      holes       flag for treatment of multiple profiles (char, optional, 'yes' for holes))");
+	_pprintLine_("");
+	_pprintLine_("      ret         return code (non-zero for warning)");
+	_pprintLine_("");
+	_pprintLine_("   Examples:");
+	_pprintLine_("      [ret]=Exp2Kml('file.exp','file.kml', 1);");
+	_pprintLine_("      [ret]=Exp2Kml('file.exp','file.kml', 1,'central_meridian',45,'standard_parallel',70,'holes','yes');");
+	_pprintLine_("      [ret]=Exp2Kml('file.exp','file.kml',-1,'central_meridian', 0,'standard_parallel',71,'holes','yes');");
+	_pprintLine_("");
 }
 
Index: /issm/trunk/src/modules/HoleFiller/HoleFiller.cpp
===================================================================
--- /issm/trunk/src/modules/HoleFiller/HoleFiller.cpp	(revision 12705)
+++ /issm/trunk/src/modules/HoleFiller/HoleFiller.cpp	(revision 12706)
@@ -60,10 +60,10 @@
 void HoleFillerUsage(void)
 {
-	printf("   HoleFiller usage:\n");
-	printf("   [image_out]=HoleFiller(image_in,smooth);\n\n");
-	printf("   where:\n");
-	printf("      image_in in double format\n");
-	printf("      smooth: 1 to smooth with a box filer, 0 to leave data raw\n");
-	printf("      image_out in double format\n");
-	printf("\n");
+	_printLine_("   HoleFiller usage:");
+	_printLine_("   [image_out]=HoleFiller(image_in,smooth);\n");
+	_printLine_("   where:");
+	_printLine_("      image_in in double format");
+	_printLine_("      smooth: 1 to smooth with a box filer, 0 to leave data raw");
+	_printLine_("      image_out in double format");
+	_printLine_("");
 }
Index: /issm/trunk/src/modules/InternalFront/InternalFront.cpp
===================================================================
--- /issm/trunk/src/modules/InternalFront/InternalFront.cpp	(revision 12705)
+++ /issm/trunk/src/modules/InternalFront/InternalFront.cpp	(revision 12706)
@@ -26,11 +26,11 @@
 	/*Fetch required fields*/
 	FetchData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
-	if(numberofelements<=0) _error_("No elements found in the model");
+	if(numberofelements<=0) _error2_("No elements found in the model");
 	FetchData(&elements,&M,&N,mxGetAssignedField(MODEL,0,"elements"));
-	if(M!=numberofelements || N!=3) _error_("Field 'elements' should be of size [md.numberofelements 3]");
+	if(M!=numberofelements || N!=3) _error2_("Field 'elements' should be of size [md.numberofelements 3]");
 	FetchData(&elementonwater,&M,&N,mxGetAssignedField(MODEL,0,"elementonwater"));
-	if(M!=numberofelements || N!=1) _error_("Field 'elementonwater' should be of size [md.numberofelements 1]");
+	if(M!=numberofelements || N!=1) _error2_("Field 'elementonwater' should be of size [md.numberofelements 1]");
 	FetchData(&elementconnectivity,&M,&N,mxGetAssignedField(MODEL,0,"elementconnectivity"));
-	if(M!=numberofelements || N!=3) _error_("Field 'elementconnectivity' should be of size [md.numberofelements 3]");
+	if(M!=numberofelements || N!=3) _error2_("Field 'elementconnectivity' should be of size [md.numberofelements 3]");
 
 	/*Allocate and initialize all variables*/
@@ -94,6 +94,6 @@
 
 void InternalFrontUsage(void) {
-	_printf_(true,"\n");
-	_printf_(true,"   usage: icefront = %s(md);\n",__FUNCT__);
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("   usage: icefront = " << __FUNCT__ << "(md);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 12705)
+++ /issm/trunk/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp	(revision 12706)
@@ -46,5 +46,5 @@
 	if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=7)){
 		InterpFromGridToMeshUsage();
-		_error_(" usage. See above");
+		_error2_("usage. See above");
 	}
 
@@ -75,21 +75,21 @@
 void InterpFromGridToMeshUsage(void)
 {
-	_printf_(true,"INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
-	_printf_(true,"   defined on a grid onto a list of points\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh.\n");
-	_printf_(true,"      x,y: coordinates of matrix data. (x and y must be in increasing order)\n");
-	_printf_(true,"      x_mesh,y_mesh: coordinates of the points onto which we interpolate.\n");
-	_printf_(true,"      default_value: default value if no data is found (holes).\n");
-	_printf_(true,"      data_mesh: vector of mesh interpolated data.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Example:\n");
-	_printf_(true,"      load('velocities.mat');\n");
-	_printf_(true,"      md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);\n");
-	_printf_(true,"\n");
+	_pprintLine_("INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points");
+	_pprintLine_("");
+	_pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
+	_pprintLine_("   defined on a grid onto a list of points");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);");
+	_pprintLine_("");
+	_pprintLine_("      data: matrix holding the data to be interpolated onto the mesh.");
+	_pprintLine_("      x,y: coordinates of matrix data. (x and y must be in increasing order)");
+	_pprintLine_("      x_mesh,y_mesh: coordinates of the points onto which we interpolate.");
+	_pprintLine_("      default_value: default value if no data is found (holes).");
+	_pprintLine_("      data_mesh: vector of mesh interpolated data.");
+	_pprintLine_("");
+	_pprintLine_("   Example:");
+	_pprintLine_("      load('velocities.mat');");
+	_pprintLine_("      md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 12705)
+++ /issm/trunk/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 12706)
@@ -69,9 +69,9 @@
 	if(nlhs!=NLHS){
 		InterpFromMesh2dUsage();
-		_error_("InterpFromMeshToMesh2dUsage usage error");
+		_error2_("InterpFromMeshToMesh2dUsage usage error");
 	}
 	if((nrhs!=6) && (nrhs!=7) && (nrhs!=8)){
 		InterpFromMesh2dUsage();
-		_error_("InterpFromMeshToMesh2dUsage usage error");
+		_error2_("InterpFromMeshToMesh2dUsage usage error");
 	}
 
@@ -114,9 +114,9 @@
 		/* Debugging of contours :{{{1*/
 		/*for(i=0;i<numcontours;i++){
-		  printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		  _printLine_("\nContour echo: contour number  " << i+1 << " / " << numcontours);
 		  contouri=*(contours+i);
-		  printf("   Number of vertices %i\n",contouri->nods);
+		  _printLine_("   Number of vertices " << contouri->nods);
 		  for (j=0;j<contouri->nods;j++){
-		  printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+		  _printLine_("   " << *(contouri->x+j) << "f " << *(contouri->y+j) << "f");
 		  }
 		  }*/
@@ -131,8 +131,8 @@
 	/*some checks*/
 	if (x_data_rows!=y_data_rows){
-		_error_("vectors x and y should have the same length!");
+		_error2_("vectors x and y should have the same length!");
 	}
 	if (x_prime_rows!=y_prime_rows){
-		_error_("vectors x_prime and y_prime should have the same length!");
+		_error2_("vectors x_prime and y_prime should have the same length!");
 	}
 	
@@ -154,16 +154,16 @@
 void InterpFromMesh2dUsage(void)
 {
-	_printf_(true,"   usage:\n");
-	_printf_(true,"         data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime);\n\n");
-	_printf_(true,"      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value);\n\n");
-	_printf_(true,"      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value,contourname);\n\n");
-	_printf_(true,"   where:\n");
-	_printf_(true,"      x,y: coordinates of the nodes where data is defined\n");
-	_printf_(true,"      index: index of the mesh where data is defined\n");
-	_printf_(true,"      data - vector holding the data to be interpolated onto the points.\n");
-	_printf_(true,"      x_prime,y_prime: coordinates of the mesh vertices onto which we interpolate.\n");
-	_printf_(true,"      default_value: a scalar or vector of size length(x_prime).\n");
-	_printf_(true,"      contourname: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.\n");
-	_printf_(true,"      data_prime:  vector of prime interpolated data.\n");
-	_printf_(true,"\n");
+	_pprintLine_("   usage:");
+	_pprintLine_("         data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime);\n");
+	_pprintLine_("      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value);\n");
+	_pprintLine_("      or data_prime=InterpFromMesh2d(index,x,y,data,x_prime,y_prime,default_value,contourname);\n");
+	_pprintLine_("   where:");
+	_pprintLine_("      x,y: coordinates of the nodes where data is defined");
+	_pprintLine_("      index: index of the mesh where data is defined");
+	_pprintLine_("      data - vector holding the data to be interpolated onto the points.");
+	_pprintLine_("      x_prime,y_prime: coordinates of the mesh vertices onto which we interpolate.");
+	_pprintLine_("      default_value: a scalar or vector of size length(x_prime).");
+	_pprintLine_("      contourname: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.");
+	_pprintLine_("      data_prime:  vector of prime interpolated data.");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp	(revision 12705)
+++ /issm/trunk/src/modules/InterpFromMeshToGrid/InterpFromMeshToGrid.cpp	(revision 12706)
@@ -64,16 +64,16 @@
 void InterpFromMeshToGridUsage(void)
 {
-	_printf_(true,"INTERPFROMMESHTOGRID - interpolation of a data defined on a mesh onto a grid\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
-	_printf_(true,"   defined on a triangular mesh onto a regular grid\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [x_m,y_m,griddata]=InterpFromMeshToGrid(index,x,y,data,xmin,ymax,xposting,yposting,nlines,ncols,default_value)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      index,x,y: delaunay triangulation defining the mesh.\n");
-	_printf_(true,"      meshdata: vertex values of data to be interpolated.\n");
-	_printf_(true,"      xmin,ymax,posting,nlines,ncols: parameters that define the grid\n");
-	_printf_(true,"      default_value: value of points located out of the mesh.\n");
-	_printf_(true,"\n");
+	_pprintLine_("INTERPFROMMESHTOGRID - interpolation of a data defined on a mesh onto a grid");
+	_pprintLine_("");
+	_pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
+	_pprintLine_("   defined on a triangular mesh onto a regular grid");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [x_m,y_m,griddata]=InterpFromMeshToGrid(index,x,y,data,xmin,ymax,xposting,yposting,nlines,ncols,default_value)");
+	_pprintLine_("");
+	_pprintLine_("      index,x,y: delaunay triangulation defining the mesh.");
+	_pprintLine_("      meshdata: vertex values of data to be interpolated.");
+	_pprintLine_("      xmin,ymax,posting,nlines,ncols: parameters that define the grid");
+	_pprintLine_("      default_value: value of points located out of the mesh.");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12705)
+++ /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12706)
@@ -7,28 +7,17 @@
 WRAPPER(InterpFromMeshToMesh2d){
 
-	/*input: */
-	double* index=NULL;
-	int     index_cols;
-	double* x_data=NULL;
-	int     x_data_rows;
-	double* y_data=NULL;
-	int     y_data_rows;
-	double* data=NULL; 
-	int     data_rows;
-	int     data_cols;
-	double* x_interp=NULL;
-	int     x_interp_rows;
-	double* y_interp=NULL;
-	int     y_interp_rows;
-	char*   contourname=NULL;
-	double* default_values=NULL;
-	int     num_default_values=0;
-	DataSet *contours = NULL;
-
-	/*Intermediary*/
-	int nels_data;
-
-	/* output: */
-	double* data_interp=NULL;
+	/*Intermediaties*/
+	int     *index              = NULL;
+	double  *x_data             = NULL;
+	double  *y_data             = NULL;
+	double  *data               = NULL;
+	int      nods_data,nels_data;
+	int      M_data,N_data;
+	double  *x_interp           = NULL;
+	double  *y_interp           = NULL;
+	int      N_interp;
+	Options *options   = NULL;
+	double  *data_interp = NULL;
+	int      test1,test2,test;
 
 	/*Boot module: */
@@ -39,50 +28,27 @@
 	if(nlhs!=NLHS){
 		InterpFromMeshToMesh2dUsage();
-		_error_("InterpFromMeshToMesh2dUsage usage error");
+		_error2_("InterpFromMeshToMesh2dUsage usage error");
 	}
 	#endif
 	/*check on input arguments: */
-	if((nrhs!=6) & (nrhs!=8)){
+	if(nrhs<NRHS){
 		InterpFromMeshToMesh2dUsage();
-		_error_("InterpFromMeshToMesh2dUsage usage error");
+		_error2_("InterpFromMeshToMesh2dUsage usage error");
 	}
 
-	/*Input datasets: */
-	FetchData(&index,&nels_data,&index_cols,INDEX);
-	FetchData(&x_data,&x_data_rows,NULL,X);
-	FetchData(&y_data,&y_data_rows,NULL,Y);
-	FetchData(&data,&data_rows,&data_cols,DATA);
-	FetchData(&x_interp,&x_interp_rows,XINTERP);
-	FetchData(&y_interp,&y_interp_rows,YINTERP);
+	/*Fetch inputs: */
+	FetchData(&index,&nels_data,&test,INDEX); if(test!=3) _error2_("index should have 3 columns");
+	FetchData(&x_data,&nods_data,X);          if(nods_data<3) _error2_("there should be at least three points");
+	FetchData(&y_data,&test,Y);               if(test!=nods_data) _error2_("vectors x and y should have the same length");
+	FetchData(&data,&M_data,&N_data,DATA);    if(M_data*N_data<1) _error2_("data is empty");
+	FetchData(&x_interp,&N_interp,XINTERP);   if(N_interp<1) _error2_("no interpolation requested");
+	FetchData(&y_interp,&test,YINTERP);       if(test!=N_interp) _error2_("vectors x_interp and y_interp should have the same length");
+	FetchData(&options,NRHS,nrhs,prhs);
 
-	/*Figure out contours and default values: */
-	if(nrhs==8){
-		FetchData(&default_values,&num_default_values,DEFAULT);
-		FetchData(&contourname,CONTOURNAME);
-		contours=DomainOutlineRead(contourname);
-	}
-	else{
-		num_default_values=0;
-		default_values=NULL;
-		contours=new DataSet();
-	}
-
-
-	/*some checks*/
-	if (x_data_rows!=y_data_rows){
-		_error_("vectors x and y should have the same length!");
-	}
-	if (x_interp_rows!=y_interp_rows){
-		_error_("vectors x_interp and y_interp should have the same length!");
-	}
-	if (index_cols!=3){
-		_error_("index should have 3 columns (input provided has %i columns)",index_cols);
-	}
-
-	/* Run core computations: */
-	InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,x_data_rows,nels_data,data,data_rows,data_cols,x_interp,y_interp,x_interp_rows,default_values,num_default_values,contours);
+	/*Run core computations*/
+	InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,nods_data,nels_data,data,M_data,N_data,x_interp,y_interp,N_interp,options);
 
 	/*Write data: */
-	WriteData(DATAINTERP,data_interp,x_interp_rows,data_cols);
+	WriteData(DATAINTERP,data_interp,N_interp,N_data);
 
 	/*end module: */
@@ -90,30 +56,27 @@
 }
 
-void InterpFromMeshToMesh2dUsage(void)//{{{1
-
-{
-	_printf_(true,"INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
-	_printf_(true,"   defined on a triangular mesh onto a list of point\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"         data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);\n");
-	_printf_(true,"      or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,default_value,contourname);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      index: index of the mesh where data is defined\n");
-	_printf_(true,"      x,y: coordinates of the nodes where data is defined\n");
-	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh. (one column per field)\n");
-	_printf_(true,"      x_interp,y_interp: coordinates of the points onto which we interpolate.\n");
-	_printf_(true,"      if default_value and contourname not specified: linear interpolation will happen on all x_interp,y_interp.\n");
-	_printf_(true,"      if (default_value,contourname) specified: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh.\n");
-	_printf_(true,"      note that default_value is either a scalar, or a vector of size  length(x_interp)\n");
-	_printf_(true,"      data_interp: vector of mesh interpolated data.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Example:\n");
-	_printf_(true,"      load('temperature.mat');\n");
-	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);\n");
-	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,253,'Contour.exp');\n");
-	_printf_(true,"\n");
+void InterpFromMeshToMesh2dUsage(void){ /*{{{*/
+	_pprintLine_("INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point");
+	_pprintLine_("");
+	_pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
+	_pprintLine_("   defined on a Delaunay triangulation onto a list of point");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("         data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);");
+	_pprintLine_("      or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,OPTIONS);");
+	_pprintLine_("");
+	_pprintLine_("      index             : index of the mesh where data is defined");
+	_pprintLine_("      x,y               : coordinates of the nodes where data is defined");
+	_pprintLine_("      data              : matrix holding the data to be interpolated onto the mesh. (one column per field)");
+	_pprintLine_("      x_interp,y_interp : coordinates of the points onto which we interpolate.");
+	_pprintLine_("      data_interp       : vector of mesh interpolated data.");
+	_pprintLine_("      Available options :");
+	_pprintLine_("         - 'default' : default value if point is outsite of triangulation (instead of linear interolation)");
+	_pprintLine_("");
+	_pprintLine_("   Example:");
+	_pprintLine_("      load('temperature.mat');");
+	_pprintLine_("      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);");
+	_pprintLine_("      md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,'default',253);");
+	_pprintLine_("");
 }
-//}}}
+/*}}}*/
Index: /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h	(revision 12705)
+++ /issm/trunk/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h	(revision 12706)
@@ -12,5 +12,8 @@
 #endif
 
-/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+/* local prototypes: */
+void InterpFromMeshToMesh2dUsage(void);
+
+/*If python: this macro needs to come before header files inclusion*/
 #ifdef _HAVE_PYTHON_
 #define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
@@ -28,4 +31,7 @@
 #include "../../c/EnumDefinitions/EnumDefinitions.h"
 
+#undef __FUNCT__ 
+#define __FUNCT__  "InterpFromMeshToMesh2d"
+
 #ifdef _HAVE_MATLAB_MODULES_
 /* serial input macros: */
@@ -36,6 +42,4 @@
 #define XINTERP prhs[4]
 #define YINTERP prhs[5]
-#define DEFAULT prhs[6]
-#define CONTOURNAME prhs[7]
 
 /* serial output macros: */
@@ -51,12 +55,8 @@
 #define XINTERP PyTuple_GetItem(args,4)
 #define YINTERP PyTuple_GetItem(args,5)
-#define DEFAULT PyTuple_GetItem(args,6)
-#define CONTOURNAME PyTuple_GetItem(args,7)
+
 /* serial output macros: */
 #define DATAINTERP output,0
 #endif
-
-#undef __FUNCT__ 
-#define __FUNCT__  "InterpFromMeshToMesh2d"
 
 /* serial arg counts: */
@@ -64,8 +64,5 @@
 #define NLHS  1
 #undef NRHS
-#define NRHS  6 //can be 8 though
-
-/* local prototypes: */
-void InterpFromMeshToMesh2dUsage(void);
+#define NRHS  6
 
 #endif
Index: /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp
===================================================================
--- /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 12705)
+++ /issm/trunk/src/modules/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.cpp	(revision 12706)
@@ -76,8 +76,8 @@
 	/*some checks*/
 	if (x_data_rows!=y_data_rows || x_data_rows!=z_data_rows){
-		_error_("vectors x, y and z should have the same length!");
+		_error2_("vectors x, y and z should have the same length!");
 	}
 	if (x_prime_rows!=y_prime_rows || x_prime_rows!=z_prime_rows){
-		_error_("vectors x_prime, y_prime and z_prime should have the same length!");
+		_error2_("vectors x_prime, y_prime and z_prime should have the same length!");
 	}
 	/*get number of elements and number of nodes in the data*/
@@ -98,22 +98,22 @@
 void InterpFromMeshToMesh3dUsage(void)
 {
-	_printf_(true,"INTERPFROMMESHTOMESH3D - interpolation from a 3d hexahedron mesh onto a list of point\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This function is a multi-threaded mex file that interpolates a field\n");
-	_printf_(true,"   defined on a triangular mesh onto a list of point\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      data_prime=InterpFromMeshToMesh3d(index,x,y,z,data,x_prime,y_prime,z_prime,default_value);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      index: index of the mesh where data is defined\n");
-	_printf_(true,"      x,y,z: coordinates of the nodes where data is defined\n");
-	_printf_(true,"      data: matrix holding the data to be interpolated onto the mesh.\n");
-	_printf_(true,"      x_prime,y_prime,z_prime: coordinates of the points onto which we interpolate.\n");
-	_printf_(true,"      default_value: default value if no data is found (holes).\n");
-	_printf_(true,"      data_prime: vector of mesh interpolated data.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Example:\n");
-	_printf_(true,"      load('temperature.mat');\n");
-	_printf_(true,"      md.initialization.temperature=InterpFromMeshToMesh3d(index,x,y,z,temperature,md.mesh.x,md.mesh.y,md.mesh.z,253);\n");
-	_printf_(true,"\n");
+	_pprintLine_("INTERPFROMMESHTOMESH3D - interpolation from a 3d hexahedron mesh onto a list of point");
+	_pprintLine_("");
+	_pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
+	_pprintLine_("   defined on a triangular mesh onto a list of point");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      data_prime=InterpFromMeshToMesh3d(index,x,y,z,data,x_prime,y_prime,z_prime,default_value);");
+	_pprintLine_("");
+	_pprintLine_("      index: index of the mesh where data is defined");
+	_pprintLine_("      x,y,z: coordinates of the nodes where data is defined");
+	_pprintLine_("      data: matrix holding the data to be interpolated onto the mesh.");
+	_pprintLine_("      x_prime,y_prime,z_prime: coordinates of the points onto which we interpolate.");
+	_pprintLine_("      default_value: default value if no data is found (holes).");
+	_pprintLine_("      data_prime: vector of mesh interpolated data.");
+	_pprintLine_("");
+	_pprintLine_("   Example:");
+	_pprintLine_("      load('temperature.mat');");
+	_pprintLine_("      md.initialization.temperature=InterpFromMeshToMesh3d(index,x,y,z,temperature,md.mesh.x,md.mesh.y,md.mesh.z,253);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/KMLFileRead/KMLFileRead.cpp
===================================================================
--- /issm/trunk/src/modules/KMLFileRead/KMLFileRead.cpp	(revision 12705)
+++ /issm/trunk/src/modules/KMLFileRead/KMLFileRead.cpp	(revision 12706)
@@ -45,8 +45,8 @@
 	/*checks on arguments on the matlab side: */
 	if (nlhs > NLHS) {
-		KMLFileReadUsage(); _error_("KMLFileRead usage error");
+		KMLFileReadUsage(); _error2_("KMLFileRead usage error");
 	}
 	if (nrhs < NRHS) {
-		KMLFileReadUsage(); _error_("KMLFileRead usage error");
+		KMLFileReadUsage(); _error2_("KMLFileRead usage error");
 	}
 
@@ -63,12 +63,12 @@
 	if (!strlen(filnam)) strcpy(filnam,"stdout");
 
-	if (verbose) printf("Opening file \"%s\".\n",filnam);
+	if (verbose) _printLine_("Opening file \"" << filnam << "\".");
 	fidi=fopen(filnam,"r");
 
 	/* Run core computations: */
-	if (verbose) printf("Calling core:\n");
+	if (verbose) _printLine_("Calling core:");
 	kobj=KMLFileReadx(fidi);
 
-	if (verbose) printf("Closing file \"%s\".\n",filnam);
+	if (verbose) _printLine_("Closing file \"" << filnam << "\".");
 	fclose(fidi);
 
@@ -83,8 +83,8 @@
 			}
 			else {
-				if (verbose) printf("Opening file \"%s\".\n",write);
+				if (verbose) _printLine_("Opening file \"" << write << "\".");
 				fido=fopen(write,"w");
 				kobj->Write(fido,"");
-				if (verbose) printf("Closing file \"%s\".\n",write);
+				if (verbose) _printLine_("Closing file \"" << write << "\".");
 				ierror=fclose(fido);
 			}
@@ -107,23 +107,23 @@
 
 void KMLFileReadUsage(void){
-	_printf_(true,"KMLFileRead - KML file reader module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module reads a KML file.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [ierror]=KMLFileRead(kmlfile,'param name',param,...);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      kmlfile      file name of kml file to be read (char)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      echo         echo command (char, optional, 'off'/'on')\n");
-	_printf_(true,"      deepecho     deep echo command (char, optional, 'off'/'on')\n");
-	_printf_(true,"      write        write command (char, optional, 'off'/'stdout'/kmlfile)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      ierror       return code (non-zero for error)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Examples:\n");
-	_printf_(true,"      [ierror]=KMLFileRead('file.kml','deepecho','on');\n");
-	_printf_(true,"      [ierror]=KMLFileRead('filin.kml','echo','on','write','filout.kml');\n");
-	_printf_(true,"\n");
+	_pprintLine_("KMLFileRead - KML file reader module:");
+	_pprintLine_("");
+	_pprintLine_("   This module reads a KML file.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [ierror]=KMLFileRead(kmlfile,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      kmlfile      file name of kml file to be read (char)");
+	_pprintLine_("");
+	_pprintLine_("      echo         echo command (char, optional, 'off'/'on')");
+	_pprintLine_("      deepecho     deep echo command (char, optional, 'off'/'on')");
+	_pprintLine_("      write        write command (char, optional, 'off'/'stdout'/kmlfile)");
+	_pprintLine_("");
+	_pprintLine_("      ierror       return code (non-zero for error)");
+	_pprintLine_("");
+	_pprintLine_("   Examples:");
+	_pprintLine_("      [ierror]=KMLFileRead('file.kml','deepecho','on');");
+	_pprintLine_("      [ierror]=KMLFileRead('filin.kml','echo','on','write','filout.kml');");
+	_pprintLine_("");
 }
 
Index: /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.cpp
===================================================================
--- /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.cpp	(revision 12705)
+++ /issm/trunk/src/modules/KMLMeshWrite/KMLMeshWrite.cpp	(revision 12706)
@@ -40,8 +40,8 @@
 	/*checks on arguments on the matlab side: */
 	if (nlhs > NLHS) {
-		KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
+		KMLMeshWriteUsage(); _error2_("KMLMeshWrite usage error");
 	}
 	if (nrhs < NRHS) {
-		KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
+		KMLMeshWriteUsage(); _error2_("KMLMeshWrite usage error");
 	}
 
@@ -87,15 +87,15 @@
 
 	if (nodecon && (mncon != nnodes))
-		_error_("Nodal connectivity table, if supplied, must be supplied for all nodes.");
+	  {_error2_("Nodal connectivity table, if supplied, must be supplied for all nodes.");}
 	else if (!nodecon)
 		mncon=nnodes;
 	if ((llat != nnodes) || (llng != nnodes) || (llat != llng))
-		_error_("Latitude and longitude vectors must be supplied for all nodes.");
+		_error2_("Latitude and longitude vectors must be supplied for all nodes.");
 	if (part && (lprt != nnodes))
-		_error_("Partitioning vector, if supplied, must be supplied for all nodes.");
+		_error2_("Partitioning vector, if supplied, must be supplied for all nodes.");
 	if (data && !((mdata == nnodes) || (mdata == melem)))
-		_error_("Data matrix, if supplied, must be supplied for all nodes or all elements.");
+		_error2_("Data matrix, if supplied, must be supplied for all nodes or all elements.");
 	if (cmap && (ncmap != 3))
-		_error_("Colormap matrix, if supplied, must have three columns for rgb.");
+		_error2_("Colormap matrix, if supplied, must have three columns for rgb.");
 	if (!strlen(filnam))
 		strcpy(filnam,"stdout");
@@ -118,26 +118,26 @@
 
 void KMLMeshWriteUsage(void){
-	_printf_(true,"KMLMeshWrite - KML mesh writer module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module writes the mesh of a model as KML polygons into the specified KML file.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      ierror=KMLMeshWrite(name,notes,elem,nodecon,lat,long,part,data,cmap,kmlfile);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      name       model name (string, may be empty)\n");
-	_printf_(true,"      notes      model notes (string or cell array of strings, may be empty)\n");
-	_printf_(true,"      elem       elements (double array)\n");
-	_printf_(true,"      nodecon    nodal connectivity array (double array, may be empty)\n");
-	_printf_(true,"      lat        nodal latititudes (double vector)\n");
-	_printf_(true,"      long       nodal longitudes (double vector)\n");
-	_printf_(true,"      part       nodal partitions (double vector, may be empty)\n");
-	_printf_(true,"      data       nodal or element data (double vector, may be empty)\n");
-	_printf_(true,"      cmap       color map (double nx3 array, may be empty)\n");
-	_printf_(true,"      kmlfile    KML file name (string)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      ierror     error flag (double, non-zero for error)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Example:\n");
-	_printf_(true,"      KMLMeshWrite(md.name,md.notes,md.elements,md.nodeconnectivity,md.lat,md.long,md.part,md.fm_criterion,options.cmap,filekml);\n");
-	_printf_(true,"\n");
+	_pprintLine_("KMLMeshWrite - KML mesh writer module:");
+	_pprintLine_("");
+	_pprintLine_("   This module writes the mesh of a model as KML polygons into the specified KML file.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      ierror=KMLMeshWrite(name,notes,elem,nodecon,lat,long,part,data,cmap,kmlfile);");
+	_pprintLine_("");
+	_pprintLine_("      name       model name (string, may be empty)");
+	_pprintLine_("      notes      model notes (string or cell array of strings, may be empty)");
+	_pprintLine_("      elem       elements (double array)");
+	_pprintLine_("      nodecon    nodal connectivity array (double array, may be empty)");
+	_pprintLine_("      lat        nodal latititudes (double vector)");
+	_pprintLine_("      long       nodal longitudes (double vector)");
+	_pprintLine_("      part       nodal partitions (double vector, may be empty)");
+	_pprintLine_("      data       nodal or element data (double vector, may be empty)");
+	_pprintLine_("      cmap       color map (double nx3 array, may be empty)");
+	_pprintLine_("      kmlfile    KML file name (string)");
+	_pprintLine_("");
+	_pprintLine_("      ierror     error flag (double, non-zero for error)");
+	_pprintLine_("");
+	_pprintLine_("   Example:");
+	_pprintLine_("      KMLMeshWrite(md.name,md.notes,md.elements,md.nodeconnectivity,md.lat,md.long,md.part,md.fm_criterion,options.cmap,filekml);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/KMLOverlay/KMLOverlay.cpp
===================================================================
--- /issm/trunk/src/modules/KMLOverlay/KMLOverlay.cpp	(revision 12705)
+++ /issm/trunk/src/modules/KMLOverlay/KMLOverlay.cpp	(revision 12706)
@@ -31,8 +31,8 @@
 	/*checks on arguments on the matlab side: */
 	if(nlhs>NLHS){
-		KMLOverlayUsage(); _error_("KMLOverlay usage error");
+		KMLOverlayUsage(); _error2_("KMLOverlay usage error");
 	}
 	if(nrhs<NRHS){
-		KMLOverlayUsage(); _error_("KMLOverlay usage error");
+		KMLOverlayUsage(); _error2_("KMLOverlay usage error");
 	}
 
@@ -42,16 +42,16 @@
 
 	options->Get(&lataxis ,&nlat ,"lataxis" );
-	if (verbose && lataxis) for (i=0; i<nlat; i++) printf("  lataxis [%d]=%g\n",i,lataxis[i]);
+	if (verbose && lataxis) for (i=0; i<nlat; i++) _printLine_("  lataxis [" << i << "]=" << lataxis[i]);
 	options->Get(&longaxis,&nlong,"longaxis");
-	if (verbose && longaxis) for (i=0; i<nlong; i++) printf("  longaxis[%d]=%g\n",i,longaxis[i]);
+	if (verbose && longaxis) for (i=0; i<nlong; i++) _printLine_("  longaxis[" << i << "]=" << longaxis[i]);
 	options->Get(&pimages,&nimages,"images");
-	if (verbose && pimages) for (i=0; i<nimages; i++) printf("  pimages[%d]=\"%s\"\n",i,pimages[i]);
+	if (verbose && pimages) for (i=0; i<nimages; i++) _printLine_("  pimages[" << i << "]=\"" << pimages[i] << "\"");
 	options->Get(&dzip,"zip",0.);
-	if (verbose) printf("  dzip=%g\n",dzip);
+	if (verbose) _printLine_("  dzip=" << dzip);
 
 	/*some checks*/
-	if (nlat !=2) _error_("Latitudinal axes \"lataxis\" require two double values, not %d.",nlat);
-	if (nlong!=2) _error_("Longitudinal axes \"longaxis\" require two double values, not %d.",nlong);
-	if (!nimages) _error_("No image files provided.");
+	if (nlat !=2) _error2_("Latitudinal axes \"lataxis\" require two double values, not " << nlat << ".");
+	if (nlong!=2) _error2_("Longitudinal axes \"longaxis\" require two double values, not " << nlong << ".");
+	if (!nimages) _error2_("No image files provided.");
 
 	if ((int)dzip){
@@ -63,12 +63,12 @@
 	if(!strlen(filkml)) strcpy(filkml,"stdout");
 
-	if(verbose) printf("Opening kml overlay file \"%s\".\n",filkml);
+	if(verbose) _printLine_("Opening kml overlay file \"" << filkml << "\".");
 	fid=fopen(filkml,"w");
 
 	/* Run core computations: */
-	if (verbose) printf("Calling core:\n");
+	if (verbose) _printLine_("Calling core:");
 	KMLOverlayx(&ierror,lataxis,longaxis,nimages,pimages,fid);
 
-	if (verbose) printf("Closing file \"%s\".\n",filkml);
+	if (verbose) _printLine_("Closing file \"" << filkml << "\".");
 	fclose(fid);
 
@@ -87,8 +87,8 @@
 				strcat(czip,pimages[i]);
 			}
-		if (verbose) printf("Zipping file \"%s\".\n",filkmz);
-		if (verbose) printf("%s\n",czip);
+		if (verbose) _printLine_("Zipping file \"" << filkmz << "\".");
+		if (verbose) _printLine_(czip);
 
-		if (mexEvalString(czip)) _error_("Error zipping file \"%s\".",filkmz);
+		if (mexEvalString(czip)) _error2_("Error zipping file \"" << filkmz << "\".");
 		xfree((void**)&czip);
 		xfree((void**)&filkmz);
@@ -113,22 +113,22 @@
 
 void KMLOverlayUsage(void){
-	_printf_(true,"KMLOverlay - KML file overlay module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module reads a list of image files and writes a KML or KMZ overlay file.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      ierror=KMLOverlay(kmlfile,'param name',param,...);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      kmlfile     KML or KMZ file name (string)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      lataxis     latitude axis (double vector [south north], required)\n");
-	_printf_(true,"      longaxis    longitude axis (double vector [west east], required)\n");
-	_printf_(true,"      images      relative or http image file names (string or array of strings or cell array of strings, required)\n");
-	_printf_(true,"      zip         flag to zip the doc.kml and image files into kmzfile (double, non-zero for kmz)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      ierror     error flag (double, non-zero for error)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Example:\n");
-	_printf_(true,"      KMLOverlay(kmlfile,'lataxis',[south north],'longaxis',[west east],'images',{'file1.png','http://issm/file2.png'},'zip',1);\n");
-	_printf_(true,"\n");
+	_pprintLine_("KMLOverlay - KML file overlay module:");
+	_pprintLine_("");
+	_pprintLine_("   This module reads a list of image files and writes a KML or KMZ overlay file.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      ierror=KMLOverlay(kmlfile,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      kmlfile     KML or KMZ file name (string)");
+	_pprintLine_("");
+	_pprintLine_("      lataxis     latitude axis (double vector [south north], required)");
+	_pprintLine_("      longaxis    longitude axis (double vector [west east], required)");
+	_pprintLine_("      images      relative or http image file names (string or array of strings or cell array of strings, required)");
+	_pprintLine_("      zip         flag to zip the doc.kml and image files into kmzfile (double, non-zero for kmz)");
+	_pprintLine_("");
+	_pprintLine_("      ierror     error flag (double, non-zero for error)");
+	_pprintLine_("");
+	_pprintLine_("   Example:");
+	_pprintLine_("      KMLOverlay(kmlfile,'lataxis',[south north],'longaxis',[west east],'images',{'file1.png','http://issm/file2.png'},'zip',1);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/Kml2Exp/Kml2Exp.cpp
===================================================================
--- /issm/trunk/src/modules/Kml2Exp/Kml2Exp.cpp	(revision 12705)
+++ /issm/trunk/src/modules/Kml2Exp/Kml2Exp.cpp	(revision 12706)
@@ -22,8 +22,8 @@
 	/*checks on arguments on the matlab side: */
 	if (nlhs > NLHS) {
-		Kml2ExpUsage(); _error_("Kml2Exp usage error");
+		Kml2ExpUsage(); _error2_("Kml2Exp usage error");
 	}
 	if (nrhs < NRHS) {
-		Kml2ExpUsage(); _error_("Kml2Exp usage error");
+		Kml2ExpUsage(); _error2_("Kml2Exp usage error");
 	}
 
@@ -37,13 +37,13 @@
 	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
 		options->Get(&cm,"central_meridian");
-		if (verbose) printf("  cm=%g\n",cm);
+		if (verbose) _printLine_("  cm=" << cm);
 		options->Get(&sp,"standard_parallel");
-		if (verbose) printf("  sp=%g\n",sp);
+		if (verbose) _printLine_("  sp=" << sp);
 	}
 
 	/*some checks*/
-	if (sgn !=+1 && sgn!= -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
-	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
-	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+	if (sgn !=+1 && sgn!= -1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
+	if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
+	if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
 
 	/* Run core computations: */
@@ -66,25 +66,25 @@
 
 void Kml2ExpUsage(void){
-	_printf_(true,"Kml2Exp - kml to exp file conversion module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module converts a file from kml to exp format.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [ret]=Kml2Exp(filexp,filkml,sgn,'param name',param,...);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      filkml      file name of kml file to be read (char)\n");
-	_printf_(true,"      filexp      file name of exp file to be written (char)\n");
-	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
-	_printf_(true,"\n");
-	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
-	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      ret         return code (non-zero for warning)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Examples:\n");
-	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp', 1);\n");
-	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp', 1,'central_meridian',45,'standard_parallel',70);\n");
-	_printf_(true,"      [ret]=Kml2Exp('file.kml','file.exp',-1,'central_meridian', 0,'standard_parallel',71);\n");
-	_printf_(true,"\n");
+	_pprintLine_("Kml2Exp - kml to exp file conversion module:");
+	_pprintLine_("");
+	_pprintLine_("   This module converts a file from kml to exp format.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [ret]=Kml2Exp(filexp,filkml,sgn,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      filkml      file name of kml file to be read (char)");
+	_pprintLine_("      filexp      file name of exp file to be written (char)");
+	_pprintLine_("      sgn         sign for hemisphere (double, +1 (north) or -1 (south))");
+	_pprintLine_("");
+	_pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
+	_pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
+	_pprintLine_("");
+	_pprintLine_("      ret         return code (non-zero for warning)");
+	_pprintLine_("");
+	_pprintLine_("   Examples:");
+	_pprintLine_("      [ret]=Kml2Exp('file.kml','file.exp', 1);");
+	_pprintLine_("      [ret]=Kml2Exp('file.kml','file.exp', 1,'central_meridian',45,'standard_parallel',70);");
+	_pprintLine_("      [ret]=Kml2Exp('file.kml','file.exp',-1,'central_meridian', 0,'standard_parallel',71);");
+	_pprintLine_("");
 }
 
Index: /issm/trunk/src/modules/Kriging/Kriging.cpp
===================================================================
--- /issm/trunk/src/modules/Kriging/Kriging.cpp	(revision 12705)
+++ /issm/trunk/src/modules/Kriging/Kriging.cpp	(revision 12706)
@@ -22,13 +22,13 @@
 	/*checks on arguments on the matlab side: */
 	if (nrhs<NRHS || nlhs>NLHS){
-		KrigingUsage(); _error_("Kriging usage error");
+		KrigingUsage(); _error2_("Kriging usage error");
 	}
 
 	/*Fetch inputs: */
 	FetchData(&x,&n_obs,X);
-	FetchData(&y,&N,Y);                       if(n_obs!=N) _error_("x and y should have the same size");
-	FetchData(&observations,&N,OBSERVATIONS); if(n_obs!=N) _error_("x and observations should have the same size");
+	FetchData(&y,&N,Y);                       if(n_obs!=N) _error2_("x and y should have the same size");
+	FetchData(&observations,&N,OBSERVATIONS); if(n_obs!=N) _error2_("x and observations should have the same size");
 	FetchData(&x_interp,&M_interp,&N_interp,XINTERP);
-	FetchData(&y_interp,&M,&N,YINTERP);       if(N!=N_interp || M!=M_interp) _error_("x_interp and y_interp should have the same size");
+	FetchData(&y_interp,&M,&N,YINTERP);       if(N!=N_interp || M!=M_interp) _error2_("x_interp and y_interp should have the same size");
 	FetchData(&options,NRHS,nrhs,prhs);
 
@@ -54,20 +54,20 @@
 
 void KrigingUsage(void){
-	_printf_(true,"\n");
-	_printf_(true,"   usage: predictions=%s(x,y,observations,x_interp,y_interp,'options');\n",__FUNCT__);
-	_printf_(true,"   available options:\n");
-	_printf_(true,"      -'model': Available variogram models 'gaussian' (default),'spherical','power','exponential'\n");
-	_printf_(true,"         -'nugget': nugget effect (default 0.2)\n");
-	_printf_(true,"         -'range':  for gaussian, spherical and exponential models (default sqrt(3))\n");
-	_printf_(true,"         -'sill':   for gaussian, spherical and exponential models (default 1)\n");
-	_printf_(true,"         -'slope':  for power model (default 1)\n");
-	_printf_(true,"         -'power':  for power model (default 1)\n");
-	_printf_(true,"      -'searchradius': search radius for each prediction (default is observations span)\n");
-	_printf_(true,"      -'boxlength':    minimum length of quadtree boxes (useful to decrease the number of observations)\n");
-	_printf_(true,"      -'maxdata':      minimum number of observations for a prediction (default is 50)\n");
-	_printf_(true,"      -'mindata':      maximum number of observations for a prediction (default is 1)\n");
-	_printf_(true,"      -'maxtrimming':  maximum trimming value (default is -1.e+21)\n");
-	_printf_(true,"      -'mintrimming':  minimum trimming value (default is +1.e+21)\n");
-	_printf_(true,"      -'minspacing':   minimum distance between observation (default is 0.01)\n");
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("   usage: predictions=" << __FUNCT__ << "(x,y,observations,x_interp,y_interp,'options');");
+	_pprintLine_("   available options:");
+	_pprintLine_("      -'model': Available variogram models 'gaussian' (default),'spherical','power','exponential'");
+	_pprintLine_("         -'nugget': nugget effect (default 0.2)");
+	_pprintLine_("         -'range':  for gaussian, spherical and exponential models (default sqrt(3))");
+	_pprintLine_("         -'sill':   for gaussian, spherical and exponential models (default 1)");
+	_pprintLine_("         -'slope':  for power model (default 1)");
+	_pprintLine_("         -'power':  for power model (default 1)");
+	_pprintLine_("      -'searchradius': search radius for each prediction (default is observations span)");
+	_pprintLine_("      -'boxlength':    minimum length of quadtree boxes (useful to decrease the number of observations)");
+	_pprintLine_("      -'maxdata':      minimum number of observations for a prediction (default is 50)");
+	_pprintLine_("      -'mindata':      maximum number of observations for a prediction (default is 1)");
+	_pprintLine_("      -'maxtrimming':  maximum trimming value (default is -1.e+21)");
+	_pprintLine_("      -'mintrimming':  minimum trimming value (default is +1.e+21)");
+	_pprintLine_("      -'minspacing':   minimum distance between observation (default is 0.01)");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/Ll2xy/Ll2xy.cpp
===================================================================
--- /issm/trunk/src/modules/Ll2xy/Ll2xy.cpp	(revision 12705)
+++ /issm/trunk/src/modules/Ll2xy/Ll2xy.cpp	(revision 12706)
@@ -25,8 +25,8 @@
 	/*checks on arguments on the matlab side: */
 	if (nlhs > NLHS) {
-		Ll2xyUsage(); _error_("Ll2xy usage error");
+		Ll2xyUsage(); _error2_("Ll2xy usage error");
 	}
 	if (nrhs < NRHS) {
-		Ll2xyUsage(); _error_("Ll2xy usage error");
+		Ll2xyUsage(); _error2_("Ll2xy usage error");
 	}
 
@@ -40,16 +40,16 @@
 	if(options->GetOption("central_meridian") || options->GetOption("standard_parallel")){
 		options->Get(&cm,"central_meridian");
-		if (verbose) printf("  cm=%g\n",cm);
+		if (verbose) _printLine_("  cm=" << cm);
 		options->Get(&sp,"standard_parallel");
-		if (verbose) printf("  sp=%g\n",sp);
+		if (verbose) _printLine_("  sp=" << sp);
 	}
 
 	/*some checks*/
-	if (verbose) printf("Checking inputs:\n");
-	if (nlat != nlon) _error_("Must have same number of lat[%d] and lon[%d] coordinates.",nlat,nlon);
+	if (verbose) _printLine_("Checking inputs:");
+	if (nlat != nlon){_error2_("Must have same number of lat[" << nlat << "] and lon[" << nlon << "] coordinates.");}
 	else                ncoord=nlat;
-	if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
-	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
-	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+	if (sgn != +1 && sgn != -1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
+	if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
+	if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
 
 	x=(double*)mxMalloc(ncoord*sizeof(double));
@@ -74,25 +74,25 @@
 
 void Ll2xyUsage(void){
-	_printf_(true,"Ll2xy - lat/long to x/y coordinate transformation module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module transforms lat/long to x/y coordinates.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [x,y]=Ll2xy(lat,lon,sgn,'param name',param,...);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      lat         latitude coordinates (double vector)\n");
-	_printf_(true,"      lon         longitude coordinates (double vector)\n");
-	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
-	_printf_(true,"\n");
-	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
-	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      x           x coordinates (double vector)\n");
-	_printf_(true,"      y           y coordinates (double vector)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Examples:\n");
-	_printf_(true,"      [x,y]=Ll2xy(lat,lon, 1);\n");
-	_printf_(true,"      [x,y]=Ll2xy(lat,lon, 1,'central_meridian',45,'standard_parallel',70);\n");
-	_printf_(true,"      [x,y]=Ll2xy(lat,lon,-1,'central_meridian', 0,'standard_parallel',71);\n");
-	_printf_(true,"\n");
+	_pprintLine_("Ll2xy - lat/long to x/y coordinate transformation module:");
+	_pprintLine_("");
+	_pprintLine_("   This module transforms lat/long to x/y coordinates.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [x,y]=Ll2xy(lat,lon,sgn,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      lat         latitude coordinates (double vector)");
+	_pprintLine_("      lon         longitude coordinates (double vector)");
+	_pprintLine_("      sgn         sign for hemisphere (double, +1 (north) or -1 (south))");
+	_pprintLine_("");
+	_pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
+	_pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
+	_pprintLine_("");
+	_pprintLine_("      x           x coordinates (double vector)");
+	_pprintLine_("      y           y coordinates (double vector)");
+	_pprintLine_("");
+	_pprintLine_("   Examples:");
+	_pprintLine_("      [x,y]=Ll2xy(lat,lon, 1);");
+	_pprintLine_("      [x,y]=Ll2xy(lat,lon, 1,'central_meridian',45,'standard_parallel',70);");
+	_pprintLine_("      [x,y]=Ll2xy(lat,lon,-1,'central_meridian', 0,'standard_parallel',71);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/MeshPartition/MeshPartition.cpp
===================================================================
--- /issm/trunk/src/modules/MeshPartition/MeshPartition.cpp	(revision 12705)
+++ /issm/trunk/src/modules/MeshPartition/MeshPartition.cpp	(revision 12706)
@@ -96,9 +96,9 @@
 
 void MeshPartitionUsage(void){
-	printf("   usage:\n");
-	printf("   [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions)");
-	printf("   where:\n");
-	printf("      element_partitioning is a vector of partitioning area numbers, for every element.\n");
-	printf("      node_partitioning is a vector of partitioning area numbers, for every node.\n");
-	printf("\n");
+	_printLine_("   usage:");
+	_printString_("   [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions)");
+	_printLine_("   where:");
+	_printLine_("      element_partitioning is a vector of partitioning area numbers, for every element.");
+	_printLine_("      node_partitioning is a vector of partitioning area numbers, for every node.");
+	_printLine_("");
 }
Index: /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp
===================================================================
--- /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 12705)
+++ /issm/trunk/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 12706)
@@ -54,5 +54,5 @@
 	//index
 	FetchData(&double_index,&nel,&dummy,INDEX);
-	if(dummy!=3 && dummy!=6)_error_(" element triangulation should be of 3 or 6 column width!");
+	if(dummy!=3 && dummy!=6)_error2_("element triangulation should be of 3 or 6 column width!");
 	index=(int*)xmalloc(nel*3*sizeof(int));
 	for(i=0;i<nel;i++){
@@ -81,9 +81,9 @@
 	/* Debugging of contours :{{{1*/
 	/*for(i=0;i<numcontours;i++){
-		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
+		_printLine_("\nContour echo: contour number  " << i+1 << " / " << numcontours);
 		contouri=*(contours+i);
-		printf("   Number of vertices %i\n",contouri->nods);
+		_printLine_("   Number of vertices " << contouri->nods);
 		for (j=0;j<contouri->nods;j++){
-			printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+			_printLine_("   " << *(contouri->x+j) << "f " << *(contouri->y+j) << "f");
 		}
 	}*/
@@ -102,13 +102,13 @@
 
 void MeshProfileIntersectionUsage(void){
-	printf("   usage:\n");
-	printf("   [segments]=MeshProfileIntersection(index,x,y,filename);\n");
-	printf("   where:\n");
-	printf("   input:\n");
-	printf("        index,x,y is a triangulation\n");
-	printf("        filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)\n");
-	printf("   output:\n");
-	printf("        segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremitis for a segment \n");
-	printf("        belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the \n");
-	printf("        mesh.\n");
+	_printLine_("   usage:");
+	_printLine_("   [segments]=MeshProfileIntersection(index,x,y,filename);");
+	_printLine_("   where:");
+	_printLine_("   input:");
+	_printLine_("        index,x,y is a triangulation");
+	_printLine_("        filename: name of Argus style .exp file containing the segments (can be groups of disconnected segments)");
+	_printLine_("   output:");
+	_printLine_("        segments: array made of x1,y1,x2,y2,element_id lines (x1,y1) and (x2,y2) are segment extremitis for a segment ");
+	_printLine_("        belonging to the elemnt_id element. there are as many lines in segments as there are segments intersecting the ");
+	_printLine_("        mesh.");
 }
Index: /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.cpp
===================================================================
--- /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.cpp	(revision 12705)
+++ /issm/trunk/src/modules/NodeConnectivity/NodeConnectivity.cpp	(revision 12706)
@@ -37,6 +37,6 @@
 
 void NodeConnectivityUsage(void) {
-	_printf_(true,"\n");
-	_printf_(true,"   usage: connectivity = %s(elements, numnodes);\n",__FUNCT__);
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("   usage: connectivity = " << __FUNCT__ << "(elements, numnodes);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp
===================================================================
--- /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 12705)
+++ /issm/trunk/src/modules/PointCloudFindNeighbors/PointCloudFindNeighbors.cpp	(revision 12706)
@@ -42,11 +42,11 @@
 
 void PointCloudFindNeighborsUsage(void){
-	printf("   usage:\n");
-	printf("   [flags]=PointCloudFindNeighbors(x,y,mindistance,multithread);\n\n");
-	printf("   where:\n");
-	printf("      x,y: list of points.\n");
-	printf("      mindistance: minimum distance that should exist between points in the cloud.\n");
-	printf("      multithread: run multithreaded or not. with multithreads, flags can get 1 and 2 values in duplicates.\n");
-	printf("      flags: array of flags (flag==1 means point is within mindistance of another point)\n");
-	printf("\n");
+	_printLine_("   usage:");
+	_printLine_("   [flags]=PointCloudFindNeighbors(x,y,mindistance,multithread);\n");
+	_printLine_("   where:");
+	_printLine_("      x,y: list of points.");
+	_printLine_("      mindistance: minimum distance that should exist between points in the cloud.");
+	_printLine_("      multithread: run multithreaded or not. with multithreads, flags can get 1 and 2 values in duplicates.");
+	_printLine_("      flags: array of flags (flag==1 means point is within mindistance of another point)");
+	_printLine_("");
 }
Index: /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp
===================================================================
--- /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp	(revision 12705)
+++ /issm/trunk/src/modules/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.cpp	(revision 12706)
@@ -42,6 +42,6 @@
 
 void PropagateFlagsFromConnectivityUsage(void) {
-	printf("\n");
-	printf("   usage: [pool] = %s(connectivity,pool,index,flags);\n",__FUNCT__);
-	printf("\n");
+	_printLine_("");
+	_printLine_("   usage: [pool] = " << __FUNCT__ << "(connectivity,pool,index,flags);");;
+	_printLine_("");
 }
Index: /issm/trunk/src/modules/Scotch/Scotch.cpp
===================================================================
--- /issm/trunk/src/modules/Scotch/Scotch.cpp	(revision 12705)
+++ /issm/trunk/src/modules/Scotch/Scotch.cpp	(revision 12706)
@@ -25,5 +25,5 @@
 
 #ifndef _HAVE_SCOTCH_ //only works if scotch library has been compiled in.
-	_error_(" Scotch not available! Cannot carry out Scotch partitioning!");
+	_error2_("Scotch not available! Cannot carry out Scotch partitioning!");
 	#else
 
Index: /issm/trunk/src/modules/Shp2Kml/Shp2Kml.cpp
===================================================================
--- /issm/trunk/src/modules/Shp2Kml/Shp2Kml.cpp	(revision 12705)
+++ /issm/trunk/src/modules/Shp2Kml/Shp2Kml.cpp	(revision 12706)
@@ -25,5 +25,5 @@
 
 	#ifndef _HAVE_SHAPELIB_ //only works if shapelib library has been compiled in.
-	_error_(" Shapelib not available! Cannot carry out shp file translation!");
+	_error2_("Shapelib not available! Cannot carry out shp file translation!");
 	#endif
 
@@ -33,8 +33,8 @@
 	/*checks on arguments on the matlab side: */
 	if (nlhs > NLHS) {
-		Shp2KmlUsage(); _error_("Shp2Kml usage error");
+		Shp2KmlUsage(); _error2_("Shp2Kml usage error");
 	}
 	if (nrhs < NRHS) {
-		Shp2KmlUsage(); _error_("Shp2Kml usage error");
+		Shp2KmlUsage(); _error2_("Shp2Kml usage error");
 	}
 
@@ -48,13 +48,13 @@
 	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
 		options->Get(&cm,"central_meridian");
-		if (verbose) printf("  cm=%g\n",cm);
+		if (verbose) _printLine_("  cm=" << cm);
 		options->Get(&sp,"standard_parallel");
-		if (verbose) printf("  sp=%g\n",sp);
+		if (verbose) _printLine_("  sp=" << sp);
 	}
 
 	/*some checks*/
-	if (sgn < -1 || sgn > +1) _error_("Hemisphere sgn=%d must be +1 (north), -1 (south), or 0 (no translation).",sgn);
-	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
-	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+	if (sgn < -1 || sgn > +1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north), -1 (south), or 0 (no translation).");
+	if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
+	if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
 
 	/* Run core computations: */
@@ -77,24 +77,24 @@
 
 void Shp2KmlUsage(void){
-	_printf_(true,"Shp2Kml - shp to kml file conversion module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module converts a file from shp to kml format.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [ret]=Shp2Kml(filshp,filkml,sgn,'param name',param,...);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      filshp      file name of shp file to be read (char, extension optional)\n");
-	_printf_(true,"      filkml      file name of kml file to be written (char)\n");
-	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))\n");
-	_printf_(true,"\n");
-	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
-	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      ret         return code (non-zero for warning)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Examples:\n");
-	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 0);\n");
-	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70);\n");
-	_printf_(true,"      [ret]=Shp2Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71);\n");
-	_printf_(true,"\n");
+	_pprintLine_("Shp2Kml - shp to kml file conversion module:");
+	_pprintLine_("");
+	_pprintLine_("   This module converts a file from shp to kml format.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [ret]=Shp2Kml(filshp,filkml,sgn,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      filshp      file name of shp file to be read (char, extension optional)");
+	_pprintLine_("      filkml      file name of kml file to be written (char)");
+	_pprintLine_("      sgn         sign for hemisphere (double, +1 (north); -1 (south); or 0 (no translation))");
+	_pprintLine_("");
+	_pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
+	_pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
+	_pprintLine_("");
+	_pprintLine_("      ret         return code (non-zero for warning)");
+	_pprintLine_("");
+	_pprintLine_("   Examples:");
+	_pprintLine_("      [ret]=Shp2Kml('file.shp','file.kml', 0);");
+	_pprintLine_("      [ret]=Shp2Kml('file.shp','file.kml', 1,'central_meridian',45,'standard_parallel',70);");
+	_pprintLine_("      [ret]=Shp2Kml('file.shp','file.kml',-1,'central_meridian', 0,'standard_parallel',71);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/StringToEnum/StringToEnum.cpp
===================================================================
--- /issm/trunk/src/modules/StringToEnum/StringToEnum.cpp	(revision 12705)
+++ /issm/trunk/src/modules/StringToEnum/StringToEnum.cpp	(revision 12706)
@@ -12,5 +12,5 @@
 	/*checks on arguments on the matlab side: */
 	if(nrhs!=NRHS){
-		StringToEnumUsage(); _error_(" usage. See above");
+		StringToEnumUsage(); _error2_("usage. See above");
 	}
 
@@ -27,6 +27,6 @@
 void StringToEnumUsage(void)
 {
-	_printf_(true,"\n");
-	_printf_(true,"   usage: %senum = StringToEnum(string);\n",__FUNCT__);
-	_printf_(true,"\n");
+	_pprintLine_("");
+	_pprintLine_("   usage: " << __FUNCT__ << "enum = StringToEnum(string);");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/TriMesh/TriMesh.cpp
===================================================================
--- /issm/trunk/src/modules/TriMesh/TriMesh.cpp	(revision 12705)
+++ /issm/trunk/src/modules/TriMesh/TriMesh.cpp	(revision 12706)
@@ -63,11 +63,11 @@
 void TriMeshUsage(void) //{{{1
 {
-	printf("\n");
-	printf("   usage: [index,x,y,segments,segmentmarkers]=TriMesh(domainoutlinefilename,rifts,area) \n");
-	printf("      where: index,x,y defines a triangulation, segments is an array made \n");
-	printf("      of exterior segments to the mesh domain outline, segmentmarkers is an array flagging each segment, \n");
-	printf("      outlinefilename an Argus domain outline file, \n");
-	printf("      area is the maximum area desired for any element of the resulting mesh, \n");
-	printf("\n");
+	_printLine_("");
+	_printLine_("   usage: [index,x,y,segments,segmentmarkers]=TriMesh(domainoutlinefilename,rifts,area) ");
+	_printLine_("      where: index,x,y defines a triangulation, segments is an array made ");
+	_printLine_("      of exterior segments to the mesh domain outline, segmentmarkers is an array flagging each segment, ");
+	_printLine_("      outlinefilename an Argus domain outline file, ");
+	_printLine_("      area is the maximum area desired for any element of the resulting mesh, ");
+	_printLine_("");
 }
 //}}}
Index: /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp
===================================================================
--- /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 12705)
+++ /issm/trunk/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 12706)
@@ -66,6 +66,5 @@
 		mexPrintf("   %s format error.\n", __FUNCT__);
 		TriMeshProcessRiftsUsage();
-		printf("   ");
-		mexErrMsgTxt(" ");
+		_error_("bad usage");
 	}
 
@@ -82,6 +81,5 @@
 	}
 	else{
-		printf("%s%s\n",__FUNCT__," error message: first argument should be the element list!");
-		mexErrMsgTxt(" ");
+		_error_("first argument should be the element list");
 	}
 
@@ -96,6 +94,5 @@
 	}
 	else{
-		printf("%s%s\n",__FUNCT__," error message: second argument should be the x corrdinate list!");
-		mexErrMsgTxt(" ");
+		_error_("second argument should be the x corrdinate list");
 	}
 
@@ -109,6 +106,5 @@
 	}
 	else{
-		printf("%s%s\n",__FUNCT__," error message: third argument should be the y corrdinate list!");
-		mexErrMsgTxt(" ");
+		_error_("third argument should be the y corrdinate list");
 	}	
 
@@ -125,6 +121,5 @@
 	}
 	else{
-		printf("%s%s\n",__FUNCT__," error message: fourth argument should be the segments list!");
-		mexErrMsgTxt(" ");
+		_error_("fourth argument should be the segments list");
 	}
 
@@ -138,29 +133,6 @@
 	}
 	else{
-		printf("%s%s\n",__FUNCT__," error message: fourth argument should be the segmentmarkers list!");
-		mexErrMsgTxt(" ");
-	}
-
-	/*
-	printf("Index: \n");
-	for (i=0;i<nel;i++){
-		for(j=0;j<3;j++){
-			printf("%lf ",*(index_in+3*i+j));
-		}
-		printf("\n");
-	}
-	printf("x,y: \n");
-	for (i=0;i<nods;i++){
-		printf("%16.16lf %16.16lf\n",x_in[i],y_in[i]);
-	}
-	printf("segments:\n");
-	for (i=0;i<num_seg;i++){
-		for(j=0;j<3;j++){
-			printf("%lf ",*(segments_in+3*i+j));
-		}
-		printf("%lf ",segmentmarkers_in[i]);
-		printf("\n");
-	}
-	*/
+		_error_("fourth argument should be the segmentmarkers list");
+	}
 
 	/*First, do some fixing on the existing mesh: we do not want any element belonging entirely to the segment list (ie: 
@@ -325,7 +297,7 @@
 void TriMeshProcessRiftsUsage(void)
 {
-	printf("\n");
-	printf("   usage: [index2,x2,y2,segments2,segmentmarkers2,rifts2]=TriMeshProcessrifts(index1,x1,y1,segments1,segmentmarkers1) \n");
-	printf("      where: (index1,x1,y1,segments1,segmentmarkers1) is an initial triangulation.\n");
-	printf("      index2,x2,y2,segments2,segmentmarkers2,rifts2 is the resulting triangulation where rifts have been processed.\n");
+	_printLine_("");
+	_printLine_("   usage: [index2,x2,y2,segments2,segmentmarkers2,rifts2]=TriMeshProcessrifts(index1,x1,y1,segments1,segmentmarkers1) ");
+	_printLine_("      where: (index1,x1,y1,segments1,segmentmarkers1) is an initial triangulation.");
+	_printLine_("      index2,x2,y2,segments2,segmentmarkers2,rifts2 is the resulting triangulation where rifts have been processed.");
 }
Index: /issm/trunk/src/modules/TriaSearch/TriaSearch.cpp
===================================================================
--- /issm/trunk/src/modules/TriaSearch/TriaSearch.cpp	(revision 12705)
+++ /issm/trunk/src/modules/TriaSearch/TriaSearch.cpp	(revision 12706)
@@ -9,5 +9,5 @@
 
 	/*input: */
-	double* index=NULL;
+	int*    index=NULL;
 	int     nel;
 	int     dummy;
@@ -37,8 +37,4 @@
 	FetchData(&y0,&numberofnodes,Y0HANDLE);
 
-	/* Echo: {{{1*/
-	//printf("(x0,y0)=(%g,%g)\n",x0,y0);
-	/*}}}*/
-
 	/* Run core computations: */
 	TriaSearchx(&tria,index,nel,x,y,nods,x0,y0,numberofnodes);
@@ -54,13 +50,12 @@
 }
 
-void TriaSearchUsage(void)
-{
-	_printf_(true,"TriaSearch- find triangle holding a point (x0,y0) in a mesh\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"         tria=TriaSearch(index,x,y,x0,y0);\n");
-	_printf_(true,"      index,x,y: mesh triangulatrion\n");
-	_printf_(true,"      x0,y0: coordinates of the point for which we are trying to find a triangle\n");
-	_printf_(true,"      x0,y0 can be an array of points\n");
-	_printf_(true,"\n");
+void TriaSearchUsage(void){
+	_pprintLine_("TriaSearch- find triangle holding a point (x0,y0) in a mesh");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("         tria=TriaSearch(index,x,y,x0,y0);");
+	_pprintLine_("      index,x,y: mesh triangulatrion");
+	_pprintLine_("      x0,y0: coordinates of the point for which we are trying to find a triangle");
+	_pprintLine_("      x0,y0 can be an array of points");
+	_pprintLine_("");
 }
Index: /issm/trunk/src/modules/Xy2ll/Xy2ll.cpp
===================================================================
--- /issm/trunk/src/modules/Xy2ll/Xy2ll.cpp	(revision 12705)
+++ /issm/trunk/src/modules/Xy2ll/Xy2ll.cpp	(revision 12706)
@@ -24,8 +24,8 @@
 	/*checks on arguments on the matlab side: */
 	if (nlhs > NLHS) {
-		Xy2llUsage(); _error_("Xy2ll usage error");
+		Xy2llUsage(); _error2_("Xy2ll usage error");
 	}
 	if (nrhs < NRHS) {
-		Xy2llUsage(); _error_("Xy2ll usage error");
+		Xy2llUsage(); _error2_("Xy2ll usage error");
 	}
 
@@ -39,15 +39,15 @@
 	if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
 		options->Get(&cm,"central_meridian");
-		if (verbose) printf("  cm=%g\n",cm);
+		if (verbose) _printLine_("  cm=" << cm);
 		options->Get(&sp,"standard_parallel");
-		if (verbose) printf("  sp=%g\n",sp);
+		if (verbose) _printLine_("  sp=" << sp);
 	}
 
 	/*some checks*/
-	if   (nx != ny) _error_("Must have same number of x[%d] and y[%d] coordinates.",nx,ny);
+	if   (nx != ny){_error2_("Must have same number of x[" << nx << "] and y[" << ny << "] coordinates.");}
 	else            ncoord=nx;
-	if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
-	if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
-	if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
+	if (sgn != +1 && sgn != -1) _error2_("Hemisphere sgn=" << sgn << " must be +1 (north) or -1 (south).");
+	if (fabs(cm)      > 180.) _error2_("Central meridian cm=" << cm << " must be between -180 (west) and +180 (east) degrees.");
+	if (sp < 0. || sp >  90.) _error2_("Standard parallel sp=" << sp << " must be between 0 and 90 degrees (in specified hemisphere).");
 
 	lat=(double*)mxMalloc(ncoord*sizeof(double));
@@ -55,5 +55,5 @@
 
 	/* Run core computations: */
-	if (verbose) printf("Calling core:\n");
+	if (verbose) _printLine_("Calling core:");
 	if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
 		iret=Xy2llx(lat,lon,x,y,ncoord,sgn,cm,sp);
@@ -73,26 +73,26 @@
 
 void Xy2llUsage(void){
-	_printf_(true,"Xy2ll - x/y to lat/long coordinate transformation module:\n");
-	_printf_(true,"\n");
-	_printf_(true,"   This module transforms x/y to lat/long coordinates.\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Usage:\n");
-	_printf_(true,"      [lat,lon]=Xy2ll(x,y,sgn,'param name',param,...);\n");
-	_printf_(true,"\n");
-	_printf_(true,"      x           x coordinates (double vector)\n");
-	_printf_(true,"      y           y coordinates (double vector)\n");
-	_printf_(true,"      sgn         sign for hemisphere (double, +1 (north) or -1 (south))\n");
-	_printf_(true,"\n");
-	_printf_(true,"      central_meridian     central meridian (double, optional, but must specify with sp)\n");
-	_printf_(true,"      standard_parallel    standard parallel (double, optional, but must specify with cm)\n");
-	_printf_(true,"\n");
-	_printf_(true,"      lat         latitude coordinates (double vector)\n");
-	_printf_(true,"      lon         longitude coordinates (double vector)\n");
-	_printf_(true,"\n");
-	_printf_(true,"   Examples:\n");
-	_printf_(true,"      [lat,lon]=Xy2ll(x,y, 1);\n");
-	_printf_(true,"      [lat,lon]=Xy2ll(x,y, 1,'central_meridian',45,'standard_parallel',70);\n");
-	_printf_(true,"      [lat,lon]=Xy2ll(x,y,-1,'central_meridian', 0,'standard_parallel',71);\n");
-	_printf_(true,"\n");
+	_pprintLine_("Xy2ll - x/y to lat/long coordinate transformation module:");
+	_pprintLine_("");
+	_pprintLine_("   This module transforms x/y to lat/long coordinates.");
+	_pprintLine_("");
+	_pprintLine_("   Usage:");
+	_pprintLine_("      [lat,lon]=Xy2ll(x,y,sgn,'param name',param,...);");
+	_pprintLine_("");
+	_pprintLine_("      x           x coordinates (double vector)");
+	_pprintLine_("      y           y coordinates (double vector)");
+	_pprintLine_("      sgn         sign for hemisphere (double, +1 (north) or -1 (south))");
+	_pprintLine_("");
+	_pprintLine_("      central_meridian     central meridian (double, optional, but must specify with sp)");
+	_pprintLine_("      standard_parallel    standard parallel (double, optional, but must specify with cm)");
+	_pprintLine_("");
+	_pprintLine_("      lat         latitude coordinates (double vector)");
+	_pprintLine_("      lon         longitude coordinates (double vector)");
+	_pprintLine_("");
+	_pprintLine_("   Examples:");
+	_pprintLine_("      [lat,lon]=Xy2ll(x,y, 1);");
+	_pprintLine_("      [lat,lon]=Xy2ll(x,y, 1,'central_meridian',45,'standard_parallel',70);");
+	_pprintLine_("      [lat,lon]=Xy2ll(x,y,-1,'central_meridian', 0,'standard_parallel',71);");
+	_pprintLine_("");
 }
 
Index: /issm/trunk/src/modules/matlab/Makefile.am
===================================================================
--- /issm/trunk/src/modules/matlab/Makefile.am	(revision 12705)
+++ /issm/trunk/src/modules/matlab/Makefile.am	(revision 12706)
@@ -1,3 +1,3 @@
-INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
+INCLUDES = @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
 EXEEXT=$(MATLABWRAPPEREXT)
 #Bin programs {{{1
@@ -41,5 +41,5 @@
 #}}}
 #Flags and libraries {{{1
-LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
+LDADD = ../../c/libISSMCore.a ../../c/libISSMModules.a $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(SPOOLESLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
 
 #Triangle library
@@ -50,6 +50,9 @@
 AM_CXXFLAGS +=  -D_HAVE_MATLAB_MODULES_ -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread 
 LDADD       += $(MEXLIB) ../../c/libISSMMatlab.a 
-
-LDADD       += ../../c/libISSMCore.a ../../c/libISSMModules.a 
+LDADD       += ../../c/libISSMCore.a 
+if CIRCULAR_DEPENDENCIES
+LDADD       += $(TRIANGLELIB) $(PETSCLIB) $(FLIBS) $(PLAPACKLIB) $(SPOOLESLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(SHAPELIBLIB) $(GSLLIB)
+endif
+LDADD       += ../../c/libISSMModules.a
 
 #Optimization flags:
Index: /issm/trunk/src/modules/python/Makefile.am
===================================================================
--- /issm/trunk/src/modules/python/Makefile.am	(revision 12705)
+++ /issm/trunk/src/modules/python/Makefile.am	(revision 12706)
@@ -17,5 +17,5 @@
 #Python part
 AM_LDFLAGS   = $(PYTHONLINK)
-AM_CXXFLAGS +=  -D_HAVE_PYTHON_MODULES_ 
+AM_CXXFLAGS +=  -D_HAVE_PYTHON_MODULES_  -fPIC
 if PYTHON3
 AM_CXXFLAGS +=  -DNPY_NO_DEPRECATED_API 
