Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a collection of changes to ensure the fortran code compiles with gfortran v10.0 #23

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
a collection of changes to ensure the fortran code compiles with gfor…
…tran v10.0
  • Loading branch information
jdkloe committed Feb 29, 2020
commit 2e0d31080dda0bdd06ae2e1d1d2037498c85e020
7 changes: 7 additions & 0 deletions fortran/eccodes_visibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ public :: codes_index_get,codes_index_select,&
codes_index_create,codes_index_get_size,codes_index_release,&
codes_grib_util_sections_copy
public :: codes_datetime_to_julian,codes_julian_to_datetime,codes_copy_key

! these public declarations cannot be added in grib_kinds.h
! since if you do that, grib_kinds.h cannot be included
! inside interface statements
public :: kindOfInt, kindOfLong, kindOfSize_t, kindOfSize
public :: kindOfDouble, kindOfFloat, sizeOfInteger, sizeOfInteger2
public :: sizeOfInteger4, sizeOfReal4, sizeOfReal8
110 changes: 110 additions & 0 deletions fortran/grib_api_externals.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,113 @@ external :: grib_f_check
integer, external :: grib_f_util_sections_copy
integer, external :: grib_f_set_definitions_path, grib_f_set_samples_path
integer, external :: grib_f_julian_to_datetime, grib_f_datetime_to_julian, grib_f_copy_key

