File: example_get_file.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (20 lines) | stat: -rw-r--r-- 532 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
! Demonstrate usage of `get_file`
program example_get_file
  use stdlib_io, only: get_file
  use stdlib_string_type, only: string_type
  use stdlib_error, only: state_type
  implicit none

  character(*), parameter :: filename = "example.txt"
  type(string_type) :: filecontent
  type(state_type) :: err

  ! Read a file into a string
  call get_file(filename, filecontent, err=err)

  if (err%error()) then
    print *, err%print()
  else
    print *, "Success! File "//filename//" imported."
  end if
end program example_get_file