HP Fortran Programmer's Guide (B3908-90031; September 2011)

Calling C routines from HP Fortran
File handling
Chapter 8200
! written; if the write was successful, it should be 10
status=IWRITE(fd, a, 10)
CLOSE (1, STATUS=’KEEP’)
! open the file for reading; we want to see if the write was
! successful
OPEN (1, FILE='file1', STATUS='UNKNOWN')
READ (1, 4) (a(i), i = 1, 10)
4 FORMAT (10A1)
CLOSE (1, STATUS='DELETE')
DO i = 1, 10
! if we find anything other than x's, the write failed
IF (a(i) .NE. 'x') STOP 'FNUM_TEST failed'
END DO
! check write's return value; it should be 10
IF (status .EQ. 10) PRINT *, 'FNUM_TEST passed'
END
Below are the command lines to compile, link, and execute the program, followed by the output from a
sample run.
$ f90 fnum_test.f90
$ a.out
FNUM_TEST passed
The HP Fortran Programmer's Reference describes the FNUM and FNUM intrinsics and the ALIAS directive.
For information about the write system routine, see the write(2) man page.