From a6e177f084d5bf1f3e8a25d924f825665c8a38bd Mon Sep 17 00:00:00 2001 From: "Andrew C. Ross" Date: Wed, 20 Mar 2024 15:34:52 -0400 Subject: [PATCH] Check if diag_field_id is > 0 before calling post_data_MOM --- generic_tracers/generic_tracer_utils.F90 | 60 +++++++++++++----------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/generic_tracers/generic_tracer_utils.F90 b/generic_tracers/generic_tracer_utils.F90 index ef83680..5d8c461 100644 --- a/generic_tracers/generic_tracer_utils.F90 +++ b/generic_tracers/generic_tracer_utils.F90 @@ -3975,14 +3975,15 @@ LOGICAL FUNCTION g_send_data_0d(diag_field_id, field, time, err_msg, diag_CS) #ifdef _USE_MOM6_DIAG type(g_diag_ctrl), pointer :: diag_CS_ptr - - if(present(diag_CS)) then - diag_CS_ptr => diag_CS - else - call g_tracer_get_diagCS(diag_CS_ptr) + if(diag_field_id .gt. 0) then + if(present(diag_CS)) then + diag_CS_ptr => diag_CS + else + call g_tracer_get_diagCS(diag_CS_ptr) + endif + call post_data_MOM(diag_field_id, field, diag_CS_ptr) + g_send_data_0d = .TRUE. endif - call post_data_MOM(diag_field_id, field, diag_CS_ptr) - g_send_data_0d = .TRUE. #else g_send_data_0d = send_data_FMS(diag_field_id, field, time, err_msg) #endif @@ -4002,14 +4003,15 @@ LOGICAL FUNCTION g_send_data_1d(diag_field_id, field, time, is_in, mask, rmask, #ifdef _USE_MOM6_DIAG type(g_diag_ctrl), pointer :: diag_CS_ptr - - if(present(diag_CS)) then - diag_CS_ptr => diag_CS - else - call g_tracer_get_diagCS(diag_CS_ptr) + if(diag_field_id .gt. 0) then + if(present(diag_CS)) then + diag_CS_ptr => diag_CS + else + call g_tracer_get_diagCS(diag_CS_ptr) + endif + call post_data_MOM(diag_field_id, field, diag_CS_ptr) + g_send_data_1d = .TRUE. endif - call post_data_MOM(diag_field_id, field, diag_CS_ptr) - g_send_data_1d = .TRUE. #else g_send_data_1d = send_data_FMS(diag_field_id, field, time, is_in, mask, rmask, ie_in, weight, err_msg) #endif @@ -4030,14 +4032,15 @@ LOGICAL FUNCTION g_send_data_2d(diag_field_id, field, time, is_in, js_in, & #ifdef _USE_MOM6_DIAG type(g_diag_ctrl), pointer :: diag_CS_ptr - - if(present(diag_CS)) then - diag_CS_ptr => diag_CS - else - call g_tracer_get_diagCS(diag_CS_ptr) + if(diag_field_id .gt. 0) then + if(present(diag_CS)) then + diag_CS_ptr => diag_CS + else + call g_tracer_get_diagCS(diag_CS_ptr) + endif + call post_data_MOM(diag_field_id, field, diag_CS_ptr)!, mask=rmask) + g_send_data_2d = .TRUE. endif - call post_data_MOM(diag_field_id, field, diag_CS_ptr)!, mask=rmask) - g_send_data_2d = .TRUE. #else g_send_data_2d = send_data_FMS(diag_field_id, field, time, is_in, js_in, & & mask, rmask, ie_in, je_in, weight, err_msg) @@ -4059,14 +4062,15 @@ LOGICAL FUNCTION g_send_data_3d(diag_field_id, field, time, is_in, js_in, ks_in, #ifdef _USE_MOM6_DIAG type(g_diag_ctrl), pointer :: diag_CS_ptr - - if(present(diag_CS)) then - diag_CS_ptr => diag_CS - else - call g_tracer_get_diagCS(diag_CS_ptr) + if(diag_field_id .gt. 0) then + if(present(diag_CS)) then + diag_CS_ptr => diag_CS + else + call g_tracer_get_diagCS(diag_CS_ptr) + endif + call post_data_MOM(diag_field_id, field, diag_CS_ptr)!, mask=rmask) + g_send_data_3d = .TRUE. endif - call post_data_MOM(diag_field_id, field, diag_CS_ptr)!, mask=rmask) - g_send_data_3d = .TRUE. #else g_send_data_3d = send_data_FMS(diag_field_id, field, time, is_in, js_in, ks_in, & & mask, rmask, ie_in, je_in, ke_in, weight, err_msg)