| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | Key | |||
| character(len=*), | intent(in) | :: | str_in | |||
| character(len=1), | intent(in) | :: | separator |
FUNCTION count_sep(Key,str_in,separator) RESULT(n_sep) IMPLICIT NONE !------------------------------------------- ! input CHARACTER(LEN=*),INTENT(IN) :: Key CHARACTER(LEN=*),INTENT(IN) :: str_in CHARACTER(LEN=1),INTENT(IN) :: separator ! output INTEGER :: n_sep !------------------------------------------- ! LOCAL VARIABLES CHARACTER(LEN=LEN(str_in)) :: str_tmp INTEGER :: len_in,i !============================================================================== n_sep=0 len_in=LEN_TRIM(str_in) str_tmp=TRIM(str_in) IF(str_tmp(1:1).EQ.separator) THEN CALL abort(__STAMP__,& "parameter '"//TRIM(Key)//"', problem with count separator: first character should not be a separator!", & TypeInfo="InvalidParameterError") END IF DO i=2,len_in-1 IF (str_tmp(i:i).EQ.separator) THEN n_sep=n_sep+1 END IF END DO IF(str_tmp(len_in:len_in).EQ.separator) THEN CALL abort(__STAMP__,& "parameter '"//TRIM(Key)//"', problem with count separator: last character should not be a separator!", & TypeInfo="InvalidParameterError") END IF END FUNCTION count_sep