From cab889133ab1c9d2c338660a07b64724b09c8071 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 6 Sep 2024 13:15:45 -0600 Subject: [PATCH] Get mapunit_value_max across all processors Resolves ESCOMP/CTSM#2744 --- tools/mksurfdata_esmf/src/mksoiltexMod.F90 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/mksurfdata_esmf/src/mksoiltexMod.F90 b/tools/mksurfdata_esmf/src/mksoiltexMod.F90 index efbb12ec0d..4014de1b92 100644 --- a/tools/mksurfdata_esmf/src/mksoiltexMod.F90 +++ b/tools/mksurfdata_esmf/src/mksoiltexMod.F90 @@ -13,13 +13,15 @@ module mksoiltexMod use mkutilsMod , only : chkerr use mkdiagnosticsMod , only : output_diagnostics_index use mkfileMod , only : mkfile_output - use mkvarctl , only : root_task, ndiag, spval + use mkvarctl , only : root_task, ndiag, spval, mpicom use mkvarctl , only : unsetsoil use mkvarpar , only : nlevsoi implicit none private ! By default make data private +#include + public :: mksoiltex ! Set soil texture integer :: mapunit_value_max @@ -61,6 +63,7 @@ subroutine mksoiltex(file_mesh_i, file_mapunit_i, file_lookup_i, mesh_o, pioid_o integer :: k,l,m,n integer :: nlay ! number of soil layers integer :: n_scid + integer :: mapunit_value_max_local integer , allocatable :: mask_i(:) real(r4), pointer :: dataptr(:) integer :: mapunit ! temporary igbp soil mapunit @@ -203,7 +206,8 @@ subroutine mksoiltex(file_mesh_i, file_mapunit_i, file_lookup_i, mesh_o, pioid_o ! Determine mapunit_value_max (set it as a module variable so that it can be ! accessible to gen_dominant_mapunit) - this is needed in the dynamic mask routine - mapunit_value_max = maxval(dataptr) + mapunit_value_max_local = maxval(dataptr) + call mpi_allreduce(mapunit_value_max_local, mapunit_value_max, 1, MPI_INTEGER, MPI_MAX, mpicom, rcode) ! Determine values in field_o call ESMF_FieldGet(field_o, farrayptr=dataptr, rc=rc)