Rewind the input file to start of namelist nml
, and return the unit of
the file opened by init_input_unit
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | nml |
Name of namelist to find start of |
function input_unit (nml)
implicit none
!> Name of namelist to find start of
character(*), intent (in) :: nml
integer :: input_unit, iostat
character(500) :: line
intrinsic adjustl, trim
input_unit = input_unit_no
if (input_unit_no > 0) then
rewind (unit=input_unit_no)
do
read (unit=input_unit_no, fmt="(a)", iostat=iostat) line
if (iostat /= 0) then
rewind (unit=input_unit_no)
exit
end if
if (trim(adjustl(line)) == "&"//nml) then
backspace (unit=input_unit_no)
return
end if
end do
end if
write (unit=error_unit_no, fmt="('Couldn''t find namelist: ',a)") nml
write (unit=*, fmt="('Couldn''t find namelist: ',a)") nml
end function input_unit