From 1bffd064be68631b7913b7be75206bbe75448b9a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 1 Jun 2015 16:01:50 +0100 Subject: [PATCH] Fix fortran interface: inout intent for arrays --- fortran/grib_f90_tail.f90 | 58 +++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/fortran/grib_f90_tail.f90 b/fortran/grib_f90_tail.f90 index 1d8b41865..adaa4bdbc 100644 --- a/fortran/grib_f90_tail.f90 +++ b/fortran/grib_f90_tail.f90 @@ -2049,7 +2049,7 @@ subroutine grib_get_int_array ( gribid, key, value, status ) integer(kind=kindOfInt), intent(in) :: gribid character(len=*), intent(in) :: key - integer(kind=kindOfInt), dimension(:),allocatable,intent(out) :: value + integer(kind=kindOfInt), dimension(:),allocatable,intent(inout) :: value integer(kind=kindOfInt),optional, intent(out) :: status integer(kind=kindOfInt) :: iret @@ -2067,7 +2067,9 @@ endif return endif - if (.not.allocated(value)) allocate(value(nb_values)) + if (allocated(value) .eqv. .false.) then + allocate(value(nb_values)) + end if size_value=size(value) iret=grib_f_get_int_array ( gribid, key, value , nb_values ) if (iret==0 .and. nb_values==1 .and. size_value/=1) then @@ -2098,34 +2100,36 @@ subroutine grib_get_long_array ( gribid, key, value, status ) integer(kind=kindOfInt), intent(in) :: gribid character(len=*), intent(in) :: key - integer(kind = kindOfLong),dimension(:),allocatable,intent(out) :: value + integer(kind = kindOfLong),dimension(:),allocatable,intent(inout) :: value integer(kind=kindOfInt),optional, intent(out) :: status integer(kind=kindOfInt) :: iret integer(kind=kindOfInt) :: nb_values integer(kind=kindOfInt) :: size_value integer(kind=kindOfInt) :: i - iret=grib_f_get_size_int(gribid,key,nb_values) - if (iret /= 0) then - call grib_f_write_on_fail(gribid) - if (present(status)) then - status = iret - else - call grib_check(iret,'grib_get',key) - endif - return + iret=grib_f_get_size_int(gribid,key,nb_values) + if (iret /= 0) then + call grib_f_write_on_fail(gribid) + if (present(status)) then + status = iret + else + call grib_check(iret,'grib_get',key) endif - if (.not.allocated(value)) allocate(value(nb_values)) - size_value=size(value) - iret=grib_f_get_long_array ( gribid, key, value , nb_values ) - if (iret==0 .and. nb_values==1 .and. size_value/=1) then - do i=2,size_value - value(i)=value(1) - enddo - endif - if (iret /= 0) then - call grib_f_write_on_fail(gribid) - endif + return + endif + if (allocated(value) .eqv. .false.) then + allocate(value(nb_values)) + end if + size_value=size(value) + iret=grib_f_get_long_array ( gribid, key, value , nb_values ) + if (iret==0 .and. nb_values==1 .and. size_value/=1) then + do i=2,size_value + value(i)=value(1) + enddo + endif + if (iret /= 0) then + call grib_f_write_on_fail(gribid) + endif if (present(status)) then status = iret else @@ -2181,10 +2185,10 @@ !> @param key key name !> @param value real(4) array value !> @param status GRIB_SUCCESS if OK, integer value on error - subroutine grib_get_real4_array ( gribid, key, value, status) + subroutine grib_get_real4_array ( gribid, key, value, status ) integer(kind=kindOfInt), intent(in) :: gribid character(len=*), intent(in) :: key - real(kind = kindOfFloat), dimension(:),allocatable,intent(out) :: value + real(kind = kindOfFloat), dimension(:),allocatable,intent(inout) :: value integer(kind=kindOfInt),optional, intent(out) :: status integer(kind=kindOfInt) :: iret integer(kind=kindOfInt) :: nb_values @@ -2201,7 +2205,9 @@ endif return endif - if (.not.allocated(value)) allocate(value(nb_values)) + if (allocated(value) .eqv. .false.) then + allocate(value(nb_values)) + end if size_value=size(value) iret=grib_f_get_real4_array ( gribid, key, value , nb_values ) if (iret==0 .and. nb_values==1 .and. size_value/=1) then