I am trying to read data from a netcdf file. But it turned out crazy
The following are some of the data I have read
-1.3207933E+10
-8.3823027E+09
-5.4078728E+11
-1.6477924E+12
-3.1043398E+17
-1.3207933E+10
-1.0523522E+10
-8.1099614E+11
-2.6932095E+11
They are completely different from what I expect. Actually , the Data
should be the following or something
-12310, -12320, -12315, -12310, -12310, -12320, -12325, -12340, -123
40,
-12340, -12345, -12350, -12350, -12354, -12360, -12365, -12370, -123
75,
-12379, -12395, -12410, -12415, -12420, -12425, -12425, -12420, -124
04,
-12400, -12395, -12385, -12375,
When I use the same fortran program to read another different fille, it
works well. The only modification I made is changing the dimension size
the following is the fortran program, I think it should be right
********************************************************
program filter
parameter (ndims=4)
parameter (nlat=73,nlon=144)
real data(nlon,nlat)
integer ncid,ncidin,ncidout,iv
integer rcode
integer start(3), count(3)
data start/1,1,1/
data count/nlon,nlat,1/
character*50 fname
character*20 file
include '/opt/netcdf/include/netcdf.inc'
ncidin = ncopn('../obs_cdc_olr.ctrl.nc',ncnowrit,rcode)
iv=4
k=1
call rdncdf2d(ncidin,iv,k,data)
do i=1,5
do j=1,5
write(6,*) data(i,j)
end do
end do
stop
end
subroutine rdncdf2d(ncidin,id,itime,data)
parameter (nlat=73, nlon=144)
parameter (ndims=3)
integer rcode
integer start(ndims), count(ndims)
real data(nlon,nlat)
character*31 dimname
data start/1,1,1/
data count/nlon,nlat,1/
start(3)=itime
call ncvgt(ncidin,id,start,count,data,rcode)
return
end
***********************************************************
There are some difference between these two file in that one has scale
factor and offset, the other does not. The following is the part of the
head information of the two netcdf files
for obs_cdc_olr.ctrl.nc (for this file where the problem happened)
short olr(time, lat, lon) ;
olr:long_name = "Daily OLR" ;
olr:valid_range = 0.f, 500.f ;
olr:actual_range = 64.75f, 341.9f ;
olr:units = "W/m^2" ;
olr:add_offset = 327.65f ;
olr:scale_factor = 0.01f ;
olr:missing_value = 32766s ;
olr:var_desc = "Outgoing Longwave Radiation\n",
"O" ;
olr:precision = 2s ;
olr:dataset = "NOAA Interpolated OLR\n",
"O" ;
olr:level_desc = "Other\n",
"-" ;
olr:statistic = "Mean\n",
"M" ;
olr:parent_stat = "Individual Obs\n",
"I" ;
for mm5_lon180_ncep.ctrl.nc (for this file it works well)
float LWOUTNEW(TDAY, LATITUDE110_28, LONGITUDE17_80) ;
LWOUTNEW:missing_value = -1.e+34f ;
LWOUTNEW:_FillValue = -1.e+34f ;
LWOUTNEW:long_name = "outgoing longwave radiation" ;
LWOUTNEW:units = "W m^-2" ;
Would anyone give me some hint about this problem?
Thanks a lot in advance !
Hui Du