write(verbose=3,name=...) should filter output to exactly one matching name line.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout) | :: | id | |||
| integer, | intent(inout) | :: | nfail |
subroutine test_088(id, nfail) use forcolormap_info, only: cmap_info integer, intent(inout) :: id, nfail character(len=*), parameter :: name = "cmap_info%write(name=...): filters to exactly one entry" logical :: ok character(len=*), parameter :: fname = "test_tmp_cmap_info_write_filter.txt" character(len=:), allocatable :: target integer :: u, ios, count character(len=512) :: line target = trim(cmap_info%get_name(1)) call delete_if_exists(fname) call cmap_info%write(verbose=3, name=target, file_name=fname) ok = exists_file(fname) if (.not. ok) then call report_test(name, ok, id, nfail) return end if count = 0 ok = .true. open(newunit=u, file=fname, status="old", action="read") do read(u,'(a)', iostat=ios) line if (ios /= 0) exit if (len_trim(line) == 0) cycle count = count + 1 ok = ok .and. (trim(line) == target) end do close(u) ok = ok .and. (count == 1) call delete_if_exists(fname) call report_test(name, ok, id, nfail) end subroutine test_088