Skip to content

Commit

Permalink
keep string_to_char_array around just to avoid character truncation w…
Browse files Browse the repository at this point in the history
…arning... is there a better way around this?
  • Loading branch information
wpbonelli committed Aug 9, 2024
1 parent 263e87a commit 1153883
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions srcbmi/mf6bmi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ function bmi_get_component_name(name) result(bmi_status) &
! -- dummy variables
character(kind=c_char), intent(out) :: name(BMI_LENCOMPONENTNAME)
integer(kind=c_int) :: bmi_status !< BMI status code
! -- local variables

name = 'MODFLOW 6'//c_null_char
name = string_to_char_array('MODFLOW 6')
bmi_status = BMI_SUCCESS

end function bmi_get_component_name
Expand Down
11 changes: 11 additions & 0 deletions srcbmi/mf6bmiUtil.f90
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ pure function char_array_to_string(char_array, length) result(f_string)

end function char_array_to_string

!> @brief Convert Fortran string to C-style character string
!<
pure function string_to_char_array(string) result(c_array)
! -- dummy variables
character(len=*), intent(in) :: string !< string to convert
character(kind=c_char, len=1) :: c_array(len(string) + 1) !< C-style character string

c_array = trim(string)//c_null_char

end function string_to_char_array

!> @brief Extract the model name from a memory address string
!<
function extract_model_name(var_address, success) result(model_name)
Expand Down

0 comments on commit 1153883

Please sign in to comment.