home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- organization: CERN, Geneva, Switzerland
- keywords: fortran
- subject: v12i089: REPOST Floppy - Fortran Coding Convention Checker Part 03/11
- from: julian@cernvax.cern.ch (julian bunn)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 12, Issue 89
- Submitted-by: julian@cernvax.cern.ch (julian bunn)
- Archive-name: ffccc/part03r
-
- #!/bin/sh
- echo 'Start of Floppy, part 03 of 11:'
- echo 'x - CUSSTMT.h'
- sed 's/^X//' > CUSSTMT.h << '/'
- X*IF DEF,NEVER
- X*-----------------------------------------------------------------------
- X* ISGLOB = running count of statements in source deck
- X* ICLOLD = the class (ICLASS) of the last EXECUTABLE statement
- X* NFIOLD = the line number of the last statement in the module
- X* NFAULT = the number of WARNINGS in the module so far
- X* RPROCS = set .TRUE. if module is to be processed
- X*-----------------------------------------------------------------------
- X*EI
- /
- echo 'x - URTERM.f'
- sed 's/^X//' > URTERM.f << '/'
- X SUBROUTINE URTERM
- X*-----------------------------------------------------------------------
- X*
- X*--- user routine termination
- X*
- X*-----------------------------------------------------------------------
- X include 'PARAM.h'
- X include 'ALCAZA.h'
- X include 'CLASS.h'
- X include 'CURSTA.h'
- X include 'FLWORK.h'
- X include 'KEYCOM.h'
- X include 'TYPDEF.h'
- X include 'JOBSUM.h'
- X include 'STATE.h'
- X include 'FLAGS.h'
- X include 'USGCOM.h'
- X include 'USCOMN.h'
- X include 'USSTMT.h'
- X include 'USIGNO.h'
- X include 'USUNIT.h'
- X include 'USARGS.h'
- X include 'CHECKS.h'
- X PARAMETER (NFS=28)
- X DIMENSION IB(21)
- X CHARACTER*(MXNMCH) CNAM,CNAMOL
- X CHARACTER*1 CFRST
- X CHARACTER*6 CFORT(NFS)
- X CHARACTER*131 CZUN
- X LOGICAL LIMPNO,BTEST
- X DATA CFORT /'ASSIGN', 'CALL ','COMMON','CLOSE ', 'DATA ',
- X +'DO ','DECODE','DOUBLE', 'END ','ENDIF ','ENTRY ', 'ELSE ',
- X +'ELSEIF','ENCODE','FORMAT', 'GOTO ','IF ', 'OPEN ','PRINT ',
- X +'PAUSE ', 'PUNCH ','READ ','REAL ','RETURN', 'REWIND','SAVE ',
- X +'STOP ','WRITE '/
- XC
- X IF(UNFLP) RETURN
- X WRITE(MZUNIT,500) NFAULT
- X WRITE(MZUNIT,560)
- XC Update statement number for input file
- X ISGLOB = ISGLOB + NLINES - 1
- X NGLOBF = 0
- XC Check that module is to be processed
- X IF(.NOT.RPROCS) GOTO 190
- XC Check for comment lines after end of module
- X IF(LCHECK(1).AND.NLINES-1.GT.NFIOLD) THEN
- X WRITE(MZUNIT,570)
- X NGLOBF = NGLOBF + 1
- X ENDIF
- XC Check that module ended with END
- X IF(LCHECK(2).AND.ICLOLD.NE.IEND) THEN
- X WRITE(MZUNIT,580)
- X NGLOBF = NGLOBF + 1
- X ENDIF
- X IF(LCHECK(3)) THEN
- XC Check for COMMON blocks remaining unused
- X DO 20 IC=1,NCOMT
- X IF(ICTITL(IC).GT.0) THEN
- X LEN=INDEX(SCTITL(IC),' ')-1
- X DO 10 IGN=1,NIGNOR
- X IF(LIGNOR(IGN).NE.LEN) GOTO 10
- X IF(SCTITL(IC)(:LEN).EQ.CIGNOR(IGN)(:LEN)) GOTO 20
- X 10 CONTINUE
- X WRITE(MZUNIT,590) SCTITL(IC)
- X NGLOBF = NGLOBF + 1
- X ENDIF
- X 20 CONTINUE
- X ENDIF
- XC Check that COMPLEX and DOUBLE PRECISION variables occur
- XC at the start of a COMMON block
- X IF(LCHECK(4)) THEN
- X CNAMOL = ' '
- X DO 70 IC=1,NCOMN
- X IF(SCTITL(ICNAME(IC)).NE.CNAMOL) THEN
- XC Change of COMMON block name ... reset counters
- XC NLAST = 1 signifies last variable in common was real/doublep
- XC NLAST = 0 signifies otherwise
- X CNAMOL = SCTITL(ICNAME(IC))
- X NLAST = 1
- X ENDIF
- X CNAM = SCNAME(IC)
- X ILEN = INDEX(CNAM,' ')
- XC Search for NAMTYP
- X MATCH = 0
- X DO 30 IN=1,NRNAME
- X IF(ILEN.NE.INDEX(SNAMES(IN+IRNAME),' ')) GOTO 30
- X IF(CNAM.NE.SNAMES(IN+IRNAME)) GOTO 30
- X NTYP = NAMTYP(IN+IRNAME)
- XC The variable must be a COMMON variable (not a dimensionality)
- X IF(.NOT.BTEST(NTYP,19)) GOTO 40
- X MATCH = 1
- X GOTO 40
- X 30 CONTINUE
- X 40 IF(MATCH.EQ.0) GOTO 70
- X IF(.NOT.BTEST(NTYP,3).AND..NOT.BTEST(NTYP,4)) THEN
- X NLAST = 0
- X ELSE IF(NLAST.EQ.0) THEN
- X DO 50 IGN=1,NIGNOR
- X IF(LIGNOR(IGN).NE.INDEX(CNAM,' ')-1) GOTO 50
- X IF(CNAM(:LIGNOR(IGN)).EQ.CIGNOR(IGN)(:LIGNOR(IGN)))
- X + GOTO 60
- X 50 CONTINUE
- X WRITE(MZUNIT,600) CNAM,CNAMOL
- X NGLOBF = NGLOBF + 1
- X 60 NLAST = 0
- X ENDIF
- X 70 CONTINUE
- X ENDIF
- XC Check for clashes in COMMON definitions
- X IF(LCHECK(5)) THEN
- X DO 140 IT=1,NCOMT
- X ILEN1 = INDEX(SCTITL(IT),' ')-1
- X DO 80 IGN=1,NIGNOR
- X IF(LIGNOR(IGN).NE.ILEN1) GOTO 80
- X IF(SCTITL(IT)(:ILEN1).EQ.CIGNOR(IGN)(:ILEN1)) GOTO 140
- X 80 CONTINUE
- X IFOUN = 0
- X DO 110 ITG=1,NGCOT
- X ILEN2 = INDEX(SGCTIT(ITG),' ')-1
- X IF(ILEN2.NE.ILEN1) GOTO 110
- X IF(SCTITL(IT).NE.SGCTIT(ITG)) GOTO 110
- X IFOUN = 1
- X IST1 = IABS(ICTITL(IT))
- X IST2 = IABS(IGCTIT(ITG))
- X DO 90 IN1=IST1,NCOMN
- X IF(ICNAME(IN1).NE.IT.AND.IGCNAM(IST2+IN1-IST1). EQ.
- X + ITG) THEN
- X WRITE(MZUNIT,510) SCTITL(IT)
- X NGLOBF = NGLOBF + 1
- X GOTO 100
- X ENDIF
- X IF(ICNAME(IN1).NE.IT) GOTO 100
- X IF(IGCNAM(IST2+IN1-IST1).NE.ITG.OR. SCNAME(IN1).NE.
- X + SGCNAM (IST2+IN1-IST1)) THEN
- X WRITE(MZUNIT,510) SCTITL(IT)
- X NGLOBF = NGLOBF + 1
- X GOTO 100
- X ENDIF
- X 90 CONTINUE
- X 100 CONTINUE
- X 110 CONTINUE
- X IF(IFOUN.EQ.0) THEN
- X NGCOT = NGCOT + 1
- X IF(NGCOT.GT.MGCOT) THEN
- X WRITE(MZUNIT,520)
- X GOTO 140
- X ENDIF
- X SGCTIT(NGCOT) = SCTITL(IT)
- X IST1 = NGCON + 1
- X IGCTIT(NGCOT) = -IST1
- X IST2 = IABS(ICTITL(IT))
- X IMX = NCOMN-IST2+1
- X DO 120 INEW=1,IMX
- X IF(ICNAME(IST2+INEW-1).NE.IT) GOTO 130
- X IF(NGCON.GE.MGCON) THEN
- X WRITE(MZUNIT,530)
- X GOTO 130
- X ENDIF
- X NGCON = NGCON + 1
- X IGCNAM(NGCON) = NGCOT
- X SGCNAM(NGCON) = SCNAME(IST2+INEW-1)
- X 120 CONTINUE
- X 130 CONTINUE
- X ENDIF
- X 140 CONTINUE
- X ENDIF
- XC Make second pass over statements in this module to check
- XC for statement function definitions and correct ordering
- XC of all statements
- XC
- XC Also check argument types of module (dimensionality etc)
- XC
- X CALL SECPAS(NGLOBF,LIMPNO)
- XC Loop over routine names
- X DO 180 IN=1,NRNAME
- XC Skip GEANT3 names if flag GALEPH
- X CNAM = SNAMES(IRNAME+IN)
- X IF(GALEPH) THEN
- X IF(CNAM(1:1).EQ.'G'.OR.CNAM(2:2).EQ.'G') GOTO 180
- X ENDIF
- X DO 150 IGN=1,NIGNOR
- X IF(LIGNOR(IGN).NE.INDEX(SNAMES(IRNAME+IN),' ')-1) GOTO 150
- X IF(CNAM(:LIGNOR(IGN)).EQ.CIGNOR(IGN)(:LIGNOR(IGN))) GOTO 180
- X 150 CONTINUE
- X NTYP = NAMTYP(IRNAME+IN)
- X DO 160 II=1,21
- XC Interrogate bit pattern for type of name IN
- X IB(II)=0
- X IF(BTEST(NTYP,II-1)) THEN
- X IB(II)=1
- X ENDIF
- X 160 CONTINUE
- XC now extract the first blank in the name
- X ILEN = INDEX(CNAM,' ')-1
- X IF((ILEN.GT.6.OR.ILEN.EQ.-1).AND.LCHECK(6)) THEN
- X WRITE(MZUNIT,620) CNAM
- X NGLOBF = NGLOBF + 1
- X ENDIF
- XC now enforce some rules
- X IF(IB(20).EQ.1.AND.LCHECK(7).AND.ILEN.NE.6) THEN
- XC in a common block
- X WRITE(MZUNIT,630) CNAM
- X NGLOBF = NGLOBF + 1
- X ENDIF
- X IF(LCHECK(8).AND.ILEN.GE.6.AND.IB(8)+IB(10)+IB(11)+IB(12)+ IB
- X + (13)+IB(14)+IB(15)+IB(16)+IB(17)+IB(20).EQ.0) THEN
- XC variable name in routine (not COMMON,FUNCTION etc)
- X WRITE(MZUNIT,640) CNAM
- X NGLOBF = NGLOBF + 1
- X ENDIF
- X IF(LCHECK(43).AND.ILEN.GE.6.AND.IB(8)+IB(10)+IB(11)+IB(12)+ IB
- X + (13)+IB(14)+IB(15)+IB(16)+IB(17)+IB(20)+IB(7).EQ.0) THEN
- XC variable name in routine (not COMMON,FUNCTION,PARAMETER etc)
- X WRITE(MZUNIT,640) CNAM
- X NGLOBF = NGLOBF + 1
- X ENDIF
- X CFRST = CNAM(1:1)
- X IF(LCHECK(9).AND.IB(1).EQ.1.AND..NOT.LIMPNO) THEN
- XC integer name
- X IF(CFRST.NE.'I'.AND.CFRST.NE.'J'. AND.CFRST.NE.'K'.AND.
- X + CFRST .NE.'L'. AND.CFRST.NE.'M'.AND.CFRST.NE.'N') THEN
- X
- X WRITE(MZUNIT,650) CNAM
- X NGLOBF = NGLOBF + 1
- X ENDIF
- X ENDIF
- X IF(LCHECK(9).AND.IB(2).EQ.1.AND..NOT.LIMPNO) THEN
- XC real name
- X IF(CFRST.EQ.'I'.OR.CFRST.EQ.'J'.OR.CFRST.EQ.'K'. OR.CFRST.
- X + EQ . 'L'.OR.CFRST.EQ.'M'.OR.CFRST.EQ.'N') THEN
- X WRITE(MZUNIT,660) CNAM
- X NGLOBF = NGLOBF + 1
- X ENDIF
- X ENDIF
- XC now check that the variable isn't a FORTRAN key-word
- XC Except in the case of 'REAL' which is a KEYWORD and a generic function
- X IF(LCHECK(10)) THEN
- X IF(CNAM.EQ.'REAL ') GOTO 180
- X DO 170 II=1,NFS
- X ILENF = INDEX(CFORT(II),' ')-1
- X IF(ILENF.LE.0) ILENF = 6
- X IF(ILENF.NE.ILEN) GOTO 170
- X IF(CNAM.EQ.CFORT(II)) THEN
- X WRITE(MZUNIT,670) CNAM,CFORT(II)
- X NGLOBF = NGLOBF + 1
- X ENDIF
- X 170 CONTINUE
- X ENDIF
- XC
- X 180 CONTINUE
- X WRITE(MZUNIT,540) NGLOBF
- X WRITE(MZUNIT,680) SCROUT
- XC Now rewind MZUNIT and check for non-zero errors before
- XC copying to MPUNIT
- X 190 CONTINUE
- X REWIND(MZUNIT)
- X IF(NGLOBF+NFAULT.NE.0.AND.RPROCS) THEN
- X 200 READ(MZUNIT,550,ERR=210,END=210) CZUN
- X WRITE(MPUNIT,550) CZUN
- X GOTO 200
- X 210 REWIND(MZUNIT)
- X ENDFILE(MZUNIT)
- X REWIND(MZUNIT)
- X ENDIF
- XC Reset NFAULT to zero ready for next module
- X NFAULT = 0
- X RPROCS = .TRUE.
- X 500 FORMAT(/,1X,'!!! ',I3,' STATEMENT WARNING(S) IN THIS MODULE ')
- X 510 FORMAT(1X,'!!! WARNING ... COMMON ',A,
- X +' HAS CHANGED IN DEFINITION')
- X 520 FORMAT(1X,'!!! NON-FATAL ERROR IN URTERM . MGCOT EXCEEDED')
- X 530 FORMAT(1X,'!!! NON-FATAL ERROR IN URTERM . MGCON EXCEEDED')
- X 540 FORMAT(/,1X,'!!! ',I3,' GLOBAL WARNING(S) IN THIS MODULE ')
- X 550 FORMAT(A131)
- X 560 FORMAT(/,1X,'BEGIN GLOBAL CHECKS WITHIN THIS MODULE',/)
- X 570 FORMAT(1X,'!!! WARNING ... AVOID COMMENT LINES AFTER END')
- X 580 FORMAT(1X,'!!! WARNING ... MODULE DOES NOT HAVE "END"')
- X 590 FORMAT(1X,'!!! WARNING ... COMMON ',A,
- X +' DECLARED BUT NOT USED IN THIS MODULE')
- X 600 FORMAT(1X,'!!! WARNING ... VARIABLE ',A, ' IN COMMON ',A,
- X +',COMPLEX OR DOUBLE PRECISION, SHOULD BE AT START OF COMMON')
- X 610 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,
- X +' CONTAINS "$" AND IS ILLEGAL')
- X 620 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,
- X +' HAS LENGTH OF >6 CHARACTERS')
- X 630 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,
- X +' IS IN COMMON AND IS NOT 6 CHARACTERS LONG')
- X 640 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,
- X +' IS A VARIABLE WITH LENGTH >5')
- X 650 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,
- X +' IS INTEGER BUT DOES NOT START I -> N')
- X 660 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,
- X +' IS REAL BUT STARTS WITH I -> N')
- X 670 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,
- X +' CLASHES WITH FORTRAN KEY-WORD ',A6)
- X 680 FORMAT(1X,20('+'), ' END MODULE CHECKS ',10('+'),
- X +/,1X,20(' '), ' FOR ',A,//)
- X END
- /
- echo 'x - floppy.o'
- sed 's/^X//' > floppy.o << '/'
- XPPPM<~]H]P{o}VZQZM(~oDPZ+]]l[PPPM`~TMd~TMh~TMl~TMp~TMx~TM$|]P]P{oz] A$|]P]P]HUM |o(o-[P]PA[P]P{ow]]$]+hP]PA~[P]P]HUP o]Adx]P]P]H"]P]P{o%o]]Ho0k]At]P]P]HPMtsA~[PPPMlsPMxs^o3
- P]PAYr]P]P]HoXX{of]]p~AP~]P]P{odUP o{~]P]P{obUPoXm]P]PAPm]P]PAam]P]P{ow`]]ile Tidied Fortran: E 99TATEMENTS,GOTO;UT,FULL,COMPRESS;GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- jXXXXXXXXXXXXXXX.46/
- echo 'x - floppy.rexx'
- sed 's/^X//' > floppy.rexx << '/'
- X/***********************************************************************/
- X/* FLOPPY exec */
- X/* */
- X/* JJB May 1987 */
- X/***********************************************************************/
- Xaddress 'COMMAND'
- Xsignal on novalue
- Xparse source . . execname .
- Xfnin = " "; ftin = "FORTRAN"; fmin = "A"
- Xfnold = ""; ftold = "FLOPIGN"; fmold = "A"
- Xtree = "NO"; checks = "STANDARD"; ignore = "NO"
- Xflopo = "YES"; full = "NO"; tidy = "NO"
- Xfntdy = "OUTPUT"; fttdy = "FORTRAN"; fmtdy = "A"
- Xgotos = "NO"; indent = "NO"; spaces = 3; groupf = "NO"
- Xrenums = "NO"; renumf = "NO"; startf = 500; stepf = 10
- Xstarts = 10; steps = 10
- X
- Xoptset = "CHECKS IGNORE TREE DISK FULL GOTOS INDENT GROUPF"
- Xoptset = optset "RENUMF RENUMS OLD OUTPUT TIDY"
- Xsngset = "TREE DISK FULL GOTOS GROUPF IGNORE TIDY"
- X
- X
- Xerr = "Name of source Fortran file not yet given."
- Xcursor = "0001"
- Xinteractive = "YES"
- Xparse upper arg input
- Xparse value input with filename '(' options
- Xxx = 'XPARSE'(filename,'A')
- X
- X/***********************/
- X/* LINE MODE TREATMENT */
- X/***********************/
- X
- Xif A.0 ^= 0 then do
- X interactive = "NO"
- X if A.1 = "?" then do; ADDRESS CMS 'HELP 'execname; signal EXIT; end
- X fnin = A.1
- X if A.0 > 1 then ftin = A.2
- X if A.0 > 2 then fmin = A.3
- X if A.0 > 3 then do
- X err = "Too many parameters given :" A.4
- X signal EXIT
- X end
- X nopts = words(options)
- X iopt = 0 ; err = " " ; flopo = "NO"
- X do forever
- X iopt = iopt + 1 ; if iopt > nopts then leave
- X if find(optset,word(options,iopt))= 0 then do
- X err = "Unidentified option on command line: "word(options,iopt)
- X signal EXIT
- X end
- X if find(sngset,word(options,iopt)) ^= 0 then do
- X interpret word(options,iopt)||'="YES"'
- X if abbrev(word(options,iopt),"DISK",4) then flopo = "YES"
- X iterate
- X end
- X if iopt < nopts then do
- X key = word(options,iopt) ; val = word(options,iopt+1)
- X if abbrev(key,"OLD",3) then do
- X if iopt + 3 > nopts then do
- X err = "Specify full file name for OLD file."
- X signal EXIT
- X end
- X fnold = val
- X ftold = word(options,iopt+2)
- X fmold = word(options,iopt+3)
- X iopt = iopt + 2
- X end
- X if abbrev(key,"OUT",3) then do
- X if iopt + 3 > nopts then do
- X err = "Specify full file name for OUTPUT file."
- X signal EXIT
- X end
- X fntdy = val
- X fttdy = word(options,iopt+2)
- X fmtdy = word(options,iopt+3)
- X iopt = iopt + 2
- X end
- X if abbrev(key,"CHEC",4) then checks = val
- X if abbrev(key,"INDE",4) then do
- X spaces = val
- X indent = "YES"
- X end
- X if abbrev(key,"RENUMF",6) then do
- X /* renumber FORMAT statements. Get the step and start. */
- X ipos = pos(",",val,1)
- X if ipos = 0 then startf = val
- X else do
- X startf = substr(val,1,ipos-1)
- X stepf = substr(val,ipos+1)
- X end
- X renumf = "YES"
- X end
- X if abbrev(key,"RENUMS",6) then do
- X /* renumber other statements. Get the step and start. */
- X ipos = pos(",",val,1)
- X if ipos = 0 then starts = val
- X else do
- X starts = substr(val,1,ipos-1)
- X steps = substr(val,ipos+1)
- X end
- X renums = "YES"
- X end
- X iopt = iopt + 1
- X iterate
- X end
- X if iopt = nopts then do
- X err = 'Missing value for option 'word(options,iopt)
- X signal EXIT
- X end
- X end
- Xend
- X
- X/****************/
- X/* GENERAL MODE */
- X/****************/
- X
- XSTART:
- Xif interactive = "NO" then signal CHECK
- Xif ^'QCONSOLE'('GRAPHIC') then do
- X err = 'Not a full screen device'
- X signal EXIT
- Xend
- Xdo forever
- X signal off error
- X 'IOS3270' execname 'PANEL ;PANEL1 (CLEAR 'cursor
- X/* signal on error ios3270 gives codes that aren't errors...*/
- X if IOSK = 'PF03' then do; err = ' '; signal EXIT; end
- X if IOSK = 'PF02' then do
- X say "Enter the CMS command :"
- X parse pull command
- X signal off error; ADDRESS CMS command; signal on error
- X say "Continue with "execname" ? [CR=YES]"
- X parse upper pull answer
- X if abbrev(answer,"N",1) then signal EXIT
- X iterate
- X end
- X if IOSK = 'PF01' then do
- X /* extract cursor position and find appropriate part of help */
- X row = substr(IOSC,1,2) ; col = substr(IOSC,3,2)
- X cursor = IOSC
- X if row = 5 then do
- X push 'FIND FLOPPY'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 7 then do
- X push 'FIND OLD'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 8 then do
- X push 'FIND CHECKS'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 9 then do
- X push 'FIND IGNORE'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 11 then do
- X push 'FIND TREE'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 13 then do
- X push 'FIND DISK'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 14 then do
- X push 'FIND FULL'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 16 & col > 40 then do
- X push 'FIND OUTPUT'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 16 & col < 41 then do
- X push 'FIND FLOPPY'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 17 then do
- X push 'FIND GOTOS'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 18 then do
- X push 'FIND INDENT'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 19 then do
- X push 'FIND GROUPF'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 20 | row = 21 then do
- X push 'FIND RENUMF'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X if row = 22 | row = 23 then do
- X push 'FIND RENUMS'
- X ADDRESS CMS 'XEDIT 'execname' HELPCMS'
- X iterate
- X end
- X ADDRESS CMS 'HELP 'execname
- X end
- X leave
- Xend
- X
- XCHECK:
- Xerr = ' '
- Xupper fnin ftin fmin fntdy fttdy fmtdy fnold ftold fmold
- Xupper tree checks ignore flopo full tidy gotos
- Xupper indent renums renumf groupf
- X
- Xif ^'FEXIST'(fnin ftin fmin) then do
- X err = "Input FORTRAN file does not exist."
- X cursor = "0001"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- Xif 'QFILE'(fnin ftin fmin,"RECFM") ^= "F" then do
- X err = "Input FORTRAN file is RECFM V. Change to RECFM F please."
- X cursor = "0001"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- Xif ^'FEXIST'(fnold ftold fmold) & LENGTH(fnold) ^= 0 then do
- X err = "FLOPPY parameter file does not exist."
- X cursor = "0004"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- Xchecks = strip(checks)
- Xif words(checks) ^= 1 then do
- X err = "Use a single Checks keyword, or separate numbers with commas"
- X cursor = "0007"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- Xif find("STANDARD ALEPH GALEPH ONLINE NONE LIST",checks) = 0 then do
- X if ^datatype(checks,'N') then do
- X if index(checks,',') = 0 then do
- X err = "Must be list of numbers or keyword. See HELP file."
- X cursor = "0007"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X else do
- X ipos = 1
- X do until ipos > length(checks)
- X ipose = index(checks,',',ipos) - 1
- X if ipose = -1 then ipose = length(checks)
- X num = substr(checks,ipos,ipose-ipos+1)
- X if ^datatype(num,"N") then do
- X err = "Invalid integer "num" in list of checks."
- X cursor = "0007"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X ipos = ipose + 2
- X end
- X end
- X end
- Xend
- X
- Xset1 = "N"
- Xif abbrev(gotos,"Y",1) | abbrev(indent,"Y",1) ,
- X | abbrev(groupf,"Y",1) | abbrev(renumf,"Y",1),
- X | abbrev(renumf,"Y",1) then set1 = "Y"
- X
- Xif set1 = "Y" then tidy = "Y"
- Xif set1 = "N" & abbrev(tidy,"Y",1) then do
- X err = "Specify how you want to tidy the code."
- X cursor = "0012"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- Xif abbrev(tidy,"Y",1) then do
- X if fntdy = " " then do
- X err = "Specify the name of the output FORTRAN file."
- X cursor = "0013"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X if fttdy = " " then do
- X err = "Specify the name of the output FORTRAN file."
- X cursor = "0014"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X if fnin||ftin||fmin = fntdy||fttdy||fmtdy then do
- X err = "Output FORTRAN will overwrite input. Rename."
- X cursor = "0013"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X if abbrev(indent,"Y",1) & ^datatype(spaces,"N") then do
- X err = "Number of spaces to indent must be an integer."
- X cursor = "0018"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X if abbrev(indent,"Y",1) & ( spaces>5 | spaces<1 ) then do
- X err = "Number of spaces must be between 1 and 5 for indent."
- X cursor = "0018"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X if abbrev(renumf,"Y",1) then do
- X if ^datatype(startf,"N") then do
- X err = "Statement number must be numeric."
- X cursor = "0021"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X if ^datatype(stepf,"N") then do
- X err = "Statement number step must be numeric."
- X cursor = "0022"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X end
- X if abbrev(renumf,"Y",1) then do
- X if ^datatype(starts,"N") then do
- X err = "Statement number must be numeric."
- X cursor = "0024"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X if ^datatype(steps,"N") then do
- X err = "Statement number step must be numeric."
- X cursor = "0025"
- X if interactive = "YES" then signal START
- X signal EXIT
- X end
- X end
- Xend
- X
- Xif ^abbrev(flopo,"N",1) & ^abbrev(flopo,"Y",1) then do
- X err = "FLOPPY output to disk: give Yes or No."
- X cursor = "0010"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- Xif ^abbrev(tree,"N",1) & ^abbrev(tree,"Y",1) then do
- X err = "TREE output from FLOPPY: give Yes or No."
- X cursor = "0009"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- Xif ^abbrev(full,"N",1) & ^abbrev(full,"Y",1) then do
- X err = "Full source listing from FLOPPY: give Yes or No."
- X cursor = "0011"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- Xif ^abbrev(ignore,"N",1) & ^abbrev(ignore,"Y",1) then do
- X err = "List of ignore names for FLOPPY: give Yes or No."
- X cursor = "0008"
- X if interactive = "YES" then signal START
- X signal EXIT
- Xend
- X
- X
- X
- X/* Now write the necessary input files */
- Xoldflag = length(fnold)
- Xif oldflag ^= 0 then file = fnold' TEMP$T A'
- Xif oldflag = 0 then do
- X file = fnin' FLOPIGN A'
- X if 'FEXIST'(file) then 'ERASE 'file /* erase unwanted ignore file */
- Xend
- Xexw = 'EXECIO 1 DISKW 'file' (STRING '
- Xexw" "
- X
- Xif abbrev(full,'Y',1) then exw"*FULL"
- X
- Xif abbrev(checks,'ALEP',1) & oldflag = 0 then exw"*ALEPH"
- X
- Xif abbrev(ignore,"Y",1) then do
- X say "You must now enter a list of the names FLOPPY is to ignore"
- X /* push terminal control characters before reading names */
- X cpus= "CPUSH"("TERM")
- X "CP TERM CHARDEL OFF"
- X "CP TERM LINEDEL OFF"
- X "CP TERM LINEND OFF"
- X "CP TERM ESCAPE OFF"
- X "CP TERM TABCHAR OFF"
- X say "Names to ignore ..... "
- X say " eg to ignore variable NUMGEN enter NUMGEN "
- X say " to ignore subroutine FRED enter #FRED "
- X say " "
- X n = 0
- X do forever
- X say "Enter name to ignore [CR=no more]"
- X parse upper pull name
- X if name = "" then leave
- X n = n + 1
- X exw name
- X end
- X /* restore control characters */
- X cpo = "CPOP"("TERM")
- Xend
- X
- Xif abbrev("LIST",checks,1) then do
- X say 'Enter the long list of rule numbers to be checked.'
- X say 'Separate each rule by a comma (,)'
- X parse upper pull checks
- Xend
- X
- Xif find("STANDARD ALEPH GALEPH ONLINE NONE LIST",checks) = 0 then do
- X if ^datatype(checks,'N') then do
- X ipos = 1
- X do until ipos > length(checks)
- X ipose = index(checks,',',ipos) - 1
- X if ipose = -1 then ipose = length(checks)
- X num = substr(checks,ipos,ipose-ipos+1)
- X if length(num) = 1 then num = " "||num
- X if length(num) = 2 then num = " "||num
- X if datatype(num,"N") then exw"*CHECK RULE "num
- X ipos = ipose + 2
- X end
- X end
- X else do
- X if length(checks) = 1 then checks = " "||checks
- X exw"*CHECK RULE "checks
- X end
- Xend
- Xelse do
- X if abbrev("STANDARD",checks,1) & oldflag = 0 then exw"*CHECK RULE *"
- X if abbrev("ALEPH",checks,1) & oldflag = 0 then exw"*ALEPH"
- X if abbrev("GALEPH",checks,1) & oldflag = 0 then exw"*ALEPH"
- X if abbrev("GALEPH",checks,1) & oldflag = 0 then exw"*GALEPH"
- X if abbrev("NONE",checks,1) then exw"*CHECK RULE -99"
- Xend
- X'FINIS 'file
- X
- Xif fnold ^= " " then do
- X 'COPYFILE 'fnold ftold fmold' = = A (REPLACE'
- X 'COPYFILE 'file fnold ftold' A (APPEND'
- X 'ERASE 'file
- Xend
- Xelse fnold = fnin
- X
- X/* Now the FLOP (not FLOPPY) input data */
- X
- Xfile = 'FLOPPY TEMP$T A'
- Xif 'FEXIST'(file) then 'ERASE 'file
- Xexw = 'EXECIO 1 DISKW 'file' (STRING '
- X
- Xif abbrev(tidy,"Y",1) then exw"OUTPUT,FULL,COMPRESS;"
- Xif abbrev(tree,"Y",1) then exw"OPTIONS,TREE;"
- Xif abbrev(gotos,"Y",1) then exw"STATEMENTS,GOTO;"
- Xif abbrev(groupf,"Y",1) then exw"STATEMENTS,SEPARATE;"
- Xif abbrev(indent,"Y",1) then exw"OPTIONS,INDENT="spaces";"
- Xif abbrev(renumf,"Y",1) then exw"STATEMENTS,FORMAT="startf","stepf";"
- Xif abbrev(renums,"Y",1) then exw"STATEMENTS,NUMBER="starts","steps";"
- X/* default cards for FLOP */
- Xexw"LIST,GLOBAL,TYPE;"
- Xexw"PRINT,ILLEGAL;"
- Xexw"OPTIONS,USER;"
- Xexw"END;"
- X'FINIS 'file
- X
- X'COPYFILE 'file' = = = (RECFM F LRECL 80 REPLACE'
- X
- X'COPYFILE 'fnold ftold fmold' = = = (RECFM F LRECL 80 REPLACE'
- X
- X/* Now assign the FILEDEFs */
- X'MAKEBUF'
- Xbufno = rc
- X'SENTRIES'
- Xentries = rc
- X'QFILEDEF ( STACK'
- Xpull dummy
- Xnum_fdefs = 0
- Xdo queued()-entries
- X num_fdefs = num_fdefs + 1
- X pull fdef.num_fdefs
- Xend
- X'DROPBUF 'bufno
- X'FILEDEF 5 CLEAR'
- X'FILEDEF 6 CLEAR'
- X'FILEDEF 11 CLEAR'
- X'FILEDEF 13 CLEAR'
- X'FILEDEF 14 CLEAR'
- X'FILEDEF 15 CLEAR'
- X'FILEDEF 50 CLEAR'
- X'FILEDEF 99 CLEAR'
- X
- X'FILEDEF 5 DISK 'file
- X'FILEDEF 11 DISK 'fnin ftin fmin
- X'FILEDEF 15 DISK 'fnold ftold fmold
- X'FILEDEF 99 DISK FLOPPY SCRATCH A (RECFM F LRECL 132'
- X
- Xif abbrev(tidy,"Y",1) then do
- X say 'Tidied FORTRAN output will be called 'fntdy fttdy fmtdy
- X 'FILEDEF 14 DISK 'fntdy fttdy fmtdy '(LRECL 80 RECFM F'
- Xend
- X
- Xif abbrev(flopo,"Y",1) then do
- X say 'FLOPPY listing file will be called 'fnin 'FLOPLIS A'
- X 'FILEDEF 6 DISK 'fnin' FLOPLIS A (LRECL 132 RECFM F'
- Xend
- Xelse 'FILEDEF 6 TERMINAL (LRECL 132 PERM'
- X
- Xif abbrev(tree,"Y",1) then do
- X say 'FLOPPY output for TREE will be called 'fnin 'FLOPTRE A'
- X 'FILEDEF 13 DISK 'fnin' TEMPTRE A (LRECL 8000 RECFM VS'
- X 'FILEDEF 50 DISK 'fnin' FLOPTRE A (LRECL 8000 RECFM VS'
- Xend
- X
- Xsay 'FLOPPY begins .... '
- X
- X/* MONITOR USAGE */
- X
- Xlogline = 'Fn 'fnin' Che 'checks,
- X 'Tre' substr(tree,1,1),
- X 'Ign' substr(ignore,1,1),
- X 'Out' substr(flopo,1,1),
- X 'Ful' substr(full,1,1),
- X 'Tid' substr(tidy,1,1),
- X 'Got' substr(gotos,1,1),
- X 'Ind' indent,
- X 'Rns' substr(renums,1,1),
- X 'Rnf' substr(renumf,1,1),
- X 'Grf' substr(groupf,1,1)
- Xlogline = substr(logline,1,80)
- X
- X'EXEC LOGUSAGE FLOPPY 'logline
- X
- X/* RUN FLOPPY */
- X'EXEC CERNLIB'
- X'FLOPPY$M'
- X
- X'EXEC LOGUSAGE FLOPPY Successful completion'
- X
- X/* Reinstate original FILEDEFs */
- X'FILEDEF 5 CLEAR'
- X'FILEDEF 6 CLEAR'
- X'FILEDEF 11 CLEAR'
- X'FILEDEF 13 CLEAR'
- X'FILEDEF 14 CLEAR'
- X'FILEDEF 15 CLEAR'
- X'FILEDEF 50 CLEAR'
- X'FILEDEF 99 CLEAR'
- Xdo i = 1 to num_fdefs
- X fdef.i
- Xend
- X
- X/* Erase unwanted files */
- Xif 'FEXIST'('FLOPPY SCRATCH A') then 'ERASE FLOPPY SCRATCH A'
- Xif 'FEXIST'(file) then 'ERASE 'file
- X
- Xsay 'FLOPPY has finished'
- X
- Xcall EXIT
- X
- X
- X
- XNOVALUE:
- Xsay 'Uninitialised variable encountered on line' sigl
- Xcall EXIT
- X
- XERROR:
- Xsay 'Error on line' sigl
- Xcall EXIT
- X
- XEXIT:
- Xif err ^= " " then say execname ": " err
- Xexit
- /
- echo 'Part 03 of Floppy complete.'
- exit
-
-
-