From a2c8ef6405d0b9e0870bfcd9b7a4332f3be43581 Mon Sep 17 00:00:00 2001
From: Gaelle Tanguy <gaelle.tanguy@meteo.fr>
Date: Fri, 18 Dec 2015 14:26:31 +0000
Subject: [PATCH]  Juan 18/12/2015 : correction for NHALO<>1

---
 src/MNH/bikhardt.f90        |  6 +++---
 src/MNH/flash_geom_elec.f90 |  6 ++----
 src/MNH/ini_one_wayn.f90    | 15 +++++++++------
 src/MNH/ini_spawn_lsn.f90   | 14 ++++++++------
 src/MNH/ion_attach_elec.f90 |  6 ++----
 src/MNH/one_wayn.f90        | 15 +++++++++------
 src/MNH/spawn_lsn.f90       | 14 ++++++++------
 7 files changed, 41 insertions(+), 35 deletions(-)

diff --git a/src/MNH/bikhardt.f90 b/src/MNH/bikhardt.f90
index 599f52176..a049ec315 100644
--- a/src/MNH/bikhardt.f90
+++ b/src/MNH/bikhardt.f90
@@ -171,6 +171,7 @@ END MODULE MODI_BIKHARDT4D
 !!                             list to avoid duplication. 
 !!     V. Masson and F. Gheusi (10/10/97) bug in cyclic case
 !!     J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1 
+!!     J.Escobar : 18/12/2015 : set valide default values in corner in // for NHALO <>1 
 !-------------------------------------------------------------------------------
 !
 !*       0.     DECLARATIONS
@@ -268,7 +269,8 @@ IF ( HLBCY(1) == 'CYCL' ) THEN
 END IF
 !-------------------------------------------------------------------------------
 !
-PFIELD2 = 0.0
+PFIELD2 = ZFIELD1(1,1,1,1) ! some valide values for missing ones
+!
 SELECT CASE (KGRID)
 !
 !*      2.1    Mass points
@@ -286,10 +288,8 @@ SELECT CASE (KGRID)
       ZBMY3 = PBMY3(JEPSY)
       ZBMY4 = PBMY4(JEPSY)
       DO JI = KXOR,KXEND
-!!$        IIF = IIB+JEPSX-1           +(JI-KXOR-JPHEXT)*KDXRATIO
         IIS = IIB+JEPSX-1+KDXRATIO/2+(JI-KXOR-JPHEXT)*KDXRATIO
         DO JJ = KYOR,KYEND
-!!$          IJF = IJB+JEPSY-1           +(JJ-KYOR-JPHEXT)*KDYRATIO
           IJS = IJB+JEPSY-1+KDYRATIO/2+(JJ-KYOR-JPHEXT)*KDYRATIO
 !
           IF (1 <= IIS .AND. IIS <= IIU .AND. 1 <= IJS .AND. IJS <= IJU) THEN
diff --git a/src/MNH/flash_geom_elec.f90 b/src/MNH/flash_geom_elec.f90
index c6d39b48f..ce170ef9a 100644
--- a/src/MNH/flash_geom_elec.f90
+++ b/src/MNH/flash_geom_elec.f90
@@ -81,6 +81,7 @@ END MODULE MODI_FLASH_GEOM_ELEC_n
 !!      J-P Pinty * LA *  Nov. 2013 : add flash map storage
 !!      M. Chong  * LA *  Juin 2010 : add LiNOx
 !!      C. Barthe * LACy * Jan. 2015 : convert trig. pt into lat,lon in ascii file
+!!      J.Escobar : 18/12/2015 : Correction of bug in bound in // for NHALO <>1 
 !!
 !-------------------------------------------------------------------------------
 !
@@ -308,10 +309,7 @@ CALL MYPROC_ELEC_ll(IPROC)
 !*      1.1     subdomains indexes
 !
 ! beginning and end indexes of the physical subdomain
-IIB = 1 + JPHEXT
-IIE = SIZE(PRT,1) - JPHEXT
-IJB = 1 + JPHEXT
-IJE = SIZE(PRT,2) - JPHEXT
+CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
 IKB = 1 + JPVEXT
 IKE = SIZE(PRT,3) - JPVEXT
 IKU = SIZE(PRT,3)
