93 use iso_c_binding,
only: c_int, c_char, c_double
100 #if defined(__WITH_MPI__)
101 function xmi_initialize_mpi(mpi_comm)
result(bmi_status) &
102 bind(C, name="initialize_mpi")
107 integer(kind=c_int) :: mpi_comm
108 integer(kind=c_int) :: bmi_status
114 call mpi_world%set_comm(mpi_comm)
120 end function xmi_initialize_mpi
130 bind(C, name="prepare_time_step")
133 real(kind=c_double),
intent(in) :: dt
134 integer(kind=c_int) :: bmi_status
149 integer(kind=c_int) :: bmi_status
162 bind(C, name="finalize_time_step")
165 integer(kind=c_int) :: bmi_status
167 logical :: hasconverged
170 if (hasconverged)
then
188 bind(C, name="get_subcomponent_count")
194 integer(kind=c_int),
intent(out) :: count
195 integer(kind=c_int) :: bmi_status
197 class(solutiongrouptype),
pointer :: sgp
202 'Error: BMI does not support the use of multiple solution groups'
209 count = sgp%nsolutions
221 bind(C, name="prepare_solve")
228 integer(kind=c_int) :: subcomponent_idx
229 integer(kind=c_int) :: bmi_status
236 'Error: BMI does not support the use of multiple solution groups'
245 call bs%prepareSolve()
261 function xmi_solve(subcomponent_idx, has_converged)
result(bmi_status) &
262 bind(C, name="solve")
269 integer(kind=c_int),
intent(in) :: subcomponent_idx
270 integer(kind=c_int),
intent(out) :: has_converged
271 integer(kind=c_int) :: bmi_status
285 if (bs%icnvg == 1)
then
307 bind(C, name="finalize_solve")
312 integer(kind=c_int),
intent(in) :: subcomponent_idx
313 integer(kind=c_int) :: bmi_status
316 integer(I4B) :: hasconverged
329 if (.not. hasconverged == 1)
then
345 bind(C, name="get_version")
350 character(kind=c_char),
intent(inout) :: mf_version(
bmi_lenversion)
351 integer(kind=c_int) :: bmi_status
353 character(len=BMI_LENVERSION) :: vstr
373 c_var_name, c_var_address) &
374 result(bmi_status)
bind(C, name="get_var_address")
381 character(kind=c_char),
intent(in) :: c_component_name(*)
382 character(kind=c_char),
intent(in) :: c_subcomponent_name(*)
384 character(kind=c_char),
intent(in) :: c_var_name(*)
386 integer(kind=c_int) :: bmi_status
388 character(len=LENCOMPONENTNAME) :: component_name
389 character(len=LENCOMPONENTNAME) :: subcomponent_name
390 character(len=LENVARNAME) :: variable_name
391 character(len=LENMEMPATH) :: mem_path
392 character(len=LENMEMADDRESS) :: mem_address
396 strlen(c_component_name, &
399 strlen(c_subcomponent_name, &
406 if (subcomponent_name ==
'')
then
414 c_var_address(1:len(trim(mem_address)) + 1) = &
This module contains simulation constants.
integer(i4b), parameter lencomponentname
maximum length of a component name
integer(i4b), parameter lenmemaddress
maximum length of the full memory address, including variable name
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenmempath
maximum length of the memory path
Explicit Solution Module.
This module defines variable data types.
type(listtype), public solutiongrouplist
character(len=lenmemaddress) function create_mem_address(mem_path, var_name)
returns the address string of the memory object
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains the MODFLOW 6 BMI.
integer(kind=c_int) function bmi_initialize()
Initialize the computational core.
Detailed error information for the BMI.
character(len= *), parameter fmt_general_err
integer, parameter bmi_failure
BMI status code for failure (taken from bmi.f90, CSDMS)
character(len=lenerrmessage) bmi_last_error
module variable containing the last error as a Fortran string
subroutine report_bmi_error(err_msg)
Sets the last BMI error message and copies it to an exported C-string.
character(len= *), parameter fmt_fail_cvg_sol
integer, parameter bmi_success
BMI status code for success (taken from bmi.f90, CSDMS)
This module contains helper routines and parameters for the MODFLOW 6 BMI.
integer(c_int), bind(C, name="BMI_LENVERSION") bmi_lenversion
length of version string, e.g. '6.3.1' or '6.4.1-dev'
class(basesolutiontype) function, pointer getsolution(subcomponent_idx)
Get the solution object for this index.
pure character(kind=c_char, len=1) function, dimension(length+1) string_to_char_array(string, length)
Convert Fortran string to C-style character string.
pure integer(i4b) function strlen(char_array, max_len)
Returns the string length without the trailing null character.
pure character(len=length) function char_array_to_string(char_array, length)
Convert C-style string to Fortran character string.
integer(c_int), bind(C, name="BMI_LENVARADDRESS") bmi_lenvaraddress
max. length for the variable's address C-string
subroutine mf6dotimestep()
Run time step.
subroutine mf6preparetimestep()
Read and prepare time step.
logical(lgp) function mf6finalizetimestep()
Finalize time step.
This module contains the eXtended Model Interface.
integer(kind=c_int) function xmi_get_version(mf_version)
Get the version string for this component.
integer(i4b), pointer iterationcounter
the counter for the outer iteration loop, initialized in xmi_prepare_iteration()
integer(kind=c_int) function xmi_solve(subcomponent_idx, has_converged)
Build and solve the linear system.
integer(kind=c_int) function xmi_prepare_time_step(dt)
Prepare a single time step.
integer(kind=c_int) function xmi_prepare_solve(subcomponent_idx)
Prepare for solving the system.
integer(kind=c_int) function xmi_get_subcomponent_count(count)
This will get the number of Numerical Solutions in the simulation.
integer(kind=c_int) function xmi_finalize_time_step()
Finalize the time step.
integer(kind=c_int) function xmi_finalize_solve(subcomponent_idx)
Finalize the solve of the system.
integer(kind=c_int) function xmi_do_time_step()
Perform a single time step.
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.
type(mpiworldtype) function, pointer, public get_mpi_world()
This module contains simulation variables.
character(len=linelength) simulation_mode
integer(i4b) istdout
unit number for stdout
This module contains version information.
integer(i4b), parameter idevelopmode
character(len= *), parameter versionnumber
Manages and solves explicit models.