Changeset 3352 for trunk/NEMOGCM/NEMO/OPA_SRC/timing.F90
- Timestamp:
- 2012-04-11T14:56:01+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEMOGCM/NEMO/OPA_SRC/timing.F90
r3294 r3352 76 76 LOGICAL :: ln_onefile = .TRUE. 77 77 LOGICAL :: lwriter 78 79 78 !!---------------------------------------------------------------------- 80 79 !! NEMO/OPA 4.0 , NEMO Consortium (2011) … … 322 321 IF( lwriter ) WRITE(numtime,*) 'Total timing (sum) :' 323 322 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_ctime323 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 326 325 IF( lwriter ) WRITE(numtime,*) 327 326 #if defined key_mpp_mpi … … 406 405 TYPE(timer), POINTER :: sl_timer_ave => NULL() 407 406 INTEGER :: icode 407 INTEGER :: ierr 408 408 LOGICAL :: ll_ord 409 409 CHARACTER(len=200) :: clfmt 410 410 411 411 ! 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 417 426 sl_timer_glob_root%cname(:) = '' 418 427 sl_timer_glob_root%tsum_cpu(:) = 0._wp … … 421 430 sl_timer_glob_root%next => NULL() 422 431 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)) 428 439 sl_timer_glob => sl_timer_glob_root 429 440 ! … … 451 462 sl_timer_ave => sl_timer_ave_root 452 463 ENDIF 453 464 454 465 ! Gather info from all processors 455 466 s_timer => s_timer_root … … 467 478 sl_timer_glob%niter, 1, MPI_INTEGER, & 468 479 0, MPI_COMM_OPA, icode) 480 469 481 IF( narea == 1 .AND. ASSOCIATED(s_timer%next) ) THEN 470 482 ALLOCATE(sl_timer_glob%next) … … 479 491 s_timer => s_timer%next 480 492 END DO 493 494 WRITE(*,*) 'ARPDBG: timing: done gathers' 481 495 482 496 IF( narea == 1 ) THEN … … 500 514 ENDIF 501 515 sl_timer_glob => sl_timer_glob%next 502 END DO 516 END DO 517 518 WRITE(*,*) 'ARPDBG: timing: done computing stats' 503 519 504 ! reorder the ave arged list by CPU time520 ! reorder the averaged list by CPU time 505 521 s_wrk => NULL() 506 522 sl_timer_ave => sl_timer_ave_root … … 509 525 sl_timer_ave => sl_timer_ave_root 510 526 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 512 530 IF ( sl_timer_ave%tsum_clock < sl_timer_ave%next%tsum_clock ) THEN 513 531 ALLOCATE(s_wrk) 532 ! Copy data into the new object pointed to by s_wrk 514 533 s_wrk = sl_timer_ave%next 534 ! Insert this new timer object before our current position 515 535 CALL insert (sl_timer_ave, sl_timer_ave_root, s_wrk) 536 ! Remove the old object from the list 516 537 CALL suppress(sl_timer_ave%next) 517 538 ll_ord = .FALSE. 518 539 CYCLE 519 540 ENDIF 520 IF( ASSOCIATED(sl_timer_ave%next) ) sl_timer_ave => sl_timer_ave%next541 IF( ASSOCIATED(sl_timer_ave%next) ) sl_timer_ave => sl_timer_ave%next 521 542 END DO 522 IF( ll_ord ) EXIT543 IF( ll_ord ) EXIT 523 544 END DO 524 545 525 546 ! 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')") 533 553 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)' 535 555 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), & 537 557 & sl_timer_ave%tsum_clock,sl_timer_ave%tsum_clock*100.*jpnij/tot_etime, & 538 558 & sl_timer_ave%tsum_cpu ,sl_timer_ave%tsum_cpu*100.*jpnij/tot_ctime , & … … 712 732 !!---------------------------------------------------------------------- 713 733 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,*) 719 739 ! 720 740 END SUBROUTINE timing_reset … … 734 754 !!---------------------------------------------------------------------- 735 755 !! *** ROUTINE insert *** 736 !! ** Purpose : insert an element in 756 !! ** Purpose : insert an element in timer structure 737 757 !!---------------------------------------------------------------------- 738 758 TYPE(timer), POINTER, INTENT(inout) :: sd_current, sd_root, sd_ptr … … 740 760 741 761 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 742 764 sd_root => sd_ptr 743 765 ELSE … … 747 769 sd_ptr%prev => sd_current%prev 748 770 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() 749 775 ! 750 776 END SUBROUTINE insert … … 764 790 IF ( ASSOCIATED(sl_temp%next) ) sl_temp%next%prev => sl_temp%prev 765 791 DEALLOCATE(sl_temp) 792 sl_temp => NULL() 766 793 ! 767 794 END SUBROUTINE suppress
Note: See TracChangeset
for help on using the changeset viewer.