Coder Social home page Coder Social logo

gha3mi / forclust Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 0.0 902 KB

ForClust - manage and control a Linux system, such as adjusting the settings of the CPU and other components.

Home Page: https://gha3mi.github.io/forclust/

License: BSD 3-Clause "New" or "Revised" License

Fortran 100.00%
cpu forclust fortran fortran-package-manager linux

forclust's Issues

Use function "get_command_as_string"

Problem: To get the output of a shell command, you must write it to a temporary file and then read it into Fortran.
See the current version of the subroutine find_number_of_cpus:

   subroutine find_number_of_cpus(this)
      class(linux_nodes), intent(inout) :: this
      integer                           :: nunit
      logical                           :: ex
      character(len=:), allocatable     :: file_name

      ! todo: get total number of linux cpus
      call execute_command_line ("echo $(nproc --all) > /tmp/forclust_ncpus")

      file_name = '/tmp/forclust_ncpus'
      inquire(file=file_name, exist=ex)
      if (ex) then
         open(newunit=nunit, file=file_name, action='read')
         read(nunit, *) this%ncpus
         close(nunit)
      else
         this%ncpus = 1
         ! error stop "file not found: "//file_name
      end if
   end subroutine find_number_of_cpus

Solution: Use the get_command_as_string function in the pipes_module module from here. With this function a new version looks like as follows:

 subroutine find_number_of_cpus(this)
    use :: pipes_module, only: get_command_as_string
    class(linux_nodes), intent(inout) :: this
    character(len=:), allocatable     :: ncpu_char

    ncpu_char = get_command_as_string('nproc --all')
    read(ncpu_char,*) this%ncpus
 end subroutine find_number_of_cpus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.