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
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