• Aucun résultat trouvé

is It

N/A
N/A
Protected

Academic year: 2022

Partager "is It"

Copied!
384
0
0

Texte intégral

(1)

IBM System/360

Disk Operating System Sort/Merge

Program Number 360N-SM-450

This publication describes the internal logic of the IBM System/360 Disk Operating System

Sort/Merge program. It is intended for use by persons involved in program maintenance. and by system programmers who are altering the program design. Program logic information is not

necessary for the operation of the program;

therefore, distribution of this publication is limited to those with maintenance and alteration requirements.

Y24-5021-0

Program Logic

(2)

PREFACE

This Program Logic Manual ('PLM) is a detailed guide to the IBM System/360 Dis.k Operating System Sort/Merge Program; it supplements the program listing by provid- ing descriptive text and flowcharts.

Effective use of this manual requires an understanding of IBM System/360 operation and of IBM System/36 0 Disk Operating System service programs, assembler language, macro instructions, and sort/merge program speci- fications. Reference publications for this information are:

• IBM system/360 Principles of operation, Form A22-6821.

• IBM system/36G Disk Operating System, sort/Merge Program Specifications, Form C24-3444.

• IBM System/36a Disk Operating system, Data Management Concepts, Form

C24-3427.

IBM system/360 Disk Operating System, System control and System Service Pro- grams, ·Form C24-3428.

IBM System/JoO Disk operating System, Supervisor and Input/Output Macros, Form C24-3429.

IBM System/36a Disk operating System, system Generation and Maintenance, Form C24-5033.

IBM System/36G Disk and Tape Operating Systems, Assembler Specifications, Form C24-3414.

Titles and abstracts of other related publications are listed in the IBM

System/36a Bibliography, Form A22-6822.

This manual consists of eight major sections. The first section is an intro- duction to the five major components

(phases) of the sort/merge program. The .next five sections describe each major component, starting with a general discus- sion of the phase. Each major component is further subdivided into logical elements

(routines). Finally, the function blocks that make up each logical element are des- cribed in detail. The seventh section includes the optional routines (data con- version, etc.) that are available for all the phases.

The last section of the manual consists of additional reference material for use in analyzing p~ogram details.

The flowcharts for all the major compo- nents and for the optional routines are located at the end of the manual. The detailed flowcharts are identified by the letters AA through ZZ. Numerals. such as 00 for the program level flowchart, iden- tify the more general flowcharts.

RESTRICTED DISTRIBUTION, This publication is intended primarily for use by IBM personnel,involved in program design and maintenance. It .may not be made available to others without the approval of local IBM

management.

First Edition, August 1966

Significant changes and additions to the

specifications contained in this publication will be reported in subsequent revisions or Technical Newsletters.

Requests for copies of IBM publications should be made to your IBM representative or to the IBM branch office se~ing your locality.

A fo~m is provided at the back of this publication for readers' comments. If the for'm has been removed. comments may be addressed to IBM Corporation, programming Publications, Endicott, New York 13760.

(3)

INTRODUCTION • • • •

.

'"

.

9

Program organization • • Program Generation.

Program Characteristics. • System Requirements. • • •

ASSIGNMENT PHASE (PHASE 0) - 01 • • •

12 12

• 13 22 23 Read and Compress Control Cards - AA • • 25

Sort compressed Control Cards - AB • • • 30 Scan SORT, MERGE4 and RECORD Control

cards - AC. • • • • • • • • • • • 31 Scan INPFIL, OUTFIL. MODS, OPTION and

END Control Cards - AD. AE. • • .. .. 33 Open work Area and pre-Edit - AF.AG.

Open Work Area and Pre-Edit (continued) - AG. • • • • •

Compute Maximum Allowable Input and

35

• 38 Output Record and Block Lengths AH. 42

Post Edit - AJ • 45

Compute Constants for Fixed-Length

Records - .AK, AL. • • • • • • • • • • • 50 Compute Cons tan ts (Variab le-.Length

Records) - AM • • • • • • • • • • 55 Compute Constants for ADD ROUT Sort -

AN. • • 58

Select Order of Merge - AP, AQ • • 61 Print Control Card and Fetch Next

Phase - AR, AS. • • • • • • • • • 64 INTERNAL SORT (PHASE 1) - 02 • 68 Initialization Routine f~r

Multi-Volume (Exit 11 Linkage) - BA • • 71

Forma t Routine - BB. • 72

Initialization for Disk or Tape Input

- Be • • • • • • 72

Input Routine for Disk or Tape - BD. • • 74

Tape Input Routine - BE. 75

Internal Sort - BF • • • • • 75

CONTENTS

output Routine - BG. • End-of- Phase Routine - BH.

• • 77 80 Initialization for ADDROUT Run - BJ. 81 Input Routine for ADDROUT Run - BK, BL ., 82 In terna 1 Sort (ADDROUT Run) - BF • • 84 output Routine (ADDROUT Run) - BG. • • • 84 Multi-Volume. Exit 11 Linkage - BM, BN • 84 PHASE 2 - EXTERNAL SORT OR MERGE • • • • 86 Phase 2 Initialization, Fixed-Length

Records - CA. • • • • • • • • • • • 96 Pass-Pass Routine, Fixed-Length

Records - CC. • • • • • • • • • .100 Input Routine, Fixed-Length Records -

CD. • • • • • • • • • • • • • • • 101 Sequence G Compare Loop, Fixed- Length

Records

-

CEo

· · · · · ·

". .103 Sequence F Compare Loop, Fixed-Length

Records - CF.

· · · · ·

· 0

·

.104

Sequence E Compare Loop, Fixed-Length Records - CG.

· · · · ·

0 0 .105

Sequence D Compare Loop, F ixed- Length

Records - CH.

· · · · ·

.106

Sequence C Compare Loop. Fixed-Length Records

-

CJ.

· ·

,

. · · · · · ·

.107

Sequence B Compare Loop, Fixed-Length

Records

-

CK.

· · · · · · ·

.107

Output Routine, Fixed-Length Records -

CL. • • • • • ~ • • • • • • • .108 Calculate Interleaved Disk Address

Routine, Fixed-Length Records - CM. • .110 Phase 2 Initialization,

Variable-Length Records - CN.

Merge-Merge Routine, Variable-Length

.110 Records - CP. • • • • • • • • • • • • .114 Pass-Pass Routine, Variable-Length

Records - CQ. • • • • • • • •

Input Routine, Variable-Length Records - CR • • • • •

· . . . . . . . .

.117 .119

(4)

Sequence F compare Loop, Variable-Length Records - CS.

Sequence E Compare Loop.

.120 Variable-Length Records - CT. • • .121 Sequence D Compare Loop.

Variable-Length Records - CU. • • • • .122 Sequence C Compare Loop,

Variable-Length Records - CV • • • • • • 123 Sequence B Compare Loop.

Variable-Length Records - CWo • .125 output Routine. Variable-Length

Records - CX. • • • • • • • • • • 126 Calculate Interleaved Disk Address

Routine. Variable-Length Records - CY .128 FINAL MERGE (PHASE 3) - 04 • • • • • • • 131 Phase 3 Initialization, Fixed-Length

Records - DA • • • • • • • • • • • • • • 133 Input Routine, Fixed-Length Records -

DB • • • .136

Mainline Compare Routine. Fixed-Length Records - DC.DD.DE,DF,DG • • • • • • • • 138 Compute Input Interleaved Disk

Address. Fixed-Length Records - DH • • • 141 Output Routine. Fixed-Length Records -

00"'-1 DK • • • .. • .. ..

Label-Linkage Routine (LLR).

Fixed-Length Records - DL • Phase 3 Initialization,

Variable-Length Records - DM.

.143 .147 .148 Input Routine. Variable-Length Records

- DN . . . . .151

Mainline Compare Routine,

Variable-Length Records -DP, DQ, DR.

DS. • • _ . . . .153

Compute Input Interleaved Disk

Address, Variable-Length Records - DT .157 Output Routine. Variable-Length

Records - DU. DV • • • • • • •

Label-Linka~e Routine (LLR).

Variable-Length Records - DW.

MERGE ONLY (PHASE 4) - 05.

.159 .164

• • • 167 Initialize Open/Close Routine - EA • • • 169 Initialize Mainline - EB • •

Input Routine - EC • • •

• • • 171

• .176

Error Routine

-

ED

. . . ·

.178

File D Compare Loop - EE .180 File C Compare Loop - EY

. . . ·

.181

File B Compare Loop - EG

. ·

.182

Output Routine

-

EH.

·

.182

End-of-Job Routine - EJ.

. ·

.187

End-of-Job Messages - EK • .187 Sequence-Error Routine - EL. • • .188 Open/Close Routine - EM. .188 Checkpoint Routine - EP. .192

OPTIONAL ROUTINES. • .194

Relocator Routine - FA • • • • • 194 Fixed-Point Convert/Reconvert Routine

- FB • • • • •

Floating-Point Convert/Reconvert Routine - FC. • • • • • • • • • Packed-Decimal (SIGPAK)

.196 .196 Convert/Reconvert Routine - FD • • • • • 197 Zoned-Decimal (SIGZON)

Convert/Reconvert Routine - FE.

Equal Routine - FF • • • • APPENDIX A: CONSTANTS AND

ABBREVIATIONS • • • • • Constants • • •

Definitions of Abbreviations • • APPENDIX B: LABEL REFERENCES • Assignment Phase •

Phase 1.

Phase 2.

Phase 3 • • Phase 4 • •

Optional Routines.

.197

• .198

• • • 301 .301

• .349 .350

• .350

• .354

• .356

• .358

• .360

• .363 APPENDIX C: EXPLANATION OF FLOWCHART

SYMBOLS • • • • • • • • • • .364 APPENDIX 0: ERROR MESSAGES. • .365

GLOSSARY. • .373

INDEX • • • .374

(5)

Chart 00. Program Level Design. • • • • 8 Chart 01. Assignment Phase (Phase 0) • • 200 Chart AA. Read and Compress Control

Cards, DSORT • • _ • • • • • • • • Chart AB. Sort compressed Control

.201 Cards, DSORT002 • • • • • • • • • • • • 202 Chart AC. Scan SORT, MERGE, and

RECORD Control Cards, DSORT003.

Chart AD. Scan INPFIL, OUTFIL, MODS, OPTION and END Control Cards,

• .203 DSOHTOO 4. • • • • • • • • • • • •.• • .204 Chart AE. Scan INPFIL, OUTFIL. MODS,

OPTION and END Control Cards (Cont' d), DSORT004. • • • • • •

Cha.rt A.F. Open Work Area and • .205 Pre-edit, DSORT005 • • • • • • • • • • • 206 Chart AG. Open Work Area and Pre-edit

(Cont'd), DSORT005 • • • • • • • • • • • 207 Chart AH. Compute Maximum Allowable

Input and Output Record and Block

Lengths, DSORT006 • • • • • • • • • • • 208 Chart AJ. Post Edit, DSORT007 • • • • • 209 Chart AR. Compute Constants, DSORT008 .210 Chart .AL. Compute Constants

(Fixed-Length Records), DSORT008 • • • • 211 Chart A.M. Compute Constants

(Variable-Length Hecords), DSORT008 • • 212 Chart AN. Compute Constants

(ADDROUT), DSORT008 • • • • • • • • • .213 Chart AP. select Order of Merge,

DSORT009 • • • • • • • • • • • • • • • • 214 Chart AQ. Select Order of Merge

(Cont'd). DSORT009 • • • • • • • • • • • 215 Chart AR. Print Option and Fetch Next

Phase, DSORT010 • • • • • • • • • • • • 216 Chart AS. Print option and Fetch Next

Phase (Cont'd), DSORT010 • • • • • .217 .218 Chart 02. Internal Sort (Phase 1)

Chart BA. Initialization for Multi-Volume (Exit 11 Linkage),

OSORT101. • • • • • • • • • • • .219 Chart BB. Format Routine. DSORT102 • • • 220 Chart BC. Initialization Routine for

Disk or Tape Input, DSORT103 • • • • • • 221 Chart BO. Input Routine for Disk or

Tape Input. DSORT103 • • • • • • • • • • 222 Chart BE. Tape Input Routine,

DSORT103. • • • • • • • • • • • .223 Chart BF. Internal Sort, DSORT103 • • • 224 Chart BG. output Routine, DSORT103 • • • 225 Chart BH. End-of-Phase Routine,

DSORT105. • • • • • • • • • • _ • • • • 226 Chart BJ. Initialization for ADDROUT

Run, DSORT104 • • • • • • • • 227 Chart BK. ADD ROUT Run Input Routine,

DSORT104. • • • • • • • • • • 228 Chart BL. ADD ROUT Run Input Routine

(Cont'd), DSORT104 • •

Chart BM. Multi-Volume Routine, • .229 DSORT103 • • • • • • • • • • • • • • • • 230 Chart BN. Multi-Volume Routine

(Cont' d), DSORT10 3. • • • • • • • • • .231

Chart 03. External Sort or Merge, Fixed-Length Records (Phase 2),

CHARTS

DSORT201 or DSORT202 • • • • • • • • • • 232 Chart CA. Phase 2 Initialization,

Fixed-Length Records. • • • • • .233 Chart CB. Merge-Merge Routine,

Fixed-Length Records. • • • • • .234 Chart CC. Pass-Pass Routine,

Fixed-Length Records • • • • • • • • • • 235 Chart CD. Input Routine, Fixed-Length

Records • • • • • • • • • • • • • • • • 236 Chart CEo Sequence G Compare Loop,

Fixed-Length Records. • • • • • • • • .237 Chart CF. Sequence F Compare Loop,

Fixed-Length Records • • • • • • • • • • 238 Chart CG. Sequence E Compare Loop,

Fixed-Length Records • • • • • • • • • • 239 Chart CH. Sequence D Compare Loop,

Fixed-Length Records • • • • • • • • • • 240 Chart CJ. sequence C Compare Loop,

Fixed-Length Records . • • • • • • • • • 241 Chart CK. sequence B Compare Loop,

Fixed-Length Records • • • • • • • • • • 242 Chart CL. Output Routine,

Fixed-Length Records • • • • • • • • • • 243 Chart CM. Calculate Interleave Disk

Address, Fixed-Length Records • • • • • 244 Chart 03. External Sort or Merge,

Variable-Length Records (Phase 2),

DSORT203 or DSORT204. • • • • • • • • .245 Chart CN. Phase 2 Initialization,

Variable-Length Records. • • • • .246 Chart CPo Merge-Merge Routine,

Variable-Length Records • • • • • • • • 247 Chart CQ. Pass-Pass Routi ne,

Variable-Length Records • • .248 Chart CR. Input Routine,

Variable-Length Records • • • • • • • • 249 Chart cs. sequence F Compare Loop,

Variable-Length Records • • • • • • • • 250 Chart CT. Sequence E Compare Loop,

Variable-Length Records • • • • • • • • 251 Chart CU. Sequence D Compare Loop,

Variable-Length Records • • • • • • • .252 Chart CV. Sequence C Compare Loop.

Variable-Length Records • • • • • • • .253 Chart CWo Sequence B Compare Loop,

Variable-Length Records • • • • • • • • 254 Chart CX. Output Routine,

Variable-Length Records • • • • • • • • 255 Chart CY. Calculate Interleave Disk

Address, Variable-Length Reco.rds • • • • 256 Chart 04. Final Merge, Fixed-Length

Records (Phase 3), DSORT301 or

DSORT302. • • • • • • • • • • • • .257 Chart DA. Phase 3 Initialization,

Fixed-Length Records • • • • • • • • • • 258 Chart DB. Input Routine, Fixed-Length

Records • • • • • • • • • • • • • • • • 259 Chart DC. Mainline Compare Routine.

Fixed-Length Records • • • • • • • • • • 260

(6)

Chart DD. Mainline Compare Routine

Fixed-Length Records (Cont'd) • • • • • 261 Chart DE. Mainline Compare Routine

Fixed-Length Records (Cont'd) • • • • • 262 Chart DF. Mainline Compare Routine

Fixed-Length Records (Cont'd) • • • • • 263 Chart DG. Mainline Compare Routine

Fixed-Length Records (Cont'd) • • • • • 264 Chart DH. Compute Input Inter.leaved

Disk Address, Fixed-Length Records • • • 265 Chart DJ. Output Routine,

Fixed-Length Records • • • • • • • • • • 266 Chart DK. Output Routine,

Fixed-Length Records (Cont'.d) .267 Chart DL. Label Linkage Routine

(LLR), Fixed-Length Records. • • • • .268 Chart 04. Final Merge,

Variable-Length Records (Phase 3),

OSORT303 or DSORT304 • • • • • • • • • • 269 Chart OM. Phase 3 Initialization,

Variable-Length Records • • .270 Chart DN. Input Routine,

Variable- Length Records • • • • .271 Chart DP. Mainline Compare Routine,

Variable-Length Records • • • • • • • • 272 Chart DO. Mainline Compare Routine,

Variable-Length Records (Cont' d) • • • • 273 Chart DR. Mainline Compare Routine,

Variable-Length Records (Cont'd) • • • 274 Chart OS. Mainline Compare Routine,

Variable-Length Records (Cont'd) • • • • 275 Chart DT. Compute Input Interleaved

Disk Address, Variable-Length Records .276 Chart DU. Output Houtine,

Variable-Length Records. • • .277 Chart DV. output Routine,

Variable-Length Records (Cont'd) • • • • 278 Chart OW. Label Linkage Routine

(LLR), Variable-Length Records • • • • • 279

Chart 05. Merge-Only (Phase 4),

DSORT401 and DSORT402 • • • • • • • • • 280 Chart EA. Initialize Open/Close

Routine, DSORT401 • • • • • • • • • • • 281 ChartEB. Initialize Mainline, .

DSORT402. • • • • • • • • • .282 Chart EC. Input Routine, DSORT402 • • • 283 Chart ED. Error Routine, DSORT402 • • .284 Chart EE. File 0 Compare Loop,

DSORT402. • • • • • • • • • • • Chart EF. File.C Compare Loop,

DSORT402. • • • • • • • • • • • Chart EG. File B. Compare Loop,

• .285

• .286 DSORT402. • • • • • • • • • • • • .287 Chart EH. Output Routine, DSORT402 • • • 288 Chart EJ. End of Job Routine,

DSORT402. • • • • • • • • • Chart EK. End of Job Messages,

DSORT401. • • • • • • • • • Chart EL. Sequence Error Routine,

DSORT401. • • • • • • • • • • • Chart EM. Open/Close Routine,

DSORT401. • • • • • • • • • • Chart EN. Open/Close Routine

(Cont'd), DSORT401 • • • • • • • Chart EP. Checkpoint Routine,

DSORT402 . . . . Chart FA. Relocator Routine, Phases

2, 3, and 4 • • • • • Chart FB. Fixed Point

Convert/Reconvert • • Chart FC. Floating-Point

Convert/Reconvert • • • • •

Chart FD. Packed-Decimal (SIGPAK) Convert/Reconvert • • • • • • • • Chart FE. zoned-Decimal (SIGZON)

• .289

• .290

• .291

• .292

• .293 .294

• .295 .296 .297 .298 Convert/Reconvert. • • • • • • • .299 Chart FF. Equal Routine, Phases 2, 3,

and 4 .. • • • • .. • • • • • .. • .300

(7)

Figure 1. Program I/O Flow for sort • • 10 Figure 2. Program I/O Flow for

Merge-Only. • • • • • • • • • • • • 11 Figure 3. Interleaved Method of

output. • • • • • • • • • • • • • 14 Figure 4. Summary of sort/Merge

Control statements. • • • • • 15 Figure 5. Disk Input/output Blocking

FOrmats • .. • • • • .. • • • • • .. • • • 16 Figure 6. Tape Input/Output Blocking

Formats . . . 17 Figure 7. Control Field Formats • • • • 18 Figure 8. Tape Input/Output Scheme

for Sort or Merge-Only Operation. • • • 22 Figure 9. Assignment Phase

Main-Storage Layout • • • • • • • • 24 Figure 10. Sort Compressed Control

Cards • • .. ... .. .. .. .. .. • • 30 Figure 11. Work Area Table (2

sect ions) . , . • • • • • • • • • 35 Figure 12. work Area Table (5

sections) • • • • • • • • • • • • 36 Figure 13. Disk Sort/Merge Phase Size

Formulas. • • • • • • • • • • • • 41 Figure 14. Exit Chart • • • • • • • • • 50 Figure 15. sort Area Layout - Overlay

8 .. • • • . . . .. 54 Figure 16. Phase 1 Internal Sorting

(Ascending Sequence) • •

Figure 17. Phase 1 Main Storage Layout. .. .. .. .. .. .. .. .. .. .. .. .. ..

69

• 70

• 71

• 73 Figure 18. Disk Address Format • •

Figure 19. Limits of Input Area • Figure 20. Doublets • • • • • Figure 21. 4-Record Sequences • Figure 22. 8-Record sequences • • Figure 23. o u t p u t . . . Figure 24. Address Creation • Figure 25. output, Variable-Length

• • • 75

• • 76

• • • 76

• • • 76 Records .. • .. .. • .. .. .. .. .. .. • ..

Figure 26. Phase 1 Compression. • • • Figure 27. Sort Blocks • • • • • • Figure 28. Phase 2 Merge • • • • • Figure 29. Variable-Length Record

Input Area. .. .. .. .. .. .. .. .. .. .. ..

78

• 79

• 80 87

• 88 89

FIG ORES

Figure 30. Main Storage output Area • • 90 Figure 31. Compare Tree • • • • • • • • 91 Figure 32. Interleaving (3-Way Merge) • 92 Figure 33. Phase 2 Main Storage

Layout fo.r Fixed-Length Reco.rds • • • • 94 FigUre 34. Phase 2 Main Storage for

Variable-Length Records • • • • • • • • 95 Figure 35. Calculate Interleaved Disk

Address • • • • • • • • • • • • • • • • 111 Figure 36. Variable-Length Disk

Address - Block Count • • • • • • • • • 116 Figure 37. Calculate Interleaved Disk

Address • • • • • • • • • • • • • .130 Figu.re 38. Phase 3 Main Storage

Layout . . . 132 Figure 39. Rewind Action Taken at

End-of-Volume Time for Multi-Volume

Tape Files • • • • • • • • • • • • • • • 134 Figure 40. Contents of Registers at

Fetch Time. • • • • • • • • • • • • • .136 Figure 41. Compare Tree (for a 4-Way

Merge) . . . 141 Figure 42. Calculate Interleaved Disk

Address • • • • • • • • • • • • • • • .142 Figure 43. Rewind Action Taken at

End-of-Volume Time for Multi-Volume

Tape Files • • • • • • • • • • • • • • • 150 Figure 44. Contents of Registers at

Fetch Time. • • • • • • • • • • • • • .152 Figure 45.

Merge) • • Figure 46.

Address.

Figure 47.

Track • • Figure 48.

Layout. • Figure 49.

Track Figure 50.

Figure 51.

Figure 52.

Figure 53.

Figure 54.

Table

Compare Tree (for a 4-Way

.155 Calculate Interleaved Disk

• • 158 Maximum Use of Output

• .161 Phase 4 Main Storage

.. .. . .. .. . . . . . . .

.168

Maximum Use of OUtput

• • • • • • • • • • • • • • • 184 Linkages Between OVerlays • • 193 Floating-Point Conversion • • 197 Phase 2 Disk Address Table .324 Phase 2 Limits Table • • • • 327 Phase 3 Disk Input Address

.333

(8)

Chart 00. Program Level Design

DSORT 01

Assignment Phase 0

Sort or Merge

SORT

INITXII 02

Internol Sort Phase 1

NO

INTPH2 03

External Sort Phase 2

INTPH3 04

Final Merge Phase 3

(3

03 MERGE

E3

F3

G3

H3

PAN(O 05

Merge Only Phose 4

H4

(9)

The IBM system/360 Disk Operating System sort/Merge Program enables the user to sort multiple files of random records, or merge mul tiple files of sequenced reco.rds. into one sequential file. This program is designed to meet the sorting and merging requirements of disk-oriented installations with 16K to S12K bytes of main storage. It is a generalized program that must be

incorporated into the resident version of the Disk Operating System library. The program is designed for operation in a disk-resident operating system environment under the supervision of a control program.

At execution time, control statements (see Program Characteristics) will tailor the generalized sort/merge program to the user's specific application. The

sort/merge control statements are punched into cards and inserted into the card reader with the symbolic address SYSIPT.

All required user-prepared job-control statements are read by the device (either a card reader or a magnetic tape unit)

assigned to SYSRDR. The sort/merge program will be retrieved in overlays from the disk-resident core image library by the control program.

Control-data information may be

contained in as many as 12 fields in each record. The program assumes that input records for a sort operation are in random sequence. Records can be sorted or merged into ascending or descending sequence. and an individual sequence can be specified for each control-data field. The output

sequence for a merge-only operation must be the same as the input sequence.

The sort/merge program is divided into five phases (see Chart 00):

Assignment Phase (Phase 0) Internal-Sort Phase (Phase 1) External-Sort Phase (Phase 2) Final Merge Phase (Phase 3) Merge-Only Phase (Phase 4)

If sorting is to be done, the assignment phase and phases 1, 2, and 3 are executed.

If only merging is to be done, the assignment and merge-only phases are executed. (See Figure~ 1 and 2 for I/O .flow diagrams.)

The sort/merge program:

• Translates mnemonic sort/merge

INTRODUCTION

control-card information that describes the file parameters for each input and output file.

Sorts multiple input files.

Allows multivolume input and/o.r output for tape and disk.

Provides for input from and output to disk storage (IBM 2311 Disk Storage Drive(s) only>, or 7- or 9-track

magnetic tapes (see System Requirements for possible combinations of 7- and 9-track tapes). Disk and tape input and output can be distributed over multiple drives.

Merges up to four tape and/or disk input files.

Provides for writing on disk or tape an output file that consists of the disk addresses of the sorted records

(ADDROUT=A option) or disk addresses plus control data of the sorted records

(ADDROUT=D option).

Provides for determining the number of work area tracks required for a sort operation (CALCAREA option).

Provides for specification of alternate input tape drives and alternate output t.ape drives for either a sort or a merge operation.

Provides checkpoint, interrupt, and restart procedures for sort operation.

Provides exits and storage areas for user-written routines.

Prints out control-ca.rd information (optional), record counts at the end of phases 1, 3, and 4, and necessary

diagnostics.

Provides, for sorting, the option to bypass unreadable data blocks when the input file is being read from tape, or indicates the need for operator

intervention when the input file is being read from tape or disk.

ProVides, for the me.rge-only operation, the option to bypass unreadable data blocks when the input. files are being read from tape or disk, or to indicate the need for operator intervention.

(10)

System Resident Device

Figure 1.

Phose I

Phase J

/--..., - - ; - - - 7

/ '< " / I ( \ AI, \ I lopo' aod/a, 1--_

\ Input J Input ) \ Work Area \ 7

'-.

r-

-<-Z.L 7 / ff\-" _ --" lopot aod/o, ~ \ --/7

/ / / ~k~eo--,

I I / / " in;; ood/o,

\--7

I I / / .... Wo,kA,eo , L I / / / . - , - - - ' \-7

/ I / / / ,,-/ \ lopot

I / / ' /"""--,--~ 1--7 I I / / ,,-'" / / \ lopo' \ L

I I / /' ,,-" / / ... -""--,---" - 7 I I / / /,/,,-"- / / ... -... \ lopo' \ I

,-_~ _ _ --,/ 1 / / ,,- / / _... _-""'---, _ _ ..';

/ ; / / , , - " - , . / ...

- ----

\ \

~--''--__It,iI.:_)./ '" / / ... - - - - - - - - - ' - - - "

//,... K,.,... ... ",..---_ -

---

- - -

---

:::;::--:.-:---

'---

' - - - - 7 I Work Area I

I ood/o, f----7

\ Ootpo' \ I

_----~-T-wo;;~ea r--7

_----

_---~~~~u~~

l--,

r---L---,.k;;;_---

=== ____________

~n!'~~t~t~ \ Work Area \ I ~ _ _ I : : : : : _ . : : . - : - - - _ _ _ _ \ Output \ I

L _---. _ _ I;:--- - - - _ - - - _ ~_,--..'l. L--7

...

--- --- ----

\ \

... ... - _ - - _ _ ---_~ Output I

... ... ... ... ... ... - - - - _ - - - - -

--

- - _

---

----~ -'---r---~ \ Output 1---\ 7 I

... , ... - - - - _ _ _ -T--~ I

... ~_... - _ _ \ Output \

~-<

\

~---'

( \ Ait \

r Output J Output /

\ I--~/

' _ L

Program I/O Flow f or Sort 10 IBM S/360 DOS Sort/Merge

(11)

System Resident Device

I I I

Assignment Phase

Control Cards

Load Assignment Phase Program

Read Control Cards and Execute

Load Phase 4

Execute Phase 4 Initialization

Merge

Figure 2. Program I/O Flow for Merge-Only

Checks the sequence of the records during the final output pass of a sort

(phase 3) or during a merge (phase 4).

Permits the user to specify either ascending or descending sequence for each individual control-data field.

(Up to 4 Tape or Disk or Mixed Tape and Disk)

Processes standard System/360 volume and file labels.

Provides exits for user processing of non-standard labels (on tape) and user labels (on tape or disk).

(12)

• Permits mixed labels for tape input to a me.rge-only operation.

PROGRAM ORGANIZATION ASSIGNMENT PHASE (PHASE 0) The assignment phase:

1. Reads and stores data from the sort/merge control statements.

2. Performs a diagnostic check for missing sort/merge control statements and

duplicate or invalid field definers.

3. Prints out the sort/merge control statements and parameters if the PRINT option is specified.

4. Converts the parameters to binary format.

5. Calculates and stores the constants required by the following phases.

INTERNAL-SORT PHASE (PHASE 1)

Phase 1 performs the initial sequencing of the input file(s). The records are read into the main-storage input area and sorted into sequences that are at least as long as the number of records that can be sorted internally at one time. These sequences are written in either the fi.rst or the second half of the disk-storage work area.

The output is interleaved to minimize the time required to complete the sort.

Phase 1 sorts multiple input files (these files may also be multivolume).

Exits from the program are provided to allow processing and/or label-checking by user-prepared routines. The checkpoint, interrupt, and restart procedure is provided at the end of the phase.

.EXTERNAL SORT PHASES (PHASE 2 AND PHASE 3) The external sort phases merge the ordered sequences produced by the internal sort phase. They perform a 2-way to 7-way merge on the record sequences produced by the internal sort phase.

Phase 2 repeatedly merges the sequences from the 2311 disk-storage work area until their numbe.r is equal to or less than the

program-determined order of merge. Phase 3 performs the last pass of the external sort. If the number of sequences produced by phase 1 is equal to or less than the order of merge, phase 2 is bypassed and only phase 3 is executed.

Both phases provide the checkpoint, interrupt, and restart feature. Phase 2 uses the interleaVed output technique;

phase 3 allows multivolume output files and provides exits from the program to allOW user modifications by user-prepared routines.

MERGE..,.ONLY PHASE (PHASE 4)

The merge-only phase is used to merge existing presorted files into one

sequential file. A maximum of four input files can be merged and these may be on disk and/or tape in any combination. The program allows for multiple-volume input and output files. The program also allows a single file to be reblocked and sequence- checked. Exits from the program are

provided to allow for user modifications by user-prepared routines.

PROGRAM GENERATION

The sort/merge program resides in the relocatable library and consists of three entities:

• primary processor generation modules

• Intermediate processor generation modules

• Relocatable object modules

These modules are designed to enable the user to linkage-edit into the core image library only those modules required to formulate a generalized sort/merge program tailored to the user's specific job

applications. At system generation time, the user has the choice of linkage editing anyone of seven distinct sort/merge object programs into the core image library.

After the specific object program has become resident in the core image library, the user can delete all the modules from the relocatable library.

The programs that can be generated at linkage-edit time are:

1. The entire sort/merge program.

(13)

2. A program that will (1) sort

fixed-length records, and (2) perform the ADDROUT option for fixed- or variable-length .records.

3. A program that will (1) sort variable-length records, and (2)

perform the ADDROUT option for fixed- or variable-length records.

4. A program that will (1) sort fixed- or variable-length records, and (2)

perform the AbDROUT option for fixed- or variable-length records.

5. A. program that will merge fixed- or variable-length records.

6. A program that will (1) sort

fixed-length records, (2) merge fixed- or variable-length records, and (3) perform the ADDROUT option for fixed- or variable-length records.

7. A program that will (1) sort

variable-length records, (2) merge fixed- or variable-length records, and

(3) perform the ADDROUT option for fixed- or variable-length records.

For further details about program qeneration for sort/merge, see IBM System/360 Disk Operating System-Bystem Generation and Maintenance, Form C24-5033.

PROGRAM CHARACTERISTICS INTERLEAVED OUTPUT

Interleaving is a technique for writing sequences in the disk work area in a manner that will minimize seek time during each subsequent pass. It may be used in a system with only one disk device but is most efficient when used with two or more disk devices. The disk work area is formatted for interleaved output during phase 1 and records are blocked for output before being written in the work area, except when there is only one sort block per track.

The interleave factor (sometimes called the gap factor) is equal to the order of

merge a t the start of a pass and may be reduced in the late stages of the pass.

Figure 3 is an example of interleaved output when the order of merge is four.

The blocks that constitute the first sequence are written at every fourth address, starting with the first address.

The blocks that constitute the second sequence are then written at every fourth address, starting with the second address.

After the first four sequences have been written, the allotted disk work area (in this example, 4 x 3 = 12 blocks) will have been filled and the pattern is then

repeated every four sequences. (For a more detailed description of interleaving, see the introduction to phase 2.)

JOB CONl'ROL STATEMENl'S

Standard job-control cards are required to define a sort or merge operation to the

job-control program. These cards are:

General--JOB, ASSGN, DATE, EXEC

Input FUe(s)--VOL,DLAB or TPLAB,XTENT

• Work Area--VO.L, DIAB, XTENT

• Output File--VOL,DIAB or TPLAB,XTENT For a complete discussion of the job-control cards and their formats, see IBM System/360 Disk Operating System,

System Control and System Service Programs, Form C24-3428, and IBM Systeml360 Disk Operating System, Sort/Merge Program Specifications, Form C24-3444.

Note: For merge-only operations, the program requires two consecutive disk tracks to temporarily store overlay DSORT401 and a portion of DSORT402 as they exchange residence in main storage at various points in the program. The user must define this area as at least a 2-track work area.

The job-control statements are followed

by the sort/merge control statements.

(14)

Track 0

Track 1

Track 2

Track 0

Track 1

Track 2

Track 3

Track 4

Track 5

Example: Number of Blocks in on Output Sequence =3 Order of Merge (M) =4

Blocks per Tracks Formatted by Phose 1 =5

Note: Numbers in circles indicate the order in which blocks are written •

. . . - - - I n t e r l e a v e Factor (4)---~---..:::::-

8

Sequence 1

--

Block 1

0 0 0 o

Sequence 1

Block 2

10 10 10 10 10 1

---

After All Sequences Have Been Written I Work Area is Shown Below

+

I

I

8

Sequence 1

o

Sequence 2

o

Sequence 3

®

Sequence 4

o

Sequence 1

Block 1 Block 1 Block 1 Block 1 Block 2

I I I I I I I

o

Sequence 2

8

Sequence 3

o

Sequence 4

o

Sequence 1

8

Sequence 2

Block 2 Block 2 Block 2 Block 3 Block 3

I I 1/2 Work

Area

o

Sequence 3

o

Sequence 4 ®sequence 5

8

Sequence 6

o

Sequence 7

Block 3 1 Block 3 Block 1 Block 1 Block 1

I I I I

I I

G

Sequence 8

o

Sequence 5

o

Sequence 6 Gsequence 7

G

Sequence 8

Block 1 Block 2 Block 2 Block 2 Block 2

I I I I I

t G

Sequence 5

o

Sequence 6

o

Sequence 7

o

Sequence 8

Block 3 Block 3 Block 3 Block 3

Area 1/20ork 1

I ~ ________ _ L _ _ _ _ _ _ _ _ _ _ ~ _ _ _ _ _ _ _ _ _ L _ _ _ _ _ _ _ _ _ _ ~ _ _ _ _ _ _ _ _ ~

,..L, I

. Figure 3. Interleaved Method of Output SORT/MERGE CONTROL STATEMENTS

control statements are necessary to define the user's specific sort or merge

operation. The user must describe the 14 IBM S/360 DOS Sort/Merge

files to be sorted or merged, the

control-data fields, the program options to be used, and the modifications to be made to the program. (See Figure 4, Summary of Sort/Merge Control statements.) This information is punched into

(15)

STATEMENT STATUS OPERAND DEFINER, STATUS, AND VALUE FORMAT DEFINER

SORT Required for FiElDS (Required) = (~,MI,~ ••• PI2,MI2,SI2) sort runs FORMAT (Required) = xx

FILES (Optional) - !!!

SIZE (Required~ = ~

MERGE Required for FiElDS (Required) = (~,MI,~ ••• PI2,MI2,SI2) merge runs FORMAT (Required) = ~

FILES (Required) - m RECORD Required TYPE (Required) = x

LENGTH (Required) = (1I,L2,L3) for FLR

= (g,L2,~,~,l5) for VLR INPFIL Required INPUT (Required) = X for sort

= (Xa, Xb, Xc, Xd) for merge-only VOLUME (O~tional)= (Na, Nb, Nc, ••• Ni)

BLKSIZE (Required) = (~-:-X) - - - OPEN (Optionol) - !!

CLOSE (Optionol) = !!

BYPASS (Optional) OUTFIL Required BLKSIZE (Required).= !!

OUTPUT (Required) = ~

OPEN (Optional) - n CLOSE (Optional) =""i!

NOTPMK (Optional)

MODS Required if PHI = (Name, Address, Ell, E12, E13) user-wri tten PH3 = (Name, Address, E31, E32)

subroutines PH4 = (Name, Address, E4J, E42, E43, EM, E45) will be added

OPTION Optional PRINT (Optionol) STORAGE (Optional) = n VERIFY (Optiona!) - KEYLEN (Optional) = ~

REST ART (Optional) ADDROUT (Optional) = ~

CALCAREA (Optional) LABEl (Optional) - (0, I)

(Q,~,~,~, ~)

END Required

Figure 4. Summary of Sort/Merge Control Statements control-statement cards, and these cards

are inserted into the input stream at SYSIPT.

given the option to correct the errors and restart or to cancel the job.

During the aSSignment phase, each

control statement is checked for incorrect entries and inconsistent combinations of entries. If any errors are detected, the program prints a message that indicates the nature of each error. When all the control statements have been checked, if no

abort-type errors were detected the user is

If certain optional entries are not made, the assignment phase will assume predetermined parameters.

For a complete discussion of control statements and control card format, see IBM System/360 Disk Operating System, --- Sort/Merge Program specifications, Form C24-3444.

(16)

RECORD FORMAT

The sort/merge program can process fixed-length or variable-length records.

These records may be unblocked or blocked in fixed- or variable-length blocks (see Figures 5 and 6). The most efficient input file record format is fixed-length records in fixed-length blocks, and the least efficient is variable-length records unblocked.

~

Logical Record.,

r~

((3 '(3 va

A Count Area A Key Field A Record I Data A

p p

~///.

!, !/;

The KEY field, on disk input files, is used by the sort/merge program only with fixed-length unblocked records. The REY field in all other formats is bypassed.

For a merge-only operation, the

sort/merge program will accept. input from mixed storage media (tape and disk).

However, anyone file must reside

completely on disk or tape. There is no restriction on how the input media can be mixed.

~

Logical Record-1

~G'

((3

Count Area A Key Field A Record 2 Data

p p

' / / / <-///-

Unblocked Fixed - Length Records (Input / Output) Key Field may be omitted

-

Logical Record

-

VG' rG

~G'

''G' (G'

A Count Area A Record I Data Record 2 Data A Count Area A Record 3 Data Record 4 Data A p ~!/. ~//h P P P '//-

Fixed - Length Records in Fixed -Le~th Blocks (Input / Output)

I--

Logical Record

~G ~G

Record I Record 2 Record 3 Record 4

rG fer

.Record 5 Record 6

VG

A Count Area A A Count Area A A

~ 0A

Data Data Data Data ~t ~1 Data Data

~

Fixed - Length Records in Variable - Length Blocks (Input)

. f.-

Logical Record-

"G "G' 'G' ''G "G' 'G'

A Count Area A BL RL Record I Data A Count Area A BL RL Record 2 Data A Count Area A

~1 ~1 ~1 Jh ~1 ~L

Variable Length - - Unblocked Records (Input /Output)

r

Logical Record -1

"G' (G' (E

:>V//,

Record I Record 2 G

Record 3 Record 4 A Count Area A BL RL RL A Count Area A BL RL RL

,,!,;, 0h

Data Data

0h

~. Data Data

Variable Length - - Blocked Records (I nput / Output)

BL (Block Lengths) = The number of bytes between gaps separating count areas.

Figure 5. Disk Input/Output Blocking Formats

(17)

V(h. Th.

V,t~

Logical

vI'"

Logical

~'t

Logical R Logical

R Logical R R R

~5l Record I ~5J/- Record 2 ~h Record 3 y~/- Record 4 ::;'///-/G Record 5

Unblocked Fixed - Length Records ( Input / Output)

:m:

I

Vf

~f

Logical Logical Logical Logical

R Logical Logical Logical R R

0l

Record J Record 2 Record 3 ~£; Record 4 Record 5 Record 6 ::;'/-; G Record 7

Fixed-Length Records in Fixed-Length Blocks (Input/Output)

wr

Logical Logical Logical

P(

Logical Logical Logical Logical

ff

Logical Logical

~

R R R R

Record 1 Record 2 Record 3

y~ Record 4 Record 5 Record 6 Record 7

~

Record 8 Record 9 ://~,

~/~

Fixed - Length Records in Variable - Length Blocks (Input)

f--

Logical Record

----I

VI

~f

R BL RL Record J Data R BL RL Record 2 Data

::-~ ~~

Unblocked Variable - Length Records (Input/Output)

f.-

Logical Record

-l

WI

R BL RL Record I Data RL Record 2 Data RL

I/~

Blocked Variable - Length Records (I nput / Output)

BL (Block Length) = The number of bytes between inlerrecord gaps.

F iqure 6. Tape Input/Output Blocking Formats For a complete discussion of record

formats, see IBM System/360 Disk Operating System, Data Management Concepts, Form C24-3427 and IBM System/360 Disk Operating System, so.rt/Merge Program Specifications, Form C24-3444.

CONTROL-DATA FIELDS

A control-data field is a group of adjacent bytes wi thin a da ta record. The program is capable of sorting or merging records with up to 12 control-data fields with a maximum total length of 256 bytes.

rt vI'"

R BL RL Record 3 Data R

I/~

g

~f

Record 3 Data R BL RL Record 4 Data

:/~

The most significant field is the major control field, and is always compared first. All other fields are minor fields, and are compared according to their

relative significance. A given minor

control field is compared only if the major control fields are compared and found to be equal.

The individual fields may be adjacent or separated; if they contain only unsigned binary data I they may overlap (see Figure 7). They may occur anywhere within a data record except in the record-length field at the beginning of each variable-length

record.

(18)

Control Control FI.ld 3 FI.ld 2 (Minor) (Minor)

I I

Adjacent Control Fields

Control Field 1 (Maior)

Control Field 2 (Minor)

Non- Adjacent Control Fields

Control FI.1d 1 (Malor)

Data

I I

I

Control Field"

(MInor)

Control Field 3 (Minor)

Overlapping Control Fields (Unsigned Binary Format)

Figure 7. Control Field Formats

I

A given control field must be located in the same relative position in each record of all files. If, for example, the first two bytes of the records in a file are designated as the major control field, the program assumes that these two bytes are the major control field in every record of that file.

If a KEY is associated with each disk input record (fixed-length unblocked records only>, the KEYLEN entry can be

Data

Data

specified in the OPTION statement, and the records can be sorted on the contents of the KEY field.

Control data may be in anyone of the following forma ts:

1. Binary (character).

2. Packed- or zoned-decimal.

(19)

3. Normalized floating point (in either the short or long format).

". Fixed-point.

The following limitations must be

observed when setting up the control fields for a file:

1. A control field for a variable-length record cannot include the record-length field.

2. Each control field must begin and end on a byte boundary.

3. Each control field must be at least one byte long.

4. Each control field may be a maximum of:

• 256 bytes when using binary (character) data.

16 bytes (including the sign) when using decimal data.

" bytes when using normalized floating-point data (short format).

8 bytes when using normalized floating-point data (long format).

256 bytes (including the sign) when using fixed-point data.

5. The total of the control-field lengths must not exceed the input record length

(the minimum record length minus four when processing variable-length

records), unless overlapping control fields are used.

6. When using either zoned-decimal data or packed-decimal data, the Signed fields must be either all ASCII or all EBCDIC;

they must not contain a combination of both.

Files may be sorted or merged in either ascending or descending sequence. The

sequence of each control-data field is independent of the other control-data fields. For example, a user may specify ascending sequence for the major control fields, and descending sequence for all the minor control fields.

The control-data fields are defined for the program by means of user-prepared control statements. These statements specify the type of operation (sort or merge), the sequence (ascending o.r

descending), and the size and location of each control-data field.

For further details about data formats, see IBM system/360 Disk operating system, sort/Merge Program Specifications, Form C24-3444.

DATA CONVERSION

The sort/merge program includes

data-conversion and -reconversion routines.

Data in the format of floating point, fixed point, packed decimal, or zoned is

converted, before processing, to binary so tha t i t can be compared. The data is

reconverted to its original form before the output file is written.

USER MODIFICATION

Phases 1, 3. and 4 of the sort/merge program provide for the addition of

user-written routines. Linkage between the program and these routines is provided by branch-and-link instructions (BAL) called exits. These exits are:

Références

Documents relatifs

The project has already completed feasibility studies in its quest to establish a habitable settlement on Mars – built by unmanned space missions – before specially

Since the corroborative bio- chemical criterion for vitamin A deficiency and xerophthalmia as a public health problem is severely depressed serum retinol (vitamin A) levels in

This algorithm is important for injectivity problems and identifiability analysis of parametric models as illustrated in the following. To our knowledge, it does not exist any

If the spatial part of the electromagnetic potential does not vanish, the Hamiltonian for the external field problem cannot be defined in free Fock space as a

[r]

Our analysis is based on the moment equations associated to (16).. As a consequence of these local properties, we can justify uniform estimates on the total energy and entropy.. For

They live in a lovely cottage in Stratford-upon-Avon, England. The house is not very big but my grandmother keeps it clean and tidy. It has only got one floor and the attic. In

They differ by the various quantum mechanical methods (exact or perturbative, time dependent or time independent) which are used to describe tunneling through the electronic