get_hostname Function

public function get_hostname() result(host_name)

Arguments

None

Return Value character(len=:), allocatable


Called by

proc~~get_hostname~~CalledByGraph proc~get_hostname get_hostname proc~output_system_log output_system_log proc~output_system_log->proc~get_hostname interface~output_system_log type_output%output_system_log interface~output_system_log->proc~output_system_log

Source Code

    function get_hostname() result(host_name)
        implicit none
        character(:), allocatable :: host_name

        character(64) :: tmp_host_name
        integer(int32) :: len, status
        integer(int32) :: i

        character(:), allocatable :: host_name_lists(:)
        integer(int32), parameter :: host_name_lists_length = 2

        allocate (character(len=16) :: host_name_lists(host_name_lists_length))
        host_name_lists(1) = "HOSTNAME"
        host_name_lists(2) = "COMPUTERNAME"

        do i = 1, host_name_lists_length
            call get_environment_variable(host_name_lists(i), &
                                          tmp_host_name, &
                                          len, &
                                          status)
            if (status == 0 .and. len > 0) then
                host_name = trim(adjustl(tmp_host_name))
                deallocate (host_name_lists)
                return
            end if
        end do

        host_name = "Unknown"

        deallocate (host_name_lists)

    end function get_hostname