CNTSTR Function

public function CNTSTR(Key, Proposal) result(CntStr)

Counts all occurances of string named "key" from inifile and store in "CNTSTR". If keyword "Key" is not found in ini file, the default value "Proposal" is used for "CNTSTR" (error if "Proposal" not given). Inifile was read in before and is stored as list of character strings starting with "FirstString".

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: Key

Search for this keyword in ini file

integer, intent(in), optional :: Proposal

Default values as integer

Return Value integer

Number of parameters named "Key" in inifile


Calls

proc~~cntstr~~CallsGraph proc~cntstr CNTSTR interface~lowcase LowCase proc~cntstr->interface~lowcase proc~remove_blanks remove_blanks proc~cntstr->proc~remove_blanks swrite swrite proc~cntstr->swrite interface~lowcase->interface~lowcase

Source Code

FUNCTION CNTSTR(Key,Proposal)
! MODULES
IMPLICIT NONE
!-----------------------------------------------------------------------------------------------------------------------------------
! INPUT VARIABLES
CHARACTER(LEN=*),INTENT(IN)          :: Key      !! Search for this keyword in ini file
INTEGER         ,OPTIONAL,INTENT(IN) :: Proposal !! Default values as integer
!-----------------------------------------------------------------------------------------------------------------------------------
! OUTPUT VARIABLES
INTEGER                              :: CntStr   !! Number of parameters named "Key" in inifile
!-----------------------------------------------------------------------------------------------------------------------------------
! LOCAL VARIABLES
CHARACTER(LEN=LEN(Key))              :: TmpKey
TYPE(tString),POINTER                :: Str1
!===================================================================================================================================

CntStr=0
CALL LowCase(Key,TmpKey)
TmpKey=remove_blanks(TmpKey)

! Search
Str1=>FirstString
DO WHILE (ASSOCIATED(Str1))
  IF (INDEX(Str1%Str,TRIM(TmpKey)//'=').EQ.1) CntStr=CntStr+1
  ! Next string in list
  Str1=>Str1%NextStr
END DO
IF (CntStr.EQ.0) THEN
  IF (PRESENT(Proposal)) THEN
    CntStr=Proposal
  ELSE
    SWRITE(UNIT_StdOut,*) 'Inifile missing necessary keyword item : ',TRIM(TmpKey)
    CALL abort(__STAMP__, &
         'Code stopped during inifile parsing!')
  END IF
END IF
END FUNCTION CNTSTR