Guest User

Untitled

a guest
Sep 7th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PROGRAM subroutine_madness
  2.  
  3. IMPLICIT NONE
  4. INTEGER :: n
  5. DOUBLE PRECISION, POINTER,  DIMENSION (:) :: xfct
  6. DOUBLE PRECISION, POINTER,  DIMENSION (:) :: yfct
  7. DOUBLE PRECISION                :: sum, sumprod
  8. DOUBLE PRECISION                :: sx, sy, sx2, sy2, sxy, roh
  9.  
  10. print*, 'n'
  11. READ (5,*) n
  12. print*, 'n', n
  13.  
  14. ALLOCATE (xfct(n),yfct(n))
  15. CALL  lies (xfct,n)
  16. CALL  lies (yfct,n)
  17. CALL  summe (xfct,n,sx)
  18. CALL  summe (yfct,n,sy)
  19. CALL  sumproduct (xfct,xfct,n,sx2)
  20. CALL  sumproduct (yfct,yfct,n,sy2)
  21. CALL  sumproduct (xfct,yfct,n,sxy)
  22.  
  23. roh=(sxy-sx*sy)/( ((sx2-sx*sx)*(sy2-sy*sy))**(0.5D0) )
  24. PRINT*, roh
  25. DEALLOCATE(xfct,yfct)
  26. END PROGRAM
  27.  
  28. !===================================
  29.  
  30. SUBROUTINE lies (xfct,n)
  31.  
  32. IMPLICIT NONE
  33. INTEGER :: n,i
  34. DOUBLE PRECISION, DIMENSION (n) :: xfct
  35.  
  36. print*, 'Messwerte'
  37. DO i=1,n
  38.   READ(5,*) xfct(i)
  39. END DO
  40.  
  41. END SUBROUTINE lies
  42.  
  43. !==================================
  44.  
  45. SUBROUTINE summe (xfct,n,sum)
  46.  
  47. IMPLICIT NONE
  48. INTEGER :: n,i
  49. DOUBLE PRECISION, DIMENSION (n) :: xfct
  50. DOUBLE PRECISION :: sum
  51.  
  52. SUM=0.D0
  53.  
  54. DO i=1,n
  55.    SUM = SUM + xfct(i)
  56. END DO
  57.  
  58. SUM = SUM/n
  59.  
  60. END SUBROUTINE summe
  61.  
  62. !==================================
  63.  
  64. SUBROUTINE sumproduct(xfct,yfct,n,sumprod)
  65.  
  66. IMPLICIT NONE
  67. INTEGER :: n,i
  68. DOUBLE PRECISION, DIMENSION (n) :: xfct
  69. DOUBLE PRECISION, DIMENSION (n) :: yfct
  70. DOUBLE PRECISION :: sumprod
  71.  
  72. sumprod = 0.D0
  73.  
  74. DO i=1,n
  75.   sumprod=sumprod + xfct(i)*yfct(i)
  76. END DO
  77.  
  78. sumprod=sumprod/n
  79. END SUBROUTINE
Add Comment
Please, Sign In to add comment