Similar to input_unit but set exist
to true if nml
was found in the
input file, and false otherwise
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | nml |
Name of namelist to find start of |
||
logical, | intent(out) | :: | exist |
Was |
function input_unit_exist (nml,exist)
implicit none
!> Name of namelist to find start of
character(*), intent (in) :: nml
!> Was `nml` was found in the input file?
logical, intent(out) :: exist
integer :: input_unit_exist, iostat
character(500) :: line
intrinsic adjustl, trim
input_unit_exist = input_unit_no
exist = .true.
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
exist = .false.
end function input_unit_exist