* -*-Fortran-*- Set Emacs Fortran mode explicitly
***********************************************************************
*
* $Id: flops.cpp,v 1.3 1995/05/16 16:17:39 dweber Exp dweber $
* /*
* $Log: flops.cpp,v $
# Revision 1.3  1995/05/16  16:17:39  dweber
# Final revision for project completion.  Notes:
#      #ifdef CMF is back to #ifdef CMFORTRAN
#      No equivalent to CMF_descriptors.  Am looking into pointers.
#      Method #6 (and 16) appear to produce incorrect results.
# .
#
# Revision 1.2  1995/04/18  01:02:09  dweber
# Isolated CMF & HPF specific features with #ifdef statements.
# Tried to update all HPF directives to be HPF specific - not CMF holdovers.
# Deleted the CMF select(var) - case(val) statements, and am using
#         if-then-elseif statements.
# Created architecture types to match the architecture.  This will need
#         some work as HPF has no concept similar to the CMF_architecture
#         functions.
# Since HPF doesn't define a type like CMF_sizeof_descriptor, I had to
#         hardcode the array layouts for HPF.  This may change.
#
# Revision 1.2  1995/04/18  01:02:09  dweber
# Isolated CMF & HPF specific features with #ifdef statements.
# Tried to update all HPF directives to be HPF specific - not CMF holdovers.
# Deleted the CMF select(var) - case(val) statements, and am using
#         if-then-elseif statements.
# Created architecture types to match the architecture.  This will need
#         some work as HPF has no concept similar to the CMF_architecture
#         functions.
# Since HPF doesn't define a type like CMF_sizeof_descriptor, I had to
#         hardcode the array layouts for HPF.  This may change.
#
# Revision 1.1  1995/02/11  20:23:27  jtowns
# Initial revision
#
* */
*
***********************************************************************
*
      subroutine flop_count(mflops,flops,peak,efficiency,
     .                      order,method,ntest,iprecon,iters,etime,
     .                      matvec_ops,preconl_ops,preconr_ops)
*
************************************************************************
*
      implicit none
      integer order,method,iters,ntest,iprecon
      real flops,mflops,peak,efficiency,etime
      real matvec_ops,preconl_ops,preconr_ops,
     .     startup_ops,algorithm_ops
      integer iprntst
