New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 3572 for branches/2012/dev_r3342_MERCATOR7_SST/NEMOGCM/NEMO/OPA_SRC/timing.F90 – NEMO

Ignore:
Timestamp:
2012-11-16T11:23:06+01:00 (11 years ago)
Author:
cbricaud
Message:

merge dev_r3342_MERCATOR7_SST with trunk: rev3342 to rev3555.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2012/dev_r3342_MERCATOR7_SST/NEMOGCM/NEMO/OPA_SRC/timing.F90

    r3294 r3572  
    7676   LOGICAL :: ln_onefile = .TRUE.  
    7777   LOGICAL :: lwriter 
    78  
    7978   !!---------------------------------------------------------------------- 
    8079   !! NEMO/OPA 4.0 , NEMO Consortium (2011) 
     
    322321      IF( lwriter ) WRITE(numtime,*) 'Total timing (sum) :' 
    323322      IF( lwriter ) WRITE(numtime,*) '--------------------' 
    324       IF( lwriter ) WRITE(numtime,*) 'Elapsed Time (s)  ','CPU Time (s)' 
    325       IF( lwriter ) WRITE(numtime,'(5x,f12.3,2x,f12.3)')  tot_etime, tot_ctime 
     323      IF( lwriter ) WRITE(numtime,"('Elapsed Time (s)  CPU Time (s)')") 
     324      IF( lwriter ) WRITE(numtime,'(5x,f12.3,1x,f12.3)')  tot_etime, tot_ctime 
    326325      IF( lwriter ) WRITE(numtime,*)  
    327326#if defined key_mpp_mpi 
     
    406405      TYPE(timer), POINTER :: sl_timer_ave      => NULL() 
    407406      INTEGER :: icode 
     407      INTEGER :: ierr 
    408408      LOGICAL :: ll_ord            
    409409      CHARACTER(len=200) :: clfmt               
    410410                  
    411411      ! Initialised the global strucutre    
    412       ALLOCATE(sl_timer_glob_root) 
    413       ALLOCATE(sl_timer_glob_root%cname     (jpnij)) 
    414       ALLOCATE(sl_timer_glob_root%tsum_cpu  (jpnij)) 
    415       ALLOCATE(sl_timer_glob_root%tsum_clock(jpnij)) 
    416       ALLOCATE(sl_timer_glob_root%niter     (jpnij)) 
     412      ALLOCATE(sl_timer_glob_root, Stat=ierr) 
     413      IF(ierr /= 0)THEN 
     414         WRITE(numtime,*) 'Failed to allocate global timing structure in waver_info' 
     415         RETURN 
     416      END IF 
     417 
     418      ALLOCATE(sl_timer_glob_root%cname     (jpnij), & 
     419               sl_timer_glob_root%tsum_cpu  (jpnij), & 
     420               sl_timer_glob_root%tsum_clock(jpnij), & 
     421               sl_timer_glob_root%niter     (jpnij), Stat=ierr) 
     422      IF(ierr /= 0)THEN 
     423         WRITE(numtime,*) 'Failed to allocate global timing structure in waver_info' 
     424         RETURN 
     425      END IF 
    417426      sl_timer_glob_root%cname(:)       = '' 
    418427      sl_timer_glob_root%tsum_cpu(:)   = 0._wp 
     
    421430      sl_timer_glob_root%next => NULL() 
    422431      sl_timer_glob_root%prev => NULL() 
    423       ALLOCATE(sl_timer_glob) 
    424       ALLOCATE(sl_timer_glob%cname     (jpnij)) 
    425       ALLOCATE(sl_timer_glob%tsum_cpu  (jpnij)) 
    426       ALLOCATE(sl_timer_glob%tsum_clock(jpnij)) 
    427       ALLOCATE(sl_timer_glob%niter     (jpnij)) 
     432      !ARPDBG - don't need to allocate a pointer that's immediately then 
     433      !         set to point to some other object. 
     434      !ALLOCATE(sl_timer_glob) 
     435      !ALLOCATE(sl_timer_glob%cname     (jpnij)) 
     436      !ALLOCATE(sl_timer_glob%tsum_cpu  (jpnij)) 
     437      !ALLOCATE(sl_timer_glob%tsum_clock(jpnij)) 
     438      !ALLOCATE(sl_timer_glob%niter     (jpnij)) 
    428439      sl_timer_glob => sl_timer_glob_root 
    429440      ! 
     
    451462         sl_timer_ave => sl_timer_ave_root             
    452463      ENDIF  
    453        
     464 
    454465      ! Gather info from all processors 
    455466      s_timer => s_timer_root 
     
    467478                         sl_timer_glob%niter, 1, MPI_INTEGER,   & 
    468479                         0, MPI_COMM_OPA, icode) 
     480 
    469481         IF( narea == 1 .AND. ASSOCIATED(s_timer%next) ) THEN 
    470482            ALLOCATE(sl_timer_glob%next) 
     
    479491         s_timer => s_timer%next 
    480492      END DO       
     493 
     494         WRITE(*,*) 'ARPDBG: timing: done gathers' 
    481495       
    482496      IF( narea == 1 ) THEN     
     
    500514            ENDIF 
    501515            sl_timer_glob => sl_timer_glob%next                                 
    502          END DO          
     516         END DO 
     517 
     518         WRITE(*,*) 'ARPDBG: timing: done computing stats' 
    503519       
    504          ! reorder the avearged list by CPU time       
     520         ! reorder the averaged list by CPU time       
    505521         s_wrk => NULL() 
    506522         sl_timer_ave => sl_timer_ave_root 
     
    509525            sl_timer_ave => sl_timer_ave_root 
    510526            DO WHILE( ASSOCIATED( sl_timer_ave%next ) ) 
    511             IF( .NOT. ASSOCIATED(sl_timer_ave%next) ) EXIT 
     527 
     528               IF( .NOT. ASSOCIATED(sl_timer_ave%next) ) EXIT 
     529 
    512530               IF ( sl_timer_ave%tsum_clock < sl_timer_ave%next%tsum_clock ) THEN  
    513531                  ALLOCATE(s_wrk) 
     532                  ! Copy data into the new object pointed to by s_wrk 
    514533                  s_wrk = sl_timer_ave%next 
     534                  ! Insert this new timer object before our current position 
    515535                  CALL insert  (sl_timer_ave, sl_timer_ave_root, s_wrk) 
     536                  ! Remove the old object from the list 
    516537                  CALL suppress(sl_timer_ave%next)             
    517538                  ll_ord = .FALSE. 
    518539                  CYCLE             
    519540               ENDIF            
    520             IF( ASSOCIATED(sl_timer_ave%next) ) sl_timer_ave => sl_timer_ave%next 
     541               IF( ASSOCIATED(sl_timer_ave%next) ) sl_timer_ave => sl_timer_ave%next 
    521542            END DO          
    522            IF( ll_ord ) EXIT 
     543            IF( ll_ord ) EXIT 
    523544         END DO 
    524545 
    525546         ! write averaged info 
    526          WRITE(numtime,*) 'Averaged timing on all processors :' 
    527          WRITE(numtime,*) '-----------------------------------' 
    528          WRITE(numtime,*) 'Section             ',                & 
    529          &   'Elapsed Time (s)  ','Elapsed Time (%)  ',          & 
    530          &   'CPU Time(s)  ','CPU Time (%)  ','CPU/Elapsed  ',   & 
    531          &   'Max Elapsed (%)  ','Min elapsed (%)  ',            &            
    532          &   'Frequency'  
     547         WRITE(numtime,"('Averaged timing on all processors :')") 
     548         WRITE(numtime,"('-----------------------------------')") 
     549         WRITE(numtime,"('Section',13x,'Elap. Time(s)',2x,'Elap. Time(%)',2x, & 
     550         &   'CPU Time(s)',2x,'CPU Time(%)',2x,'CPU/Elap',1x,   & 
     551         &   'Max elap(%)',2x,'Min elap(%)',2x,            &            
     552         &   'Freq')") 
    533553         sl_timer_ave => sl_timer_ave_root   
    534          clfmt = '(1x,a,4x,f12.3,6x,f12.3,x,f12.3,2x,f12.3,6x,f7.3,5x,f12.3,5x,f12.3,2x,f9.2)' 
     554         clfmt = '((A),E15.7,2x,f6.2,5x,f12.2,5x,f6.2,5x,f7.2,2x,f12.2,4x,f6.2,2x,f9.2)' 
    535555         DO WHILE ( ASSOCIATED(sl_timer_ave) ) 
    536             WRITE(numtime,TRIM(clfmt))   sl_timer_ave%cname,                            & 
     556            WRITE(numtime,TRIM(clfmt))   sl_timer_ave%cname(1:18),                            & 
    537557            &   sl_timer_ave%tsum_clock,sl_timer_ave%tsum_clock*100.*jpnij/tot_etime,   & 
    538558            &   sl_timer_ave%tsum_cpu  ,sl_timer_ave%tsum_cpu*100.*jpnij/tot_ctime  ,   & 
     
    712732      !!---------------------------------------------------------------------- 
    713733      l_initdone = .TRUE.  
    714       IF(lwp) WRITE(numout,*) 
    715       IF(lwp) WRITE(numout,*) 'timing_reset : instrumented routines for timing' 
    716       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~' 
    717       CALL timing_list(s_timer_root) 
    718       WRITE(numout,*) 
     734!      IF(lwp) WRITE(numout,*) 
     735!      IF(lwp) WRITE(numout,*) 'timing_reset : instrumented routines for timing' 
     736!      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~' 
     737!      CALL timing_list(s_timer_root) 
     738!      WRITE(numout,*) 
    719739      ! 
    720740   END SUBROUTINE timing_reset 
     
    734754      !!---------------------------------------------------------------------- 
    735755      !!               ***  ROUTINE insert  *** 
    736       !! ** Purpose :   insert an element in  imer structure 
     756      !! ** Purpose :   insert an element in timer structure 
    737757      !!---------------------------------------------------------------------- 
    738758      TYPE(timer), POINTER, INTENT(inout) :: sd_current, sd_root, sd_ptr 
     
    740760      
    741761      IF( ASSOCIATED( sd_current, sd_root ) ) THEN 
     762         ! If our current element is the root element then 
     763         ! replace it with the one being inserted 
    742764         sd_root => sd_ptr 
    743765      ELSE 
     
    747769      sd_ptr%prev     => sd_current%prev 
    748770      sd_current%prev => sd_ptr 
     771      ! Nullify the pointer to the new element now that it is held 
     772      ! within the list. If we don't do this then a subsequent call 
     773      ! to ALLOCATE memory to this pointer will fail. 
     774      sd_ptr => NULL() 
    749775      !     
    750776   END SUBROUTINE insert 
     
    764790      IF ( ASSOCIATED(sl_temp%next) ) sl_temp%next%prev => sl_temp%prev 
    765791      DEALLOCATE(sl_temp) 
     792      sl_temp => NULL() 
    766793      ! 
    767794    END SUBROUTINE suppress 
Note: See TracChangeset for help on using the changeset viewer.