ifin_lala(3f) - [M_matrix] test if variable name exists in lala()
LICENSE(MIT)
logical function ifin_lala(varname)
character(len=*),intent(in) :: varname
Determine if a variable name currently exists in lala().
ifin_lala TRUE if varname exists in lala, else FALSE.
sample program:
program demo_ifin_lala
use M_matrix, only : ifin_lala
implicit none
write(*,*)'eps ',ifin_lala('eps')
write(*,*)'unknown ',ifin_lala('unknown')
end program demo_ifin_lala
Results:
eps T
unknown F
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varname |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | id(GG_MAX_NAME_LENGTH) | ||||
integer, | public | :: | k |
function ifin_lala(varname)
! ident_32="@(#) M_matrix ifin_lala(3f) access LALA variable stack and see if a variable name exists"
character(len=*),intent(in) :: varname
integer :: id(GG_MAX_NAME_LENGTH)
logical :: ifin_lala
integer :: k
ifin_lala=.true.
if(GM_BIGMEM.LT.0) call lala_init(200000) ! if not initialized initialize
if( .not.mat_is_name(varname))then
call journal('sc',varname,'is not a valid variable name')
ifin_lala=.false.
endif
! convert character name to lala character set
id=iachar(' ')
call mat_str2buf(varname,id,len(varname))
call mat_copyid(G_VAR_IDS(1,G_TOP_OF_SAVED-1), ID) ! copy ID to next blank entry in G_VAR_IDS for messages(?)
do k=GG_MAX_NUMBER_OF_NAMES,1,-1 ! start at bottom and search up through names till find the name
if (mat_eqid(G_VAR_IDS(1:,k), id))exit ! if found name exit loop
enddo
! if matched the name inserted above did not find it.
if ( (k .ge. GG_MAX_NUMBER_OF_NAMES-1) .or. (k .eq. G_TOP_OF_SAVED-1)) then
ifin_lala=.false. ! unknown variable name
endif
end function ifin_lala