Commits

Tobin Isaac committed ef60af6

KSPFGMRES: make KSPMonitor usage match KSPGMRES

KSPGMRES always monitors before an iteration has been taken, even if it is
determined that no iterations are necessary. This change makes KSPFGMRES match
KSPGMRES.

Comments (0)

Files changed (1)

src/ksp/ksp/impls/gmres/fgmres/fgmres.c

 
   ksp->rnorm = res_norm;
   ierr       = KSPLogResidualHistory(ksp,res_norm);CHKERRQ(ierr);
+  ierr       = KSPMonitor(ksp,ksp->its,res_norm);CHKERRQ(ierr);
 
   /* check for the convergence - maybe the current guess is good enough */
   ierr = (*ksp->converged)(ksp,ksp->its,res_norm,&ksp->reason,ksp->cnvP);CHKERRQ(ierr);
   /* keep iterating until we have converged OR generated the max number
      of directions OR reached the max number of iterations for the method */
   while (!ksp->reason && loc_it < max_k && ksp->its < ksp->max_it) {
-    if (loc_it) {ierr = KSPLogResidualHistory(ksp,res_norm);CHKERRQ(ierr);}
+    if (loc_it) {
+      ierr = KSPLogResidualHistory(ksp,res_norm);CHKERRQ(ierr);
+      ierr = KSPMonitor(ksp,ksp->its,res_norm);CHKERRQ(ierr);
+    }
     fgmres->it = (loc_it - 1);
-    ierr       = KSPMonitor(ksp,ksp->its,res_norm);CHKERRQ(ierr);
 
     /* see if more space is needed for work vectors */
     if (fgmres->vv_allocated <= loc_it + VEC_OFFSET + 1) {
 
   /*
      Monitor if we know that we will not return for a restart */
-  if (ksp->reason || ksp->its >= ksp->max_it) {
+  if (loc_it && (ksp->reason || ksp->its >= ksp->max_it)) {
     ierr = KSPMonitor(ksp,ksp->its,res_norm);CHKERRQ(ierr);
   }