diff --git a/src/ARCH_SRC/surfex/dummy_eggangles.F90 b/src/ARCH_SRC/surfex/dummy_eggangles.F90
index e7742fe01506c64f75995a7bb79b72091220bc9d..2da05b1bcbe0a9badb3a8cf085cec6d1c77f726b 100644
--- a/src/ARCH_SRC/surfex/dummy_eggangles.F90
+++ b/src/ARCH_SRC/surfex/dummy_eggangles.F90
@@ -1,8 +1,13 @@
 MODULE EGGANGLES
-USE PARKIND1  ,ONLY : JPIM,    JPRB
+!-------------------------------------------------------------------------------
+!!    MODIFICATIONS
+!!    -------------
+!!      J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
+!-------------------------------------------------------------------------------
+USE PARKIND1  ,ONLY : JPIM
 TYPE LOLA
   SEQUENCE
-  REAL(KIND=JPRB) :: LON, LAT
+  REAL :: LON, LAT
 END TYPE LOLA
 INTERFACE ANGLE_DOMAIN
   MODULE PROCEDURE ANGLE_DOMAIN_RS, ANGLE_DOMAIN_LOLAS, ANGLE_DOMAIN_RV, ANGLE_DOMAIN_LOLAV
@@ -42,60 +47,60 @@ INTERFACE SIZE_W2E
 END INTERFACE
 
 CONTAINS
-REAL(KIND=JPRB) FUNCTION ANGLE_DOMAIN_RS(ALPHA,PI,DOM,UNIT) RESULT (BETA)
-REAL(KIND=JPRB), INTENT(IN)                           :: ALPHA
+REAL FUNCTION ANGLE_DOMAIN_RS(ALPHA,PI,DOM,UNIT) RESULT (BETA)
+REAL, INTENT(IN)                           :: ALPHA
 CHARACTER (LEN=2), INTENT(IN), OPTIONAL               :: DOM
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL               :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                 :: PI
+REAL, INTENT(IN), OPTIONAL                 :: PI
 END FUNCTION ANGLE_DOMAIN_RS
 TYPE (LOLA) FUNCTION ANGLE_DOMAIN_LOLAS(ALPHA,PI,DOM,UNIT) RESULT (BETA)
 TYPE (LOLA), INTENT(IN)                                :: ALPHA
 CHARACTER (LEN=2), INTENT(IN), OPTIONAL                :: DOM
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL                :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                  :: PI
+REAL, INTENT(IN), OPTIONAL                  :: PI
 END FUNCTION ANGLE_DOMAIN_LOLAS
 ! -------------------------------------------------------------------------------
 FUNCTION ANGLE_DOMAIN_RV(ALPHA,PI,DOM,UNIT) RESULT (BETA)
-REAL(KIND=JPRB), DIMENSION(:), INTENT(IN)             :: ALPHA
+REAL, DIMENSION(:), INTENT(IN)             :: ALPHA
 CHARACTER (LEN=2), INTENT(IN), OPTIONAL               :: DOM
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL               :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                 :: PI
+REAL, INTENT(IN), OPTIONAL                 :: PI
 END FUNCTION ANGLE_DOMAIN_RV
 ! -------------------------------------------------------------------------------
 FUNCTION ANGLE_DOMAIN_LOLAV(YL_ALPHA,PI,DOM,UNIT) RESULT (YD_BETA)
 TYPE (LOLA), DIMENSION(:), INTENT(IN)               :: YL_ALPHA
 CHARACTER (LEN=2), INTENT(IN), OPTIONAL             :: DOM
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL             :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL               :: PI
+REAL, INTENT(IN), OPTIONAL               :: PI
 END FUNCTION ANGLE_DOMAIN_LOLAV
 ! -------------------------------------------------------------------------------
 INTEGER(KIND=JPIM) FUNCTION VAL_LAT_S(LAT,NUM_ERR,PI,UNIT) RESULT(ETAT)
-REAL(KIND=JPRB), INTENT(IN)                          :: LAT
+REAL, INTENT(IN)                          :: LAT
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL              :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                :: PI
+REAL, INTENT(IN), OPTIONAL                :: PI
 INTEGER(KIND=JPIM), INTENT(IN), OPTIONAL             :: NUM_ERR
 END FUNCTION VAL_LAT_S
 ! -------------------------------------------------------------------------------
 INTEGER(KIND=JPIM) FUNCTION VAL_LAT_V(P_LAT,NUM_ERR,PI,UNIT) RESULT(ETAT)
-REAL(KIND=JPRB), DIMENSION(:), INTENT(IN)                 :: P_LAT
+REAL, DIMENSION(:), INTENT(IN)                 :: P_LAT
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL                   :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                     :: PI
+REAL, INTENT(IN), OPTIONAL                     :: PI
 INTEGER(KIND=JPIM), INTENT(IN), OPTIONAL                  :: NUM_ERR
 END FUNCTION VAL_LAT_V
 ! -------------------------------------------------------------------------------
 INTEGER(KIND=JPIM) FUNCTION VAL_LON_S(LON,NUM_ERR,PI,DOM,UNIT) RESULT(ETAT)
-REAL(KIND=JPRB), INTENT(IN)                                :: LON
+REAL, INTENT(IN)                                :: LON
 CHARACTER (LEN=2), INTENT(IN), OPTIONAL                    :: DOM
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL                    :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                      :: PI
+REAL, INTENT(IN), OPTIONAL                      :: PI
 INTEGER(KIND=JPIM), INTENT(IN), OPTIONAL                   :: NUM_ERR
 END FUNCTION VAL_LON_S
 ! -------------------------------------------------------------------------------
 INTEGER(KIND=JPIM) FUNCTION VAL_LON_V(LON,NUM_ERR,PI,DOM,UNIT) RESULT(ETAT)
-REAL(KIND=JPRB), DIMENSION(:), INTENT(IN)                       :: LON
+REAL, DIMENSION(:), INTENT(IN)                       :: LON
 CHARACTER (LEN=2), INTENT(IN), OPTIONAL                         :: DOM
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL                         :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                           :: PI
+REAL, INTENT(IN), OPTIONAL                           :: PI
 INTEGER(KIND=JPIM), INTENT(IN), OPTIONAL                        :: NUM_ERR
 END FUNCTION VAL_LON_V
 ! -------------------------------------------------------------------------------
@@ -103,7 +108,7 @@ INTEGER(KIND=JPIM) FUNCTION VAL_COORD_S(PT_COORD,NUM_ERR,PI,DOM,UNIT) RESULT(ETA
 TYPE (LOLA), INTENT(IN)                               :: PT_COORD
 CHARACTER (LEN=2), INTENT(IN), OPTIONAL               :: DOM
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL               :: UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                 :: PI
+REAL, INTENT(IN), OPTIONAL                 :: PI
 INTEGER(KIND=JPIM), INTENT(IN), OPTIONAL              :: NUM_ERR
 END FUNCTION VAL_COORD_S
 ! -------------------------------------------------------------------------------
@@ -111,7 +116,7 @@ INTEGER(KIND=JPIM) FUNCTION VAL_COORD_V(YD_PT_COORD,K_NUM_ERR,PI,CD_DOM,CD_UNIT)
 TYPE (LOLA), DIMENSION(:), INTENT(IN)                   :: YD_PT_COORD
 CHARACTER (LEN=2), INTENT(IN), OPTIONAL                 :: CD_DOM
 CHARACTER (LEN=1), INTENT(IN), OPTIONAL                 :: CD_UNIT
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                   :: PI
+REAL, INTENT(IN), OPTIONAL                   :: PI
 INTEGER(KIND=JPIM), INTENT(IN), OPTIONAL                :: K_NUM_ERR
 END FUNCTION VAL_COORD_V
 ! -------------------------------------------------------------------------------
@@ -136,73 +141,73 @@ FUNCTION LOLAD_V (COORD_RAD) RESULT (COORD_DEG)
 TYPE(LOLA), DIMENSION(:), INTENT(IN)                :: COORD_RAD
 END FUNCTION LOLAD_V
 ! -------------------------------------------------------------------------------
-REAL(KIND=JPRB) FUNCTION COSIN_TO_ANGLE_S(COSINUS,SINUS) RESULT (ANGLE)
+REAL FUNCTION COSIN_TO_ANGLE_S(COSINUS,SINUS) RESULT (ANGLE)
 ! (Cosinus,Sinus) => Angle
-REAL(KIND=JPRB), INTENT(IN)                  :: COSINUS,SINUS
+REAL, INTENT(IN)                  :: COSINUS,SINUS
 END FUNCTION COSIN_TO_ANGLE_S
 
 FUNCTION COSIN_TO_ANGLE_V(COSINUS,SINUS) RESULT (ANGLE)
 ! (Cosinus,Sinus) => Angle
-REAL(KIND=JPRB), DIMENSION(:), INTENT(IN)              :: COSINUS,SINUS
+REAL, DIMENSION(:), INTENT(IN)              :: COSINUS,SINUS
 END FUNCTION COSIN_TO_ANGLE_V
 ! -------------------------------------------------------------------------------
-REAL(KIND=JPRB) FUNCTION P_ACOS_S(COSINUS) RESULT (ANGLE)
+REAL FUNCTION P_ACOS_S(COSINUS) RESULT (ANGLE)
 ! Protected ACOS
-REAL(KIND=JPRB), INTENT(IN)                  :: COSINUS
+REAL, INTENT(IN)                  :: COSINUS
 END FUNCTION P_ACOS_S
 
 FUNCTION P_ACOS_V(COSINUS) RESULT (ANGLE)
 ! Protected ACOS
-REAL(KIND=JPRB), DIMENSION(:), INTENT(IN)              :: COSINUS
+REAL, DIMENSION(:), INTENT(IN)              :: COSINUS
 END FUNCTION P_ACOS_V
 ! -------------------------------------------------------------------------------
-REAL(KIND=JPRB) FUNCTION P_ASIN_S(SINUS) RESULT (ANGLE)
+REAL FUNCTION P_ASIN_S(SINUS) RESULT (ANGLE)
 ! Protected ASIN
-REAL(KIND=JPRB), INTENT(IN)                  :: SINUS
+REAL, INTENT(IN)                  :: SINUS
 END FUNCTION P_ASIN_S
 
 FUNCTION P_ASIN_V(SINUS) RESULT (ANGLE)
 ! Protected ASIN
-REAL(KIND=JPRB), DIMENSION(:), INTENT(IN)            :: SINUS
+REAL, DIMENSION(:), INTENT(IN)            :: SINUS
 END FUNCTION P_ASIN_V
-REAL(KIND=JPRB) FUNCTION MINIMAX_S(VAL,LIM) RESULT (VALO)
+REAL FUNCTION MINIMAX_S(VAL,LIM) RESULT (VALO)
 ! Return Value in [-LIM,LIM]
-REAL(KIND=JPRB), INTENT(IN)                      :: VAL
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL            :: LIM
+REAL, INTENT(IN)                      :: VAL
+REAL, INTENT(IN), OPTIONAL            :: LIM
 END FUNCTION MINIMAX_S
 FUNCTION MINIMAX_V(VAL,LIM) RESULT (VALO)
 ! Return Value in [-LIM,LIM]
-REAL(KIND=JPRB), DIMENSION(:), INTENT(IN)          :: VAL
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL              :: LIM
-REAL(KIND=JPRB), DIMENSION(SIZE(VAL)) :: VALO
+REAL, DIMENSION(:), INTENT(IN)          :: VAL
+REAL, INTENT(IN), OPTIONAL              :: LIM
+REAL, DIMENSION(SIZE(VAL)) :: VALO
 END FUNCTION MINIMAX_V
 ! -------------------------------------------------------------------------------
-REAL(KIND=JPRB) FUNCTION DIST_2REF_L(COORD_LON,REF_LON,PI) RESULT(DIST)
-REAL(KIND=JPRB), INTENT(IN)                   :: COORD_LON, REF_LON
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL         :: PI       
+REAL FUNCTION DIST_2REF_L(COORD_LON,REF_LON,PI) RESULT(DIST)
+REAL, INTENT(IN)                   :: COORD_LON, REF_LON
+REAL, INTENT(IN), OPTIONAL         :: PI       
 END FUNCTION DIST_2REF_L
 ! -------------------------------------------------------------------------------
-REAL(KIND=JPRB) FUNCTION DIST_2REF_S(PT_COORD,REF_COORD,PI) RESULT(DIST)
+REAL FUNCTION DIST_2REF_S(PT_COORD,REF_COORD,PI) RESULT(DIST)
 
 TYPE (LOLA), INTENT(IN)                       :: PT_COORD, REF_COORD
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL         :: PI 
+REAL, INTENT(IN), OPTIONAL         :: PI 
 END FUNCTION DIST_2REF_S
 ! -------------------------------------------------------------------------------
 FUNCTION DIST_2REF_V(PT_COORD,REF_COORD,PI) RESULT(DIST)
 TYPE (LOLA), DIMENSION(:), INTENT(IN)                   :: PT_COORD
 TYPE (LOLA), INTENT(IN)                                 :: REF_COORD
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL                   :: PI 
-REAL(KIND=JPRB), DIMENSION(SIZE(PT_COORD)) :: DIST
+REAL, INTENT(IN), OPTIONAL                   :: PI 
+REAL, DIMENSION(SIZE(PT_COORD)) :: DIST
 END FUNCTION DIST_2REF_V
 ! -------------------------------------------------------------------------------
-REAL(KIND=JPRB) FUNCTION SIZE_W2E_L(WEST_LON,EAST_LON,PI) RESULT(TAILLE)
-REAL(KIND=JPRB), INTENT(IN)                   :: WEST_LON, EAST_LON
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL         :: PI 
+REAL FUNCTION SIZE_W2E_L(WEST_LON,EAST_LON,PI) RESULT(TAILLE)
+REAL, INTENT(IN)                   :: WEST_LON, EAST_LON
+REAL, INTENT(IN), OPTIONAL         :: PI 
 END FUNCTION SIZE_W2E_L
 ! -------------------------------------------------------------------------------
-REAL(KIND=JPRB) FUNCTION SIZE_W2E_S(WEST_COORD,EAST_COORD,PI) RESULT(TAILLE)
+REAL FUNCTION SIZE_W2E_S(WEST_COORD,EAST_COORD,PI) RESULT(TAILLE)
 TYPE (LOLA), INTENT(IN)                       :: WEST_COORD, EAST_COORD
-REAL(KIND=JPRB), INTENT(IN), OPTIONAL         :: PI 
+REAL, INTENT(IN), OPTIONAL         :: PI 
 END FUNCTION SIZE_W2E_S
 ! -------------------------------------------------------------------------------
 END MODULE EGGANGLES      
diff --git a/src/LIB/RAD/ECMWF_RAD/parkind1.f90 b/src/LIB/RAD/ECMWF_RAD/parkind1.f90
index cf3fd688455b1a96f35038a5e6386d1289d8e76f..a6caebf9c6f87742a8eb2230aa2cbffe2e63f37b 100644
--- a/src/LIB/RAD/ECMWF_RAD/parkind1.f90
+++ b/src/LIB/RAD/ECMWF_RAD/parkind1.f90
@@ -8,6 +8,7 @@ MODULE PARKIND1
 !     *** Define usual kinds for strong typing ***
 !     J.Escobar : 9/06/2015, for I*8 compilation force JPIM to default size
 !     J.-P. Chaboureau: 14/10/2016, adding logical kind JPLM for RTTOV
+!     J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !
 IMPLICIT NONE
 SAVE
@@ -28,7 +29,8 @@ INTEGER, PARAMETER :: JPRT = SELECTED_REAL_KIND(2,1)
 INTEGER, PARAMETER :: JPRS = SELECTED_REAL_KIND(4,2)
 INTEGER, PARAMETER :: JPRM = SELECTED_REAL_KIND(6,37)
 REAL               :: REAL_DEF_JPRB
-INTEGER, PARAMETER :: JPRB = KIND(REAL_DEF_JPRB) ! SELECTED_REAL_KIND(13,300)
+INTEGER, PARAMETER :: JPRB = SELECTED_REAL_KIND(13,300) !  KIND(REAL_DEF_JPRB) 
+INTEGER, PARAMETER :: JPRB_DEF = KIND(REAL_DEF_JPRB) 
 !
 !     Logical Kinds
 !     -------------
diff --git a/src/LIB/SURCOUCHE/src/mode_netcdf.f90 b/src/LIB/SURCOUCHE/src/mode_netcdf.f90
index 8a98a298dbb861027bec45c5cbee21b394bd26c3..7f87881d4c9d8e29eb8d5294d1aa7b685b0094d3 100644
--- a/src/LIB/SURCOUCHE/src/mode_netcdf.f90
+++ b/src/LIB/SURCOUCHE/src/mode_netcdf.f90
@@ -1,5 +1,9 @@
 #if defined(MNH_IOCDF4)
 MODULE MODE_NETCDF
+!!
+!!      Original  14/04/2015 D. Gazen
+!!      D.Gazen & J.Escobar 24/03/2107 : Correction for compilation of netcdf4IO in REAL*4 <=> MNH_REAL=R4      
+!!
 USE MODD_NETCDF
 
 IMPLICIT NONE 
@@ -316,6 +320,7 @@ INTEGER(KIND=IDCDF_KIND) :: INCID
 CHARACTER(LEN=30) :: YVARNAME
 INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND),PARAMETER :: IZERO = 0
