MODFLOW 6
version 6.7.0.dev0
USGS Modular Hydrologic Model
|
This module contains the eXtended Model Interface. More...
Functions/Subroutines | |
integer(kind=c_int) function | xmi_prepare_time_step (dt) |
Prepare a single time step. More... | |
integer(kind=c_int) function | xmi_do_time_step () |
Perform a single time step. More... | |
integer(kind=c_int) function | xmi_finalize_time_step () |
Finalize the time step. More... | |
integer(kind=c_int) function | xmi_get_subcomponent_count (count) |
This will get the number of Numerical Solutions in the simulation. More... | |
integer(kind=c_int) function | xmi_prepare_solve (subcomponent_idx) |
Prepare for solving the system. More... | |
integer(kind=c_int) function | xmi_solve (subcomponent_idx, has_converged) |
Build and solve the linear system. More... | |
integer(kind=c_int) function | xmi_finalize_solve (subcomponent_idx) |
Finalize the solve of the system. More... | |
integer(kind=c_int) function | xmi_get_version (mf_version) |
Get the version string for this component. More... | |
integer(kind=c_int) function | get_var_address (c_component_name, c_subcomponent_name, c_var_name, c_var_address) |
Get the full address string for a variable. More... | |
Variables | |
integer(i4b), pointer | iterationcounter => null() |
the counter for the outer iteration loop, initialized in xmi_prepare_iteration() More... | |
In this module we expose functionality in the MODFLOW 6 shared library, that is beyond the basic model interface: https://bmi-spec.readthedocs.io/en/latest/. The main extensions are
The common BMI control flow is
With the XMI you can now also use it as:
Or, when you want to isolate the call to the linear solve, a typical application could look like this:
Note that the last example can only work when there is a single Solution Group defined. This will typically not be a problem, though, as applications with multiple Solution Groups should be quite rare.
integer(kind=c_int) function mf6xmi::get_var_address | ( | character(kind=c_char), dimension(*), intent(in) | c_component_name, |
character(kind=c_char), dimension(*), intent(in) | c_subcomponent_name, | ||
character(kind=c_char), dimension(*), intent(in) | c_var_name, | ||
character(kind=c_char), dimension(bmi_lenvaraddress), intent(out) | c_var_address | ||
) |
This routine constructs the full address string of a variable using the exact same logic as the internal memory manager. This routine should always be used when accessing a variable through the BMI to assure compatibility with future versions of the library.
[in] | c_component_name | name of the component (a Model or Solution) |
[in] | c_subcomponent_name | name of the subcomponent (Package), or an empty string'' when not applicable |
[in] | c_var_name | name of the variable |
[out] | c_var_address | full address of the variable |
Definition at line 365 of file mf6xmi.F90.
integer(kind=c_int) function mf6xmi::xmi_do_time_step |
It does so by looping over all solution groups, and calling the calculate function on all solutions in there.
Definition at line 146 of file mf6xmi.F90.
integer(kind=c_int) function mf6xmi::xmi_finalize_solve | ( | integer(kind=c_int), intent(in) | subcomponent_idx | ) |
This will determine convergence, reports, calculate flows and budgets, and more... It should always follow after a call to xmi_prepare_solve() and xmi_solve().
[in] | subcomponent_idx | the index of the subcomponent (Numerical Solution) |
[in] | subcomponent_idx | index of the subcomponent (i.e. Numerical Solution) |
Definition at line 306 of file mf6xmi.F90.
integer(kind=c_int) function mf6xmi::xmi_finalize_time_step |
This will mostly write output and messages. It is essential to call this to finish the time step.
Definition at line 161 of file mf6xmi.F90.
integer(kind=c_int) function mf6xmi::xmi_get_subcomponent_count | ( | integer(kind=c_int), intent(out) | count | ) |
For most applications, this number will be equal to 1. Note that this part of the XMI only works when the simulation is defined with a single Solution Group. (If you don't know what a Solution Group is, then you are most likely not using more than one...)
[out] | count | number of solutions |
Definition at line 187 of file mf6xmi.F90.
integer(kind=c_int) function mf6xmi::xmi_get_version | ( | character(kind=c_char), dimension(bmi_lenversion), intent(inout) | mf_version | ) |
Definition at line 344 of file mf6xmi.F90.
integer(kind=c_int) function mf6xmi::xmi_prepare_solve | ( | integer(kind=c_int) | subcomponent_idx | ) |
This preparation mostly consists of advancing the solutions, models, and exchanges in the simulation. The index subcomponent_idx
runs from 1 to the value returned by xmi_get_subcomponent_count().
subcomponent_idx | index of the subcomponent (i.e. Numerical Solution) |
Definition at line 220 of file mf6xmi.F90.
integer(kind=c_int) function mf6xmi::xmi_prepare_time_step | ( | real(kind=c_double), intent(in) | dt | ) |
The routine takes the time step dt
as an argument. However, MODFLOW (currently) does not allow to alter this value after initialization, so it is ignored here.
[in] | dt | time step |
Definition at line 129 of file mf6xmi.F90.
integer(kind=c_int) function mf6xmi::xmi_solve | ( | integer(kind=c_int), intent(in) | subcomponent_idx, |
integer(kind=c_int), intent(out) | has_converged | ||
) |
The solve is called on the Numerical Solution indicated by the value of subcomponent_idx
, which runs from 1 to the value returned by xmi_get_subcomponent_count(). Before calling this, a matching call to xmi_prepare_solve() should be done.
[in] | subcomponent_idx | index of the subcomponent (i.e. Numerical Solution) |
[out] | has_converged | equal to 1 for convergence, 0 otherwise |
Definition at line 261 of file mf6xmi.F90.
integer(i4b), pointer mf6xmi::iterationcounter => null() |
Definition at line 96 of file mf6xmi.F90.