Skip to content

Commit

Permalink
Get mapunit_value_max across all processors
Browse files Browse the repository at this point in the history
Resolves ESCOMP#2744
  • Loading branch information
billsacks committed Sep 6, 2024
1 parent ffdd332 commit 10319de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/mksurfdata_esmf/src/mksoiltexMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mpif.h>

public :: mksoiltex ! Set soil texture

integer :: mapunit_value_max
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -202,7 +205,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)
Expand Down

0 comments on commit 10319de

Please sign in to comment.