1subroutine memory_all(str,comm) 2 use m_rusage, only : rss_max 3#ifdef MPI 4 use mpi_siesta 5#endif 6 character(len=*), intent(in) :: str 7 integer, intent(in) :: comm 8 9 integer :: mpierror 10 real :: mem(2), tmem(2) 11 integer :: nprocs, myrank 12 13#ifdef MPI 14 call MPI_Comm_Size( Comm, nprocs, MPIerror ) 15 call MPI_Comm_Rank( Comm, myrank, MPIerror ) 16#else 17 nprocs = 1 18 myrank = 0 19#endif 20 21 mem(2) = rss_max() 22 mem(1) = - mem(2) 23 24#ifdef MPI 25 call MPI_Reduce(mem,tmem,2,MPI_Real,MPI_max,0,comm,MPIerror) 26 mem = tmem 27#endif 28 29 if (myrank == 0) then 30 write(6,"(a,2f12.2)") " &m -- Peak memory (Mb) " // trim(str) // " (max,min): ", mem(2), -mem(1) 31 endif 32 33end subroutine memory_all 34