program dynamic_array_maximum_3d
    implicit none
    integer :: n1, n2, n3, n4 , k, i, j, l, a
    integer :: sum3
    real :: max_element
    real, allocatable :: array(:,:,:), array2(:,:,:), array3(:,:,:)

    write(*, *) "Enter 3 integers"
    read(*, *) n, m, k
    m = 100

    if (1 .eq. 1) then
        a = 3
    else if (2 .eq. 1) then
        a = 4
    endif

    m = m + 1
    k = m * 1000 + n * 10

    allocate(array(n, m + n, k + m + n), &
            &array2(k, m + n, k), &
            &array3(k, m, k + n))

    call random_seed()
    do i = 1, n1
        do j = 1, m * n1
            do l = 1, k * m * n1
                call random_number(array(i,j,l))
                array(i,j,l) = int(array(i,j,l) * 100)
            end do
        end do
    end do

    max_element = array(1,1,1)
    do i = 1, n1
        do j = 1, m
            do l = 1, k
                max_element = MAX(array(i,j,l), max_element)
            end do
        end do
    end do
    deallocate(array, array2, array3)
    write(*, *) max_element
end program dynamic_array_maximum_3d

! function sum3(x, y, z)
!  implicit none
!  integer :: x, y, z
!  integer :: sum3
!  sum3 = x + y + z
! end function sum3
