This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Milo, > I'm interested in using the Perl NetCDF library for a simple task, > that is to validate a large number of netcdf files. A simple check > that they're actual netcdf and not junk is all that is required. > Apparently in C++ there's an is_valid() method that could be used for > this purpose, but I can't find anything similar with Perl. I've tried > NetCDF::open("$file",NOWRITE) but this dies if an invalid file is found. > > Do you have any suggestions? The NetCDF-Perl package doesn't have anything equivalent to the is_valid() method. I think you could modify the "ncopts" variable so that the open() doesn't die but, instead, returns an error code. It would then be a matter of writing a Perl subroutine that tested the file for validity by performing the same steps as the is_valid() function. It seems, however, that it would be simpler to write C++ program to do the validating rather than a NetCDF-Perl script. > Thanks, > Milo Thurston. > > -- > Dr. Milo Thurston > http://climateprediction.net > http://www.oerc.ox.ac.uk Regards, Steve Emmerson Ticket Details =================== Ticket ID: BVM-455008 Department: Support netCDF Perl Priority: Normal Status: Closed