'NetCDF fortran fails to nf90_open a netCDF file starting with a header line HDF
I am having a problem dealing with wind analysis CCMP_Wind_Analysis_yyyymmdd_V02.0_L3.0_RSS.nc downloaded from ftp.ssmi.com.
NetCDF fortran library successfully opened the climatology but not the individual daily data with the provided sample code.
program open
USE netcdf
IMPLICIT NONE
INTEGER(KIND=4) :: ierr !Open netCDF file
ierr=nf90_open(path='infile', mode=nf90_nowrite, ncid=ncid)
ierr=nf90_close(ncid)
end program open
It returned
error code -51, "NetCDF: Unknown file format "
The failed file seems created by Matlab and it's version was netCDF-4 classic model
$ ncdump -k Data/CCMP/200408/CCMP_Wind_Analysis_20040801_V02.0_L3.0_RSS.nc
$ netCDF-4 classic model
and climatology was created by IDL and it's version was clasic
$ ncdump -k Data/CCMP/CCMP_Wind_Analysis_climatology_V02.0_L3.5_RSS.nc
$ classic
The both daily and climatology data can be opened by ncdump or by grads, but I want to binary dump the daily data and it's much faster if I can use fortran.
Does anyone know why and how it can be solved?
Thanks in advance.
Solution 1:[1]
It seems most likely that your Fortran code is linked to a netCDF classic library, not a netCDF4 library. A netCDF4 library will produce something like the following response to nf-config:
zender@spectral:~$ nf-config
This 4.5.3 has been built with the following features:
--cc -> clang
--cflags -> -I/opt/homebrew/Cellar/netcdf/4.8.1_1/include -fPIC -g -Wall -Wno-unused-variable -Wno-unused-parameter -O2
--fc -> /opt/homebrew/bin/gfortran
--fflags -> -I/opt/homebrew/Cellar/netcdf/4.8.1_1/include -I/opt/homebrew/Cellar/netcdf/4.8.1_1/include
--flibs -> -L/opt/homebrew/Cellar/netcdf/4.8.1_1/lib -lnetcdff -lnetcdf
--has-f90 -> TRUE
--has-f03 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--prefix -> /opt/homebrew/Cellar/netcdf/4.8.1_1
--includedir-> /opt/homebrew/Cellar/netcdf/4.8.1_1/include
--version -> 4.5.3
zender@spectral:~$
Make sure that --has-nc4 -> yes not -> no.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Charlie Zender |
