Read array of "nReals" real values named "Key" from ini file. If keyword "Key" is not found in setup file, the default values "Proposal" are used to create the array (error if "Proposal" not given). Setup file 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) | :: | nReals |
Number of values in array |
||
| real(kind=wp), | intent(in), | optional | :: | Proposal(:) |
Default values as real array |
|
| logical, | intent(in), | optional | :: | quiet_def_in |
flag to be quiet if DEFAULT is taken |
Real array read from setup file or initialized with default values
FUNCTION GETREALARRAY(Key,nReals,Proposal,quiet_def_in) ! MODULES IMPLICIT NONE !----------------------------------------------------------------------------------------------------------------------------------- ! INPUT VARIABLES CHARACTER(LEN=*),INTENT(IN) :: Key !! Search for this keyword in ini file INTEGER,INTENT(IN) :: nReals !! Number of values in array REAL(wp) ,OPTIONAL,INTENT(IN) :: Proposal(:) !! Default values as real array LOGICAL ,OPTIONAL,INTENT(IN) :: quiet_def_in !! flag to be quiet if DEFAULT is taken !----------------------------------------------------------------------------------------------------------------------------------- ! OUTPUT VARIABLES REAL(wp) :: GetRealArray(nReals) !! Real array read from setup file or initialized with default values !----------------------------------------------------------------------------------------------------------------------------------- ! LOCAL VARIABLES CHARACTER(LEN=MAXLEN) :: HelpStr,ProposalStr CHARACTER(LEN=8) :: DefMsg INTEGER :: iReal INTEGER :: ioerr LOGICAL :: quiet_def !=================================================================================================================================== IF (PRESENT(Proposal)) THEN CALL ConvertToProposalStr(ProposalStr,realarr=Proposal) CALL FindStr(Key,HelpStr,DefMsg,ProposalStr) ELSE CALL FindStr(Key,HelpStr,DefMsg) END IF !count number of components iReal=1+count_sep(helpstr,",") IF(iReal.NE.nReals)THEN WRITE(UNIT_stdout,'(A,I4,A,I4)')'PROBLEM IN READIN OF LINE (RealArray), number of elements : ', iReal, ' .NE. ',nReals WRITE(UNIT_stdout,*) '"',TRIM(key),' = ',TRIM(helpStr),'"' CALL abort(__STAMP__,"") END IF READ(HelpStr,*,IOSTAT=ioerr)GetRealArray IF(ioerr.NE.0)THEN WRITE(UNIT_stdout,*)'PROBLEM IN READIN OF LINE (RealArray):' WRITE(UNIT_stdout,*) '"',TRIM(key),' = ',TRIM(helpStr),'"' CALL abort(__STAMP__,"") 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,a28,i4,a4,a7,a3)',ADVANCE='NO') ' | ',TRIM(Key),' | ',& 'Real array of size (',nReals,') | ',TRIM(DefMsg),' | ' DO iReal=0,nReals-1 IF ((iReal.GT.0) .AND. (MOD(iReal,8).EQ.0)) THEN SWRITE(UNIT_stdOut,*) SWRITE(UNIT_stdOut,'(a80,a3)',ADVANCE='NO')'',' | ' END IF SWRITE(UNIT_stdOut,'(f5.2)',ADVANCE='NO')GetRealArray(iReal+1) END DO SWRITE(UNIT_stdOut,*) END IF !quiet_def END FUNCTION GETREALARRAY