Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROGRAM subroutine_madness
- IMPLICIT NONE
- INTEGER :: n
- DOUBLE PRECISION, POINTER, DIMENSION (:) :: xfct
- DOUBLE PRECISION, POINTER, DIMENSION (:) :: yfct
- DOUBLE PRECISION :: sum, sumprod
- DOUBLE PRECISION :: sx, sy, sx2, sy2, sxy, roh
- print*, 'n'
- READ (5,*) n
- print*, 'n', n
- ALLOCATE (xfct(n),yfct(n))
- CALL lies (xfct,n)
- CALL lies (yfct,n)
- CALL summe (xfct,n,sx)
- CALL summe (yfct,n,sy)
- CALL sumproduct (xfct,xfct,n,sx2)
- CALL sumproduct (yfct,yfct,n,sy2)
- CALL sumproduct (xfct,yfct,n,sxy)
- roh=(sxy-sx*sy)/( ((sx2-sx*sx)*(sy2-sy*sy))**(0.5D0) )
- PRINT*, roh
- DEALLOCATE(xfct,yfct)
- END PROGRAM
- !===================================
- SUBROUTINE lies (xfct,n)
- IMPLICIT NONE
- INTEGER :: n,i
- DOUBLE PRECISION, DIMENSION (n) :: xfct
- print*, 'Messwerte'
- DO i=1,n
- READ(5,*) xfct(i)
- END DO
- END SUBROUTINE lies
- !==================================
- SUBROUTINE summe (xfct,n,sum)
- IMPLICIT NONE
- INTEGER :: n,i
- DOUBLE PRECISION, DIMENSION (n) :: xfct
- DOUBLE PRECISION :: sum
- SUM=0.D0
- DO i=1,n
- SUM = SUM + xfct(i)
- END DO
- SUM = SUM/n
- END SUBROUTINE summe
- !==================================
- SUBROUTINE sumproduct(xfct,yfct,n,sumprod)
- IMPLICIT NONE
- INTEGER :: n,i
- DOUBLE PRECISION, DIMENSION (n) :: xfct
- DOUBLE PRECISION, DIMENSION (n) :: yfct
- DOUBLE PRECISION :: sumprod
- sumprod = 0.D0
- DO i=1,n
- sumprod=sumprod + xfct(i)*yfct(i)
- END DO
- sumprod=sumprod/n
- END SUBROUTINE
Add Comment
Please, Sign In to add comment