#!/bin/csh
#
#   Run FTNCHEK, a FORTRAN syntax checker, on GAMESS.
#
#   Option 1 is to test individual source code in the directory TestDir,
#   by the command 'checkgms'.
#
#   Option 2 is to test source code in the directory TestDir, plus the
#   remaining parts of GAMESS in the production code directory ProdDir,
#   as a total program, by the command 'checkgms all'.  In order to
#   run the second option, you must redimension a table in FTNCHEK,
#   namely, raise HASHSZ from 20930 to 30930 in ftnchek.h, as GAMESS
#   is now too big to fit in the default space.
#
#   FTNCHEK is available from its point of origin, Fordham University,
#   by anonymous FTP to ftp.dsm.fordham.edu, directory /pub/ftnchek.
#   or see http:/www.dsm.fordham.edu/~ftnchek/ftp-index.html
#   This program is also available at netlib and sunsite, typically.
#   The author, Robert Moniot, is a hero!
#
#   Note that in addition to the dimension change just noted, we suppress
#   a few of the warning messages issued by FTNCHEK for argument testing.
#   A list of these modifications can be sent to you, if you wish.
#
#   The user needs to set two directories:
#
set TestDir='/u1/mike/testgms/source'
set ProdDir='/u1/mike/gamess/source'
#
if ($1 == all) goto do_it_all_together
#
#   ----- this section tests each module separately -----
#
#   The 2nd argument to "comp" causes source activation only,
#   placing the pure FORTRAN in your ~/scr directory for checking.
#   -noextern suppresses messages about unresolved references
#   -common=2 ensures commons agree in type and length
#   -arguments=1 checks only number of args
#   -arguments=2 also ensures arguments agree in data type
#   -array=0 suppresses most array dimension checking
#   -calltree=1 generates who calls whom list, 0 disables this.
#   -crossref generates who is called by whom list, including commons
#
chdir $TestDir
foreach file (*.src)
   set file=$file:r
   if ($file == ddi)    continue
   if ($file == ddishm) continue
   if ($file == ddio3k) continue
   if ($file == unport) continue
   if ($file == vector) continue
   ../comp $file true
   ftnchek -noextern -common=2 -arguments=1 -array=0 \
           -calltree=0 -nocrossref \
       ~/scr/$file.f >& ~/scr/$file.lis
   echo FTNCHEK output for this module is now in ~/scr/$file.lis
   rm ~/scr/$file.f
end
exit
#
#   ----- this section tests the entire program -----
#
do_it_all_together:
#
#   We will analyze all sources, together.
#   Any source found in the working directory is taken as a priority,
#   otherwise we use a standard copy from the production code directory.
#   If new source module names are being developed, you must expand
#   the list of all GAMESS source modules as shown.
#
chdir $ProdDir
set module_list=(*.src)
#---set module_list=(xxx.src yyy.src $module_list)
chdir $TestDir
#
foreach file ($module_list)
   set file=$file:r
   if ($file == blas)   continue
   if ($file == vector) continue
   if (-e $file.src) then
      ../comp $file true
   else
      cp $ProdDir/$file.src .
      ../comp $file true
      rm $file.src
   endif
end
#
echo " "
echo Beginning FTNCHEK of the entire program, stand by...
date
chdir ~/scr
ftnchek -noextern -common=2 -arguments=1 -array=0 \
        -calltree=0 -nocrossref -resources=yes\
        *.f >& gamess.lis
echo FTNCHEK diagnostic messages are now in ~/scr/gamess.lis
rm *.f
date
exit
