home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume12 / ffccc / part03 < prev    next >
Encoding:
Text File  |  1990-05-14  |  30.4 KB  |  924 lines

  1. Newsgroups: comp.sources.misc
  2. organization: CERN, Geneva, Switzerland
  3. keywords: fortran
  4. subject: v12i089: REPOST Floppy - Fortran Coding Convention Checker Part 03/11
  5. from: julian@cernvax.cern.ch (julian bunn)
  6. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  7.  
  8. Posting-number: Volume 12, Issue 89
  9. Submitted-by: julian@cernvax.cern.ch (julian bunn)
  10. Archive-name: ffccc/part03r
  11.  
  12. #!/bin/sh
  13. echo 'Start of Floppy, part 03 of 11:'
  14. echo 'x - CUSSTMT.h'
  15. sed 's/^X//' > CUSSTMT.h << '/'
  16. X*IF DEF,NEVER   
  17. X*-----------------------------------------------------------------------
  18. X*   ISGLOB  = running count of statements in source deck
  19. X*   ICLOLD  = the class (ICLASS) of the last EXECUTABLE statement   
  20. X*   NFIOLD  = the line number of the last statement in the module   
  21. X*   NFAULT  = the number of WARNINGS in the module so far   
  22. X*   RPROCS  = set .TRUE. if module is to be processed   
  23. X*-----------------------------------------------------------------------
  24. X*EI 
  25. /
  26. echo 'x - URTERM.f'
  27. sed 's/^X//' > URTERM.f << '/'
  28. X      SUBROUTINE URTERM 
  29. X*-----------------------------------------------------------------------
  30. X*   
  31. X*--- user routine termination   
  32. X*   
  33. X*-----------------------------------------------------------------------
  34. X      include 'PARAM.h' 
  35. X      include 'ALCAZA.h' 
  36. X      include 'CLASS.h' 
  37. X      include 'CURSTA.h' 
  38. X      include 'FLWORK.h' 
  39. X      include 'KEYCOM.h' 
  40. X      include 'TYPDEF.h' 
  41. X      include 'JOBSUM.h' 
  42. X      include 'STATE.h' 
  43. X      include 'FLAGS.h' 
  44. X      include 'USGCOM.h' 
  45. X      include 'USCOMN.h' 
  46. X      include 'USSTMT.h' 
  47. X      include 'USIGNO.h' 
  48. X      include 'USUNIT.h' 
  49. X      include 'USARGS.h' 
  50. X      include 'CHECKS.h' 
  51. X      PARAMETER (NFS=28)
  52. X      DIMENSION IB(21)  
  53. X      CHARACTER*(MXNMCH) CNAM,CNAMOL
  54. X      CHARACTER*1 CFRST 
  55. X      CHARACTER*6 CFORT(NFS)
  56. X      CHARACTER*131 CZUN
  57. X      LOGICAL LIMPNO,BTEST  
  58. X      DATA CFORT /'ASSIGN', 'CALL  ','COMMON','CLOSE ', 'DATA  ',   
  59. X     +'DO    ','DECODE','DOUBLE', 'END   ','ENDIF ','ENTRY ', 'ELSE  ', 
  60. X     +'ELSEIF','ENCODE','FORMAT', 'GOTO  ','IF    ', 'OPEN  ','PRINT ', 
  61. X     +'PAUSE ', 'PUNCH ','READ  ','REAL  ','RETURN', 'REWIND','SAVE  ', 
  62. X     +'STOP  ','WRITE '/
  63. XC   
  64. X      IF(UNFLP) RETURN  
  65. X      WRITE(MZUNIT,500) NFAULT  
  66. X      WRITE(MZUNIT,560) 
  67. XC Update statement number for input file
  68. X      ISGLOB = ISGLOB + NLINES - 1  
  69. X      NGLOBF = 0
  70. XC Check that module is to be processed  
  71. X      IF(.NOT.RPROCS)                                           GOTO 190
  72. XC Check for comment lines after end of module   
  73. X      IF(LCHECK(1).AND.NLINES-1.GT.NFIOLD) THEN 
  74. X         WRITE(MZUNIT,570)  
  75. X         NGLOBF = NGLOBF + 1
  76. X      ENDIF 
  77. XC Check that module ended with END  
  78. X      IF(LCHECK(2).AND.ICLOLD.NE.IEND) THEN 
  79. X         WRITE(MZUNIT,580)  
  80. X         NGLOBF = NGLOBF + 1
  81. X      ENDIF 
  82. X      IF(LCHECK(3)) THEN
  83. XC Check for COMMON blocks remaining unused  
  84. X         DO 20 IC=1,NCOMT   
  85. X            IF(ICTITL(IC).GT.0) THEN
  86. X               LEN=INDEX(SCTITL(IC),' ')-1  
  87. X               DO 10 IGN=1,NIGNOR   
  88. X                  IF(LIGNOR(IGN).NE.LEN)                         GOTO 10
  89. X                  IF(SCTITL(IC)(:LEN).EQ.CIGNOR(IGN)(:LEN))      GOTO 20
  90. X   10          CONTINUE 
  91. X               WRITE(MZUNIT,590) SCTITL(IC) 
  92. X               NGLOBF = NGLOBF + 1  
  93. X            ENDIF   
  94. X   20    CONTINUE   
  95. X      ENDIF 
  96. XC Check that COMPLEX and DOUBLE PRECISION variables occur   
  97. XC at the start of a COMMON block
  98. X      IF(LCHECK(4)) THEN
  99. X         CNAMOL = '        '
  100. X         DO 70 IC=1,NCOMN   
  101. X            IF(SCTITL(ICNAME(IC)).NE.CNAMOL) THEN   
  102. XC Change of COMMON block name ... reset counters
  103. XC NLAST = 1 signifies last variable in common was real/doublep  
  104. XC NLAST = 0 signifies otherwise 
  105. X               CNAMOL = SCTITL(ICNAME(IC))  
  106. X               NLAST = 1
  107. X            ENDIF   
  108. X            CNAM = SCNAME(IC)   
  109. X            ILEN = INDEX(CNAM,' ')  
  110. XC Search for NAMTYP 
  111. X            MATCH = 0   
  112. X            DO 30 IN=1,NRNAME   
  113. X               IF(ILEN.NE.INDEX(SNAMES(IN+IRNAME),' '))          GOTO 30
  114. X               IF(CNAM.NE.SNAMES(IN+IRNAME))                     GOTO 30
  115. X               NTYP = NAMTYP(IN+IRNAME) 
  116. XC The variable must be a COMMON variable (not a dimensionality) 
  117. X               IF(.NOT.BTEST(NTYP,19))                           GOTO 40
  118. X               MATCH = 1
  119. X                                                                 GOTO 40
  120. X   30       CONTINUE
  121. X   40       IF(MATCH.EQ.0)                                       GOTO 70
  122. X            IF(.NOT.BTEST(NTYP,3).AND..NOT.BTEST(NTYP,4)) THEN  
  123. X               NLAST = 0
  124. X            ELSE IF(NLAST.EQ.0) THEN
  125. X               DO 50 IGN=1,NIGNOR   
  126. X                  IF(LIGNOR(IGN).NE.INDEX(CNAM,' ')-1)           GOTO 50
  127. X                  IF(CNAM(:LIGNOR(IGN)).EQ.CIGNOR(IGN)(:LIGNOR(IGN)))   
  128. X     +                                                           GOTO 60
  129. X   50          CONTINUE 
  130. X               WRITE(MZUNIT,600) CNAM,CNAMOL
  131. X               NGLOBF = NGLOBF + 1  
  132. X   60          NLAST = 0
  133. X            ENDIF   
  134. X   70    CONTINUE   
  135. X      ENDIF 
  136. XC Check for clashes in COMMON definitions   
  137. X      IF(LCHECK(5)) THEN
  138. X         DO 140 IT=1,NCOMT  
  139. X            ILEN1 = INDEX(SCTITL(IT),' ')-1 
  140. X            DO 80 IGN=1,NIGNOR  
  141. X               IF(LIGNOR(IGN).NE.ILEN1)                          GOTO 80
  142. X               IF(SCTITL(IT)(:ILEN1).EQ.CIGNOR(IGN)(:ILEN1))    GOTO 140
  143. X   80       CONTINUE
  144. X            IFOUN = 0   
  145. X            DO 110 ITG=1,NGCOT  
  146. X               ILEN2 = INDEX(SGCTIT(ITG),' ')-1 
  147. X               IF(ILEN2.NE.ILEN1)                               GOTO 110
  148. X               IF(SCTITL(IT).NE.SGCTIT(ITG))                    GOTO 110
  149. X               IFOUN = 1
  150. X               IST1 = IABS(ICTITL(IT))  
  151. X               IST2 = IABS(IGCTIT(ITG)) 
  152. X               DO 90 IN1=IST1,NCOMN 
  153. X                  IF(ICNAME(IN1).NE.IT.AND.IGCNAM(IST2+IN1-IST1). EQ.   
  154. X     +            ITG) THEN 
  155. X                     WRITE(MZUNIT,510) SCTITL(IT)   
  156. X                     NGLOBF = NGLOBF + 1
  157. X                                                                GOTO 100
  158. X                  ENDIF 
  159. X                  IF(ICNAME(IN1).NE.IT)                         GOTO 100
  160. X                  IF(IGCNAM(IST2+IN1-IST1).NE.ITG.OR. SCNAME(IN1).NE.   
  161. X     +            SGCNAM (IST2+IN1-IST1)) THEN  
  162. X                     WRITE(MZUNIT,510) SCTITL(IT)   
  163. X                     NGLOBF = NGLOBF + 1
  164. X                                                                GOTO 100
  165. X                  ENDIF 
  166. X   90          CONTINUE 
  167. X  100          CONTINUE 
  168. X  110       CONTINUE
  169. X            IF(IFOUN.EQ.0) THEN 
  170. X               NGCOT = NGCOT + 1
  171. X               IF(NGCOT.GT.MGCOT) THEN  
  172. X                  WRITE(MZUNIT,520) 
  173. X                                                                GOTO 140
  174. X               ENDIF
  175. X               SGCTIT(NGCOT) = SCTITL(IT)   
  176. X               IST1 = NGCON + 1 
  177. X               IGCTIT(NGCOT) = -IST1
  178. X               IST2 = IABS(ICTITL(IT))  
  179. X               IMX = NCOMN-IST2+1   
  180. X               DO 120 INEW=1,IMX
  181. X                  IF(ICNAME(IST2+INEW-1).NE.IT)                 GOTO 130
  182. X                  IF(NGCON.GE.MGCON) THEN   
  183. X                     WRITE(MZUNIT,530)  
  184. X                                                                GOTO 130
  185. X                  ENDIF 
  186. X                  NGCON = NGCON + 1 
  187. X                  IGCNAM(NGCON) = NGCOT 
  188. X                  SGCNAM(NGCON) = SCNAME(IST2+INEW-1)   
  189. X  120          CONTINUE 
  190. X  130          CONTINUE 
  191. X            ENDIF   
  192. X  140    CONTINUE   
  193. X      ENDIF 
  194. XC Make second pass over statements in this module to check  
  195. XC for statement function definitions and correct ordering   
  196. XC of all statements 
  197. XC   
  198. XC Also check argument types of module (dimensionality etc)  
  199. XC   
  200. X      CALL SECPAS(NGLOBF,LIMPNO)
  201. XC Loop over routine names   
  202. X      DO 180 IN=1,NRNAME
  203. XC Skip GEANT3 names if flag GALEPH  
  204. X         CNAM = SNAMES(IRNAME+IN)   
  205. X         IF(GALEPH) THEN
  206. X            IF(CNAM(1:1).EQ.'G'.OR.CNAM(2:2).EQ.'G')            GOTO 180
  207. X         ENDIF  
  208. X         DO 150 IGN=1,NIGNOR
  209. X            IF(LIGNOR(IGN).NE.INDEX(SNAMES(IRNAME+IN),' ')-1)   GOTO 150
  210. X            IF(CNAM(:LIGNOR(IGN)).EQ.CIGNOR(IGN)(:LIGNOR(IGN))) GOTO 180
  211. X  150    CONTINUE   
  212. X         NTYP = NAMTYP(IRNAME+IN)   
  213. X         DO 160 II=1,21 
  214. XC Interrogate bit pattern for type of name IN   
  215. X            IB(II)=0
  216. X            IF(BTEST(NTYP,II-1)) THEN   
  217. X               IB(II)=1 
  218. X            ENDIF   
  219. X  160    CONTINUE   
  220. XC now extract the first blank in the name   
  221. X         ILEN = INDEX(CNAM,' ')-1   
  222. X         IF((ILEN.GT.6.OR.ILEN.EQ.-1).AND.LCHECK(6)) THEN   
  223. X            WRITE(MZUNIT,620) CNAM  
  224. X            NGLOBF = NGLOBF + 1 
  225. X         ENDIF  
  226. XC now enforce some rules
  227. X         IF(IB(20).EQ.1.AND.LCHECK(7).AND.ILEN.NE.6) THEN   
  228. XC in a common block 
  229. X            WRITE(MZUNIT,630) CNAM  
  230. X            NGLOBF = NGLOBF + 1 
  231. X         ENDIF  
  232. X         IF(LCHECK(8).AND.ILEN.GE.6.AND.IB(8)+IB(10)+IB(11)+IB(12)+ IB  
  233. X     +   (13)+IB(14)+IB(15)+IB(16)+IB(17)+IB(20).EQ.0) THEN 
  234. XC variable name in routine (not COMMON,FUNCTION etc)
  235. X            WRITE(MZUNIT,640) CNAM  
  236. X            NGLOBF = NGLOBF + 1 
  237. X         ENDIF  
  238. X         IF(LCHECK(43).AND.ILEN.GE.6.AND.IB(8)+IB(10)+IB(11)+IB(12)+ IB 
  239. X     +   (13)+IB(14)+IB(15)+IB(16)+IB(17)+IB(20)+IB(7).EQ.0) THEN   
  240. XC variable name in routine (not COMMON,FUNCTION,PARAMETER etc)  
  241. X            WRITE(MZUNIT,640) CNAM  
  242. X            NGLOBF = NGLOBF + 1 
  243. X         ENDIF  
  244. X         CFRST = CNAM(1:1)  
  245. X         IF(LCHECK(9).AND.IB(1).EQ.1.AND..NOT.LIMPNO) THEN  
  246. XC integer name  
  247. X            IF(CFRST.NE.'I'.AND.CFRST.NE.'J'. AND.CFRST.NE.'K'.AND. 
  248. X     +      CFRST .NE.'L'. AND.CFRST.NE.'M'.AND.CFRST.NE.'N') THEN  
  249. X    
  250. X               WRITE(MZUNIT,650) CNAM   
  251. X               NGLOBF = NGLOBF + 1  
  252. X            ENDIF   
  253. X         ENDIF  
  254. X         IF(LCHECK(9).AND.IB(2).EQ.1.AND..NOT.LIMPNO) THEN  
  255. XC real name 
  256. X            IF(CFRST.EQ.'I'.OR.CFRST.EQ.'J'.OR.CFRST.EQ.'K'. OR.CFRST.  
  257. X     +      EQ . 'L'.OR.CFRST.EQ.'M'.OR.CFRST.EQ.'N') THEN  
  258. X               WRITE(MZUNIT,660) CNAM   
  259. X               NGLOBF = NGLOBF + 1  
  260. X            ENDIF   
  261. X         ENDIF  
  262. XC now check that the variable isn't a FORTRAN key-word  
  263. XC Except in the case of 'REAL' which is a KEYWORD and a generic function
  264. X         IF(LCHECK(10)) THEN
  265. X            IF(CNAM.EQ.'REAL    ')                              GOTO 180
  266. X            DO 170 II=1,NFS 
  267. X               ILENF = INDEX(CFORT(II),' ')-1   
  268. X               IF(ILENF.LE.0) ILENF = 6 
  269. X               IF(ILENF.NE.ILEN)                                GOTO 170
  270. X               IF(CNAM.EQ.CFORT(II)) THEN   
  271. X                  WRITE(MZUNIT,670) CNAM,CFORT(II)  
  272. X                  NGLOBF = NGLOBF + 1   
  273. X               ENDIF
  274. X  170       CONTINUE
  275. X         ENDIF  
  276. XC   
  277. X  180 CONTINUE  
  278. X      WRITE(MZUNIT,540) NGLOBF  
  279. X      WRITE(MZUNIT,680) SCROUT  
  280. XC Now rewind MZUNIT and check for non-zero errors before
  281. XC  copying to MPUNIT
  282. X  190 CONTINUE  
  283. X      REWIND(MZUNIT)
  284. X      IF(NGLOBF+NFAULT.NE.0.AND.RPROCS) THEN
  285. X  200    READ(MZUNIT,550,ERR=210,END=210) CZUN  
  286. X         WRITE(MPUNIT,550) CZUN 
  287. X                                                                GOTO 200
  288. X  210    REWIND(MZUNIT) 
  289. X         ENDFILE(MZUNIT)
  290. X         REWIND(MZUNIT) 
  291. X      ENDIF 
  292. XC Reset NFAULT to zero ready for next module
  293. X      NFAULT = 0
  294. X      RPROCS = .TRUE.   
  295. X  500 FORMAT(/,1X,'!!! ',I3,' STATEMENT WARNING(S) IN THIS MODULE ')
  296. X  510 FORMAT(1X,'!!! WARNING ... COMMON ',A,
  297. X     +' HAS CHANGED IN DEFINITION') 
  298. X  520 FORMAT(1X,'!!! NON-FATAL ERROR IN URTERM . MGCOT EXCEEDED')   
  299. X  530 FORMAT(1X,'!!! NON-FATAL ERROR IN URTERM . MGCON EXCEEDED')   
  300. X  540 FORMAT(/,1X,'!!! ',I3,' GLOBAL WARNING(S) IN THIS MODULE ')   
  301. X  550 FORMAT(A131)  
  302. X  560 FORMAT(/,1X,'BEGIN GLOBAL CHECKS WITHIN THIS MODULE',/)   
  303. X  570 FORMAT(1X,'!!! WARNING ... AVOID COMMENT LINES AFTER END')
  304. X  580 FORMAT(1X,'!!! WARNING ... MODULE DOES NOT HAVE "END"')   
  305. X  590 FORMAT(1X,'!!! WARNING ... COMMON ',A,
  306. X     +' DECLARED BUT NOT USED IN THIS MODULE')  
  307. X  600 FORMAT(1X,'!!! WARNING ... VARIABLE ',A, ' IN COMMON ',A, 
  308. X     +',COMPLEX OR DOUBLE PRECISION, SHOULD BE AT START OF COMMON') 
  309. X  610 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,  
  310. X     +' CONTAINS "$" AND IS ILLEGAL')   
  311. X  620 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,  
  312. X     +' HAS LENGTH OF >6 CHARACTERS')   
  313. X  630 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,  
  314. X     +' IS IN COMMON AND IS NOT 6 CHARACTERS LONG') 
  315. X  640 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,  
  316. X     +' IS A VARIABLE WITH LENGTH >5')  
  317. X  650 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,  
  318. X     +' IS INTEGER BUT DOES NOT START I -> N')  
  319. X  660 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,  
  320. X     +' IS REAL BUT STARTS WITH I -> N')
  321. X  670 FORMAT(1X,'!!! WARNING ... VARIABLE ',A,  
  322. X     +' CLASHES WITH FORTRAN KEY-WORD ',A6) 
  323. X  680 FORMAT(1X,20('+'), ' END MODULE CHECKS            ',10('+'),  
  324. X     +/,1X,20(' '), ' FOR ',A,//)   
  325. X      END   
  326. /
  327. echo 'x - floppy.o'
  328. sed 's/^X//' > floppy.o << '/'
  329. 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
  330. P]PAYr]P]P]Ho XX{of]]p~AP~]P]P{odUP    o{~]P]P{o bUPoXm]P]PAPm]P]PAam]P]P{ow`]]ile  Tidied Fortran: E 99TATEMENTS,GOTO;UT,FULL,COMPRESS;GXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXX
  331. jXXXXXXXXXXXXXXX.46/
  332. echo 'x - floppy.rexx'
  333. sed 's/^X//' > floppy.rexx << '/'
  334. X/***********************************************************************/
  335. X/* FLOPPY exec                                                         */
  336. X/*                                                                     */
  337. X/* JJB May 1987                                                        */
  338. X/***********************************************************************/
  339. Xaddress 'COMMAND'
  340. Xsignal on novalue
  341. Xparse source . . execname .
  342. Xfnin = " "; ftin = "FORTRAN"; fmin = "A"
  343. Xfnold = ""; ftold = "FLOPIGN"; fmold = "A"
  344. Xtree = "NO"; checks = "STANDARD"; ignore = "NO"
  345. Xflopo = "YES"; full = "NO"; tidy = "NO"
  346. Xfntdy = "OUTPUT"; fttdy = "FORTRAN"; fmtdy = "A"
  347. Xgotos = "NO"; indent = "NO"; spaces = 3; groupf = "NO"
  348. Xrenums = "NO"; renumf = "NO"; startf = 500; stepf = 10
  349. Xstarts = 10; steps = 10
  350. Xoptset = "CHECKS IGNORE TREE DISK FULL GOTOS INDENT GROUPF"
  351. Xoptset = optset "RENUMF RENUMS OLD OUTPUT TIDY"
  352. Xsngset = "TREE DISK FULL GOTOS GROUPF IGNORE TIDY"
  353. Xerr = "Name of source Fortran file not yet given."
  354. Xcursor = "0001"
  355. Xinteractive = "YES"
  356. Xparse upper arg input
  357. Xparse value input with filename '(' options
  358. Xxx = 'XPARSE'(filename,'A')
  359. X/***********************/
  360. X/* LINE MODE TREATMENT */
  361. X/***********************/
  362. Xif A.0 ^= 0 then do
  363. X   interactive = "NO"
  364. X   if A.1 = "?" then do; ADDRESS CMS 'HELP 'execname; signal EXIT; end
  365. X   fnin = A.1
  366. X   if A.0 > 1 then ftin = A.2
  367. X   if A.0 > 2 then fmin = A.3
  368. X   if A.0 > 3 then do
  369. X      err = "Too many parameters given :" A.4
  370. X      signal EXIT
  371. X   end
  372. X   nopts = words(options)
  373. X   iopt = 0 ; err = " " ; flopo = "NO"
  374. X   do forever
  375. X      iopt = iopt + 1 ; if iopt > nopts then leave
  376. X      if find(optset,word(options,iopt))= 0 then do
  377. X         err = "Unidentified option on command line: "word(options,iopt)
  378. X         signal EXIT
  379. X      end
  380. X      if find(sngset,word(options,iopt)) ^= 0 then do
  381. X         interpret word(options,iopt)||'="YES"'
  382. X         if abbrev(word(options,iopt),"DISK",4) then flopo = "YES"
  383. X         iterate
  384. X      end
  385. X      if iopt < nopts then do
  386. X         key = word(options,iopt) ; val = word(options,iopt+1)
  387. X         if abbrev(key,"OLD",3) then do
  388. X            if iopt + 3 > nopts then do
  389. X               err = "Specify full file name for OLD file."
  390. X               signal EXIT
  391. X            end
  392. X            fnold = val
  393. X            ftold = word(options,iopt+2)
  394. X            fmold = word(options,iopt+3)
  395. X            iopt = iopt + 2
  396. X         end
  397. X         if abbrev(key,"OUT",3) then do
  398. X            if iopt + 3 > nopts then do
  399. X               err = "Specify full file name for OUTPUT file."
  400. X               signal EXIT
  401. X            end
  402. X            fntdy = val
  403. X            fttdy = word(options,iopt+2)
  404. X            fmtdy = word(options,iopt+3)
  405. X            iopt = iopt + 2
  406. X         end
  407. X         if abbrev(key,"CHEC",4) then checks = val
  408. X         if abbrev(key,"INDE",4) then do
  409. X            spaces = val
  410. X            indent = "YES"
  411. X         end
  412. X         if abbrev(key,"RENUMF",6) then do
  413. X            /* renumber FORMAT statements. Get the step and start. */
  414. X            ipos = pos(",",val,1)
  415. X            if ipos = 0 then startf = val
  416. X            else do
  417. X               startf = substr(val,1,ipos-1)
  418. X               stepf  = substr(val,ipos+1)
  419. X            end
  420. X            renumf = "YES"
  421. X         end
  422. X         if abbrev(key,"RENUMS",6) then do
  423. X            /* renumber other statements. Get the step and start. */
  424. X            ipos = pos(",",val,1)
  425. X            if ipos = 0 then starts = val
  426. X            else do
  427. X               starts = substr(val,1,ipos-1)
  428. X               steps  = substr(val,ipos+1)
  429. X            end
  430. X            renums = "YES"
  431. X         end
  432. X         iopt = iopt + 1
  433. X         iterate
  434. X      end
  435. X      if iopt = nopts then do
  436. X         err = 'Missing value for option 'word(options,iopt)
  437. X         signal EXIT
  438. X      end
  439. X   end
  440. Xend
  441. X/****************/
  442. X/* GENERAL MODE */
  443. X/****************/
  444. XSTART:
  445. Xif interactive = "NO" then signal CHECK
  446. Xif ^'QCONSOLE'('GRAPHIC') then do
  447. X   err = 'Not a full screen device'
  448. X   signal EXIT
  449. Xend
  450. Xdo forever
  451. X   signal off error
  452. X   'IOS3270' execname 'PANEL ;PANEL1 (CLEAR 'cursor
  453. X/* signal on error    ios3270 gives codes that aren't errors...*/
  454. X   if IOSK = 'PF03' then do; err = ' '; signal EXIT; end
  455. X   if IOSK = 'PF02' then do
  456. X      say "Enter the CMS command :"
  457. X      parse pull command
  458. X      signal off error; ADDRESS CMS command; signal on error
  459. X      say "Continue with "execname" ? [CR=YES]"
  460. X      parse upper pull answer
  461. X      if abbrev(answer,"N",1) then signal EXIT
  462. X      iterate
  463. X   end
  464. X   if IOSK = 'PF01' then do
  465. X      /* extract cursor position and find appropriate part of help */
  466. X      row = substr(IOSC,1,2) ; col = substr(IOSC,3,2)
  467. X      cursor = IOSC
  468. X      if row = 5 then do
  469. X         push 'FIND FLOPPY'
  470. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  471. X         iterate
  472. X      end
  473. X      if row = 7 then do
  474. X         push 'FIND OLD'
  475. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  476. X         iterate
  477. X      end
  478. X      if row = 8 then do
  479. X         push 'FIND CHECKS'
  480. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  481. X         iterate
  482. X      end
  483. X      if row = 9 then do
  484. X         push 'FIND IGNORE'
  485. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  486. X         iterate
  487. X      end
  488. X      if row = 11 then do
  489. X         push 'FIND TREE'
  490. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  491. X         iterate
  492. X      end
  493. X      if row = 13 then do
  494. X         push 'FIND DISK'
  495. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  496. X         iterate
  497. X      end
  498. X      if row = 14 then do
  499. X         push 'FIND FULL'
  500. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  501. X         iterate
  502. X      end
  503. X      if row = 16 & col > 40 then do
  504. X         push 'FIND OUTPUT'
  505. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  506. X         iterate
  507. X      end
  508. X      if row = 16 & col < 41 then do
  509. X         push 'FIND FLOPPY'
  510. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  511. X         iterate
  512. X      end
  513. X      if row = 17 then do
  514. X         push 'FIND GOTOS'
  515. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  516. X         iterate
  517. X      end
  518. X      if row = 18 then do
  519. X         push 'FIND INDENT'
  520. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  521. X         iterate
  522. X      end
  523. X      if row = 19 then do
  524. X         push 'FIND GROUPF'
  525. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  526. X         iterate
  527. X      end
  528. X      if row = 20 | row = 21 then do
  529. X         push 'FIND RENUMF'
  530. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  531. X         iterate
  532. X      end
  533. X      if row = 22 | row = 23 then do
  534. X         push 'FIND RENUMS'
  535. X         ADDRESS CMS 'XEDIT 'execname' HELPCMS'
  536. X         iterate
  537. X      end
  538. X      ADDRESS CMS 'HELP 'execname
  539. X   end
  540. X   leave
  541. Xend
  542. XCHECK:
  543. Xerr = ' '
  544. Xupper fnin ftin fmin fntdy fttdy fmtdy fnold ftold fmold
  545. Xupper tree checks ignore flopo full tidy gotos
  546. Xupper indent renums renumf groupf
  547. Xif ^'FEXIST'(fnin ftin fmin) then do
  548. X   err = "Input FORTRAN file does not exist."
  549. X   cursor = "0001"
  550. X   if interactive = "YES" then signal START
  551. X   signal EXIT
  552. Xend
  553. Xif 'QFILE'(fnin ftin fmin,"RECFM") ^= "F" then do
  554. X   err = "Input FORTRAN file is RECFM V. Change to RECFM F please."
  555. X   cursor = "0001"
  556. X   if interactive = "YES" then signal START
  557. X   signal EXIT
  558. Xend
  559. Xif ^'FEXIST'(fnold ftold fmold) & LENGTH(fnold) ^= 0 then do
  560. X   err = "FLOPPY parameter file does not exist."
  561. X   cursor = "0004"
  562. X   if interactive = "YES" then signal START
  563. X   signal EXIT
  564. Xend
  565. Xchecks = strip(checks)
  566. Xif words(checks) ^= 1 then do
  567. X   err = "Use a single Checks keyword, or separate numbers with commas"
  568. X   cursor = "0007"
  569. X   if interactive = "YES" then signal START
  570. X   signal EXIT
  571. Xend
  572. Xif find("STANDARD ALEPH GALEPH ONLINE NONE LIST",checks) = 0 then do
  573. X   if ^datatype(checks,'N') then do
  574. X      if index(checks,',') = 0 then do
  575. X         err = "Must be list of numbers or keyword. See HELP file."
  576. X         cursor = "0007"
  577. X         if interactive = "YES" then signal START
  578. X         signal EXIT
  579. X      end
  580. X      else do
  581. X         ipos = 1
  582. X         do until ipos > length(checks)
  583. X            ipose = index(checks,',',ipos) - 1
  584. X            if ipose = -1 then ipose = length(checks)
  585. X            num = substr(checks,ipos,ipose-ipos+1)
  586. X            if ^datatype(num,"N") then do
  587. X                err = "Invalid integer "num" in list of checks."
  588. X                cursor = "0007"
  589. X                if interactive = "YES" then signal START
  590. X                signal EXIT
  591. X            end
  592. X            ipos = ipose + 2
  593. X         end
  594. X      end
  595. X   end
  596. Xend
  597. Xset1 = "N"
  598. Xif abbrev(gotos,"Y",1) | abbrev(indent,"Y",1) ,
  599. X     | abbrev(groupf,"Y",1) | abbrev(renumf,"Y",1),
  600. X     | abbrev(renumf,"Y",1) then set1 = "Y"
  601. Xif set1 = "Y" then tidy = "Y"
  602. Xif set1 = "N" & abbrev(tidy,"Y",1) then do
  603. X   err = "Specify how you want to tidy the code."
  604. X   cursor = "0012"
  605. X   if interactive = "YES" then signal START
  606. X   signal EXIT
  607. Xend
  608. Xif abbrev(tidy,"Y",1) then do
  609. X   if fntdy = " " then do
  610. X      err = "Specify the name of the output FORTRAN file."
  611. X      cursor = "0013"
  612. X      if interactive = "YES" then signal START
  613. X      signal EXIT
  614. X   end
  615. X   if fttdy = " " then do
  616. X      err = "Specify the name of the output FORTRAN file."
  617. X      cursor = "0014"
  618. X      if interactive = "YES" then signal START
  619. X      signal EXIT
  620. X   end
  621. X   if fnin||ftin||fmin = fntdy||fttdy||fmtdy then do
  622. X      err = "Output FORTRAN will overwrite input. Rename."
  623. X      cursor = "0013"
  624. X      if interactive = "YES" then signal START
  625. X      signal EXIT
  626. X   end
  627. X   if abbrev(indent,"Y",1) & ^datatype(spaces,"N") then do
  628. X      err = "Number of spaces to indent must be an integer."
  629. X      cursor = "0018"
  630. X      if interactive = "YES" then signal START
  631. X      signal EXIT
  632. X   end
  633. X   if abbrev(indent,"Y",1) & ( spaces>5 | spaces<1 ) then do
  634. X      err = "Number of spaces must be between 1 and 5 for indent."
  635. X      cursor = "0018"
  636. X      if interactive = "YES" then signal START
  637. X      signal EXIT
  638. X   end
  639. X   if abbrev(renumf,"Y",1) then do
  640. X      if ^datatype(startf,"N") then do
  641. X         err = "Statement number must be numeric."
  642. X         cursor = "0021"
  643. X         if interactive = "YES" then signal START
  644. X         signal EXIT
  645. X      end
  646. X      if ^datatype(stepf,"N") then do
  647. X         err = "Statement number step must be numeric."
  648. X         cursor = "0022"
  649. X         if interactive = "YES" then signal START
  650. X         signal EXIT
  651. X      end
  652. X   end
  653. X   if abbrev(renumf,"Y",1) then do
  654. X      if ^datatype(starts,"N") then do
  655. X         err = "Statement number must be numeric."
  656. X         cursor = "0024"
  657. X         if interactive = "YES" then signal START
  658. X         signal EXIT
  659. X      end
  660. X      if ^datatype(steps,"N") then do
  661. X         err = "Statement number step must be numeric."
  662. X         cursor = "0025"
  663. X         if interactive = "YES" then signal START
  664. X         signal EXIT
  665. X      end
  666. X   end
  667. Xend
  668. Xif ^abbrev(flopo,"N",1) & ^abbrev(flopo,"Y",1) then do
  669. X   err = "FLOPPY output to disk: give Yes or No."
  670. X   cursor = "0010"
  671. X   if interactive = "YES" then signal START
  672. X   signal EXIT
  673. Xend
  674. Xif ^abbrev(tree,"N",1) & ^abbrev(tree,"Y",1) then do
  675. X   err = "TREE output from FLOPPY: give Yes or No."
  676. X   cursor = "0009"
  677. X   if interactive = "YES" then signal START
  678. X   signal EXIT
  679. Xend
  680. Xif ^abbrev(full,"N",1) & ^abbrev(full,"Y",1) then do
  681. X   err = "Full source listing from FLOPPY: give Yes or No."
  682. X   cursor = "0011"
  683. X   if interactive = "YES" then signal START
  684. X   signal EXIT
  685. Xend
  686. Xif ^abbrev(ignore,"N",1) & ^abbrev(ignore,"Y",1) then do
  687. X   err = "List of ignore names for FLOPPY: give Yes or No."
  688. X   cursor = "0008"
  689. X   if interactive = "YES" then signal START
  690. X   signal EXIT
  691. Xend
  692. X/* Now write the necessary input files */
  693. Xoldflag = length(fnold)
  694. Xif oldflag ^= 0 then file = fnold' TEMP$T A'
  695. Xif oldflag  = 0 then do
  696. X   file = fnin' FLOPIGN A'
  697. X   if 'FEXIST'(file) then 'ERASE 'file /* erase unwanted ignore file */
  698. Xend
  699. Xexw = 'EXECIO 1 DISKW 'file' (STRING '
  700. Xexw" "
  701. Xif abbrev(full,'Y',1) then exw"*FULL"
  702. Xif abbrev(checks,'ALEP',1) & oldflag = 0 then exw"*ALEPH"
  703. Xif abbrev(ignore,"Y",1) then do
  704. X    say "You must now enter a list of the names FLOPPY is to ignore"
  705. X    /* push terminal control characters before reading names */
  706. X    cpus= "CPUSH"("TERM")
  707. X    "CP TERM CHARDEL OFF"
  708. X    "CP TERM LINEDEL OFF"
  709. X    "CP TERM LINEND  OFF"
  710. X    "CP TERM ESCAPE  OFF"
  711. X    "CP TERM TABCHAR OFF"
  712. X    say "Names to ignore ..... "
  713. X    say " eg to ignore variable NUMGEN enter NUMGEN "
  714. X    say "    to ignore subroutine FRED enter #FRED "
  715. X    say " "
  716. X    n = 0
  717. X    do forever
  718. X       say "Enter name to ignore [CR=no more]"
  719. X       parse upper pull name
  720. X       if name = "" then leave
  721. X       n = n + 1
  722. X       exw name
  723. X    end
  724. X    /* restore control characters                            */
  725. X    cpo = "CPOP"("TERM")
  726. Xend
  727. Xif abbrev("LIST",checks,1) then do
  728. X   say 'Enter the long list of rule numbers to be checked.'
  729. X   say 'Separate each rule by a comma (,)'
  730. X   parse upper pull checks
  731. Xend
  732. Xif find("STANDARD ALEPH GALEPH ONLINE NONE LIST",checks) = 0 then do
  733. X   if ^datatype(checks,'N') then do
  734. X      ipos = 1
  735. X      do until ipos > length(checks)
  736. X         ipose = index(checks,',',ipos) - 1
  737. X         if ipose = -1 then ipose = length(checks)
  738. X         num = substr(checks,ipos,ipose-ipos+1)
  739. X         if length(num) = 1 then num = "  "||num
  740. X         if length(num) = 2 then num = " "||num
  741. X         if datatype(num,"N") then exw"*CHECK RULE "num
  742. X         ipos = ipose + 2
  743. X      end
  744. X   end
  745. X   else do
  746. X      if length(checks) = 1 then checks = " "||checks
  747. X      exw"*CHECK RULE  "checks
  748. X   end
  749. Xend
  750. Xelse do
  751. X   if abbrev("STANDARD",checks,1) & oldflag = 0 then exw"*CHECK RULE *"
  752. X   if abbrev("ALEPH",checks,1) & oldflag = 0 then exw"*ALEPH"
  753. X   if abbrev("GALEPH",checks,1) & oldflag = 0 then exw"*ALEPH"
  754. X   if abbrev("GALEPH",checks,1) & oldflag = 0 then exw"*GALEPH"
  755. X   if abbrev("NONE",checks,1) then exw"*CHECK RULE -99"
  756. Xend
  757. X'FINIS 'file
  758. Xif fnold ^= " " then do
  759. X   'COPYFILE 'fnold ftold fmold' = = A (REPLACE'
  760. X   'COPYFILE 'file fnold ftold' A (APPEND'
  761. X   'ERASE 'file
  762. Xend
  763. Xelse fnold = fnin
  764. X/* Now the FLOP (not FLOPPY) input data */
  765. Xfile = 'FLOPPY TEMP$T A'
  766. Xif 'FEXIST'(file) then 'ERASE 'file
  767. Xexw = 'EXECIO 1 DISKW 'file' (STRING '
  768. Xif abbrev(tidy,"Y",1)   then exw"OUTPUT,FULL,COMPRESS;"
  769. Xif abbrev(tree,"Y",1)   then exw"OPTIONS,TREE;"
  770. Xif abbrev(gotos,"Y",1)  then exw"STATEMENTS,GOTO;"
  771. Xif abbrev(groupf,"Y",1) then exw"STATEMENTS,SEPARATE;"
  772. Xif abbrev(indent,"Y",1) then exw"OPTIONS,INDENT="spaces";"
  773. Xif abbrev(renumf,"Y",1) then exw"STATEMENTS,FORMAT="startf","stepf";"
  774. Xif abbrev(renums,"Y",1) then exw"STATEMENTS,NUMBER="starts","steps";"
  775. X/* default cards for FLOP */
  776. Xexw"LIST,GLOBAL,TYPE;"
  777. Xexw"PRINT,ILLEGAL;"
  778. Xexw"OPTIONS,USER;"
  779. Xexw"END;"
  780. X'FINIS 'file
  781. X'COPYFILE 'file' = = = (RECFM F LRECL 80 REPLACE'
  782. X'COPYFILE 'fnold ftold fmold' = = = (RECFM F LRECL 80 REPLACE'
  783. X/* Now assign the FILEDEFs */
  784. X'MAKEBUF'
  785. Xbufno = rc
  786. X'SENTRIES'
  787. Xentries = rc
  788. X'QFILEDEF ( STACK'
  789. Xpull dummy
  790. Xnum_fdefs = 0
  791. Xdo queued()-entries
  792. X   num_fdefs = num_fdefs + 1
  793. X   pull fdef.num_fdefs
  794. Xend
  795. X'DROPBUF 'bufno
  796. X'FILEDEF 5 CLEAR'
  797. X'FILEDEF 6 CLEAR'
  798. X'FILEDEF 11 CLEAR'
  799. X'FILEDEF 13 CLEAR'
  800. X'FILEDEF 14 CLEAR'
  801. X'FILEDEF 15 CLEAR'
  802. X'FILEDEF 50 CLEAR'
  803. X'FILEDEF 99 CLEAR'
  804. X'FILEDEF 5 DISK 'file
  805. X'FILEDEF 11 DISK 'fnin ftin fmin
  806. X'FILEDEF 15 DISK 'fnold ftold fmold
  807. X'FILEDEF 99 DISK FLOPPY SCRATCH A (RECFM F LRECL 132'
  808. Xif abbrev(tidy,"Y",1) then do
  809. X  say 'Tidied FORTRAN output will be called 'fntdy fttdy fmtdy
  810. X  'FILEDEF 14 DISK 'fntdy fttdy fmtdy '(LRECL 80 RECFM F'
  811. Xend
  812. Xif abbrev(flopo,"Y",1) then do
  813. X  say 'FLOPPY listing file will be called 'fnin 'FLOPLIS A'
  814. X  'FILEDEF 6 DISK 'fnin' FLOPLIS A (LRECL 132 RECFM F'
  815. Xend
  816. Xelse 'FILEDEF 6 TERMINAL (LRECL 132 PERM'
  817. Xif abbrev(tree,"Y",1) then do
  818. X  say 'FLOPPY output for TREE will be called 'fnin 'FLOPTRE A'
  819. X  'FILEDEF 13 DISK 'fnin' TEMPTRE A (LRECL 8000 RECFM VS'
  820. X  'FILEDEF 50 DISK 'fnin' FLOPTRE A (LRECL 8000 RECFM VS'
  821. Xend
  822. Xsay 'FLOPPY begins .... '
  823. X/* MONITOR USAGE */
  824. Xlogline = 'Fn 'fnin' Che 'checks,
  825. X          'Tre' substr(tree,1,1),
  826. X          'Ign' substr(ignore,1,1),
  827. X          'Out' substr(flopo,1,1),
  828. X          'Ful' substr(full,1,1),
  829. X          'Tid' substr(tidy,1,1),
  830. X          'Got' substr(gotos,1,1),
  831. X          'Ind' indent,
  832. X          'Rns' substr(renums,1,1),
  833. X          'Rnf' substr(renumf,1,1),
  834. X          'Grf' substr(groupf,1,1)
  835. Xlogline = substr(logline,1,80)
  836. X'EXEC LOGUSAGE FLOPPY 'logline
  837. X/* RUN FLOPPY */
  838. X'EXEC CERNLIB'
  839. X'FLOPPY$M'
  840. X'EXEC LOGUSAGE FLOPPY Successful completion'
  841. X/* Reinstate original FILEDEFs */
  842. X'FILEDEF 5 CLEAR'
  843. X'FILEDEF 6 CLEAR'
  844. X'FILEDEF 11 CLEAR'
  845. X'FILEDEF 13 CLEAR'
  846. X'FILEDEF 14 CLEAR'
  847. X'FILEDEF 15 CLEAR'
  848. X'FILEDEF 50 CLEAR'
  849. X'FILEDEF 99 CLEAR'
  850. Xdo i = 1 to num_fdefs
  851. X   fdef.i
  852. Xend
  853. X/* Erase unwanted files */
  854. Xif 'FEXIST'('FLOPPY SCRATCH A') then 'ERASE FLOPPY SCRATCH A'
  855. Xif 'FEXIST'(file) then 'ERASE 'file
  856. Xsay 'FLOPPY has finished'
  857. Xcall EXIT
  858. XNOVALUE:
  859. Xsay 'Uninitialised variable encountered on line' sigl
  860. Xcall EXIT
  861. XERROR:
  862. Xsay 'Error on line' sigl
  863. Xcall EXIT
  864. XEXIT:
  865. Xif err ^= " " then say execname ": " err
  866. Xexit
  867. /
  868. echo 'Part 03 of Floppy complete.'
  869. exit
  870.  
  871.  
  872.