Index: /issm/trunk-jpl/jenkins/jenkins.sh
===================================================================
--- /issm/trunk-jpl/jenkins/jenkins.sh	(revision 20942)
+++ /issm/trunk-jpl/jenkins/jenkins.sh	(revision 20943)
@@ -92,5 +92,4 @@
 		ISSM_COMPILATION="no"
 	fi
-	ISSM_COMPILATION="yes"
 
 else
Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 20942)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 20943)
@@ -187,13 +187,7 @@
 
 	/*Intermediary*/
-	FILE *output_fid;
-	char *outbinfilename = NULL;
 	char *lockfilename   = NULL;
 	bool  waitonlock     = false;
 
-	/*Close output file: */
-	this->parameters->FindParam(&output_fid,OutputFilePointerEnum);
-	this->parameters->FindParam(&outbinfilename,OutputFileNameEnum);
-	pfclose(output_fid,outbinfilename);
 
 	/*Write lock file if requested: */
@@ -225,9 +219,6 @@
 
 	/*Clean up*/
-	xDelete<char>(outbinfilename);
 	xDelete<char>(lockfilename);
-
-}
-/*}}}*/
+} /*}}}*/
 FemModel* FemModel::copy(void){/*{{{*/
 
@@ -296,5 +287,4 @@
 	FILE *IOMODEL            = NULL;
 	FILE *toolkitsoptionsfid = NULL;
-	FILE *output_fid         = NULL;
 
 	/*recover my_rank:*/
@@ -314,8 +304,4 @@
 	pfclose(toolkitsoptionsfid,toolkitsfilename);
 
-	/*Open output file once for all and add output file descriptor to parameters*/
-	output_fid=pfopen(outputfilename,"wb");
-	this->parameters->SetParam(output_fid,OutputFilePointerEnum);
-	
 	/*Now save all of these file names into parameters, you never know when you might need them: */
 	this->parameters->AddObject(new StringParam(ToolkitsFileNameEnum,toolkitsfilename));
@@ -441,5 +427,4 @@
 
 	FILE* restartfid=NULL;
-	FILE* output_fid=NULL;
 	char* restartfilename = NULL;
 	int   femmodel_size=0; 
@@ -471,10 +456,6 @@
 	femmodel_buffer_ini=femmodel_buffer; //keep track of the initial position, so as to free later.
 
-	this->parameters->FindParam(&output_fid,OutputFilePointerEnum);
-
 	/*Create new FemModel by demarshalling the buffer: */
 	this->Marshall(&femmodel_buffer,NULL,MARSHALLING_BACKWARD);
-
-	this->parameters->SetParam(output_fid,OutputFilePointerEnum);
 
 	/*Reset position of buffer: */
@@ -487,7 +468,5 @@
 	xDelete<char>(restartfilename);
 	xDelete<char>(femmodel_buffer);
-	
-}
-/*}}}*/
+}/*}}}*/
 void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){/*{{{*/
 
@@ -2448,5 +2427,4 @@
 /*}}}*/
 #endif
-
 void FemModel::HydrologyEPLupdateDomainx(IssmDouble* pEplcount){ /*{{{*/
 
@@ -2585,5 +2563,4 @@
 }
 /*}}}*/
-
 #ifdef _HAVE_JAVASCRIPT_ 
 FemModel::FemModel(IssmDouble* buffer, int buffersize, char* toolkits, char* solution, char* modelname,ISSM_MPI_Comm incomm, bool trace){ /*{{{*/
@@ -2641,9 +2618,4 @@
 	poutputbuffersize=outputbuffersizeparam->GetParameterValue();
 
-	/*Close output file. Watch out, only close the output file after recovering the buffer pointers. Not sure 
-	 * why, but otherwise, the buffers are garbage: */
-	this->parameters->FindParam(&output_fid,OutputFilePointerEnum);
-	fclose(output_fid);
-
 	/*Assign output values: */
 	*poutput=*poutputbuffer;
@@ -2660,5 +2632,5 @@
 	size_t      outputsize;
 	char       *outputbuffer;
-	const char*       rootpath=""; //needed for Dakota runs only, which we won't do here.
+	const char *rootpath = "";   //needed for Dakota runs only, which we won't do here.
 
 	/*recover my_rank:*/
Index: /issm/trunk-jpl/src/c/classes/IoModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 20942)
+++ /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 20943)
@@ -733,112 +733,112 @@
 				ISSM_MPI_Bcast(&record_length,1,ISSM_MPI_INT,0,IssmComm::GetComm());  
 				switch(record_code){
-				case 1: 
-					/*boolean. get it from cpu 0 */
-					ISSM_MPI_Bcast(&booleanint,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-
-					/*create BoolParam: */
-					this->AddConstant(new IoConstant((bool)booleanint,record_name)); //cast to a boolean
-					break;
-
-				case 2:
-					/*integer. get it from cpu 0 */
-					ISSM_MPI_Bcast(&integer,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-
-					/*create IntParam: */
-					this->AddConstant(new IoConstant(integer,record_name));
-					break;
-				case 3:
-					/*scalar. get it from cpu 0 */
-					  {
-						/*IssmDouble, check whether it is already there (from "declare independents")*/
-						bool exists = false;
-						vector<IoConstant*>::iterator iter;
-						for(iter=constants.begin();iter<constants.end();iter++){
-							IoConstant* ioconstant=*iter;
-							if(strcmp(ioconstant->name,record_name)==0){
-								exists = true;
-								break;
+					case 1: 
+						/*boolean. get it from cpu 0 */
+						ISSM_MPI_Bcast(&booleanint,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+
+						/*create BoolParam: */
+						this->AddConstant(new IoConstant((bool)booleanint,record_name)); //cast to a boolean
+						break;
+
+					case 2:
+						/*integer. get it from cpu 0 */
+						ISSM_MPI_Bcast(&integer,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+
+						/*create IntParam: */
+						this->AddConstant(new IoConstant(integer,record_name));
+						break;
+					case 3:
+						/*scalar. get it from cpu 0 */
+						  {
+							/*IssmDouble, check whether it is already there (from "declare independents")*/
+							bool exists = false;
+							vector<IoConstant*>::iterator iter;
+							for(iter=constants.begin();iter<constants.end();iter++){
+								IoConstant* ioconstant=*iter;
+								if(strcmp(ioconstant->name,record_name)==0){
+									exists = true;
+									break;
+								}
 							}
+							if(!exists){
+								ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm());
+								scalar=pscalar;
+								/*create DoubleParam: */
+								this->AddConstant(new IoConstant(scalar,record_name));
+							}
+						  }
+						break;
+					case 4: 
+						ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+						if(string_size){
+							string=xNew<char>((string_size+1));
+							string[string_size]='\0';
+
+							/*Read string from cpu 0: */
+							ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
 						}
-						if(!exists){
-							ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm());
-							scalar=pscalar;
-							/*create DoubleParam: */
-							this->AddConstant(new IoConstant(scalar,record_name));
+						else{
+							string=xNew<char>(1);
+							string[0]='\0';
 						}
-					  }
-					break;
-				case 4: 
-					ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-					if(string_size){
-						string=xNew<char>((string_size+1));
-						string[string_size]='\0';
-
-						/*Read string from cpu 0: */
-						ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
-					}
-					else{
-						string=xNew<char>(1);
-						string[0]='\0';
-					}
-					if(strcmp(record_name,"md.flowequation.fe_SSA")==0){
-						this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
-					} else if(strcmp(record_name,"md.flowequation.fe_HO")==0){
-						this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
-					} else if(strcmp(record_name,"md.flowequation.fe_FS")==0){
-						this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
-					} else if(strcmp(record_name,"md.groundingline.migration")==0){
-						this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
-					} else if(strcmp(record_name,"md.masstransport.hydrostatic_adjustment")==0){
-						this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
-					} else {
-						/*Add string to parameters: */
-						this->AddConstant(new IoConstant(string,record_name));
-					}
-
-					/*Free string*/
-					xDelete<char>(string);
-
-					break;
-				case 5: break; //do nothing. not interested in this type of data, which is memory intensive.
-				case 6: break; //do nothing. not interested in this type of data, which is memory intensive.
-				case 7: break; //do nothing. not interested in this type of data, which is memory intensive.
-				case 8: break; //do nothing. not interested in this type of data, which is memory intensive.
-				case 9:
-					ISSM_MPI_Bcast(&numstrings,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-					/*Now allocate string array: */
-					if(numstrings){
-						strings=xNew<char*>(numstrings);
-						for(int i=0;i<numstrings;i++)strings[i]=NULL;
-
-						/*Go through strings, and read: */
-						for(int i=0;i<numstrings;i++){
-
-							ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
-							if(string_size){
-								string=xNew<char>((string_size+1));
-								string[string_size]='\0';
-								ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
-							}
-							else{
-								string=xNew<char>(1);
-								string[0]='\0';
-							}
-							strings[i]=string;
+						if(strcmp(record_name,"md.flowequation.fe_SSA")==0){
+							this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
+						} else if(strcmp(record_name,"md.flowequation.fe_HO")==0){
+							this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
+						} else if(strcmp(record_name,"md.flowequation.fe_FS")==0){
+							this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
+						} else if(strcmp(record_name,"md.groundingline.migration")==0){
+							this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
+						} else if(strcmp(record_name,"md.masstransport.hydrostatic_adjustment")==0){
+							this->AddConstant(new IoConstant(StringToEnumx(string),record_name));
+						} else {
+							/*Add string to parameters: */
+							this->AddConstant(new IoConstant(string,record_name));
 						}
-					}
-
-					/*Add strings to parameters: */
-					this->AddConstant(new IoConstant(strings,numstrings,record_name));
-
-					/*Free string*/
-					for(int i=0;i<numstrings;i++) xDelete<char>(strings[i]);
-					xDelete<char*>(strings);
-					break;
-				default: 
-					_error_("unknown record type:" << record_code); 
-					break;
+
+						/*Free string*/
+						xDelete<char>(string);
+
+						break;
+					case 5: break; //do nothing. not interested in this type of data, which is memory intensive.
+					case 6: break; //do nothing. not interested in this type of data, which is memory intensive.
+					case 7: break; //do nothing. not interested in this type of data, which is memory intensive.
+					case 8: break; //do nothing. not interested in this type of data, which is memory intensive.
+					case 9:
+							  ISSM_MPI_Bcast(&numstrings,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+							  /*Now allocate string array: */
+							  if(numstrings){
+								  strings=xNew<char*>(numstrings);
+								  for(int i=0;i<numstrings;i++)strings[i]=NULL;
+
+								  /*Go through strings, and read: */
+								  for(int i=0;i<numstrings;i++){
+
+									  ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+									  if(string_size){
+										  string=xNew<char>((string_size+1));
+										  string[string_size]='\0';
+										  ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
+									  }
+									  else{
+										  string=xNew<char>(1);
+										  string[0]='\0';
+									  }
+									  strings[i]=string;
+								  }
+							  }
+
+							  /*Add strings to parameters: */
+							  this->AddConstant(new IoConstant(strings,numstrings,record_name));
+
+							  /*Free string*/
+							  for(int i=0;i<numstrings;i++) xDelete<char>(strings[i]);
+							  xDelete<char*>(strings);
+							  break;
+					default: 
+							  _error_("unknown record type:" << record_code); 
+							  break;
 				}
-
+				xDelete<char>(record_name);
 			}
 		}
Index: /issm/trunk-jpl/src/c/classes/Params/Parameters.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/Parameters.cpp	(revision 20942)
+++ /issm/trunk-jpl/src/c/classes/Params/Parameters.cpp	(revision 20943)
@@ -221,4 +221,18 @@
 
 /*Object management*/
+void Parameters::Delete(int param_enum){/*{{{*/
+
+	_assert_(param_enum>ParametersSTARTEnum);
+	_assert_(param_enum<ParametersENDEnum);
+
+	int index = param_enum - ParametersSTARTEnum -1;
+	if(this->params[index]){
+		delete this->params[index];
+		this->params[index] = NULL;
+	}
+
+	return;
+}
+/*}}}*/
 bool Parameters::Exist(int param_enum){/*{{{*/
 
Index: /issm/trunk-jpl/src/c/classes/Params/Parameters.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/Parameters.h	(revision 20942)
+++ /issm/trunk-jpl/src/c/classes/Params/Parameters.h	(revision 20943)
@@ -32,4 +32,5 @@
 		void  DeepEcho();
 		void  Echo();
+		void  Delete(int enum_type);
 		bool  Exist(int enum_type);
 		void  Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction);
Index: /issm/trunk-jpl/src/c/modules/OutputResultsx/OutputResultsx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 20942)
+++ /issm/trunk-jpl/src/c/modules/OutputResultsx/OutputResultsx.cpp	(revision 20943)
@@ -46,43 +46,44 @@
 	}
 
-	/*Now, open file for writing, if not already done: */
-	if(!femmodel->parameters->Exist(OutputFilePointerEnum)){
+	/*Now, open file for writing*/
+	_assert_(!femmodel->parameters->Exist(OutputFilePointerEnum));
+	femmodel->parameters->FindParam(&outputfilename,OutputFileNameEnum);
+	femmodel->parameters->FindParam(&io_gather,SettingsIoGatherEnum);
 
-		/*We don't have a file pointer. Retrieve the output file name and open it for writing:*/
-		femmodel->parameters->FindParam(&outputfilename,OutputFileNameEnum);
+#ifdef _HAVE_JAVASCRIPT_
+	femmodel->parameters->FindParam(&fid,OutputFilePointerEnum);
+#else
 
-		/*What strategy? : */
-		femmodel->parameters->FindParam(&io_gather,SettingsIoGatherEnum);
+	if(io_gather){
+		/*Just open the file for output on cpu 0. We are gathering the data on cpu 0 from all other cpus: */
+		if(my_rank==0) fid=pfopen0(outputfilename ,"ab+");
+	}
+	else{
+		/*We are opening different  files for output on all cpus. Append the  rank to the filename, and open: */
+		sprintf(cpu_outputfilename,"%s.%i",outputfilename,my_rank);
+		fid=pfopen(cpu_outputfilename ,"ab+");
+	}
 
-		if(io_gather){
-			/*Just open the file for output on cpu 0. We are gathering the data on cpu 0 from all other cpus: */
-			if(my_rank==0) fid=pfopen0(outputfilename ,"wb");
-		}
-		else{
-			/*We are opening different  files for output on all cpus. Append the  rank to the filename, and open: */
-			femmodel->parameters->FindParam(&fid,OutputFilePointerEnum);
-			sprintf(cpu_outputfilename,"%s.%i",outputfilename,my_rank);
-			fid=pfopen(cpu_outputfilename ,"wb");
-		}
-		xDelete<char>(outputfilename);
-
-		/*Add file pointer in parameters for further calls to OutputResultsx: */
-		femmodel->parameters->SetParam(fid,OutputFilePointerEnum);
-	}
+	/*Add file pointer in parameters for further calls to OutputResultsx: */
+	femmodel->parameters->SetParam(fid,OutputFilePointerEnum);
+#endif
 
 	/*Write results to disk: */
 	femmodel->results->Write(femmodel->parameters);
 
+	femmodel->parameters->Delete(OutputFilePointerEnum);
+
 	/*Delete and reinitialize results, in parallel: */
 	femmodel->results->clear();
 
+#ifndef _HAVE_JAVASCRIPT_
 	/*Close output file? :*/
-	/*FIXME WARNING: issm.cpp is taking care of it for now (quick fix)
-	  if((step==1) && (time==0)){
-	  if(io_gather){
-	  if(my_rank==0) pfclose(fid,outputfilename);
-	  }
-	  else pfclose(fid,cpu_outputfilename);
-	  }
-	*/
+	if(io_gather){
+		if(my_rank==0) pfclose(fid,outputfilename);
+	}
+	else pfclose(fid,cpu_outputfilename);
+#endif
+
+	/*Clean up and return*/
+	xDelete<char>(outputfilename);
 }
