[cig-commits] [commit] master: Use same clocks module in Solver and Mesher (e1e0e04)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Sun Oct 19 01:59:15 PDT 2014
Repository : https://github.com/geodynamics/axisem
On branch : master
Link : https://github.com/geodynamics/axisem/compare/f404e465d87a1c16f432915994bd53e70708631c...e1e0e0477eff45293e3ac8fee6c6c542f2fc5c6d
>---------------------------------------------------------------
commit e1e0e0477eff45293e3ac8fee6c6c542f2fc5c6d
Author: Simon Stähler <staehler at geophysik.uni-muenchen.de>
Date: Sun Oct 19 10:57:37 2014 +0200
Use same clocks module in Solver and Mesher
- Program-specific routines (defining the individual clocks) are moved to clocks_wrapper_*.f90
- Removed kind=4 statements in clocks module and changed to double precision
- Updated Makefiles and main.f90s
>---------------------------------------------------------------
e1e0e0477eff45293e3ac8fee6c6c542f2fc5c6d
MESHER/Makefile.TEMPLATE | 33 +++--
MESHER/clocks.f90 | 80 +++++-----
MESHER/clocks_wrapper_mesher.f90 | 90 +++++++++++
MESHER/main.f90 | 60 +-------
SOLVER/Makefile.TEMPLATE | 37 ++---
SOLVER/clocks.f90 | 312 +--------------------------------------
SOLVER/clocks_wrapper_solver.f90 | 99 +++++++++++++
SOLVER/main.f90 | 36 ++---
8 files changed, 282 insertions(+), 465 deletions(-)
diff --git a/MESHER/Makefile.TEMPLATE b/MESHER/Makefile.TEMPLATE
index aa942ed..535aa65 100644
--- a/MESHER/Makefile.TEMPLATE
+++ b/MESHER/Makefile.TEMPLATE
@@ -4,21 +4,22 @@ include ../make_axisem.macros
SRCS = background_models.F90 test_bkgrdmodel.F90 analytic_mapping.f90 \
analytic_semi_mapping.f90 analytic_spheroid_mapping.f90 clocks.f90 \
- data_bkgrdmodel.f90 data_coarse.f90 data_diag.f90 data_gllmesh.f90 \
- data_grid.f90 data_mesh.f90 data_numbering.f90 data_pdb.f90 \
- data_spec.f90 data_time.f90 discont_meshing.f90 gllmeshgen.f90 \
- global_parameters.f90 input.f90 interpolation.f90 main.f90 \
- mesh_info.f90 meshgen.f90 model_discontinuities.f90 numbering.f90 \
- parallelization.f90 pdb.f90 sorting.f90 splib.f90 subpar_mapping.f90
+ clocks_wrapper_mesher.f90 data_bkgrdmodel.f90 data_coarse.f90 \
+ data_diag.f90 data_gllmesh.f90 data_grid.f90 data_mesh.f90 \
+ data_numbering.f90 data_pdb.f90 data_spec.f90 data_time.f90 \
+ discont_meshing.f90 gllmeshgen.f90 global_parameters.f90 input.f90 \
+ interpolation.f90 main.f90 mesh_info.f90 meshgen.f90 \
+ model_discontinuities.f90 numbering.f90 parallelization.f90 pdb.f90 \
+ sorting.f90 splib.f90 subpar_mapping.f90
OBJS = background_models.o test_bkgrdmodel.o analytic_mapping.o \
analytic_semi_mapping.o analytic_spheroid_mapping.o clocks.o \
- data_bkgrdmodel.o data_coarse.o data_diag.o data_gllmesh.o \
- data_grid.o data_mesh.o data_numbering.o data_pdb.o data_spec.o \
- data_time.o discont_meshing.o gllmeshgen.o global_parameters.o \
- input.o interpolation.o main.o mesh_info.o meshgen.o \
- model_discontinuities.o numbering.o parallelization.o pdb.o sorting.o \
- splib.o subpar_mapping.o
+ clocks_wrapper_mesher.o data_bkgrdmodel.o data_coarse.o data_diag.o \
+ data_gllmesh.o data_grid.o data_mesh.o data_numbering.o data_pdb.o \
+ data_spec.o data_time.o discont_meshing.o gllmeshgen.o \
+ global_parameters.o input.o interpolation.o main.o mesh_info.o \
+ meshgen.o model_discontinuities.o numbering.o parallelization.o pdb.o \
+ sorting.o splib.o subpar_mapping.o
ifeq ($(strip $(USE_NETCDF)),true)
FFLAGS += -Dunc
@@ -61,6 +62,7 @@ analytic_mapping.o: analytic_semi_mapping.o analytic_spheroid_mapping.o \
analytic_semi_mapping.o: global_parameters.o Makefile ../make_axisem.macros
analytic_spheroid_mapping.o: global_parameters.o Makefile ../make_axisem.macros
clocks.o: Makefile ../make_axisem.macros
+clocks_wrapper_mesher.o: clocks.o data_time.o Makefile ../make_axisem.macros
data_bkgrdmodel.o: global_parameters.o Makefile ../make_axisem.macros
data_coarse.o: Makefile ../make_axisem.macros
data_diag.o: Makefile ../make_axisem.macros
@@ -80,9 +82,10 @@ global_parameters.o: Makefile ../make_axisem.macros
input.o: background_models.o data_bkgrdmodel.o data_coarse.o data_diag.o \
data_grid.o data_mesh.o data_spec.o global_parameters.o Makefile ../make_axisem.macros
interpolation.o: global_parameters.o Makefile ../make_axisem.macros
-main.o: clocks.o data_bkgrdmodel.o data_grid.o data_mesh.o data_time.o \
- discont_meshing.o gllmeshgen.o input.o mesh_info.o meshgen.o \
- numbering.o parallelization.o pdb.o test_bkgrdmodel.o Makefile ../make_axisem.macros
+main.o: clocks.o clocks_wrapper_mesher.o data_bkgrdmodel.o data_grid.o \
+ data_mesh.o data_time.o discont_meshing.o gllmeshgen.o input.o \
+ mesh_info.o meshgen.o numbering.o parallelization.o pdb.o \
+ test_bkgrdmodel.o Makefile ../make_axisem.macros
mesh_info.o: data_bkgrdmodel.o data_diag.o data_gllmesh.o data_grid.o \
data_mesh.o data_numbering.o data_spec.o global_parameters.o Makefile ../make_axisem.macros
meshgen.o: analytic_spheroid_mapping.o data_bkgrdmodel.o data_coarse.o \
diff --git a/MESHER/clocks.f90 b/MESHER/clocks.f90
index 1de2753..02dc602 100644
--- a/MESHER/clocks.f90
+++ b/MESHER/clocks.f90
@@ -18,44 +18,37 @@
! 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)
!
-! AUTHOR: V. Balaji (vb at gfdl.gov)
-! SGI/GFDL Princeton University
!
-! This program is free software; you can redistribute it and/or modify
-! it under the terms of the GNU General Public License as published by
-! the Free Software Foundation; either version 2 of the License, or
-! (at your option) any later version.
+! ORIGINAL AUTHOR: V. Balaji (vb at gfdl.gov)
+! SGI/GFDL Princeton University
!
-! This program is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-! GNU General Public License for more details.
+! ADAPTED BY: S. Stähler and M. v. Driel
+! to adhere Fortran 2003 standards
!
-! For the full text of the GNU General Public License,
-! write to: Free Software Foundation, Inc.,
-! 675 Mass Ave, Cambridge, MA 02139, USA.
!-----------------------------------------------------------------------
implicit none
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, parameter :: sp = selected_real_kind(6, 37)
+ integer, parameter :: dp = selected_real_kind(15, 307)
+ integer, parameter :: qp = selected_real_kind(33, 4931)
+
+ integer :: ticks_per_sec, max_ticks, ref_tick, start_tick, end_tick
+ real(kind=dp) :: tick_rate
+ integer, parameter :: max_clocks = 256
+ integer :: clock_num = 0
+ logical :: 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
@@ -65,11 +58,12 @@ module clocks_mod
public :: clocks_init, clocks_exit, get_clock, clock_id, tick
character(len=256), private :: &
- version = '$Id: clocks.F90,v 2.2 2001/02/14 19:06:12 vb Exp $'
+ version = 'Clocks.F90,v 3.0 2014/10/19'
contains
-!-----------------------------------------------------------------------
+
+!-----------------------------------------------------------------------------------------
subroutine clocks_init(flag)
!initialize clocks module
!if flag is set, only print if flag=0
@@ -109,10 +103,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 +117,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 +129,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,14 +178,13 @@ 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
- real(kind=4), intent(out), optional :: total_time, time_per_call
+ integer, intent(in) :: id
+ integer, intent(out), optional :: ticks, calls
+ real(kind=dp), intent(out), optional :: total_time, time_per_call
if( 0.LT.id .AND. id.LE.max_clocks )then
if( PRESENT(ticks) )ticks = clocks(id)%ticks
@@ -207,19 +198,19 @@ 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
!for instance, flag could be set to pe number by the calling program
!to have only PE 0 print clocks
integer, intent(in), optional :: flag
- integer :: i
+ integer :: i
!total_time is for one clock
!cumul_time is total measured time between clocks_init and clocks_exit
- real(kind=4) :: total_time, time_per_call, cumul_time
+ real(kind=dp) :: total_time, time_per_call, cumul_time
if( PRESENT(flag) )then
if( flag.NE.0 )return
@@ -242,8 +233,7 @@ subroutine clocks_exit(flag)
return
end subroutine clocks_exit
-!--------------------------------------------------------------------
+!-----------------------------------------------------------------------------------------
-!=======================
end module clocks_mod
-!=======================
+!=========================================================================================
diff --git a/MESHER/clocks_wrapper_mesher.f90 b/MESHER/clocks_wrapper_mesher.f90
new file mode 100644
index 0000000..5d514c4
--- /dev/null
+++ b/MESHER/clocks_wrapper_mesher.f90
@@ -0,0 +1,90 @@
+!
+! Copyright 2013, Tarje Nissen-Meyer, Alexandre Fournier, Martin van Driel
+! Simon Stähler, Kasra Hosseini, Stefanie Hempel
+!
+! This file is part of AxiSEM.
+! It is distributed from the webpage <http://www.axisem.info>
+!
+! AxiSEM is free software: you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation, either version 3 of the License, or
+! (at your option) any later version.
+!
+! AxiSEM is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with AxiSEM. If not, see <http://www.gnu.org/licenses/>.
+!
+!=========================================================================================
+!> Module to do the MESHER-specific initialization of the clocks module
+!! i.e. defining the MESHER-specific clocks
+module clocks_wrapper_mesher
+
+ implicit none
+ private
+
+ public :: start_clock, end_clock
+
+contains
+
+!-----------------------------------------------------------------------------------------
+!> Driver routine to start the timing, using the clocks_mod module.
+subroutine start_clock
+
+ use data_time
+ use clocks_mod, only : clock_id, clocks_init
+
+ implicit none
+
+ character(len=8) :: mydate
+ character(len=10) :: mytime
+
+ call date_and_time(mydate,mytime)
+ write(6,11) mydate(5:6), mydate(7:8), mydate(1:4), mytime(1:2), mytime(3:4)
+
+11 format(' Meshing started on ', A2,'/',A2,'/',A4,' at ', A2,'h ',A2,'min',/)
+
+
+ call clocks_init(0)
+
+ idold01 = clock_id('mergesort')
+ idold05 = clock_id('mergesort - ind')
+ idold02 = clock_id('generate_skeleton')
+ idold03 = clock_id('create_gllmesh')
+ idold04 = clock_id('define_global_global_numbering')
+ idold06 = clock_id('bkgrdmodel_testing')
+ idold08 = clock_id('glob-slob/flob numbering')
+ idold07 = clock_id('get_global no loop')
+ idold09 = clock_id('get_global in loop')
+ idold11 = clock_id('create_pdb')
+
+ idold12 = clock_id('define_glocal_numbering')
+ idold13 = clock_id('define_sflocal_numbering')
+ idold14 = clock_id('generate_serendipity_per_proc')
+
+end subroutine start_clock
+!-----------------------------------------------------------------------------------------
+
+!-----------------------------------------------------------------------------------------
+!> Wapper routine to end timing and display clock informations.
+subroutine end_clock
+
+ use clocks_mod, only : clocks_exit
+
+ implicit none
+
+ write(6,*)
+ write(6,"(10x,'Summary of timing measurements:')")
+ write(6,*)
+
+ call clocks_exit(0)
+
+
+end subroutine end_clock
+!-----------------------------------------------------------------------------------------
+
+end module clocks_wrapper_mesher
+!=========================================================================================
diff --git a/MESHER/main.f90 b/MESHER/main.f90
index ba72562..660d59e 100644
--- a/MESHER/main.f90
+++ b/MESHER/main.f90
@@ -37,7 +37,8 @@ program gllmesh
use data_mesh
use data_time
- use clocks_mod
+ use clocks_mod, only: tick
+ use clocks_wrapper_mesher, only: start_clock, end_clock
implicit none
@@ -116,61 +117,4 @@ program gllmesh
write(6,*)'....DONE WITH MESHER !'
end program gllmesh
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-subroutine start_clock
- ! Driver routine to start the timing, using the clocks_mod module.
-
- use data_time
- use clocks_mod, only : clock_id, clocks_init
-
- implicit none
-
- character(len=8) :: mydate
- character(len=10) :: mytime
-
- call date_and_time(mydate,mytime)
- write(6,11) mydate(5:6), mydate(7:8), mydate(1:4), mytime(1:2), mytime(3:4)
-
-11 format(' Meshing started on ', A2,'/',A2,'/',A4,' at ', A2,'h ',A2,'min',/)
-
-
- call clocks_init(0)
-
- idold01 = clock_id('mergesort')
- idold05 = clock_id('mergesort - ind')
- idold02 = clock_id('generate_skeleton')
- idold03 = clock_id('create_gllmesh')
- idold04 = clock_id('define_global_global_numbering')
- idold06 = clock_id('bkgrdmodel_testing')
- idold08 = clock_id('glob-slob/flob numbering')
- idold07 = clock_id('get_global no loop')
- idold09 = clock_id('get_global in loop')
- idold11 = clock_id('create_pdb')
-
- idold12 = clock_id('define_glocal_numbering')
- idold13 = clock_id('define_sflocal_numbering')
- idold14 = clock_id('generate_serendipity_per_proc')
-
-end subroutine start_clock
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-subroutine end_clock
- ! Wapper routine to end timing and display clock informations.
-
- use clocks_mod, only : clocks_exit
-
- implicit none
-
- write(6,*)
- write(6,"(10x,'Summary of timing measurements:')")
- write(6,*)
-
- call clocks_exit(0)
-
- write(6,*)
-
-end subroutine end_clock
!=========================================================================================
diff --git a/SOLVER/Makefile.TEMPLATE b/SOLVER/Makefile.TEMPLATE
index 689f286..66b0a02 100644
--- a/SOLVER/Makefile.TEMPLATE
+++ b/SOLVER/Makefile.TEMPLATE
@@ -7,11 +7,11 @@ SRCS = background_models.F90 commpi.F90 commun.F90 get_model.F90 \
nc_routines.F90 nc_snapshots.F90 parameters.F90 time_evol_wave.F90 \
analytic_mapping.f90 analytic_semi_mapping.f90 \
analytic_spheroid_mapping.f90 apply_masks.f90 attenuation.f90 \
- clocks.f90 data_comm.f90 data_heterogeneous.f90 data_io.f90 \
- data_matr.f90 data_mesh.f90 data_pointwise.f90 data_proc.f90 \
- data_source.f90 data_spec.f90 data_time.f90 def_grid.f90 \
- def_precomp_terms.f90 get_mesh.f90 global_parameters.f90 \
- interpolation.f90 kdtree2.f90 list.f90 main.f90 \
+ clocks.f90 clocks_wrapper_solver.f90 data_comm.f90 \
+ data_heterogeneous.f90 data_io.f90 data_matr.f90 data_mesh.f90 \
+ data_pointwise.f90 data_proc.f90 data_source.f90 data_spec.f90 \
+ data_time.f90 def_grid.f90 def_precomp_terms.f90 get_mesh.f90 \
+ global_parameters.f90 interpolation.f90 kdtree2.f90 list.f90 main.f90 \
pointwise_derivatives.f90 rotations.f90 seismograms.f90 source.f90 \
stiffness_di.f90 stiffness_fluid.f90 stiffness_mono.f90 \
stiffness_quad.f90 subpar_mapping.f90 unrolled_loops.f90 utlity.f90 \
@@ -21,14 +21,14 @@ OBJS = background_models.o commpi.o commun.o get_model.o \
lateral_heterogeneities.o meshes_io.o nc_helpers.o nc_routines.o \
nc_snapshots.o parameters.o time_evol_wave.o analytic_mapping.o \
analytic_semi_mapping.o analytic_spheroid_mapping.o apply_masks.o \
- attenuation.o clocks.o data_comm.o data_heterogeneous.o data_io.o \
- data_matr.o data_mesh.o data_pointwise.o data_proc.o data_source.o \
- data_spec.o data_time.o def_grid.o def_precomp_terms.o get_mesh.o \
- global_parameters.o interpolation.o kdtree2.o list.o main.o \
- pointwise_derivatives.o rotations.o seismograms.o source.o \
- stiffness_di.o stiffness_fluid.o stiffness_mono.o stiffness_quad.o \
- subpar_mapping.o unrolled_loops.o utlity.o wavefields_io.o ftz.o \
- pthread.o
+ attenuation.o clocks.o clocks_wrapper_solver.o data_comm.o \
+ data_heterogeneous.o data_io.o data_matr.o data_mesh.o \
+ data_pointwise.o data_proc.o data_source.o data_spec.o data_time.o \
+ def_grid.o def_precomp_terms.o get_mesh.o global_parameters.o \
+ interpolation.o kdtree2.o list.o main.o pointwise_derivatives.o \
+ rotations.o seismograms.o source.o stiffness_di.o stiffness_fluid.o \
+ stiffness_mono.o stiffness_quad.o subpar_mapping.o unrolled_loops.o \
+ utlity.o wavefields_io.o ftz.o pthread.o
ifeq ($(strip $(USE_NETCDF)),true)
FFLAGS += -Denable_netcdf
@@ -96,7 +96,8 @@ apply_masks.o: global_parameters.o Makefile ../make_axisem.macros
attenuation.o: analytic_mapping.o commun.o data_io.o data_matr.o data_mesh.o \
data_pointwise.o data_proc.o data_source.o data_spec.o data_time.o \
get_mesh.o global_parameters.o pointwise_derivatives.o utlity.o Makefile ../make_axisem.macros
-clocks.o: data_io.o data_proc.o data_time.o Makefile ../make_axisem.macros
+clocks.o: Makefile ../make_axisem.macros
+clocks_wrapper_solver.o: clocks.o data_io.o data_proc.o data_time.o Makefile ../make_axisem.macros
data_comm.o: global_parameters.o list.o Makefile ../make_axisem.macros
data_heterogeneous.o: global_parameters.o Makefile ../make_axisem.macros
data_io.o: global_parameters.o Makefile ../make_axisem.macros
@@ -119,9 +120,9 @@ get_mesh.o: background_models.o commun.o data_comm.o data_io.o data_mesh.o \
global_parameters.o: Makefile ../make_axisem.macros
interpolation.o: global_parameters.o Makefile ../make_axisem.macros
list.o: global_parameters.o Makefile ../make_axisem.macros
-main.o: clocks.o commun.o data_io.o data_mesh.o data_proc.o data_source.o \
- def_grid.o get_mesh.o meshes_io.o nc_routines.o nc_snapshots.o \
- parameters.o time_evol_wave.o Makefile ../make_axisem.macros
+main.o: clocks_wrapper_solver.o commun.o data_io.o data_mesh.o data_proc.o \
+ data_source.o def_grid.o get_mesh.o meshes_io.o nc_routines.o \
+ nc_snapshots.o parameters.o time_evol_wave.o Makefile ../make_axisem.macros
pointwise_derivatives.o: data_mesh.o data_pointwise.o data_spec.o \
global_parameters.o unrolled_loops.o Makefile ../make_axisem.macros
rotations.o: data_io.o data_mesh.o data_proc.o data_source.o \
@@ -146,7 +147,7 @@ wavefields_io.o: data_io.o data_mesh.o data_pointwise.o data_proc.o \
data_source.o global_parameters.o nc_routines.o nc_snapshots.o \
pointwise_derivatives.o Makefile ../make_axisem.macros
background_models.o: data_proc.o global_parameters.o interpolation.o Makefile ../make_axisem.macros
-commpi.o: clocks.o data_comm.o data_io.o data_mesh.o data_proc.o data_time.o \
+commpi.o: clocks.o data_comm.o data_mesh.o data_proc.o data_time.o \
global_parameters.o list.o Makefile ../make_axisem.macros
commun.o: clocks.o commpi.o data_io.o data_mesh.o data_proc.o data_time.o \
global_parameters.o Makefile ../make_axisem.macros
diff --git a/SOLVER/clocks.f90 b/SOLVER/clocks.f90
deleted file mode 100644
index a7cae53..0000000
--- a/SOLVER/clocks.f90
+++ /dev/null
@@ -1,311 +0,0 @@
-!
-! Copyright 2013, Tarje Nissen-Meyer, Alexandre Fournier, Martin van Driel
-! Simon Stähler, Kasra Hosseini, Stefanie Hempel
-!
-! This file is part of AxiSEM.
-! It is distributed from the webpage <http://www.axisem.info>
-!
-! AxiSEM is free software: you can redistribute it and/or modify
-! it under the terms of the GNU General Public License as published by
-! the Free Software Foundation, either version 3 of the License, or
-! (at your option) any later version.
-!
-! AxiSEM is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-! GNU General Public License for more details.
-!
-! 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)
-!
-! AUTHOR: V. Balaji (vb at gfdl.gov)
-! SGI/GFDL Princeton University
-!
-! This program is free software; you can redistribute it and/or modify
-! it under the terms of the GNU General Public License as published by
-! the Free Software Foundation; either version 2 of the License, or
-! (at your option) any later version.
-!
-! This program is distributed in the hope that it will be useful,
-! but WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-! GNU General Public License for more details.
-!
-! For the full text of the GNU General Public License,
-! write to: Free Software Foundation, Inc.,
-! 675 Mass Ave, Cambridge, MA 02139, USA.
-!-----------------------------------------------------------------------
-
- implicit none
-
- private
-
- 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 :: clock
- character(len=32) :: name
- integer :: ticks, calls
- end type clock
-
- 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
- !for instance, flag could be set to pe number by the calling program
- !to have only PE 0 in a parallel run print clocks
- integer, intent(in), optional :: flag
- integer :: i
- logical :: verbose
-
- verbose = .FALSE.
-
- if( PRESENT(flag) ) verbose = flag.EQ.0
-
- if( clocks_initialized ) return
- clocks_initialized = .TRUE.
-
- !initialize clocks and reference tick
- call system_clock( ref_tick, ticks_per_sec, max_ticks )
- tick_rate = 1./ticks_per_sec
- start_tick = ref_tick
- if( verbose )then
- write(6,*) ' CLOCKS module '//trim(version)
- write(6,*) ' Realtime clock resolution=', tick_rate, '(', &
- ticks_per_sec, ' ticks/sec)'
- end if
-
- !default clock name is Clock001, etc
-
- if( verbose ) then
- do i = 1,max_clocks
- write( clocks(i)%name,"(a5,i3.3)") 'Clock', i
- end do
- end if
-
- clocks%ticks = 0
- clocks%calls = 0
-
- return
-end subroutine clocks_init
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-function clock_id(name)
- !return an ID for a new or existing clock
- integer :: clock_id
- character(len=*), intent(in) :: name
-
- if( .NOT.clocks_initialized ) call clocks_init()
- clock_id = 0
- do while( trim(name).NE.trim(clocks(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
- return
- else
- clock_num = clock_id
- clocks(clock_id)%name = name
- return
- end if
- end if
- end do
- return
-end function clock_id
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-function tick( string, id, name, since )
- integer :: tick
- character(len=*), intent(in), optional :: string
- character(len=*), intent(in), optional :: name
- integer, intent(in), optional :: id, since
- integer :: current_tick, nid
-
- !take time first, so that this routine's overhead isn't included
- call system_clock(current_tick)
- if( .NOT.clocks_initialized )call clocks_init()
-
- !ref_tick is the clock value at the last call to tick (or clocks_init)
- !unless superseded by the since argument.
- if( PRESENT(since) )ref_tick = since
-
- !correct ref_tick in the unlikely event of clock rollover
- if( current_tick.LT.ref_tick )ref_tick = ref_tick - max_ticks
-
- if( PRESENT(string) )then
- !print time since reference tick
- print '(a,f14.6)', &
- 'CLOCKS: '//trim(string), (current_tick-ref_tick)*tick_rate
- else if( PRESENT(id) )then
- !accumulate time on clock id
- if( 0.LT.id .AND. id.LE.max_clocks )then
- clocks(id)%ticks = clocks(id)%ticks + current_tick - ref_tick
- clocks(id)%calls = clocks(id)%calls + 1
- else
- print *, 'CLOCKS ERROR: invalid id=', id
- end if
- else if( PRESENT(name) )then
- nid = clock_id(name)
- !accumulate time on clock id
- if( 0.LT.nid .AND. nid.LE.max_clocks )then
- clocks(nid)%ticks = clocks(nid)%ticks + current_tick - ref_tick
- clocks(nid)%calls = clocks(nid)%calls + 1
- else
- print *, 'CLOCKS ERROR: invalid id=', nid
- end if
- end if
- !reset reference tick
- call system_clock(ref_tick)
- tick = ref_tick
-
- 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
- real(kind=4), intent(out), optional :: total_time, time_per_call
-
- if( 0.LT.id .AND. id.LE.max_clocks )then
- if( PRESENT(ticks) )ticks = clocks(id)%ticks
- if( PRESENT(calls) )calls = clocks(id)%calls
- if( PRESENT(total_time) )total_time = clocks(id)%ticks*tick_rate
- if( PRESENT(time_per_call) )time_per_call = &
- clocks(id)%ticks*tick_rate/clocks(id)%calls
- else
- print *, 'CLOCKS ERROR: invalid id=', id
- end if
-
- return
-end subroutine get_clock
-!-----------------------------------------------------------------------------------------
-
-!-----------------------------------------------------------------------------------------
-subroutine clocks_exit(flag)
- !print all cumulative clocks
- !if flag is set, only print if flag=0
- !for instance, flag could be set to pe number by the calling program
- !to have only PE 0 print clocks
- integer, intent(in), optional :: flag
- integer :: i
- !total_time is for one clock
- !cumul_time is total measured time between clocks_init and clocks_exit
- real(kind=4) :: total_time, time_per_call, cumul_time
-
- if( PRESENT(flag) )then
- if( flag.NE.0 )return
- end if
-
- call system_clock(end_tick)
- cumul_time = (end_tick-start_tick)*tick_rate
- write(6,"(32x,a)") ' calls t_call t_total t_frac'
- do i = 1, max_clocks
- if( clocks(i)%calls.NE.0 )then
- total_time = clocks(i)%ticks*tick_rate
- time_per_call = total_time/clocks(i)%calls
- write(6,"(a40,i8,2f14.6,f7.3)") &
- 'CLOCKS: '//clocks(i)%name, &
- clocks(i)%calls, time_per_call, total_time, total_time/cumul_time
- end if
- end do
- write(6,"(a,f14.6)") 'CLOCKS: Total measured time: ', cumul_time
-
- return
-
-end subroutine clocks_exit
-!-----------------------------------------------------------------------------------------
-
-end module clocks_mod
-!=========================================================================================
diff --git a/SOLVER/clocks.f90 b/SOLVER/clocks.f90
new file mode 120000
index 0000000..7be24cb
--- /dev/null
+++ b/SOLVER/clocks.f90
@@ -0,0 +1 @@
+../MESHER/clocks.f90
\ No newline at end of file
diff --git a/SOLVER/clocks_wrapper_solver.f90 b/SOLVER/clocks_wrapper_solver.f90
new file mode 100644
index 0000000..dea5911
--- /dev/null
+++ b/SOLVER/clocks_wrapper_solver.f90
@@ -0,0 +1,99 @@
+!
+! Copyright 2013, Tarje Nissen-Meyer, Alexandre Fournier, Martin van Driel
+! Simon Stähler, Kasra Hosseini, Stefanie Hempel
+!
+! This file is part of AxiSEM.
+! It is distributed from the webpage <http://www.axisem.info>
+!
+! AxiSEM is free software: you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation, either version 3 of the License, or
+! (at your option) any later version.
+!
+! AxiSEM is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with AxiSEM. If not, see <http://www.gnu.org/licenses/>.
+!
+!=========================================================================================
+!> Module to do the SOLVER-specific initialization of the clocks module
+!! i.e. defining the SOLVER-specific clocks
+module clocks_wrapper_solver
+
+ implicit none
+ private
+
+ public :: start_clock, end_clock
+
+contains
+
+!-----------------------------------------------------------------------------------------
+!> Driver routine to start the timing, using the clocks_mod module.
+subroutine start_clock
+
+ use clocks_mod, only : clocks_init, clock_id
+ 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
+!-----------------------------------------------------------------------------------------
+
+!-----------------------------------------------------------------------------------------
+!> Wapper routine to end timing and display clock informations.
+subroutine end_clock
+
+ 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
+!-----------------------------------------------------------------------------------------
+
+end module clocks_wrapper_solver
+!=========================================================================================
diff --git a/SOLVER/main.f90 b/SOLVER/main.f90
index 4a35db3..9a3550b 100644
--- a/SOLVER/main.f90
+++ b/SOLVER/main.f90
@@ -22,21 +22,21 @@
!=========================================================================================
program axisem
- use data_proc, only : nproc, mynum, appnproc, appmynum, lpr, procstrg
- use data_io, only : dump_xdmf, use_netcdf, verbose
- use nc_routines, only : nc_end_output, nc_finish_prepare
- use nc_snapshots, only : nc_close_snapfile
- use data_source, only : isim
- use data_mesh, only : do_mesh_tests
- use parameters, only : open_local_output_file, readin_parameters, &
- read_inparam_basic_verbosity
- use get_mesh, only : read_db
- use def_grid, only : init_grid, mesh_tests, deallocate_preloop_arrays
- use time_evol_wave, only : prepare_waves, time_loop
- use commun, only : pinit, pend, barrier
- use meshes_io, only : finish_xdmf_xml
- use data_io, only : verbose, define_io_appendix
- use clocks_mod, only : start_clock, end_clock
+ use data_proc, only : nproc, mynum, appnproc, appmynum, lpr, procstrg
+ use data_io, only : dump_xdmf, use_netcdf, verbose
+ use nc_routines, only : nc_end_output, nc_finish_prepare
+ use nc_snapshots, only : nc_close_snapfile
+ use data_source, only : isim
+ use data_mesh, only : do_mesh_tests
+ use parameters, only : open_local_output_file, readin_parameters, &
+ read_inparam_basic_verbosity
+ use get_mesh, only : read_db
+ use def_grid, only : init_grid, mesh_tests, deallocate_preloop_arrays
+ use time_evol_wave, only : prepare_waves, time_loop
+ use commun, only : pinit, pend, barrier
+ use meshes_io, only : finish_xdmf_xml
+ use data_io, only : verbose, define_io_appendix
+ use clocks_wrapper_solver, only : start_clock, end_clock
implicit none
@@ -49,7 +49,7 @@ program axisem
call define_io_appendix(appnproc, nproc)
call open_local_output_file ! parameters, open file for processor-specific screen output
- call start_clock !clocks
+ call start_clock !clocks_wrapper_solver
if (lpr .and. verbose >= 1) &
write(6,*) 'MAIN: Reading parameters..................................'
@@ -103,11 +103,11 @@ program axisem
call nc_close_snapfile ! nc_snapshots
endif
- call end_clock ! clocks
+ call end_clock ! clocks_wrapper_solver
call pend ! commun
- if(lpr) write(6,*) '=========PROGRAM axisem FINISHED============='
+ if (lpr) write(6,*) '=========PROGRAM axisem FINISHED============='
if (verbose > 1) write(69,*) '=========PROGRAM axisem FINISHED============='
end program axisem
More information about the CIG-COMMITS
mailing list