
MODULE HOLDER
  IMPLICIT NONE

  TYPE INTERNAL
     REAL :: R
     INTEGER :: I, J
  END TYPE INTERNAL

CONTAINS

  SUBROUTINE TEST(A, B)
    REAL, INTENT(OUT), OPTIONAL :: A
    REAL, INTENT(IN) :: B
    IF (PRESENT(A)) THEN
       A = TEST_INTERNAL()
    END IF
  CONTAINS
    FUNCTION TEST_INTERNAL()
      REAL :: TEST_INTERNAL
      TEST_INTERNAL = 2.0 * B
    END FUNCTION TEST_INTERNAL
  END SUBROUTINE TEST

  SUBROUTINE PROC_TEST(A)
    ABSTRACT INTERFACE
       FUNCTION PTINT(B)
         TYPE USEFUL
            REAL :: R, S
         END TYPE USEFUL
         TYPE(USEFUL), INTENT(IN) :: B
         REAL PTINT
       END FUNCTION PTINT
    END INTERFACE
    PROCEDURE(PTINT) :: A

  END SUBROUTINE PROC_TEST

END MODULE HOLDER






PROGRAM TRY_SOMETHING
  USE HOLDER
  IMPLICIT NONE
  REAL :: FIRST, SECOND
  TYPE(INTERNAL), DIMENSION(2,2) :: CUSTOM_TYPE

  CUSTOM_TYPE%I = 1
  CUSTOM_TYPE%J = 0
  CUSTOM_TYPE(:,:)%R = 1.0
  PRINT *, CUSTOM_TYPE(:,:)

  ! FIRST = 1.0
  ! SECOND = 2.0

  ! PRINT *, FIRST
  ! PRINT *, SECOND
  ! CALL TEST(A=FIRST, B=SECOND)
  ! PRINT *, FIRST
  ! PRINT *, SECOND

END PROGRAM TRY_SOMETHING