+REAL(KIND=8)      :: ZFIELD8
 INTEGER           :: IRESP
 
 IRESP = 0
@@ -338,7 +343,14 @@ ELSE
 END IF
 
 ! Write the data
+#if defined(MNH_MPI_DOUBLE_PRECISION)
+! PFIELD REAL(KIND=8)
 STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, PFIELD)
+#else
+!! PFIELD REAL(KIND=4) saved as REAL(KIND=8)  
+ZFIELD8 = PFIELD
+STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, ZFIELD8)
+#endif
 IF (status /= NF_NOERR) CALL HANDLE_ERR(status,__LINE__,'NCWRITX0[NF_PUT_VAR_DOUBLE]',IRESP)
 
 KRESP = IRESP
@@ -358,6 +370,7 @@ INTEGER(KIND=IDCDF_KIND) :: INCID
 CHARACTER(LEN=30)     :: YVARNAME
 INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: ZFIELD8
 INTEGER               :: IRESP
 
 IRESP = 0
@@ -383,7 +396,16 @@ ELSE
 END IF
 
 ! Write the data
+#if defined(MNH_MPI_DOUBLE_PRECISION)
+! PFIELD REAL(KIND=8)
 STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, PFIELD)
+#else
+!! PFIELD REAL(KIND=4) saved as REAL(KIND=8)  
+ALLOCATE(ZFIELD8(SIZE(PFIELD)))
+ZFIELD8 = PFIELD
+STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, ZFIELD8)
+DEALLOCATE(ZFIELD8)
+#endif
 IF (status /= NF_NOERR) CALL HANDLE_ERR(status,__LINE__,'NCWRITX1[NF_PUT_VAR_DOUBLE]',IRESP)
  
 KRESP = IRESP
@@ -408,6 +430,7 @@ INTEGER(KIND=IDCDF_KIND) :: INCID
 CHARACTER(LEN=30)     :: YVARNAME
 INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8),DIMENSION(:,:),ALLOCATABLE :: ZFIELD8
 INTEGER               :: IRESP
 
 IRESP = 0
@@ -438,7 +461,16 @@ ELSE
 END IF
 
 ! Write the data
+#if defined(MNH_MPI_DOUBLE_PRECISION)
+! PFIELD REAL(KIND=8)
 STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, PFIELD)
+#else
+!! PFIELD REAL(KIND=4) saved as REAL(KIND=8)  
+ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2)))
+ZFIELD8 = PFIELD
+STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, ZFIELD8)
+DEALLOCATE(ZFIELD8)
+#endif
 IF (status /= NF_NOERR) CALL HANDLE_ERR(status,__LINE__,'NCWRITX2[NF_PUT_VAR_DOUBLE]',IRESP)
  
 KRESP = IRESP
@@ -458,6 +490,7 @@ INTEGER(KIND=IDCDF_KIND) :: INCID
 CHARACTER(LEN=30)     :: YVARNAME
 INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8),DIMENSION(:,:,:),ALLOCATABLE :: ZFIELD8
 INTEGER               :: IRESP
 
 IRESP = 0
@@ -483,7 +516,16 @@ ELSE
 END IF
 
 ! Write the data
+#if defined(MNH_MPI_DOUBLE_PRECISION)
+! PFIELD REAL(KIND=8)
 STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, PFIELD)
+#else
+!! PFIELD REAL(KIND=4) saved as REAL(KIND=8)  
+ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3)))
+ZFIELD8 = PFIELD
+STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, ZFIELD8)
+DEALLOCATE(ZFIELD8)
+#endif
 IF (status /= NF_NOERR) CALL HANDLE_ERR(status,__LINE__,'NCWRITX3[NF_PUT_VAR_DOUBLE] '//TRIM(HVARNAME),IRESP)
  
 KRESP = IRESP
@@ -503,6 +545,7 @@ INTEGER(KIND=IDCDF_KIND) :: INCID
 CHARACTER(LEN=30)     :: YVARNAME
 INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8),DIMENSION(:,:,:,:),ALLOCATABLE :: ZFIELD8
 INTEGER               :: IRESP
 
 IRESP = 0
@@ -528,7 +571,17 @@ ELSE
 END IF
 
 ! Write the data
+#if defined(MNH_MPI_DOUBLE_PRECISION)
+! PFIELD REAL(KIND=8)
 STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, PFIELD)
+#else
+!! PFIELD REAL(KIND=4) saved as REAL(KIND=8)  
+ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),&
+     &SIZE(PFIELD,4)))
+ZFIELD8 = PFIELD
+STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, ZFIELD8)
+DEALLOCATE(ZFIELD8)
+#endif
 IF (status /= NF_NOERR) CALL HANDLE_ERR(status,__LINE__,'NCWRITX4[NF_PUT_VAR_DOUBLE]',IRESP)
  
 KRESP = IRESP
@@ -548,6 +601,7 @@ INTEGER(KIND=IDCDF_KIND) :: INCID
 CHARACTER(LEN=30)     :: YVARNAME
 INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8),DIMENSION(:,:,:,:,:),ALLOCATABLE :: ZFIELD8
 INTEGER               :: IRESP
 
 IRESP = 0
@@ -573,7 +627,17 @@ ELSE
 END IF
 
 ! Write the data
+#if defined(MNH_MPI_DOUBLE_PRECISION)
+! PFIELD REAL(KIND=8)
 STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, PFIELD)
+#else
+!! PFIELD REAL(KIND=4) saved as REAL(KIND=8)
+ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),&
+     &SIZE(PFIELD,4),SIZE(PFIELD,5)))
+ZFIELD8 = PFIELD
+STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, ZFIELD8)
+DEALLOCATE(ZFIELD8) 
+#endif
 IF (status /= NF_NOERR) CALL HANDLE_ERR(status,__LINE__,'NCWRITX5[NF_PUT_VAR_DOUBLE]',IRESP)
  
 KRESP = IRESP
@@ -593,6 +657,7 @@ INTEGER(KIND=IDCDF_KIND) :: INCID
 CHARACTER(LEN=30)     :: YVARNAME
 INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8),DIMENSION(:,:,:,:,:,:),ALLOCATABLE :: ZFIELD8
 INTEGER               :: IRESP
 
 IRESP = 0
@@ -618,7 +683,17 @@ ELSE
 END IF
 
 ! Write the data
+#if defined(MNH_MPI_DOUBLE_PRECISION)
+! PFIELD REAL(KIND=8)
 STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, PFIELD)
+#else
+!! PFIELD REAL(KIND=4) saved as REAL(KIND=8)
+ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),&
+     &SIZE(PFIELD,4),SIZE(PFIELD,5),SIZE(PFIELD,6)))
+ZFIELD8 = PFIELD
+STATUS = NF_PUT_VAR_DOUBLE(INCID, IVARID, ZFIELD8)
+DEALLOCATE(ZFIELD8) 
+#endif
 IF (status /= NF_NOERR) CALL HANDLE_ERR(status,__LINE__,'NCWRITX6[NF_PUT_VAR_DOUBLE]',IRESP)
  
 KRESP = IRESP
@@ -947,6 +1022,7 @@ INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND) :: ITYPE   ! variable type
 INTEGER(KIND=IDCDF_KIND) :: IDIMS   ! number of dimensions
 INTEGER(KIND=IDCDF_KIND) :: ICOMLEN ! comment length
+REAL(KIND=8)      :: ZFIELD8
 INTEGER           :: IRESP
 
 IRESP = 0
@@ -968,7 +1044,12 @@ IF (STATUS /= NF_NOERR) CALL HANDLE_ERR(STATUS,__LINE__,'NCREADX0[NF_INQ_VARTYPE
 
 IF (IDIMS == 0 .AND. ITYPE == NF_DOUBLE) THEN
    ! Read variable
+#if defined(MNH_MPI_DOUBLE_PRECISION)
    STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, PFIELD)
+#else
+   STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, ZFIELD8)
+   PFIELD = ZFIELD8
+#endif
    IF (STATUS /= NF_NOERR) THEN
       CALL HANDLE_ERR(status,__LINE__,'NCREADX0[NF_GET_VAR_DOUBLE] '//TRIM(YVARNAME),IRESP)
       GOTO 1000
@@ -999,6 +1080,7 @@ INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND) :: ITYPE   ! variable type
 INTEGER(KIND=IDCDF_KIND) :: IDIMS   ! number of dimensions
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: ZFIELD8
 INTEGER(KIND=IDCDF_KIND) :: ICOMLEN ! comment length
 INTEGER               :: IVARSIZE
 INTEGER(KIND=IDCDF_KIND) :: IDIMLEN
@@ -1035,7 +1117,14 @@ IF (IDIMS == SIZE(SHAPE(PFIELD)) .AND. ITYPE == NF_DOUBLE) THEN
    
    IF (IVARSIZE == SIZE(PFIELD)) THEN
       ! Read variable
+#if defined(MNH_MPI_DOUBLE_PRECISION)
       STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, PFIELD)
+#else
+      ALLOCATE(ZFIELD8(SIZE(PFIELD)))
+      STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, ZFIELD8)
+      PFIELD = ZFIELD8
+      DEALLOCATE(ZFIELD8)
+#endif
       IF (STATUS /= NF_NOERR) THEN
          CALL HANDLE_ERR(status,__LINE__,'NCREADX1[NF_GET_VAR_DOUBLE] '//TRIM(YVARNAME),IRESP)
          GOTO 1000
@@ -1070,6 +1159,7 @@ INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND) :: ITYPE   ! variable type
 INTEGER(KIND=IDCDF_KIND) :: IDIMS   ! number of dimensions
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8), DIMENSION(:,:), ALLOCATABLE :: ZFIELD8
 INTEGER(KIND=IDCDF_KIND) :: ICOMLEN ! comment length
 INTEGER               :: IVARSIZE
 INTEGER(KIND=IDCDF_KIND) :: IDIMLEN
@@ -1106,7 +1196,15 @@ IF (IDIMS == SIZE(SHAPE(PFIELD)) .AND. ITYPE == NF_DOUBLE) THEN
    
    IF (IVARSIZE == SIZE(PFIELD)) THEN
       ! Read variable
+#if defined(MNH_MPI_DOUBLE_PRECISION)
       STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, PFIELD)
