diff --git a/src/fiat/gstats/gstats.F90 b/src/fiat/gstats/gstats.F90 index e6795c2c..1a12169f 100644 --- a/src/fiat/gstats/gstats.F90 +++ b/src/fiat/gstats/gstats.F90 @@ -8,7 +8,7 @@ ! nor does it submit to any jurisdiction. ! -SUBROUTINE GSTATS(KNUM,KSWITCH) +SUBROUTINE GSTATS(KNUM, KSWITCH) !**** *GSTATS* - Gather timing statistics @@ -39,7 +39,7 @@ SUBROUTINE GSTATS(KNUM,KSWITCH) ! EXTERNALS. USER_CLOCK - timing routine -! ---------- MPL_BARRIER - syncronization of processors +! ---------- ! REFERENCE. ! ---------- @@ -62,98 +62,85 @@ SUBROUTINE GSTATS(KNUM,KSWITCH) ! F. Vana 05-Mar-2015 Support for single precision ! ------------------------------------------------------------------ -USE EC_PARKIND ,ONLY : JPRD, JPIM ,JPIB -USE YOMHOOK ,ONLY : LHOOK, DR_HOOK, JPHOOK - -USE YOMGSTATS -USE MPL_MODULE -USE MPL_STATS_MOD -USE OML_MOD +USE EC_PARKIND, ONLY: JPRD, JPIM ,JPIB +USE YOMHOOK, ONLY: LHOOK, DR_HOOK, JPHOOK +USE YOMGSTATS, ONLY: JPMAXSTAT, LSTATS, LGSTATS_LABEL, CCDESC, CCTYPE, LSTATSCPU, TIMESUM, NCALLS, & + & NSWITCHVAL, TIMESQSUM, TIMEMAX, TIMESUMB, TTCPUSUM, TVCPUSUM, TIMELCALL, & + & NTMEM, TIME_LAST_CALL, JPERR, MYPROC_STATS, THISTIME, TTCPULCALL, TVCPULCALL, & + & THISTCPU, THISVCPU, NSTATS_MEM, LSTATS_ALLOC, LSTATS_MPL, UNKNOWN_NUMSEND, & + & UNKNOWN_NUMRECV, UNKNOWN_SENDBYTES, UNKNOWN_RECVBYTES, NUMSEND, NUMRECV, & + & SENDBYTES, RECVBYTES, JPMAXDELAYS, NDELAY_INDEX, NDELAY_COUNTER, & + & TDELAY_VALUE, CDELAY_TIME, LTRACE_STATS, NTRACE_STATS, NCALLS_TOTAL, & + & TIME_TRACE, NCALL_TRACE, LAST_KSWITCH, LAST_KNUM +USE MPL_STATS_MOD, ONLY: MPL_STATSON, MPL_STATSREAD +USE OML_MOD, ONLY: OML_MY_THREAD, OML_GET_MAX_THREADS, OML_MAX_THREADS IMPLICIT NONE -INTEGER(KIND=JPIM),INTENT(IN) :: KNUM -INTEGER(KIND=JPIM),INTENT(IN) :: KSWITCH +INTEGER(KIND=JPIM), INTENT(IN) :: KNUM +INTEGER(KIND=JPIM), INTENT(IN) :: KSWITCH -INTEGER(KIND=JPIM) :: IMOD,ICALL +INTEGER(KIND=JPIM) :: IMOD, ICALL INTEGER(KIND=JPIM) :: IIMEM, IIPAG, IIMEMC INTEGER(KIND=JPIB) :: IMEM, IMEMH, IMEMS, IMEMC, IPAG, INUM INTEGER(KIND=JPIB) :: GETMAXRSS, GETHWM, GETSTK, GETCURHEAP, GETPAG EXTERNAL GETMAXRSS, GETHWM, GETSTK, GETCURHEAP, GETPAG -REAL(KIND=JPRD) :: ZTIMED,ZCLOCK,ZCLOCK1,ZTIME,ZTCPU,ZVCPU -LOGICAL :: LLFIRST=.TRUE. -LOGICAL :: LLMFIRST=.TRUE. - CHARACTER(LEN=32), SAVE :: CCDESC_DRHOOK(JPMAXSTAT) - CHARACTER(LEN=32), SAVE :: CCDESC_BARR(JPMAXSTAT) +REAL(KIND=JPRD) :: ZTIMED, ZCLOCK, ZCLOCK1, ZTIME, ZTCPU, ZVCPU +LOGICAL :: LLFIRST = .TRUE. +LOGICAL :: LLMFIRST = .TRUE. +CHARACTER(LEN=32), SAVE :: CCDESC_DRHOOK(JPMAXSTAT) +CHARACTER(LEN=32), SAVE :: CCDESC_BARR(JPMAXSTAT) SAVE IIMEM, IIPAG, IIMEMC -INTEGER(KIND=JPIM),SAVE :: NUM_THREADS +INTEGER(KIND=JPIM), SAVE :: NUM_THREADS INTEGER(KIND=JPIM) :: INUMTH ! Current value <= NUM_THREADS -REAL(KIND=JPHOOK),ALLOCATABLE,SAVE :: ZHOOK_HANDLE(:) -REAL(KIND=JPHOOK),SAVE :: ZHOOK_HANDLE_COMMS, ZHOOK_HANDLE_COMMS1 -REAL(KIND=JPHOOK),SAVE :: ZHOOK_HANDLE_TRANS -REAL(KIND=JPHOOK),SAVE :: ZHOOK_HANDLE_BARR +REAL(KIND=JPHOOK), ALLOCATABLE,SAVE :: ZHOOK_HANDLE(:) +REAL(KIND=JPHOOK), SAVE :: ZHOOK_HANDLE_COMMS, ZHOOK_HANDLE_COMMS1 +REAL(KIND=JPHOOK), SAVE :: ZHOOK_HANDLE_TRANS +REAL(KIND=JPHOOK), SAVE :: ZHOOK_HANDLE_BARR CHARACTER*4 CC -CHARACTER (LEN = 10) :: CLDATEOD,CLZONEOD +CHARACTER(LEN=10) :: CLDATEOD, CLZONEOD INTEGER(KIND=JPIM) :: IVALUES(8) -INTEGER(KIND=JPIM) :: NMAX_STATS, KULNAM - ! Change LLFINDSUMB to TRUE to add diagnostics to help find SUMB times ! Note that a similar setting exists in dr_hook_util for the same objective -LOGICAL :: LLFINDSUMB=.FALSE. -INTEGER(KIND=JPIM),SAVE :: ISUMBSTACK(10) +LOGICAL :: LLFINDSUMB = .FALSE. +INTEGER(KIND=JPIM), SAVE :: ISUMBSTACK(10) INTEGER(KIND=JPIM) :: J -REAL(KIND=JPRD) :: ZSUM,ZSUMB,ZTOT -REAL(KIND=JPRD) :: SBYTES,RBYTES -INTEGER(KIND=JPIM) :: NSEND,NRECV +REAL(KIND=JPRD) :: SBYTES, RBYTES +INTEGER(KIND=JPIM) :: NSEND, NRECV +CHARACTER(LEN=4) :: CL_MAXSTAT +CHARACTER(LEN=66) :: CL_ERROR_MESSAGE #include "user_clock.intfb.h" -! write(0,*) "GSTATS:LSTATS,JPMAXSTAT,LGSTATS_LABEL,KNUM=",LSTATS,JPMAXSTAT,LGSTATS_LABEL,KNUM - -IF(LSTATS) THEN - -! only process gstats calls for master thread - - IF(OML_MY_THREAD() > 1)GOTO 99999 - - IF(.NOT.ALLOCATED(ZHOOK_HANDLE))THEN - NUM_THREADS=OML_GET_MAX_THREADS() +! Process GSTATS calls if LSTATS is .TRUE. and we are the master +IF (LSTATS .AND. OML_MY_THREAD() == 1) THEN + IF (.NOT. ALLOCATED(ZHOOK_HANDLE)) THEN + NUM_THREADS = OML_GET_MAX_THREADS() ALLOCATE(ZHOOK_HANDLE(NUM_THREADS)) ENDIF - IF(LGSTATS_LABEL)THEN - DO INUM=1,JPMAXSTAT - WRITE(CC,'(I4)')INUM - CCDESC_BARR(INUM)='>BAR-'//CCDESC(INUM)(1:21)//'('//CC//')' + IF (LGSTATS_LABEL) THEN + DO INUM = 1, JPMAXSTAT + WRITE(CC,'(I4)') INUM + CCDESC_BARR(INUM) = '>BAR-' // CCDESC(INUM)(1:21) // '(' // CC // ')' ENDDO - DO INUM=1,JPMAXSTAT - WRITE(CC,'(I4)')INUM -! write(6,*) inum,cctype(inum) - IF(CCTYPE(INUM).EQ."TRS".OR.CCTYPE(INUM).EQ.'MP-'.OR.CCTYPE(INUM).EQ.'MPL'& - & .OR.CCTYPE(INUM).EQ.'BAR'.OR.CCTYPE(INUM).EQ.'OMP') THEN - CCDESC_DRHOOK(INUM)='>'//CCTYPE(INUM)//'-'//CCDESC(INUM)(1:21)//'('//CC//')' + DO INUM = 1, JPMAXSTAT + WRITE(CC,'(I4)') INUM + IF (CCTYPE(INUM) .EQ. "TRS" .OR. CCTYPE(INUM) .EQ. 'MP-' .OR. CCTYPE(INUM) .EQ. 'MPL' & + & .OR. CCTYPE(INUM) .EQ. 'BAR' .OR. CCTYPE(INUM) .EQ. 'OMP') THEN + CCDESC_DRHOOK(INUM) = '>' // CCTYPE(INUM) // '-' // CCDESC(INUM)(1:21) // '(' // CC // ')' ENDIF ENDDO - LGSTATS_LABEL=.FALSE. + LGSTATS_LABEL = .FALSE. ENDIF ! ------------------------------------------------------------------ -!J IF(KNUM/=0) THEN -!J IF(LSYNCSTATS .AND.(KSWITCH==0.OR. KSWITCH==2)) THEN -!J IF(.NOT.OML_IN_PARALLEL().AND. KNUM < 500 )THEN -!J IF(LHOOK)CALL DR_HOOK(CCDESC_BARR(KNUM),0,ZHOOK_HANDLE_BARR) -!J CALL MPL_BARRIER(CDSTRING='GSTATS:') -!J IF(LHOOK)CALL DR_HOOK(CCDESC_BARR(KNUM),1,ZHOOK_HANDLE_BARR) -!J ENDIF -!J ENDIF -!J ENDIF - CALL USER_CLOCK(PELAPSED_TIME=ZCLOCK) - IF (LSTATSCPU.OR.KNUM==0) THEN - CALL USER_CLOCK(PTOTAL_CP=ZTCPU,PVECTOR_CP=ZVCPU) + IF (LSTATSCPU .OR. KNUM == 0) THEN + CALL USER_CLOCK(PTOTAL_CP=ZTCPU, PVECTOR_CP=ZVCPU) ELSE ZTCPU = 0.0_JPRD ZVCPU = 0.0_JPRD @@ -165,103 +152,103 @@ SUBROUTINE GSTATS(KNUM,KSWITCH) ENDIF IF (LHOOK .AND. (KSWITCH == 0 .OR. KSWITCH == 1)) THEN -! write(0,*) "KNUM,SWITCH=",KNUM,KSWITCH -! write(0,*) "CCTYPE=",CCTYPE(KNUM) -! write(0,*) "CCDESC_DRHOOK=",CCDESC_DRHOOK(KNUM) - IF(CCTYPE(KNUM).EQ."TRS")THEN - CALL DR_HOOK(CCDESC_DRHOOK(KNUM),KSWITCH,ZHOOK_HANDLE_TRANS) - ELSEIF(CCTYPE(KNUM).EQ.'MP-')THEN - CALL DR_HOOK(CCDESC_DRHOOK(KNUM),KSWITCH,ZHOOK_HANDLE_COMMS) - ELSEIF(CCTYPE(KNUM).EQ.'MPL'.AND.KNUM.NE.682)THEN - CALL DR_HOOK(CCDESC_DRHOOK(KNUM),KSWITCH,ZHOOK_HANDLE_COMMS1) - ELSEIF(CCTYPE(KNUM).EQ.'OMP')THEN - INUMTH = OML_MAX_THREADS() ! The prevailing number of threads -- could now be less than the absolute max (i.e. export OMP_NUM_THREADS=) - CALL DR_HOOK(CCDESC_DRHOOK(KNUM),KSWITCH,ZHOOK_HANDLE(1:INUMTH)) - ELSEIF(CCTYPE(KNUM).EQ.'BAR')THEN - CALL DR_HOOK(CCDESC_DRHOOK(KNUM),KSWITCH,ZHOOK_HANDLE_BARR) + IF (CCTYPE(KNUM) .EQ. "TRS") THEN + CALL DR_HOOK(CCDESC_DRHOOK(KNUM), KSWITCH, ZHOOK_HANDLE_TRANS) + ELSEIF (CCTYPE(KNUM) .EQ. 'MP-') THEN + CALL DR_HOOK(CCDESC_DRHOOK(KNUM), KSWITCH, ZHOOK_HANDLE_COMMS) + ELSEIF (CCTYPE(KNUM) .EQ. 'MPL' .AND. KNUM .NE. 682) THEN + CALL DR_HOOK(CCDESC_DRHOOK(KNUM), KSWITCH, ZHOOK_HANDLE_COMMS1) + ELSEIF (CCTYPE(KNUM) .EQ. 'OMP') THEN + ! The prevailing number of threads -- could now be less than the absolute max (i.e. export + ! OMP_NUM_THREADS=) + INUMTH = OML_MAX_THREADS() + CALL DR_HOOK(CCDESC_DRHOOK(KNUM), KSWITCH, ZHOOK_HANDLE(1:INUMTH)) + ELSEIF (CCTYPE(KNUM) .EQ. 'BAR')THEN + CALL DR_HOOK(CCDESC_DRHOOK(KNUM), KSWITCH, ZHOOK_HANDLE_BARR) ENDIF -! measure GSTATS HOOK overhead + ! Measure GSTATS HOOK overhead CALL USER_CLOCK(PELAPSED_TIME=ZCLOCK1) - TIMESUM(401) = TIMESUM(401)+ZCLOCK1-ZCLOCK - NCALLS(401) = NCALLS(401)+1 - ZCLOCK=ZCLOCK1 + TIMESUM(401) = TIMESUM(401) + ZCLOCK1 - ZCLOCK + NCALLS(401) = NCALLS(401) + 1 + ZCLOCK = ZCLOCK1 ENDIF IF (LLFIRST) THEN -! write(0,*) "JPMAXSTAT:2=",JPMAXSTAT - NSWITCHVAL(:) = -1 TIMESQSUM(:) = 0.0_JPRD TIMEMAX(:) = 0.0_JPRD TIMESUMB(:) = 0.0_JPRD - IF( LLFINDSUMB )THEN - ISUMBSTACK(:)=0 + IF (LLFINDSUMB) THEN + ISUMBSTACK(:) = 0 ENDIF TTCPUSUM(:) = 0.0_JPRD TVCPUSUM(:) = 0.0_JPRD TIMELCALL(:) = ZCLOCK - CCDESC="" - CCTYPE="" - NTMEM = 0 + CCDESC = "" + CCTYPE = "" + NTMEM = 0 NTMEM(:,5) = 99999999 - IIMEM=0 - IIPAG=0 - IIMEMC=0 + IIMEM = 0 + IIPAG = 0 + IIMEMC = 0 TIME_LAST_CALL = ZCLOCK LLFIRST = .FALSE. ENDIF - IF(KNUM < 0.OR. KNUM > JPMAXSTAT) CALL ABOR1('GSTATS') - IF(KSWITCH == 0.OR. KSWITCH == 1) THEN - NCALLS(KNUM) = NCALLS(KNUM)+1 + ! Check KNUM is valid (> 0 and < JPMAXSTAT) + IF (KNUM < 0) CALL ABOR1('GSTATS: KNUM cannot be negative') + IF (KNUM > JPMAXSTAT) THEN + WRITE(CL_MAXSTAT,'(I4)') JPMAXSTAT + CALL ABOR1('GSTATS: KNUM cannot be greater than ' // CL_MAXSTAT) ENDIF - IMOD = MOD(NCALLS(KNUM),2) - IF(.NOT.((KSWITCH == 0.AND. IMOD == 1) .OR.& - &(KSWITCH == 2.AND. IMOD == 1) .OR.& - &(KSWITCH == 3.AND. IMOD == 1) .OR.& - &(KSWITCH == 1.AND. IMOD == 0))) THEN - WRITE(JPERR,*) 'KNUM,KSWITCH,IMOD,NCALLS(KNUM)',& - &KNUM,KSWITCH,IMOD,NCALLS(KNUM) - CALL ABOR1('GSTATS') + + IF (KSWITCH == 0 .OR. KSWITCH == 1) THEN + NCALLS(KNUM) = NCALLS(KNUM) + 1 ENDIF + IMOD = MOD(NCALLS(KNUM), 2) -! WRITE(0,'("GSTATS(SUMB): ",I4,2X,I1,2X,A40)') KNUM,KSWITCH,CCDESC(KNUM) + ! Check we haven't opened or closed a region twice in a row + IF (.NOT.((KSWITCH == 0 .AND. IMOD == 1) .OR. (KSWITCH == 2 .AND. IMOD == 1) .OR. & + & (KSWITCH == 3 .AND. IMOD == 1) .OR. (KSWITCH == 1 .AND. IMOD == 0))) THEN + WRITE(CL_ERROR_MESSAGE,'(A42,I4)') "Invalid GSTATS call - check region KNUM = ", KNUM + CALL ABOR1('GSTATS: ' // CL_ERROR_MESSAGE) + ENDIF - NSWITCHVAL(KNUM)=KSWITCH + NSWITCHVAL(KNUM) = KSWITCH - IF( KSWITCH == 0 ) THEN -! Start timing event - IF(KNUM>=500)THEN - ZTIMED = ZCLOCK-TIME_LAST_CALL - TIMESUMB(KNUM) = TIMESUMB(KNUM)+ZTIMED + IF (KSWITCH == 0) THEN + ! Start timing event + IF (KNUM >= 500) THEN + ZTIMED = ZCLOCK - TIME_LAST_CALL + TIMESUMB(KNUM) = TIMESUMB(KNUM) + ZTIMED ELSE ZTIMED = 0.0_JPRD ENDIF - IF( LLFINDSUMB .AND. MYPROC_STATS <= 2 )THEN -! diagnostic code to find source of sumb (this should only be activated temporarily) - DO J=9,1,-1 - ISUMBSTACK(J+1)=ISUMBSTACK(J) + IF (LLFINDSUMB .AND. MYPROC_STATS <= 2)THEN + ! Diagnostic code to find source of sumb (this should only be activated temporarily) + DO J = 9, 1, -1 + ISUMBSTACK(J+1) = ISUMBSTACK(J) ENDDO - ISUMBSTACK(1)=KNUM - IF( ZTIMED > 0.1_JPRD .AND. (TIMESUMB(KNUM) > 1.0_JPRD) )THEN - WRITE(0,'("GSTATS(SUMB): KNUM=",I4," ZTIMED=",F10.6," TIMESUMB=",F10.6)')& - & KNUM,ZTIMED,TIMESUMB(KNUM) - DO J=1,10 - IF( ISUMBSTACK(J) > 0 )THEN - WRITE(0,'("GSTATS(SUMB): ",I4,2X,I8,2X,A40)')ISUMBSTACK(J),& - & NCALLS(ISUMBSTACK(J)),CCDESC(ISUMBSTACK(J)) + ISUMBSTACK(1) = KNUM + IF (ZTIMED > 0.1_JPRD .AND. (TIMESUMB(KNUM) > 1.0_JPRD)) THEN + WRITE(0,'("GSTATS(SUMB): KNUM=",I4," ZTIMED=",F10.6," TIMESUMB=",F10.6)') & + & KNUM, ZTIMED, TIMESUMB(KNUM) + DO J = 1, 10 + IF (ISUMBSTACK(J) > 0) THEN + WRITE(0,'("GSTATS(SUMB): ",I4,2X,I8,2X,A40)') ISUMBSTACK(J), NCALLS(ISUMBSTACK(J)), & + & CCDESC(ISUMBSTACK(J)) ENDIF ENDDO ENDIF -! check if grouped counters are overlapping - DO J=0,JPMAXSTAT - IF( J /= KNUM )THEN - IF( CCTYPE(J )/=' '.AND.CCTYPE(J )/='TRS'.AND.CCTYPE(J )/='MP-' .AND.& - & CCTYPE(KNUM)/=' '.AND.CCTYPE(KNUM)/='TRS'.AND.CCTYPE(KNUM)/='MP-' )THEN - IF( NSWITCHVAL(J)==0.OR.NSWITCHVAL(J)==3 )THEN - WRITE(0,'("GSTATS(SUMB): OVERLAPPING COUNTERS ",I4,2X,I4)')KNUM,J + ! Check if grouped counters are overlapping + DO J = 0, JPMAXSTAT + IF (J /= KNUM)THEN + IF (CCTYPE(J ) /= ' ' .AND. CCTYPE(J ) /= 'TRS' .AND. CCTYPE(J ) /= 'MP-' .AND. & + & CCTYPE(KNUM) /= ' ' .AND. CCTYPE(KNUM) /= 'TRS' .AND. CCTYPE(KNUM) /= 'MP-') THEN + IF (NSWITCHVAL(J) == 0 .OR. NSWITCHVAL(J) == 3) THEN + WRITE(0,'("GSTATS(SUMB): OVERLAPPING COUNTERS ",I4,2X,I4)') KNUM, J ENDIF ENDIF ENDIF @@ -274,15 +261,15 @@ SUBROUTINE GSTATS(KNUM,KSWITCH) TVCPULCALL(KNUM) = ZVCPU THISTCPU(KNUM) = 0.0_JPRD THISVCPU(KNUM) = 0.0_JPRD - IF(MYPROC_STATS.LE.NSTATS_MEM.AND.MYPROC_STATS.NE.0) THEN - IMEM = GETMAXRSS()/1024 + IF (MYPROC_STATS .LE. NSTATS_MEM .AND. MYPROC_STATS .NE. 0) THEN + IMEM = GETMAXRSS() / 1024 IPAG = GETPAG() - IMEMH = GETHWM()/1024 - IMEMS = GETSTK()/1024 + IMEMH = GETHWM() / 1024 + IMEMS = GETSTK() / 1024 IMEMC = 0 - IF(LSTATS_ALLOC) IMEMC = GETCURHEAP()/1024 - IF(IMEM > IIMEM.OR.IPAG > IIPAG.OR.(LSTATS_ALLOC.AND.(IMEMC.NE.IIMEMC))) THEN - IF(LLMFIRST) THEN + IF (LSTATS_ALLOC) IMEMC = GETCURHEAP() / 1024 + IF (IMEM > IIMEM .OR. IPAG > IIPAG .OR. (LSTATS_ALLOC .AND. (IMEMC .NE. IIMEMC))) THEN + IF (LLMFIRST) THEN WRITE(0,*) ".---------------------------------------------------------" WRITE(0,*) "| Memory trace details" WRITE(0,*) "| --------------------" @@ -305,136 +292,127 @@ SUBROUTINE GSTATS(KNUM,KSWITCH) WRITE(0,'(A10,A5,21X,A7,2A8,A7,A5,A5,A8)') & & "MEMORY "," KNUM","RSS_INC"," RSS_MAX"," HEAP_MX"," STK", & & " PGS"," CALL"," HEAP" - LLMFIRST=.FALSE. + LLMFIRST = .FALSE. ENDIF WRITE(0,'(A10,I5,1X,A20,1X,I6,2(1X,I7),1X,I6,1X,I4,1X,I4,1X,I7)') & - & "MEMORY bfr",KNUM,CCDESC(KNUM),IMEM-IIMEM,IMEM,IMEMH,IMEMS, & - & IPAG-IIPAG,(NCALLS(KNUM)+1)/2,IMEMC + & "MEMORY bfr", KNUM, CCDESC(KNUM), IMEM - IIMEM, IMEM, IMEMH, IMEMS, IPAG - IIPAG, & + & (NCALLS(KNUM) + 1) / 2, IMEMC ENDIF - NTMEM(KNUM,2)=IMEM - IIMEM=IMEM - IIPAG=IPAG - IIMEMC=IMEMC + NTMEM(KNUM,2) = IMEM + IIMEM = IMEM + IIPAG = IPAG + IIMEMC = IMEMC ENDIF - IF(LSTATS_MPL.AND.CCTYPE(KNUM) .EQ. 'MPL') THEN - CALL MPL_STATSON(NSEND,SBYTES,NRECV,RBYTES) - UNKNOWN_NUMSEND(KNUM)=UNKNOWN_NUMSEND(KNUM)+NSEND - UNKNOWN_NUMRECV(KNUM)=UNKNOWN_NUMRECV(KNUM)+NRECV - UNKNOWN_SENDBYTES(KNUM)=UNKNOWN_SENDBYTES(KNUM)+SBYTES - UNKNOWN_RECVBYTES(KNUM)=UNKNOWN_RECVBYTES(KNUM)+RBYTES + IF (LSTATS_MPL .AND. CCTYPE(KNUM) .EQ. 'MPL') THEN + CALL MPL_STATSON(NSEND, SBYTES, NRECV, RBYTES) + UNKNOWN_NUMSEND(KNUM) = UNKNOWN_NUMSEND(KNUM) + NSEND + UNKNOWN_NUMRECV(KNUM) = UNKNOWN_NUMRECV(KNUM) + NRECV + UNKNOWN_SENDBYTES(KNUM) = UNKNOWN_SENDBYTES(KNUM) + SBYTES + UNKNOWN_RECVBYTES(KNUM) = UNKNOWN_RECVBYTES(KNUM) + RBYTES ENDIF - ELSEIF( KSWITCH == 1 ) THEN -! Finish timing event - ZTIME = THISTIME(KNUM)+(ZCLOCK-TIMELCALL(KNUM)) - IF(LSTATS_MPL.AND.CCTYPE(KNUM) .EQ. 'MPL') THEN - CALL MPL_STATSREAD(NSEND,SBYTES,NRECV,RBYTES) - NUMSEND(KNUM)=NUMSEND(KNUM)+NSEND - NUMRECV(KNUM)=NUMRECV(KNUM)+NRECV - SENDBYTES(KNUM)=SENDBYTES(KNUM)+SBYTES - RECVBYTES(KNUM)=RECVBYTES(KNUM)+RBYTES + ELSEIF (KSWITCH == 1) THEN + ! Finish timing event + ZTIME = THISTIME(KNUM) + (ZCLOCK - TIMELCALL(KNUM)) + IF (LSTATS_MPL .AND. CCTYPE(KNUM) .EQ. 'MPL') THEN + CALL MPL_STATSREAD(NSEND, SBYTES, NRECV, RBYTES) + NUMSEND(KNUM) = NUMSEND(KNUM) + NSEND + NUMRECV(KNUM) = NUMRECV(KNUM) + NRECV + SENDBYTES(KNUM) = SENDBYTES(KNUM) + SBYTES + RECVBYTES(KNUM) = RECVBYTES(KNUM) + RBYTES ENDIF - TIMESUM(KNUM) = TIMESUM(KNUM)+ZTIME - TIMESQSUM(KNUM) = TIMESQSUM(KNUM)+ZTIME**2 - TIMEMAX(KNUM) = MAX(TIMEMAX(KNUM),ZTIME) - TTCPUSUM(KNUM) = TTCPUSUM(KNUM)+THISTCPU(KNUM)+ZTCPU-TTCPULCALL(KNUM) - TVCPUSUM(KNUM) = TVCPUSUM(KNUM)+THISVCPU(KNUM)+ZVCPU-TVCPULCALL(KNUM) - IF(MYPROC_STATS.LE.NSTATS_MEM.AND.MYPROC_STATS.NE.0) THEN - IMEM = GETMAXRSS()/1024 + TIMESUM(KNUM) = TIMESUM(KNUM) + ZTIME + TIMESQSUM(KNUM) = TIMESQSUM(KNUM) + ZTIME ** 2 + TIMEMAX(KNUM) = MAX(TIMEMAX(KNUM), ZTIME) + TTCPUSUM(KNUM) = TTCPUSUM(KNUM) + THISTCPU(KNUM) + ZTCPU - TTCPULCALL(KNUM) + TVCPUSUM(KNUM) = TVCPUSUM(KNUM) + THISVCPU(KNUM) + ZVCPU - TVCPULCALL(KNUM) + IF (MYPROC_STATS .LE. NSTATS_MEM .AND. MYPROC_STATS .NE. 0) THEN + IMEM = GETMAXRSS() / 1024 IPAG = GETPAG() - IMEMH = GETHWM()/1024 - IMEMS = GETSTK()/1024 + IMEMH = GETHWM() / 1024 + IMEMS = GETSTK() / 1024 IMEMC = 0 - IF(LSTATS_ALLOC) IMEMC = GETCURHEAP()/1024 - IF(IMEM > IIMEM.OR.IPAG > IIPAG.OR.(LSTATS_ALLOC.AND.(IMEMC.NE.IIMEMC))) THEN + IF (LSTATS_ALLOC) IMEMC = GETCURHEAP() / 1024 + IF (IMEM > IIMEM .OR. IPAG > IIPAG .OR. (LSTATS_ALLOC .AND. (IMEMC .NE. IIMEMC))) THEN WRITE(0,'(A10,I5,1X,A20,1X,I6,2(1X,I7),1X,I6,1X,I4,1X,I4,1X,I7)') & - & "MEMORY aft ",KNUM,CCDESC(KNUM),IMEM-IIMEM,IMEM,IMEMH,IMEMS, & - & IPAG-IIPAG,NCALLS(KNUM)/2,IMEMC + & "MEMORY aft ", KNUM, CCDESC(KNUM), IMEM - IIMEM, IMEM, IMEMH, IMEMS, IPAG - IIPAG, & + & NCALLS(KNUM) / 2, IMEMC ENDIF - IIMEM=IMEM - IIPAG=IPAG - IIMEMC=IMEMC - IMEM=IMEM-NTMEM(KNUM,2) - NTMEM(KNUM,4)=NTMEM(KNUM,4)+IMEM - IF(IMEM > NTMEM(KNUM,1)) THEN - NTMEM(KNUM,1)=IMEM - NTMEM(KNUM,3)=NCALLS(KNUM) + IIMEM = IMEM + IIPAG = IPAG + IIMEMC = IMEMC + IMEM = IMEM - NTMEM(KNUM, 2) + NTMEM(KNUM,4) = NTMEM(KNUM, 4) + IMEM + IF (IMEM > NTMEM(KNUM,1)) THEN + NTMEM(KNUM,1) = IMEM + NTMEM(KNUM,3) = NCALLS(KNUM) ENDIF - IF(IMEM < NTMEM(KNUM,5)) NTMEM(KNUM,5)=IMEM + IF (IMEM < NTMEM(KNUM,5)) NTMEM(KNUM,5) = IMEM ENDIF -! Save counters that result in large delays - IF( KNUM >= 500 .AND. NCALLS(KNUM)/2 > 10 )THEN - IF( ZTIME > TIMESUM(KNUM)/FLOAT(NCALLS(KNUM)/2) + 0.2_JPRD )THEN - ! ignore counters 1007 and 1013 due to NFRLW frequency LW radiation calls + ! Save counters that result in large delays + IF (KNUM >= 500 .AND. NCALLS(KNUM) / 2 > 10)THEN + IF (ZTIME > TIMESUM(KNUM) / FLOAT(NCALLS(KNUM)/2) + 0.2_JPRD) THEN + ! Ignore counters 1007 and 1013 due to NFRLW frequency LW radiation calls ! in ec_phys_tl and ec_phys_ad call trees ! also ignore 635 and 636 due to increasing sujbwavallo matrix sizes - IF( KNUM /= 1007 .AND. KNUM /= 1013 .AND. KNUM /= 635 .AND. KNUM /= 636 )THEN - IF( NDELAY_INDEX < JPMAXDELAYS )THEN - NDELAY_INDEX=NDELAY_INDEX+1 - NDELAY_COUNTER(NDELAY_INDEX)=KNUM - TDELAY_VALUE(NDELAY_INDEX)=ZTIME-TIMESUM(KNUM)/FLOAT(NCALLS(KNUM)/2) - CALL DATE_AND_TIME(CLDATEOD,CDELAY_TIME(NDELAY_INDEX),CLZONEOD,IVALUES) + IF (KNUM /= 1007 .AND. KNUM /= 1013 .AND. KNUM /= 635 .AND. KNUM /= 636 ) THEN + IF (NDELAY_INDEX < JPMAXDELAYS) THEN + NDELAY_INDEX = NDELAY_INDEX + 1 + NDELAY_COUNTER(NDELAY_INDEX) = KNUM + TDELAY_VALUE(NDELAY_INDEX) = ZTIME - TIMESUM(KNUM) / FLOAT(NCALLS(KNUM) / 2) + CALL DATE_AND_TIME(CLDATEOD, CDELAY_TIME(NDELAY_INDEX), CLZONEOD, IVALUES) ENDIF ENDIF ENDIF ENDIF - ELSEIF( KSWITCH == 2 ) THEN -! Suspend timing event - ZTIMED = ZCLOCK-TIMELCALL(KNUM) - THISTIME(KNUM) = THISTIME(KNUM)+ZTIMED - THISTCPU(KNUM) = THISTCPU(KNUM)+ZTCPU-TTCPULCALL(KNUM) - THISVCPU(KNUM) = THISVCPU(KNUM)+ZVCPU-TVCPULCALL(KNUM) - IF(LSTATS_MPL.AND.CCTYPE(KNUM) .EQ. 'MPL') THEN - CALL MPL_STATSREAD(NSEND,SBYTES,NRECV,RBYTES) - NUMSEND(KNUM)=NUMSEND(KNUM)+NSEND - NUMRECV(KNUM)=NUMRECV(KNUM)+NRECV - SENDBYTES(KNUM)=SENDBYTES(KNUM)+SBYTES - RECVBYTES(KNUM)=RECVBYTES(KNUM)+RBYTES + ELSEIF (KSWITCH == 2) THEN + ! Suspend timing event + ZTIMED = ZCLOCK - TIMELCALL(KNUM) + THISTIME(KNUM) = THISTIME(KNUM) + ZTIMED + THISTCPU(KNUM) = THISTCPU(KNUM) + ZTCPU - TTCPULCALL(KNUM) + THISVCPU(KNUM) = THISVCPU(KNUM) + ZVCPU - TVCPULCALL(KNUM) + IF (LSTATS_MPL .AND. CCTYPE(KNUM) .EQ. 'MPL') THEN + CALL MPL_STATSREAD(NSEND, SBYTES, NRECV, RBYTES) + NUMSEND(KNUM) = NUMSEND(KNUM) + NSEND + NUMRECV(KNUM) = NUMRECV(KNUM) + NRECV + SENDBYTES(KNUM) = SENDBYTES(KNUM) + SBYTES + RECVBYTES(KNUM) = RECVBYTES(KNUM) + RBYTES ENDIF - ELSEIF( KSWITCH == 3 ) THEN -! Resume timing event + ELSEIF (KSWITCH == 3) THEN + ! Resume timing event TIMELCALL(KNUM) = ZCLOCK TTCPULCALL(KNUM) = ZTCPU TVCPULCALL(KNUM) = ZVCPU - IF(LSTATS_MPL.AND.CCTYPE(KNUM) .EQ. 'MPL') THEN - CALL MPL_STATSON(NSEND,SBYTES,NRECV,RBYTES) - UNKNOWN_NUMSEND(KNUM)=UNKNOWN_NUMSEND(KNUM)+NSEND - UNKNOWN_NUMRECV(KNUM)=UNKNOWN_NUMRECV(KNUM)+NRECV - UNKNOWN_SENDBYTES(KNUM)=UNKNOWN_SENDBYTES(KNUM)+SBYTES - UNKNOWN_RECVBYTES(KNUM)=UNKNOWN_RECVBYTES(KNUM)+RBYTES + IF (LSTATS_MPL .AND. CCTYPE(KNUM) .EQ. 'MPL') THEN + CALL MPL_STATSON(NSEND, SBYTES, NRECV, RBYTES) + UNKNOWN_NUMSEND(KNUM) = UNKNOWN_NUMSEND(KNUM) + NSEND + UNKNOWN_NUMRECV(KNUM) = UNKNOWN_NUMRECV(KNUM) + NRECV + UNKNOWN_SENDBYTES(KNUM) = UNKNOWN_SENDBYTES(KNUM) + SBYTES + UNKNOWN_RECVBYTES(KNUM) = UNKNOWN_RECVBYTES(KNUM) + RBYTES ENDIF - IF(KNUM>=500)THEN - ZTIMED = ZCLOCK-TIME_LAST_CALL - TIMESUMB(KNUM) = TIMESUMB(KNUM)+ZTIMED + IF (KNUM >= 500) THEN + ZTIMED = ZCLOCK - TIME_LAST_CALL + TIMESUMB(KNUM) = TIMESUMB(KNUM) + ZTIMED ENDIF ENDIF - IF(KNUM >= 500)THEN + IF (KNUM >= 500) THEN TIME_LAST_CALL = ZCLOCK ENDIF -! Trace stats - NCALLS_TOTAL = NCALLS_TOTAL+1 + ! Trace stats + NCALLS_TOTAL = NCALLS_TOTAL + 1 IF (LTRACE_STATS .AND. NCALLS_TOTAL <= NTRACE_STATS) THEN ICALL = NCALLS_TOTAL TIME_TRACE(ICALL) = ZCLOCK - NCALL_TRACE(ICALL) = (JPMAXSTAT+1)*KSWITCH+KNUM + NCALL_TRACE(ICALL) = (JPMAXSTAT+1) * KSWITCH + KNUM ENDIF -! measure gstats overhead + ! Measure gstats overhead CALL USER_CLOCK(PELAPSED_TIME=ZCLOCK1) - TIMESUM(400) = TIMESUM(400)+ZCLOCK1-ZCLOCK - NCALLS(400) = NCALLS(400)+1 - LAST_KSWITCH=KSWITCH - LAST_KNUM=KNUM - -! ZSUM=SUM(TIMESUM(500:JPMAXSTAT)) -! ZSUMB=SUM(TIMESUMB(500:JPMAXSTAT)) -! ZTOT=ZCLOCK1-TIMELCALL(0) -! IF( (ZSUM+ZSUMB)/ZTOT >1.0_JPRD )THEN -! write(0,'("GSTATS_DEBUG: KNUM=",I6," KSWITCH=",I1," (zsum+zsumb)/ztot=",F10.6)')& -! &KNUM,KSWITCH,(zsum+zsumb)/ztot -! ENDIF + TIMESUM(400) = TIMESUM(400) + ZCLOCK1 - ZCLOCK + NCALLS(400) = NCALLS(400) + 1 + LAST_KSWITCH = KSWITCH + LAST_KNUM = KNUM ENDIF -99999 CONTINUE END SUBROUTINE GSTATS diff --git a/src/fiat/gstats/gstats_barrier.F90 b/src/fiat/gstats/gstats_barrier.F90 index 723f8a9a..cacf5635 100644 --- a/src/fiat/gstats/gstats_barrier.F90 +++ b/src/fiat/gstats/gstats_barrier.F90 @@ -10,20 +10,18 @@ SUBROUTINE GSTATS_BARRIER(KNUM) -USE EC_PARKIND ,ONLY : JPIM - -USE YOMGSTATS, ONLY : LBARRIER_STATS -USE MPL_MODULE , ONLY : MPL_BARRIER +USE EC_PARKIND, ONLY: JPIM +USE YOMGSTATS, ONLY: LBARRIER_STATS +USE MPL_MODULE, ONLY: MPL_BARRIER IMPLICIT NONE INTEGER(KIND=JPIM) :: KNUM -IF(LBARRIER_STATS)THEN - CALL GSTATS(KNUM,0) +IF (LBARRIER_STATS) THEN + CALL GSTATS(KNUM, 0) CALL MPL_BARRIER() - CALL GSTATS(KNUM,1) + CALL GSTATS(KNUM, 1) ENDIF END SUBROUTINE GSTATS_BARRIER - diff --git a/src/fiat/gstats/gstats_barrier2.F90 b/src/fiat/gstats/gstats_barrier2.F90 index 38ac0e69..66a4f46a 100644 --- a/src/fiat/gstats/gstats_barrier2.F90 +++ b/src/fiat/gstats/gstats_barrier2.F90 @@ -10,27 +10,25 @@ SUBROUTINE GSTATS_BARRIER2(KNUM) -USE EC_PARKIND ,ONLY : JPIM - -USE YOMGSTATS, ONLY : LBARRIER_STATS2,NBAR_PTR,NBAR2 -USE MPL_MODULE , ONLY : MPL_BARRIER +USE EC_PARKIND, ONLY: JPIM +USE YOMGSTATS, ONLY: LBARRIER_STATS2, NBAR_PTR, NBAR2 +USE MPL_MODULE, ONLY: MPL_BARRIER IMPLICIT NONE INTEGER(KIND=JPIM) :: KNUM INTEGER(KIND=JPIM) :: INUM -IF(LBARRIER_STATS2)THEN - IF(NBAR_PTR(KNUM) == 0) THEN - INUM=NBAR2 - NBAR2=NBAR2+1 - NBAR_PTR(KNUM)=INUM +IF (LBARRIER_STATS2) THEN + IF (NBAR_PTR(KNUM) == 0) THEN + INUM = NBAR2 + NBAR2 = NBAR2 + 1 + NBAR_PTR(KNUM) = INUM ENDIF - INUM=NBAR_PTR(KNUM) - CALL GSTATS(INUM,0) + INUM = NBAR_PTR(KNUM) + CALL GSTATS(INUM, 0) CALL MPL_BARRIER() - CALL GSTATS(INUM,1) + CALL GSTATS(INUM, 1) ENDIF END SUBROUTINE GSTATS_BARRIER2 - diff --git a/src/fiat/gstats/gstats_label.F90 b/src/fiat/gstats/gstats_label.F90 index 2fdf1ad6..eb183b56 100644 --- a/src/fiat/gstats/gstats_label.F90 +++ b/src/fiat/gstats/gstats_label.F90 @@ -8,31 +8,29 @@ ! nor does it submit to any jurisdiction. ! -SUBROUTINE GSTATS_LABEL(KNUM,CTYPE,CDESC) +SUBROUTINE GSTATS_LABEL(KNUM, CTYPE, CDESC) -USE EC_PARKIND ,ONLY : JPIM - -USE YOMGSTATS +USE EC_PARKIND, ONLY: JPIM +USE YOMGSTATS, ONLY: JPMAXSTAT, CCDESC, CCTYPE, JPERR IMPLICIT NONE INTEGER(KIND=JPIM) :: KNUM -CHARACTER(*) CDESC -CHARACTER(*) CTYPE +CHARACTER(*) :: CDESC +CHARACTER(*) :: CTYPE INTEGER(KIND=JPIM) :: ILEN, ITLEN -IF(KNUM < 0 .OR. KNUM>JPMAXSTAT) CALL ABOR1('GSTATS_LABEL:ILLEGAL KNUM') +IF (KNUM < 0 .OR. KNUM > JPMAXSTAT) CALL ABOR1('GSTATS_LABEL:ILLEGAL KNUM') ILEN = LEN(CDESC) ILEN = MIN(ILEN,50) ITLEN = LEN(CTYPE) ITLEN = MIN(ILEN,3) -IF(CCDESC(KNUM) == '') THEN +IF (CCDESC(KNUM) == '') THEN CCDESC(KNUM) = CDESC(1:ILEN) CCTYPE(KNUM) = CTYPE(1:ITLEN) -ELSEIF(CCDESC(KNUM)(1:ILEN) /= CDESC(1:ILEN)) THEN - WRITE(JPERR,*)'LABEL',KNUM,' USED ',CCDESC(KNUM) +ELSEIF (CCDESC(KNUM)(1:ILEN) /= CDESC(1:ILEN)) THEN + WRITE(JPERR,*) 'LABEL', KNUM, ' USED ', CCDESC(KNUM) CALL ABOR1('GSTATS_LABEL:OVERWRITE OF USED LABEL') ENDIF END SUBROUTINE GSTATS_LABEL - diff --git a/src/fiat/gstats/gstats_print.F90 b/src/fiat/gstats/gstats_print.F90 index a8a08c98..91e7dbeb 100644 --- a/src/fiat/gstats/gstats_print.F90 +++ b/src/fiat/gstats/gstats_print.F90 @@ -55,11 +55,17 @@ SUBROUTINE GSTATS_PRINT(KULOUT,PAVEAVE,KLEN) ! F. Vana 05-Mar-2015 Support for single precision ! G. Mozdzynski 18-Aug-2015 Avoid confusion, procs are tasks ! ------------------------------------------------------------------ -USE EC_PARKIND ,ONLY : JPRD, JPIM -USE YOMGSTATS -USE MPL_MODULE -USE MPL_STATS_MOD +USE EC_PARKIND, ONLY: JPRD, JPIM +USE YOMGSTATS, ONLY: JPMAXDELAYS, JPMAXSTAT, NPROC_STATS, LXML_STATS, MYPROC_STATS, LSYNCSTATS, & + & LDETAILED_STATS, LSTATS_COMMS, LSTATS_OMP, LBARRIER_STATS2, JBMAXBASE, & + & NBAR_PTR, CCDESC, CCTYPE, LSTATS, TIMESUM, TIMESQSUM, TIMEMAX, TIMESUMB, & + & TIMELCALL, NCALLS, TTCPUSUM, TVCPUSUM, JPTAGSTAT, NPRCIDS_STATS, LSTATS_MPL, & + & NUMSEND, SENDBYTES, NUMRECV, RECVBYTES, LSTATSCPU, NPRNT_STATS, TIME_START, & + & UNKNOWN_NUMSEND, UNKNOWN_NUMRECV, UNKNOWN_SENDBYTES, UNKNOWN_RECVBYTES, & + & NDELAY_INDEX, NDELAY_COUNTER, TDELAY_VALUE, CDELAY_TIME, LTRACE_STATS, & + & NCALLS_TOTAL, NTRACE_STATS, NCALL_TRACE, TIME_TRACE, LSTATS_MEM, NTMEM +USE MPL_MODULE, ONLY: MPL_SEND, MPL_RECV, MPL_BARRIER IMPLICIT NONE @@ -110,8 +116,6 @@ SUBROUTINE GSTATS_PRINT(KULOUT,PAVEAVE,KLEN) ! ------------------------------------------------------------------ -! write(0,*) "JPMAXSTAT,NPRNT_STATS =",JPMAXSTAT,NPRNT_STATS - ILBUF = JPARRAYS*(JPMAXSTAT+1) ILRECV = 500*4 ZAVEAVE(:) = 0.0_JPRD @@ -305,7 +309,6 @@ SUBROUTINE GSTATS_PRINT(KULOUT,PAVEAVE,KLEN) ZT_SUMB=ZT_SUMB+ZSUMB ENDIF IF( LDETAILED_STATS .AND. JROC <= NPRNT_STATS ) THEN -! IF(JNUM < 501 .OR. LSTATS_COMMS .OR. LSTATS_OMP) THEN WRITE(KULOUT,'(I4,1X,A3,1X,A40,1X,I5,6(1X,F9.1),1X,F5.1,1X,F8.2)')& &JNUM,CCTYPE(JNUM),CCDESC(JNUM),ICALLS,ZSUM,ZAVE,ZAVETCPU,ZAVEVCPU,& &ZSTDDEV,ZMAX,ZSUMB,ZFRAC @@ -325,12 +328,9 @@ SUBROUTINE GSTATS_PRINT(KULOUT,PAVEAVE,KLEN) & '',ZFRAC,'',& & '' ENDIF -! ENDIF ENDIF ENDIF ENDDO -! ZCOMTIM = SUM(TIMESUM(51:99))+SUM(TIMESUM(151:199)) -! ZDETAIL = SUM(TIMESUM(:))-TIMESUM(0)-TIMESUM(1)-SUM(TIMESUM(20:23)) IF( LDETAILED_STATS .AND. JROC <= NPRNT_STATS ) THEN WRITE(KULOUT,*) '' WRITE(KULOUT,'((A,2F8.1))')& diff --git a/src/fiat/gstats/gstats_psut.F90 b/src/fiat/gstats/gstats_psut.F90 index 7b315541..bcb963e9 100644 --- a/src/fiat/gstats/gstats_psut.F90 +++ b/src/fiat/gstats/gstats_psut.F90 @@ -12,20 +12,18 @@ SUBROUTINE GSTATS_PSUT ! MEASURE PARALLELL START UP TIME -USE EC_PARKIND ,ONLY : JPRD, JPIM - -USE YOMGSTATS -USE MPL_MODULE - +USE EC_PARKIND, ONLY: JPRD, JPIM +USE YOMGSTATS, ONLY: NPROC_STATS, JPTAGSTAT, MYPROC_STATS, TIME_START, TIMELCALL, NPRCIDS_STATS +USE MPL_MODULE, ONLY: MPL_BARRIER, MPL_SEND, MPL_RECV IMPLICIT NONE -INTEGER(KIND=JPIM) :: ITAG,ILSEND,ILBUF,JROC,IRECV,ISEND -REAL(KIND=JPRD) :: ZTBUF(2),ZCLOCK,ZCLOCKB +INTEGER(KIND=JPIM) :: ITAG, ILSEND, ILBUF, JROC, IRECV, ISEND +REAL(KIND=JPRD) :: ZTBUF(2), ZCLOCK, ZCLOCKB #include "user_clock.intfb.h" -IF(NPROC_STATS > 1) THEN +IF (NPROC_STATS > 1) THEN CALL USER_CLOCK(PELAPSED_TIME=ZCLOCKB) CALL MPL_BARRIER CALL USER_CLOCK(PELAPSED_TIME=ZCLOCK) @@ -35,19 +33,17 @@ SUBROUTINE GSTATS_PSUT TIME_START(1) = ZCLOCKB - TIMELCALL(0) ILBUF = 2 ENDIF - DO JROC=2,NPROC_STATS + DO JROC = 2, NPROC_STATS IF (MYPROC_STATS .EQ. JROC ) THEN ZTBUF(1) = ZCLOCKB ZTBUF(2) = ZCLOCK ILSEND = 2 ISEND = 1 - CALL MPL_SEND(ZTBUF(1:ILSEND),KDEST=NPRCIDS_STATS(ISEND), & - & KTAG=ITAG,CDSTRING='SUSTATS:') + CALL MPL_SEND(ZTBUF(1:ILSEND), KDEST=NPRCIDS_STATS(ISEND), KTAG=ITAG, CDSTRING='SUSTATS:') ELSEIF (MYPROC_STATS == 1 ) THEN IRECV = JROC - CALL MPL_RECV(ZTBUF(1:ILBUF),KSOURCE=NPRCIDS_STATS(IRECV), & - & KTAG=ITAG,CDSTRING='SUSTATS:') - TIME_START(JROC) = ZTBUF(1) - TIMELCALL(0) -(ZTBUF(2)-ZCLOCK) + CALL MPL_RECV(ZTBUF(1:ILBUF), KSOURCE=NPRCIDS_STATS(IRECV), KTAG=ITAG, CDSTRING='SUSTATS:') + TIME_START(JROC) = ZTBUF(1) - TIMELCALL(0) - (ZTBUF(2) - ZCLOCK) ENDIF CALL MPL_BARRIER ENDDO diff --git a/src/fiat/gstats/gstats_setup.F90 b/src/fiat/gstats/gstats_setup.F90 index 0b8a8291..e4a30add 100644 --- a/src/fiat/gstats/gstats_setup.F90 +++ b/src/fiat/gstats/gstats_setup.F90 @@ -54,10 +54,14 @@ SUBROUTINE GSTATS_SETUP( KPROC,KMYPROC,KPRCIDS,& ! rather than LBARRIER_STATS ! ------------------------------------------------------------------ -USE EC_PARKIND ,ONLY : JPIM ,JPRD - -USE YOMGSTATS -USE MPL_STATS_MOD +USE EC_PARKIND, ONLY: JPIM, JPRD +USE YOMGSTATS, ONLY: LSTATS, LSTATSCPU, LSYNCSTATS, LDETAILED_STATS, LBARRIER_STATS, & + & LBARRIER_STATS2, LXML_STATS, LSTATS_OMP, LSTATS_COMMS, NSTATS_MEM, & + & LSTATS_MEM, LSTATS_ALLOC, LTRACE_STATS, NTRACE_STATS, MYPROC_STATS, & + & NPROC_STATS, NPRCIDS_STATS, NCALL_TRACE, TIME_TRACE, LSTATS_MPL, NUMSEND, & + & NUMRECV, SENDBYTES, RECVBYTES, UNKNOWN_NUMSEND, UNKNOWN_NUMRECV, & + & UNKNOWN_SENDBYTES, UNKNOWN_RECVBYTES, NPRNT_STATS +USE MPL_STATS_MOD, ONLY: MPL_STATSINIT IMPLICIT NONE @@ -93,15 +97,15 @@ SUBROUTINE GSTATS_SETUP( KPROC,KMYPROC,KPRCIDS,& LSTATS_MEM = LDSTATS_MEM LSTATS_ALLOC = LDSTATS_ALLOC LTRACE_STATS = LDTRACE_STATS -IF(LTRACE_STATS) NTRACE_STATS = KTRACE_STATS +IF (LTRACE_STATS) NTRACE_STATS = KTRACE_STATS MYPROC_STATS = KMYPROC NPROC_STATS = KPROC ALLOCATE(NPRCIDS_STATS(NPROC_STATS)) NPRCIDS_STATS(:) = KPRCIDS(1:NPROC_STATS) -IF(NPROC_STATS == 1) LSYNCSTATS = .FALSE. +IF (NPROC_STATS == 1) LSYNCSTATS = .FALSE. -IF (LTRACE_STATS .AND. NTRACE_STATS>0 ) THEN +IF (LTRACE_STATS .AND. NTRACE_STATS > 0) THEN ALLOCATE(NCALL_TRACE(NTRACE_STATS)) ALLOCATE(TIME_TRACE (NTRACE_STATS)) NCALL_TRACE(:) = 0 @@ -109,8 +113,8 @@ SUBROUTINE GSTATS_SETUP( KPROC,KMYPROC,KPRCIDS,& ENDIF -IF(LDETAILED_STATS) THEN - LSTATS_MPL=.TRUE. +IF (LDETAILED_STATS) THEN + LSTATS_MPL = .TRUE. ALLOCATE(NUMSEND(501:1000)) ALLOCATE(NUMRECV(501:1000)) ALLOCATE(SENDBYTES(501:1000)) @@ -119,22 +123,17 @@ SUBROUTINE GSTATS_SETUP( KPROC,KMYPROC,KPRCIDS,& ALLOCATE(UNKNOWN_NUMRECV(501:1000)) ALLOCATE(UNKNOWN_SENDBYTES(501:1000)) ALLOCATE(UNKNOWN_RECVBYTES(501:1000)) - NUMSEND(:)=0 - NUMRECV(:)=0 - SENDBYTES(:)=0 - RECVBYTES(:)=0 - UNKNOWN_NUMSEND(:)=0 - UNKNOWN_NUMRECV(:)=0 - UNKNOWN_SENDBYTES(:)=0 - UNKNOWN_RECVBYTES(:)=0 + NUMSEND(:) = 0 + NUMRECV(:) = 0 + SENDBYTES(:) = 0 + RECVBYTES(:) = 0 + UNKNOWN_NUMSEND(:) = 0 + UNKNOWN_NUMRECV(:) = 0 + UNKNOWN_SENDBYTES(:) = 0 + UNKNOWN_RECVBYTES(:) = 0 CALL MPL_STATSINIT ENDIF -NPRNT_STATS=KPRNT_STATS - -! write(0,*) "GSTATS_SETUP: NPRNT_STATS=",NPRNT_STATS +NPRNT_STATS = KPRNT_STATS -RETURN END SUBROUTINE GSTATS_SETUP - - diff --git a/src/fiat/gstats/yomgstats.F90 b/src/fiat/gstats/yomgstats.F90 index 1c680b9e..508c9798 100644 --- a/src/fiat/gstats/yomgstats.F90 +++ b/src/fiat/gstats/yomgstats.F90 @@ -10,7 +10,7 @@ MODULE YOMGSTATS -USE EC_PARKIND ,ONLY : JPRD, JPIM +USE EC_PARKIND, ONLY: JPRD, JPIM IMPLICIT NONE