爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7711|回复: 2

[求助] fortran读取nc数据问题

[复制链接]

新浪微博达人勋

发表于 2021-10-23 20:00:29 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
我在用Fortran读取nc数据时,打印出的数据全是0,但nc文件中的数据是有非零的数的,不知道怎么回事,有大佬能帮忙看看吗?代码如下:
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

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2021-10-24 11:12:59 | 显示全部楼层
感谢分享
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2021-10-24 16:24:40 | 显示全部楼层

我这是没有读取成功的,读出来数据全是0,不知道怎么回事
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表