Advertisement
lsmenicucci

hold my coffee

Aug 29th, 2022
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE variables
  2.     IMPLICIT NONE
  3.  
  4.     INTEGER, PARAMETER  :: n = 5
  5.     REAL, DIMENSION(N)   :: a, b
  6.  
  7.     CONTAINS
  8.  
  9.     SUBROUTINE print_array_inline(size, arr)
  10.         INTEGER, INTENT(IN) :: size
  11.         REAL, DIMENSION(size), INTENT(IN) :: arr
  12.  
  13.         INTEGER :: i
  14.  
  15.         DO i = 1, size
  16.             WRITE(*, "(F12.8)", advance = "no") arr(i)
  17.         END DO
  18.  
  19.     END SUBROUTINE
  20.  
  21.     SUBROUTINE print_state()
  22.         CALL print_array_inline(n, a)
  23.         CALL print_array_inline(n, b)
  24.  
  25.         WRITE(*, *)
  26.     END SUBROUTINE
  27.  
  28. END MODULE variables
  29.  
  30.  
  31. PROGRAM hold_my_coffee
  32.     USE variables
  33.  
  34.     IMPLICIT NONE
  35.     INTEGER :: i
  36.  
  37.     DO i = 1, 10  
  38.         CALL RANDOM_NUMBER(a)
  39.         CALL RANDOM_NUMBER(b)
  40.  
  41.         CALL print_state()
  42.     END DO
  43. END PROGRAM hold_my_coffee
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement