Skip to content

Commit

Permalink
Spring clean GSTATS (#15)
Browse files Browse the repository at this point in the history
* Remove commented-out code

* Improve indentation

* Remove unused MPL_MODULE import in GSTATS

* Qualify all module imports

* Improve GSTATS error reporting

* Remove GOTO statement

* Improve readability of GSTATS

* Remove unused variables

* Adjust whitespace to improve readability

* Improve some old fashioned code
  • Loading branch information
samhatfield authored Feb 27, 2024
1 parent 1b311a3 commit 066e3f9
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 310 deletions.
438 changes: 208 additions & 230 deletions src/fiat/gstats/gstats.F90

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions src/fiat/gstats/gstats_barrier.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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

24 changes: 11 additions & 13 deletions src/fiat/gstats/gstats_barrier2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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

20 changes: 9 additions & 11 deletions src/fiat/gstats/gstats_label.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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

20 changes: 10 additions & 10 deletions src/fiat/gstats/gstats_print.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -325,12 +328,9 @@ SUBROUTINE GSTATS_PRINT(KULOUT,PAVEAVE,KLEN)
& '<frac unit="percent">',ZFRAC,'</frac>',&
& '</num>'
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))')&
Expand Down
24 changes: 10 additions & 14 deletions src/fiat/gstats/gstats_psut.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
45 changes: 22 additions & 23 deletions src/fiat/gstats/gstats_setup.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -93,24 +97,24 @@ 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
TIME_TRACE (:) = 0.0_JPRD
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))
Expand All @@ -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


2 changes: 1 addition & 1 deletion src/fiat/gstats/yomgstats.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

MODULE YOMGSTATS

USE EC_PARKIND ,ONLY : JPRD, JPIM
USE EC_PARKIND, ONLY: JPRD, JPIM

IMPLICIT NONE

Expand Down

0 comments on commit 066e3f9

Please sign in to comment.