Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add formatting to out fortran energy tests.
[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   if (ierr .ne. MPI_SUCCESS) then
17      print *, 'MPI_Init failed:', ierr
18      stop 1
19   endif
20   call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
21   if (ierr .ne. MPI_SUCCESS) then
22      print *, 'MPI_Comm_rank failed:', ierr
23      call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
24      stop 1
25   endif
26
27   pstates = smpi_get_host_nb_pstates()
28
29   t = MPI_Wtime()
30
31   print '(1a,F15.8,1a,i2,1a,i2,1a)', '[', t, '] [rank ', rank, '] ',&
32     pstates, ' pstates available'
33   do i = 0, pstates - 1
34      p = smpi_get_host_power_peak_at(i)
35      print '(1a,F15.8,1a,i2,1a,F15.4)', '[', t, '] [rank ', rank, &
36     '] Power: ', p
37   end do
38
39   do i = 0, pstates - 1
40      call smpi_set_host_pstate(i)
41      t = MPI_Wtime()
42      p = smpi_get_host_current_power_peak()
43      print '(1a,F15.8,1a,i2,1a,i2,1a,F15.4)', '[', t, '] [rank ', &
44     rank, '] Current pstate: ', i, '; Current power: ', p
45
46      e = 1e9
47      call smpi_execute_flops(e)
48
49      t = MPI_Wtime()
50      e = smpi_get_host_consumed_energy()
51      print '(1a,F15.8,1a,i2,1a,F15.4)', '[', t, '] [rank ', &
52     rank, '] Energy consumed (Joules): ', e
53   end do
54
55   call MPI_Finalize(ierr)
56   if (ierr .ne. MPI_SUCCESS) then
57      print *, 'MPI_Finalize failed:', ierr
58      call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
59      stop 1
60   endif
61
62 end program main