mirror of https://github.com/ecmwf/eccodes.git
ECC-1064: Fortran: Implement codes_get_api_version()
This commit is contained in:
parent
ace7546f06
commit
0bf6d79c0d
|
@ -20,6 +20,7 @@ program get_product_kind
|
||||||
integer :: iret
|
integer :: iret
|
||||||
integer :: ihandle
|
integer :: ihandle
|
||||||
integer :: count=0
|
integer :: count=0
|
||||||
|
integer :: version=0
|
||||||
character(len=32) :: product_kind
|
character(len=32) :: product_kind
|
||||||
character(len=120) :: infile_name
|
character(len=120) :: infile_name
|
||||||
|
|
||||||
|
@ -27,6 +28,9 @@ program get_product_kind
|
||||||
write(*,*) 'infile_name|',infile_name,'|'
|
write(*,*) 'infile_name|',infile_name,'|'
|
||||||
call codes_open_file(ifile,infile_name,'r')
|
call codes_open_file(ifile,infile_name,'r')
|
||||||
|
|
||||||
|
call codes_get_api_version(version)
|
||||||
|
write(*,*) 'API version: ',version
|
||||||
|
|
||||||
! the first message is loaded from file
|
! the first message is loaded from file
|
||||||
! ihandle is the message id to be used in subsequent calls
|
! ihandle is the message id to be used in subsequent calls
|
||||||
call codes_new_from_file(ifile,ihandle,CODES_PRODUCT_ANY,iret)
|
call codes_new_from_file(ifile,ihandle,CODES_PRODUCT_ANY,iret)
|
||||||
|
|
|
@ -12,10 +12,14 @@
|
||||||
|
|
||||||
label="get_product_kind_f"
|
label="get_product_kind_f"
|
||||||
fTmp=${label}.tmp
|
fTmp=${label}.tmp
|
||||||
|
fOut=${label}.out
|
||||||
|
|
||||||
# Create a file containing both GRIB and BUFR messages
|
# Create a file containing both GRIB and BUFR messages
|
||||||
cat ${data_dir}/sample.grib2 ${data_dir}/bufr/syno_multi.bufr >$fTmp
|
cat ${data_dir}/sample.grib2 ${data_dir}/bufr/syno_multi.bufr >$fTmp
|
||||||
|
|
||||||
${examples_dir}/eccodes_f_get_product_kind $fTmp >/dev/null 2>&1
|
${examples_dir}/eccodes_f_get_product_kind $fTmp > $fOut
|
||||||
|
cat $fOut
|
||||||
|
grep -q "product: BUFR" $fOut
|
||||||
|
grep -q "product: GRIB" $fOut
|
||||||
|
|
||||||
rm -f ${fTmp}
|
rm -f $fTmp $fOut
|
||||||
|
|
|
@ -1545,6 +1545,26 @@ subroutine codes_dump ( msgid , status)
|
||||||
call grib_dump (msgid, status)
|
call grib_dump (msgid, status)
|
||||||
end subroutine codes_dump
|
end subroutine codes_dump
|
||||||
|
|
||||||
|
|
||||||
|
!> Get the API version
|
||||||
|
!>
|
||||||
|
!> In case of error, if the status parameter (optional) is not given, the program will
|
||||||
|
!> exit with an error message.\n Otherwise the error message can be
|
||||||
|
!> gathered with @ref grib_get_error_string.
|
||||||
|
!>
|
||||||
|
!> @param api_version The version as an integer
|
||||||
|
!> @param status GRIB_SUCCESS if OK, integer value on error
|
||||||
|
subroutine codes_get_api_version(api_version, status)
|
||||||
|
integer(kind = kindOfInt), intent(out) :: api_version
|
||||||
|
integer(kind=kindOfInt),optional, intent(out) :: status
|
||||||
|
|
||||||
|
call grib_f_get_api_version(api_version)
|
||||||
|
if (present(status)) then
|
||||||
|
status = CODES_SUCCESS
|
||||||
|
endif
|
||||||
|
end subroutine codes_get_api_version
|
||||||
|
|
||||||
|
|
||||||
!> Get the error message given an error code
|
!> Get the error message given an error code
|
||||||
!>
|
!>
|
||||||
!> @param error error code
|
!> @param error error code
|
||||||
|
|
|
@ -26,6 +26,7 @@ public :: codes_new_from_message, &
|
||||||
public :: codes_release
|
public :: codes_release
|
||||||
public :: codes_dump
|
public :: codes_dump
|
||||||
public :: codes_get_error_string
|
public :: codes_get_error_string
|
||||||
|
public :: codes_get_api_version
|
||||||
public :: codes_get_size
|
public :: codes_get_size
|
||||||
public :: codes_get_message_size, codes_copy_message
|
public :: codes_get_message_size, codes_copy_message
|
||||||
public :: codes_write, codes_grib_multi_append
|
public :: codes_write, codes_grib_multi_append
|
||||||
|
|
|
@ -2160,6 +2160,18 @@ int grib_f_get_error_string(int* err, char* buf, int len){
|
||||||
return grib_f_get_error_string_(err,buf,len);
|
return grib_f_get_error_string_(err,buf,len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
int grib_f_get_api_version_(int* apiVersion,int len){
|
||||||
|
*apiVersion = grib_get_api_version();
|
||||||
|
return GRIB_SUCCESS;
|
||||||
|
}
|
||||||
|
int grib_f_get_api_version__(int* apiVersion, int len){
|
||||||
|
return grib_f_get_api_version_(apiVersion, len);
|
||||||
|
}
|
||||||
|
int grib_f_get_api_version(int* apiVersion, int len){
|
||||||
|
return grib_f_get_api_version_(apiVersion, len);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int grib_f_get_size_int_(int* gid, char* key, int* val, int len){
|
int grib_f_get_size_int_(int* gid, char* key, int* val, int len){
|
||||||
grib_handle *h = get_handle(*gid);
|
grib_handle *h = get_handle(*gid);
|
||||||
|
|
|
@ -202,6 +202,11 @@ int grib_f_dump(int *gid);
|
||||||
int grib_f_print_(int *gid, char *key, int len);
|
int grib_f_print_(int *gid, char *key, int len);
|
||||||
int grib_f_print__(int *gid, char *key, int len);
|
int grib_f_print__(int *gid, char *key, int len);
|
||||||
int grib_f_print(int *gid, char *key, int len);
|
int grib_f_print(int *gid, char *key, int len);
|
||||||
|
|
||||||
|
int grib_f_get_api_version_(int* apiVersion,int len);
|
||||||
|
int grib_f_get_api_version__(int* apiVersion,int len);
|
||||||
|
int grib_f_get_api_version(int* apiVersion,int len);
|
||||||
|
|
||||||
int grib_f_get_error_string_(int *err, char *buf, int len);
|
int grib_f_get_error_string_(int *err, char *buf, int len);
|
||||||
int grib_f_get_error_string__(int *err, char *buf, int len);
|
int grib_f_get_error_string__(int *err, char *buf, int len);
|
||||||
int grib_f_get_error_string(int *err, char *buf, int len);
|
int grib_f_get_error_string(int *err, char *buf, int len);
|
||||||
|
|
Loading…
Reference in New Issue