! Module module mod_rgen private public :: rgen interface rgen module procedure rgen1d, rgen2d end interface contains subroutine rgen1d(x) real :: x(:) call random_number(x) end subroutine rgen1d subroutine rgen2d(x) real :: x(:,:) call random_number(x) end subroutine rgen2d end module mod_rgen ! Main program program main use mod_rgen implicit none real, allocatable :: a(:,:), b(:) integer :: n print*, 'Give N' read*, n allocate(a(n,n),b(n)) call rgen(a) ! Calling rgen1d and rgen2d wont work since- call rgen(b) ! -they have been made private in the module print*, 'A is a 2D matrix with values', a print*, 'B is a 1D matrix with values', b deallocate(a,b) end program main