File: example_bitsets_input.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 (32 lines) | stat: -rw-r--r-- 1,078 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
program example_input
  use stdlib_bitsets
  implicit none
  character(*), parameter :: &
    bits_0 = '000000000000000000000000000000000', &
    bits_1 = '000000000000000000000000000000001', &
    bits_33 = '100000000000000000000000000000000'
  integer :: unit
  type(bitset_64) :: set0, set1, set2, set3, set4, set5
  call set0%from_string(bits_0)
  call set1%from_string(bits_1)
  call set2%from_string(bits_33)
  open (newunit=unit, file='test.bin', status='replace', &
        form='unformatted', action='write')
  call set2%output(unit)
  call set1%output(unit)
  call set0%output(unit)
  close (unit)
  open (newunit=unit, file='test.bin', status='old', &
        form='unformatted', action='read')
  call set5%input(unit)
  call set4%input(unit)
  call set3%input(unit)
  close (unit)
  if (set3 /= set0 .or. set4 /= set1 .or. set5 /= set2) then
    error stop 'Transfer to and from units using '// &
      ' output and input failed.'
  else
    write (*, *) 'Transfer to and from units using '// &
      'output and input succeeded.'
  end if
end program example_input