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

Updates member pointers of type field_def to allocatables #1211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
56 changes: 28 additions & 28 deletions field_manager/field_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
Loading