SORT-MERGE/XL Programmer's Guide (32650-90884)
Appendix D 103
FORTRAN Program Examples
Example of Core Merging Routine
Example of Core Merging Routine
The following program merges the personnel files shown at the beginning of the previous
example. They are merged by employee number. The record size is determined by the input
files. The
status
parameter is checked after the calls to HPMERGEINIT and HPMERGEEND.
Example D-2. MERGEFILE Program
$standard_level system
program MERGEFILE
C
C This program reads the files TEMPEMP and PERMEMP, merges them by EMPLOYEE
C NUMBER, and outputs them to the file ALLEMP.
C The compiler directive '$standard_level system' is used to supress
C FORTRAN 77 warnings for non-standard features, which include intrinsics
C calls.
C
integer TEMPFILENUM
2 ,PERMFILENUM
3 ,OUTFILENUM
4 ,STATUS
C
common /PARMS/ TEMPFILENUM, PERMFILENUM
2 ,OUTFILENUM, STATUS
C
call OPEN_FILES
call DO_MERGE
call CLOSE_FILES
stop
end
C
subroutine OPEN_FILES
C
system intrinsic HPFOPEN
2 ,QUIT
C
integer DESIGNATOR
2 ,DOMAIN
3 ,ACCESS
4 ,RECORD_SIZE
5 ,PERMANENT
6 ,NEW
7 ,WRITE
8 ,SIZE
9 ,TEMPFILENUM
A ,PERMFILENUM
B ,OUTFILENUM
C ,STATUS
C
character TEMPFILE*10
2 ,PERMFILE*10
3 ,OUTFILE*10
C
common /PARMS/ TEMPFILENUM, PERMFILENUM
2 ,OUTFILENUM, STATUS