SORT-MERGE/XL Programmer's Guide (32650-90884)
110 AppendixD
FORTRAN Program Examples
Example of Record Input
OUTPUTFILE(1) = OUTFILENUM
OUTPUTFILE(2) = 0
OUTPUT_OPTION = 0
RECLENGTH = 80
NUMKEYS = 1
KEYS(1) = 1
KEYS(2) = 20
KEYS(3) = 0
KEYS(4) = 0
ALTSEQ(1:1) = CHAR(255)
ALTSEQ(2:2) = CHAR(255)
call HPSORTINIT (STATUS,, OUTPUTFILE, OUTPUT_OPTION
2 ,RECLENGTH,, NUMKEYS, KEYS, ALTSEQ)
if (STATUS .ne. 0) then
MESSAGE = ' '
call HPSORTERRORMESS (STATUS, MESSAGE, LENGTH)
print *,MESSAGE
endif
LENGTH = 72
EOF = .false.
C Read TEMPEMP file. Start with a priming read. If EOF is not found on
C the priming read, call HPSORTINPUT to put the record into the sort, then
C read and input until EOF is found.
LNGTH = FREAD (TEMPFILENUM, BUFFER, LENGTH)
if (ccode()) 10,30,20
10 print *, 'FREAD error on TEMPFILE'
call QUIT (10)
20 EOF = .true.
30 continue
do while ( .not. EOF)
BUFFER(40:40) = '*'
call HPSORTINPUT (STATUS, BUFFER, LENGTH)
if (STATUS .ne. 0) then
MESSAGE = ' '
call HPSORTERRORMESS (STATUS, MESSAGE, LENGTH)
print *, MESSAGE
endif
C Read the next record. CCG indicates EOF has been found.
LNGTH = FREAD (TEMPFILENUM, BUFFER, LENGTH)
if (ccode()) 40,60,50
40 print *, 'FREAD error on TEMPFILE'
call QUIT (40)
50 EOF = .true.