Changeset 1555 for XIOS/dev


Ignore:
Timestamp:
06/29/18 17:16:31 (6 years ago)
Author:
yushan
Message:

all netcdf routines inside critical section

Location:
XIOS/dev/branch_openmp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/bld.cfg

    r1544 r1555  
    3434bld::target libxios.a  
    3535#bld::target generate_fortran_interface.exe  
    36 #bld::target xios_server.exe  
     36bld::target xios_server.exe  
    3737#bld::target test_regular.exe 
    3838#bld::target test_expand_domain.exe 
    3939#bld::target test_new_features.exe  
    4040#bld::target test_unstruct_complete.exe  
    41 bld::target test_omp.exe  
    42 bld::target test_complete_omp.exe  
     41#bld::target test_omp.exe  
     42#bld::target test_complete_omp.exe  
    4343#bld::target test_remap.exe  
    4444#bld::target test_remap_ref.exe  
    45 bld::target test_remap_omp.exe  
     45#bld::target test_remap_omp.exe  
    4646#bld::target test_unstruct_omp.exe 
    4747#bld::target test_netcdf_omp.exe 
     
    5252#bld::target test_connectivity_expand.exe 
    5353#bld::target toy_cmip6.exe 
    54 bld::target toy_cmip6_omp.exe 
     54#bld::target toy_cmip6_omp.exe 
    5555bld::exe_dep 
    5656 
  • XIOS/dev/branch_openmp/src/io/netCdfInterface.cpp

    r1520 r1555  
    2222int CNetCdfInterface::create(const StdString& fileName, int cMode, int& ncId) 
    2323{ 
    24   int status = nc_create(fileName.c_str(), cMode, &ncId); 
     24  int status; 
     25  #pragma omp critical (_netcdf) 
     26  { 
     27    info(100)<<"start nc_create"<<std::endl; 
     28    status = nc_create(fileName.c_str(), cMode, &ncId); 
     29    info(100)<<"end nc_create"<<std::endl; 
     30  } 
    2531  if (NC_NOERR != status) 
    2632  { 
     
    5056{ 
    5157  int status = xios::nc_create_par(fileName.c_str(), cMode, comm, to_mpi_info(MPI_INFO_NULL), &ncId); 
     58 
    5259  if (NC_NOERR != status) 
    5360  { 
     
    7481int CNetCdfInterface::open(const StdString& fileName, int oMode, int& ncId) 
    7582{ 
    76   int status = nc_open(fileName.c_str(), oMode, &ncId); 
     83  int status; 
     84  #pragma omp critical (_netcdf) 
     85  { 
     86    info(100)<<"start nc_open"<<std::endl; 
     87    status = nc_open(fileName.c_str(), oMode, &ncId); 
     88    info(100)<<"end nc_open"<<std::endl; 
     89  } 
    7790  if (NC_NOERR != status) 
    7891  { 
     
    102115int CNetCdfInterface::openPar(const StdString& fileName, int oMode, MPI_Comm comm, MPI_Info info, int& ncId) 
    103116{ 
    104   int status; 
    105   #pragma omp critical (_netcdf) 
    106   status = xios::nc_open_par(fileName.c_str(), oMode, comm, to_mpi_info(MPI_INFO_NULL), &ncId); 
     117  int status = xios::nc_open_par(fileName.c_str(), oMode, comm, to_mpi_info(MPI_INFO_NULL), &ncId); 
    107118   
    108119  if (NC_NOERR != status) 
     
    129140{ 
    130141  int status = NC_NOERR; 
    131   #pragma omp master 
    132   { 
     142  #pragma omp critical (_netcdf) 
     143  { 
     144    info(100)<<"start nc_close"<<std::endl; 
    133145    status = nc_close(ncId); 
    134     if (NC_NOERR != status) 
    135     { 
    136       StdString errormsg(nc_strerror(status)); 
    137       StdStringStream sstr; 
    138       sstr << "Error when calling function nc_close(ncId)" << std::endl 
    139            << errormsg << std::endl 
    140            << "Unable to close file, given its id: " << ncId << std::endl; 
    141       StdString e = sstr.str(); 
    142       throw CNetCdfException(e); 
    143     } 
     146    info(100)<<"end nc_close"<<std::endl; 
     147  } 
     148       
     149  if (NC_NOERR != status) 
     150  { 
     151    StdString errormsg(nc_strerror(status)); 
     152    StdStringStream sstr; 
     153    sstr << "Error when calling function nc_close(ncId)" << std::endl 
     154         << errormsg << std::endl 
     155         << "Unable to close file, given its id: " << ncId << std::endl; 
     156    StdString e = sstr.str(); 
     157    throw CNetCdfException(e); 
    144158  } 
    145159 
     
    154168int CNetCdfInterface::reDef(int ncId) 
    155169{ 
    156   int status = nc_redef(ncId); 
     170  int status; 
     171  #pragma omp critical (_netcdf) 
     172  { 
     173    info(100)<<"start nc_reDef"<<std::endl; 
     174    status = nc_redef(ncId); 
     175    info(100)<<"end nc_reDef"<<std::endl; 
     176  } 
     177   
    157178  if (NC_NOERR != status) 
    158179  { 
     
    176197int CNetCdfInterface::endDef(int ncId) 
    177198{ 
    178   int status = nc_enddef(ncId); 
     199  int status; 
     200  #pragma omp critical (_netcdf) 
     201  { 
     202    info(100)<<"start nc_enddef"<<std::endl; 
     203    status = nc_enddef(ncId); 
     204    info(100)<<"end nc_enddef"<<std::endl; 
     205  } 
    179206  if (NC_NOERR != status) 
    180207  { 
     
    201228int CNetCdfInterface::inqNcId(int ncid, const StdString& grpName, int& grpId) 
    202229{ 
    203   int status = nc_inq_ncid(ncid, grpName.c_str(), &grpId); 
     230  int status; 
     231  #pragma omp critical (_netcdf) 
     232  { 
     233    info(100)<<"start nc_inq_ncid"<<std::endl; 
     234    status = nc_inq_ncid(ncid, grpName.c_str(), &grpId); 
     235    info(100)<<"end nc_inq_ncid"<<std::endl; 
     236  } 
     237   
    204238  if (NC_NOERR != status) 
    205239  { 
     
    227261int CNetCdfInterface::inqVarId(int ncid, const StdString& varName, int& varId) 
    228262{ 
    229   int status = nc_inq_varid(ncid, varName.c_str(), &varId); 
     263  int status; 
     264  #pragma omp critical (_netcdf) 
     265  { 
     266    info(100)<<"start nc_inq_varid"<<std::endl; 
     267    status = nc_inq_varid(ncid, varName.c_str(), &varId); 
     268    info(100)<<"end nc_inq_varid"<<std::endl; 
     269  } 
    230270  if (NC_NOERR != status) 
    231271  { 
     
    252292int CNetCdfInterface::inqDimId(int ncid, const StdString& dimName, int& dimId) 
    253293{ 
    254   int status = nc_inq_dimid(ncid, dimName.c_str(), &dimId); 
     294  int status; 
     295  #pragma omp critical (_netcdf) 
     296  { 
     297    info(100)<<"start nc_inq_dimid"<<std::endl; 
     298    status = nc_inq_dimid(ncid, dimName.c_str(), &dimId); 
     299    info(100)<<"end nc_inq_dimid"<<std::endl; 
     300  } 
     301   
    255302  if (NC_NOERR != status) 
    256303  { 
     
    278325{ 
    279326  char varNameBuff[NC_MAX_NAME + 1]; 
    280   int status = nc_inq_varname(ncid, varId, varNameBuff); 
     327  int status; 
     328  #pragma omp critical (_netcdf) 
     329  { 
     330    info(100)<<"start nc_inq_varname"<<std::endl; 
     331    status = nc_inq_varname(ncid, varId, varNameBuff); 
     332    info(100)<<"end nc_inq_varname"<<std::endl; 
     333  } 
    281334  if (NC_NOERR != status) 
    282335  { 
     
    302355int CNetCdfInterface::inqUnLimDim(int ncid, int& dimId) 
    303356{ 
    304   int status = nc_inq_unlimdim(ncid, &dimId); 
     357  int status; 
     358  #pragma omp critical (_netcdf) 
     359  { 
     360    info(100)<<"start nc_inq_unlimdim"<<std::endl; 
     361    status = nc_inq_unlimdim(ncid, &dimId); 
     362    info(100)<<"end nc_inq_unlimdim"<<std::endl; 
     363  } 
    305364  if (NC_NOERR != status) 
    306365  { 
     
    328387{ 
    329388  char fullNameIn[NC_MAX_NAME + 1]; 
    330   int status = nc_inq_dimname(ncid, dimId, fullNameIn); 
     389  int status; 
     390  #pragma omp critical (_netcdf) 
     391  { 
     392    info(100)<<"start nc_inq_dimname"<<std::endl; 
     393    status = nc_inq_dimname(ncid, dimId, fullNameIn); 
     394    info(100)<<"end nc_inq_dimname"<<std::endl; 
     395  } 
    331396  if (NC_NOERR != status) 
    332397  { 
     
    353418int CNetCdfInterface::inqDimLen(int ncid, int dimId, StdSize& dimLen) 
    354419{ 
    355   int status = nc_inq_dimlen(ncid, dimId, &dimLen); 
     420  int status; 
     421  #pragma omp critical (_netcdf) 
     422  { 
     423    info(100)<<"start nc_inq_dimlen"<<std::endl; 
     424    status = nc_inq_dimlen(ncid, dimId, &dimLen); 
     425    info(100)<<"end nc_inq_dimlen"<<std::endl; 
     426  } 
    356427  if (NC_NOERR != status) 
    357428  { 
     
    378449int CNetCdfInterface::inqVarNDims(int ncid, int varId, int& nDims) 
    379450{ 
    380   int status = nc_inq_varndims(ncid, varId, &nDims); 
     451  int status; 
     452  #pragma omp critical (_netcdf) 
     453  { 
     454    info(100)<<"start nc_inq_varndims"<<std::endl; 
     455    status = nc_inq_varndims(ncid, varId, &nDims); 
     456    info(100)<<"end nc_inq_varndims"<<std::endl; 
     457  } 
    381458  if (NC_NOERR != status) 
    382459  { 
     
    403480int CNetCdfInterface::inqVarDimId(int ncid, int varId, int* dimIds) 
    404481{ 
    405   int status = nc_inq_vardimid(ncid, varId, dimIds); 
     482  int status; 
     483  #pragma omp critical (_netcdf) 
     484  { 
     485    info(100)<<"start nc_inq_vardimid"<<std::endl; 
     486    status = nc_inq_vardimid(ncid, varId, dimIds); 
     487    info(100)<<"end nc_inq_vardimid"<<std::endl; 
     488  } 
    406489  if (NC_NOERR != status) 
    407490  { 
     
    429512int CNetCdfInterface::inqDimIds(int ncid, int& nDims, int* dimIds, int includeParents) 
    430513{ 
    431   int status = nc_inq_dimids(ncid, &nDims, dimIds, includeParents); 
     514  int status; 
     515  #pragma omp critical (_netcdf) 
     516  { 
     517    info(100)<<"start nc_inq_dimids"<<std::endl; 
     518    status = nc_inq_dimids(ncid, &nDims, dimIds, includeParents); 
     519    info(100)<<"end nc_inq_dimids"<<std::endl; 
     520  } 
    432521  if (NC_NOERR != status) 
    433522  { 
     
    456545  StdSize strlen = 0; 
    457546  std::vector<char> buff; 
    458   int status = nc_inq_grpname_full(ncid, &strlen, NULL); 
    459   if (NC_NOERR == status) 
    460   { 
    461     buff.resize(strlen + 1); 
    462     status = nc_inq_grpname_full(ncid, NULL, &buff[0]); 
    463   } 
    464  
     547  int status; 
     548  #pragma omp critical (_netcdf) 
     549  { 
     550    info(100)<<"start nc_inq_grpname_full"<<std::endl; 
     551    status = nc_inq_grpname_full(ncid, &strlen, NULL); 
     552    info(100)<<"end nc_inq_grpname_full"<<std::endl; 
     553   
     554    if (NC_NOERR == status) 
     555    { 
     556      buff.resize(strlen + 1); 
     557      status = nc_inq_grpname_full(ncid, NULL, &buff[0]); 
     558    } 
     559    info(100)<<"start nc_inq_grpname_full"<<std::endl; 
     560  } 
    465561  if (NC_NOERR != status) 
    466562  { 
     
    489585int CNetCdfInterface::inqGrpIds(int ncid, int& numgrps, int* ncids) 
    490586{ 
    491   int status = nc_inq_grps(ncid, &numgrps, ncids); 
     587  int status; 
     588  #pragma omp critical (_netcdf) 
     589  { 
     590    info(100)<<"start nc_inq_grps"<<std::endl; 
     591    status = nc_inq_grps(ncid, &numgrps, ncids); 
     592    info(100)<<"end nc_inq_grps"<<std::endl; 
     593  } 
    492594  if (NC_NOERR != status) 
    493595  { 
     
    514616int CNetCdfInterface::inqVarIds(int ncid, int& nvars, int* varids) 
    515617{ 
    516   int status = nc_inq_varids(ncid, &nvars, varids); 
     618  int status; 
     619  #pragma omp critical (_netcdf) 
     620  { 
     621    info(100)<<"start nc_inq_varids"<<std::endl; 
     622    status = nc_inq_varids(ncid, &nvars, varids); 
     623    info(100)<<"end nc_inq_varids"<<std::endl; 
     624  } 
    517625  if (NC_NOERR != status) 
    518626  { 
     
    541649int CNetCdfInterface::inqAtt(int ncid, int varid, const StdString& name, nc_type& type, size_t& len) 
    542650{ 
    543   int status = nc_inq_att(ncid, varid, name.c_str(), &type, &len); 
     651  int status; 
     652  #pragma omp critical (_netcdf) 
     653  { 
     654    info(100)<<"start nc_inq_att"<<std::endl; 
     655    status = nc_inq_att(ncid, varid, name.c_str(), &type, &len); 
     656    info(100)<<"end nc_inq_att"<<std::endl; 
     657  } 
     658   
    544659  if (NC_NOERR != status) 
    545660  { 
     
    565680int CNetCdfInterface::inqNAtts(int ncid, int& ngatts) 
    566681{ 
    567   int status = nc_inq_natts(ncid, &ngatts); 
     682  int status; 
     683  #pragma omp critical (_netcdf) 
     684  { 
     685    info(100)<<"start nc_inq_natts"<<std::endl; 
     686    status = nc_inq_natts(ncid, &ngatts); 
     687    info(100)<<"end nc_inq_natts"<<std::endl; 
     688  } 
    568689  if (NC_NOERR != status) 
    569690  { 
     
    590711int CNetCdfInterface::inqVarNAtts(int ncid, int varid, int& natts) 
    591712{ 
    592   int status = nc_inq_varnatts(ncid, varid, &natts); 
     713  int status; 
     714  #pragma omp critical (_netcdf) 
     715  { 
     716    info(100)<<"start nc_inq_varnatts"<<std::endl; 
     717    status = nc_inq_varnatts(ncid, varid, &natts); 
     718    info(100)<<"end nc_inq_varnatts"<<std::endl; 
     719  } 
    593720  if (NC_NOERR != status) 
    594721  { 
     
    611738{ 
    612739  std::vector<char> attName(NC_MAX_NAME + 1,' '); 
    613   int status = nc_inq_attname(ncid, varid, attnum, &attName[0]); 
     740  int status; 
     741  #pragma omp critical (_netcdf) 
     742  { 
     743    info(100)<<"start nc_inq_attname"<<std::endl; 
     744    status = nc_inq_attname(ncid, varid, attnum, &attName[0]); 
     745    info(100)<<"end nc_inq_attname"<<std::endl; 
     746  } 
    614747  if (NC_NOERR != status) 
    615748  { 
     
    642775int CNetCdfInterface::defGrp(int parentNcid, const StdString& grpName, int& grpId) 
    643776{ 
    644   int status = nc_def_grp(parentNcid, grpName.c_str(), &grpId); 
     777  int status; 
     778  #pragma omp critical (_netcdf) 
     779  { 
     780    info(100)<<"start nc_def_grp"<<std::endl; 
     781    status = nc_def_grp(parentNcid, grpName.c_str(), &grpId); 
     782    info(100)<<"end nc_def_grp"<<std::endl; 
     783  } 
    645784  if (NC_NOERR != status) 
    646785  { 
     
    667806int CNetCdfInterface::defDim(int ncid, const StdString& dimName, StdSize dimLen, int& dimId) 
    668807{ 
    669   int status = nc_def_dim(ncid, dimName.c_str(), dimLen, &dimId); 
     808  int status; 
     809  #pragma omp critical (_netcdf) 
     810  { 
     811    info(100)<<"start nc_def_dim"<<std::endl; 
     812    status = nc_def_dim(ncid, dimName.c_str(), dimLen, &dimId); 
     813    info(100)<<"end nc_def_dim"<<std::endl; 
     814  } 
    670815  if (NC_NOERR != status) 
    671816  { 
     
    698843                             int nDims, const int dimIds[], int& varId) 
    699844{ 
    700   int status = nc_def_var(ncid, varName.c_str(), xtype, nDims, dimIds, &varId); 
     845  int status; 
     846  #pragma omp critical (_netcdf) 
     847  { 
     848    info(100)<<"start nc_def_var"<<std::endl; 
     849    status = nc_def_var(ncid, varName.c_str(), xtype, nDims, dimIds, &varId); 
     850    info(100)<<"end nc_def_var"<<std::endl; 
     851  } 
    701852  if (NC_NOERR != status) 
    702853  { 
     
    727878int CNetCdfInterface::defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[]) 
    728879{ 
    729   int status = nc_def_var_chunking(ncid, varId, storage, chunkSize); 
     880  int status; 
     881  #pragma omp critical (_netcdf) 
     882  { 
     883    info(100)<<"start nc_def_var_chunking"<<std::endl; 
     884    status = nc_def_var_chunking(ncid, varId, storage, chunkSize); 
     885    info(100)<<"end nc_def_var_chunking"<<std::endl; 
     886  } 
    730887  if (NC_NOERR != status) 
    731888  { 
     
    755912   
    756913  if (compressionLevel == 0) return NC_NOERR ; 
    757   int status = nc_def_var_deflate(ncid, varId, (compressionLevel > 0), (compressionLevel > 0), compressionLevel); 
     914  int status; 
     915  #pragma omp critical (_netcdf) 
     916  { 
     917    info(100)<<"start nc_def_var_deflate"<<std::endl; 
     918    status = nc_def_var_deflate(ncid, varId, (compressionLevel > 0), (compressionLevel > 0), compressionLevel); 
     919    info(100)<<"end nc_def_var_deflate"<<std::endl; 
     920  } 
    758921  if (NC_NOERR != status) 
    759922  { 
     
    781944{ 
    782945  int old_fill_mode; 
    783   int status = nc_set_fill(ncid, fill ? NC_FILL: NC_NOFILL, &old_fill_mode); 
     946  int status; 
     947  #pragma omp critical (_netcdf) 
     948  { 
     949    info(100)<<"start nc_set_fill"<<std::endl; 
     950    status = nc_set_fill(ncid, fill ? NC_FILL: NC_NOFILL, &old_fill_mode); 
     951    info(100)<<"end nc_set_fill"<<std::endl; 
     952  } 
    784953  if (NC_NOERR != status) 
    785954  { 
     
    808977int CNetCdfInterface::defVarFill(int ncid, int varId, int noFill, void* fillValue) 
    809978{ 
    810   int status = nc_def_var_fill(ncid, varId, noFill, fillValue); 
     979  int status; 
     980  #pragma omp critical (_netcdf) 
     981  { 
     982    info(100)<<"start nc_def_var_fill"<<std::endl; 
     983    status = nc_def_var_fill(ncid, varId, noFill, fillValue); 
     984    info(100)<<"end nc_def_var_fill"<<std::endl; 
     985  } 
    811986  if (NC_NOERR != status) 
    812987  { 
     
    8361011int CNetCdfInterface::varParAccess(int ncid, int varId, int access) 
    8371012{ 
    838   int status = nc_var_par_access(ncid, varId, access); 
     1013  int status; 
     1014  #pragma omp critical (_netcdf) 
     1015  { 
     1016    info(100)<<"start nc_var_par_access"<<std::endl; 
     1017    status = nc_var_par_access(ncid, varId, access); 
     1018    info(100)<<"end nc_var_par_access"<<std::endl; 
     1019  } 
    8391020  if (NC_NOERR != status) 
    8401021  { 
     
    8591040int CNetCdfInterface::sync(int ncid) 
    8601041{ 
    861   int status = nc_sync(ncid); 
     1042  int status; 
     1043  #pragma omp critical (_netcdf) 
     1044  { 
     1045    info(100)<<"start nc_sync"<<std::endl; 
     1046    status = nc_sync(ncid); 
     1047    info(100)<<"end nc_sync"<<std::endl; 
     1048  } 
    8621049  if (NC_NOERR != status) 
    8631050  { 
     
    8791066int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, double* data) 
    8801067{ 
    881   return nc_get_att_double(ncid, varid, attrName, data); 
     1068  int status; 
     1069  #pragma omp critical (_netcdf) 
     1070  { 
     1071    info(100)<<"start nc_get_att_double"<<std::endl; 
     1072    status = nc_get_att_double(ncid, varid, attrName, data); 
     1073    info(100)<<"end nc_get_att_double"<<std::endl; 
     1074  } 
     1075  return status; 
    8821076} 
    8831077 
     
    8851079int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, float* data) 
    8861080{ 
    887   return nc_get_att_float(ncid, varid, attrName, data); 
     1081  int status; 
     1082  #pragma omp critical (_netcdf) 
     1083  { 
     1084    info(100)<<"start nc_get_att_float"<<std::endl; 
     1085    status = nc_get_att_float(ncid, varid, attrName, data); 
     1086    info(100)<<"end nc_get_att_float"<<std::endl; 
     1087  } 
     1088  return status; 
    8881089} 
    8891090 
     
    8911092int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, int* data) 
    8921093{ 
    893   return nc_get_att_int(ncid, varid, attrName, data); 
     1094  int status; 
     1095  #pragma omp critical (_netcdf) 
     1096  { 
     1097    info(100)<<"start nc_get_att_int"<<std::endl; 
     1098    status = nc_get_att_int(ncid, varid, attrName, data); 
     1099    info(100)<<"end nc_get_att_int"<<std::endl; 
     1100  } 
     1101  return status;  
    8941102} 
    8951103 
     
    8971105int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, long* data) 
    8981106{ 
    899   return nc_get_att_long(ncid, varid, attrName, data); 
     1107  int status; 
     1108  #pragma omp critical (_netcdf) 
     1109  { 
     1110    info(100)<<"start nc_get_att_long"<<std::endl; 
     1111    status = nc_get_att_long(ncid, varid, attrName, data); 
     1112    info(100)<<"end nc_get_att_long"<<std::endl; 
     1113  } 
     1114  return status; 
    9001115} 
    9011116 
     
    9031118int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, short* data) 
    9041119{ 
    905   return nc_get_att_short(ncid, varid, attrName, data); 
     1120  int status; 
     1121  #pragma omp critical (_netcdf) 
     1122  { 
     1123    info(100)<<"start nc_get_att_short"<<std::endl; 
     1124    status = nc_get_att_short(ncid, varid, attrName, data); 
     1125    info(100)<<"end nc_get_att_short"<<std::endl; 
     1126  } 
     1127  return status; 
    9061128} 
    9071129 
     
    9091131int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, char* data) 
    9101132{ 
    911   return nc_get_att_text(ncid, varid, attrName, data); 
     1133  int status; 
     1134  #pragma omp critical (_netcdf) 
     1135  { 
     1136    info(100)<<"start nc_get_att_text"<<std::endl; 
     1137    status = nc_get_att_text(ncid, varid, attrName, data); 
     1138    info(100)<<"end nc_get_att_text"<<std::endl; 
     1139  } 
     1140  return status; 
    9121141} 
    9131142 
     
    9171146                                   StdSize numVal, const double* data) 
    9181147{ 
    919   return nc_put_att_double(ncid, varid, attrName, NC_DOUBLE, numVal, data); 
     1148  int status; 
     1149  #pragma omp critical (_netcdf) 
     1150  { 
     1151    info(100)<<"start nc_put_att_double"<<std::endl; 
     1152    status = nc_put_att_double(ncid, varid, attrName, NC_DOUBLE, numVal, data); 
     1153    info(100)<<"end nc_put_att_double"<<std::endl; 
     1154  } 
     1155  return status; 
    9201156} 
    9211157 
     
    9241160                                   StdSize numVal, const float* data) 
    9251161{ 
    926   return nc_put_att_float(ncid, varid, attrName, NC_FLOAT, numVal, data); 
     1162  int status; 
     1163  #pragma omp critical (_netcdf) 
     1164  { 
     1165    info(100)<<"start nc_put_att_float"<<std::endl; 
     1166    status = nc_put_att_float(ncid, varid, attrName, NC_FLOAT, numVal, data); 
     1167    info(100)<<"end nc_put_att_float"<<std::endl; 
     1168  } 
     1169  return status; 
    9271170} 
    9281171 
     
    9311174                                   StdSize numVal, const int* data) 
    9321175{ 
    933   return nc_put_att_int(ncid, varid, attrName, NC_INT, numVal, data); 
     1176  int status; 
     1177  #pragma omp critical (_netcdf) 
     1178  { 
     1179    info(100)<<"start nc_put_att_int"<<std::endl; 
     1180    status = nc_put_att_int(ncid, varid, attrName, NC_INT, numVal, data); 
     1181    info(100)<<"end nc_put_att_int"<<std::endl; 
     1182  } 
     1183  return status; 
    9341184} 
    9351185 
     
    9381188                                   StdSize numVal, const long* data) 
    9391189{ 
    940   return nc_put_att_long(ncid, varid, attrName, NC_LONG, numVal, data); 
     1190  int status; 
     1191  #pragma omp critical (_netcdf) 
     1192  { 
     1193    info(100)<<"start nc_put_att_long"<<std::endl; 
     1194    status = nc_put_att_long(ncid, varid, attrName, NC_LONG, numVal, data); 
     1195    info(100)<<"end nc_put_att_long"<<std::endl; 
     1196  } 
     1197  return status; 
    9411198} 
    9421199 
     
    9451202                                   StdSize numVal, const short* data) 
    9461203{ 
    947   return nc_put_att_short(ncid, varid, attrName, NC_SHORT, numVal, data); 
     1204  int status; 
     1205  #pragma omp critical (_netcdf) 
     1206  { 
     1207    info(100)<<"start nc_put_att_short"<<std::endl; 
     1208    status = nc_put_att_short(ncid, varid, attrName, NC_SHORT, numVal, data); 
     1209    info(100)<<"end nc_put_att_short"<<std::endl; 
     1210  } 
     1211  return status; 
    9481212} 
    9491213 
     
    9521216                                   StdSize numVal, const char* data) 
    9531217{ 
    954   return nc_put_att_text(ncid, varid, attrName, numVal, data); 
     1218  int status; 
     1219  #pragma omp critical (_netcdf) 
     1220  { 
     1221    info(100)<<"start nc_put_att_text"<<std::endl; 
     1222    status = nc_put_att_text(ncid, varid, attrName, numVal, data); 
     1223    info(100)<<"end nc_put_att_text"<<std::endl; 
     1224  } 
     1225  return status; 
    9551226} 
    9561227 
     
    9591230int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, double* data) 
    9601231{ 
    961   return nc_get_vara_double(ncid, varid, start, count, data); 
     1232  int status; 
     1233  #pragma omp critical (_netcdf) 
     1234  { 
     1235    info(100)<<"start nc_get_vara_double"<<std::endl; 
     1236    status = nc_get_vara_double(ncid, varid, start, count, data); 
     1237    info(100)<<"end nc_get_vara_double"<<std::endl; 
     1238  } 
     1239  return status; 
    9621240} 
    9631241 
     
    9651243int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, float* data) 
    9661244{ 
    967   return nc_get_vara_float(ncid, varid, start, count, data); 
     1245  int status; 
     1246  #pragma omp critical (_netcdf) 
     1247  { 
     1248    info(100)<<"start nc_get_vara_float"<<std::endl; 
     1249    status = nc_get_vara_float(ncid, varid, start, count, data); 
     1250    info(100)<<"end nc_get_vara_float"<<std::endl; 
     1251  } 
     1252  return status;  
    9681253} 
    9691254 
     
    9711256int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, int* data) 
    9721257{ 
    973   return nc_get_vara_int(ncid, varid, start, count, data); 
     1258  int status; 
     1259  #pragma omp critical (_netcdf) 
     1260  { 
     1261    info(100)<<"start nc_get_vara_int"<<std::endl; 
     1262    status = nc_get_vara_int(ncid, varid, start, count, data); 
     1263    info(100)<<"end nc_get_vara_int"<<std::endl; 
     1264  } 
     1265  return status;  
    9741266} 
    9751267 
     
    9771269int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, char* data) 
    9781270{ 
    979   return nc_get_vara_text(ncid, varid, start, count, data); 
     1271  int status; 
     1272  #pragma omp critical (_netcdf) 
     1273  { 
     1274    info(100)<<"start nc_get_vara_text"<<std::endl; 
     1275    status = nc_get_vara_text(ncid, varid, start, count, data); 
     1276    info(100)<<"end nc_get_vara_text"<<std::endl; 
     1277  } 
     1278  return status; 
    9801279} 
    9811280 
     
    9841283int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const double* data) 
    9851284{ 
    986   return nc_put_vara_double(ncid, varid, start, count, data); 
     1285  int status; 
     1286  #pragma omp critical (_netcdf) 
     1287  { 
     1288    info(100)<<"start nc_put_vara_double"<<std::endl; 
     1289    status = nc_put_vara_double(ncid, varid, start, count, data); 
     1290    info(100)<<"end nc_put_vara_double"<<std::endl; 
     1291  } 
     1292  return status; 
    9871293} 
    9881294 
     
    9901296int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const float* data) 
    9911297{ 
    992   return nc_put_vara_float(ncid, varid, start, count, data); 
     1298  int status; 
     1299  #pragma omp critical (_netcdf) 
     1300  { 
     1301    info(100)<<"start nc_put_vara_float"<<std::endl; 
     1302    status = nc_put_vara_float(ncid, varid, start, count, data); 
     1303    info(100)<<"end nc_put_vara_float"<<std::endl; 
     1304  } 
     1305  return status; 
    9931306} 
    9941307 
     
    9961309int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const int* data) 
    9971310{ 
    998   return nc_put_vara_int(ncid, varid, start, count, data); 
     1311  int status; 
     1312  #pragma omp critical (_netcdf) 
     1313  { 
     1314    info(100)<<"start nc_put_vara_int"<<std::endl; 
     1315    status = nc_put_vara_int(ncid, varid, start, count, data); 
     1316    info(100)<<"end nc_put_vara_int"<<std::endl; 
     1317  } 
     1318  return status; 
    9991319} 
    10001320 
     
    10021322int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const char* data) 
    10031323{ 
    1004   return nc_put_vara_text(ncid, varid, start, count, data); 
     1324  int status; 
     1325  #pragma omp critical (_netcdf) 
     1326  { 
     1327    info(100)<<"start nc_put_vara_text"<<std::endl; 
     1328    status = nc_put_vara_text(ncid, varid, start, count, data); 
     1329    info(100)<<"end nc_put_vara_text"<<std::endl; 
     1330  } 
     1331  return status; 
    10051332} 
    10061333 
     
    10151342{ 
    10161343   int varId = 0; 
    1017    return (NC_NOERR == (nc_inq_varid(ncId, varName.c_str(), &varId))); 
     1344   int status; 
     1345   #pragma omp critical (_netcdf) 
     1346   { 
     1347     info(100)<<"start isVarExisted"<<std::endl; 
     1348     status = nc_inq_varid(ncId, varName.c_str(), &varId); 
     1349     info(100)<<"end isVarExisted"<<std::endl; 
     1350   } 
     1351   return (NC_NOERR == status); 
    10181352} 
    10191353 
     
    10211355{ 
    10221356   int dimId = 0; 
    1023    return (NC_NOERR == (nc_inq_dimid(ncId, dimName.c_str(), &dimId))); 
     1357   int status; 
     1358   #pragma omp critical (_netcdf) 
     1359   { 
     1360     info(100)<<"start isDimExisted"<<std::endl; 
     1361     status = nc_inq_dimid(ncId, dimName.c_str(), &dimId); 
     1362     info(100)<<"end isDimExisted"<<std::endl; 
     1363   } 
     1364   return (NC_NOERR == status); 
    10241365} 
    10251366 
  • XIOS/dev/branch_openmp/src/io/netcdf.hpp

    r1328 r1555  
    3333  { 
    3434#if defined(USING_NETCDF_PAR) 
    35     return ::nc_create_par(path, cmode, comm, info, ncidp) ; 
     35    int status; 
     36    #pragma omp critical (_netcdf) 
     37    { 
     38      status = ::nc_create_par(path, cmode, comm, info, ncidp) ; 
     39    } 
     40    return status; 
    3641#else 
    3742    ERROR("int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info,int *ncidp)", 
     
    4449  { 
    4550#if defined(USING_NETCDF_PAR) 
    46     return ::nc_open_par(path, mode, comm, info, ncidp) ; 
     51    int status; 
     52    #pragma omp critical (_netcdf) 
     53    { 
     54      status = ::nc_open_par(path, mode, comm, info, ncidp) ; 
     55    } 
     56    return status; 
    4757#else 
    4858    ERROR("int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info,int *ncidp)", 
     
    5565  { 
    5666#if defined(USING_NETCDF_PAR) 
    57     return ::nc_var_par_access(ncid, varid, par_access) ; 
     67    int status = ::nc_var_par_access(ncid, varid, par_access) ; 
     68     
     69    return status; 
    5870#else 
    5971    ERROR("int nc_var_par_access(int ncid, int varid, int par_access)", 
  • XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.cpp

    r1545 r1555  
    807807   
    808808  int my_rank_loc = client->intraComm->ep_comm_ptr->size_rank_info[1].first; 
    809    
    810   cout<<"begin write weight info"<< endl; 
     809  int my_rank = client->intraComm->ep_comm_ptr->size_rank_info[0].first; 
     810   
     811   
    811812  
    812813  WriteNetCdf *netCdfWriter; 
    813814 
    814  
    815815  MPI_Barrier_local(client->intraComm); 
     816   
    816817  if(my_rank_loc==0) 
    817818  { 
    818    
     819    info(100)<<"rank "<< my_rank <<" create weight info file"<< std::endl; 
     820     
    819821    WriteNetCdf my_writer(filename, client->intraComm);   
     822    info(100)<<"rank "<< my_rank <<" file created"<< std::endl; 
    820823    netCdfWriter = &my_writer;  
    821824   
     
    824827    netCdfWriter->addDimensionWrite("n_dst", n_dst); 
    825828    netCdfWriter->addDimensionWrite("n_weight", globalNbWeight); 
     829    info(100)<<"rank "<< my_rank <<" addDimensionWrite : n_src, n_dst, n_weight"<< std::endl; 
    826830   
    827831    std::vector<StdString> dims(1,"n_weight"); 
     
    831835    netCdfWriter->addVariableWrite("dst_idx", NC_INT, dims); 
    832836    netCdfWriter->addVariableWrite("weight", NC_DOUBLE, dims); 
     837     
     838    info(100)<<"rank "<< my_rank <<" addVariableWrite : src_idx, dst_idx, weight"<< std::endl; 
    833839 
    834840    // End of definition 
    835841    netCdfWriter->endDefinition(); 
     842    info(100)<<"rank "<< my_rank <<" endDefinition"<< std::endl; 
    836843   
    837844    netCdfWriter->closeFile(); 
    838   } 
    839    
    840  
     845    info(100)<<"rank "<< my_rank <<" file closed"<< std::endl; 
     846  } 
     847   
    841848  MPI_Barrier_local(client->intraComm); 
    842849   
     
    844851  { 
    845852    // open file 
     853    info(100)<<"rank "<< my_rank <<" writing in weight info file"<< std::endl; 
     854     
    846855    WriteNetCdf my_writer(filename, true, client->intraComm);   
     856    info(100)<<"rank "<< my_rank <<" file opened"<< std::endl; 
    847857    netCdfWriter = &my_writer;  
    848858     
     
    853863      netCdfWriter->writeDataIndex(dst_idx, "dst_idx", false, 0, &start, &count); 
    854864      netCdfWriter->writeDataIndex(weights, "weight", false, 0, &start, &count); 
    855     } 
     865       
     866      info(100)<<"rank "<< my_rank <<" WriteDataIndex : src_idx, dst_idx, weight"<< std::endl; 
     867    } 
     868     
     869    netCdfWriter->closeFile(); 
     870    info(100)<<"rank "<< my_rank <<" file closed"<< std::endl; 
     871     
    856872  } 
    857873   
Note: See TracChangeset for help on using the changeset viewer.