From c08ed5b418534b36b647d8bbf7194ec878bc7e61 Mon Sep 17 00:00:00 2001 From: Ganga P Purja Pun Date: Wed, 3 May 2023 11:59:38 -0400 Subject: [PATCH] Updates pointers of type field_def to allocatables --- field_manager/field_manager.F90 | 56 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/field_manager/field_manager.F90 b/field_manager/field_manager.F90 index f605447818..86ae62caaa 100644 --- a/field_manager/field_manager.F90 +++ b/field_manager/field_manager.F90 @@ -492,10 +492,10 @@ module field_manager_mod integer :: max_index type (field_def), pointer :: first_field => NULL() type (field_def), pointer :: last_field => NULL() - integer, pointer, dimension(:) :: i_value => NULL() - logical, pointer, dimension(:) :: l_value => NULL() - real, pointer, dimension(:) :: r_value => NULL() - character(len=fm_string_len), pointer, dimension(:) :: s_value => NULL() + integer, allocatable, dimension(:) :: i_value + logical, allocatable, dimension(:) :: l_value + real, allocatable, dimension(:) :: r_value + character(len=fm_string_len), allocatable, dimension(:) :: s_value type (field_def), pointer :: next => NULL() type (field_def), pointer :: prev => NULL() end type field_def @@ -1590,10 +1590,10 @@ function create_field(parent_p, name) & list_p%field_type = null_type list_p%max_index = 0 list_p%array_dim = 0 -if (associated(list_p%i_value)) deallocate(list_p%i_value) -if (associated(list_p%l_value)) deallocate(list_p%l_value) -if (associated(list_p%r_value)) deallocate(list_p%r_value) -if (associated(list_p%s_value)) deallocate(list_p%s_value) +if (allocated(list_p%i_value)) deallocate(list_p%i_value) +if (allocated(list_p%l_value)) deallocate(list_p%l_value) +if (allocated(list_p%r_value)) deallocate(list_p%r_value) +if (allocated(list_p%s_value)) deallocate(list_p%s_value) ! If this is the first field in the parent, then set the pointer ! to it, otherwise, update the "next" pointer for the last list if (parent_p%length .le. 0) then @@ -2791,7 +2791,7 @@ function fm_new_value_integer(name, value, create, index, append) & field_index = NO_FIELD return - elseif (.not. associated(temp_field_p%i_value) .and. & + elseif (.not. allocated(temp_field_p%i_value) .and. & index_t .gt. 0) then ! Array undefined, so allocate the array allocate(temp_field_p%i_value(1)) @@ -2805,8 +2805,8 @@ function fm_new_value_integer(name, value, create, index, append) & do i = 1, temp_field_p%max_index temp_i_value(i) = temp_field_p%i_value(i) enddo - if (associated (temp_field_p%i_value)) deallocate(temp_field_p%i_value) - temp_field_p%i_value => temp_i_value + if (allocated (temp_field_p%i_value)) deallocate(temp_field_p%i_value) + temp_field_p%i_value = temp_i_value temp_field_p%max_index = index_t endif ! Assign the value and set the field_index for return @@ -2924,7 +2924,7 @@ function fm_new_value_logical(name, value, create, index, append) & field_index = NO_FIELD return - elseif (.not. associated(temp_field_p%l_value) .and. & + elseif (.not. allocated(temp_field_p%l_value) .and. & index_t .gt. 0) then ! Array undefined, so allocate the array allocate(temp_field_p%l_value(1)) @@ -2939,8 +2939,8 @@ function fm_new_value_logical(name, value, create, index, append) & do i = 1, temp_field_p%max_index temp_l_value(i) = temp_field_p%l_value(i) enddo - if (associated(temp_field_p%l_value)) deallocate(temp_field_p%l_value) - temp_field_p%l_value => temp_l_value + if (allocated(temp_field_p%l_value)) deallocate(temp_field_p%l_value) + temp_field_p%l_value = temp_l_value temp_field_p%max_index = index_t endif @@ -3068,7 +3068,7 @@ function fm_new_value_real(name, value, create, index, append) & ! Can't set non-null field to null field_index = NO_FIELD return - elseif (.not. associated(temp_field_p%r_value) .and. & + elseif (.not. allocated(temp_field_p%r_value) .and. & index_t .gt. 0) then ! Array undefined, so allocate the array allocate(temp_field_p%r_value(1)) @@ -3082,8 +3082,8 @@ function fm_new_value_real(name, value, create, index, append) & do i = 1, temp_field_p%max_index temp_r_value(i) = temp_field_p%r_value(i) enddo - if (associated(temp_field_p%r_value)) deallocate(temp_field_p%r_value) - temp_field_p%r_value => temp_r_value + if (allocated(temp_field_p%r_value)) deallocate(temp_field_p%r_value) + temp_field_p%r_value = temp_r_value temp_field_p%max_index = index_t endif ! Assign the value and set the field_index for return @@ -3201,7 +3201,7 @@ function fm_new_value_string(name, value, create, index, append) & field_index = NO_FIELD return - elseif (.not. associated(temp_field_p%s_value) .and. & + elseif (.not. allocated(temp_field_p%s_value) .and. & index_t .gt. 0) then ! Array undefined, so allocate the array allocate(temp_field_p%s_value(1)) @@ -3216,8 +3216,8 @@ function fm_new_value_string(name, value, create, index, append) & do i = 1, temp_field_p%max_index temp_s_value(i) = temp_field_p%s_value(i) enddo - if (associated(temp_field_p%s_value)) deallocate(temp_field_p%s_value) - temp_field_p%s_value => temp_s_value + if (allocated(temp_field_p%s_value)) deallocate(temp_field_p%s_value) + temp_field_p%s_value = temp_s_value temp_field_p%max_index = index_t endif @@ -3375,10 +3375,10 @@ subroutine initialize nullify(root%last_field) root%max_index = 0 root%array_dim = 0 - if (associated(root%i_value)) deallocate(root%i_value) - if (associated(root%l_value)) deallocate(root%l_value) - if (associated(root%r_value)) deallocate(root%r_value) - if (associated(root%s_value)) deallocate(root%s_value) + if (allocated(root%i_value)) deallocate(root%i_value) + if (allocated(root%l_value)) deallocate(root%l_value) + if (allocated(root%r_value)) deallocate(root%r_value) + if (allocated(root%s_value)) deallocate(root%s_value) nullify(root%next) nullify(root%prev) @@ -3431,10 +3431,10 @@ function make_list(this_list_p, name) & ! Initialize the new list list_p%length = 0 list_p%field_type = list_type -if (associated(list_p%i_value)) deallocate(list_p%i_value) -if (associated(list_p%l_value)) deallocate(list_p%l_value) -if (associated(list_p%r_value)) deallocate(list_p%r_value) -if (associated(list_p%s_value)) deallocate(list_p%s_value) +if (allocated(list_p%i_value)) deallocate(list_p%i_value) +if (allocated(list_p%l_value)) deallocate(list_p%l_value) +if (allocated(list_p%r_value)) deallocate(list_p%r_value) +if (allocated(list_p%s_value)) deallocate(list_p%s_value) end function make_list