6 use iso_c_binding,
only: c_int, c_char, c_null_char
67 character(kind=c_char),
intent(in) :: c_var_address(*)
68 character(len=LENMEMPATH),
intent(out) :: mem_path
69 character(len=LENVARNAME),
intent(out) :: var_name
70 logical(LGP),
intent(out) :: success
72 character(len=LENMEMADDRESS) :: var_address
73 logical(LGP) :: valid, found
80 call split_mem_address(var_address, mem_path, var_name, valid)
109 character(len=LENMEMPATH),
intent(in) :: mem_path
110 character(len=LENVARNAME),
intent(in) :: var_name
111 logical(LGP),
intent(out) :: found
130 character(len=LENMEMPATH),
intent(in) :: mem_path
131 character(len=LENVARNAME),
intent(in) :: var_name
133 logical(LGP) :: found
134 character(len=LENMEMADDRESS) :: replacement
135 character(len=LINELENGTH) :: version
136 character(len=MAXCHARLEN) :: msg
139 if (.not. found)
return
142 "API VARIABLE '"//trim(var_name)//
"' IN '"//trim(mem_path)// &
143 "' WAS DEPRECATED IN VERSION "//trim(version)//
". USE '"// &
144 trim(replacement)//
"' INSTEAD."
151 pure function strlen(char_array, max_len)
result(string_length)
153 integer(I4B),
intent(in) :: max_len
154 character(c_char),
intent(in) :: char_array(max_len)
155 integer(I4B) :: string_length
160 do i = 1,
size(char_array)
161 if (char_array(i) .eq. c_null_char)
then
162 string_length = i - 1
173 integer(c_int),
intent(in) :: length
174 character(c_char),
intent(in) :: char_array(length)
175 character(len=length) :: f_string
180 f_string(i:i) = char_array(i)
189 integer(c_int),
intent(in) :: length
190 character(len=length),
intent(in) :: string
191 character(kind=c_char, len=1) :: c_array(length + 1)
196 c_array(i) = string(i:i)
198 c_array(length + 1) = c_null_char
206 character(len=*),
intent(in) :: var_address
207 character(len=LENMODELNAME) :: model_name
208 logical(LGP),
intent(out) :: success
210 character(len=LENMEMPATH) :: mem_path
211 character(len=LENCOMPONENTNAME) :: dummy_component
212 character(len=LENVARNAME) :: var_name
213 logical(LGP) :: split_succeeded
218 if (.not. split_succeeded)
then
234 integer(kind=c_int),
intent(in) :: grid_id
235 character(len=LENMODELNAME) :: model_name
239 character(len=LINELENGTH) :: error_msg
245 if (basemodel%id == grid_id)
then
246 model_name = basemodel%name
251 write (error_msg,
'(a,i0)')
'BMI error: no model for grid id ', grid_id
263 integer(I4B),
intent(in) :: subcomponent_idx
267 integer(I4B) :: solutionidx
271 solutionidx = sgp%idsolutions(subcomponent_idx)
282 character(len=LENMODELNAME) :: model_name
283 character(len=LENGRIDTYPE) :: grid_type_f
290 if (basemodel%name == model_name)
then
291 call basemodel%dis%get_dis_type(grid_type_f)
301 integer(kind=c_int),
intent(in) :: grid_id
302 character(len=*),
intent(in) :: expected_type
305 character(len=LENMODELNAME) :: model_name
306 character(len=LENGRIDTYPE) :: grid_type
313 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
integer(i4b), parameter lenvarlocation
max length for Fortran variable location string
class(basesolutiontype) function, pointer getsolution(subcomponent_idx)
Get the solution object for this index.
integer(i4b), parameter lenunits
max length for Fortran units string
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.
integer(c_int), bind(C, name="BMI_LENUNITS") bmi_lenunits
max. length for units C-strings
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_LENVARLOCATION") bmi_lenvarlocation
max. length for variable location C-strings
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.