home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FTNCHK32.ZIP / ftnchek.hlp < prev    next >
Text File  |  1993-02-16  |  24KB  |  434 lines

  1.  
  2.  
  3.  
  4. 1 FTNCHEK
  5.  Fortran program checker.
  6. 2 Introduction
  7.  
  8.  
  9.       Ftnchek (short  for  Fortran  checker)  is  designed  to  detect
  10.  certain errors in a Fortran program that a compiler usually does not.
  11.  Ftnchek is not primarily  intended  to  detect  syntax  errors.   Its
  12.  purpose  is  to assist the user in finding semantic errors.  Semantic
  13.  errors are legal in the Fortran language  but  are  wasteful  or  may
  14.  cause  incorrect  operation.   For example, variables which are never
  15.  used  may  indicate  some  omission  in  the  program;  uninitialized
  16.  variables  contain  garbage  which  may cause incorrect results to be
  17.  calculated; and variables which are not declared  may  not  have  the
  18.  intended  type.  Ftnchek is intended to assist users in the debugging
  19.  of their Fortran program.  It is not intended  to  catch  all  syntax
  20.  errors.   This  is  the  function  of  the  compiler.  Prior to using
  21.  Ftnchek, the user should verify that the program compiles correctly.
  22.  
  23.       For more detailed information, consult the documentation.
  24. 2 Invoking_Ftnchek
  25.  
  26.  Ftnchek is invoked through a command of the form:
  27.  
  28.      $ ftnchek [/option/option ...] filename [filename ...]
  29.  
  30.  
  31.       The brackets indicate something which is optional.  The brackets
  32.  themselves  are  not  actually  typed.  Here options are command-line
  33.  switches or settings, which control the operation of the program  and
  34.  the  amount of information that will be printed out.  If no option is
  35.  specified, the default action is to print error  messages,  warnings,
  36.  and  informational  messages,  but  not the program listing or symbol
  37.  tables.
  38.  
  39.       Each option begins with the '/' character.  (Ftnchek also allows
  40.  the '-' character to be used.)
  41. 2 Files
  42.  
  43.  
  44.       When giving a name of an input file, the extension is  optional.
  45.  If  no extension is given, Ftnchek will first look for a project file
  46.  with extension '.prj', and will use that if it exists.  If not,  then
  47.  Ftnchek will look for a Fortran source file with the extension '.for'
  48.  for VMS systems, '.f' for Unix systems.  More than one file name  can
  49.  be  given to Ftnchek, and it will process the modules in all files as
  50.  if they were in a single file.
  51.  
  52.       If no filename is  given,  Ftnchek  will  read  input  from  the
  53.  standard input.
  54. 2 Options
  55.  
  56.  Ftnchek options fall into two categories:  switches, which are either
  57.  true  or  false,  and settings, which have a numeric or string value.
  58.  The name of a switch or numeric setting can be preceded  by  'no'  to
  59.  turn  it  off:   e.g.   /nousage  would  turn  off the warnings about
  60.  variable usage.  Only the first 3 characters of an option  name  (not
  61.  counting the '/') need be provided.
  62. 3 /array=n
  63.  Controls  warnings  about  mismatches  between   actual   and   dummy
  64.  subprogram  array  arguments.   (An  actual  argument  is an argument
  65.  passed to the subprogram by  the  caller;  a  dummy  argument  is  an
  66.  argument  received  by  the  subprogram.)  Default = 3.  The warnings
  67.  which can be turned off are for constructions that might legitimately
  68.  be  used  by  a  knowledgeable  programmer,  but  that often indicate
  69.  programming errors.
  70.  
  71.       The meanings of the setting values are as follows:
  72.  
  73.          0:  only the warnings noted below.
  74.  
  75.          1:  give warnings if the arguments differ in their number  of
  76.             dimensions,  or if the actual argument is an array element
  77.             while the dummy argument is a whole array.
  78.  
  79.          2:  give warnings if  the  arguments  are  both  arrays,  but
  80.             differ in size.
  81.  
  82.          3:  give both types of warnings.
  83.  
  84.       Note:  no warning is ever given if the  actual  argument  is  an
  85.  array  element  while  the dummy argument is a scalar variable, and a
  86.  warning is always given regardless of  this  setting  if  the  actual
  87.  argument  is  an array while the dummy argument is a scalar variable,
  88.  or if the actual argument is a scalar variable  or  expression  while
  89.  the  dummy  argument  is an array.  Variable-dimensioned arrays match
  90.  any array size.
  91. 3 /calltree
  92.  Causes Ftnchek to print  out  the  call  structure  of  the  complete
  93.  program in the form of a tree.  The tree is printed out starting from
  94.  the main program, which is listed on  the  first  line  at  the  left
  95.  margin.  Then on the following lines, each routine called by the main
  96.  program is listed, indented a few spaces,  followed  by  the  subtree
  97.  starting at that routine.  Default = no.
  98.  
  99.       If a routine is called by more than one other routine, its  call
  100.  subtree  is  printed  only  the  first time it is encountered.  Later
  101.  calls give only the routine name and the notice "(see above)".
  102.  
  103.       Note that the call tree will be incomplete if any of  the  input
  104.  files  are project files that were created in /library mode.  See the
  105.  discussion of project files below.
  106.  
  107.       Technical points:  Each list  of  routines  called  by  a  given
  108.  routine  is  printed  in  alphabetical  order.  If no main program is
  109.  found, a report to that effect is printed out, and no  call  tree  is
  110.  printed.   If multiple main programs are found, the call tree of each
  111.  is printed separately.
  112.  
  113.       Now that  Ftnchek  recognizes  the  call  tree  structure  of  a
  114.  program,  its  checking  behavior  is  somewhat altered from previous
  115.  versions, which checked the calls of every  routine  by  every  other
  116.  routine,  regardless of whether those routines could ever actually be
  117.  invoked at run time.  Now, if a file is read with the  /library  flag
  118.  in  effect,  the calls made by a routine in that file will be checked
  119.  only if the calling routine is  in  the  main  program's  call  tree.
  120.  Likewise,  COMMON declarations in a library file will only be checked
  121.  if the routine is in the call tree.  If the /library flag is not set,
  122.  Ftnchek   will   check   all   inter-module   calls  and  all  common
  123.  declarations, as it did formerly.   (If  there  is  no  main  program
  124.  anywhere  in the set of files that Ftnchek has read, so that there is
  125.  no call tree, then library routines  will  be  checked  if  they  are
  126.  called by any routine in the complete set of files.)
  127. 3 /columns=n
  128.  Set maximum statement length to n columns.  (Beyond this is ignored.)
  129.  This  setting  is  provided  to  allow checking of programs which may
  130.  violate the Fortran standard limit of 72 columns for the length of  a
  131.  statement.   According to the standard, all characters past column 72
  132.  are ignored.  If this setting is used when  the  /f77  option  is  in
  133.  effect,  a  warning  will  be given for any overlength lines that are
  134.  processed.  Max is 132.  Default = 72.
  135. 3 /common=n
  136.  This setting varies the strictness  of  checking  of  COMMON  blocks.
  137.  Default = 3.
  138.  
  139.       The different levels are:
  140.  
  141.          0:  no checking.
  142.  
  143.          1:   in  each  declaration   of   a   given   COMMON   block,
  144.             corresponding memory locations must agree in data type.
  145.  
  146.          2:  also warn if different declarations of the same block are
  147.             not equal in total length.
  148.  
  149.          3:  corresponding variables in each declaration  of  a  block
  150.             must agree in data type and (if arrays) in size and number
  151.             of dimensions.
  152. 3 /declare
  153.  If this flag is set, all identifiers whose datatype is  not  declared
  154.  in  each  module  will be listed.  This flag is useful for helping to
  155.  find misspelled variable names, etc.  The same listing will be  given
  156.  if the module contains an IMPLICIT NONE statement.  Default = no.
  157. 3 /division
  158.  This switch is provided to help users spot potential division by zero
  159.  problems.   If  this  switch  is selected, every division except by a
  160.  constant  will  be  flagged.   (It  is  assumed  that  the  user   is
  161.  intelligent  enough  not  to  divide  by a constant which is equal to
  162.  zero!) Default = no.
  163. 3 /extern
  164.  Causes Ftnchek to report  whether  any  subprograms  invoked  by  the
  165.  program  are  never defined, or are multiply defined.  Ordinarily, if
  166.  Ftnchek is being run on a complete  program,  each  subprogram  other
  167.  than  the  intrinsic  functions  should be defined once and only once
  168.  somewhere.  Turn off this switch if you just want to check  a  subset
  169.  of  files  which  form part of a larger complete program, or to check
  170.  all at once a number of unrelated files which might each  contain  an
  171.  unnamed main program.  Subprogram arguments will still be checked for
  172.  correctness.  Default = yes.
  173. 3 /f77
  174.  Use this flag to catch language extensions which violate the  Fortran
  175.  77  standard.   Such  extensions  may  cause  your  program not to be
  176.  portable.  Examples include the use of underscores in variable names;
  177.  variable  names  longer  than  six characters; statement lines longer
  178.  than 72 characters; and nonstandard statements such  as  the  DO  ...
  179.  ENDDO  structure.   Ftnchek  does  not report on the use of lowercase
  180.  letters.  Default=no.
  181. 3 /help
  182.  This command is identical in function to the  "?"  argument,  and  is
  183.  provided  simply  as  a  convenience  for  those systems in which the
  184.  question  mark  has  special  meaning  to  the  command  interpreter.
  185.  Default = no.
  186. 3 /hollerith
  187.  Hollerith constants (other than within format specifications)  are  a
  188.  source  of  possible  portability  problems, so when the /portability
  189.  flag is set, warnings about them will be produced.  If  your  program
  190.  uses  many hollerith constants, these warnings can obscure other more
  191.  serious warnings.  So you can set this flag to "no" to  suppress  the
  192.  warnings  about  holleriths.   This  flag  has  no  effect  when  the
  193.  /portability flag is turned off.  Default = yes.
  194. 3 /include=n
  195.  Specifies a directory to be searched for files specified  by  INCLUDE
  196.  statements.   Unlike  other  command-line  options,  this  setting is
  197.  cumulative; that is, if it is given more than  once  on  the  command
  198.  line, all the directories so specified are placed on a list that will
  199.  be searched in the same order as they are given.  The order in  which
  200.  Ftnchek  searches  for  a  file  to  be  included  is:   the  current
  201.  directory;  the   directory   specified   by   environment   variable
  202.  FTNCHEK_INCLUDE  if  any;  the  directories specified by any /include
  203.  options; the directory specified by environment variable INCLUDE; and
  204.  finally in the standard systemwide directory SYS$LIBRARY.
  205. 3 /library
  206.  This switch is used when a number of subprograms are contained  in  a
  207.  file,  but  not  all  of them are used by the application.  Normally,
  208.  Ftnchek warns you if any subprograms  are  defined  but  never  used.
  209.  This switch will suppress these warnings.  Default = no.
  210. 3 /linebreak
  211.  Normally, when scanning a statement which is continued onto the  next
  212.  line,  Ftnchek  treats the end of the line as a space.  This behavior
  213.  is the same as for Pascal and C, and also corresponds to  how  humans
  214.  normally  would  read  and write programs.  However, occasionally one
  215.  would like to use Ftnchek to check a program in which identifiers and
  216.  keywords  are  split  across  lines,  for instance programs which are
  217.  produced using a preprocessor.  Choosing the option /nolinebreak will
  218.  cause Ftnchek to skip over the end of line and also any leading space
  219.  on the continuation line (from the continuation mark up to the  first
  220.  nonspace character).  Default = yes, i.e.  treat linebreaks as space.
  221.  Default = no.
  222.  
  223.       Note  that  in  nolinebreak  mode,  if  token  pairs   requiring
  224.  intervening  space  (for  instance, GOTO 100) are separated only by a
  225.  linebreak, they will be rejoined.
  226.  
  227.       Also, tokens requiring more than one character of lookahead  for
  228.  the  resolution  of  ambiguities  must not be split across lines.  In
  229.  particular, a complex constant may not be split across a line.
  230. 3 /list
  231.  Specifies that a listing of the Fortran program is to be printed  out
  232.  with  line  numbers.   If Ftnchek detects an error, the error message
  233.  follows the program line with a caret ( ^ ) specifying  the  location
  234.  of the error.  If no source listing was requested, Ftnchek will still
  235.  print  out  any  line  containing  an  error,  to  aid  the  user  in
  236.  determining where the error occurred.  Default = no.
  237. 3 /novice
  238.  This flag is  intended  to  provide  additional  helpful  output  for
  239.  beginners.   At  this  time,  the only extra message it provides is a
  240.  comment that any function that is used but not defined anywhere might
  241.  be an array which the user forgot to declare in a DIMENSION statement
  242.  (since the syntax of an array reference is the  same  as  that  of  a
  243.  function reference).  Default = yes.
  244.  
  245.       In earlier versions  of  Ftnchek,  this  option  could  take  on
  246.  various  numerical values, as a way of controlling various classes of
  247.  warnings.  These warnings are now controlled  individually  by  their
  248.  own flags.  Novice level 1 is now handled by the /array flag; level 2
  249.  has been eliminated; level 3 is equivalent now to setting /novice  to
  250.  yes; level 4 is handled by the /impure flag.
  251. 3 /output=n
  252.  This setting is provided for convenience  on  systems  which  do  not
  253.  allow easy redirection of output from programs.  When this setting is
  254.  given, the output which normally appears on the screen will  be  sent
  255.  instead to the named file.  Note, however, that operational errors of
  256.  Ftnchek itself (e.g.  out of space or cannot open file) will still be
  257.  sent  to the screen.  The extension for the filename is optional, and
  258.  if no extension is given, the extension '.lis' will be used.
  259. 3 /portability
  260.  Ftnchek will give warnings for  a  variety  of  non-portable  usages.
  261.  These  include  the use of tabs except in comments or inside strings,
  262.  the use of hollerith constants, and the equivalencing of variables of
  263.  different  data  types.   This  option  does not produce warnings for
  264.  violations  of  the  Fortran  77  standard,  which  may  also   cause
  265.  portability  problems.  To catch those, use the /f77 option.  Default
  266.  = no.
  267. 3 /pretty
  268.  Controls certain messages related to the  appearance  of  the  source
  269.  code.   These warn about things that might in some cases be deceptive
  270.  to the reader.  At present, the only warning that  is  controlled  by
  271.  this  flag  refers  to  comments  that  are  interspersed  among  the
  272.  continuation lines of a statement.  Default = yes.
  273. 3 /project
  274.  Ftnchek will create a project file from  each  source  file  that  is
  275.  input  while  this flag is in effect.  The project file will be given
  276.  the same name as the input file,  but  with  the  extension  '.f'  or
  277.  '.for'  replaced  by  '.prj'.   (If input is from standard input, the
  278.  project file is named ftnchek.prj.) Default = no.
  279.  
  280.       A project file contains a summary of information from the source
  281.  file,  for  use in checking agreement among FUNCTION, SUBROUTINE, and
  282.  COMMON block usages in other files.  It allows incremental  checking,
  283.  which  saves  time  whenever you have a large set of files containing
  284.  shared subroutines, most of which seldom change.  You can run Ftnchek
  285.  once  on  each  file with the /project flag set, creating the project
  286.  files.  Usually you would also set the /library and  /noextern  flags
  287.  at this time, to suppress messages relating to consistency with other
  288.  files.  Only error messages pertaining to each file by itself will be
  289.  printed at this time.  Thereafter, run Ftnchek without these flags on
  290.  all the project  files  together,  to  check  consistency  among  the
  291.  different  files.  All messages internal to the individual files will
  292.  now be omitted.  Only when a file is altered will a new project  file
  293.  need to be made for it.
  294.  
  295.       Project files  contain  only  information  needed  for  checking
  296.  agreement between files.  This means that a project file is of no use
  297.  if all modules of the complete program  are  contained  in  a  single
  298.  file.
  299.  
  300.       Ordinarily, project files should be created  with  the  /library
  301.  flag  in  effect.  In this mode, the information saved in the project
  302.  file  consists  of  all  subprogram  declarations,   all   subprogram
  303.  invocations  not  resolved  by declarations in the same file, and one
  304.  instance of each COMMON  block  declaration.   This  is  the  minimum
  305.  amount  of  information  needed to check agreement between files.  Of
  306.  course, this means that the calling hierarchy among routines  defined
  307.  within  the  file  is lost.  Normally the loss of this information is
  308.  unimportant.  If you wish to retain this information for some reason,
  309.  you  can  create  the project file with the /library flag turned off.
  310.  In this mode, Ftnchek saves, besides the  information  listed  above,
  311.  one invocation of each subprogram by any other subprogram in the same
  312.  file, and all common block declarations.  This means that the project
  313.  file  will  be  larger  than  necessary, and that when it is read in,
  314.  Ftnchek may repeat some inter-module checks that it already did  when
  315.  the project file was created.
  316.  
  317.       Because of the  loss  of  information  entailed  by  creating  a
  318.  project  file with the /library flag in effect, whenever that project
  319.  file is read  in  later,  it  will  be  treated  as  a  library  file
  320.  regardless of the current setting of the /library flag.  On the other
  321.  hand, a project file created with library mode turned off can be read
  322.  in later in either mode.
  323.  
  324.       Naturally, when the /project flag is set, Ftnchek will not  read
  325.  project files as input.
  326. 3 /pure
  327.  Assume functions are "pure", i.e., they will not have side effects by
  328.  modifying  their arguments or variables in a common block.  When this
  329.  flag is in effect, Ftnchek will base its  determination  of  set  and
  330.  used  status of the actual arguments on the assumption that arguments
  331.  passed to a function are not altered.  It will also issue  a  warning
  332.  if  a  function is found to modify any of its arguments or any common
  333.  variables.  Default=yes.
  334.  
  335.       When this  flag  is  turned  off,  actual  arguments  passed  to
  336.  functions  will be handled the same way as actual arguments passed to
  337.  subroutines.  This means that Ftnchek will assume that arguments  may
  338.  be  modified  by  the  functions.   No  warnings  will  be given if a
  339.  function is found to have side effects.  Because stricter checking is
  340.  possible  if  functions  are assumed to be pure, you should turn this
  341.  flag off only if your  program  actually  uses  functions  with  side
  342.  effects.
  343. 3 /sixchar
  344.  One of the goals of the Ftnchek program is to  help  users  to  write
  345.  portable Fortran programs.  One potential source of nonportability is
  346.  the use of variable names that are longer than six characters.   Some
  347.  compilers  just  ignore  the  extra  characters.  This behavior could
  348.  potentially lead to two different variables being considered  as  the
  349.  same.  For instance, variables named AVERAGECOST and AVERAGEPRICE are
  350.  the same in the first six characters.  If  you  wish  to  catch  such
  351.  possible conflicts, use this flag.  Default = no.
  352. 3 /symtab
  353.  A symbol table will be printed  out  for  each  module,  listing  all
  354.  identifiers  mentioned  in  the module.  This table gives the name of
  355.  each variable, its datatype, and the number of dimensions for arrays.
  356.  An  asterisk  (*)  indicates  that  the  variable has been implicitly
  357.  typed, rather than  being  named  in  an  explicit  type  declaration
  358.  statement.   The  table  also  lists  all  subprograms invoked by the
  359.  module, all COMMON blocks declared, etc.  Default = no.
  360. 3 /truncation
  361.  Warn about possible truncation (or roundoff) errors.  Most  of  these
  362.  are  related  to  integer arithmetic.  The warnings enabled when this
  363.  flag is in effect are:  conversion of a complex or  double  precision
  364.  value  to  single  precision; conversion of any real type to integer;
  365.  use of the result of integer  division  where  a  real  result  seems
  366.  intended  (namely  as  an  exponent,  or  if  the  quotient  is later
  367.  converted to real); division in an integer constant  expression  that
  368.  yields  a  result of zero; exponentiation of an integer by a negative
  369.  integer  (which  yields  zero  unless  the  base  integer  is  1   in
  370.  magnitude);  and use of a non-integer array subscript, DO index or DO
  371.  loop bounds.  Default=yes.
  372.  
  373.       Note:  warnings about truncating type conversions are given only
  374.  when  the  conversion  is  done automatically, i.e.  by an assignment
  375.  statement.  If intrinsic functions such as INT are  used  to  perform
  376.  the conversion, no warning is given.
  377. 3 /usage=n
  378.  Warn about unused or possible uninitialized variables.  Default=3.
  379.  
  380.       The meanings of the setting values are as follows:
  381.  
  382.          0:  no warnings.
  383.  
  384.          1:  warn if variables are (or may be) used  before  they  are
  385.             set.
  386.  
  387.          2:  warn if variables are declared or set but never used.
  388.  
  389.          3:  give both types of warnings.
  390.  
  391.       Sometimes Ftnchek makes a mistake about these warnings.  Usually
  392.  it  errs on the side of giving a warning where no problem exists, but
  393.  in rare cases it may fail to warn where the problem does exist.   See
  394.  the section on bugs for examples.  If variables are equivalenced, the
  395.  rule used by Ftnchek is that a reference to any variable implies  the
  396.  same  reference  to all variables it is equivalenced to.  For arrays,
  397.  the rule is that a reference to any array element  is  treated  as  a
  398.  reference to all elements of the array.
  399. 3 /verbose
  400.  This option is on by default.  Turning it off reduces the  amount  of
  401.  output  relating to normal operation, so that error messages are more
  402.  apparent.  This option is provided for the convenience of  users  who
  403.  are  checking  large suites of files.  The eliminated output includes
  404.  the names of project files, and the message reporting that no  syntax
  405.  errors  were  found.   (Some  of this output is turned back on by the
  406.  /list and /symtab options.) Default = yes.
  407. 2 Changing_the_defaults
  408.  
  409.       Ftnchek includes a mechanism for changing the default values  of
  410.  all  options  by defining environment variables.  When Ftnchek starts
  411.  up, it looks in its environment for any  variables  whose  names  are
  412.  composed by prefixing the string FTNCHEK_ onto the uppercased version
  413.  of the option name.  If such a variable is found, its value  is  used
  414.  to  specify  the default for the corresponding switch or setting.  In
  415.  the case of settings (for example, the novice level) the value of the
  416.  environment  variable  is  read as the default setting value.  In the
  417.  case of switches, the default switch will be taken  as  true  or  yes
  418.  unless  the  environment  variable has the value 0 or NO.  Of course,
  419.  command-line options will override these defaults  the  same  way  as
  420.  they override the built-in defaults.
  421.  
  422.       Note that the environment variable name must be constructed with
  423.  the  full-length  option  name,  which  must  be  in  uppercase.  For
  424.  example, to make Ftnchek print a source listing by default,  set  the
  425.  environment  variable FTNCHEK_LIST to 1 or YES or anything other than
  426.  0 or NO.  The  names  FTNCHEK_LIS  (not  the  full  option  name)  or
  427.  ftnchek_list  (lower  case)  would not be recognized.  The way to set
  428.  the environment variables on the  VAX/VMS  system  is  by  using  the
  429.  DEFINE command.  For example, to set the default /list switch to YES,
  430.  give the command
  431.  
  432.      $ DEFINE FTNCHEK_LIST 1
  433.  
  434.