| 
 
	积分563贡献 精华在线时间 小时注册时间2020-11-21最后登录1970-1-1 
 | 
 
| 
我在用Fortran读取nc数据时,打印出的数据全是0,但nc文件中的数据是有非零的数的,不知道怎么回事,有大佬能帮忙看看吗?代码如下:
x
登录后查看更多精彩内容~您需要 登录 才可以下载或查看,没有帐号?立即注册 
  program readnc
 !subroutine readnc
 use netcdf
 implicit none
 integer :: ncId, rhVarId, status,staread
 integer, parameter :: numTimes = 612, numLats = 30, numLons = 34
 real, dimension(numTimes, numLats, numLons) &
 :: rhValues, TO
 !Open netCDF file.
 status = nf90_open("TO.nc", nf90_NoWrite, ncid)
 if(status /= nf90_NoErr) call check_err(status)
 status = nf90_inq_varid(ncid, "TO", rhVarId)
 if(status /= nf90_NoErr) call check_err(status)
 !Read the values at the last time by passing an array section
 status = nf90_get_var(ncid, rhVarId, rhValues, &
 start = (/ 1, 1, 1 /), &
 count = (/ 1, numLats, numLons/))
 if(status /= nf90_NoErr) call check_err(status)
 !    read(ncid, "(f12.4)") rhValues
 !closes an open netCDF dataset
 !    status = nf90_close(ncid)
 !    if (status /= nf90_noerr) call check_err(status)
 !end subroutine readnc
 write(*,*)TO(1,:,:)
 end program readnc
 
 
 
 subroutine check_err(status)
 include 'netcdf.inc'
 integer status
 if(status.ne.nf_noerr)then
 print *, nf_strerror(status)
 stop
 endif
 end
 
 
 | 
 |