fdoc

subroutineread_whole_file

subroutine read_whole_file(path, text, stat, errmsg)

Read all of file path. This can be called from parallel code, as all file I/O of threads has to take turns: libgfortran 16 can crash otherwise (see example/io_race.f90).

Arguments

NameTypeIntentAttributesDescription
pathcharacter(len=*)in

the file

textcharacter(len=:)outallocatable

its contents, or ''

statintegerout

nonzero on failure

errmsgcharacter(len=:)outallocatable

what is wrong

Source

Show the code
subroutine read_whole_file(path, text, stat, errmsg)
    character(len=*), intent(in) :: path                    !! the file
    character(len=:), allocatable, intent(out) :: text      !! its contents, or `''`
    integer, intent(out) :: stat                            !! nonzero on failure
    character(len=:), allocatable, intent(out) :: errmsg    !! what is wrong

    !$omp critical (file_io)
    call read_file(path, text, stat, errmsg)
    !$omp end critical (file_io)
end subroutine read_whole_file

Graphs

Called by