c Chuong trinh phan tich nhan to voi so lieu mua c Tinh cho tung thang. Ung voi moi thang cac bien c la so tram (MT) tham gia tinh toan, con dung c luong mau la do dai chuoi thoi gian quan trac c tu nam NAM1 den nam NAM2 (N = NAM2 - NAM1 + 1) c c $large $debug program nto dimension nam(30,132), /yy(30),tb(132,12) dimension n(132),nn(132),n1(132),na(132),nam3(30,132) dimension tentram(132),tentr(132),tram(132) dimension xy(4000),x(30,132),xx(30,132) character *15 fsl,fin,fdl,tentram,tentr,tram write(*,'(a\)')' Ten file so lieu mua : ' read(*,'(a)')fsl write(*,'(a\)')' Ten file dung luong mau : ' read(*,'(a)')fdl write(*,'(a\)')' Moc dau(NAM1) va cuoi(NAM2) cua chuoi:' read(*,*)nam1,nam2 write(*,'(a\)')' Ten file in ra : ' read(*,'(a)')fin write(*,'(a\)')' So luong tram = ' read(*,*)mtt open(2,file=fdl,status='old') open(3,file=fin,status='new') read(2,*)(n(i),i=1,mtt) c do 100 k=1,12 write(*,'('' Co tinh cho thang '',i3,'' ? (0/1)'')') k read(*,*)ic if(ic.eq.0) goto 100 do 400 iii=1,11 400 write(*,*) write(*,'(25x,''.................................'')') write(*,'(25x,'' May dang tinh, khong can thiep !'')') write(*,'(25x,''.................................'')') do 201 iii=1,10 201 write(*,*) write(*,'('' '')') write(*,'(1H+,40x,'' Tinh voi thang'',I3)') k open(1,file=fsl,status='old') do 601 j=1,mtt do 601 i=1,n(j) 601 nam(i,j)=0 do 501 i=1,mtt tentr(i)=' ' tram(i)=' ' 501 nn(i)=0 do 11 j=1,mtt read(1,*)tentram(j) c write(*,*)tentram(j) read(1,*)vdo read(1,*)kdo read(1,*)dcao i=0 in=1 15 read(1,*)nam0,(xy(l),l=1,12) c write(*,'(1h+,i6)')nam0 if(nam0.lt.nam1.or.nam0.gt.nam2) goto 25 i=i+1 nam(i,j)=nam0 x(i,j)=xy(k)/10. 25 in=in+1 if(in-n(j))15,15,20 20 nn(j)=i 11 continue nt=nam2-nam1+1 l=0 li=0 do 30 j=1,mtt if(nn(j).ge.(nt-5)) then l=l+1 tentr(l)=tentram(j) nnj=nn(j) do 35 i=1,nnj if(nam(i,j).eq.0) goto 1012 nam3(i,l)=nam(i,j) 35 xx(i,l)=x(i,j) n1(l)=nn(j) else li=li+1 tram(li)=tentram(j) endif 30 continue ml=l mi=li write(3,'(20x,'' Cac tram tham gia tinh toan'')') write(3,'(1x,5a15,'','')')(tentr(i),i=1,ml) write(3,'(20x,'' Cac tram khong tham gia tinh toan'')') write(3,'(1x,5a15,'','')')(tram(i),i=1,mi) do 40 i=1,nt 40 na(i)=nam1+i-1 do 45 j=1,ml l=1 nj=n1(j) do 50 i=1,nt if(l.gt.nj)goto 54 if(nam3(l,j)-na(i)) 53,52,53 52 x(i,j)=xx(l,j) l=l+1 goto 50 53 x(i,j)=-1 goto 50 54 if(i.le.nt)x(i,j)=-1 50 continue 45 continue do 101 i=1,ml tram(i)=' ' do 101 j=1,nt if(x(j,i).lt.0)goto 102 goto 101 102 tram(i)=tentr(i) 101 continue do 103 ii=1,ml if(tentr(ii).ne.tram(ii))goto 103 write(*,'(1H+,'' B.khuyet cho tram '',a15)')tram(ii) ibk=ii i=1 rk=0 10 if(i.eq.ibk)goto 3 nj=0 do 4 j=1,nt if(x(j,i).lt.0.or.x(j,ibk).lt.0)goto 4 nj=nj+1 xy(nj)=x(j,i) yy(nj)=x(j,ibk) 4 continue if(nj.lt.10)goto 3 call sd(xy,yy,nj,r,a,b) if(abs(r).le.rk)goto 3 rk=r ak=a bk=b ik=i 3 i=i+1 if(i.le.ml)goto 10 c write(*,*)' Dang tien hanh bo khuyet cho tram ',tram(ii) do 5 j=1,nt if(x(j,ibk).ge.0)goto 5 if(x(j,ik).lt.0)goto 5 x(j,ibk)=ak*x(j,ik)+bk 5 continue do 7 j=1,ml tb(j,k)=0 nj=0 do 8 i=1,nt if(x(i,j).lt.0)goto 9 tb(j,k)=tb(j,k)+x(i,j) goto 8 9 nj=nj+1 8 continue if(nj.eq.nt)goto 77 tb(j,k)=tb(j,k)/(nt-nj) c tb(j,k)=tb(j,k)/10. goto 7 77 tb(j,k)=-1 7 continue 103 continue do 150 j=1,ml do 150 i=1,nt if(x(i,j).lt.0)x(i,j)=tb(j,k) 150 continue write(3,'(10x,'' So lieu da b.khyet'')') ma=10 jj=1 222 do 21 i=1,nt 21 write(3,'(1x,i5,10f7.1)') na(i),(x(i,j),j=jj,ma) if(ma.eq.ml) goto 33 jj=ma+1 mm=ma+10 if(mm.gt.ml) ma=ml if(mm.le.ml) ma=mm goto 222 33 l=0 do 22 j=1,ml do 22 i=1,nt l=l+1 write(*,'(1H+,'' L = '',i6)')l 22 xy(l)=x(i,j) call ptnt(xy,nt,ml,1.) 100 continue 1012 write(*,'('' Sai chuong trinh !'')') 1011 stop end c c c subroutine sd(x,y,n,r,a,b) dimension x(1),y(1) tbx=0 tby=0 do 1 i=1,n tbx=tbx+x(i) 1 tby=tby+y(i) tbx=tbx/n tby=tby/n fsx=0 fsy=0 r=0 do 2 i=1,n fsx=fsx+(x(i)-tbx)**2 fsy=fsy+(y(i)-tby)**2 2 r=r+(x(i)-tbx)*(y(i)-tby) fsx=sqrt(fsx/n) fsy=sqrt(fsy/n) r=r/(fsx*fsy)/n a=r*fsy/fsx b=a*tbx-tby return end