elemental impure subroutine select_node(this)
class(linux_nodes), intent(inout) :: this
character(len=100) :: current_cpu_path
integer :: nunit, stat, i
integer :: temp
character(len=100) :: temp_char
logical :: ex
character(len=:), allocatable :: file_name
! check if intel_pstate exists
call this%is_intel_pstate_available()
if (this%is_intel_pstate == 1) then
! read turbo
open(newunit=nunit, file='/sys/devices/system/cpu/intel_pstate/no_turbo', iostat=stat)
read(nunit, *) temp
close(nunit)
if (temp==1) this%turbo = 'off'
if (temp==0) this%turbo = 'on'
else
this%turbo = 'off'
end if
call this%find_number_of_cpus()
if (.not. allocated(this%cpu)) allocate(this%cpu(this%ncpus))
do concurrent (i = 1:this%ncpus)
! path cpu
write (current_cpu_path, "(a,a,i0)") adjustl(trim(this%path_node)),"cpu",i-1
this%cpu(i)%path_cpu = adjustl(trim(current_cpu_path))
! read base frequency
file_name = this%cpu(i)%path_cpu//"/cpufreq/base_frequency"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=file_name, iostat=stat)
read(nunit, *) this%cpu(i)%base_frequency
close(nunit)
else
this%cpu(i)%base_frequency = 0
! error stop "file not found: "//file_name
endif
! read cpuinfo max frequency
file_name = this%cpu(i)%path_cpu//"/cpufreq/cpuinfo_max_freq"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=file_name, iostat=stat)
read(nunit, *) this%cpu(i)%cpuinfo_max_freq
close(nunit)
else
this%cpu(i)%cpuinfo_max_freq = 0
! error stop "file not found: "//file_name
endif
! read cpuinfo min frequency
file_name = this%cpu(i)%path_cpu//"/cpufreq/cpuinfo_min_freq"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=file_name, iostat=stat)
read(nunit, *) this%cpu(i)%cpuinfo_min_freq
close(nunit)
else
this%cpu(i)%cpuinfo_min_freq = 0
! error stop "file not found: "//file_name
endif
! read scaling cur frequency
file_name = this%cpu(i)%path_cpu//"/cpufreq/scaling_cur_freq"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=file_name, iostat=stat)
read(nunit, *) this%cpu(i)%scaling_cur_freq
close(nunit)
else
this%cpu(i)%scaling_cur_freq = 0
! error stop "file not found: "//file_name
endif
! read scaling max frequency
file_name = this%cpu(i)%path_cpu//"/cpufreq/scaling_max_freq"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=this%cpu(i)%path_cpu//"/cpufreq/scaling_max_freq", iostat=stat)
read(nunit, *) this%cpu(i)%scaling_max_freq
close(nunit)
else
this%cpu(i)%scaling_max_freq = 0
! error stop "file not found: "//file_name
endif
! read scaling min frequency
file_name = this%cpu(i)%path_cpu//"/cpufreq/scaling_min_freq"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=file_name, iostat=stat)
read(nunit, *) this%cpu(i)%scaling_min_freq
close(nunit)
else
this%cpu(i)%scaling_min_freq = 0
! error stop "file not found: "//file_name
endif
! read scaling governor
file_name = this%cpu(i)%path_cpu//"/cpufreq/scaling_governor"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=file_name, iostat=stat)
read(nunit, *) temp_char
this%cpu(i)%scaling_governor = adjustl(trim(temp_char))
close(nunit)
else
this%cpu(i)%scaling_governor = "not found"
! error stop "file not found: "//file_name
endif
! read energy performance preference
file_name = this%cpu(i)%path_cpu//"/cpufreq/energy_performance_preference"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=file_name, iostat=stat)
read(nunit, *) temp_char
this%cpu(i)%energy_performance_preference = adjustl(trim(temp_char))
close(nunit)
else
this%cpu(i)%energy_performance_preference = "not found"
! error stop "file not found: "//file_name
endif
end do
! read online
this%cpu(1)%online = 1
do concurrent (i = 2:this%ncpus)
file_name = this%cpu(i)%path_cpu//"/online"
inquire(file=file_name, exist=ex)
if (ex) then
open(newunit=nunit, file=this%cpu(i)%path_cpu//"/online", iostat=stat)
read(nunit, *) this%cpu(i)%online
close(nunit)
else
this%cpu(i)%online = 0
! error stop "file not found: "//file_name
endif
end do
end subroutine select_node