program f90_floodr implicit none integer,parameter::nnmax=1000 integer,parameter::ndmax=1000 real(8)::rh(1:nnmax),rv(1:nnmax),vcoef ! Reservoir H-V data real(8)::ti(1:ndmax),q_in(1:ndmax),ELini,outlet ! Inflow data real(8)::EL,VOL,q_out real(8)::hh,dh,eps,q1,q2,Qin,Qout,R,elv integer::i,j,nn,nd,iUD,io character(len=50)::fnameR1,fnameR2 call getarg(1,fnameR1) call getarg(2,fnameR2) ! Input H-V data open(11,file=fnameR1,status='old') read(11,*) vcoef do i=1,nnmax read(11,*,iostat=io) rh(i),rv(i) rv(i)=rv(i)*vcoef if(io<0)exit end do close(11) nn=i-1 ! Input time sequence of inflow open(11,file=fnameR2,status='old') read(11,*) ELini,outlet do i=1,ndmax read(11,*,iostat=io) ti(i),q_in(i) if(io<0)exit end do close(11) nd=i-1 ! Initial outflow elv=ELini EL=elv VOL=RET_V(nn,rh,rv,EL) elv=RET_H(nn,rh,rv,VOL) q_out=SPQ(elv)+outlet i=1 iUD=0 write(6,'(2(a5),6(a15))') 'i','iUD','time','EL','EL-elv','VOL','q_in','q_out' write(6,'(2(i5),6(e15.7))') i,iUD,ti(i),EL,EL-elv,VOL,q_in(i),q_out ! Iterative calculation iUD=1 dh=0.0001 eps=0.0005 do i=1,nd-1 Qin=0.5D0*(q_in(i)+q_in(i+1))*(ti(i+1)-ti(i))*3600.0D0 hh=0.0D0 j=0 do j=j+1; hh=hh+dble(iUD)*dh elv=EL ;q1=SPQ(elv)+outlet elv=EL+hh ;q2=SPQ(elv)+outlet Qout=0.5D0*(q1+q2)*(ti(i+1)-ti(i))*3600.0D0 R=VOL+Qin-Qout elv=RET_H(nn,rh,rv,R) if(iUD==1.and.j==10)then if(EL+hh>elv)then iUD=-1 hh=0.0D0 j=0 end if end if if(iUD==-1.and.j==10)then if(EL+hh