conf_par_env_value Function

private function conf_par_env_value(this, env_val) result(status)

Type Bound

CONF_PAR

Arguments

Type IntentOptional Attributes Name
class(CONF_PAR), intent(inout) :: this
class(*), intent(out) :: env_val

Return Value logical


Source Code

   FUNCTION conf_par_env_value(this, env_val) result(status)
      CLASS(CONF_PAR), INTENT(INOUT) :: this
      CLASS(*), INTENT(OUT) :: env_val
      LOGICAL :: status

      CHARACTER(len=max_paramter_name_len) :: string_val
      INTEGER :: stat

      ! Do nothing is already set via environment variable
      IF (this%source == 'E') THEN
         status = .TRUE.
         RETURN
      END IF

      ! Check environment variable, only if default is set
      IF (this%source == 'D') THEN
         CALL uppercase(this%name)
         CALL get_environment_variable("DBCSR_"//this%name, string_val, status=stat)
         IF (stat .NE. 0 .AND. stat .NE. 1) DBCSR_ABORT("Invalid environment value")
         IF (stat == 0) THEN
            this%source = 'E'

            SELECT TYPE (env_val)
            TYPE IS (CHARACTER(len=*))
               env_val = string_val
            TYPE IS (INTEGER)
               call str2int(string_val, env_val, stat)
               IF (stat .NE. 0) &
                  DBCSR_ABORT("Wrong environment variable reading. Expecting an integer value.")
            CLASS DEFAULT
               DBCSR_ABORT("Unrecognized type")
            END SELECT
         END IF
      END IF

      status = .FALSE.

   END FUNCTION CONF_PAR_ENV_VALUE