+#else
+      ! REAL(KIND=4) was stored as REAL(KIND=8)
+      ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2)))
+      STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, ZFIELD8)
+      PFIELD = ZFIELD8
+      DEALLOCATE(ZFIELD8)
+#endif
       IF (STATUS /= NF_NOERR) THEN
          CALL HANDLE_ERR(status,__LINE__,'NCREADX2[NF_GET_VAR_DOUBLE] '//TRIM(YVARNAME),IRESP)
          GOTO 1000
@@ -1141,6 +1239,7 @@ INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND) :: ITYPE   ! variable type
 INTEGER(KIND=IDCDF_KIND) :: IDIMS   ! number of dimensions
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8), DIMENSION(:,:,:), ALLOCATABLE :: ZFIELD8
 INTEGER(KIND=IDCDF_KIND) :: ICOMLEN ! comment length
 INTEGER               :: IVARSIZE
 INTEGER(KIND=IDCDF_KIND) :: IDIMLEN
@@ -1177,7 +1276,15 @@ IF (IDIMS == SIZE(SHAPE(PFIELD)) .AND. ITYPE == NF_DOUBLE) THEN
    
    IF (IVARSIZE == SIZE(PFIELD)) THEN
       ! Read variable
+#if defined(MNH_MPI_DOUBLE_PRECISION)
       STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, PFIELD)
+#else
+      ! REAL(KIND=4) was stored as REAL(KIND=8)
+      ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3)))
+      STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, ZFIELD8)
+      PFIELD = ZFIELD8
+      DEALLOCATE(ZFIELD8)
+#endif
       IF (STATUS /= NF_NOERR) THEN
          CALL HANDLE_ERR(status,__LINE__,'NCREADX3[NF_GET_VAR_DOUBLE] '//TRIM(YVARNAME),IRESP)
          GOTO 1000
@@ -1212,6 +1319,7 @@ INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND) :: ITYPE   ! variable type
 INTEGER(KIND=IDCDF_KIND) :: IDIMS   ! number of dimensions
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8), DIMENSION(:,:,:,:), ALLOCATABLE :: ZFIELD8
 INTEGER(KIND=IDCDF_KIND) :: ICOMLEN ! comment length
 INTEGER               :: IVARSIZE
 INTEGER(KIND=IDCDF_KIND) :: IDIMLEN
@@ -1248,7 +1356,16 @@ IF (IDIMS == SIZE(SHAPE(PFIELD)) .AND. ITYPE == NF_DOUBLE) THEN
    
    IF (IVARSIZE == SIZE(PFIELD)) THEN
       ! Read variable
+#if defined(MNH_MPI_DOUBLE_PRECISION)
       STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, PFIELD)
+#else
+      ! REAL(KIND=4) was stored as REAL(KIND=8)
+      ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),&
+           &SIZE(PFIELD,4)))
+      STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, ZFIELD8)
+      PFIELD = ZFIELD8
+      DEALLOCATE(ZFIELD8)
+#endif
       IF (STATUS /= NF_NOERR) THEN
          CALL HANDLE_ERR(status,__LINE__,'NCREADX4[NF_GET_VAR_DOUBLE] '//TRIM(YVARNAME),IRESP)
          GOTO 1000
@@ -1283,6 +1400,7 @@ INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND) :: ITYPE   ! variable type
 INTEGER(KIND=IDCDF_KIND) :: IDIMS   ! number of dimensions
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8), DIMENSION(:,:,:,:,:), ALLOCATABLE :: ZFIELD8
 INTEGER(KIND=IDCDF_KIND) :: ICOMLEN ! comment length
 INTEGER               :: IVARSIZE
 INTEGER(KIND=IDCDF_KIND) :: IDIMLEN
@@ -1319,7 +1437,16 @@ IF (IDIMS == SIZE(SHAPE(PFIELD)) .AND. ITYPE == NF_DOUBLE) THEN
    
    IF (IVARSIZE == SIZE(PFIELD)) THEN
       ! Read variable
+#if defined(MNH_MPI_DOUBLE_PRECISION)
       STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, PFIELD)
+#else
+      ! REAL(KIND=4) was stored as REAL(KIND=8)
+      ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),&
+           &SIZE(PFIELD,4),SIZE(PFIELD,5)))
+      STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, ZFIELD8)
+      PFIELD = ZFIELD8
+      DEALLOCATE(ZFIELD8)
+#endif
       IF (STATUS /= NF_NOERR) THEN
          CALL HANDLE_ERR(status,__LINE__,'NCREADX5[NF_GET_VAR_DOUBLE] '//TRIM(YVARNAME),IRESP)
          GOTO 1000
@@ -1354,6 +1481,7 @@ INTEGER(KIND=IDCDF_KIND) :: IVARID
 INTEGER(KIND=IDCDF_KIND) :: ITYPE   ! variable type
 INTEGER(KIND=IDCDF_KIND) :: IDIMS   ! number of dimensions
 INTEGER(KIND=IDCDF_KIND), DIMENSION(SIZE(SHAPE(PFIELD))) :: IVDIMS
+REAL(KIND=8), DIMENSION(:,:,:,:,:,:), ALLOCATABLE :: ZFIELD8
 INTEGER(KIND=IDCDF_KIND) :: ICOMLEN ! comment length
 INTEGER               :: IVARSIZE
 INTEGER(KIND=IDCDF_KIND) :: IDIMLEN
@@ -1390,7 +1518,16 @@ IF (IDIMS == SIZE(SHAPE(PFIELD)) .AND. ITYPE == NF_DOUBLE) THEN
    
    IF (IVARSIZE == SIZE(PFIELD)) THEN
       ! Read variable
+#if defined(MNH_MPI_DOUBLE_PRECISION)
       STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, PFIELD)
