MODFLOW 6  version 6.8.0.dev0
USGS Modular Hydrologic Model
imslinearsettingsmodule Module Reference

Data Types

type  imslinearsettingstype
 

Enumerations

enum  
 IMS linear preconditioner types. More...
 

Functions/Subroutines

subroutine init (this, mem_path)
 
subroutine preset_config (this, idfparam)
 Set solver pre-configured settings based on complexity option. More...
 
subroutine read_from_file (this, parser, iout)
 Read the settings for the linear solver from the .ims file,. More...
 
subroutine check_settings (this)
 Check the settings after reading the configuration from file. More...
 
subroutine destroy (this)
 
pure integer(i4b) function, public resolve_ipc (level, relax)
 Resolve the preconditioner enum from the ILU controls. More...
 

Variables

integer(i4b), parameter, public cg_method = 1
 
integer(i4b), parameter, public bcgs_method = 2
 
@, public ipc_unknown = 0
 preconditioner type not set More...
 
@, public ipc_ilu0 = 1
 ILU0 (incomplete LU, zero fill) More...
 
@, public ipc_milu0 = 2
 modified ILU0 More...
 
@, public ipc_ilut = 3
 ILUT (incomplete LU with threshold) More...
 
@, public ipc_milut = 4
 modified ILUT More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
private

Definition at line 15 of file ImsLinearSettings.f90.

Function/Subroutine Documentation

◆ check_settings()

