Index: /issm/trunk-jpl/src/c/cores/transient_core.cpp
===================================================================
--- /issm/trunk-jpl/src/c/cores/transient_core.cpp	(revision 23066)
+++ /issm/trunk-jpl/src/c/cores/transient_core.cpp	(revision 23067)
@@ -89,79 +89,93 @@
 		tomitgcmcomm=parcom->GetParameterValue();
 
+		int oceangridnxsize,oceangridnysize,ngrids_ocean,nels_ocean;
+		IssmDouble  oceantime,coupling_time;
+		IssmDouble *oceangridx;
+		IssmDouble *oceangridy;
+		IssmDouble *base_oceangrid;
+		IssmDouble* x_ice = NULL;
+		IssmDouble* y_ice = NULL;
+		IssmDouble* lat_ice = NULL;
+		IssmDouble* lon_ice = NULL;
+		IssmDouble* z_ice = NULL;
+		IssmDouble* icebase= NULL;
+		int*        index_ice= NULL;
+		int*        index_ocean = NULL;
+		int         ngrids_ice=femmodel->vertices->NumberOfVertices();
+		int         nels_ice=femmodel->elements->NumberOfElements();
+
+		/*Recover fixed parameters and store them*/
+		femmodel->parameters->FindParam(&coupling_time,TimesteppingCouplingTimeEnum);
 		if(my_rank==0){
-			int oceangridnxsize,oceangridnysize,ngrids_ocean,nels_ocean;
-			IssmDouble  oceantime,coupling_time;
-			IssmDouble *oceangridx;
-			IssmDouble *oceangridy;
-			IssmDouble *base_oceangrid;
-			IssmDouble* x_ice = NULL;
-			IssmDouble* y_ice = NULL;
-			IssmDouble* lat_ice = NULL;
-			IssmDouble* lon_ice = NULL;
-			IssmDouble* z_ice = NULL;
-			IssmDouble* icebase= NULL;
-			int*        index_ice= NULL;
-			int*        index_ocean = NULL;
-			int         ngrids_ice=femmodel->vertices->NumberOfVertices();
-			int         nels_ice=femmodel->elements->NumberOfElements();
-
-			/*Recover fixed parameters and store them*/
-			femmodel->parameters->FindParam(&coupling_time,TimesteppingCouplingTimeEnum);
 			ISSM_MPI_Send(&coupling_time,1,ISSM_MPI_DOUBLE,0,10001000,tomitgcmcomm);
 			ISSM_MPI_Recv(&oceangridnxsize,1,ISSM_MPI_INT,0,10001003,tomitgcmcomm,&status);
 			ISSM_MPI_Recv(&oceangridnysize,1,ISSM_MPI_INT,0,10001004,tomitgcmcomm,&status);
-			femmodel->parameters->SetParam(oceangridnxsize,OceanGridNxEnum);
-			femmodel->parameters->SetParam(oceangridnysize,OceanGridNyEnum);
-			ngrids_ocean=oceangridnxsize*oceangridnysize;
+		}
+		ngrids_ocean=oceangridnxsize*oceangridnysize;
+		ISSM_MPI_Bcast(&oceangridnxsize,1,ISSM_MPI_INT,0,IssmComm::GetComm());
+		ISSM_MPI_Bcast(&oceangridnysize,1,ISSM_MPI_INT,0,IssmComm::GetComm());
+		ISSM_MPI_Bcast(&ngrids_ocean,1,ISSM_MPI_INT,0,IssmComm::GetComm());
+		ISSM_MPI_Bcast(&oceantime,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
+		femmodel->parameters->SetParam(oceangridnxsize,OceanGridNxEnum);
+		femmodel->parameters->SetParam(oceangridnysize,OceanGridNyEnum);
+		if(my_rank==0){
 			oceangridx = xNew<IssmDouble>(ngrids_ocean);
 			ISSM_MPI_Recv(oceangridx,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001005,tomitgcmcomm,&status);
 			oceangridy = xNew<IssmDouble>(ngrids_ocean);
 			ISSM_MPI_Recv(oceangridy,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001006,tomitgcmcomm,&status);
-			femmodel->parameters->SetParam(oceangridx,ngrids_ocean,OceanGridXEnum);
-			femmodel->parameters->SetParam(oceangridy,ngrids_ocean,OceanGridYEnum);
 
 			/*Exchange varying parameters for the initialization*/
 			ISSM_MPI_Send(&time,1,ISSM_MPI_DOUBLE,0,10001001,tomitgcmcomm);
 			ISSM_MPI_Recv(&oceantime,1,ISSM_MPI_DOUBLE,0,10001002,tomitgcmcomm,&status);
-
-			/*Interpolate ice base onto ocean grid*/
-			femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&z_ice,&index_ice);
-			BamgTriangulatex(&index_ocean,&nels_ocean,oceangridx,oceangridy,ngrids_ocean);
-			femmodel->vertices->LatLonList(&lat_ice,&lon_ice);
-			GetVectorFromInputsx(&icebase,femmodel,BaseEnum,VertexSIdEnum);
-			Options* options = new Options();
-			GenericOption<double> *odouble = new GenericOption<double>();
-			const char* name = "default";
-			odouble->name =xNew<char>(strlen(name)+1);
-			memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
-			odouble->value=+9999.;
-			odouble->numel=1;
-			odouble->ndims=1;
-			odouble->size=NULL;
-			options->AddOption(odouble);
-			InterpFromMeshToMesh2dx(&base_oceangrid,index_ice,lon_ice,lat_ice,ngrids_ice,nels_ice,
-							icebase,ngrids_ice,1,
-							oceangridx,oceangridy,ngrids_ocean,options);
-			delete options;
-
+		}
+		if(my_rank!=0){
+			oceangridx=xNew<IssmDouble>(ngrids_ocean);
+			oceangridy=xNew<IssmDouble>(ngrids_ocean);
+		}
+		ISSM_MPI_Bcast(oceangridx,ngrids_ocean,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
+		ISSM_MPI_Bcast(oceangridy,ngrids_ocean,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
+		femmodel->parameters->SetParam(oceangridx,ngrids_ocean,OceanGridXEnum);
+		femmodel->parameters->SetParam(oceangridy,ngrids_ocean,OceanGridYEnum);
+
+		/*Interpolate ice base onto ocean grid*/
+		femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&z_ice,&index_ice);
+		BamgTriangulatex(&index_ocean,&nels_ocean,oceangridx,oceangridy,ngrids_ocean);
+		femmodel->vertices->LatLonList(&lat_ice,&lon_ice);
+		GetVectorFromInputsx(&icebase,femmodel,BaseEnum,VertexSIdEnum);
+		Options* options = new Options();
+		GenericOption<double> *odouble = new GenericOption<double>();
+		const char* name = "default";
+		odouble->name =xNew<char>(strlen(name)+1);
+		memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
+		odouble->value=+9999.;
+		odouble->numel=1;
+		odouble->ndims=1;
+		odouble->size=NULL;
+		options->AddOption(odouble);
+		InterpFromMeshToMesh2dx(&base_oceangrid,index_ice,lon_ice,lat_ice,ngrids_ice,nels_ice,
+						icebase,ngrids_ice,1,
+						oceangridx,oceangridy,ngrids_ocean,options);
+		delete options;
+
+		if(my_rank==0){
 			ISSM_MPI_Send(base_oceangrid,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm);
-
-			/*Delete*/
-			xDelete<int>(index_ice);
-			xDelete<int>(index_ocean);
-			xDelete<IssmDouble>(lat_ice);
-			xDelete<IssmDouble>(lon_ice);
-			xDelete<IssmDouble>(x_ice);
-			xDelete<IssmDouble>(y_ice);
-			xDelete<IssmDouble>(z_ice);
-			xDelete<IssmDouble>(icebase);
-			xDelete<IssmDouble>(base_oceangrid);
-			xDelete<IssmDouble>(oceangridx);
-			xDelete<IssmDouble>(oceangridy);
-		}
-		#else
-		_error_("not supported");
-		#endif
+		}
+
+		/*Delete*/
+		xDelete<int>(index_ice);
+		xDelete<int>(index_ocean);
+		xDelete<IssmDouble>(lat_ice);
+		xDelete<IssmDouble>(lon_ice);
+		xDelete<IssmDouble>(x_ice);
+		xDelete<IssmDouble>(y_ice);
+		xDelete<IssmDouble>(z_ice);
+		xDelete<IssmDouble>(icebase);
+		xDelete<IssmDouble>(base_oceangrid);
+		xDelete<IssmDouble>(oceangridx);
+		xDelete<IssmDouble>(oceangridy);
 	}