*
************************************************************************
*

      goto (610,620,630,640,650,660) method
  
 610  startup_ops= 3. + matvec_ops
      algorithm_ops= 10. + matvec_ops
      iprntst = 10*iprecon + ntest
      
      if (iprntst .eq. 2) then
         startup_ops= startup_ops + 2.
      elseif ((iprntst .eq. 1) .or. (iprntst .eq. 3) .or.
     .        (iprntst .eq. 4) .or. (iprntst .eq. 5) .or.
     .        (iprntst .eq. 6)) then
      elseif (iprntst .eq. 11) then
         startup_ops= startup_ops + preconl_ops + 2.
         algorithm_ops= algorithm_ops + preconl_ops + 4.
      elseif (iprntst .eq. 12) then
         startup_ops= startup_ops + preconl_ops + 4.
         algorithm_ops= algorithm_ops + preconl_ops + 4.
      elseif ((iprntst .eq. 13) .or. (iprntst .eq. 15) .or.
     .        (iprntst .eq. 16)) then
         startup_ops= startup_ops + preconl_ops
         algorithm_ops= algorithm_ops + preconl_ops + 2.
      elseif (iprntst .eq. 14) then
         startup_ops= startup_ops + 2.*preconl_ops + 2.
         algorithm_ops= algorithm_ops + preconl_ops + 2.
      elseif (iprntst .eq. 31) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops + 2.
         algorithm_ops= algorithm_ops + preconl_ops  
     .        + preconr_ops + 4.
      elseif (iprntst .eq. 32) then
         startup_ops= startup_ops + preconl_ops  
     .        + preconr_ops + 4.
         algorithm_ops= algorithm_ops + preconl_ops  
     .        + preconr_ops + 4.
      elseif ((iprntst .eq. 33) .or. (iprntst .eq. 35) .or.
     .        (iprntst .eq. 36)) then
         startup_ops= startup_ops + preconl_ops  
     .        + preconr_ops 
         algorithm_ops= algorithm_ops + preconl_ops  
     .        + preconr_ops + 2.
      elseif (iprntst .eq. 32) then
         startup_ops= startup_ops + 2.*preconl_ops  
     .        + preconr_ops + 2.
         algorithm_ops= algorithm_ops + preconl_ops  
     .        + preconr_ops + 2. 
      endif

      algorithm_ops= algorithm_ops*iters
      goto 700

 620  startup_ops= 3. + 2.*matvec_ops
      algorithm_ops= 10. + 2.*matvec_ops
      iprntst = 10*iprecon + ntest

      if (iprntst .eq. 1) then
         startup_ops= startup_ops + 2.
         algorithm_ops= algorithm_ops + 2.
      elseif (iprntst .eq. 2) then
         startup_ops= startup_ops + 4.
         algorithm_ops= algorithm_ops + 2.
      elseif ((iprntst .eq. 3) .or. (iprntst .eq. 4) .or.
     .        (iprntst .eq. 5) .or. (iprntst .eq. 6)) then
      elseif (iprntst .eq. 11) then
         startup_ops= startup_ops + 2.*preconl_ops + 2.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 12) then
         startup_ops= startup_ops + 2.*preconl_ops + 4.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 12) then
         startup_ops= startup_ops + 2.*preconl_ops + 2.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 14) then
         startup_ops= startup_ops + 3.*preconl_ops + 4.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif ((iprntst .eq. 15) .or. (iprntst .eq. 16)) then
         startup_ops= startup_ops + 2.*preconl_ops
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 2.
      elseif (iprntst .eq. 31) then
         startup_ops= startup_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops + 2.
         algorithm_ops= algorithm_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 32) then
         startup_ops= startup_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
         algorithm_ops= algorithm_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 33) then
         startup_ops= startup_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops 
         algorithm_ops= algorithm_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 34) then
         startup_ops= startup_ops + 3.*preconl_ops 
     .        + 2.*preconr_ops + 2.
         algorithm_ops= algorithm_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4. 
      elseif ((iprntst .eq. 35) .or. (iprntst .eq. 36)) then
         startup_ops= startup_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops 
         algorithm_ops= algorithm_ops + 2.*preconl_ops 
     .        + 2.*preconr_ops + 2.
      endif

      algorithm_ops= algorithm_ops*iters
      goto 700

 630  startup_ops= 3. + matvec_ops
      algorithm_ops= 14. + 2.*matvec_ops
      iprntst = 10*iprecon + ntest

      if (iprntst .eq. 1) then
         algorithm_ops= algorithm_ops + 2.
      elseif (iprntst .eq. 2) then
         startup_ops= startup_ops + 2.
         algorithm_ops= algorithm_ops + 2.
      elseif ((iprntst .eq. 3) .or. (iprntst .eq. 4) .or.
     .        (iprntst .eq. 5) .or. (iprntst .eq. 6)) then
      elseif (iprntst .eq. 11) then
         startup_ops= startup_ops + preconl_ops + 2.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 12) then
         startup_ops= startup_ops + preconl_ops + 4.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 13) then
         startup_ops= startup_ops + preconl_ops
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 14) then
         startup_ops= startup_ops + 2.*preconl_ops + 2.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif ((iprntst .eq. 15) .or. (iprntst .eq. 16)) then
         startup_ops= startup_ops + preconl_ops
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 2.
      elseif (iprntst .eq. 31) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops + 2.
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 32) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops + 4.
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 33) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 34) then
         startup_ops= startup_ops + 2.*preconl_ops 
     .        + preconr_ops + 2.
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4. 
      elseif ((iprntst .eq. 35) .or. (iprntst .eq. 36)) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops 
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 2.
      endif

      algorithm_ops= algorithm_ops*iters
      goto 700


************************************************************************
 640  startup_ops= 3. + matvec_ops
      algorithm_ops= 14. + 2.*matvec_ops
      iprntst = 10*iprecon + ntest

      if (iprntst .eq. 1) then
         algorithm_ops= algorithm_ops + 2.
      elseif (iprntst .eq. 2) then
         startup_ops= startup_ops + 2.
         algorithm_ops= algorithm_ops + 2.
      elseif ((iprntst .eq. 3) .or. (iprntst .eq. 4) .or.
     .        (iprntst .eq. 5) .or. (iprntst .eq. 6)) then
      elseif (iprntst .eq. 11) then
         startup_ops= startup_ops + preconl_ops + 2.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 12) then
         startup_ops= startup_ops + preconl_ops + 4.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 13) then
         startup_ops= startup_ops + preconl_ops
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif (iprntst .eq. 14) then
         startup_ops= startup_ops + 2.*preconl_ops + 2.
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 4.
      elseif ((iprntst .eq. 15) .or. (iprntst .eq. 16)) then
         startup_ops= startup_ops + preconl_ops
         algorithm_ops= algorithm_ops + 2.*preconl_ops + 2.
      elseif (iprntst .eq. 31) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops + 2.
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 32) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops + 4.
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 33) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4.
      elseif (iprntst .eq. 34) then
         startup_ops= startup_ops + 2.*preconl_ops 
     .        + preconr_ops + 2.
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 4. 
      elseif ((iprntst .eq. 35) .or. (iprntst .eq. 36)) then
         startup_ops= startup_ops + preconl_ops 
     .        + preconr_ops 
         algorithm_ops= algorithm_ops + matvec_ops
     .        + 2.*preconl_ops 
     .        + 2.*preconr_ops + 2.
      endif

      algorithm_ops= algorithm_ops*iters
      goto 700



 641  startup_ops= 3. + matvec_ops
      if (ntest .eq. 2) then
         startup_ops= startup_ops + 2.
      elseif ((ntest .eq. 1) .or. (ntest .eq. 5)) then
      endif
      algorithm_ops= 17. + 2.*matvec_ops
      if ((ntest .eq. 1) .or. (ntest .eq. 2)) then
         algorithm_ops= algorithm_ops + 2.
      elseif (ntest .eq. 5) then
      endif
      algorithm_ops= algorithm_ops*iters
      goto 700

 650  startup_ops= 1. + matvec_ops
      if (ntest .eq. 1) then
         startup_ops= startup_ops + 2.
      elseif (ntest .eq. 2) then
         startup_ops= startup_ops + 4.
      elseif (ntest .eq. 5) then
      endif
      algorithm_ops= 20. + 2.*matvec_ops
      if ((ntest .eq. 1) .or. (ntest .eq. 2)) then
         algorithm_ops= algorithm_ops + 2.
      elseif (ntest .eq. 5) then
      endif
      algorithm_ops= algorithm_ops*iters
      goto 700

 660  startup_ops= 5. + 2.*matvec_ops
      if (ntest .eq. 2) then
         startup_ops= startup_ops + 2.
      elseif ((ntest .eq. 1) .or. (ntest .eq. 5)) then
      endif
      algorithm_ops= 36.5 + 2.*matvec_ops
      if ((ntest .eq. 1) .or. (ntest .eq. 2)) then
         algorithm_ops= algorithm_ops + 2.
      elseif (ntest .eq. 5) then
      endif
      algorithm_ops= algorithm_ops*iters
      if (mod(iters,2).eq.1) algorithm_ops= algorithm_ops + 16.

 700  flops= (startup_ops + algorithm_ops)*order
      mflops=flops/(1.d6*etime)
      efficiency= (mflops/peak)*100

      return
      end
