0% found this document useful (0 votes)
42 views

Fortran Programs: 1-Cross Sections

1. The document contains Fortran code examples for calculating cross-sectional areas, channel flow properties, depth over time from pumping, and traffic rates from sensor data. 2. The cross-section area code calculates the area under a graph by summing triangular sections between data points. 3. The channel flow codes calculate properties like flow depth from inputs like channel size, flow velocity, using formulas like the Manning or Bernoulli equations.

Uploaded by

Karim Hamad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Fortran Programs: 1-Cross Sections

1. The document contains Fortran code examples for calculating cross-sectional areas, channel flow properties, depth over time from pumping, and traffic rates from sensor data. 2. The cross-section area code calculates the area under a graph by summing triangular sections between data points. 3. The channel flow codes calculate properties like flow depth from inputs like channel size, flow velocity, using formulas like the Manning or Bernoulli equations.

Uploaded by

Karim Hamad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Fortran programs

1-cross sections
program crosssection
dimension x(12),y(12)
print*,"enter num of cross sections "
read*,k
do 20 i=1,k
print*,"enter N "
read*,n
do 30 j=1,n
30 read(*,*)x(j),y(j)
do 50 l=2,n-1
50 sum=sum+x(l)*(y(l+1)-y(l-1))
b=x(1)*(y(2)-y(n))
c=x(n)*(y(1)-y(n-1))
area=sum+b+c
area=0.5*abs(area)
20 write(*,*)"area = ",area,"m2"
end

Fortran programming 2 by / karim hamad 1


2-channel
program channel
real s,n,h,v,r,b
print*,"enter S "
read*,s
print*,"enter N "
read*,n
print*,"enter H "
read*,h
print*,"enter V "
read*,v
r=(v*n/sqrt(s))**1.5
b=(2*h*r)/(h-r)
write(*,*)"B = ",b," ","M"
end

Fortran programming 2 by / karim hamad 2


3-channel 2
program channel2
real n,s,b,r,h,i
print*,"enter n "
read*,n
print*,"enter s "
read*,s
print*,"enter B "
read*,b
write(*,*)"velocity m/s "," ","height m"
do 10 i=2,3,0.01
r=((n*i)/sqrt(s))**1.5
h=(b*r)/(b-2*r)
10 write(*,20)i," ",h
write(*,*)" "
20 format(f5.2,a20,f5.3)
end

Fortran programming 2 by / karim hamad 3


program 6
programa depth
real q,a,t
open(17,file="output6.txt")
q=600.
a=1300.
write(17,*)"time (day) depth (m)"
do 10 t=0,10,0.5
if(t.eq.0.0)goto 10
y=y+(q/a)*(3.0*(sin(t-0.5)**2.0)-1.0)*0.5
10 write(17,50)t,y
50 format(f10.2,f20.3)
stop
End

‫ شيل الحاجه المتعلمه باالصفر وحط‬52.0 ‫∆ ب‬t ‫●لو عاوز‬


52.0

Fortran programming 2 by / karim hamad 4


program 7
program depth
dimension t(10001),y(10001)
open(17,file="output7.txt")
read*,a,q,delta
n=10.0/delta
call dep(t,y,n,q,delta,a)
write(17,*)"time(day) depth(m) "
do 20 j=1,n+1
20 write(17,50)t(j),y(j)
50 format (f5.2,f20.3)
stop
end

subroutine dep(t,y,n,q,delta,a)
dimension t(n+1),y(n+1)
t(1)=0.0
y(1)=0.0
do 10 i=2,n+1
t(i)=t(i-1)+delta
y(i)=y(i-1)+(q/a)*((3.0*sin(t(i-1))**2) -1.0)*delta
10 continue
return
end

Fortran programming 2 by / karim hamad 5


program 13

program area
dimension h(501)
real m
open(12,file="water.txt")
read(12,*)b,deltx
m=b/deltx
n=m+1
read(12,*)(h(i),i=1,n)
!trapezoidal rule
sum1=0.5*(h(1)+h(n))
do 10 i=2,n-1
10 sum2=sum2+h(i)
area1=deltx*(sum1+sum2)

!simpson rule
remainder=mod(m,2.0)
if(remainder.eq.0.0)then
sum3=h(1)+h(n)
do 20 j=2,n-1,2
20 sum4=sum4+h(j)
do 30 k=3,n-2,2
30 sum5=sum5+h(k)
area2=(deltx/3)*(sum3+4*sum4+2*sum5)

Fortran programming 2 by / karim hamad 6


else
sum3=h(2)+h(n)
area0=0.5*(h(1)+h(2))*deltx
do 40 j=3,n,2
40 sum4=sum4+h(j)
do 50 k=4,n-1,2
50 sum5=sum5+h(k)

area2=area0+(deltx/3)*(sum3+4*sum4+2*sum5)
endif

write(*,100)"area by trapezoidal rule = ",area1," m2 "


write(*,100)"area by simpson rule = ",area2," m2 "
100 format (a30,f10.3,a5)
end

Fortran programming 2 by / karim hamad 7


program 15
program traffic
dimension t(100),r(100)
open(17,file="15.txt")
read(17,*)n
read(17,*)(t(i),r(i),i=1,n)
traff=0.0
do 10 i=1,n-1
10 traff=traff+0.5*(r(i+1)+r(i))*(t(i+1)-t(i))*60.0
ntraff=traff
write(*,50)"traffic rate = ",ntraff," cars / day "
50 format (a15,i10,a20)
stop
end

Fortran programming 2 by / karim hamad 8

You might also like