Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(sim_message): Refactor to have independent sim_message #353

Merged
merged 7 commits into from
Mar 18, 2020
2 changes: 1 addition & 1 deletion autotest/test_gwf_returncodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_mf6_idomain_error():

@raises(RuntimeError)
def test_unknown_keyword_error():
returncode, buff = run_mf6([mf6_exe, 'unknown_keyword'], ws)
returncode, buff = run_mf6([mf6_exe, '--unknown_keyword'], ws)
msg = 'could not run {}'.format('unknown_keyword')
if returncode != 0:
err_str = 'mf6: illegal option'
Expand Down
19 changes: 10 additions & 9 deletions src/Model/GroundWaterFlow/gwf3.f90
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ subroutine gwf_cr(filename, id, modelname, smr)
use ListsModule, only: basemodellist
use BaseModelModule, only: AddBaseModelToList
use SimModule, only: ustop, store_error, count_errors
use InputOutputModule, only: write_centered
use GenericUtilitiesModule, only: write_centered
use ConstantsModule, only: LINELENGTH, LENPACKAGENAME
use VersionModule, only: VERSION, MFVNAM, MFTITLE, &
FMTDISCLAIMER, IDEVELOPMODE
Expand Down Expand Up @@ -164,19 +164,20 @@ subroutine gwf_cr(filename, id, modelname, smr)
call namefile_obj%openlistfile(this%iout)
!
! -- Write title to list file
call write_centered('MODFLOW'//MFVNAM, this%iout, 80)
call write_centered(MFTITLE, this%iout, 80)
call write_centered('GROUNDWATER FLOW MODEL (GWF)', this%iout, 80)
call write_centered('VERSION '//VERSION, this%iout, 80)
call write_centered('MODFLOW'//MFVNAM, 80, iunit=this%iout)
call write_centered(MFTITLE, 80, iunit=this%iout)
call write_centered('GROUNDWATER FLOW MODEL (GWF)', 80, iunit=this%iout)
call write_centered('VERSION '//VERSION, 80, iunit=this%iout)
!
! -- Write if develop mode
if (IDEVELOPMODE == 1) call write_centered('***DEVELOP MODE***', &
this%iout, 80)
if (IDEVELOPMODE == 1) then
call write_centered('***DEVELOP MODE***', 80, iunit=this%iout)
end if
!
! -- Write compiler version
call get_compiler(compiler)
call write_centered(' ', this%iout, 80)
call write_centered(trim(adjustl(compiler)), this%iout, 80)
call write_centered(' ', 80, iunit=this%iout)
call write_centered(trim(adjustl(compiler)), 80, iunit=this%iout)
!
! -- Write disclaimer
write(this%iout, FMTDISCLAIMER)
Expand Down
43 changes: 29 additions & 14 deletions src/Model/GroundWaterFlow/gwf3csub8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ module GwfCsubModule
LENBUDTXT, LENAUXNAME, LENORIGIN, &
TABLEFT, TABCENTER, TABRIGHT, &
TABSTRING, TABUCSTRING, TABINTEGER, TABREAL
use SimVariablesModule, only: istdout
use GenericUtilities, only: is_same
use GenericUtilitiesModule, only: is_same, sim_message
use SmoothingModule, only: sQuadraticSaturation, &
sQuadraticSaturationDerivative
use NumericalPackageModule, only: NumericalPackageType
Expand All @@ -20,7 +19,7 @@ module GwfCsubModule
GetTimeSeriesLinkFromList
use InputOutputModule, only: get_node, extract_idnum_or_bndname, UWWORD
use BaseDisModule, only: DisBaseType
use SimModule, only: count_errors, store_error, store_error_unit, ustop
use SimModule, only: count_errors, store_error, store_error_unit, ustop
use ArrayHandlersModule, only: ExpandArray
use SortModule, only: qsort, selectn
!
Expand Down Expand Up @@ -448,6 +447,7 @@ subroutine csub_cc(this, iend, icnvg, nodes, hnew, hold, hclose, rclose)
real(DP), intent(in) :: hclose
real(DP), intent(in) :: rclose
! -- local
character(len=LINELENGTH) :: line
integer(I4B) :: ifirst
integer(I4B) :: ib
integer(I4B) :: node
Expand All @@ -471,12 +471,15 @@ subroutine csub_cc(this, iend, icnvg, nodes, hnew, hold, hclose, rclose)
real(DP) :: v2
real(DP) :: df
! format
02000 format(4x,'CSUB PACKAGE FAILED CONVERGENCE CRITERIA',//, &
4x,'INTERBED MAX. HEAD CHANGE ',1x,'INTERBED MAX. FLOW DIFF',/, &
4x,2(a10,1x,a15,1x),/,4x,53('-'))
02010 format(4x,2(i10,1x,G15.7,1x))
02020 format(4x,53('-'))
02030 format('CONVERGENCE FAILED AS A RESULT OF CSUB PACKAGE',1x,a)
character(len=*), parameter :: fmtheader = "(2(a10,1x,a15,1x))"
character(len=*), parameter :: header = &
&"(4x,'CSUB PACKAGE FAILED CONVERGENCE CRITERIA',//, &
&4x,'INTERBED MAX. HEAD CHANGE ',1x,'INTERBED MAX. FLOW DIFF',/, &
&4x,a/,4x,53('-'))"
character(len=*), parameter :: fmtline = "(4x,2(i10,1x,G15.7,1x))"
character(len=*), parameter :: fmtfooter = "(4x,53('-'))"
character(len=*), parameter :: fmtmsg = &
&"('CONVERGENCE FAILED AS A RESULT OF CSUB PACKAGE',1x,a)"
! --------------------------------------------------------------------------
ifirst = 1
if (this%gwfiss == 0) then
Expand Down Expand Up @@ -535,17 +538,29 @@ subroutine csub_cc(this, iend, icnvg, nodes, hnew, hold, hclose, rclose)
icnvg = 0
! write convergence check information if this is the last outer iteration
if (iend == 1) then
write(istdout, 2030) this%name
write(this%iout, 2000) &
! -- write table to this%iout
call sim_message(this%name, fmt=fmtmsg, iunit=this%iout)
write(line, fmtheader) &
' LOCATION', ' HEAD CHANGE', &
' LOCATION', 'FLOW DIFFERENCE'
call sim_message(line, fmt=header, iunit=this%iout)
write(line, fmtline) ihmax, hmax, irmax, rmax
call sim_message(line, iunit=this%iout)
! -- write table to stdout
call sim_message(this%name, fmt=fmtmsg)
write(line, fmtheader) &
' LOCATION', ' HEAD CHANGE', &
' LOCATION', 'FLOW DIFFERENCE'
write(istdout, 2010) ihmax, hmax, irmax, rmax
write(this%iout,2010) ihmax, hmax, irmax, rmax
call sim_message(line, fmt=header)
write(line, fmtline) ihmax, hmax, irmax, rmax
call sim_message(line)
end if
end if
end if
if (icnvg == 0) then
write(this%iout,2020)
!write(this%iout,2020)
call sim_message('', fmt=fmtfooter, iunit=this%iout)
call sim_message('', fmt=fmtfooter)
end if
!
! -- return
Expand Down
40 changes: 27 additions & 13 deletions src/Model/GroundWaterFlow/gwf3lak8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module LakModule
DNODATA, &
TABLEFT, TABCENTER, TABRIGHT, &
TABSTRING, TABUCSTRING, TABINTEGER, TABREAL
use SimVariablesModule, only: istdout
use MemoryTypeModule, only: MemoryTSType
use MemoryManagerModule, only: mem_allocate, mem_reallocate, mem_setptr, &
mem_deallocate
Expand All @@ -24,8 +23,8 @@ module LakModule
use ObsModule, only: ObsType
use InputOutputModule, only: get_node, URWORD, extract_idnum_or_bndname
use BaseDisModule, only: DisBaseType
use SimModule, only: count_errors, store_error, ustop, &
store_error_unit
use SimModule, only: count_errors, store_error, ustop
use GenericUtilitiesModule, only: sim_message
use ArrayHandlersModule, only: ExpandArray
use BlockParserModule, only: BlockParserType
use BaseDisModule, only: DisBaseType
Expand Down Expand Up @@ -3840,6 +3839,7 @@ subroutine lak_cc(this, iend, icnvg, hclose, rclose)
real(DP), intent(in) :: hclose
real(DP), intent(in) :: rclose
! -- local
character(len=LINELENGTH) :: line
integer(I4B) :: n
integer(I4B) :: ifirst
real(DP) :: dh
Expand All @@ -3855,11 +3855,14 @@ subroutine lak_cc(this, iend, icnvg, hclose, rclose)
real(DP) :: ex
real(DP) :: pd
! format
02000 format(4x,'LAKE PACKAGE FAILED CONVERGENCE CRITERIA',//, &
4x,a10,4(1x,a15),/,4x,74('-'))
02010 format(4x,i10,4(1x,G15.7))
02020 format(4x,74('-'))
02030 format('CONVERGENCE FAILED AS A RESULT OF LAKE PACKAGE',1x,a)
character(len=*), parameter :: fmtheader = "(4x,a10,4(1x,a15))"
character(len=*), parameter :: header = &
&"(4x,'LAKE PACKAGE FAILED CONVERGENCE CRITERIA',//, &
&4x,a/,4x,74('-'))"
character(len=*), parameter :: fmtline = "(4x,i10,4(1x,G15.7))"
character(len=*), parameter :: fmtfooter = "(4x,74('-'))"
character(len=*), parameter :: fmtmsg = &
&"('CONVERGENCE FAILED AS A RESULT OF LAKE PACKAGE',1x,a)"
! --------------------------------------------------------------------------
ifirst = 1
if (this%iconvchk /= 0) then
Expand All @@ -3885,19 +3888,30 @@ subroutine lak_cc(this, iend, icnvg, hclose, rclose)
if (iend == 1) then
if (ifirst == 1) then
ifirst = 0
write(istdout,2030) this%name
write(this%iout, 2000) ' LAKE', &
' DH', ' DH CRITERIA', &
! -- write table to this%iout
call sim_message(this%name, fmt=fmtmsg, iunit=this%iout)
write(line, fmtheader) &
' LAKE', &
' DH', ' DH CRITERIA', &
' PCTDIFF', ' PCTDIFF CRITER'
call sim_message(line, fmt=header, iunit=this%iout)
! -- write table to stdout
call sim_message(line, fmt=header)
end if
write(this%iout,2010) n, dh, hclose, pd, this%pdmax
write(line, fmtline) n, dh, hclose, pd, this%pdmax
call sim_message(line, iunit=this%iout)
! -- write table to stdout
call sim_message(line)
else
exit final_check
end if
end if
end do final_check
if (ifirst == 0) then
write(this%iout,2020)
! -- write table to this%iout
call sim_message('', fmt=fmtfooter, iunit=this%iout)
! -- write table to stdout
call sim_message('', fmt=fmtfooter)
end if
end if
!
Expand Down
46 changes: 32 additions & 14 deletions src/Model/GroundWaterFlow/gwf3sfr8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module SfrModule
LENPACKAGENAME, MAXCHARLEN, &
DHNOFLO, DHDRY, DNODATA, &
TABLEFT, TABCENTER, TABRIGHT
use SimVariablesModule, only: istdout
use SmoothingModule, only: sQuadraticSaturation, sQSaturation, &
sQuadraticSaturationDerivative, sQSaturationDerivative, &
use SmoothingModule, only: sQuadraticSaturation, sQSaturation, &
sQuadraticSaturationDerivative, &
sQSaturationDerivative, &
sCubicSaturation, sChSmooth
use BndModule, only: BndType
use BudgetObjectModule, only: BudgetObjectType, budgetobject_cr
Expand All @@ -22,6 +22,7 @@ module SfrModule
use InputOutputModule, only: get_node, URWORD, extract_idnum_or_bndname
use BaseDisModule, only: DisBaseType
use SimModule, only: count_errors, store_error, store_error_unit, ustop
use GenericUtilitiesModule, only: sim_message
use SparseModule, only: sparsematrix
use ArrayHandlersModule, only: ExpandArray
use BlockParserModule, only: BlockParserType
Expand Down Expand Up @@ -1577,19 +1578,23 @@ subroutine sfr_cc(this, iend, icnvg, hclose, rclose)
real(DP), intent(in) :: hclose
real(DP), intent(in) :: rclose
! -- local
character(len=LINELENGTH) :: line
character(len=15) :: cdhmax
character(len=15) :: crmax
integer(I4B) :: n
integer(I4B) :: ifirst
real(DP) :: dh
real(DP) :: r
! format
02000 format(4x,'STREAMFLOW ROUTING PACKAGE FAILED CONVERGENCE CRITERIA',//, &
4x,a10,2(1x,a15),/,4x,74('-'))
02010 format(4x,i10,2(1x,G15.7))
02020 format(4x,74('-'))
02030 format('CONVERGENCE FAILED AS A RESULT OF STREAMFLOW ROUTING PACKAGE', &
1x,a)
character(len=*), parameter :: fmtheader = "(4x,a10,2(1x,a15))"
character(len=*), parameter :: header = &
&"(4x,'STREAMFLOW ROUTING PACKAGE FAILED CONVERGENCE CRITERIA',//, &
&4x,a/,4x,74('-'))"
character(len=*), parameter :: fmtline = "(4x,i10,2(1x,a15))"
character(len=*), parameter :: fmtfooter = "(4x,74('-'))"
character(len=*), parameter :: fmtmsg = &
&"('CONVERGENCE FAILED AS A RESULT OF STREAMFLOW ROUTING PACKAGE', &
&1x,a)"
! --------------------------------------------------------------------------
ifirst = 1
if (this%iconvchk /= 0) then
Expand All @@ -1603,9 +1608,14 @@ subroutine sfr_cc(this, iend, icnvg, hclose, rclose)
if (iend == 1) then
if (ifirst == 1) then
ifirst = 0
write(istdout,2030) this%name
write(this%iout, 2000) ' REACH', &
' MAX. DH', ' MAX. RESIDUAL'
! -- write table to this%iout
call sim_message(this%name, fmt=fmtmsg, iunit=this%iout)
write(line, fmtheader) &
' REACH', &
' MAX. DH', ' MAX. RESIDUAL'
call sim_message(line, fmt=header, iunit=this%iout)
! -- write table to stdout
call sim_message(line, fmt=header)
end if
cdhmax = ' '
crmax = ' '
Expand All @@ -1615,15 +1625,23 @@ subroutine sfr_cc(this, iend, icnvg, hclose, rclose)
if (ABS(r) > rclose) then
write(crmax, '(G15.7)') r
end if
write(this%iout,2010) n, cdhmax, crmax
!write(this%iout,2010) n, cdhmax, crmax
write(line, fmtline) n, cdhmax, crmax
call sim_message(line, iunit=this%iout)
! -- write table to stdout
call sim_message(line)
! terminate check since no need to find more than one non-convergence
else
exit final_check
end if
end if
end do final_check
if (ifirst == 0) then
write(this%iout,2020)
!write(this%iout,2020)
! -- write table to this%iout
call sim_message('', fmt=fmtfooter, iunit=this%iout)
! -- write table to stdout
call sim_message('', fmt=fmtfooter)
end if
end if
!
Expand Down
6 changes: 4 additions & 2 deletions src/Model/ModelUtilities/Connections.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module ConnectionsModule
use ArrayReadersModule, only: ReadArray
use KindModule, only: DP, I4B
use ConstantsModule, only: LENMODELNAME, LENORIGIN
use SimVariablesModule, only: istdout
use GenericUtilitiesModule, only: sim_message
use BlockParserModule, only: BlockParserType

implicit none
Expand Down Expand Up @@ -360,6 +360,7 @@ subroutine read_connectivity_from_block(this, name_model, nodes, nja, iout)
integer(I4B), intent(in) :: nja
integer(I4B), intent(in) :: iout
! -- local
character(len=LINELENGTH) :: line
character(len=LINELENGTH) :: keyword
integer(I4B) :: ii,n,m
integer(I4B) :: ierr, nerr
Expand Down Expand Up @@ -459,7 +460,8 @@ subroutine read_connectivity_from_block(this, name_model, nodes, nja, iout)
do ii = this%ia(n), this%ia(n + 1) - 1
m = this%ja(ii)
if(n /= this%ja(this%isym(ii))) then
write(istdout, fmtsymerr) aname(2), ii, this%isym(ii)
write(line, fmtsymerr) aname(2), ii, this%isym(ii)
call sim_message(line)
call this%parser%StoreErrorUnit()
call ustop()
endif
Expand Down
Loading