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
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| path | character(len=*) | in | the file | |
| text | character(len=:) | out | allocatable | its contents, or |
| stat | integer | out | nonzero on failure | |
| errmsg | character(len=:) | out | allocatable | 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