
# UNISRC_ID: @(#)f_create.sh	27.2	85/03/10  
#  FILE NAME is 'f_create'
#
#  This script is called by the make file generated for the directory.

#  This script runs a compile with the -U option for a .f file and sends the
#  error output to awk.  The awk file prints the name of the .f file if 
#  errors occurred during compilation.  This output is printed to a file
#  which is the routine name concatenated with '.audit'.  Note that this file
#  is always created, but its size is >0 when the compilation generated errors.

#  The size of the .audit file is checked next, and if it is >0, the Softool
#  AUDITOR is executed on the .f file.  The AUDITOR output report is put into
#  a file named from the routine name concatenated with '.L' and the status
#  output of the operation is appended to a log file called 'audit.log'.
#  (Status is 0 if the tool executes properly.)
#  An AUDITOR control file is also used (aud_control) which supresses all 
#  warning, portability, and documentation messages.

#  Next, the .audit file is removed.

#  Next, if compile errors were encountered, the source is modified so that
#  the AUDITOR error messages appear before the source line which caused them
#  as comments.  In addition, the name of the routine is written to a file
#  called 'compile.err'.

rm -f tmp_srcmod `basename $1 .f`.L audit.log 
fc -c -U -g $1 2>&1 | awk -f /usr/contrib/bin/awk_fpe >`basename $1 .f`.aud
echo "compile done" 
echo $1
    if test -s `basename $1 .f`.aud 
      then
	  echo "starting audit"
	  /usr/softool/pedir/AUDITOR <$1 >`basename $1 .f`.L \
	      2>>audit.log /usr/contrib/bin/aud_cntrl
      fi
    rm `basename $1 .f`.aud
    if test -s `basename $1 .f`.L
      then
	  echo "starting auditor report modifications"
	  echo `basename $1 .f`.L
	  awk -f /usr/contrib/bin/aud.mod `basename $1 .f`.L | ex `basename $1 .f`.L
	  echo "starting source modifications"
	  awk -f /usr/contrib/bin/src.mod tmp_srcmod
	  mv tmp_newsrc $1
          echo "compile error in:  " $1 >> ../compile.err
       fi
    rm -f tmp_srcmod `basename $1 .f`.L
