diff --git a/source/m1qn3_interface.f90 b/source/m1qn3_interface.f90
index 52a3d1927ab804e4379f26bd453a2b1c65cae1d9..68ca430cfdc9a341c30f9a3c4bd0e19daf4d2fe3 100644
--- a/source/m1qn3_interface.f90
+++ b/source/m1qn3_interface.f90
@@ -190,11 +190,11 @@ subroutine m1qn3_interface(iter, grad, files, config, fluxes, obs, states, covar
       if ( config%lognormal ) then
         ! lognormal
         ! 2Jp = 2*sum(z) + x^Tx (where x = state vector in chi space and z is state vector in physical space)
-        cost_p = sum(states%px) + dot_product(x,x)
+        cost_p = 2.*sum(states%px) + real(dot_product(x,x),kind=4)
       else
         ! normal
         ! 2Jp = x^Tx (where x = state vector in chi space)
-        cost_p = dot_product(x,x) 
+        cost_p = real(dot_product(x,x),kind=4) 
       endif
       ! J = 0.5*(Jp + Jo) 
       cost = 0.5*(cost_p + cost_o)