I wrote this simple code. I obtain Q_in
and Q_fin
but the value of Q
remains zero. So I think that the do
loop doesn't work.
program readwrite
implicit none
real a(200,4),Q_in,Q_fin,Q,Q_tot,v_med
integer i,j,nj
character*40 nome
write(6,*) 'nome file'
read(5,'(a)') nome
open(unit=16,file=nome)
nj=180
do i=1,nj
read(16,*) (a(i,j),j=1,4)
enddo
Q_in=(a(1,1)-a(1,3))/2*a(1,2)
Q_fin=(2-a(180,1))/2*a(180,2)
Q=0
do i=1,nj-1
Q=Q+1/2*((a(i+1,2)+a(i,2))*(a(i+1,1)-a(i,1)))
enddo
Q_tot=Q+Q_in+Q_fin
v_med=Q_tot/2
write(6,*) 'velocita media', v_med
write(6,*) 'Q', Q
write(6,*) 'Q_in', Q_in
write(6,*) 'Q_fin', Q_fin
end