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 257 of file ImsLinearSettings.f90.

258  class(ImsLinearSettingsType) :: this !< linear settings
259  ! local
260  character(len=LINELENGTH) :: warnmsg
261 
262  if (this%level == 0 .and. this%droptol > 0.0_dp) then
263  write (warnmsg, '(a)') "PRECONDITIONER_DROP_TOLERANCE is ignored because &
264  &PRECONDITIONER_LEVELS equals zero."
265  call store_warning(warnmsg)
266  end if
267 
Here is the call graph for this function:

◆ destroy()

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

Definition at line 270 of file ImsLinearSettings.f90.

271  class(ImsLinearSettingsType) :: this !< linear settings
272 
273  call mem_deallocate(this%dvclose)
274  call mem_deallocate(this%rclose)
275  call mem_deallocate(this%icnvgopt)
276  call mem_deallocate(this%iter1)
277  call mem_deallocate(this%ilinmeth)
278  call mem_deallocate(this%iscl)
279  call mem_deallocate(this%iord)
280  call mem_deallocate(this%north)
281  call mem_deallocate(this%relax)
282  call mem_deallocate(this%level)
283  call mem_deallocate(this%droptol)
284  call mem_deallocate(this%ifdparam)
285 

◆ 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) :: keyword
142  integer(I4B) :: iscaling, iordering
143 
144  call parser%GetBlock('LINEAR', block_found, ierr, supportopenclose=.true., &
145  blockrequired=.false.)
146 
147  if (block_found) then
148  write (iout, '(/1x,a)') 'PROCESSING LINEAR DATA'
149  do
150  call parser%GetNextLine(end_of_block)
151  if (end_of_block) exit
152  call parser%GetStringCaps(keyword)
153  ! -- parse keyword
154  select case (keyword)
155  case ('INNER_DVCLOSE')
156  this%dvclose = parser%GetDouble()
157  case ('INNER_RCLOSE')
158  this%rclose = parser%GetDouble()
159  ! -- look for additional key words
160  call parser%GetStringCaps(keyword)
161  if (keyword == 'STRICT') then
162  this%icnvgopt = 1
163  else if (keyword == 'L2NORM_RCLOSE') then
164  this%icnvgopt = 2
165  else if (keyword == 'RELATIVE_RCLOSE') then
166  this%icnvgopt = 3
167  else if (keyword == 'L2NORM_RELATIVE_RCLOSE') then
168  this%icnvgopt = 4
169  end if
170  case ('INNER_MAXIMUM')
171  this%iter1 = parser%GetInteger()
172  case ('LINEAR_ACCELERATION')
173  call parser%GetStringCaps(keyword)
174  if (keyword .eq. 'CG') then
175  this%ilinmeth = 1
176  else if (keyword .eq. 'BICGSTAB') then
177  this%ilinmeth = 2
178  else
179  this%ilinmeth = 0
180  write (errmsg, '(3a)') &
181  'Unknown IMSLINEAR LINEAR_ACCELERATION method (', &
182  trim(keyword), ').'
183  call store_error(errmsg)
184  end if
185  case ('SCALING_METHOD')
186  call parser%GetStringCaps(keyword)
187  iscaling = 0
188  if (keyword .eq. 'NONE') then
189  iscaling = 0
190  else if (keyword .eq. 'DIAGONAL') then
191  iscaling = 1
192  else if (keyword .eq. 'L2NORM') then
193  iscaling = 2
194  else
195  write (errmsg, '(3a)') &
196  'Unknown IMSLINEAR SCALING_METHOD (', trim(keyword), ').'
197  call store_error(errmsg)
198  end if
199  this%iscl = iscaling
200  case ('RED_BLACK_ORDERING')
201  iordering = 0
202  case ('REORDERING_METHOD')
203  call parser%GetStringCaps(keyword)
204  iordering = 0
205  if (keyword == 'NONE') then
206  iordering = 0
207  else if (keyword == 'RCM') then
208  iordering = 1
209  else if (keyword == 'MD') then
210  iordering = 2
211  else
212  write (errmsg, '(3a)') &
213  'Unknown IMSLINEAR REORDERING_METHOD (', trim(keyword), ').'
214  call store_error(errmsg)
215  end if
216  this%iord = iordering
217  case ('NUMBER_ORTHOGONALIZATIONS')
218  this%north = parser%GetInteger()
219  case ('RELAXATION_FACTOR')
220  this%relax = parser%GetDouble()
221  case ('PRECONDITIONER_LEVELS')
222  this%level = parser%GetInteger()
223  if (this%level < 0) then
224  write (errmsg, '(a,1x,a)') &
225  'IMSLINEAR PRECONDITIONER_LEVELS must be greater than', &
226  'or equal to zero'
227  call store_error(errmsg)
228  end if
229  case ('PRECONDITIONER_DROP_TOLERANCE')
230  this%droptol = parser%GetDouble()
231  if (this%droptol < dzero) then
232  write (errmsg, '(a,1x,a)') &
233  'IMSLINEAR PRECONDITIONER_DROP_TOLERANCE', &
234  'must be greater than or equal to zero'
235  call store_error(errmsg)
236  end if
237  !
238  ! -- default
239  case default
240  write (errmsg, '(3a)') &
241  'Unknown IMSLINEAR keyword (', trim(keyword), ').'
242  call store_error(errmsg)
243  end select
244  end do
245  write (iout, '(1x,a)') 'END OF LINEAR DATA'
246  else
247  if (this%ifdparam == 0) THEN
248  write (errmsg, '(a)') 'NO LINEAR block detected.'
249  call store_error(errmsg)
250  end if
251  end if
252 
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 298 of file ImsLinearSettings.f90.

299  integer(I4B), intent(in) :: level !< ILU fill level
300  real(DP), intent(in) :: relax !< relaxation factor (> 0 selects the modified ILU)
301  integer(I4B) :: ipc !< resolved preconditioner enum (IPC_*)
302  !
303  ! -- map explicitly to the target enum (do not rely on IPC_* being
304  ! consecutive); relax > 0 selects the modified variant
305  if (level > 0) then
306  if (relax > dzero) then
307  ipc = ipc_milut
308  else
309  ipc = ipc_ilut
310  end if
311  else
312  if (relax > dzero) then
313  ipc = ipc_milu0
314  else
315  ipc = ipc_ilu0
316  end if
317  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