stuffa(3f) - [M_calculator] directly store a string into calculator
variable name table
(LICENSE:PD)
subroutine stuffa(varnam,string,ioflag)
character(len=*),intent(in) :: varnam
character(len=*),intent(in) :: string
character(len=*),intent(in),optional :: ioflag
Breaking the rule of only accessing the calculator thru calculator(3f):
a direct deposit of a value into the calculator assumed to be used
only by friendly calls, for efficiency and to avoid problems with
recursion if a routine called by the calculator in JUOWN1(3f) wants
to store something back into the calculator
variable table.
varnam variable name to create or replace in calculator module
string string to associate with the calculator variable name varnam
ioflag journal logging type passed on to journal(3f) procedure. If it
is not present or blank, the journal(3f) routine is not evoked.
Sample program:
program demo_stuffa
use M_calculator, only : stuffa
use M_calculator, only : snum0
implicit none
call stuffa('$A','')
call stuffa('$mystring','this is the value of the string')
write(*,*)snum0('$mystring')
call stuffa('$mystring','this is the new value of the string')
write(*,*)snum0('$mystring')
end program demo_stuffa
John S. Urban
Public Domain
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varnam | |||
character(len=*), | intent(in) | :: | string | |||
character(len=*), | intent(in), | optional | :: | ioflag |
subroutine stuffa(varnam,string,ioflag) ! ident_15="@(#) M_calculator stuffa(3f) directly store a string into calculator variable name table" character(len=*),intent(in) :: varnam ! assuming friendly, not checking for null or too long varnam0 character(len=:),allocatable :: varnam_local character(len=*),intent(in) :: string character(len=*),intent(in),optional :: ioflag character(len=:),allocatable :: ioflag_local integer :: indx integer :: ierr !----------------------------------------------------------------------------------------------------------------------------------- if(present(ioflag))then ioflag_local=trim(ioflag) else ioflag_local=' ' endif varnam_local=adjustl(trim(varnam)) ierr=0 !----------------------------------------------------------------------------------------------------------------------------------- call locate(keys_q,varnam_local,indx,ierr) if(indx.le.0)then ! variable name not in dictionary indx=iabs(indx) call insert(keys_q,varnam_local,indx) ! adding the new variable name to the variable name array call insert(values,' ' ,indx) call insert(values_len,0 ,indx) elseif(ioflag_local.ne.'')then ! display variable string to trail and output as indicated by ioflag write(*,g)ioflag,varnam_local//'=',string endif ! found variable name in dictionary call replace(values,string,indx) call replace(values_len,len_trim(string),indx) !----------------------------------------------------------------------------------------------------------------------------------- end subroutine stuffa