- 积分
- 1091
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-4-16
- 最后登录
- 1970-1-1

|
发表于 2015-10-26 18:28:56
|
显示全部楼层
program geogrid_clc
implicit none
integer :: i,j
integer :: isigned, endian, wordsize
integer :: nx, ny, nz
real :: scalefactor
real*8 :: xllcorner, yllcorner, cellsize, missvalue
character :: head12
real, allocatable :: rarray(:,:), iarray(:,:)
isigned = 1
endian = 0
wordsize = 2
scalefactor = 1.0
nz = 1
! read in the ascii new landuse data
open (10, file = 'file.asc')
!read in the header
read(10,*) head12, nx
read(10,*) head12, ny
read(10,*) head12, xllcorner
read(10,*) head12, yllcorner
read(10,*) head12, cellsize
read(10,*) head12, missvalue
allocate(rarray(nx,ny))
allocate(iarray(nx,ny))
!read in the data
do j = 1,ny
read(10,*) iarray(:,j)
end do
! reverse the data so that it begins at the lower-left corner
do j = 1,ny
rarray(:,j) = iarray(:,ny-(j-1))
enddo
!set the missing values
do j = 1, ny
do i = 1, nx
if ( rarray(i,j) < 0 ) then
rarray(i,j) = -99 ! set negative terrain to be zero since those are near coastal or river
banks
end if
end do
end do
call write_geogrid(rarray, nx, ny, nz, isigned, endian, scalefactor, wordsize)
end program
楼主,我又来了,我又看到了一个这个文件,为什么我觉得它才是把ASCII格式转换为二进制格式的代码呢?倒数第二行也写到call write_geogrid这个函数,感觉也是调用write_geogrid.c,求解答下。谢谢 |
|