File: example_error_state1.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 (18 lines) | stat: -rw-r--r-- 712 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
program example_error_state1
  use stdlib_error, only: state_type, STDLIB_VALUE_ERROR, STDLIB_SUCCESS, operator(/=) 
  implicit none
  type(state_type) :: err

  ! To create a state variable, we enter its integer state flag, followed by a list of variables 
  ! that will be automatically assembled into a formatted error message. No need to provide string formats
  err = state_type(STDLIB_VALUE_ERROR,'just an example with scalar ',&
                   'integer=',1,'real=',2.0,'complex=',(3.0,1.0),'and array ',[1,2,3],'inputs')

  ! Print flag
  print *, err%print()

  ! Check success
  print *, 'Check error: ',err%error()
  print *, 'Check flag : ',err /= STDLIB_SUCCESS

end program example_error_state1