Skip to content

Commit

Permalink
Merge pull request #319 from kalibera/no-reentrant-open
Browse files Browse the repository at this point in the history
Avoid re-opening already opened CDF file.
  • Loading branch information
rhijmans authored Oct 18, 2023
2 parents 2c4831e + 5b784ea commit a16e9e5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/netCDFwriteCD.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,18 @@
}


.stopWriteCDF <- function(x) {
.writeRangeCDF <- function(x) {

nc <- ncdf4::nc_open(x@file@name, write=TRUE)
on.exit( ncdf4::nc_close(nc) )
ncdf4::ncatt_put(nc, x@title, 'min', as.numeric(x@data@min))
ncdf4::ncatt_put(nc, x@title, 'max', as.numeric(x@data@max))
}


.stopWriteCDF <- function(x) {

.writeRangeCDF(x)
if (inherits(x, 'RasterBrick')) {
r <- brick(x@file@name)
} else {
Expand Down

0 comments on commit a16e9e5

Please sign in to comment.