From d0f8e9f2c45268c278abe09025464c1b994e08df Mon Sep 17 00:00:00 2001
From: sebastien masson <smasson@Macintosh-62.local>
Date: Wed, 1 Dec 2021 17:00:14 +0100
Subject: [PATCH] update mppini for XIOS: force to keep 1 land domain by band
 of MPI domains

---
 src/OCE/LBC/mppini.F90 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/OCE/LBC/mppini.F90 b/src/OCE/LBC/mppini.F90
index 5087828e2..4cbfe0f48 100644
--- a/src/OCE/LBC/mppini.F90
+++ b/src/OCE/LBC/mppini.F90
@@ -948,7 +948,7 @@ CONTAINS
       !
       INTEGER :: idiv, iimax, ijmax, iarea
       INTEGER :: inbi, inbj, inx, iny, inry, isty
-      INTEGER :: ji, jn
+      INTEGER :: ji, jj, jn
       INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   inboce           ! number oce oce pint in each mpi subdomain
       INTEGER, ALLOCATABLE, DIMENSION(:  ) ::   inboce_1d
       INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   iimppt, ijpi
@@ -1038,6 +1038,15 @@ CONTAINS
       ldIsOce(:,:) = inboce(:,:) /= 0
       DEALLOCATE(inboce, inboce_1d)
       !
+#if defined key_xios
+      ! Only when using XIOS: XIOS does a domain decomposition only in bands (for IO performances).
+      !                       XIOS is crashing if one of these bands contains only land-domains which have been suppressed.
+      ! -> solution (before a fix of xios): force to keep at least one land-domain by band of mpi domains
+      DO jj = 1, inbj
+         IF( COUNT( ldIsOce(:,jj) ) == 0 )   ldIsOce(1,jj) = .TRUE.   ! for to keep 1st MPI domain in the row of domains
+      END DO
+#endif      
+      !
    END SUBROUTINE mpp_is_ocean
 
 
-- 
GitLab