diff --git a/src/MNH/ini_one_wayn.f90 b/src/MNH/ini_one_wayn.f90
index d1a3f7ca4..6db1416cb 100644
--- a/src/MNH/ini_one_wayn.f90
+++ b/src/MNH/ini_one_wayn.f90
@@ -141,6 +141,7 @@ SUBROUTINE INI_ONE_WAY_n(KDAD,HLUOUT,PTSTEP,KMI,KTCOUNT,                 &
 !!                   07/2010  idem for ice phase chemical species
 !!    Bosseur & Filippi 07/2013 Adds Forefire
 !!    J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1 
+!!      J.Escobar : 18/12/2015 : Correction of bug in bound in // for NHALO <>1 
 !!
 !------------------------------------------------------------------------------
 !
@@ -212,7 +213,7 @@ REAL, DIMENSION(:,:,:,:),INTENT(OUT)  :: PLBXSVM ,PLBYSVM  ! in x and y-dir.
 !
 !*       0.2   declarations of local variables
 !
-INTEGER                :: IIB,IIE,IJB,IJE
+INTEGER                :: IIB,IIE,IJB,IJE,IIU,IJU
 INTEGER                :: ILBX,ILBY,ILBX2,ILBY2
 REAL,   DIMENSION(:,:,:), ALLOCATABLE  :: ZWORK
 LOGICAL  :: GVERT_INTERP
@@ -239,11 +240,13 @@ REAL, DIMENSION(:,:,:,:), ALLOCATABLE :: ZCHEMMI  ! chemical ice phase concentra
 ! 
 CALL GOTO_MODEL(KDAD)
 !
-CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
-IIB=IIB-JPHEXT
-IIE=IIE+JPHEXT
-IJB=IJB-JPHEXT
-IJE=IJE+JPHEXT
+!!$CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
+CALL GET_DIM_EXT_ll ('B',IIU,IJU)
+IIB=1
+IIE=IIU
+IJB=1
+IJE=IJU
+
 ALLOCATE(ZWORK(IIB:IIE,IJB:IJE,SIZE(PLBXTHM,3)))  ! can be smaller than child extended subdomain
 ! LS_FORCING routine can not correctly manage extra halo zone
 ! LB will be filled only with one layer halo zone for the moment
diff --git a/src/MNH/ini_spawn_lsn.f90 b/src/MNH/ini_spawn_lsn.f90
index f2a63d23e..8c5809786 100644
--- a/src/MNH/ini_spawn_lsn.f90
+++ b/src/MNH/ini_spawn_lsn.f90
@@ -139,6 +139,7 @@ END MODULE MODI_INI_SPAWN_LS_n
 !!                   09/07/98  ( J. Stein ) bug in the storage of the interp
 !!                                          coeff for U
 !!      J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1 
+!!      J.Escobar : 18/12/2015 : Correction of bug in bound in // for NHALO <>1 
 !------------------------------------------------------------------------------
 !
 !*      0.   DECLARATIONS
@@ -209,7 +210,7 @@ INTEGER                :: JI                      ! Loop index
 INTEGER, DIMENSION(SIZE(PZZ,1),SIZE(PZZ,2),SIZE(PCOEFLIN_LBXM,3))   :: IKLIN
 REAL   , DIMENSION(SIZE(PZZ,1),SIZE(PZZ,2),SIZE(PCOEFLIN_LBXM,3))   :: ZCOEFLIN
 INTEGER                :: ILBX,ILBY,ILBX2,ILBY2
-INTEGER                :: IIB,IJB,IIE,IJE,IKU
+INTEGER                :: IIB,IJB,IIE,IJE,IIU,IJU,IKU
 REAL   , DIMENSION(SIZE(PZZ,1),SIZE(PZZ,2),1)                       :: ZZSLS
 REAL   , DIMENSION(SIZE(PZZ,1),SIZE(PZZ,2),1)                       :: ZZSMTLS
 REAL   , DIMENSION(SIZE(PZZ,1),SIZE(PZZ,2),SIZE(PCOEFLIN_LBXM,3))   :: ZZSS
@@ -237,11 +238,12 @@ REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZTZSMT,ZZSMT
 !
 CALL GOTO_MODEL(KDAD)
 !
-CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
-IIB=IIB-JPHEXT
-IIE=IIE+JPHEXT
-IJB=IJB-JPHEXT
-IJE=IJE+JPHEXT
+!!$CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
+CALL GET_DIM_EXT_ll ('B',IIU,IJU)
+IIB=1
+IIE=IIU
+IJB=1
+IJE=IJU
 !
 !*      1 GATHER LS FIELD FOR THE CHILD MODEL KMI
 !
diff --git a/src/MNH/ion_attach_elec.f90 b/src/MNH/ion_attach_elec.f90
index 33963eb14..90a6f300e 100644
--- a/src/MNH/ion_attach_elec.f90
+++ b/src/MNH/ion_attach_elec.f90
@@ -74,6 +74,7 @@ END MODULE MODI_ION_ATTACH_ELEC
 !!    -------------
 !!      Original    2010
 !!      Modifications:
+!!      J.Escobar : 18/12/2015 : Correction of bug in bound in // for NHALO <>1 
 !!
 !-------------------------------------------------------------------------------
 !
@@ -149,10 +150,7 @@ REAL    :: ZCOMB         ! Recombination
 ZCQD = 4 * XPI * XEPSILON * XBOLTZ / XECHARGE
 ZCDIF = XBOLTZ /XECHARGE
 !
-IIB = 1 + JPHEXT
-IIE = SIZE(PTHT,1) - JPHEXT
-IJB = 1 + JPHEXT
-IJE = SIZE(PTHT,2) - JPHEXT
+CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
 IKB = 1 + JPVEXT
 IKE = SIZE(PTHT,3) - JPVEXT
 !
diff --git a/src/MNH/one_wayn.f90 b/src/MNH/one_wayn.f90
index 38f722963..90ee35c4a 100644
--- a/src/MNH/one_wayn.f90
+++ b/src/MNH/one_wayn.f90
@@ -189,6 +189,7 @@ SUBROUTINE ONE_WAY_n(KDAD,HLUOUT,PTSTEP,KMI,KTCOUNT,                     &
 !!                   07/2010  idem for ice phase chemical species
 !!    Bosseur & Filippi 07/2013 Adds Forefire
 !!   J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1
+!!      J.Escobar : 18/12/2015 : Correction of bug in bound in // for NHALO <>1 
 !------------------------------------------------------------------------------
 !
 !*      0.   DECLARATIONS
@@ -270,7 +271,7 @@ REAL, DIMENSION(:,:,:,:),INTENT(OUT) :: PLBXSVS ,PLBYSVS  ! in x and y-dir.
 !*       0.2   declarations of local variables
 !
 REAL                   :: ZTIME                   ! Interpolation length
-INTEGER                :: IIB,IIE,IJB,IJE
+INTEGER                :: IIB,IIE,IJB,IJE,IIU,IJU
 INTEGER                :: ILBX,ILBY,ILBX2,ILBY2
 REAL     ::   ZBIGTSTEP    ! time step of the dad model ($n)
 REAL     ::   ZRV_O_RD     ! = Rv /  Rd
@@ -306,11 +307,13 @@ CALL GOTO_MODEL(KDAD)
 ALLOCATE(ZJ(SIZE(XRHODJ,1),SIZE(XRHODJ,2),SIZE(XRHODJ,3)))
 ALLOCATE(ZRHOD(SIZE(XRHODJ,1),SIZE(XRHODJ,2),SIZE(XRHODJ,3)))
 !
-CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
-IIB=IIB-JPHEXT
-IIE=IIE+JPHEXT
-IJB=IJB-JPHEXT
-IJE=IJE+JPHEXT
+!!$CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
+CALL GET_DIM_EXT_ll ('B',IIU,IJU)
+IIB=1
+IIE=IIU
+IJB=1
+IJE=IJU
+
 ALLOCATE(ZWORK(IIB:IIE,IJB:IJE,SIZE(PLBXTHM,3)))  ! can be smaller than child extended subdomain
 ! LS_FORCING routine can not correctly manage extra halo zone
 ! LB will be filled only with one layer halo zone for the moment
diff --git a/src/MNH/spawn_lsn.f90 b/src/MNH/spawn_lsn.f90
index 86c686a5d..74f43ed3e 100644
--- a/src/MNH/spawn_lsn.f90
+++ b/src/MNH/spawn_lsn.f90
@@ -124,6 +124,7 @@ END MODULE MODI_SPAWN_LS_n
 !!    -------------
 !!      Original     22/12/97
 !!    P. Jabouille   19/04/00 parallelisation
+!!      J.Escobar : 18/12/2015 : Correction of bug in bound in // for NHALO <>1 
 !!
 !------------------------------------------------------------------------------
 !
@@ -180,7 +181,7 @@ REAL, DIMENSION(:,:,:), INTENT(OUT)   :: PLSUS,PLSVS,PLSWS ! Large Scale source
 !*       0.2   declarations of local variables
 !
 REAL                   :: ZTIME                   ! Interpolation length
-INTEGER                :: IIB,IJB,IIE,IJE,IKU
+INTEGER                :: IIB,IJB,IIE,IJE,IIU,IJU,IKU
 LOGICAL                :: GVERT_INTERP
 INTEGER, DIMENSION(SIZE(PZZ,1),SIZE(PZZ,2),SIZE(PCOEFLIN_LBXM,3))   :: IKLIN
 REAL   , DIMENSION(SIZE(PZZ,1),SIZE(PZZ,2),SIZE(PCOEFLIN_LBXM,3))   :: ZCOEFLIN
@@ -210,11 +211,12 @@ REAL, DIMENSION(:,:,:), ALLOCATABLE :: Z1,Z2,Z3,Z4,Z5
 !
 CALL GOTO_MODEL(KDAD)
 !
-CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
-IIB=IIB-1
-IIE=IIE+1
-IJB=IJB-1
-IJE=IJE+1
+!!$CALL GET_INDICE_ll (IIB,IJB,IIE,IJE)
+CALL GET_DIM_EXT_ll ('B',IIU,IJU)
+IIB=1
+IIE=IIU
+IJB=1
+IJE=IJU
 !
 !*      1 GATHER LS FIELD FOR THE CHILD MODEL KMI
 !
-- 
GitLab