Ignore:
Timestamp:
11/22/22 12:43:52 (17 months ago)
Author:
jderouillat
Message:

Backport the system to log the memory consumption (commit ID [2418-2420,2425-2426])

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/branches/xios-3.0-beta/src/io/netCdfInterface.cpp

    r1957 r2427  
    1010#include "netCdfInterface.hpp" 
    1111#include "netCdfException.hpp" 
     12#include "mem_checker.hpp" 
    1213 
    1314namespace xios 
     
    2223int CNetCdfInterface::create(const StdString& fileName, int cMode, int& ncId) 
    2324{ 
     25  CMemChecker::get("NetCDF create").resume(); 
    2426  int status = nc_create(fileName.c_str(), cMode, &ncId); 
    2527  if (NC_NOERR != status) 
     
    3436    throw CNetCdfException(e); 
    3537  } 
     38  CMemChecker::get("NetCDF create").suspend(); 
    3639 
    3740  return status; 
     
    4952int CNetCdfInterface::createPar(const StdString& fileName, int cMode, MPI_Comm comm, MPI_Info info, int& ncId) 
    5053{ 
     54  CMemChecker::get("NetCDF create").resume(); 
    5155  int status = xios::nc_create_par(fileName.c_str(), cMode, comm, info, &ncId); 
    5256  if (NC_NOERR != status) 
     
    6165    throw CNetCdfException(e); 
    6266  } 
     67  CMemChecker::get("NetCDF create").suspend(); 
    6368 
    6469  return status; 
     
    7479int CNetCdfInterface::open(const StdString& fileName, int oMode, int& ncId) 
    7580{ 
     81  CMemChecker::get("NetCDF open").resume(); 
    7682  int status = nc_open(fileName.c_str(), oMode, &ncId); 
    7783  if (NC_NOERR != status) 
     
    8692    throw CNetCdfException(e); 
    8793  } 
     94  CMemChecker::get("NetCDF open").suspend(); 
    8895 
    8996  return status; 
     
    102109int CNetCdfInterface::openPar(const StdString& fileName, int oMode, MPI_Comm comm, MPI_Info info, int& ncId) 
    103110{ 
     111  CMemChecker::get("NetCDF open").resume(); 
    104112  int status = xios::nc_open_par(fileName.c_str(), oMode, comm, info, &ncId); 
    105113  if (NC_NOERR != status) 
     
    114122    throw CNetCdfException(e); 
    115123  } 
     124  CMemChecker::get("NetCDF open").suspend(); 
    116125 
    117126  return status; 
     
    125134int CNetCdfInterface::close(int ncId) 
    126135{ 
     136  CMemChecker::get("NetCDF close").resume(); 
    127137  int status = nc_close(ncId); 
    128138  if (NC_NOERR != status) 
     
    136146    throw CNetCdfException(e); 
    137147  } 
     148  CMemChecker::get("NetCDF close").suspend(); 
    138149 
    139150  return status; 
     
    147158int CNetCdfInterface::reDef(int ncId) 
    148159{ 
     160  CMemChecker::get("NetCDF other").resume(); 
    149161  int status = nc_redef(ncId); 
    150162  if (NC_NOERR != status) 
     
    158170    throw CNetCdfException(e); 
    159171  } 
     172  CMemChecker::get("NetCDF other").suspend(); 
    160173 
    161174  return status; 
     
    169182int CNetCdfInterface::endDef(int ncId) 
    170183{ 
     184  CMemChecker::get("NetCDF other").resume(); 
    171185  int status = nc_enddef(ncId); 
    172186  if (NC_NOERR != status) 
     
    181195    throw CNetCdfException(e); 
    182196  } 
     197  CMemChecker::get("NetCDF other").suspend(); 
    183198 
    184199  return status; 
     
    773788int CNetCdfInterface::setFill(int ncid, bool fill) 
    774789{ 
     790  CMemChecker::get("NetCDF other").resume(); 
    775791  int old_fill_mode; 
    776792  int status = nc_set_fill(ncid, fill ? NC_FILL: NC_NOFILL, &old_fill_mode); 
     
    786802    throw CNetCdfException(e); 
    787803  } 
     804  CMemChecker::get("NetCDF other").suspend(); 
    788805 
    789806  return status; 
     
    801818int CNetCdfInterface::defVarFill(int ncid, int varId, int noFill, void* fillValue) 
    802819{ 
     820  CMemChecker::get("NetCDF other").resume(); 
    803821  int status = nc_def_var_fill(ncid, varId, noFill, fillValue); 
    804822  if (NC_NOERR != status) 
     
    814832    throw CNetCdfException(e); 
    815833  } 
     834  CMemChecker::get("NetCDF other").suspend(); 
    816835 
    817836  return status; 
     
    829848int CNetCdfInterface::varParAccess(int ncid, int varId, int access) 
    830849{ 
     850  CMemChecker::get("NetCDF other").resume(); 
    831851  int status = nc_var_par_access(ncid, varId, access); 
    832852  if (NC_NOERR != status) 
     
    841861    throw CNetCdfException(e); 
    842862  } 
     863  CMemChecker::get("NetCDF other").suspend(); 
    843864 
    844865  return status; 
     
    852873int CNetCdfInterface::sync(int ncid) 
    853874{ 
     875  CMemChecker::get("NetCDF other").resume(); 
    854876  int status = nc_sync(ncid); 
    855877  if (NC_NOERR != status) 
     
    864886    throw CNetCdfException(e); 
    865887  } 
     888  CMemChecker::get("NetCDF other").suspend(); 
    866889 
    867890  return status; 
Note: See TracChangeset for help on using the changeset viewer.