[cig-commits] [commit] master: moving clock wrappers to clocks module (762b00d)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Fri Oct 17 05:30:04 PDT 2014
Repository : https://github.com/geodynamics/axisem
On branch : master
Link : https://github.com/geodynamics/axisem/compare/607f803cf074063627513d235f9ed0837fc1dd44...b6457db24acdde4a4e1c08935ae1b22adf87f5bf
>---------------------------------------------------------------
commit 762b00d61704a71147d634a905a61933f86531f4
Author: martinvandriel <vandriel at erdw.ethz.ch>
Date: Thu Oct 16 20:06:18 2014 +0200
moving clock wrappers to clocks module
slightly uggly, but imho less uggly then heaving them in the main programme
>---------------------------------------------------------------
762b00d61704a71147d634a905a61933f86531f4
SOLVER/clocks.f90 | 114 +++++++++++++++++++++++++++++++++++++++++------------
SOLVER/data_io.f90 | 2 +-
SOLVER/main.f90 | 68 +-------------------------------
3 files changed, 91 insertions(+), 93 deletions(-)
diff --git a/SOLVER/clocks.f90 b/SOLVER/clocks.f90
index 1de2753..a7cae53 100644
--- a/SOLVER/clocks.f90
+++ b/SOLVER/clocks.f90
@@ -18,10 +18,8 @@
! You should have received a copy of the GNU General Public License
! along with AxiSEM. If not, see <http://www.gnu.org/licenses/>.
!
-
-!=======================
+!=========================================================================================
module clocks_mod
-!=======================
!-----------------------------------------------------------------------
! CLOCKS module (for timing code sections)
@@ -48,14 +46,14 @@ module clocks_mod
private
- integer, private :: ticks_per_sec, max_ticks, ref_tick, start_tick, end_tick
- real(kind=4), private :: tick_rate
- integer, private, parameter :: max_clocks = 256
- integer, private :: clock_num = 0
- logical, private :: clocks_initialized = .FALSE.
+ integer :: ticks_per_sec, max_ticks, ref_tick, start_tick, end_tick
+ real(kind=4) :: tick_rate
+ integer, parameter :: max_clocks = 256
+ integer :: clock_num = 0
+ logical, private :: clocks_initialized = .false.
!clocks are stored in this internal type
- type, private :: clock
+ type :: clock
character(len=32) :: name
integer :: ticks, calls
end type clock
@@ -63,13 +61,81 @@ module clocks_mod
type(clock) :: clocks(0:max_clocks)
public :: clocks_init, clocks_exit, get_clock, clock_id, tick
+ public :: start_clock, end_clock
character(len=256), private :: &
version = '$Id: clocks.F90,v 2.2 2001/02/14 19:06:12 vb Exp $'
contains
-!-----------------------------------------------------------------------
+!--- WRAPPER ROUTINES, SPECIFIC TO AXISEM -----------------------------------------------
+
+!-----------------------------------------------------------------------------------------
+subroutine start_clock
+ ! Driver routine to start the timing, using the clocks_mod module.
+
+ use data_time, only : idcomm, iddump, idmpi, idmpiws, idmpiwf, idnbio, idold, &
+ idstiff, idanelts, idanelst
+ use data_proc, only : lpr, mynum
+ use data_io, only : verbose
+
+ implicit none
+
+ character(len=8) :: mydate
+ character(len=10) :: mytime
+
+ call date_and_time(mydate,mytime)
+ if (lpr) write(6,11) mydate(5:6), mydate(7:8), mydate(1:4), mytime(1:2), mytime(3:4)
+
+11 format(' Simulation started on ', A2,'/',A2,'/',A4,' at ', A2,'h ',A2,'min',/)
+
+ if (verbose > 1) write(69,11) mydate(5:6), mydate(7:8), mydate(1:4), &
+ mytime(1:2), mytime(3:4)
+
+ if (verbose > 1) then
+ call clocks_init(mynum)
+ else
+ call clocks_init()
+ endif
+
+ idold = clock_id('Time loop routine')
+ idcomm = clock_id('Assembly/MPI routines')
+ idmpi = clock_id(' > Only MPI routine')
+ idmpiws = clock_id(' > Only solid MPI_WAIT')
+ idmpiwf = clock_id(' > Only fluid MPI_WAIT')
+ idstiff = clock_id('Stiffness routine')
+ idanelst = clock_id(' > Anelastic stiffness routine')
+ idanelts = clock_id('Anelastic time step routine')
+ iddump = clock_id('Dump routine')
+ idnbio = clock_id('Non Blocking IO red light')
+
+end subroutine start_clock
+!-----------------------------------------------------------------------------------------
+
+!-----------------------------------------------------------------------------------------
+subroutine end_clock
+ ! Wapper routine to end timing and display clock informations.
+
+ use data_proc, only : mynum
+
+ implicit none
+
+ if (mynum==0) then
+ write(6,*)
+ write(6,"(10x,'Summary of timing measurements:')")
+ write(6,*)
+ endif
+
+ call clocks_exit(mynum)
+
+ if (mynum==0) write(6,*)
+
+end subroutine end_clock
+!-----------------------------------------------------------------------------------------
+
+!--- END WRAPPER ROUTINES, SPECIFIC TO AXISEM --------------------------------------------
+
+!-----------------------------------------------------------------------------------------
subroutine clocks_init(flag)
!initialize clocks module
!if flag is set, only print if flag=0
@@ -109,10 +175,9 @@ subroutine clocks_init(flag)
return
end subroutine clocks_init
-!-----------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
function clock_id(name)
!return an ID for a new or existing clock
integer :: clock_id
@@ -124,8 +189,8 @@ function clock_id(name)
clock_id = clock_id + 1
if( clock_id.GT.clock_num )then
if( clock_num.EQ.max_clocks )then
- print *, &
- 'CLOCKS ERROR: you are requesting too many clocks, max clocks=', max_clocks
+ print *, 'CLOCKS ERROR: you are requesting too many clocks, max clocks=', &
+ max_clocks
return
else
clock_num = clock_id
@@ -136,10 +201,9 @@ function clock_id(name)
end do
return
end function clock_id
-!-----------------------------------------------------------------------
-
+!-----------------------------------------------------------------------------------------
-!-----------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
function tick( string, id, name, since )
integer :: tick
character(len=*), intent(in), optional :: string
@@ -186,10 +250,9 @@ function tick( string, id, name, since )
return
end function tick
-!-----------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
subroutine get_clock( id, ticks, calls, total_time, time_per_call )
integer, intent(in) :: id
integer, intent(out), optional :: ticks, calls
@@ -207,9 +270,9 @@ subroutine get_clock( id, ticks, calls, total_time, time_per_call )
return
end subroutine get_clock
-!-----------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
-!--------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
subroutine clocks_exit(flag)
!print all cumulative clocks
!if flag is set, only print if flag=0
@@ -242,8 +305,7 @@ subroutine clocks_exit(flag)
return
end subroutine clocks_exit
-!--------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
-!=======================
end module clocks_mod
-!=======================
+!=========================================================================================
diff --git a/SOLVER/data_io.f90 b/SOLVER/data_io.f90
index f370ab3..d21ec5d 100644
--- a/SOLVER/data_io.f90
+++ b/SOLVER/data_io.f90
@@ -77,4 +77,4 @@ module data_io
character(len=80), dimension(:), allocatable :: fname_rec_velo
end module data_io
-!-----------------------------------------------------------------------------------------
+!=========================================================================================
diff --git a/SOLVER/main.f90 b/SOLVER/main.f90
index 1835561..9ed7fbe 100644
--- a/SOLVER/main.f90
+++ b/SOLVER/main.f90
@@ -35,6 +35,7 @@ program axisem
use commun, only : pinit, pend, barrier
use meshes_io, only : finish_xdmf_xml
use data_io, only : verbose
+ use clocks_mod, only : start_clock, end_clock
implicit none
@@ -114,72 +115,7 @@ end program axisem
!-----------------------------------------------------------------------------------------
-subroutine start_clock
- ! Driver routine to start the timing, using the clocks_mod module.
-
- use data_time, only : idcomm, iddump, idmpi, idmpiws, idmpiwf, idnbio, idold, &
- idstiff, idanelts, idanelst
- use data_proc, only : lpr, mynum
- use clocks_mod, only : clock_id, clocks_init
- use data_io, only : verbose
-
- implicit none
-
- character(len=8) :: mydate
- character(len=10) :: mytime
-
- call date_and_time(mydate,mytime)
- if (lpr) write(6,11) mydate(5:6), mydate(7:8), mydate(1:4), mytime(1:2), mytime(3:4)
-
-11 format(' Simulation started on ', A2,'/',A2,'/',A4,' at ', A2,'h ',A2,'min',/)
-
- if (verbose > 1) write(69,11) mydate(5:6), mydate(7:8), mydate(1:4), &
- mytime(1:2), mytime(3:4)
-
- if (verbose > 1) then
- call clocks_init(mynum)
- else
- call clocks_init()
- endif
-
- idold = clock_id('Time loop routine')
- idcomm = clock_id('Assembly/MPI routines')
- idmpi = clock_id(' > Only MPI routine')
- idmpiws = clock_id(' > Only solid MPI_WAIT')
- idmpiwf = clock_id(' > Only fluid MPI_WAIT')
- idstiff = clock_id('Stiffness routine')
- idanelst = clock_id(' > Anelastic stiffness routine')
- idanelts = clock_id('Anelastic time step routine')
- iddump = clock_id('Dump routine')
- idnbio = clock_id('Non Blocking IO red light')
-
-end subroutine start_clock
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-subroutine end_clock
- ! Wapper routine to end timing and display clock informations.
-
- use clocks_mod, only : clocks_exit
- use data_proc, only : mynum
-
- implicit none
-
- if (mynum==0) then
- write(6,*)
- write(6,"(10x,'Summary of timing measurements:')")
- write(6,*)
- endif
-
- call clocks_exit(mynum)
-
- if (mynum==0) write(6,*)
-
-end subroutine end_clock
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-subroutine define_io_appendix(app,iproc)
+subroutine define_io_appendix(app, iproc)
! Defines the 4 digit character string appended to any
! data or io file related to process myid.
More information about the CIG-COMMITS
mailing list