Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(ESMF_Config), | intent(inout) | :: | config | |||
logical, | intent(out) | :: | value | |||
type(ESMF_KeywordEnforcer), | optional | :: | keywordEnforcer | |||
character(len=*), | intent(in), | optional | :: | label | ||
logical, | intent(in), | optional | :: | default | ||
integer, | intent(out), | optional | :: | rc |
subroutine ESMF_ConfigGetLogical(config, value, & keywordEnforcer, label, default, rc) ! !ARGUMENTS: type(ESMF_Config), intent(inout) :: config logical, intent(out) :: value type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below character(len=*), intent(in), optional :: label logical, intent(in), optional :: default integer, intent(out), optional :: rc ! ! !DESCRIPTION: ! Gets a logical {\tt value} from the {\tt config} object. ! ! Recognizes any upper/lowercase composition of the following keywords as ! logical true/false values: ! ! true t .true. .t. yes y on \\ ! false f .false. .f. no n off \\ ! ! The arguments are: ! \begin{description} ! \item [config] ! Already created {\tt ESMF\_Config} object. ! \item [value] ! Returned logical value. ! \item [{[label]}] ! Identifying label. ! \item [{[default]}] ! Default value if label is not found in configuration object. ! If not specified, the default value is .false. ! \item [{[rc]}] ! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors. ! \end{description} ! !EOPI ------------------------------------------------------------------- character(len=NBUF_MAX) :: string integer :: localrc ! Initialize return code; assume routine not implemented if (present(rc)) rc = ESMF_RC_NOT_IMPL localrc = ESMF_RC_NOT_IMPL !check variables ESMF_INIT_CHECK_DEEP(ESMF_ConfigGetInit,config,rc) ! Default setting if( present( default ) ) then value = default else value = .false. endif ! Processing if (present (label ) ) then call ESMF_ConfigGetString( config, string, label=label, rc=localrc) else call ESMF_ConfigGetString( config, string, rc = localrc ) endif if ( localrc == ESMF_SUCCESS ) then ! Convert string to lower case string = ESMF_UtilStringLowerCase(string) ! Check if valid true/false keyword if (string == 't' .or. string == 'true' .or. & string == '.true.' .or. string == '.t.' .or. & string == 'y' .or. string == 'yes' .or. & string == 'on') then value = .true. call ESMF_ConfigSetCurrentAttrUsed(config, used=.true.) else if (string == 'f' .or. string == 'false' .or. & string == '.false.' .or. string == '.f.' .or. & string == 'n' .or. string == 'no' .or. & string == 'off') then value = .false. call ESMF_ConfigSetCurrentAttrUsed(config, used=.true.) else ! undo what GetSring() did call ESMF_ConfigSetCurrentAttrUsed(config, used=.false.) if (ESMF_LogFoundError(ESMF_RC_CANNOT_GET, & msg="bad boolean value '" // string // & "' in configuration file.", & ESMF_CONTEXT, rcToReturn=rc)) return endif endif else if( present( default )) then localrc = ESMF_SUCCESS endif end if if( present( rc )) then rc = localrc endif end subroutine ESMF_ConfigGetLogical