Changeset 22825
- Timestamp:
- 06/04/18 17:32:11 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/cores/transient_core.cpp
r22816 r22825 77 77 #endif 78 78 79 if(isoceancoupling){ {{{ 79 if(isoceancoupling){ /*{{{*/ 80 #ifndef _HAVE_ADOLC_ 80 81 if(VerboseSolution()) _printf0_(" ocean coupling: initialization \n"); 81 82 int my_rank; 82 int oceangridnxsize,oceangridnysize;83 IssmDouble *oceangridx;84 IssmDouble *oceangridy;85 IssmDouble *icebase;86 IssmDouble coupling_time,oceantime;87 83 ISSM_MPI_Comm tomitgcmcomm; 88 84 ISSM_MPI_Status status; 89 85 90 86 my_rank=IssmComm::GetRank(); 91 femmodel->parameters->FindParam(&coupling_time,TimesteppingCouplingTimeEnum);92 87 GenericParam<ISSM_MPI_Comm>* parcom = dynamic_cast<GenericParam<ISSM_MPI_Comm>*>(femmodel->parameters->FindParamObject(ToMITgcmCommEnum)); 93 88 if(!parcom)_error_("TransferForcing error message: could not find ToMITgcmCommEnum communicator"); 94 89 tomitgcmcomm=parcom->GetParameterValue(); 90 95 91 if(my_rank==0){ 92 int oceangridnxsize,oceangridnysize,ngrids_ocean,nels_ocean; 93 IssmDouble oceantime,coupling_time; 94 IssmDouble *oceangridx; 95 IssmDouble *oceangridy; 96 IssmDouble *base_oceangrid; 97 IssmDouble* x_ice = NULL; 98 IssmDouble* y_ice = NULL; 99 IssmDouble* lat_ice = NULL; 100 IssmDouble* lon_ice = NULL; 101 IssmDouble* z_ice = NULL; 102 IssmDouble* icebase= NULL; 103 int* index_ice= NULL; 104 int* index_ocean = NULL; 105 int ngrids_ice=femmodel->vertices->NumberOfVertices(); 106 int nels_ice=femmodel->elements->NumberOfElements(); 107 96 108 /*Recover fixed parameters and store them*/ 109 femmodel->parameters->FindParam(&coupling_time,TimesteppingCouplingTimeEnum); 97 110 ISSM_MPI_Send(&coupling_time,1,ISSM_MPI_DOUBLE,0,10001000,tomitgcmcomm); 98 111 ISSM_MPI_Recv(&oceangridnxsize,1,ISSM_MPI_INT,0,10001003,tomitgcmcomm,&status); … … 100 113 femmodel->parameters->SetParam(oceangridnxsize,OceanGridNxEnum); 101 114 femmodel->parameters->SetParam(oceangridnysize,OceanGridNyEnum); 102 oceangridx = xNew<IssmDouble>(oceangridnxsize*oceangridnysize); 103 ISSM_MPI_Recv(oceangridx,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001005,tomitgcmcomm,&status); 104 oceangridy = xNew<IssmDouble>(oceangridnxsize*oceangridnysize); 105 ISSM_MPI_Recv(oceangridy,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001006,tomitgcmcomm,&status); 106 femmodel->parameters->SetParam(oceangridx,oceangridnxsize*oceangridnysize,OceanGridXEnum); 107 femmodel->parameters->SetParam(oceangridy,oceangridnxsize*oceangridnysize,OceanGridYEnum); 115 ngrids_ocean=oceangridnxsize*oceangridnysize; 116 oceangridx = xNew<IssmDouble>(ngrids_ocean); 117 ISSM_MPI_Recv(oceangridx,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001005,tomitgcmcomm,&status); 118 oceangridy = xNew<IssmDouble>(ngrids_ocean); 119 ISSM_MPI_Recv(oceangridy,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001006,tomitgcmcomm,&status); 120 femmodel->parameters->SetParam(oceangridx,ngrids_ocean,OceanGridXEnum); 121 femmodel->parameters->SetParam(oceangridy,ngrids_ocean,OceanGridYEnum); 108 122 109 123 /*Exchange varying parameters for the initialization*/ 110 124 ISSM_MPI_Send(&time,1,ISSM_MPI_DOUBLE,0,10001001,tomitgcmcomm); 111 125 ISSM_MPI_Recv(&oceantime,1,ISSM_MPI_DOUBLE,0,10001002,tomitgcmcomm,&status); 112 icebase = xNew<IssmDouble>(oceangridnxsize*oceangridnysize); 113 for(int i=0;i<oceangridnxsize;i++){ 114 for(int j=0;j<oceangridnysize;j++){ 115 icebase[i*oceangridnysize+j]=2*oceangridx[i*oceangridnysize+j]; 116 } 117 } 118 ISSM_MPI_Send(icebase,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm); 126 127 /*Interpolate ice base onto ocean grid*/ 128 femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&z_ice,&index_ice); 129 BamgTriangulatex(&index_ocean,&nels_ocean,oceangridx,oceangridy,ngrids_ocean); 130 femmodel->vertices->LatLonList(&lat_ice,&lon_ice); 131 GetVectorFromInputsx(&icebase,femmodel,BaseEnum,VertexSIdEnum); 132 InterpFromMeshToMesh2dx(&base_oceangrid,index_ice,lon_ice,lat_ice,ngrids_ice,nels_ice, 133 icebase,ngrids_ice,1, 134 oceangridx,oceangridy,ngrids_ocean,NULL); 135 136 ISSM_MPI_Send(base_oceangrid,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm); 137 138 /*Delete*/ 139 xDelete<int>(index_ice); 140 xDelete<int>(index_ocean); 141 xDelete<IssmDouble>(lat_ice); 142 xDelete<IssmDouble>(lon_ice); 143 xDelete<IssmDouble>(x_ice); 144 xDelete<IssmDouble>(y_ice); 145 xDelete<IssmDouble>(z_ice); 119 146 xDelete<IssmDouble>(icebase); 147 xDelete<IssmDouble>(base_oceangrid); 120 148 xDelete<IssmDouble>(oceangridx); 121 149 xDelete<IssmDouble>(oceangridy); 122 150 } 151 #else 152 _error_("not supported"); 153 #endif 123 154 } 124 }}}155 /*}}}*/ 125 156 126 157 IssmDouble output_value; … … 219 250 if((oceantime - time > 0.1*yts) & (oceantime - time < -0.1*yts)) _error_("Ocean and ice time are starting to diverge"); 220 251 ISSM_MPI_Recv(oceanmelt,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001007,tomitgcmcomm,&status); 221 for(int i=0;i<ngrids_ice;i++) base_oceangrid[i]=0;252 //for(int i=0;i<ngrids_ice;i++) base_oceangrid[i]=0; 222 253 ISSM_MPI_Send(base_oceangrid,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm); 223 254
Note:
See TracChangeset
for help on using the changeset viewer.