41 std::string
readopts(
"PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS" );
48 MPI_Init( &argc, &argv );
54 std::string
atmFilename = TestDir +
"unittest/wholeATM_T.h5m";
70 std::string ocnFilename = TestDir +
"unittest/recMeshOcn.h5m";
71 std::string mapFilename = TestDir +
"unittest/atm_ocn_map.nc";
73 std::string baseline = TestDir +
"unittest/baseline1.txt";
74 int rankInOcnComm = -1;
75 int cmpocn = 17, cplocn = 18,
78 int rankInCouComm = -1;
92 opts.
addOpt< std::string >(
"atmosphere,t",
"atm mesh filename (source)", &
atmFilename );
93 opts.
addOpt< std::string >(
"ocean,m",
"ocean mesh filename (target)", &ocnFilename );
94 opts.
addOpt< std::string >(
"map_file,w",
"map file from source to target", &mapFilename );
96 opts.
addOpt<
int >(
"startAtm,a",
"start task for atmosphere layout", &
startG1 );
97 opts.
addOpt<
int >(
"endAtm,b",
"end task for atmosphere layout", &
endG1 );
99 opts.
addOpt<
int >(
"startOcn,c",
"start task for ocean layout", &
startG2 );
100 opts.
addOpt<
int >(
"endOcn,d",
"end task for ocean layout", &
endG2 );
102 opts.
addOpt<
int >(
"startCoupler,g",
"start task for coupler layout", &startG4 );
103 opts.
addOpt<
int >(
"endCoupler,j",
"end task for coupler layout", &endG4 );
106 opts.
addOpt<
int >(
"iterations,n",
"number of iterations for coupler", &n );
108 bool no_regression_test =
false;
109 opts.
addOpt<
void >(
"no_regression,r",
"do not do regression test against baseline 1", &no_regression_test );
117 <<
"\n ocn file: " << ocnFilename <<
"\n on tasks : " <<
startG2 <<
":" <<
endG2
118 <<
"\n map file:" << mapFilename <<
"\n on tasks : " << startG4 <<
":" << endG4 <<
"\n";
119 if( !no_regression_test )
121 std::cout <<
" check projection against baseline: " << baseline <<
"\n";
130 MPI_Group atmPEGroup;
133 CHECKIERR(
ierr,
"Cannot create atm MPI group and communicator " )
135 MPI_Group ocnPEGroup;
141 MPI_Group couPEGroup;
147 MPI_Group joinAtmCouGroup;
153 MPI_Group joinOcnCouGroup;
161 int cmpAtmAppID = -1;
163 int cplAtmAppID = -1;
166 int cmpOcnAppID = -1;
168 int cplOcnAppID = -1, cplAtmOcnAppID = -1;
172 if( couComm != MPI_COMM_NULL )
174 MPI_Comm_rank( couComm, &rankInCouComm );
185 if( atmComm != MPI_COMM_NULL )
195 if( ocnComm != MPI_COMM_NULL )
197 MPI_Comm_rank( ocnComm, &rankInOcnComm );
206 if( couComm != MPI_COMM_NULL )
210 CHECKIERR(
ierr,
"Cannot register ocn_atm map instance over coupler pes " )
213 int disc_orders[3] = { 4, 1, 1 };
215 const std::string intx_from_file_identifier =
"map-from-file";
217 if( couComm != MPI_COMM_NULL )
220 int dummy_rowcol = -1;
222 ierr = iMOAB_LoadMappingWeightsFromFile( cplAtmOcnPID, &dummyCpl, &dummy_rowcol, &dummyType,
223 intx_from_file_identifier.c_str(), mapFilename.c_str() );
227 if( atmCouComm != MPI_COMM_NULL )
232 ierr = iMOAB_MigrateMapMesh( cmpAtmPID, cplAtmOcnPID, cplAtmPID, &atmCouComm, &atmPEGroup, &couPEGroup, &type,
233 &
cmpatm, &cplocn, &direction );
234 CHECKIERR(
ierr,
"failed to migrate mesh for atm on coupler" );
236 if( *cplAtmPID >= 0 )
238 char prefix[] =
"atmcov";
246 if( ocnCouComm != MPI_COMM_NULL )
251 ierr = iMOAB_MigrateMapMesh( cmpOcnPID, cplAtmOcnPID, cplOcnPID, &ocnCouComm, &ocnPEGroup, &couPEGroup, &type,
252 &cmpocn, &cplocn, &direction );
253 CHECKIERR(
ierr,
"failed to migrate mesh for ocn on coupler" );
255 if( *cplOcnPID >= 0 )
257 char prefix[] =
"ocntgt";
260 char outputFileRec[] =
"CoupOcn.h5m";
270 int atmCompNDoFs = disc_orders[0] * disc_orders[0], ocnCompNDoFs = 1 ;
272 const char* bottomFields =
"a2oTbot:a2oUbot:a2oVbot";
273 const char* bottomProjectedFields =
"a2oTbot_proj:a2oUbot_proj:a2oVbot_proj";
275 if( couComm != MPI_COMM_NULL )
278 CHECKIERR(
ierr,
"failed to define the field tags a2oTbot:a2oUbot:a2oVbot" );
281 CHECKIERR(
ierr,
"failed to define the field tags a2oTbot_proj:a2oUbot_proj:a2oVbot_proj " );
292 if( cplAtmAppID >= 0 )
294 int nverts[3], nelem[3], nblocks[3], nsbc[3], ndbc[3];
304 int numAllElem = nelem[2];
305 std::vector< double > vals;
306 int storLeng = atmCompNDoFs * numAllElem * 3;
309 vals.resize( storLeng );
310 for(
int k = 0; k < storLeng; k++ )
318 const char* concat_fieldname =
"a2oTbot:a2oUbot:a2oVbot";
319 const char* concat_fieldnameT =
"a2oTbot_proj:a2oUbot_proj:a2oVbot_proj";
322 for(
int iters = 0; iters < n; iters++ )
325 PUSH_TIMER(
"Send/receive data from atm component to coupler in ocn context" )
326 if( atmComm != MPI_COMM_NULL )
330 ierr = iMOAB_SendElementTag( cmpAtmPID,
"a2oTbot:a2oUbot:a2oVbot", &atmCouComm, &cplocn );
335 iMOAB_DumpCommGraph( cmpAtmPID, &
context, &is_sender,
"AtmCovOcnS" );
338 if( couComm != MPI_COMM_NULL )
341 ierr = iMOAB_ReceiveElementTag( cplAtmPID,
"a2oTbot:a2oUbot:a2oVbot", &atmCouComm, &
cmpatm );
346 iMOAB_DumpCommGraph( cmpAtmPID, &
context, &is_sender,
"AtmCovOcnR" );
351 if( atmComm != MPI_COMM_NULL )
353 ierr = iMOAB_FreeSenderBuffers( cmpAtmPID, &cplocn );
354 CHECKIERR(
ierr,
"cannot free buffers used to resend atm tag towards the coverage mesh" )
358 if( *cplAtmPID >= 0 && n == 1 )
360 char prefix[] =
"atmcov_withdata";
362 CHECKIERR(
ierr,
"failed to write local atm cov mesh with data" );
365 if( couComm != MPI_COMM_NULL && 1 == n )
368 char outputFileRecvd[] =
"recvAtmCoupOcn.h5m";
370 CHECKIERR(
ierr,
"could not write recvAtmCoupOcn.h5m to disk" )
374 if( couComm != MPI_COMM_NULL )
378 PUSH_TIMER(
"Apply Scalar projection weights" )
379 ierr = iMOAB_ApplyScalarProjectionWeights( cplAtmOcnPID, intx_from_file_identifier.c_str(),
380 concat_fieldname, concat_fieldnameT );
381 CHECKIERR(
ierr, "failed to compute projection weight application" );
385 char outputFileTgt[] =
"fOcnOnCpl8.h5m";
392 if( ocnComm != MPI_COMM_NULL )
397 CHECKIERR(
ierr,
"failed to define the field tag for receiving back the tags "
398 "a2oTbot_proj:a2oUbot_proj:a2oVbot_proj on ocn pes" );
404 if( couComm != MPI_COMM_NULL )
409 iMOAB_SendElementTag( cplOcnPID,
"a2oTbot_proj:a2oUbot_proj:a2oVbot_proj", &ocnCouComm, &context_id );
410 CHECKIERR(
ierr,
"cannot send tag values back to ocean pes" )
414 if( ocnComm != MPI_COMM_NULL )
417 ierr = iMOAB_ReceiveElementTag( cmpOcnPID,
"a2oTbot_proj:a2oUbot_proj:a2oVbot_proj", &ocnCouComm,
419 CHECKIERR(
ierr,
"cannot receive tag values from ocean mesh on coupler pes" )
422 if( couComm != MPI_COMM_NULL )
425 ierr = iMOAB_FreeSenderBuffers( cplOcnPID, &context_id );
429 if( ocnComm != MPI_COMM_NULL && 1 == n )
432 char outputFileOcn[] =
"OcnWithProj.h5m";
437 if( !no_regression_test )
442 int nverts[3], nelem[3];
445 std::vector< int > gidElems;
446 gidElems.resize( nelem[2] );
447 std::vector< double > tempElems;
448 tempElems.resize( nelem[2] );
450 const std::string GidStr =
"GLOBAL_ID";
461 check_baseline_file( baseline, gidElems, tempElems, 1.e-9, err_code );
463 std::cout <<
" passed baseline test atm2ocn on ocean task " << rankInOcnComm <<
"\n";
469 if( couComm != MPI_COMM_NULL )
474 if( ocnComm != MPI_COMM_NULL )
480 if( atmComm != MPI_COMM_NULL )
486 if( couComm != MPI_COMM_NULL )
492 if( couComm != MPI_COMM_NULL )
503 if( MPI_COMM_NULL != atmCouComm ) MPI_Comm_free( &atmCouComm );
504 MPI_Group_free( &joinAtmCouGroup );
505 if( MPI_COMM_NULL != atmComm ) MPI_Comm_free( &atmComm );
507 if( MPI_COMM_NULL != ocnComm ) MPI_Comm_free( &ocnComm );
509 if( MPI_COMM_NULL != ocnCouComm ) MPI_Comm_free( &ocnCouComm );
510 MPI_Group_free( &joinOcnCouGroup );
512 if( MPI_COMM_NULL != couComm ) MPI_Comm_free( &couComm );
514 MPI_Group_free( &atmPEGroup );
516 MPI_Group_free( &ocnPEGroup );
518 MPI_Group_free( &couPEGroup );
519 MPI_Group_free( &
jgroup );