Commit 985d9e9a authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added CDI function gribapiLibraryVersion(major_version, minor_version,...

added CDI function gribapiLibraryVersion(major_version, minor_version, revision_version) [Feature #5043]
parent 1c1e9093
......@@ -3,6 +3,10 @@
* Version 1.7.0 released
* using CGRIBEX library version 1.7.0
2014-08-20 Uwe Schulzweida
* added CDI function gribapiLibraryVersion(major_version, minor_version, revision_version) [Feature #5043]
2014-08-15 Uwe Schulzweida
* gridCompare: check position parameter of unstructured grids only if gridnumber > 0
......
......@@ -1026,6 +1026,9 @@ void streamDefHistory(int streamID, int size, const char *history);
int streamInqHistorySize(int streamID);
void streamInqHistoryString(int streamID, char *history);
void gribapiLibraryVersion(int *major_version, int *minor_version, int *revision_version);
/*
#if defined (__cplusplus)
}
......
......@@ -2352,3 +2352,9 @@
! CHARACTER*(*) history)
EXTERNAL streamInqHistoryString
! gribapiLibraryVersion
! (INTEGER major_version,
! INTEGER minor_version,
! INTEGER revision_version)
EXTERNAL gribapiLibraryVersion
......@@ -504,5 +504,6 @@ FCALLSCFUN2 (STRING, tableInqParUnitsPtr, TABLEINQPARUNITSPTR, tableinqparunitsp
FCALLSCSUB3 (streamDefHistory, STREAMDEFHISTORY, streamdefhistory, INT, INT, STRING)
FCALLSCFUN1 (INT, streamInqHistorySize, STREAMINQHISTORYSIZE, streaminqhistorysize, INT)
FCALLSCSUB2 (streamInqHistoryString, STREAMINQHISTORYSTRING, streaminqhistorystring, INT, PSTRING)
FCALLSCSUB3 (gribapiLibraryVersion, GRIBAPILIBRARYVERSION, gribapilibraryversion, PINT, PINT, PINT)
#endif
......@@ -21,20 +21,31 @@ static char gribapi_libvers[64] = "";
static int gribapi_libvers_init;
#endif
void gribapiLibraryVersion(int* major_version, int* minor_version, int* revision_version)
{
#if defined (HAVE_LIBGRIB_API)
long version = grib_get_api_version();
(*major_version) = version/10000;
(*minor_version) = (version-(*major_version)*10000)/100;
(*revision_version) = (version-(*major_version)*10000-(*minor_version)*100);
#else
(*major_version) = 0;
(*minor_version) = 0;
(*revision_version) = 0;
#endif
}
const char *gribapiLibraryVersionString(void)
{
#if defined (HAVE_LIBGRIB_API)
if (!gribapi_libvers_init)
{
long version = grib_get_api_version();
int major_version, minor_version, revision_version;
major_version = (int)(version/10000L);
minor_version = (int)(version-(long)major_version*10000L)/100;
revision_version = (int)(version-(long)major_version*10000L - minor_version*100);
gribapiLibraryVersion(&major_version, &minor_version, &revision_version);
sprintf(gribapi_libvers, "%d.%d.%d",
major_version, minor_version, revision_version);
sprintf(gribapi_libvers, "%d.%d.%d", major_version, minor_version, revision_version);
gribapi_libvers_init = 1;
}
#endif
......
......@@ -3377,6 +3377,15 @@ module mo_cdi
end subroutine streamInqHistoryString
end interface
interface
subroutine gribapiLibraryVersion(major_version,minor_version,revision_version) bind(c,name='gribapiLibraryVersion')
import :: c_int
integer(kind=c_int), intent(out) :: major_version
integer(kind=c_int), intent(out) :: minor_version
integer(kind=c_int), intent(out) :: revision_version
end subroutine gribapiLibraryVersion
end interface
public :: getchar
public :: getchar_unlocked
public :: cdiReset
......@@ -3750,6 +3759,7 @@ module mo_cdi
public :: streamDefHistory
public :: streamInqHistorySize
public :: streamInqHistoryString
public :: gribapiLibraryVersion
public :: ctrim
public :: CDI_MAX_NAME
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment