times.f90 Source File


This file depends on

sourcefile~~times.f90~~EfferentGraph sourcefile~times.f90 times.f90 sourcefile~parallel_lmdz.f90 parallel_lmdz.F90 sourcefile~times.f90->sourcefile~parallel_lmdz.f90 sourcefile~paramet_mod_h.f90 paramet_mod_h.f90 sourcefile~times.f90->sourcefile~paramet_mod_h.f90 sourcefile~lmdz_mpi.f90 lmdz_mpi.F90 sourcefile~times.f90->sourcefile~lmdz_mpi.f90 sourcefile~parallel_lmdz.f90->sourcefile~paramet_mod_h.f90 sourcefile~parallel_lmdz.f90->sourcefile~lmdz_mpi.f90 sourcefile~vampir.f90 vampir.F90 sourcefile~parallel_lmdz.f90->sourcefile~vampir.f90 sourcefile~mod_const_mpi.f90 mod_const_mpi.f90 sourcefile~parallel_lmdz.f90->sourcefile~mod_const_mpi.f90 sourcefile~iniprint_mod_h.f90 iniprint_mod_h.f90 sourcefile~parallel_lmdz.f90->sourcefile~iniprint_mod_h.f90 sourcefile~control_mod.f90 control_mod.f90 sourcefile~parallel_lmdz.f90->sourcefile~control_mod.f90 sourcefile~wxios_mod.f90 wxios_mod.F90 sourcefile~parallel_lmdz.f90->sourcefile~wxios_mod.f90 sourcefile~wxios_mod.f90->sourcefile~iniprint_mod_h.f90 sourcefile~lmdz_xios.f90 lmdz_xios.F90 sourcefile~wxios_mod.f90->sourcefile~lmdz_xios.f90 sourcefile~dimphy.f90 dimphy.f90 sourcefile~wxios_mod.f90->sourcefile~dimphy.f90 sourcefile~mod_phys_lmdz_para.f90 mod_phys_lmdz_para.f90 sourcefile~wxios_mod.f90->sourcefile~mod_phys_lmdz_para.f90 sourcefile~geometry_mod.f90 geometry_mod.f90 sourcefile~wxios_mod.f90->sourcefile~geometry_mod.f90 sourcefile~mod_phys_lmdz_mpi_data.f90 mod_phys_lmdz_mpi_data.f90 sourcefile~wxios_mod.f90->sourcefile~mod_phys_lmdz_mpi_data.f90 sourcefile~infotrac_phy.f90 infotrac_phy.F90 sourcefile~wxios_mod.f90->sourcefile~infotrac_phy.f90 sourcefile~strings_mod.f90 strings_mod.f90 sourcefile~wxios_mod.f90->sourcefile~strings_mod.f90 sourcefile~print_control_mod.f90 print_control_mod.f90 sourcefile~wxios_mod.f90->sourcefile~print_control_mod.f90 sourcefile~mod_phys_lmdz_transfert_para.f90 mod_phys_lmdz_transfert_para.f90 sourcefile~wxios_mod.f90->sourcefile~mod_phys_lmdz_transfert_para.f90 sourcefile~mod_grid_phy_lmdz.f90 mod_grid_phy_lmdz.f90 sourcefile~wxios_mod.f90->sourcefile~mod_grid_phy_lmdz.f90 sourcefile~nrtype.f90 nrtype.f90 sourcefile~wxios_mod.f90->sourcefile~nrtype.f90 sourcefile~ioipsl_getin_p_mod.f90 ioipsl_getin_p_mod.f90 sourcefile~wxios_mod.f90->sourcefile~ioipsl_getin_p_mod.f90 sourcefile~mod_phys_lmdz_para.f90->sourcefile~mod_phys_lmdz_mpi_data.f90 sourcefile~mod_phys_lmdz_para.f90->sourcefile~print_control_mod.f90 sourcefile~mod_phys_lmdz_para.f90->sourcefile~mod_phys_lmdz_transfert_para.f90 sourcefile~mod_phys_lmdz_para.f90->sourcefile~mod_grid_phy_lmdz.f90 sourcefile~mod_phys_lmdz_omp_data.f90 mod_phys_lmdz_omp_data.F90 sourcefile~mod_phys_lmdz_para.f90->sourcefile~mod_phys_lmdz_omp_data.f90 sourcefile~geometry_mod.f90->sourcefile~mod_grid_phy_lmdz.f90 sourcefile~geometry_mod.f90->sourcefile~nrtype.f90 sourcefile~mod_phys_lmdz_mpi_data.f90->sourcefile~lmdz_mpi.f90 sourcefile~mod_phys_lmdz_mpi_data.f90->sourcefile~print_control_mod.f90 sourcefile~lmdz_cppkeys_wrapper.f90 lmdz_cppkeys_wrapper.F90 sourcefile~mod_phys_lmdz_mpi_data.f90->sourcefile~lmdz_cppkeys_wrapper.f90 sourcefile~infotrac_phy.f90->sourcefile~iniprint_mod_h.f90 sourcefile~infotrac_phy.f90->sourcefile~mod_phys_lmdz_para.f90 sourcefile~infotrac_phy.f90->sourcefile~strings_mod.f90 sourcefile~infotrac_phy.f90->sourcefile~ioipsl_getin_p_mod.f90 sourcefile~infotrac_phy.f90->sourcefile~lmdz_cppkeys_wrapper.f90 sourcefile~readtracfiles_mod.f90 readTracFiles_mod.f90 sourcefile~infotrac_phy.f90->sourcefile~readtracfiles_mod.f90 sourcefile~lmdz_reprobus_wrappers.f90 lmdz_reprobus_wrappers.F90 sourcefile~infotrac_phy.f90->sourcefile~lmdz_reprobus_wrappers.f90 sourcefile~mod_phys_lmdz_transfert_para.f90->sourcefile~mod_phys_lmdz_mpi_data.f90 sourcefile~mod_phys_lmdz_omp_transfert.f90 mod_phys_lmdz_omp_transfert.f90 sourcefile~mod_phys_lmdz_transfert_para.f90->sourcefile~mod_phys_lmdz_omp_transfert.f90 sourcefile~mod_phys_lmdz_mpi_transfert.f90 mod_phys_lmdz_mpi_transfert.f90 sourcefile~mod_phys_lmdz_transfert_para.f90->sourcefile~mod_phys_lmdz_mpi_transfert.f90 sourcefile~ioipsl_getin_p_mod.f90->sourcefile~mod_phys_lmdz_para.f90 sourcefile~ioipsl_getin_p_mod.f90->sourcefile~strings_mod.f90 sourcefile~ioipsl_getin_p_mod.f90->sourcefile~mod_phys_lmdz_transfert_para.f90 sourcefile~mod_phys_lmdz_omp_transfert.f90->sourcefile~mod_phys_lmdz_mpi_data.f90 sourcefile~mod_phys_lmdz_omp_transfert.f90->sourcefile~mod_phys_lmdz_omp_data.f90 sourcefile~mod_phys_lmdz_mpi_transfert.f90->sourcefile~lmdz_mpi.f90 sourcefile~mod_phys_lmdz_mpi_transfert.f90->sourcefile~mod_phys_lmdz_mpi_data.f90 sourcefile~mod_phys_lmdz_mpi_transfert.f90->sourcefile~mod_grid_phy_lmdz.f90 sourcefile~readtracfiles_mod.f90->sourcefile~strings_mod.f90 sourcefile~readtracfiles_mod.f90->sourcefile~ioipsl_getin_p_mod.f90 sourcefile~lmdz_reprobus_wrappers.f90->sourcefile~mod_grid_phy_lmdz.f90 sourcefile~mod_phys_lmdz_omp_data.f90->sourcefile~dimphy.f90 sourcefile~mod_phys_lmdz_omp_data.f90->sourcefile~mod_phys_lmdz_mpi_data.f90 sourcefile~mod_phys_lmdz_omp_data.f90->sourcefile~print_control_mod.f90

