home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchek284.zip / ftnchek.doc < prev    next >
Text File  |  1995-06-02  |  142KB  |  3,631 lines

  1.  
  2.  
  3.  
  4. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  5.  
  6.  
  7. NAME
  8.         ftnchek - Fortran program checker
  9.  
  10.  
  11. SYNOPSIS
  12.        ftnchek [ -arguments=num ] [ -array=num ] [ -[no]backslash
  13.        ]
  14.             [ -[no]calltree ] [ -columns=num ] [ -common=num ]
  15.             [ -[no]crossref ] [ -[no]declare ] [ -[no]division ]
  16.             [ -[no]extern ] [ -[no]f77 ] [ -[no]help ]
  17.             [ -[no]hollerith ] [ -include=str ] [ -[no]library ]
  18.             [ -[no]list ] [ -makedcls=num ] [ -[no]novice ]
  19.             [ -output=str ] [ -[no]portability ] [ -[no]pretty ]
  20.             [ -[no]project ] [ -[no]pure ] [ -[no]reference ]
  21.             [ -[no]resource ] [ -[no]sixchar ] [ -[no]sort ]
  22.             [ -[no]symtab ] [ -[no]tab ] [ -[no]truncation ]
  23.             [ -usage=num ] [ -[no]verbose ] [ -[no]volatile ]
  24.             [ -wordsize=num ] [ -wrap=num ] [ files ...  ]
  25.  
  26.  
  27. DESCRIPTION
  28.  
  29.  
  30.        ftnchek (short for Fortran checker) is designed to  detect
  31.        certain  errors  in a Fortran program that a compiler usu-
  32.        ally does not.   ftnchek  is  not  primarily  intended  to
  33.        detect  syntax  errors.  Its purpose is to assist the user
  34.        in finding semantic errors.  Semantic errors are legal  in
  35.        the  Fortran language but are wasteful or may cause incor-
  36.        rect operation.  For example, variables  which  are  never
  37.        used may indicate some omission in the program; uninitial-
  38.        ized variables contain garbage which may  cause  incorrect
  39.        results  to  be  calculated;  and  variables which are not
  40.        declared may not  have  the  intended  type.   ftnchek  is
  41.        intended to assist users in the debugging of their Fortran
  42.        program.  It is not intended to catch all  syntax  errors.
  43.        This  is  the  function  of  the compiler.  Prior to using
  44.        ftnchek, the user should verify that the program  compiles
  45.        correctly.
  46.  
  47.  
  48.  
  49.        This  document  first  summarizes  how  to invoke ftnchek.
  50.        That section  should  be  read  before  beginning  to  use
  51.        ftnchek.   Later  sections  describe  ftnchek's options in
  52.        more detail, give an example of its use, and  explain  how
  53.        to  interpret  the output.  The final sections mention the
  54.        limitations and known bugs in ftnchek.
  55.  
  56. INVOKING FTNCHEK
  57.         ftnchek is invoked through a command of the form:
  58.  
  59.         $ ftnchek [-option -option ...] filename [filename ...]
  60.  
  61.  
  62.  
  63.  
  64.                            2 June 1995                          1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  71.  
  72.  
  73.        The brackets indicate something which  is  optional.   The
  74.        brackets  themselves are not actually typed.  Here options
  75.        are command-line switches or settings, which  control  the
  76.        operation  of  the  program  and the amount of information
  77.        that will be printed out.  If no option is specified,  the
  78.        default  action  is to print error messages, warnings, and
  79.        informational messages, but not  the  program  listing  or
  80.        symbol tables.
  81.  
  82.  
  83.        Each option begins with the '-' character.  (On VAX/VMS or
  84.        MS-DOS systems you  may  use  either  '/'  or  '-'.)   The
  85.        options  are  described at greater length in the next sec-
  86.        tion.
  87.  
  88.        ftnchek options fall into two categories: switches,  which
  89.        are  either  true  or  false,  and  settings, which have a
  90.        numeric or string value.  The name of a switch is prefixed
  91.        by  'no'  to  turn it off: e.g. -nopure would turn off the
  92.        warnings about impure functions. The 'no' prefix can  also
  93.        be  used with numeric settings, having the effect of turn-
  94.        ing off the corresponding  warnings.   Only  the  first  3
  95.        characters  of  an option name (not counting the '-') need
  96.        be provided.  A colon may be used in place  of  an  equals
  97.        sign  for  option value assignments; however, we show only
  98.        the equals sign form below.
  99.  
  100.  
  101.        The switches and settings which ftnchek  currently  recog-
  102.        nizes are:
  103.  
  104.        -arguments=num
  105.               Set  level  of  strictness  in  checking subprogram
  106.               arguments.  Min is 0 (no checking).  Max is 3 (most
  107.               checking).  Default = 3.
  108.  
  109.        -array=num
  110.               Set level of strictness in checking array arguments
  111.               of subprograms.  Min is 0 (least strict).  Max is 3
  112.               (most strict).  Default = 3.
  113.  
  114.        -backslash
  115.               Handle  UNIX-style  backslash  escapes in character
  116.               strings.  Default = no.
  117.  
  118.        -calltree
  119.               Print tree of subprogram call hierarchy.  Default =
  120.               no.
  121.  
  122.        -columns=num
  123.               Set  maximum  line  length  to num columns. (Beyond
  124.               this is ignored.)  Max is 132.  Default = 72.
  125.  
  126.  
  127.  
  128.  
  129.  
  130.                            2 June 1995                          2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  137.  
  138.  
  139.        -common=num
  140.               Set level of strictness in checking COMMON  blocks.
  141.               Min  is 0 (no checking).  Max is 3 (must be identi-
  142.               cal).  Default = 3.
  143.  
  144.        -crossref
  145.               Print cross-reference list of subprogram calls  and
  146.               COMMON block use.  Default = no.
  147.  
  148.        -declare
  149.               Print  a  list of all identifiers whose datatype is
  150.               not explicitly declared.  Default = no.
  151.  
  152.        -division
  153.               Warn wherever division is done (except division  by
  154.               a constant).  Default = no.
  155.  
  156.        -extern
  157.               Warn  if external subprograms which are invoked are
  158.               never defined.  Default = yes.
  159.  
  160.        -f77   Warn about extensions to the Fortran  77  Standard.
  161.               Default = no.
  162.  
  163.        -help  Print command summary.  Default = no.
  164.  
  165.        -hollerith
  166.               Warn  about  Hollerith  constants  if  -portability
  167.               option is in effect.  Default = yes.
  168.  
  169.        -include=path
  170.               Define a directory to  search  for  INCLUDE  files.
  171.               Cumulative.
  172.  
  173.        -library
  174.               Begin  library  mode: do not warn about subprograms
  175.               in file that are defined but never used.  Default =
  176.               no.
  177.  
  178.        -list  Print source listing of program.  Default = no.
  179.  
  180.        -makedcls=num
  181.               Prepare  a file of declarations.  Min is 0 (no dec-
  182.               laration file).  Max is 511.  Default = 1  if  this
  183.               option  is  specified  with an out-of-range numeric
  184.               value.
  185.  
  186.        -novice
  187.               Give output suitable for novice users.   Default  =
  188.               yes.
  189.  
  190.        -output=filename
  191.               Send  output to the given file.  Default is to send
  192.               output to the screen. (Default  filename  extension
  193.  
  194.  
  195.  
  196.                            2 June 1995                          3
  197.  
  198.  
  199.  
  200.  
  201.  
  202. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  203.  
  204.  
  205.               is .lis).
  206.  
  207.        -portability
  208.               Warn about non-portable usages.  Default = no.
  209.  
  210.        -pretty
  211.               Give warnings for possibly misleading appearance of
  212.               source code.    Default = yes.
  213.  
  214.        -project
  215.               Create  project  file  (see   explanation   below).
  216.               Default = no.
  217.  
  218.        -pure  Assume  functions  are  pure,  i.e.  have  no  side
  219.               effects.  Default = yes.
  220.  
  221.        -reference
  222.               Print table of subprograms referenced by each  sub-
  223.               program.  Default = no.
  224.  
  225.        -resource
  226.               Print  amount  of  resources  used in analyzing the
  227.               program.  Default = no.
  228.  
  229.        -sixchar
  230.               List any variable names which clash at 6 characters
  231.               length.  Default = no.
  232.  
  233.        -sort  Print  list  of  subprograms sorted in prerequisite
  234.               order.  Default = no.
  235.  
  236.        -symtab
  237.               Print symbol table for each subprogram.  Default  =
  238.               no.
  239.  
  240.        -tab   Accept  DEC-style  tab-formatted source.  Default =
  241.               no.
  242.  
  243.        -truncation
  244.               Check for possible loss of accuracy by  truncation.
  245.               Default = yes.
  246.  
  247.        -usage=num
  248.               Control  warnings about unused variables, etc.  Min
  249.               is 0 (no  checking).  Max  is  3  (most  checking).
  250.               Default = 3.
  251.  
  252.        -verbose
  253.               Produce full amount of output.  Default = yes.
  254.  
  255.        -volatile
  256.               Assume  COMMON blocks lose definition between acti-
  257.               vations.  Default = no.
  258.  
  259.  
  260.  
  261.  
  262.                            2 June 1995                          4
  263.  
  264.  
  265.  
  266.  
  267.  
  268. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  269.  
  270.  
  271.        -wordsize=num
  272.               Set the default word size for numeric quantities to
  273.               num bytes.  Default = 4 bytes.
  274.  
  275.        -wrap=num
  276.               Set  output column at which to wrap long error mes-
  277.               sages and warnings to the next line.  If set to  0,
  278.               turn off wrapping.  Default = 79.
  279.  
  280.        When  more  than  one option is used, they should be sepa-
  281.        rated by a blank space, except  on  systems  such  as  VMS
  282.        where options begin with slash ( / ).  No blank spaces may
  283.        be placed around the equals sign  (  =  )  in  a  setting.
  284.        ftnchek  "?"   will  produce a command summary listing all
  285.        options and settings.
  286.  
  287.  
  288.        When giving a name of an  input  file,  the  extension  is
  289.        optional.   If  no  extension is given, ftnchek will first
  290.        look for a project file with extension .prj, and will  use
  291.        that  if  it exists.  If not, then ftnchek will look for a
  292.        Fortran source file with the extension .for for  VMS  sys-
  293.        tems, .f for UNIX systems.  More than one file name can be
  294.        given to ftnchek, and it will process the modules  in  all
  295.        files as if they were in a single file.
  296.  
  297.  
  298.        Wildcards are allowed in the specification of filenames on
  299.        the command line for the VMS and MS-DOS versions, as  also
  300.        of  course  under  UNIX and any other system that performs
  301.        wildcard expansion in the command processor.
  302.  
  303.        If no filename is given, ftnchek will read input from  the
  304.        standard input.
  305.  
  306.  
  307.  
  308. OPTIONS
  309.        This  section  provides  a  more  detailed  discussion  of
  310.        ftnchek command-line options.  Options and  filenames  may
  311.        be interspersed on a command line.  Most options are posi-
  312.        tional: each option remains in effect from the point it is
  313.        encountered  until  it  is  overridden  by a later change.
  314.        Thus for example, the listing may be suppressed  for  some
  315.        files  and  not for others.  Exceptions are: the -wordsize
  316.        setting, which cannot be changed once processing of  input
  317.        files  has  started;  the  -arguments,  -array, -calltree,
  318.        -common, -crossref, -extern, -reference, -resource, -sort,
  319.        and  -volatile  options,  where the action depends only on
  320.        the value of the option  after  the  processing  of  input
  321.        files  is  finished;  and  the  -include setting, which is
  322.        cumulative.
  323.  
  324.        The option names in the following list are in alphabetical
  325.  
  326.  
  327.  
  328.                            2 June 1995                          5
  329.  
  330.  
  331.  
  332.  
  333.  
  334. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  335.  
  336.  
  337.        order.
  338.  
  339.  
  340.  
  341.        -arguments=num
  342.                 Controls warnings about mismatches between actual
  343.               and dummy subprogram arguments.  (An  actual  argu-
  344.               ment is an argument passed to the subprogram by the
  345.               caller; a dummy argument is an argument received by
  346.               the subprogram.)
  347.  
  348.               The meanings of the setting values are as follows:
  349.  
  350.               0:  turn off all such warnings.
  351.  
  352.               1:  warn  only about different number of arguments.
  353.  
  354.               2:  warn only about mismatch of data type of  argu-
  355.                   ments and of function itself.
  356.  
  357.               3:  all warnings.
  358.  
  359.               Default = 3.
  360.  
  361.               This  setting  is provided mainly to suppress warn-
  362.               ings when you wish to use ftnchek  for  some  other
  363.               purpose  than checking for errors, for example when
  364.               you only want to print the call tree.  It does  not
  365.               apply  to  checking  invocations of intrinsic func-
  366.               tions or statement functions.
  367.  
  368.               See also: -array, -library, -usage.
  369.  
  370.  
  371.  
  372.        -array=num
  373.                Controls the  degree  of  strictness  in  checking
  374.               agreement between actual and dummy subprogram argu-
  375.               ments that are arrays.  The warnings controlled  by
  376.               this  setting  are  for  constructions  that  might
  377.               legitimately be used by a knowledgeable programmer,
  378.               but that often indicate programming errors.
  379.  
  380.               The meanings of the setting values are as follows:
  381.  
  382.               0:  only  warn  about  cases that are seldom inten-
  383.                   tional (see note below).
  384.  
  385.               1:  warn if the arguments differ in their number of
  386.                   dimensions,  or  if  the  actual argument is an
  387.                   array element while the  dummy  argument  is  a
  388.                   whole array.
  389.  
  390.               2:  warn  if  both  arguments  are arrays, but they
  391.  
  392.  
  393.  
  394.                            2 June 1995                          6
  395.  
  396.  
  397.  
  398.  
  399.  
  400. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  401.  
  402.  
  403.                   differ in number of elements.
  404.  
  405.               3:  give both types of warnings.
  406.  
  407.               Default = 3.
  408.  
  409.               Note: A warning is always given regardless of  this
  410.               setting  if  the  actual argument is an array while
  411.               the dummy argument is a scalar variable, or if  the
  412.               actual  argument is a scalar variable or expression
  413.               while the dummy argument is an array.   No  warning
  414.               is  ever  given  if the actual argument is an array
  415.               element while the dummy argument is a scalar  vari-
  416.               able.    Variable-dimensioned   arrays  and  arrays
  417.               dimensioned with 1 or asterisk match any number  of
  418.               array  elements.   There  is  no  check  of whether
  419.               multi-dimensional arrays agree in the size of  each
  420.               dimension separately.
  421.  
  422.               See also: -arguments, -library, -usage.
  423.  
  424.  
  425.  
  426.        -backslash
  427.                 Handle  UNIX-style backslash escapes in character
  428.               strings.  The escape sequence following  the  back-
  429.               slash will be evaluated according to the ANSI stan-
  430.               dard for strings in C: up to three  digits  signify
  431.               an  octal value, an x signifies the start of a hex-
  432.               adecimal constant, any of the letters a b f n  r  t
  433.               signify  special control codes, and any other char-
  434.               acter (including newline) signifies  the  character
  435.               itself.   When  this  option  is  in effect, a non-
  436.               standard warning will be given if the -f77 flag  is
  437.               set.  Default = no.
  438.  
  439.               If  this  option  is  turned off (the default), the
  440.               backslash will be treated  like  any  other  normal
  441.               character,  but a warning about portability will be
  442.               generated if the -portability flag is set.  Because
  443.               of the fact that some compilers treat the backslash
  444.               in a nonstandard way, it is possible for  standard-
  445.               conforming  programs to be non-portable if they use
  446.               the backslash character in strings.
  447.  
  448.               Since ftnchek does not do much with the interpreted
  449.               string,  it is seldom necessary to use this option.
  450.               It is needed in order to  avoid  spurious  warnings
  451.               only  if  (a)  the program being checked uses back-
  452.               slash to embed an apostrophe or  quote  mark  in  a
  453.               string  instead  of using the standard mechanism of
  454.               doubling the delimiter; (b) the backslash  is  used
  455.               to  escape  the  end-of-line in order to continue a
  456.               string across  multiple  source  lines;  or  (c)  a
  457.  
  458.  
  459.  
  460.                            2 June 1995                          7
  461.  
  462.  
  463.  
  464.  
  465.  
  466. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  467.  
  468.  
  469.               PARAMETER definition uses an intrinsic string func-
  470.               tion such as LEN with such a  string  as  argument,
  471.               and that value is later used to define array dimen-
  472.               sions, etc.
  473.  
  474.  
  475.  
  476.        -calltree
  477.                Causes ftnchek to print out the call structure  of
  478.               the  complete  program  in the form of a tree.  The
  479.               tree is printed out starting from the main program,
  480.               which  is listed on the first line at the left mar-
  481.               gin.  Then on the  following  lines,  each  routine
  482.               called  by  the  main program is listed, indented a
  483.               few spaces, followed by  the  subtree  starting  at
  484.               that routine.  Default = no.
  485.  
  486.               If  a routine is called by more than one other rou-
  487.               tine, its call subtree is printed  only  the  first
  488.               time  it is encountered.  Later calls give only the
  489.               routine name and the notice ``(see above)''.
  490.  
  491.               Note that the call tree will be incomplete  if  any
  492.               of  the  input  files  are project files containing
  493.               more than one module that were created in  -library
  494.               mode.  See the discussion of project files below.
  495.  
  496.               Technical points: Each list of routines called by a
  497.               given routine is printed in alphabetical order.  If
  498.               multiple  main programs are found, the call tree of
  499.               each is printed separately.  If no main program  is
  500.               found,  a report to that effect is printed out, and
  501.               the call trees of any  top-level  non-library  rou-
  502.               tines  are  printed.   This  flag only controls the
  503.               printing of the call tree: ftnchek  constructs  the
  504.               call  tree in any case because it is used to deter-
  505.               mine which library modules will  be  cross-checked.
  506.               See the discussion of the -library flag.
  507.  
  508.               See  also:  -crossref, -library, -reference, -sort,
  509.               -symtab.
  510.  
  511.  
  512.  
  513.        -columns=num
  514.                Set  maximum  statement  length  to  num  columns.
  515.               (Beyond this is ignored.)  This setting is provided
  516.               to allow checking of programs which may violate the
  517.               Fortran standard limit of 72 columns for the length
  518.               of a statement.  According  to  the  standard,  all
  519.               characters  past  column  72  are ignored.  If this
  520.               setting is used when the -f77 option is in  effect,
  521.               a  warning  will  be  given  for any lines in which
  522.               characters past column 72 are  processed.   Max  is
  523.  
  524.  
  525.  
  526.                            2 June 1995                          8
  527.  
  528.  
  529.  
  530.  
  531.  
  532. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  533.  
  534.  
  535.               132.  Default = 72.
  536.  
  537.  
  538.  
  539.        -common=num
  540.                 This setting varies the strictness of checking of
  541.               COMMON blocks.
  542.  
  543.               The different levels are:
  544.  
  545.               0:  no checking.
  546.  
  547.               1:  in each declaration of a  given  COMMON  block,
  548.                   corresponding memory locations (words or bytes)
  549.                   must agree in data type.
  550.  
  551.               2:  also warn if different declarations of the same
  552.                   block are not equal in total length.
  553.  
  554.               3:  corresponding  variables in each declaration of
  555.                   a block must agree in data type and (if arrays)
  556.                   in size and number of dimensions.
  557.  
  558.               Default = 3.
  559.  
  560.               The  Fortran 77 Standard requires each named common
  561.               block, but not blank common, to be the same  length
  562.               in all modules of the program.  Level 3 provides an
  563.               extra degree of checking to support a frequent pro-
  564.               gramming practice.
  565.  
  566.               See also: -library, -usage, -volatile.
  567.  
  568.  
  569.  
  570.        -crossref
  571.                Specifies that a cross-reference table be printed.
  572.               This table lists each subprogram followed by a list
  573.               of  the routines that call it.  Also prints a table
  574.               listing each COMMON block followed by a list of the
  575.               routines that access it.  Default = no.
  576.  
  577.               The  cross-reference  listing omits library modules
  578.               that are not in the call tree of the main  program.
  579.               The  list  is alphabetized.  The routines listed as
  580.               using a COMMON block are those in which some  vari-
  581.               ables  in  the block are accessed, not simply those
  582.               routines that declare the block.  (To find out what
  583.               routines  declare a COMMON block but do not use it,
  584.               see the -usage flag.)
  585.  
  586.               See also: -calltree, -reference, -sort, -symtab.
  587.  
  588.  
  589.  
  590.  
  591.  
  592.                            2 June 1995                          9
  593.  
  594.  
  595.  
  596.  
  597.  
  598. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  599.  
  600.  
  601.        -declare
  602.                 If  this  flag  is  set,  all  identifiers  whose
  603.               datatype  is  not  declared  in each module will be
  604.               listed.  This flag is useful for  helping  to  find
  605.               misspelled  variable  names, etc.  The same listing
  606.               will be given if the module  contains  an  IMPLICIT
  607.               NONE statement.  Default = no.
  608.  
  609.               See also: -sixchar, -usage.
  610.  
  611.  
  612.  
  613.        -division
  614.                 This switch is provided to help users spot poten-
  615.               tial division by zero problems.  If this switch  is
  616.               selected,  every division except by a constant will
  617.               be flagged.  (It is assumed that the user is intel-
  618.               ligent  enough not to divide by a constant which is
  619.               equal to zero!)  Default = no.
  620.  
  621.               See also: -portability, -truncation.
  622.  
  623.  
  624.  
  625.        -extern
  626.                Causes ftnchek to report whether  any  subprograms
  627.               invoked  by  the  program are never defined, or are
  628.               multiply defined.  Ordinarily, if ftnchek is  being
  629.               run  on  a  complete program, each subprogram other
  630.               than the intrinsic functions should be defined once
  631.               and  only  once somewhere.  Turn off this switch if
  632.               you just want to check a subset of files which form
  633.               part  of a larger complete program, or to check all
  634.               at once a number of  unrelated  files  which  might
  635.               each  contain  an unnamed main program.  Subprogram
  636.               arguments will still be  checked  for  correctness.
  637.               Default = yes.
  638.  
  639.               See also: -library.
  640.  
  641.  
  642.  
  643.        -f77     Use  this flag to catch language extensions which
  644.               violate the Fortran 77 Standard.   Such  extensions
  645.               may  cause  your program not to be portable.  Exam-
  646.               ples include the use  of  underscores  in  variable
  647.               names;  variable  names longer than six characters;
  648.               statement lines longer than 72 characters; and non-
  649.               standard statements such as the DO ... ENDDO struc-
  650.               ture.  ftnchek does not report on the use of lower-
  651.               case letters.  Default = no.
  652.  
  653.               See also: -portability, -pretty, -wordsize.
  654.  
  655.  
  656.  
  657.  
  658.                            2 June 1995                         10
  659.  
  660.  
  661.  
  662.  
  663.  
  664. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  665.  
  666.  
  667.        -help   Prints a list of all the command-line options with
  668.               a short description of each along with its  default
  669.               value.   This  command  is identical in function to
  670.               the ``?''  argument, and is provided  as  a  conve-
  671.               nience for those systems in which the question mark
  672.               has special meaning  to  the  command  interpreter.
  673.               Default = no.
  674.  
  675.               The help listing also prints the version number and
  676.               patch level of ftnchek and a copyright notice.
  677.  
  678.               Note: the  ``default''  values  printed  in  square
  679.               brackets  in  the help listing are, strictly speak-
  680.               ing, not the built-in defaults but the current val-
  681.               ues  after any environment options and any command-
  682.               line options preceding the -help option  have  been
  683.               processed.
  684.  
  685.  
  686.  
  687.        -hollerith
  688.                 Hollerith  constants  (other  than  within FORMAT
  689.               specifications) are a source of possible  portabil-
  690.               ity problems, so when the -portability flag is set,
  691.               warnings about them will be produced.  If your pro-
  692.               gram  uses many Hollerith constants, these warnings
  693.               can obscure other more serious  warnings.   So  you
  694.               can  set  this flag to ``no'' to suppress the warn-
  695.               ings about Holleriths.  This  flag  has  no  effect
  696.               unless  the  -portability  flag  (which  is  off by
  697.               default) is turned on.  Default = yes.
  698.  
  699.               See also: -portability.
  700.  
  701.  
  702.  
  703.        -include=path
  704.                Specifies a directory to  be  searched  for  files
  705.               specified by INCLUDE statements.  Unlike other com-
  706.               mand-line options, this setting is cumulative; that
  707.               is,  if  it  is given more than once on the command
  708.               line, all the directories so specified  are  placed
  709.               on  a  list that will be searched in the same order
  710.               as they are given.   The  order  in  which  ftnchek
  711.               searches  for a file to be included is: the current
  712.               directory; the directory specified  by  environment
  713.               variable  FTNCHEK_INCLUDE  if  any; the directories
  714.               specified by any -include  options;  the  directory
  715.               specified  by  environment  variable  INCLUDE;  and
  716.               finally  in   a   standard   systemwide   directory
  717.               (/usr/include  for  UNIX,  SYS$LIBRARY for VMS, and
  718.               \include for MSDOS).
  719.  
  720.  
  721.  
  722.  
  723.  
  724.                            2 June 1995                         11
  725.  
  726.  
  727.  
  728.  
  729.  
  730. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  731.  
  732.  
  733.        -library
  734.                This switch is used when a number  of  subprograms
  735.               are  contained  in  a file, but not all of them are
  736.               used by the application.  Normally,  ftnchek  warns
  737.               you  if any subprograms are defined but never used.
  738.               This switch will suppress these warnings.   Default
  739.               = no.
  740.  
  741.               This  switch  also  controls which subprogram calls
  742.               and COMMON block declarations are  checked.   If  a
  743.               file  is read with the -library flag in effect, the
  744.               subprogram calls and COMMON declarations  contained
  745.               in  a  routine in that file will be checked only if
  746.               that routine is in the main  program's  call  tree.
  747.               On the other hand, if the -library switch is turned
  748.               off, then ftnchek checks the calls of every routine
  749.               by every other routine, regardless of whether those
  750.               routines could ever  actually  be  invoked  at  run
  751.               time,  and  likewise  all COMMON block declarations
  752.               are compared for agreement.
  753.  
  754.               (If there is no main program anywhere in the set of
  755.               files  that  ftnchek  has read, so that there is no
  756.               call tree, then ftnchek  will  look  for  any  non-
  757.               library  routines  that are not called by any other
  758.               routine, and use these as substitutes for the  main
  759.               program  in constructing the call tree and deciding
  760.               what to check.  If no  such  top-level  non-library
  761.               routines are found, then all inter-module calls and
  762.               all COMMON declarations will be checked.)
  763.  
  764.               See also: -arguments, -calltree, -common,  -extern.
  765.  
  766.  
  767.  
  768.        -list   Specifies that a listing of the Fortran program is
  769.               to be printed out with line  numbers.   If  ftnchek
  770.               detects  an  error,  the  error message follows the
  771.               program line with a caret  (  ^  )  specifying  the
  772.               location  of  the  error.  If no source listing was
  773.               requested, ftnchek will still print  out  any  line
  774.               containing an error, to aid the user in determining
  775.               where the error occurred.  Default = no.
  776.  
  777.               See also: -symtab, -verbose.
  778.  
  779.  
  780.  
  781.        -makedcls=num
  782.                Prepare a neatly-formatted file of declarations of
  783.               variables,  common  blocks, and namelist lists, for
  784.               possible merging into the source code.  The  decla-
  785.               rations  are  stored  in a file of the same name as
  786.               the source code, but with the extension changed  to
  787.  
  788.  
  789.  
  790.                            2 June 1995                         12
  791.  
  792.  
  793.  
  794.  
  795.  
  796. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  797.  
  798.  
  799.               .dcl.   If no declarations are written to the file,
  800.               it is deleted to reduce clutter from empty files.
  801.  
  802.               If input comes from standard input,  instead  of  a
  803.               named  file, then declarations are written to stan-
  804.               dard output.
  805.  
  806.               Variables are declared in alphabetical order within
  807.               each declaration class and type, with integer vari-
  808.               ables first, because of their later possible use in
  809.               array dimensions.
  810.  
  811.               PARAMETER statements are an exception to the alpha-
  812.               betical order rule, because the Fortran 77 Standard
  813.               requires  that  the  expressions defining parameter
  814.               values refer only to constants and  already-defined
  815.               parameter  names.   This forces the original source
  816.               file order of such statements to  be  preserved  in
  817.               the declaration files.
  818.  
  819.               Explicit declaration of all variables is considered
  820.               good modern programming practice.   By  using  com-
  821.               piler  options to reject undeclared variables, mis-
  822.               spelled variable names  (or  names  extending  past
  823.               column 72) can be caught at compile time.  Explicit
  824.               declarations  also  greatly   facilitate   changing
  825.               floating-point   precision  with  filters  such  as
  826.               dtoq(1L), dtos(1L), fd2s(1L),  fs2d(1L),  qtod(1L),
  827.               and stod(1L).  These programs are capable of chang-
  828.               ing types of explicit floating-point type  declara-
  829.               tions,  intrinsic  functions,  and  constants,  but
  830.               because they do not carry out rigorous lexical  and
  831.               grammatical  analysis  of  the Fortran source code,
  832.               they cannot provide modified type declarations  for
  833.               undeclared variables.
  834.  
  835.               The setting values are given by the sum of selected
  836.               option values from the following list:
  837.  
  838.               0:    Do not write a declaration file.
  839.  
  840.               1:    Write a declaration file.
  841.  
  842.               2:    Normally, all variables are included  in  the
  843.                     declaration  file.  With this option, include
  844.                     only undeclared variables.  This  setting  is
  845.                     useful  if  you  want to check for undeclared
  846.                     variables, since Fortran  source  files  with
  847.                     all  variables  properly  declared  will  not
  848.                     result in a .dcl  file.   With  this  option,
  849.                     common  blocks and namelist lists will not be
  850.                     included in the declaration  file,  since  by
  851.                     their nature they cannot be undeclared.
  852.  
  853.  
  854.  
  855.  
  856.                            2 June 1995                         13
  857.  
  858.  
  859.  
  860.  
  861.  
  862. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  863.  
  864.  
  865.               4:    The  declarations  are normally prettyprinted
  866.                     to line up neatly in common  columns,  as  in
  867.                     the  declaration files output by the Extended
  868.                     PFORT Verifier, pfort(1L).  This option value
  869.                     selects  instead compact output, without col-
  870.                     umn alignment.
  871.  
  872.               8:    Causes continuation lines to  be  used  where
  873.                     permissible.   The  default is to begin a new
  874.                     declaration on each  line.   This  option  is
  875.                     appropriate  to  use with the option for com-
  876.                     pact output.
  877.  
  878.               16:   Output Fortran keywords in lowercase, instead
  879.                     of the default uppercase.
  880.  
  881.               32:   Output  variables and constants in lowercase,
  882.                     instead of the default uppercase.   Character
  883.                     string  constants  are  not  affected by this
  884.                     option.
  885.  
  886.               64:   Omit declarations of internal  integer  vari-
  887.                     ables  produced  by the SFTRAN3 preprocessor,
  888.                     xsf3(1L),  as  part  of  the  translation  of
  889.                     structured  Fortran  statements  to  ordinary
  890.                     Fortran.  These variables have  six-character
  891.                     names of the form NPRddd, NXdddd, N2dddd, and
  892.                     N3dddd, where d is a decimal digit.   Because
  893.                     they  are  invisible  in  the  SFTRAN3 source
  894.                     code, and will change if the SFTRAN3 code  is
  895.                     modified,   such   variables  should  not  be
  896.                     explicitly declared.   Instead,  they  should
  897.                     just  assume the default Fortran INTEGER data
  898.                     type based on their initial letter, N.
  899.  
  900.               128:  Use an asterisk as the comment character; the
  901.                     default is otherwise 'C'.
  902.  
  903.               256:  Use  'c' instead of 'C' or '*' as the comment
  904.                     character.
  905.  
  906.               If any non-zero value is specified,  then  declara-
  907.               tion  output  is  selected, even if the value 1 was
  908.               not included in the sum.
  909.  
  910.               The declaration files contain distinctive  comments
  911.               that  mark  the  start  and end of declarations for
  912.               each program unit, to facilitate using text  editor
  913.               macros  for  merging the declarations back into the
  914.               source code.
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.                            2 June 1995                         14
  923.  
  924.  
  925.  
  926.  
  927.  
  928. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  929.  
  930.  
  931.        -novice
  932.                This flag is intended to provide more helpful out-
  933.               put for beginners.  It has two effects:
  934.  
  935.               (a) provides  an extra message to the effect that a
  936.                   function that is used but not defined  anywhere
  937.                   might  be  an  array  which  the user forgot to
  938.                   declare in a  DIMENSION  statement  (since  the
  939.                   syntax  of  an  array  reference is the same as
  940.                   that of a function reference).
  941.  
  942.               (b) modifies the form of  the  error  messages  and
  943.                   warnings.    If  the  flag  is  turned  off  by
  944.                   -nonovice, these  messages  are  printed  in  a
  945.                   style more resembling UNIX lint.
  946.  
  947.               Default = yes.
  948.  
  949.               In  versions  of  ftnchek prior to 2.6, this option
  950.               could take on various numerical values, as a way of
  951.               controlling  various  classes  of  warnings.  These
  952.               warnings are now controlled individually  by  their
  953.               own  flags.   Novice  level 1 is now handled by the
  954.               -array flag; level 2 has been eliminated;  level  3
  955.               is  equivalent now to setting -novice to yes; level
  956.               4 is handled by the -pure flag.
  957.  
  958.  
  959.  
  960.        -output=filename
  961.                This setting is provided for convenience  on  sys-
  962.               tems  which do not allow easy redirection of output
  963.               from programs.  When this  setting  is  given,  the
  964.               output which normally appears on the screen will be
  965.               sent instead to the  named  file.   Note,  however,
  966.               that operational errors of ftnchek itself (e.g. out
  967.               of space or cannot open file) will still be sent to
  968.               the  screen.   The  extension  for  the filename is
  969.               optional, and if no extension is given, the  exten-
  970.               sion .lis will be used.
  971.  
  972.  
  973.  
  974.        -portability
  975.                 ftnchek  will give warnings for a variety of non-
  976.               portable usages.  Examples include the use of  tabs
  977.               except  in  comments  or inside strings, the use of
  978.               Hollerith constants, and the equivalencing of vari-
  979.               ables  of  different  data types.  This option does
  980.               not produce warnings for  supported  extensions  to
  981.               the  Fortran  77  Standard,  which  may  also cause
  982.               portability problems.  To catch those, use the -f77
  983.               option.  Default = no.
  984.  
  985.  
  986.  
  987.  
  988.                            2 June 1995                         15
  989.  
  990.  
  991.  
  992.  
  993.  
  994. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  995.  
  996.  
  997.               See  also:  -backslash,  -f77, -hollerith, -pretty,
  998.               -wordsize.
  999.  
  1000.  
  1001.  
  1002.        -pretty
  1003.                Controls certain messages related to  the  appear-
  1004.               ance  of  the source code.  These warn about things
  1005.               that might be deceptive to the reader.   Default  =
  1006.               yes.
  1007.  
  1008.               The  warnings  controlled by this flag include such
  1009.               things as comments that are interspersed among  the
  1010.               continuation  lines  of  a statement, lack of space
  1011.               between a keyword and a  following  variable  name,
  1012.               and statement lines containing characters past col-
  1013.               umn 72.
  1014.  
  1015.               See also: -f77, -portability.
  1016.  
  1017.  
  1018.  
  1019.        -project
  1020.                ftnchek will  create  a  project  file  from  each
  1021.               source  file  that  is  input while this flag is in
  1022.               effect.  The project file will be  given  the  same
  1023.               name  as  the input file, but with the extension .f
  1024.               or .for replaced by .prj.  (If input is from  stan-
  1025.               dard input, the project file is named ftnchek.prj.)
  1026.               Default = no.
  1027.  
  1028.               A project file contains a  summary  of  information
  1029.               from the source file, for use in checking agreement
  1030.               among FUNCTION, SUBROUTINE, and  COMMON  usages  in
  1031.               other files.  It allows incremental checking, which
  1032.               saves time whenever you have a large set  of  files
  1033.               containing shared subroutines, most of which seldom
  1034.               change.  You can run ftnchek once on each file with
  1035.               the  -project flag set, creating the project files.
  1036.               Usually you would also set the -library and  -noex-
  1037.               tern  flags  at  this  time,  to  suppress messages
  1038.               relating to consistency  with  other  files.   Only
  1039.               error  messages  pertaining  to each file by itself
  1040.               will be printed  at  this  time.   Thereafter,  run
  1041.               ftnchek  without  these  flags  on  all the project
  1042.               files together, to check consistency among the dif-
  1043.               ferent  files.   All messages internal to the indi-
  1044.               vidual files will now be omitted.  Only when a file
  1045.               is  altered will a new project file need to be made
  1046.               for it.
  1047.  
  1048.               Naturally, when the -project flag is  set,  ftnchek
  1049.               will not read project files as input.
  1050.  
  1051.  
  1052.  
  1053.  
  1054.                            2 June 1995                         16
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1061.  
  1062.  
  1063.               Project  files  contain only information needed for
  1064.               checking agreement between files.  This means  that
  1065.               a  project  file is of no use if all modules of the
  1066.               complete program are contained in a single file.
  1067.  
  1068.               A more detailed discussion is given in the  section
  1069.               on Using Project Files.
  1070.  
  1071.  
  1072.  
  1073.        -pure   Assume functions are ``pure'', i.e., they will not
  1074.               have side effects by modifying their  arguments  or
  1075.               variables  in a COMMON block.  When this flag is in
  1076.               effect, ftnchek will base its determination of  set
  1077.               and  used  status  of  the  actual arguments on the
  1078.               assumption that arguments passed to a function  are
  1079.               not  altered.   It  will  also issue a warning if a
  1080.               function is found to modify any of its arguments or
  1081.               any COMMON variables.  Default = yes.
  1082.  
  1083.               When  this  flag  is  turned  off, actual arguments
  1084.               passed to functions will be handled the same way as
  1085.               actual arguments passed to subroutines.  This means
  1086.               that ftnchek will assume that arguments may be mod-
  1087.               ified  by the functions.  No warnings will be given
  1088.               if a  function  is  found  to  have  side  effects.
  1089.               Because  stricter checking is possible if functions
  1090.               are assumed to be pure, you should turn  this  flag
  1091.               off  only  if  your program actually uses functions
  1092.               with side effects.
  1093.  
  1094.  
  1095.  
  1096.        -reference
  1097.                Specifies that a who-calls-who table  be  printed.
  1098.               This table lists each subprogram followed by a list
  1099.               of the routines it calls.  Default = no.
  1100.  
  1101.               The reference list omits routines called by  unused
  1102.               library  modules.  Thus it contains the same infor-
  1103.               mation as for the -calltree flag, namely the  hier-
  1104.               archy of subprogram calls, but printed in a differ-
  1105.               ent  format.   This  prints  out  a   breadth-first
  1106.               traversal of the call tree whereas -calltree prints
  1107.               out a depth-first traversal.  If both -calltree and
  1108.               -reference flags are given, only the reference form
  1109.               of the table will be produced.
  1110.  
  1111.               See also: -calltree,  -crossref,  -library,  -sort,
  1112.               -symtab.
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.                            2 June 1995                         17
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1127.  
  1128.  
  1129.        -resource
  1130.                 Prints the amount of resources used by ftnchek in
  1131.               processing the program.  This listing may be useful
  1132.               in  analyzing the size and complexity of a program.
  1133.               It can also  help  in  choosing  larger  sizes  for
  1134.               ftnchek's  internal tables if they are too small to
  1135.               analyze a particular program.  Default = no.
  1136.  
  1137.               In this listing, the term  ``chunk  size''  is  the
  1138.               size of the blocks of memory allocated to store the
  1139.               item in question, in units of the size of one item,
  1140.               not necessarily in bytes.  When the initially allo-
  1141.               cated space is filled up, more memory is  allocated
  1142.               in chunks of this size.  The following is an expla-
  1143.               nation of the items printed:
  1144.  
  1145.               Source lines processed:
  1146.                   Total number of lines of  code,  with  separate
  1147.                   totals  for  statement lines and comment lines.
  1148.                   Comment lines include lines with 'C' or '*'  in
  1149.                   column  1 as well as blank lines and lines con-
  1150.                   taining  only  an  inline  comment.   Statement
  1151.                   lines are all other lines, including lines that
  1152.                   have an inline  comment  following  some  code.
  1153.                   Continuation  lines  are  counted  as  separate
  1154.                   lines.  Lines in include files are counted each
  1155.                   time the file is included.
  1156.  
  1157.               Total executable statements:
  1158.                   Number of statements in the program, other than
  1159.                   specification, data,  statement-function,  FOR-
  1160.                   MAT, ENTRY, and END statements.
  1161.  
  1162.               Total number of modules:
  1163.                   A  module is any external subprogram, including
  1164.                   the main program, subroutines,  functions,  and
  1165.                   block  data  units.   This  count is of modules
  1166.                   defined within the source, not  modules  refer-
  1167.                   enced.   Statement  functions are not included.
  1168.                   A subprogram with multiple entry points is only
  1169.                   counted once.
  1170.  
  1171.               Max identifier name chars:
  1172.                   Number  of  characters used for storing identi-
  1173.                   fier names.  An identifier is a variable,  sub-
  1174.                   program, or common block name.  Local names are
  1175.                   those  of  local  variables  in  a  subprogram,
  1176.                   whereas  global  names  refer to subprogram and
  1177.                   common block names, as well as  dummy  argument
  1178.                   names  and common variable names.  Actual argu-
  1179.                   ment text (up to 15 characters for  each  argu-
  1180.                   ment)  is  also  included here.  The space used
  1181.                   for local names is recovered at the end of each
  1182.                   module,  whereas  the  global space grows until
  1183.  
  1184.  
  1185.  
  1186.                            2 June 1995                         18
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1193.  
  1194.  
  1195.                   the whole program is analyzed.   Unfortunately,
  1196.                   this figure may include some common block names
  1197.                   and arguments stored more than once, although a
  1198.                   heuristic is used that will avoid duplicates in
  1199.                   many cases.
  1200.  
  1201.               Max token text chars:
  1202.                   A token is the smallest syntactic unit  of  the
  1203.                   FORTRAN  language above the level of individual
  1204.                   characters. For instance a token can be a vari-
  1205.                   able  name, a numerical constant, a quoted text
  1206.                   string, or a punctuation character.  Token text
  1207.                   is  stored  while  a module is being processed.
  1208.                   For technical reasons, single-character  tokens
  1209.                   are not included in this total.  Items that are
  1210.                   not represented in  the  symbol  table  may  be
  1211.                   duplicated.  The space for token text is recov-
  1212.                   ered at the end of each module, so this  figure
  1213.                   represents the maximum for any one module.
  1214.  
  1215.               Max local symbols:
  1216.                   This  is  the  largest number of entries in the
  1217.                   local symbol table for any module.  Local  sym-
  1218.                   bol  table  entries  include  all variables and
  1219.                   parameters, common block names, statement func-
  1220.                   tions, external subprograms and intrinsic func-
  1221.                   tions referenced by the module.   Literal  con-
  1222.                   stants  are  not  stored  in  the  local symbol
  1223.                   table.
  1224.  
  1225.               Max global symbols:
  1226.                   This is the number of  entries  in  the  global
  1227.                   symbol  table at the end of processing.  Global
  1228.                   symbol table entries include  external  subpro-
  1229.                   gram  and  common block names.  Intrinsic func-
  1230.                   tions and statement functions are not included.
  1231.  
  1232.               Max number of tokenlists:
  1233.                   A token list is a sequence of tokens represent-
  1234.                   ing the actual or dummy argument list of a sub-
  1235.                   program,  or  the list of variables in a common
  1236.                   block or namelist.  Therefore this number  rep-
  1237.                   resents   the  largest  sum  of  COMMON,  CALL,
  1238.                   NAMELIST  and  ENTRY  statements  and  function
  1239.                   invocations  for  any one module.  The space is
  1240.                   recovered at the end of each module.
  1241.  
  1242.               Max token list/tree space:
  1243.                   This is the largest number of tokens in all the
  1244.                   token  lists and token trees of any one module.
  1245.                   A  token  tree  is  formed  when  analyzing  an
  1246.                   expression: each operand is a leaf of the tree,
  1247.                   and the operators  are  the  nodes.   Therefore
  1248.                   this   number  is  a  measure  of  the  maximum
  1249.  
  1250.  
  1251.  
  1252.                            2 June 1995                         19
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1259.  
  1260.  
  1261.                   complexity  of  an  individual   module.    For
  1262.                   instance  a  module  with  many long arithmetic
  1263.                   expressions will have a high number.  Note that
  1264.                   unlike  token  text described above, the number
  1265.                   of tokens is independent of the length  of  the
  1266.                   variable  names  or  literal  constants  in the
  1267.                   expressions.
  1268.  
  1269.               Number of subprogram invocations:
  1270.                   This is the sum over all modules of the  number
  1271.                   of  CALL  statements  and  function invocations
  1272.                   (except intrinsic functions and statement func-
  1273.                   tions).
  1274.  
  1275.               Number of common block decls:
  1276.                   This  is the sum over all modules of the number
  1277.                   of common block declarations.   That  is,  each
  1278.                   declaration of a block in a different module is
  1279.                   counted separately.  (The standard allows  mul-
  1280.                   tiple  declarations  of a block within the same
  1281.                   module; these are counted as only one  declara-
  1282.                   tion since they are equivalent to a single long
  1283.                   declaration.)
  1284.  
  1285.               Number of array dim & param ptrs:
  1286.                   This is the sum over all modules of the  number
  1287.                   of  array  dimension  and  parameter definition
  1288.                   text strings saved for  use  by  the  -makedcls
  1289.                   option.   The length of the text strings is not
  1290.                   counted.  Each dimension of a  multidimensional
  1291.                   array is counted separately.
  1292.  
  1293.               These  numbers are obviously not the same when pro-
  1294.               ject files are used in place of the original source
  1295.               code.   Even the numbers for global entities may be
  1296.               different,  since  some  redundant  information  is
  1297.               eliminated in project files.
  1298.  
  1299.  
  1300.  
  1301.        -sixchar
  1302.                One of the goals of the ftnchek program is to help
  1303.               users to  write  portable  Fortran  programs.   One
  1304.               potential  source  of  nonportability is the use of
  1305.               variable names that are longer than six characters.
  1306.               Some  compilers  just  ignore the extra characters.
  1307.               This behavior could potentially lead to two differ-
  1308.               ent  variables  being  considered as the same.  For
  1309.               instance, variables  named  AVERAGECOST  and  AVER-
  1310.               AGEPRICE  are the same in the first six characters.
  1311.               If you wish to catch such possible  conflicts,  use
  1312.               this flag.  Default = no.
  1313.  
  1314.               Use the -f77 flag if you want to list all variables
  1315.  
  1316.  
  1317.  
  1318.                            2 June 1995                         20
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1325.  
  1326.  
  1327.               longer than six characters, not  just  those  pairs
  1328.               that are the same in the first six.
  1329.  
  1330.               See also: -f77, -portability.
  1331.  
  1332.  
  1333.  
  1334.        -sort    Specifies  that a sorted list of all modules used
  1335.               in the program be printed.  This list is in  ``pre-
  1336.               requisite'' order, i.e. each module is printed only
  1337.               after all the modules from which it is called  have
  1338.               been  printed.  This is also called a ``topological
  1339.               sort'' of the call tree.   Each  module  is  listed
  1340.               only  once.  Routines that are not in the call tree
  1341.               of the main program are omitted.  If there are  any
  1342.               cycles  in the call graph (illegal in standard For-
  1343.               tran) they will be detected and diagnosed.  Default
  1344.               = no.
  1345.  
  1346.               See   also:   -calltree,   -crossref,   -reference,
  1347.               -symtab.
  1348.  
  1349.  
  1350.  
  1351.        -symtab
  1352.                A symbol table will be printed out for  each  mod-
  1353.               ule,  listing all identifiers mentioned in the mod-
  1354.               ule.  This table gives the name of  each  variable,
  1355.               its  datatype,  and  the  number  of dimensions for
  1356.               arrays.  An asterisk (*) indicates that  the  vari-
  1357.               able  has  been implicitly typed, rather than being
  1358.               named in an explicit  type  declaration  statement.
  1359.               The table also lists all subprograms invoked by the
  1360.               module, all COMMON blocks declared, etc.  Default =
  1361.               no.
  1362.  
  1363.               See  also: -calltree, -crossref, -list, -reference,
  1364.               -sort.
  1365.  
  1366.  
  1367.  
  1368.        -tab    Accept DEC-style  tab-formatted  source.   A  line
  1369.               beginning  with an initial tab will be treated as a
  1370.               new statement line unless the character  after  the
  1371.               tab is a nonzero digit, in which case it is treated
  1372.               as a continuation line.  The next column after  the
  1373.               tab  or  continuation mark is taken as column 7.  A
  1374.               warning will be given in the case where the line is
  1375.               a  continuation,  if  -f77 is in effect.  Default =
  1376.               no.
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.                            2 June 1995                         21
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1391.  
  1392.  
  1393.        -truncation
  1394.                 Warn  about  possible  truncation  (or  roundoff)
  1395.               errors.   Most  of  these  are  related  to integer
  1396.               arithmetic.  The warnings enabled when this flag is
  1397.               in effect are:
  1398.  
  1399.               (a) use  of  the result of integer division where a
  1400.                   real result seems intended (namely as an  expo-
  1401.                   nent,  or if the quotient is later converted to
  1402.                   real);
  1403.  
  1404.               (b) division in an integer constant expression that
  1405.                   yields a result of zero;
  1406.  
  1407.               (c) exponentiation  of  an  integer  by  a negative
  1408.                   integer (which  yields  zero  unless  the  base
  1409.                   integer is 1 in magnitude);
  1410.  
  1411.               (d) use  of  a  non-integer  array  subscript or DO
  1412.                   index;
  1413.  
  1414.               (e) conversion of any real type to integer, or con-
  1415.                   version of a complex value to real or integer;
  1416.  
  1417.               (f) conversion  of a double precision value to sin-
  1418.                   gle precision, or vice-versa (promotion).  This
  1419.                   applies  both  to  real  types  and  to complex
  1420.                   types.
  1421.  
  1422.               Default = yes.
  1423.  
  1424.               Note: warnings about  truncating  type  conversions
  1425.               are given only when the conversion is done automat-
  1426.               ically,  e.g.   by  an  assignment  statement.   If
  1427.               intrinsic functions such as INT are used to perform
  1428.               the conversion, no warning is given.  Promotions of
  1429.               real  types  from  single  to  double precision are
  1430.               included here because such conversions imply a pos-
  1431.               sible  loss of accuracy that is similar to the cor-
  1432.               responding demotions.
  1433.  
  1434.               See also: -portability, -wordsize.
  1435.  
  1436.  
  1437.  
  1438.        -usage=num
  1439.                Warn about unused or possible uninitialized  vari-
  1440.               ables and unused common blocks.
  1441.  
  1442.               The meanings of the setting values are as follows:
  1443.  
  1444.               0:  no warnings.
  1445.  
  1446.               1:  warn  if  variables are (or may be) used before
  1447.  
  1448.  
  1449.  
  1450.                            2 June 1995                         22
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1457.  
  1458.  
  1459.                   they are set.
  1460.  
  1461.               2:  warn if variables are declared or set but never
  1462.                   used.
  1463.  
  1464.               3:  give both types of warnings.
  1465.  
  1466.               Default = 3.
  1467.  
  1468.               Sometimes ftnchek makes a mistake about these warn-
  1469.               ings.  Usually it errs on  the  side  of  giving  a
  1470.               warning  where no problem exists, but in rare cases
  1471.               it may fail to warn where the problem  does  exist.
  1472.               See the section on Bugs for examples.  If variables
  1473.               are equivalenced, the rule used by ftnchek is  that
  1474.               a reference to any variable implies the same refer-
  1475.               ence to all variables it is equivalenced  to.   For
  1476.               arrays,  the  rule is that a reference to any array
  1477.               element is treated as a reference to  all  elements
  1478.               of the array.
  1479.  
  1480.               This  setting  controls warnings not only for local
  1481.               variables but also for variables in COMMON  blocks.
  1482.               Level  2  also  controls whether a warning is given
  1483.               when an entire COMMON block is unused.  When check-
  1484.               ing  for  used-before-set  errors  involving COMMON
  1485.               variables, ftnchek does not do  a  thorough  enough
  1486.               analysis of the calling sequence to know which rou-
  1487.               tines are called before others.  So warnings  about
  1488.               this  type of error will only be given for cases in
  1489.               which a variable is used in some  routine  but  not
  1490.               set  in any other routine.   Checking of individual
  1491.               COMMON variables is done only if the  -common  set-
  1492.               ting is 3 (variable by variable agreement).
  1493.  
  1494.               See also: -common, -declare, -volatile.
  1495.  
  1496.  
  1497.  
  1498.        -verbose
  1499.                 This  option  is  on  by default.  Turning it off
  1500.               reduces the amount of  output  relating  to  normal
  1501.               operation,  so  that error messages are more appar-
  1502.               ent.  This option is provided for  the  convenience
  1503.               of  users  who  are checking large suites of files.
  1504.               The eliminated output includes the names of project
  1505.               files,  and  the  message  reporting that no syntax
  1506.               errors were found.  (Some of this output is  turned
  1507.               back on by the -list and -symtab options.)  Default
  1508.               = yes.
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.                            2 June 1995                         23
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1523.  
  1524.  
  1525.        -volatile
  1526.                Assume that COMMON blocks are volatile.  Default =
  1527.               no.
  1528.  
  1529.               Many  Fortran  programmers  assume  that variables,
  1530.               whether local or in COMMON, are static,  i.e.  that
  1531.               once  assigned a value, they retain that value per-
  1532.               manently until assigned a different  value  by  the
  1533.               program.   However, in fact the Fortran 77 Standard
  1534.               does not require this to be the case.  Local  vari-
  1535.               ables may become undefined between activations of a
  1536.               module in which they are declared.  Similarly, COM-
  1537.               MON  blocks  may  become  undefined if no module in
  1538.               which they are declared is active.  (The  technical
  1539.               term   for  this  behavior  is  ``automatic'',  but
  1540.               ftnchek uses the  word  ``volatile''  since  it  is
  1541.               clearer  to the nonspecialist.)  Only COMMON blocks
  1542.               declared in a SAVE statement, or  declared  in  the
  1543.               main  program  or in a block data subprogram remain
  1544.               defined as long as the program is  running.   Vari-
  1545.               ables  and  COMMON blocks that can become undefined
  1546.               at some point are called volatile.
  1547.  
  1548.               If the -volatile flag is turned  on,  ftnchek  will
  1549.               warn  you if it finds a volatile COMMON block.  If,
  1550.               at the same time, the -usage  setting  is  1  or  3
  1551.               (check  used before set), ftnchek will try to check
  1552.               whether such a block can lose  its  defined  status
  1553.               between  activations  of  the  modules  where it is
  1554.               declared.  ftnchek does not do a very good  job  of
  1555.               this:  the rule used is to see whether the block is
  1556.               declared in two  separated  subtrees  of  the  call
  1557.               tree.   For instance, this would be the case if two
  1558.               modules, both called from the main program,  shared
  1559.               a  volatile  COMMON block.  A block can also become
  1560.               undefined between two successive calls of the  same
  1561.               subprogram, but ftnchek is not smart enough to tell
  1562.               whether a subprogram can be called more than  once,
  1563.               so this case is not checked for.
  1564.  
  1565.               The  -volatile flag does not affect the way ftnchek
  1566.               checks the usage of local variables.
  1567.  
  1568.               See also: -common, -usage.
  1569.  
  1570.  
  1571.  
  1572.        -wordsize=num
  1573.                Specifies the default word size to be  num  bytes.
  1574.               This  is  the  size of logical and single-precision
  1575.               numeric variables that are not given explicit  pre-
  1576.               cisions.   Double-precision  and  complex variables
  1577.               will be twice this value, and double complex  vari-
  1578.               ables  four  times.   Explicit  precisions for non-
  1579.  
  1580.  
  1581.  
  1582.                            2 June 1995                         24
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1589.  
  1590.  
  1591.               character variables are an extension to the Fortran
  1592.               77  Standard,  and  are  given by type declarations
  1593.               such as REAL*8 X.  Default = 4 bytes.
  1594.  
  1595.               If you want to change the built-in default value of
  1596.               this  setting,  compile ftnchek with the macro name
  1597.               BpW (Bytes per Word) set  to  the  desired  default
  1598.               value.   This  is not critical: the word size value
  1599.               does not matter  for  checking  standard-conforming
  1600.               programs  that  do  not declare explicit precisions
  1601.               for non-character variables or store Hollerith data
  1602.               in  variables.   This  setting also does not affect
  1603.               the default size of character variables,  which  is
  1604.               always   1  byte.   Hollerith  constants  also  are
  1605.               assumed to occupy 1 byte per character.
  1606.  
  1607.               The word size is used to determine whether  trunca-
  1608.               tion  occurs in assignment statements, and to catch
  1609.               precision mismatches in subprogram  argument  lists
  1610.               and  common  block  lists.  The exact warnings that
  1611.               are issued will  depend  on  the  status  of  other
  1612.               flags.   Under both the -portability or -nowordsize
  1613.               flags, any mixing of explicit with  default  preci-
  1614.               sion  objects  (character expressions not included)
  1615.               is  warned  about.   This  applies  to   arithmetic
  1616.               expressions  containing  both types of objects, and
  1617.               to  subprogram  arguments  and  COMMON   variables.
  1618.               Under  the -truncation flag, a warning is given for
  1619.               assignment of an expression to a  shorter  variable
  1620.               of  the same type, or for promotion of a lower pre-
  1621.               cision value to higher precision in  an  arithmetic
  1622.               expression or an assignment statement.
  1623.  
  1624.               Giving  a  word  size  of 0, or equivalently, using
  1625.               -nowordsize means that no  default  value  will  be
  1626.               assumed.   Use  this instead of -portability if you
  1627.               want to check only for those aspects of portability
  1628.               related  to  mixing default and explicit precision,
  1629.               for example to flag places where REAL*8 is  treated
  1630.               as equivalent to DOUBLE PRECISION.
  1631.  
  1632.               See also: -portability, -truncation.
  1633.  
  1634.  
  1635.  
  1636.        -wrap=col
  1637.                 Controls  the  wrapping  of error messages.  Long
  1638.               error messages that would run  past  the  specified
  1639.               column  will  be  broken  up  into  separate  lines
  1640.               between the words of the message for  better  read-
  1641.               ability.  If turned off with -nowrap, each separate
  1642.               error message will be printed on one line,  leaving
  1643.               it  up  to the display to wrap the message or trun-
  1644.               cate it.  Default = 79.
  1645.  
  1646.  
  1647.  
  1648.                            2 June 1995                         25
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1655.  
  1656.  
  1657. CHANGING THE DEFAULTS
  1658.         ftnchek includes a mechanism  for  changing  the  default
  1659.        values  of  all options by defining environment variables.
  1660.        When ftnchek starts up, it looks in  its  environment  for
  1661.        any  variables  whose  names are composed by prefixing the
  1662.        string FTNCHEK_ onto the uppercased version of the  option
  1663.        name.   If  such a variable is found, its value is used to
  1664.        specify the default for the corresponding switch  or  set-
  1665.        ting.   In  the case of settings (for example, the -common
  1666.        strictness setting) the value of the environment  variable
  1667.        is  read  as  the  default  setting value.  In the case of
  1668.        switches, the default switch will be taken as true or  yes
  1669.        unless the environment variable has the value 0 or NO.  Of
  1670.        course, command-line options will override these  defaults
  1671.        the same way as they override the built-in defaults.
  1672.  
  1673.        Note  that  the  environment  variable  name  must be con-
  1674.        structed with the full-length option name, which  must  be
  1675.        in uppercase.  For example, to make ftnchek print a source
  1676.        listing  by  default,   set   the   environment   variable
  1677.        FTNCHEK_LIST  to  1 or YES or anything other than 0 or NO.
  1678.        The names  FTNCHEK_LIS  (not  the  full  option  name)  or
  1679.        ftnchek_list (lower case) would not be recognized.
  1680.  
  1681.  
  1682.        Here are some examples of how to set environment variables
  1683.        on various systems.  For simplicity, all the examples  set
  1684.        the default -list switch to YES.
  1685.  
  1686.        1. UNIX, Bourne shell:        $  FTNCHEK_LIST=YES;  export
  1687.        FTNCHEK_LIST
  1688.  
  1689.        2. UNIX, C shell:             % setenv FTNCHEK_LIST YES
  1690.  
  1691.        3. VAX/VMS:                   $ DEFINE FTNCHEK_LIST YES
  1692.  
  1693.        4. MSDOS:                     $ SET FTNCHEK_LIST=YES
  1694.  
  1695.  
  1696.  
  1697. USING PROJECT FILES
  1698.         This section contains detailed information on how to  use
  1699.        project files most effectively, and how to avoid some pit-
  1700.        falls.
  1701.  
  1702.        Ordinarily, project  files  should  be  created  with  the
  1703.        -library  flag  in  effect.  In this mode, the information
  1704.        saved in the project file consists of all subprogram  dec-
  1705.        larations, all subprogram invocations not resolved by dec-
  1706.        larations in the same file, and one instance of each  COM-
  1707.        MON  block  declaration.   This  is  the minimum amount of
  1708.        information needed to check agreement between files.
  1709.  
  1710.        If the file contains more than one routine, there are some
  1711.  
  1712.  
  1713.  
  1714.                            2 June 1995                         26
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1721.  
  1722.  
  1723.        possible problems that can arise from creating the project
  1724.        file in library mode, because the calling hierarchy  among
  1725.        routines  defined  within  the file is lost.  Also, if the
  1726.        routines in the file make use of COMMON  blocks  that  are
  1727.        shared  with  routines  in  other files, there will not be
  1728.        enough information saved for the correct checking  of  set
  1729.        and  used  status  of  COMMON  blocks and COMMON variables
  1730.        according to the -usage setting.  Therefore if you plan to
  1731.        use  project  files  when  the  -usage  setting is nonzero
  1732.        (which is the default situation), and if multiple routines
  1733.        in  one  project file share COMMON blocks with routines in
  1734.        other files, the project files should be created with  the
  1735.        -library  flag  turned  off.  In this mode, ftnchek saves,
  1736.        besides the information listed above,  one  invocation  of
  1737.        each  subprogram by any other subprogram in the same file,
  1738.        and all COMMON block declarations.  This  means  that  the
  1739.        project  file will be larger than necessary, and that when
  1740.        it is read in, ftnchek may repeat some inter-module checks
  1741.        that it already did when the project file was created.  If
  1742.        each project file contains only one module,  there  is  no
  1743.        loss  of  information  in  creating  the  project files in
  1744.        library mode.
  1745.  
  1746.        Because of the possible loss of  information  entailed  by
  1747.        creating  a project file with the -library flag in effect,
  1748.        whenever that project file is read in later,  it  will  be
  1749.        treated  as  a library file regardless of the current set-
  1750.        ting of the -library flag.  On the other hand,  a  project
  1751.        file  created  with library mode turned off can be read in
  1752.        later in either mode.
  1753.  
  1754.  
  1755.        Here is an example of how to use the UNIX make utility  to
  1756.        automatically create a new project file each time the cor-
  1757.        responding source file is altered, and to check the set of
  1758.        files  for  consistency.  The example assumes that a macro
  1759.        OBJS has been defined which lists all the names of  object
  1760.        files  to  be  linked  together  to form the complete exe-
  1761.        cutable program.
  1762.  
  1763.            # tell make what a project file suffix is
  1764.            .SUFFIXES: .prj
  1765.  
  1766.            # tell make how to create a .prj file from a .f file
  1767.            .f.prj:
  1768.                    ftnchek -project -noextern -library $<
  1769.  
  1770.            # set up macro PRJS containing project filenames
  1771.            PRJS= $(OBJS:.o=.prj)
  1772.  
  1773.            # "make check" will check everything that has been changed.
  1774.            check: $(PRJS)
  1775.                    ftnchek $(PRJS)
  1776.  
  1777.  
  1778.  
  1779.  
  1780.                            2 June 1995                         27
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1787.  
  1788.  
  1789.  
  1790.  
  1791. AN EXAMPLE
  1792.        The following simple Fortran program illustrates the  mes-
  1793.        sages given by ftnchek.  The program is intended to accept
  1794.        an array of test scores and then compute the  average  for
  1795.        the series.
  1796.  
  1797.  
  1798.        C       AUTHORS: MIKE MYERS AND LUCIA SPAGNUOLO
  1799.        C       DATE:    MAY 8, 1989
  1800.  
  1801.        C       Variables:
  1802.        C               SCORE -> an array of test scores
  1803.        C               SUM ->   sum of the test scores
  1804.        C               COUNT -> counter of scores read in
  1805.        C               I ->     loop counter
  1806.  
  1807.                REAL FUNCTION COMPAV(SCORE,COUNT)
  1808.                    INTEGER SUM,COUNT,J,SCORE(5)
  1809.  
  1810.                    DO 30 I = 1,COUNT
  1811.                        SUM = SUM + SCORE(I)
  1812.        30          CONTINUE
  1813.                    COMPAV = SUM/COUNT
  1814.                END
  1815.  
  1816.  
  1817.                PROGRAM AVENUM
  1818.        C
  1819.        C                       MAIN PROGRAM
  1820.        C
  1821.        C       AUTHOR:   LOIS BIGBIE
  1822.        C       DATE:     MAY 15, 1990
  1823.        C
  1824.        C       Variables:
  1825.        C               MAXNOS -> maximum number of input values
  1826.        C               NUMS    -> an array of numbers
  1827.        C               COUNT   -> exact number of input values
  1828.        C               AVG     -> average returned by COMPAV
  1829.        C               I       -> loop counter
  1830.        C
  1831.  
  1832.                    PARAMETER(MAXNOS=5)
  1833.                    INTEGER I, COUNT
  1834.                    REAL NUMS(MAXNOS), AVG
  1835.                    COUNT = 0
  1836.                    DO 80 I = 1,MAXNOS
  1837.                        READ (5,*,END=100) NUMS(I)
  1838.                        COUNT = COUNT + 1
  1839.        80          CONTINUE
  1840.        100         AVG = COMPAV(NUMS, COUNT)
  1841.                END
  1842.  
  1843.  
  1844.  
  1845.  
  1846.                            2 June 1995                         28
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1853.  
  1854.  
  1855.        The  compiler gives no error messages when this program is
  1856.        compiled.  Yet here is what happens when it is run:
  1857.  
  1858.  
  1859.        $ run average
  1860.        70
  1861.        90
  1862.        85
  1863.        <EOF>
  1864.        $
  1865.  
  1866.  
  1867.        What happened?  Why didn't the program do  anything?   The
  1868.        following  is  the  output from ftnchek when it is used to
  1869.        debug the above program:
  1870.  
  1871.  
  1872.  
  1873.  
  1874.        $ ftnchek -list -symtab average
  1875.  
  1876.        FTNCHEK Version 2.8 May 1995
  1877.  
  1878.        File average.f:
  1879.  
  1880.              1 C       AUTHORS: MIKE MYERS AND LUCIA SPAGNUOLO
  1881.              2 C       DATE:    MAY 8, 1989
  1882.              3
  1883.              4 C       Variables:
  1884.              5 C               SCORE -> an array of test scores
  1885.              6 C               SUM ->   sum of the test scores
  1886.              7 C               COUNT -> counter of scores read in
  1887.              8 C               I ->     loop counter
  1888.              9
  1889.             10         REAL FUNCTION COMPAV(SCORE,COUNT)
  1890.             11             INTEGER SUM,COUNT,J,SCORE(5)
  1891.             12
  1892.             13             DO 30 I = 1,COUNT
  1893.             14                 SUM = SUM + SCORE(I)
  1894.             15 30          CONTINUE
  1895.             16             COMPAV = SUM/COUNT
  1896.                                   ^
  1897.        Warning near line 16 col 20: integer quotient expr converted to real
  1898.             17         END
  1899.             18
  1900.  
  1901.        Module COMPAV: func: real
  1902.  
  1903.        Variables:
  1904.  
  1905.              Name Type Dims     Name Type Dims     Name Type Dims     Name Type Dims
  1906.            COMPAV real         COUNT intg             I intg*            J intg
  1907.             SCORE intg  1        SUM intg
  1908.  
  1909.  
  1910.  
  1911.  
  1912.                            2 June 1995                         29
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1919.  
  1920.  
  1921.        * Variable not declared. Type has been implicitly defined.
  1922.  
  1923.  
  1924.        Warning: Variables declared but never referenced:
  1925.                 J
  1926.  
  1927.        Warning: Variables may be used before set:
  1928.               SUM
  1929.  
  1930.  
  1931.             19
  1932.             20         PROGRAM AVENUM
  1933.             21 C
  1934.             22 C                       MAIN PROGRAM
  1935.             23 C
  1936.             24 C       AUTHOR:   LOIS BIGBIE
  1937.             25 C       DATE:     MAY 15, 1990
  1938.             26 C
  1939.             27 C       Variables:
  1940.             28 C               MAXNOS -> maximum number of input values
  1941.             29 C               NUMS    -> an array of numbers
  1942.             30 C               COUNT   -> exact number of input values
  1943.             31 C               AVG     -> average returned by COMPAV
  1944.             32 C               I       -> loop counter
  1945.             33 C
  1946.             34
  1947.             35             PARAMETER(MAXNOS=5)
  1948.             36             INTEGER I, COUNT
  1949.             37             REAL NUMS(MAXNOS), AVG
  1950.             38             COUNT = 0
  1951.             39             DO 80 I = 1,MAXNOS
  1952.             40                 READ (5,*,END=100) NUMS(I)
  1953.             41                 COUNT = COUNT + 1
  1954.             42 80          CONTINUE
  1955.             43 100         AVG = COMPAV(NUMS, COUNT)
  1956.             44         END
  1957.  
  1958.        Module AVENUM: prog
  1959.  
  1960.        External subprograms referenced:
  1961.  
  1962.            COMPAV: real*
  1963.  
  1964.        Variables:
  1965.  
  1966.              Name Type Dims     Name Type Dims     Name Type Dims     Name Type Dims
  1967.               AVG real         COUNT intg             I intg        MAXNOS intg*
  1968.              NUMS real  1
  1969.  
  1970.        * Variable not declared. Type has been implicitly defined.
  1971.  
  1972.  
  1973.        Warning: Variables set but never used:
  1974.               AVG
  1975.  
  1976.  
  1977.  
  1978.                            2 June 1995                         30
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  1985.  
  1986.  
  1987.         0 syntax errors detected in file average.f
  1988.         6 warnings issued in file average.f
  1989.  
  1990.        Subprogram COMPAV:  argument data type mismatch
  1991.          at position 1:
  1992.            Dummy arg SCORE is type intg  in module COMPAV line 10 file average.f
  1993.            Actual arg NUMS is type real  in module AVENUM line 43 file average.f
  1994.  
  1995.  
  1996.        According to ftnchek, the program contains variables which
  1997.        may be used before they are assigned an initial value, and
  1998.        variables which are not needed.  ftnchek  also  warns  the
  1999.        user  that  an  integer  quotient  has been converted to a
  2000.        real. This may assist the user in catching  an  unintended
  2001.        roundoff error.  Since the -symtab flag was given, ftnchek
  2002.        prints out a table containing identifiers from  the  local
  2003.        module  and  their  corresponding  datatype  and number of
  2004.        dimensions.  Finally, ftnchek warns that the function COM-
  2005.        PAV is not used with the proper type of arguments.
  2006.  
  2007.        With ftnchek's help, we can debug the program.  We can see
  2008.        that there were the following errors:
  2009.  
  2010.        1.  SUM and COUNT  should  have  been  converted  to  real
  2011.            before doing the division.
  2012.  
  2013.        2.  SUM  should have been initialized to 0 before entering
  2014.            the loop.
  2015.  
  2016.        3.  AVG was never printed out after being calculated.
  2017.  
  2018.        4.  NUMS should have  been  declared  INTEGER  instead  of
  2019.            REAL.
  2020.  
  2021.        We also see that I, not J, should have been declared INTE-
  2022.        GER in function COMPAV. Also, MAXNOS was not  declared  as
  2023.        INTEGER, nor COMPAV as REAL, in program AVENUM.  These are
  2024.        not errors, but they may  indicate  carelessness.   As  it
  2025.        happened,  the  default  type of these variables coincided
  2026.        with the intended type.
  2027.  
  2028.        Here is the corrected program, and its output when run:
  2029.  
  2030.  
  2031.        C       AUTHORS: MIKE MYERS AND LUCIA SPAGNUOLO
  2032.        C       DATE:    MAY 8, 1989
  2033.        C
  2034.        C       Variables:
  2035.        C               SCORE -> an array of test scores
  2036.        C               SUM ->   sum of the test scores
  2037.        C               COUNT -> counter of scores read in
  2038.        C               I ->     loop counter
  2039.        C
  2040.               REAL FUNCTION COMPAV(SCORE,COUNT)
  2041.  
  2042.  
  2043.  
  2044.                            2 June 1995                         31
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2051.  
  2052.  
  2053.                    INTEGER SUM,COUNT,I,SCORE(5)
  2054.        C
  2055.                    SUM = 0
  2056.                    DO 30 I = 1,COUNT
  2057.                        SUM = SUM + SCORE(I)
  2058.        30          CONTINUE
  2059.                    COMPAV = FLOAT(SUM)/FLOAT(COUNT)
  2060.                END
  2061.        C
  2062.        C
  2063.                PROGRAM AVENUM
  2064.        C
  2065.        C                       MAIN PROGRAM
  2066.        C
  2067.        C       AUTHOR:   LOIS BIGBIE
  2068.        C       DATE:     MAY 15, 1990
  2069.        C
  2070.        C       Variables:
  2071.        C               MAXNOS -> maximum number of input values
  2072.        C               NUMS    -> an array of numbers
  2073.        C               COUNT   -> exact number of input values
  2074.        C               AVG     -> average returned by COMPAV
  2075.        C               I       -> loop counter
  2076.        C
  2077.        C
  2078.                    INTEGER MAXNOS
  2079.                    PARAMETER(MAXNOS=5)
  2080.                    INTEGER I, NUMS(MAXNOS), COUNT
  2081.                    REAL AVG,COMPAV
  2082.                    COUNT = 0
  2083.                    DO 80 I = 1,MAXNOS
  2084.                        READ (5,*,END=100) NUMS(I)
  2085.                        COUNT = COUNT + 1
  2086.        80          CONTINUE
  2087.        100         AVG = COMPAV(NUMS, COUNT)
  2088.                    WRITE(6,*) 'AVERAGE =',AVG
  2089.                END
  2090.  
  2091.        $ run average
  2092.        70
  2093.        90
  2094.        85
  2095.        <EOF>
  2096.        AVERAGE =   81.66666
  2097.        $
  2098.  
  2099.  
  2100.        With ftnchek's help, our program is a success!
  2101.  
  2102.  
  2103. INTERPRETING THE OUTPUT
  2104.        The messages given by  ftnchek  include  not  only  syntax
  2105.        errors  but also warnings and informational messages about
  2106.        things that are legal Fortran but that may indicate errors
  2107.  
  2108.  
  2109.  
  2110.                            2 June 1995                         32
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2117.  
  2118.  
  2119.        or carelessness.  Most of these messages can be turned off
  2120.        by command-line options.  Which option controls each  mes-
  2121.        sage  depends  on the nature of the condition being warned
  2122.        about.  See the descriptions of the command-line flags  in
  2123.        the  previous  sections, and of individual messages below.
  2124.        Each message is prefixed with a word or phrase  indicating
  2125.        the nature of the condition and its severity.
  2126.  
  2127.        ``Error'' means a syntax error.  The simplest kind of syn-
  2128.        tax errors are typographical errors,  for  example  unbal-
  2129.        anced  parentheses or misspelling of a keyword.  This type
  2130.        of error is caught by the  parser  and  appears  with  the
  2131.        description ``parse error'' or ``syntax error'' (depending
  2132.        on whether the parser was built using GNU  bison  or  UNIX
  2133.        yacc  respectively).  This type of error message cannot be
  2134.        suppressed.  Be aware that this type of error often  means
  2135.        that  ftnchek  has  not properly interpreted the statement
  2136.        where the error occurs, so that  its  subsequent  checking
  2137.        operations  will be compromised.  You should eliminate all
  2138.        syntax errors before proceeding  to  interpret  the  other
  2139.        messages ftnchek gives.
  2140.  
  2141.        ``Warning:  Nonstandard syntax'' indicates an extension to
  2142.        Fortran that ftnchek supports but that is not according to
  2143.        the  Fortran  77  Standard.   The  extensions that ftnchek
  2144.        accepts are described in the section on Extensions  below.
  2145.        One  example  is the DO ... ENDDO construction.  If a pro-
  2146.        gram uses these extensions, warnings will be given only if
  2147.        the -f77 flag is set.  The default is to give no warnings.
  2148.  
  2149.        ``Warning'' in other cases means a condition that is  sus-
  2150.        picious  but  that  may or may not be a programming error.
  2151.        Frequently these conditions are legal under the  standard.
  2152.        Some are illegal but do not fall under the heading of syn-
  2153.        tax errors.  Usage errors are one example.  These refer to
  2154.        the  possibility that a variable may be used before it has
  2155.        been assigned a value (generally  an  error),  or  that  a
  2156.        variable  is  declared  but  never  used (harmless but may
  2157.        indicate carelessness).  The amount of checking for  usage
  2158.        errors  is controlled by the -usage flag, which is set for
  2159.        the maximum amount of checking by default.
  2160.  
  2161.        Truncation warnings cover situations in which accuracy may
  2162.        be  lost unintentionally, for example when a double preci-
  2163.        sion value is assigned to a real variable.  These warnings
  2164.        are  controlled  by  the  -truncation flag, which is on by
  2165.        default.
  2166.  
  2167.        ``Nonportable usage'' warns about some  feature  that  may
  2168.        not  be  accepted  by some compilers even though it is not
  2169.        contrary to the Fortran 77 Standard, or that may cause the
  2170.        program  to  perform  differently  on different platforms.
  2171.        For example, equivalencing real and integer  variables  is
  2172.        usually a non-portable practice.  The use of extensions to
  2173.  
  2174.  
  2175.  
  2176.                            2 June 1995                         33
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2183.  
  2184.  
  2185.        the standard language is, of  course,  another  source  of
  2186.        non-portability,  but  this is handled as a separate case.
  2187.        To check a program for true portability, both the  -porta-
  2188.        bility  and  the -f77 flags should be used.  They are both
  2189.        turned off by default.  The -wordsize setting is  provided
  2190.        to  check  only  those nonportable usages that depend on a
  2191.        particular machine wordsize.
  2192.  
  2193.        ``Possibly misleading appearance'' is used for legal  con-
  2194.        structions  that  may not mean what they appear to mean at
  2195.        first glance.  For  example,  Fortran  is  insensitive  to
  2196.        blank  space, so extraneous space within variable names or
  2197.        the lack of space between a keyword  and  a  variable  can
  2198.        convey the wrong impression to the reader.  These messages
  2199.        can be suppressed by turning off the -pretty  flag,  which
  2200.        is on by default.
  2201.  
  2202.        Other messages that are given after all the files are pro-
  2203.        cessed, and having to do with agreement  between  modules,
  2204.        do  not  use  the word ``warning'' but generally fall into
  2205.        that category.  Examples include type  mismatches  between
  2206.        corresponding variables in different COMMON block declara-
  2207.        tions, or between dummy and actual arguments of a  subpro-
  2208.        gram.   These  warnings  are controlled by the -common and
  2209.        -arguments settings respectively.  By default both are set
  2210.        for maximum strictness of checking.
  2211.  
  2212.        Another  group of warnings about conditions that are often
  2213.        harmless refer to cases where the array  properties  of  a
  2214.        variable  passed  as  a subprogram argument differ between
  2215.        the two routines.  For instance, an array element might be
  2216.        passed  to  a subroutine that expects a whole array.  This
  2217.        is a commonly-used technique for processing single rows or
  2218.        columns of two-dimensional arrays.  However, it could also
  2219.        indicate a programming error.  The -array  setting  allows
  2220.        the  user to adjust the degree of strictness to be used in
  2221.        checking this kind of agreement between actual  and  dummy
  2222.        array arguments.  By default the strictness is maximum.
  2223.  
  2224.        ``Oops''  indicates  a technical problem, meaning either a
  2225.        bug in ftnchek or that its resources have been exceeded.
  2226.  
  2227.        The format of the error messages has  been  modified  from
  2228.        previous  versions for more clarity. The syntax error mes-
  2229.        sages and warnings now have the  filename  included  along
  2230.        with  the  line number and column number.  ftnchek now has
  2231.        two different options for the appearance  of  these  error
  2232.        messages.   If -novice is in effect, which is the default,
  2233.        the messages are very similar in style  to  those  of  the
  2234.        previous  version.  (In default style, the filename is not
  2235.        printed in messages within the  body  of  the  program  if
  2236.        -list is in effect.)  The other style of error messages is
  2237.        selected by the -nonovice  option.   In  this  style,  the
  2238.        appearance  of the messages is similar to that of the UNIX
  2239.  
  2240.  
  2241.  
  2242.                            2 June 1995                         34
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2249.  
  2250.  
  2251.        lint program.
  2252.  
  2253.        ftnchek is still blind to some  kinds  of  syntax  errors.
  2254.        The  two most important ones are detailed checking of FOR-
  2255.        MAT statements, and almost anything to do with control  of
  2256.        execution  flow  by  means of IF, DO, and GOTO statements:
  2257.        namely correct nesting of control structures, matching  of
  2258.        opening statements such as IF ... THEN with closing state-
  2259.        ments such as ENDIF,  and  the  proper  use  of  statement
  2260.        labels (numbers).  Most compilers will catch these errors.
  2261.        See the section on Limitations for a more detailed discus-
  2262.        sion.
  2263.  
  2264.        If  ftnchek gives you a syntax error message when the com-
  2265.        piler does not, it may be because your program contains an
  2266.        extension  to  standard  Fortran  which is accepted by the
  2267.        compiler but not by ftnchek.  (See the section  on  Exten-
  2268.        sions.)   On  a  VAX/VMS  system, you can use the compiler
  2269.        option /STANDARD to cause  the  compiler  to  accept  only
  2270.        standard Fortran.  On most UNIX or UNIX-like systems, this
  2271.        can be accomplished by setting the flag -ansi.  Also, con-
  2272.        sult  the README file included in the ftnchek distribution
  2273.        for information on how to control which extensions ftnchek
  2274.        accepts.
  2275.  
  2276.        Many   of   the   messages  given  by  ftnchek  are  self-
  2277.        explanatory.  Those that need some additional  explanation
  2278.        are listed below in alphabetical order.
  2279.  
  2280.        Common block NAME: data type mismatch at position n
  2281.               The  n-th  variable  in the COMMON block differs in
  2282.               data type in two different declarations of the COM-
  2283.               MON  block.   By  default (-common strictness level
  2284.               3), ftnchek is very picky about COMMON blocks:  the
  2285.               variables listed in them must match exactly by data
  2286.               type and array dimensions.  That is, the legal pair
  2287.               of declarations in different modules:
  2288.  
  2289.                    COMMON /COM1/ A,B
  2290.  
  2291.  
  2292.               and
  2293.  
  2294.                   COMMON /COM1/ A(2)
  2295.  
  2296.  
  2297.               will  cause  ftnchek to give warnings at strictness
  2298.               level 3.  These two declarations are legal in  For-
  2299.               tran  since  they  both declare two real variables.
  2300.               At strictness level 1 or 2,  no  warning  would  be
  2301.               given  in  this  example,  but the warning would be
  2302.               given if there  were  a  data  type  mismatch,  for
  2303.               instance,  if  B were declared INTEGER.  Controlled
  2304.               by -common setting.
  2305.  
  2306.  
  2307.  
  2308.                            2 June 1995                         35
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2315.  
  2316.  
  2317.        Common block NAME has long data type following short data
  2318.               type
  2319.               Some  compilers  require  alignment  of  multi-byte
  2320.               items so that each item begins at an  address  that
  2321.               is  a  multiple  of the item size.  Thus if a short
  2322.               (e.g. single-precision real) item is followed by  a
  2323.               long (e.g.  double precision real) item, the latter
  2324.               may  not  be  aligned  correctly.   Controlled   by
  2325.               -portability option.
  2326.  
  2327.  
  2328.        Common block NAME has mixed character and non-character
  2329.               variables
  2330.               The  ANSI standard requires that if any variable in
  2331.               a COMMON block is of type CHARACTER, then all other
  2332.               variables  in the same COMMON block must also be of
  2333.               type CHARACTER.  Controlled by -f77 option.
  2334.  
  2335.  
  2336.        Common block NAME: varying length
  2337.               For -common setting level  2,  this  message  means
  2338.               that  a  COMMON block is declared to have different
  2339.               numbers of words in two different  subprograms.   A
  2340.               word is the amount of storage occupied by one inte-
  2341.               ger or real variable.  For -common setting level 3,
  2342.               it  means  that the two declarations have different
  2343.               numbers of variables, where an array of any size is
  2344.               considered  one  variable.  This is not necessarily
  2345.               an error, but it may indicate that  a  variable  is
  2346.               missing from one of the lists.  Note that according
  2347.               to the Fortran 77 Standard,  it  is  an  error  for
  2348.               named  COMMON blocks (but not blank COMMON) to dif-
  2349.               fer in number of words in declarations in different
  2350.               modules.  Given for -common setting 2 or 3.
  2351.  
  2352.  
  2353.        Error: Badly formed logical/relational operator or con-
  2354.               stant
  2355.  
  2356.        Error: Badly formed real constant
  2357.               The syntax analyzer has found the start of  one  of
  2358.               the  special words that begin and end with a period
  2359.               (e.g. .EQ.), or the start of  a  numeric  constant,
  2360.               but  did  not succeed in finding a complete item of
  2361.               that kind.
  2362.  
  2363.  
  2364.        Error: cannot be adjustable size in module NAME
  2365.               A character variable cannot be declared with a size
  2366.               that  is  an asterisk in parentheses unless it is a
  2367.               dummy argument, a parameter, or  the  name  of  the
  2368.               function defined in the module.
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.                            2 June 1995                         36
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2381.  
  2382.  
  2383.        Error: cannot be declared in SAVE statement in module NAME
  2384.               Only local  variables  and  common  blocks  can  be
  2385.               declared in a SAVE statement.
  2386.  
  2387.  
  2388.        Error: No path to this statement
  2389.               ftnchek will detect statements which are ignored or
  2390.               by-passed because there is no foreseeable route  to
  2391.               the  statement.   For example, an unnumbered state-
  2392.               ment  (a  statement  without  a  statement  label),
  2393.               occurring  immediately after a GOTO statement, can-
  2394.               not possibly be executed.
  2395.  
  2396.  
  2397.        Error: Parse error
  2398.               This means that the parser, which analyzes the For-
  2399.               tran  program  into  expressions, statements, etc.,
  2400.               has been unable to find a valid interpretation  for
  2401.               some  portion  of  a  statement in the program.  If
  2402.               your compiler does not report a syntax error at the
  2403.               same  place,  the most common explanations are: (1)
  2404.               use of an extension to ANSI standard  Fortran  that
  2405.               is  not recognized by ftnchek, or (2) the statement
  2406.               requires more lookahead than ftnchek uses (see sec-
  2407.               tion on Bugs).
  2408.  
  2409.               NOTE:  This  message means that the affected state-
  2410.               ment is not interpreted.  Therefore, it is possible
  2411.               that  ftnchek's  subsequent  processing  will be in
  2412.               error, if it depends on  any  matters  affected  by
  2413.               this statement (type declarations, etc.).
  2414.  
  2415.  
  2416.        Error: Statement out of order.
  2417.               ftnchek  will detect statements that are out of the
  2418.               sequence specified for ANSI  standard  Fortran  77.
  2419.               Table  1 illustrates the allowed sequence of state-
  2420.               ments in the Fortran  language.   Statements  which
  2421.               are  out  of  order  are nonetheless interpreted by
  2422.               ftnchek, to prevent ``cascades'' of error messages.
  2423.  
  2424.  
  2425.  
  2426.               --------------------------------------------------------
  2427.                                 |               | implicit
  2428.                                 |  parameter    |---------------------
  2429.                                 |               | other specification
  2430.                       format    |---------------|---------------------
  2431.                        and      |               | statement-function
  2432.                       entry     |  data         |---------------------
  2433.                                 |               | executable
  2434.               --------------------------------------------------------
  2435.  
  2436.                                     Table 1
  2437.  
  2438.  
  2439.  
  2440.                            2 June 1995                         37
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2447.  
  2448.  
  2449.        Error: Syntax error
  2450.               This  is  the  same  as ``Error: Parse error'' (see
  2451.               above).  It is generated if your version of ftnchek
  2452.               was  built  using  the  UNIX  yacc parser generator
  2453.               rather than GNU bison.
  2454.  
  2455.  
  2456.        Identifiers which are not unique in first six chars
  2457.               Warns that two identifiers which are longer than  6
  2458.               characters do not differ in the first 6 characters.
  2459.               This is for portability: they may not be considered
  2460.               distinct by some compilers.  Controlled by -sixchar
  2461.               option.
  2462.  
  2463.  
  2464.        Nonportable usage: argument precision  may  not  be
  2465.               correct  for intrinsic function
  2466.               The precision of an argument passed to an intrinsic
  2467.               function   may  be  incorrect  on  some  computers.
  2468.               Issued  when  a  numeric  variable  declared   with
  2469.               explicit  precision (e.g.  REAL*8 X) is passed to a
  2470.               specific intrinsic function (e.g. DSQRT(X)).   Con-
  2471.               trolled by -portability and -wordsize.
  2472.  
  2473.  
  2474.        Nonportable usage: character constant/variable length
  2475.               exceeds 255
  2476.               Some  compilers  do  not  support character strings
  2477.               more than 255 characters in length.  Controlled  by
  2478.               -portability.
  2479.  
  2480.  
  2481.        Nonportable usage: File contains tabs
  2482.               ftnchek  expands tabs to be equivalent to spaces up
  2483.               to the next column which is a multiple of 8.   Some
  2484.               compilers  treat  tabs  differently, and also it is
  2485.               possible that files sent by  electronic  mail  will
  2486.               have  the  tabs  converted  to  blanks in some way.
  2487.               Therefore files containing tabs may not be compiled
  2488.               correctly  after  being  transferred.  ftnchek does
  2489.               not give this message if  tabs  only  occur  within
  2490.               comments  or  character  constants.   Controlled by
  2491.               -portability.
  2492.  
  2493.  
  2494.        Nonportable usage: non-integer DO loop bounds
  2495.               This warning is only given when the  DO  index  and
  2496.               bounds are non-integer.  Use of non-integer quanti-
  2497.               ties in a DO statement may cause unexpected errors,
  2498.               or  different results on different machines, due to
  2499.               roundoff effects.  Controlled by -portability.
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.                            2 June 1995                         38
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2513.  
  2514.  
  2515.        Possibly it is an array which was not declared
  2516.               This message is appended to warnings related  to  a
  2517.               function  invocation  or  to  an argument type mis-
  2518.               match, for which the possibility exists  that  what
  2519.               appears to be a function is actually meant to be an
  2520.               array.  If the programmer forgot  to  dimension  an
  2521.               array,  references to the array will be interpreted
  2522.               as function invocations.  This message will be sup-
  2523.               pressed  if  the  name  in  question  appears in an
  2524.               EXTERNAL or INTRINSIC statement.  Controlled by the
  2525.               -novice option.
  2526.  
  2527.  
  2528.        Possibly misleading appearance: characters past 72 columns
  2529.               The program is being processed with  the  statement
  2530.               field  width  at its standard value of 72, and some
  2531.               nonblank characters have been found past column 72.
  2532.               In this case, ftnchek is not processing the charac-
  2533.               ters past column 72, and is notifying the user that
  2534.               the  statement  may  not  have  the meaning that it
  2535.               appears  to  have.   These  characters   might   be
  2536.               intended  by  the programmer to be significant, but
  2537.               they will be ignored by the compiler.   (A  similar
  2538.               warning  is alternatively given under the -f77 flag
  2539.               if the -columns setting is  used  to  increase  the
  2540.               statement field width.)  Controlled by -pretty.
  2541.  
  2542.  
  2543.        Possibly  misleading  appearance:  Common  block declared
  2544.               in more than one statement
  2545.               Such  multiple  declarations are legal and have the
  2546.               same effect as a continuation of the original  dec-
  2547.               laration  of the block.  This warning is only given
  2548.               if the two declarations are  separated  by  one  or
  2549.               more   intervening   statements.    Controlled   by
  2550.               -pretty.
  2551.  
  2552.  
  2553.        Possibly misleading appearance: Continuation follows
  2554.               comment  or blank line
  2555.               ftnchek issues this warning message  to  alert  the
  2556.               user  that  a continuation of a statement is inter-
  2557.               spersed with comments, making it easy to  overlook.
  2558.               Controlled by -pretty.
  2559.  
  2560.  
  2561.        Possibly misleading appearance: Extraneous parentheses
  2562.               Warns  about  parentheses surrounding a variable by
  2563.               itself in  an  expression.   When  a  parenthesized
  2564.               variable  is passed as an argument to a subprogram,
  2565.               it is treated as an expression, not as  a  variable
  2566.               whose  value can be modified by the called routine.
  2567.               Controlled by -pretty.
  2568.  
  2569.  
  2570.  
  2571.  
  2572.                            2 June 1995                         39
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2579.  
  2580.  
  2581.        Subprogram NAME: argument data type mismatch at position n
  2582.               The  subprogram's n-th actual argument (in the CALL
  2583.               or the usage of a function) differs in datatype  or
  2584.               precision from the n-th dummy argument (in the SUB-
  2585.               ROUTINE or FUNCTION declaration).  For instance, if
  2586.               the user defines a subprogram by
  2587.  
  2588.                    SUBROUTINE SUBA(X)
  2589.                    REAL X
  2590.  
  2591.  
  2592.               and elsewhere invokes SUBA by
  2593.  
  2594.                    CALL SUBA(2)
  2595.  
  2596.  
  2597.               ftnchek  will detect the error.  The reason here is
  2598.               that the number 2 is integer, not real.   The  user
  2599.               should have said
  2600.  
  2601.                    CALL SUBA(2.0)
  2602.  
  2603.  
  2604.               When  checking  an  argument which is a subprogram,
  2605.               ftnchek must be able to determine whether it  is  a
  2606.               function  or  a  subroutine.   The  rules  used  by
  2607.               ftnchek to do this are as follows: If  the  subpro-
  2608.               gram,  besides  being passed as an actual argument,
  2609.               is also invoked directly elsewhere in the same mod-
  2610.               ule, then its type is determined by that usage.  If
  2611.               not, then if the name of the  subprogram  does  not
  2612.               appear  in  an  explicit  type  declaration,  it is
  2613.               assumed to be a subroutine;  if  it  is  explicitly
  2614.               typed  it  is taken as a function.  Therefore, sub-
  2615.               routines passed as actual arguments  need  only  be
  2616.               declared  by  an  EXTERNAL statement in the calling
  2617.               module, whereas functions must also  be  explicitly
  2618.               typed  in order to avoid generating this error mes-
  2619.               sage.
  2620.  
  2621.               Controlled by -arguments.
  2622.  
  2623.  
  2624.        Subprogram NAME: argument arrayness mismatch at position n
  2625.               Similar to the preceding situation, but the subpro-
  2626.               gram dummy argument differs from the  corresponding
  2627.               actual argument in its number of dimensions or num-
  2628.               ber of elements.   Controlled  by  -array  together
  2629.               with -arguments.
  2630.  
  2631.  
  2632.        Subprogram NAME: argument mismatch at position n
  2633.               A  character dummy argument is larger than the cor-
  2634.               responding actual argument, or  a  Hollerith  dummy
  2635.  
  2636.  
  2637.  
  2638.                            2 June 1995                         40
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2645.  
  2646.  
  2647.               argument  is  larger  than the corresponding actual
  2648.               argument.  Controlled by -arguments.
  2649.  
  2650.  
  2651.        Subprogram NAME: argument usage mismatch
  2652.               ftnchek detects a possible conflict between the way
  2653.               a  subprogram uses an argument and the way in which
  2654.               the argument is supplied to  the  subprogram.   The
  2655.               conflict  can  be  one  of  two  types, as outlined
  2656.               below.
  2657.  
  2658.  
  2659.           Dummy arg is modified, Actual arg is const or expr
  2660.               A dummy argument is an argument as named in a  SUB-
  2661.               ROUTINE  or  FUNCTION statement and used within the
  2662.               subprogram.  An actual argument is an  argument  as
  2663.               passed  to  a subroutine or function by the caller.
  2664.               ftnchek is saying that a dummy argument is modified
  2665.               by  the  subprogram,  implying  that  its  value is
  2666.               changed in the calling module.   The  corresponding
  2667.               actual argument should not be a constant or expres-
  2668.               sion, but rather a variable or array element  which
  2669.               can  be legitimately assigned to.  Given for -usage
  2670.               setting 1 or 3.
  2671.  
  2672.  
  2673.           Dummy arg used before set, Actual arg not set
  2674.               Here a dummy argument may be used in the subprogram
  2675.               before having a value assigned to it by the subpro-
  2676.               gram.  The  corresponding  actual  argument  should
  2677.               have  a value assigned to it by the caller prior to
  2678.               invoking the subprogram.  Given for -usage  setting
  2679.               1 or 3.
  2680.  
  2681.               These  warnings  are not affected by the -arguments
  2682.               setting.
  2683.  
  2684.  
  2685.        Subprogram NAME invoked inconsistently
  2686.               Here the mismatch is between the  datatype  of  the
  2687.               subprogram  itself  as  used  and  as  defined. For
  2688.               instance, if the user declares
  2689.  
  2690.                    INTEGER FUNCTION COUNT(A)
  2691.  
  2692.  
  2693.               and invokes COUNT in another module as
  2694.  
  2695.                    N = COUNT(A)
  2696.  
  2697.  
  2698.               without declaring its datatype, it will default  to
  2699.               real  type,  based on the first letter of its name.
  2700.               The  calling  module  should  have   included   the
  2701.  
  2702.  
  2703.  
  2704.                            2 June 1995                         41
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2711.  
  2712.  
  2713.               declaration
  2714.  
  2715.                    INTEGER COUNT
  2716.  
  2717.  
  2718.               Given for -arguments setting 2 or 3.
  2719.  
  2720.  
  2721.        Subprogram NAME:  varying length argument lists:
  2722.               An  inconsistency has been found between the number
  2723.               of dummy arguments (parameters)  a  subprogram  has
  2724.               and  the  number of actual arguments given it in an
  2725.               invocation.  ftnchek keeps track of all invocations
  2726.               of  subprograms  (CALL  statements  and expressions
  2727.               using functions) and compares them with the defini-
  2728.               tions  of  the  subprograms elsewhere in the source
  2729.               code.  The Fortran compiler normally does not catch
  2730.               this type of error.  Given for -arguments setting 1
  2731.               or 3.
  2732.  
  2733.  
  2734.        Variable not declared.  Type has been implicitly defined
  2735.               When  printing  the  symbol  table  for  a  module,
  2736.               ftnchek  will flag with an asterisk all identifiers
  2737.               that are not explicitly typed  and  will  show  the
  2738.               datatype that was assigned through implicit typing.
  2739.               This provides support for users who wish to declare
  2740.               all  variables  as  is  required  in Pascal or some
  2741.               other languages.  This message  appears  only  when
  2742.               the  -symtab  option  is in effect.  Alternatively,
  2743.               use the -declare flag if you want to get a list  of
  2744.               all undeclared variables.
  2745.  
  2746.  
  2747.        Variables declared but never referenced
  2748.               Detects  any identifiers that were declared in your
  2749.               program but were never used, either to be  assigned
  2750.               a value or to have their value accessed.  Variables
  2751.               in COMMON are excluded.  Given for -usage setting 2
  2752.               or 3.
  2753.  
  2754.  
  2755.        Variables set but never used
  2756.               ftnchek  will  notify  the user when a variable has
  2757.               been assigned a value, but the variable is not oth-
  2758.               erwise  used  in the program.  Usually this results
  2759.               from an oversight.  Given for -usage setting  2  or
  2760.               3.
  2761.  
  2762.  
  2763.        Variables used before set
  2764.               This  message  indicates that an identifier is used
  2765.               to compute a value  prior  to  its  initialization.
  2766.               Such  usage  may  lead  to an incorrect value being
  2767.  
  2768.  
  2769.  
  2770.                            2 June 1995                         42
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2777.  
  2778.  
  2779.               computed, since  its  initial  value  is  not  con-
  2780.               trolled.  Given for -usage setting 1 or 3.
  2781.  
  2782.  
  2783.        Variables may be used before set
  2784.               Similar  to  used before set except that ftnchek is
  2785.               not able to determine its  status  with  certainty.
  2786.               ftnchek  assumes  a variable may be used before set
  2787.               if the first usage of the variable occurs prior  in
  2788.               the  program  text  to  its  assignment.  Given for
  2789.               -usage setting 1 or 3.
  2790.  
  2791.  
  2792.        Warning: DO index is not integer
  2793.               This warning is only given when the DO  bounds  are
  2794.               integer,  but the DO index is not.  It may indicate
  2795.               a failure to declare the index to  be  an  integer.
  2796.               Controlled by -truncation option.
  2797.  
  2798.  
  2799.        Warning: integer quotient expr converted to real
  2800.               The  quotient of two integers results in an integer
  2801.               type  result,  in  which  the  fractional  part  is
  2802.               dropped.   If  such an integer expression involving
  2803.               division is later converted to a real datatype,  it
  2804.               may be that a real type division had been intended.
  2805.               Controlled by -truncation option.
  2806.  
  2807.  
  2808.        Warning: Integer quotient expr used in exponent
  2809.               The quotient of two integers results in an  integer
  2810.               type  result,  in  which  the  fractional  part  is
  2811.               dropped.  If such an integer expression is used  as
  2812.               an  exponent,  it  is quite likely that a real type
  2813.               division was intended.  Controlled  by  -truncation
  2814.               option.
  2815.  
  2816.  
  2817.        Warning: NAME not set when RETURN encountered
  2818.               The way that functions in Fortran return a value is
  2819.               by assigning the value to the name of the function.
  2820.               This  message  indicates  that the function was not
  2821.               assigned a value before the point  where  a  RETURN
  2822.               statement was found.  Therefore it is possible that
  2823.               the function could return an undefined value.
  2824.  
  2825.  
  2826.        Warning: Nonstandard syntax: adjustable size cannot  be
  2827.               concate- nated here
  2828.               The Fortran 77 Standard forbids concatenating char-
  2829.               acter variables whose size is an asterisk in paren-
  2830.               theses, except in an assignment  statement.    Con-
  2831.               trolled by -f77.
  2832.  
  2833.  
  2834.  
  2835.  
  2836.                            2 June 1995                         43
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2843.  
  2844.  
  2845.        Warning: Nonstandard syntax: characters past 72 columns
  2846.               A  statement has been read which has nonblank char-
  2847.               acters past column 72,  with  the  statement  field
  2848.               extended beyond the standard value of 72 columns by
  2849.               the -col setting.   Standard  Fortran  ignores  all
  2850.               text  in  those columns, but some compilers do not.
  2851.               Thus the program may be treated differently by dif-
  2852.               ferent  compilers.   Controlled  by -f77 option and
  2853.               -columns setting.
  2854.  
  2855.  
  2856.        Warning: Possible division by zero
  2857.               This message is printed out  wherever  division  is
  2858.               done  (except  division  by a constant).  Use it to
  2859.               help locate a runtime  division  by  zero  problem.
  2860.               Controlled by -division option.
  2861.  
  2862.  
  2863.        Warning: real truncated to intg
  2864.               ftnchek  has detected an assignment statement which
  2865.               has a real expression on the right, but an  integer
  2866.               variable  on  the left.  The fractional part of the
  2867.               real value will be lost.  If you explicitly convert
  2868.               the  real  expression  to  integer using the INT or
  2869.               NINT  intrinsic  function,  no  warning   will   be
  2870.               printed.   A similar message is printed if a double
  2871.               precision expression is assigned to a single preci-
  2872.               sion  variable,  etc.   Controlled  by  -truncation
  2873.               option.
  2874.  
  2875.  
  2876.        Warning: subscript is not integer
  2877.               Since array subscripts are normally integer quanti-
  2878.               ties,  the use of a non-integer expression here may
  2879.               signal an error.  Controlled by -truncation option.
  2880.  
  2881.  
  2882.        Warning: Unknown intrinsic function
  2883.               This message warns the user that a name declared in
  2884.               an  INTRINSIC  statement  is  unknown  to  ftnchek.
  2885.               Probably  it  is  a nonstandard intrinsic function,
  2886.               and so the program will not be portable.  The func-
  2887.               tion  will  be treated by ftnchek as a user-defined
  2888.               function.  This warning is not  controlled  by  any
  2889.               option,  since it affects ftnchek's analysis of the
  2890.               program.
  2891.  
  2892.  
  2893. LIMITATIONS AND EXTENSIONS
  2894.        ftnchek accepts ANSI  standard  Fortran-77  programs  with
  2895.        some minor limitations and numerous common extensions.
  2896.  
  2897.        Limitations:
  2898.  
  2899.  
  2900.  
  2901.  
  2902.                            2 June 1995                         44
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2909.  
  2910.  
  2911.               ftnchek  uses  only one line of lookahead when ana-
  2912.               lyzing a program into its basic syntactic elements.
  2913.               If a particular statement is difficult to identify,
  2914.               it may be handled improperly if  the  ambiguity  is
  2915.               not  resolved  on  a  single line.  This limitation
  2916.               applies to complex constants except in DATA  state-
  2917.               ments,  and  to situations in which a variable name
  2918.               might be confused with a keyword.  For example,  if
  2919.               the  variable name WRITE is used for an array, then
  2920.               a very long statement assigning  a  value  to  some
  2921.               element  of this array could be mistaken as a WRITE
  2922.               statement if the equals sign is  not  on  the  same
  2923.               line as the word WRITE.
  2924.  
  2925.               The  dummy  arguments  in  statement  functions are
  2926.               treated like ordinary  variables  of  the  program.
  2927.               That is, their scope is the entire module, not just
  2928.               the statement function definition.
  2929.  
  2930.               The checking of FORMAT statements is lax,  tolerat-
  2931.               ing missing separators (comma, etc.) between format
  2932.               descriptors in places where the  Standard  requires
  2933.               them,  and  allowing  .d fields on descriptors that
  2934.               should not have them.   It  does  warn  under  -f77
  2935.               about  nonstandard  descriptor  types (like O), and
  2936.               supported extensions.
  2937.  
  2938.               The only checking related to control  of  execution
  2939.               flow  is  a warning about statements that cannot be
  2940.               reached because they do not have a label  and  they
  2941.               follow  an  unconditional  transfer.   There  is no
  2942.               checking for correct nesting of DO loops or  match-
  2943.               ing  of opening statements such as IF ... THEN with
  2944.               closing statements such as ENDIF,  nor  the  proper
  2945.               definition  and  use  of  statement labels.  Fortu-
  2946.               nately, most compilers will catch these errors.
  2947.  
  2948.               If a user-supplied subprogram has the same name  as
  2949.               one of the nonstandard intrinsic functions, it must
  2950.               be declared in an EXTERNAL statement in any routine
  2951.               that  invokes  it.  Otherwise it will be subject to
  2952.               the checking normally given to the intrinsic  func-
  2953.               tion.   Since  the  nonstandard  intrinsics are not
  2954.               standard, this EXTERNAL statement is  not  required
  2955.               by  the Fortran 77 Standard.  See the lists of sup-
  2956.               ported nonstandard intrinsic functions under Exten-
  2957.               sions below.
  2958.  
  2959.        Extensions:
  2960.               All  of these extensions (except lower-case charac-
  2961.               ters) will generate warnings if the  -f77  flag  is
  2962.               set.   Some of the extensions listed below are part
  2963.               of the Fortran-90 Standard.  These are indicated by
  2964.               the notation (F90).
  2965.  
  2966.  
  2967.  
  2968.                            2 June 1995                         45
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  2975.  
  2976.  
  2977.               Tabs  are permitted, and translated into equivalent
  2978.               blanks  which  correspond  to  tab  stops  every  8
  2979.               columns.   The  standard  does  not recognize tabs.
  2980.               Note that some compilers allow tabs, but treat them
  2981.               differently.  The treatment defined for DEC FORTRAN
  2982.               can be achieved using the -tab option.
  2983.  
  2984.               Strings may be delimited by either quote  marks  or
  2985.               apostrophes.   A  sequence of two delimiter charac-
  2986.               ters is interpreted as a single embedded  delimiter
  2987.               character.  (F90)
  2988.  
  2989.               Strings  may  contain  UNIX-style  backslash escape
  2990.               sequences.  They will be interpreted as such if the
  2991.               -backslash  flag  is  set.  Otherwise the backslash
  2992.               character will be  treated  as  a  normal  printing
  2993.               character.
  2994.  
  2995.               Lower  case  characters are permitted, and are con-
  2996.               verted internally to uppercase except in  character
  2997.               strings.   The  standard specifies upper case only,
  2998.               except in comments and strings.  (F90)
  2999.  
  3000.               Hollerith constants are  permitted,  in  accordance
  3001.               with  the  Fortran  77  Standard, appendix C.  They
  3002.               should not be used in expressions, or confused with
  3003.               datatype CHARACTER.
  3004.  
  3005.               The letter 'D' (upper or lower case) in column 1 is
  3006.               treated as the beginning of a comment.  There is no
  3007.               option to treat such lines as statements instead of
  3008.               comments.
  3009.  
  3010.               Statements may be longer than 72  columns  provided
  3011.               that  the  setting -column was used to increase the
  3012.               limit.  According to the standard,  all  text  from
  3013.               columns  73  through 80 is ignored, and no line may
  3014.               be longer than 80 columns.
  3015.  
  3016.               Variable names may be longer than  six  characters.
  3017.               The standard specifies six as the maximum.  ftnchek
  3018.               permits names up to 31 characters long (F90).
  3019.  
  3020.               Variable names may contain underscores  and  dollar
  3021.               signs,  which  are  treated  the same as alphabetic
  3022.               letters.  The default type for variables  beginning
  3023.               with  these  characters  is REAL.  In IMPLICIT type
  3024.               statements specifying a range  of  characters,  the
  3025.               dollar  sign  follows  Z  and is followed by under-
  3026.               score.  Fortran 90 permits underscores in  variable
  3027.               names.
  3028.  
  3029.               The  UNIX version tolerates the presence of prepro-
  3030.               cessor directives, namely lines beginning with  the
  3031.  
  3032.  
  3033.  
  3034.                            2 June 1995                         46
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3041.  
  3042.  
  3043.               pound  sign  (#).   These  are treated as comments,
  3044.               except for #line directives, which are interpreted,
  3045.               and are used to set the line number and source file
  3046.               name for warnings and error  messages.   Note  that
  3047.               #include  directives  are not processed by ftnchek.
  3048.               Programs that use them for including  source  files
  3049.               should  be  passed  through the preprocessor before
  3050.               being input to ftnchek.  As  noted  below,  ftnchek
  3051.               does  process INCLUDE statements, which have a dif-
  3052.               ferent syntax.
  3053.  
  3054.               The DO ...  ENDDO control structure  is  permitted.
  3055.               The  syntax  which  is  recognized  is according to
  3056.               either of the following two forms:
  3057.                    DO [label [,]] var = expr , expr [, expr]
  3058.                     ...
  3059.                    END DO
  3060.               or
  3061.                    DO [label [,]] WHILE ( expr )
  3062.                     ...
  3063.                    END DO
  3064.               where square brackets indicate  optional  elements.
  3065.               This  is a subset of the Fortran 90 do-loop syntax.
  3066.  
  3067.               The ACCEPT and TYPE statements (for  terminal  I/O)
  3068.               are permitted, with the same syntax as PRINT.
  3069.  
  3070.               Statements  may  have  any  number  of continuation
  3071.               lines.  The standard allows a maximum of 19.
  3072.  
  3073.               Inline  comments,  beginning  with  an  exclamation
  3074.               mark, are permitted.  (F90)
  3075.  
  3076.               NAMELIST  I/O is supported.  The syntax is the same
  3077.               as in Fortran 90.
  3078.  
  3079.               FORMAT statements can  contain  a  dollar  sign  to
  3080.               indicate  suppression of carriage-return.  An inte-
  3081.               ger expression enclosed in angle  brackets  can  be
  3082.               used  anywhere in a FORMAT statement where the For-
  3083.               tran 77 Standard allows an integer constant (except
  3084.               for the length of a Hollerith constant), to provide
  3085.               a run-time value  for  a  repeat  specification  or
  3086.               field width.
  3087.  
  3088.               The  IMPLICIT  NONE  statement  is  supported.  The
  3089.               meaning of this statement  is  that  all  variables
  3090.               must  have  their  data  types explicitly declared.
  3091.               Rather than flag the occurrences of such  variables
  3092.               with  syntax error messages, ftnchek waits till the
  3093.               end of the module, and then prints out  a  list  of
  3094.               all  undeclared  variables,  as  it  does  for  the
  3095.               -declare option.  (F90)
  3096.  
  3097.  
  3098.  
  3099.  
  3100.                            2 June 1995                         47
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3107.  
  3108.  
  3109.               Data types INTEGER, REAL, COMPLEX, and LOGICAL  are
  3110.               allowed to have an optional precision specification
  3111.               in type declarations.  For instance,  REAL*8  means
  3112.               an  8-byte  floating  point  data type.  The REAL*8
  3113.               datatype is not necessarily  considered  equivalent
  3114.               to  DOUBLE  PRECISION,  depending  on the -wordsize
  3115.               setting.  The Fortran 77 Standard allows  a  length
  3116.               specification only for CHARACTER data.
  3117.  
  3118.               ftnchek supports the DOUBLE COMPLEX type specifica-
  3119.               tion for a complex quantity whose real  and  imagi-
  3120.               nary parts are double precision.  Mixed-mode arith-
  3121.               metic involving single-precision complex with  dou-
  3122.               ble-precision real data, prohibited under the Stan-
  3123.               dard, yields a double complex result.   The  double
  3124.               complex  counterparts of all the standard intrinsic
  3125.               functions for complex data are included:
  3126.  
  3127.                   DCMPLX    DCONJG    DIMAG     DREAL     IMAG
  3128.                   CDABS     CDSQRT    CDEXP     CDLOG     CDSIN     CDCOS
  3129.                   ZABS      ZSQRT     ZEXP      ZLOG      ZSIN      ZCOS
  3130.  
  3131.  
  3132.               The  following  other  commonly  found  nonstandard
  3133.               intrinsic  functions are provided.  All except EXIT
  3134.               and LOC are defined in MIL-STD 1753.
  3135.  
  3136.                   BTEST     IAND      IOR       IBSET     IBCLR
  3137.                   IBITS     IEOR      ISHFT     ISHFTC    NOT
  3138.                   EXIT      LOC
  3139.  
  3140.  
  3141.               For the UNIX version of ftnchek, the following com-
  3142.               mon UNIX intrinsic functions are provided:
  3143.  
  3144.                   ABORT     AND       GETARG    GETENV    GMTIME
  3145.                   IARGC     LSHIFT    LTIME     OR        IRAND
  3146.                   RAND      RSHIFT    SRAND     SYSTEM    TIME
  3147.                   XOR
  3148.  
  3149.  
  3150.               Note:  there  are  two common calling sequences for
  3151.               RAND and IRAND: with zero arguments or with 1 argu-
  3152.               ment.  By default, ftnchek accepts either form.  If
  3153.               you wish to enforce strict adherence to one form or
  3154.               the  other,  you should compile ftnchek with one of
  3155.               the two macros RAND_NO_ARG or RAND_ONE_ARG set.
  3156.  
  3157.               For the VAX/VMS version of ftnchek,  the  following
  3158.               common VMS intrinsic functions are provided:
  3159.  
  3160.                   DATE      ERRSNS    IDATE     RAN       SECNDS
  3161.                   SIZEOF    TIME
  3162.  
  3163.  
  3164.  
  3165.  
  3166.                            2 June 1995                         48
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3173.  
  3174.  
  3175.               Argument  checking  is not tight for those nonstan-
  3176.               dard intrinsics that take arrays or mixed  argument
  3177.               types.
  3178.  
  3179.               ftnchek permits the INCLUDE statement, which causes
  3180.               inclusion of the text of the given file.  The  syn-
  3181.               tax is
  3182.                    INCLUDE 'filename'
  3183.  
  3184.               This  is compatible with Fortran 90.  When compiled
  3185.               for VMS, ftnchek will assume a default extension of
  3186.               .for  if  no filename extension is given.  Also for
  3187.               compatibility with VMS, the VMS version allows  the
  3188.               qualifier /[NO]LIST following the filename, to con-
  3189.               trol the listing of the included file.  There is no
  3190.               support for including VMS text modules.
  3191.  
  3192.               In diagnostic output relating to items contained in
  3193.               include files, the location of the error is  speci-
  3194.               fied  by  both its location in the include file and
  3195.               the location in the parent file where the file  was
  3196.               included.
  3197.  
  3198.               ftnchek  accepts PARAMETER definitions that involve
  3199.               intrinsic functions and exponentiation  by  a  non-
  3200.               integer  exponent.  Both of these cases are prohib-
  3201.               ited by the Fortran 77 Standard, and will be warned
  3202.               about  if  the  -f77  flag is set.  If an intrinsic
  3203.               function  is  a  compile-time   integer   constant,
  3204.               ftnchek  will  evaluate  it.   This  allows  better
  3205.               checking if the  parameter  is  used  in  declaring
  3206.               array sizes.  Fortran 90 allows intrinsic functions
  3207.               in PARAMETER definitions.
  3208.  
  3209.               The intrinsic functions that are evaluated are:
  3210.  
  3211.                   ABS       IABS      DIM       IDIM      MAX
  3212.                   MAX0      MIN       MIN0      MOD       SIGN
  3213.                   ISIGN     LEN       ICHAR     INDEX
  3214.  
  3215.  
  3216.               The functions of integer  arguments  are  evaluated
  3217.               only  if the arguments are integer constant expres-
  3218.               sions.   (These  may  involve  integer   constants,
  3219.               parameters,  and  evaluated  intrinsic  functions.)
  3220.               The function LEN is evaluated if its argument is an
  3221.               expression  involving  only character constants and
  3222.               variables whose  length  is  not  adjustable.   The
  3223.               functions ICHAR and INDEX are evaluated only if the
  3224.               arguments are character constants.  ftnchek gives a
  3225.               warning  if  it  needs  the value of some intrinsic
  3226.               function that is not evaluated.
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.                            2 June 1995                         49
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3239.  
  3240.  
  3241. NEW FEATURES
  3242.        Here are the changes from Version 2.7 to Version 2.8:
  3243.  
  3244.        1.  Improvements in handling  command-line  settings:  add
  3245.            support  for  colon as assignment operator, and extend
  3246.            setting switch support to include a default  value  to
  3247.            replace  out-of-range values, instead of just choosing
  3248.            the nearer endpoint of the valid range.
  3249.  
  3250.        2.  New options: -makedcls=num to generate variable decla-
  3251.            rations;  -backslash  to  handle  UNIX-style backslash
  3252.            escapes in character strings; -resource to  print  out
  3253.            internal resource usage; -tab to accept DEC-style tab-
  3254.            formatted source.
  3255.  
  3256.        3.  New extensions to syntax: Accept  quote  marks  as  an
  3257.            alternative  to  apostrophes  for  delimiting strings.
  3258.            Accept 'D' as equivalent to 'C' in column 1  for  com-
  3259.            ments.   A patch is supplied to allow ``Cray pointer''
  3260.            syntax to be tolerated.  (This patch does not  include
  3261.            checking proper use of pointers.)
  3262.  
  3263.        4.  Provide  variable  names and not just position numbers
  3264.            in warnings about mismatches in common block  declara-
  3265.            tions and subprogram argument lists.
  3266.  
  3267.        5.  Add installation validation suite to check for correct
  3268.            functioning after a new installation, or a new  compi-
  3269.            lation  with a different compiler or compiler options.
  3270.            The validation suite also serves to record input cases
  3271.            that  exhibited bugs in older versions of the program,
  3272.            providing regression testing to ensure that changes do
  3273.            not  introduce  new  bugs,  or restore old ones.  This
  3274.            test suite uncovered compiler optimizer errors  on  at
  3275.            least one system, errors which did not appear in older
  3276.            versions of ftnchek.
  3277.  
  3278.        6.  Improve memory management  to  avoid  running  out  of
  3279.            space.
  3280.  
  3281.        7.  Update  the  UNIX  Makefile with new targets following
  3282.            the Free Software Foundation standards, and create the
  3283.            CHECKLIST  file  to record systems for which this ver-
  3284.            sion of ftnchek has been successfully  built  and  has
  3285.            passed the validation suite tests.
  3286.  
  3287.        8.  Add  the man2ps script, and a target in the UNIX Make-
  3288.            file to use it for converting the manual pages file to
  3289.            PostScript.
  3290.  
  3291.        9.  Correct  several small typographical irregularities in
  3292.            these manual pages.  troff preserves all input spaces,
  3293.            so  great  care  is needed in preparing troff input to
  3294.            avoid introducing  spurious  space  into  the  typeset
  3295.  
  3296.  
  3297.  
  3298.                            2 June 1995                         50
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3305.  
  3306.  
  3307.            output.
  3308.  
  3309.        Grateful acknowledgement is given to Nelson H. F. Beebe of
  3310.        the  University  of  Utah  for  providing  most  of  these
  3311.        improvements,  and  especially for writing most of the new
  3312.        code to produce variable declarations, which represents  a
  3313.        very substantial effort.
  3314.  
  3315.        Here are the changes from Version 2.6 to Version 2.7:
  3316.  
  3317.        1.  Fixed bugs: to allow statement functions with no argu-
  3318.            ments; to catch extra  comma  in  subprogram  argument
  3319.            lists; argument of LEN does not need to have a defined
  3320.            value.
  3321.  
  3322.        2.  Insensitive to blanks as per the Standard.
  3323.  
  3324.        3.  Changed behavior of options:  -f77  controls  warnings
  3325.            about  statement  out  of  order and COMMON block with
  3326.            mixed character and non-character data;  -help  option
  3327.            now  lists patch level and copyright; -novice controls
  3328.            appearance of warning messages.
  3329.  
  3330.        4.  Added handling of explicit precision and  double  com-
  3331.            plex  data  type.  REAL*8 is no longer synonymous with
  3332.            DOUBLE PRECISION, depending on the  machine  wordsize.
  3333.            Checking length agreement for character data also done
  3334.            properly now.
  3335.  
  3336.        5.  Checking usage status  of  COMMON  blocks  and  COMMON
  3337.            variables.
  3338.  
  3339.        6.  Improved format of messages.
  3340.  
  3341.        7.  Support for common nonstandard intrinsic functions.
  3342.  
  3343.        8.  New options: -arguments, -crossref, -reference, -sort,
  3344.            -volatile, -wordsize, and -wrap.
  3345.  
  3346.        9.  Behavior when no top-level non-library modules  found,
  3347.            changed  from  no  cross-checking  to  complete cross-
  3348.            checking.
  3349.  
  3350.        10. Added expansion of wildcards for filenames on the com-
  3351.            mand line to the VMS and MS-DOS versions.
  3352.  
  3353.        11. Parser is generated by bison.  Formerly yacc was used.
  3354.  
  3355.        12. Made changes to allow the IBM PC version handle larger
  3356.            files.
  3357.  
  3358. BUGS
  3359.        ftnchek  still  has much room for improvement.  Your feed-
  3360.        back is appreciated.  We want to know about any  bugs  you
  3361.  
  3362.  
  3363.  
  3364.                            2 June 1995                         51
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3371.  
  3372.  
  3373.        notice.   Bugs  include  not  only  cases in which ftnchek
  3374.        issues an error message where no error exists, but also if
  3375.        ftnchek  fails to issue a warning when it ought to.  Note,
  3376.        however, that ftnchek is not intended to catch all  syntax
  3377.        errors (see section on Limitations).  Also, it is not con-
  3378.        sidered a bug for a variable to be reported as used before
  3379.        set,  if  the  reason  is  that  the usage of the variable
  3380.        occurs prior in the text to where  the  variable  is  set.
  3381.        For  instance,  this could occur when a GOTO causes execu-
  3382.        tion to loop backward to some  previously  skipped  state-
  3383.        ments.   ftnchek  does  not  analyze the program flow, but
  3384.        assumes that statements occurring earlier in the text  are
  3385.        executed before the following ones.
  3386.  
  3387.        We especially want to know if ftnchek crashes for any rea-
  3388.        son.  It is not supposed to crash, even on  programs  with
  3389.        syntax  errors.   Suggestions  are welcomed for additional
  3390.        features which you would find useful.  Tell us if  any  of
  3391.        ftnchek's  messages are incomprehensible.  Comments on the
  3392.        readability and accuracy of this document  are  also  wel-
  3393.        come.
  3394.  
  3395.        You  may also suggest support for additional extensions to
  3396.        the Fortran language.  These will be included only  if  it
  3397.        is  felt  that  the  extensions  are  sufficiently  widely
  3398.        accepted by compilers.
  3399.  
  3400.        If you find a bug in ftnchek, first consult  the  list  of
  3401.        known  bugs  below to see if it has already been reported.
  3402.        Also check the section entitled ``Limitations  and  Exten-
  3403.        sions''  above  for restrictions that could be causing the
  3404.        problem.  If you do not find  the  problem  documented  in
  3405.        either place, then send a report including
  3406.  
  3407.        1.  The  operating system and CPU type on which ftnchek is
  3408.            running.
  3409.  
  3410.        2.  The version of ftnchek.
  3411.  
  3412.        3.  A brief description of the bug.
  3413.  
  3414.        4.  If possible, a small sample program showing the bug.
  3415.  
  3416.        The report should be  sent  to  either  of  the  following
  3417.        addresses:
  3418.  
  3419.  
  3420.              MONIOT@FORDMULC.BITNET
  3421.              moniot@mary.fordham.edu
  3422.  
  3423.  
  3424.  
  3425.        Highest priority will be given to bugs which cause ftnchek
  3426.        to crash.  Bugs  involving  incorrect  warnings  or  error
  3427.  
  3428.  
  3429.  
  3430.                            2 June 1995                         52
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3437.  
  3438.  
  3439.        messages may take longer to fix.
  3440.  
  3441.        Certain  problems  that arise when checking large programs
  3442.        can be fixed by increasing the sizes of the data areas  in
  3443.        ftnchek.   (These problems are generally signaled by error
  3444.        messages beginning with ``Oops''.)  The  simplest  way  to
  3445.        increase  the  table  sizes is by recompiling ftnchek with
  3446.        the LARGE_MACHINE macro name defined.  Consult  the  make-
  3447.        file and README file for the method of doing this.
  3448.  
  3449.        The following is a list of known bugs.
  3450.  
  3451.        1.  Bug:  Used-before-set  message  is  suppressed for any
  3452.            variable which  is  used  as  the  loop  index  in  an
  3453.            implied-do  loop,  even  if it was in fact used before
  3454.            being set in some  earlier  statement.   For  example,
  3455.            consider J in the statement
  3456.  
  3457.  
  3458.                  WRITE(5,*) (A(J), J=1,10)
  3459.  
  3460.  
  3461.  
  3462.            Here  ftnchek parses the I/O expression, A(J), where J
  3463.            is used, before it parses the implied loop where J  is
  3464.            set.   Normally  this  would cause ftnchek to report a
  3465.            spurious used-before-set warning for  J.   Since  this
  3466.            report is usually in error and occurs fairly commonly,
  3467.            ftnchek suppresses the warning for J altogether.
  3468.  
  3469.            Prognosis: A future version  of   ftnchek  is  planned
  3470.            which will handle implied-do loops correctly.
  3471.  
  3472.        2.  Bug:  Variables  used (not as arguments) in statement-
  3473.            function subprograms do not have  their  usage  status
  3474.            updated when the statement function is invoked.
  3475.  
  3476.            Prognosis: To be fixed in a future version of ftnchek.
  3477.  
  3478.        3.  Bug: VAX version does not expand  wildcards  in  file-
  3479.            names on the command line if they are followed without
  3480.            space by an option, e.g.  ftnchek  *.f/calltree  would
  3481.            not expand the *.f.  This is because VMS-style options
  3482.            without intervening space are not supported by the GNU
  3483.            shell_mung routine that is used to expand wildcards.
  3484.  
  3485.            Prognosis: unlikely to be fixed.
  3486.  
  3487.  
  3488. ACKNOWLEDGEMENTS
  3489.        ftnchek  is  a  public-domain program.  It was designed by
  3490.        Dr. Robert Moniot, professor at Fordham University.   Dur-
  3491.        ing  the  academic  year  of  1988-1989, Michael Myers and
  3492.        Lucia Spagnuolo  developed  the  program  to  perform  the
  3493.  
  3494.  
  3495.  
  3496.                            2 June 1995                         53
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3503.  
  3504.  
  3505.        variable  usage  checks.  During the following year it was
  3506.        augmented by Lois Bigbie to check subprogram arguments and
  3507.        COMMON  block  declarations.   Brian Downing assisted with
  3508.        the implementation of the INCLUDE statement.   John  Quinn
  3509.        wrote  the  common block usage checks.  Nelson H. F. Beebe
  3510.        of the University of Utah added most of the  new  code  to
  3511.        implement  the  -makedcls feature.  The -reference feature
  3512.        was contributed by Gerome Emmanuel, Ecole  des  mines,  U.
  3513.        Nancy  (slightly  modified).   The  patch for Cray pointer
  3514.        syntax was provided by John Dannenhoffer of  United  Tech-
  3515.        nologies  Research  Center.   Additional  features will be
  3516.        added as time permits.  With Version  2.5,  the  name  was
  3517.        changed from forchek to ftnchek, to avoid confusion with a
  3518.        similar program named forcheck, developed earlier at  Lei-
  3519.        den University.
  3520.  
  3521.        We  would  like  to  thank  John Amor of the University of
  3522.        British Columbia, Reg Clemens of the  Air  Force  Phillips
  3523.        Lab  in  Albuquerque,  Markus Draxler of the University of
  3524.        Stuttgart, Victor Eijkhout of the University of  Tennessee
  3525.        at  Knoxville,  Greg Flint of Purdue University, Daniel P.
  3526.        Giesy of NASA Langley Research Center,  Fritz  Keinert  of
  3527.        Iowa  State University, Judah Milgram of the University of
  3528.        Maryland College Park, Hugh  Nicholas  of  the  Pittsburgh
  3529.        Supercomputing  Center,  Dan Severance of Yale University,
  3530.        Phil Sterne of  Lawrence  Livermore  National  Laboratory,
  3531.        Larry  Weissman of the University of Washington, Warren J.
  3532.        Wiscombe of NASA Goddard,  and  especially  Nelson  H.  F.
  3533.        Beebe of the University of Utah, for pointing out bugs and
  3534.        suggesting some improvements.  We also thank Jack Dongarra
  3535.        for  putting  ftnchek  into the netlib library of publicly
  3536.        available software.
  3537.  
  3538.  
  3539. INSTALLATION AND SUPPORT
  3540.        The ftnchek program can be obtained by anonymous ftp  from
  3541.        many   software   servers,   including   host   netlib.org
  3542.        (128.169.92.17) where it is located in directory /fortran.
  3543.  
  3544.        Installation requires a C compiler for your computer.  See
  3545.        the  README  file  provided  with  the  distribution   for
  3546.        instructions  on  installing ftnchek on your system.  Exe-
  3547.        cutable binary in ZIP format for IBM  PC  computers  under
  3548.        MS-DOS  is available by anonymous ftp from oak.oakland.edu
  3549.        (141.210.10.117) where it is located  in  directory  /Sim-
  3550.        Tel/msdos/fortran,   filename   ftnchk28.zip.   Executable
  3551.        binary in binhexed stuffit format for Macintosh  computers
  3552.        is  available  from sumex-aim.stanford.edu (36.44.0.6), in
  3553.        directory info-mac/Development, filename ftnchek-28.hqx.
  3554.  
  3555.  
  3556.        The nroff version of this document is  named  ftnchek.man.
  3557.        On UNIX systems, it can be used as the man page or you can
  3558.        print it using the command nroff -man ftnchek.man  |  lpr.
  3559.  
  3560.  
  3561.  
  3562.                            2 June 1995                         54
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568. FTNCHEK 2.8.3(1L)                               FTNCHEK 2.8.3(1L)
  3569.  
  3570.  
  3571.        The distribution also includes a plain ASCII version named
  3572.        ftnchek.doc, a PostScript version named ftnchek.ps, and  a
  3573.        VMS HELP version named ftnchek.hlp.
  3574.  
  3575.        Information about the latest version and the status of the
  3576.        project can be obtained by the Internet  command  ``finger
  3577.        ftnchek@mary.fordham.edu''.   For  further information and
  3578.        to report bugs, you  may  contact  Dr.  Robert  Moniot  at
  3579.        either of the following network addresses:
  3580.  
  3581.  
  3582.              MONIOT@FORDMULC.BITNET
  3583.              moniot@mary.fordham.edu
  3584.  
  3585.  
  3586.  
  3587. SEE ALSO
  3588.        dcl2inc(1L),   dtoq(1L),   dtos(1L),   f77(1),   fd2s(1L),
  3589.        fs2d(1L),   pfort(1L),   qtod(1L),   sf3(1L),    stod(1L).
  3590.        xsf3(1L).
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.                            2 June 1995                         55
  3629.  
  3630.  
  3631.