爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7421|回复: 7

[求助] fortarn读取nc资料出错

[复制链接]

新浪微博达人勋

发表于 2015-9-20 19:46:50 | 显示全部楼层 |阅读模式
1金钱
fortarn程序有几个错误,我快受不了了,哪位大神能帮下啊
全部代码如下
program main


  use netcdf


  implicit none

  


  ! --  Variable declaration.  ---------------------------------------------------------------------

  ! **  Parameters.  **
  character*200, parameter :: IFNAME = "temp_ITPCAS-CMFD_V0105_B-01_198101.nc", OFNAME = "output.bin"

  integer, parameter :: NX_SRT =   1, NX_END = 700, NX = NX_END - NX_SRT + 1
  integer, parameter :: NY_SRT =   1, NY_END = 400, NY = NY_END - NY_SRT + 1
  integer, parameter :: NT_SRT =   1, NT_END = 248, NT = NT_END - NT_SRT + 1

  real, parameter :: OMVALUE = 1.0E+36

  ! **  Loop variables.  **
  integer :: i, j, t

  ! **  Variables needed NetCDF functions.  **
  integer*4  ncid
   integer*4 status
  integer*4, dimension(3) :: dmid
  integer*4, dimension(3) :: start, count

  ! **  Variables for storing NetCDF variable properties.  **
  integer*4 :: nlon, nlat, ntime
  integer*2 :: imvalue
  real*4 :: sfactor, aoffset

  ! **  Working array.  **
  integer*2, dimension(NX, NY, NT) :: ivar
  real*4, dimension(NX, NY, NT) :: fvar


  ! --  Variable initialization.  ------------------------------------------------------------------

  start(1) = NX_SRT; count(1) = NX
  start(2) = NY_SRT; count(2) = NY
  start(3) = NT_SRT; count(3) = NT


  ! --  Data input.  -------------------------------------------------------------------------------

  status = nf90_open (IFNAME, nf90_nowrite, ncid)
  call check (status)

  status = nf90_get_var (ncid, 4, ivar, start, count)
  call check (status)

  status = nf90_get_att (ncid, 4, "scale_factor", sfactor)
  call check (status)

  status = nf90_get_att (ncid, 4, "add_offset", aoffset)
  call check (status)

  status = nf90_get_att (ncid, 4, "missing_value", imvalue)
  call check (status)

  status = nf90_close (ncid)
  call check (status)


  ! --  Data processing.  --------------------------------------------------------------------------

  do t = 1, NT
    do j = 1, NY
      do i = 1, NX
        if (ivar(i, j, t) /= imvalue) then
          fvar(i, j, t) = ivar(i, j, t) * sfactor + aoffset
        else
          fvar(i, j, t) = OMVALUE
        end if
      end do
    end do
  end do


  ! --  Data output.  ------------------------------------------------------------------------------

  open (21, file = OFNAME, form = 'unformatted', access = 'direct', recl = NX * NY * 4)

  do t = 1, NT
    write (21, rec = t) ((fvar(i, j, t), i = 1, NX), j = 1, NY)
  end do

  close (21)


contains


  ! --  Subordinate subroutines and functions.  ----------------------------------------------------

  subroutine check (status)

    integer, intent(in) :: status

    if (status /= nf90_noerr) then
      write (*, *) trim (nf90_strerror (status))
      stop "Stopped"
    end if

  end subroutine check

end program main
出错的问题如下
D:\fortion\nc\nc1.f90(62): Could not find the file netcdf.mod.
Compiling Fortran...
D:\fortion\nc\nc1.f90
D:\fortion\nc\nc1.f90(62) : Error: Error in opening the Library module file.   [NETCDF]
  use netcdf
------^
D:\fortion\nc\nc1.f90(109) : Error: This name does not have a type, and must have an explicit type.   [NF90_OPEN]
  status = nf90_open (IFNAME, nf90_nowrite, ncid)
-----------^
D:\fortion\nc\nc1.f90(133) : Error: This name does not have a type, and must have an explicit type.   [NF90_GET_VAR]
  status = nf90_get_var (ncid, 4, ivar, start, count)
-----------^
D:\fortion\nc\nc1.f90(136) : Error: This name does not have a type, and must have an explicit type.   [NF90_GET_ATT]
  status = nf90_get_att (ncid, 4, "scale_factor", sfactor)
-----------^
D:\fortion\nc\nc1.f90(145) : Error: This name does not have a type, and must have an explicit type.   [NF90_CLOSE]
  status = nf90_close (ncid)
-----------^
D:\fortion\nc\nc1.f90(184) : Error: This name does not have a type, and must have an explicit type.   [NF90_NOERR]
    if (status /= nf90_noerr) then
------------------^
D:\fortion\nc\nc1.f90(185) : Error: This name does not have a type, and must have an explicit type.   [NF90_STRERROR]
      write (*, *) trim (nf90_strerror (status))
-------------------------^
D:\fortion\nc\nc1.f90(185) : Error: The data types of the argument(s) are invalid.   [TRIM]
      write (*, *) trim (nf90_strerror (status))
-------------------------^
Error executing df.exe.

nc1.obj - 8 error(s), 0 warning(s)
第一个问题,有mod文件,但是不知道怎么设置
第二个问题,调用的子程序status出错,
求大神帮忙看下,万分感谢

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

新浪微博达人勋

发表于 2015-9-21 01:37:09 | 显示全部楼层
你use的东西并没有写成module
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2015-9-24 21:57:44 | 显示全部楼层
include “netcdf.inc”
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2015-9-25 09:51:00 | 显示全部楼层
正在学习。。。
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2016-3-12 16:04:59 | 显示全部楼层
学习。。。。。。。。。。。。。。。。。
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2016-7-18 21:23:18 | 显示全部楼层
请问解决了没有?
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-10-10 11:43:06 | 显示全部楼层
没装好那个netcdf的库吧?
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-10-11 11:51:06 | 显示全部楼层
有解决吗?
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

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

本版积分规则

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

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

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