Skip to content

Commit

Permalink
Fixes #1363. Fixed a bug related to an optional argument not passed in
Browse files Browse the repository at this point in the history
  • Loading branch information
atrayano committed Feb 22, 2022
1 parent fc5e540 commit 04888c8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions base/Base/Base_Base_implementation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3658,13 +3658,20 @@ subroutine genAlias(name, n, splitNameArray, aliasName, rc)
integer :: n
character(len=*) :: name
character(len=*), allocatable :: splitNameArray(:)
character(len=*) :: aliasName
character(len=*), optional :: aliasName
integer, optional :: rc

integer :: i, k
integer :: k1, k2, kk, count
integer :: nn
character(len=ESMF_MAXSTR), allocatable :: tmp(:)
character(len=ESMF_MAXSTR) :: aliasName_

if (present(aliasName)) then
aliasName_ = aliasName
else
aliasName_ = name
end if

allocate(splitNameArray(n), stat=status)
_VERIFY(status)
Expand All @@ -3673,9 +3680,9 @@ subroutine genAlias(name, n, splitNameArray, aliasName, rc)
! count the separators (";") in aliasName
count = 0
k1 = 1
kk = len_trim(aliasName)
kk = len_trim(aliasName_)
do k=1,kk
if (aliasName(k:k) == ";") then
if (aliasName_(k:k) == ";") then
count = count+1
end if
end do
Expand All @@ -3684,17 +3691,17 @@ subroutine genAlias(name, n, splitNameArray, aliasName, rc)

count = 0
do k=1,kk
if (aliasName(k:k) == ";") then
if (aliasName_(k:k) == ";") then
count = count+1
k2=k-1
if (count > n) exit ! use atmost n of the aliases
tmp(count) = aliasName(k1:k2)
tmp(count) = aliasName_(k1:k2)
k1 = k+1
end if
end do
count = count+1
k2 = kk
tmp(count) = aliasName(k1:k2)
tmp(count) = aliasName_(k1:k2)

do i=1,min(nn,n)
splitNameArray(i) = tmp(i)
Expand Down

0 comments on commit 04888c8

Please sign in to comment.