Scale.F


#include "iadefines.h"
c**********************************************************************
#include "author.inc"
c*    $Id: Scale.F,v 1.11 1996/04/24 19:14:11 turner Exp $
c*
c*    Subroutine to scale a linear system.
c*
c*    <PARAMETER LIST>
c*
c*     Input:
c*      scale - parameter to control scaling
c*         0  ==>  no scaling
c*         1  ==>  scale by maximum absolute value in each row
c*         2  ==>  row-scale and then scale by diagonal elements
c*                 (Jacobi preconditioning)
c*      ia - integer vector containing info about how "a" is stored
c*        NOTE: see description of ia below
c*      ja - index array
c*
c*     In/Out:
c*      b - source vector
c*      a - coefficient matrix
c*
c*     Output:
c*      status - return status
c*        -3  ==>  internal error
c*        -2  ==>  memory allocation failure
c*         0  ==>  success
c*
#include "iadesc.inc"
c*
c*    <SUBROUTINES REQUIRED>
c*
c*     JT_DiagScale - scales by diagonal elements
c*     JT_RowScale - scales by max element in each row
c*
#include "copyright.inc"
c**********************************************************************
      subroutine JT_Scale (scale, b, a, ia, ja, status)
      implicit none
c
c ... Input:
      integer scale
      integer ia(_JT_no_of_storage_parameters_)
      integer ja(*)
c
c ... In/Out:
      real a(*)
#ifdef strict_f77
      real b(*)
#else
      real b(ia(_JT_nrows_))
#endif
c
c ... Output:
      integer status
c
      if (scale .eq. 0) return
c
c ... Scale by max element in each row.
      call JT_RowScale (b, a, ia, ja, status)
      if (status .ne. 0) goto 9999
c
      if (scale .eq. 2) then
c
c .... Apply diagonal (Jacobi) scaling.
       call JT_DiagScale (b, a, ia, ja, status)
      endif
c
 9999 continue
      if (status .eq. -1) status = -3
c
      return
      end