module mod

implicit none

contains

subroutine namelistWrite(array)

real, dimension(:), intent(in) :: array
integer :: istat

namelist / foo / array

open(unit=16, file='foo.nml', status='replace', action='write',&
     form='formatted', delim='apostrophe',iostat=istat)
write(unit=16,nml=foo,iostat=istat)
close(unit=16,status='keep',iostat=istat)

end subroutine namelistWrite

end module mod


program testDriver

use mod
implicit none

real, dimension(3) :: a = (/ 1.0, 2.0, 3.0 /)

call namelistWrite(a)

end program testDriver
