- 积分
- 247
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-11-7
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2016-1-8 19:59:39
|
显示全部楼层
你好,没太懂你给的例子,所以自己试着写了一下,还是有错误,希望你能再教教我
Program main
Implicit none
Character*8 stid(1:76685) !原始数据除去表头有76685行
Real maxt(1:76685),mint(1:76685),avgt(1:76685),rain(1:76685) !
integer years(1:76685)
integer year(1:76685),month(1:76685),day(1:76685)
integer stalist(1:35) !有35个气象站
integer i,j,k
real st
integer ista
character*46 filename
integer:: stat
!程序开始
Open(1,file='e:\station.txt',status='old')
open(2,file='e:\station5.txt',status='unknown')
read(1,*)
do i=1,76685
Read(1,*)stid(i),years(i),maxt(i),mint(i),avgt(i),rain(i)
write(2, '(A5,2x, I8,2x,F8.1,2x,F8.1,2x, <5>(F8.1,2x))')stid(i),years(i),maxt(i),mint(i),avgt(i),rain(i)
enddo
open(122, file=infile, form='formatted', status='old')
do while(.true.)
read(122, '(A5,2x, I8,2x,F8.1,2x,F8.1,2x, <5>(F8.1,2x))', iostat=stat)stid(i),years(i),maxt(i),mint(i),avgt(i),rain(i)
if(stat/=0) exit
do st=1,35
if(stid==stalist(st) )then
open(111, file=stalist(st)'.txt', form='formatted', status='old', position='append')
write(111, '(A5,2x, I8,2x,F8.1,2x,F8.1,2x, <5>(F8.1,2x))') stid(i),years(i),maxt(i),mint(i),avgt(i),rain(i)
close(111)
end if
end do
end do
Close(1)
close(2)
close(122)
end |
-
|