From 69fe1d316f3f0c13d30998b8a09baa9d6b12e9bd Mon Sep 17 00:00:00 2001 From: Mohit Dalvi Date: Wed, 16 Sep 2026 11:14:39 +0100 Subject: [PATCH 1/6] Remove check for presence of optional diagnostic data arrays, and set pointers to internal arrays only if any diags required in current call. --- .../ukca_diagnostics_set_ptrs_mod.F90 | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 b/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 index a6608b1..deeba43 100644 --- a/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 +++ b/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 @@ -169,20 +169,8 @@ SUBROUTINE set_diag_ptrs_1d_domain(error_code_ptr, ukca_config, diagnostics, & ELSE ! No request array set up for this group - diagnostics%n_request(dgroup_flat_real) = 0 - ! Check data array is absent - IF (PRESENT(data_flat_real)) THEN - error_code_ptr = errcode_diag_mismatch - IF (ASSOCIATED(diag2d_copy_out)) THEN - message_txt = message_txt_data_array_redundant // ' (flat real group)' - ELSE - message_txt = & - 'Array present for unrequested diagnostic output (flat real group)' - END IF - END IF - END IF IF (error_code_ptr > 0) THEN @@ -235,22 +223,8 @@ SUBROUTINE set_diag_ptrs_1d_domain(error_code_ptr, ukca_config, diagnostics, & ELSE ! No request array set up for this group - diagnostics%n_request(dgroup_fullht_real) = 0 - ! Check data array is absent - IF (PRESENT(data_fullht_real)) THEN - error_code_ptr = errcode_diag_mismatch - IF (ASSOCIATED(diag3d_copy_out)) THEN - message_txt = message_txt_data_array_redundant // & - ' (full height real group)' - ELSE - message_txt = & - 'Array present for unrequested diagnostic output ' // & - '(full height real group)' - END IF - END IF - END IF IF (error_code_ptr > 0) THEN @@ -261,7 +235,7 @@ SUBROUTINE set_diag_ptrs_1d_domain(error_code_ptr, ukca_config, diagnostics, & END IF ! Record number of spatial dimensions in use for each diagnostic group -! and set pointers +! and set pointers if any diagnostics are requested in this call. IF (ASSOCIATED(diag2d_copy_out)) THEN diagnostics%dimension_out(dgroup_flat_real) = imdi @@ -275,13 +249,15 @@ SUBROUTINE set_diag_ptrs_1d_domain(error_code_ptr, ukca_config, diagnostics, & diagnostics%dimension_out(dgroup_fullht_real) = 1 END IF -IF (PRESENT(data_flat_real)) THEN +IF ( PRESENT(data_flat_real) .AND. & + diagnostics%n_request(dgroup_flat_real) > 0 ) THEN diagnostics%value_0d_real_ptr => data_flat_real ELSE NULLIFY(diagnostics%value_0d_real_ptr) END IF -IF (PRESENT(data_fullht_real)) THEN +IF ( PRESENT(data_fullht_real) .AND. & + diagnostics%n_request(dgroup_fullht_real) > 0 ) THEN diagnostics%value_1d_real_ptr => data_fullht_real ELSE NULLIFY(diagnostics%value_1d_real_ptr) From e49ceffa08e1c9cf89f80d9339ec8f43d31c5338 Mon Sep 17 00:00:00 2001 From: Mohit Dalvi Date: Wed, 16 Sep 2026 13:46:34 +0100 Subject: [PATCH 2/6] minor --- src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 b/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 index deeba43..458d339 100644 --- a/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 +++ b/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 @@ -235,7 +235,7 @@ SUBROUTINE set_diag_ptrs_1d_domain(error_code_ptr, ukca_config, diagnostics, & END IF ! Record number of spatial dimensions in use for each diagnostic group -! and set pointers if any diagnostics are requested in this call. +! and set pointers only if any diagnostics are requested in this call. IF (ASSOCIATED(diag2d_copy_out)) THEN diagnostics%dimension_out(dgroup_flat_real) = imdi From 13b4287aee086fad5c0633e452f4d1f193698973 Mon Sep 17 00:00:00 2001 From: Mohit Dalvi Date: Wed, 16 Sep 2026 14:00:26 +0100 Subject: [PATCH 3/6] Update code for in other version of the routine. --- .../ukca_diagnostics_set_ptrs_mod.F90 | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 b/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 index 458d339..b764e2a 100644 --- a/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 +++ b/src/control/core/interface/ukca_diagnostics_set_ptrs_mod.F90 @@ -384,20 +384,8 @@ SUBROUTINE set_diag_ptrs_3d_domain(error_code_ptr, ukca_config, diagnostics, & ELSE ! No request array set up for this group - diagnostics%n_request(dgroup_flat_real) = 0 - ! Check data array is absent - IF (PRESENT(data_flat_real)) THEN - error_code_ptr = errcode_diag_mismatch - IF (ASSOCIATED(diag2d_copy_out)) THEN - message_txt = message_txt_data_array_redundant // ' (flat real group)' - ELSE - message_txt = & - 'Array present for unrequested diagnostic output (flat real group)' - END IF - END IF - END IF IF (error_code_ptr > 0) THEN @@ -452,22 +440,8 @@ SUBROUTINE set_diag_ptrs_3d_domain(error_code_ptr, ukca_config, diagnostics, & ELSE ! No request array set up for this group - diagnostics%n_request(dgroup_fullht_real) = 0 - ! Check data array is absent - IF (PRESENT(data_fullht_real)) THEN - error_code_ptr = errcode_diag_mismatch - IF (ASSOCIATED(diag3d_copy_out)) THEN - message_txt = message_txt_data_array_redundant // & - ' (full height real group)' - ELSE - message_txt = & - 'Array present for unrequested diagnostic output ' // & - '(full height real group)' - END IF - END IF - END IF IF (error_code_ptr > 0) THEN @@ -478,7 +452,7 @@ SUBROUTINE set_diag_ptrs_3d_domain(error_code_ptr, ukca_config, diagnostics, & END IF ! Record number of spatial dimensions in use for each diagnostic group -! and set pointers +! and set pointers only if any diagnostics are requested in this call. IF (ASSOCIATED(diag2d_copy_out)) THEN diagnostics%dimension_out(dgroup_flat_real) = imdi @@ -492,13 +466,15 @@ SUBROUTINE set_diag_ptrs_3d_domain(error_code_ptr, ukca_config, diagnostics, & diagnostics%dimension_out(dgroup_fullht_real) = 3 END IF -IF (PRESENT(data_flat_real)) THEN +IF (PRESENT(data_flat_real) .AND. & + diagnostics%n_request(dgroup_flat_real) > 0 ) THEN diagnostics%value_2d_real_ptr => data_flat_real ELSE NULLIFY(diagnostics%value_2d_real_ptr) END IF -IF (PRESENT(data_fullht_real)) THEN +IF (PRESENT(data_fullht_real) .AND. & + diagnostics%n_request(dgroup_fullht_real) > 0 ) THEN diagnostics%value_3d_real_ptr => data_fullht_real ELSE NULLIFY(diagnostics%value_3d_real_ptr) From 00223c7bd7002adb770eb4fbc6c2736f27e92b33 Mon Sep 17 00:00:00 2001 From: Mohit Dalvi Date: Wed, 23 Sep 2026 17:40:18 +0100 Subject: [PATCH 4/6] Another fix - routine checks for 2-D diag group by default, instead of the group passed in. --- src/control/core/interface/ukca_diagnostics_output_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/control/core/interface/ukca_diagnostics_output_mod.F90 b/src/control/core/interface/ukca_diagnostics_output_mod.F90 index 8f62eff..de55fd9 100644 --- a/src/control/core/interface/ukca_diagnostics_output_mod.F90 +++ b/src/control/core/interface/ukca_diagnostics_output_mod.F90 @@ -701,7 +701,7 @@ SUBROUTINE output_diag_status(error_code_ptr, group, diagnostics, & IF (PRESENT(error_message)) error_message = '' IF (PRESENT(error_routine)) error_routine = '' -IF (ALLOCATED(diagnostics%requests_ptr(dgroup_flat_real)%varnames)) THEN +IF (ALLOCATED(diagnostics%requests_ptr(group)%varnames)) THEN n_req = diagnostics%n_request(group) IF (SIZE(status_flags) /= n_req) THEN error_code_ptr = errcode_diag_mismatch From ad27d4dca0c5961eadcc5805165a9b0f2083be24 Mon Sep 17 00:00:00 2001 From: Mohit Dalvi Date: Wed, 23 Sep 2026 23:28:27 +0100 Subject: [PATCH 5/6] Remove check for status flags, as array will anyway be populated only if n_req > 0. --- src/control/core/interface/ukca_diagnostics_output_mod.F90 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/control/core/interface/ukca_diagnostics_output_mod.F90 b/src/control/core/interface/ukca_diagnostics_output_mod.F90 index de55fd9..470a47b 100644 --- a/src/control/core/interface/ukca_diagnostics_output_mod.F90 +++ b/src/control/core/interface/ukca_diagnostics_output_mod.F90 @@ -710,10 +710,7 @@ SUBROUTINE output_diag_status(error_code_ptr, group, diagnostics, & 'diagnostics (group ', group, ')' END IF ELSE - error_code_ptr = errcode_diag_mismatch - WRITE(message_txt,'(A,I0,A)') & - 'Status flag array present but diagnostic requests are not set ' // & - '(group ', group, ')' + n_req = 0 END IF IF (error_code_ptr > 0) THEN From e8462089f6b455146f3a4aed03491f0ef89c16f1 Mon Sep 17 00:00:00 2001 From: Mohit Dalvi Date: Tue, 6 Oct 2026 15:25:07 +0100 Subject: [PATCH 6/6] Added name to CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index de11f63..0724228 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -9,3 +9,4 @@ | JoeCartonKelly-MO | Joseph Carton-Kelly | Met Office | 2026-04-15 | | yg460-cam | Yao Ge | University of Cambridge | 2026-04-17 | | theabro | Nathan Luke Abraham | NCAS & University of Cambridge | 2026-03-19 | +| mcdalvi | Mohit Dalvi | Met Office | 2026-10-06 |