subroutine imslinearsettingsmodule::check_settings ( class(imslinearsettingstype this)
private
Parameters
thislinear settings

Definition at line 270 of file ImsLinearSettings.f90.

271  class(ImsLinearSettingsType) :: this !< linear settings
272  ! local
273  character(len=LINELENGTH) :: warnmsg
274 
275  if (this%level == 0 .and. this%droptol > 0.0_dp) then
276  write (warnmsg, '(a)') "PRECONDITIONER_DROP_TOLERANCE is ignored because &
277  &PRECONDITIONER_LEVELS equals zero."
278  call store_warning(warnmsg)
279  end if
280 
Here is the call graph for this function:

◆ destroy()

subroutine imslinearsettingsmodule::destroy ( class(imslinearsettingstype this)
private
Parameters
thislinear settings

Definition at line 283 of file ImsLinearSettings.f90.

284  class(ImsLinearSettingsType) :: this !< linear settings
285 
286  call mem_deallocate(this%dvclose)
287  call mem_deallocate(this%rclose)
288  call mem_deallocate(this%icnvgopt)
289  call mem_deallocate(this%iter1)
290  call mem_deallocate(this%ilinmeth)
291  call mem_deallocate(this%iscl)
292  call mem_deallocate(this%iord)
293  call mem_deallocate(this%north)
294  call mem_deallocate(this%relax)
295  call mem_deallocate(this%level)
296  call mem_deallocate(this%droptol)
297  call mem_deallocate(this%ifdparam)
298 

◆ init()

subroutine imslinearsettingsmodule::init ( class(imslinearsettingstype this,
character(len=lenmempath)  mem_path 
)
Parameters
thislinear settings
mem_pathsolution memory path

Definition at line 49 of file ImsLinearSettings.f90.

51  class(ImsLinearSettingsType) :: this !< linear settings
52  character(len=LENMEMPATH) :: mem_path !< solution memory path
53 
54  this%memory_path = create_mem_path(mem_path, 'IMSLINEAR')
55 
56  call mem_allocate(this%dvclose, 'DVCLOSE', this%memory_path)
57  call mem_allocate(this%rclose, 'RCLOSE', this%memory_path)
58  call mem_allocate(this%icnvgopt, 'ICNVGOPT', this%memory_path)
59  call mem_allocate(this%iter1, 'ITER1', this%memory_path)
60  call mem_allocate(this%ilinmeth, 'ILINMETH', this%memory_path)
61  call mem_allocate(this%iscl, 'ISCL', this%memory_path)
62  call mem_allocate(this%iord, 'IORD', this%memory_path)
63  call mem_allocate(this%north, 'NORTH', this%memory_path)
64  call mem_allocate(this%relax, 'RELAX', this%memory_path)
65  call mem_allocate(this%level, 'LEVEL', this%memory_path)
66  call mem_allocate(this%droptol, 'DROPTOL', this%memory_path)
67  call mem_allocate(this%ifdparam, 'IDFPARAM', this%memory_path)
68 
69  ! defaults
70  this%dvclose = dzero
71  this%rclose = dzero
72  this%icnvgopt = 0
73  this%iter1 = 0
74  this%ilinmeth = 0
75  this%iscl = 0
76  this%iord = 0
77  this%north = 0
78  this%relax = dzero
79  this%level = 0
80  this%droptol = dzero
81  this%ifdparam = 0
82 
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
Here is the call graph for this function:

◆ preset_config()

subroutine imslinearsettingsmodule::preset_config ( class(imslinearsettingstype this,
integer(i4b)  idfparam 
)
Parameters
thislinear settings
idfparamcomplexity option

Definition at line 87 of file ImsLinearSettings.f90.

88  class(ImsLinearSettingsType) :: this !< linear settings
89  integer(I4B) :: idfparam !< complexity option
90 
91  this%ifdparam = idfparam
92 
93  select case (idfparam)
94  case (1) ! Simple option
95  this%iter1 = 50
96  this%ilinmeth = 1
97  this%iscl = 0
98  this%iord = 0
99  this%dvclose = dem3
100  this%rclose = dem1
101  this%relax = dzero
102  this%level = 0
103  this%droptol = dzero
104  this%north = 0
105  case (2) ! Moderate
106  this%iter1 = 100
107  this%ilinmeth = 2
108  this%iscl = 0
109  this%iord = 0
110  this%dvclose = dem2
111  this%rclose = dem1
112  this%relax = 0.97d0
113  this%level = 0
114  this%droptol = dzero
115  this%north = 0
116  case (3) ! Complex
117  this%iter1 = 500
118  this%ilinmeth = 2
119  this%iscl = 0
120  this%iord = 0
121  this%dvclose = dem1
122  this%rclose = dem1
123  this%relax = dzero
124  this%level = 5
125  this%droptol = dem4
126  this%north = 2
127  end select
128 

◆ read_from_file()

subroutine imslinearsettingsmodule::read_from_file ( class(imslinearsettingstype this,
type(blockparsertype parser,
integer(i4b)  iout 
)
private
Parameters
thislinear settings
parserblock parser
ioutlisting file

Definition at line 133 of file ImsLinearSettings.f90.

134  class(ImsLinearSettingsType) :: this !< linear settings
135  type(BlockParserType) :: parser !< block parser
136  integer(I4B) :: iout !< listing file
137  ! local
138  logical(LGP) :: block_found, end_of_block
139  integer(I4B) :: ierr
140  character(len=LINELENGTH) :: errmsg
141  character(len=LINELENGTH) :: warnmsg
142  character(len=LINELENGTH) :: keyword
143  integer(I4B) :: iscaling, iordering
144 
145  call parser%GetBlock('LINEAR', block_found, ierr, supportopenclose=.true., &
146  blockrequired=.false.)
147 
148  if (block_found) then
149  write (iout, '(/1x,a)') 'PROCESSING LINEAR DATA'
150  do
151  call parser%GetNextLine(end_of_block)
152  if (end_of_block) exit
153  call parser%GetStringCaps(keyword)
154  ! -- parse keyword
155  select case (keyword)
156  case ('INNER_DVCLOSE')
157  this%dvclose = parser%GetDouble()
158  case ('INNER_RCLOSE')
159  this%rclose = parser%GetDouble()
160  ! -- look for additional key words
161  call parser%GetStringCaps(keyword)
162  if (keyword == 'STRICT') then
163  this%icnvgopt = 1
164  else if (keyword == 'L2NORM_RCLOSE') then
165  this%icnvgopt = 2
166  else if (keyword == 'RELATIVE_RCLOSE') then
167  this%icnvgopt = 3
168  else if (keyword == 'L2NORM_RELATIVE_RCLOSE') then
169  this%icnvgopt = 4
170  end if
171  case ('INNER_MAXIMUM')
172  this%iter1 = parser%GetInteger()
173  case ('LINEAR_ACCELERATION')
174  call parser%GetStringCaps(keyword)
175  if (keyword .eq. 'CG') then
176  this%ilinmeth = 1
177  else if (keyword .eq. 'BICGSTAB') then
178  this%ilinmeth = 2
179  else
180  this%ilinmeth = 0
181  write (errmsg, '(3a)') &
182  'Unknown IMSLINEAR LINEAR_ACCELERATION method (', &
183  trim(keyword), ').'
184  call store_error(errmsg)
185  end if
186  case ('SCALING_METHOD')
187  call parser%GetStringCaps(keyword)
188  iscaling = 0
189  if (keyword .eq. 'NONE') then
190  iscaling = 0
191  else if (keyword .eq. 'DIAGONAL') then
192  iscaling = 1
193  else if (keyword .eq. 'L2NORM') then
194  iscaling = 2
195  else
196  write (errmsg, '(3a)') &
197  'Unknown IMSLINEAR SCALING_METHOD (', trim(keyword), ').'
198  call store_error(errmsg)
199  end if
200  this%iscl = iscaling
201  case ('RED_BLACK_ORDERING')
202  iordering = 0
203  case ('REORDERING_METHOD')
204  call parser%GetStringCaps(keyword)
205  iordering = 0
206  if (keyword == 'NONE') then
207  iordering = 0
208  else if (keyword == 'RCM') then
209  iordering = 1
210  else if (keyword == 'MD') then
211  iordering = 2
212  else
213  write (errmsg, '(3a)') &
214  'Unknown IMSLINEAR REORDERING_METHOD (', trim(keyword), ').'
215  call store_error(errmsg)
216  end if
217  this%iord = iordering
218  case ('NUMBER_ORTHOGONALIZATIONS')
219  this%north = parser%GetInteger()
220  case ('RELAXATION_FACTOR')
221  this%relax = parser%GetDouble()
222  case ('PRECONDITIONER_LEVELS')
223  this%level = parser%GetInteger()
224  if (this%level < 0) then
225  write (errmsg, '(a,1x,a)') &
226  'IMSLINEAR PRECONDITIONER_LEVELS must be greater than', &
227  'or equal to zero'
228  call store_error(errmsg)
229  end if
230  case ('PRECONDITIONER_DROP_TOLERANCE')
231  this%droptol = parser%GetDouble()
232  if (this%droptol < dzero) then
233  write (errmsg, '(a,1x,a)') &
234  'IMSLINEAR PRECONDITIONER_DROP_TOLERANCE', &
235  'must be greater than or equal to zero'
236  call store_error(errmsg)
237  end if
238  !
239  ! -- deprecated variables
240  case ('INNER_HCLOSE')
241  this%dvclose = parser%GetDouble()
242  !
243  ! -- create warning message
244  write (warnmsg, '(a)') &
245  'SETTING INNER_DVCLOSE TO INNER_HCLOSE VALUE'
246  !
247  ! -- create deprecation warning
248  call deprecation_warning('LINEAR', 'INNER_HCLOSE', '6.1.1', &
249  warnmsg, parser%GetUnit())
250  !
251  ! -- default
252  case default
253  write (errmsg, '(3a)') &
254  'Unknown IMSLINEAR keyword (', trim(keyword), ').'
255  call store_error(errmsg)
256  end select
257  end do
258  write (iout, '(1x,a)') 'END OF LINEAR DATA'
259  else
260  if (this%ifdparam == 0) THEN
261  write (errmsg, '(a)') 'NO LINEAR block detected.'
262  call store_error(errmsg)
263  end if
264  end if
265 
Here is the call graph for this function:

◆ resolve_ipc()

pure integer(i4b) function, public imslinearsettingsmodule::resolve_ipc ( integer(i4b), intent(in)  level,
real(dp), intent(in)  relax 
)

Maps the ILU fill level and relaxation factor to a specific IPC_* preconditioner: level > 0 -> IPC_ILUT (-> IPC_MILUT when relax > 0) level == 0 -> IPC_ILU0 (-> IPC_MILU0 when relax > 0)

Extracted into a pure function so the same resolution can be reused when preconditioner settings change at runtime (e.g. by stress period).

Parameters
[in]levelILU fill level
[in]relaxrelaxation factor (> 0 selects the modified ILU)
Returns
resolved preconditioner enum (IPC_*)

Definition at line 311 of file ImsLinearSettings.f90.

312  integer(I4B), intent(in) :: level !< ILU fill level
313  real(DP), intent(in) :: relax !< relaxation factor (> 0 selects the modified ILU)
314  integer(I4B) :: ipc !< resolved preconditioner enum (IPC_*)
315  !
316  ! -- map explicitly to the target enum (do not rely on IPC_* being
317  ! consecutive); relax > 0 selects the modified variant
318  if (level > 0) then
319  if (relax > dzero) then
320  ipc = ipc_milut
321  else
322  ipc = ipc_ilut
323  end if
324  else
325  if (relax > dzero) then
326  ipc = ipc_milu0
327  else
328  ipc = ipc_ilu0
329  end if
330  end if
Here is the caller graph for this function:

Variable Documentation

◆ bcgs_method

integer(i4b), parameter, public imslinearsettingsmodule::bcgs_method = 2

Definition at line 11 of file ImsLinearSettings.f90.

11  integer(I4B), public, parameter :: BCGS_METHOD = 2

◆ cg_method

integer(i4b), parameter, public imslinearsettingsmodule::cg_method = 1

Definition at line 10 of file ImsLinearSettings.f90.

10  integer(I4B), public, parameter :: CG_METHOD = 1

◆ ipc_ilu0

@, public imslinearsettingsmodule::ipc_ilu0 = 1

Definition at line 17 of file ImsLinearSettings.f90.

17  enumerator :: IPC_ILU0 = 1 !< ILU0 (incomplete LU, zero fill)

◆ ipc_ilut

@, public imslinearsettingsmodule::ipc_ilut = 3

Definition at line 19 of file ImsLinearSettings.f90.

19  enumerator :: IPC_ILUT = 3 !< ILUT (incomplete LU with threshold)

◆ ipc_milu0

@, public imslinearsettingsmodule::ipc_milu0 = 2

Definition at line 18 of file ImsLinearSettings.f90.

18  enumerator :: IPC_MILU0 = 2 !< modified ILU0

◆ ipc_milut

@, public imslinearsettingsmodule::ipc_milut = 4

Definition at line 20 of file ImsLinearSettings.f90.

20  enumerator :: IPC_MILUT = 4 !< modified ILUT

◆ ipc_unknown

@, public imslinearsettingsmodule::ipc_unknown = 0

Definition at line 16 of file ImsLinearSettings.f90.

16  enumerator :: IPC_UNKNOWN = 0 !< preconditioner type not set