Commit 7d7e2fbb authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Fix for race condition when loading ecl grids

parent 11a11fa5
......@@ -1304,7 +1304,10 @@ ecl_exit_loop:
bool print_bedges = false;
//some intermediate info
bool print_info = false;
//#if defined(USE_OMP)
// std::vector<omp_lock_t> block_locks(dims[0]*dims[1]*dims[2]);
// for(int q = 0; q < dims[0]*dims[1]*dims[2]; ++q) omp_init_lock(&block_locks[q]);
//#endif
//check_shared_mrk = false;
//check_private_mrk = false;
......@@ -1344,15 +1347,29 @@ ecl_exit_loop:
tag_name << "PROJ_PNT_PROC_" << GetLocalProcessorRank();
pnt = CreateTag(tag_name.str(),DATA_REAL,NODE,NONE,2);
}
for(int uneven = 0; uneven < 2; uneven++)
#if defined(USE_OMP)
#pragma omp for
#endif
for(int i = 0; i < dims[0]+q; i++)
//for(int i = 0; i < dims[0]+q; i++)
for(int jt = uneven; jt < dims[1-q]+1; jt+=2)
{
//printf("%s %6.2f%%\r",q ? "ny":"nx", ((Storage::real)i)/((Storage::real)dims[0]+q-1)*100);
//fflush(stdout);
for(int j = 0; j < dims[1]+(1-q); ++j)
//for(int j = 0; j < dims[1]+(1-q); ++j)
for(int it = 0; it < dims[q]; it++)
{
int i,j;
if( q )
{
i = jt;
j = it;
}
else
{
i = it;
j = jt;
}
//if( i == 63 && j == 129 && q == 1 ) print_inter = true;
if( print_info )
{
......@@ -1471,7 +1488,15 @@ ecl_exit_loop:
{
Storage::integer_array b = edges[k].IntegerArray(block_number);
for(int r = 0; r < (int)b.size(); ++r)
{
//#if defined(USE_OMP)
// omp_set_lock(&block_locks[b[r]]);
//#endif
block_edges[b[r]].push_back(edges[k]);
//#if defined(USE_OMP)
// omp_unset_lock(&block_locks[b[r]]);
//#endif
}
}
//sort block numbers on edges
for(int k = 0; k < (int)edges.size(); ++k)
......@@ -1704,7 +1729,13 @@ ecl_exit_loop:
f->Integer(face_origin) = q;
if(!f->CheckEdgeOrder()) std::cout << __FILE__ << ":" << __LINE__ << " bad edge order, edges " << loop.size() << std::endl;
//detect block number
//#if defined(USE_OMP)
// omp_set_lock(&block_locks[ECL_IJK_DATA(blocki[m],blockj[m],k)]);
//#endif
block_faces[ECL_IJK_DATA(blocki[m],blockj[m],k)].push_back(f);
//#if defined(USE_OMP)
// omp_unset_lock(&block_locks[ECL_IJK_DATA(blocki[m],blockj[m],k)]);
//#endif
/*
ElementArray<Element> nodes = f->getAdjElements(NODE);
//block_number_intersection(nodes,block_number,block_number_inter);
......@@ -1846,6 +1877,9 @@ ecl_exit_loop:
//printf("\n");
printf("finished creating faces for pairs of pillar along %s\n",q ? "ny":"nx");
} //q
//#if defined(USE_OMP)
// for(int q = 0; q < dims[0]*dims[1]*dims[2]; ++q) omp_destroy_lock(&block_locks[q]);
//#endif
//do not need this tag on nodes
//DeleteTag(block_number, NODE);
//now construct top and bottom interfaces
......@@ -1856,10 +1890,12 @@ ecl_exit_loop:
#endif
{
ElementArray<Node> edge_nodes(this,2);
for(int q = 0; q < 2; ++q) //uneven cell construction for OpenMP
{
#if defined(USE_OMP)
#pragma omp for
#endif
for(int i = 0; i < dims[0]; ++i)
for(int i = q; i < dims[0]; i+=2)
{
//printf("top/bottom/cells %6.2f%%\r", ((Storage::real)i)/((Storage::real)dims[0]-1)*100);
//fflush(stdout);
......@@ -2063,6 +2099,7 @@ ecl_exit_loop:
} //k
} //j
} //i
} //q
}
printf("finished tops/bottoms/cells\n");
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment