11 #ifndef OOPS_ASSIMILATION_MINRES_H_    12 #define OOPS_ASSIMILATION_MINRES_H_    18 #include "oops/util/dot_product.h"    19 #include "oops/util/formats.h"    20 #include "oops/util/Logger.h"    65 template <
typename VECTOR, 
typename AMATRIX, 
typename PMATRIX>
    66 double MINRES(VECTOR & x, 
const VECTOR & 
b,
    67               const AMATRIX & A, 
const PMATRIX & precond,
    68               const int maxiter, 
const double tolerance) {
    74   double xnrm2 = dot_product(x, x);
    86   precond.multiply(r, y);
    88   double normReduction = 1.0;
    89   double ynrm2 = sqrt(dot_product(y, y));
    90   double beta  = sqrt(dot_product(y, r));
   102   for (jiter = 0; jiter < maxiter; ++jiter) {
   103     Log::info() << 
" MINRES Starting Iteration " << jiter+1 << std::endl;
   113     double alpha = dot_product(y, 
v);
   118     precond.multiply(
r2, y);
   121     beta  = sqrt(dot_product(y, 
r2));
   124     double oldeps = 
epsln;
   125     double delta = cs*dbar + sn*
alpha;
   126     double gbar = sn*dbar - cs*
alpha;
   135     double phi = cs*phibar;
   139     double denom = 1/
gamma;
   144     work.axpy(-oldeps*denom, work1);
   145     work.axpy(-delta*denom, work2);
   148     normReduction = phibar/ynrm2;
   150     Log::info() << 
"MINRES end of iteration " << jiter+1 << 
". PNorm reduction= "   151                 << util::full_precision(normReduction) << std::endl << std::endl;
   154         Log::info() << 
"MINRES: Achieved required reduction in residual norm." << std::endl;
   160   Log::info() << 
"MINRES: end" << std::endl;
   162   return normReduction;
   167 #endif  // OOPS_ASSIMILATION_MINRES_H_ 
The namespace for the main oops code. 
 
subroutine, public info(self)
 
real(fp), parameter, public tolerance
 
complex(r8), parameter r1
 
real(r8), parameter gamma
 
double MINRES(VECTOR &x, const VECTOR &b, const AMATRIX &A, const PMATRIX &precond, const int maxiter, const double tolerance)