+	#else
+	_error_("not supported");
+	#endif
 	/*}}}*/
 
@@ -220,75 +234,77 @@
 			if(!parcom)_error_("TransferForcing error message: could not find ToMITgcmCommEnum communicator");
 			tomitgcmcomm=parcom->GetParameterValue();
+			int ngrids_ocean, nels_ocean;
+			IssmDouble oceantime;
+			IssmDouble rho_ice;
+			IssmDouble *oceanmelt;
+			IssmDouble *base_oceangrid;
+			IssmDouble *oceangridx;
+			IssmDouble *oceangridy;
+			IssmDouble* x_ice = NULL;
+			IssmDouble* y_ice = NULL;
+			IssmDouble* lat_ice = NULL;
+			IssmDouble* lon_ice = NULL;
+			IssmDouble* z_ice = NULL;
+			IssmDouble* icebase= NULL;
+			IssmDouble* melt_mesh = NULL;
+			int*        index_ice= NULL;
+			int*        index_ocean = NULL;
+			int         ngrids_ice=femmodel->vertices->NumberOfVertices();
+			int         nels_ice=femmodel->elements->NumberOfElements();
+
+			/*Recover mesh and inputs needed*/
+			femmodel->parameters->FindParam(&rho_ice,MaterialsRhoIceEnum);
+			femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&z_ice,&index_ice);
+			femmodel->parameters->FindParam(&oceangridx,&ngrids_ocean,OceanGridXEnum);
+			femmodel->parameters->FindParam(&oceangridy,&ngrids_ocean,OceanGridYEnum);
+			BamgTriangulatex(&index_ocean,&nels_ocean,oceangridx,oceangridy,ngrids_ocean);
+
+			femmodel->vertices->LatLonList(&lat_ice,&lon_ice);
+
+			/*Interpolate ice base onto ocean grid*/
+			GetVectorFromInputsx(&icebase,femmodel,BaseEnum,VertexSIdEnum);
+			InterpFromMeshToMesh2dx(&base_oceangrid,index_ice,lon_ice,lat_ice,ngrids_ice,nels_ice,
+						icebase,ngrids_ice,1,
+						oceangridx,oceangridy,ngrids_ocean,NULL);
+
+			/*Send and receive data*/
 			if(my_rank==0){
-				int ngrids_ocean, nels_ocean;
-				IssmDouble oceantime;
-				IssmDouble rho_ice;
-				IssmDouble *oceanmelt;
-				IssmDouble *base_oceangrid;
-				IssmDouble *oceangridx;
-				IssmDouble *oceangridy;
-				IssmDouble* x_ice = NULL;
-				IssmDouble* y_ice = NULL;
-				IssmDouble* lat_ice = NULL;
-				IssmDouble* lon_ice = NULL;
-				IssmDouble* z_ice = NULL;
-				IssmDouble* icebase= NULL;
-				IssmDouble* melt_mesh = NULL;
-				int*        index_ice= NULL;
-				int*        index_ocean = NULL;
-				int         ngrids_ice=femmodel->vertices->NumberOfVertices();
-				int         nels_ice=femmodel->elements->NumberOfElements();
-
-				/*Recover mesh and inputs needed*/
-				femmodel->parameters->FindParam(&rho_ice,MaterialsRhoIceEnum);
-				femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&z_ice,&index_ice);
-				femmodel->parameters->FindParam(&oceangridx,&ngrids_ocean,OceanGridXEnum);
-				femmodel->parameters->FindParam(&oceangridy,&ngrids_ocean,OceanGridYEnum);
-				BamgTriangulatex(&index_ocean,&nels_ocean,oceangridx,oceangridy,ngrids_ocean);
-
-				femmodel->vertices->LatLonList(&lat_ice,&lon_ice);
-
-				/*Interpolate ice base onto ocean grid*/
-				GetVectorFromInputsx(&icebase,femmodel,BaseEnum,VertexSIdEnum);
-				InterpFromMeshToMesh2dx(&base_oceangrid,index_ice,lon_ice,lat_ice,ngrids_ice,nels_ice,
-							icebase,ngrids_ice,1,
-							oceangridx,oceangridy,ngrids_ocean,NULL);
-
-				/*Send and receive data*/
 				ISSM_MPI_Send(&time,1,ISSM_MPI_DOUBLE,0,10001001,tomitgcmcomm);
