FORTRAN 90 L e c

advertisement
FORTRAN 90
Lecturer : Rafel Hekmat Hameed
University of Babylon
Subject : Fortran 90
College of Engineering
Year : Second B.Sc.
Mechanical Engineering Dep.
Q / GA
The increase in temperature dT of a chemical reaction can be calculated
using:
‫ ܂܌‬ൌ ૚ െ ‫܍‬ሺି‫ܜܓ‬ሻ ;
‫ ܓ‬ൌ ‫ܙି܍‬
;
‫ ܙ‬ൌ ૛૙૙૙Ȁሺ‫ ܂‬൅ ૛ૠ૜Ǥ ૚૟ሻ
Where T is the temperature in centigrade, and t is the time in second. Write a
program which evaluates the temperature of such a reaction at 2 minute intervals.
The initial temperature is supplied by the user and the above equation dT should be
re-calculated once every second. The program should terminate when the
temperature reaches twice the initial temperature. Use function subprogram to
compute dT, form a table contain T and dT every one second, and print your
formatted results in output file.
implicit none
real::q,t,to,d,k
integer::time
read(*,*) to
open(unit=9,file="rd.dat")
t=to
DO time=1,120
q=2000/(t+273.16)
k=exp(-q)
if((t+d(k,time))>=(2.0*to))exit
t=t+d(k,time)
ϭ
WRITE(9,20) t,d(k,time), time
20FORMAT(2X,"TEMP=",1X,F6.3,2X,"DT=",1X,F6.3,2X,"TIME=",
1X,I4)
enddo
end
real function d(k,time)
implicit none
real::k
integer::time
d=1-exp(-k*time)
end
Q/GB
Write a fortran 90 function subprogram, which transform the Cartesian
coordinate presentation (x,y) to the polar coordinates (r,), if you know
‫ܡ‬
‫ܠ‬
‫ܚ‬
‫ܚ‬
‫ ܖܑܛ‬ી ൌ ǡ‫ ܛܗ܋‬ી ൌ ǡ‫ ܚ‬ൌ ඥ‫ ܠ‬૛ ൅ ‫ ܡ‬૛
Note:  must be in degree
PROGRAM CONVERT
IMPLICIT NONE
REAL::X,Y,FF,D,F,FD
READ(*,*)X,Y
FF=F(X,Y)
D=FD(FF,X)
WRITE(*,*)FF,D
END
Ϯ
REAL FUNCTION F(X,Y)
IMPLICIT NONE
REAL::X,Y,R
R=SQRT(X**2+Y**2)
F=R
END
REAL FUNCTION FD(FF,X)
IMPLICIT NONE
REAL,PARAMETER::PI=3.14159
REAL::X,FF,Q
Q=ACOS(X/FF)
FD=(Q*180)/PI
END
ϯ
Download