C File: test_module_11.f
C Purpose: Illustrates the use of multiple Fortran modules to define values 
C    for several variables that are used in the program.  This program 
C    differs from test_module_03.f in having modules that have "USE MODULE"s
C    inside them , as well as some variables that are declared to be PRIVATE.
C
C Compile and run this program as follows:
C
C    gfortran -c test_module_11.f   # << this creates the files "mymod11a.mod"
C                                                               "mymod11b.mod"
C                                                               "mymod11c.mod"
C    gfortran test_module_11.f      # << this creates a file "a.out"
C
C The output generated by this program is (see test_module_11-OUT.txt):
C
C mymod11B: X = 123; Y = 234; Z = 345; U = 567; V = 678
C mymod11C: X = 123; Y = 234; Z =   12.345; U = 567; V = 678
C pgm main: X = 123; Y =  98.765; Z =  12.345; U =  87.654; V = 678

!-------------------------------------------------------------------------------
      MODULE MYMOD11A
      IMPLICIT NONE

      INTEGER :: X = 123, Y = 234, Z = 345
      END MODULE mymod11a

!-------------------------------------------------------------------------------
      MODULE MYMOD11B
      USE MYMOD11A    ! << Note that "use mymod11a" is inside mymod11b

          private :: Z    ! << hides Z imported from mymod11a
          INTEGER :: U = 567, V = 678
      contains
          subroutine print_mymod11b()
 10       format ('mymod11B: X = ', I3, '; Y = ', I3, '; Z = ', I3, 
     &                    '; U = ', I3, '; V = ', I3)
          write (*,10) X, Y, Z, U, V
          end subroutine print_mymod11b

      END MODULE mymod11b

!-------------------------------------------------------------------------------
      MODULE MYMOD11C
      USE mymod11B    ! << Note that "use mymod11b" is inside mymod11c

          PRIVATE :: Y, U ! << hides Y from mymod11a, U from mymod11b
          REAL :: Z = 12.345  ! << reusing Z
      contains
          subroutine print_mymod11c()
          call print_mymod11b()
 11       FORMAT('mymod11C: X = ', I3, '; Y = ', I3,'; Z = ', F8.3,
     &                     '; U = ', I3, '; V = ',I3)
          WRITE (*,11) X, Y, Z, U, V
          end subroutine print_mymod11c

      END MODULE mymod11C

!-------------------------------------------------------------------------------
      PROGRAM PGM
      USE mymod11c

      REAL :: Y = 98.765, U = 87.654  ! << reusing Y, U

      call print_mymod11c()

 10   FORMAT('pgm main: X = ', I3, '; Y = ', F7.3,'; Z = ', F7.3,
     &                     '; U = ', F7.3, '; V = ',I3)
      write (*,10) X, Y, Z, U, V

      stop
      end program PGM
!-------------------------------------------------------------------------------
