- 积分
- 121
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-9-20
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在时间间隔大于900秒的相邻两数据之间,插入计数值,程序如下:
program leibaoxuanqu
integer,parameter::tt=20
integer,parameter::dd=28
integer i,j,n,c
real lat(tt),lon(tt),str(tt)
integer year(tt),month(tt),day(tt),hour(tt),mini(tt),sec(tt),msec(tt),a(tt)
integer byear(dd),bmonth(dd),bday(dd),bhour(dd),bmini(dd),bsec(dd),bmsec(dd)
real blat(dd),blon(dd),bstr(dd)
!设置样本条件
!时间格式转换
open(100, file="D:\fortran\2009xiajiwell1.txt",status="old", iostat=error)
open(200, file="D:\fortran\2009leibao.txt",status="replace", iostat=error)
if ( error/=0 ) then
write(100,*) "Open 2009xiajiwell1.txt fail."
stop
end if
do i=1,tt
read(100,*) year(i),month(i), day(i), hour(i),mini(i),sec(i),msec(i), lat(tt),lon(tt),str(tt)
end do
byear(1)=year(1)
bmonth(1)=month(1)
bday(1)=day(1)
bhour(1)=hour(1)
bmini(1)=mini(1)
bsec(1)=sec(1)
bmsec(1)=msec(1)
blat(1)=lat(1)
blon(1)=lon(1)
bstr(1)=str(1)
write(200,99) byear(1),bmonth(1), bday(1), bhour(1),bmini(1),bsec(1),bmsec(1),blat(1),blon(1),bstr(1)
99 format(i4,1x,5(i2.2,1x),i3.3,1x,f8.5,1x,f9.5,1x,f8.3)
n=1
j=1
do i=1,19
j=j+1
c=i+1
mx=month(i)*30*24*60*60
dx=day(i)*24*60*60 !把月,日、小时、分、秒转化成秒
hx=hour(i)*60*60
mx=mini(i)*60
sx=sec(i)
my=bmonth(c)*30*24*60*60
dy=bday(c)*24*60*60
hy=bhour(c)*60*60
my=bmini(c)*60
sy=bsec(c)
!条件上下相邻的两条数据的时间间隔大于900秒
if(((my+dy+hy+my+sy)-(mx+dx+hx+mx+sx))>900)then
write(200,*) n
n=n+1
else !不满足条件直接赋值
byear(j)=year(i)
bmonth(j)=month(i)
bday(j)=day(i)
bhour(j)=hour(i)
bmini(j)=mini(i)
bsec(j)=sec(i)
bmsec(j)=msec(i)
blat(j)=lat(i)
blon(j)=lon(i)
bstr(j)=str(i)
end if
write(200,99)byear(j),bmonth(j), bday(j), bhour(j),bmini(j),bsec(j),bmsec(j),blat(j), blon(j), bstr(j)
end do
stop
end program leibaoxuanqu
原始数据
2009 06 05 08 31 37 398 36.29283 120.35725 16.837
2009 06 05 09 45 15 442 35.9729 120.62507 -17.169
2009 06 05 09 49 15 084 35.91164 120.6116 -23.925
2009 06 05 09 50 24 234 35.90533 120.66304 -14.064
2009 06 05 09 51 45 562 35.91808 120.67847 -23.675
2009 06 05 09 51 46 012 35.98477 120.63826 -12.856
2009 06 05 09 52 45 014 35.91652 120.67787 -17.328
2009 06 05 09 53 34 797 36.01581 120.64723 -21.914
2009 06 05 09 56 24 814 35.88767 120.62961 -12.617
2009 06 05 10 00 57 545 35.83185 120.66916 -8.416
2009 06 05 10 12 46 961 35.89435 120.67093 15.645
2009 06 05 10 38 36 600 36.13832 120.02913 -9.03
2009 06 05 10 44 32 532 36.05127 120.19465 -8.982
2009 06 05 10 46 07 680 36.11611 120.22468 -30.509
2009 06 05 10 47 43 451 36.06186 120.16666 -30.63
2009 06 05 11 18 13 014 35.98156 120.4347 -16.441
2009 06 15 12 33 46 829 35.99499 120.1754 -6.154
2009 06 15 12 43 37 182 36.20735 120.43149 -5.081
2009 06 15 12 46 56 892 36.17541 120.27978 -13.919
2009 06 15 12 50 12 378 36.20195 120.28278 -18.358
计算结果如下
2009 06 05 08 31 37 398 0.00000 0.00000 0.000
2009 06 05 08 31 37 398 0.00000 0.00000 0.000
2009 06 05 09 45 15 442 0.00000 0.00000 0.000
2009 06 05 09 49 15 084 0.00000 0.00000 0.000
2009 06 05 09 50 24 234 0.00000 0.00000 0.000
2009 06 05 09 51 45 562 0.00000 0.00000 0.000
2009 06 05 09 51 46 012 0.00000 0.00000 0.000
2009 06 05 09 52 45 014 0.00000 0.00000 0.000
2009 06 05 09 53 34 797 0.00000 0.00000 0.000
2009 06 05 09 56 24 814 0.00000 0.00000 0.000
2009 06 05 10 00 57 545 0.00000 0.00000 0.000
2009 06 05 10 12 46 961 0.00000 0.00000 0.000
2009 06 05 10 38 36 600 0.00000 0.00000 0.000
2009 06 05 10 44 32 532 0.00000 0.00000 0.000
2009 06 05 10 46 07 680 0.00000 0.00000 0.000
2009 06 05 10 47 43 451 0.00000 0.00000 0.000
2009 06 05 11 18 13 014 0.00000 0.00000 0.000
2009 06 15 12 33 46 829 0.00000 0.00000 0.000
2009 06 15 12 43 37 182 0.00000 0.00000 0.000
2009 06 15 12 46 56 892 0.00000 0.00000 0.000
貌似if条件根本没起作用,请各位帮忙看看问题在哪 谢谢
|
|