write(...,append=.true.) should append to an existing file (doubling line count for verbose=3).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(inout) | :: | id | |||
| integer, | intent(inout) | :: | nfail |
subroutine test_089(id, nfail) use forcolormap_info, only: cmap_info integer, intent(inout) :: id, nfail character(len=*), parameter :: name = "cmap_info%write(append=.true.): appends to existing file" logical :: ok character(len=*), parameter :: fname = "test_tmp_cmap_info_write_append.txt" integer :: n, u, ios, count character(len=512) :: line n = cmap_info%get_ncolormaps() call delete_if_exists(fname) call cmap_info%write(verbose=3, file_name=fname) call cmap_info%write(verbose=3, file_name=fname, append=.true.) ok = exists_file(fname) if (.not. ok) then call report_test(name, ok, id, nfail) return end if count = 0 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) count = count + 1 end do close(u) ok = (count == 2*n) call delete_if_exists(fname) call report_test(name, ok, id, nfail) end subroutine test_089