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

fix bounds check in get_diag_buffer #1160

Merged
merged 1 commit into from
Apr 6, 2023
Merged
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
5 changes: 3 additions & 2 deletions diag_manager/fms_diag_buffer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ module fms_diag_buffer_mod
procedure :: flush_buffer
procedure :: remap_buffer
procedure :: set_buffer_id
! TODO deferred routines, will require some interfaces
! TODO could make these 'defered' ie. declared here but defined in each child type
! holding off cause the class(*) + polymorphism in here is probably already enough to upset the gods of compilation
!procedure(allocate_buffer), deferred :: allocate_buffer
!procedure, deferred :: get_buffer
!procedure, deferred :: initialize_buffer
Expand All @@ -64,7 +65,7 @@ module fms_diag_buffer_mod

!> Scalar buffer type to extend fmsDiagBufferContainer_type
type, extends(fmsDiagBuffer_class) :: buffer0d_type
class(*), allocatable :: buffer(:) !< "scalar" numberic buffer value
class(*), allocatable :: buffer(:) !< "scalar" numeric buffer value
!! will only be allocated to hold 1 value
class(*), allocatable :: counter(:) !< (x,y,z, time-of-day) used in the time averaging functions
contains
Expand Down
4 changes: 2 additions & 2 deletions diag_manager/fms_diag_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,9 @@ function get_diag_buffer(this, bufferid) &
class(fmsDiagObject_type), intent(in) :: this
integer, intent(in) :: bufferid
class(fmsDiagBuffer_class),allocatable:: rslt
if( (bufferid .gt. UBOUND(this%FMS_diag_buffers, 1)) .or. (bufferid .lt. UBOUND(this%FMS_diag_buffers, 1))) &
if( (bufferid .gt. UBOUND(this%FMS_diag_buffers, 1)) .or. (bufferid .lt. LBOUND(this%FMS_diag_buffers, 1))) &
call mpp_error(FATAL, 'get_diag_bufer: invalid bufferid given')
rslt = fms_diag_object%FMS_diag_buffers(bufferid)%diag_buffer_obj
rslt = this%FMS_diag_buffers(bufferid)%diag_buffer_obj
end function
#endif

Expand Down