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".
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | Key |
Search for this keyword in ini file |
||
| integer, | intent(in), | optional | :: | Proposal |
Default values as integer |
Number of parameters named "Key" in inifile
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