-				oceanmelt = xNew<IssmDouble>(ngrids_ocean);
 				ISSM_MPI_Recv(&oceantime,1,ISSM_MPI_DOUBLE,0,10001002,tomitgcmcomm,&status);
 				if((oceantime - time > 0.1*yts) & (oceantime - time < -0.1*yts)) _error_("Ocean and ice time are starting to diverge");
+				oceanmelt = xNew<IssmDouble>(ngrids_ocean);
 				ISSM_MPI_Recv(oceanmelt,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001007,tomitgcmcomm,&status);
-				//for(int i=0;i<ngrids_ice;i++) base_oceangrid[i]=0;
 				ISSM_MPI_Send(base_oceangrid,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm);
-
-				/*Interp melt onto ice grid*/
-				InterpFromMeshToMesh2dx(&melt_mesh,index_ocean,oceangridx,oceangridy,ngrids_ocean,nels_ocean,
-							oceanmelt,ngrids_ocean,1,
-							lon_ice,lat_ice,ngrids_ice,NULL);
-
-				for(int i=0;i<ngrids_ice;i++) melt_mesh[i]=-melt_mesh[i]/rho_ice; //heat flux provided by ocean is in kg/m^2/s
-				InputUpdateFromVectorx(femmodel,melt_mesh,BasalforcingsFloatingiceMeltingRateEnum,VertexSIdEnum);
-
-				/*Delete*/
-				xDelete<int>(index_ice);
-				xDelete<int>(index_ocean);
-				xDelete<IssmDouble>(lat_ice);
-				xDelete<IssmDouble>(lon_ice);
-				xDelete<IssmDouble>(x_ice);
-				xDelete<IssmDouble>(y_ice);
-				xDelete<IssmDouble>(z_ice);
-				xDelete<IssmDouble>(melt_mesh);
-				xDelete<IssmDouble>(oceangridx);
-				xDelete<IssmDouble>(oceangridy);
-				xDelete<IssmDouble>(oceanmelt);
-				xDelete<IssmDouble>(icebase);
-				xDelete<IssmDouble>(base_oceangrid);
 			}
