From e72443f5ece72b688f3cc59438fe738ecdee0e8b Mon Sep 17 00:00:00 2001
From: Gaelle Tanguy <gaelle.tanguy@meteo.fr>
Date: Thu, 26 Nov 2015 14:51:46 +0000
Subject: [PATCH] G.Delautier 11/2015 correction dor arome files

---
 src/SURFEX/mode_read_extern.F90 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/SURFEX/mode_read_extern.F90 b/src/SURFEX/mode_read_extern.F90
index 7f5fcb524..b5417c8c9 100644
--- a/src/SURFEX/mode_read_extern.F90
+++ b/src/SURFEX/mode_read_extern.F90
@@ -541,6 +541,8 @@ DEALLOCATE(ZSOILGRID)
 ALLOCATE(ZNAT(KNI))
 IF (IVERSION>=7) THEN
   CALL READ_SURF(HFILEPGDTYPE,'FRAC_NATURE',ZNAT,IRESP,HDIR='A')
+ELSE
+  ZNAT=1.0  
 ENDIF
 
 !
@@ -634,7 +636,7 @@ IF (HFIELD=='WG    ' .OR. HFIELD=='WGI   ') THEN
   IF (HFIELD=='WG    ') THEN
     DO JPATCH=1,IPATCH
       DO JLAYER=1,ILAYER
-        WHERE(ZNAT(:)>0.0)
+        WHERE(ZNAT(:)>0.0 .AND. ZVAR(:,JLAYER,JPATCH)/=XUNDEF)
           ZVAR(:,JLAYER,JPATCH) = MAX(MIN(ZVAR(:,JLAYER,JPATCH),ZWSAT(:)),0.)
           !
           ZFIELD(:,JLAYER,JPATCH) = (ZVAR(:,JLAYER,JPATCH) - ZWWILT(:)) / (ZWFC(:) - ZWWILT(:))
@@ -644,7 +646,7 @@ IF (HFIELD=='WG    ' .OR. HFIELD=='WGI   ') THEN
   ELSE IF (HFIELD=='WGI   ') THEN
     DO JPATCH=1,IPATCH
       DO JLAYER=1,ILAYER
-        WHERE(ZNAT(:)>0.0)
+        WHERE(ZNAT(:)>0.0 .AND. ZVAR(:,JLAYER,JPATCH)/=XUNDEF)
           ZFIELD(:,JLAYER,JPATCH) = ZVAR(:,JLAYER,JPATCH) / ZWSAT(:)  
         END WHERE 
       END DO
-- 
GitLab