set_cpu_energy_performance_preference Subroutine

private impure elemental subroutine set_cpu_energy_performance_preference(this, energy_performance_preference)

Type Bound

linux_cpu

Arguments

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

Contents


Source Code

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

      this%energy_performance_preference = energy_performance_preference

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