Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add/update copyright notices.
[simgrid.git] / examples / smpi / energy / f90 / sef90.f90
1 ! Copyright (c) 2013-2014. The SimGrid Team.
2 ! All rights reserved.
3
4 ! This program is free software; you can redistribute it and/or modify it
5 ! under the terms of the license (GNU LGPL) which comes with this package.
6
7 program main
8   use mpi
9
10   integer ierr
11   integer rank, pstates
12   integer i
13   double precision p, t, e
14
15   call MPI_Init(ierr)
16   call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
17
18   pstates = smpi_get_host_nb_pstates()
19
20   t = MPI_Wtime()
21
22   print *, '[', t, '] [rank ', rank, ']', pstates, 'pstates available'
23   do i = 0, pstates - 1
24      p = smpi_get_host_power_peak_at(i)
25      print *, '[', t, '] [rank ', rank, '] Power: ', p
26   end do
27
28   do i = 0, pstates - 1
29      call smpi_set_host_power_peak_at(i)
30      t = MPI_Wtime()
31      p = smpi_get_host_current_power_peak()
32      print *, '[', t, '] [rank ', rank, '] Current pstate: ', i, '; Current power: ', p
33
34      e = 1e9
35      call smpi_execute_flops(e)
36
37      t = MPI_Wtime()
38      e = smpi_get_host_consumed_energy()
39      print *, '[', t, '] [rank ', rank, '] Energy consumed (Joules): ', e
40   end do
41
42   call MPI_Finalize(ierr)
43
44 end program main