Files dependent on this one

sourcefile~~times.f90~~AfferentGraph sourcefile~times.f90 times.f90 sourcefile~call_calfis_mod.f90 call_calfis_mod.f90 sourcefile~call_calfis_mod.f90->sourcefile~times.f90 sourcefile~bands.f90 bands.f90 sourcefile~call_calfis_mod.f90->sourcefile~bands.f90 sourcefile~caladvtrac_loc.f90 caladvtrac_loc.f90 sourcefile~caladvtrac_loc.f90->sourcefile~times.f90 sourcefile~caladvtrac_loc.f90->sourcefile~bands.f90 sourcefile~caladvtrac_mod.f90 caladvtrac_mod.f90 sourcefile~caladvtrac_loc.f90->sourcefile~caladvtrac_mod.f90 sourcefile~gradiv2_loc.f90 gradiv2_loc.f90 sourcefile~gradiv2_loc.f90->sourcefile~times.f90 sourcefile~gradiv2_mod.f90 gradiv2_mod.f90 sourcefile~gradiv2_loc.f90->sourcefile~gradiv2_mod.f90 sourcefile~nxgraro2_loc.f90 nxgraro2_loc.f90 sourcefile~nxgraro2_loc.f90->sourcefile~times.f90 sourcefile~nxgraro2_mod.f90 nxgraro2_mod.f90 sourcefile~nxgraro2_loc.f90->sourcefile~nxgraro2_mod.f90 sourcefile~fluxstokenc_p.f90 fluxstokenc_p.f90 sourcefile~fluxstokenc_p.f90->sourcefile~times.f90 sourcefile~fluxstokenc_p.f90->sourcefile~bands.f90 sourcefile~fluxstokenc_p.f90->sourcefile~caladvtrac_mod.f90 sourcefile~advtrac_loc.f90 advtrac_loc.f90 sourcefile~advtrac_loc.f90->sourcefile~times.f90 sourcefile~advtrac_loc.f90->sourcefile~bands.f90 sourcefile~advtrac_mod.f90 advtrac_mod.f90 sourcefile~advtrac_loc.f90->sourcefile~advtrac_mod.f90 sourcefile~call_dissip_mod.f90 call_dissip_mod.f90 sourcefile~call_dissip_mod.f90->sourcefile~times.f90 sourcefile~call_dissip_mod.f90->sourcefile~bands.f90 sourcefile~dissip_mod.f90 dissip_mod.f90 sourcefile~call_dissip_mod.f90->sourcefile~dissip_mod.f90 sourcefile~divgrad2_loc.f90 divgrad2_loc.f90 sourcefile~divgrad2_loc.f90->sourcefile~times.f90 sourcefile~divgrad2_mod.f90 divgrad2_mod.f90 sourcefile~divgrad2_loc.f90->sourcefile~divgrad2_mod.f90 sourcefile~bands.f90->sourcefile~times.f90 sourcefile~leapfrog_loc.f90 leapfrog_loc.f90 sourcefile~leapfrog_loc.f90->sourcefile~times.f90 sourcefile~leapfrog_loc.f90->sourcefile~call_calfis_mod.f90 sourcefile~leapfrog_loc.f90->sourcefile~call_dissip_mod.f90 sourcefile~leapfrog_loc.f90->sourcefile~bands.f90 sourcefile~leapfrog_mod.f90 leapfrog_mod.f90 sourcefile~leapfrog_loc.f90->sourcefile~leapfrog_mod.f90 sourcefile~guide_loc_mod.f90 guide_loc_mod.f90 sourcefile~leapfrog_loc.f90->sourcefile~guide_loc_mod.f90 sourcefile~leapfrog_mod.f90->sourcefile~call_calfis_mod.f90 sourcefile~leapfrog_mod.f90->sourcefile~call_dissip_mod.f90 sourcefile~leapfrog_mod.f90->sourcefile~bands.f90 sourcefile~leapfrog_mod.f90->sourcefile~caladvtrac_mod.f90 sourcefile~integrd_mod.f90 integrd_mod.f90 sourcefile~leapfrog_mod.f90->sourcefile~integrd_mod.f90 sourcefile~caldyn_mod.f90 caldyn_mod.f90 sourcefile~leapfrog_mod.f90->sourcefile~caldyn_mod.f90 sourcefile~advtrac_mod.f90->sourcefile~bands.f90 sourcefile~vlspltgen_mod.f90 vlspltgen_mod.f90 sourcefile~advtrac_mod.f90->sourcefile~vlspltgen_mod.f90 sourcefile~vlz_mod.f90 vlz_mod.f90 sourcefile~vlz_mod.f90->sourcefile~bands.f90 sourcefile~caladvtrac_mod.f90->sourcefile~bands.f90 sourcefile~caladvtrac_mod.f90->sourcefile~advtrac_mod.f90 sourcefile~groupe_mod.f90 groupe_mod.f90 sourcefile~caladvtrac_mod.f90->sourcefile~groupe_mod.f90 sourcefile~integrd_mod.f90->sourcefile~bands.f90 sourcefile~advect_new_mod.f90 advect_new_mod.f90 sourcefile~integrd_mod.f90->sourcefile~advect_new_mod.f90 sourcefile~nxgraro2_mod.f90->sourcefile~bands.f90 sourcefile~gradiv2_mod.f90->sourcefile~bands.f90 sourcefile~caldyn_mod.f90->sourcefile~bands.f90 sourcefile~caldyn_mod.f90->sourcefile~advect_new_mod.f90 sourcefile~dissip_mod.f90->sourcefile~bands.f90 sourcefile~dissip_mod.f90->sourcefile~nxgraro2_mod.f90 sourcefile~dissip_mod.f90->sourcefile~gradiv2_mod.f90 sourcefile~dissip_mod.f90->sourcefile~divgrad2_mod.f90 sourcefile~guide_loc_mod.f90->sourcefile~bands.f90 sourcefile~gcm.f90 gcm.F90 sourcefile~gcm.f90->sourcefile~bands.f90 sourcefile~groupe_mod.f90->sourcefile~bands.f90 sourcefile~groupe_mod.f90->sourcefile~advtrac_mod.f90 sourcefile~advect_new_mod.f90->sourcefile~bands.f90 sourcefile~divgrad2_mod.f90->sourcefile~bands.f90 sourcefile~vlspltgen_mod.f90->sourcefile~bands.f90 sourcefile~vlspltgen_mod.f90->sourcefile~vlz_mod.f90 sourcefile~advect_new_loc.f90 advect_new_loc.f90 sourcefile~advect_new_loc.f90->sourcefile~advect_new_mod.f90 sourcefile~vlsplt_loc.f90 vlsplt_loc.F90 sourcefile~vlsplt_loc.f90->sourcefile~vlz_mod.f90 sourcefile~groupe_loc.f90 groupe_loc.f90 sourcefile~groupe_loc.f90->sourcefile~groupe_mod.f90 sourcefile~vlspltgen_loc.f90 vlspltgen_loc.F90 sourcefile~vlspltgen_loc.f90->sourcefile~vlspltgen_mod.f90 sourcefile~caldyn_loc.f90 caldyn_loc.f90 sourcefile~caldyn_loc.f90->sourcefile~caldyn_mod.f90 sourcefile~integrd_loc.f90 integrd_loc.f90 sourcefile~integrd_loc.f90->sourcefile~integrd_mod.f90 sourcefile~dissip_loc.f90 dissip_loc.f90 sourcefile~dissip_loc.f90->sourcefile~dissip_mod.f90