-			#else
-			_error_("not supported");
-			#endif
-		}
+			ISSM_MPI_Bcast(&oceantime,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
+			if(my_rank!=0) oceanmelt=xNew<IssmDouble>(ngrids_ocean);
+			ISSM_MPI_Bcast(oceanmelt,ngrids_ocean,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
+
+			/*Interp melt onto ice grid*/
+			InterpFromMeshToMesh2dx(&melt_mesh,index_ocean,oceangridx,oceangridy,ngrids_ocean,nels_ocean,
+						oceanmelt,ngrids_ocean,1,
+						lon_ice,lat_ice,ngrids_ice,NULL);
+
+			for(int i=0;i<ngrids_ice;i++) melt_mesh[i]=-melt_mesh[i]/rho_ice; //heat flux provided by ocean is in kg/m^2/s
+			InputUpdateFromVectorx(femmodel,melt_mesh,BasalforcingsFloatingiceMeltingRateEnum,VertexSIdEnum);
+
+			/*Delete*/
+			xDelete<int>(index_ice);
+			xDelete<int>(index_ocean);
+			xDelete<IssmDouble>(lat_ice);
+			xDelete<IssmDouble>(lon_ice);
+			xDelete<IssmDouble>(x_ice);
+			xDelete<IssmDouble>(y_ice);
+			xDelete<IssmDouble>(z_ice);
+			xDelete<IssmDouble>(melt_mesh);
+			xDelete<IssmDouble>(oceangridx);
+			xDelete<IssmDouble>(oceangridy);
+			xDelete<IssmDouble>(oceanmelt);
+			xDelete<IssmDouble>(icebase);
+			xDelete<IssmDouble>(base_oceangrid);
+		}
+		#else
+		_error_("not supported");
+		#endif
 		/*}}}*/
 