+#else
+      ! REAL(KIND=4) was stored as REAL(KIND=8)
+      ALLOCATE(ZFIELD8(SIZE(PFIELD,1),SIZE(PFIELD,2),SIZE(PFIELD,3),&
+           &SIZE(PFIELD,4),SIZE(PFIELD,5),SIZE(PFIELD,6)))
+      STATUS = NF_GET_VAR_DOUBLE(KNCID, IVARID, ZFIELD8)
+      PFIELD = ZFIELD8
+      DEALLOCATE(ZFIELD8)
+#endif
       IF (STATUS /= NF_NOERR) THEN
          CALL HANDLE_ERR(status,__LINE__,'NCREADX6[NF_GET_VAR_DOUBLE] '//TRIM(YVARNAME),IRESP)
          GOTO 1000
diff --git a/src/MNH/aerozon.f90 b/src/MNH/aerozon.f90
index d4b4ae5a0545b5e11bbde8d5b00dd13c03e417a7..04808cb47b5e9041c1e79bced1cb28382c912a0c 100644
--- a/src/MNH/aerozon.f90
+++ b/src/MNH/aerozon.f90
@@ -3,10 +3,6 @@
 !MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  
 !MNH_LIC for details. version 1.
 !-----------------------------------------------------------------
-!--------------- special set of characters for RCS information
-!-----------------------------------------------------------------
-! $Source$ $Revision$ $Date$
-!-----------------------------------------------------------------
 !     ##########################
       MODULE MODI_AEROZON
 !     ##########################
@@ -142,12 +138,14 @@ END MODULE MODI_AEROZON
 !!    MODIFICATIONS
 !!    -------------
 !!      (P.Peyrille) 20/07/04 : add LFIX_DAT to have perpetual day
+!!      J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !-------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
 !              ------------
 !ECMWF radiation scheme specific modules 
 !
+USE PARKIND1 , ONLY : JPRB
 USE YOEAERD  , ONLY : RCAEOPS  ,RCAEOPL  ,RCAEOPU  ,RCAEOPD  ,RCTRBGA  ,&
      RCVOBGA  ,RCSTBGA  ,RCTRPT   ,RCAEADM  ,RCAEROS  ,&
      RCAEADK
@@ -234,13 +232,18 @@ REAL :: ZA1, ZA2      ! Ancillary variables
 REAL, DIMENSION(SIZE(PTHT,1),SIZE(PTHT,2),SIZE(PTHT,3)) :: ZEXNT ! Exner function
 !
 ! Variables for aerosols and ozone climatologies set up
-REAL, DIMENSION (:),     ALLOCATABLE  :: ZAESEA, ZAELAN, ZAEURB, ZAEDES
-REAL, DIMENSION (:,:),   ALLOCATABLE  :: ZPRES_HL,ZT_HL, ZPAVE, ZOZON, ZWORK_GRID
-REAL, DIMENSION (:,:),   ALLOCATABLE  :: ZCVDAES, ZCVDAEL, ZCVDAEU, ZCVDAED,ZETAH
-REAL, DIMENSION (:),     ALLOCATABLE  :: ZGEMU 
+
+REAL, DIMENSION (:,:),   ALLOCATABLE  :: ZPAVE, ZWORK_GRID
+REAL, DIMENSION (:),   ALLOCATABLE  :: ZAESEA, ZAELAN, ZAEURB, ZAEDES
+!
+REAL(KIND=JPRB), DIMENSION (:,:),   ALLOCATABLE  :: ZT_HL
+REAL(KIND=JPRB), DIMENSION (:),   ALLOCATABLE  :: ZAESEA_RAD, ZAELAN_RAD, ZAEURB_RAD, ZAEDES_RAD
+REAL(KIND=JPRB), DIMENSION (:,:), ALLOCATABLE  :: ZCVDAES, ZCVDAEL, ZCVDAEU, ZCVDAED
+REAL(KIND=JPRB), DIMENSION (:,:), ALLOCATABLE  :: ZPRES_HL,ZOZON,ZETAH
+REAL(KIND=JPRB), DIMENSION (:),   ALLOCATABLE  :: ZGEMU 
 INTEGER :: ZYMD, ZHOURS   ! date for climatology initialisation
 INTEGER :: JKCEP,JK_NH
-REAL, DIMENSION (:,:,:), ALLOCATABLE  :: ZAER
+REAL(KIND=JPRB), DIMENSION (:,:,:), ALLOCATABLE  :: ZAER
 REAL, DIMENSION(:),      ALLOCATABLE  :: ZAECOV_SEA, ZAECOV_URB, ZAECOV_LAN, ZAECOV_DES
 !
 !-------------------------------------------------------------------------------
@@ -430,6 +433,11 @@ IF(HAER /= 'NONE') THEN
   ALLOCATE (ZAELAN(KDLON))
   ALLOCATE (ZAEURB(KDLON))
   ALLOCATE (ZAEDES(KDLON))
+
+  ALLOCATE (ZAESEA_RAD(KDLON)) 
+  ALLOCATE (ZAELAN_RAD(KDLON))
+  ALLOCATE (ZAEURB_RAD(KDLON))
+  ALLOCATE (ZAEDES_RAD(KDLON))
 !
 ! AEROSOLS ECMWF climatologies
 !
@@ -464,9 +472,10 @@ IF(HAER /= 'NONE') THEN
 !
 ! final aerosol profiles on mnh grid
 !
+  ZAESEA_RAD = ZAESEA ; ZAELAN_RAD = ZAELAN ; ZAEURB_RAD = ZAEURB ; ZAEDES_RAD = ZAEDES
   CALL RADAER (1, KDLON, KDLON, 1, KFLEV, ZPRES_HL,ZT_HL, &
        ZCVDAES ,ZCVDAEL ,ZCVDAEU ,ZCVDAED, &
-       ZAESEA, ZAELAN, ZAEURB, ZAEDES, &
+       ZAESEA_RAD, ZAELAN_RAD, ZAEURB_RAD, ZAEDES_RAD, &
        ZAER )
 !
 !!- VOLCANIC AEROSOL SET TO epsilon IN ABSENCE OF ERUPTION 
@@ -480,6 +489,11 @@ IF(HAER /= 'NONE') THEN
   DEALLOCATE (ZAELAN)
   DEALLOCATE (ZAEURB)
   DEALLOCATE (ZAEDES)
+
+  DEALLOCATE (ZAESEA_RAD)
+  DEALLOCATE (ZAELAN_RAD)
+  DEALLOCATE (ZAEURB_RAD)
+  DEALLOCATE (ZAEDES_RAD)
 ELSE
   ZAER(:,:,:)= 1E-12
 END IF
diff --git a/src/MNH/ch_monitorn.f90 b/src/MNH/ch_monitorn.f90
index 607ba4ec87c1ac59b4b034d2f0a62b598729e9df..dba8b09843dde98783e4943550e6473af989509b 100644
--- a/src/MNH/ch_monitorn.f90
+++ b/src/MNH/ch_monitorn.f90
@@ -110,6 +110,7 @@ END MODULE MODI_CH_MONITOR_n
 !!    11/12/15 (M. Leriche & P. Tulet) add ch_init_ice initialise index for ice chem.
 !!    18/01/16 (M Leriche) for sedimentation fusion C2R2 and khko
 !!    15/02/16 (M Leriche) call ch_init_rosenbrock only one time
+!!    20/01/17 (G.Delautier) bug if CPROGRAM/=DIAG
 !!
 !!    EXTERNAL
 !!    --------
@@ -621,7 +622,9 @@ SELECT CASE (CCH_TDISCRETIZATION)
 END SELECT
 !
 !
-IF (LEN_TRIM(CSPEC_BU_DIAG)/=0.OR.LEN_TRIM(CSPEC_DIAG)/=0) GSPLIT=.FALSE.  ! Modif. for DIAG
+IF (CPROGRAM=='DIAG  ') THEN
+  IF (LEN_TRIM(CSPEC_BU_DIAG)/=0.OR.LEN_TRIM(CSPEC_DIAG)/=0) GSPLIT=.FALSE.  ! Modif. for DIAG
+END IF
 !
 !
 !*       1.6   allocate tables
diff --git a/src/MNH/ecmwf_radiation_vers2.f90 b/src/MNH/ecmwf_radiation_vers2.f90
index 390732604adc586c127ab8ad05b62a3f6b0e953a..76c7a122e4da04fc9a1c24aad720c55235a7f4c3 100644
--- a/src/MNH/ecmwf_radiation_vers2.f90
+++ b/src/MNH/ecmwf_radiation_vers2.f90
@@ -2,142 +2,6 @@
 !MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
 !MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  
 !MNH_LIC for details. version 1.
-!-----------------------------------------------------------------
-!--------------- special set of characters for RCS information
-!-----------------------------------------------------------------
-! $Source: /home/cvsroot/MNH-VX-Y-Z/src/MNH/ecmwf_radiation_vers2.f90,v $ $Revision: 1.3.2.4.2.2.2.1 $
-! masdev4_7 BUG1 2007/06/15 17:47:17
-!-----------------------------------------------------------------
-!      #################################
-       MODULE MODI_ECMWF_RADIATION_VERS2
-!      #################################
-INTERFACE
-! 
-SUBROUTINE ECMWF_RADIATION_VERS2 ( KLON,KLEV,KRAD_DIAG, KAER, &
-     PDZ,HEFRADL, HEFRADI, HOPWSW, HOPISW, HOPWLW, HOPILW, PFUDG, &
-     PRII0, PAER , PALBD , PALBP, PAPH , PAP,                 &
-     PCCO2, PCLFR , PDP  , PEMIS, PEMIW , PLSM , PMU0, POZON, &
-     PQ   , PQIWC ,PIWC, PQLWC, PLWC,PQS  , PQRWC,PRWC,               &
-     PTH  , PT    , PTS, PCCT_C2R2, PCRT_C2R2, PCIT_C1R3,     &
-     PFCT  , PFLT , PFCS , PFLS  ,                            &  
-     PDTLW, PDTSW ,PFLUX_TOP_GND_IRVISNIR,                    & 
-     PSFSWDIR, PSFSWDIF,                                      &
-     PFSDWN, PFSUP, PFLUX_LW ,                                &
-     PDTLW_CS, PDTSW_CS ,PFLUX_TOP_GND_IRVISNIR_CS,           &
-     PFCDWN, PFCUP, PFLUX_CLW,                                & 
-     PPLAN_ALB_VIS, PPLAN_ALB_NIR, PPLAN_TRA_VIS, PPLAN_TRA_NIR,&
-     PPLAN_ABS_VIS, PPLAN_ABS_NIR, PEFCL_LWD, PEFCL_LWU,      &
-     PFLWP,PFIWP, PRADLP, PRADIP,PEFCL_RRTM, PCLSW_TOTAL,     &
-     PTAU_TOTAL, POMEGA_TOTAL, PCG_TOTAL,                     &
-     ODUST,PPIZA_DST,PCGA_DST,PTAUREL_DST )
-!  
-INTEGER, INTENT(IN) :: KAER !number of aerosol class     
-REAL, DIMENSION (:,:), INTENT (IN) ::PDZ !thickness of the mesh (m)
-INTEGER, INTENT(IN) :: KLEV ! number of vertical level for radiation calulation 
-INTEGER, INTENT(IN) :: KLON ! number of columns            " 
-INTEGER, INTENT(IN) :: KRAD_DIAG ! index for the number of diagnostic fields 
-!                                        choice in
-CHARACTER (LEN=*), INTENT (IN) :: HEFRADL !cloud water effective radius calculation  
-CHARACTER (LEN=*), INTENT (IN) :: HEFRADI !ice water effective radius calculation
-CHARACTER (LEN=*), INTENT (IN) :: HOPWSW !cloud water SW optical properties  
-CHARACTER (LEN=*), INTENT (IN) :: HOPISW !ice water SW optical properties 
-CHARACTER (LEN=*), INTENT (IN) :: HOPWLW !cloud water LW optical properties
-CHARACTER (LEN=*), INTENT (IN) :: HOPILW !ice water  LW optical properties
-REAL, INTENT(IN)               :: PFUDG  ! subgrid cloud inhomogeneity factor 
-!
-!
-REAL, INTENT(INOUT)                  :: PRII0 ! corrected solar constant
-REAL, INTENT(IN)                     :: PCCO2 ! CO2 content (Pa/Pa)
-REAL, DIMENSION (:,:,:), INTENT (IN) :: PAER  ! aerosol optical thickness
-REAL, DIMENSION (:,:), INTENT (IN)   :: PALBD ! surface diffuse spectral albedo
-REAL, DIMENSION (:,:), INTENT (IN)   :: PALBP ! surface direct spectral albedo
-REAL, DIMENSION (:), INTENT (IN)     :: PEMIS ! surface emissivity
-REAL, DIMENSION (:), INTENT (IN)     :: PEMIW ! surface emissivity in LW window
-REAL, DIMENSION (:), INTENT (IN)     :: PLSM  ! land sea mask
-REAL, DIMENSION (:), INTENT (IN)     :: PMU0  ! cosine of solar angle 
-REAL, DIMENSION (:,:), INTENT (IN)   :: POZON ! ozone content (Pa/Pa)
-REAL, DIMENSION (:), INTENT (IN)     :: PTS   ! surfaec temperature
-REAL, DIMENSION (:,:), INTENT (IN)   :: PT    ! mean layer  temperature (mass point) 
-REAL, DIMENSION (:,:), INTENT (IN)   :: PAP   ! mean layer  pressure (mass point)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PTH   ! half-level temperature
-REAL, DIMENSION (:,:), INTENT (IN)   :: PAPH  ! half-level pressure 
-REAL, DIMENSION (:,:), INTENT (IN)   :: PDP   ! layer pressure thickness
-REAL, DIMENSION (:,:), INTENT (IN)   :: PQ    ! mean layer specific humidity  (Pa/pa) 
-REAL, DIMENSION (:,:), INTENT (IN)   :: PQS   ! mean layer saturation spec. humid.
-REAL, DIMENSION (:,:), INTENT (IN)   :: PQIWC ! mean-layer ice specific water content (kg/kg)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PIWC ! mean-layer ice water content (kg/m3)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PQLWC ! mean-layer liquid specific water content(kg/Kg)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PLWC ! mean-layer liquid water content(kg/m3)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PQRWC ! mean-layer rain specific water content(kg/kg)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PRWC ! mean-layer rain water content(kg/m3)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PCLFR  ! mean-layer cloud fraction
-REAL, DIMENSION (:,:), INTENT (IN)   :: PCCT_C2R2 ! cloud water concentration (C2R2)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PCRT_C2R2 ! rain water concentration (C2R2)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PCIT_C1R3 ! ice crystal concentration (C1R3)
-REAL, DIMENSION(:,:,:),INTENT(IN)    :: PPIZA_DST   !Single scattering albedo of dust (wvl dependent)
-REAL, DIMENSION(:,:,:),INTENT(IN)   :: PCGA_DST    !Assymetry factor for dust (wvl dependent)
-REAL, DIMENSION(:,:,:),INTENT(IN)   :: PTAUREL_DST !Optical depth of dust relative to the one at 550nm
-
-LOGICAL, INTENT (IN)                 :: ODUST  ! flag for dust
-!
-! OUTPUTS 
-!
-REAL, DIMENSION (:,:), INTENT (OUT) :: PDTLW   ! LW temperature tendency
-REAL, DIMENSION (:,:), INTENT (OUT) :: PDTSW   ! SW temperature tendency
-REAL, DIMENSION (:,:), INTENT (OUT) :: PFLUX_TOP_GND_IRVISNIR ! Top and Ground rad. FLUX.
-REAL, DIMENSION (:,:), INTENT (OUT) :: PSFSWDIR ! surface SW direct flux
-REAL, DIMENSION (:,:), INTENT (OUT) :: PSFSWDIF ! surface SW diffuse flux
-! 
-!KRAD_DIAG >=1 --> optional: flux profiles
-!
-REAL, DIMENSION (:,:), INTENT (OUT)  :: PFCT ! Total LW net flux
-REAL, DIMENSION (:,:), INTENT (OUT)  :: PFLT ! Total SW net flux
-REAL, DIMENSION (:,:), INTENT (OUT) :: PFSDWN! Downward SW flux
-REAL, DIMENSION (:,:), INTENT (OUT) :: PFSUP ! Upward SW flux
-REAL, DIMENSION (:,:,:), INTENT (OUT) :: PFLUX_LW ! LW flux (upward and downward)
-!
-!KRAD_DIAG >=2 --> optional: clear-sky outputs
-!
-REAL, DIMENSION (:,:), INTENT (OUT) :: PDTLW_CS   ! LW clear sky temperature tendancy
-REAL, DIMENSION (:,:), INTENT (OUT) :: PDTSW_CS   ! SW  clear sky temperature tendancy
-REAL, DIMENSION (:,:), INTENT (OUT) :: PFLUX_TOP_GND_IRVISNIR_CS !  Top and
-                                                    !  Ground radiative Clear-sky FLUXes
-REAL, DIMENSION (:,:), INTENT (OUT)  :: PFCS ! Clear-sky LW net flux 
-REAL, DIMENSION (:,:), INTENT (OUT)  :: PFLS ! Clear-sky SW net flux
-REAL, DIMENSION (:,:), INTENT (OUT)  :: PFCDWN  ! Downward SW Clear sky flux 
-REAL, DIMENSION (:,:), INTENT (OUT)  :: PFCUP   ! Upward SW Clear sky flux 
-REAL, DIMENSION (:,:,:), INTENT (OUT):: PFLUX_CLW !Clear sky  LW flux (upward and downward)
-!
-!KRAD_DIAG >=3 --> optional: other macroscpic radiative parameteres
-!
-REAL, DIMENSION (:), INTENT (OUT) :: PPLAN_ALB_VIS !PLANetary ALBedo in VISible 
-REAL, DIMENSION (:), INTENT (OUT) :: PPLAN_ALB_NIR !     "          Near-InfraRed
-REAL, DIMENSION (:), INTENT (OUT) :: PPLAN_TRA_VIS !PLANetary TRANsmission in VISible
-REAL, DIMENSION (:), INTENT (OUT) :: PPLAN_TRA_NIR !     "          Near-InfraRed
-REAL, DIMENSION (:), INTENT (OUT) :: PPLAN_ABS_VIS !PLANetary ABSorption in VISible
-REAL, DIMENSION (:), INTENT (OUT) :: PPLAN_ABS_NIR !     "          Near-InfraRed 
-
-
-!
-!KRAD_DIAG >=4 --> optional: more cloud effect radiative parameters 
-!
-REAL, DIMENSION (:,:), INTENT (OUT) :: PFLWP       ! Liquid water path
-REAL, DIMENSION (:,:), INTENT (OUT) :: PFIWP       ! Ice water path
-REAL, DIMENSION (:,:), INTENT (OUT) :: PRADLP      ! Cloud water effective radius  
-REAL, DIMENSION (:,:), INTENT (OUT) :: PRADIP      ! Cloud ice effective radius
-REAL, DIMENSION (:,:), INTENT (OUT) :: PEFCL_LWD   ! effective downward LW nebulosity 
-REAL, DIMENSION (:,:), INTENT (OUT) :: PEFCL_LWU   ! effective upward LW nebulosity
-                                                   ! Note: not meaningfull when using RRTM 
-REAL, DIMENSION (:,:), INTENT (OUT) :: PEFCL_RRTM ! Effective LW nebuloisty (RRTM case)
-REAL, DIMENSION (:,:), INTENT (OUT) :: PCLSW_TOTAL ! Effective SW cloud fraction(mixed phase)
-REAL, DIMENSION (:,:,:), INTENT (OUT) :: PTAU_TOTAL !Effective cloud optical thickness
-REAL, DIMENSION (:,:,:), INTENT (OUT) :: POMEGA_TOTAL! "   single scattering albedo
-REAL, DIMENSION (:,:,:), INTENT (OUT) :: PCG_TOTAL   ! "   asymetry factor 
-!
-END SUBROUTINE ECMWF_RADIATION_VERS2
-END INTERFACE
-END MODULE MODI_ECMWF_RADIATION_VERS2
-!
 !##############################################################
 !OPTION! -Ni
 SUBROUTINE ECMWF_RADIATION_VERS2 ( KLON,KLEV,KRAD_DIAG, KAER, &
@@ -205,12 +69,14 @@ SUBROUTINE ECMWF_RADIATION_VERS2 ( KLON,KLEV,KRAD_DIAG, KAER, &
 !         G.Delautier 9/2014: remplace MODD_RAIN_C2R2_PARAM par MODD_RAIN_C2R2_KHKO_PARAM
 !         M.Mazoyer 2016 :  limit of 100 microns for effective radius 
 !         B.VIE 2016 : LIMA
+!         J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !-----------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
 !              ------------
 !ECMWF radiation scheme specific modules 
 !
+USE PARKIND1 , ONLY : JPRB
 USE YOMCST   , ONLY : RG ,RD ,RTT ,RPI
 USE YOERAD   , ONLY : NMODE, NSW ,LRRTM ,LINHOM ,LRADIP, LRADLP 
 USE YOELW    , ONLY : NSIL     ,NTRA     ,NUA      ,TSTAND   ,XP
@@ -279,7 +145,7 @@ CHARACTER (LEN=*), INTENT (IN) :: HOPWLW !cloud water LW optical properties
 CHARACTER (LEN=*), INTENT (IN) :: HOPILW !ice water  LW optical properties
 REAL, INTENT(IN)               :: PFUDG  !subgrid cloud inhomogeneity factor
 !
-REAL, INTENT(INOUT)                     :: PRII0 ! corrected solar constant
+REAL(KIND=JPRB), INTENT(INOUT)       :: PRII0 ! corrected solar constant
 REAL, INTENT(IN)                     :: PCCO2 ! CO2 content (Pa/Pa)
 REAL, DIMENSION (:,:,:), INTENT (IN) :: PAER  ! aerosol optical thickness
 REAL, DIMENSION (:,:), INTENT (IN)   :: PALBD ! surface diffuse spectral albedo
@@ -289,14 +155,14 @@ REAL, DIMENSION (:), INTENT (IN)     :: PEMIW ! surface emissivity in LW window
 REAL, DIMENSION (:), INTENT (IN)     :: PLSM  ! land sea mask
 REAL, DIMENSION (:), INTENT (IN)     :: PMU0  ! cosine of solar angle 
 REAL, DIMENSION (:,:), INTENT (IN)   :: POZON ! ozone content (Pa/Pa)
-REAL, DIMENSION (:), INTENT (IN)     :: PTS   ! surfaec temperature
-REAL, DIMENSION (:,:), INTENT (IN)   :: PT    ! mean layer  temperature (mass point) 
-REAL, DIMENSION (:,:), INTENT (IN)   :: PAP   ! mean layer  pressure (mass point)
-REAL, DIMENSION (:,:), INTENT (IN)   :: PTH   ! half-level temperature
-REAL, DIMENSION (:,:), INTENT (IN)   :: PAPH  ! half-level pressure 
-REAL, DIMENSION (:,:), INTENT (IN)   :: PDP   ! layer pressure thickness
-REAL, DIMENSION (:,:), INTENT (IN)   :: PQ    ! mean layer specific humidity  (Pa/pa) 
-REAL, DIMENSION (:,:), INTENT (IN)   :: PQS   ! mean layer saturation spec. humid.
+REAL(KIND=JPRB), DIMENSION (:), INTENT (IN)     :: PTS   ! surfaec temperature
+REAL(KIND=JPRB), DIMENSION (:,:), INTENT (IN)   :: PT    ! mean layer  temperature (mass point) 
+REAL(KIND=JPRB), DIMENSION (:,:), INTENT (IN)   :: PAP   ! mean layer  pressure (mass point)
+REAL(KIND=JPRB), DIMENSION (:,:), INTENT (IN)   :: PTH   ! half-level temperature
+REAL(KIND=JPRB), DIMENSION (:,:), INTENT (IN)   :: PAPH  ! half-level pressure 
+REAL(KIND=JPRB), DIMENSION (:,:), INTENT (IN)   :: PDP   ! layer pressure thickness
+REAL(KIND=JPRB), DIMENSION (:,:), INTENT (IN)   :: PQ    ! mean layer specific humidity  (Pa/pa) 
+REAL(KIND=JPRB), DIMENSION (:,:), INTENT (IN)   :: PQS   ! mean layer saturation spec. humid.
 REAL, DIMENSION (:,:), INTENT (IN)   :: PQIWC ! mean-layer ice specific water content (kg/kg)
 REAL, DIMENSION (:,:), INTENT (IN)   :: PIWC ! mean-layer ice water content (kg/m3)
 REAL, DIMENSION (:,:), INTENT (IN)   :: PQLWC ! mean-layer liquid specific water content(kg/Kg)
@@ -307,9 +173,9 @@ REAL, DIMENSION (:,:), INTENT (IN)   :: PCLFR  ! mean-layer cloud fraction
 REAL, DIMENSION (:,:), INTENT (IN)   :: PCCT_C2R2 ! cloud water concentration (C2R2)
 REAL, DIMENSION (:,:), INTENT (IN)   :: PCRT_C2R2 ! rain water concentration (C2R2)
 REAL, DIMENSION (:,:), INTENT (IN)   :: PCIT_C1R3 ! ice crystal concentration (C1R3)
-REAL, DIMENSION(:,:,:),INTENT(IN)    :: PPIZA_DST   !Single scattering albedo of dust (wvl dependent)
-REAL, DIMENSION(:,:,:),INTENT(IN)    :: PCGA_DST    !Assymetry factor for dust (wvl dependent)
-REAL, DIMENSION(:,:,:),INTENT(IN)    :: PTAUREL_DST !Optical depth of dust relative to the one at 550nm
+REAL(KIND=JPRB), DIMENSION(:,:,:),INTENT(IN)    :: PPIZA_DST   !Single scattering albedo of dust (wvl dependent)
+REAL(KIND=JPRB), DIMENSION(:,:,:),INTENT(IN)    :: PCGA_DST    !Assymetry factor for dust (wvl dependent)
+REAL(KIND=JPRB), DIMENSION(:,:,:),INTENT(IN)    :: PTAUREL_DST !Optical depth of dust relative to the one at 550nm
 LOGICAL, INTENT (IN)                 :: ODUST  ! flag for dust
 !
 !
@@ -384,7 +250,7 @@ REAL          :: ZALND, ZASEA, ZD, ZDEN, ZNTOT, ZNUM, ZRATIO, Z1RADI,&
      ZBETAI, ZOMGI, ZOMGP, ZFDEL,  ZTCELS, ZFSR,  ZAIWC, ZBIWC,  &
      ZTBLAY, ZADDPLK,  ZPLANCK, Z1RADL, Z1RADR
 
-REAL, DIMENSION(KLON) ::  ZTCLEAR, ZDT0, ZEMIS, ZEMIW, &
+REAL(KIND=JPRB), DIMENSION(KLON) ::  ZTCLEAR, ZDT0, ZEMIS, ZEMIW, &
      ZFIWP , ZFLWP, ZFRWP, ZIWC,      &
      ZLWC, ZMU0, ZPSOL, ZVIEW,        &
      ZBICFU,  ZKICFU1, ZKICFU2,       &
@@ -397,29 +263,32 @@ REAL, DIMENSION(KLON) ::  ZTCLEAR, ZDT0, ZEMIS, ZEMIW, &
      ZUVDF, ZPARF
 !cc           , ZRADRD
 !
-REAL, DIMENSION(KLON,NSW)    :: ZALBD , ZALBP , ZDIRFS, ZDIFFS
-REAL, DIMENSION(KLON,KLEV)   :: ZCLFR,  ZCLDLD  , ZCLDLU, ZCLDSW,        &  
+REAL(KIND=JPRB), DIMENSION(KLON,NSW)    :: ZALBD , ZALBP , ZDIRFS, ZDIFFS
+REAL(KIND=JPRB), DIMENSION(KLON,KLEV)   :: ZCLFR,  ZCLDLD  , ZCLDLU, ZCLDSW,        &  
      ZOZON, ZOZ   , ZOZN,    ZTAVE ,  ZDPGCP, &
      ZCOOLR  , ZCOOLC, ZHEATR  , ZHEATC,      & 
      ZDFLWT  , ZDFLWC, ZDFSWT  , ZDFSWC
 !
-REAL, DIMENSION(KLON,KLEV+1) :: ZPMB  , ZTL, & 
+REAL(KIND=JPRB), DIMENSION(KLON,KLEV+1) :: ZPMB  , ZTL, & 
      ZFCDWN, ZFCUP, ZFSDWN, ZFSUP, &
      ZFLT, ZFCT,ZFCS, ZFLS
 !
-REAL, DIMENSION(KLON,NSW,KLEV) :: ZCG ,ZOMEGA, ZTAU
+REAL(KIND=JPRB), DIMENSION(KLON,NSW,KLEV) :: ZCG ,ZOMEGA, ZTAU
 !
-REAL, DIMENSION(KLON,2,KLEV+1) :: ZFLUX_LW, ZFLUX_CLW      
+REAL(KIND=JPRB), DIMENSION(KLON,2,KLEV+1) :: ZFLUX_LW, ZFLUX_CLW      
 !
-REAL, DIMENSION(KLON,KLEV,16)  :: ZTAUCLD
+REAL(KIND=JPRB), DIMENSION(KLON,KLEV,16)  :: ZTAUCLD
 !
-REAL, DIMENSION(KLON,KAER,KLEV) :: ZAER_SW,ZAER_LW ! Optical aerosol properties
+REAL(KIND=JPRB), DIMENSION(KLON,KAER,KLEV) :: ZAER_SW,ZAER_LW ! Optical aerosol properties
 LOGICAL :: GPROP_OP             !drapeau sur les condition a remplir pour que le
                                 !calcul des propriétés optiques soit effectué
 !
 REAL, ALLOCATABLE, DIMENSION(:) :: XRTMIN, XCTMIN
 REAL :: XALPHAC,XNUC,XALPHAR,XNUR,XCREC,XCRER,XFREFFR,XAC,XAR,XLBEXC,XLBEXR,XFREFFI,XLBEXI
+!
+REAL(KIND=JPRB) :: ZCCO2_RAD
 !--------------------------------------------------------------
+ZCCO2_RAD = PCCO2
 !
 !          0. LIMA
 IF ( CCLOUD == "LIMA" ) THEN
@@ -1239,7 +1108,7 @@ ENDDO
 !                 ------------------------------------
 IF ( .NOT. LRRTM) THEN
   CALL LW ( IKIDIA , IKFDIA , KLON  , KLEV , NMODE, &
-       PCCO2 , ZCLDLD, ZCLDLU,                     &
+       ZCCO2_RAD , ZCLDLD, ZCLDLU,                     &
        PDP   , ZDT0  , ZEMIS , ZEMIW,              &
        ZPMB  , ZOZON , ZTL,                        &
        ZAER_LW  , ZTAVE , ZVIEW , PQ,                 &
@@ -1263,7 +1132,7 @@ ELSE
 !
   CALL RRTM_RRTM_140GP(IKIDIA,IKFDIA,KLON,KLEV,   &
        ZAER_LW,PAPH,PAP,PTS,PTH,PT,ZEMIS,ZEMIW,      &
-       PQ    , PCCO2 , ZOZN  , ZCLDSW  , ZTAUCLD, &
+       PQ    , ZCCO2_RAD , ZOZN  , ZCLDSW  , ZTAUCLD, &
        ZEMIT , ZFLUX_LW , ZFLUX_CLW , ZTCLEAR )
 ENDIF
 
@@ -1277,7 +1146,7 @@ ENDDO
 !
 IF (ZRMUZ > 0.) THEN
       CALL SW ( IKIDIA , IKFDIA , KLON  , KLEV  , KAER,     &
-           PRII0 , PCCO2 , ZPSOL , ZALBD , ZALBP , PQ   , PQS,  &
+           PRII0 , ZCCO2_RAD , ZPSOL , ZALBD , ZALBP , PQ   , PQS,  &
            ZMU0  , ZCG   , ZCLDSW, PDP   , ZOMEGA, ZOZ  , ZPMB, &
            ZTAU  , ZTAVE , ZAER_SW,                                &
            ZHEATR, ZFSDWN, ZFSUP , ZHEATC, ZFCDWN, ZFCUP,       &
diff --git a/src/MNH/ini_modeln.f90 b/src/MNH/ini_modeln.f90
index 7a6ba97763bef83acc53b15c472a2a8db3d0a0ab..c4bed29b516a198818ea5505a892cbbfbdddca5b 100644
--- a/src/MNH/ini_modeln.f90
+++ b/src/MNH/ini_modeln.f90
@@ -271,6 +271,7 @@ END MODULE MODI_INI_MODEL_n
 !!                   10/2016 M.Mazoyer New KHKO output fields
 !!                      10/2016 (C.Lac) Add max values
 !!       F. Brosse   Oct.  2016 add prod/loss terms computation for chemistry
+!!                   01/2017 (G.Delautier) bug chemistry : modify test for prod/loss terms computation
 !!                   Apr. 2017 (P. Wautelet) allocate MAX variables if LMEAN_FIELD and call INI_MEAN_FIELD
 !---------------------------------------------------------------------------------
 !
@@ -2182,12 +2183,11 @@ IF ( LFOREFIRE ) THEN
 		, TDTCUR%TDATE%YEAR, TDTCUR%TDATE%MONTH, TDTCUR%TDATE%DAY, TDTCUR%TIME, XTSTEP)
 END IF
 #endif
-
 !-------------------------------------------------------------------------------
 !
 !*      30.   Total production/Loss for chemical species
 !
-IF (LUSECHEM.OR.LCHEMDIAG)  THEN
+IF (LCHEMDIAG)  THEN
         CALL CH_INIT_PRODLOSSTOT_n(ILUOUT)
         IF (NEQ_PLT>0) THEN
                 ALLOCATE(XPROD(IIU,IJU,IKU,NEQ_PLT))
@@ -2207,7 +2207,7 @@ END IF
 !
 !*     31. Extended production/loss terms for chemical species
 !
-IF (LUSECHEM.OR.LCHEMDIAG) THEN
+IF (LCHEMDIAG) THEN
         CALL CH_INIT_BUDGET_n(ILUOUT)
         IF (NEQ_BUDGET>0) THEN
                 ALLOCATE(IINDEX(2,NNONZEROTERMS))
diff --git a/src/MNH/ini_radiations_ecmwf.f90 b/src/MNH/ini_radiations_ecmwf.f90
index 72a746e3f622c3591d3df3aa031126b06b391b32..6c2cee16b749190123f8046af87bc2a048c17db5 100644
--- a/src/MNH/ini_radiations_ecmwf.f90
+++ b/src/MNH/ini_radiations_ecmwf.f90
@@ -3,11 +3,6 @@
 !MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  
 !MNH_LIC for details. version 1.
 !-----------------------------------------------------------------
-!--------------- special set of characters for RCS information
-!-----------------------------------------------------------------
-! $Source$ $Revision$
-! masdev4_7 BUG1 2007/06/15 17:47:18
-!-----------------------------------------------------------------
 !     ##########################
       MODULE MODI_INI_RADIATIONS_ECMWF
 !     ##########################
@@ -176,12 +171,14 @@ END MODULE MODI_INI_RADIATIONS_ECMWF
 !!      (A.Grini) 07/2005 add dust
 !!      (M.Tomasini P.Peyrille)  06/2012  to set date to a perpetual day if LFIX_DAT=T
 !!      (V. Masson)          replaces cover fractions by sea/town/bare soil fractions
+!!      J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !-------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
 !              ------------
 !ECMWF radiation scheme specific modules 
 !
+USE PARKIND1,  ONLY : JPRB
 USE YOEAERD  , ONLY : RCAEOPS  ,RCAEOPL  ,RCAEOPU  ,RCAEOPD  ,RCTRBGA  ,&
      RCVOBGA  ,RCSTBGA  ,RCTRPT   ,RCAEADM  ,RCAEROS  ,&
      RCAEADK
@@ -296,12 +293,14 @@ REAL, DIMENSION(SIZE(PTHT,1),SIZE(PTHT,2),SIZE(PTHT,3)) :: ZEXNT ! Exner functio
 !
 ! Variables for aerosols and ozone climatologies set up
 REAL, DIMENSION (:),     ALLOCATABLE  :: ZAESEA, ZAELAN, ZAEURB, ZAEDES
+REAL(KIND=JPRB), DIMENSION (:), ALLOCATABLE  :: ZAESEA_RAD, ZAELAN_RAD, ZAEURB_RAD, ZAEDES_RAD
 LOGICAL, DIMENSION (:,:),ALLOCATABLE  :: GAFRICA, GASIA, GAUSTRALIA
 REAL, DIMENSION (:,:),   ALLOCATABLE  :: ZDESERT ! desert fraction
-REAL, DIMENSION (:,:,:), ALLOCATABLE  :: ZAER
-REAL, DIMENSION (:,:),   ALLOCATABLE  :: ZPRES_HL,ZT_HL, ZPAVE, ZOZON, ZWORK_GRID
-REAL, DIMENSION (:,:),   ALLOCATABLE  :: ZCVDAES, ZCVDAEL, ZCVDAEU, ZCVDAED,ZETAH
-REAL, DIMENSION (:),     ALLOCATABLE  :: ZGEMU 
+REAL, DIMENSION (:,:),   ALLOCATABLE  :: ZPAVE, ZWORK_GRID
+REAL(KIND=JPRB), DIMENSION (:,:,:), ALLOCATABLE  :: ZAER
+REAL(KIND=JPRB), DIMENSION (:,:),   ALLOCATABLE  :: ZPRES_HL,ZT_HL,ZOZON
+REAL(KIND=JPRB), DIMENSION (:,:),   ALLOCATABLE  :: ZCVDAES, ZCVDAEL, ZCVDAEU, ZCVDAED,ZETAH
+REAL(KIND=JPRB), DIMENSION (:),     ALLOCATABLE  :: ZGEMU 
 REAL, DIMENSION(:),      ALLOCATABLE  :: ZAECOV_SEA, ZAECOV_URB, ZAECOV_LAN, ZAECOV_DES
 INTEGER :: ZYMD, ZHOURS   ! date for climatology initialisation
 !
@@ -556,6 +555,11 @@ IF(HAER /= 'NONE') THEN
   ALLOCATE (ZAELAN(KDLON))
   ALLOCATE (ZAEURB(KDLON))
   ALLOCATE (ZAEDES(KDLON))
+
+  ALLOCATE (ZAESEA_RAD(KDLON))
+  ALLOCATE (ZAELAN_RAD(KDLON))
+  ALLOCATE (ZAEURB_RAD(KDLON))
+  ALLOCATE (ZAEDES_RAD(KDLON))
 !
 ! AEROSOLS ECMWF climatologies
 !
@@ -654,9 +658,10 @@ IF(HAER /= 'NONE') THEN
 !
 ! final aerosol profiles on mnh grid
 !
+  ZAESEA_RAD = ZAESEA ; ZAELAN_RAD = ZAELAN ; ZAEURB_RAD = ZAEURB ; ZAEDES_RAD = ZAEDES
   CALL RADAER (1, KDLON, KDLON, 1, KFLEV, ZPRES_HL,ZT_HL, &
        ZCVDAES ,ZCVDAEL ,ZCVDAEU ,ZCVDAED, &
-       ZAESEA, ZAELAN, ZAEURB, ZAEDES, &
+       ZAESEA_RAD, ZAELAN_RAD, ZAEURB_RAD, ZAEDES_RAD, &
        ZAER )
 !
 !!- VOLCANIC AEROSOL SET TO epsilon IN ABSENCE OF ERUPTION 
@@ -670,6 +675,11 @@ IF(HAER /= 'NONE') THEN
   DEALLOCATE (ZAELAN)
   DEALLOCATE (ZAEURB)
   DEALLOCATE (ZAEDES)
+
+  DEALLOCATE (ZAESEA_RAD)
+  DEALLOCATE (ZAELAN_RAD)
+  DEALLOCATE (ZAEURB_RAD)
+  DEALLOCATE (ZAEDES_RAD)
 ELSE
   ZAER(:,:,:)= 1E-12
 END IF
diff --git a/src/MNH/radiations.f90 b/src/MNH/radiations.f90
index 7b9798cb402c9d2547f6deaa05ff7d43adaf709b..d2ae05c52a962dcdbef4c09a6396f693b20a7425 100644
--- a/src/MNH/radiations.f90
+++ b/src/MNH/radiations.f90
@@ -3,11 +3,6 @@
 !MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  
 !MNH_LIC for details. version 1.
 !-----------------------------------------------------------------
-!--------------- special set of characters for RCS information
-!-----------------------------------------------------------------
-! $Source: /home/cvsroot/MNH-VX-Y-Z/src/MNH/radiations.f90,v $ $Revision: 1.3.2.3.2.2.2.4 $
-! masdev4_7 BUG1 2007/06/15 17:47:18
-!-----------------------------------------------------------------
 !    ########################
      MODULE MODI_RADIATIONS   
 !    ########################
@@ -212,11 +207,13 @@ END MODULE MODI_RADIATIONS
 !!      B.Aouizerats 2010     Explicit aerosol optical properties
 !!      C.Lac       11/2015   Correction on aerosols
 !!      B.Vie            /13  LIMA
+!!      J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !-------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
 !              ------------
 !
+USE PARKIND1 , ONLY : JPRB
 USE MODE_FMWRIT
 USE MODE_FM
 USE MODE_ll
@@ -375,9 +372,11 @@ INTEGER :: IDIM          ! effective number of columns for which the radiation
 INTEGER :: INIR          ! index corresponding to NIR fisrt band (in SW)
 !
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZTAVE    ! mean-layer temperature
+REAL(KIND=JPRB), DIMENSION(:,:), ALLOCATABLE   :: ZTAVE_RAD    ! mean-layer temperature
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZPAVE    ! mean-layer pressure
-REAL, DIMENSION(:,:), ALLOCATABLE   :: ZQSAVE   ! saturation specific humidity
-REAL, DIMENSION(:,:), ALLOCATABLE   :: ZQVAVE   ! mean-layer specific humidity
+REAL(KIND=JPRB), DIMENSION(:,:), ALLOCATABLE   :: ZPAVE_RAD    ! mean-layer pressure
+REAL(KIND=JPRB), DIMENSION(:,:), ALLOCATABLE   :: ZQSAVE   ! saturation specific humidity
+REAL(KIND=JPRB), DIMENSION(:,:), ALLOCATABLE   :: ZQVAVE   ! mean-layer specific humidity
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZQLAVE   ! Liquid water KG/KG
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZQRAVE   ! Rain water  KG/KG
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZQIAVE   ! Ice water Kg/KG
@@ -386,9 +385,9 @@ REAL, DIMENSION(:,:), ALLOCATABLE   :: ZQRWC   ! Rain water  content kg/m3
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZQIWC   ! ice water content  kg/m3
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZCFAVE   ! mean-layer cloud fraction
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZO3AVE   ! mean-layer ozone content 
-REAL, DIMENSION(:,:), ALLOCATABLE   :: ZPRES_HL ! half-level pressure
-REAL, DIMENSION(:,:), ALLOCATABLE   :: ZT_HL    ! half-level temperature
-REAL, DIMENSION(:,:), ALLOCATABLE   :: ZDPRES   ! layer pressure thickness
+REAL(KIND=JPRB), DIMENSION(:,:), ALLOCATABLE   :: ZPRES_HL ! half-level pressure
+REAL(KIND=JPRB), DIMENSION(:,:), ALLOCATABLE   :: ZT_HL    ! half-level temperature
+REAL(KIND=JPRB), DIMENSION(:,:), ALLOCATABLE   :: ZDPRES   ! layer pressure thickness
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZCCT_C2R2! Cloud water Concentarion (C2R2)
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZCRT_C2R2! Rain water Concentarion (C2R2)
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZCIT_C1R3! Ice water Concentarion (C2R2)
@@ -400,10 +399,10 @@ REAL, DIMENSION(:,:), ALLOCATABLE   :: ZALBP    ! spectral surface albedo for di
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZALBD    ! spectral surface albedo for diffuse radiations 
 REAL, DIMENSION (:),  ALLOCATABLE   :: ZEMIS    ! surface LW  emissivity 
 REAL, DIMENSION (:), ALLOCATABLE    :: ZEMIW    ! surface LW  WINDOW emissivity
-REAL, DIMENSION(:), ALLOCATABLE     :: ZTS      ! reformatted surface PTSRAD array 
+REAL(KIND=JPRB), DIMENSION(:), ALLOCATABLE     :: ZTS      ! reformatted surface PTSRAD array 
 REAL, DIMENSION(:), ALLOCATABLE     :: ZLSM     ! reformatted land sea mask
 REAL, DIMENSION(:),   ALLOCATABLE   :: ZRMU0    ! Reformatted ZMU0 array
-REAL                                :: ZRII0    ! corrected solar constant
+REAL(KIND=JPRB)                     :: ZRII0    ! corrected solar constant
 !
 REAL, DIMENSION(:,:), ALLOCATABLE :: ZDTLW    ! LW temperature tendency
 REAL, DIMENSION(:,:), ALLOCATABLE :: ZDTSW    ! SW temperature tendency
@@ -503,15 +502,15 @@ REAL, DIMENSION(:),     ALLOCATABLE :: ZEMIS_SPLIT, ZEMIW_SPLIT
 REAL, DIMENSION(:),     ALLOCATABLE :: ZRMU0_SPLIT
 REAL, DIMENSION(:,:),   ALLOCATABLE :: ZCFAVE_SPLIT
 REAL, DIMENSION(:,:),   ALLOCATABLE :: ZO3AVE_SPLIT
-REAL, DIMENSION(:,:),   ALLOCATABLE :: ZT_HL_SPLIT
-REAL, DIMENSION(:,:),   ALLOCATABLE :: ZPRES_HL_SPLIT
-REAL, DIMENSION(:,:),   ALLOCATABLE :: ZTAVE_SPLIT
-REAL, DIMENSION(:,:),   ALLOCATABLE :: ZPAVE_SPLIT
+REAL(KIND=JPRB), DIMENSION(:,:),   ALLOCATABLE :: ZT_HL_SPLIT
+REAL(KIND=JPRB), DIMENSION(:,:),   ALLOCATABLE :: ZPRES_HL_SPLIT
+REAL(KIND=JPRB), DIMENSION(:,:),   ALLOCATABLE :: ZTAVE_SPLIT
+REAL(KIND=JPRB), DIMENSION(:,:),   ALLOCATABLE :: ZPAVE_SPLIT
 REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZAER_SPLIT
-REAL, DIMENSION(:,:),   ALLOCATABLE :: ZDPRES_SPLIT
+REAL(KIND=JPRB), DIMENSION(:,:),   ALLOCATABLE :: ZDPRES_SPLIT
 REAL, DIMENSION(:),     ALLOCATABLE :: ZLSM_SPLIT
-REAL, DIMENSION(:,:),   ALLOCATABLE :: ZQVAVE_SPLIT
-REAL, DIMENSION(:,:),   ALLOCATABLE :: ZQSAVE_SPLIT
+REAL(KIND=JPRB), DIMENSION(:,:),   ALLOCATABLE :: ZQVAVE_SPLIT
+REAL(KIND=JPRB), DIMENSION(:,:),   ALLOCATABLE :: ZQSAVE_SPLIT
 REAL, DIMENSION(:,:),   ALLOCATABLE :: ZQLAVE_SPLIT
 REAL, DIMENSION(:,:),   ALLOCATABLE :: ZQIAVE_SPLIT
 REAL, DIMENSION(:,:),   ALLOCATABLE :: ZQRAVE_SPLIT
@@ -525,7 +524,7 @@ REAL, DIMENSION(:,:), ALLOCATABLE   :: ZCIT_C1R3_SPLIT
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZCCT_LIMA_SPLIT
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZCRT_LIMA_SPLIT
 REAL, DIMENSION(:,:), ALLOCATABLE   :: ZCIT_LIMA_SPLIT
-REAL, DIMENSION(:),     ALLOCATABLE :: ZTS_SPLIT
+REAL(KIND=JPRB), DIMENSION(:),     ALLOCATABLE :: ZTS_SPLIT
 REAL, DIMENSION(:,:),   ALLOCATABLE :: ZSFSWDIR_SPLIT
 REAL, DIMENSION(:,:),   ALLOCATABLE :: ZSFSWDIF_SPLIT
 REAL, DIMENSION(:,:),   ALLOCATABLE :: ZNFLW_CS_SPLIT
@@ -579,12 +578,12 @@ REAL, DIMENSION(:,:,:), ALLOCATABLE :: PAER_AER      !tau/tau_{550} aerosol from
 REAL, DIMENSION(:,:,:), ALLOCATABLE :: PAER_SLT      !tau/tau_{550} sea salt               (lon,lat,lev,wvl)
 REAL, DIMENSION(:,:,:), ALLOCATABLE :: PAER_DST     !tau/tau_{550} dust               (lon,lat,lev,wvl)
 REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZTAU550_EQ_TMP      !tau/tau_{550} aerosols               (lon,lat,lev,wvl)
-REAL, DIMENSION(:,:,:), ALLOCATABLE   :: ZPIZA_EQ            !Single scattering albedo of aerosols (points,lev,wvl)
-REAL, DIMENSION(:,:,:), ALLOCATABLE   :: ZCGA_EQ             !Assymetry factor aerosols            (points,lev,wvl)
-REAL, DIMENSION(:,:,:), ALLOCATABLE   :: ZTAUREL_EQ          !tau/tau_{550} aerosols               (points,lev,wvl)
-REAL, DIMENSION(:,:,:), ALLOCATABLE   :: ZPIZA_EQ_SPLIT      !Single scattering albedo of aerosols (points,lev,wvl)
-REAL, DIMENSION(:,:,:), ALLOCATABLE   :: ZCGA_EQ_SPLIT       !Assymetry factor aerosols            (points,lev,wvl)
-REAL, DIMENSION(:,:,:), ALLOCATABLE   :: ZTAUREL_EQ_SPLIT    !tau/tau_{550} aerosols               (points,lev,wvl)
+REAL(KIND=JPRB), DIMENSION(:,:,:), ALLOCATABLE   :: ZPIZA_EQ            !Single scattering albedo of aerosols (points,lev,wvl)
+REAL(KIND=JPRB), DIMENSION(:,:,:), ALLOCATABLE   :: ZCGA_EQ             !Assymetry factor aerosols            (points,lev,wvl)
+REAL(KIND=JPRB), DIMENSION(:,:,:), ALLOCATABLE   :: ZTAUREL_EQ          !tau/tau_{550} aerosols               (points,lev,wvl)
+REAL(KIND=JPRB), DIMENSION(:,:,:), ALLOCATABLE   :: ZPIZA_EQ_SPLIT      !Single scattering albedo of aerosols (points,lev,wvl)
+REAL(KIND=JPRB), DIMENSION(:,:,:), ALLOCATABLE   :: ZCGA_EQ_SPLIT       !Assymetry factor aerosols            (points,lev,wvl)
+REAL(KIND=JPRB), DIMENSION(:,:,:), ALLOCATABLE   :: ZTAUREL_EQ_SPLIT    !tau/tau_{550} aerosols               (points,lev,wvl)
 REAL, DIMENSION(KFLEV,KSWB)           :: ZPIZA_EQ_CLEAR      !Single scattering albedo of aerosols (lev,wvl)
 REAL, DIMENSION(KFLEV,KSWB)           :: ZCGA_EQ_CLEAR       !Assymetry factor aerosols            (lev,wvl)
 REAL, DIMENSION(KFLEV,KSWB)           :: ZTAUREL_EQ_CLEAR    !tau/tau_{550} aerosols               (lev,wvl)
@@ -1948,13 +1947,17 @@ IF( IDIM <= KRAD_COLNBR ) THEN
 ! there is less than KRAD_COLNBR verticals to be considered therefore
 ! no split of the arrays is performed
 !
+ ALLOCATE(ZTAVE_RAD(SIZE(ZTAVE,1),SIZE(ZTAVE,2)))
+ ALLOCATE(ZPAVE_RAD(SIZE(ZPAVE,1),SIZE(ZPAVE,2)))
+ ZTAVE_RAD = ZTAVE
+ ZPAVE_RAD = ZPAVE
  IF (CCLOUD == 'LIMA') THEN
   CALL ECMWF_RADIATION_VERS2  ( IDIM ,KFLEV, KRAD_DIAG, KAER,     &      
        ZDZ,HEFRADL,HEFRADI,HOPWSW, HOPISW, HOPWLW, HOPILW,PFUDG,      &
-       ZRII0, ZAER , ZALBD, ZALBP, ZPRES_HL, ZPAVE,               &
+       ZRII0, ZAER , ZALBD, ZALBP, ZPRES_HL, ZPAVE_RAD,               &
        PCCO2, ZCFAVE, ZDPRES, ZEMIS, ZEMIW, ZLSM, ZRMU0,          &
        ZO3AVE , ZQVAVE, ZQIAVE ,ZQIWC,ZQLAVE,ZQLWC, ZQSAVE, ZQRAVE,  ZQRWC,  &
-       ZT_HL,ZTAVE, ZTS, ZCCT_LIMA, ZCRT_LIMA, ZCIT_LIMA,         &
+       ZT_HL,ZTAVE_RAD, ZTS, ZCCT_LIMA, ZCRT_LIMA, ZCIT_LIMA,         &
        ZNFLW_CS, ZNFLW, ZNFSW_CS,ZNFSW,                           &
        ZDTLW, ZDTSW, ZFLUX_TOP_GND_IRVISNIR,                      &
        ZSFSWDIR, ZSFSWDIF,                                        &
@@ -1969,10 +1972,10 @@ IF( IDIM <= KRAD_COLNBR ) THEN
  ELSE
    CALL ECMWF_RADIATION_VERS2  ( IDIM ,KFLEV, KRAD_DIAG, KAER,     &      
        ZDZ,HEFRADL,HEFRADI,HOPWSW, HOPISW, HOPWLW, HOPILW,PFUDG,      &
-       ZRII0, ZAER , ZALBD, ZALBP, ZPRES_HL, ZPAVE,               &
+       ZRII0, ZAER , ZALBD, ZALBP, ZPRES_HL, ZPAVE_RAD,               &
        PCCO2, ZCFAVE, ZDPRES, ZEMIS, ZEMIW, ZLSM, ZRMU0,          &
        ZO3AVE , ZQVAVE, ZQIAVE ,ZQIWC,ZQLAVE,ZQLWC, ZQSAVE, ZQRAVE,  ZQRWC,  &
-       ZT_HL,ZTAVE, ZTS, ZCCT_C2R2, ZCRT_C2R2, ZCIT_C1R3,         &
+       ZT_HL,ZTAVE_RAD, ZTS, ZCCT_C2R2, ZCRT_C2R2, ZCIT_C1R3,         &
        ZNFLW_CS, ZNFLW, ZNFSW_CS,ZNFSW,                           &
        ZDTLW, ZDTSW, ZFLUX_TOP_GND_IRVISNIR,                      &
        ZSFSWDIR, ZSFSWDIF,                                        &
@@ -1985,6 +1988,7 @@ IF( IDIM <= KRAD_COLNBR ) THEN
        ZOMEGA_TOTAL,ZCG_TOTAL,                                    &
        GAOP, ZPIZA_EQ,ZCGA_EQ,ZTAUREL_EQ                       )
  END IF
+ DEALLOCATE(ZTAVE_RAD,ZPAVE_RAD)
 !
 ELSE
 !
diff --git a/src/MNH/set_mask.f90 b/src/MNH/set_mask.f90
index 5880001127f60879e7dd8aa8d3f65b4185347e54..88b9711ff73bfeda46d3ab521d57b21385b76cb2 100644
--- a/src/MNH/set_mask.f90
+++ b/src/MNH/set_mask.f90
@@ -5,7 +5,7 @@
 !-----------------------------------------------------------------
 !--------------- special set of characters for RCS information
 !-----------------------------------------------------------------
-! $Source$ $Revision$
+! $Source: /home/cvsroot/MNH-VX-Y-Z/src/MNH/set_mask.f90,v $ $Revision: 1.2.2.1.2.1.18.2 $
 ! MASDEV4_7 budget 2006/09/08 10:35:15
 !-----------------------------------------------------------------
 !     ###################
@@ -57,6 +57,7 @@
 !!      Modification 18/06/99  (N.Asencio) : //  , computation are performed on the extended
 !!                                           domain but logical array mask is initialized
 !!                                           to FALSE outside the physical domain
+!!                   02/02/2017 (J.Escobar & JPP ) bug for 1 model only <-> remove unneeded FIELD_MODEL%
 !---------------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
@@ -64,7 +65,7 @@
 !
 USE MODD_BUDGET
 USE MODE_ll
-USE MODD_FIELD_n, ONLY : FIELD_MODEL
+USE MODD_FIELD_n , ONLY : XWT , XRT
 !
 !
 IMPLICIT NONE
@@ -94,11 +95,11 @@ LBU_MASK(:,:,:)=.FALSE.
 ! Change the following lines to set the criterion for each of the NBUMASK masks
 ! 
 ! 1st mask on vertical velocity at level k=10
-LBU_MASK(IIB:IIE,IJB:IJE,1)=FIELD_MODEL(NBUMOD)%XWT(IIB:IIE,IJB:IJE,10)>0.
+LBU_MASK(IIB:IIE,IJB:IJE,1)=XWT(IIB:IIE,IJB:IJE,10)>0.
 !
 !2rd mask on rain mixing ratio at level k=2
 IF (NBUMASK>=2) &
-  LBU_MASK(IIB:IIE,IJB:IJE,2)=FIELD_MODEL(NBUMOD)%XRT(IIB:IIE,IJB:IJE,2,3)>1.E-8
+  LBU_MASK(IIB:IIE,IJB:IJE,2)=XRT(IIB:IIE,IJB:IJE,2,3)>1.E-8
 !
 !==============================================================================
 !
diff --git a/src/SURFEX/abor1_sfx.F90 b/src/SURFEX/abor1_sfx.F90
index 5559730140fb272f4d273ec0032c7a1c1d1282c2..ef01151ea5a725a2c088e237d80aa8e93e9580c6 100644
--- a/src/SURFEX/abor1_sfx.F90
+++ b/src/SURFEX/abor1_sfx.F90
@@ -32,6 +32,7 @@
 !!    MODIFICATIONS
 !!    -------------
 !!      Original    06/2008 
+!!      16/01/2017 J.Escobar :  For MNH , Pb with CLOSE_FILE  // if not all proc abort  
 !-------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
@@ -94,7 +95,11 @@ WRITE(ILUOUT,*)YTEXT
 WRITE(ILUOUT,*) '-                                                                         -'
 WRITE(ILUOUT,*) '---------------------------------------------------------------------------'
 WRITE(ILUOUT,*) '---------------------------------------------------------------------------'
+#ifndef SFX_MNH
  CALL CLOSE_FILE(YPROGRAM,ILUOUT)
+#else
+ CLOSE(UNIT=ILUOUT)
+#endif
 !
 #ifdef SFX_ARO
 call abor1('abort by abor1_sfx')
diff --git a/src/SURFEX/assim_inland_watern.F90 b/src/SURFEX/assim_inland_watern.F90
index b78e0d6fba32fdeae8a3f22b3550eec9c35089b1..f83a3883fbe50369301aba713ac6a8a613887ebf 100644
--- a/src/SURFEX/assim_inland_watern.F90
+++ b/src/SURFEX/assim_inland_watern.F90
@@ -29,6 +29,7 @@ SUBROUTINE ASSIM_INLAND_WATER_n (I, U, W, &
 !!    -------------
 !!      Original    04/2012
 !!      Trygve Aspelien, Separating IO  06/2013
+!!      J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !!--------------------------------------------------------------------
 !
 !
@@ -62,8 +63,8 @@ REAL,DIMENSION(KI), INTENT(IN) :: PITM
  CHARACTER(LEN=2),   INTENT(IN) :: HTEST ! must be equal to 'OK'
 LOGICAL, INTENT(IN) :: OLKEEPEXTZONE
 LOGICAL, DIMENSION(KI), INTENT(IN) :: OD_MASKEXT
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLON_IN
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLAT_IN
+REAL           , DIMENSION (:), INTENT(IN) ::  PLON_IN
+REAL           , DIMENSION (:), INTENT(IN) ::  PLAT_IN
 !
 !*      0.2    declarations of local variables
 !
diff --git a/src/SURFEX/assim_isban.F90 b/src/SURFEX/assim_isban.F90
index 72bda813e2c054cd1bbb5688038078981a470858..c197c62295cb620540ac11d12a5d820de7267d08 100644
--- a/src/SURFEX/assim_isban.F90
+++ b/src/SURFEX/assim_isban.F90
@@ -33,6 +33,7 @@ SUBROUTINE ASSIM_ISBA_n (DGMI, IG, I, U, &
 !!    -------------
 !!      Original    04/2012
 !!      Trygve Aspelien, Separating IO  06/2013
+!!      J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !!--------------------------------------------------------------------
 !
 !
@@ -88,8 +89,8 @@ REAL, DIMENSION(KI), INTENT(IN) :: PHU2M
 REAL, DIMENSION(KI), INTENT(IN) :: PSWE
  CHARACTER(LEN=2),    INTENT(IN) :: HTEST ! must be equal to 'OK'
 LOGICAL,  DIMENSION (KI), INTENT(IN) ::  OD_MASKEXT
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLON_IN
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLAT_IN
+REAL           , DIMENSION (:), INTENT(IN) ::  PLON_IN
+REAL           , DIMENSION (:), INTENT(IN) ::  PLAT_IN
 !
 !*      0.2    declarations of local variables
 !
diff --git a/src/SURFEX/assim_nature_isba_oi.F90 b/src/SURFEX/assim_nature_isba_oi.F90
index c3f521193a1439c697549c36c4065dd15f0ef878..3e64c444c5690364e84a2dcca787ff3aa2d7026c 100644
--- a/src/SURFEX/assim_nature_isba_oi.F90
+++ b/src/SURFEX/assim_nature_isba_oi.F90
@@ -31,6 +31,7 @@ SUBROUTINE ASSIM_NATURE_ISBA_OI (I, &
 !   (07/2011)  : Read pgd+prep (B. Decharme)
 !   (04/2012)  : Made as a subroutine (T. Aspelien)
 !   (06/2013)  : Separating IO (T. Aspelien)
+!   J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 ! ******************************************************************************************
 ! ------------------------------------------------------------------------------------------
 !
@@ -75,8 +76,8 @@ REAL, DIMENSION(KI), INTENT(IN) :: PHU2M_O
 REAL, DIMENSION(KI), INTENT(OUT):: PSWE
  CHARACTER(LEN=2),    INTENT(IN) :: HTEST ! must be equal to 'OK'
 LOGICAL,  DIMENSION (KI) ::  OD_MASKEXT
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLON_IN
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLAT_IN
+REAL           , DIMENSION (:), INTENT(IN) ::  PLON_IN
+REAL           , DIMENSION (:), INTENT(IN) ::  PLAT_IN
 
 !    Declarations of local variables
 !
diff --git a/src/SURFEX/assim_naturen.F90 b/src/SURFEX/assim_naturen.F90
index 48ac005001c887df6e2c13a7b5cceb392aa3693b..793792aca3b3df95f2e30b646e6ebc8fc82402e6 100644
--- a/src/SURFEX/assim_naturen.F90
+++ b/src/SURFEX/assim_naturen.F90
@@ -32,6 +32,7 @@ SUBROUTINE ASSIM_NATURE_n (DGMI, IG, I, U, &
 !!    MODIFICATIONS
 !!    -------------
 !!      Original    04/2012
+!!      J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !!--------------------------------------------------------------------
 !
 !
@@ -77,8 +78,8 @@ REAL, DIMENSION(KI), INTENT(IN) :: PHU2M
 REAL, DIMENSION(KI), INTENT(IN) :: PSWE
  CHARACTER(LEN=2),    INTENT(IN) :: HTEST ! must be equal to 'OK'
 LOGICAL,  DIMENSION (KI), INTENT(IN) ::  OD_MASKEXT
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLON
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLAT
+REAL           , DIMENSION (:), INTENT(IN) ::  PLON
+REAL           , DIMENSION (:), INTENT(IN) ::  PLAT
 !
 !*      0.2    declarations of local variables
 !
diff --git a/src/SURFEX/assim_sean.F90 b/src/SURFEX/assim_sean.F90
index 7fe2c80b13537ceaf029a02cf3ed38d4781f00ce..49b695b877e016796db7791c1298e46400228480 100644
--- a/src/SURFEX/assim_sean.F90
+++ b/src/SURFEX/assim_sean.F90
@@ -29,6 +29,7 @@ SUBROUTINE ASSIM_SEA_n (S, U, &
 !!    -------------
 !!      Original       04/2012
 !!      Trygve Aspelien, Separating IO  06/2013 
+!!      J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
 !!--------------------------------------------------------------------
 !
 !
@@ -65,8 +66,8 @@ REAL,DIMENSION(KI), INTENT(IN) :: PITM
  CHARACTER(LEN=2),   INTENT(IN) :: HTEST ! must be equal to 'OK'
 LOGICAL, INTENT(IN) :: OLKEEPEXTZONE
 LOGICAL, DIMENSION(KI), INTENT(IN) :: OD_MASKEXT
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLON_IN
-REAL(KIND=JPRB), DIMENSION (:), INTENT(IN) ::  PLAT_IN
+REAL           , DIMENSION (:), INTENT(IN) ::  PLON_IN
+REAL           , DIMENSION (:), INTENT(IN) ::  PLAT_IN
 !
 !*      0.2    declarations of local variables
 !
diff --git a/src/SURFEX/modd_wp.F90 b/src/SURFEX/modd_wp.F90
index c05a99bbd22acefe3180fb1709029f408a70019b..18cb57ba015d521c6d186065d355e145cba8e7a6 100644
--- a/src/SURFEX/modd_wp.F90
+++ b/src/SURFEX/modd_wp.F90
@@ -5,5 +5,7 @@
 MODULE modd_wp
   !! necessary for compiling Gelato, but not included in LIB/GELATO for reasons relevant to 
   !! Gelato build process
-   INTEGER, PUBLIC, PARAMETER ::   wp = SELECTED_REAL_KIND(12,307)   !: double precision (real 8)
+  !! Modi J.Escobar 24/03/2017 : auto detection of size of real for possible compilation in 4/8bytes
+   REAL , PRIVATE             :: REAL_DEF_WP
+   INTEGER, PUBLIC, PARAMETER ::   wp =  KIND(REAL_DEF_WP) ! SELECTED_REAL_KIND(12,307)   !: double precision (real 8)
 END MODULE modd_wp
diff --git a/src/SURFEX/mode_geo_gauss.F90 b/src/SURFEX/mode_geo_gauss.F90
index bbb2778c54692dbe71e5fd99a3b81f8081b49d6d..9dcb2b0422f3388a6753d70d6b65289eaf6e43f2 100644
--- a/src/SURFEX/mode_geo_gauss.F90
+++ b/src/SURFEX/mode_geo_gauss.F90
@@ -11,6 +11,7 @@ MODULE MODE_GEO_GAUSS
   !!     MODIFICATION
   !!     ------------
   !!       Original  10/2005
+  !!       J.Escobar 30/03/2017  : Management of compilation of ECMWF_RAD in REAL*8 with MNH_REAL=R4
   !!
   !--------------------------------------------------------------------------- 
   USE EGGANGLES, ONLY : LOLA
@@ -106,7 +107,7 @@ MODULE MODE_GEO_GAUSS
     TYPE (LOLA), INTENT(IN)          :: PT_TR
     TYPE (LOLA), INTENT(IN)          :: PT_POLE
 
-    REAL(KIND=JPRB)    :: ZSIN, ZCOS
+    REAL    :: ZSIN, ZCOS
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:ROTATE_G_S',0,ZHOOK_HANDLE)
@@ -129,7 +130,7 @@ MODULE MODE_GEO_GAUSS
     TYPE (LOLA), INTENT(IN)                        :: PT_POLE
     TYPE (LOLA), DIMENSION(SIZE(PT_TR))            :: PT_REEL
 
-    REAL(KIND=JPRB), DIMENSION(SIZE(PT_TR))                   :: ZSIN, ZCOS
+    REAL, DIMENSION(SIZE(PT_TR))                   :: ZSIN, ZCOS
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:ROTATE_G_V',0,ZHOOK_HANDLE)
@@ -155,7 +156,7 @@ MODULE MODE_GEO_GAUSS
     TYPE (LOLA), INTENT(IN)          :: PT_REEL
     TYPE (LOLA), INTENT(IN)          :: PT_POLE
 
-    REAL(KIND=JPRB) :: ZSIN, ZCOS
+    REAL :: ZSIN, ZCOS
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
    
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:ANTI_ROTATE_G_S',0,ZHOOK_HANDLE)
@@ -177,7 +178,7 @@ MODULE MODE_GEO_GAUSS
     TYPE (LOLA), INTENT(IN)                        :: PT_POLE
     TYPE (LOLA), DIMENSION(SIZE(PT_REEL))          :: PT_TR  
 
-    REAL(KIND=JPRB), DIMENSION(SIZE(PT_REEL)) :: ZSIN, ZCOS
+    REAL, DIMENSION(SIZE(PT_REEL)) :: ZSIN, ZCOS
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
    IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:ANTI_ROTATE_G_V',0,ZHOOK_HANDLE)
@@ -202,7 +203,7 @@ MODULE MODE_GEO_GAUSS
     TYPE (LOLA), INTENT(IN)          :: PT_COORD
     REAL, INTENT(IN)                 :: PCODIL
 
-    REAL(KIND=JPRB) :: ZPC2, ZSIN, ZCOS
+    REAL :: ZPC2, ZSIN, ZCOS
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:ETIR_S',0,ZHOOK_HANDLE)
@@ -222,7 +223,7 @@ MODULE MODE_GEO_GAUSS
     REAL, INTENT(IN)                        :: PCODIL
     TYPE (LOLA), DIMENSION(SIZE(PT_COORD))  :: PT_ET
 
-    REAL(KIND=JPRB), DIMENSION(SIZE(PT_COORD))         :: ZPC2, ZSIN, ZCOS
+    REAL, DIMENSION(SIZE(PT_COORD))         :: ZPC2, ZSIN, ZCOS
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:ETIR_V',0,ZHOOK_HANDLE)
@@ -241,7 +242,7 @@ MODULE MODE_GEO_GAUSS
     TYPE (LOLA), INTENT(IN)          :: PT_COORD
     REAL, INTENT(IN)                 :: PCODIL
 
-    REAL(KIND=JPRB)     :: ZPC2, ZSIN, ZCOS
+    REAL     :: ZPC2, ZSIN, ZCOS
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:RETRE_S',0,ZHOOK_HANDLE)
@@ -261,7 +262,7 @@ MODULE MODE_GEO_GAUSS
     REAL, INTENT(IN)                        :: PCODIL
     TYPE (LOLA), DIMENSION(SIZE(PT_COORD))  :: PT_RE
 
-    REAL(KIND=JPRB), DIMENSION(SIZE(PT_COORD))         :: ZPC2, ZSIN, ZCOS
+    REAL, DIMENSION(SIZE(PT_COORD))         :: ZPC2, ZSIN, ZCOS
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:RETRE_V',0,ZHOOK_HANDLE)
@@ -283,7 +284,7 @@ MODULE MODE_GEO_GAUSS
     TYPE (LOLA), INTENT(IN)          :: POLE, PT_COORD
     REAL, INTENT(IN)                 :: PCODIL
     
-    REAL(KIND=JPRB) :: ZPC2
+    REAL :: ZPC2
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:MAP_FAC_S',0,ZHOOK_HANDLE)
     ZPC2  = PCODIL*PCODIL
@@ -299,7 +300,7 @@ MODULE MODE_GEO_GAUSS
     REAL, INTENT(IN)                        :: PCODIL
     REAL, DIMENSION(SIZE(PT_COORD))         :: PMF
 
-    REAL(KIND=JPRB), DIMENSION(SIZE(PT_COORD))         :: ZPC2
+    REAL, DIMENSION(SIZE(PT_COORD))         :: ZPC2
     REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
     IF (LHOOK) CALL DR_HOOK('MODE_GEO_GAUSS:MAP_FAC_V',0,ZHOOK_HANDLE)
diff --git a/src/SURFEX/mode_read_extern.F90 b/src/SURFEX/mode_read_extern.F90
index 9b81e89f5344f8cf1d23720e1e76b93671b31f7b..223a60cb29281fdfd8fe136085f9ca5250366bc1 100644
--- a/src/SURFEX/mode_read_extern.F90
+++ b/src/SURFEX/mode_read_extern.F90
@@ -294,6 +294,14 @@ IF (HNAT=='NAT' .AND. (IVERSION>=7 .OR. .NOT.GECOCLIMAP)) THEN
     YCOMMENT=YRECFM2
     CALL READ_SURF(&
                HPROGRAM,YRECFM2,GDATA_GROUND_DEPTH,IRESP,HCOMMENT=YCOMMENT)
+    IF (IRESP/=0 .AND. YRECFM2=='L_GROUND_DEPTH' ) THEN
+     WRITE  (KLUOUT,*) ' | ERROR Reading L_GROUND_DEPTH try with L_GROUND_DPT'
+
+      YRECFM2='L_GROUND_DPT'
+      YCOMMENT=YRECFM2
+      CALL READ_SURF(&
+               HPROGRAM,YRECFM2,GDATA_GROUND_DEPTH,IRESP,HCOMMENT=YCOMMENT)
+    ENDIF  
     !
     IF (GDATA_GROUND_DEPTH) THEN
       !
diff --git a/src/configure b/src/configure
index 8f6ce93178628910eadcf35b96eef86b1879b564..cb9feedf79b593e1dd2a5afb962d6c680f74e33a 100755
--- a/src/configure
+++ b/src/configure
@@ -36,6 +36,19 @@ cd ${LOCAL}/conf
 TARG=$(uname -s -n)
 #
 case "$TARG" in
+'Linux'*'occigen'*)
+                export     ARCH=${ARCH:-LXifort}
+                export  VER_MPI=${VER_MPI:-MPIINTEL}
+                export OPTLEVEL=${OPTLEVEL:-O2}
+		export VER_CDF=${VER_CDF:-CDFAUTO}
+                export   MNHENV=${MNHENV:-"
+ulimit -s unlimited
+module purge
+module load intel/17.0 intelmpi/2017.0.098
+export SLURM_CPU_BIND=none
+export I_MPI_PIN_PROCESSOR_LIST=all:map=spread
+"}
+              ;;
 'Linux service'*)
                 export     ARCH=${ARCH:-LXifort}
                 export  VER_MPI=${VER_MPI:-MPIICE}
@@ -267,20 +280,6 @@ export I_MPI_PIN_PROCESSOR_LIST=all:map=spread
 "}
               ;;
 
-'Linux occigen'*)
-                export     ARCH=${ARCH:-LXifort}
-                export  VER_MPI=${VER_MPI:-MPIINTEL}
-                export OPTLEVEL=${OPTLEVEL:-O2}
-		export VER_CDF=${VER_CDF:-CDFAUTO}
-                export   MNHENV=${MNHENV:-"
-ulimit -s unlimited
-module load intel/15.0.3.187
-module load intelmpi/5.0.1.035
-export SLURM_CPU_BIND=none
-export I_MPI_PIN_PROCESSOR_LIST=all:map=spread
-"}
-              ;;
-
 Linux*)
                 export     ARCH=${ARCH:-LXgfortran}
                 export  VER_MPI=${VER_MPI:-MPIVIDE}
@@ -290,6 +289,15 @@ Linux*)
 		export VER_CDF=${VER_CDF:-CDFAUTO}
 		export NEED_NCARG=${NEED_NCARG:-YES}
               ;;
+Darwin*)
+                echo "WARNING:: Darwin for Mac not tested "
+                export     ARCH=${ARCH:-LXgfortran}
+                export  VER_MPI=${VER_MPI:-MPIVIDE}
+                export OPTLEVEL=${OPTLEVEL:-DEBUG}
+                export MVWORK=${MVWORK:-NO}
+		export VER_CDF=${VER_CDF:-CDFAUTO}
+		export NEED_NCARG=${NEED_NCARG:-NO}
+              ;;
 *)
                 echo "WARNING ; system not yet tested "
                 echo "WARNING ; edit profile_mesonh & set correct variables ARCH , VER_MPI & OPTLEVEL "