@@ -196,12 +196,13 @@ public void setChunker(Nc4Chunking chunker) {
196196 }
197197
198198 /**
199- * Checks whether {@code raf} is a valid file NetCDF-4 file. Actually, it checks whether it is a valid HDF-5 file of
200- * any type. Furthermore, it checks whether the NetCDF C library is available on the system. If both conditions are
201- * satisfied, this method returns {@code true}; otherwise it returns {@code false}.
199+ * Checks whether {@code raf} is a HDF-5 or CDF-5 file. Furthermore, it checks whether the netCDF-C library
200+ * is available on the system. If {@link NetcdfClibrary#isStrictRead()} is {@code true}, it strictly limits
201+ * reading to files that are likely netCDF-4, not just any HDF-5 file. If {@code false}, it will attempt to
202+ * read any HDF-5 or CDF-5 file through the netCDF-C library.
202203 *
203204 * @param raf a file on disk.
204- * @return {@code true} if {@code raf} is a valid HDF-5 file and the NetCDF C library is available.
205+ * @return {@code true} if {@code raf} is a valid HDF-5 or CDF-5 file and the netCDF- C library is available.
205206 * @throws IOException if an I/O error occurs.
206207 */
207208 @ Override
@@ -223,12 +224,12 @@ public boolean isValidFile(RandomAccessFile raf) throws IOException {
223224 } else if (!isClibraryPresent ()) {
224225 log .debug ("File appears to be valid but netCDF-C isn't installed: {}" , raf .getLocation ());
225226 } else {
226- // file appears to be valid and netCDF-c is present
227+ // file appears to be valid and netCDF-C is present
227228 if (NetcdfClibrary .isStrictRead ()) {
228- // strictly limit to reading files that are very likely netcdf4
229- validCheck2 = isLikelyNetcdf4 (raf );
229+ // strictly limit to reading files that are very likely netCDF-4 or CDF-5
230+ validCheck2 = format == NCheader . NC_FORMAT_64BIT_DATA || isLikelyNetcdf4 (raf );
230231 } else {
231- // try to read all HDF5 files through the netCDF-C library
232+ // try to read all HDF-5 and CDF-5 files through the netCDF-C library
232233 validCheck2 = true ;
233234 }
234235 }
@@ -253,7 +254,7 @@ public String getFileTypeId() {
253254
254255 @ Override
255256 public String getFileTypeVersion () {
256- // TODO this only works for files writtten by netcdf4 c library. what about plain hdf5?
257+ // TODO this only works for files written by netcdf4 c library. what about plain hdf5?
257258 return ncfile .getRootGroup ().findAttributeString (CDM .NCPROPERTIES , "N/A" );
258259 }
259260
0 commit comments