Cant answer your question, but if you want to chew some CPU, heres a cobol program that will compute prime numbers...Doesnt do any IO though.
000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. PRIMECB2. 000300* EXAMPLE OF IN-LINE PERFORMS, END-IF, INITIALIZE STATEMENTS 000400 DATA DIVISION. 000500 WORKING-STORAGE SECTION. 000600 01 NUMBER-ARRAY. 000700 05 NA-LINE OCCURS 3355440. 000710* 05 NA-LINE OCCURS 26214. 000720* ABOVE OCCURS CLAUSE IS LARGEST THAT WILL WORK FOR COBOL/VS 000800 10 NA-NUMBER PIC X. 000900 88 IS-PRIME VALUE '1'. 001000 88 IS-NOT-PRIME VALUE ZERO. 001100 10 NA-PROOF PIC S9(8) BINARY. 001200 01 CANDIDATE PIC S9(8) BINARY. 001300 01 CPRIME PIC S9(8) BINARY. 001400 01 ARRAY-SIZE PIC S9(8) BINARY. 001500 001600 PROCEDURE DIVISION. 001700 MAINLINE. 001800 INITIALIZE NUMBER-ARRAY REPLACING ALPHANUMERIC BY '1' 001900 INITIALIZE NUMBER-ARRAY REPLACING NUMERIC BY ZERO 000200 002100 COMPUTE ARRAY-SIZE = LENGTH OF NUMBER-ARRAY / 5 002200 002300 PERFORM VARYING CPRIME FROM 2 BY 1 002400 UNTIL CPRIME > ARRAY-SIZE 002500 IF IS-PRIME (CPRIME) 002600 COMPUTE CANDIDATE = CPRIME + CPRIME 002700 PERFORM UNTIL CANDIDATE > ARRAY-SIZE 002800 SET IS-NOT-PRIME(CANDIDATE) TO TRUE 002900 MOVE CPRIME TO NA-PROOF(CANDIDATE) 003000 ADD CPRIME TO CANDIDATE 003100 END-PERFORM 003200 END-IF 003300 END-PERFORM 003400 003500 PERFORM VARYING CANDIDATE FROM 1 BY 1 003600 UNTIL CANDIDATE > ARRAY-SIZE 003700 IF IS-PRIME (CANDIDATE) 003800 DISPLAY CANDIDATE ' IS PRIME' 003900* ELSE 004000* DISPLAY CANDIDATE ' DIVISIBLE BY ' 004100* NA-PROOF(CANDIDATE) 004200 END-IF 004300 END-PERFORM. 004400 STOP RUN. _________________________________________________________________ Dave Jousma Assistant Vice President, Mainframe Engineering [email protected] 1830 East Paris, Grand Rapids, MIĀ 49546 MD RSCB2H p 616.653.8429 f 616.653.2717 -----Original Message----- From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf Of Jesse 1 Robinson Sent: Thursday, March 31, 2016 6:04 PM To: [email protected] Subject: COBOL Rookie Problem I'm writing my first COBOL program in decades. It's not supposed to do anything important, but it's not a toy. I need a program that chews up CPU in order to try out ABO (Automatic Binary Optimizer). I started with a REXX and am now rewriting in COBOL 4.2. It's not doing what I want, which is to read a sequential file, do some arithmetic, then write out records to a couple of other sequential files. Very simple, but I'm missing something. When the input file is empty-no records-the program does 1,100 reads! When the input file has one record, it does 2,200 reads!! It's not a real loop because the program ends normally after all the commotion. What's wrong? The REXX is structured almost identically, and it works fine. PROCEDURE DIVISION USING iterate . IF ADDRESS OF iterate = NULL THEN MOVE 1 TO iterate; END-IF DISPLAY "Iterate" iterate "times" UPON CONSOLE OPEN OUTPUT testoute OPEN OUTPUT testouto PERFORM iterate TIMES OPEN INPUT testin MOVE "N" TO testin-eof PERFORM UNTIL testin-eof = "Y" display "Reading record" UPON CONSOLE READ testin INTO in-rec AT END MOVE "Y" TO testin-eof < < < EOF is not getting set as it should END-READ IF testin-eof = "N" THEN MOVE 0 TO dig-sum PERFORM VARYING i1 FROM 1 BY 1 UNTIL i1 = 80 ADD in-digit(i1) TO dig-sum MOVE dig-sum TO rec-sum MOVE SPACES TO out-filler DIVIDE dig-sum BY 2 GIVING quo REMAINDER rem IF rem = 0 THEN WRITE outpute-rec FROM out-rec ELSE WRITE outputo-rec FROM out-rec END-IF END-PERFORM END-IF END-PERFORM CLOSE testin END-PERFORM CLOSE testoute CLOSE testouto STOP RUN . END PROGRAM ABOTEST . . . . J.O.Skip Robinson Southern California Edison Company Electric Dragon Team Paddler SHARE MVS Program Co-Manager 323-715-0595 Mobile 626-302-7535 Office [email protected]<mailto:[email protected]> ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
