6 use iso_c_binding,
only: c_int, c_char, c_null_char
57 character(kind=c_char),
intent(in) :: c_var_address(*)
58 character(len=LENMEMPATH),
intent(out) :: mem_path
59 character(len=LENVARNAME),
intent(out) :: var_name
60 logical(LGP),
intent(out) :: success
62 character(len=LENMEMADDRESS) :: var_address
63 logical(LGP) :: valid, found
70 call split_mem_address(var_address, mem_path, var_name, valid)
96 character(len=LENMEMPATH),
intent(in) :: mem_path
97 character(len=LENVARNAME),
intent(in) :: var_name
98 logical(LGP),
intent(out) :: found
112 pure function strlen(char_array, max_len)
result(string_length)
114 integer(I4B),
intent(in) :: max_len
115 character(c_char),
intent(in) :: char_array(max_len)
116 integer(I4B) :: string_length
121 do i = 1,
size(char_array)
122 if (char_array(i) .eq. c_null_char)
then
123 string_length = i - 1
134 integer(c_int),
intent(in) :: length
135 character(c_char),
intent(in) :: char_array(length)
136 character(len=length) :: f_string
141 f_string(i:i) = char_array(i)
150 integer(c_int),
intent(in) :: length
151 character(len=length),
intent(in) :: string
152 character(kind=c_char, len=1) :: c_array(length + 1)
157 c_array(i) = string(i:i)
159 c_array(length + 1) = c_null_char
167 character(len=*),
intent(in) :: var_address
168 character(len=LENMODELNAME) :: model_name
169 logical(LGP),
intent(out) :: success
171 character(len=LENMEMPATH) :: mem_path
172 character(len=LENCOMPONENTNAME) :: dummy_component
173 character(len=LENVARNAME) :: var_name
174 logical(LGP) :: split_succeeded
179 if (.not. split_succeeded)
then
195 integer(kind=c_int),
intent(in) :: grid_id
196 character(len=LENMODELNAME) :: model_name
200 character(len=LINELENGTH) :: error_msg
206 if (basemodel%id == grid_id)
then
207 model_name = basemodel%name
212 write (error_msg,
'(a,i0)')
'BMI error: no model for grid id ', grid_id
224 integer(I4B),
intent(in) :: subcomponent_idx
228 integer(I4B) :: solutionidx
232 solutionidx = sgp%idsolutions(subcomponent_idx)
243 character(len=LENMODELNAME) :: model_name
244 character(len=LENGRIDTYPE) :: grid_type_f
251 if (numericalmodel%name == model_name)
then
252 call numericalmodel%dis%get_dis_type(grid_type_f)
261 integer(kind=c_int),
intent(in) :: grid_id
262 character(len=*),
intent(in) :: expected_type
265 character(len=LENMODELNAME) :: model_name
266 character(len=LENGRIDTYPE) :: grid_type
273 if (expected_type == grid_type) is_match = .true.
class(basemodeltype) function, pointer, public getbasemodelfromlist(list, idx)
class(basesolutiontype) function, pointer, public getbasesolutionfromlist(list, idx)
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
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 lenmodelname
maximum length of the model name
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter, public lenmemtype
maximum length of a memory manager type
integer(i4b), parameter maxcharlen
maximum length of char string
integer(i4b), parameter lenmempath
maximum length of the memory path
This module defines variable data types.
type(listtype), public basemodellist
type(listtype), public solutiongrouplist
type(listtype), public basesolutionlist
character(len=lenmemseparator), parameter mempathseparator
used to build up the memory address for the stored variables
subroutine split_mem_address(mem_address, mem_path, var_name, success)
Split a memory address string into memory path and variable name.
subroutine split_mem_path(mem_path, component, subcomponent)
Split the memory path into component(s)
subroutine, public get_from_memorystore(name, mem_path, mt, found, check)
@ brief Get a memory type entry from the memory list
Store and issue logging messages to output units.
subroutine, public write_message(text, iunit, fmt, skipbefore, skipafter, advance)
Write a message to an output unit.
Detailed error information for the BMI.
character(len= *), parameter fmt_invalid_var
character(len= *), parameter fmt_unknown_var
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.
This module contains helper routines and parameters for the MODFLOW 6 BMI.
integer(c_int), bind(C, name="BMI_LENVARTYPE") bmi_lenvartype
max. length for variable type C-strings
integer(c_int), bind(C, name="BMI_LENCOMPONENTNAME") bmi_lencomponentname
component name length, i.e. 'MODFLOW 6'
character(len=lenmodelname) function get_model_name(grid_id)
Get the model name from the grid id.
subroutine split_address(c_var_address, mem_path, var_name, success)
Split the variable address string.
subroutine get_grid_type_model(model_name, grid_type_f)
Get the grid type for a named model as a fortran string.
integer(c_int), bind(C, name="BMI_LENVERSION") bmi_lenversion
length of version string, e.g. '6.3.1' or '6.4.1-dev'
integer(c_int), bind(C, name="BMI_LENGRIDTYPE") bmi_lengridtype
max. length for grid type C-strings
class(basesolutiontype) function, pointer getsolution(subcomponent_idx)
Get the solution object for this index.
integer(i4b), parameter lengridtype
max length for Fortran grid type string
logical function confirm_grid_type(grid_id, expected_type)
Confirm that grid is of an expected type.
subroutine check_mem_address(mem_path, var_name, found)
Check if the variable exists in the memory manager.
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.
character(len=lenmodelname) function extract_model_name(var_address, success)
Extract the model name from a memory address string.
integer(c_int), bind(C, name="BMI_LENVARADDRESS") bmi_lenvaraddress
max. length for the variable's address C-string
class(numericalmodeltype) function, pointer, public getnumericalmodelfromlist(list, idx)
This module contains simulation variables.
integer(i4b) istdout
unit number for stdout
class(solutiongrouptype) function, pointer, public getsolutiongroupfromlist(list, idx)
Highest level model type. All models extend this parent type.