From 9ba56e862ded99d231dc2133a5d82ca0e213ac4a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 20 Dec 2023 14:17:30 +0000 Subject: [PATCH] Fortran: Compiler warnings (SUP-3893) --- fortran/grib_api_externals.h | 1 + fortran/grib_f90_tail.f90 | 8 +++--- fortran/grib_fortran.c | 20 +++++++++++++-- fortran/grib_fortran_prototypes.h | 41 +++++++++++++++++-------------- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/fortran/grib_api_externals.h b/fortran/grib_api_externals.h index f41562c02..85a442c96 100644 --- a/fortran/grib_api_externals.h +++ b/fortran/grib_api_externals.h @@ -20,6 +20,7 @@ integer, external :: grib_f_skip_computed, & integer, external :: grib_f_keys_iterator_get_name, & grib_f_keys_iterator_rewind integer, external :: grib_f_new_from_message, & + grib_f_new_from_message_int, & grib_f_new_from_message_copy, & grib_f_new_from_samples, & codes_bufr_f_new_from_samples, & diff --git a/fortran/grib_f90_tail.f90 b/fortran/grib_f90_tail.f90 index 600e621a5..c7b3f0de9 100644 --- a/fortran/grib_f90_tail.f90 +++ b/fortran/grib_f90_tail.f90 @@ -1365,7 +1365,7 @@ if (present(status)) then status = iret else - call grib_check(iret, 'new_from_message', '') + call grib_check(iret, 'new_from_message_char', '') end if end subroutine grib_new_from_message_char @@ -1394,11 +1394,13 @@ integer(kind=kindOfInt) :: iret size_bytes = size(message, dim=1)*sizeOfInteger4 - iret = grib_f_new_from_message(gribid, message, size_bytes) + ! See SUP-3893 + !iret = grib_f_new_from_message(gribid, message, size_bytes) + iret = grib_f_new_from_message_int(gribid, message, size_bytes) if (present(status)) then status = iret else - call grib_check(iret, 'new_from_message', '') + call grib_check(iret, 'new_from_message_int4', '') end if end subroutine grib_new_from_message_int4 diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 751f28460..03540d84b 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -1497,11 +1497,10 @@ int codes_f_bufr_keys_iterator_delete(int* iterid) { int grib_f_new_from_message_(int* gid, void* buffer , size_t* bufsize){ grib_handle *h = NULL; h = grib_handle_new_from_message_copy(0, buffer, *bufsize); - if(h){ + if (h){ push_handle(h,gid); return GRIB_SUCCESS; } - *gid = -1; return GRIB_INTERNAL_ERROR; } @@ -1512,6 +1511,23 @@ int grib_f_new_from_message(int* gid, void* buffer , size_t* bufsize){ return grib_f_new_from_message_(gid, buffer , bufsize); } +/* See SUP-3893: Need to provide an 'int' version */ +int grib_f_new_from_message_int_(int* gid, int* buffer , size_t* bufsize){ + grib_handle *h = NULL; + h = grib_handle_new_from_message_copy(0, (void*)buffer, *bufsize); + if (h){ + push_handle(h,gid); + return GRIB_SUCCESS; + } + *gid = -1; + return GRIB_INTERNAL_ERROR; +} +int grib_f_new_from_message_int__(int* gid, int* buffer , size_t* bufsize){ + return grib_f_new_from_message_int_(gid, buffer , bufsize); +} +int grib_f_new_from_message_int(int* gid, int* buffer , size_t* bufsize){ + return grib_f_new_from_message_int_(gid, buffer , bufsize); +} /*****************************************************************************/ int grib_f_new_from_message_copy_(int* gid, void* buffer , size_t* bufsize){ grib_handle *h = NULL; diff --git a/fortran/grib_fortran_prototypes.h b/fortran/grib_fortran_prototypes.h index f0267cc79..0912dadc6 100644 --- a/fortran/grib_fortran_prototypes.h +++ b/fortran/grib_fortran_prototypes.h @@ -16,15 +16,15 @@ extern "C" { int grib_f_read_any_headers_only_from_file_(int *fid, char *buffer, size_t *nbytes); int grib_f_read_any_headers_only_from_file__(int *fid, char *buffer, size_t *nbytes); int grib_f_read_any_headers_only_from_file(int *fid, char *buffer, size_t *nbytes); -int grib_f_read_any_from_file_(int *fid, void *buffer, size_t *nbytes); -int grib_f_read_any_from_file__(int *fid, void *buffer, size_t *nbytes); -int grib_f_read_any_from_file(int *fid, void *buffer, size_t *nbytes); -int grib_f_write_file_(int *fid, void *buffer, size_t *nbytes); -int grib_f_write_file__(int *fid, void *buffer, size_t *nbytes); -int grib_f_write_file(int *fid, void *buffer, size_t *nbytes); -int grib_f_read_file_(int *fid, void *buffer, size_t *nbytes); -int grib_f_read_file__(int *fid, void *buffer, size_t *nbytes); -int grib_f_read_file(int *fid, void *buffer, size_t *nbytes); +int grib_f_read_any_from_file_(int *fid, void* buffer, size_t *nbytes); +int grib_f_read_any_from_file__(int *fid, void* buffer, size_t *nbytes); +int grib_f_read_any_from_file(int *fid, void* buffer, size_t *nbytes); +int grib_f_write_file_(int *fid, void* buffer, size_t *nbytes); +int grib_f_write_file__(int *fid, void* buffer, size_t *nbytes); +int grib_f_write_file(int *fid, void* buffer, size_t *nbytes); +int grib_f_read_file_(int *fid, void* buffer, size_t *nbytes); +int grib_f_read_file__(int *fid, void* buffer, size_t *nbytes); +int grib_f_read_file(int *fid, void* buffer, size_t *nbytes); int grib_f_open_file_(int *fid, char *name, char *op, int lname, int lop); int grib_f_open_file__(int *fid, char *name, char *op, int lname, int lop); int grib_f_open_file(int *fid, char *name, char *op, int lname, int lop); @@ -99,12 +99,17 @@ int grib_f_skip_read_only(int *iterid); int grib_f_skip_function_(int *iterid); int grib_f_skip_function__(int *iterid); int grib_f_skip_function(int *iterid); -int grib_f_new_from_message_(int *gid, void *buffer, size_t *bufsize); -int grib_f_new_from_message__(int *gid, void *buffer, size_t *bufsize); -int grib_f_new_from_message(int *gid, void *buffer, size_t *bufsize); -int grib_f_new_from_message_copy_(int *gid, void *buffer, size_t *bufsize); -int grib_f_new_from_message_copy__(int *gid, void *buffer, size_t *bufsize); -int grib_f_new_from_message_copy(int *gid, void *buffer, size_t *bufsize); + +int grib_f_new_from_message_(int *gid, void* buffer, size_t *bufsize); +int grib_f_new_from_message__(int *gid, void* buffer, size_t *bufsize); +int grib_f_new_from_message(int *gid, void* buffer, size_t *bufsize); +int grib_f_new_from_message_int_(int *gid, int *buffer, size_t *bufsize); +int grib_f_new_from_message_int__(int *gid, int *buffer, size_t *bufsize); +int grib_f_new_from_message_int(int *gid, int *buffer, size_t *bufsize); + +int grib_f_new_from_message_copy_(int *gid, void* buffer, size_t *bufsize); +int grib_f_new_from_message_copy__(int *gid, void* buffer, size_t *bufsize); +int grib_f_new_from_message_copy(int *gid, void* buffer, size_t *bufsize); int grib_f_new_from_samples_(int *gid, char *name, int lname); int grib_f_new_from_samples__(int *gid, char *name, int lname); int grib_f_new_from_samples(int *gid, char *name, int lname); @@ -353,9 +358,9 @@ int grib_f_get_data_real8(int *gid, double *lats, double *lons, double *values, int grib_f_get_message_size_(int *gid, size_t *len); int grib_f_get_message_size__(int *gid, size_t *len); int grib_f_get_message_size(int *gid, size_t *len); -int grib_f_copy_message_(int *gid, void *mess, size_t *len); -int grib_f_copy_message__(int *gid, void *mess, size_t *len); -int grib_f_copy_message(int *gid, void *mess, size_t *len); +int grib_f_copy_message_(int *gid, void* mess, size_t *len); +int grib_f_copy_message__(int *gid, void* mess, size_t *len); +int grib_f_copy_message(int *gid, void* mess, size_t *len); void grib_f_check_(int *err, char *call, char *str, int lencall, int lenstr); void grib_f_check__(int *err, char *call, char *key, int lencall, int lenkey); void grib_f_check(int *err, char *call, char *key, int lencall, int lenkey);