GETREALALLOCARRAY Subroutine

public subroutine GETREALALLOCARRAY(Key, GetRealArray, nReals, Proposal, quiet_def_in)

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".

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: Key

Search for this keyword in ini file

real(kind=wp), ALLOCATABLE :: GetRealArray(:)

Real array read from setup file or initialized with default values

integer, intent(out) :: 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


Calls

proc~~getrealallocarray~~CallsGraph proc~getrealallocarray GETREALALLOCARRAY interface~findstr FindStr proc~getrealallocarray->interface~findstr proc~converttoproposalstr ConvertToProposalStr proc~getrealallocarray->proc~converttoproposalstr proc~count_sep count_sep proc~getrealallocarray->proc~count_sep swrite swrite proc~getrealallocarray->swrite interface~findstr->interface~findstr proc~remove_blanks remove_blanks proc~converttoproposalstr->proc~remove_blanks

Called by

proc~~getrealallocarray~~CalledByGraph proc~getrealallocarray GETREALALLOCARRAY proc~initanalyze InitAnalyze proc~initanalyze->proc~getrealallocarray proc~initmhd3d t_functional_mhd3d%InitMHD3D proc~initmhd3d->proc~getrealallocarray proc~initprofile InitProfile proc~initmhd3d->proc~initprofile proc~initprofile->proc~getrealallocarray

Source Code

SUBROUTINE GETREALALLOCARRAY(Key,GetRealArray,nReals,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 array
LOGICAL         ,OPTIONAL,INTENT(IN) :: quiet_def_in !! flag to be quiet if DEFAULT is taken
!-----------------------------------------------------------------------------------------------------------------------------------
! OUTPUT VARIABLES
INTEGER,INTENT(OUT)       :: nReals           !! Number of values in array
REAL(wp),ALLOCATABLE      :: GetRealArray(:)  !! 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
nReals=1+count_sep(helpstr,",")

IF(ALLOCATED(GetRealarray)) DEALLOCATE(GetRealArray)
ALLOCATE(GetRealArray(nReals))

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 SUBROUTINE GETREALALLOCARRAY