File: file_23.f90

package info (click to toggle)
lfortran 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 46,332 kB
  • sloc: cpp: 137,068; f90: 51,260; python: 6,444; ansic: 4,277; yacc: 2,285; fortran: 806; sh: 524; makefile: 30; javascript: 15
file content (35 lines) | stat: -rw-r--r-- 952 bytes parent folder | download
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
33
34
35
! Testing different kinds of integer variables as unit number. 
program file_23
    type :: file_t
       integer(1) :: iunit_1
       integer(2) :: iunit_2
       integer(4) :: iunit_4
       integer(8) :: iunit_8
    end type file_t
 
    type(file_t) :: f
    character(30) :: str
    open(newunit=f%iunit_1, file='file_23_data.txt')
    read(f%iunit_1, *) str 
    print *, str
    if(str /= "HelloWorld!") error stop
    close(f%iunit_1)
    
    open(newunit=f%iunit_2, file='file_23_data.txt')
    read(f%iunit_2, *) str
    print *, str
    if(str /= "HelloWorld!") error stop
    close(f%iunit_2)
    
    open(newunit=f%iunit_4, file='file_23_data.txt')
    read(f%iunit_4, *) str
    print *, str
    if(str /= "HelloWorld!") error stop
    close(f%iunit_4)
    
    open(newunit=f%iunit_8, file='file_23_data.txt')
    read(f%iunit_8, *) str
    print *, str
    if(str /= "HelloWorld!") error stop
    close(f%iunit_8)
 end program file_23