From 7f945d41c2d55ddedd899cdc28041a921bb8e79c Mon Sep 17 00:00:00 2001 From: mjr-deltares <45555666+mjr-deltares@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:18:29 +0200 Subject: [PATCH] feat(api): add get_version routine to modflow api (xmi) (#936) * add get_version routine to modflow api (xmi) * update xmi get_version --- src/Utilities/version.f90 | 6 ++++-- srcbmi/mf6bmiUtil.f90 | 3 +++ srcbmi/mf6xmi.f90 | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Utilities/version.f90 b/src/Utilities/version.f90 index d1c1aff4763..f9078d34409 100644 --- a/src/Utilities/version.f90 +++ b/src/Utilities/version.f90 @@ -14,8 +14,10 @@ module VersionModule implicit none public ! -- modflow 6 version - integer(I4B), parameter :: IDEVELOPMODE = 1 - character(len=40), parameter :: VERSION = '6.4.0 release candidate 03/04/2022' + integer(I4B), parameter :: IDEVELOPMODE = 1 + character(len=*), parameter :: VERSIONNUMBER = '6.4.0' + character(len=*), parameter :: VERSIONTAG = ' release candidate 03/04/2022' + character(len=40), parameter :: VERSION = VERSIONNUMBER//VERSIONTAG character(len=10), parameter :: MFVNAM = ' 6' character(len=*), parameter :: MFTITLE = & 'U.S. GEOLOGICAL SURVEY MODULAR HYDROLOGIC MODEL' diff --git a/srcbmi/mf6bmiUtil.f90 b/srcbmi/mf6bmiUtil.f90 index 94609c35cee..9896d0cee91 100644 --- a/srcbmi/mf6bmiUtil.f90 +++ b/srcbmi/mf6bmiUtil.f90 @@ -35,6 +35,9 @@ module mf6bmiUtil integer(c_int), bind(C, name="BMI_LENCOMPONENTNAME") :: BMI_LENCOMPONENTNAME = 256 !< component name length, i.e. 'MODFLOW 6' !DIR$ ATTRIBUTES DLLEXPORT :: BMI_LENCOMPONENTNAME + integer(c_int), bind(C, name="BMI_LENVERSION") :: BMI_LENVERSION = 256 !< length of version string, e.g. '6.3.1' or '6.4.1-dev' + !DIR$ ATTRIBUTES DLLEXPORT :: BMI_LENVERSION + contains !> @brief Split the variable address string diff --git a/srcbmi/mf6xmi.f90 b/srcbmi/mf6xmi.f90 index ae29bb72923..37dea0fe0fc 100644 --- a/srcbmi/mf6xmi.f90 +++ b/srcbmi/mf6xmi.f90 @@ -301,6 +301,30 @@ function xmi_finalize_solve(subcomponent_idx) result(bmi_status) bind(C, name="f end function xmi_finalize_solve + + !> @brief Get the version string for this component + !< + function xmi_get_version(mf_version) result(bmi_status) bind(C, name="get_version") + !DIR$ ATTRIBUTES DLLEXPORT :: xmi_get_version + ! -- modules + use VersionModule, only: VERSIONNUMBER, IDEVELOPMODE + ! -- dummy variables + character(kind=c_char), intent(out) :: mf_version(BMI_LENVERSION) + integer(kind=c_int) :: bmi_status !< BMI status code + ! -- local variables + character(len=BMI_LENVERSION) :: vstr + + if (IDEVELOPMODE == 1) then + vstr = VERSIONNUMBER//'-dev' + else + vstr = VERSIONNUMBER + end if + mf_version = string_to_char_array(vstr, len_trim(vstr)) + bmi_status = BMI_SUCCESS + + end function xmi_get_version + + !> @brief Get the full address string for a variable !! !! This routine constructs the full address string of a variable using the