From ce46f0f452cba498510dde4b6129f522313e0fed Mon Sep 17 00:00:00 2001 From: Jorn Bruggeman Date: Thu, 25 Jul 2024 21:23:09 +0100 Subject: [PATCH] fix logging when there are unfulfilled dependencies (#82) --- src/fabm_job.F90 | 65 +++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/fabm_job.F90 b/src/fabm_job.F90 index 7c3c7bb2..4f4a1406 100644 --- a/src/fabm_job.F90 +++ b/src/fabm_job.F90 @@ -574,36 +574,43 @@ subroutine task_print(self, unit, indent, specific_variable) indent_ = 0 if (present(indent)) indent_ = indent - if (size(self%load) > 0 .or. size(self%load_hz) > 0 .or. size(self%load_scalar) > 0) write (unit,'(a,a)') repeat(' ', indent_), 'Read cache prefilling:' - do i = 1, size(self%load) - if (self%load(i) /= 0) write (unit,'(a," - interior[",i0,"]")') repeat(' ', indent_), i - end do - do i = 1, size(self%load_hz) - if (self%load_hz(i) /= 0) write (unit,'(a," - horizontal[",i0,"]")') repeat(' ', indent_), i - end do - do i = 1, size(self%load_scalar) - if (self%load_scalar(i) /= 0) write (unit,'(a," - scalar[",i0,"]")') repeat(' ', indent_), i - end do + ! Print out prefill instructions for the read and write caches + ! These instructions have only been allocated if all dependencies were fulfilled. + ! Since we want to support logging even if that is not the case, we explicitly check the allocation status. + if (allocated(self%load)) then + if (size(self%load) > 0 .or. size(self%load_hz) > 0 .or. size(self%load_scalar) > 0) & + write (unit,'(a,a)') repeat(' ', indent_), 'Read cache prefilling:' + do i = 1, size(self%load) + if (self%load(i) /= 0) write (unit,'(a," - interior[",i0,"]")') repeat(' ', indent_), i + end do + do i = 1, size(self%load_hz) + if (self%load_hz(i) /= 0) write (unit,'(a," - horizontal[",i0,"]")') repeat(' ', indent_), i + end do + do i = 1, size(self%load_scalar) + if (self%load_scalar(i) /= 0) write (unit,'(a," - scalar[",i0,"]")') repeat(' ', indent_), i + end do - if (size(self%prefill) > 0 .or. size(self%prefill_hz) > 0) write (unit,'(a,a)') repeat(' ', indent_), 'Write cache prefilling:' - do i = 1, size(self%prefill) - select case (self%prefill(i)) - case (prefill_none) - case (prefill_constant) - write (unit,'(a," - interior[",i0,"] = constant value")') repeat(' ', indent_), i - case default - write (unit,'(a," - interior[",i0,"] = previous value")') repeat(' ', indent_), i - end select - end do - do i = 1, size(self%prefill_hz) - select case (self%prefill_hz(i)) - case (prefill_none) - case (prefill_constant) - write (unit,'(a," - horizontal[",i0,"] = constant value")') repeat(' ', indent_), i - case default - write (unit,'(a," - horizontal[",i0,"] = previous value")') repeat(' ', indent_), i - end select - end do + if (size(self%prefill) > 0 .or. size(self%prefill_hz) > 0) & + write (unit,'(a,a)') repeat(' ', indent_), 'Write cache prefilling:' + do i = 1, size(self%prefill) + select case (self%prefill(i)) + case (prefill_none) + case (prefill_constant) + write (unit,'(a," - interior[",i0,"] = constant value")') repeat(' ', indent_), i + case default + write (unit,'(a," - interior[",i0,"] = previous value")') repeat(' ', indent_), i + end select + end do + do i = 1, size(self%prefill_hz) + select case (self%prefill_hz(i)) + case (prefill_none) + case (prefill_constant) + write (unit,'(a," - horizontal[",i0,"] = constant value")') repeat(' ', indent_), i + case default + write (unit,'(a," - horizontal[",i0,"] = previous value")') repeat(' ', indent_), i + end select + end do + end if do icall = 1, size(self%calls) header_written = .false.