set_cpu_scaling_governor Subroutine

private impure elemental subroutine set_cpu_scaling_governor(this, scaling_governor)

Type Bound

linux_cpu

Arguments

Type IntentOptional Attributes Name
class(linux_cpu), intent(inout) :: this
character(len=*), intent(in) :: scaling_governor

Contents


Source Code

   elemental impure subroutine set_cpu_scaling_governor(this,scaling_governor)
      class(linux_cpu), intent(inout) :: this
      character(len=*), intent(in)    :: scaling_governor
      integer                         :: nunit, stat
      logical                         :: ex
      character(len=:), allocatable   :: file_name

      this%scaling_governor = scaling_governor

      file_name = this%path_cpu//"/cpufreq/scaling_governor"
      inquire(file=file_name, exist=ex)
      if (ex) then
         open(newunit=nunit, file=this%path_cpu//"/cpufreq/scaling_governor", iostat=stat)
         write(nunit, '(a)') this%scaling_governor
         close(nunit)
      else
         ! error stop "file not found: "//file_name
      endif
   end subroutine set_cpu_scaling_governor