anchor.diff:      real(kflt)                      :: tfista,tpfista,mnest
       real                            :: elapsed
       real(kflt)                      :: facc
  -    real(kflt)                      :: grd_nrm ! grd_nrm to be minimized; magnitude of the gradient
  -    real(kflt)                      :: max_err
       real(kflt),parameter            :: gamma1=0.9_kflt,gamma2=0.999_kflt
       logical                         :: fixed_gamma = .true.
       real(kflt)                      :: g1,g2
  
positive.code:              end if
            end if
            
            ! print reconstr. err. 
            max_err = sqrt(maxval((fmodel - fdata + lambda * prm)**2))
            grd_nrm = sqrt(sum((fmodel - fdata + lambda * prm)**2)/size(prm))
            
            ! compute gradient  of the cost function
            call cost_compute_gradient(fdata,fmodel,lambda,prm,grd)
  
            select case(trim(algorithm))
            case('gd')
  
negative.code:     dimm = dim1 + dim2
  
      tot_iter = 0
      
      write(ulog,'(a)') &
           '# iter, '//&
           ' max_abs_grad, sum(grad**2),'//&
           '     data_ene, prior_energy,'//&
           '     cpu_time'
  
      if (niter_agd > 0) call map_all('adam',nvars,nclasses,seq,seqs_table,prm,fmodel,&
           fdata,data_format,ulog,beta,lambda,&
           niter_agd,mc_nsweeps,tot_iter,nupdate)
      
  