#!/bin/csh
# This script performs a global source code syntax check of each
# ESP-r module (Linux version). It is intended for use after all
# executables have been created (via the Install script) but prior
# to invoking the option to clean up the source folders. The script
# invokes forchk to identify potential coding issues. The results
# are placed in file xx.chk, which is backed up prior to use. 

# For bps and prj a file 'all_source.F' is created because the
# number of files is more than forchk can handle.

# The output includes the last 40 lines of the forchk report
# as it progresses through each ESP-r module. This summary section
# may help to spot new errors.

# This script is for Linux computers and requires that forchk
# is within the user's $PATH and that $FCKCNF has been defined
# (typically as a pointer to esp-r.cnf in /usr/local/lib/forcheck/.


echo "'all_fckX11' assumes forchk V13 is located in /usr/local/bin."
echo "Usage: cd to the ESP-r src directory then issue the command 'all_fckX11"
echo "current working directory is " $PWD

foreach i (esruaco esrub2e esruc2e esruclm esrucnv esrudfs esrudbm \
  esrue2r esrueco esrugrd esruish esrumfs esrumld esrumrt esrunet esrupdb \
  esruprj esrures esruvew )
 if ( -d $i ) then
   echo looking at $i
   cd $i
   if ( -f xx.chk ) mv xx.chk xx.chk-
   if ( -f $i.xx.chk ) mv $i.xx.chk $i.xx.chk-
   /usr/local/bin/forchk  -I ../include *.F *.f90 ../lib/esru_ask.F ../lib/esru_blk.F ../lib/esru_libNonGTK.F > $i.xx.chk
   echo "looking at" $i.xx.chk
   tail -40 $i.xx.chk | more
   cd ..
 endif
end

foreach i (esrubps )
 if ( -d $i ) then
   echo looking at $i
   cd $i
   if ( -f xx.chk ) mv xx.chk xx.chk-
   if ( -f $i.xx.chk ) mv $i.xx.chk $i.xx.chk-
   /usr/local/bin/forchk  -I ../include *.F *.f90 ../lib/esru_ask.F ../lib/esru_blk.F ../lib/esru_libNonGTK.F > $i.xx.chk
   echo "looking at bps" $i.xx.chk
   tail -40 $i.xx.chk | more
   cd ..
 endif
end
