Skip to content

Commit

Permalink
dOxyGenized MOM_safe_alloc.F90
Browse files Browse the repository at this point in the history
  Added dOxyGen comments for all routines and arguments in MOM_safe_alloc.F90.
All answers are bitwise identical.
  • Loading branch information
Hallberg-NOAA committed May 7, 2018
1 parent bef564f commit c64fc57
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/framework/MOM_safe_alloc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ module MOM_safe_alloc

public safe_alloc_ptr, safe_alloc_alloc

!> Allocate a pointer to a 1-d, 2-d or 3-d array
interface safe_alloc_ptr
module procedure safe_alloc_ptr_3d_2arg, safe_alloc_ptr_2d_2arg
module procedure safe_alloc_ptr_3d, safe_alloc_ptr_2d, safe_alloc_ptr_1d
end interface safe_alloc_ptr

!> Allocate a 2-d or 3-d allocatable array
interface safe_alloc_alloc
module procedure safe_alloc_allocatable_3d, safe_alloc_allocatable_2d
end interface safe_alloc_alloc
Expand All @@ -34,10 +36,11 @@ module MOM_safe_alloc

contains

!> Allocate a pointer to a 1-d array
subroutine safe_alloc_ptr_1d(ptr, i1, i2)
real, pointer :: ptr(:)
integer, intent(in) :: i1
integer, optional, intent(in) :: i2
real, dimension(:), pointer :: ptr !< A pointer to allocate
integer, intent(in) :: i1 !< The size of the array, or its starting index if i2 is present
integer, optional, intent(in) :: i2 !< The ending index of the array
if (.not.associated(ptr)) then
if (present(i2)) then
allocate(ptr(i1:i2))
Expand All @@ -48,54 +51,67 @@ subroutine safe_alloc_ptr_1d(ptr, i1, i2)
endif
end subroutine safe_alloc_ptr_1d

!> Allocate a pointer to a 2-d array based on its dimension sizes
subroutine safe_alloc_ptr_2d_2arg(ptr, ni, nj)
real, pointer :: ptr(:,:)
integer, intent(in) :: ni, nj
real, dimension(:,:), pointer :: ptr !< A pointer to allocate
integer, intent(in) :: ni, nj !< The sizes of the 1st and 2nd dimensions of the array
if (.not.associated(ptr)) then
allocate(ptr(ni,nj))
ptr(:,:) = 0.0
endif
end subroutine safe_alloc_ptr_2d_2arg

!> Allocate a pointer to a 3-d array based on its dimension sizes
subroutine safe_alloc_ptr_3d_2arg(ptr, ni, nj, nk)
real, pointer :: ptr(:,:,:)
integer, intent(in) :: ni, nj, nk
real, dimension(:,:,:), pointer :: ptr !< A pointer to allocate
integer, intent(in) :: ni, nj !< The sizes of the 1st and 2nd dimensions of the array
integer, intent(in) :: nk !< The size to allocate for the 3rd dimension
if (.not.associated(ptr)) then
allocate(ptr(ni,nj,nk))
ptr(:,:,:) = 0.0
endif
end subroutine safe_alloc_ptr_3d_2arg

!> Allocate a pointer to a 2-d array based on its index starting and ending values
subroutine safe_alloc_ptr_2d(ptr, is, ie, js, je)
real, pointer :: ptr(:,:)
integer, intent(in) :: is, ie, js, je
real, dimension(:,:), pointer :: ptr !< A pointer to allocate
integer, intent(in) :: is, ie !< The start and end indices to allocate for the 1st dimension
integer, intent(in) :: js, je !< The start and end indices to allocate for the 2nd dimension
if (.not.associated(ptr)) then
allocate(ptr(is:ie,js:je))
ptr(:,:) = 0.0
endif
end subroutine safe_alloc_ptr_2d

!> Allocate a pointer to a 3-d array based on its index starting and ending values
subroutine safe_alloc_ptr_3d(ptr, is, ie, js, je, nk)
real, pointer :: ptr(:,:,:)
integer, intent(in) :: is, ie, js, je, nk
real, dimension(:,:,:), pointer :: ptr !< A pointer to allocate
integer, intent(in) :: is, ie !< The start and end indices to allocate for the 1st dimension
integer, intent(in) :: js, je !< The start and end indices to allocate for the 2nd dimension
integer, intent(in) :: nk !< The size to allocate for the 3rd dimension
if (.not.associated(ptr)) then
allocate(ptr(is:ie,js:je,nk))
ptr(:,:,:) = 0.0
endif
end subroutine safe_alloc_ptr_3d

!> Allocate a 2-d allocatable array based on its index starting and ending values
subroutine safe_alloc_allocatable_2d(ptr, is, ie, js, je)
real, allocatable :: ptr(:,:)
integer, intent(in) :: is, ie, js, je
real, dimension(:,:), allocatable :: ptr !< An allocatable array to allocate
integer, intent(in) :: is, ie !< The start and end indices to allocate for the 1st dimension
integer, intent(in) :: js, je !< The start and end indices to allocate for the 2nd dimension
if (.not.allocated(ptr)) then
allocate(ptr(is:ie,js:je))
ptr(:,:) = 0.0
endif
end subroutine safe_alloc_allocatable_2d

!> Allocate a 3-d allocatable array based on its index starting and ending values
subroutine safe_alloc_allocatable_3d(ptr, is, ie, js, je, nk)
real, allocatable :: ptr(:,:,:)
integer, intent(in) :: is, ie, js, je, nk
real, dimension(:,:,:), allocatable :: ptr !< An allocatable array to allocate
integer, intent(in) :: is, ie !< The start and end indices to allocate for the 1st dimension
integer, intent(in) :: js, je !< The start and end indices to allocate for the 2nd dimension
integer, intent(in) :: nk !< The size to allocate for the 3rd dimension
if (.not.allocated(ptr)) then
allocate(ptr(is:ie,js:je,nk))
ptr(:,:,:) = 0.0
Expand Down

0 comments on commit c64fc57

Please sign in to comment.