Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/riverroute/mosart_budget_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ subroutine check_budget(this, begr, endr, ntracers, dt)
integer :: yr,mon,day,ymd,tod ! time vars
real(r8) :: tmp_in(6, ntracers) ! array to pass to mpi_sum
real(r8) :: tmp_glob(6, ntracers) ! array from mpi_sum
logical :: error_budget ! flag for an error
logical :: error_budget_abs ! flag for an absolute error
logical :: error_budget_rel ! flag for an realtive error
real(r8) :: abserr, relerr
!-------------------------------------------------

Expand Down Expand Up @@ -237,7 +238,8 @@ subroutine check_budget(this, begr, endr, ntracers, dt)
call shr_mpi_sum(tmp_in, tmp_glob, mpicom_rof, 'mosart global budget', all=.false.)

do nt = 1, ntracers
error_budget = .false.
error_budget_abs = .false.
error_budget_rel = .false.
abserr = 0.0_r8
relerr = 0.0_r8
this%beg_vol_glob(nt) = tmp_glob(index_beg_vol_grc, nt)
Expand All @@ -248,13 +250,13 @@ subroutine check_budget(this, begr, endr, ntracers, dt)
this%lag_glob(nt) = tmp_glob(index_lag_grc, nt)
if (this%do_budget(nt)) then
if (abs(this%net_glob(nt) - this%lag_glob(nt)*dt) > this%tolerance) then ! absolute tolerance
error_budget = .true.
error_budget_abs = .true.
abserr = abs(this%net_glob(nt) - this%lag_glob(nt))
end if
if (abs(this%net_glob(nt) + this%lag_glob(nt)) > 1e-6) then ! Why '+'?, why not '*dt'? - if both, could be simplified to "if (error_budget) then"
if ( abs(this%net_glob(nt) - this%lag_glob(nt)) &
/abs(this%net_glob(nt) + this%lag_glob(nt)) > this%rel_tolerance) then ! rel. tolerance
error_budget = .true.
error_budget_rel = .true.
relerr = abs(this%net_glob(nt) - this%lag_glob(nt)) /abs(this%net_glob(nt) + this%lag_glob(nt))
end if
end if
Expand All @@ -272,8 +274,11 @@ subroutine check_budget(this, begr, endr, ntracers, dt)
write (iulog, '(a,f22.6,a)') ' eul erout lag = ', this%lag_glob(nt), '(mil m3)'
write (iulog, '(a,f22.6)') ' absolute budget error = ', abserr
write (iulog, '(a,f22.6)') ' relative budget error = ', relerr
if (error_budget) then
write(iulog,'(a)') ' BUDGET OUT OF BALANCE WARNING '
if (error_budget_abs) then
write(iulog,'(a)') ' BUDGET OUT OF BALANCE WARNING (abs) '
endif
if (error_budget_rel) then
write(iulog,'(a)') ' BUDGET OUT OF BALANCE WARNING (rel) '
endif
write (iulog, '(a)') '-----------------------------------'
end if
Expand Down
1 change: 1 addition & 0 deletions src/riverroute/mosart_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ subroutine mosart_read_namelist()
call mpi_bcast (fincl3, (max_namlen+2)*size(fincl3), MPI_CHARACTER, 0, mpicom_rof, ier)
call mpi_bcast (avgflag_pertape, size(avgflag_pertape), MPI_CHARACTER, 0, mpicom_rof, ier)
call mpi_bcast (budget_frq, 1, MPI_INTEGER, 0, mpicom_rof, ier)
call mpi_bcast (debug_mosart, 1, MPI_LOGICAL, 0, mpicom_rof, ier)

! lnd2rof liquid tracers (liquid tracers OTHER than water)
! coupling the land input of tracers other than standard water to MOSART
Expand Down