GETREAL Function

public function GETREAL(Key, Proposal, quiet_def_in) result(GetReal)

Read real named "key" from setup file and store in "GETREAL". If keyword "Key" is not found in ini file, the default value "Proposal" is used for "GETREAL" (error if "Proposal" not given). Ini file 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

real(kind=wp), intent(in), optional :: Proposal

Default values as real scalar

logical, intent(in), optional :: quiet_def_in

flag to be quiet if DEFAULT is taken

Return Value real(kind=wp)

Real read from setup file or initialized with default value


Calls

proc~~getreal~~CallsGraph proc~getreal GETREAL interface~findstr FindStr proc~getreal->interface~findstr proc~converttoproposalstr ConvertToProposalStr proc~getreal->proc~converttoproposalstr interface~findstr->interface~findstr proc~remove_blanks remove_blanks proc~converttoproposalstr->proc~remove_blanks

Source Code

FUNCTION GETREAL(Key,Proposal,quiet_def_in)
! MODULES
IMPLICIT NONE
!-----------------------------------------------------------------------------------------------------------------------------------
! INPUT VARIABLES
CHARACTER(LEN=*),INTENT(IN)          :: Key          !! Search for this keyword in ini file
REAL(wp)        ,OPTIONAL,INTENT(IN) :: Proposal     !! Default values as real scalar
LOGICAL         ,OPTIONAL,INTENT(IN) :: quiet_def_in !! flag to be quiet if DEFAULT is taken
!-----------------------------------------------------------------------------------------------------------------------------------
! OUTPUT VARIABLES
REAL(wp)                             :: GetReal  !! Real read from setup file or initialized with default value
!-----------------------------------------------------------------------------------------------------------------------------------
! LOCAL VARIABLES
CHARACTER(LEN=MAXLEN)                :: HelpStr,ProposalStr
CHARACTER(LEN=8)                     :: DefMsg
INTEGER                              :: ioerr
LOGICAL                              :: quiet_def
!===================================================================================================================================

IF (PRESENT(Proposal)) THEN
  CALL ConvertToProposalStr(ProposalStr,realScalar=Proposal)
  CALL FindStr(Key,HelpStr,DefMsg,ProposalStr)
ELSE
  CALL FindStr(Key,HelpStr,DefMsg)
END IF
! Find values of pi in the string
READ(HelpStr,*,IOSTAT=ioerr)GetReal
IF(ioerr.NE.0)THEN
  CALL abort(__STAMP__,&
       "Problem reading parameter '"//TRIM(key)//"', expected real, got '= "//TRIM(helpStr)//"'", &
       TypeInfo="InvalidParameterError")
END IF
quiet_def=.FALSE.
IF(PRESENT(quiet_def_in))THEN
  IF(INDEX(TRIM(DefMsg),"DEFAULT").NE.0)THEN
    quiet_def=quiet_def_in
  END IF
END IF
IF(.NOT.quiet_def) THEN
  SWRITE(UNIT_StdOut,'(a3,a30,a3,e33.5,a3,a7,a3)')' | ',TRIM(Key),' | ', GetReal,' | ',TRIM(DefMsg),' | '
END IF
END FUNCTION GETREAL