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 @@ ...@@ -3,6 +3,10 @@
* Version 1.7.0 released * Version 1.7.0 released
* using CGRIBEX library version 1.7.0 * 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 2014-08-15 Uwe Schulzweida
* gridCompare: check position parameter of unstructured grids only if gridnumber > 0 * gridCompare: check position parameter of unstructured grids only if gridnumber > 0
......
...@@ -1026,6 +1026,9 @@ void streamDefHistory(int streamID, int size, const char *history); ...@@ -1026,6 +1026,9 @@ void streamDefHistory(int streamID, int size, const char *history);
int streamInqHistorySize(int streamID); int streamInqHistorySize(int streamID);
void streamInqHistoryString(int streamID, char *history); void streamInqHistoryString(int streamID, char *history);
void gribapiLibraryVersion(int *major_version, int *minor_version, int *revision_version);
/* /*
#if defined (__cplusplus) #if defined (__cplusplus)
} }
......
...@@ -2352,3 +2352,9 @@ ...@@ -2352,3 +2352,9 @@
! CHARACTER*(*) history) ! CHARACTER*(*) history)
EXTERNAL streamInqHistoryString EXTERNAL streamInqHistoryString
! gribapiLibraryVersion
! (INTEGER major_version,
! INTEGER minor_version,
! INTEGER revision_version)
EXTERNAL gribapiLibraryVersion
...@@ -504,5 +504,6 @@ FCALLSCFUN2 (STRING, tableInqParUnitsPtr, TABLEINQPARUNITSPTR, tableinqparunitsp ...@@ -504,5 +504,6 @@ FCALLSCFUN2 (STRING, tableInqParUnitsPtr, TABLEINQPARUNITSPTR, tableinqparunitsp
FCALLSCSUB3 (streamDefHistory, STREAMDEFHISTORY, streamdefhistory, INT, INT, STRING) FCALLSCSUB3 (streamDefHistory, STREAMDEFHISTORY, streamdefhistory, INT, INT, STRING)
FCALLSCFUN1 (INT, streamInqHistorySize, STREAMINQHISTORYSIZE, streaminqhistorysize, INT) FCALLSCFUN1 (INT, streamInqHistorySize, STREAMINQHISTORYSIZE, streaminqhistorysize, INT)
FCALLSCSUB2 (streamInqHistoryString, STREAMINQHISTORYSTRING, streaminqhistorystring, INT, PSTRING) FCALLSCSUB2 (streamInqHistoryString, STREAMINQHISTORYSTRING, streaminqhistorystring, INT, PSTRING)
FCALLSCSUB3 (gribapiLibraryVersion, GRIBAPILIBRARYVERSION, gribapilibraryversion, PINT, PINT, PINT)
#endif #endif
...@@ -21,20 +21,31 @@ static char gribapi_libvers[64] = ""; ...@@ -21,20 +21,31 @@ static char gribapi_libvers[64] = "";
static int gribapi_libvers_init; static int gribapi_libvers_init;
#endif #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) const char *gribapiLibraryVersionString(void)
{ {
#if defined (HAVE_LIBGRIB_API) #if defined (HAVE_LIBGRIB_API)
if (!gribapi_libvers_init) if (!gribapi_libvers_init)
{ {
long version = grib_get_api_version();
int major_version, minor_version, revision_version; int major_version, minor_version, revision_version;
major_version = (int)(version/10000L); gribapiLibraryVersion(&major_version, &minor_version, &revision_version);
minor_version = (int)(version-(long)major_version*10000L)/100;
revision_version = (int)(version-(long)major_version*10000L - minor_version*100);
sprintf(gribapi_libvers, "%d.%d.%d", sprintf(gribapi_libvers, "%d.%d.%d", major_version, minor_version, revision_version);
major_version, minor_version, revision_version);
gribapi_libvers_init = 1; gribapi_libvers_init = 1;
} }
#endif #endif
......
...@@ -3377,6 +3377,15 @@ module mo_cdi ...@@ -3377,6 +3377,15 @@ module mo_cdi
end subroutine streamInqHistoryString end subroutine streamInqHistoryString
end interface 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
public :: getchar_unlocked public :: getchar_unlocked
public :: cdiReset public :: cdiReset
...@@ -3750,6 +3759,7 @@ module mo_cdi ...@@ -3750,6 +3759,7 @@ module mo_cdi
public :: streamDefHistory public :: streamDefHistory
public :: streamInqHistorySize public :: streamInqHistorySize
public :: streamInqHistoryString public :: streamInqHistoryString
public :: gribapiLibraryVersion
public :: ctrim public :: ctrim
public :: CDI_MAX_NAME 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