Skip to content

Commit deeca5f

Browse files
author
dmh
committed
disable refcounting until semantics are decided
1 parent 13b6603 commit deeca5f

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

include/nc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ typedef struct NC {
2828
char* path;
2929
int mode; /* as provided to nc_open/nc_create */
3030
int substrate;
31+
#ifdef USE_REFCOUNT
3132
int refcount; /* To enable multiple name-based opens */
33+
#endif
3234
} NC;
3335

3436
/*

libdispatch/dfile.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ netCDF library.
547547
If a the path is a DAP URL, then the open mode is read-only.
548548
Setting NC_WRITE will be ignored.
549549
550+
As of version 4.3.1.2, multiple calls to nc_open with the same
551+
path will return the same ncid value.
552+
550553
\note When opening a netCDF-4 file HDF5 error reporting is turned off,
551554
if it is on. This doesn't stop the HDF5 error stack from recording the
552555
errors, it simply stops their display to the user through stderr.
@@ -1034,9 +1037,11 @@ nc_abort(int ncid)
10341037
int stat = NC_check_id(ncid, &ncp);
10351038
if(stat != NC_NOERR) return stat;
10361039

1040+
#ifdef USE_REFCOUNT
10371041
/* What to do if refcount > 0? */
10381042
/* currently, forcibly abort */
10391043
ncp->refcount = 0;
1044+
#endif
10401045

10411046
stat = ncp->dispatch->abort(ncid);
10421047
del_from_NCList(ncp);
@@ -1091,8 +1096,10 @@ nc_close(int ncid)
10911096
int stat = NC_check_id(ncid, &ncp);
10921097
if(stat != NC_NOERR) return stat;
10931098

1099+
#ifdef USE_REFCOUNT
10941100
ncp->refcount--;
10951101
if(ncp->refcount <= 0)
1102+
#endif
10961103
{
10971104
stat = ncp->dispatch->close(ncid);
10981105
/* Remove from the nc list */
@@ -1602,6 +1609,11 @@ NC_create(const char *path, int cmode, size_t initialsz,
16021609
/* Add to list of known open files and define ext_ncid */
16031610
add_to_NCList(ncp);
16041611

1612+
#ifdef USE_REFCOUNT
1613+
/* bump the refcount */
1614+
ncp->refcount++;
1615+
#endif
1616+
16051617
/* Assume create will fill in remaining ncp fields */
16061618
if ((stat = dispatcher->create(path, cmode, initialsz, basepe, chunksizehintp,
16071619
useparallel, mpi_info, dispatcher, ncp))) {
@@ -1651,13 +1663,15 @@ NC_open(const char *path, int cmode,
16511663
nc_initialized = 1;
16521664
}
16531665

1666+
#ifdef USE_REFCOUNT
16541667
/* If this path is already open, then bump the refcount and return it */
16551668
ncp = find_in_NCList_by_name(path);
16561669
if(ncp != NULL) {
16571670
ncp->refcount++;
16581671
if(ncidp) *ncidp = ncp->ext_ncid;
16591672
return NC_NOERR;
16601673
}
1674+
#endif
16611675

16621676
isurl = NC_testurl(path);
16631677
if(isurl)
@@ -1749,6 +1763,11 @@ NC_open(const char *path, int cmode,
17491763
/* Add to list of known open files */
17501764
add_to_NCList(ncp);
17511765

1766+
#ifdef USE_REFCOUNT
1767+
/* bump the refcount */
1768+
ncp->refcount++;
1769+
#endif
1770+
17521771
/* Assume open will fill in remaining ncp fields */
17531772
stat = dispatcher->open(path, cmode, basepe, chunksizehintp,
17541773
useparallel, mpi_info, dispatcher, ncp);

libdispatch/nclistmgr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ add_to_NCList(NC* ncp)
4242
return NC_ENOMEM;
4343
numfiles = 0;
4444
}
45+
#ifdef USE_REFCOUNT
4546
/* Check the refcount */
4647
if(ncp->refcount > 0)
4748
return NC_NOERR;
49+
#endif
4850

4951
new_id = 0; /* id's begin at 1 */
5052
for(i=1; i < NCFILELISTLENGTH; i++) {
@@ -64,9 +66,11 @@ del_from_NCList(NC* ncp)
6466
unsigned int ncid = ((unsigned int)ncp->ext_ncid) >> ID_SHIFT;
6567
if(numfiles == 0 || ncid == 0 || nc_filelist == NULL) return;
6668
if(nc_filelist[ncid] != ncp) return;
69+
#ifdef USE_REFCOUNT
6770
/* Check the refcount */
6871
if(ncp->refcount > 0)
6972
return; /* assume caller has decrecmented */
73+
#endif
7074

7175
nc_filelist[ncid] = NULL;
7276
numfiles--;

0 commit comments

Comments
 (0)