MODFLOW 6
version 6.6.0.dev0
USGS Modular Hydrologic Model
|
This module contains the MODFLOW 6 BMI. More...
Functions/Subroutines | |
integer(kind=c_int) function | bmi_get_component_name (name) |
integer(kind=c_int) function | bmi_initialize () |
Initialize the computational core. More... | |
integer(kind=c_int) function | bmi_update () |
Perform a computational time step. More... | |
integer(kind=c_int) function | bmi_finalize () |
Clean up the initialized simulation. More... | |
integer(kind=c_int) function | get_start_time (start_time) |
Get the start time of the simulation. More... | |
integer(kind=c_int) function | get_end_time (end_time) |
Get the end time of the simulation. More... | |
integer(kind=c_int) function | get_current_time (current_time) |
Get the current time of the simulation. More... | |
integer(kind=c_int) function | get_time_step (time_step) |
Get the time step for the simulation. More... | |
integer(kind=c_int) function | get_input_item_count (count) |
Get the number of input variables in the simulation. More... | |
integer(kind=c_int) function | get_output_item_count (count) |
Get the number of output variables in the simulation. More... | |
integer(kind=c_int) function | get_input_var_names (c_names) |
Returns all input variables in the simulation. More... | |
integer(kind=c_int) function | get_output_var_names (c_names) |
Returns all output variables in the simulation. More... | |
integer(kind=c_int) function | get_var_itemsize (c_var_address, var_size) |
Get the size (in bytes) of a single element of a variable. More... | |
integer(kind=c_int) function | get_var_nbytes (c_var_address, var_nbytes) |
Get size of the variable, in bytes. More... | |
integer(kind=c_int) function | get_value_double (c_var_address, c_arr_ptr) |
Copy the double precision values of a variable into the array. More... | |
integer(kind=c_int) function | get_value_int (c_var_address, c_arr_ptr) |
Copy the integer values of a variable into the array. More... | |
integer(kind=c_int) function | get_value_bool (c_var_address, c_arr_ptr) |
Copy the logical scalar value into the array. More... | |
integer(kind=c_int) function | get_value_string (c_var_address, c_arr_ptr) |
Copy the string(s) of a variable into the array. More... | |
integer(kind=c_int) function | get_value (c_var_address, c_arr_ptr) |
Copy the value of a variable into the array. More... | |
integer(kind=c_int) function | get_value_ptr (c_var_address, c_arr_ptr) |
Get a pointer to an array. More... | |
integer(kind=c_int) function | get_value_ptr_double (c_var_address, c_arr_ptr) |
Get a pointer to the array of double precision numbers. More... | |
integer(kind=c_int) function | get_value_ptr_int (c_var_address, c_arr_ptr) |
Get a pointer to the array of integer numbers. More... | |
integer(kind=c_int) function | get_value_ptr_bool (c_var_address, c_arr_ptr) |
Get a pointer to the logical scalar value. More... | |
integer(kind=c_int) function | set_value (c_var_address, c_arr_ptr) |
Set new values for a given variable. More... | |
integer(kind=c_int) function | set_value_double (c_var_address, c_arr_ptr) |
Set new values for a variable of type double. More... | |
integer(kind=c_int) function | set_value_int (c_var_address, c_arr_ptr) |
Set new values for a variable of type integer. More... | |
integer(kind=c_int) function | set_value_bool (c_var_address, c_arr_ptr) |
Set new value for a logical scalar variable. More... | |
integer(kind=c_int) function | get_var_type (c_var_address, c_var_type) |
Get the variable type as a string. More... | |
integer(kind=c_int) function | get_var_rank (c_var_address, c_var_rank) |
Get the variable rank (non-BMI) More... | |
integer(kind=c_int) function | get_var_shape (c_var_address, c_var_shape) |
Get the shape of the array for the variable (non-BMI) More... | |
Variables | |
integer(c_int), bind(C, name="ISTDOUTTOFILE") | istdout_to_file = 1 |
output control: =0 to screen, >0 to file More... | |
This BMI interface matches the CSDMS standard, with a few modifications:
Note on style: BMI apparently uses underscores, we use underscores in some places but camelcase in other. Since this is a dedicated BMI interface module, we'll use underscores here as well.
integer(kind=c_int) function mf6bmi::bmi_finalize |
Performs teardown tasks for the initialized simulation, this call should match the call to bmi_initialize()
Definition at line 112 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::bmi_get_component_name | ( | character(kind=c_char), dimension(bmi_lencomponentname), intent(inout) | name | ) |
Definition at line 43 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::bmi_initialize |
It is required to have the MODFLOW 6 configuration file 'mfsim.nam' available in the current working directory when calling this routine.
NOTE: initialization should always be matched with a call to bmi_finalize(). However, we currently do not support the reinitialization of a model in the same memory space... You would have to create a new process for that.
Definition at line 66 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::bmi_update |
It will prepare the timestep, call the calculation routine on all the solution groups in the simulation, and finalize the timestep by printing out diagnostics and writing output. It can be called in succession to perform multiple steps up to the simulation's end time is reached.
Definition at line 95 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_current_time | ( | real(kind=c_double), intent(out) | current_time | ) |
As MODFLOW currently does not have internal time, this will be equal to the time passed w.r.t. the start time of the simulation.
[out] | current_time | current time |
Definition at line 167 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_end_time | ( | real(kind=c_double), intent(out) | end_time | ) |
As MODFLOW does currently does not have internal time, this will be equal to the total runtime.
[out] | end_time | end time |
Definition at line 149 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_input_item_count | ( | integer(kind=c_int), intent(out) | count | ) |
This concerns all variables stored in the memory manager
[out] | count | the number of input variables |
Definition at line 204 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_input_var_names | ( | character(kind=c_char, len=1), dimension(*), intent(inout) | c_names | ) |
This functions returns the full address for all variables in the memory manager
The array c_names
should be pre-allocated of proper size:
size = BMI_LENVARADDRESS * get_input_item_count()
The strings will be written contiguously with stride equal to BMI_LENVARADDRESS and nul-terminated where the trailing spaces start:
c_names = 'variable_address_1\x00 ... variable_address_2\x00 ... ' etc.
[in,out] | c_names | array with memory paths for input variables |
Definition at line 248 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_output_item_count | ( | integer(kind=c_int), intent(out) | count | ) |
This concerns all variables stored in the memory manager
[out] | count | the number of output variables |
Definition at line 221 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_output_var_names | ( | character(kind=c_char, len=1), dimension(*), intent(inout) | c_names | ) |
This function works analogously to get_input_var_names(), and currently returns the same set of memory variables, which is all of them!
[in,out] | c_names | array with memory paths for output variables |
Definition at line 283 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_start_time | ( | real(kind=c_double), intent(out) | start_time | ) |
As MODFLOW currently does not have internal time, this will be returning 0.0 for now. New version...
[out] | start_time | start time |
Definition at line 132 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_time_step | ( | real(kind=c_double), intent(out) | time_step | ) |
Note that the returned value may vary between and within stress periods, depending on your time discretization settings in the TDIS package.
[out] | time_step | current time step |
Definition at line 186 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(inout) | c_arr_ptr | ||
) |
The copied variable is located at c_var_address
. The caller should provide c_arr_ptr
pointing to an array of the proper shape (the BMI function get_var_shape() can be used to create it). Multi-dimensional arrays are supported.
[in] | c_var_address | memory address string of the variable |
[in,out] | c_arr_ptr | pointer to the array |
Definition at line 657 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value_bool | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(in) | c_arr_ptr | ||
) |
The copied variable us located at c_var_address
. The caller should provide c_arr_ptr
pointing to a scalar array with rank=0.
[in] | c_var_address | memory address string of the variable |
[in] | c_arr_ptr | pointer to the logical array |
Definition at line 530 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value_double | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(in) | c_arr_ptr | ||
) |
The copied variable us located at c_var_address
. The caller should provide c_arr_ptr
pointing to an array of the proper shape (the BMI function get_var_shape() can be used to create it). Multi-dimensional arrays are supported.
[in] | c_var_address | memory address string of the variable |
[in] | c_arr_ptr | pointer to the double precision array |
Definition at line 378 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value_int | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(in) | c_arr_ptr | ||
) |
The copied variable is located at c_var_address
. The caller should provide c_arr_ptr
pointing to an array of the proper shape (the BMI function get_var_shape() can be used to create it). Multi-dimensional arrays are supported.
[in] | c_var_address | memory address string of the variable |
[in] | c_arr_ptr | pointer to the integer array |
Definition at line 455 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value_ptr | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(inout) | c_arr_ptr | ||
) |
The array is located at c_var_address
. There is no copying of data involved. Multi-dimensional arrays are supported and the get_var_rank() function can be used to get the variable's dimensionality, and get_var_shape() for its shape.
[in] | c_var_address | memory address string of the variable |
[in,out] | c_arr_ptr | pointer to the array |
Definition at line 706 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value_ptr_bool | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(inout) | c_arr_ptr | ||
) |
Only scalar values (with rank=0) are supported.
[in] | c_var_address | memory address string of the variable |
[in,out] | c_arr_ptr | pointer to the array |
Definition at line 860 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value_ptr_double | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(inout) | c_arr_ptr | ||
) |
The array is located at c_var_address
. There is no copying of data involved. Multi-dimensional arrays are supported and the get_var_rank() function can be used to get the variable's dimensionality, and get_var_shape() for its shape.
[in] | c_var_address | memory address string of the variable |
[in,out] | c_arr_ptr | pointer to the array |
Definition at line 753 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value_ptr_int | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(inout) | c_arr_ptr | ||
) |
The array is located at c_var_address
. There is no copying of data involved. Multi-dimensional arrays are supported and the get_var_rank() function can be used to get the variable's dimensionality.
[in] | c_var_address | memory address string of the variable |
[in,out] | c_arr_ptr | pointer to the array |
Definition at line 807 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_value_string | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(in) | c_arr_ptr | ||
) |
The copied variable is located at c_var_address
. The caller should provide c_arr_ptr
pointing to an array of the proper shape (the BMI function get_var_shape() can be used to create it). For strings currently scalars and 1d arrays (of CharacterStringType) are
[in] | c_var_address | memory address string of the variable |
[in] | c_arr_ptr | pointer to the string array |
Definition at line 578 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_var_itemsize | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
integer(kind=c_int), intent(out) | var_size | ||
) |
[in] | c_var_address | memory address string of the variable |
[out] | var_size | size of the element in bytes |
Definition at line 314 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_var_nbytes | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
integer(kind=c_int), intent(out) | var_nbytes | ||
) |
[in] | c_var_address | memory address string of the variable |
[out] | var_nbytes | size in bytes |
Definition at line 341 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_var_rank | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
integer(kind=c_int), intent(out) | c_var_rank | ||
) |
In order to support multi-dimensional arrays, this function gives access to the rank of the array.
[in] | c_var_address | memory address string of the variable |
[out] | c_var_rank | variable rank |
Definition at line 1191 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_var_shape | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
integer(c_int), dimension(*), intent(inout) | c_var_shape | ||
) |
The shape is an integer array with size equal to the rank of the variable (see get_var_rank()) and values that give the length of the array in each dimension. The target shape array c_var_shape
should be allocated before calling this routine.
Note that the returned shape representation will has been converted to C-style.
[in] | c_var_address | memory address string of the variable |
[in,out] | c_var_shape | 1D array with the variable's shape |
Definition at line 1229 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::get_var_type | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
character(kind=c_char), dimension(bmi_lenvartype), intent(out) | c_var_type | ||
) |
The type returned is that of a single element. When the variable cannot be found, the string
[in] | c_var_address | memory address string of the variable |
[out] | c_var_type | variable type as a string |
Definition at line 1151 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::set_value | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(inout) | c_arr_ptr | ||
) |
The array pointed to by c_arr_ptr
can have rank equal to 0, 1, or 2 and should have a C-style layout, which is particularly important for rank > 1.
[in] | c_var_address | memory address string of the variable |
[in,out] | c_arr_ptr | pointer to the array |
Definition at line 902 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::set_value_bool | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(in) | c_arr_ptr | ||
) |
The array pointed to by c_arr_ptr
must have a rank equal to 0.
[in] | c_var_address | memory address string of the variable |
[in] | c_arr_ptr | pointer to the logical array |
Definition at line 1094 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::set_value_double | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(in) | c_arr_ptr | ||
) |
The array pointed to by c_arr_ptr
can have rank equal to 0, 1, or 2 and should have a C-style layout, which is particularly important for rank > 1.
[in] | c_var_address | memory address string of the variable |
[in] | c_arr_ptr | pointer to the double precision array |
Definition at line 948 of file mf6bmi.f90.
integer(kind=c_int) function mf6bmi::set_value_int | ( | character(kind=c_char), dimension(*), intent(in) | c_var_address, |
type(c_ptr), intent(in) | c_arr_ptr | ||
) |
The array pointed to by c_arr_ptr
can have rank equal to 0, 1, or 2.
[in] | c_var_address | memory address string of the variable |
[in] | c_arr_ptr | pointer to the integer array |
Definition at line 1021 of file mf6bmi.f90.
integer(c_int), bind(C, name="ISTDOUTTOFILE") mf6bmi::istdout_to_file = 1 |
Definition at line 38 of file mf6bmi.f90.