Re: [netcdfgroup] Closing files opened only for reading (C interface - nc_close()?)

As a follow-up, I've spent considerable time dealing with this issue, and it
seems like the problem is that nc_open() *always* locks files. I've found
that if I use a debug executable or a release executable and run from within
the LabWindows/CVI IDE, execution suspends on the nc_close() calls, but if I
just continue execution a few times (it suspends 3 times, I believe), the
function will finish executing and the file won't be locked anymore. Of
course, if I run the executable from outside the IDE, it crashes completely.
It seems like it's either a problem with nc_open or nc_close. Any help would
be greatly appreciated.

          -Paul

On Mon, Aug 1, 2011 at 13:50, Paul Ganssle <p.g.anssle@xxxxxxxxx> wrote:

> Hi all,
>    I'm looking for some help with a netcdf-powered application, and it
> seemed like this was the right mailing list to ask. Apologies in advance if
> this is an inappropriate place to ask this question.
>
>
>   The problem I'm having is with the file open/close model in netcdf 4
> (4.1.3). I'm using LabWindows/CVI 9.0 to build a program and using netCDF
> for all my data reading/writing needs. The problem is that in a few cases it
> seems like I'm leaving these files open causing them to lock, but given that
> you can't call nc_close() on a file that's been opened for reading only
> (totally crashes my application if I do that - no error is returned), I
> don't really understand how to unlock the files. Right now I'm dealing with
> files where you build some set of variables and metadata in a UI editor,
> then save them to file. If you load them from file first, when you try to
> save them, it returns the error "Could not add HDF5 metadata", but that only
> happens when the file is locked due to being in use, because there's a call
> to DeleteFilename(filename) that occurs before the nc_create call.
>
>    Given that it was only ever opened with nc_open(filename, NC_NOWRITE,
> &ncid), I don't understand why it could possibly be locked. So my overall
> question is, "how do I fix this?", but more specifically, I guess I'm
> looking for a way to either force close netcdf files that were opened by
> some unknown function or force close all open netcdf files.
>
>            Best,
>                Paul Ganssle
>
  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: