program TEST_ARRAY_TRANSMISSION

    double precision, dimension(:,:), allocatable :: DBLE_2D_ARRAY
    type TYPE1
       double precision :: DBLE_FIELD
    end type
    type TYPE2
       type(TYPE1) :: TYPE1_FIELD
    end type
    type(TYPE1), dimension(:,:), allocatable :: TYPE1_2D_ARRAY
    type(TYPE2), dimension(:), allocatable :: TYPE2_1D_ARRAY
    type(TYPE2), dimension(:,:), allocatable :: TYPE2_2D_ARRAY


    write(6,*) "test 2D array of double precisions - lbound 0, ubound 0"
    allocate(DBLE_2D_ARRAY(2,0:0))
    DBLE_2D_ARRAY(1:2,0) = (/ 1., 2. /) ! dble([1:2])
    write(6,*) "direct write", DBLE_2D_ARRAY(1:2,0)
    call WRITE_1D_ARRAY(DBLE_2D_ARRAY(1:2,0))

    write(6,*) "test 2D array of type TYPE1 - lbound 0, ubound 0"
    allocate(TYPE1_2D_ARRAY(2,0:0))
    TYPE1_2D_ARRAY(1:2,0)%DBLE_FIELD = (/ 1., 2. /) ! dble([1:2])
    write(6,*) "direct write", TYPE1_2D_ARRAY(1:2,0)%DBLE_FIELD
    call WRITE_1D_ARRAY(TYPE1_2D_ARRAY(1:2,0)%DBLE_FIELD)

    write(6,*) "test 2D array of type TYPE2 - lbound 1, ubound 1"
    allocate(TYPE2_2D_ARRAY(2,1))
    TYPE2_2D_ARRAY(1:2,1)%TYPE1_FIELD%DBLE_FIELD = (/ 1., 2. /) ! dble([1:2])
    write(6,*) "direct write", TYPE2_2D_ARRAY(1:2,1)%TYPE1_FIELD%DBLE_FIELD
    call WRITE_1D_ARRAY(TYPE2_2D_ARRAY(1:2,1)%TYPE1_FIELD%DBLE_FIELD)

    write(6,*) "test 2D array of type TYPE2 - lbound 0, ubound 0"
    deallocate(TYPE2_2D_ARRAY)
    allocate(TYPE2_2D_ARRAY(2,0:0))
    TYPE2_2D_ARRAY(1:2,0)%TYPE1_FIELD%DBLE_FIELD = (/ 1., 2. /) ! dble([1:2])
    write(6,*) "direct write", TYPE2_2D_ARRAY(1:2,0)%TYPE1_FIELD%DBLE_FIELD
    call WRITE_1D_ARRAY(TYPE2_2D_ARRAY(1:2,0)%TYPE1_FIELD%DBLE_FIELD)

    write(6,*) "test 1D array of type TYPE2 - lbound 0, ubound 1"
    allocate(TYPE2_1D_ARRAY(0:1))
    TYPE2_1D_ARRAY(0:1)%TYPE1_FIELD%DBLE_FIELD = (/ 1., 2. /) ! dble([1:2])
    write(6,*) "direct write", TYPE2_1D_ARRAY(0:1)%TYPE1_FIELD%DBLE_FIELD
    call WRITE_1D_ARRAY(TYPE2_1D_ARRAY(0:1)%TYPE1_FIELD%DBLE_FIELD)


contains

  subroutine WRITE_1D_ARRAY(DBLE_1D_ARRAY)

    double precision, dimension(:), intent(in) :: DBLE_1D_ARRAY


    write(6,*) "write after transmission", DBLE_1D_ARRAY
    write(6,*) "lbound - ubound", lbound(DBLE_1D_ARRAY,1), ubound(DBLE_1D_ARRAY,1)
    write(6,*)

  end subroutine WRITE_1D_ARRAY

end program TEST_ARRAY_TRANSMISSION

