Re: Concurrent read/write from a file

Dave Husson wrote:


This did not work for me. After rereading my terse plea for help, I'm sure that I did not explain my problem well enough. It was late.

The problem is on the read side. I have a C++ process that reads a data from a serial port and writes it to a netcdf file. New data arrives and is processed approximately once a second. I have a java process that needs to read the most recent entry (last) entry in the netcdf file and push the data to an applet that is displaying a graph in "real-time". I do a variable.getSize() to determine the number of items in the file. Once the file is open, I always get the same value returned from getSize(). In C/C++, I do the same operations, but prior to the getSize(), I do an nc_sync() of the file. When I do the getSize(), I see the file growing, as I expected.

I modified my java code to use NetcdfFileWriteable instead of NetcdfFile and called flush() on the file in the equivalent place to where I was doing the nc_sync(). This gave me the same result as before. I always get the size of the file at the time it is opened and never see the file growing.

Thanks for the help.
Dave

caron@xxxxxxxxxxxxxxxx wrote:

hmm, yes i think i understand your problem now. it appears to be a limitation in the underlying i/o reading layer. i will investigate if theres an easy way to do it. for now, the only workaround i know is to reopen the file.

BTW, are you using netcdf java 2.0 or 2.1?

The NetcdfFileWriteable class is for writing files, so you can forget about using it for this case.


  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: