c===============================================================================
c
c     One-off calculation for computing resource requirements for     
c     MetaCenter application ...
c
c===============================================================================

      implicit       none

      integer        maxd
      parameter    ( maxd = 3 )

      integer        d,    n(maxd),    td,    nt,   fcn_gp,  flop_gp,
     *               nrun

      integer        i,    ntot

      real           mem,   flop_run,   cpu_run,    memint_run,
     *               su_run

      integer        float_size
      parameter    ( float_size = 1 )

      real           rate
      parameter    ( rate = 3.0e8 * 3600.0 )

100   continue
         write(*,*) 'Spatial dimensionality (1-3)?'
         read(*,*,end=900,err=100) d
         if( d .lt. 1  .or.  d .gt. maxd ) go to 100
         do i = 1 , d
            write(*,*) 'n ', i, '?'
            read(*,*,end=900,err=100) n(i)
         end do
         ntot = n(1)
         do i = 2 , d
            ntot = ntot * n(i)
         end do
         write(*,*) 'Time dependent [0/1]?'
         read(*,*,end=900,err=100) td
         if( td .ne. 0 ) then
            write(*,*) 'Number of time steps?'
            read(*,*,end=900,err=100) nt
         else 
            nt = 1
         end if
         write(*,*) 'Fcns per grid point?'
         read(*,*,end=900,err=100) fcn_gp
         write(*,*) 'Estimated flops per grid point?'
         read(*,*,end=900,err=100) flop_gp
         write(*,*) 'Number of runs?'
         read(*,*,end=900,err=100) nrun

         mem = float(ntot) * float(float_size) *
     *         float(fcn_gp) / 1.0e6
         flop_run = float(ntot) * float(nt) * float(flop_gp)
         cpu_run = flop_run / rate 
         memint_run = cpu_run * mem
         write(*,*) 'CPU/run:     ', cpu_run,     ' hours'
         write(*,*) 'Mem/run:     ', mem,         ' MW'
         write(*,*) 'Mem Int/run: ', memint_run,  ' MW-hours'
         su_run = 0.76 * cpu_run + 0.015625 * memint_run
         write(*,*) 'SU/run:      ', su_run
         write(*,*) 'SU total:    ', su_run * nrun
      go to 100
900   continue
      stop
      end