Contents

Source Code


Source Code

module times
  integer,private,save :: Last_Count=0
  real, private,save :: Last_cpuCount=0
  logical, private,save :: AllTimer_IsActive=.false.
  
  integer, parameter :: nb_timer = 4
  integer, parameter :: timer_caldyn  = 1
  integer, parameter :: timer_vanleer = 2
  integer, parameter :: timer_dissip = 3
  integer, parameter :: timer_physic = 4
  integer, parameter :: stopped = 1
  integer, parameter :: running = 2
  integer, parameter :: suspended = 3 
  
  integer :: max_size
  real,    allocatable, dimension(:,:,:) :: timer_table
  real,    allocatable, dimension(:,:,:) :: timer_table_sqr 
  integer, allocatable, dimension(:,:,:) :: timer_iteration
  real,    allocatable, dimension(:,:,:) :: timer_average
  real,    allocatable, dimension(:,:,:) :: timer_delta
  real,    allocatable,dimension(:) :: timer_running, last_time
  integer, allocatable,dimension(:) :: timer_state
  
  contains
  
  subroutine init_timer
    USE parallel_lmdz
    USE dimensions_mod, ONLY: iim, jjm, llm, ndm
USE paramet_mod_h
implicit none


    
    max_size=jjm+1
    allocate(timer_table(max_size,nb_timer,0:mpi_size-1))
    allocate(timer_table_sqr(max_size,nb_timer,0:mpi_size-1))
    allocate(timer_iteration(max_size,nb_timer,0:mpi_size-1))
    allocate(timer_average(max_size,nb_timer,0:mpi_size-1))
    allocate(timer_delta(max_size,nb_timer,0:mpi_size-1))
    allocate(timer_running(nb_timer))
    allocate(timer_state(nb_timer))
    allocate(last_time(nb_timer))
    
    timer_table(:,:,:)=0
    timer_table_sqr(:,:,:)=0
    timer_iteration(:,:,:)=0
    timer_average(:,:,:)=0
    timer_delta(:,:,:)=0
    timer_state(:)=stopped      
  end subroutine init_timer
  
  subroutine start_timer(no_timer)
    implicit none
    integer :: no_timer
    
    if (AllTimer_IsActive) then
    
      if (timer_state(no_timer)/=stopped) then
        CALL abort_gcm("times","start_timer :: timer is already running or suspended",1)
      else
        timer_state(no_timer)=running
      endif
      
      timer_running(no_timer)=0
      call cpu_time(last_time(no_timer))
    
    endif
    
  end subroutine start_timer
  
  subroutine suspend_timer(no_timer)
    implicit none
    integer :: no_timer
     
    if (AllTimer_IsActive) then   
      if (timer_state(no_timer)/=running) then
         CALL abort_gcm("times","suspend_timer :: timer is not running",1)
      else
        timer_state(no_timer)=suspended
      endif
    
      timer_running(no_timer)=timer_running(no_timer)-last_time(no_timer)
      call cpu_time(last_time(no_timer))
      timer_running(no_timer)=timer_running(no_timer)+last_time(no_timer)
    endif
  end subroutine suspend_timer
  
  subroutine resume_timer(no_timer)
    implicit none
    integer :: no_timer
     
    if (AllTimer_IsActive) then   
      if (timer_state(no_timer)/=suspended) then
        CALL abort_gcm("times","resume_timer :: timer is not suspended",1)
      else
        timer_state(no_timer)=running
      endif
      
      call cpu_time(last_time(no_timer))
    endif
    
  end subroutine resume_timer

  subroutine stop_timer(no_timer)
    USE parallel_lmdz
    implicit none
    integer :: no_timer
    integer :: N
    real :: V,V2
    
    if (AllTimer_IsActive) then
       
      if (timer_state(no_timer)/=running) then
        CALL abort_gcm("times","stop_timer :: timer is not running",1)
      else
        timer_state(no_timer)=stopped
      endif
    
      timer_running(no_timer)=timer_running(no_timer)-last_time(no_timer)
      call cpu_time(last_time(no_timer))
      timer_running(no_timer)=timer_running(no_timer)+last_time(no_timer)
    
      timer_table(jj_nb,no_timer,mpi_rank)=timer_table(jj_nb,no_timer,mpi_rank)+timer_running(no_timer)
      timer_table_sqr(jj_nb,no_timer,mpi_rank)=timer_table_sqr(jj_nb,no_timer,mpi_rank)+timer_running(no_timer)**2
      timer_iteration(jj_nb,no_timer,mpi_rank)=timer_iteration(jj_nb,no_timer,mpi_rank)+1
      timer_average(jj_nb,no_timer,mpi_rank)=timer_table(jj_nb,no_timer,mpi_rank)/timer_iteration(jj_nb,no_timer,mpi_rank)
      if (timer_iteration(jj_nb,no_timer,mpi_rank)>=2) then
        N=timer_iteration(jj_nb,no_timer,mpi_rank)
	V2=timer_table_sqr(jj_nb,no_timer,mpi_rank)
	V=timer_table(jj_nb,no_timer,mpi_rank)
	timer_delta(jj_nb,no_timer,mpi_rank)=sqrt(ABS(V2-V*V/N)/(N-1)) 
      else
        timer_delta(jj_nb,no_timer,mpi_rank)=0
      endif
    endif
    
  end subroutine stop_timer
   
  subroutine allgather_timer
    USE parallel_lmdz
    USE lmdz_mpi
    implicit none

    integer :: ierr
    integer :: data_size
    real, allocatable,dimension(:,:) :: tmp_table

    IF (using_mpi) THEN    
   
      if (AllTimer_IsActive) then
    
    
      allocate(tmp_table(max_size,nb_timer))
    
      data_size=max_size*nb_timer
    
      tmp_table(:,:)=timer_table(:,:,mpi_rank)
      call mpi_allgather(tmp_table(1,1),data_size,MPI_REAL_LMDZ,timer_table(1,1,0),data_size,MPI_REAL_LMDZ,COMM_LMDZ,ierr)
      tmp_table(:,:)=timer_table_sqr(:,:,mpi_rank)
      call mpi_allgather(tmp_table(1,1),data_size,MPI_REAL_LMDZ,timer_table_sqr(1,1,0),data_size,MPI_REAL_LMDZ,COMM_LMDZ,ierr)
      deallocate(tmp_table)
    
      endif
      
    ENDIF ! using_mpi
    
  end subroutine allgather_timer
  
  subroutine allgather_timer_average
    USE parallel_lmdz
    USE lmdz_mpi
    implicit none
    integer :: ierr
    integer :: data_size
    real, allocatable,dimension(:,:),target :: tmp_table
    integer, allocatable,dimension(:,:),target :: tmp_iter
    integer :: istats

    IF (using_mpi) THEN
        
      if (AllTimer_IsActive) then
    
      allocate(tmp_table(max_size,nb_timer))
      allocate(tmp_iter(max_size,nb_timer))
   
      data_size=max_size*nb_timer

      tmp_table(:,:)=timer_average(:,:,mpi_rank)
      call mpi_allgather(tmp_table(1,1),data_size,MPI_REAL_LMDZ,timer_average(1,1,0),data_size,MPI_REAL_LMDZ,COMM_LMDZ,ierr)
      tmp_table(:,:)=timer_delta(:,:,mpi_rank)
      call mpi_allgather(tmp_table(1,1),data_size,MPI_REAL_LMDZ,timer_delta(1,1,0),data_size,MPI_REAL_LMDZ,COMM_LMDZ,ierr)
      tmp_iter(:,:)=timer_iteration(:,:,mpi_rank)
      call mpi_allgather(tmp_iter(1,1),data_size,MPI_INTEGER,timer_iteration(1,1,0),data_size,MPI_INTEGER,COMM_LMDZ,ierr)
      deallocate(tmp_table)
    
      endif
      
    ENDIF  ! using_mp�
  end subroutine allgather_timer_average
  
  subroutine InitTime
  implicit none
    integer :: count,count_rate,count_max
    
    AllTimer_IsActive=.TRUE.
    if (AllTimer_IsActive) then
      call system_clock(count,count_rate,count_max)
      call cpu_time(Last_cpuCount)
      Last_Count=count
    endif
  end subroutine InitTime
  
  function DiffTime()
  implicit none
    double precision :: DiffTime
    integer :: count,count_rate,count_max
  
    call system_clock(count,count_rate,count_max)
    if (Count>=Last_Count) then
      DiffTime=(1.*(Count-last_Count))/count_rate
    else
      DiffTime=(1.*(Count-last_Count+Count_max))/count_rate
    endif
    Last_Count=Count 
  end function DiffTime
  
  function DiffCpuTime()
  implicit none
    real :: DiffCpuTime
    real :: Count
    
    call cpu_time(Count)
    DiffCpuTime=Count-Last_cpuCount
    Last_cpuCount=Count 
  end function DiffCpuTime

end module times