Read a formatted unit to its end, one line per record. toml-f and jonquil read a unit by re-opening it first, which NAG 7.2 rejects for a unit from NEWUNIT=
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | unit |
Formatted unit to read |
||
| character(len=:), | intent(out), | allocatable | :: | text |
Text read, with lines separated by new_line(‘a’) |
|
| type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
subroutine read_unit_text(unit, text, error) !> Formatted unit to read integer, intent(in) :: unit !> Text read, with lines separated by new_line('a') character(len=:), allocatable, intent(out) :: text !> Error handling type(error_t), allocatable, intent(out) :: error character(len=:), allocatable :: line integer :: stat text = "" do call getline(unit, line, stat) if (stat > 0) then call fatal_error(error, "Failed to read from unit") return end if text = text // line // new_line('a') if (stat < 0) exit end do end subroutine read_unit_text