Skip to content

Commit 09af9d7

Browse files
committed
Allow passing values of type integer(8)/integer(kind=I8KIND) to mpas_log_write.
1 parent 73b588d commit 09af9d7

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/framework/mpas_log.F

+26-7
Original file line numberDiff line numberDiff line change
@@ -470,15 +470,15 @@ end subroutine mpas_log_open
470470
!> regardless of if all tasks have open log files.
471471
!> flushNow: flag indicating the message should be flushed immediately.
472472
!> Note: error and critical error messages are always flushed immediately.
473-
!> intArgs, realArgs, logicArgs: arrays of variable values to be inserted into the
474-
!> message to replace the following characters: $i, $r, $l
473+
!> intArgs, int8Args,realArgs, logicArgs: arrays of variable values to be inserted into the
474+
!> message to replace the following characters: $i, $w, $r, $l
475475
!> See routine log_expand_string below for details.
476476
!>
477477
!
478478
!-----------------------------------------------------------------------
479479

480480
recursive subroutine mpas_log_write(message, messageType, masterOnly, flushNow, &
481-
intArgs, realArgs, logicArgs, err)
481+
intArgs, int8Args, realArgs, logicArgs, err)
482482

483483
use mpas_threading
484484

@@ -492,6 +492,7 @@ recursive subroutine mpas_log_write(message, messageType, masterOnly, flushNow,
492492
logical, intent(in), optional :: masterOnly !< Input: flag to only print message on master task
493493
logical, intent(in), optional :: flushNow !< Input: flag to force a flush of the message buffer
494494
integer, dimension(:), intent(in), optional :: intArgs !< Input: integer variable values to insert into message
495+
integer(kind=I8KIND), dimension(:), intent(in), optional :: int8Args !< Input: integer variable values to insert into message
495496
real(kind=RKIND), dimension(:), intent(in), optional :: realArgs !< Input: real variable values to insert into message
496497
!< Input: exponential notation variable values to insert into message
497498
logical, dimension(:), intent(in), optional :: logicArgs !< Input: logical variable values to insert into message
@@ -540,7 +541,7 @@ recursive subroutine mpas_log_write(message, messageType, masterOnly, flushNow,
540541

541542

542543
! Construct message by expanding variable values as needed and inserting message type prefix
543-
call log_expand_string(message, messageExpanded, intArgs=intArgs, logicArgs=logicArgs, realArgs=realArgs)
544+
call log_expand_string(message, messageExpanded, intArgs=intArgs, int8Args=int8Args, logicArgs=logicArgs, realArgs=realArgs)
544545

545546
! Determine message prefix
546547
select case (messageTypeHere)
@@ -870,6 +871,7 @@ end subroutine log_abort
870871
!> The variables to be expanded are represented with a '$' symbol followed
871872
!> by one of these indicators:
872873
!> $i -> integer, formatted to be length of integer
874+
!> $w -> integer(kind=I8KIND), formatted to be length of integer
873875
!> $l -> logical, fomatted as 'T' or 'F'
874876
!> $r -> real, formatted as 9 digits of precision for SP mode, 17 for DP mode
875877
!> Floats are formatted using 'G' format which is smart about
@@ -886,7 +888,7 @@ end subroutine log_abort
886888
!> can be handled by the string concatenation command (//).
887889
!> This routine is based off of mpas_expand_string.
888890
!-----------------------------------------------------------------------
889-
subroutine log_expand_string(inString, outString, intArgs, logicArgs, realArgs)
891+
subroutine log_expand_string(inString, outString, intArgs, int8Args, logicArgs, realArgs)
890892

891893
implicit none
892894

@@ -896,6 +898,7 @@ subroutine log_expand_string(inString, outString, intArgs, logicArgs, realArgs)
896898
character (len=*), intent(in) :: inString !< Input: message to be expanded
897899

898900
integer, dimension(:), intent(in), optional :: intArgs
901+
integer(kind=I8KIND), dimension(:), intent(in), optional :: int8Args
899902
!< Input, Optional: array of integer variable values to be used in expansion
900903
logical, dimension(:), intent(in), optional :: logicArgs
901904
!< Input, Optional: array of logical variable values to be used in expansion
@@ -915,8 +918,8 @@ subroutine log_expand_string(inString, outString, intArgs, logicArgs, realArgs)
915918
! local variables
916919
!-----------------------------------------------------------------
917920
integer :: i, curLen
918-
integer :: nInts, nLogicals, nReals, nExps !< the length of the variable arrays passed in
919-
integer :: iInt, iLogical, iReal !< Counter for the current index into each variable array
921+
integer :: nInts, nInt8s, nLogicals, nReals, nExps !< the length of the variable arrays passed in
922+
integer :: iInt, iInt8, iLogical, iReal !< Counter for the current index into each variable array
920923
character (len=ShortStrKIND) :: realFormat !< Format string to create to use for writing real variables to log file
921924
integer :: realPrecision !< precision of a real variable
922925

@@ -926,6 +929,7 @@ subroutine log_expand_string(inString, outString, intArgs, logicArgs, realArgs)
926929

927930
! Initialize the current index for each variable array to 1
928931
iInt = 1
932+
iInt8 = 1
929933
iLogical = 1
930934
iReal = 1
931935

@@ -936,6 +940,12 @@ subroutine log_expand_string(inString, outString, intArgs, logicArgs, realArgs)
936940
nInts = 0
937941
endif
938942

943+
if (present(int8Args)) then
944+
nInt8s = size(int8Args)
945+
else
946+
nInt8s = 0
947+
endif
948+
939949
if (present(logicArgs)) then
940950
nLogicals = size(logicArgs)
941951
else
@@ -973,6 +983,15 @@ subroutine log_expand_string(inString, outString, intArgs, logicArgs, realArgs)
973983
else
974984
varPart = errVarPart
975985
endif
986+
case ('w')
987+
! make the format large enough to include a large integer (up to 17 digits for 8-byte int)
988+
! it will be trimmed below
989+
if (iInt8 <= nInt8s) then
990+
write(varPart,'(i17)') int8Args(iInt8)
991+
iInt8 = iInt8 + 1
992+
else
993+
varPart = errVarPart
994+
endif
976995
case ('l')
977996
if (iLogical <= nLogicals) then
978997
if (logicArgs(iLogical)) then

0 commit comments

Comments
 (0)