- 积分
 - 116
 
	- 贡献
 -  
 
	- 精华
 
	- 在线时间
 -  小时
 
	- 注册时间
 - 2015-11-28
 
	- 最后登录
 - 1970-1-1
 
 
 
 
 
 
 | 
	
 
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册 
 
 
 
x
 
我读取了一个HDF文件,想把数据以NETCDF格式输出,按照说明上那几步来却始终出现这一错误forrtl: severe (174): SIGSEGV, segmentation fault occurred。尝试过很多方法,比如ulimit -s unlimit,在Makefile里加test-heap-arrays  64 -heap-arrays -check all -fp-stack-check ,而且把程序简化了一下,输出的错误都是一样。数据读取时应该没什么问题,可以以txt格式输出,但是以netcdf格式输出就不行了。小弟初学者,望大牛们解答。注:两个维度都是2400,dataset也是2400*2400.
 
 
 
 
     program  
 
      use netcdf 
 
      implicit none 
 
!parameter declaration 
 
      include  'PARMS3.EXT' 
      include  'IODECL3.EXT' 
      include  'FDESC3.EXT' 
      include  'STATE3.EXT' 
 
      character(len=100) , parameter :: file_name= 
     &           'MCD15A2H.A2002185.h13v03.006.2015149103711.hdf' 
      integer,parameter             :: x_length=2400, y_length=2400 
      integer,parameter             :: dfacc_read=1, dfnt_int32=24 
 
!function declaration 
 
      integer   :: sfstart, sfselect, sfrdata, sfendacc, sfend 
 
!variable declaration 
 
      integer   :: sd_id, sds_id, sds_index, status 
      integer   :: start(2), edges(2), stride(2) 
      integer   :: dataset(x_length, y_length) 
      integer   :: i, j 
      integer   :: ncid, ydimid, xdimid, varid 
 
!end of variable declaration 
!start 
!open the file and initialize the SD interface 
 
      sd_id = sfstart(file_name, dfacc_read) 
 
!select data set.(zero-based) 
 
      sds_index = 1 
      sds_id = sfselect(sd_id, sds_index) 
 
!start edges stride 
 
      start(1) = 0 
      start(2) = 0 
      edges(1) = y_length 
      edges(2) = x_length 
      stride(1) = 1 
      stride(2) = 1 
 
!read entire data into 'data' array 
 
      status = sfrdata(sds_id, start, stride, edges, dataset) 
 
!write into a netcdf. 
 
        status=nf90_create('1.nc',nf90_clobber,ncid) 
          if (status /=nf90_noerr) call handle_err(status) 
        status=nf90_def_dim(ncid,'YDim',y_length, 
     &                      ydimid) !!!!!!! 
          if (status /=nf90_noerr) call handle_err(status) 
        status=nf90_def_dim(ncid,'XDim',x_length, 
     &                      xdimid) 
          if (status /=nf90_noerr) call handle_err(status) 
 
        status=nf90_def_var(ncid,'abc', NF90_BYTE, 
     &                     (/ydimid,xdimid/),varid)!!!!NF90_UINT 
          if (status /=nf90_noerr) call handle_err(status) 
 
        status=nf90_put_att(ncid,varid,'UINT8',NF90_BYTE) !! 
          if (status /=nf90_noerr) call handle_err(status) 
 
        status=nf90_enddef(ncid) 
          if (status /=nf90_noerr) call handle_err(status) 
 
        status=nf90_put_var(ncid,varid,dataset) 
 
          if (status /=nf90_noerr) call handle_err(status) 
        status=nf90_close(ncid) 
          if (status /=nf90_noerr) call handle_err(status) 
 
 
!terminate access to the data set 
 
      status = sfendacc(sds_id) 
      if(status /= 0) print*, 'errow in sfendacc' 
!terminate access to the SD interface and close the file. 
 
      status = sfend(sd_id) 
      if(status /= 0) print*, 'errow in sfend' 
 
      end program test 
 
 
!************************************************************************* 
 
        subroutine handle_err(status) 
        use netcdf 
        implicit none 
        integer, intent(in) :: status 
        if (status /=nf90_noerr) then 
        print *, trim(nf90_strerror(status)) 
        stop "Fortran Stopped" 
        end if 
        end subroutine handle_err 
 
 
 
 
 |   
 
 
 
 |