1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| PROGRAM rocketlaunch
IMPLICIT NONE
INTEGER i,n,nl
C n is the number of row in the data file
OPEN (22,file='exo4data.dat',form='formatted',status='old')
nl=0
READ (22,*) n
PRINT *, 'n=', n
CALL matra(i,n)
END
C
C this subroutine stores the data file into a matrix A :
C
SUBROUTINE matra(i,n)
INTEGER i,n
REAL A(n,2)
DO i=1,n
READ (22,*) (A(i,j),j=1,2)
END DO
PRINT *, 'A=',A
CALL velocity(i,n,A)
RETURN
END
C
C this subroutine computes the estimated velocities and stores them
C into the matrix C :
C
SUBROUTINE velocity(i,n,B)
IMPLICIT NONE
INTEGER i,n
REAL B(n,2),C(n+1)
DO i=3,n
C(i)=(B(i+1,2)-B(i-1,2))/(B(i+1,1)-B(i-1,1))
END DO
C(1)=n
C(2)=(B(2,2)-B(1,2))/(B(2,1)-B(1,1))
C(n)=(B(n,2)-B(n-1,2))/(B(n,1)-B(n-1,1))
PRINT *, 'C=',C
OPEN (unit=33,file='velocity.dat',form='unformatted',
1 status='replace',action='write')
WRITE (33) C
CALL acceleration(i,n,B,C)
RETURN
END
C
C this subroutine computes the estimated accelerations and stores them
C into the matrix G :
C
SUBROUTINE acceleration(i,n,E,F)
IMPLICIT NONE
INTEGER i,n
REAL E(n,2),F(n+1),G(n+1)
DO i=3,n
G(i)=(F(i+1)-F(i-1))/(E(i+1,1)-E(i-1,1))
END DO
G(1)=n
G(2)=(F(2)-F(1))/(E(2,1)-E(1,1))
G(n)=(F(n)-F(n-1))/(E(n,1)-E(n-1,1))
PRINT *, 'G=',G
RETURN
END |
Partager