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)
99 character(len=LENMEMPATH),
intent(in) :: mem_path
100 character(len=LENVARNAME),
intent(in) :: var_name
101 logical(LGP),
intent(out) :: found
120 character(len=LENMEMPATH),
intent(in) :: mem_path
121 character(len=LENVARNAME),
intent(in) :: var_name
123 logical(LGP) :: found
124 character(len=LENMEMADDRESS) :: replacement
125 character(len=LINELENGTH) :: version
126 character(len=MAXCHARLEN) :: msg
129 if (.not. found)
return
132 "API VARIABLE '"//trim(var_name)//
"' IN '"//trim(mem_path)// &
133 "' WAS DEPRECATED IN VERSION "//trim(version)//
". USE '"// &
134 trim(replacement)//
"' INSTEAD."
141 pure function strlen(char_array, max_len)
result(string_length)
143 integer(I4B),
intent(in) :: max_len
144 character(c_char),
intent(in) :: char_array(max_len)
145 integer(I4B) :: string_length
150 do i = 1,
size(char_array)
151 if (char_array(i) .eq. c_null_char)
then
152 string_length = i - 1
163 integer(c_int),
intent(in) :: length
164 character(c_char),
intent(in) :: char_array(length)
165 character(len=length) :: f_string
170 f_string(i:i) = char_array(i)
179 integer(c_int),
intent(in) :: length
180 character(len=length),
intent(in) :: string
181 character(kind=c_char, len=1) :: c_array(length + 1)
186 c_array(i) = string(i:i)
188 c_array(length + 1) = c_null_char
196 character(len=*),
intent(in) :: var_address
197 character(len=LENMODELNAME) :: model_name
198 logical(LGP),
intent(out) :: success
200 character(len=LENMEMPATH) :: mem_path
201 character(len=LENCOMPONENTNAME) :: dummy_component
202 character(len=LENVARNAME) :: var_name
203 logical(LGP) :: split_succeeded
208 if (.not. split_succeeded)
then
224 integer(kind=c_int),
intent(in) :: grid_id
225 character(len=LENMODELNAME) :: model_name
229 character(len=LINELENGTH) :: error_msg
235 if (basemodel%id == grid_id)
then
236 model_name = basemodel%name
241 write (error_msg,
'(a,i0)')
'BMI error: no model for grid id ', grid_id
253 integer(I4B),
intent(in) :: subcomponent_idx
257 integer(I4B) :: solutionidx
261 solutionidx = sgp%idsolutions(subcomponent_idx)
272 character(len=LENMODELNAME) :: model_name
273 character(len=LENGRIDTYPE) :: grid_type_f
280 if (basemodel%name == model_name)
then
281 call basemodel%dis%get_dis_type(grid_type_f)
291 integer(kind=c_int),
intent(in) :: grid_id
292 character(len=*),
intent(in) :: expected_type
295 character(len=LENMODELNAME) :: model_name
296 character(len=LENGRIDTYPE) :: grid_type
303 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
Previous variable names checked in as deprecated aliases.
subroutine, public get_deprecated_alias(name, mem_path, found, replacement, version)
Get the replacement and version of a deprecated name.
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.
subroutine warn_deprecated_address(mem_path, var_name)
Store a warning the first time a deprecated variable name is used.
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
This module contains simulation methods.
subroutine, public store_warning(msg, substring)
Store warning message.
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.