From d39cf62ce58708a5c8942bed8b855926fb7b8b2d Mon Sep 17 00:00:00 2001 From: Nicholas Hannah Date: Wed, 10 Jun 2015 13:24:25 -0700 Subject: [PATCH] Check relative and absolute errors when doing conservative remapping. #62 --- src/ALE/MOM_remapping.F90 | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/ALE/MOM_remapping.F90 b/src/ALE/MOM_remapping.F90 index 487d12ce8c..0797cd928e 100644 --- a/src/ALE/MOM_remapping.F90 +++ b/src/ALE/MOM_remapping.F90 @@ -534,15 +534,22 @@ subroutine remapping_core( CS, n0, h0, u0, n1, dx, u1 ) if (k<=n0) then; hTmp = h0(k); else; hTmp = 0.; endif z0 = z0 + hTmp ; z1 = z1 + ( hTmp + ( dx(k+1) - dx(k) ) ) enddo + ! Maximum error based on guess at maximum roundoff if (abs(totalHU2-totalHU0) > (err0+err2)*max(real(n0), real(n1)) .and. (err0+err2)/=0.) then - write(0,*) 'h0=',h0 - write(0,*) 'hf=',h0(1:n1)+dx(2:n1+1)-dx(1:n1) - write(0,*) 'u0=',u0 - write(0,*) 'u1=',u1 - write(0,*) 'total HU0,HUf,f-0=',totalHU0,totalHU2,totalHU2-totalHU0 - write(0,*) 'err0,errF=',err0,err2 - call MOM_error( FATAL, 'MOM_remapping, remapping_core: '//& - 'Total stuff on h0 and hF differ by more than roundoff' ) + ! Maximum relative error + if (abs(totalHU2-totalHU0) / totalHU2 > 1e-6) then + ! Maximum absolute error + if (abs(totalHU2-totalHU0) > 1e-18) then + write(0,*) 'h0=',h0 + write(0,*) 'hf=',h0(1:n1)+dx(2:n1+1)-dx(1:n1) + write(0,*) 'u0=',u0 + write(0,*) 'u1=',u1 + write(0,*) 'total HU0,HUf,f-0=',totalHU0,totalHU2,totalHU2-totalHU0 + write(0,*) 'err0,errF=',err0,err2 + call MOM_error( FATAL, 'MOM_remapping, remapping_core: '//& + 'Total stuff on h0 and hF differ by more than roundoff' ) + endif + endif endif #endif