interface
function grib_f_write_file_char(ifile, buffer, ibytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
character(len=1), dimension(:),intent(in) :: buffer
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret
end function grib_f_write_file_char
function grib_f_write_file_int4(ifile, buffer, ibytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
integer(kind=4), dimension(:),intent(in) :: buffer
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret
end function grib_f_write_file_int4
function grib_f_write_file_real4(ifile, buffer, ibytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
real(kind=4), dimension(:),intent(in) :: buffer
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret
end function grib_f_write_file_real4
function grib_f_write_file_real8(ifile, buffer, ibytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
real(kind=8), dimension(:),intent(in) :: buffer
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret
end function grib_f_write_file_real8
end interface

interface
function grib_f_new_from_message_char(gribid, message, size_bytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(out) :: gribid
character(len=1), dimension(:),intent(in) :: message
integer(kind=kindOfSize_t) :: size_bytes
integer(kind=kindOfInt) :: iret
end function grib_f_new_from_message_char
function grib_f_new_from_message_int4(gribid, message, size_bytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(out) :: gribid
integer(kind=4), dimension(:),intent(in) :: message
integer(kind=kindOfSize_t) :: size_bytes
integer(kind=kindOfInt) :: iret
end function grib_f_new_from_message_int4
end interface

interface
function grib_f_read_any_from_file_char(ifile,buffer,nbytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
character(len=1),dimension(:), intent(out) :: buffer
integer(kind=kindOfSize_t), intent(inout) :: nbytes
integer(kind=kindOfInt) :: iret
end function grib_f_read_any_from_file_char
function grib_f_read_any_from_file_int4(ifile,buffer,nbytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
integer(kind=4),dimension(:), intent(out) :: buffer
integer(kind=kindOfSize_t), intent(inout) :: nbytes
integer(kind=kindOfInt) :: iret
end function grib_f_read_any_from_file_int4
function grib_f_read_any_from_file_real4(ifile,buffer,nbytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
real(kind=4),dimension(:), intent(out) :: buffer
integer(kind=kindOfSize_t), intent(inout) :: nbytes
integer(kind=kindOfInt) :: iret
end function grib_f_read_any_from_file_real4
function grib_f_read_any_from_file_real8(ifile,buffer,nbytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
real(kind=8),dimension(:), intent(out) :: buffer
integer(kind=kindOfSize_t), intent(inout) :: nbytes
integer(kind=kindOfInt) :: iret
end function grib_f_read_any_from_file_real8
end interface

interface
function grib_f_read_file_char(ifile,buffer,ibytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
character(len=1),dimension(:), intent(out) :: buffer
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret
end function grib_f_read_file_char
function grib_f_read_file_int4(ifile,buffer,ibytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
integer(kind=4),dimension(:), intent(out) :: buffer
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret
end function grib_f_read_file_int4
function grib_f_read_file_real4(ifile,buffer,ibytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
real(kind=4),dimension(:), intent(out) :: buffer
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret
end function grib_f_read_file_real4
function grib_f_read_file_real8(ifile,buffer,ibytes) result(iret)
include "grib_kinds.h"
integer(kind=kindOfInt),intent(in) :: ifile
real(kind=8),dimension(:), intent(out) :: buffer
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret
end function grib_f_read_file_real8
end interface
64 changes: 32 additions & 32 deletions fortran/grib_f90_tail.f90
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ subroutine grib_read_bytes_char ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_read_file(ifile,buffer,ibytes)
iret=grib_f_read_file_char(ifile,buffer,ibytes)
if (present(status)) then
status = iret
else
Expand All @@ -557,7 +557,7 @@ subroutine grib_read_bytes_char_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_read_file(ifile,buffer,nbytes)
iret=grib_f_read_file_char(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -586,7 +586,7 @@ subroutine grib_read_bytes_int4 ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_read_file(ifile,buffer,ibytes)
iret=grib_f_read_file_int4(ifile,buffer,ibytes)
if (present(status)) then
status = iret
else
Expand All @@ -613,7 +613,7 @@ subroutine grib_read_bytes_int4_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_read_file(ifile,buffer,nbytes)
iret=grib_f_read_file_int4(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -642,7 +642,7 @@ subroutine grib_read_bytes_real4 ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_read_file(ifile,buffer,ibytes)
iret=grib_f_read_file_real4(ifile,buffer,ibytes)
if (present(status)) then
status = iret
else
Expand All @@ -669,7 +669,7 @@ subroutine grib_read_bytes_real4_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_read_file(ifile,buffer,nbytes)
iret=grib_f_read_file_real4(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -698,7 +698,7 @@ subroutine grib_read_bytes_real8 ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_read_file(ifile,buffer,ibytes)
iret=grib_f_read_file_real8(ifile,buffer,ibytes)
if (present(status)) then
status = iret
else
Expand All @@ -725,7 +725,7 @@ subroutine grib_read_bytes_real8_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_read_file(ifile,buffer,nbytes)
iret=grib_f_read_file_real8(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -753,12 +753,12 @@ subroutine grib_read_from_file_int4 ( ifile, buffer, nbytes, status )
integer(kind=kindOfSize_t) :: ibytes
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_read_any_from_file(ifile,buffer,ibytes)
ibytes=int(nbytes,kindOfSize_t)
iret=grib_f_read_any_from_file_int4(ifile,buffer,ibytes)
if (iret == GRIB_SUCCESS .and. ibytes > huge(nbytes)) then
iret = GRIB_MESSAGE_TOO_LARGE
endif
nbytes=ibytes
nbytes=int(ibytes,kindOfInt)
if (present(status)) then
status = iret
else
Expand All @@ -785,7 +785,7 @@ subroutine grib_read_from_file_int4_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_read_any_from_file(ifile,buffer,nbytes)
iret=grib_f_read_any_from_file_int4(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -814,11 +814,11 @@ subroutine grib_read_from_file_real4 ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_read_any_from_file(ifile,buffer,ibytes)
iret=grib_f_read_any_from_file_real4(ifile,buffer,ibytes)
if (iret == GRIB_SUCCESS .and. ibytes > huge(nbytes)) then
iret = GRIB_MESSAGE_TOO_LARGE
endif
nbytes=ibytes
nbytes=int(ibytes,kindOfInt)
if (present(status)) then
status = iret
else
Expand All @@ -845,7 +845,7 @@ subroutine grib_read_from_file_real4_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_read_any_from_file(ifile,buffer,nbytes)
iret=grib_f_read_any_from_file_real4(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -874,11 +874,11 @@ subroutine grib_read_from_file_real8 ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_read_any_from_file(ifile,buffer,ibytes)
iret=grib_f_read_any_from_file_real8(ifile,buffer,ibytes)
if (iret == GRIB_SUCCESS .and. ibytes > huge(nbytes)) then
iret = GRIB_MESSAGE_TOO_LARGE
endif
nbytes=ibytes
nbytes=int(ibytes,kindOfInt)
if (present(status)) then
status = iret
else
Expand All @@ -905,7 +905,7 @@ subroutine grib_read_from_file_real8_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_read_any_from_file(ifile,buffer,nbytes)
iret=grib_f_read_any_from_file_real8(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -934,11 +934,11 @@ subroutine grib_read_from_file_char ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_read_any_from_file(ifile,buffer,ibytes)
iret=grib_f_read_any_from_file_char(ifile,buffer,ibytes)
if (iret == GRIB_SUCCESS .and. ibytes > huge(nbytes)) then
iret = GRIB_MESSAGE_TOO_LARGE
endif
nbytes=ibytes
nbytes=int(ibytes,kindOfInt)
if (present(status)) then
status = iret
else
Expand All @@ -965,7 +965,7 @@ subroutine grib_read_from_file_char_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_read_any_from_file(ifile,buffer,nbytes)
iret=grib_f_read_any_from_file_char(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -994,7 +994,7 @@ subroutine grib_write_bytes_char ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_write_file(ifile,buffer,ibytes)
iret=grib_f_write_file_char(ifile,buffer,ibytes)
if (present(status)) then
status = iret
else
Expand All @@ -1021,7 +1021,7 @@ subroutine grib_write_bytes_char_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional,intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_write_file(ifile,buffer,nbytes)
iret=grib_f_write_file_char(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -1050,7 +1050,7 @@ subroutine grib_write_bytes_int4 ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_write_file(ifile,buffer,ibytes)
iret=grib_f_write_file_int4(ifile,buffer,ibytes)
if (present(status)) then
status = iret
else
Expand All @@ -1077,7 +1077,7 @@ subroutine grib_write_bytes_int4_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional,intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_write_file(ifile,buffer,nbytes)
iret=grib_f_write_file_int4(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -1106,7 +1106,7 @@ subroutine grib_write_bytes_real4 ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_write_file(ifile,buffer,ibytes)
iret=grib_f_write_file_real4(ifile,buffer,ibytes)
if (present(status)) then
status = iret
else
Expand All @@ -1133,7 +1133,7 @@ subroutine grib_write_bytes_real4_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional,intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_write_file(ifile,buffer,nbytes)
iret=grib_f_write_file_real4(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -1162,7 +1162,7 @@ subroutine grib_write_bytes_real8 ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt) :: iret

ibytes=nbytes
iret=grib_f_write_file(ifile,buffer,ibytes)
iret=grib_f_write_file_real8(ifile,buffer,ibytes)
if (present(status)) then
status = iret
else
Expand All @@ -1189,7 +1189,7 @@ subroutine grib_write_bytes_real8_size_t ( ifile, buffer, nbytes, status )
integer(kind=kindOfInt),optional,intent(out) :: status
integer(kind=kindOfInt) :: iret

iret=grib_f_write_file(ifile,buffer,nbytes)
iret=grib_f_write_file_real8(ifile,buffer,nbytes)
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -1362,7 +1362,7 @@ subroutine grib_new_from_message_char( gribid, message, status )
integer(kind=kindOfInt) :: iret

size_bytes=size(message,dim=1)
iret = grib_f_new_from_message ( gribid, message, size_bytes )
iret = grib_f_new_from_message_char ( gribid, message, size_bytes )
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -1395,7 +1395,7 @@ subroutine grib_new_from_message_int4 ( gribid, message, status )
integer(kind=kindOfInt) :: iret

size_bytes=size(message,dim=1)*sizeOfInteger4
iret = grib_f_new_from_message ( gribid, message, size_bytes )
iret = grib_f_new_from_message_int4 ( gribid, message, size_bytes )
if (present(status)) then
status = iret
else
Expand Down Expand Up @@ -2705,7 +2705,7 @@ subroutine grib_get_message_size_int ( gribid, nbytes, status)
if (iret == GRIB_SUCCESS .and. ibytes > huge(nbytes)) then
iret = GRIB_MESSAGE_TOO_LARGE
endif
nbytes = ibytes
nbytes = int(ibytes,kindOfInt)
if (iret /= 0) then
call grib_f_write_on_fail(gribid)
endif
Expand Down
Loading