Skip to content

Commit e014d13

Browse files
committed
cleanup double allocation of variables
1 parent a8327b4 commit e014d13

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/Model/GroundWaterEnergy/gwe-abc.f90

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
module AbcModule
1717
use ConstantsModule, only: LINELENGTH, LENMEMPATH, DZERO, LENVARNAME, &
18-
LENPACKAGENAME, TABLEFT, TABCENTER
18+
LENPACKAGENAME, TABLEFT, TABCENTER, LENMEMTYPE
1919
use KindModule, only: I4B, DP
2020
use MemoryManagerModule, only: mem_setptr
2121
use MemoryHelperModule, only: create_mem_path
@@ -441,14 +441,15 @@ end subroutine abc_allocate_scalars
441441
subroutine abc_allocate_arrays(this)
442442
! -- modules
443443
!! use MemoryManagerModule, only: mem_allocate
444-
use MemoryManagerModule, only: mem_setptr, mem_checkin, mem_allocate
444+
use MemoryManagerModule, only: mem_setptr, mem_checkin, mem_allocate, &
445+
get_mem_type
445446
! -- dummy
446447
class(AbcType), intent(inout) :: this
447-
! integer(I4B), dimension(:), pointer, contiguous, optional :: nodelist
448+
! integer(I4B), dimension(:), pointer, contiguous, optional :: nodelist
448449
!real(DP), dimension(:, :), pointer, contiguous, optional :: auxvar
449450
! -- local
450451
integer(I4B) :: n
451-
!
452+
character(len=LENMEMTYPE) :: var_type !< memory type
452453
!
453454
! -- allocate character array for status
454455
allocate (this%status(this%ncv))
@@ -487,8 +488,20 @@ subroutine abc_allocate_arrays(this)
487488
call this%swr%ar()
488489
end if
489490
if (this%inlhf /= 0) then
490-
call mem_allocate(this%wspd, this%ncv, 'WSPD', this%memoryPath)
491-
call mem_allocate(this%tatm, this%ncv, 'TATM', this%memoryPath)
491+
call get_mem_type('WSPD', this%memoryPath, var_type)
492+
if (var_type == 'UNKNOWN') then
493+
call mem_allocate(this%wspd, this%ncv, 'WSPD', this%memoryPath)
494+
do n = 1, this%ncv
495+
this%wspd(n) = DZERO
496+
end do
497+
end if
498+
call get_mem_type('TATM', this%memoryPath, var_type)
499+
if (var_type == 'UNKNOWN') then
500+
call mem_allocate(this%tatm, this%ncv, 'TATM', this%memoryPath)
501+
do n = 1, this%ncv
502+
this%tatm(n) = DZERO
503+
end do
504+
end if
492505
call mem_allocate(this%rh, this%ncv, 'RH', this%memoryPath)
493506
!
494507
! -- initialize

0 commit comments

Comments
 (0)