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

  1. Newsgroups: comp.sources.misc
  2. organization: CERN, Geneva, Switzerland
  3. keywords: fortran
  4. subject: v12i091: Floppy - Fortran Coding Convention Checker Part 05/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 91
  9. Submitted-by: julian@cernvax.cern.ch (julian bunn)
  10. Archive-name: ffccc/part05
  11.  
  12. #!/bin/sh
  13. echo 'Start of Floppy, part 05 of 11:'
  14. echo 'x - PROCES.f'
  15. sed 's/^X//' > PROCES.f << '/'
  16. X      SUBROUTINE PROCES 
  17. X*-----------------------------------------------------------------------
  18. X*   
  19. X*   Processes one routine statement by statement:   
  20. X*   filtering, replacements 
  21. X*   
  22. X*-----------------------------------------------------------------------
  23. X      include 'PARAM.h' 
  24. X      include 'ALCAZA.h' 
  25. X      include 'CLASS.h' 
  26. X      include 'FLAGS.h' 
  27. X      include 'CURSTA.h' 
  28. X      include 'STATE.h' 
  29. X      include 'JOBSUM.h' 
  30. X      LOGICAL SAMEST
  31. X*--- treat routine header and init  
  32. X      CALL RSTART   
  33. X*--- TREE preparation if no proper header   
  34. X      IF(ACTION(29).AND.SCROUT.EQ.'NOHEADER')  CALL TREEST(0)   
  35. X*--- user top of routine
  36. X      IF(ACTION(22))  CALL URINIT   
  37. X    
  38. X*--- NP controls the number of blank lines for print headers
  39. X      NP=0  
  40. X*--- process only if routine selected   
  41. X      IF (STATUS(7))  THEN  
  42. X*--- loop over all statements in routine
  43. X         DO 60 IST=1,NSTAMM 
  44. X            STATUS(8)=.TRUE.
  45. X            STATUS(10)=.TRUE.   
  46. X            STATUS(11)=.FALSE.  
  47. X            IF (ICLASS(IST,1).GT.0)  THEN   
  48. X*--- extract and set classes
  49. X               CALL EXTRAC(IST,'FULL')  
  50. X               ICURCL(1)=ICLASS(IST,1)  
  51. X               ICURCL(2)=ICLASS(IST,2)  
  52. X               IF (ICURCL(1).EQ.ILL) NFDCLS(ILL,1)=NFDCLS(ILL,1)+1  
  53. X            ENDIF   
  54. X            IF (ICLASS(IST,1).EQ.ILL.AND.ACTION(3))  THEN   
  55. X               IF (STATUS(9))  THEN 
  56. X                  STATUS(9)=.FALSE. 
  57. X                  IF (ACTION(6))  THEN  
  58. X                     WRITE (MPUNIT,10000) 'all',SCROUT  
  59. X                  ELSE  
  60. X                     WRITE (MPUNIT,10000) 'selected',SCROUT 
  61. X                  ENDIF 
  62. X               ENDIF
  63. X               STATUS(10)=.FALSE.   
  64. X               CALL FLPRNT(1,'illegal',NLLINE(IST)-NFLINE(IST)+1,SIMA(  
  65. X     +         NFLINE(IST)),NSTATC(8))  
  66. X               NP=1 
  67. X*--- print all if requested 
  68. X            ELSEIF (ACTION(6))  THEN
  69. X*--- routine header 
  70. X               IF (STATUS(9))  THEN 
  71. X                  STATUS(9)=.FALSE. 
  72. X                  WRITE (MPUNIT,10000) 'all',SCROUT 
  73. X               ENDIF
  74. X               STATUS(10)=.FALSE.   
  75. X               CALL FLPRNT(NP,' ',NLLINE(IST)-NFLINE(IST)+1,SIMA(NFLINE(
  76. X     +         IST)),NSTATC(8)) 
  77. X               NP=0 
  78. X            ENDIF   
  79. X*--- call user routine for ALL statements   
  80. X            IF(ACTION(22))  CALL USSALL 
  81. X*--- process only legal FORTRAN statements  
  82. X            IF (ICLASS(IST,1).GT.0.AND.ICLASS(IST,1).NE.ILL)  THEN  
  83. X*--- get statement number   
  84. X               SNEWST(1)(1:6)=SIMA(NFLINE(IST))(1:6)
  85. X*--- filter for classes 
  86. X               IF (ACTION(17)) CALL FILTER(13,8)
  87. X               IF (STATUS(8))  THEN 
  88. X*--- get statement names
  89. X                  ISNAME=IRNAME+NRNAME  
  90. X                  CALL GETALL   
  91. X*--- filter for names   
  92. X                  IF (ACTION(18)) CALL FILTER(11,8) 
  93. X                  IF (STATUS(8))  THEN  
  94. X*--- filter for strings 
  95. X                     IF (ACTION(19)) CALL FILTER(12,8)  
  96. X                     IF (STATUS(8))  THEN   
  97. X*--- all filters passed - update statistics 
  98. X                        IMODIF(IST)=1   
  99. X                        NSTATC(4)=NSTATC(4)+1   
  100. X                        NFDCLS(ICURCL(1),1)=NFDCLS(ICURCL(1),1)+1   
  101. X                        IF (ICURCL(1).EQ.IIF) NFDCLS(ICURCL(2),2)=NFDCLS
  102. X     +                  (ICURCL(2),2)+1 
  103. X*--- user start of statement
  104. X                        IF(ACTION(22))  CALL USSBEG 
  105. X*--- prepare indentation if requested   
  106. X                        IF(ACTION(21))  CALL PROIND 
  107. X*----get type for variables 
  108. X                        IF (ACTION(20)) CALL SETTYP(1)  
  109. X*--- check for incorrect relational operators in character type 
  110. X                        CALL CHKCHR 
  111. X*--- treat names further if any 
  112. X                        IF(NSNAME.GT.0)  THEN   
  113. X*--- prepare TREE output
  114. X                           IF(ACTION(29))  CALL TREEST(1)   
  115. X*--- find used and unused common blocks 
  116. X                           IF(ACTION(24).AND..NOT.STATUS(12))   
  117. X     +                     CALL PROCOM  
  118. X*--- perform name replacements  
  119. X                           IF (ACTION(15)) CALL REPNAM  
  120. X                           IF (STATUS(11)) GOTO 10  
  121. X                           IF (ACTION(1).OR.ACTION(2))  THEN
  122. X*--- add names to routine name list 
  123. X                              CALL LSORT(SNAMES(ISNAME+1),  
  124. X     +                        NAMTYP(ISNAME+1),.TRUE.,NSNAME)   
  125. X                              CALL LMERGE(SNAMES,NAMTYP,.TRUE.,IRNAME,  
  126. X     +                        NRNAME,NSNAME)
  127. X                              CALL SUPMOR(SNAMES,NAMTYP,.TRUE.,IRNAME,  
  128. X     +                        NRNAME+NSNAME,NRNAME) 
  129. X                           ENDIF
  130. X                        ENDIF   
  131. X                        IF (ACTION(5).AND.STATUS(10))  THEN 
  132. X*--- print filtered 
  133. X                           IF (STATUS(9))  THEN 
  134. X                              WRITE (MPUNIT,10000) 'filtered',SCROUT
  135. X                              STATUS(9)=.FALSE. 
  136. X                           ENDIF
  137. X                           STATUS(10)=.FALSE.   
  138. X                           CALL FLPRNT(NP,' ',NLLINE(IST)-NFLINE(IST)+1,
  139. X     +                     SIMA(NFLINE(IST)),NSTATC(8)) 
  140. X                           NP=0 
  141. X                        ENDIF   
  142. X                        IF (ACTION(11).OR.ACTION(12)) THEN  
  143. X*--- remove {} , change holl. to quotes if requested
  144. X                           CALL QUOSUB  
  145. X                           IF (STATUS(11)) GOTO 10  
  146. X*--- string replacement 
  147. X                           IF(ACTION(12))  CALL REPSTR  
  148. X                           IF (STATUS(11)) GOTO 10  
  149. X*--- re-insert {} around strings for REFORM 
  150. X                           CALL MARKST('FULL',IERR) 
  151. X                           STATUS(11)=IERR.NE.0 
  152. X                           IF (STATUS(11)) GOTO 10  
  153. X                        ENDIF   
  154. X*--- re-numbering if requested  
  155. X                        IF (ACTION(13)) CALL RENUMB 
  156. X*--- user end of statement  
  157. X                        IF(ACTION(22))  CALL USSEND 
  158. X                     ENDIF  
  159. X                  ENDIF 
  160. X               ENDIF
  161. X*--- here you arrive without filter checks  
  162. X   10          CONTINUE 
  163. X               IFILTR=0 
  164. X               IF (STATUS(11)) IMODIF(IST)=MOD(IMODIF(IST),10)  
  165. X*--- reformat = put modified statement into SIMA
  166. X               IF (IMODIF(IST).GT.10.OR.ACTION(21).AND.IMODIF(IST).GT.0)
  167. X     +         THEN 
  168. X                  CALL REFORM   
  169. X*--- not changed if REFORM problem, or identical after REFORM   
  170. X                  IF (STATUS(11).OR.SAMEST(IST))
  171. X     +            IMODIF(IST)=MOD(IMODIF(IST),10)   
  172. X               ENDIF
  173. X               IF (IMODIF(IST).GT.10)  THEN 
  174. X*--- count changed statements   
  175. X                  NSTATC(5)=NSTATC(5)+1 
  176. X                  IF (ACTION(4).AND.STATUS(10))  THEN   
  177. X*--- print changed statements   
  178. X                     IF (STATUS(9))  THEN   
  179. X                        WRITE (MPUNIT,10000) 'changed',SCROUT   
  180. X                        STATUS(9)=.FALSE.   
  181. X                     ENDIF  
  182. X                     CALL FLPRNT(1,' ',NLLINE(IST)-NFLINE(IST)+1,SIMA(  
  183. X     +               NFLINE(IST)),NSTATC(8))
  184. X                  ENDIF 
  185. X*--- re-formatted statement in SNEWST   
  186. X*   put into SIMA, push SIMA if new longer than old, introduce blank
  187. X*   lines if new shorter than old   
  188. X                  N=0   
  189. X                  DO 20 I=NFLINE(IST),NLLINE(IST)   
  190. X                     IF (NLTYPE(I).NE.0)  THEN  
  191. X                        N=N+1   
  192. X                        IF (N.GT.NEWOUT)  THEN  
  193. X                           SIMA(I)=' '  
  194. X                        ELSE
  195. X                           SIMA(I)=SNEWST(N)
  196. X                        ENDIF   
  197. X                     ENDIF  
  198. X   20             CONTINUE  
  199. X                  NPUSH=NEWOUT-N
  200. X                  IF (NPUSH.GT.0)  THEN 
  201. X                     DO 30 I=NLINES,NLLINE(IST)+1,-1
  202. X                        NLTYPE(I+NPUSH)=NLTYPE(I)   
  203. X                        SIMA(I+NPUSH)=SIMA(I)   
  204. X   30                CONTINUE   
  205. X                     NLINES=NLINES+NPUSH
  206. X*---  loop over all statements since they might be in a different order 
  207. X                     DO 40 I=1,NSTAMM   
  208. X                        IF(NFLINE(I).GT.NFLINE(IST)) THEN   
  209. X                           NFLINE(I)=NFLINE(I)+NPUSH
  210. X                           NLLINE(I)=NLLINE(I)+NPUSH
  211. X                        ENDIF   
  212. X   40                CONTINUE   
  213. X                     DO 50 I=1,NPUSH
  214. X                        SIMA(NLLINE(IST)+I)=SNEWST(N+I) 
  215. X   50                CONTINUE   
  216. X                     NLLINE(IST)=NLLINE(IST)+NPUSH  
  217. X                  ENDIF 
  218. X                  IF (ACTION(4))  THEN  
  219. X                     CALL FLPRNT(0,'changed to',NLLINE(IST)-NFLINE(IST)+
  220. X     +               1,SIMA(NFLINE(IST)),NDUMMY)
  221. X                     NP=1   
  222. X                  ENDIF 
  223. X               ENDIF
  224. X            ENDIF   
  225. X   60    CONTINUE   
  226. X      ENDIF 
  227. X*--- user end of routine
  228. X      IF(ACTION(22))  CALL URTERM   
  229. X*--- TREE output if any 
  230. X      IF(ACTION(29))  CALL TREESU   
  231. X10000 FORMAT(/1X,20('++++'),A10,' statements, routine =',A10)   
  232. X  999 END   
  233. /
  234. echo 'x - PROCOM.f'
  235. sed 's/^X//' > PROCOM.f << '/'
  236. X      SUBROUTINE PROCOM 
  237. X*-----------------------------------------------------------------------
  238. X*   
  239. X*   Processes common blocks: collects name lists,   
  240. X*   marks the variables referenced in each routine  
  241. X*   
  242. X*-----------------------------------------------------------------------
  243. X      include 'PARAM.h' 
  244. X      include 'ALCAZA.h' 
  245. X      include 'CLASS.h' 
  246. X      include 'FLAGS.h' 
  247. X      include 'CURSTA.h' 
  248. X      include 'FLWORK.h' 
  249. X      include 'STATE.h' 
  250. X      LOGICAL RANGE 
  251. X      CHARACTER SCB*8   
  252. X*--- get external statement number  
  253. X      ICLE=ISTMDS(6,ICURCL(1))  
  254. X      IF(ICLE.EQ.12)  THEN  
  255. X*--- common block   
  256. X         IV=0   
  257. X         ICOMMB=ISTMDS(17,ICURCL(1))
  258. X         ICOMMV=ISTMDS(21,ICURCL(1))
  259. X   10    CONTINUE   
  260. X*--- find c.b. name, and first and last variable in this c.b.   
  261. X         IF(ITBIT(NAMTYP(ISNAME+IV+1),ICOMMB).EQ.0) THEN
  262. X*--- first name not c.b. name ---> blank common 
  263. X            SCB='BLANKCOM'  
  264. X         ELSE   
  265. X            SCB=SNAMES(ISNAME+IV+1) 
  266. X            IV=IV+1 
  267. X         ENDIF  
  268. X*--- last var. in this c.b. is min. pos. of '//', or c.b. name  
  269. X         IPT=NSSTRT(IV+1)-1 
  270. X         INS=INDEX(SSTA(IPT+1:NCHST),'//')  
  271. X         IND=INDEX(SSTA(IPT+1:NCHST),'/ /') 
  272. X         IF(IND.GT.0) THEN  
  273. X            IF(INS.GT.0) THEN   
  274. X               INS=MIN(IND,INS) 
  275. X            ELSE
  276. X               INS=IND  
  277. X            ENDIF   
  278. X         ENDIF  
  279. X         IF(INS.GT.0) THEN  
  280. X            INS=IPT+INS 
  281. X         ELSE   
  282. X            INS=NCHST+1 
  283. X         ENDIF  
  284. X*--- collect variable name ref.s in IWS 
  285. X         N=0
  286. X         ILOW=IV+1  
  287. X         DO 20 I=ILOW,NSNAME
  288. X            K=ISNAME+I  
  289. X            NT=NAMTYP(K)
  290. X            IF(ITBIT(NT,ICOMMB).NE.0) GOTO 30   
  291. X            IF(NSSTRT(I).GT.INS) GOTO 30
  292. X            IF(ITBIT(NT,ICOMMV).NE.0) THEN  
  293. X               IF(NCBVAR+N.EQ.MXNAME) GOTO 180  
  294. X               N=N+1
  295. X               SCBVAR(NCBVAR+N)=SNAMES(K)   
  296. X            ENDIF   
  297. X            IV=I
  298. X   20    CONTINUE   
  299. X   30    CONTINUE   
  300. X*--- store in name list for this common block   
  301. X         IF(N.GT.0) THEN
  302. X            CALL LSORT(SCBVAR(NCBVAR+1),IWS,.FALSE.,N)  
  303. X*--- look for name in c.b. name table   
  304. X            CALL NAMSRC(SCB,SCBNAM,NCBNAM,IPOS,LAST)
  305. X            IF(IPOS.EQ.0) THEN  
  306. X*--- not in table - add to existing 
  307. X               IF(NCBNAM.EQ.MAXGRP) GOTO 190
  308. X               DO 40 I=NCBNAM,LAST+1,-1 
  309. X                  SCBNAM(I+1)=SCBNAM(I) 
  310. X                  NCBGRP(I+1)=NCBGRP(I) 
  311. X                  KCBGRP(I+1)=KCBGRP(I) 
  312. X   40          CONTINUE 
  313. X               NCBNAM=NCBNAM+1  
  314. X               SCBNAM(LAST+1)=SCB   
  315. X               NCBGRP(LAST+1)=N 
  316. X               KCBGRP(LAST+1)=NCBVAR
  317. X            ELSE
  318. X*--- already in table - add in place, and merge 
  319. X               CALL NAMOVE(SCBVAR,KCBGRP(IPOS)+NCBGRP(IPOS),NCBVAR,N)   
  320. X               CALL LMERGE(SCBVAR,IWS,.FALSE.,KCBGRP(IPOS),NCBGRP(IPOS),
  321. X     +         N)   
  322. X               DO 50 I=1,NCBNAM 
  323. X                  IF(KCBGRP(I).GT.KCBGRP(IPOS)) KCBGRP(I)=KCBGRP(I)+N   
  324. X   50          CONTINUE 
  325. X               DO 60 I=1,NEQNAM 
  326. X                  IF(KEQGRP(I).GT.KCBGRP(IPOS)) KEQGRP(I)=KEQGRP(I)+N   
  327. X   60          CONTINUE 
  328. X               NCBGRP(IPOS)=NCBGRP(IPOS)+N  
  329. X            ENDIF   
  330. X            NCBVAR=NCBVAR+N 
  331. X         ENDIF  
  332. X         IF(IV.LT.NSNAME) GOTO 10   
  333. X      ELSEIF(ICLE.EQ.30)  THEN  
  334. X*--- EQUIVALENCE
  335. X         IV=0   
  336. X         IPT=0  
  337. X   70    CONTINUE   
  338. X         ILB=INDEX(SSTA(IPT+1:NCHST),'(')   
  339. X         IF(ILB.GT.0) THEN  
  340. X            ILB=ILB+IPT 
  341. X            CALL SKIPLV(SSTA,ILB+1,NCHST,.FALSE.,IRB,ILEV)  
  342. X            IF(IRB.GT.0) THEN   
  343. X               IPT=IRB  
  344. X*--- only names outside brackets (inside each group)
  345. X               CALL GETRNG(ILB+1,IRB-1,IWS) 
  346. X               ILOW=IV+1
  347. X               N=0  
  348. X               DO 80 I=ILOW,NSNAME  
  349. X                  IF(NSSTRT(I).GT.IRB) GOTO 90  
  350. X                  IF(.NOT.RANGE(NSSTRT(I),IWS)) THEN
  351. X                     IF(NCBVAR+N.EQ.MXNAME) GOTO 180
  352. X                     N=N+1  
  353. X                     SCBVAR(NCBVAR+N)=SNAMES(ISNAME+I)  
  354. X                  ENDIF 
  355. X                  IV=I  
  356. X   80          CONTINUE 
  357. X   90          CONTINUE 
  358. X               IF(N.GT.0) THEN  
  359. X                  IF(NEQNAM.EQ.MAXGRP) GOTO 200 
  360. X                  CALL LSORT(SCBVAR(NCBVAR+1),IWS,.FALSE.,N)
  361. X                  NEQNAM=NEQNAM+1   
  362. X                  KEQGRP(NEQNAM)=NCBVAR 
  363. X                  NEQGRP(NEQNAM)=N  
  364. X                  NCBVAR=NCBVAR+N   
  365. X               ENDIF
  366. X               IF(IPT.LT.NCHST) GOTO 70 
  367. X            ENDIF   
  368. X         ENDIF  
  369. X      ELSEIF(ICLE.EQ.16.OR.ISTMDS(11,ICURCL(1)).EQ.1)  THEN 
  370. X*--- DATA statement, or executable, i.e. start of routine   
  371. X         IF(.NOT.STATUS(13)) THEN   
  372. X*--- merge all equiv. groups with common blocks 
  373. X            STATUS(13)=.TRUE.   
  374. X  100       CONTINUE
  375. X            DO 150 IE=1,NEQNAM  
  376. X               KEQ=KEQGRP(IE)   
  377. X               NEQ=NEQGRP(IE)   
  378. X               DO 140 IEI=1,NEQ 
  379. X                  DO 130 IC=1,NCBNAM
  380. X                     CALL NAMSRC(SCBVAR(KEQGRP(IE)+IEI),SCBVAR(KCBGRP   
  381. X     +               (IC)+1), NCBGRP(IC),IPOS,LAST) 
  382. X                     IF(IPOS.NE.0) THEN 
  383. X*--- equiv. group var. is in this c.b., add complete group  
  384. X                        CALL NAMOVE(SCBVAR,KCBGRP(IC)+NCBGRP(IC),KEQ,   
  385. X     +                  NEQ)
  386. X                        KCB=KCBGRP(IC)  
  387. X                        DO 110 I=1,NCBNAM   
  388. X                           IF(KEQ.LT.KCB) THEN  
  389. X                              IF(KCBGRP(I).LE.KCB.AND.KCBGRP(I).GT.KEQ) 
  390. X     +                        KCBGRP(I)=KCBGRP(I)-NEQ   
  391. X                           ELSE 
  392. X                              IF(KCBGRP(I).GT.KCB.AND.KCBGRP(I).LT.KEQ) 
  393. X     +                        KCBGRP(I)=KCBGRP(I)+NEQ   
  394. X                           ENDIF
  395. X  110                   CONTINUE
  396. X                        DO 120 I=1,NEQNAM   
  397. X                           IF(KEQ.LT.KCB) THEN  
  398. X                              IF(KEQGRP(I).LE.KCB.AND.KEQGRP(I).GT.KEQ) 
  399. X     +                        KEQGRP(I)=KEQGRP(I)-NEQ   
  400. X                           ELSE 
  401. X                              IF(KEQGRP(I).GT.KCB.AND.KEQGRP(I).LT.KEQ) 
  402. X     +                        KEQGRP(I)=KEQGRP(I)+NEQ   
  403. X                           ENDIF
  404. X  120                   CONTINUE
  405. X                        CALL LMERGE(SCBVAR,IWS,.FALSE.,KCBGRP(IC),NCBGRP
  406. X     +                  (IC),NEQ)   
  407. X                        CALL SUPMUL(SCBVAR,IWS,.FALSE.,KCBGRP(IC),  
  408. X     +                  NCBGRP(IC)+NEQ,N)   
  409. X                        NCBGRP(IC)=N
  410. X                        NEQGRP(IE)=0
  411. X*--- restart search 
  412. X                        GOTO 100
  413. X                     ENDIF  
  414. X  130             CONTINUE  
  415. X  140          CONTINUE 
  416. X  150       CONTINUE
  417. X         ENDIF  
  418. X*--- look for any name in statement being in a c.b. 
  419. X         DO 170 I=1,NSNAME  
  420. X            DO 160 IC=1,NCBNAM  
  421. X               CALL NAMSRC(SNAMES(ISNAME+I),SCBVAR(KCBGRP(IC)+1),NCBGRP 
  422. X     +         (IC), IPOS,LAST) 
  423. X               IF(IPOS.GT.0) THEN   
  424. X*--- name is in this c.b. - set flag, count 
  425. X                  IF(LCBVAR(KCBGRP(IC)+IPOS).EQ.0)  
  426. X     +            LCBNAM(IC)=LCBNAM(IC)+1   
  427. X                  LCBVAR(KCBGRP(IC)+IPOS)=LCBVAR(KCBGRP(IC)+IPOS)+1 
  428. X                  GOTO 170  
  429. X               ENDIF
  430. X  160       CONTINUE
  431. X  170    CONTINUE   
  432. X      ENDIF 
  433. X      GOTO 999  
  434. X*--- error - name buffer overflow   
  435. X  180 CONTINUE  
  436. X      STATUS(12)=.TRUE. 
  437. X      WRITE(MPUNIT,10000) MXNAME,SCROUT 
  438. X      GOTO 999  
  439. X  190 CONTINUE  
  440. X      STATUS(12)=.TRUE. 
  441. X      WRITE(MPUNIT,10010) MAXGRP,SCROUT 
  442. X      GOTO 999  
  443. X  200 CONTINUE  
  444. X      STATUS(12)=.TRUE. 
  445. X      WRITE(MPUNIT,10020) MAXGRP,SCROUT 
  446. X10000 FORMAT(/' +++++++++ WARNING - more than',I8,' variable names',
  447. X     +' in COMMON and EQUIV., routine ',A8,' skipped')  
  448. X10010 FORMAT(/' +++++++++ WARNING - more than',I8,' common block names',
  449. X     +', routine ',A8,' skipped')   
  450. X10020 FORMAT(/' +++++++++ WARNING - more than',I8,' groups',
  451. X     +' in EQUIVALENCE, routine ',A8,' skipped')
  452. X  999 END   
  453. /
  454. echo 'x - SETTYP.f'
  455. sed 's/^X//' > SETTYP.f << '/'
  456. X      SUBROUTINE SETTYP(MODE)   
  457. X*-----------------------------------------------------------------------
  458. X*   
  459. X*   Sets variable types for a given statement, or updates default list  
  460. X*   and names so far in case of IMPLICIT.   
  461. X*   
  462. X*   Only sensible if called for all statements in a routine, and while  
  463. X*   establishing a name list for that routine.  
  464. X*   
  465. X*   Input   
  466. X*   MODE      = 0 : reset default type table, no further action 
  467. X*             > 0 : process statement   
  468. X*   SSTA (statement), NSNAME, NRNAME etc.   
  469. X*   Output  
  470. X*   NAMTYP in common /STATE/
  471. X*   
  472. X*   Each type corresponds to a bit position (for testing use ITBIT).
  473. X*   
  474. X*   Types are:  
  475. X*   
  476. X*   Bit          meaning
  477. X*   
  478. X*     1          INTEGER
  479. X*     2          REAL   
  480. X*     3          LOGICAL
  481. X*     4          COMPLEX
  482. X*     5          DOUBLE PRECISION   
  483. X*     6          CHARACTER  
  484. X*     7          PARAMETER  
  485. X*     8          COMMON block name  
  486. X*     9          NAMELIST name  
  487. X*    10          statement function 
  488. X*    11          INTRINSIC  
  489. X*    12          EXTERNAL   
  490. X*    13          PROGRAM name   
  491. X*    14          BLOCK DATA name
  492. X*    15          SUBROUTINE 
  493. X*    16          ENTRY  
  494. X*    17          FUNCTION (intrinsic or external)   
  495. X*    18          dimensioned
  496. X*    19          (routine or function) argument 
  497. X*    20          in a COMMON block  
  498. X*    21          strongly typed function (internal usage)   
  499. X*   
  500. X*-----------------------------------------------------------------------
  501. X      include 'PARAM.h' 
  502. X      include 'ALCAZA.h' 
  503. X      include 'CLASS.h' 
  504. X      include 'FLWORK.h' 
  505. X      include 'FLAGS.h' 
  506. X      include 'CURSTA.h' 
  507. X      include 'STATE.h' 
  508. X      include 'TYPDEF.h' 
  509. X      include 'CONDEC.h' 
  510. X      CHARACTER STEMP*1 ,STEMP1*1   
  511. X      LOGICAL RANGE 
  512. X      DIMENSION ILOC(MCLASS),KDEFTP(26),NLIM1(2),NLIM2(2)   
  513. X*--- KDEFTP = default FORTRAN types (REAL and INTEGER) for first letter 
  514. X*    KILOC  = last location of ISTMDS not relevant for ILOC 
  515. X*    ILOC   = local copy of type descriptors from ISTMDS
  516. X      DATA KDEFTP/8*2,6*1,12*2/, KILOC/14/  
  517. X      include 'CONDAT.h' 
  518. X      IF(MODE.EQ.0)  THEN   
  519. X*--- routine header: reset default type table   
  520. X         DO 10 I=1,26   
  521. X            KVTYPE(I)=KDEFTP(I) 
  522. X   10    CONTINUE   
  523. X         GOTO 999   
  524. X      ENDIF 
  525. X      DO 20 I=ISNAME+1,ISNAME+NSNAME
  526. X         NAMTYP(I)=0
  527. X   20 CONTINUE  
  528. X      IF(ICURCL(1).EQ.IIF)  THEN
  529. X         IUP=2  
  530. X*--- find end of IF(...)
  531. X         JPT=INDEX(SSTA(:NCHST),'(')
  532. X         CALL SKIPLV(SSTA,JPT+1,NCHST,.FALSE.,KND,ILEV) 
  533. X         NLIM1(1)=1 
  534. X         DO 30 I=1,NSNAME   
  535. X            IF(NSSTRT(I).GT.KND) GOTO 40
  536. X   30    CONTINUE   
  537. X         I=NSNAME+1 
  538. X   40    CONTINUE   
  539. X         NLIM2(1)=I-1   
  540. X         NLIM1(2)=I 
  541. X         NLIM2(2)=NSNAME
  542. X      ELSE  
  543. X         IUP=1  
  544. X         KND=NCHST  
  545. X         NLIM1(1)=1 
  546. X         NLIM2(1)=NSNAME
  547. X      ENDIF 
  548. X      DO 120 IPART=1,IUP
  549. X         IF (IPART.EQ.1)  THEN  
  550. X            ICL=ICURCL(1)   
  551. X            KST=1   
  552. X         ELSE   
  553. X            ICL=ICURCL(2)   
  554. X            KST=KND+1   
  555. X            KND=NCHST   
  556. X         ENDIF  
  557. X*--- get flags, counts, and types   
  558. X         DO 50 I=1,MCLASS-KILOC 
  559. X            ILOC(I)=ISTMDS(KILOC+I,ICL) 
  560. X   50    CONTINUE   
  561. X         IFLG2=ILOC(1)/10   
  562. X         IFLG1=ILOC(1)-10*IFLG2 
  563. X         ILPT=2 
  564. X         IULOOP=1   
  565. X         IF(IFLG2.NE.0) THEN
  566. X*--- take only names outside brackets, get ranges for this  
  567. X            CALL GETRNG(KST,KND,IWS)
  568. X         ENDIF  
  569. X         IF(IFLG2.EQ.2) THEN
  570. X*--- treat COMMON block names specially 
  571. X            IULOOP=2
  572. X            ICOMMB=ILOC(ILPT+1) 
  573. X            NLPT=ILOC(ILPT) 
  574. X         ENDIF  
  575. X         IF(IFLG1.EQ.0) THEN
  576. X*--- treat all names the same   
  577. X            ILOW=NLIM1(IPART)   
  578. X            INUP=NLIM2(IPART)   
  579. X            NLOOP=1 
  580. X         ELSEIF(IFLG1.EQ.1) THEN
  581. X*--- different types for first name, and rest   
  582. X            NLOOP=2 
  583. X         ELSE   
  584. X*--- special treatment for IMPLICIT statement   
  585. X            CALL SETIMP 
  586. X*--- update the already existing names except strongly typed
  587. X            DO 60 I=1,NRNAME
  588. X               NT=NAMTYP(IRNAME+I)  
  589. X*--- do not change type of strongly typed function, nor parameter   
  590. X               IF (ITBIT(NT,7).EQ.0.AND.ITBIT(NT,21).EQ.0) THEN 
  591. X                  K=ICVAL(SNAMES(IRNAME+I)(1:1))
  592. X                  NT=NT-MOD(NT,64)  
  593. X                  CALL ISBIT(NT,KVTYPE(K))  
  594. X                  NAMTYP(IRNAME+I)=NT   
  595. X               ENDIF
  596. X   60       CONTINUE
  597. X            GOTO 999
  598. X         ENDIF  
  599. X*--- the following IF(...) must stay here because of IMPLICIT   
  600. X         IF (NSNAME.EQ.0.OR.ILOC(2).EQ.0) GOTO 999  
  601. X         DO 110 ILOOP=IULOOP,NLOOP  
  602. X            IF (IFLG1.NE.0) THEN
  603. X               IF (ILOOP.EQ.1) THEN 
  604. X                  ILOW=NLIM1(IPART) 
  605. X                  INUP=NLIM1(IPART) 
  606. X               ELSE 
  607. X                  IF(IFLG2.EQ.2) THEN   
  608. X                     ILOW=NLIM1(IPART)  
  609. X                  ELSE  
  610. X                     ILOW=NLIM1(IPART)+1
  611. X                  ENDIF 
  612. X                  INUP=NLIM2(IPART) 
  613. X                  ILPT=ILPT+NLPT+1  
  614. X               ENDIF
  615. X            ENDIF   
  616. X            NLPT=ILOC(ILPT) 
  617. X*--- loop over names
  618. X            DO 100 JN=ILOW,INUP 
  619. X               IF (IFLG2.NE.0) THEN 
  620. X*--- take only names outside brackets   
  621. X                  IF (RANGE(NSSTRT(JN),IWS)) GOTO 100   
  622. X               ENDIF
  623. X*--- check whether already typed in this statement (except COMMON)  
  624. X            IF(IFLG2.LT.2)  THEN
  625. X               DO 70 JL=1,JN-1  
  626. X                  IF (SNAMES(ISNAME+JL).EQ.SNAMES(ISNAME+JN)) THEN  
  627. X                     NT=NAMTYP(ISNAME+JL)   
  628. X                     IPOS=0 
  629. X                     GOTO 90
  630. X                  ENDIF 
  631. X   70          CONTINUE 
  632. X               ENDIF
  633. X*--- check against existing routine name table  
  634. X               CALL NAMSRC(SNAMES(ISNAME+JN),SNAMES(IRNAME+1),NRNAME,   
  635. X     +         IPOS, LAST)  
  636. X               IF (IPOS.EQ.0) THEN  
  637. X*--- not yet in table   
  638. X                  NT=0  
  639. X               ELSE 
  640. X                  NT=NAMTYP(IRNAME+IPOS)
  641. X               ENDIF
  642. X               IF(IFLG2.EQ.2) THEN  
  643. X*--- common block   
  644. X*--- look for common block name = /.../ 
  645. X                     NFCB=NSSTRT(JN)-1  
  646. X                     STEMP=SSTA(NFCB:NFCB)  
  647. X                     IF(STEMP.EQ.' ') THEN  
  648. X                        NFCB=NFCB-1 
  649. X                        STEMP=SSTA(NFCB:NFCB)   
  650. X                     ENDIF  
  651. X                     IF(STEMP.EQ.'/') THEN  
  652. X                        NSCB=NSEND(JN)+1
  653. X                        IF(NSCB.LT.NCHST) THEN  
  654. X                           STEMP=SSTA(NSCB:NSCB)
  655. X                           IF(STEMP.EQ.' ') STEMP=SSTA(NSCB+1:NSCB+1)   
  656. X                           IF(STEMP.EQ.'/') THEN
  657. X                              NFCB=NFCB-1   
  658. X                              STEMP1=SSTA(NFCB:NFCB)
  659. X                              IF(STEMP1.EQ.' ') STEMP1=SSTA(NFCB-1:NFCB 
  660. X     +                        -1)   
  661. X                              JNL=MAX(JN-1,1)   
  662. X                              IF((JN.EQ.1.OR.ITBIT(NAMTYP(ISNAME+JNL),  
  663. X     +                        ICOMMB).EQ.0).AND.STEMP1.NE.'/') THEN 
  664. X                                 NT=0   
  665. X                                 CALL ISBIT(NT,ICOMMB)  
  666. X                                 NAMTYP(ISNAME+JN)=NT   
  667. X                                 GOTO 100   
  668. X                              ENDIF 
  669. X                           ENDIF
  670. X                        ENDIF   
  671. X                     ENDIF  
  672. X               ENDIF
  673. X*--- loop over types (for first, or second, or all) 
  674. X               DO 80 JT=ILPT+1,ILPT+NLPT
  675. X                  ITYP=ILOC(JT) 
  676. X                  IF (ITYP.EQ.0) THEN   
  677. X*--- skip if already typed (REAL, INTEGER, etc.)
  678. X                     IF (MOD(NT,64).NE.0) GOTO 80   
  679. X*--- skip if ENTRY in SUBROUTINE
  680. X                     IF(STATUS(14).AND.ISTMDS(6,ICL).EQ.29) GOTO 80 
  681. X*--- take default type  
  682. X                     ITYP=KVTYPE(ICVAL(SNAMES(ISNAME+JN)(1:1)) )
  683. X    
  684. X                  ELSEIF (ITYP.LE.6) THEN   
  685. X*--- strong typing - reset other types  
  686. X                     NT=NT-MOD(NT,64)   
  687. X                  ELSEIF (ITYP.EQ.10) THEN  
  688. X*--- check for statement function declaration (not dimensioned) 
  689. X                     IF (ITBIT(NT,18).NE.0) GOTO 80 
  690. X*--- no':' allowed in bracket   
  691. X                     JLB=INDEX(SSTA(KST:KND),'(')+KST-1 
  692. X                     JRB=INDEX(SSTA(KST:KND),')')+KST-1 
  693. X                     CALL POSCH(':',SSTA,JLB+1,JRB-1,.FALSE.,0,KPOS,
  694. X     +               ILEV)  
  695. X                     IF (KPOS.NE.0) GOTO 80 
  696. X                  ELSEIF (ITYP.EQ.17.OR.ITYP.EQ.18) THEN
  697. X*--- function (17) or array (18)
  698. X*    get next non-blank behind name 
  699. X                     IF (NSEND(JN).EQ.KND) GOTO 80  
  700. X                     CALL GETNBL(SSTA(NSEND(JN)+1:KND),STEMP,NN)
  701. X                     IF (NN.EQ.0.OR.STEMP.NE.'(')GOTO 80
  702. X                     IF (ITYP.EQ.17) THEN   
  703. X*--- only function if not dimensioned   
  704. X                        IF (ITBIT(NT,18).NE.0) GOTO 80  
  705. X*--- should not be statement function   
  706. X                        IF (ITBIT(NT,10).NE.0) GOTO 80  
  707. X*--- no ':' allowed on zero level in bracket following  
  708. X                        JLB=NSEND(JN)+INDEX(SSTA(NSEND(JN)+1:KND),'(')  
  709. X                        CALL SKIPLV(SSTA,JLB+1,KND,.FALSE.,JRB,ILEV)
  710. X                        CALL POSCH(':',SSTA,JLB+1,JRB-1,.FALSE.,0,KPOS, 
  711. X     +                  ILEV )  
  712. X                        IF (KPOS.NE.0) GOTO 80  
  713. X                     ENDIF  
  714. X                  ENDIF 
  715. X*--- type is accepted for this variable - set   
  716. X                  CALL ISBIT(NT,ITYP)   
  717. X   80          CONTINUE 
  718. X   90          CONTINUE 
  719. X               NAMTYP(ISNAME+JN)=NT 
  720. X               IF (IPOS.GT.0) THEN  
  721. X                  NAMTYP(IRNAME+IPOS)=NT
  722. X               ENDIF
  723. X  100       CONTINUE
  724. X  110    CONTINUE   
  725. X  120 CONTINUE  
  726. X  999 END   
  727. /
  728. echo 'x - TYPDEF.h'
  729. sed 's/^X//' > TYPDEF.h << '/'
  730. X      COMMON/TYPDEF/KVTYPE(26)  
  731. X*IF DEF,NEVER   
  732. X*-----------------------------------------------------------------------
  733. X*   
  734. X*   KVTYPE(I)          current default type for starting character no. I
  735. X*-----------------------------------------------------------------------
  736. X*EI 
  737. /
  738. echo 'x - floppy.helpcms'
  739. sed 's/^X//' > floppy.helpcms << '/'
  740. X.cm CAT:CMS
  741. X.cm NAM:FLOPPY
  742. X.cm EXP: Fortran Coding Convention Checker
  743. X.cm DAT: 87.09.20
  744. X.cm A/R: J.J.Bunn
  745. X.cm KEY: FLOP TREE TIDY CONVENTION RULE FORTRAN
  746. X.cm ABS: A program which checks a Fortran program against
  747. X.cm ABS: a pre-defined set of coding conventions.
  748. X.cm ABS: Options to tidy the source Fortran and to write
  749. X.cm ABS: an input file for FLOW (a separate utility) are
  750. X.cm ABS: provided.
  751. X.cm FLG: LOCAL
  752. X.cm END:
  753. XFLOPPY (Coding Convention Checker)
  754. XFLOPPY is used to check that a body of Fortran code complies with a set
  755. Xof coding conventions. This is done by parsing the Fortran using FLOP
  756. X(see DD/US/13 Flop User's Guide by H.Grote) and then analysing the
  757. Xstructure against the specified set of instructions.
  758. XIn addition, FLOPPY may be used to 'tidy' the source Fortran, in other
  759. Xwords to indent the DO/IF clauses, renumber the statement labels, and so
  760. XIt may also be used to produce an analysis file which is interpreted late
  761. Xby the TREE utility (type HELP TREE for details). The TREE utility is
  762. Xcapable of giving a graphical representation of the subroutine calling
  763. Xtree in the source Fortran, as well as for analysing the usage of COMMON
  764. Xblock variables.
  765. XFLOPPY is used as follows:
  766. X+--------+--------------------------------------------------------------+
  767. X|        |                                                              |
  768. X| FLOPPY | [ ? | fn [ft [fm]] [( Options ]]                             |
  769. X|        |                                                              |
  770. X|        | Options:                                                     |
  771. X|        |                                                              |
  772. X|        | [CHECKS {STANDARD|NONE|ALEPH|GALEPH|ONLINE|LIST|number_list}]|
  773. X|        | [DISK]                                                       |
  774. X|        | [FULL]                                                       |
  775. X|        | [GOTOS]                                                      |
  776. X|        | [GROUPF]                                                     |
  777. X|        | [IGNORE]                                                     |
  778. X|        | [INDENT    spaces]                                           |
  779. X|        | [OLD       fn ft fm]                                         |
  780. X|        | [OUTPUT    fn ft fm]                                         |
  781. X|        | [RENUMF    start_value[,step_value]]                         |
  782. X|        | [RENUMS    start_value[,step_value]]                         |
  783. X|        | [TIDY]                                                       |
  784. X|        | [TREE]                                                       |
  785. X+--------+--------------------------------------------------------------+
  786. Xwhere:
  787. X          When FLOPPY is entered without any parameters a panel will be
  788. X          displayed in which details of the Floppy job may be entered.
  789. X?         If this is the only operand this HELP file will be displayed.
  790. XFn Ft Fm  The file name of the Fortran on which Floppy is to operate.
  791. XCHECKS    STANDARD     The standard set of coding conventions are checked
  792. X                       These are the ones marked by a (*) in the list
  793. X                       below (in Usage Notes).
  794. X          NONE         No coding conventions will be checked. This option
  795. X                       is useful with the TREE option.
  796. X          LIST         The user will be prompted for a list of those
  797. X                       coding conventions he wishes to check.
  798. X          ALEPH        Specifies that the set of conventions is that
  799. X                       agreed on by the Aleph Offline Group.
  800. X          GALEPH       Specifies that the set of conventions is as for
  801. X                       the ALEPH qualifier, but additionally all names
  802. X                       beginning G..... or IG.... will be ignored.
  803. X          ONLINE       This qualifier is not yet implemented.
  804. X          number_list  Numbers should correspond to the numbers in the
  805. X                       list given below. Specifying 99 indicates that
  806. X                       all the checks are to be made. Specifying a
  807. X                       negative number means that the corresponding
  808. X                       convention will not be checked. So for example
  809. X                       CHECKS 99,-1,-20 will cause all conventions
  810. X                       except 1 and 20 to be checked.
  811. XDISK      Inclusion of this option causes the output from Floppy to be
  812. X          written to a file.
  813. XFULL      Specifying this option causes Floppy to print all source Fortra
  814. X          statements, instead of just those in breach of the coding
  815. X          conventions checked (which is the default).
  816. XGOTOS     Inclusion of this option causes the GOTO statements in the sour
  817. X          Fortran to be right adjusted in the new Fortran file.
  818. XGROUPF    Causes all FORMAT statements that appear in each subroutine to
  819. X          grouped at the end of the subroutine in the new Fortran file.
  820. XIGNORE    If this option is invoked, then the user will be prompted for a
  821. X          list of variable and/or subroutine/function names which he woul
  822. X          like to be ignored when Floppy checks the coding conventions.
  823. X          This is particularly useful when Floppy is run on external code
  824. X          containing names over which the user has no control, for exampl
  825. X          HBOOK calls.
  826. XINDENT    Inclusion of this option causes all DO and IF clauses to be
  827. X          indented by nn spaces, according to their level of nesting.
  828. XOLD       The file name given with this qualifier should refer to an
  829. X          existing 'FLOPIGN' file, created by a previous Floppy run.
  830. X          The FLOPIGN file contains the list of coding convention numbers
  831. X          together with a list of any specified names to be ignored, and
  832. X          is created automatically when Floppy is run. Specify this
  833. X          option if you have a particularly complex Floppy environment
  834. X          that you do not want to re-create each Floppy run.
  835. XOUTPUT    The file name given with this option will be the file to
  836. X          which the 'tidied' Fortran is written. By default this file
  837. X          has the name 'OUTPUT FORTRAN A'.
  838. XRENUMF    Specifying this option together with a value for START and STEP
  839. X          will cause all FORMAT statements to be renumbered, beginning at
  840. X          value START and stepping by STEP.
  841. XRENUMS    Specifying this option together with a value for START and STEP
  842. X          will cause ALL statements to be renumbered, beginning at
  843. X          value START and stepping by STEP.
  844. XTIDY      This option is automatically selected when any of GOTOS, INDENT
  845. X          GROUPF, RENUMF, RENUMS are selected on the command line.
  846. XTREE      Specifying this option causes an analysis file to be written
  847. X          which may be used as input to the TREE utility. If all the user
  848. X          requires from Floppy is this analysis file, then he should
  849. X          specify CHECKS NONE, to avoid Floppy wasting time making any
  850. X          coding convention checks.
  851. XUsage Notes
  852. X  Here follows the list of coding conventions which may at present
  853. X  be checked by Floppy. The conventions in the STANDARD set are
  854. X  marked by an asterisk (*).
  855. X          *  1   Avoid comment lines after end of module
  856. X          *  2   End all program modules with the END statement
  857. X          *  3   Declared COMMON blocks must be used in the module
  858. X          *  4   COMPLEX and DOUBLEPRECISION vars at end of COMMON
  859. X          *  5   COMMON block definitions should not change
  860. X          *  6   Variable names should be 6 or fewer characters long
  861. X             7   Variables in COMMON should be 6 characters long
  862. X             8   Variables not in COMMON should be <6 characters
  863. X          *  9   Integer variables should begin with I to N
  864. X          *  10  Variable names should not equal FORTRAN keywords
  865. X          *  11  Avoid comment lines before module declaration
  866. X          *  12  Module names should not equal intrinsic functions
  867. X          *  13  First statement in a module should be declaration
  868. X          *  14  Module should begin with at least 3 comment lines
  869. X             15  Comment lines should begin with a C
  870. X          *  16  No comment lines between continuations
  871. X          *  17  Avoid non-standard variable types eg INTEGER*2
  872. X          *  18  Avoid multiple COMMON definitions per line
  873. X          *  19  Do not dimension COMMON variables outside COMMON
  874. X          *  20  Avoid embedded blanks in variable names
  875. X          *  21  Avoid embedded blanks in syntactic entities
  876. X          *  22  Avoid the use of PRINT statements (use WRITE)
  877. X             23  Do not give the END statement a label
  878. X          *  24  Avoid WRITE(* construction
  879. X             25  Avoid WRITE statement in a FUNCTION
  880. X          *  26  Avoid the use of PAUSE statements
  881. X          *  27  Statement labels should not begin in column 1
  882. X          *  28  Always precede STOP by a descriptive WRITE
  883. X          *  29  Avoid the use of ENTRY in FUNCTIONS
  884. X          *  30  Avoid using I/O in FUNCTIONs
  885. X             31  Avoid the use of the alternate RETURN statement
  886. X          *  32  COMMON block names should not equal variable names
  887. X          *  33  Avoid use of obsolete CERN library routines
  888. X             34  Avoid FUNCTION names the same as intrinsics
  889. X          *  35  Local functions should be declared EXTERNAL
  890. X          *  36  Module names should all be different
  891. X          *  37  Avoid expressions of mixed mode eg A=B/I
  892. X          *  38  Length of passed CHARACTER variables should be *
  893. X          *  39  Order of statements should conform to note
  894. X          *  40  Separate Statement Functions by comment lines
  895. X          *  41  No names in Statement Function definitions elsewhere
  896. X             42  Use LLT,LGT etc to compare CHARACTER vars. in IFs
  897. X             43  Variables (not COMMON, not PARAMs) <6 characters
  898. X          *  44  Passed arguments should be dimensioned * in module
  899. /
  900. echo 'x - floppy.vmshlp'
  901. sed 's/^X//' > floppy.vmshlp << '/'
  902. X1   FLOPPY
  903. X
  904. X   Floppy is a program which checks that an input file of Fortran
  905. X   code complies with a set of coding conventions. 
  906. X
  907. X   There is a "FLOPPY User Guide" DD/US/112 available in the UCO,
  908. X   Batiment 512, Tel. 4952.
  909. X   FLOPPY can also produce output for the FLOW program, a tool
  910. X   which analyses the structure of Fortran code. Type HELP FLOW
  911. X   for details. 
  912. X
  913. X   There are some extra features which are described below.
  914. X
  915. X   For problems with FLOPPY or FLOW contact VXCERN::JULIAN (Tel.5029)
  916. X
  917. X  Format:
  918. X
  919. X    FLOPPY [filename]
  920. X
  921. X   NB Floppy uses FLOP (DD/US/13 Flop User's Guide by H.Grote)
  922. X   to parse the source Fortran.
  923. X2   Parameters
  924. X
  925. X  filename
  926. X
  927. X    Specifies the name of the input file of FORTRAN upon which the
  928. X    coding convention checks are to be made. The code must be
  929. X    standard FORTRAN 77, and must have compiled without errors,
  930. X    otherwise the results from using FLOPPY will be unreliable.
  931. X
  932. X    You may use wild-cards in the filename; if more than one file
  933. X    is found matching the specification, then the files will be
  934. X    internally concatenated.
  935. X
  936. X    Note that non-standard constructs such as INCLUDE statements
  937. X    will be treated as illegal statements by FLOPPY, and ignored.
  938. X
  939. X    If you are using FLOPPY to tidy your Fortran (see /TIDY option),
  940. X    then 'filename' may be for instance an EDITF.DAT extracted
  941. X    with HISTORIAN option S, or likewise may be a file where the
  942. X    COMMON block declarations are hidden in INCLUDE statements. This
  943. X    will not jeopardize the indentation of DO loops and IF clauses,
  944. X    nor the re-numbering of statement labels.
  945. X
  946. X2   Qualifiers
  947. X/CHECKS
  948. X
  949. X    /CHECKS[=(n[,.....])]
  950. X    /NOCHECKS
  951. X
  952. X    Define the coding convention checks to be made.
  953. X
  954. X    If no list is given, then the checks marked by a '*'
  955. X    in the list below are made.
  956. X
  957. X    If n=99 then all checks are made
  958. X
  959. X    If /NOCHECKS is specified then no checks are made.
  960. X
  961. X    If n is negative, then check number n is not made.
  962. X
  963. X    Thus to make all the checks except numbers 3 and 31,
  964. X    specify /CHECKS=(99,-3,-31). See the Examples.
  965. X
  966. X    The coding convention numbering (n) is as follows:
  967. X
  968. X  *  Check no. 1   Avoid comment lines after end of module
  969. X  *  Check no. 2   End all program modules with the END statement
  970. X  *  Check no. 3   Declared COMMON blocks must be used in the module
  971. X  *  Check no. 4   COMPLEX and DOUBLEPRECISION vars at end of COMMON
  972. X  *  Check no. 5   COMMON block definitions should not change
  973. X  *  Check no. 6   Variable names should be 6 or less characters long
  974. X     Check no. 7   Variables in COMMON should be 6 characters long
  975. X     Check no. 8   Variables not in COMMON should be <6 characters
  976. X  *  Check no. 9   Integer variables should begin with I to N
  977. X  *  Check no. 10  Variable names should not equal FORTRAN keywords
  978. X  *  Check no. 11  Avoid comment lines before module declaration
  979. X  *  Check no. 12  Module names should not equal intrinsic functions
  980. X  *  Check no. 13  First statement in a module should be declaration
  981. X  *  Check no. 14  Module should begin with at least 3 comment lines
  982. X     Check no. 15  Comment lines should begin with a C
  983. X  *  Check no. 16  No comment lines between continuations
  984. X  *  Check no. 17  Avoid non-standard variable types eg INTEGER*2
  985. X  *  Check no. 18  Avoid multiple COMMON definitions per line
  986. X  *  Check no. 19  Do not dimension COMMON variables outside COMMON
  987. X  *  Check no. 20  Avoid embedded blanks in variable names
  988. X  *  Check no. 21  Avoid embedded blanks in syntactic entities
  989. X  *  Check no. 22  Avoid the use of PRINT statements (use WRITE)
  990. X     Check no. 23  Do not give the END statement a label
  991. X  *  Check no. 24  Avoid WRITE(* construction
  992. X     Check no. 25  Avoid WRITE statement in a FUNCTION
  993. X  *  Check no. 26  Avoid the use of PAUSE statements
  994. X  *  Check no. 27  Statement labels should not begin in column 1
  995. X  *  Check no. 28  Always precede STOP by a descriptive WRITE
  996. X  *  Check no. 29  Avoid the use of ENTRY in FUNCTIONS
  997. X  *  Check no. 30  Avoid using I/O in FUNCTIONs
  998. X     Check no. 31  Avoid the use of the alternate RETURN statement
  999. X  *  Check no. 32  COMMON block names should not equal variable names
  1000. X  *  Check no. 33  Avoid use of obsolete CERN library routines
  1001. X     Check no. 34  Avoid FUNCTION names the same as intrinsics
  1002. X  *  Check no. 35  Local functions should be declared EXTERNAL
  1003. X  *  Check no. 36  Module names should all be different
  1004. X  *  Check no. 37  Avoid expressions of mixed mode eg A=B/I
  1005. X  *  Check no. 38  Length of passed CHARACTER variables should be   *
  1006. X  *  Check no. 39  Order of statements should conform to note
  1007. X  *  Check no. 40  Separate Statement Functions by comment lines
  1008. X  *  Check no. 41  No names in Statement Function definitions elsewhere
  1009. X     Check no. 42  Use LLT,LGT etc to compare CHARACTER vars. in IFs
  1010. X     Check no. 43  Variables (not COMMON, not PARAMs) <6 characters
  1011. X  *  Check no. 44  Passed arguments should be dimensioned * in module
  1012. X
  1013. X
  1014. X/TREE
  1015. X
  1016. X    /TREE
  1017. X
  1018. X    Cause a summary output file to be produced, containing a packed
  1019. X    description of the source FORTRAN. The summary file contains
  1020. X    such information as the list of all FORTRAN module names, their
  1021. X    arguments, calling list, and so on. The file is unformatted; it
  1022. X    should be used as input to an auxiliary tool called TREE, and
  1023. X    is unreadable at the terminal.
  1024. X
  1025. X/OUTPUT
  1026. X
  1027. X    /OUTPUT[=filename]
  1028. X
  1029. X    Cause the output from FLOPPY (normally viewed at the terminal)
  1030. X    to be sent to a disk file. If filename is not specified the
  1031. X    output file will have the stem name of the source FORTRAN file,
  1032. X    with an extension of .FLOPLIS .
  1033. X
  1034. X/FULL
  1035. X
  1036. X    /FULL
  1037. X
  1038. X    Cause all source FORTRAN statements to be output, as opposed to
  1039. X    only those breaking the specified coding conventions.
  1040. X
  1041. X/IGNORE
  1042. X
  1043. X    /IGNORE=(name[,.....])
  1044. X
  1045. X    Specify a list of FORTRAN module and variable names to be
  1046. X    ignored when the coding convention checks are made. Specify
  1047. X    module names by preceding the name with a # sign e.g. #MINUIT,
  1048. X    specify variable names normally.
  1049. X
  1050. X/SPECIAL
  1051. X
  1052. X    /SPECIAL[=type]
  1053. X
  1054. X    Specify that a special version of FLOPPY be used. The default
  1055. X    'special' version is STANDARD, which causes those checks marked
  1056. X    by a '*' (see /CHECKS) to be implemented.
  1057. X
  1058. X    STANDARD : Use the standard check set.
  1059. X    ALEPH    : Use the standard ALEPH check set. 
  1060. X    ONLINE   : Use the check set for Online Programs (not yet available).
  1061. X    GALEPH   : Variables beginning with G..... or xG.... are ignored.
  1062. X
  1063. X    Other special versions may be defined on request to the author.
  1064. X
  1065. X/LOG
  1066. X
  1067. X    /LOG
  1068. X    /NOLOG
  1069. X
  1070. X    Show a summary of the FLOPPY command parsing, or not.
  1071. X
  1072. X/OLD
  1073. X
  1074. X    /OLD[=filename]
  1075. X
  1076. X    Each time FLOPPY is run, an "IGNORE" file is written with the
  1077. X    user specifications for that particular run. If the /OLD
  1078. X    qualifier is used, one may specify an already existing "IGNORE"
  1079. X    file. If the filename is omitted, then the filename used is
  1080. X    obtained from the stem of the source FORTRAN file and the
  1081. X    extension .FLOPIGN .
  1082. X
  1083. X    Note that this qualifier does not affect the use of /TIDY
  1084. X    as the FORTRAN tidying parameters are not stored in the "IGNORE"
  1085. X    file.
  1086. X
  1087. X
  1088. X2   /TIDY
  1089. X
  1090. X    Write a new file of FORTRAN after re-formatting the input
  1091. X    according to the qualifiers specified.
  1092. X
  1093. X    Format:
  1094. X
  1095. X    FLOPPY/TIDY [filename]
  1096. X
  1097. X    The TIDY qualifier must be accompanied by at least one of the
  1098. X    following qualifiers. If all you want to do is TIDY your Fortran,
  1099. X    then use the /NOCHECKS qualifier as well.
  1100. X
  1101. X3   Qualifiers
  1102. X/FORTRAN
  1103. X
  1104. X    /FORTRAN[=filename]
  1105. X
  1106. X    Cause the reformatted FORTRAN output to be written on the filename
  1107. X    specified. If no filename is given, then the output Fortran is
  1108. X    written to a file called FORTRAN.FOR .
  1109. X
  1110. X/GOTOS
  1111. X
  1112. X    /GOTOS
  1113. X
  1114. X    Right adjust all GOTO statements so that they finish in column 72.
  1115. X
  1116. X/INDENT
  1117. X
  1118. X    /INDENT[=n]
  1119. X
  1120. X    Indent DO and IF clauses by the specified number of spaces. The
  1121. X    default is 3, and if specified, n should be in the range 1 to 5.
  1122. X
  1123. X/FORMAT
  1124. X
  1125. X    /FORMAT[=(START=n,STEP=m)]
  1126. X
  1127. X    Re-number FORTRAN statements starting at n and stepping by m.
  1128. X
  1129. X/GROUPF
  1130. X
  1131. X    /GROUPF
  1132. X
  1133. X    Group all FORMAT statements at the bottom of each module in which
  1134. X    they appear.
  1135. X
  1136. X/STMNTS
  1137. X
  1138. X    /STMNTS[=(START=n,STEP=m)]
  1139. X
  1140. X    Re-number all statements (not FORMATs) starting at n and stepping
  1141. X    by m.
  1142. X
  1143. X2   Examples
  1144. X
  1145. X    $ FLOPPY myfile.for
  1146. X
  1147. X    Make all the available coding convention checks on the FORTRAN
  1148. X    file myfile.for.
  1149. X
  1150. X    $ FLOPPY/TREE/NOCHECKS myfile.for
  1151. X
  1152. X    Produce a TREE output file, and make no checks.
  1153. X
  1154. X    $ FLOPPY/IGNORE=(FRED,#MICHEL) myfile.for
  1155. X
  1156. X    Make all the available checks, but ignore the variable called
  1157. X    FRED and the subroutine called MICHEL.
  1158. X
  1159. X    $ FLOPPY/CHECKS=(1,5,25,3)/FULL myfile.for
  1160. X
  1161. X    Check conventions 1,3,5 and 25, and list all lines from the
  1162. X    source FORTRAN.
  1163. X
  1164. X    $ FLOPPY/CHECKS=(99,-1,-2,-20) my*.for
  1165. X
  1166. X    Check all conventions except numbers 1,2 and 20. Use all files
  1167. X    beginning 'MY' and with filetype .FOR .
  1168. X
  1169. X    $ FLOPPY/NOLOG/OUT=output.lis  myfile.for
  1170. X
  1171. X    Send the FLOPPY output to a listing file, and disable the command
  1172. X    parsing information.
  1173. X
  1174. X    $ FLOPPY/NOCHECKS/TIDY/INDENT=2 myfile.for
  1175. X
  1176. X    Produce a new FORTRAN file with all DO and IF clauses indented by
  1177. X    two spaces. No coding convention checking is done. The new
  1178. X    fortran will be called FORTRAN.FOR.
  1179. X
  1180. X    $ FLOPPY/TIDY/STMNTS=(START=10,STEP=5)/FORTRAN=out.for myfile.for
  1181. X
  1182. X    Renumber statements starting at 10 (10, 15, 20 etc.) and write
  1183. X    the new FORTRAN to the file out.for.
  1184. /
  1185. echo 'Part 05 of Floppy complete.'
  1186. exit
  1187.  
  1188.  
  1189.