SORT-MERGE/XL Programmer's Guide (32650-90884)

Appendix D 113
FORTRAN Program Examples
Example of Record Output
Example of Record Output
The following program sorts the personnel files shown for the last example. They are
sorted by last name. The output records are altered before they are output.
Example D-4. SORTREC_OUTPUT Program
$standard_level system
program SORTREC_OUTPUT
C
C This program reads the files TEMPEMP and PERMEMP, sorts them by last
C name, outputs them by record, alters the output recors, and prints the
C record to $STDLIST.
C
integer TEMPFILENUM
2 ,PERMFILENUM
3 ,STATUS
C
common /PARMS/ TEMPFILENUM, PERMFILENUM, STATUS
C
call OPEN_FILES
call DO_SORT
call CLOSE_FILES
stop
end
C
subroutine OPEN_FILES
C
system intrinsic HPFOPEN
2 ,QUIT
C
integer DESIGNATOR
2 ,DOMAIN
3 ,ACCESS
4 ,PERMANENT
5 ,TEMPFILENUM
6 ,PERMFILENUM
7 ,STATUS
C
character TEMPFILE*10
2 ,PERMFILE*10
C
common /PARMS/ TEMPFILENUM, PERMFILENUM, STATUS
C
DESIGNATOR = 2
DOMAIN = 3
ACCESS = 11
C
TEMPFILE = '%TEMPEMP%'
PERMANENT = 1
call HPFOPEN (TEMPFILENUM, STATUS, DESIGNATOR,
2 ,TEMPFILE, DOMAIN, PERMANENT)
if (STATUS .ne. 0) then
print *, 'HPFOPEN error on TEMPFILE. Terminating.'
call QUIT (1)