Index: LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/cosp_output_write_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 5154)
@@ -3,7 +3,7 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    MODULE cosp_output_write_mod
-  
+
    USE cosp_output_mod
-  
+
    IMPLICIT NONE
 
@@ -28,5 +28,5 @@
     USE wxios, only: wxios_closedef
     USE lmdz_xios, only: xios_update_calendar, xios_field_is_active, using_xios
-  IMPLICIT NONE  
+  IMPLICIT NONE
 !!! Variables d'entree
   integer               :: itap, Nlevlmdz, Ncolumns, Npoints
@@ -67,5 +67,5 @@
        itau_wcosp = itau_phy + itap + start_time * day_step_phy
         if (prt_level >= 10) then
-             WRITE(lunout,*)'itau_wcosp, itap, start_time, day_step_phy =', & 
+             WRITE(lunout,*)'itau_wcosp, itap, start_time, day_step_phy =', &
                              itau_wcosp, itap, start_time, day_step_phy
         endif
@@ -78,5 +78,5 @@
 
     ok_sync = .TRUE.
-    
+
 !DO iinit=1, iinitend
 ! AI sept 2014 cette boucle supprimee
@@ -93,5 +93,5 @@
 !         WRITE(lunout,*)'Apell xios_update_calendar cosp_varsdefined iinitend ', &
 !                         cosp_varsdefined,iinitend
-!   endif 
+!   endif
 !    CALL xios_update_calendar(itau_wcosp)
 !ENDIF
@@ -102,11 +102,11 @@
 !!!! Sorties Calipso
  if (cfg%Llidar_sim) then
-!!! AI 02 2018 
+!!! AI 02 2018
 ! Traitement missing_val
    where(stlidar%lidarcld == R_UNDEF) stlidar%lidarcld = missing_val
-   where(stlidar%proftemp == R_UNDEF) stlidar%proftemp = missing_val   !TIBO  
+   where(stlidar%proftemp == R_UNDEF) stlidar%proftemp = missing_val   !TIBO
    where(stlidar%profSR == R_UNDEF) stlidar%profSR = missing_val       !TIBO2
-   where(sglidar%beta_mol == R_UNDEF) sglidar%beta_mol = missing_val  
-   where(sglidar%beta_tot == R_UNDEF) sglidar%beta_tot = missing_val 
+   where(sglidar%beta_mol == R_UNDEF) sglidar%beta_mol = missing_val
+   where(sglidar%beta_tot == R_UNDEF) sglidar%beta_tot = missing_val
    where(stlidar%cldlayer == R_UNDEF) stlidar%cldlayer = missing_val
    where(stlidar%cldtype == R_UNDEF) stlidar%cldtype = missing_val     !OPAQ
@@ -119,9 +119,9 @@
    where(stlidar%lidarcldtype == R_UNDEF) stlidar%lidarcldtype = missing_val   !OPAQ
    where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = missing_val
- 
+
 !   print*,'Appel histwrite2d_cosp'
    if (cfg%Lcllcalipso) CALL histwrite2d_cosp(o_cllcalipso,stlidar%cldlayer(:,1))
    if (cfg%Lclhcalipso) CALL histwrite2d_cosp(o_clhcalipso,stlidar%cldlayer(:,3))
-   if (cfg%Lclmcalipso) CALL histwrite2d_cosp(o_clmcalipso,stlidar%cldlayer(:,2)) 
+   if (cfg%Lclmcalipso) CALL histwrite2d_cosp(o_clmcalipso,stlidar%cldlayer(:,2))
    if (cfg%Lcltcalipso) CALL histwrite2d_cosp(o_cltcalipso,stlidar%cldlayer(:,4))
    if (cfg%Lclcalipso) CALL histwrite3d_cosp(o_clcalipso,stlidar%lidarcld,nvert)
@@ -182,5 +182,5 @@
    if (cfg%LparasolRefl) CALL histwrite3d_cosp(o_parasol_refl,stlidar%parasolrefl,nvertp)
 
-  if (cfg%LparasolRefl) then 
+  if (cfg%LparasolRefl) then
     do k=1,PARASOL_NREFL
      do ip=1, Npoints
@@ -202,12 +202,12 @@
      if (cfg%Latb532) CALL histwrite4d_cosp(o_atb532,sglidar%beta_tot)
    ELSE
-     if (cfg%Latb532) then  
-       do icl=1,Ncolumns 
+     if (cfg%Latb532) then
+       do icl=1,Ncolumns
           CALL histwrite3d_cosp(o_atb532,sglidar%beta_tot(:,icl,:),nvertmcosp,icl)
        enddo
-     endif 
+     endif
    ENDIF
 
-   if (cfg%LlidarBetaMol532) CALL histwrite3d_cosp(o_beta_mol532,sglidar%beta_mol,nvertmcosp) 
+   if (cfg%LlidarBetaMol532) CALL histwrite3d_cosp(o_beta_mol532,sglidar%beta_mol,nvertmcosp)
 
  endif !Lidar
@@ -259,5 +259,5 @@
   where(isccp%fq_isccp == R_UNDEF) isccp%fq_isccp = missing_val
   where(isccp%boxtau == R_UNDEF) isccp%boxtau = missing_val
-  where(isccp%boxptop == R_UNDEF) isccp%boxptop = missing_val 
+  where(isccp%boxptop == R_UNDEF) isccp%boxptop = missing_val
 
    CALL histwrite2d_cosp(o_sunlit,gbx%sunlit)
@@ -267,5 +267,5 @@
      if (cfg%Lclisccp) then
        do icl=1,7
-         CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl) 
+         CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl)
        enddo
      endif
@@ -273,10 +273,10 @@
 
    if (cfg%Lboxtauisccp) CALL histwrite3d_cosp(o_boxtauisccp,isccp%boxtau,nvertcol)
-   if (cfg%Lboxptopisccp) CALL histwrite3d_cosp(o_boxptopisccp,isccp%boxptop,nvertcol) 
-   if (cfg%Lcltisccp) CALL histwrite2d_cosp(o_tclisccp,isccp%totalcldarea) 
-   if (cfg%Lpctisccp) CALL histwrite2d_cosp(o_ctpisccp,isccp%meanptop) 
-   if (cfg%Ltauisccp) CALL histwrite2d_cosp(o_tauisccp,isccp%meantaucld) 
-   if (cfg%Lalbisccp) CALL histwrite2d_cosp(o_albisccp,isccp%meanalbedocld) 
-   if (cfg%Lmeantbisccp) CALL histwrite2d_cosp(o_meantbisccp,isccp%meantb) 
+   if (cfg%Lboxptopisccp) CALL histwrite3d_cosp(o_boxptopisccp,isccp%boxptop,nvertcol)
+   if (cfg%Lcltisccp) CALL histwrite2d_cosp(o_tclisccp,isccp%totalcldarea)
+   if (cfg%Lpctisccp) CALL histwrite2d_cosp(o_ctpisccp,isccp%meanptop)
+   if (cfg%Ltauisccp) CALL histwrite2d_cosp(o_tauisccp,isccp%meantaucld)
+   if (cfg%Lalbisccp) CALL histwrite2d_cosp(o_albisccp,isccp%meanalbedocld)
+   if (cfg%Lmeantbisccp) CALL histwrite2d_cosp(o_meantbisccp,isccp%meantb)
    if (cfg%Lmeantbclrisccp) CALL histwrite2d_cosp(o_meantbclrisccp,isccp%meantbclr)
  endif ! Isccp
@@ -294,5 +294,5 @@
    ELSE
      if (cfg%LclMISR) then
-      do icl=1,7 
+      do icl=1,7
         CALL histwrite3d_cosp(o_clMISR,misr%fq_MISR(:,icl,:),nvertmisr,icl)
       enddo
@@ -329,5 +329,5 @@
         modis%Cloud_Top_Pressure_Total_Mean = missing_val
   where(modis%Liquid_Water_Path_Mean == R_UNDEF) &
-        modis%Liquid_Water_Path_Mean = missing_val 
+        modis%Liquid_Water_Path_Mean = missing_val
   where(modis%Ice_Water_Path_Mean == R_UNDEF) &
         modis%Ice_Water_Path_Mean = missing_val
@@ -335,5 +335,5 @@
   where(modis%Optical_Thickness_Total_LogMean == R_UNDEF) &
           modis%Optical_Thickness_Total_LogMean = missing_val
-           
+
   where(modis%Optical_Thickness_Water_LogMean == R_UNDEF) &
           modis%Optical_Thickness_Water_LogMean = missing_val
@@ -341,5 +341,5 @@
   where(modis%Optical_Thickness_Ice_LogMean == R_UNDEF) &
           modis%Optical_Thickness_Ice_LogMean = missing_val
-    
+
   if (cfg%Lcllmodis) CALL histwrite2d_cosp(o_cllmodis,modis%Cloud_Fraction_Low_Mean)
   if (cfg%Lclhmodis) CALL histwrite2d_cosp(o_clhmodis,modis%Cloud_Fraction_High_Mean)
@@ -351,5 +351,5 @@
   if (cfg%Ltauwmodis) CALL histwrite2d_cosp(o_tauwmodis,modis%Optical_Thickness_Water_Mean)
   if (cfg%Ltauimodis) CALL histwrite2d_cosp(o_tauimodis,modis%Optical_Thickness_Ice_Mean)
-  if (cfg%Ltautlogmodis) CALL histwrite2d_cosp(o_tautlogmodis,modis%Optical_Thickness_Total_LogMean)  
+  if (cfg%Ltautlogmodis) CALL histwrite2d_cosp(o_tautlogmodis,modis%Optical_Thickness_Total_LogMean)
   if (cfg%Ltauwlogmodis) CALL histwrite2d_cosp(o_tauwlogmodis,modis%Optical_Thickness_Water_LogMean)
   if (cfg%Ltauilogmodis) CALL histwrite2d_cosp(o_tauilogmodis,modis%Optical_Thickness_Ice_LogMean)
@@ -369,7 +369,7 @@
        do icl=1,7
          CALL histwrite3d_cosp(o_clmodis, &
-         modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl)           
+         modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl)
        enddo
-      endif 
+      endif
    ENDIF
 
@@ -391,9 +391,9 @@
      endif
      if (cfg%Lcrlmodis) then
-       do icl=1,7 
+       do icl=1,7
          CALL histwrite3d_cosp(o_crlmodis, &
             modis%Optical_Thickness_vs_ReffLiq(:,icl,:),nvertReffLiq,icl)
        enddo
-     endif 
+     endif
    ENDIF
  endif !modis
@@ -445,8 +445,7 @@
     USE lmdz_print_control, ONLY: lunout,prt_level
     USE wxios
+    USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     INTEGER                          :: iff
@@ -480,5 +479,5 @@
         IF ( var%cles(iff) ) THEN
           if (prt_level >= 10) then
-            WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name 
+            WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name
           endif
           CALL wxios_add_field_to_file(var%name, 2, cosp_nidfiles(iff), cosp_outfilenames(iff), &
@@ -506,8 +505,7 @@
     USE lmdz_print_control, ONLY: lunout,prt_level
     USE wxios
+    USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     INTEGER                        :: iff, klevs
@@ -582,5 +580,5 @@
         IF ( var%cles(iff) ) THEN
           if (prt_level >= 10) then
-              WRITE(lunout,*)'Appel wxios_add_field_to_file 3d nom variable nam_axvert = ',nom, nam_axvert 
+              WRITE(lunout,*)'Appel wxios_add_field_to_file 3d nom variable nam_axvert = ',nom, nam_axvert
           endif
           CALL wxios_add_field_to_file(nom, 3, cosp_nidfiles(iff), cosp_outfilenames(iff), &
@@ -610,7 +608,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN) :: var
@@ -643,5 +641,5 @@
     !Et sinon on.... écrit
     IF (SIZE(field)/=klon) &
-  CALL abort_physic('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1) 
+  CALL abort_physic('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1)
 
     CALL Gather_omp(field,buffer_omp)
@@ -655,5 +653,5 @@
                 ALLOCATE(index2d(nbp_lon*jj_nb))
 #ifndef CPP_IOIPSL_NO_OUTPUT
-        CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d) 
+        CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d)
 #endif
             deallocate(index2d)
@@ -670,5 +668,5 @@
             ENDIF
           ENDIF
-      ENDDO 
+      ENDDO
 
     IF (using_xios) THEN
@@ -681,5 +679,5 @@
     ENDIF
 
-!$OMP END MASTER   
+!$OMP END MASTER
   ENDIF ! vars_defined
   IF (prt_level >= 9) WRITE(lunout,*)'End histrwrite2d_cosp ',var%name
@@ -697,7 +695,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN)    :: var
@@ -741,5 +739,5 @@
     !Et sinon on.... écrit
     IF (SIZE(field,1)/=klon) &
-   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)                                  
+   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
     nlev=SIZE(field,2)
 
@@ -755,5 +753,5 @@
            ALLOCATE(index3d(nbp_lon*jj_nb*nlev))
 #ifndef CPP_IOIPSL_NO_OUTPUT
-    CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,nbp_lon*jj_nb*nlev,index3d) 
+    CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,nbp_lon*jj_nb*nlev,index3d)
 #endif
 
@@ -778,5 +776,5 @@
   ENDIF
 
-!$OMP END MASTER   
+!$OMP END MASTER
   ENDIF ! vars_defined
   IF (prt_level >= 9) write(lunout,*)'End histrwrite3d_cosp ',nom
@@ -794,7 +792,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN)    :: var
@@ -814,5 +812,5 @@
     !Et sinon on.... écrit
     IF (SIZE(field,1)/=klon) &
-   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)            
+   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
 
     nlev=SIZE(field,2)
@@ -829,5 +827,5 @@
    ENDIF
 
-!$OMP END MASTER   
+!$OMP END MASTER
   ENDIF ! vars_defined
   IF (prt_level >= 9) write(lunout,*)'End histrwrite4d_cosp ',nom
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/cosp2/cosp_output_write_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/cosp2/cosp_output_write_mod.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/cosp2/cosp_output_write_mod.F90	(revision 5154)
@@ -462,8 +462,7 @@
     USE lmdz_print_control, ONLY: lunout,prt_level
     USE wxios
+    USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     INTEGER                          :: iff
@@ -523,8 +522,7 @@
     USE lmdz_print_control, ONLY: lunout,prt_level
     USE wxios
+    USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     INTEGER                        :: iff, klevs
@@ -627,7 +625,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN) :: var
@@ -714,7 +712,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN)    :: var
@@ -811,7 +809,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN)    :: var
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/cospv2/lmdz_cosp_output_write_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/cospv2/lmdz_cosp_output_write_mod.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/cospv2/lmdz_cosp_output_write_mod.F90	(revision 5154)
@@ -657,9 +657,8 @@
     USE lmdz_grid_phy, ONLY: nbp_lon
     USE lmdz_print_control, ONLY: lunout,prt_level
-  USE wxios
+    USE wxios
+    USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     INTEGER                          :: iff
@@ -711,10 +710,9 @@
     USE lmdz_print_control, ONLY: lunout,prt_level
 
-  USE wxios
+    USE wxios
+    USE lmdz_clesphys
 
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     INTEGER                        :: iff, klevs
@@ -809,7 +807,7 @@
   USE lmdz_xios, only: xios_send_field
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN) :: var
@@ -892,8 +890,7 @@
   USE lmdz_xios, only: xios_send_field
   USE lmdz_abort_physic, ONLY: abort_physic
-
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN)    :: var
@@ -984,8 +981,7 @@
   USE lmdz_xios, only: xios_send_field
   USE lmdz_abort_physic, ONLY: abort_physic
-
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN)    :: var
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad.v1.5.1/readaerosol_optic_ecrad.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad.v1.5.1/readaerosol_optic_ecrad.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad.v1.5.1/readaerosol_optic_ecrad.F90	(revision 5154)
@@ -22,8 +22,7 @@
   USE infotrac_phy, ONLY: tracers, nqtot, nbtr
   USE YOMCST
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-
-  include "clesphys.h"
 
   ! Input arguments
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad/lmdz/readaerosol_optic_ecrad.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad/lmdz/readaerosol_optic_ecrad.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad/lmdz/readaerosol_optic_ecrad.F90	(revision 5154)
@@ -22,8 +22,7 @@
   USE infotrac_phy, ONLY: tracers, nqtot, nbtr
   USE YOMCST
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-
-  include "clesphys.h"
 
   ! Input arguments
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad/lmdz/readaerosolstrato_ecrad.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad/lmdz/readaerosolstrato_ecrad.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/ecrad/lmdz/readaerosolstrato_ecrad.F90	(revision 5154)
@@ -25,8 +25,7 @@
     USE xios
 #endif
+  USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     CHARACTER (len = 80) :: abort_message
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90	(revision 5154)
@@ -12,4 +12,5 @@
   USE YOMCST, ONLY: RG
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   !    Yves Balkanski le 12 avril 2006
@@ -21,7 +22,5 @@
   !
   IMPLICIT NONE
-  ! 
-  INCLUDE "clesphys.h"
-  !
+  !!
   ! Input arguments:
   !
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/aeropt_lw_rrtm.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/aeropt_lw_rrtm.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/aeropt_lw_rrtm.F90	(revision 5154)
@@ -16,8 +16,8 @@
   USE YOMCST, ONLY: RG
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
 
-  INCLUDE "clesphys.h"
   !
   ! Input arguments:
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/lwu.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/lwu.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/lwu.F90	(revision 5154)
@@ -3,321 +3,320 @@
 !
 SUBROUTINE LWU &
- & ( KIDIA, KFDIA, KLON, KLEV,&
- & PAER , PCCO2, PDP , PPMB, PQOF , PTAVE, PVIEW, PWV,&
- & PABCU &
- & )  
-
-!**** *LWU* - LONGWAVE EFFECTIVE ABSORBER AMOUNTS
-
-!     PURPOSE.
-!     --------
-!           COMPUTES ABSORBER AMOUNTS INCLUDING PRESSURE AND
-!           TEMPERATURE EFFECTS
-
-!**   INTERFACE.
-!     ----------
-
-!        EXPLICIT ARGUMENTS :
-!        --------------------
-!     ==== INPUTS ===
-! PAER   : (KLON,6,KLEV)     ; OPTICAL THICKNESS OF THE AEROSOLS
-! PCCO2  :                   ; CONCENTRATION IN CO2 (PA/PA)
-! PDP    : (KLON,KLEV)       ; LAYER PRESSURE THICKNESS (PA)
-! PPMB   : (KLON,KLEV+1)     ; HALF LEVEL PRESSURE
-! PQOF   : (KLON,KLEV)       ; CONCENTRATION IN OZONE (PA/PA)
-! PTAVE  : (KLON,KLEV)       ; TEMPERATURE
-! PWV    : (KLON,KLEV)       ; SPECIFIC HUMIDITY PA/PA
-! PVIEW  : (KLON)            ; COSECANT OF VIEWING ANGLE
-!     ==== OUTPUTS ===
-! PABCU  :(KLON,NUA,3*KLEV+1); EFFECTIVE ABSORBER AMOUNTS
-
-!        IMPLICIT ARGUMENTS :   NONE
-!        --------------------
-
-!     METHOD.
-!     -------
-
-!          1. COMPUTES THE PRESSURE AND TEMPERATURE WEIGHTED AMOUNTS OF
-!     ABSORBERS.
-
-!     EXTERNALS.
-!     ----------
-
-!          NONE
-
-!     REFERENCE.
-!     ----------
-
-!        SEE RADIATION'S PART OF THE MODEL'S DOCUMENTATION AND
-!        ECMWF RESEARCH DEPARTMENT DOCUMENTATION OF THE IFS
-
-!     AUTHOR.
-!     -------
-!        JEAN-JACQUES MORCRETTE  *ECMWF*
-
-!     MODIFICATIONS.
-!     --------------
-!        ORIGINAL : 89-07-14
-!        JJ Morcrette 97-04-18 Revised Continuum + Clean-up
-!        M.Hamrud      01-Oct-2003 CY28 Cleaning
-
-!-----------------------------------------------------------------------
-
-USE PARKIND1  ,ONLY : JPIM     ,JPRB
-USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
-
-USE YOMCST   , ONLY : RG
-USE YOESW    , ONLY : RAER
-USE YOELW    , ONLY : NSIL     ,NUA      ,NG1      ,NG1P1    ,&
- & ALWT     ,BLWT     ,RO3T     ,RT1      ,TREF     ,&
- & RVGCO2   ,RVGH2O   ,RVGO3  
-!USE YOERDI   , ONLY : RCH4     ,RN2O     ,RCFC11   ,RCFC12
-USE YOERDU   , ONLY : R10E     ,REPSCO   ,REPSCQ
+        & (KIDIA, KFDIA, KLON, KLEV, &
+        & PAER, PCCO2, PDP, PPMB, PQOF, PTAVE, PVIEW, PWV, &
+        & PABCU &
+        &)
+
+  !**** *LWU* - LONGWAVE EFFECTIVE ABSORBER AMOUNTS
+
+  !     PURPOSE.
+  !     --------
+  !           COMPUTES ABSORBER AMOUNTS INCLUDING PRESSURE AND
+  !           TEMPERATURE EFFECTS
+
+  !**   INTERFACE.
+  !     ----------
+
+  !        EXPLICIT ARGUMENTS :
+  !        --------------------
+  !     ==== INPUTS ===
+  ! PAER   : (KLON,6,KLEV)     ; OPTICAL THICKNESS OF THE AEROSOLS
+  ! PCCO2  :                   ; CONCENTRATION IN CO2 (PA/PA)
+  ! PDP    : (KLON,KLEV)       ; LAYER PRESSURE THICKNESS (PA)
+  ! PPMB   : (KLON,KLEV+1)     ; HALF LEVEL PRESSURE
+  ! PQOF   : (KLON,KLEV)       ; CONCENTRATION IN OZONE (PA/PA)
+  ! PTAVE  : (KLON,KLEV)       ; TEMPERATURE
+  ! PWV    : (KLON,KLEV)       ; SPECIFIC HUMIDITY PA/PA
+  ! PVIEW  : (KLON)            ; COSECANT OF VIEWING ANGLE
+  !     ==== OUTPUTS ===
+  ! PABCU  :(KLON,NUA,3*KLEV+1); EFFECTIVE ABSORBER AMOUNTS
+
+  !        IMPLICIT ARGUMENTS :   NONE
+  !        --------------------
+
+  !     METHOD.
+  !     -------
+
+  !          1. COMPUTES THE PRESSURE AND TEMPERATURE WEIGHTED AMOUNTS OF
+  !     ABSORBERS.
+
+  !     EXTERNALS.
+  !     ----------
+
+  !          NONE
+
+  !     REFERENCE.
+  !     ----------
+
+  !        SEE RADIATION'S PART OF THE MODEL'S DOCUMENTATION AND
+  !        ECMWF RESEARCH DEPARTMENT DOCUMENTATION OF THE IFS
+
+  !     AUTHOR.
+  !     -------
+  !        JEAN-JACQUES MORCRETTE  *ECMWF*
+
+  !     MODIFICATIONS.
+  !     --------------
+  !        ORIGINAL : 89-07-14
+  !        JJ Morcrette 97-04-18 Revised Continuum + Clean-up
+  !        M.Hamrud      01-Oct-2003 CY28 Cleaning
+
+  !-----------------------------------------------------------------------
+
+  USE PARKIND1, ONLY: JPIM, JPRB
+  USE YOMHOOK, ONLY: LHOOK, DR_HOOK
+
+  USE YOMCST, ONLY: RG
+  USE YOESW, ONLY: RAER
+  USE YOELW, ONLY: NSIL, NUA, NG1, NG1P1, &
+          & ALWT, BLWT, RO3T, RT1, TREF, &
+          & RVGCO2, RVGH2O, RVGO3
+  !USE YOERDI   , ONLY : RCH4     ,RN2O     ,RCFC11   ,RCFC12
+  USE YOERDU, ONLY: R10E, REPSCO, REPSCQ
 #ifdef REPROBUS
 USE chem_rep, ONLY: rch42d, rn2o2d, rcfc112d, rcfc122d, ok_rtime2d
 USE infotrac_phy, ONLY : type_trac
 #endif
-
-
-IMPLICIT NONE
-
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAER(KLON,6,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PCCO2 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PDP(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PPMB(KLON,KLEV+1) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PQOF(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAVE(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PVIEW(KLON) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PWV(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: PABCU(KLON,NUA,3*KLEV+1) 
-
-#include "clesphys.h"
-!-----------------------------------------------------------------------
-
-!*       0.1   ARGUMENTS
-!              ---------
-
-!-----------------------------------------------------------------------
-
-!              ------------
-REAL(KIND=JPRB) :: ZABLY(KLON,7,3*KLEV+1)  , ZDPM(KLON,3*KLEV)&
- & ,  ZDUC(KLON, 3*KLEV+1)    , ZFACT(KLON)&
- & ,  ZUPM(KLON,3*KLEV)  
-REAL(KIND=JPRB) :: ZPHIO(KLON),ZPSC2(KLON) , ZPSC3(KLON), ZPSH1(KLON)&
- & ,  ZPSH2(KLON),ZPSH3(KLON) , ZPSH4(KLON), ZPSH5(KLON)&
- & ,  ZPSH6(KLON),ZPSIO(KLON) , ZTCON(KLON)&
- & ,  ZPHM6(KLON),ZPSM6(KLON) , ZPHN6(KLON), ZPSN6(KLON)  
-REAL(KIND=JPRB) :: ZSSIG(KLON,3*KLEV+1)    , ZTAVI(KLON)&
- & ,  ZUAER(KLON,NSIL)        , ZXOZ(KLON) , ZXWV(KLON)  
-
-INTEGER(KIND=JPIM) :: IAE1, IAE2, IAE3, IC, ICP1, IG1, IJ, IJPN,&
- & IKIP1, IKJ, IKJP, IKJPN, IKJR, IKL, JA, JAE, &
- & JK, JKI, JKK, JL  
-
-REAL(KIND=JPRB) :: ZALUP, ZCAC8, ZCAH1, ZCAH2, ZCAH3, ZCAH4,&
- & ZCAH5, ZCAH6, ZCBC8, ZCBH1, ZCBH2, ZCBH3, &
- & ZCBH4, ZCBH5, ZCBH6, ZDIFF, ZDPMG, ZDPMP0, &
- & ZFPPW, ZTX, ZTX2, ZU6, ZUP, ZUPMCO2, ZUPMG, &
- & ZUPMH2O, ZUPMO3, ZZABLY  
-REAL(KIND=JPRB) :: ZHOOK_HANDLE
-
-
-!-----------------------------------------------------------------------
-
-!*         1.    INITIALIZATION
-!                --------------
-
-!-----------------------------------------------------------------------
-
-!*         2.    PRESSURE OVER GAUSS SUB-LEVELS
-!                ------------------------------
-
-IF (LHOOK) CALL DR_HOOK('LWU',0,ZHOOK_HANDLE)
-DO JL = KIDIA,KFDIA
-  ZSSIG(JL, 1 ) = PPMB(JL,1) * 100._JPRB
-ENDDO
-
-DO JK = 1 , KLEV
-  IKJ=(JK-1)*NG1P1+1
-  IKJR = IKJ
-  IKJP = IKJ + NG1P1
-  DO JL = KIDIA,KFDIA
-    ZSSIG(JL,IKJP)=PPMB(JL,JK+1)* 100._JPRB
-  ENDDO
-  DO IG1=1,NG1
-    IKJ=IKJ+1
-    DO JL = KIDIA,KFDIA
-      ZSSIG(JL,IKJ)= (ZSSIG(JL,IKJR) + ZSSIG(JL,IKJP)) * 0.5_JPRB &
-       & + RT1(IG1) * (ZSSIG(JL,IKJP) - ZSSIG(JL,IKJR)) * 0.5_JPRB  
-    ENDDO
-  ENDDO
-ENDDO
-
-!-----------------------------------------------------------------------
-
-!*         4.    PRESSURE THICKNESS AND MEAN PRESSURE OF SUB-LAYERS
-!                --------------------------------------------------
-
-DO JKI=1,3*KLEV
-  IKIP1=JKI+1
-  DO JL = KIDIA,KFDIA
-    ZUPM(JL,JKI)=(ZSSIG(JL,JKI)+ZSSIG(JL,IKIP1))*0.5_JPRB
-    ZDPM(JL,JKI)=(ZSSIG(JL,JKI)-ZSSIG(JL,IKIP1))/(10._JPRB*RG)
-  ENDDO
-ENDDO
-
-DO JK = 1 , KLEV
-  IKL = KLEV+1 - JK
-  DO JL = KIDIA,KFDIA
-    ZXWV(JL) = MAX (PWV(JL,IKL) , REPSCQ )
-    ZXOZ(JL) = MAX (PQOF(JL,IKL) / PDP(JL,IKL) , REPSCO )
-  ENDDO
-  IKJ=(JK-1)*NG1P1+1
-  IKJPN=IKJ+NG1
-  DO JKK=IKJ,IKJPN
-    DO JL = KIDIA,KFDIA
-      ZDPMG = ZDPM(JL,JKK)
-      ZDPMP0 = ZDPMG / 101325._JPRB
-      ZUPMG = ZUPM(JL,JKK) * ZDPMP0
-      ZUPMCO2 = ( ZUPM(JL,JKK) + RVGCO2 ) * ZDPMP0
-      ZUPMH2O = ( ZUPM(JL,JKK) + RVGH2O ) * ZDPMP0
-      ZUPMO3  = ( ZUPM(JL,JKK) + RVGO3  ) * ZDPMP0
-      ZDUC(JL,JKK) = ZDPMG
-      ZABLY(JL,6,JKK) = ZXOZ(JL) * ZDPMG
-      ZABLY(JL,7,JKK) = ZXOZ(JL) * ZUPMO3
-      ZU6 = ZXWV(JL) * ZUPMG
-      ZFPPW = 1.6078_JPRB * ZXWV(JL) / (1.0_JPRB+0.608_JPRB*ZXWV(JL))
-      ZABLY(JL,1,JKK)  = ZXWV(JL) * ZUPMH2O
-      ZABLY(JL,5,JKK) = ZU6 * ZFPPW
-      ZABLY(JL,4,JKK) = ZU6 * (1.0_JPRB-ZFPPW)
-      ZABLY(JL,3,JKK)  = PCCO2 * ZUPMCO2
-      ZABLY(JL,2,JKK)  = PCCO2 * ZDPMG
-    ENDDO
-  ENDDO
-ENDDO
-
-!-----------------------------------------------------------------------
-
-!*         5.    CUMULATIVE ABSORBER AMOUNTS FROM TOP OF ATMOSPHERE
-!                --------------------------------------------------
-
-DO JA = 1, NUA
-  DO JL = KIDIA,KFDIA
-    PABCU(JL,JA,3*KLEV+1) = 0.0_JPRB
-  ENDDO
-ENDDO
-
-DO JK = 1 , KLEV
-  IJ=(JK-1)*NG1P1+1
-  IJPN=IJ+NG1
-  IKL=KLEV+1-JK
-
-!*         5.1  CUMULATIVE AEROSOL AMOUNTS FROM TOP OF ATMOSPHERE
-!               --------------------------------------------------
-! --            NB: 'PAER' AEROSOLS ARE ENTERED FROM TOP TO BOTTOM
-
-  IAE1=3*KLEV+1-IJ
-  IAE2=3*KLEV+1-(IJ+1)
-  IAE3=3*KLEV+1-IJPN
-! print *,'IAE1= ',IAE1
-! print *,'IAE2= ',IAE2
-! print *,'IAE3= ',IAE3
-! print *,'KIDIA= ',KIDIA
-! print *,'KFDIA= ',KFDIA
-! print *,'KLEV= ',KLEV
-  DO JAE=1,6
-    DO JL = KIDIA,KFDIA
-!   print *,'JL= ',JL,'-JAE= ',JAE,'-JK= ',JK,'-NSIL= ',NSIL
-      ZUAER(JL,JAE) =&
-       & (RAER(JAE,1)*PAER(JL,1,JK)+RAER(JAE,2)*PAER(JL,2,JK)&
-       & +RAER(JAE,3)*PAER(JL,3,JK)+RAER(JAE,4)*PAER(JL,4,JK)&
-       & +RAER(JAE,5)*PAER(JL,5,JK)+RAER(JAE,6)*PAER(JL,6,JK))&
-       & /(ZDUC(JL,IAE1)+ZDUC(JL,IAE2)+ZDUC(JL,IAE3))  
-    ENDDO
-  ENDDO
-
-!*         5.2  INTRODUCES TEMPERATURE EFFECTS ON ABSORBER AMOUNTS
-!               --------------------------------------------------
-
-  DO JL = KIDIA,KFDIA
-    ZTAVI(JL)=PTAVE(JL,IKL)
-    ZFACT(JL)=1.0_JPRB-ZTAVI(JL)/296._JPRB
-    ZTCON(JL)=EXP(6.08_JPRB*(296._JPRB/ZTAVI(JL)-1.0_JPRB))
-!     ZTCON(JL)=EXP(6.08*ZFACT(JL))
-    ZTX=ZTAVI(JL)-TREF
-    ZTX2=ZTX*ZTX
-    ZZABLY = ZABLY(JL,1,IAE1)+ZABLY(JL,1,IAE2)+ZABLY(JL,1,IAE3)
-    ZUP=MIN( MAX( 0.5_JPRB*R10E*LOG( ZZABLY ) + 5._JPRB, 0.0_JPRB), 6.0_JPRB)
-    ZCAH1=ALWT(1,1)+ZUP*(ALWT(1,2)+ZUP*(ALWT(1,3)))
-    ZCBH1=BLWT(1,1)+ZUP*(BLWT(1,2)+ZUP*(BLWT(1,3)))
-    ZPSH1(JL)=EXP( ZCAH1 * ZTX + ZCBH1 * ZTX2 )
-    ZCAH2=ALWT(2,1)+ZUP*(ALWT(2,2)+ZUP*(ALWT(2,3)))
-    ZCBH2=BLWT(2,1)+ZUP*(BLWT(2,2)+ZUP*(BLWT(2,3)))
-    ZPSH2(JL)=EXP( ZCAH2 * ZTX + ZCBH2 * ZTX2 )
-    ZCAH3=ALWT(3,1)+ZUP*(ALWT(3,2)+ZUP*(ALWT(3,3)))
-    ZCBH3=BLWT(3,1)+ZUP*(BLWT(3,2)+ZUP*(BLWT(3,3)))
-    ZPSH3(JL)=EXP( ZCAH3 * ZTX + ZCBH3 * ZTX2 )
-    ZCAH4=ALWT(4,1)+ZUP*(ALWT(4,2)+ZUP*(ALWT(4,3)))
-    ZCBH4=BLWT(4,1)+ZUP*(BLWT(4,2)+ZUP*(BLWT(4,3)))
-    ZPSH4(JL)=EXP( ZCAH4 * ZTX + ZCBH4 * ZTX2 )
-    ZCAH5=ALWT(5,1)+ZUP*(ALWT(5,2)+ZUP*(ALWT(5,3)))
-    ZCBH5=BLWT(5,1)+ZUP*(BLWT(5,2)+ZUP*(BLWT(5,3)))
-    ZPSH5(JL)=EXP( ZCAH5 * ZTX + ZCBH5 * ZTX2 )
-    ZCAH6=ALWT(6,1)+ZUP*(ALWT(6,2)+ZUP*(ALWT(6,3)))
-    ZCBH6=BLWT(6,1)+ZUP*(BLWT(6,2)+ZUP*(BLWT(6,3)))
-    ZPSH6(JL)=EXP( ZCAH6 * ZTX + ZCBH6 * ZTX2 )
-    ZPHM6(JL)=EXP(-5.81E-4_JPRB * ZTX - 1.13E-6_JPRB * ZTX2 )
-    ZPSM6(JL)=EXP(-5.57E-4_JPRB * ZTX - 3.30E-6_JPRB * ZTX2 )
-    ZPHN6(JL)=EXP(-3.46E-5_JPRB * ZTX + 2.05E-7_JPRB * ZTX2 )
-    ZPSN6(JL)=EXP( 3.70E-3_JPRB * ZTX - 2.30E-6_JPRB * ZTX2 )
-  ENDDO
-
-  DO JL = KIDIA,KFDIA
-    ZTAVI(JL)=PTAVE(JL,IKL)
-    ZTX=ZTAVI(JL)-TREF
-    ZTX2=ZTX*ZTX
-    ZZABLY = ZABLY(JL,3,IAE1)+ZABLY(JL,3,IAE2)+ZABLY(JL,3,IAE3)
-    ZALUP = R10E * LOG ( ZZABLY )
-    ZUP   = MAX( 0.0_JPRB , 5.0_JPRB + 0.5_JPRB * ZALUP )
-    ZPSC2(JL) = (ZTAVI(JL)/TREF) ** ZUP
-    ZCAC8=ALWT(8,1)+ZUP*(ALWT(8,2)+ZUP*(ALWT(8,3)))
-    ZCBC8=BLWT(8,1)+ZUP*(BLWT(8,2)+ZUP*(BLWT(8,3)))
-    ZPSC3(JL)=EXP( ZCAC8 * ZTX + ZCBC8 * ZTX2 )
-    ZPHIO(JL) = EXP( RO3T(1) * ZTX + RO3T(2) * ZTX2)
-    ZPSIO(JL) = EXP( 2.0_JPRB* (RO3T(3)*ZTX+RO3T(4)*ZTX2))
-  ENDDO
-
-  DO JKK=IJ,IJPN
-    IC=3*KLEV+1-JKK
-    ICP1=IC+1
-    DO JL = KIDIA,KFDIA
-      ZDIFF = PVIEW(JL)
-!- H2O continuum      
-      PABCU(JL,10,IC)=PABCU(JL,10,ICP1)+ ZABLY(JL,4,IC)          *ZDIFF
-      PABCU(JL,11,IC)=PABCU(JL,11,ICP1)+ ZABLY(JL,5,IC)*ZTCON(JL)*ZDIFF
-!- O3      
-      PABCU(JL,12,IC)=PABCU(JL,12,ICP1)+ ZABLY(JL,6,IC)*ZPHIO(JL)*ZDIFF
-      PABCU(JL,13,IC)=PABCU(JL,13,ICP1)+ ZABLY(JL,7,IC)*ZPSIO(JL)*ZDIFF
-!- CO2
-      PABCU(JL,7,IC)=PABCU(JL,7,ICP1)+ ZABLY(JL,3,IC)*ZPSC2(JL)*ZDIFF
-      PABCU(JL,8,IC)=PABCU(JL,8,ICP1)+ ZABLY(JL,3,IC)*ZPSC3(JL)*ZDIFF
-      PABCU(JL,9,IC)=PABCU(JL,9,ICP1)+ ZABLY(JL,3,IC)*ZPSC3(JL)*ZDIFF
-!- H2O
-      PABCU(JL,1,IC)=PABCU(JL,1,ICP1)+ ZABLY(JL,1,IC)*ZPSH1(JL)
-      PABCU(JL,2,IC)=PABCU(JL,2,ICP1)+ ZABLY(JL,1,IC)*ZPSH2(JL)
-      PABCU(JL,3,IC)=PABCU(JL,3,ICP1)+ ZABLY(JL,1,IC)*ZPSH5(JL)*ZDIFF
-      PABCU(JL,4,IC)=PABCU(JL,4,ICP1)+ ZABLY(JL,1,IC)*ZPSH3(JL)
-      PABCU(JL,5,IC)=PABCU(JL,5,ICP1)+ ZABLY(JL,1,IC)*ZPSH4(JL)
-      PABCU(JL,6,IC)=PABCU(JL,6,ICP1)+ ZABLY(JL,1,IC)*ZPSH6(JL)*ZDIFF
-!- aerosols
-      PABCU(JL,14,IC)=PABCU(JL,14,ICP1)+ ZUAER(JL,1)    *ZDUC(JL,IC)*ZDIFF
-      PABCU(JL,15,IC)=PABCU(JL,15,ICP1)+ ZUAER(JL,2)    *ZDUC(JL,IC)*ZDIFF
-      PABCU(JL,16,IC)=PABCU(JL,16,ICP1)+ ZUAER(JL,3)    *ZDUC(JL,IC)*ZDIFF
-      PABCU(JL,17,IC)=PABCU(JL,17,ICP1)+ ZUAER(JL,4)    *ZDUC(JL,IC)*ZDIFF
-      PABCU(JL,18,IC)=PABCU(JL,18,ICP1)+ ZUAER(JL,5)    *ZDUC(JL,IC)*ZDIFF
+  USE lmdz_clesphys
+
+  IMPLICIT NONE
+
+  INTEGER(KIND = JPIM), INTENT(IN) :: KLON
+  INTEGER(KIND = JPIM), INTENT(IN) :: KLEV
+  INTEGER(KIND = JPIM), INTENT(IN) :: KIDIA
+  INTEGER(KIND = JPIM), INTENT(IN) :: KFDIA
+  REAL(KIND = JPRB), INTENT(IN) :: PAER(KLON, 6, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PCCO2
+  REAL(KIND = JPRB), INTENT(IN) :: PDP(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PPMB(KLON, KLEV + 1)
+  REAL(KIND = JPRB), INTENT(IN) :: PQOF(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PTAVE(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PVIEW(KLON)
+  REAL(KIND = JPRB), INTENT(IN) :: PWV(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(OUT) :: PABCU(KLON, NUA, 3 * KLEV + 1)
+
+  !-----------------------------------------------------------------------
+
+  !*       0.1   ARGUMENTS
+  !              ---------
+
+  !-----------------------------------------------------------------------
+
+  !              ------------
+  REAL(KIND = JPRB) :: ZABLY(KLON, 7, 3 * KLEV + 1), ZDPM(KLON, 3 * KLEV)&
+          &, ZDUC(KLON, 3 * KLEV + 1), ZFACT(KLON)&
+          &, ZUPM(KLON, 3 * KLEV)
+  REAL(KIND = JPRB) :: ZPHIO(KLON), ZPSC2(KLON), ZPSC3(KLON), ZPSH1(KLON)&
+          &, ZPSH2(KLON), ZPSH3(KLON), ZPSH4(KLON), ZPSH5(KLON)&
+          &, ZPSH6(KLON), ZPSIO(KLON), ZTCON(KLON)&
+          &, ZPHM6(KLON), ZPSM6(KLON), ZPHN6(KLON), ZPSN6(KLON)
+  REAL(KIND = JPRB) :: ZSSIG(KLON, 3 * KLEV + 1), ZTAVI(KLON)&
+          &, ZUAER(KLON, NSIL), ZXOZ(KLON), ZXWV(KLON)
+
+  INTEGER(KIND = JPIM) :: IAE1, IAE2, IAE3, IC, ICP1, IG1, IJ, IJPN, &
+          & IKIP1, IKJ, IKJP, IKJPN, IKJR, IKL, JA, JAE, &
+          & JK, JKI, JKK, JL
+
+  REAL(KIND = JPRB) :: ZALUP, ZCAC8, ZCAH1, ZCAH2, ZCAH3, ZCAH4, &
+          & ZCAH5, ZCAH6, ZCBC8, ZCBH1, ZCBH2, ZCBH3, &
+          & ZCBH4, ZCBH5, ZCBH6, ZDIFF, ZDPMG, ZDPMP0, &
+          & ZFPPW, ZTX, ZTX2, ZU6, ZUP, ZUPMCO2, ZUPMG, &
+          & ZUPMH2O, ZUPMO3, ZZABLY
+  REAL(KIND = JPRB) :: ZHOOK_HANDLE
+
+
+  !-----------------------------------------------------------------------
+
+  !*         1.    INITIALIZATION
+  !                --------------
+
+  !-----------------------------------------------------------------------
+
+  !*         2.    PRESSURE OVER GAUSS SUB-LEVELS
+  !                ------------------------------
+
+  IF (LHOOK) CALL DR_HOOK('LWU', 0, ZHOOK_HANDLE)
+  DO JL = KIDIA, KFDIA
+    ZSSIG(JL, 1) = PPMB(JL, 1) * 100._JPRB
+  ENDDO
+
+  DO JK = 1, KLEV
+    IKJ = (JK - 1) * NG1P1 + 1
+    IKJR = IKJ
+    IKJP = IKJ + NG1P1
+    DO JL = KIDIA, KFDIA
+      ZSSIG(JL, IKJP) = PPMB(JL, JK + 1) * 100._JPRB
+    ENDDO
+    DO IG1 = 1, NG1
+      IKJ = IKJ + 1
+      DO JL = KIDIA, KFDIA
+        ZSSIG(JL, IKJ) = (ZSSIG(JL, IKJR) + ZSSIG(JL, IKJP)) * 0.5_JPRB &
+                & + RT1(IG1) * (ZSSIG(JL, IKJP) - ZSSIG(JL, IKJR)) * 0.5_JPRB
+      ENDDO
+    ENDDO
+  ENDDO
+
+  !-----------------------------------------------------------------------
+
+  !*         4.    PRESSURE THICKNESS AND MEAN PRESSURE OF SUB-LAYERS
+  !                --------------------------------------------------
+
+  DO JKI = 1, 3 * KLEV
+    IKIP1 = JKI + 1
+    DO JL = KIDIA, KFDIA
+      ZUPM(JL, JKI) = (ZSSIG(JL, JKI) + ZSSIG(JL, IKIP1)) * 0.5_JPRB
+      ZDPM(JL, JKI) = (ZSSIG(JL, JKI) - ZSSIG(JL, IKIP1)) / (10._JPRB * RG)
+    ENDDO
+  ENDDO
+
+  DO JK = 1, KLEV
+    IKL = KLEV + 1 - JK
+    DO JL = KIDIA, KFDIA
+      ZXWV(JL) = MAX (PWV(JL, IKL), REPSCQ)
+      ZXOZ(JL) = MAX (PQOF(JL, IKL) / PDP(JL, IKL), REPSCO)
+    ENDDO
+    IKJ = (JK - 1) * NG1P1 + 1
+    IKJPN = IKJ + NG1
+    DO JKK = IKJ, IKJPN
+      DO JL = KIDIA, KFDIA
+        ZDPMG = ZDPM(JL, JKK)
+        ZDPMP0 = ZDPMG / 101325._JPRB
+        ZUPMG = ZUPM(JL, JKK) * ZDPMP0
+        ZUPMCO2 = (ZUPM(JL, JKK) + RVGCO2) * ZDPMP0
+        ZUPMH2O = (ZUPM(JL, JKK) + RVGH2O) * ZDPMP0
+        ZUPMO3 = (ZUPM(JL, JKK) + RVGO3) * ZDPMP0
+        ZDUC(JL, JKK) = ZDPMG
+        ZABLY(JL, 6, JKK) = ZXOZ(JL) * ZDPMG
+        ZABLY(JL, 7, JKK) = ZXOZ(JL) * ZUPMO3
+        ZU6 = ZXWV(JL) * ZUPMG
+        ZFPPW = 1.6078_JPRB * ZXWV(JL) / (1.0_JPRB + 0.608_JPRB * ZXWV(JL))
+        ZABLY(JL, 1, JKK) = ZXWV(JL) * ZUPMH2O
+        ZABLY(JL, 5, JKK) = ZU6 * ZFPPW
+        ZABLY(JL, 4, JKK) = ZU6 * (1.0_JPRB - ZFPPW)
+        ZABLY(JL, 3, JKK) = PCCO2 * ZUPMCO2
+        ZABLY(JL, 2, JKK) = PCCO2 * ZDPMG
+      ENDDO
+    ENDDO
+  ENDDO
+
+  !-----------------------------------------------------------------------
+
+  !*         5.    CUMULATIVE ABSORBER AMOUNTS FROM TOP OF ATMOSPHERE
+  !                --------------------------------------------------
+
+  DO JA = 1, NUA
+    DO JL = KIDIA, KFDIA
+      PABCU(JL, JA, 3 * KLEV + 1) = 0.0_JPRB
+    ENDDO
+  ENDDO
+
+  DO JK = 1, KLEV
+    IJ = (JK - 1) * NG1P1 + 1
+    IJPN = IJ + NG1
+    IKL = KLEV + 1 - JK
+
+    !*         5.1  CUMULATIVE AEROSOL AMOUNTS FROM TOP OF ATMOSPHERE
+    !               --------------------------------------------------
+    ! --            NB: 'PAER' AEROSOLS ARE ENTERED FROM TOP TO BOTTOM
+
+    IAE1 = 3 * KLEV + 1 - IJ
+    IAE2 = 3 * KLEV + 1 - (IJ + 1)
+    IAE3 = 3 * KLEV + 1 - IJPN
+    ! print *,'IAE1= ',IAE1
+    ! print *,'IAE2= ',IAE2
+    ! print *,'IAE3= ',IAE3
+    ! print *,'KIDIA= ',KIDIA
+    ! print *,'KFDIA= ',KFDIA
+    ! print *,'KLEV= ',KLEV
+    DO JAE = 1, 6
+      DO JL = KIDIA, KFDIA
+        !   print *,'JL= ',JL,'-JAE= ',JAE,'-JK= ',JK,'-NSIL= ',NSIL
+        ZUAER(JL, JAE) = &
+                & (RAER(JAE, 1) * PAER(JL, 1, JK) + RAER(JAE, 2) * PAER(JL, 2, JK)&
+                & + RAER(JAE, 3) * PAER(JL, 3, JK) + RAER(JAE, 4) * PAER(JL, 4, JK)&
+                & + RAER(JAE, 5) * PAER(JL, 5, JK) + RAER(JAE, 6) * PAER(JL, 6, JK))&
+                & / (ZDUC(JL, IAE1) + ZDUC(JL, IAE2) + ZDUC(JL, IAE3))
+      ENDDO
+    ENDDO
+
+    !*         5.2  INTRODUCES TEMPERATURE EFFECTS ON ABSORBER AMOUNTS
+    !               --------------------------------------------------
+
+    DO JL = KIDIA, KFDIA
+      ZTAVI(JL) = PTAVE(JL, IKL)
+      ZFACT(JL) = 1.0_JPRB - ZTAVI(JL) / 296._JPRB
+      ZTCON(JL) = EXP(6.08_JPRB * (296._JPRB / ZTAVI(JL) - 1.0_JPRB))
+      !     ZTCON(JL)=EXP(6.08*ZFACT(JL))
+      ZTX = ZTAVI(JL) - TREF
+      ZTX2 = ZTX * ZTX
+      ZZABLY = ZABLY(JL, 1, IAE1) + ZABLY(JL, 1, IAE2) + ZABLY(JL, 1, IAE3)
+      ZUP = MIN(MAX(0.5_JPRB * R10E * LOG(ZZABLY) + 5._JPRB, 0.0_JPRB), 6.0_JPRB)
+      ZCAH1 = ALWT(1, 1) + ZUP * (ALWT(1, 2) + ZUP * (ALWT(1, 3)))
+      ZCBH1 = BLWT(1, 1) + ZUP * (BLWT(1, 2) + ZUP * (BLWT(1, 3)))
+      ZPSH1(JL) = EXP(ZCAH1 * ZTX + ZCBH1 * ZTX2)
+      ZCAH2 = ALWT(2, 1) + ZUP * (ALWT(2, 2) + ZUP * (ALWT(2, 3)))
+      ZCBH2 = BLWT(2, 1) + ZUP * (BLWT(2, 2) + ZUP * (BLWT(2, 3)))
+      ZPSH2(JL) = EXP(ZCAH2 * ZTX + ZCBH2 * ZTX2)
+      ZCAH3 = ALWT(3, 1) + ZUP * (ALWT(3, 2) + ZUP * (ALWT(3, 3)))
+      ZCBH3 = BLWT(3, 1) + ZUP * (BLWT(3, 2) + ZUP * (BLWT(3, 3)))
+      ZPSH3(JL) = EXP(ZCAH3 * ZTX + ZCBH3 * ZTX2)
+      ZCAH4 = ALWT(4, 1) + ZUP * (ALWT(4, 2) + ZUP * (ALWT(4, 3)))
+      ZCBH4 = BLWT(4, 1) + ZUP * (BLWT(4, 2) + ZUP * (BLWT(4, 3)))
+      ZPSH4(JL) = EXP(ZCAH4 * ZTX + ZCBH4 * ZTX2)
+      ZCAH5 = ALWT(5, 1) + ZUP * (ALWT(5, 2) + ZUP * (ALWT(5, 3)))
+      ZCBH5 = BLWT(5, 1) + ZUP * (BLWT(5, 2) + ZUP * (BLWT(5, 3)))
+      ZPSH5(JL) = EXP(ZCAH5 * ZTX + ZCBH5 * ZTX2)
+      ZCAH6 = ALWT(6, 1) + ZUP * (ALWT(6, 2) + ZUP * (ALWT(6, 3)))
+      ZCBH6 = BLWT(6, 1) + ZUP * (BLWT(6, 2) + ZUP * (BLWT(6, 3)))
+      ZPSH6(JL) = EXP(ZCAH6 * ZTX + ZCBH6 * ZTX2)
+      ZPHM6(JL) = EXP(-5.81E-4_JPRB * ZTX - 1.13E-6_JPRB * ZTX2)
+      ZPSM6(JL) = EXP(-5.57E-4_JPRB * ZTX - 3.30E-6_JPRB * ZTX2)
+      ZPHN6(JL) = EXP(-3.46E-5_JPRB * ZTX + 2.05E-7_JPRB * ZTX2)
+      ZPSN6(JL) = EXP(3.70E-3_JPRB * ZTX - 2.30E-6_JPRB * ZTX2)
+    ENDDO
+
+    DO JL = KIDIA, KFDIA
+      ZTAVI(JL) = PTAVE(JL, IKL)
+      ZTX = ZTAVI(JL) - TREF
+      ZTX2 = ZTX * ZTX
+      ZZABLY = ZABLY(JL, 3, IAE1) + ZABLY(JL, 3, IAE2) + ZABLY(JL, 3, IAE3)
+      ZALUP = R10E * LOG (ZZABLY)
+      ZUP = MAX(0.0_JPRB, 5.0_JPRB + 0.5_JPRB * ZALUP)
+      ZPSC2(JL) = (ZTAVI(JL) / TREF) ** ZUP
+      ZCAC8 = ALWT(8, 1) + ZUP * (ALWT(8, 2) + ZUP * (ALWT(8, 3)))
+      ZCBC8 = BLWT(8, 1) + ZUP * (BLWT(8, 2) + ZUP * (BLWT(8, 3)))
+      ZPSC3(JL) = EXP(ZCAC8 * ZTX + ZCBC8 * ZTX2)
+      ZPHIO(JL) = EXP(RO3T(1) * ZTX + RO3T(2) * ZTX2)
+      ZPSIO(JL) = EXP(2.0_JPRB * (RO3T(3) * ZTX + RO3T(4) * ZTX2))
+    ENDDO
+
+    DO JKK = IJ, IJPN
+      IC = 3 * KLEV + 1 - JKK
+      ICP1 = IC + 1
+      DO JL = KIDIA, KFDIA
+        ZDIFF = PVIEW(JL)
+        !- H2O continuum
+        PABCU(JL, 10, IC) = PABCU(JL, 10, ICP1) + ZABLY(JL, 4, IC) * ZDIFF
+        PABCU(JL, 11, IC) = PABCU(JL, 11, ICP1) + ZABLY(JL, 5, IC) * ZTCON(JL) * ZDIFF
+        !- O3
+        PABCU(JL, 12, IC) = PABCU(JL, 12, ICP1) + ZABLY(JL, 6, IC) * ZPHIO(JL) * ZDIFF
+        PABCU(JL, 13, IC) = PABCU(JL, 13, ICP1) + ZABLY(JL, 7, IC) * ZPSIO(JL) * ZDIFF
+        !- CO2
+        PABCU(JL, 7, IC) = PABCU(JL, 7, ICP1) + ZABLY(JL, 3, IC) * ZPSC2(JL) * ZDIFF
+        PABCU(JL, 8, IC) = PABCU(JL, 8, ICP1) + ZABLY(JL, 3, IC) * ZPSC3(JL) * ZDIFF
+        PABCU(JL, 9, IC) = PABCU(JL, 9, ICP1) + ZABLY(JL, 3, IC) * ZPSC3(JL) * ZDIFF
+        !- H2O
+        PABCU(JL, 1, IC) = PABCU(JL, 1, ICP1) + ZABLY(JL, 1, IC) * ZPSH1(JL)
+        PABCU(JL, 2, IC) = PABCU(JL, 2, ICP1) + ZABLY(JL, 1, IC) * ZPSH2(JL)
+        PABCU(JL, 3, IC) = PABCU(JL, 3, ICP1) + ZABLY(JL, 1, IC) * ZPSH5(JL) * ZDIFF
+        PABCU(JL, 4, IC) = PABCU(JL, 4, ICP1) + ZABLY(JL, 1, IC) * ZPSH3(JL)
+        PABCU(JL, 5, IC) = PABCU(JL, 5, ICP1) + ZABLY(JL, 1, IC) * ZPSH4(JL)
+        PABCU(JL, 6, IC) = PABCU(JL, 6, ICP1) + ZABLY(JL, 1, IC) * ZPSH6(JL) * ZDIFF
+        !- aerosols
+        PABCU(JL, 14, IC) = PABCU(JL, 14, ICP1) + ZUAER(JL, 1) * ZDUC(JL, IC) * ZDIFF
+        PABCU(JL, 15, IC) = PABCU(JL, 15, ICP1) + ZUAER(JL, 2) * ZDUC(JL, IC) * ZDIFF
+        PABCU(JL, 16, IC) = PABCU(JL, 16, ICP1) + ZUAER(JL, 3) * ZDUC(JL, IC) * ZDIFF
+        PABCU(JL, 17, IC) = PABCU(JL, 17, ICP1) + ZUAER(JL, 4) * ZDUC(JL, IC) * ZDIFF
+        PABCU(JL, 18, IC) = PABCU(JL, 18, ICP1) + ZUAER(JL, 5) * ZDUC(JL, IC) * ZDIFF
 #ifdef REPROBUS
         IF (type_trac=='repr'.and. ok_rtime2d) THEN
@@ -341,33 +340,33 @@
          ELSE
 #endif
-!- CH4
-      PABCU(JL,19,IC)=PABCU(JL,19,ICP1)&
-       & + ZABLY(JL,2,IC)*RCH4/PCCO2*ZPHM6(JL)*ZDIFF  
-      PABCU(JL,20,IC)=PABCU(JL,20,ICP1)&
-       & + ZABLY(JL,3,IC)*RCH4/PCCO2*ZPSM6(JL)*ZDIFF  
-!- N2O
-      PABCU(JL,21,IC)=PABCU(JL,21,ICP1)&
-       & + ZABLY(JL,2,IC)*RN2O/PCCO2*ZPHN6(JL)*ZDIFF  
-      PABCU(JL,22,IC)=PABCU(JL,22,ICP1)&
-       & + ZABLY(JL,3,IC)*RN2O/PCCO2*ZPSN6(JL)*ZDIFF  
-!- CFC11
-      PABCU(JL,23,IC)=PABCU(JL,23,ICP1)&
-       & + ZABLY(JL,2,IC)*RCFC11/PCCO2        *ZDIFF  
-!- CFC12
-      PABCU(JL,24,IC)=PABCU(JL,24,ICP1)&
-       & + ZABLY(JL,2,IC)*RCFC12/PCCO2        *ZDIFF  
+        !- CH4
+        PABCU(JL, 19, IC) = PABCU(JL, 19, ICP1)&
+                & + ZABLY(JL, 2, IC) * RCH4 / PCCO2 * ZPHM6(JL) * ZDIFF
+        PABCU(JL, 20, IC) = PABCU(JL, 20, ICP1)&
+                & + ZABLY(JL, 3, IC) * RCH4 / PCCO2 * ZPSM6(JL) * ZDIFF
+        !- N2O
+        PABCU(JL, 21, IC) = PABCU(JL, 21, ICP1)&
+                & + ZABLY(JL, 2, IC) * RN2O / PCCO2 * ZPHN6(JL) * ZDIFF
+        PABCU(JL, 22, IC) = PABCU(JL, 22, ICP1)&
+                & + ZABLY(JL, 3, IC) * RN2O / PCCO2 * ZPSN6(JL) * ZDIFF
+        !- CFC11
+        PABCU(JL, 23, IC) = PABCU(JL, 23, ICP1)&
+                & + ZABLY(JL, 2, IC) * RCFC11 / PCCO2 * ZDIFF
+        !- CFC12
+        PABCU(JL, 24, IC) = PABCU(JL, 24, ICP1)&
+                & + ZABLY(JL, 2, IC) * RCFC12 / PCCO2 * ZDIFF
 #ifdef REPROBUS
         END IF
 #endif
-    ENDDO
-  ENDDO
-
-ENDDO
-!      print *,'END OF LWU'
-
-
-
-!-----------------------------------------------------------------------
-
-IF (LHOOK) CALL DR_HOOK('LWU',1,ZHOOK_HANDLE)
+      ENDDO
+    ENDDO
+
+  ENDDO
+  !      print *,'END OF LWU'
+
+
+
+  !-----------------------------------------------------------------------
+
+  IF (LHOOK) CALL DR_HOOK('LWU', 1, ZHOOK_HANDLE)
 END SUBROUTINE LWU
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/radlsw.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/radlsw.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/radlsw.F90	(revision 5154)
@@ -152,10 +152,10 @@
 USE YOMLUN_IFSAUX , ONLY : NULOUT
 USE YOMCT3        , ONLY : NSTEP
+USE lmdz_clesphys
+USE lmdz_yoethf
 
 IMPLICIT NONE
 
-include "clesphys.h"
 !!include "clesrrtm.h"
-include "YOETHF.h"
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/radlsw.intfb.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/radlsw.intfb.h	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/radlsw.intfb.h	(revision 5154)
@@ -20,6 +20,7 @@
  & NRADIP , NRADLP , NICEOPT, NLIQOPT, NINHOM ,NLAYINH ,&
  & RCCNLND, RCCNSEA, RLWINHF, RSWINHF, RRe2De ,&
- & LEDBUG 
-include "clesphys.h"
+ & LEDBUG
+ USE lmdz_clesphys
+
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/read_rsun_rrtm.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/read_rsun_rrtm.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/read_rsun_rrtm.F90	(revision 5154)
@@ -18,8 +18,8 @@
 
   USE YOESW, ONLY : RSUN
+  USE lmdz_clesphys
 
   IMPLICIT NONE
 
-  INCLUDE "clesphys.h"
 
   ! Input arguments
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/readaerosol_optic_rrtm.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/readaerosol_optic_rrtm.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/readaerosol_optic_rrtm.F90	(revision 5154)
@@ -22,8 +22,7 @@
   USE infotrac_phy, ONLY: tracers, nqtot, nbtr
   USE YOMCST
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-
-  include "clesphys.h"
 
   ! Input arguments
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/readaerosolstrato2_rrtm.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/readaerosolstrato2_rrtm.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/readaerosolstrato2_rrtm.F90	(revision 5154)
@@ -21,8 +21,7 @@
     USE lmdz_xios
     USE lmdz_abort_physic, ONLY: abort_physic
+    USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     CHARACTER (len = 80) :: abort_message
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/recmwf_aero.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/recmwf_aero.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/recmwf_aero.F90	(revision 5154)
@@ -164,4 +164,5 @@
   USE YOMARPHY , ONLY : LRDUST 
   USE phys_output_mod, ONLY : swaerofree_diag, swaero_diag
+  USE lmdz_clesphys
 
   !-----------------------------------------------------------------------
@@ -171,5 +172,4 @@
 
   IMPLICIT NONE
-  INCLUDE "clesphys.h"
 
   INTEGER(KIND=JPIM),INTENT(IN)    :: KPROMA 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/rrtm_ecrt_140gp.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/rrtm_ecrt_140gp.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/rrtm_ecrt_140gp.F90	(revision 5154)
@@ -5,402 +5,400 @@
 
 SUBROUTINE RRTM_ECRT_140GP &
- & ( K_IPLON, klon , klev, kcld,&
- & paer , paph , pap,&
- & pts  , pth  , pt,&
- & P_ZEMIS, P_ZEMIW,&
- & pq   , pcco2, pozn, pcldf, ptaucld, ptclear,&
- & P_CLDFRAC,P_TAUCLD,&
- & PTAU_LW,&
- & P_COLDRY,P_WKL,P_WX,&
- & P_TAUAERL,PAVEL,P_TAVEL,PZ,P_TZ,P_TBOUND,K_NLAYERS,P_SEMISS,K_IREFLECT )  
-
-!     Reformatted for F90 by JJMorcrette, ECMWF, 980714
-
-!     Read in atmospheric profile from ECMWF radiation code, and prepare it
-!     for use in RRTM.  Set other RRTM input parameters.  Values are passed
-!     back through existing RRTM arrays and commons.
-
-!- Modifications
-
-!     2000-05-15 Deborah Salmond  Speed-up
-
-USE PARKIND1  ,ONLY : JPIM     ,JPRB
-USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
-
-USE PARRRTM  , ONLY : JPBAND   ,JPXSEC   ,JPLAY   ,&
- & JPINPX  
-USE YOERAD   , ONLY : NLW      ,NOVLP
-!MPL/IM 20160915 on prend GES de phylmd USE YOERDI   , ONLY :    RCH4     ,RN2O    ,RCFC11  ,RCFC12
-USE YOESW    , ONLY : RAER
-
-!------------------------------Arguments--------------------------------
-
-IMPLICIT NONE
-
-
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLON! Number of atmospheres (longitudes) 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV! Number of atmospheric layers 
-INTEGER(KIND=JPIM),INTENT(IN)    :: K_IPLON 
-INTEGER(KIND=JPIM),INTENT(OUT)   :: KCLD 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAER(KLON,6,KLEV) ! Aerosol optical thickness
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPH(KLON,KLEV+1) ! Interface pressures (Pa)
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAP(KLON,KLEV) ! Layer pressures (Pa)
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS(KLON) ! Surface temperature (K)
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTH(KLON,KLEV+1) ! Interface temperatures (K)
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PT(KLON,KLEV) ! Layer temperature (K)
-REAL(KIND=JPRB)   ,INTENT(IN)    :: P_ZEMIS(KLON) ! Non-window surface emissivity
-REAL(KIND=JPRB)   ,INTENT(IN)    :: P_ZEMIW(KLON) ! Window surface emissivity
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ(KLON,KLEV) ! H2O specific humidity (mmr)
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PCCO2 ! CO2 mass mixing ratio
-REAL(KIND=JPRB)   ,INTENT(IN)    :: POZN(KLON,KLEV) ! O3 mass mixing ratio
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLDF(KLON,KLEV) ! Cloud fraction
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAUCLD(KLON,KLEV,JPBAND) ! Cloud optical depth
-!--C.Kleinschmitt
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAU_LW(KLON,KLEV,NLW) ! LW Optical depth of aerosols  
-!--end
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTCLEAR 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_CLDFRAC(JPLAY) ! Cloud fraction
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_TAUCLD(JPLAY,JPBAND) ! Spectral optical thickness
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_COLDRY(JPLAY) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_WKL(JPINPX,JPLAY) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_WX(JPXSEC,JPLAY) ! Amount of trace gases
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_TAUAERL(JPLAY,JPBAND) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: PAVEL(JPLAY) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_TAVEL(JPLAY) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: PZ(0:JPLAY) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_TZ(0:JPLAY) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_TBOUND 
-INTEGER(KIND=JPIM),INTENT(OUT)   :: K_NLAYERS 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_SEMISS(JPBAND) 
-INTEGER(KIND=JPIM),INTENT(OUT)   :: K_IREFLECT 
-!      real rch4                       ! CH4 mass mixing ratio
-!      real rn2o                       ! N2O mass mixing ratio
-!      real rcfc11                     ! CFC11 mass mixing ratio
-!      real rcfc12                     ! CFC12 mass mixing ratio
-!- from AER
-!- from PROFILE             
-!- from SURFACE             
-REAL(KIND=JPRB) :: ztauaer(5)
-REAL(KIND=JPRB) :: zc1j(0:klev)               ! total cloud from top and level k
-REAL(KIND=JPRB) :: Z_AMD                  ! Effective molecular weight of dry air (g/mol)
-REAL(KIND=JPRB) :: Z_AMW                  ! Molecular weight of water vapor (g/mol)
-REAL(KIND=JPRB) :: Z_AMCO2                ! Molecular weight of carbon dioxide (g/mol)
-REAL(KIND=JPRB) :: Z_AMO                  ! Molecular weight of ozone (g/mol)
-REAL(KIND=JPRB) :: Z_AMCH4                ! Molecular weight of methane (g/mol)
-REAL(KIND=JPRB) :: Z_AMN2O                ! Molecular weight of nitrous oxide (g/mol)
-REAL(KIND=JPRB) :: Z_AMC11                ! Molecular weight of CFC11 (g/mol) - CFCL3
-REAL(KIND=JPRB) :: Z_AMC12                ! Molecular weight of CFC12 (g/mol) - CF2CL2
-REAL(KIND=JPRB) :: Z_AVGDRO               ! Avogadro's number (molecules/mole)
-REAL(KIND=JPRB) :: Z_GRAVIT               ! Gravitational acceleration (cm/sec2)
-
-! Atomic weights for conversion from mass to volume mixing ratios; these
-!  are the same values used in ECRT to assure accurate conversion to vmr
-data Z_AMD   /  28.970_JPRB    /
-data Z_AMW   /  18.0154_JPRB   /
-data Z_AMCO2 /  44.011_JPRB    /
-data Z_AMO   /  47.9982_JPRB   /
-data Z_AMCH4 /  16.043_JPRB    /
-data Z_AMN2O /  44.013_JPRB    /
-data Z_AMC11 / 137.3686_JPRB   /
-data Z_AMC12 / 120.9140_JPRB   /
-data Z_AVGDRO/ 6.02214E23_JPRB /
-data Z_GRAVIT/ 9.80665E02_JPRB /
-
-INTEGER(KIND=JPIM) :: IATM, IMOL, IXMAX, J1, J2, JAE, JB, JK, JL, I_L
-INTEGER(KIND=JPIM) :: I_NMOL, I_NXMOL
-
-REAL(KIND=JPRB) :: Z_AMM, ZCLDLY, ZCLEAR, ZCLOUD, ZEPSEC
-REAL(KIND=JPRB) :: ZHOOK_HANDLE
-
-!MPL/IM 20160915 on prend GES de phylmd
-#include "clesphys.h"
-! ***
-
-! *** mji
-! Initialize all molecular amounts and aerosol optical depths to zero here, 
-! then pass ECRT amounts into RRTM arrays below.
-
-!      DATA ZWKL /MAXPRDW*0.0/
-!      DATA ZWX  /MAXPROD*0.0/
-!      DATA KREFLECT /0/
-
-! Activate cross section molecules:
-!     NXMOL     - number of cross-sections input by user
-!     IXINDX(I) - index of cross-section molecule corresponding to Ith
-!                 cross-section specified by user
-!                 = 0 -- not allowed in RRTM
-!                 = 1 -- CCL4
-!                 = 2 -- CFC11
-!                 = 3 -- CFC12
-!                 = 4 -- CFC22
-!      DATA KXMOL  /2/
-!      DATA KXINDX /0,2,3,0,31*0/
-
-!      IREFLECT=KREFLECT
-!      NXMOL=KXMOL
-
-IF (LHOOK) CALL DR_HOOK('RRTM_ECRT_140GP',0,ZHOOK_HANDLE)
-K_IREFLECT=0
-I_NXMOL=2
-
-DO J1=1,35
-! IXINDX(J1)=0
-  DO J2=1,KLEV
-    P_WKL(J1,J2)=0.0_JPRB 
-  ENDDO
-ENDDO
-!IXINDX(2)=2
-!IXINDX(3)=3
-
-!     Set parameters needed for RRTM execution:
-IATM    = 0
-!      IXSECT  = 1
-!      NUMANGS = 0
-!      IOUT    = -1
-IXMAX   = 4
-
-!     Bands 6,7,8 are considered the 'window' and allowed to have a
-!     different surface emissivity (as in ECMWF).  Eli wrote this part....
-P_SEMISS(1)  = P_ZEMIS(K_IPLON)
-P_SEMISS(2)  = P_ZEMIS(K_IPLON)
-P_SEMISS(3)  = P_ZEMIS(K_IPLON)
-P_SEMISS(4)  = P_ZEMIS(K_IPLON)
-P_SEMISS(5)  = P_ZEMIS(K_IPLON)
-P_SEMISS(6)  = P_ZEMIW(K_IPLON)
-P_SEMISS(7)  = P_ZEMIW(K_IPLON)
-P_SEMISS(8)  = P_ZEMIW(K_IPLON)
-P_SEMISS(9)  = P_ZEMIS(K_IPLON)
-P_SEMISS(10) = P_ZEMIS(K_IPLON)
-P_SEMISS(11) = P_ZEMIS(K_IPLON)
-P_SEMISS(12) = P_ZEMIS(K_IPLON)
-P_SEMISS(13) = P_ZEMIS(K_IPLON)
-P_SEMISS(14) = P_ZEMIS(K_IPLON)
-P_SEMISS(15) = P_ZEMIS(K_IPLON)
-P_SEMISS(16) = P_ZEMIS(K_IPLON)
-
-!     Set surface temperature.  
-
-P_TBOUND = pts(K_IPLON)
-
-!     Install ECRT arrays into RRTM arrays for pressure, temperature,
-!     and molecular amounts.  Pressures are converted from Pascals
-!     (ECRT) to mb (RRTM).  H2O, CO2, O3 and trace gas amounts are 
-!     converted from mass mixing ratio to volume mixing ratio.  CO2
-!     converted with same dry air and CO2 molecular weights used in 
-!     ECRT to assure correct conversion back to the proper CO2 vmr.
-!     The dry air column COLDRY (in molec/cm2) is calculated from 
-!     the level pressures PZ (in mb) based on the hydrostatic equation
-!     and includes a correction to account for H2O in the layer.  The
-!     molecular weight of moist air (amm) is calculated for each layer.
-!     Note: RRTM levels count from bottom to top, while the ECRT input
-!     variables count from the top down and must be reversed here.
-
-K_NLAYERS = klev
-I_NMOL = 6
-PZ(0) = paph(K_IPLON,klev+1)/100._JPRB
-P_TZ(0) = pth(K_IPLON,klev+1)
-DO I_L = 1, KLEV
-  PAVEL(I_L) = pap(K_IPLON,KLEV-I_L+1)/100._JPRB
-  P_TAVEL(I_L) = pt(K_IPLON,KLEV-I_L+1)
-  PZ(I_L) = paph(K_IPLON,KLEV-I_L+1)/100._JPRB
-  P_TZ(I_L) = pth(K_IPLON,KLEV-I_L+1)
-  P_WKL(1,I_L) = pq(K_IPLON,KLEV-I_L+1)*Z_AMD/Z_AMW
-  P_WKL(2,I_L) = pcco2*Z_AMD/Z_AMCO2
-  P_WKL(3,I_L) = pozn(K_IPLON,KLEV-I_L+1)*Z_AMD/Z_AMO
-  P_WKL(4,I_L) = rn2o*Z_AMD/Z_AMN2O
-  P_WKL(6,I_L) = rch4*Z_AMD/Z_AMCH4
-  Z_AMM = (1-P_WKL(1,I_L))*Z_AMD + P_WKL(1,I_L)*Z_AMW
-  P_COLDRY(I_L) = (PZ(I_L-1)-PZ(I_L))*1.E3_JPRB*Z_AVGDRO/(Z_GRAVIT*Z_AMM*(1+P_WKL(1,I_L)))
-ENDDO
-
-!- Fill RRTM aerosol arrays with operational ECMWF aerosols,
-!  do the mixing and distribute over the 16 spectral intervals
-
-DO I_L=1,KLEV
-  JK=KLEV-I_L+1
-!       DO JAE=1,5
-  JAE=1
-  ZTAUAER(JAE) =&
-   & RAER(JAE,1)*PAER(K_IPLON,1,JK)+RAER(JAE,2)*PAER(K_IPLON,2,JK)&
-   & +RAER(JAE,3)*PAER(K_IPLON,3,JK)+RAER(JAE,4)*PAER(K_IPLON,4,JK)&
-   & +RAER(JAE,5)*PAER(K_IPLON,5,JK)+RAER(JAE,6)*PAER(K_IPLON,6,JK)  
-  P_TAUAERL(I_L, 1)=ZTAUAER(1)
-  P_TAUAERL(I_L, 2)=ZTAUAER(1)
-  JAE=2
-  ZTAUAER(JAE) =&
-   & RAER(JAE,1)*PAER(K_IPLON,1,JK)+RAER(JAE,2)*PAER(K_IPLON,2,JK)&
-   & +RAER(JAE,3)*PAER(K_IPLON,3,JK)+RAER(JAE,4)*PAER(K_IPLON,4,JK)&
-   & +RAER(JAE,5)*PAER(K_IPLON,5,JK)+RAER(JAE,6)*PAER(K_IPLON,6,JK)  
-  P_TAUAERL(I_L, 3)=ZTAUAER(2)
-  P_TAUAERL(I_L, 4)=ZTAUAER(2)
-  P_TAUAERL(I_L, 5)=ZTAUAER(2)
-  JAE=3
-  ZTAUAER(JAE) =&
-   & RAER(JAE,1)*PAER(K_IPLON,1,JK)+RAER(JAE,2)*PAER(K_IPLON,2,JK)&
-   & +RAER(JAE,3)*PAER(K_IPLON,3,JK)+RAER(JAE,4)*PAER(K_IPLON,4,JK)&
-   & +RAER(JAE,5)*PAER(K_IPLON,5,JK)+RAER(JAE,6)*PAER(K_IPLON,6,JK)  
-  P_TAUAERL(I_L, 6)=ZTAUAER(3)
-  P_TAUAERL(I_L, 8)=ZTAUAER(3)
-  P_TAUAERL(I_L, 9)=ZTAUAER(3)
-  JAE=4
-  ZTAUAER(JAE) =&
-   & RAER(JAE,1)*PAER(K_IPLON,1,JK)+RAER(JAE,2)*PAER(K_IPLON,2,JK)&
-   & +RAER(JAE,3)*PAER(K_IPLON,3,JK)+RAER(JAE,4)*PAER(K_IPLON,4,JK)&
-   & +RAER(JAE,5)*PAER(K_IPLON,5,JK)+RAER(JAE,6)*PAER(K_IPLON,6,JK)  
-  P_TAUAERL(I_L, 7)=ZTAUAER(4)
-  JAE=5
-  ZTAUAER(JAE) =&
-   & RAER(JAE,1)*PAER(K_IPLON,1,JK)+RAER(JAE,2)*PAER(K_IPLON,2,JK)&
-   & +RAER(JAE,3)*PAER(K_IPLON,3,JK)+RAER(JAE,4)*PAER(K_IPLON,4,JK)&
-   & +RAER(JAE,5)*PAER(K_IPLON,5,JK)+RAER(JAE,6)*PAER(K_IPLON,6,JK)  
-!       END DO
-  P_TAUAERL(I_L,10)=ZTAUAER(5)
-  P_TAUAERL(I_L,11)=ZTAUAER(5)
-  P_TAUAERL(I_L,12)=ZTAUAER(5)
-  P_TAUAERL(I_L,13)=ZTAUAER(5)
-  P_TAUAERL(I_L,14)=ZTAUAER(5)
-  P_TAUAERL(I_L,15)=ZTAUAER(5)
-  P_TAUAERL(I_L,16)=ZTAUAER(5)
-ENDDO
-!--Use LW AOD from own Mie calculations (C. Kleinschmitt)
-DO I_L=1,KLEV
-  JK=KLEV-I_L+1
-  DO JAE=1, NLW 
-    P_TAUAERL(I_L,JAE) = MAX( PTAU_LW(K_IPLON, JK, JAE), 1e-30 )
-  ENDDO
-ENDDO
-!--end C. Kleinschmitt
-
-DO J2=1,KLEV
-  DO J1=1,JPXSEC
-    P_WX(J1,J2)=0.0_JPRB
-  ENDDO
-ENDDO
-
-DO I_L = 1, KLEV
-!- Set cross section molecule amounts from ECRT; convert to vmr
-  P_WX(2,I_L) = rcfc11*Z_AMD/Z_AMC11
-  P_WX(3,I_L) = rcfc12*Z_AMD/Z_AMC12
-  P_WX(2,I_L) = P_COLDRY(I_L) * P_WX(2,I_L) * 1.E-20_JPRB
-  P_WX(3,I_L) = P_COLDRY(I_L) * P_WX(3,I_L) * 1.E-20_JPRB
-
-!- Here, all molecules in WKL and WX are in volume mixing ratio; convert to
-!  molec/cm2 based on COLDRY for use in RRTM
-
-  DO IMOL = 1, I_NMOL
-    P_WKL(IMOL,I_L) = P_COLDRY(I_L) * P_WKL(IMOL,I_L)
-  ENDDO  
-  
-! DO IX = 1,JPXSEC
-! IF (IXINDX(IX)  /=  0) THEN
-!     WX(IXINDX(IX),L) = COLDRY(L) * WX(IX,L) * 1.E-20_JPRB
-! ENDIF
-! END DO  
-
-ENDDO
-
-!- Approximate treatment for various cloud overlaps
-ZCLEAR=1.0_JPRB
-ZCLOUD=0.0_JPRB
-ZC1J(0)=0.0_JPRB
-ZEPSEC=1.E-03_JPRB
-JL=K_IPLON
-
-!++MODIFCODE
-IF ((NOVLP == 1).OR.(NOVLP ==6).OR.(NOVLP ==8)) THEN
-!--MODIFCODE
-
-  DO JK=1,KLEV
-    IF (pcldf(JL,JK) > ZEPSEC) THEN
-      ZCLDLY=pcldf(JL,JK)
-      ZCLEAR=ZCLEAR &
-       & *(1.0_JPRB-MAX( ZCLDLY , ZCLOUD ))&
-       & /(1.0_JPRB-MIN( ZCLOUD , 1.0_JPRB-ZEPSEC ))  
-      ZCLOUD = ZCLDLY
-      ZC1J(JK)= 1.0_JPRB - ZCLEAR
-    ELSE
-      ZCLDLY=0.0_JPRB
-      ZCLEAR=ZCLEAR &
-       & *(1.0_JPRB-MAX( ZCLDLY , ZCLOUD ))&
-       & /(1.0_JPRB-MIN( ZCLOUD , 1.0_JPRB-ZEPSEC ))  
-      ZCLOUD = ZCLDLY
-      ZC1J(JK)= 1.0_JPRB - ZCLEAR
-    ENDIF
-  ENDDO
-
-!++MODIFCODE
-ELSEIF ((NOVLP == 2).OR.(NOVLP ==7)) THEN
-!--MODIFCODE
-
-  DO JK=1,KLEV
-    IF (pcldf(JL,JK) > ZEPSEC) THEN
-      ZCLDLY=pcldf(JL,JK)
-      ZCLOUD = MAX( ZCLDLY , ZCLOUD )
-      ZC1J(JK) = ZCLOUD
-    ELSE
-      ZCLDLY=0.0_JPRB
-      ZCLOUD = MAX( ZCLDLY , ZCLOUD )
-      ZC1J(JK) = ZCLOUD
-    ENDIF
-  ENDDO
-
-!++MODIFCODE
-ELSEIF ((NOVLP == 3).OR.(NOVLP ==5)) THEN
-!--MODIFCODE
-
-  DO JK=1,KLEV
-    IF (pcldf(JL,JK) > ZEPSEC) THEN
-      ZCLDLY=pcldf(JL,JK)
-      ZCLEAR = ZCLEAR * (1.0_JPRB-ZCLDLY)
-      ZCLOUD = 1.0_JPRB - ZCLEAR
-      ZC1J(JK) = ZCLOUD
-    ELSE
-      ZCLDLY=0.0_JPRB
-      ZCLEAR = ZCLEAR * (1.0_JPRB-ZCLDLY)
-      ZCLOUD = 1.0_JPRB - ZCLEAR
-      ZC1J(JK) = ZCLOUD
-    ENDIF
-  ENDDO
-
-ELSEIF (NOVLP == 4) THEN
-
-ENDIF
-PTCLEAR=1.0_JPRB-ZC1J(KLEV)
-
-! Transfer cloud fraction and cloud optical depth to RRTM arrays; 
-! invert array index for pcldf to go from bottom to top for RRTM
-
-!- clear-sky column
-IF (PTCLEAR  >  1.0_JPRB-ZEPSEC) THEN
-  KCLD=0
+        & (K_IPLON, klon, klev, kcld, &
+        & paer, paph, pap, &
+        & pts, pth, pt, &
+        & P_ZEMIS, P_ZEMIW, &
+        & pq, pcco2, pozn, pcldf, ptaucld, ptclear, &
+        & P_CLDFRAC, P_TAUCLD, &
+        & PTAU_LW, &
+        & P_COLDRY, P_WKL, P_WX, &
+        & P_TAUAERL, PAVEL, P_TAVEL, PZ, P_TZ, P_TBOUND, K_NLAYERS, P_SEMISS, K_IREFLECT)
+
+  !     Reformatted for F90 by JJMorcrette, ECMWF, 980714
+
+  !     Read in atmospheric profile from ECMWF radiation code, and prepare it
+  !     for use in RRTM.  Set other RRTM input parameters.  Values are passed
+  !     back through existing RRTM arrays and commons.
+
+  !- Modifications
+
+  !     2000-05-15 Deborah Salmond  Speed-up
+
+  USE PARKIND1, ONLY: JPIM, JPRB
+  USE YOMHOOK, ONLY: LHOOK, DR_HOOK
+
+  USE PARRRTM, ONLY: JPBAND, JPXSEC, JPLAY, &
+          & JPINPX
+  USE YOERAD, ONLY: NLW, NOVLP
+  !MPL/IM 20160915 on prend GES de phylmd USE YOERDI   , ONLY :    RCH4     ,RN2O    ,RCFC11  ,RCFC12
+  USE YOESW, ONLY: RAER
+  USE lmdz_clesphys
+
+  !------------------------------Arguments--------------------------------
+
+  IMPLICIT NONE
+
+  INTEGER(KIND = JPIM), INTENT(IN) :: KLON! Number of atmospheres (longitudes)
+  INTEGER(KIND = JPIM), INTENT(IN) :: KLEV! Number of atmospheric layers
+  INTEGER(KIND = JPIM), INTENT(IN) :: K_IPLON
+  INTEGER(KIND = JPIM), INTENT(OUT) :: KCLD
+  REAL(KIND = JPRB), INTENT(IN) :: PAER(KLON, 6, KLEV) ! Aerosol optical thickness
+  REAL(KIND = JPRB), INTENT(IN) :: PAPH(KLON, KLEV + 1) ! Interface pressures (Pa)
+  REAL(KIND = JPRB), INTENT(IN) :: PAP(KLON, KLEV) ! Layer pressures (Pa)
+  REAL(KIND = JPRB), INTENT(IN) :: PTS(KLON) ! Surface temperature (K)
+  REAL(KIND = JPRB), INTENT(IN) :: PTH(KLON, KLEV + 1) ! Interface temperatures (K)
+  REAL(KIND = JPRB), INTENT(IN) :: PT(KLON, KLEV) ! Layer temperature (K)
+  REAL(KIND = JPRB), INTENT(IN) :: P_ZEMIS(KLON) ! Non-window surface emissivity
+  REAL(KIND = JPRB), INTENT(IN) :: P_ZEMIW(KLON) ! Window surface emissivity
+  REAL(KIND = JPRB), INTENT(IN) :: PQ(KLON, KLEV) ! H2O specific humidity (mmr)
+  REAL(KIND = JPRB), INTENT(IN) :: PCCO2 ! CO2 mass mixing ratio
+  REAL(KIND = JPRB), INTENT(IN) :: POZN(KLON, KLEV) ! O3 mass mixing ratio
+  REAL(KIND = JPRB), INTENT(IN) :: PCLDF(KLON, KLEV) ! Cloud fraction
+  REAL(KIND = JPRB), INTENT(IN) :: PTAUCLD(KLON, KLEV, JPBAND) ! Cloud optical depth
+  !--C.Kleinschmitt
+  REAL(KIND = JPRB), INTENT(IN) :: PTAU_LW(KLON, KLEV, NLW) ! LW Optical depth of aerosols
+  !--end
+  REAL(KIND = JPRB), INTENT(OUT) :: PTCLEAR
+  REAL(KIND = JPRB), INTENT(OUT) :: P_CLDFRAC(JPLAY) ! Cloud fraction
+  REAL(KIND = JPRB), INTENT(OUT) :: P_TAUCLD(JPLAY, JPBAND) ! Spectral optical thickness
+  REAL(KIND = JPRB), INTENT(OUT) :: P_COLDRY(JPLAY)
+  REAL(KIND = JPRB), INTENT(OUT) :: P_WKL(JPINPX, JPLAY)
+  REAL(KIND = JPRB), INTENT(OUT) :: P_WX(JPXSEC, JPLAY) ! Amount of trace gases
+  REAL(KIND = JPRB), INTENT(OUT) :: P_TAUAERL(JPLAY, JPBAND)
+  REAL(KIND = JPRB), INTENT(OUT) :: PAVEL(JPLAY)
+  REAL(KIND = JPRB), INTENT(OUT) :: P_TAVEL(JPLAY)
+  REAL(KIND = JPRB), INTENT(OUT) :: PZ(0:JPLAY)
+  REAL(KIND = JPRB), INTENT(OUT) :: P_TZ(0:JPLAY)
+  REAL(KIND = JPRB), INTENT(OUT) :: P_TBOUND
+  INTEGER(KIND = JPIM), INTENT(OUT) :: K_NLAYERS
+  REAL(KIND = JPRB), INTENT(OUT) :: P_SEMISS(JPBAND)
+  INTEGER(KIND = JPIM), INTENT(OUT) :: K_IREFLECT
+  !      real rch4                       ! CH4 mass mixing ratio
+  !      real rn2o                       ! N2O mass mixing ratio
+  !      real rcfc11                     ! CFC11 mass mixing ratio
+  !      real rcfc12                     ! CFC12 mass mixing ratio
+  !- from AER
+  !- from PROFILE
+  !- from SURFACE
+  REAL(KIND = JPRB) :: ztauaer(5)
+  REAL(KIND = JPRB) :: zc1j(0:klev)               ! total cloud from top and level k
+  REAL(KIND = JPRB) :: Z_AMD                  ! Effective molecular weight of dry air (g/mol)
+  REAL(KIND = JPRB) :: Z_AMW                  ! Molecular weight of water vapor (g/mol)
+  REAL(KIND = JPRB) :: Z_AMCO2                ! Molecular weight of carbon dioxide (g/mol)
+  REAL(KIND = JPRB) :: Z_AMO                  ! Molecular weight of ozone (g/mol)
+  REAL(KIND = JPRB) :: Z_AMCH4                ! Molecular weight of methane (g/mol)
+  REAL(KIND = JPRB) :: Z_AMN2O                ! Molecular weight of nitrous oxide (g/mol)
+  REAL(KIND = JPRB) :: Z_AMC11                ! Molecular weight of CFC11 (g/mol) - CFCL3
+  REAL(KIND = JPRB) :: Z_AMC12                ! Molecular weight of CFC12 (g/mol) - CF2CL2
+  REAL(KIND = JPRB) :: Z_AVGDRO               ! Avogadro's number (molecules/mole)
+  REAL(KIND = JPRB) :: Z_GRAVIT               ! Gravitational acceleration (cm/sec2)
+
+  ! Atomic weights for conversion from mass to volume mixing ratios; these
+  !  are the same values used in ECRT to assure accurate conversion to vmr
+  data Z_AMD   /  28.970_JPRB    /
+  data Z_AMW   /  18.0154_JPRB   /
+  data Z_AMCO2 /  44.011_JPRB    /
+  data Z_AMO   /  47.9982_JPRB   /
+  data Z_AMCH4 /  16.043_JPRB    /
+  data Z_AMN2O /  44.013_JPRB    /
+  data Z_AMC11 / 137.3686_JPRB   /
+  data Z_AMC12 / 120.9140_JPRB   /
+  data Z_AVGDRO/ 6.02214E23_JPRB /
+  data Z_GRAVIT/ 9.80665E02_JPRB /
+
+  INTEGER(KIND = JPIM) :: IATM, IMOL, IXMAX, J1, J2, JAE, JB, JK, JL, I_L
+  INTEGER(KIND = JPIM) :: I_NMOL, I_NXMOL
+
+  REAL(KIND = JPRB) :: Z_AMM, ZCLDLY, ZCLEAR, ZCLOUD, ZEPSEC
+  REAL(KIND = JPRB) :: ZHOOK_HANDLE
+
+  ! ***
+
+  ! *** mji
+  ! Initialize all molecular amounts and aerosol optical depths to zero here,
+  ! then pass ECRT amounts into RRTM arrays below.
+
+  !      DATA ZWKL /MAXPRDW*0.0/
+  !      DATA ZWX  /MAXPROD*0.0/
+  !      DATA KREFLECT /0/
+
+  ! Activate cross section molecules:
+  !     NXMOL     - number of cross-sections input by user
+  !     IXINDX(I) - index of cross-section molecule corresponding to Ith
+  !                 cross-section specified by user
+  !                 = 0 -- not allowed in RRTM
+  !                 = 1 -- CCL4
+  !                 = 2 -- CFC11
+  !                 = 3 -- CFC12
+  !                 = 4 -- CFC22
+  !      DATA KXMOL  /2/
+  !      DATA KXINDX /0,2,3,0,31*0/
+
+  !      IREFLECT=KREFLECT
+  !      NXMOL=KXMOL
+
+  IF (LHOOK) CALL DR_HOOK('RRTM_ECRT_140GP', 0, ZHOOK_HANDLE)
+  K_IREFLECT = 0
+  I_NXMOL = 2
+
+  DO J1 = 1, 35
+    ! IXINDX(J1)=0
+    DO J2 = 1, KLEV
+      P_WKL(J1, J2) = 0.0_JPRB
+    ENDDO
+  ENDDO
+  !IXINDX(2)=2
+  !IXINDX(3)=3
+
+  !     Set parameters needed for RRTM execution:
+  IATM = 0
+  !      IXSECT  = 1
+  !      NUMANGS = 0
+  !      IOUT    = -1
+  IXMAX = 4
+
+  !     Bands 6,7,8 are considered the 'window' and allowed to have a
+  !     different surface emissivity (as in ECMWF).  Eli wrote this part....
+  P_SEMISS(1) = P_ZEMIS(K_IPLON)
+  P_SEMISS(2) = P_ZEMIS(K_IPLON)
+  P_SEMISS(3) = P_ZEMIS(K_IPLON)
+  P_SEMISS(4) = P_ZEMIS(K_IPLON)
+  P_SEMISS(5) = P_ZEMIS(K_IPLON)
+  P_SEMISS(6) = P_ZEMIW(K_IPLON)
+  P_SEMISS(7) = P_ZEMIW(K_IPLON)
+  P_SEMISS(8) = P_ZEMIW(K_IPLON)
+  P_SEMISS(9) = P_ZEMIS(K_IPLON)
+  P_SEMISS(10) = P_ZEMIS(K_IPLON)
+  P_SEMISS(11) = P_ZEMIS(K_IPLON)
+  P_SEMISS(12) = P_ZEMIS(K_IPLON)
+  P_SEMISS(13) = P_ZEMIS(K_IPLON)
+  P_SEMISS(14) = P_ZEMIS(K_IPLON)
+  P_SEMISS(15) = P_ZEMIS(K_IPLON)
+  P_SEMISS(16) = P_ZEMIS(K_IPLON)
+
+  !     Set surface temperature.
+
+  P_TBOUND = pts(K_IPLON)
+
+  !     Install ECRT arrays into RRTM arrays for pressure, temperature,
+  !     and molecular amounts.  Pressures are converted from Pascals
+  !     (ECRT) to mb (RRTM).  H2O, CO2, O3 and trace gas amounts are
+  !     converted from mass mixing ratio to volume mixing ratio.  CO2
+  !     converted with same dry air and CO2 molecular weights used in
+  !     ECRT to assure correct conversion back to the proper CO2 vmr.
+  !     The dry air column COLDRY (in molec/cm2) is calculated from
+  !     the level pressures PZ (in mb) based on the hydrostatic equation
+  !     and includes a correction to account for H2O in the layer.  The
+  !     molecular weight of moist air (amm) is calculated for each layer.
+  !     Note: RRTM levels count from bottom to top, while the ECRT input
+  !     variables count from the top down and must be reversed here.
+
+  K_NLAYERS = klev
+  I_NMOL = 6
+  PZ(0) = paph(K_IPLON, klev + 1) / 100._JPRB
+  P_TZ(0) = pth(K_IPLON, klev + 1)
   DO I_L = 1, KLEV
-    P_CLDFRAC(I_L) = 0.0_JPRB
-  ENDDO
-  DO JB=1,JPBAND
-    DO I_L=1,KLEV
-      P_TAUCLD(I_L,JB) = 0.0_JPRB
-    ENDDO
-  ENDDO
-
-ELSE
-
-!- cloudy column
-!   The diffusivity factor (Savijarvi, 1997) on the cloud optical 
-!   thickness TAUCLD has already been applied in RADLSW
-
-  KCLD=1
-  DO I_L=1,KLEV
-    P_CLDFRAC(I_L) = pcldf(K_IPLON,I_L)
-  ENDDO
-  DO JB=1,JPBAND
-    DO I_L=1,KLEV
-      P_TAUCLD(I_L,JB) = ptaucld(K_IPLON,I_L,JB)
-    ENDDO
-  ENDDO
-
-ENDIF
-
-!     ------------------------------------------------------------------
- 
-IF (LHOOK) CALL DR_HOOK('RRTM_ECRT_140GP',1,ZHOOK_HANDLE)
+    PAVEL(I_L) = pap(K_IPLON, KLEV - I_L + 1) / 100._JPRB
+    P_TAVEL(I_L) = pt(K_IPLON, KLEV - I_L + 1)
+    PZ(I_L) = paph(K_IPLON, KLEV - I_L + 1) / 100._JPRB
+    P_TZ(I_L) = pth(K_IPLON, KLEV - I_L + 1)
+    P_WKL(1, I_L) = pq(K_IPLON, KLEV - I_L + 1) * Z_AMD / Z_AMW
+    P_WKL(2, I_L) = pcco2 * Z_AMD / Z_AMCO2
+    P_WKL(3, I_L) = pozn(K_IPLON, KLEV - I_L + 1) * Z_AMD / Z_AMO
+    P_WKL(4, I_L) = rn2o * Z_AMD / Z_AMN2O
+    P_WKL(6, I_L) = rch4 * Z_AMD / Z_AMCH4
+    Z_AMM = (1 - P_WKL(1, I_L)) * Z_AMD + P_WKL(1, I_L) * Z_AMW
+    P_COLDRY(I_L) = (PZ(I_L - 1) - PZ(I_L)) * 1.E3_JPRB * Z_AVGDRO / (Z_GRAVIT * Z_AMM * (1 + P_WKL(1, I_L)))
+  ENDDO
+
+  !- Fill RRTM aerosol arrays with operational ECMWF aerosols,
+  !  do the mixing and distribute over the 16 spectral intervals
+
+  DO I_L = 1, KLEV
+    JK = KLEV - I_L + 1
+    !       DO JAE=1,5
+    JAE = 1
+    ZTAUAER(JAE) = &
+            & RAER(JAE, 1) * PAER(K_IPLON, 1, JK) + RAER(JAE, 2) * PAER(K_IPLON, 2, JK)&
+            & + RAER(JAE, 3) * PAER(K_IPLON, 3, JK) + RAER(JAE, 4) * PAER(K_IPLON, 4, JK)&
+            & + RAER(JAE, 5) * PAER(K_IPLON, 5, JK) + RAER(JAE, 6) * PAER(K_IPLON, 6, JK)
+    P_TAUAERL(I_L, 1) = ZTAUAER(1)
+    P_TAUAERL(I_L, 2) = ZTAUAER(1)
+    JAE = 2
+    ZTAUAER(JAE) = &
+            & RAER(JAE, 1) * PAER(K_IPLON, 1, JK) + RAER(JAE, 2) * PAER(K_IPLON, 2, JK)&
+            & + RAER(JAE, 3) * PAER(K_IPLON, 3, JK) + RAER(JAE, 4) * PAER(K_IPLON, 4, JK)&
+            & + RAER(JAE, 5) * PAER(K_IPLON, 5, JK) + RAER(JAE, 6) * PAER(K_IPLON, 6, JK)
+    P_TAUAERL(I_L, 3) = ZTAUAER(2)
+    P_TAUAERL(I_L, 4) = ZTAUAER(2)
+    P_TAUAERL(I_L, 5) = ZTAUAER(2)
+    JAE = 3
+    ZTAUAER(JAE) = &
+            & RAER(JAE, 1) * PAER(K_IPLON, 1, JK) + RAER(JAE, 2) * PAER(K_IPLON, 2, JK)&
+            & + RAER(JAE, 3) * PAER(K_IPLON, 3, JK) + RAER(JAE, 4) * PAER(K_IPLON, 4, JK)&
+            & + RAER(JAE, 5) * PAER(K_IPLON, 5, JK) + RAER(JAE, 6) * PAER(K_IPLON, 6, JK)
+    P_TAUAERL(I_L, 6) = ZTAUAER(3)
+    P_TAUAERL(I_L, 8) = ZTAUAER(3)
+    P_TAUAERL(I_L, 9) = ZTAUAER(3)
+    JAE = 4
+    ZTAUAER(JAE) = &
+            & RAER(JAE, 1) * PAER(K_IPLON, 1, JK) + RAER(JAE, 2) * PAER(K_IPLON, 2, JK)&
+            & + RAER(JAE, 3) * PAER(K_IPLON, 3, JK) + RAER(JAE, 4) * PAER(K_IPLON, 4, JK)&
+            & + RAER(JAE, 5) * PAER(K_IPLON, 5, JK) + RAER(JAE, 6) * PAER(K_IPLON, 6, JK)
+    P_TAUAERL(I_L, 7) = ZTAUAER(4)
+    JAE = 5
+    ZTAUAER(JAE) = &
+            & RAER(JAE, 1) * PAER(K_IPLON, 1, JK) + RAER(JAE, 2) * PAER(K_IPLON, 2, JK)&
+            & + RAER(JAE, 3) * PAER(K_IPLON, 3, JK) + RAER(JAE, 4) * PAER(K_IPLON, 4, JK)&
+            & + RAER(JAE, 5) * PAER(K_IPLON, 5, JK) + RAER(JAE, 6) * PAER(K_IPLON, 6, JK)
+    !       END DO
+    P_TAUAERL(I_L, 10) = ZTAUAER(5)
+    P_TAUAERL(I_L, 11) = ZTAUAER(5)
+    P_TAUAERL(I_L, 12) = ZTAUAER(5)
+    P_TAUAERL(I_L, 13) = ZTAUAER(5)
+    P_TAUAERL(I_L, 14) = ZTAUAER(5)
+    P_TAUAERL(I_L, 15) = ZTAUAER(5)
+    P_TAUAERL(I_L, 16) = ZTAUAER(5)
+  ENDDO
+  !--Use LW AOD from own Mie calculations (C. Kleinschmitt)
+  DO I_L = 1, KLEV
+    JK = KLEV - I_L + 1
+    DO JAE = 1, NLW
+      P_TAUAERL(I_L, JAE) = MAX(PTAU_LW(K_IPLON, JK, JAE), 1e-30)
+    ENDDO
+  ENDDO
+  !--end C. Kleinschmitt
+
+  DO J2 = 1, KLEV
+    DO J1 = 1, JPXSEC
+      P_WX(J1, J2) = 0.0_JPRB
+    ENDDO
+  ENDDO
+
+  DO I_L = 1, KLEV
+    !- Set cross section molecule amounts from ECRT; convert to vmr
+    P_WX(2, I_L) = rcfc11 * Z_AMD / Z_AMC11
+    P_WX(3, I_L) = rcfc12 * Z_AMD / Z_AMC12
+    P_WX(2, I_L) = P_COLDRY(I_L) * P_WX(2, I_L) * 1.E-20_JPRB
+    P_WX(3, I_L) = P_COLDRY(I_L) * P_WX(3, I_L) * 1.E-20_JPRB
+
+    !- Here, all molecules in WKL and WX are in volume mixing ratio; convert to
+    !  molec/cm2 based on COLDRY for use in RRTM
+
+    DO IMOL = 1, I_NMOL
+      P_WKL(IMOL, I_L) = P_COLDRY(I_L) * P_WKL(IMOL, I_L)
+    ENDDO
+
+    ! DO IX = 1,JPXSEC
+    ! IF (IXINDX(IX)  /=  0) THEN
+    !     WX(IXINDX(IX),L) = COLDRY(L) * WX(IX,L) * 1.E-20_JPRB
+    ! ENDIF
+    ! END DO
+
+  ENDDO
+
+  !- Approximate treatment for various cloud overlaps
+  ZCLEAR = 1.0_JPRB
+  ZCLOUD = 0.0_JPRB
+  ZC1J(0) = 0.0_JPRB
+  ZEPSEC = 1.E-03_JPRB
+  JL = K_IPLON
+
+  !++MODIFCODE
+  IF ((NOVLP == 1).OR.(NOVLP ==6).OR.(NOVLP ==8)) THEN
+    !--MODIFCODE
+
+    DO JK = 1, KLEV
+      IF (pcldf(JL, JK) > ZEPSEC) THEN
+        ZCLDLY = pcldf(JL, JK)
+        ZCLEAR = ZCLEAR &
+                & * (1.0_JPRB - MAX(ZCLDLY, ZCLOUD))&
+                & / (1.0_JPRB - MIN(ZCLOUD, 1.0_JPRB - ZEPSEC))
+        ZCLOUD = ZCLDLY
+        ZC1J(JK) = 1.0_JPRB - ZCLEAR
+      ELSE
+        ZCLDLY = 0.0_JPRB
+        ZCLEAR = ZCLEAR &
+                & * (1.0_JPRB - MAX(ZCLDLY, ZCLOUD))&
+                & / (1.0_JPRB - MIN(ZCLOUD, 1.0_JPRB - ZEPSEC))
+        ZCLOUD = ZCLDLY
+        ZC1J(JK) = 1.0_JPRB - ZCLEAR
+      ENDIF
+    ENDDO
+
+    !++MODIFCODE
+  ELSEIF ((NOVLP == 2).OR.(NOVLP ==7)) THEN
+    !--MODIFCODE
+
+    DO JK = 1, KLEV
+      IF (pcldf(JL, JK) > ZEPSEC) THEN
+        ZCLDLY = pcldf(JL, JK)
+        ZCLOUD = MAX(ZCLDLY, ZCLOUD)
+        ZC1J(JK) = ZCLOUD
+      ELSE
+        ZCLDLY = 0.0_JPRB
+        ZCLOUD = MAX(ZCLDLY, ZCLOUD)
+        ZC1J(JK) = ZCLOUD
+      ENDIF
+    ENDDO
+
+    !++MODIFCODE
+  ELSEIF ((NOVLP == 3).OR.(NOVLP ==5)) THEN
+    !--MODIFCODE
+
+    DO JK = 1, KLEV
+      IF (pcldf(JL, JK) > ZEPSEC) THEN
+        ZCLDLY = pcldf(JL, JK)
+        ZCLEAR = ZCLEAR * (1.0_JPRB - ZCLDLY)
+        ZCLOUD = 1.0_JPRB - ZCLEAR
+        ZC1J(JK) = ZCLOUD
+      ELSE
+        ZCLDLY = 0.0_JPRB
+        ZCLEAR = ZCLEAR * (1.0_JPRB - ZCLDLY)
+        ZCLOUD = 1.0_JPRB - ZCLEAR
+        ZC1J(JK) = ZCLOUD
+      ENDIF
+    ENDDO
+
+  ELSEIF (NOVLP == 4) THEN
+
+  ENDIF
+  PTCLEAR = 1.0_JPRB - ZC1J(KLEV)
+
+  ! Transfer cloud fraction and cloud optical depth to RRTM arrays;
+  ! invert array index for pcldf to go from bottom to top for RRTM
+
+  !- clear-sky column
+  IF (PTCLEAR  >  1.0_JPRB - ZEPSEC) THEN
+    KCLD = 0
+    DO I_L = 1, KLEV
+      P_CLDFRAC(I_L) = 0.0_JPRB
+    ENDDO
+    DO JB = 1, JPBAND
+      DO I_L = 1, KLEV
+        P_TAUCLD(I_L, JB) = 0.0_JPRB
+      ENDDO
+    ENDDO
+
+  ELSE
+
+    !- cloudy column
+    !   The diffusivity factor (Savijarvi, 1997) on the cloud optical
+    !   thickness TAUCLD has already been applied in RADLSW
+
+    KCLD = 1
+    DO I_L = 1, KLEV
+      P_CLDFRAC(I_L) = pcldf(K_IPLON, I_L)
+    ENDDO
+    DO JB = 1, JPBAND
+      DO I_L = 1, KLEV
+        P_TAUCLD(I_L, JB) = ptaucld(K_IPLON, I_L, JB)
+      ENDDO
+    ENDDO
+
+  ENDIF
+
+  !     ------------------------------------------------------------------
+
+  IF (LHOOK) CALL DR_HOOK('RRTM_ECRT_140GP', 1, ZHOOK_HANDLE)
 END SUBROUTINE RRTM_ECRT_140GP
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/rrtm_rrtm_140gp.intfb.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/rrtm_rrtm_140gp.intfb.h	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/rrtm_rrtm_140gp.intfb.h	(revision 5154)
@@ -12,7 +12,7 @@
 USE YOERAD   ,ONLY : NLW !--C.Kleinschmitt
 USE PARRRTM , ONLY : JPBAND ,JPXSEC ,JPGPT ,JPLAY ,&
- & JPINPX  
+ & JPINPX
+ USE lmdz_clesphys
 !-NLW in clesphys now OB
-include "clesphys.h"
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/srtm_srtm_224gp.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/srtm_srtm_224gp.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/srtm_srtm_224gp.F90	(revision 5154)
@@ -3,121 +3,118 @@
 !
 SUBROUTINE SRTM_SRTM_224GP &
- & ( KIDIA , KFDIA  , KLON  , KLEV  , KSW , KOVLP ,&
- &   PAER  , PALBD  , PALBP , PAPH  , PAP ,&
- &   PTS   , PTH    , PT    ,&
- &   PQ    , PCCO2  , POZN  , PRMU0 ,&
- &   PFRCL , PTAUC  , PASYC , POMGC ,&
- &   PALBT , PFSUX  , PFSUC &
- & )  
-
-!-- interface to RRTM_SW
-!     JJMorcrette 030225
-
-USE PARKIND1  ,ONLY : JPIM     ,JPRB
-USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
-
-USE PARSRTM  , ONLY : JPLAY
-!USE YOERDI   , ONLY : RCH4   , RN2O   
-USE YOERAD   , ONLY : NAER
-USE YOESRTAER, ONLY : RSRTAUA, RSRPIZA, RSRASYA
-USE YOMPHY3  , ONLY : RII0
-USE YOMCST   , ONLY : RI0 
-
-
-
-IMPLICIT NONE
-
-#include "clesphys.h"
-
-!-- Input arguments
-
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
-INTEGER(KIND=JPIM)               :: KLEV! UNDETERMINED INTENT 
-INTEGER(KIND=JPIM)               :: KSW! UNDETERMINED INTENT 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KOVLP 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAER(KLON,6,KLEV)    ! top to bottom
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBD(KLON,KSW) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBP(KLON,KSW) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPH(KLON,KLEV+1) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAP(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS(KLON) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTH(KLON,KLEV+1) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PT(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PCCO2 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: POZN(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PRMU0(KLON)
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PFRCL(KLON,KLEV)     ! bottom to top
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAUC(KLON,KSW,KLEV) ! bottom to top
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PASYC(KLON,KSW,KLEV) ! bottom to top
-REAL(KIND=JPRB)   ,INTENT(IN)    :: POMGC(KLON,KSW,KLEV) ! bottom to top
-REAL(KIND=JPRB)                  :: PALBT(KLON,KSW) ! Argument NOT used
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSUX(KLON,2,KLEV+1) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSUC(KLON,2,KLEV+1) 
-!INTEGER_M :: KMOL, KCLDATM, KNFLAG, KCEFLAG, KIQFLAG, KSTR  
-
-!-- Output arguments
-
-!-----------------------------------------------------------------------
-
-!-- dummy integers
-
-INTEGER(KIND=JPIM) :: ICLDATM, INFLAG, ICEFLAG, I_LIQFLAG, I_NMOL, I_NSTR
-
-INTEGER(KIND=JPIM) :: IK, IMOL, J1, J2, JAE, JL, JK, JSW
-
-!-- dummy reals
-
-REAL(KIND=JPRB) :: Z_PZ(0:JPLAY)   , Z_TZ(0:JPLAY)   , Z_PAVEL(JPLAY)  , Z_TAVEL(JPLAY)
-REAL(KIND=JPRB) :: Z_COLDRY(JPLAY) , Z_COLMOL(JPLAY) , Z_WKL(35,JPLAY)
-REAL(KIND=JPRB) :: Z_CO2MULT(JPLAY), Z_COLCH4(JPLAY) , Z_COLCO2(JPLAY) , Z_COLH2O(JPLAY)
-REAL(KIND=JPRB) :: Z_COLN2O(JPLAY) , Z_COLO2(JPLAY)  , Z_COLO3(JPLAY)
-REAL(KIND=JPRB) :: Z_FORFAC(JPLAY) , Z_FORFRAC(JPLAY), Z_SELFFAC(JPLAY), Z_SELFFRAC(JPLAY)
-REAL(KIND=JPRB) :: Z_FAC00(JPLAY)  , Z_FAC01(JPLAY)  , Z_FAC10(JPLAY)  , Z_FAC11(JPLAY)
-REAL(KIND=JPRB) :: Z_TBOUND        , Z_ONEMINUS    , ZRMU0 , ZADJI0
-REAL(KIND=JPRB) :: ZALBD(KSW)    , ZALBP(KSW)    , ZFRCL(JPLAY)
-REAL(KIND=JPRB) :: ZTAUC(JPLAY,KSW), ZASYC(JPLAY,KSW), ZOMGC(JPLAY,KSW)
-REAL(KIND=JPRB) :: ZTAUA(JPLAY,KSW), ZASYA(JPLAY,KSW), ZOMGA(JPLAY,KSW)
-
-REAL(KIND=JPRB) :: ZBBCD(JPLAY+1), ZBBCU(JPLAY+1), ZBBFD(JPLAY+1), ZBBFU(JPLAY+1)
-REAL(KIND=JPRB) :: ZUVCD(JPLAY+1), ZUVCU(JPLAY+1), ZUVFD(JPLAY+1), ZUVFU(JPLAY+1)
-REAL(KIND=JPRB) :: ZVSCD(JPLAY+1), ZVSCU(JPLAY+1), ZVSFD(JPLAY+1), ZVSFU(JPLAY+1)
-REAL(KIND=JPRB) :: ZNICD(JPLAY+1), ZNICU(JPLAY+1), ZNIFD(JPLAY+1), ZNIFU(JPLAY+1)
-
-INTEGER(KIND=JPIM) :: I_LAYTROP, I_LAYSWTCH, I_LAYLOW
-INTEGER(KIND=JPIM) :: INDFOR(JPLAY), INDSELF(JPLAY)
-INTEGER(KIND=JPIM) :: JP(JPLAY), JT(JPLAY), JT1(JPLAY)
-
-REAL(KIND=JPRB) :: Z_AMD                  ! Effective molecular weight of dry air (g/mol)
-REAL(KIND=JPRB) :: Z_AMW                  ! Molecular weight of water vapor (g/mol)
-REAL(KIND=JPRB) :: Z_AMCO2                ! Molecular weight of carbon dioxide (g/mol)
-REAL(KIND=JPRB) :: Z_AMO                  ! Molecular weight of ozone (g/mol)
-REAL(KIND=JPRB) :: Z_AMCH4                ! Molecular weight of methane (g/mol)
-REAL(KIND=JPRB) :: Z_AMN2O                ! Molecular weight of nitrous oxide (g/mol)
-REAL(KIND=JPRB) :: Z_AMC11                ! Molecular weight of CFC11 (g/mol) - CFCL3
-REAL(KIND=JPRB) :: Z_AMC12                ! Molecular weight of CFC12 (g/mol) - CF2CL2
-REAL(KIND=JPRB) :: Z_AVGDRO               ! Avogadro's number (molecules/mole)
-REAL(KIND=JPRB) :: Z_GRAVIT               ! Gravitational acceleration (cm/sec2)
-REAL(KIND=JPRB) :: Z_AMM
-
-! Atomic weights for conversion from mass to volume mixing ratios; these
-!  are the same values used in ECRT to assure accurate conversion to vmr
-data Z_AMD   /  28.970_JPRB    /
-data Z_AMW   /  18.0154_JPRB   /
-data Z_AMCO2 /  44.011_JPRB    /
-data Z_AMO   /  47.9982_JPRB   /
-data Z_AMCH4 /  16.043_JPRB    /
-data Z_AMN2O /  44.013_JPRB    /
-data Z_AMC11 / 137.3686_JPRB   /
-data Z_AMC12 / 120.9140_JPRB   /
-data Z_AVGDRO/ 6.02214E23_JPRB /
-data Z_GRAVIT/ 9.80665E02_JPRB /
-
-REAL(KIND=JPRB) :: ZCLEAR, ZCLOUD, ZEPSEC, ZTOTCC
-
-INTEGER(KIND=JPIM) :: IOVLP
-REAL(KIND=JPRB) :: ZHOOK_HANDLE
+        & (KIDIA, KFDIA, KLON, KLEV, KSW, KOVLP, &
+        &   PAER, PALBD, PALBP, PAPH, PAP, &
+        &   PTS, PTH, PT, &
+        &   PQ, PCCO2, POZN, PRMU0, &
+        &   PFRCL, PTAUC, PASYC, POMGC, &
+        &   PALBT, PFSUX, PFSUC &
+        &)
+
+  !-- interface to RRTM_SW
+  !     JJMorcrette 030225
+
+  USE PARKIND1, ONLY: JPIM, JPRB
+  USE YOMHOOK, ONLY: LHOOK, DR_HOOK
+
+  USE PARSRTM, ONLY: JPLAY
+  !USE YOERDI   , ONLY : RCH4   , RN2O
+  USE YOERAD, ONLY: NAER
+  USE YOESRTAER, ONLY: RSRTAUA, RSRPIZA, RSRASYA
+  USE YOMPHY3, ONLY: RII0
+  USE YOMCST, ONLY: RI0
+  USE lmdz_clesphys
+
+  IMPLICIT NONE
+
+  !-- Input arguments
+
+  INTEGER(KIND = JPIM), INTENT(IN) :: KLON
+  INTEGER(KIND = JPIM) :: KLEV! UNDETERMINED INTENT
+  INTEGER(KIND = JPIM) :: KSW! UNDETERMINED INTENT
+  INTEGER(KIND = JPIM), INTENT(IN) :: KIDIA
+  INTEGER(KIND = JPIM), INTENT(IN) :: KFDIA
+  INTEGER(KIND = JPIM), INTENT(IN) :: KOVLP
+  REAL(KIND = JPRB), INTENT(IN) :: PAER(KLON, 6, KLEV)    ! top to bottom
+  REAL(KIND = JPRB), INTENT(IN) :: PALBD(KLON, KSW)
+  REAL(KIND = JPRB), INTENT(IN) :: PALBP(KLON, KSW)
+  REAL(KIND = JPRB), INTENT(IN) :: PAPH(KLON, KLEV + 1)
+  REAL(KIND = JPRB), INTENT(IN) :: PAP(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PTS(KLON)
+  REAL(KIND = JPRB), INTENT(IN) :: PTH(KLON, KLEV + 1)
+  REAL(KIND = JPRB), INTENT(IN) :: PT(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PQ(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PCCO2
+  REAL(KIND = JPRB), INTENT(IN) :: POZN(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PRMU0(KLON)
+  REAL(KIND = JPRB), INTENT(IN) :: PFRCL(KLON, KLEV)     ! bottom to top
+  REAL(KIND = JPRB), INTENT(IN) :: PTAUC(KLON, KSW, KLEV) ! bottom to top
+  REAL(KIND = JPRB), INTENT(IN) :: PASYC(KLON, KSW, KLEV) ! bottom to top
+  REAL(KIND = JPRB), INTENT(IN) :: POMGC(KLON, KSW, KLEV) ! bottom to top
+  REAL(KIND = JPRB) :: PALBT(KLON, KSW) ! Argument NOT used
+  REAL(KIND = JPRB), INTENT(OUT) :: PFSUX(KLON, 2, KLEV + 1)
+  REAL(KIND = JPRB), INTENT(OUT) :: PFSUC(KLON, 2, KLEV + 1)
+  !INTEGER_M :: KMOL, KCLDATM, KNFLAG, KCEFLAG, KIQFLAG, KSTR
+
+  !-- Output arguments
+
+  !-----------------------------------------------------------------------
+
+  !-- dummy integers
+
+  INTEGER(KIND = JPIM) :: ICLDATM, INFLAG, ICEFLAG, I_LIQFLAG, I_NMOL, I_NSTR
+
+  INTEGER(KIND = JPIM) :: IK, IMOL, J1, J2, JAE, JL, JK, JSW
+
+  !-- dummy reals
+
+  REAL(KIND = JPRB) :: Z_PZ(0:JPLAY), Z_TZ(0:JPLAY), Z_PAVEL(JPLAY), Z_TAVEL(JPLAY)
+  REAL(KIND = JPRB) :: Z_COLDRY(JPLAY), Z_COLMOL(JPLAY), Z_WKL(35, JPLAY)
+  REAL(KIND = JPRB) :: Z_CO2MULT(JPLAY), Z_COLCH4(JPLAY), Z_COLCO2(JPLAY), Z_COLH2O(JPLAY)
+  REAL(KIND = JPRB) :: Z_COLN2O(JPLAY), Z_COLO2(JPLAY), Z_COLO3(JPLAY)
+  REAL(KIND = JPRB) :: Z_FORFAC(JPLAY), Z_FORFRAC(JPLAY), Z_SELFFAC(JPLAY), Z_SELFFRAC(JPLAY)
+  REAL(KIND = JPRB) :: Z_FAC00(JPLAY), Z_FAC01(JPLAY), Z_FAC10(JPLAY), Z_FAC11(JPLAY)
+  REAL(KIND = JPRB) :: Z_TBOUND, Z_ONEMINUS, ZRMU0, ZADJI0
+  REAL(KIND = JPRB) :: ZALBD(KSW), ZALBP(KSW), ZFRCL(JPLAY)
+  REAL(KIND = JPRB) :: ZTAUC(JPLAY, KSW), ZASYC(JPLAY, KSW), ZOMGC(JPLAY, KSW)
+  REAL(KIND = JPRB) :: ZTAUA(JPLAY, KSW), ZASYA(JPLAY, KSW), ZOMGA(JPLAY, KSW)
+
+  REAL(KIND = JPRB) :: ZBBCD(JPLAY + 1), ZBBCU(JPLAY + 1), ZBBFD(JPLAY + 1), ZBBFU(JPLAY + 1)
+  REAL(KIND = JPRB) :: ZUVCD(JPLAY + 1), ZUVCU(JPLAY + 1), ZUVFD(JPLAY + 1), ZUVFU(JPLAY + 1)
+  REAL(KIND = JPRB) :: ZVSCD(JPLAY + 1), ZVSCU(JPLAY + 1), ZVSFD(JPLAY + 1), ZVSFU(JPLAY + 1)
+  REAL(KIND = JPRB) :: ZNICD(JPLAY + 1), ZNICU(JPLAY + 1), ZNIFD(JPLAY + 1), ZNIFU(JPLAY + 1)
+
+  INTEGER(KIND = JPIM) :: I_LAYTROP, I_LAYSWTCH, I_LAYLOW
+  INTEGER(KIND = JPIM) :: INDFOR(JPLAY), INDSELF(JPLAY)
+  INTEGER(KIND = JPIM) :: JP(JPLAY), JT(JPLAY), JT1(JPLAY)
+
+  REAL(KIND = JPRB) :: Z_AMD                  ! Effective molecular weight of dry air (g/mol)
+  REAL(KIND = JPRB) :: Z_AMW                  ! Molecular weight of water vapor (g/mol)
+  REAL(KIND = JPRB) :: Z_AMCO2                ! Molecular weight of carbon dioxide (g/mol)
+  REAL(KIND = JPRB) :: Z_AMO                  ! Molecular weight of ozone (g/mol)
+  REAL(KIND = JPRB) :: Z_AMCH4                ! Molecular weight of methane (g/mol)
+  REAL(KIND = JPRB) :: Z_AMN2O                ! Molecular weight of nitrous oxide (g/mol)
+  REAL(KIND = JPRB) :: Z_AMC11                ! Molecular weight of CFC11 (g/mol) - CFCL3
+  REAL(KIND = JPRB) :: Z_AMC12                ! Molecular weight of CFC12 (g/mol) - CF2CL2
+  REAL(KIND = JPRB) :: Z_AVGDRO               ! Avogadro's number (molecules/mole)
+  REAL(KIND = JPRB) :: Z_GRAVIT               ! Gravitational acceleration (cm/sec2)
+  REAL(KIND = JPRB) :: Z_AMM
+
+  ! Atomic weights for conversion from mass to volume mixing ratios; these
+  !  are the same values used in ECRT to assure accurate conversion to vmr
+  data Z_AMD   /  28.970_JPRB    /
+  data Z_AMW   /  18.0154_JPRB   /
+  data Z_AMCO2 /  44.011_JPRB    /
+  data Z_AMO   /  47.9982_JPRB   /
+  data Z_AMCH4 /  16.043_JPRB    /
+  data Z_AMN2O /  44.013_JPRB    /
+  data Z_AMC11 / 137.3686_JPRB   /
+  data Z_AMC12 / 120.9140_JPRB   /
+  data Z_AVGDRO/ 6.02214E23_JPRB /
+  data Z_GRAVIT/ 9.80665E02_JPRB /
+
+  REAL(KIND = JPRB) :: ZCLEAR, ZCLOUD, ZEPSEC, ZTOTCC
+
+  INTEGER(KIND = JPIM) :: IOVLP
+  REAL(KIND = JPRB) :: ZHOOK_HANDLE
 
 
@@ -126,271 +123,271 @@
 
 
-!-----------------------------------------------------------------------
-!-- calculate information needed ny the radiative transfer routine 
-
-IF (LHOOK) CALL DR_HOOK('SRTM_SRTM_224GP',0,ZHOOK_HANDLE)
-ZEPSEC  = 1.E-06_JPRB
-Z_ONEMINUS=1.0_JPRB -  ZEPSEC
-ZADJI0 = RII0 / RI0
-!-- overlap: 1=max-ran, 2=maximum, 3=random
-IOVLP=3
-
-!print *,'Entering srtm_srtm_224gp'
-
-ICLDATM = 1
-INFLAG    = 2
-ICEFLAG    = 3
-I_LIQFLAG = 1
-I_NMOL    = 6
-I_NSTR    = 2
-
-DO JL = KIDIA, KFDIA
-  ZRMU0=PRMU0(JL)
-  IF (ZRMU0 > 0.0_JPRB) THEN
-
-!- coefficients related to the cloud optical properties (original RRTM_SW)
-
-!  print *,'just before SRTM_CLDPROP'
-
-!  DO JK=1,KLEV 
-!    CLDFRAC(JK) = PFRCL (JL,JK)
-!    CLDDAT1(JK) = PSCLA1(JL,JK)
-!    CLDDAT2(JK) = PSCLA2(JL,JK)
-!    CLDDAT3(JK) = PSCLA3(JL,JK)
-!    CLDDAT4(JK) = PSCLA4(JL,JK)
-!    DO JMOM=0,16
-!      CLDDATMOM(JMOM,JK)=PSCLMOM(JL,JMOM,JK)
-!    ENDDO
-!    print 9101,JK,CLDFRAC(JK),CLDDAT1(JK),CLDDAT2(JK),CLDDAT3(JK)&
-!    &,CLDDAT4(JK),(CLDDATMOM(JMOM,JK),JMOM=0,NSTR)
-    9101 format(1x,'srtm_srtm_224gp Cld :',I3,f7.4,7E12.5)
-!  ENDDO
-
-!  CALL SRTM_CLDPROP &
-!    &( KLEV, ICLDATM, INFLAG, ICEFLAG, LIQFLAG, NSTR &
-!    &, CLDFRAC, CLDDAT1, CLDDAT2, CLDDAT3, CLDDAT4, CLDDATMOM &
-!    &, TAUCLDORIG, TAUCLOUD, SSACLOUD, XMOM &
-!    &)
-
-!- coefficients for the temperature and pressure dependence of the 
-! molecular absorption coefficients
-
-    DO J1=1,35
-      DO J2=1,KLEV
-        Z_WKL(J1,J2)=0.0_JPRB 
-      ENDDO
-    ENDDO
-
-    Z_TBOUND=PTS(JL)
-    Z_PZ(0) = paph(JL,klev+1)/100._JPRB
-    Z_TZ(0) = pth (JL,klev+1)
-
-    ZCLEAR=1.0_JPRB
-    ZCLOUD=0.0_JPRB
-    ZTOTCC=0.0_JPRB
-    DO JK = 1, KLEV
-      Z_PAVEL(JK) = pap(JL,KLEV-JK+1) /100._JPRB
-      Z_TAVEL(JK) = pt (JL,KLEV-JK+1)
-      Z_PZ(JK)    = paph(JL,KLEV-JK+1)/100._JPRB
-      Z_TZ(JK)    = pth (JL,KLEV-JK+1)
-      Z_WKL(1,JK) = pq(JL,KLEV-JK+1)  *Z_AMD/Z_AMW
-      Z_WKL(2,JK) = pcco2             *Z_AMD/Z_AMCO2
-      Z_WKL(3,JK) = pozn(JL,KLEV-JK+1)*Z_AMD/Z_AMO
-      Z_WKL(4,JK) = rn2o              *Z_AMD/Z_AMN2O
-      Z_WKL(6,JK) = rch4              *Z_AMD/Z_AMCH4
-      Z_AMM = (1-Z_WKL(1,JK))*Z_AMD + Z_WKL(1,JK)*Z_AMW
-      Z_COLDRY(JK) = (Z_PZ(JK-1)-Z_PZ(JK))*1.E3_JPRB*Z_AVGDRO/(Z_GRAVIT*Z_AMM*(1+Z_WKL(1,JK)))
-!    print 9200,JK,PAVEL(JK),TAVEL(JK),(WKL(JA,JK),JA=1,4),WKL(6,JK),COLDRY(JK)
-      9200 format(1x,'SRTM ',I3,2F7.1,6E13.5)
-
-      IF (KOVLP == 1) THEN
-        ZCLEAR=ZCLEAR*(1.0_JPRB-MAX(PFRCL(JL,JK),ZCLOUD)) &
-         & /(1.0_JPRB-MIN(ZCLOUD,1.0_JPRB-ZEPSEC))  
-        ZCLOUD=PFRCL(JL,JK)
-        ZTOTCC=1.0_JPRB-ZCLEAR
-      ELSEIF (KOVLP == 2) THEN
-        ZCLOUD=MAX(ZCLOUD,PFRCL(JL,JK))
-        ZCLEAR=1.0_JPRB-ZCLOUD
-        ZTOTCC=ZCLOUD
-      ELSEIF (KOVLP == 3) THEN
-        ZCLEAR=ZCLEAR*(1.0_JPRB-PFRCL(JL,JK))
-        ZCLOUD=1.0_JPRB-ZCLEAR
-        ZTOTCC=ZCLOUD
+  !-----------------------------------------------------------------------
+  !-- calculate information needed ny the radiative transfer routine
+
+  IF (LHOOK) CALL DR_HOOK('SRTM_SRTM_224GP', 0, ZHOOK_HANDLE)
+  ZEPSEC = 1.E-06_JPRB
+  Z_ONEMINUS = 1.0_JPRB - ZEPSEC
+  ZADJI0 = RII0 / RI0
+  !-- overlap: 1=max-ran, 2=maximum, 3=random
+  IOVLP = 3
+
+  !print *,'Entering srtm_srtm_224gp'
+
+  ICLDATM = 1
+  INFLAG = 2
+  ICEFLAG = 3
+  I_LIQFLAG = 1
+  I_NMOL = 6
+  I_NSTR = 2
+
+  DO JL = KIDIA, KFDIA
+    ZRMU0 = PRMU0(JL)
+    IF (ZRMU0 > 0.0_JPRB) THEN
+
+      !- coefficients related to the cloud optical properties (original RRTM_SW)
+
+      !  print *,'just before SRTM_CLDPROP'
+
+      !  DO JK=1,KLEV
+      !    CLDFRAC(JK) = PFRCL (JL,JK)
+      !    CLDDAT1(JK) = PSCLA1(JL,JK)
+      !    CLDDAT2(JK) = PSCLA2(JL,JK)
+      !    CLDDAT3(JK) = PSCLA3(JL,JK)
+      !    CLDDAT4(JK) = PSCLA4(JL,JK)
+      !    DO JMOM=0,16
+      !      CLDDATMOM(JMOM,JK)=PSCLMOM(JL,JMOM,JK)
+      !    ENDDO
+      !    print 9101,JK,CLDFRAC(JK),CLDDAT1(JK),CLDDAT2(JK),CLDDAT3(JK)&
+      !    &,CLDDAT4(JK),(CLDDATMOM(JMOM,JK),JMOM=0,NSTR)
+      9101 format(1x, 'srtm_srtm_224gp Cld :', I3, f7.4, 7E12.5)
+      !  ENDDO
+
+      !  CALL SRTM_CLDPROP &
+      !    &( KLEV, ICLDATM, INFLAG, ICEFLAG, LIQFLAG, NSTR &
+      !    &, CLDFRAC, CLDDAT1, CLDDAT2, CLDDAT3, CLDDAT4, CLDDATMOM &
+      !    &, TAUCLDORIG, TAUCLOUD, SSACLOUD, XMOM &
+      !    &)
+
+      !- coefficients for the temperature and pressure dependence of the
+      ! molecular absorption coefficients
+
+      DO J1 = 1, 35
+        DO J2 = 1, KLEV
+          Z_WKL(J1, J2) = 0.0_JPRB
+        ENDDO
+      ENDDO
+
+      Z_TBOUND = PTS(JL)
+      Z_PZ(0) = paph(JL, klev + 1) / 100._JPRB
+      Z_TZ(0) = pth (JL, klev + 1)
+
+      ZCLEAR = 1.0_JPRB
+      ZCLOUD = 0.0_JPRB
+      ZTOTCC = 0.0_JPRB
+      DO JK = 1, KLEV
+        Z_PAVEL(JK) = pap(JL, KLEV - JK + 1) / 100._JPRB
+        Z_TAVEL(JK) = pt (JL, KLEV - JK + 1)
+        Z_PZ(JK) = paph(JL, KLEV - JK + 1) / 100._JPRB
+        Z_TZ(JK) = pth (JL, KLEV - JK + 1)
+        Z_WKL(1, JK) = pq(JL, KLEV - JK + 1) * Z_AMD / Z_AMW
+        Z_WKL(2, JK) = pcco2 * Z_AMD / Z_AMCO2
+        Z_WKL(3, JK) = pozn(JL, KLEV - JK + 1) * Z_AMD / Z_AMO
+        Z_WKL(4, JK) = rn2o * Z_AMD / Z_AMN2O
+        Z_WKL(6, JK) = rch4 * Z_AMD / Z_AMCH4
+        Z_AMM = (1 - Z_WKL(1, JK)) * Z_AMD + Z_WKL(1, JK) * Z_AMW
+        Z_COLDRY(JK) = (Z_PZ(JK - 1) - Z_PZ(JK)) * 1.E3_JPRB * Z_AVGDRO / (Z_GRAVIT * Z_AMM * (1 + Z_WKL(1, JK)))
+        !    print 9200,JK,PAVEL(JK),TAVEL(JK),(WKL(JA,JK),JA=1,4),WKL(6,JK),COLDRY(JK)
+        9200 format(1x, 'SRTM ', I3, 2F7.1, 6E13.5)
+
+        IF (KOVLP == 1) THEN
+          ZCLEAR = ZCLEAR * (1.0_JPRB - MAX(PFRCL(JL, JK), ZCLOUD)) &
+                  & / (1.0_JPRB - MIN(ZCLOUD, 1.0_JPRB - ZEPSEC))
+          ZCLOUD = PFRCL(JL, JK)
+          ZTOTCC = 1.0_JPRB - ZCLEAR
+        ELSEIF (KOVLP == 2) THEN
+          ZCLOUD = MAX(ZCLOUD, PFRCL(JL, JK))
+          ZCLEAR = 1.0_JPRB - ZCLOUD
+          ZTOTCC = ZCLOUD
+        ELSEIF (KOVLP == 3) THEN
+          ZCLEAR = ZCLEAR * (1.0_JPRB - PFRCL(JL, JK))
+          ZCLOUD = 1.0_JPRB - ZCLEAR
+          ZTOTCC = ZCLOUD
+        ENDIF
+
+      ENDDO
+
+      !  print *,'ZTOTCC ZCLEAR : ',ZTOTCC,' ',ZCLEAR
+
+      DO IMOL = 1, I_NMOL
+        DO JK = 1, KLEV
+          Z_WKL(IMOL, JK) = Z_COLDRY(JK) * Z_WKL(IMOL, JK)
+        ENDDO
+      ENDDO
+
+      !    IF (ZTOTCC == 0.0_JPRB) THEN
+      !      DO JK=1,KLEV
+      !        ZFRCL(JK)=0.0_JPRB
+      !      ENDDO
+      !    ELSE
+      !      DO JK=1,KLEV
+      !        ZFRCL(JK)=PFRCL(JL,JK)/ZTOTCC
+      !      ENDDO
+      !    ENDIF
+
+      !  print *,'just before SRTM_SETCOEF'
+
+      ZFRCL(1:KLEV) = PFRCL(JL, 1:KLEV)
+      ZCLEAR = 0._JPRB
+      ZCLOUD = 1._JPRB
+
+      CALL SRTM_SETCOEF &
+              & (KLEV, I_NMOL, &
+              & Z_PAVEL, Z_TAVEL, Z_PZ, Z_TZ, Z_TBOUND, &
+              & Z_COLDRY, Z_WKL, &
+              & I_LAYTROP, I_LAYSWTCH, I_LAYLOW, &
+              & Z_CO2MULT, Z_COLCH4, Z_COLCO2, Z_COLH2O, Z_COLMOL, Z_COLN2O, Z_COLO2, Z_COLO3, &
+              & Z_FORFAC, Z_FORFRAC, INDFOR, Z_SELFFAC, Z_SELFFRAC, INDSELF, &
+              & Z_FAC00, Z_FAC01, Z_FAC10, Z_FAC11, &
+              & JP, JT, JT1     &
+              &)
+
+      !  print *,'just after SRTM_SETCOEF'
+
+      !- call the radiation transfer routine
+
+      DO JSW = 1, KSW
+        ZALBD(JSW) = PALBD(JL, JSW)
+        ZALBP(JSW) = PALBP(JL, JSW)
+        DO JK = 1, KLEV
+          ZTAUC(JK, JSW) = PTAUC(JL, JSW, JK)
+          ZASYC(JK, JSW) = PASYC(JL, JSW, JK)
+          ZOMGC(JK, JSW) = POMGC(JL, JSW, JK)
+          !      print 9002,JSW,JK,ZFRCL(JK),ZTAUC(JK,JSW),ZASYC(JK,JSW),ZOMGC(JK,JSW)
+          9002  format(1x, 'srtm_224gp ClOPropECmodel ', 2I3, f8.4, 3E12.5)
+        ENDDO
+      ENDDO
+
+      !- mixing of aerosols
+
+      !  print *,'Aerosol optical properties computations'
+      !  DO JSW=1,KSW
+      !    print 9012,JSW,(JAE,RSRTAUA(JSW,JAE),RSRPIZA(JSW,JAE),RSRASYA(JSW,JAE),JAE=1,6)
+      9012 format(I3, (/, I3, 3E13.5))
+      !  ENDDO
+
+      !  DO JK=1,KLEV
+      !    print 9013,JK,(PAER(JL,JAE,JK),JAE=1,6)
+      9013 format(1x, I3, 6E12.5)
+      !  ENDDO
+
+      IF (NAER == 0) THEN
+        DO JSW = 1, KSW
+          DO JK = 1, KLEV
+            ZTAUA(JK, JSW) = 0.0_JPRB
+            ZASYA(JK, JSW) = 0.0_JPRB
+            ZOMGA(JK, JSW) = 1.0_JPRB
+          ENDDO
+        ENDDO
+      ELSE
+        DO JSW = 1, KSW
+          DO JK = 1, KLEV
+            IK = KLEV + 1 - JK
+            ZTAUA(JK, JSW) = 0.0_JPRB
+            ZASYA(JK, JSW) = 0.0_JPRB
+            ZOMGA(JK, JSW) = 0.0_JPRB
+            DO JAE = 1, 6
+              ZTAUA(JK, JSW) = ZTAUA(JK, JSW) + RSRTAUA(JSW, JAE) * PAER(JL, JAE, IK)
+              ZOMGA(JK, JSW) = ZOMGA(JK, JSW) + RSRTAUA(JSW, JAE) * PAER(JL, JAE, IK) &
+                      & * RSRPIZA(JSW, JAE)
+              ZASYA(JK, JSW) = ZASYA(JK, JSW) + RSRTAUA(JSW, JAE) * PAER(JL, JAE, IK) &
+                      & * RSRPIZA(JSW, JAE) * RSRASYA(JSW, JAE)
+            ENDDO
+            IF (ZOMGA(JK, JSW) /= 0.0_JPRB) THEN
+              ZASYA(JK, JSW) = ZASYA(JK, JSW) / ZOMGA(JK, JSW)
+            ENDIF
+            IF (ZTAUA(JK, JSW) /= 0.0_JPRB) THEN
+              ZOMGA(JK, JSW) = ZOMGA(JK, JSW) / ZTAUA(JK, JSW)
+            ENDIF
+            !      print 9003,JSW,JK,ZTAUA(JK,JSW),ZOMGA(JK,JSW),ZASYA(JK,JSW)
+            9003  format(1x, 'Aerosols ', 2I3, 3F10.4)
+          ENDDO
+        ENDDO
       ENDIF
 
-    ENDDO
-
-!  print *,'ZTOTCC ZCLEAR : ',ZTOTCC,' ',ZCLEAR
-
-    DO IMOL=1,I_NMOL
-      DO JK=1,KLEV
-        Z_WKL(IMOL,JK)=Z_COLDRY(JK)* Z_WKL(IMOL,JK)
-      ENDDO
-    ENDDO
-
-!    IF (ZTOTCC == 0.0_JPRB) THEN
-!      DO JK=1,KLEV
-!        ZFRCL(JK)=0.0_JPRB   
-!      ENDDO
-!    ELSE
-!      DO JK=1,KLEV
-!        ZFRCL(JK)=PFRCL(JL,JK)/ZTOTCC
-!      ENDDO
-!    ENDIF
-
-!  print *,'just before SRTM_SETCOEF'
-
-    ZFRCL(1:KLEV)=PFRCL(JL,1:KLEV)
-    ZCLEAR=0._JPRB
-    ZCLOUD=1._JPRB
-
-    CALL SRTM_SETCOEF &
-     & ( KLEV   , I_NMOL,&
-     & Z_PAVEL  , Z_TAVEL   , Z_PZ     , Z_TZ     , Z_TBOUND,&
-     & Z_COLDRY , Z_WKL,&
-     & I_LAYTROP, I_LAYSWTCH, I_LAYLOW,&
-     & Z_CO2MULT, Z_COLCH4  , Z_COLCO2 , Z_COLH2O , Z_COLMOL  , Z_COLN2O  , Z_COLO2 , Z_COLO3,&
-     & Z_FORFAC , Z_FORFRAC , INDFOR , Z_SELFFAC, Z_SELFFRAC, INDSELF,&
-     & Z_FAC00  , Z_FAC01   , Z_FAC10  , Z_FAC11,&
-     & JP     , JT      , JT1     &
-     & )  
-  
-!  print *,'just after SRTM_SETCOEF'
-
-!- call the radiation transfer routine
-  
-    DO JSW=1,KSW
-      ZALBD(JSW)=PALBD(JL,JSW)
-      ZALBP(JSW)=PALBP(JL,JSW)
-      DO JK=1,KLEV
-        ZTAUC(JK,JSW) = PTAUC(JL,JSW,JK)
-        ZASYC(JK,JSW) = PASYC(JL,JSW,JK)
-        ZOMGC(JK,JSW) = POMGC(JL,JSW,JK)
-!      print 9002,JSW,JK,ZFRCL(JK),ZTAUC(JK,JSW),ZASYC(JK,JSW),ZOMGC(JK,JSW)
-        9002  format(1x,'srtm_224gp ClOPropECmodel ',2I3,f8.4,3E12.5)
-      ENDDO
-    ENDDO
-
-!- mixing of aerosols
- 
-!  print *,'Aerosol optical properties computations'
-!  DO JSW=1,KSW
-!    print 9012,JSW,(JAE,RSRTAUA(JSW,JAE),RSRPIZA(JSW,JAE),RSRASYA(JSW,JAE),JAE=1,6)
-    9012 format(I3,(/,I3,3E13.5))
-!  ENDDO
-
-!  DO JK=1,KLEV
-!    print 9013,JK,(PAER(JL,JAE,JK),JAE=1,6)
-    9013 format(1x,I3,6E12.5)
-!  ENDDO
-
-    IF (NAER == 0) THEN
-      DO JSW=1,KSW
-        DO JK=1,KLEV
-          ZTAUA(JK,JSW)= 0.0_JPRB
-          ZASYA(JK,JSW)= 0.0_JPRB
-          ZOMGA(JK,JSW)= 1.0_JPRB
-        ENDDO
-      ENDDO
+      DO JK = 1, KLEV + 1
+        ZBBCU(JK) = 0.0_JPRB
+        ZBBCD(JK) = 0.0_JPRB
+        ZBBFU(JK) = 0.0_JPRB
+        ZBBFD(JK) = 0.0_JPRB
+        ZUVCU(JK) = 0.0_JPRB
+        ZUVCD(JK) = 0.0_JPRB
+        ZUVFU(JK) = 0.0_JPRB
+        ZUVFD(JK) = 0.0_JPRB
+        ZVSCU(JK) = 0.0_JPRB
+        ZVSCD(JK) = 0.0_JPRB
+        ZVSFU(JK) = 0.0_JPRB
+        ZVSFD(JK) = 0.0_JPRB
+        ZNICU(JK) = 0.0_JPRB
+        ZNICD(JK) = 0.0_JPRB
+        ZNIFU(JK) = 0.0_JPRB
+        ZNIFD(JK) = 0.0_JPRB
+      ENDDO
+
+      !  print *,'just before calling STRM_SPCVRT for JL=',JL,' and ZRMU0=',ZRMU0
+
+      CALL SRTM_SPCVRT &
+              & (KLEV, I_NMOL, KSW, Z_ONEMINUS, &
+              & Z_PAVEL, Z_TAVEL, Z_PZ, Z_TZ, Z_TBOUND, ZALBD, ZALBP, &
+              & ZFRCL, ZTAUC, ZASYC, ZOMGC, ZTAUA, ZASYA, ZOMGA, ZRMU0, &
+              & Z_COLDRY, Z_WKL, &
+              & I_LAYTROP, I_LAYSWTCH, I_LAYLOW, &
+              & Z_CO2MULT, Z_COLCH4, Z_COLCO2, Z_COLH2O, Z_COLMOL, Z_COLN2O, Z_COLO2, Z_COLO3, &
+              & Z_FORFAC, Z_FORFRAC, INDFOR, Z_SELFFAC, Z_SELFFRAC, INDSELF, &
+              & Z_FAC00, Z_FAC01, Z_FAC10, Z_FAC11, &
+              & JP, JT, JT1, &
+              & ZBBFD, ZBBFU, ZUVFD, ZUVFU, ZVSFD, ZVSFU, ZNIFD, ZNIFU, &
+              & ZBBCD, ZBBCU, ZUVCD, ZUVCU, ZVSCD, ZVSCU, ZNICD, ZNICU &
+              &)
+
+      !  print *,'SRTM_SRTM_224GP before potential scaling'
+      !    IF (IOVLP == 3) THEN
+      !      DO JK=1,KLEV+1
+      !!      print 9004,JK,ZBBCU(JK),ZBBCD(JK),ZBBFU(JK),ZBBFD(JK)
+      9004 format(1x, 'Clear-sky and total fluxes U & D ', I3, 4F10.3)
+      !        PFSUC(JL,1,JK)=ZBBCU(JK)
+      !        PFSUC(JL,2,JK)=ZBBCD(JK)
+      !        PFSUX(JL,1,JK)=ZBBFU(JK)
+      !        PFSUX(JL,2,JK)=ZBBFD(JK)
+      !      ENDDO
+      !    ELSE
+      !    print *,'SRTM_SRTM_224GP after potential scaling'
+      DO JK = 1, KLEV + 1
+        PFSUC(JL, 1, JK) = ZADJI0 * ZBBCU(JK)
+        PFSUC(JL, 2, JK) = ZADJI0 * ZBBCD(JK)
+        PFSUX(JL, 1, JK) = ZADJI0 * ((1.0_JPRB - ZCLEAR) * ZBBFU(JK) + ZCLEAR * ZBBCU(JK))
+        PFSUX(JL, 2, JK) = ZADJI0 * ((1.0_JPRB - ZCLEAR) * ZBBFD(JK) + ZCLEAR * ZBBCD(JK))
+      ENDDO
+      !    ENDIF
+
+      !  DO JK=1,KLEV+1
+      !    print 9005,JK,PFSUC(JL,1,JK),PFSUC(JL,2,JK),PFSUX(JL,1,JK),PFSUX(JL,2,JK)
+      9005 format(1x, 'Clear-sky and total fluxes U & D ', I3, 4F10.3)
+      !  ENDDO
+
     ELSE
-      DO JSW=1,KSW
-        DO JK=1,KLEV
-          IK=KLEV+1-JK
-          ZTAUA(JK,JSW)=0.0_JPRB
-          ZASYA(JK,JSW)=0.0_JPRB
-          ZOMGA(JK,JSW)=0.0_JPRB
-          DO JAE=1,6
-            ZTAUA(JK,JSW)=ZTAUA(JK,JSW)+RSRTAUA(JSW,JAE)*PAER(JL,JAE,IK)
-            ZOMGA(JK,JSW)=ZOMGA(JK,JSW)+RSRTAUA(JSW,JAE)*PAER(JL,JAE,IK) &
-             & *RSRPIZA(JSW,JAE)  
-            ZASYA(JK,JSW)=ZASYA(JK,JSW)+RSRTAUA(JSW,JAE)*PAER(JL,JAE,IK) &
-             & *RSRPIZA(JSW,JAE)*RSRASYA(JSW,JAE)  
-          ENDDO
-          IF (ZOMGA(JK,JSW) /= 0.0_JPRB) THEN
-            ZASYA(JK,JSW)=ZASYA(JK,JSW)/ZOMGA(JK,JSW)
-          ENDIF
-          IF (ZTAUA(JK,JSW) /= 0.0_JPRB) THEN
-            ZOMGA(JK,JSW)=ZOMGA(JK,JSW)/ZTAUA(JK,JSW)
-          ENDIF
-!      print 9003,JSW,JK,ZTAUA(JK,JSW),ZOMGA(JK,JSW),ZASYA(JK,JSW)
-9003  format(1x,'Aerosols ',2I3,3F10.4)
-        ENDDO
+      DO JK = 1, KLEV + 1
+        PFSUC(JL, 1, JK) = 0.0_JPRB
+        PFSUC(JL, 2, JK) = 0.0_JPRB
+        PFSUX(JL, 1, JK) = 0.0_JPRB
+        PFSUX(JL, 2, JK) = 0.0_JPRB
       ENDDO
     ENDIF
-
-    DO JK=1,KLEV+1
-      ZBBCU(JK)=0.0_JPRB
-      ZBBCD(JK)=0.0_JPRB
-      ZBBFU(JK)=0.0_JPRB
-      ZBBFD(JK)=0.0_JPRB
-      ZUVCU(JK)=0.0_JPRB
-      ZUVCD(JK)=0.0_JPRB
-      ZUVFU(JK)=0.0_JPRB
-      ZUVFD(JK)=0.0_JPRB
-      ZVSCU(JK)=0.0_JPRB
-      ZVSCD(JK)=0.0_JPRB
-      ZVSFU(JK)=0.0_JPRB
-      ZVSFD(JK)=0.0_JPRB
-      ZNICU(JK)=0.0_JPRB
-      ZNICD(JK)=0.0_JPRB
-      ZNIFU(JK)=0.0_JPRB
-      ZNIFD(JK)=0.0_JPRB
-    ENDDO
-
-!  print *,'just before calling STRM_SPCVRT for JL=',JL,' and ZRMU0=',ZRMU0
-
-    CALL SRTM_SPCVRT &
-     & ( KLEV   , I_NMOL    , KSW    , Z_ONEMINUS,&
-     & Z_PAVEL  , Z_TAVEL   , Z_PZ     , Z_TZ     , Z_TBOUND  , ZALBD   , ZALBP,&
-     & ZFRCL  , ZTAUC   , ZASYC  , ZOMGC  , ZTAUA   , ZASYA   , ZOMGA , ZRMU0,&
-     & Z_COLDRY , Z_WKL,&
-     & I_LAYTROP, I_LAYSWTCH, I_LAYLOW,&
-     & Z_CO2MULT, Z_COLCH4  , Z_COLCO2 , Z_COLH2O , Z_COLMOL  , Z_COLN2O  , Z_COLO2 , Z_COLO3,&
-     & Z_FORFAC , Z_FORFRAC , INDFOR , Z_SELFFAC, Z_SELFFRAC, INDSELF,&
-     & Z_FAC00  , Z_FAC01   , Z_FAC10  , Z_FAC11,&
-     & JP     , JT      , JT1,&
-     & ZBBFD  , ZBBFU   , ZUVFD  , ZUVFU  , ZVSFD   , ZVSFU   , ZNIFD , ZNIFU,&
-     & ZBBCD  , ZBBCU   , ZUVCD  , ZUVCU  , ZVSCD   , ZVSCU   , ZNICD , ZNICU &
-     & )  
-
-!  print *,'SRTM_SRTM_224GP before potential scaling'
-!    IF (IOVLP == 3) THEN
-!      DO JK=1,KLEV+1
-!!      print 9004,JK,ZBBCU(JK),ZBBCD(JK),ZBBFU(JK),ZBBFD(JK)
-        9004 format(1x,'Clear-sky and total fluxes U & D ',I3,4F10.3)
-!        PFSUC(JL,1,JK)=ZBBCU(JK)
-!        PFSUC(JL,2,JK)=ZBBCD(JK)
-!        PFSUX(JL,1,JK)=ZBBFU(JK)
-!        PFSUX(JL,2,JK)=ZBBFD(JK)
-!      ENDDO
-!    ELSE
-!    print *,'SRTM_SRTM_224GP after potential scaling'
-      DO JK=1,KLEV+1
-        PFSUC(JL,1,JK)=ZADJI0 * ZBBCU(JK)
-        PFSUC(JL,2,JK)=ZADJI0 * ZBBCD(JK)
-        PFSUX(JL,1,JK)=ZADJI0 * ( (1.0_JPRB-ZCLEAR)*ZBBFU(JK)+ZCLEAR*ZBBCU(JK) )
-        PFSUX(JL,2,JK)=ZADJI0 * ( (1.0_JPRB-ZCLEAR)*ZBBFD(JK)+ZCLEAR*ZBBCD(JK) )
-      ENDDO
-!    ENDIF
-
-!  DO JK=1,KLEV+1
-!    print 9005,JK,PFSUC(JL,1,JK),PFSUC(JL,2,JK),PFSUX(JL,1,JK),PFSUX(JL,2,JK)
-    9005 format(1x,'Clear-sky and total fluxes U & D ',I3,4F10.3)
-!  ENDDO
-  
-  ELSE
-    DO JK=1,KLEV+1
-      PFSUC(JL,1,JK)=0.0_JPRB
-      PFSUC(JL,2,JK)=0.0_JPRB
-      PFSUX(JL,1,JK)=0.0_JPRB
-      PFSUX(JL,2,JK)=0.0_JPRB
-    ENDDO
-  ENDIF
-ENDDO
-
-!PRINT *,'OUT OF SRTM_224GP'
-
-!-----------------------------------------------------------------------
-IF (LHOOK) CALL DR_HOOK('SRTM_SRTM_224GP',1,ZHOOK_HANDLE)
+  ENDDO
+
+  !PRINT *,'OUT OF SRTM_224GP'
+
+  !-----------------------------------------------------------------------
+  IF (LHOOK) CALL DR_HOOK('SRTM_SRTM_224GP', 1, ZHOOK_HANDLE)
 END SUBROUTINE SRTM_SRTM_224GP
 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/srtm_srtm_224gp_mcica.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/srtm_srtm_224gp_mcica.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/srtm_srtm_224gp_mcica.F90	(revision 5154)
@@ -1,397 +1,393 @@
 SUBROUTINE SRTM_SRTM_224GP_MCICA &
- & ( KIDIA , KFDIA  , KLON  , KLEV  , KSW , KCOLS , KCLDLY ,&
- &   PAER  , PALBD  , PALBP , PAPH  , PAP , &
- &   PTS   , PTH    , PT    ,&
- &   PQ    , PCCO2  , POZN  , PRMU0 ,&
- &   PFRCL , PTAUC  , PASYC , POMGC ,&
- &   PFSUX , PFSUC &
- & )  
-
-!-- interface to RRTM_SW
-!     JJMorcrette 030225
-!     JJMorcrette 20050110  McICA version
-
-USE PARKIND1  ,ONLY : JPIM     ,JPRB
-USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
-
-USE PARSRTM  , ONLY : JPLAY
-!MPL/IM 20160915 on prend GES de phylmd USE YOERDI   , ONLY : RCH4   , RN2O   
-USE YOERAD   , ONLY : NAER
-USE YOESRTAER, ONLY : RSRTAUA, RSRPIZA, RSRASYA
-USE YOMPHY3  , ONLY : RII0
-USE YOMCST   , ONLY : RI0 
-
-IMPLICIT NONE
-
-!-- Input arguments
-
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV
-INTEGER(KIND=JPIM),INTENT(IN)    :: KSW  
-INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KCOLS
-INTEGER(KIND=JPIM),INTENT(IN)    :: KCLDLY(KCOLS) 
-
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAER(KLON,6,KLEV)    ! top to bottom
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBD(KLON,KSW) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PALBP(KLON,KSW) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPH(KLON,KLEV+1) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PAP(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS(KLON) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTH(KLON,KLEV+1) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PT(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PCCO2 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: POZN(KLON,KLEV) 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PRMU0(KLON)
-
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PFRCL(KLON,KCOLS,KLEV) ! bottom to top
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAUC(KLON,KCOLS,KLEV) ! bottom to top
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PASYC(KLON,KCOLS,KLEV) ! bottom to top
-REAL(KIND=JPRB)   ,INTENT(IN)    :: POMGC(KLON,KCOLS,KLEV) ! bottom to top
-
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSUX(KLON,2,KLEV+1) 
-REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFSUC(KLON,2,KLEV+1) 
-
-!-- Output arguments
-
-!-----------------------------------------------------------------------
-
-!-- dummy integers
-
-INTEGER(KIND=JPIM) :: ICLDATM, INFLAG, ICEFLAG, I_LIQFLAG, ITMOL, I_NSTR
-
-INTEGER(KIND=JPIM) :: IK, IMOL, J1, J2, JAE, JL, JK, JSW
-
-!-- dummy reals
-
-REAL(KIND=JPRB) :: ZPZ(0:JPLAY)   , ZTZ(0:JPLAY)   , ZPAVEL(JPLAY)  , ZTAVEL(JPLAY)
-REAL(KIND=JPRB) :: ZCOLDRY(JPLAY) , ZCOLMOL(JPLAY) , ZWKL(35,JPLAY)
-REAL(KIND=JPRB) :: ZCO2MULT(JPLAY), ZCOLCH4(JPLAY) , ZCOLCO2(JPLAY) , ZCOLH2O(JPLAY)
-REAL(KIND=JPRB) :: ZCOLN2O(JPLAY) , ZCOLO2(JPLAY)  , ZCOLO3(JPLAY)
-REAL(KIND=JPRB) :: ZFORFAC(JPLAY) , ZFORFRAC(JPLAY), ZSELFFAC(JPLAY), ZSELFFRAC(JPLAY)
-REAL(KIND=JPRB) :: ZFAC00(JPLAY)  , ZFAC01(JPLAY)  , ZFAC10(JPLAY)  , ZFAC11(JPLAY)
-REAL(KIND=JPRB) :: ZTBOUND        , ZONEMINUS    , ZRMU0 , ZADJI0
-REAL(KIND=JPRB) :: ZALBD(KSW)    , ZALBP(KSW)    
-
-REAL(KIND=JPRB) :: ZFRCL(KCOLS,JPLAY), ZTAUC(JPLAY,KCOLS), ZASYC(JPLAY,KCOLS), ZOMGC(JPLAY,KCOLS)
-REAL(KIND=JPRB) :: ZTAUA(JPLAY,KSW), ZASYA(JPLAY,KSW), ZOMGA(JPLAY,KSW)
-
-REAL(KIND=JPRB) :: ZBBCD(JPLAY+1), ZBBCU(JPLAY+1), ZBBFD(JPLAY+1), ZBBFU(JPLAY+1)
-!REAL(KIND=JPRB) :: ZUVCD(JPLAY+1), ZUVCU(JPLAY+1), ZUVFD(JPLAY+1), ZUVFU(JPLAY+1)
-!REAL(KIND=JPRB) :: ZVSCD(JPLAY+1), ZVSCU(JPLAY+1), ZVSFD(JPLAY+1), ZVSFU(JPLAY+1)
-!REAL(KIND=JPRB) :: ZNICD(JPLAY+1), ZNICU(JPLAY+1), ZNIFD(JPLAY+1), ZNIFU(JPLAY+1)
-
-INTEGER(KIND=JPIM) :: ILAYTROP, ILAYSWTCH, ILAYLOW
-INTEGER(KIND=JPIM) :: INDFOR(JPLAY), INDSELF(JPLAY)
-INTEGER(KIND=JPIM) :: JP(JPLAY), JT(JPLAY), JT1(JPLAY)
-
-REAL(KIND=JPRB) :: ZAMD                  ! Effective molecular weight of dry air (g/mol)
-REAL(KIND=JPRB) :: ZAMW                  ! Molecular weight of water vapor (g/mol)
-REAL(KIND=JPRB) :: ZAMCO2                ! Molecular weight of carbon dioxide (g/mol)
-REAL(KIND=JPRB) :: ZAMO                  ! Molecular weight of ozone (g/mol)
-REAL(KIND=JPRB) :: ZAMCH4                ! Molecular weight of methane (g/mol)
-REAL(KIND=JPRB) :: ZAMN2O                ! Molecular weight of nitrous oxide (g/mol)
-REAL(KIND=JPRB) :: ZAMC11                ! Molecular weight of CFC11 (g/mol) - CFCL3
-REAL(KIND=JPRB) :: ZAMC12                ! Molecular weight of CFC12 (g/mol) - CF2CL2
-REAL(KIND=JPRB) :: ZAVGDRO               ! Avogadro's number (molecules/mole)
-REAL(KIND=JPRB) :: ZGRAVIT               ! Gravitational acceleration (cm/sec2)
-REAL(KIND=JPRB) :: ZAMM
-
-REAL(KIND=JPRB) :: RAMW                  ! Molecular weight of water vapor (g/mol)
-REAL(KIND=JPRB) :: RAMCO2                ! Molecular weight of carbon dioxide (g/mol)
-REAL(KIND=JPRB) :: RAMO                  ! Molecular weight of ozone (g/mol)
-REAL(KIND=JPRB) :: RAMCH4                ! Molecular weight of methane (g/mol)
-REAL(KIND=JPRB) :: RAMN2O                ! Molecular weight of nitrous oxide (g/mol)
-
-! Atomic weights for conversion from mass to volume mixing ratios; these
-!  are the same values used in ECRT to assure accurate conversion to vmr
-data ZAMD   /  28.970_JPRB    /
-data ZAMW   /  18.0154_JPRB   /
-data ZAMCO2 /  44.011_JPRB    /
-data ZAMO   /  47.9982_JPRB   /
-data ZAMCH4 /  16.043_JPRB    /
-data ZAMN2O /  44.013_JPRB    /
-data ZAMC11 / 137.3686_JPRB   /
-data ZAMC12 / 120.9140_JPRB   /
-data ZAVGDRO/ 6.02214E23_JPRB /
-data ZGRAVIT/ 9.80665E02_JPRB /
-data RAMW   /  0.05550_JPRB   /
-data RAMCO2 /  0.02272_JPRB   /
-data RAMO   /  0.02083_JPRB   /
-data RAMCH4 /  0.06233_JPRB    /
-data RAMN2O /  0.02272_JPRB    /
-
-
-REAL(KIND=JPRB) :: ZCLEAR, ZCLOUD, ZEPSEC, ZTOTCC
-
-INTEGER(KIND=JPIM) :: IOVLP
-REAL(KIND=JPRB) :: ZHOOK_HANDLE
+        & (KIDIA, KFDIA, KLON, KLEV, KSW, KCOLS, KCLDLY, &
+        &   PAER, PALBD, PALBP, PAPH, PAP, &
+        &   PTS, PTH, PT, &
+        &   PQ, PCCO2, POZN, PRMU0, &
+        &   PFRCL, PTAUC, PASYC, POMGC, &
+        &   PFSUX, PFSUC &
+        &)
+
+  !-- interface to RRTM_SW
+  !     JJMorcrette 030225
+  !     JJMorcrette 20050110  McICA version
+
+  USE PARKIND1, ONLY: JPIM, JPRB
+  USE YOMHOOK, ONLY: LHOOK, DR_HOOK
+
+  USE PARSRTM, ONLY: JPLAY
+  !MPL/IM 20160915 on prend GES de phylmd USE YOERDI   , ONLY : RCH4   , RN2O
+  USE YOERAD, ONLY: NAER
+  USE YOESRTAER, ONLY: RSRTAUA, RSRPIZA, RSRASYA
+  USE YOMPHY3, ONLY: RII0
+  USE YOMCST, ONLY: RI0
+  USE lmdz_clesphys
+
+  IMPLICIT NONE
+
+  !-- Input arguments
+
+  INTEGER(KIND = JPIM), INTENT(IN) :: KLON
+  INTEGER(KIND = JPIM), INTENT(IN) :: KLEV
+  INTEGER(KIND = JPIM), INTENT(IN) :: KSW
+  INTEGER(KIND = JPIM), INTENT(IN) :: KIDIA
+  INTEGER(KIND = JPIM), INTENT(IN) :: KFDIA
+  INTEGER(KIND = JPIM), INTENT(IN) :: KCOLS
+  INTEGER(KIND = JPIM), INTENT(IN) :: KCLDLY(KCOLS)
+
+  REAL(KIND = JPRB), INTENT(IN) :: PAER(KLON, 6, KLEV)    ! top to bottom
+  REAL(KIND = JPRB), INTENT(IN) :: PALBD(KLON, KSW)
+  REAL(KIND = JPRB), INTENT(IN) :: PALBP(KLON, KSW)
+  REAL(KIND = JPRB), INTENT(IN) :: PAPH(KLON, KLEV + 1)
+  REAL(KIND = JPRB), INTENT(IN) :: PAP(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PTS(KLON)
+  REAL(KIND = JPRB), INTENT(IN) :: PTH(KLON, KLEV + 1)
+  REAL(KIND = JPRB), INTENT(IN) :: PT(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PQ(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PCCO2
+  REAL(KIND = JPRB), INTENT(IN) :: POZN(KLON, KLEV)
+  REAL(KIND = JPRB), INTENT(IN) :: PRMU0(KLON)
+
+  REAL(KIND = JPRB), INTENT(IN) :: PFRCL(KLON, KCOLS, KLEV) ! bottom to top
+  REAL(KIND = JPRB), INTENT(IN) :: PTAUC(KLON, KCOLS, KLEV) ! bottom to top
+  REAL(KIND = JPRB), INTENT(IN) :: PASYC(KLON, KCOLS, KLEV) ! bottom to top
+  REAL(KIND = JPRB), INTENT(IN) :: POMGC(KLON, KCOLS, KLEV) ! bottom to top
+
+  REAL(KIND = JPRB), INTENT(OUT) :: PFSUX(KLON, 2, KLEV + 1)
+  REAL(KIND = JPRB), INTENT(OUT) :: PFSUC(KLON, 2, KLEV + 1)
+
+  !-- Output arguments
+
+  !-----------------------------------------------------------------------
+
+  !-- dummy integers
+
+  INTEGER(KIND = JPIM) :: ICLDATM, INFLAG, ICEFLAG, I_LIQFLAG, ITMOL, I_NSTR
+
+  INTEGER(KIND = JPIM) :: IK, IMOL, J1, J2, JAE, JL, JK, JSW
+
+  !-- dummy reals
+
+  REAL(KIND = JPRB) :: ZPZ(0:JPLAY), ZTZ(0:JPLAY), ZPAVEL(JPLAY), ZTAVEL(JPLAY)
+  REAL(KIND = JPRB) :: ZCOLDRY(JPLAY), ZCOLMOL(JPLAY), ZWKL(35, JPLAY)
+  REAL(KIND = JPRB) :: ZCO2MULT(JPLAY), ZCOLCH4(JPLAY), ZCOLCO2(JPLAY), ZCOLH2O(JPLAY)
+  REAL(KIND = JPRB) :: ZCOLN2O(JPLAY), ZCOLO2(JPLAY), ZCOLO3(JPLAY)
+  REAL(KIND = JPRB) :: ZFORFAC(JPLAY), ZFORFRAC(JPLAY), ZSELFFAC(JPLAY), ZSELFFRAC(JPLAY)
+  REAL(KIND = JPRB) :: ZFAC00(JPLAY), ZFAC01(JPLAY), ZFAC10(JPLAY), ZFAC11(JPLAY)
+  REAL(KIND = JPRB) :: ZTBOUND, ZONEMINUS, ZRMU0, ZADJI0
+  REAL(KIND = JPRB) :: ZALBD(KSW), ZALBP(KSW)
+
+  REAL(KIND = JPRB) :: ZFRCL(KCOLS, JPLAY), ZTAUC(JPLAY, KCOLS), ZASYC(JPLAY, KCOLS), ZOMGC(JPLAY, KCOLS)
+  REAL(KIND = JPRB) :: ZTAUA(JPLAY, KSW), ZASYA(JPLAY, KSW), ZOMGA(JPLAY, KSW)
+
+  REAL(KIND = JPRB) :: ZBBCD(JPLAY + 1), ZBBCU(JPLAY + 1), ZBBFD(JPLAY + 1), ZBBFU(JPLAY + 1)
+  !REAL(KIND=JPRB) :: ZUVCD(JPLAY+1), ZUVCU(JPLAY+1), ZUVFD(JPLAY+1), ZUVFU(JPLAY+1)
+  !REAL(KIND=JPRB) :: ZVSCD(JPLAY+1), ZVSCU(JPLAY+1), ZVSFD(JPLAY+1), ZVSFU(JPLAY+1)
+  !REAL(KIND=JPRB) :: ZNICD(JPLAY+1), ZNICU(JPLAY+1), ZNIFD(JPLAY+1), ZNIFU(JPLAY+1)
+
+  INTEGER(KIND = JPIM) :: ILAYTROP, ILAYSWTCH, ILAYLOW
+  INTEGER(KIND = JPIM) :: INDFOR(JPLAY), INDSELF(JPLAY)
+  INTEGER(KIND = JPIM) :: JP(JPLAY), JT(JPLAY), JT1(JPLAY)
+
+  REAL(KIND = JPRB) :: ZAMD                  ! Effective molecular weight of dry air (g/mol)
+  REAL(KIND = JPRB) :: ZAMW                  ! Molecular weight of water vapor (g/mol)
+  REAL(KIND = JPRB) :: ZAMCO2                ! Molecular weight of carbon dioxide (g/mol)
+  REAL(KIND = JPRB) :: ZAMO                  ! Molecular weight of ozone (g/mol)
+  REAL(KIND = JPRB) :: ZAMCH4                ! Molecular weight of methane (g/mol)
+  REAL(KIND = JPRB) :: ZAMN2O                ! Molecular weight of nitrous oxide (g/mol)
+  REAL(KIND = JPRB) :: ZAMC11                ! Molecular weight of CFC11 (g/mol) - CFCL3
+  REAL(KIND = JPRB) :: ZAMC12                ! Molecular weight of CFC12 (g/mol) - CF2CL2
+  REAL(KIND = JPRB) :: ZAVGDRO               ! Avogadro's number (molecules/mole)
+  REAL(KIND = JPRB) :: ZGRAVIT               ! Gravitational acceleration (cm/sec2)
+  REAL(KIND = JPRB) :: ZAMM
+
+  REAL(KIND = JPRB) :: RAMW                  ! Molecular weight of water vapor (g/mol)
+  REAL(KIND = JPRB) :: RAMCO2                ! Molecular weight of carbon dioxide (g/mol)
+  REAL(KIND = JPRB) :: RAMO                  ! Molecular weight of ozone (g/mol)
+  REAL(KIND = JPRB) :: RAMCH4                ! Molecular weight of methane (g/mol)
+  REAL(KIND = JPRB) :: RAMN2O                ! Molecular weight of nitrous oxide (g/mol)
+
+  ! Atomic weights for conversion from mass to volume mixing ratios; these
+  !  are the same values used in ECRT to assure accurate conversion to vmr
+  data ZAMD   /  28.970_JPRB    /
+  data ZAMW   /  18.0154_JPRB   /
+  data ZAMCO2 /  44.011_JPRB    /
+  data ZAMO   /  47.9982_JPRB   /
+  data ZAMCH4 /  16.043_JPRB    /
+  data ZAMN2O /  44.013_JPRB    /
+  data ZAMC11 / 137.3686_JPRB   /
+  data ZAMC12 / 120.9140_JPRB   /
+  data ZAVGDRO/ 6.02214E23_JPRB /
+  data ZGRAVIT/ 9.80665E02_JPRB /
+  data RAMW   /  0.05550_JPRB   /
+  data RAMCO2 /  0.02272_JPRB   /
+  data RAMO   /  0.02083_JPRB   /
+  data RAMCH4 /  0.06233_JPRB    /
+  data RAMN2O /  0.02272_JPRB    /
+
+  REAL(KIND = JPRB) :: ZCLEAR, ZCLOUD, ZEPSEC, ZTOTCC
+
+  INTEGER(KIND = JPIM) :: IOVLP
+  REAL(KIND = JPRB) :: ZHOOK_HANDLE
 
 
 #include "srtm_setcoef.intfb.h"
 #include "srtm_spcvrt_mcica.intfb.h"
-!MPL/IM 20160915 on prend GES de phylmd
-#include "clesphys.h"
-
-!-----------------------------------------------------------------------
-!-- calculate information needed ny the radiative transfer routine 
-
-IF (LHOOK) CALL DR_HOOK('SRTM_SRTM_224GP_MCICA',0,ZHOOK_HANDLE)
-ZEPSEC  = 1.E-06_JPRB
-ZONEMINUS=1.0_JPRB -  ZEPSEC
-ZADJI0 = RII0 / RI0
-!-- overlap: 1=max-ran, 2=maximum, 3=random
-IOVLP=3
-
-!print *,'Entering srtm_srtm_224gp_mcica'
-
-ICLDATM  = 1
-INFLAG   = 2
-ICEFLAG  = 3
-I_LIQFLAG= 1
-ITMOL    = 6
-I_NSTR   = 2
-
-DO JL = KIDIA, KFDIA
-  ZRMU0=PRMU0(JL)
-  IF (ZRMU0 > 0.0_JPRB) THEN
-
-!- coefficients related to the cloud optical properties (original RRTM_SW)
-
-!  print *,'just before SRTM_CLDPROP'
-
-!  DO JK=1,KLEV 
-!    CLDFRAC(JK) = PFRCL (JL,JK)
-!    CLDDAT1(JK) = PSCLA1(JL,JK)
-!    CLDDAT2(JK) = PSCLA2(JL,JK)
-!    CLDDAT3(JK) = PSCLA3(JL,JK)
-!    CLDDAT4(JK) = PSCLA4(JL,JK)
-!    DO JMOM=0,16
-!      CLDDATMOM(JMOM,JK)=PSCLMOM(JL,JMOM,JK)
-!    ENDDO
-!    print 9101,JK,CLDFRAC(JK),CLDDAT1(JK),CLDDAT2(JK),CLDDAT3(JK)&
-!    &,CLDDAT4(JK),(CLDDATMOM(JMOM,JK),JMOM=0,NSTR)
-    9101 format(1x,'srtm_srtm_224gp Cld :',I3,f7.4,7E12.5)
-!  ENDDO
-
-!  CALL SRTM_CLDPROP &
-!    &( KLEV, ICLDATM, INFLAG, ICEFLAG, LIQFLAG, NSTR &
-!    &, CLDFRAC, CLDDAT1, CLDDAT2, CLDDAT3, CLDDAT4, CLDDATMOM &
-!    &, TAUCLDORIG, TAUCLOUD, SSACLOUD, XMOM &
-!    &)
-
-!- coefficients for the temperature and pressure dependence of the 
-! molecular absorption coefficients
-
-    DO J1=1,35
-      DO J2=1,KLEV
-        ZWKL(J1,J2)=0.0_JPRB 
-      ENDDO
-    ENDDO
-
-    ZTBOUND=PTS(JL)
-    ZPZ(0) = paph(JL,klev+1)*0.01_JPRB
-    ZTZ(0) = pth (JL,klev+1)
-
-    ZCLEAR=1.0_JPRB
-    ZCLOUD=0.0_JPRB
-    ZTOTCC=0.0_JPRB
-    DO JK = 1, KLEV
-      ZPAVEL(JK) = pap(JL,KLEV-JK+1) *0.01_JPRB
-      ZTAVEL(JK) = pt (JL,KLEV-JK+1)
-      ZPZ(JK)    = paph(JL,KLEV-JK+1) *0.01_JPRB
-      ZTZ(JK)    = pth (JL,KLEV-JK+1)
-      ZWKL(1,JK) = pq(JL,KLEV-JK+1)  *ZAMD*RAMW
-      ZWKL(2,JK) = pcco2             *ZAMD*RAMCO2
-      ZWKL(3,JK) = pozn(JL,KLEV-JK+1)*ZAMD*RAMO
-      ZWKL(4,JK) = rn2o              *ZAMD*RAMN2O
-      ZWKL(6,JK) = rch4              *ZAMD*RAMCH4
-      ZAMM = (1-ZWKL(1,JK))*ZAMD + ZWKL(1,JK)*ZAMW
-      ZCOLDRY(JK) = (ZPZ(JK-1)-ZPZ(JK))*1.E3_JPRB*ZAVGDRO/(ZGRAVIT*ZAMM*(1+ZWKL(1,JK)))
-!    print 9200,JK,PAVEL(JK),TAVEL(JK),(WKL(JA,JK),JA=1,4),WKL(6,JK),COLDRY(JK)
-      9200 format(1x,'SRTM ',I3,2F7.1,6E13.5)
-
-
-
-    ENDDO
-
-!  print *,'ZTOTCC ZCLEAR : ',ZTOTCC,' ',ZCLEAR
-
-    DO IMOL=1,ITMOL
-      DO JK=1,KLEV
-        ZWKL(IMOL,JK)=ZCOLDRY(JK)* ZWKL(IMOL,JK)
-      ENDDO
-    ENDDO
-
-!  print *,'just before SRTM_SETCOEF'
-
-    CALL SRTM_SETCOEF &
-     & ( KLEV   , ITMOL,&
-     & ZPAVEL  , ZTAVEL   , ZPZ     , ZTZ     , ZTBOUND,&
-     & ZCOLDRY , ZWKL,&
-     & ILAYTROP, ILAYSWTCH, ILAYLOW,&
-     & ZCO2MULT, ZCOLCH4  , ZCOLCO2 , ZCOLH2O , ZCOLMOL  , ZCOLN2O  , ZCOLO2 , ZCOLO3,&
-     & ZFORFAC , ZFORFRAC , INDFOR  , ZSELFFAC, ZSELFFRAC, INDSELF, &
-     & ZFAC00  , ZFAC01   , ZFAC10  , ZFAC11,&
-     & JP      , JT       , JT1     &
-     & )  
-  
-!  print *,'just after SRTM_SETCOEF'
-
-!- call the radiation transfer routine
-  
-    DO JSW=1,KSW
-      ZALBD(JSW)=PALBD(JL,JSW)
-      ZALBP(JSW)=PALBP(JL,JSW)
-    ENDDO
-
-    DO JSW=1,KCOLS
-      DO JK=1,KLEV        
-        ZFRCL(JSW,JK) = PFRCL(JL,JSW,JK)
-        ZTAUC(JK,JSW) = PTAUC(JL,JSW,JK)
-        ZASYC(JK,JSW) = PASYC(JL,JSW,JK)
-        ZOMGC(JK,JSW) = POMGC(JL,JSW,JK)
-
-!---- security: might have to be moved upstream to radlswr -------
-!        IF(ZTAUC(JK,JSW) == 0._JPRB) ZFRCL(JSW,JK) = 0._JPRB
-!-----------------------------------------------------------------
-
-
-!       IF (ZFRCL(JSW,JK) /= 0._JPRB) THEN
-!          print 9002,JSW,JK,ZFRCL(JSW,JK),ZTAUC(JK,JSW),ZASYC(JK,JSW),ZOMGC(JK,JSW)
-9002      format(1x,'srtm_224gp_McICA ClOPropECmodel ',2I3,f8.4,3E12.5)
-!        ENDIF
-      ENDDO
-    ENDDO
-
-!- mixing of aerosols
- 
-!  print *,'Aerosol optical properties computations'
-!  DO JSW=1,KSW
-!    print 9012,JSW,(JAE,RSRTAUA(JSW,JAE),RSRPIZA(JSW,JAE),RSRASYA(JSW,JAE),JAE=1,6)
-    9012 format(I3,(/,I3,3E13.5))
-!  ENDDO
-
-!  DO JK=1,KLEV
-!    print 9013,JK,(PAER(JL,JAE,JK),JAE=1,6)
-    9013 format(1x,I3,6E12.5)
-!  ENDDO
-
-    IF (NAER == 0) THEN
-      DO JSW=1,KSW
-        DO JK=1,KLEV
-          ZTAUA(JK,JSW)= 0.0_JPRB
-          ZASYA(JK,JSW)= 0.0_JPRB
-          ZOMGA(JK,JSW)= 1.0_JPRB
-        ENDDO
-      ENDDO
+  !MPL/IM 20160915 on prend GES de phylmd
+  !-----------------------------------------------------------------------
+  !-- calculate information needed ny the radiative transfer routine
+
+  IF (LHOOK) CALL DR_HOOK('SRTM_SRTM_224GP_MCICA', 0, ZHOOK_HANDLE)
+  ZEPSEC = 1.E-06_JPRB
+  ZONEMINUS = 1.0_JPRB - ZEPSEC
+  ZADJI0 = RII0 / RI0
+  !-- overlap: 1=max-ran, 2=maximum, 3=random
+  IOVLP = 3
+
+  !print *,'Entering srtm_srtm_224gp_mcica'
+
+  ICLDATM = 1
+  INFLAG = 2
+  ICEFLAG = 3
+  I_LIQFLAG = 1
+  ITMOL = 6
+  I_NSTR = 2
+
+  DO JL = KIDIA, KFDIA
+    ZRMU0 = PRMU0(JL)
+    IF (ZRMU0 > 0.0_JPRB) THEN
+
+      !- coefficients related to the cloud optical properties (original RRTM_SW)
+
+      !  print *,'just before SRTM_CLDPROP'
+
+      !  DO JK=1,KLEV
+      !    CLDFRAC(JK) = PFRCL (JL,JK)
+      !    CLDDAT1(JK) = PSCLA1(JL,JK)
+      !    CLDDAT2(JK) = PSCLA2(JL,JK)
+      !    CLDDAT3(JK) = PSCLA3(JL,JK)
+      !    CLDDAT4(JK) = PSCLA4(JL,JK)
+      !    DO JMOM=0,16
+      !      CLDDATMOM(JMOM,JK)=PSCLMOM(JL,JMOM,JK)
+      !    ENDDO
+      !    print 9101,JK,CLDFRAC(JK),CLDDAT1(JK),CLDDAT2(JK),CLDDAT3(JK)&
+      !    &,CLDDAT4(JK),(CLDDATMOM(JMOM,JK),JMOM=0,NSTR)
+      9101 format(1x, 'srtm_srtm_224gp Cld :', I3, f7.4, 7E12.5)
+      !  ENDDO
+
+      !  CALL SRTM_CLDPROP &
+      !    &( KLEV, ICLDATM, INFLAG, ICEFLAG, LIQFLAG, NSTR &
+      !    &, CLDFRAC, CLDDAT1, CLDDAT2, CLDDAT3, CLDDAT4, CLDDATMOM &
+      !    &, TAUCLDORIG, TAUCLOUD, SSACLOUD, XMOM &
+      !    &)
+
+      !- coefficients for the temperature and pressure dependence of the
+      ! molecular absorption coefficients
+
+      DO J1 = 1, 35
+        DO J2 = 1, KLEV
+          ZWKL(J1, J2) = 0.0_JPRB
+        ENDDO
+      ENDDO
+
+      ZTBOUND = PTS(JL)
+      ZPZ(0) = paph(JL, klev + 1) * 0.01_JPRB
+      ZTZ(0) = pth (JL, klev + 1)
+
+      ZCLEAR = 1.0_JPRB
+      ZCLOUD = 0.0_JPRB
+      ZTOTCC = 0.0_JPRB
+      DO JK = 1, KLEV
+        ZPAVEL(JK) = pap(JL, KLEV - JK + 1) * 0.01_JPRB
+        ZTAVEL(JK) = pt (JL, KLEV - JK + 1)
+        ZPZ(JK) = paph(JL, KLEV - JK + 1) * 0.01_JPRB
+        ZTZ(JK) = pth (JL, KLEV - JK + 1)
+        ZWKL(1, JK) = pq(JL, KLEV - JK + 1) * ZAMD * RAMW
+        ZWKL(2, JK) = pcco2 * ZAMD * RAMCO2
+        ZWKL(3, JK) = pozn(JL, KLEV - JK + 1) * ZAMD * RAMO
+        ZWKL(4, JK) = rn2o * ZAMD * RAMN2O
+        ZWKL(6, JK) = rch4 * ZAMD * RAMCH4
+        ZAMM = (1 - ZWKL(1, JK)) * ZAMD + ZWKL(1, JK) * ZAMW
+        ZCOLDRY(JK) = (ZPZ(JK - 1) - ZPZ(JK)) * 1.E3_JPRB * ZAVGDRO / (ZGRAVIT * ZAMM * (1 + ZWKL(1, JK)))
+        !    print 9200,JK,PAVEL(JK),TAVEL(JK),(WKL(JA,JK),JA=1,4),WKL(6,JK),COLDRY(JK)
+        9200 format(1x, 'SRTM ', I3, 2F7.1, 6E13.5)
+
+      ENDDO
+
+      !  print *,'ZTOTCC ZCLEAR : ',ZTOTCC,' ',ZCLEAR
+
+      DO IMOL = 1, ITMOL
+        DO JK = 1, KLEV
+          ZWKL(IMOL, JK) = ZCOLDRY(JK) * ZWKL(IMOL, JK)
+        ENDDO
+      ENDDO
+
+      !  print *,'just before SRTM_SETCOEF'
+
+      CALL SRTM_SETCOEF &
+              & (KLEV, ITMOL, &
+              & ZPAVEL, ZTAVEL, ZPZ, ZTZ, ZTBOUND, &
+              & ZCOLDRY, ZWKL, &
+              & ILAYTROP, ILAYSWTCH, ILAYLOW, &
+              & ZCO2MULT, ZCOLCH4, ZCOLCO2, ZCOLH2O, ZCOLMOL, ZCOLN2O, ZCOLO2, ZCOLO3, &
+              & ZFORFAC, ZFORFRAC, INDFOR, ZSELFFAC, ZSELFFRAC, INDSELF, &
+              & ZFAC00, ZFAC01, ZFAC10, ZFAC11, &
+              & JP, JT, JT1     &
+              &)
+
+      !  print *,'just after SRTM_SETCOEF'
+
+      !- call the radiation transfer routine
+
+      DO JSW = 1, KSW
+        ZALBD(JSW) = PALBD(JL, JSW)
+        ZALBP(JSW) = PALBP(JL, JSW)
+      ENDDO
+
+      DO JSW = 1, KCOLS
+        DO JK = 1, KLEV
+          ZFRCL(JSW, JK) = PFRCL(JL, JSW, JK)
+          ZTAUC(JK, JSW) = PTAUC(JL, JSW, JK)
+          ZASYC(JK, JSW) = PASYC(JL, JSW, JK)
+          ZOMGC(JK, JSW) = POMGC(JL, JSW, JK)
+
+          !---- security: might have to be moved upstream to radlswr -------
+          !        IF(ZTAUC(JK,JSW) == 0._JPRB) ZFRCL(JSW,JK) = 0._JPRB
+          !-----------------------------------------------------------------
+
+
+          !       IF (ZFRCL(JSW,JK) /= 0._JPRB) THEN
+          !          print 9002,JSW,JK,ZFRCL(JSW,JK),ZTAUC(JK,JSW),ZASYC(JK,JSW),ZOMGC(JK,JSW)
+          9002      format(1x, 'srtm_224gp_McICA ClOPropECmodel ', 2I3, f8.4, 3E12.5)
+          !        ENDIF
+        ENDDO
+      ENDDO
+
+      !- mixing of aerosols
+
+      !  print *,'Aerosol optical properties computations'
+      !  DO JSW=1,KSW
+      !    print 9012,JSW,(JAE,RSRTAUA(JSW,JAE),RSRPIZA(JSW,JAE),RSRASYA(JSW,JAE),JAE=1,6)
+      9012 format(I3, (/, I3, 3E13.5))
+      !  ENDDO
+
+      !  DO JK=1,KLEV
+      !    print 9013,JK,(PAER(JL,JAE,JK),JAE=1,6)
+      9013 format(1x, I3, 6E12.5)
+      !  ENDDO
+
+      IF (NAER == 0) THEN
+        DO JSW = 1, KSW
+          DO JK = 1, KLEV
+            ZTAUA(JK, JSW) = 0.0_JPRB
+            ZASYA(JK, JSW) = 0.0_JPRB
+            ZOMGA(JK, JSW) = 1.0_JPRB
+          ENDDO
+        ENDDO
+      ELSE
+        DO JSW = 1, KSW
+          DO JK = 1, KLEV
+            IK = KLEV + 1 - JK
+            ZTAUA(JK, JSW) = 0.0_JPRB
+            ZASYA(JK, JSW) = 0.0_JPRB
+            ZOMGA(JK, JSW) = 0.0_JPRB
+            DO JAE = 1, 6
+              ZTAUA(JK, JSW) = ZTAUA(JK, JSW) + RSRTAUA(JSW, JAE) * PAER(JL, JAE, IK)
+              ZOMGA(JK, JSW) = ZOMGA(JK, JSW) + RSRTAUA(JSW, JAE) * PAER(JL, JAE, IK) &
+                      & * RSRPIZA(JSW, JAE)
+              ZASYA(JK, JSW) = ZASYA(JK, JSW) + RSRTAUA(JSW, JAE) * PAER(JL, JAE, IK) &
+                      & * RSRPIZA(JSW, JAE) * RSRASYA(JSW, JAE)
+            ENDDO
+            IF (ZOMGA(JK, JSW) /= 0.0_JPRB) THEN
+              ZASYA(JK, JSW) = ZASYA(JK, JSW) / ZOMGA(JK, JSW)
+            ENDIF
+            IF (ZTAUA(JK, JSW) /= 0.0_JPRB) THEN
+              ZOMGA(JK, JSW) = ZOMGA(JK, JSW) / ZTAUA(JK, JSW)
+            ENDIF
+            !      print 9003,JSW,JK,ZTAUA(JK,JSW),ZOMGA(JK,JSW),ZASYA(JK,JSW)
+            9003  format(1x, 'Aerosols ', 2I3, 3F10.4)
+          ENDDO
+        ENDDO
+      ENDIF
+
+      DO JK = 1, KLEV + 1
+        ZBBCU(JK) = 0.0_JPRB
+        ZBBCD(JK) = 0.0_JPRB
+        ZBBFU(JK) = 0.0_JPRB
+        ZBBFD(JK) = 0.0_JPRB
+        !      ZUVCU(JK)=0.0_JPRB
+        !      ZUVCD(JK)=0.0_JPRB
+        !      ZUVFU(JK)=0.0_JPRB
+        !      ZUVFD(JK)=0.0_JPRB
+        !      ZVSCU(JK)=0.0_JPRB
+        !      ZVSCD(JK)=0.0_JPRB
+        !      ZVSFU(JK)=0.0_JPRB
+        !      ZVSFD(JK)=0.0_JPRB
+        !      ZNICU(JK)=0.0_JPRB
+        !      ZNICD(JK)=0.0_JPRB
+        !      ZNIFU(JK)=0.0_JPRB
+        !      ZNIFD(JK)=0.0_JPRB
+      ENDDO
+
+      !    print *,'just before calling STRM_SPCVRT for JL=',JL,' and ZRMU0=',ZRMU0
+
+      CALL SRTM_SPCVRT_MCICA &
+              &(KLEV, ITMOL, KSW, KCOLS, ZONEMINUS, &
+              & ZPAVEL, ZTAVEL, ZPZ, ZTZ, ZTBOUND, ZALBD, ZALBP, &
+              & ZFRCL, ZTAUC, ZASYC, ZOMGC, ZTAUA, ZASYA, ZOMGA, ZRMU0, &
+              & ZCOLDRY, ZWKL, &
+              & ILAYTROP, ILAYSWTCH, ILAYLOW, &
+              & ZCO2MULT, ZCOLCH4, ZCOLCO2, ZCOLH2O, ZCOLMOL, ZCOLN2O, ZCOLO2, ZCOLO3, &
+              & ZFORFAC, ZFORFRAC, INDFOR, ZSELFFAC, ZSELFFRAC, INDSELF, &
+              & ZFAC00, ZFAC01, ZFAC10, ZFAC11, &
+              & JP, JT, JT1, &
+              & ZBBFD, ZBBFU, ZBBCD, ZBBCU)
+
+      !     & ZBBFD   , ZBBFU    , ZUVFD  , ZUVFU  , ZVSFD   , ZVSFU   , ZNIFD , ZNIFU,&
+      !     & ZBBCD   , ZBBCU    , ZUVCD  , ZUVCU  , ZVSCD   , ZVSCU   , ZNICD , ZNICU &
+      !     & )
+
+      !  print *,'SRTM_SRTM_224GP before potential scaling'
+      !    IF (IOVLP == 3) THEN
+      !      DO JK=1,KLEV+1
+      !!      print 9004,JK,ZBBCU(JK),ZBBCD(JK),ZBBFU(JK),ZBBFD(JK)
+      9004 format(1x, 'Clear-sky and total fluxes U & D ', I3, 4F10.3)
+      !        PFSUC(JL,1,JK)=ZBBCU(JK)
+      !        PFSUC(JL,2,JK)=ZBBCD(JK)
+      !        PFSUX(JL,1,JK)=ZBBFU(JK)
+      !        PFSUX(JL,2,JK)=ZBBFD(JK)
+      !      ENDDO
+      !    ELSE
+      !    print *,'SRTM_SRTM_224GP after potential scaling'
+      DO JK = 1, KLEV + 1
+        PFSUC(JL, 1, JK) = ZADJI0 * ZBBCU(JK)
+        PFSUC(JL, 2, JK) = ZADJI0 * ZBBCD(JK)
+        PFSUX(JL, 1, JK) = ZADJI0 * ((1.0_JPRB - ZCLEAR) * ZBBFU(JK) + ZCLEAR * ZBBCU(JK))
+        PFSUX(JL, 2, JK) = ZADJI0 * ((1.0_JPRB - ZCLEAR) * ZBBFD(JK) + ZCLEAR * ZBBCD(JK))
+        !-- for testing only
+        PFSUC(JL, 1, JK) = ZADJI0 * ZBBCU(JK)
+        PFSUC(JL, 2, JK) = ZADJI0 * ZBBCD(JK)
+        PFSUX(JL, 1, JK) = ZADJI0 * ZBBFU(JK)
+        PFSUX(JL, 2, JK) = ZADJI0 * ZBBFD(JK)
+      ENDDO
+      !    ENDIF
+
+      !  DO JK=1,KLEV+1
+      !    print 9005,JK,PFSUC(JL,1,JK),PFSUC(JL,2,JK),PFSUX(JL,1,JK),PFSUX(JL,2,JK)
+      9005 format(1x, 'Clear-sky and total fluxes U & D ', I3, 4F10.3)
+      !  ENDDO
+
     ELSE
-      DO JSW=1,KSW
-        DO JK=1,KLEV
-          IK=KLEV+1-JK
-          ZTAUA(JK,JSW)=0.0_JPRB
-          ZASYA(JK,JSW)=0.0_JPRB
-          ZOMGA(JK,JSW)=0.0_JPRB
-          DO JAE=1,6
-            ZTAUA(JK,JSW)=ZTAUA(JK,JSW)+RSRTAUA(JSW,JAE)*PAER(JL,JAE,IK)
-            ZOMGA(JK,JSW)=ZOMGA(JK,JSW)+RSRTAUA(JSW,JAE)*PAER(JL,JAE,IK) &
-             & *RSRPIZA(JSW,JAE)  
-            ZASYA(JK,JSW)=ZASYA(JK,JSW)+RSRTAUA(JSW,JAE)*PAER(JL,JAE,IK) &
-             & *RSRPIZA(JSW,JAE)*RSRASYA(JSW,JAE)  
-          ENDDO
-          IF (ZOMGA(JK,JSW) /= 0.0_JPRB) THEN
-            ZASYA(JK,JSW)=ZASYA(JK,JSW)/ZOMGA(JK,JSW)
-          ENDIF
-          IF (ZTAUA(JK,JSW) /= 0.0_JPRB) THEN
-            ZOMGA(JK,JSW)=ZOMGA(JK,JSW)/ZTAUA(JK,JSW)
-          ENDIF
-!      print 9003,JSW,JK,ZTAUA(JK,JSW),ZOMGA(JK,JSW),ZASYA(JK,JSW)
-9003  format(1x,'Aerosols ',2I3,3F10.4)
-        ENDDO
+      DO JK = 1, KLEV + 1
+        PFSUC(JL, 1, JK) = 0.0_JPRB
+        PFSUC(JL, 2, JK) = 0.0_JPRB
+        PFSUX(JL, 1, JK) = 0.0_JPRB
+        PFSUX(JL, 2, JK) = 0.0_JPRB
       ENDDO
     ENDIF
-
-    DO JK=1,KLEV+1
-      ZBBCU(JK)=0.0_JPRB
-      ZBBCD(JK)=0.0_JPRB
-      ZBBFU(JK)=0.0_JPRB
-      ZBBFD(JK)=0.0_JPRB
-!      ZUVCU(JK)=0.0_JPRB
-!      ZUVCD(JK)=0.0_JPRB
-!      ZUVFU(JK)=0.0_JPRB
-!      ZUVFD(JK)=0.0_JPRB
-!      ZVSCU(JK)=0.0_JPRB
-!      ZVSCD(JK)=0.0_JPRB
-!      ZVSFU(JK)=0.0_JPRB
-!      ZVSFD(JK)=0.0_JPRB
-!      ZNICU(JK)=0.0_JPRB
-!      ZNICD(JK)=0.0_JPRB
-!      ZNIFU(JK)=0.0_JPRB
-!      ZNIFD(JK)=0.0_JPRB
-    ENDDO
-
-!    print *,'just before calling STRM_SPCVRT for JL=',JL,' and ZRMU0=',ZRMU0
-
-    CALL SRTM_SPCVRT_MCICA &
-     &( KLEV   , ITMOL    , KSW    , KCOLS  , ZONEMINUS,&
-     & ZPAVEL  , ZTAVEL   , ZPZ    , ZTZ    , ZTBOUND , ZALBD   , ZALBP,&
-     & ZFRCL   , ZTAUC    , ZASYC  , ZOMGC  , ZTAUA   , ZASYA   , ZOMGA , ZRMU0,&
-     & ZCOLDRY , ZWKL     ,&
-     & ILAYTROP, ILAYSWTCH, ILAYLOW,&
-     & ZCO2MULT, ZCOLCH4  , ZCOLCO2, ZCOLH2O , ZCOLMOL  , ZCOLN2O, ZCOLO2 , ZCOLO3,&
-     & ZFORFAC , ZFORFRAC , INDFOR , ZSELFFAC, ZSELFFRAC, INDSELF,&
-     & ZFAC00  , ZFAC01   , ZFAC10 , ZFAC11  ,&
-     & JP      , JT       , JT1    ,&
-     & ZBBFD   , ZBBFU    , ZBBCD  , ZBBCU )
-     
-!     & ZBBFD   , ZBBFU    , ZUVFD  , ZUVFU  , ZVSFD   , ZVSFU   , ZNIFD , ZNIFU,&
-!     & ZBBCD   , ZBBCU    , ZUVCD  , ZUVCU  , ZVSCD   , ZVSCU   , ZNICD , ZNICU &
-!     & )  
-
-!  print *,'SRTM_SRTM_224GP before potential scaling'
-!    IF (IOVLP == 3) THEN
-!      DO JK=1,KLEV+1
-!!      print 9004,JK,ZBBCU(JK),ZBBCD(JK),ZBBFU(JK),ZBBFD(JK)
-        9004 format(1x,'Clear-sky and total fluxes U & D ',I3,4F10.3)
-!        PFSUC(JL,1,JK)=ZBBCU(JK)
-!        PFSUC(JL,2,JK)=ZBBCD(JK)
-!        PFSUX(JL,1,JK)=ZBBFU(JK)
-!        PFSUX(JL,2,JK)=ZBBFD(JK)
-!      ENDDO
-!    ELSE
-!    print *,'SRTM_SRTM_224GP after potential scaling'
-      DO JK=1,KLEV+1
-        PFSUC(JL,1,JK)=ZADJI0 * ZBBCU(JK)
-        PFSUC(JL,2,JK)=ZADJI0 * ZBBCD(JK)
-        PFSUX(JL,1,JK)=ZADJI0 * ( (1.0_JPRB-ZCLEAR)*ZBBFU(JK)+ZCLEAR*ZBBCU(JK) )
-        PFSUX(JL,2,JK)=ZADJI0 * ( (1.0_JPRB-ZCLEAR)*ZBBFD(JK)+ZCLEAR*ZBBCD(JK) )
-!-- for testing only
-        PFSUC(JL,1,JK)=ZADJI0 * ZBBCU(JK)
-        PFSUC(JL,2,JK)=ZADJI0 * ZBBCD(JK)
-        PFSUX(JL,1,JK)=ZADJI0 * ZBBFU(JK)
-        PFSUX(JL,2,JK)=ZADJI0 * ZBBFD(JK)
-      ENDDO
-!    ENDIF
-
-!  DO JK=1,KLEV+1
-!    print 9005,JK,PFSUC(JL,1,JK),PFSUC(JL,2,JK),PFSUX(JL,1,JK),PFSUX(JL,2,JK)
-    9005 format(1x,'Clear-sky and total fluxes U & D ',I3,4F10.3)
-!  ENDDO
-  
-  ELSE
-    DO JK=1,KLEV+1
-      PFSUC(JL,1,JK)=0.0_JPRB
-      PFSUC(JL,2,JK)=0.0_JPRB
-      PFSUX(JL,1,JK)=0.0_JPRB
-      PFSUX(JL,2,JK)=0.0_JPRB
-    ENDDO
-  ENDIF
-ENDDO
-
-!PRINT *,'OUT OF SRTM_224GP_MCICA'
-
-!-----------------------------------------------------------------------
-IF (LHOOK) CALL DR_HOOK('SRTM_SRTM_224GP_MCICA',1,ZHOOK_HANDLE)
+  ENDDO
+
+  !PRINT *,'OUT OF SRTM_224GP_MCICA'
+
+  !-----------------------------------------------------------------------
+  IF (LHOOK) CALL DR_HOOK('SRTM_SRTM_224GP_MCICA', 1, ZHOOK_HANDLE)
 END SUBROUTINE SRTM_SRTM_224GP_MCICA
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suecrad.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suecrad.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suecrad.F90	(revision 5154)
@@ -2,213 +2,214 @@
 ! $Id: suecrad.F90 4251 2022-09-20 00:22:43Z fhourdin $
 !
-SUBROUTINE SUECRAD (KULOUT, KLEV, PETAH )
-
-!**** *SUECRAD*   - INITIALIZE COMMONS YOERxx CONTROLLING RADIATION
-
-!     PURPOSE.
-!     --------
-!           INITIALIZE YOERAD, THE COMMON THAT CONTROLS THE
-!           RADIATION OF THE MODEL, AND YOERDU THAT INCLUDES
-!           ADJUSTABLE PARAMETERS FOR RADIATION COMPUTATIONS
-
-!**   INTERFACE.
-!     ----------
-!        CALL *SUECRAD* FROM *SUPHEC*
-!              -------        ------
-
-!        EXPLICIT ARGUMENTS :
-!        --------------------
-!        NONE
-
-!        IMPLICIT ARGUMENTS :
-!        --------------------
-!        COMMONS YOERAD, YOERDU
-
-!     METHOD.
-!     -------
-!        SEE DOCUMENTATION
-
-!     EXTERNALS.
-!     ----------
-!        SUAER, SUAERH, SUAERV, SULW, SUSW, SUOCST, SUSAT
-!        SUAERL, SUAERSN, SUSRTAER, SRTM_INIT, SUSRTCOP
-
-!     REFERENCE.
-!     ----------
-!        ECMWF Research Department documentation of the IFS
-
-!     AUTHOR.
-!     -------
-!        JEAN-JACQUES MORCRETTE  *ECMWF*
-
-!     MODIFICATIONS.
-!     --------------
-!        ORIGINAL : 88-12-15
-!        P.COURTIER AND M.HAMRUD NAME SURAD ALREADY USED
-!        Modified 93-11-15 by Ph. Dandin : FMR scheme with MF
-!        Modified 95-12 by PhD : Cloud overlapping hypothesis for FMR
-!        980317 JJMorcrette clean-up (NRAD, NFLUX)
-!        000118 JJMorcrette variable concentr. uniformly mixed gases
-!        990525 JJMorcrette GISS volcanic and new tropospheric aerosols
-!        990831 JJMorcrette RRTM
-!        R. El Khatib 01-02-02 proper initialization of NFRRC moved in SUCFU
-!        010129 JJMorcrette clean-up LERAD1H, NLNGR1H
-!        011105 GMozdzynski support new radiation grid
-!        011005 JJMorcrette CCN --> Re Water clouds
-!        R. El Khatib 01-02-02 LRRTM=lecmwf by default
-!        020909 GMozdzynski support NRADRES to specify radiation grid
-!        021001 GMozdzynski support on-demand radiation communications
-!        030422 GMozdzynski automatic min-halo
-!        030501 JJMorcrette new radiation grid on, new aerosols on (default)
-!        030513 JJMorcrette progn. O3 / radiation interactions off (default)
-!        M.Hamrud      01-Oct-2003 CY28 Cleaning
-!        050315 JJMorcrette prog.aerosols v1
-!        041214 JJMorcrette SRTM
-!        050111 JJMorcrette new cloud optical properties
-!        050415 GMozdzynski Reduced halo support for radiation interpolation
-!        051004 JJMorcrette UV surface radiation processor
-!        051220 JJMorcrette SRTM112g+LWSCAT+UVprocessor+(bgfx:swclr, radaca)
-!        060510 JJMorcrette MODIS albedo (UVis, NIR)x(parallel+diffuse)
-!        060510 JJMorcrette MODIS albedo (UVis, NIR)x(parallel+diffuse)
-!        JJMorcrette 20060721 PP of clear-sky PAR and TOA incident solar radiation
-!        060625 JJMorcrette MODIS albedo (UVis, NIR)x(parallel+diffuse)
-!        060726 JJMorcrette McICA default operational configuration
-!     ------------------------------------------------------------------
-
-USE PARKIND1  ,ONLY : JPIM     ,JPRB
-USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
-
-USE PARDIM   , ONLY : JPMXGL
-USE PARRRTM  , ONLY : JPLAY
-USE PARSRTM  , ONLY : JPGPT
-USE YOMCT0   , ONLY : LOUTPUT  ,NPRINTLEV,LALLOPR,&
- & NPROC    ,N_REGIONS_NS  ,N_REGIONS_EW
-USE YOMDIM   , ONLY : NDLON    ,NSMAX    ,NDGENL    ,&
- & NDGSAL   ,NDGLG    ,NDGSAG   ,NDGENG   ,NDSUR1    ,&
- & NDLSUR   ,NDGSUR   ,NGPBLKS  ,NFLEVG   ,NPROMA  
-USE YOMCT0B  , ONLY : LECMWF
-USE YOMDYN   , ONLY : TSTEP
-! Ce qui concerne NULRAD commente par MPL le 15.04.09
-!USE YOMLUN   , ONLY : NULNAM   ,NULRAD   ,NULOUT
-USE YOMLUN   , ONLY : NULRAD   ,NULOUT
-USE YOMCST   , ONLY : RDAY     ,RG       ,RCPD     ,RPI     ,RI0
-USE YOMPHY   , ONLY : LMPHYS, LRAYFM   ,LRAYFM15
-USE YOEPHY   , ONLY : LEPHYS   ,LERADI, LE4ALB
-USE YOERDI   , ONLY : RCCO2, RCCH4, RCN2O, RCCFC11, RCCFC12, RSOLINC
-USE YOERAD   , ONLY : NAER     , NOZOCL   ,&
- & NRADFR   ,NRADPFR  ,NRADPLA  ,NRINT    ,&
- & NRADNFR  ,NRADSFR  ,NOVLP    ,NRPROMA  ,&
-!& NLW      ,NSW      ,NTSW     ,NCSRADF  ,&
-! NSW mis dans .def MPL 20140211
- & NLW      ,NTSW     ,NCSRADF  ,&
- & NMODE    ,NLNGR1H  ,NSWNL    ,NSWTL    ,NUV     ,&
- & LERAD1H  ,LERADHS  ,LEPO3RA  ,LRADLB   ,LONEWSW ,&
- & LCCNL    ,LCCNO    ,&
- & LECSRAD  ,LHVOLCA  ,LNEWAER  ,LRRTM    ,LSRTM   ,LDIFFC  ,&
- & NRADINT  ,NRADRES  ,CRTABLEDIR,CRTABLEFIL       ,&
- & NICEOPT  ,NLIQOPT  ,NRADIP   ,NRADLP   ,NINHOM  ,NLAYINH ,&
- & LRAYL    ,LOPTRPROMA,&
- & RCCNLND  ,RCCNSEA  ,RLWINHF  ,RSWINHF  ,RRe2De  ,&
- & RPERTOZ  ,NPERTOZ  ,NMCICA   ,&
- & LNOTROAER,NPERTAER ,LECO2VAR ,LHGHG    ,NHINCSOL,NSCEN ,&
- & LEDBUG
-USE YOERDU   , ONLY : NUAER    ,NTRAER   ,RCDAY    ,R10E     ,&
- & REPLOG   ,REPSC    ,REPSCO   ,REPSCQ   ,REPSCT   ,&
- & REPSCW   ,DIFF  
-USE YOEAERD  , ONLY : CVDAES   ,CVDAEL   ,CVDAEU   ,CVDAED   ,&
- & RCAEOPS  ,RCAEOPL  ,RCAEOPU  ,RCAEOPD  ,RCTRBGA  ,&
- & RCVOBGA  ,RCSTBGA  ,RCTRPT   ,RCAEADM  ,RCAEROS  ,            &
- & RCAEADK  
-USE YOE_UVRAD, ONLY : JUVLAM, LUVPROC, LUVTDEP, LUVDBG, NRADUV, NUVTIM, RUVLAM, RMUZUV
-
-USE YOMMP    , ONLY : MYPROC   ,NPRCIDS  ,LSPLIT   ,NAPSETS  ,&
- & NPTRFLOFF,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,&
- & NSTA,NONL,NPTRFRSTLAT,NFRSTLAT,NLSTLAT ,&
- & MY_REGION_NS  ,MY_REGION_EW   ,NGLOBALINDEX ,&
- & NRISTA  ,NRIONL   ,NRIOFF    ,NRIEXT   ,NRICORE ,&
- & NRISENDPOS ,NRIRECVPOS ,NRISENDPTR ,NRIRECVPTR ,&
- & NARIB1  ,NRIPROCS ,NRIMPBUFSZ,NRISPT   ,NRIRPT ,&
- & NRICOMM ,&
- & NROSTA  ,NROONL   ,NROOFF    ,NROEXT   ,NROCORE ,&
- & NROSENDPOS ,NRORECVPOS ,NROSENDPTR ,NRORECVPTR ,&
- & NAROB1  ,NROPROCS ,NROMPBUFSZ,NROSPT   ,NRORPT ,&
- & NROCOMM
-USE YOMGC    , ONLY : GELAT    ,GELAM
-USE YOMLEG   , ONLY : RMU      ,RSQM2
-USE YOMSC2   , ONLY : &
- & NRIWIDEN  ,NRIWIDES  ,NRIWIDEW  ,NRIWIDEE,&
- & NROWIDEN  ,NROWIDES  ,NROWIDEW  ,NROWIDEE
-USE YOMGEM   , ONLY : NGPTOT   ,NGPTOTG   ,NGPTOTMX ,NLOENG
-USE YOMTAG   , ONLY : MTAGRAD
-USE YOMPRAD  , ONLY : LODBGRADI,LODBGRADL ,RADGRID  ,&
- & LRADONDEM  
-USE YOMRADF  , ONLY : EMTD     ,TRSW     ,EMTC      ,TRSC    ,&
- & SRSWD    ,SRLWD    ,SRSWDCS  ,SRLWDCS   ,SRSWDV  ,&
- & SRSWDUV  ,EDRO     ,SRSWPAR  ,SRSWUVB   ,SRSWPARC,  SRSWTINC,&
- & EMTU, RMOON
-! Commente par MPL 26.11.08 
-!USE YOPHNC   , ONLY :  LERADN2
-! MPLefebvre 6-11-08 commente tout ce qui concerne MPL_MODULE
-!USE MPL_MODULE  , ONLY :  MPL_BROADCAST, MPL_SEND, MPL_RECV
-USE YOM_YGFL , ONLY : YO3
-!!!!! A REVOIR (MPL) NDLNPR devrait etre initialise dans sudyn.F90
-USE YOMDYN   , ONLY : NDLNPR
-
-IMPLICIT NONE
-
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KULOUT 
-REAL(KIND=JPRB)   ,INTENT(IN)    :: PETAH(KLEV+1) 
-!     LOCAL ARRAYS FOR THE PURPOSE OF READING NAMRGRI (RADIATION GRID)
-INTEGER(KIND=JPIM) :: NRGRI(JPMXGL)
-
-INTEGER(KIND=JPIM) :: IDGL,INBLW,IRADFR,IST1HR,ISTNHR,IDIR,IFIL
-INTEGER(KIND=JPIM) :: IRIRPTSUR,IRISPTSUR,IRIMAPLEN
-INTEGER(KIND=JPIM) :: JLON,JGLAT,JGL,JGLSUR,IDLSUR,IOFF,ILAT,ISTLON,IENDLON
-INTEGER(KIND=JPIM) :: IRORPTSUR,IROSPTSUR,IROMAPLEN
-INTEGER(KIND=JPIM) :: ILBRLATI,IUBRLATI,IGLGLO,IDUM,IU
-INTEGER(KIND=JPIM) :: J,JROC,IGPTOT
-INTEGER(KIND=JPIM) :: IROWIDEMAXN,IROWIDEMAXS,IROWIDEMAXW,IROWIDEMAXE
-INTEGER(KIND=JPIM) :: IRIWIDEMAXN,IRIWIDEMAXS,IRIWIDEMAXW,IRIWIDEMAXE
-INTEGER(KIND=JPIM) :: IARIB1MAX,IAROB1MAX
-INTEGER(KIND=JPIM) :: IWIDE(10)
-INTEGER(KIND=JPIM) :: ILATS_DIFF_F,ILATS_DIFF_C
-INTEGER(KIND=JPIM), PARAMETER :: JP_MIN_HALO=5
-INTEGER(KIND=JPIM) :: ISW,JUV,IDAYUV
-
-LOGICAL :: LLINEAR_GRID
-LOGICAL :: LLDEBUG,LLP
-
-REAL(KIND=JPRB) :: ZSTPHR, ZTSTEP, ZGEMU, ZLON, ZD1, ZD2, ZD3, ZD4, ZD5, ZD6
-REAL(KIND=JPRB) :: ZMINRADLAT,ZMAXRADLAT,ZMINRADLON,ZMAXRADLON
-REAL(KIND=JPRB) :: ZMINMDLLAT,ZMAXMDLLAT,ZMINMDLLON,ZMAXMDLLON
-REAL(KIND=JPRB) :: ZLAT
-!REAL(KIND=JPRB) :: RLATVOL, RLONVOL
-
-CHARACTER (LEN = 300) ::  CLFN
-INTEGER(KIND=JPIM), PARAMETER :: JPIOMASTER=1
-
-INTEGER(KIND=JPIM), ALLOCATABLE :: IRISENDPOS(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IRIRECVPOS(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IRISENDPTR(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IRIRECVPTR(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IRICOMM(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IRIMAP(:,:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IROSENDPOS(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IRORECVPOS(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IROSENDPTR(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IRORECVPTR(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IROCOMM(:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IROMAP(:,:)
-INTEGER(KIND=JPIM), ALLOCATABLE :: IGLOBALINDEX(:)
-
-REAL(KIND=JPRB),ALLOCATABLE :: ZLATX(:)
-REAL(KIND=JPRB),ALLOCATABLE :: ZLONX(:)
-REAL(KIND=JPRB) :: ZHOOK_HANDLE
-
-INTERFACE
+SUBROUTINE SUECRAD (KULOUT, KLEV, PETAH)
+
+  !**** *SUECRAD*   - INITIALIZE COMMONS YOERxx CONTROLLING RADIATION
+
+  !     PURPOSE.
+  !     --------
+  !           INITIALIZE YOERAD, THE COMMON THAT CONTROLS THE
+  !           RADIATION OF THE MODEL, AND YOERDU THAT INCLUDES
+  !           ADJUSTABLE PARAMETERS FOR RADIATION COMPUTATIONS
+
+  !**   INTERFACE.
+  !     ----------
+  !        CALL *SUECRAD* FROM *SUPHEC*
+  !              -------        ------
+
+  !        EXPLICIT ARGUMENTS :
+  !        --------------------
+  !        NONE
+
+  !        IMPLICIT ARGUMENTS :
+  !        --------------------
+  !        COMMONS YOERAD, YOERDU
+
+  !     METHOD.
+  !     -------
+  !        SEE DOCUMENTATION
+
+  !     EXTERNALS.
+  !     ----------
+  !        SUAER, SUAERH, SUAERV, SULW, SUSW, SUOCST, SUSAT
+  !        SUAERL, SUAERSN, SUSRTAER, SRTM_INIT, SUSRTCOP
+
+  !     REFERENCE.
+  !     ----------
+  !        ECMWF Research Department documentation of the IFS
+
+  !     AUTHOR.
+  !     -------
+  !        JEAN-JACQUES MORCRETTE  *ECMWF*
+
+  !     MODIFICATIONS.
+  !     --------------
+  !        ORIGINAL : 88-12-15
+  !        P.COURTIER AND M.HAMRUD NAME SURAD ALREADY USED
+  !        Modified 93-11-15 by Ph. Dandin : FMR scheme with MF
+  !        Modified 95-12 by PhD : Cloud overlapping hypothesis for FMR
+  !        980317 JJMorcrette clean-up (NRAD, NFLUX)
+  !        000118 JJMorcrette variable concentr. uniformly mixed gases
+  !        990525 JJMorcrette GISS volcanic and new tropospheric aerosols
+  !        990831 JJMorcrette RRTM
+  !        R. El Khatib 01-02-02 proper initialization of NFRRC moved in SUCFU
+  !        010129 JJMorcrette clean-up LERAD1H, NLNGR1H
+  !        011105 GMozdzynski support new radiation grid
+  !        011005 JJMorcrette CCN --> Re Water clouds
+  !        R. El Khatib 01-02-02 LRRTM=lecmwf by default
+  !        020909 GMozdzynski support NRADRES to specify radiation grid
+  !        021001 GMozdzynski support on-demand radiation communications
+  !        030422 GMozdzynski automatic min-halo
+  !        030501 JJMorcrette new radiation grid on, new aerosols on (default)
+  !        030513 JJMorcrette progn. O3 / radiation interactions off (default)
+  !        M.Hamrud      01-Oct-2003 CY28 Cleaning
+  !        050315 JJMorcrette prog.aerosols v1
+  !        041214 JJMorcrette SRTM
+  !        050111 JJMorcrette new cloud optical properties
+  !        050415 GMozdzynski Reduced halo support for radiation interpolation
+  !        051004 JJMorcrette UV surface radiation processor
+  !        051220 JJMorcrette SRTM112g+LWSCAT+UVprocessor+(bgfx:swclr, radaca)
+  !        060510 JJMorcrette MODIS albedo (UVis, NIR)x(parallel+diffuse)
+  !        060510 JJMorcrette MODIS albedo (UVis, NIR)x(parallel+diffuse)
+  !        JJMorcrette 20060721 PP of clear-sky PAR and TOA incident solar radiation
+  !        060625 JJMorcrette MODIS albedo (UVis, NIR)x(parallel+diffuse)
+  !        060726 JJMorcrette McICA default operational configuration
+  !     ------------------------------------------------------------------
+
+  USE PARKIND1, ONLY: JPIM, JPRB
+  USE YOMHOOK, ONLY: LHOOK, DR_HOOK
+
+  USE PARDIM, ONLY: JPMXGL
+  USE PARRRTM, ONLY: JPLAY
+  USE PARSRTM, ONLY: JPGPT
+  USE YOMCT0, ONLY: LOUTPUT, NPRINTLEV, LALLOPR, &
+          & NPROC, N_REGIONS_NS, N_REGIONS_EW
+  USE YOMDIM, ONLY: NDLON, NSMAX, NDGENL, &
+          & NDGSAL, NDGLG, NDGSAG, NDGENG, NDSUR1, &
+          & NDLSUR, NDGSUR, NGPBLKS, NFLEVG, NPROMA
+  USE YOMCT0B, ONLY: LECMWF
+  USE YOMDYN, ONLY: TSTEP
+  ! Ce qui concerne NULRAD commente par MPL le 15.04.09
+  !USE YOMLUN   , ONLY : NULNAM   ,NULRAD   ,NULOUT
+  USE YOMLUN, ONLY: NULRAD, NULOUT
+  USE YOMCST, ONLY: RDAY, RG, RCPD, RPI, RI0
+  USE YOMPHY, ONLY: LMPHYS, LRAYFM, LRAYFM15
+  USE YOEPHY, ONLY: LEPHYS, LERADI, LE4ALB
+  USE YOERDI, ONLY: RCCO2, RCCH4, RCN2O, RCCFC11, RCCFC12, RSOLINC
+  USE YOERAD, ONLY: NAER, NOZOCL, &
+          & NRADFR, NRADPFR, NRADPLA, NRINT, &
+          & NRADNFR, NRADSFR, NOVLP, NRPROMA, &
+          !& NLW      ,NSW      ,NTSW     ,NCSRADF  ,&
+          ! NSW mis dans .def MPL 20140211
+          & NLW, NTSW, NCSRADF, &
+          & NMODE, NLNGR1H, NSWNL, NSWTL, NUV, &
+          & LERAD1H, LERADHS, LEPO3RA, LRADLB, LONEWSW, &
+          & LCCNL, LCCNO, &
+          & LECSRAD, LHVOLCA, LNEWAER, LRRTM, LSRTM, LDIFFC, &
+          & NRADINT, NRADRES, CRTABLEDIR, CRTABLEFIL, &
+          & NICEOPT, NLIQOPT, NRADIP, NRADLP, NINHOM, NLAYINH, &
+          & LRAYL, LOPTRPROMA, &
+          & RCCNLND, RCCNSEA, RLWINHF, RSWINHF, RRe2De, &
+          & RPERTOZ, NPERTOZ, NMCICA, &
+          & LNOTROAER, NPERTAER, LECO2VAR, LHGHG, NHINCSOL, NSCEN, &
+          & LEDBUG
+  USE YOERDU, ONLY: NUAER, NTRAER, RCDAY, R10E, &
+          & REPLOG, REPSC, REPSCO, REPSCQ, REPSCT, &
+          & REPSCW, DIFF
+  USE YOEAERD, ONLY: CVDAES, CVDAEL, CVDAEU, CVDAED, &
+          & RCAEOPS, RCAEOPL, RCAEOPU, RCAEOPD, RCTRBGA, &
+          & RCVOBGA, RCSTBGA, RCTRPT, RCAEADM, RCAEROS, &
+          & RCAEADK
+  USE YOE_UVRAD, ONLY: JUVLAM, LUVPROC, LUVTDEP, LUVDBG, NRADUV, NUVTIM, RUVLAM, RMUZUV
+
+  USE YOMMP, ONLY: MYPROC, NPRCIDS, LSPLIT, NAPSETS, &
+          & NPTRFLOFF, NFRSTLOFF, MYFRSTACTLAT, MYLSTACTLAT, &
+          & NSTA, NONL, NPTRFRSTLAT, NFRSTLAT, NLSTLAT, &
+          & MY_REGION_NS, MY_REGION_EW, NGLOBALINDEX, &
+          & NRISTA, NRIONL, NRIOFF, NRIEXT, NRICORE, &
+          & NRISENDPOS, NRIRECVPOS, NRISENDPTR, NRIRECVPTR, &
+          & NARIB1, NRIPROCS, NRIMPBUFSZ, NRISPT, NRIRPT, &
+          & NRICOMM, &
+          & NROSTA, NROONL, NROOFF, NROEXT, NROCORE, &
+          & NROSENDPOS, NRORECVPOS, NROSENDPTR, NRORECVPTR, &
+          & NAROB1, NROPROCS, NROMPBUFSZ, NROSPT, NRORPT, &
+          & NROCOMM
+  USE YOMGC, ONLY: GELAT, GELAM
+  USE YOMLEG, ONLY: RMU, RSQM2
+  USE YOMSC2, ONLY: &
+          & NRIWIDEN, NRIWIDES, NRIWIDEW, NRIWIDEE, &
+          & NROWIDEN, NROWIDES, NROWIDEW, NROWIDEE
+  USE YOMGEM, ONLY: NGPTOT, NGPTOTG, NGPTOTMX, NLOENG
+  USE YOMTAG, ONLY: MTAGRAD
+  USE YOMPRAD, ONLY: LODBGRADI, LODBGRADL, RADGRID, &
+          & LRADONDEM
+  USE YOMRADF, ONLY: EMTD, TRSW, EMTC, TRSC, &
+          & SRSWD, SRLWD, SRSWDCS, SRLWDCS, SRSWDV, &
+          & SRSWDUV, EDRO, SRSWPAR, SRSWUVB, SRSWPARC, SRSWTINC, &
+          & EMTU, RMOON
+  ! Commente par MPL 26.11.08
+  !USE YOPHNC   , ONLY :  LERADN2
+  ! MPLefebvre 6-11-08 commente tout ce qui concerne MPL_MODULE
+  !USE MPL_MODULE  , ONLY :  MPL_BROADCAST, MPL_SEND, MPL_RECV
+  USE YOM_YGFL, ONLY: YO3
+  !!!!! A REVOIR (MPL) NDLNPR devrait etre initialise dans sudyn.F90
+  USE YOMDYN, ONLY: NDLNPR
+  USE lmdz_clesphys
+
+  IMPLICIT NONE
+
+  INTEGER(KIND = JPIM), INTENT(IN) :: KLEV
+  INTEGER(KIND = JPIM), INTENT(IN) :: KULOUT
+  REAL(KIND = JPRB), INTENT(IN) :: PETAH(KLEV + 1)
+  !     LOCAL ARRAYS FOR THE PURPOSE OF READING NAMRGRI (RADIATION GRID)
+  INTEGER(KIND = JPIM) :: NRGRI(JPMXGL)
+
+  INTEGER(KIND = JPIM) :: IDGL, INBLW, IRADFR, IST1HR, ISTNHR, IDIR, IFIL
+  INTEGER(KIND = JPIM) :: IRIRPTSUR, IRISPTSUR, IRIMAPLEN
+  INTEGER(KIND = JPIM) :: JLON, JGLAT, JGL, JGLSUR, IDLSUR, IOFF, ILAT, ISTLON, IENDLON
+  INTEGER(KIND = JPIM) :: IRORPTSUR, IROSPTSUR, IROMAPLEN
+  INTEGER(KIND = JPIM) :: ILBRLATI, IUBRLATI, IGLGLO, IDUM, IU
+  INTEGER(KIND = JPIM) :: J, JROC, IGPTOT
+  INTEGER(KIND = JPIM) :: IROWIDEMAXN, IROWIDEMAXS, IROWIDEMAXW, IROWIDEMAXE
+  INTEGER(KIND = JPIM) :: IRIWIDEMAXN, IRIWIDEMAXS, IRIWIDEMAXW, IRIWIDEMAXE
+  INTEGER(KIND = JPIM) :: IARIB1MAX, IAROB1MAX
+  INTEGER(KIND = JPIM) :: IWIDE(10)
+  INTEGER(KIND = JPIM) :: ILATS_DIFF_F, ILATS_DIFF_C
+  INTEGER(KIND = JPIM), PARAMETER :: JP_MIN_HALO = 5
+  INTEGER(KIND = JPIM) :: ISW, JUV, IDAYUV
+
+  LOGICAL :: LLINEAR_GRID
+  LOGICAL :: LLDEBUG, LLP
+
+  REAL(KIND = JPRB) :: ZSTPHR, ZTSTEP, ZGEMU, ZLON, ZD1, ZD2, ZD3, ZD4, ZD5, ZD6
+  REAL(KIND = JPRB) :: ZMINRADLAT, ZMAXRADLAT, ZMINRADLON, ZMAXRADLON
+  REAL(KIND = JPRB) :: ZMINMDLLAT, ZMAXMDLLAT, ZMINMDLLON, ZMAXMDLLON
+  REAL(KIND = JPRB) :: ZLAT
+  !REAL(KIND=JPRB) :: RLATVOL, RLONVOL
+
+  CHARACTER (LEN = 300) :: CLFN
+  INTEGER(KIND = JPIM), PARAMETER :: JPIOMASTER = 1
+
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IRISENDPOS(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IRIRECVPOS(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IRISENDPTR(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IRIRECVPTR(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IRICOMM(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IRIMAP(:, :)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IROSENDPOS(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IRORECVPOS(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IROSENDPTR(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IRORECVPTR(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IROCOMM(:)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IROMAP(:, :)
+  INTEGER(KIND = JPIM), ALLOCATABLE :: IGLOBALINDEX(:)
+
+  REAL(KIND = JPRB), ALLOCATABLE :: ZLATX(:)
+  REAL(KIND = JPRB), ALLOCATABLE :: ZLONX(:)
+  REAL(KIND = JPRB) :: ZHOOK_HANDLE
+
+  INTERFACE
 #include "setup_trans.h"
 #include "trans_inq.h"
-END INTERFACE
+  END INTERFACE
 
 #include "abor1.intfb.h"
@@ -241,1301 +242,1297 @@
 #include "su_mcica.intfb.h"
 
-!      ----------------------------------------------------------------
-
-#include "clesphys.h"
+  !      ----------------------------------------------------------------
+
 #include "naerad.h"
 #include "namrgri.h"
-!MPL/IM 20160915 on prend GES de phylmd
-
-!*         1.       INITIALIZE NEUROFLUX LONGWAVE RADIATION
-!                   ---------------------------------------
-
-IF (LHOOK) CALL DR_HOOK('SUECRAD',0,ZHOOK_HANDLE)
-!CALL GSTATS(1818,0)     MPL 2.12.08
-!IF (LERADN2) THEN
-!  CALL SULWNEUR(KLEV)
-!ENDIF
-
-!*         2.       SET DEFAULT VALUES.
-!                   -------------------
-
-!*         2.1      PRESET INDICES IN *YOERAD*
-!                   --------------------------
-
-LERAD1H=.FALSE.
-NLNGR1H=6
-
-LERADHS=.TRUE.
-LONEWSW=.TRUE.
-LECSRAD=.FALSE.
-
-!LE4ALB=.FALSE.
-!This is read from SU0PHY in NAEPHY and put in YOEPHY
-
-!- default setting of cloud optical properties
-!  liquid water cloud 0: Fouquart    (SW), Smith-Shi   (LW)
-!                     1: Slingo      (SW), Savijarvi   (LW)
-!                     2: Slingo      (SW), Lindner-Li  (LW)
-!  ice water cloud    0: Ebert-Curry (SW), Smith-Shi   (LW)
-!                     1: Ebert-Curry (SW), Ebert-Curry (LW)
-!                     2: Fu-Liou'93  (SW), Fu-Liou'93  (LW)
-!                     3: Fu'96       (SW), Fu et al'98 (LW)
-NLIQOPT=2           ! before 3?R1 default=0    2
-NICEOPT=3           ! before 3?R1 default=1    3
-
-!- default setting of cloud effective radius/diameter
-!  liquid water cloud 0: f(P) 10 to 45
-!                     1: 13: ocean; 10: land
-!                     2: Martin et al. CCN 50 over ocean, 900 over land
-!  ice water cloud    0: 40 microns
-!                     1: f(T) 40 to 130 microns
-!                     2: f(T) 30 to 60
-!                     3: f(T,IWC) Sun'01: 22.5 to 175 microns
-!  conversion factor between effective radius and particle size for ice
-NRADIP=3            ! before 3?R1 default=2 	3
-NRADLP=2            ! before 3?R1 default=2	2
-print *,'SUECRAD: NRADLP, NRADIP=',NRADLP,NRADIP
-RRe2De=0.64952_JPRB ! before 3?R1 default=0.5_JPRB
-
-!- RRTM as LW scheme
-LRRTM  = .FALSE.
-LECMWF = .FALSE.
-IF (iflag_rrtm.EQ.1) THEN
-        LRRTM  = .TRUE.
-        LECMWF = .TRUE.
-!       LRRTM  = .FALSE.  ! Utiliser pour faire tourner le "vieux" rayonnement
-!       LECMWF = .FALSE. 
-ENDIF
-
-!LRRTM  = .FALSE.
-
-!- SRTM as SW scheme
-!!!!! A REVOIR (MPL) verifier signification de LSRTM
-LSRTM = .FALSE.     ! before 3?R1 default was .FALSE.    true
-
-! -- McICA treatment of cloud-radiation interactions 
-! - 1 is maximum-random, 2 is generalized cloud overlap (before 31R1 default=0 no McICA)
-NMcICA = 2          !  2 for generalized overlap
-
-!- Inhomogeneity factors in LW and SW (0=F, 1=0.7 in both, 2=Barker's, 3=Cairns)
-NINHOM = 0          ! before 3?R1 default=1
-NLAYINH= 0
-RLWINHF = 1.0_JPRB  ! before 3?R1 default=0.7
-RSWINHF = 1.0_JPRB  ! before 3?R1 default=0.7  
-!- Diffusivity correction a la Savijarvi
-LDIFFC = .FALSE.    ! before 31R1 default=.FALSE. 
-
-!- history of volcanic aerosols
-LHVOLCA=.FALSE.
-!- monthly climatol. of tropospheric aerosols from Tegen et al. (1997)
-LNEWAER=.TRUE.
-!!! cpl LNOTROAER=.FALSE.
-LNOTROAER=.TRUE.
-NPERTAER=0
-
-!- New Rayleigh formulation
-LRAYL=.TRUE.
-
-!- Number concentration of aerosols if specified
-LCCNL=.TRUE.        ! before 3?R1 default=.FALSE.     true
-LCCNO=.TRUE.        ! before 3?R1 default=.FALSE.     true
-RCCNLND=900._JPRB   ! before 3?R1 default=900. now irrelevant
-RCCNSEA=50._JPRB    ! before 3?R1 default=50.  now irrelevant
-
-!- interaction radiation / prognostic O3 off by default
-LEPO3RA=.FALSE.
-print *,'SUECRAD-0'
-IF (.NOT.YO3%LGP) THEN
-  LEPO3RA=.FALSE.
-ENDIF
-RPERTOZ=0._JPRB
-NPERTOZ=0
-
-!NAER: CONFIGURATION INDEX FOR AEROSOLS
-!!!!! A REVOIR (MPL) a mettre dans un fichier .def
-NAER   =1
-NMODE  =0
-NOZOCL =1
-NRADFR =-3
-IF (NSMAX >= 511) NRADFR =-1
-NRADPFR=0
-NRADPLA=15
-
-! -- UV diagnostic of surface fluxes over the 280-400 nm interval 
-!    with up-to 24 values (5 nm wide spectral intervals)
-LUVPROC=.FALSE.
-LUVTDEP=.TRUE.
-LUVDBG =.FALSE.
-NRADUV =-3
-NUVTIM = 0
-NUV    = 24
-RMUZUV = 1.E-01_JPRB
-DO JUV=1,NUV
-  RUVLAM(JUV)=280._JPRB+(JUV-1)*5._JPRB
-ENDDO
-
-!- radiation interpolation (George M's grid on by default)
-LLDEBUG=.TRUE.
-LEDBUG=.FALSE.
-NRADINT=3
-NRADRES=0
-
-NRINT  =4
-
-LRADLB=.TRUE.
-CRTABLEDIR='./'
-CRTABLEFIL='not set'
-LRADONDEM=.TRUE.
-!GM Temporary as per trans/external/setup_trans.F90
-LLINEAR_GRID=NSMAX > (NDLON+3)/3
-IF( LLDEBUG )THEN
-  WRITE(NULOUT,'("SUECRAD: NSMAX=",I6)')NSMAX
-  WRITE(NULOUT,'("SUECRAD: NDLON=",I6)')NDLON
-  WRITE(NULOUT,'("SUECRAD: LLINEAR_GRID=",L5)')LLINEAR_GRID
-ENDIF
-
-NUAER  = 24
-NTRAER = 15
-! 1: max-random, 2: max, 3: random (5,6,7,8 pour meso-NH)
-! le CASE qui suit car les conventions sont differentes dans ARP et LMDZ (MPL 20100415)
-SELECT CASE (overlap)
+  !MPL/IM 20160915 on prend GES de phylmd
+
+  !*         1.       INITIALIZE NEUROFLUX LONGWAVE RADIATION
+  !                   ---------------------------------------
+
+  IF (LHOOK) CALL DR_HOOK('SUECRAD', 0, ZHOOK_HANDLE)
+  !CALL GSTATS(1818,0)     MPL 2.12.08
+  !IF (LERADN2) THEN
+  !  CALL SULWNEUR(KLEV)
+  !ENDIF
+
+  !*         2.       SET DEFAULT VALUES.
+  !                   -------------------
+
+  !*         2.1      PRESET INDICES IN *YOERAD*
+  !                   --------------------------
+
+  LERAD1H = .FALSE.
+  NLNGR1H = 6
+
+  LERADHS = .TRUE.
+  LONEWSW = .TRUE.
+  LECSRAD = .FALSE.
+
+  !LE4ALB=.FALSE.
+  !This is read from SU0PHY in NAEPHY and put in YOEPHY
+
+  !- default setting of cloud optical properties
+  !  liquid water cloud 0: Fouquart    (SW), Smith-Shi   (LW)
+  !                     1: Slingo      (SW), Savijarvi   (LW)
+  !                     2: Slingo      (SW), Lindner-Li  (LW)
+  !  ice water cloud    0: Ebert-Curry (SW), Smith-Shi   (LW)
+  !                     1: Ebert-Curry (SW), Ebert-Curry (LW)
+  !                     2: Fu-Liou'93  (SW), Fu-Liou'93  (LW)
+  !                     3: Fu'96       (SW), Fu et al'98 (LW)
+  NLIQOPT = 2           ! before 3?R1 default=0    2
+  NICEOPT = 3           ! before 3?R1 default=1    3
+
+  !- default setting of cloud effective radius/diameter
+  !  liquid water cloud 0: f(P) 10 to 45
+  !                     1: 13: ocean; 10: land
+  !                     2: Martin et al. CCN 50 over ocean, 900 over land
+  !  ice water cloud    0: 40 microns
+  !                     1: f(T) 40 to 130 microns
+  !                     2: f(T) 30 to 60
+  !                     3: f(T,IWC) Sun'01: 22.5 to 175 microns
+  !  conversion factor between effective radius and particle size for ice
+  NRADIP = 3            ! before 3?R1 default=2 	3
+  NRADLP = 2            ! before 3?R1 default=2	2
+  print *, 'SUECRAD: NRADLP, NRADIP=', NRADLP, NRADIP
+  RRe2De = 0.64952_JPRB ! before 3?R1 default=0.5_JPRB
+
+  !- RRTM as LW scheme
+  LRRTM = .FALSE.
+  LECMWF = .FALSE.
+  IF (iflag_rrtm.EQ.1) THEN
+    LRRTM = .TRUE.
+    LECMWF = .TRUE.
+    !       LRRTM  = .FALSE.  ! Utiliser pour faire tourner le "vieux" rayonnement
+    !       LECMWF = .FALSE.
+  ENDIF
+
+  !LRRTM  = .FALSE.
+
+  !- SRTM as SW scheme
+  !!!!! A REVOIR (MPL) verifier signification de LSRTM
+  LSRTM = .FALSE.     ! before 3?R1 default was .FALSE.    true
+
+  ! -- McICA treatment of cloud-radiation interactions
+  ! - 1 is maximum-random, 2 is generalized cloud overlap (before 31R1 default=0 no McICA)
+  NMcICA = 2          !  2 for generalized overlap
+
+  !- Inhomogeneity factors in LW and SW (0=F, 1=0.7 in both, 2=Barker's, 3=Cairns)
+  NINHOM = 0          ! before 3?R1 default=1
+  NLAYINH = 0
+  RLWINHF = 1.0_JPRB  ! before 3?R1 default=0.7
+  RSWINHF = 1.0_JPRB  ! before 3?R1 default=0.7
+  !- Diffusivity correction a la Savijarvi
+  LDIFFC = .FALSE.    ! before 31R1 default=.FALSE.
+
+  !- history of volcanic aerosols
+  LHVOLCA = .FALSE.
+  !- monthly climatol. of tropospheric aerosols from Tegen et al. (1997)
+  LNEWAER = .TRUE.
+  !!! cpl LNOTROAER=.FALSE.
+  LNOTROAER = .TRUE.
+  NPERTAER = 0
+
+  !- New Rayleigh formulation
+  LRAYL = .TRUE.
+
+  !- Number concentration of aerosols if specified
+  LCCNL = .TRUE.        ! before 3?R1 default=.FALSE.     true
+  LCCNO = .TRUE.        ! before 3?R1 default=.FALSE.     true
+  RCCNLND = 900._JPRB   ! before 3?R1 default=900. now irrelevant
+  RCCNSEA = 50._JPRB    ! before 3?R1 default=50.  now irrelevant
+
+  !- interaction radiation / prognostic O3 off by default
+  LEPO3RA = .FALSE.
+  print *, 'SUECRAD-0'
+  IF (.NOT.YO3%LGP) THEN
+    LEPO3RA = .FALSE.
+  ENDIF
+  RPERTOZ = 0._JPRB
+  NPERTOZ = 0
+
+  !NAER: CONFIGURATION INDEX FOR AEROSOLS
+  !!!!! A REVOIR (MPL) a mettre dans un fichier .def
+  NAER = 1
+  NMODE = 0
+  NOZOCL = 1
+  NRADFR = -3
+  IF (NSMAX >= 511) NRADFR = -1
+  NRADPFR = 0
+  NRADPLA = 15
+
+  ! -- UV diagnostic of surface fluxes over the 280-400 nm interval
+  !    with up-to 24 values (5 nm wide spectral intervals)
+  LUVPROC = .FALSE.
+  LUVTDEP = .TRUE.
+  LUVDBG = .FALSE.
+  NRADUV = -3
+  NUVTIM = 0
+  NUV = 24
+  RMUZUV = 1.E-01_JPRB
+  DO JUV = 1, NUV
+    RUVLAM(JUV) = 280._JPRB + (JUV - 1) * 5._JPRB
+  ENDDO
+
+  !- radiation interpolation (George M's grid on by default)
+  LLDEBUG = .TRUE.
+  LEDBUG = .FALSE.
+  NRADINT = 3
+  NRADRES = 0
+
+  NRINT = 4
+
+  LRADLB = .TRUE.
+  CRTABLEDIR = './'
+  CRTABLEFIL = 'not set'
+  LRADONDEM = .TRUE.
+  !GM Temporary as per trans/external/setup_trans.F90
+  LLINEAR_GRID = NSMAX > (NDLON + 3) / 3
+  IF(LLDEBUG)THEN
+    WRITE(NULOUT, '("SUECRAD: NSMAX=",I6)')NSMAX
+    WRITE(NULOUT, '("SUECRAD: NDLON=",I6)')NDLON
+    WRITE(NULOUT, '("SUECRAD: LLINEAR_GRID=",L5)')LLINEAR_GRID
+  ENDIF
+
+  NUAER = 24
+  NTRAER = 15
+  ! 1: max-random, 2: max, 3: random (5,6,7,8 pour meso-NH)
+  ! le CASE qui suit car les conventions sont differentes dans ARP et LMDZ (MPL 20100415)
+  SELECT CASE (overlap)
   CASE (:1)
-   NOVLP = 2    
+    NOVLP = 2
   CASE (2)
-   NOVLP = 3    
+    NOVLP = 3
   CASE (3:)
-   NOVLP = 1    
+    NOVLP = 1
   END SELECT
-print *,'SUECRAD: NOVLP=',NOVLP
-NLW    = 16
-NTSW   = 14
-!NSW    = 6    !!!!! Maintenant dans config.def (MPL 20140213)
-NSWNL  = 6
-NSWTL  = 2
-NCSRADF= 1
-IF(NSMAX >= 106) THEN
-  NRPROMA = 80
-ELSEIF(NSMAX == 63) THEN
-  NRPROMA=48
-ELSE
-  NRPROMA=64
-ENDIF
-
-!*         2.3      SET SECURITY PARAMETERS
-!                   -----------------------
-
-REPSC  = 1.E-04_JPRB
-REPSCO = 1.E-12_JPRB
-REPSCQ = 1.E-12_JPRB
-REPSCT = 1.E-12_JPRB
-REPSCW = 1.E-12_JPRB
-REPLOG = 1.E-12_JPRB
-
-
-!*          2.4     BACKGROUND GAS CONCENTRATIONS (IPCC/SACC, 1990)
-!                   -----------------------------------------------
-
-LECO2VAR=.FALSE.
-LHGHG   =.FALSE.
-NHINCSOL= 0
-NSCEN   = 1
-RSOLINC = RI0
-
-! Valeurs d origine MPL 18052010
-!RCCO2   = 353.E-06_JPRB
-!RCCH4   = 1.72E-06_JPRB
-!RCN2O   = 310.E-09_JPRB
-!RCCFC11 = 280.E-12_JPRB
-!RCCFC12 = 484.E-12_JPRB
-
-! Valeurs LMDZ (physiq.def) MPL 18052010
-!RCCO2   = 348.E-06_JPRB
-!RCCH4   = 1.65E-06_JPRB
-!RCN2O   = 306.E-09_JPRB
-!RCCFC11 = 280.E-12_JPRB
-!RCCFC12 = 484.E-12_JPRB
-
-!MPL/IM 20160915 on prend GES de phylmd
-RCCO2   = CO2_ppm * 1.0e-06
-RCCH4   = CH4_ppb * 1.0e-09
-RCN2O   = N2O_ppb * 1.0e-09
-RCCFC11 = CFC11_ppt * 1.0e-12
-RCCFC12 = CFC12_ppt * 1.0e-12
-!print *,'LMDZSUECRAD-1 RCCO2=',RCCO2
-!print *,'LMDZSUECRAD-1 RCCH4=',RCCH4
-!print *,'LMDZSUECRAD-1 RCN2O=',RCN2O
-!print *,'LMDZSUECRAD-1 RCCFC11=',RCCFC11
-!print *,'LMDZSUECRAD-1 RCCFC12=',RCCFC12
-!     ------------------------------------------------------------------
-
-!*         3.       READ VALUES OF RADIATION CONFIGURATION
-!                   --------------------------------------
-
-!CALL POSNAM(NULNAM,'NAERAD')
-!READ (NULNAM,NAERAD)
-print *,'SUECRAD-2'
-
-!CALL POSNAM(NULNAM,'NAEAER')
-!READ (NULNAM,NAEAER)
-
-!IF (NTYPAER(9) /= 0) THEN
-!  RGEMUV=(RLATVOL+90._JPRB)*RPI/180._JPRB
-!  RGELAV=RLONVOL*RPI/180._JPRB
-!  RCLONV=COS(RGELAV)
-!  RSLONV=SIN(RGELAV)
-!  DO J=1,NGPTOT-1
-!    IF (RGELAV > GELAM(J) .AND. RGELAV <= GELAM(J+1) .AND. &
-!      & RGEMUV < RMU(JL) .AND. RGEMUV >= RMU(JL+1) ) THEN
-!      RDGMUV=ABS( RMU(J+1) - RMU(J))
-!      RDGLAV=ABS( GELAM(J+1)-GELAM(J) )
-!      RDSLONV=ABS( SIN(GELAM(JL+1))-SIN(GELAM(JL)) )
-!      RDCLONV=ABS( COS(GELAM(JL+1))-COS(GELAM(JL)) )
-!    END IF
-!  END DO
-!END IF  
-
-!- reset some parameters if SW6 is used (revert to pre-CY3?R1 operational configuration)
-IF (.NOT.LSRTM) THEN
-  NMcICA = 0
-  LCCNL  = .FALSE. 
-  LCCNO  = .FALSE.
-  LDIFFC = .FALSE.
-  NICEOPT= 1
-  NLIQOPT= 0
-  NRADIP = 4
-  NRADLP = 3
-  RRe2De = 0.5_JPRB
-  NINHOM = 1
-  RLWINHF= 0.7_JPRB
-  RSWINHF= 0.7_JPRB
-ENDIF
-print *,'SUECRAD-3'
-
-!- for McICA computations, make sure these parameters are as follows ...
-IF (NMCICA /= 0) THEN
-  NINHOM = 0
-  RLWINHF= 1.0_JPRB
-  RSWINHF= 1.0_JPRB
-!-- read the XCW values for Raisanen-Cole-Barker cloud generator
-  CALL SU_McICA
-ENDIF
-print *,'SUECRAD-4'
-
-
-
-IF( LLDEBUG )THEN
-  WRITE(NULOUT,'("SUECRAD: NRADINT=",I2)')NRADINT
-  WRITE(NULOUT,'("SUECRAD: NRADRES=",I4)')NRADRES
-ENDIF
-
-!     DETERMINE WHETHER NRPROMA IS NEGATIVE AND SET LOPTRPROMA
-
-LOPTRPROMA=NRPROMA > 0
-NRPROMA=ABS(NRPROMA)
-
-IF( NRADINT > 0 .AND. NRADRES == NSMAX )THEN
-  WRITE(NULOUT,'("SUECRAD: NRADINT > 0 .AND. NRADRES = NSMAX, NRADINT RESET TO 0")')
-  NRADINT=0
-ENDIF
-
-IF( NRADINT > 0 .AND. LRAYFM .AND. NAER /= 0 .AND. .NOT.LHVOLCA )THEN
-!   This combination is not supported as aerosol data would be
-!   required to be interpolated (see radintg)
-  WRITE(NULOUT,'("SUECRAD: NRADINT>0, LRAYFM=T NAER /= 0 .AND. LHVOLCA=F,",&
-   & " NRADRES RESET TO NSMAX (NO INTERPOLATION)")')  
-  NRADRES=NSMAX
-ENDIF
-!CALL GSTATS(1818,1)      MPL 2.12.08
-
-100 CONTINUE
-
-IF( LERADI )THEN   ! START OF LERADI BLOCK
-
-  IF( NRADINT == -1 )THEN
-
-  !     INITIALISE DATA STRUCTURES REQUIRED FOR RADIATION INTERPOLATION
-
-    LODBGRADI=.FALSE.
-    CALL SUECRADI
-
-  !     INITIALISE DATA STRUCTURES REQUIRED FOR RADIATION COURSE GRID
-  !     LOAD BALANCING
-
-    LODBGRADL=.FALSE.
-!   CALL SUECRADL    ! MPL 1.12.08
-    CALL ABOR1('JUSTE APRES CALL SUECRADL COMMENTE')
-
-  ELSEIF( NRADINT == 0 )THEN
-
-    IF( NRADRES /= NSMAX )THEN
-      WRITE(NULOUT,'("SUECRAD: NRADINT=0 REQUESTED, NRADRES RESET TO NSMAX")')
-      NRADRES=NSMAX
-    ENDIF
-    RADGRID%NGPTOT=NGPTOT
-
-    NARIB1=0
-    NAROB1=0
-
-  ELSEIF( NRADINT >=1 .AND. NRADINT <= 3 )THEN
-
-    NARIB1=0
-    NAROB1=0
-
-! set the default radiation grid resolution for the current model resolution
-! if not already specified
-    IF( NRADRES == 0 )THEN
-      IF( LLINEAR_GRID )THEN                ! RATIO OF GRID-POINTS (MODEL/RAD)
-        IF( NSMAX == 63 )THEN               
-          NRADRES=21                        ! 3.62
-          LLINEAR_GRID=.FALSE.
-        ENDIF
-        IF( NSMAX ==   95 ) NRADRES=   95   ! 1.00
-        IF( NSMAX ==  159 ) NRADRES=   63   ! 5.84
-        IF( NSMAX ==  255 ) NRADRES=   95   ! 6.69
-        IF( NSMAX ==  319 ) NRADRES=  159   ! 3.87
-        IF( NSMAX ==  399 ) NRADRES=  159   ! 5.99
-        IF( NSMAX ==  511 ) NRADRES=  255   ! 3.92
-        IF( NSMAX ==  639 ) NRADRES=  319   ! 3.92
-        IF( NSMAX ==  799 ) NRADRES=  399   ! 3.94
-        IF( NSMAX == 1023 ) NRADRES=  511   ! 3.94
-        IF( NSMAX == 1279 ) NRADRES=  639       ! 
-        IF( NSMAX == 2047 ) NRADRES= 1023       ! 
-      ELSE ! NOT LINEAR GRID                
-        IF( NSMAX ==   21 ) NRADRES=   21   ! 1.00
-        IF( NSMAX ==   42 ) NRADRES=   21   ! 3.62
-        IF( NSMAX ==   63 ) NRADRES=   42   ! 2.17
-        IF( NSMAX ==  106 ) NRADRES=   63   ! 2.69
-        IF( NSMAX ==  170 ) NRADRES=   63   ! 6.69
-        IF( NSMAX ==  213 ) NRADRES=  106   ! 3.87
-        IF( NSMAX ==  266 ) NRADRES=  106   ! 5.99
-        IF( NSMAX ==  341 ) NRADRES=  170   ! 3.92
-        IF( NSMAX ==  426 ) NRADRES=  213   ! 3.92
-        IF( NSMAX ==  533 ) NRADRES=  266   ! 3.94
-        IF( NSMAX ==  682 ) NRADRES=  341   ! 3.94
+  print *, 'SUECRAD: NOVLP=', NOVLP
+  NLW = 16
+  NTSW = 14
+  !NSW    = 6    !!!!! Maintenant dans config.def (MPL 20140213)
+  NSWNL = 6
+  NSWTL = 2
+  NCSRADF = 1
+  IF(NSMAX >= 106) THEN
+    NRPROMA = 80
+  ELSEIF(NSMAX == 63) THEN
+    NRPROMA = 48
+  ELSE
+    NRPROMA = 64
+  ENDIF
+
+  !*         2.3      SET SECURITY PARAMETERS
+  !                   -----------------------
+
+  REPSC = 1.E-04_JPRB
+  REPSCO = 1.E-12_JPRB
+  REPSCQ = 1.E-12_JPRB
+  REPSCT = 1.E-12_JPRB
+  REPSCW = 1.E-12_JPRB
+  REPLOG = 1.E-12_JPRB
+
+
+  !*          2.4     BACKGROUND GAS CONCENTRATIONS (IPCC/SACC, 1990)
+  !                   -----------------------------------------------
+
+  LECO2VAR = .FALSE.
+  LHGHG = .FALSE.
+  NHINCSOL = 0
+  NSCEN = 1
+  RSOLINC = RI0
+
+  ! Valeurs d origine MPL 18052010
+  !RCCO2   = 353.E-06_JPRB
+  !RCCH4   = 1.72E-06_JPRB
+  !RCN2O   = 310.E-09_JPRB
+  !RCCFC11 = 280.E-12_JPRB
+  !RCCFC12 = 484.E-12_JPRB
+
+  ! Valeurs LMDZ (physiq.def) MPL 18052010
+  !RCCO2   = 348.E-06_JPRB
+  !RCCH4   = 1.65E-06_JPRB
+  !RCN2O   = 306.E-09_JPRB
+  !RCCFC11 = 280.E-12_JPRB
+  !RCCFC12 = 484.E-12_JPRB
+
+  !MPL/IM 20160915 on prend GES de phylmd
+  RCCO2 = CO2_ppm * 1.0e-06
+  RCCH4 = CH4_ppb * 1.0e-09
+  RCN2O = N2O_ppb * 1.0e-09
+  RCCFC11 = CFC11_ppt * 1.0e-12
+  RCCFC12 = CFC12_ppt * 1.0e-12
+  !print *,'LMDZSUECRAD-1 RCCO2=',RCCO2
+  !print *,'LMDZSUECRAD-1 RCCH4=',RCCH4
+  !print *,'LMDZSUECRAD-1 RCN2O=',RCN2O
+  !print *,'LMDZSUECRAD-1 RCCFC11=',RCCFC11
+  !print *,'LMDZSUECRAD-1 RCCFC12=',RCCFC12
+  !     ------------------------------------------------------------------
+
+  !*         3.       READ VALUES OF RADIATION CONFIGURATION
+  !                   --------------------------------------
+
+  !CALL POSNAM(NULNAM,'NAERAD')
+  !READ (NULNAM,NAERAD)
+  print *, 'SUECRAD-2'
+
+  !CALL POSNAM(NULNAM,'NAEAER')
+  !READ (NULNAM,NAEAER)
+
+  !IF (NTYPAER(9) /= 0) THEN
+  !  RGEMUV=(RLATVOL+90._JPRB)*RPI/180._JPRB
+  !  RGELAV=RLONVOL*RPI/180._JPRB
+  !  RCLONV=COS(RGELAV)
+  !  RSLONV=SIN(RGELAV)
+  !  DO J=1,NGPTOT-1
+  !    IF (RGELAV > GELAM(J) .AND. RGELAV <= GELAM(J+1) .AND. &
+  !      & RGEMUV < RMU(JL) .AND. RGEMUV >= RMU(JL+1) ) THEN
+  !      RDGMUV=ABS( RMU(J+1) - RMU(J))
+  !      RDGLAV=ABS( GELAM(J+1)-GELAM(J) )
+  !      RDSLONV=ABS( SIN(GELAM(JL+1))-SIN(GELAM(JL)) )
+  !      RDCLONV=ABS( COS(GELAM(JL+1))-COS(GELAM(JL)) )
+  !    END IF
+  !  END DO
+  !END IF
+
+  !- reset some parameters if SW6 is used (revert to pre-CY3?R1 operational configuration)
+  IF (.NOT.LSRTM) THEN
+    NMcICA = 0
+    LCCNL = .FALSE.
+    LCCNO = .FALSE.
+    LDIFFC = .FALSE.
+    NICEOPT = 1
+    NLIQOPT = 0
+    NRADIP = 4
+    NRADLP = 3
+    RRe2De = 0.5_JPRB
+    NINHOM = 1
+    RLWINHF = 0.7_JPRB
+    RSWINHF = 0.7_JPRB
+  ENDIF
+  print *, 'SUECRAD-3'
+
+  !- for McICA computations, make sure these parameters are as follows ...
+  IF (NMCICA /= 0) THEN
+    NINHOM = 0
+    RLWINHF = 1.0_JPRB
+    RSWINHF = 1.0_JPRB
+    !-- read the XCW values for Raisanen-Cole-Barker cloud generator
+    CALL SU_McICA
+  ENDIF
+  print *, 'SUECRAD-4'
+
+  IF(LLDEBUG)THEN
+    WRITE(NULOUT, '("SUECRAD: NRADINT=",I2)')NRADINT
+    WRITE(NULOUT, '("SUECRAD: NRADRES=",I4)')NRADRES
+  ENDIF
+
+  !     DETERMINE WHETHER NRPROMA IS NEGATIVE AND SET LOPTRPROMA
+
+  LOPTRPROMA = NRPROMA > 0
+  NRPROMA = ABS(NRPROMA)
+
+  IF(NRADINT > 0 .AND. NRADRES == NSMAX)THEN
+    WRITE(NULOUT, '("SUECRAD: NRADINT > 0 .AND. NRADRES = NSMAX, NRADINT RESET TO 0")')
+    NRADINT = 0
+  ENDIF
+
+  IF(NRADINT > 0 .AND. LRAYFM .AND. NAER /= 0 .AND. .NOT.LHVOLCA)THEN
+    !   This combination is not supported as aerosol data would be
+    !   required to be interpolated (see radintg)
+    WRITE(NULOUT, '("SUECRAD: NRADINT>0, LRAYFM=T NAER /= 0 .AND. LHVOLCA=F,",&
+            & " NRADRES RESET TO NSMAX (NO INTERPOLATION)")')
+    NRADRES = NSMAX
+  ENDIF
+  !CALL GSTATS(1818,1)      MPL 2.12.08
+
+  100 CONTINUE
+
+  IF(LERADI)THEN   ! START OF LERADI BLOCK
+
+    IF(NRADINT == -1)THEN
+
+      !     INITIALISE DATA STRUCTURES REQUIRED FOR RADIATION INTERPOLATION
+
+      LODBGRADI = .FALSE.
+      CALL SUECRADI
+
+      !     INITIALISE DATA STRUCTURES REQUIRED FOR RADIATION COURSE GRID
+      !     LOAD BALANCING
+
+      LODBGRADL = .FALSE.
+      !   CALL SUECRADL    ! MPL 1.12.08
+      CALL ABOR1('JUSTE APRES CALL SUECRADL COMMENTE')
+
+    ELSEIF(NRADINT == 0)THEN
+
+      IF(NRADRES /= NSMAX)THEN
+        WRITE(NULOUT, '("SUECRAD: NRADINT=0 REQUESTED, NRADRES RESET TO NSMAX")')
+        NRADRES = NSMAX
       ENDIF
-    ENDIF
-print *,'SUECRAD-5'
-
-! test if radiation grid resolution has been set
-    IF( NRADRES == 0 )THEN
-      WRITE(NULOUT,'("SUECRAD: NRADRES NOT SET OR DEFAULT FOUND,NSMAX=",I4)')NSMAX
-      CALL ABOR1('SUECRAD: NRADRES NOT SET OR DEFAULT FOUND')
-    ENDIF
-
-! test if no interpolation is required
-    IF( NRADINT > 0 .AND. NRADRES == NSMAX )THEN
-      WRITE(NULOUT,'("SUECRAD: NRADINT > 0 .AND. NRADRES = NSMAX, NRADINT RESET TO 0")')
-      NRADINT=0
-      GOTO 100
-    ENDIF
-
-!    CALL GSTATS(1818,0)       MPL 2.12.08
-    IF( CRTABLEFIL == 'not set' )THEN
-      IF( LLINEAR_GRID )THEN
-        IF( NRADRES < 1000 )THEN
-          WRITE(CRTABLEFIL,'("rtablel_2",I3.3)')NRADRES
+      RADGRID%NGPTOT = NGPTOT
+
+      NARIB1 = 0
+      NAROB1 = 0
+
+    ELSEIF(NRADINT >=1 .AND. NRADINT <= 3)THEN
+
+      NARIB1 = 0
+      NAROB1 = 0
+
+      ! set the default radiation grid resolution for the current model resolution
+      ! if not already specified
+      IF(NRADRES == 0)THEN
+        IF(LLINEAR_GRID)THEN                ! RATIO OF GRID-POINTS (MODEL/RAD)
+          IF(NSMAX == 63)THEN
+            NRADRES = 21                        ! 3.62
+            LLINEAR_GRID = .FALSE.
+          ENDIF
+          IF(NSMAX ==   95) NRADRES = 95   ! 1.00
+          IF(NSMAX ==  159) NRADRES = 63   ! 5.84
+          IF(NSMAX ==  255) NRADRES = 95   ! 6.69
+          IF(NSMAX ==  319) NRADRES = 159   ! 3.87
+          IF(NSMAX ==  399) NRADRES = 159   ! 5.99
+          IF(NSMAX ==  511) NRADRES = 255   ! 3.92
+          IF(NSMAX ==  639) NRADRES = 319   ! 3.92
+          IF(NSMAX ==  799) NRADRES = 399   ! 3.94
+          IF(NSMAX == 1023) NRADRES = 511   ! 3.94
+          IF(NSMAX == 1279) NRADRES = 639       !
+          IF(NSMAX == 2047) NRADRES = 1023       !
+        ELSE ! NOT LINEAR GRID
+          IF(NSMAX ==   21) NRADRES = 21   ! 1.00
+          IF(NSMAX ==   42) NRADRES = 21   ! 3.62
+          IF(NSMAX ==   63) NRADRES = 42   ! 2.17
+          IF(NSMAX ==  106) NRADRES = 63   ! 2.69
+          IF(NSMAX ==  170) NRADRES = 63   ! 6.69
+          IF(NSMAX ==  213) NRADRES = 106   ! 3.87
+          IF(NSMAX ==  266) NRADRES = 106   ! 5.99
+          IF(NSMAX ==  341) NRADRES = 170   ! 3.92
+          IF(NSMAX ==  426) NRADRES = 213   ! 3.92
+          IF(NSMAX ==  533) NRADRES = 266   ! 3.94
+          IF(NSMAX ==  682) NRADRES = 341   ! 3.94
+        ENDIF
+      ENDIF
+      print *, 'SUECRAD-5'
+
+      ! test if radiation grid resolution has been set
+      IF(NRADRES == 0)THEN
+        WRITE(NULOUT, '("SUECRAD: NRADRES NOT SET OR DEFAULT FOUND,NSMAX=",I4)')NSMAX
+        CALL ABOR1('SUECRAD: NRADRES NOT SET OR DEFAULT FOUND')
+      ENDIF
+
+      ! test if no interpolation is required
+      IF(NRADINT > 0 .AND. NRADRES == NSMAX)THEN
+        WRITE(NULOUT, '("SUECRAD: NRADINT > 0 .AND. NRADRES = NSMAX, NRADINT RESET TO 0")')
+        NRADINT = 0
+        GOTO 100
+      ENDIF
+
+      !    CALL GSTATS(1818,0)       MPL 2.12.08
+      IF(CRTABLEFIL == 'not set')THEN
+        IF(LLINEAR_GRID)THEN
+          IF(NRADRES < 1000)THEN
+            WRITE(CRTABLEFIL, '("rtablel_2",I3.3)')NRADRES
+          ELSE
+            WRITE(CRTABLEFIL, '("rtablel_2",I4.4)')NRADRES
+          ENDIF
         ELSE
-          WRITE(CRTABLEFIL,'("rtablel_2",I4.4)')NRADRES
-        ENDIF
-      ELSE
-        IF( NRADRES < 1000 )THEN
-          WRITE(CRTABLEFIL,'("rtable_2" ,I3.3)')NRADRES
-        ELSE
-          WRITE(CRTABLEFIL,'("rtable_2" ,I4.4)')NRADRES
+          IF(NRADRES < 1000)THEN
+            WRITE(CRTABLEFIL, '("rtable_2" ,I3.3)')NRADRES
+          ELSE
+            WRITE(CRTABLEFIL, '("rtable_2" ,I4.4)')NRADRES
+          ENDIF
         ENDIF
       ENDIF
-    ENDIF
-!    CALL GSTATS(1818,1)       MPL 2.12.08
-
-    RADGRID%NSMAX=NRADRES
-
-    IF( MYPROC == JPIOMASTER )THEN
-      IDIR=LEN_TRIM(CRTABLEDIR)
-      IFIL=LEN_TRIM(CRTABLEFIL)
-      CLFN=CRTABLEDIR(1:IDIR)//CRTABLEFIL(1:IFIL)
-! Ce qui concerne NULRAD commente par MPL le 15.04.09
-!     OPEN(NULRAD,FILE=CLFN,ACTION="READ",ERR=999)
-!     GOTO 1000
-!     999 CONTINUE
-!     WRITE(NULOUT,'("SUECRAD: UNABLE TO OPEN FILE ",A)')CLFN
-!     CALL ABOR1('SUECRAD: UNABLE TO OPEN RADIATION GRID RTABLE FILE')
-!     1000 CONTINUE
-      NRGRI(:)=0
-! Ce qui concerne NAMRGRI commente par MPL le 15.04.09
-!     CALL POSNAM(NULRAD,'NAMRGRI')
-!     READ (NULRAD,NAMRGRI)
-      IDGL=1
-      DO WHILE( NRGRI(IDGL)>0 )
-        IF( LLDEBUG )THEN
-          WRITE(NULOUT,'("SUECRAD: NRGRI(",I4,")=",I4)')IDGL,NRGRI(IDGL)
-        ENDIF
-        IDGL=IDGL+1
-      ENDDO
-      IDGL=IDGL-1
-      RADGRID%NDGLG=IDGL
-      IF( LLDEBUG )THEN
-        WRITE(NULOUT,'("SUECRAD: RADGRID%NDGLG=",I4)')RADGRID%NDGLG
+      !    CALL GSTATS(1818,1)       MPL 2.12.08
+
+      RADGRID%NSMAX = NRADRES
+
+      IF(MYPROC == JPIOMASTER)THEN
+        IDIR = LEN_TRIM(CRTABLEDIR)
+        IFIL = LEN_TRIM(CRTABLEFIL)
+        CLFN = CRTABLEDIR(1:IDIR) // CRTABLEFIL(1:IFIL)
+        ! Ce qui concerne NULRAD commente par MPL le 15.04.09
+        !     OPEN(NULRAD,FILE=CLFN,ACTION="READ",ERR=999)
+        !     GOTO 1000
+        !     999 CONTINUE
+        !     WRITE(NULOUT,'("SUECRAD: UNABLE TO OPEN FILE ",A)')CLFN
+        !     CALL ABOR1('SUECRAD: UNABLE TO OPEN RADIATION GRID RTABLE FILE')
+        !     1000 CONTINUE
+        NRGRI(:) = 0
+        ! Ce qui concerne NAMRGRI commente par MPL le 15.04.09
+        !     CALL POSNAM(NULRAD,'NAMRGRI')
+        !     READ (NULRAD,NAMRGRI)
+        IDGL = 1
+        DO WHILE(NRGRI(IDGL)>0)
+          IF(LLDEBUG)THEN
+            WRITE(NULOUT, '("SUECRAD: NRGRI(",I4,")=",I4)')IDGL, NRGRI(IDGL)
+          ENDIF
+          IDGL = IDGL + 1
+        ENDDO
+        IDGL = IDGL - 1
+        RADGRID%NDGLG = IDGL
+        IF(LLDEBUG)THEN
+          WRITE(NULOUT, '("SUECRAD: RADGRID%NDGLG=",I4)')RADGRID%NDGLG
+        ENDIF
+        !     CLOSE(NULRAD)
       ENDIF
-!     CLOSE(NULRAD)
-    ENDIF
-!    CALL GSTATS(667,0)     MPL 2.12.08
-    IF( NPROC > 1 )THEN
-      stop 'Pas pret pour proc > 1'
-!     CALL MPL_BROADCAST (RADGRID%NDGLG,MTAGRAD,JPIOMASTER,CDSTRING='SUECRAD:')
-    ENDIF
-    ALLOCATE(RADGRID%NRGRI(RADGRID%NDGLG))
-    IF( MYPROC == JPIOMASTER )THEN
-      RADGRID%NRGRI(1:RADGRID%NDGLG)=NRGRI(1:RADGRID%NDGLG)
-    ENDIF
-    IF( NPROC > 1 )THEN
-      stop 'Pas pret pour proc > 1'
-!     CALL MPL_BROADCAST (RADGRID%NRGRI(1:RADGRID%NDGLG),MTAGRAD,JPIOMASTER,CDSTRING='SUECRAD:')
-    ENDIF
-!    CALL GSTATS(667,1)      MPL 2.12.08
-
-!    CALL GSTATS(1818,0)     MPL 2.12.08
-    IF    ( NRADINT == 1 )THEN
-      WRITE(NULOUT,'("SUECRAD: INTERPOLATION METHOD - SPECTRAL TRANSFORM")')
-      RADGRID%NDGSUR=0
-      NRIWIDEN=0
-      NRIWIDES=0
-      NRIWIDEW=0
-      NRIWIDEE=0
-      NROWIDEN=0
-      NROWIDES=0
-      NROWIDEW=0
-      NROWIDEE=0
-    ELSEIF( NRADINT == 2 )THEN
-      WRITE(NULOUT,'("SUECRAD: INTERPOLATION METHOD - 4 POINT")')
-      RADGRID%NDGSUR=2
-    ELSEIF( NRADINT == 3 )THEN
-      WRITE(NULOUT,'("SUECRAD: INTERPOLATION METHOD - 12 POINT")')
-      RADGRID%NDGSUR=2
-    ENDIF
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDGSUR       =",I8)')RADGRID%NDGSUR
-
-    RADGRID%NDGSAG=1-RADGRID%NDGSUR
-    RADGRID%NDGENG=RADGRID%NDGLG+RADGRID%NDGSUR
-    RADGRID%NDLON=RADGRID%NRGRI(RADGRID%NDGLG/2)
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDGSAG       =",I8)')RADGRID%NDGSAG
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDGENG       =",I8)')RADGRID%NDGENG
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDGLG        =",I8)')RADGRID%NDGLG
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDLON        =",I8)')RADGRID%NDLON
-    CALL FLUSH(NULOUT)
-
-    ALLOCATE(RADGRID%NLOENG(RADGRID%NDGSAG:RADGRID%NDGENG))
-    RADGRID%NLOENG(1:RADGRID%NDGLG)=RADGRID%NRGRI(1:RADGRID%NDGLG)
-    IF(RADGRID%NDGSUR >= 1)THEN
-      DO JGLSUR=1,RADGRID%NDGSUR
-        RADGRID%NLOENG(1-JGLSUR)=RADGRID%NLOENG(JGLSUR)
-      ENDDO
-      DO JGLSUR=1,RADGRID%NDGSUR
-        RADGRID%NLOENG(RADGRID%NDGLG+JGLSUR)=RADGRID%NLOENG(RADGRID%NDGLG+1-JGLSUR)
-      ENDDO
-    ENDIF
-!     CALL GSTATS(1818,1)     MPL 2.12.08
-
-! Setup the transform package for the radiation grid
-    CALL SETUP_TRANS (KSMAX=RADGRID%NSMAX, &
-     & KDGL=RADGRID%NDGLG, &
-     & KLOEN=RADGRID%NLOENG(1:RADGRID%NDGLG), &
-     & LDLINEAR_GRID=LLINEAR_GRID, &
-     & LDSPLIT=LSPLIT, &
-     & KAPSETS=NAPSETS, &
-     & KRESOL=RADGRID%NRESOL_ID)
-
-    ALLOCATE(RADGRID%NSTA(RADGRID%NDGSAG:RADGRID%NDGENG+N_REGIONS_NS-1,N_REGIONS_EW))
-    ALLOCATE(RADGRID%NONL(RADGRID%NDGSAG:RADGRID%NDGENG+N_REGIONS_NS-1,N_REGIONS_EW))
-    ALLOCATE(RADGRID%NPTRFRSTLAT(N_REGIONS_NS))
-    ALLOCATE(RADGRID%NFRSTLAT(N_REGIONS_NS))
-    ALLOCATE(RADGRID%NLSTLAT(N_REGIONS_NS))
-    ALLOCATE(RADGRID%RMU(RADGRID%NDGSAG:RADGRID%NDGENG))
-    ALLOCATE(RADGRID%RSQM2(RADGRID%NDGSAG:RADGRID%NDGENG))
-    ALLOCATE(RADGRID%RLATIG(RADGRID%NDGSAG:RADGRID%NDGENG))
-
-! Interrogate the transform package for the radiation grid
-!    CALL GSTATS(1818,0)    MPL 2.12.08
-    CALL TRANS_INQ (KRESOL     =RADGRID%NRESOL_ID, &
-     & KSPEC2     =RADGRID%NSPEC2, &
-     & KNUMP      =RADGRID%NUMP, &
-     & KGPTOT     =RADGRID%NGPTOT, &
-     & KGPTOTG    =RADGRID%NGPTOTG, &
-     & KGPTOTMX   =RADGRID%NGPTOTMX, &
-     & KPTRFRSTLAT=RADGRID%NPTRFRSTLAT, &
-     & KFRSTLAT   =RADGRID%NFRSTLAT, &
-     & KLSTLAT    =RADGRID%NLSTLAT, &
-     & KFRSTLOFF  =RADGRID%NFRSTLOFF, &
-     & KSTA       =RADGRID%NSTA(1:RADGRID%NDGLG+N_REGIONS_NS-1,:), &
-     & KONL       =RADGRID%NONL(1:RADGRID%NDGLG+N_REGIONS_NS-1,:), &
-     & KPTRFLOFF  =RADGRID%NPTRFLOFF, &
-     & PMU        =RADGRID%RMU(1:) )  
-
-    IF( NRADINT == 2 .OR. NRADINT == 3 )THEN
-      DO JGL=1,RADGRID%NDGLG
-        RADGRID%RSQM2(JGL) = SQRT(1.0_JPRB - RADGRID%RMU(JGL)*RADGRID%RMU(JGL))
-        RADGRID%RLATIG(JGL) = ASIN(RADGRID%RMU(JGL))
-!       WRITE(NULOUT,'("SUECRAD: JGL=",I6," RADGRID%RLATIG=",F10.3)')&
-!        & JGL,RADGRID%RLATIG(JGL)
-      ENDDO
+      !    CALL GSTATS(667,0)     MPL 2.12.08
+      IF(NPROC > 1)THEN
+        stop 'Pas pret pour proc > 1'
+        !     CALL MPL_BROADCAST (RADGRID%NDGLG,MTAGRAD,JPIOMASTER,CDSTRING='SUECRAD:')
+      ENDIF
+      ALLOCATE(RADGRID%NRGRI(RADGRID%NDGLG))
+      IF(MYPROC == JPIOMASTER)THEN
+        RADGRID%NRGRI(1:RADGRID%NDGLG) = NRGRI(1:RADGRID%NDGLG)
+      ENDIF
+      IF(NPROC > 1)THEN
+        stop 'Pas pret pour proc > 1'
+        !     CALL MPL_BROADCAST (RADGRID%NRGRI(1:RADGRID%NDGLG),MTAGRAD,JPIOMASTER,CDSTRING='SUECRAD:')
+      ENDIF
+      !    CALL GSTATS(667,1)      MPL 2.12.08
+
+      !    CALL GSTATS(1818,0)     MPL 2.12.08
+      IF    (NRADINT == 1)THEN
+        WRITE(NULOUT, '("SUECRAD: INTERPOLATION METHOD - SPECTRAL TRANSFORM")')
+        RADGRID%NDGSUR = 0
+        NRIWIDEN = 0
+        NRIWIDES = 0
+        NRIWIDEW = 0
+        NRIWIDEE = 0
+        NROWIDEN = 0
+        NROWIDES = 0
+        NROWIDEW = 0
+        NROWIDEE = 0
+      ELSEIF(NRADINT == 2)THEN
+        WRITE(NULOUT, '("SUECRAD: INTERPOLATION METHOD - 4 POINT")')
+        RADGRID%NDGSUR = 2
+      ELSEIF(NRADINT == 3)THEN
+        WRITE(NULOUT, '("SUECRAD: INTERPOLATION METHOD - 12 POINT")')
+        RADGRID%NDGSUR = 2
+      ENDIF
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDGSUR       =",I8)')RADGRID%NDGSUR
+
+      RADGRID%NDGSAG = 1 - RADGRID%NDGSUR
+      RADGRID%NDGENG = RADGRID%NDGLG + RADGRID%NDGSUR
+      RADGRID%NDLON = RADGRID%NRGRI(RADGRID%NDGLG / 2)
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDGSAG       =",I8)')RADGRID%NDGSAG
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDGENG       =",I8)')RADGRID%NDGENG
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDGLG        =",I8)')RADGRID%NDGLG
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDLON        =",I8)')RADGRID%NDLON
+      CALL FLUSH(NULOUT)
+
+      ALLOCATE(RADGRID%NLOENG(RADGRID%NDGSAG:RADGRID%NDGENG))
+      RADGRID%NLOENG(1:RADGRID%NDGLG) = RADGRID%NRGRI(1:RADGRID%NDGLG)
       IF(RADGRID%NDGSUR >= 1)THEN
-        DO JGLSUR=1,RADGRID%NDGSUR
-          RADGRID%RMU(1-JGLSUR)=RADGRID%RMU(JGLSUR)
-          RADGRID%RSQM2(1-JGLSUR)=RADGRID%RSQM2(JGLSUR)
-          RADGRID%RLATIG(1-JGLSUR)=RPI-RADGRID%RLATIG(JGLSUR)
+        DO JGLSUR = 1, RADGRID%NDGSUR
+          RADGRID%NLOENG(1 - JGLSUR) = RADGRID%NLOENG(JGLSUR)
         ENDDO
-        DO JGLSUR=1,RADGRID%NDGSUR
-          RADGRID%RMU(RADGRID%NDGLG+JGLSUR)=RADGRID%RMU(RADGRID%NDGLG+1-JGLSUR)
-          RADGRID%RSQM2(RADGRID%NDGLG+JGLSUR)=RADGRID%RSQM2(RADGRID%NDGLG+1-JGLSUR)
-          RADGRID%RLATIG(RADGRID%NDGLG+JGLSUR)=-RPI-RADGRID%RLATIG(RADGRID%NDGLG+1-JGLSUR)
+        DO JGLSUR = 1, RADGRID%NDGSUR
+          RADGRID%NLOENG(RADGRID%NDGLG + JGLSUR) = RADGRID%NLOENG(RADGRID%NDGLG + 1 - JGLSUR)
         ENDDO
       ENDIF
+      !     CALL GSTATS(1818,1)     MPL 2.12.08
+
+      ! Setup the transform package for the radiation grid
+      CALL SETUP_TRANS (KSMAX = RADGRID%NSMAX, &
+              & KDGL = RADGRID%NDGLG, &
+              & KLOEN = RADGRID%NLOENG(1:RADGRID%NDGLG), &
+              & LDLINEAR_GRID = LLINEAR_GRID, &
+              & LDSPLIT = LSPLIT, &
+              & KAPSETS = NAPSETS, &
+              & KRESOL = RADGRID%NRESOL_ID)
+
+      ALLOCATE(RADGRID%NSTA(RADGRID%NDGSAG:RADGRID%NDGENG + N_REGIONS_NS - 1, N_REGIONS_EW))
+      ALLOCATE(RADGRID%NONL(RADGRID%NDGSAG:RADGRID%NDGENG + N_REGIONS_NS - 1, N_REGIONS_EW))
+      ALLOCATE(RADGRID%NPTRFRSTLAT(N_REGIONS_NS))
+      ALLOCATE(RADGRID%NFRSTLAT(N_REGIONS_NS))
+      ALLOCATE(RADGRID%NLSTLAT(N_REGIONS_NS))
+      ALLOCATE(RADGRID%RMU(RADGRID%NDGSAG:RADGRID%NDGENG))
+      ALLOCATE(RADGRID%RSQM2(RADGRID%NDGSAG:RADGRID%NDGENG))
+      ALLOCATE(RADGRID%RLATIG(RADGRID%NDGSAG:RADGRID%NDGENG))
+
+      ! Interrogate the transform package for the radiation grid
+      !    CALL GSTATS(1818,0)    MPL 2.12.08
+      CALL TRANS_INQ (KRESOL = RADGRID%NRESOL_ID, &
+              & KSPEC2 = RADGRID%NSPEC2, &
+              & KNUMP = RADGRID%NUMP, &
+              & KGPTOT = RADGRID%NGPTOT, &
+              & KGPTOTG = RADGRID%NGPTOTG, &
+              & KGPTOTMX = RADGRID%NGPTOTMX, &
+              & KPTRFRSTLAT = RADGRID%NPTRFRSTLAT, &
+              & KFRSTLAT = RADGRID%NFRSTLAT, &
+              & KLSTLAT = RADGRID%NLSTLAT, &
+              & KFRSTLOFF = RADGRID%NFRSTLOFF, &
+              & KSTA = RADGRID%NSTA(1:RADGRID%NDGLG + N_REGIONS_NS - 1, :), &
+              & KONL = RADGRID%NONL(1:RADGRID%NDGLG + N_REGIONS_NS - 1, :), &
+              & KPTRFLOFF = RADGRID%NPTRFLOFF, &
+              & PMU = RADGRID%RMU(1:))
+
+      IF(NRADINT == 2 .OR. NRADINT == 3)THEN
+        DO JGL = 1, RADGRID%NDGLG
+          RADGRID%RSQM2(JGL) = SQRT(1.0_JPRB - RADGRID%RMU(JGL) * RADGRID%RMU(JGL))
+          RADGRID%RLATIG(JGL) = ASIN(RADGRID%RMU(JGL))
+          !       WRITE(NULOUT,'("SUECRAD: JGL=",I6," RADGRID%RLATIG=",F10.3)')&
+          !        & JGL,RADGRID%RLATIG(JGL)
+        ENDDO
+        IF(RADGRID%NDGSUR >= 1)THEN
+          DO JGLSUR = 1, RADGRID%NDGSUR
+            RADGRID%RMU(1 - JGLSUR) = RADGRID%RMU(JGLSUR)
+            RADGRID%RSQM2(1 - JGLSUR) = RADGRID%RSQM2(JGLSUR)
+            RADGRID%RLATIG(1 - JGLSUR) = RPI - RADGRID%RLATIG(JGLSUR)
+          ENDDO
+          DO JGLSUR = 1, RADGRID%NDGSUR
+            RADGRID%RMU(RADGRID%NDGLG + JGLSUR) = RADGRID%RMU(RADGRID%NDGLG + 1 - JGLSUR)
+            RADGRID%RSQM2(RADGRID%NDGLG + JGLSUR) = RADGRID%RSQM2(RADGRID%NDGLG + 1 - JGLSUR)
+            RADGRID%RLATIG(RADGRID%NDGLG + JGLSUR) = -RPI - RADGRID%RLATIG(RADGRID%NDGLG + 1 - JGLSUR)
+          ENDDO
+        ENDIF
+      ENDIF
+
+      RADGRID%NDGSAL = 1
+      RADGRID%NDGENL = RADGRID%NLSTLAT(MY_REGION_NS) - RADGRID%NFRSTLOFF
+      RADGRID%NDSUR1 = 3 - MOD(RADGRID%NDLON, 2)
+      IDLSUR = MAX(RADGRID%NDLON, 2 * RADGRID%NSMAX + 1)
+      RADGRID%NDLSUR = IDLSUR + RADGRID%NDSUR1
+      RADGRID%MYFRSTACTLAT = RADGRID%NFRSTLAT(MY_REGION_NS)
+      RADGRID%MYLSTACTLAT = RADGRID%NLSTLAT(MY_REGION_NS)
+
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NRESOL_ID    =",I8)')RADGRID%NRESOL_ID
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NSMAX        =",I8)')RADGRID%NSMAX
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NSPEC2       =",I8)')RADGRID%NSPEC2
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NGPTOT       =",I8)')RADGRID%NGPTOT
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NGPTOTG      =",I8)')RADGRID%NGPTOTG
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDGSAL       =",I8)')RADGRID%NDGSAL
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDGENL       =",I8)')RADGRID%NDGENL
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDSUR1       =",I8)')RADGRID%NDSUR1
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDLSUR       =",I8)')RADGRID%NDLSUR
+      WRITE(NULOUT, '("SUECRAD: RADGRID%MYFRSTACTLAT =",I8)')RADGRID%MYFRSTACTLAT
+      WRITE(NULOUT, '("SUECRAD: RADGRID%MYLSTACTLAT  =",I8)')RADGRID%MYLSTACTLAT
+      CALL FLUSH(NULOUT)
+
+      ALLOCATE(RADGRID%NASM0(0:RADGRID%NSPEC2))
+      ALLOCATE(RADGRID%MYMS(RADGRID%NUMP))
+      CALL TRANS_INQ (KRESOL = RADGRID%NRESOL_ID, &
+              & KASM0 = RADGRID%NASM0, &
+              & KMYMS = RADGRID%MYMS)
+
+      ALLOCATE(RADGRID%GELAM(RADGRID%NGPTOT))
+      ALLOCATE(RADGRID%GELAT(RADGRID%NGPTOT))
+      ALLOCATE(RADGRID%GESLO(RADGRID%NGPTOT))
+      ALLOCATE(RADGRID%GECLO(RADGRID%NGPTOT))
+      ALLOCATE(RADGRID%GEMU (RADGRID%NGPTOT))
+
+      IOFF = 0
+      ILAT = RADGRID%NPTRFLOFF
+      DO JGLAT = RADGRID%NFRSTLAT(MY_REGION_NS), &
+              & RADGRID%NLSTLAT(MY_REGION_NS)
+        ZGEMU = RADGRID%RMU(JGLAT)
+        ILAT = ILAT + 1
+        ISTLON = RADGRID%NSTA(ILAT, MY_REGION_EW)
+        IENDLON = ISTLON - 1 + RADGRID%NONL(ILAT, MY_REGION_EW)
+
+        DO JLON = ISTLON, IENDLON
+          ZLON = REAL(JLON - 1, JPRB) * 2.0_JPRB * RPI &
+                  & / REAL(RADGRID%NLOENG(JGLAT), JPRB)
+          IOFF = IOFF + 1
+          RADGRID%GELAM(IOFF) = ZLON
+          RADGRID%GELAT(IOFF) = ASIN(ZGEMU)
+          RADGRID%GESLO(IOFF) = SIN(ZLON)
+          RADGRID%GECLO(IOFF) = COS(ZLON)
+          RADGRID%GEMU (IOFF) = ZGEMU
+        ENDDO
+      ENDDO
+
+      IF(NRADINT == 2 .OR. NRADINT == 3)THEN
+
+        !   For grid point interpolations we need to calculate the halo size
+        !   required by each processor
+
+        ALLOCATE(ZLATX(RADGRID%NGPTOTMX))
+        ALLOCATE(ZLONX(RADGRID%NGPTOTMX))
+        DO J = 1, RADGRID%NGPTOT
+          ZLATX(J) = RADGRID%GELAT(J) / RPI * 2.0_JPRB * 90.0
+          ZLONX(J) = (RADGRID%GELAM(J) - RPI) / RPI * 180.0
+        ENDDO
+        ZMINRADLAT = MINVAL(ZLATX(1:RADGRID%NGPTOT))
+        ZMAXRADLAT = MAXVAL(ZLATX(1:RADGRID%NGPTOT))
+        ZMINRADLON = MINVAL(ZLONX(1:RADGRID%NGPTOT))
+        ZMAXRADLON = MAXVAL(ZLONX(1:RADGRID%NGPTOT))
+        IF(LLDEBUG)THEN
+          WRITE(NULOUT, '("RADGRID,BEGIN")')
+          IF(MYPROC /= 1)THEN
+            stop 'Pas pret pour proc > 1'
+            !         CALL MPL_SEND(RADGRID%NGPTOT,KDEST=NPRCIDS(1),KTAG=1,CDSTRING='SUECRAD.R')
+            !         CALL MPL_SEND(ZLATX(1:RADGRID%NGPTOT),KDEST=NPRCIDS(1),KTAG=2,CDSTRING='SUECRAD.R')
+            !         CALL MPL_SEND(ZLONX(1:RADGRID%NGPTOT),KDEST=NPRCIDS(1),KTAG=3,CDSTRING='SUECRAD.R')
+          ENDIF
+          IF(MYPROC == 1)THEN
+            DO JROC = 1, NPROC
+              IF(JROC == MYPROC)THEN
+                DO J = 1, RADGRID%NGPTOT
+                  WRITE(NULOUT, '(F7.2,2X,F7.2,2X,I6)')ZLATX(J), ZLONX(J), MYPROC
+                ENDDO
+              ELSE
+                stop 'Pas pret pour proc > 1'
+                !             CALL MPL_RECV(IGPTOT,KSOURCE=NPRCIDS(JROC),KTAG=1,CDSTRING='SUECRAD.M')
+                !             CALL MPL_RECV(ZLATX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=2,CDSTRING='SUECRAD.M')
+                !             CALL MPL_RECV(ZLONX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=3,CDSTRING='SUECRAD.M')
+                DO J = 1, IGPTOT
+                  WRITE(NULOUT, '(F7.2,2X,F7.2,2X,I6)')ZLATX(J), ZLONX(J), JROC
+                ENDDO
+              ENDIF
+            ENDDO
+          ENDIF
+          WRITE(NULOUT, '("RADGRID,END")')
+        ENDIF
+        DEALLOCATE(ZLATX)
+        DEALLOCATE(ZLONX)
+
+        ALLOCATE(ZLATX(NGPTOTMX))
+        ALLOCATE(ZLONX(NGPTOTMX))
+        DO J = 1, NGPTOT
+          ZLATX(J) = GELAT(J) / RPI * 2.0_JPRB * 90.0
+          ZLONX(J) = (GELAM(J) - RPI) / RPI * 180.0
+        ENDDO
+        ZMINMDLLAT = MINVAL(ZLATX(1:NGPTOT))
+        ZMAXMDLLAT = MAXVAL(ZLATX(1:NGPTOT))
+        ZMINMDLLON = MINVAL(ZLONX(1:NGPTOT))
+        ZMAXMDLLON = MAXVAL(ZLONX(1:NGPTOT))
+        IF(LLDEBUG)THEN
+          WRITE(NULOUT, '("MODELGRID,BEGIN")')
+          IF(MYPROC /= 1)THEN
+            stop 'Pas pret pour proc > 1'
+            !         CALL MPL_SEND(NGPTOT,KDEST=NPRCIDS(1),KTAG=1,CDSTRING='SUECRAD')
+            !         CALL MPL_SEND(ZLATX(1:NGPTOT),KDEST=NPRCIDS(1),KTAG=2,CDSTRING='SUECRAD')
+            !         CALL MPL_SEND(ZLONX(1:NGPTOT),KDEST=NPRCIDS(1),KTAG=3,CDSTRING='SUECRAD')
+            !         CALL MPL_SEND(NGLOBALINDEX(1:NGPTOT),KDEST=NPRCIDS(1),KTAG=4,CDSTRING='SUECRAD')
+          ENDIF
+          IF(MYPROC == 1)THEN
+            DO JROC = 1, NPROC
+              IF(JROC == MYPROC)THEN
+                DO J = 1, NGPTOT
+                  WRITE(NULOUT, '(F7.2,2X,F7.2,2X,I6,2X,I12)')ZLATX(J), ZLONX(J), MYPROC, NGLOBALINDEX(J)
+                ENDDO
+              ELSE
+                stop 'Pas pret pour proc > 1'
+                !             CALL MPL_RECV(IGPTOT,KSOURCE=NPRCIDS(JROC),KTAG=1,CDSTRING='SUECRAD')
+                !             CALL MPL_RECV(ZLATX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=2,CDSTRING='SUECRAD')
+                !             CALL MPL_RECV(ZLONX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=3,CDSTRING='SUECRAD')
+                ALLOCATE(IGLOBALINDEX(1:IGPTOT))
+                !             CALL MPL_RECV(IGLOBALINDEX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=4,CDSTRING='SUECRAD')
+                DO J = 1, IGPTOT
+                  WRITE(NULOUT, '(F7.2,2X,F7.2,2X,I6,2X,I12)')ZLATX(J), ZLONX(J), JROC, IGLOBALINDEX(J)
+                ENDDO
+                DEALLOCATE(IGLOBALINDEX)
+              ENDIF
+            ENDDO
+          ENDIF
+          WRITE(NULOUT, '("MODELGRID,END")')
+        ENDIF
+        DEALLOCATE(ZLATX)
+        DEALLOCATE(ZLONX)
+
+        IF(LLDEBUG)THEN
+          WRITE(NULOUT, '("ZMINRADLAT=",F10.2)')ZMINRADLAT
+          WRITE(NULOUT, '("ZMINMDLLAT=",F10.2)')ZMINMDLLAT
+          WRITE(NULOUT, '("ZMAXRADLAT=",F10.2)')ZMAXRADLAT
+          WRITE(NULOUT, '("ZMAXMDLLAT=",F10.2)')ZMAXMDLLAT
+          WRITE(NULOUT, '("ZMINRADLON=",F10.2)')ZMINRADLON
+          WRITE(NULOUT, '("ZMINMDLLON=",F10.2)')ZMINMDLLON
+          WRITE(NULOUT, '("ZMAXRADLON=",F10.2)')ZMAXRADLON
+          WRITE(NULOUT, '("ZMAXMDLLON=",F10.2)')ZMAXMDLLON
+        ENDIF
+
+        ZLAT = NDGLG / 180.
+        ILATS_DIFF_C = CEILING(ABS(ZMINRADLAT - ZMINMDLLAT) * ZLAT)
+        ILATS_DIFF_F = FLOOR  (ABS(ZMINRADLAT - ZMINMDLLAT) * ZLAT)
+        IF(ZMINRADLAT < ZMINMDLLAT)THEN
+          NRIWIDES = JP_MIN_HALO + ILATS_DIFF_C
+        ELSE
+          NRIWIDES = MAX(0, JP_MIN_HALO - ILATS_DIFF_F)
+        ENDIF
+        ILATS_DIFF_C = CEILING(ABS(ZMAXRADLAT - ZMAXMDLLAT) * ZLAT)
+        ILATS_DIFF_F = FLOOR  (ABS(ZMAXRADLAT - ZMAXMDLLAT) * ZLAT)
+        IF(ZMAXRADLAT < ZMAXMDLLAT)THEN
+          NRIWIDEN = MAX(0, JP_MIN_HALO - ILATS_DIFF_F)
+        ELSE
+          NRIWIDEN = JP_MIN_HALO + ILATS_DIFF_C
+        ENDIF
+        ILATS_DIFF_C = CEILING(ABS(ZMINRADLON - ZMINMDLLON) * ZLAT)
+        ILATS_DIFF_F = FLOOR  (ABS(ZMINRADLON - ZMINMDLLON) * ZLAT)
+        IF(ZMINRADLON < ZMINMDLLON)THEN
+          NRIWIDEW = JP_MIN_HALO + ILATS_DIFF_C
+        ELSE
+          NRIWIDEW = MAX(0, JP_MIN_HALO - ILATS_DIFF_F)
+        ENDIF
+        ILATS_DIFF_C = CEILING(ABS(ZMAXRADLON - ZMAXMDLLON) * ZLAT)
+        ILATS_DIFF_F = FLOOR  (ABS(ZMAXRADLON - ZMAXMDLLON) * ZLAT)
+        IF(ZMAXRADLON < ZMAXMDLLON)THEN
+          NRIWIDEE = MAX(0, JP_MIN_HALO - ILATS_DIFF_F)
+        ELSE
+          NRIWIDEE = JP_MIN_HALO + ILATS_DIFF_C
+        ENDIF
+
+        ZLAT = RADGRID%NDGLG / 180.
+        ILATS_DIFF_C = CEILING(ABS(ZMINRADLAT - ZMINMDLLAT) * ZLAT)
+        ILATS_DIFF_F = FLOOR  (ABS(ZMINRADLAT - ZMINMDLLAT) * ZLAT)
+        IF(ZMINMDLLAT < ZMINRADLAT)THEN
+          NROWIDES = JP_MIN_HALO + ILATS_DIFF_C
+        ELSE
+          NROWIDES = MAX(0, JP_MIN_HALO - ILATS_DIFF_F)
+        ENDIF
+        ILATS_DIFF_C = CEILING(ABS(ZMAXRADLAT - ZMAXMDLLAT) * ZLAT)
+        ILATS_DIFF_F = FLOOR  (ABS(ZMAXRADLAT - ZMAXMDLLAT) * ZLAT)
+        IF(ZMAXMDLLAT < ZMAXRADLAT)THEN
+          NROWIDEN = MAX(0, JP_MIN_HALO - ILATS_DIFF_F)
+        ELSE
+          NROWIDEN = JP_MIN_HALO + ILATS_DIFF_C
+        ENDIF
+        ILATS_DIFF_C = CEILING(ABS(ZMINRADLON - ZMINMDLLON) * ZLAT)
+        ILATS_DIFF_F = FLOOR  (ABS(ZMINRADLON - ZMINMDLLON) * ZLAT)
+        IF(ZMINMDLLON < ZMINRADLON)THEN
+          NROWIDEW = JP_MIN_HALO + ILATS_DIFF_C
+        ELSE
+          NROWIDEW = MAX(0, JP_MIN_HALO - ILATS_DIFF_F)
+        ENDIF
+        ILATS_DIFF_C = CEILING(ABS(ZMAXRADLON - ZMAXMDLLON) * ZLAT)
+        ILATS_DIFF_F = FLOOR  (ABS(ZMAXRADLON - ZMAXMDLLON) * ZLAT)
+        IF(ZMAXMDLLON < ZMAXRADLON)THEN
+          NROWIDEE = MAX(0, JP_MIN_HALO - ILATS_DIFF_F)
+        ELSE
+          NROWIDEE = JP_MIN_HALO + ILATS_DIFF_C
+        ENDIF
+
+      ENDIF
+
+      RADGRID%NDGSAH = MAX(RADGRID%NDGSAG, &
+              & RADGRID%NDGSAL + RADGRID%NFRSTLOFF - NROWIDEN) - RADGRID%NFRSTLOFF
+      RADGRID%NDGENH = MIN(RADGRID%NDGENG, &
+              & RADGRID%NDGENL + RADGRID%NFRSTLOFF + NROWIDES) - RADGRID%NFRSTLOFF
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDGSAH       =",I8)')RADGRID%NDGSAH
+      WRITE(NULOUT, '("SUECRAD: RADGRID%NDGENH       =",I8)')RADGRID%NDGENH
+
+      IF(NRADINT == 2 .OR. NRADINT == 3)THEN
+
+        ILBRLATI = MAX(RADGRID%NDGSAG, &
+                & RADGRID%NDGSAL + RADGRID%NFRSTLOFF - NROWIDEN) - RADGRID%NFRSTLOFF
+        IUBRLATI = MIN(RADGRID%NDGENG, &
+                & RADGRID%NDGENL + RADGRID%NFRSTLOFF + NROWIDES) - RADGRID%NFRSTLOFF
+        ALLOCATE(RADGRID%RLATI(ILBRLATI:IUBRLATI))
+        ALLOCATE(RADGRID%RIPI0(ILBRLATI:IUBRLATI))
+        ALLOCATE(RADGRID%RIPI1(ILBRLATI:IUBRLATI))
+        ALLOCATE(RADGRID%RIPI2(ILBRLATI:IUBRLATI))
+
+        DO JGL = ILBRLATI, IUBRLATI
+          IGLGLO = JGL + RADGRID%NFRSTLOFF
+          IF(IGLGLO >= 0.AND.IGLGLO <= RADGRID%NDGLG) THEN
+            ZD1 = RADGRID%RLATIG(IGLGLO - 1) - RADGRID%RLATIG(IGLGLO)
+            ZD2 = RADGRID%RLATIG(IGLGLO - 1) - RADGRID%RLATIG(IGLGLO + 1)
+            ZD3 = RADGRID%RLATIG(IGLGLO - 1) - RADGRID%RLATIG(IGLGLO + 2)
+            ZD4 = RADGRID%RLATIG(IGLGLO) - RADGRID%RLATIG(IGLGLO + 1)
+            ZD5 = RADGRID%RLATIG(IGLGLO) - RADGRID%RLATIG(IGLGLO + 2)
+            ZD6 = RADGRID%RLATIG(IGLGLO + 1) - RADGRID%RLATIG(IGLGLO + 2)
+            RADGRID%RIPI0(JGL) = -1.0_JPRB / (ZD1 * ZD4 * ZD5)
+            RADGRID%RIPI1(JGL) = 1.0_JPRB / (ZD2 * ZD4 * ZD6)
+            RADGRID%RIPI2(JGL) = -1.0_JPRB / (ZD3 * ZD5 * ZD6)
+          ENDIF
+          RADGRID%RLATI(JGL) = RADGRID%RLATIG(IGLGLO)
+        ENDDO
+
+        IF(NPROC > 1)THEN
+          IRIRPTSUR = NGPTOTG
+          IRISPTSUR = 2 * NGPTOTG
+        ELSE
+          IRIRPTSUR = 0
+          IRISPTSUR = 0
+        ENDIF
+
+        ALLOCATE(NRISTA(NDGSAL - NRIWIDEN:NDGENL + NRIWIDES))
+        ALLOCATE(NRIONL(NDGSAL - NRIWIDEN:NDGENL + NRIWIDES))
+        ALLOCATE(NRIOFF(NDGSAL - NRIWIDEN:NDGENL + NRIWIDES))
+        ALLOCATE(NRIEXT(1 - NDLON:NDLON + NDLON, 1 - NRIWIDEN:NDGENL + NRIWIDES))
+        ALLOCATE(NRICORE(NGPTOT))
+        ALLOCATE(IRISENDPOS(IRISPTSUR))
+        ALLOCATE(IRIRECVPOS(IRIRPTSUR))
+        ALLOCATE(IRISENDPTR(NPROC + 1))
+        ALLOCATE(IRIRECVPTR(NPROC + 1))
+        ALLOCATE(IRICOMM(NPROC))
+        ALLOCATE(IRIMAP(4, NDGLG))
+        ! MPL 1.12.08
+        !     CALL RDCSET('RI',NRIWIDEN,NRIWIDES,NRIWIDEW,NRIWIDEE,&
+        !      & IRIRPTSUR,IRISPTSUR,&
+        !      & NDGLG,NDLON,NDGSAG,NDGENG,IDUM,IDUM,NDGSAL,NDGENL,&
+        !      & NDSUR1,NDLSUR,NDGSUR,NGPTOT,IDUM,&
+        !      & NPTRFLOFF,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,&
+        !      & NSTA,NONL,NLOENG,NPTRFRSTLAT,NFRSTLAT,NLSTLAT,&
+        !      & RMU,RSQM2,&
+        !      & NRISTA,NRIONL,NRIOFF,NRIEXT,NRICORE,NARIB1,&
+        !      & NRIPROCS,NRIMPBUFSZ,NRIRPT,NRISPT,&
+        !      & IRISENDPOS,IRIRECVPOS,IRISENDPTR,IRIRECVPTR,IRICOMM,IRIMAP,IRIMAPLEN)
+        CALL ABOR1('JUSTE APRES CALL RDCSET COMMENTE')
+        WRITE(NULOUT, '("SUECRAD: NARIB1=",I12)')NARIB1
+        ALLOCATE(NRISENDPOS(NRISPT))
+        ALLOCATE(NRIRECVPOS(NRIRPT))
+        ALLOCATE(NRISENDPTR(NRIPROCS + 1))
+        ALLOCATE(NRIRECVPTR(NRIPROCS + 1))
+        ALLOCATE(NRICOMM(NRIPROCS))
+        NRISENDPOS(1:NRISPT) = IRISENDPOS(1:NRISPT)
+        NRIRECVPOS(1:NRIRPT) = IRIRECVPOS(1:NRIRPT)
+        NRISENDPTR(1:NRIPROCS + 1) = IRISENDPTR(1:NRIPROCS + 1)
+        NRIRECVPTR(1:NRIPROCS + 1) = IRIRECVPTR(1:NRIPROCS + 1)
+        NRICOMM(1:NRIPROCS) = IRICOMM(1:NRIPROCS)
+        DEALLOCATE(IRISENDPOS)
+        DEALLOCATE(IRIRECVPOS)
+        DEALLOCATE(IRISENDPTR)
+        DEALLOCATE(IRIRECVPTR)
+        DEALLOCATE(IRICOMM)
+        DEALLOCATE(IRIMAP)
+
+        IF(NPROC > 1)THEN
+          IRORPTSUR = RADGRID%NGPTOTG
+          IROSPTSUR = 2 * RADGRID%NGPTOTG
+        ELSE
+          IRORPTSUR = 0
+          IROSPTSUR = 0
+        ENDIF
+
+        ALLOCATE(NROSTA(RADGRID%NDGSAL - NROWIDEN:RADGRID%NDGENL + NROWIDES))
+        ALLOCATE(NROONL(RADGRID%NDGSAL - NROWIDEN:RADGRID%NDGENL + NROWIDES))
+        ALLOCATE(NROOFF(RADGRID%NDGSAL - NROWIDEN:RADGRID%NDGENL + NROWIDES))
+        ALLOCATE(NROEXT(1 - RADGRID%NDLON:RADGRID%NDLON + RADGRID%NDLON, &
+                & 1 - NROWIDEN:RADGRID%NDGENL + NROWIDES))
+        ALLOCATE(NROCORE(RADGRID%NGPTOT))
+        ALLOCATE(IROSENDPOS(IROSPTSUR))
+        ALLOCATE(IRORECVPOS(IRORPTSUR))
+        ALLOCATE(IROSENDPTR(NPROC + 1))
+        ALLOCATE(IRORECVPTR(NPROC + 1))
+        ALLOCATE(IROCOMM(NPROC))
+        ALLOCATE(IROMAP(4, RADGRID%NDGLG))
+        ! MPL 1.12.08
+        !     CALL RDCSET('RO',NROWIDEN,NROWIDES,NROWIDEW,NROWIDEE,&
+        !      & IRORPTSUR,IROSPTSUR,&
+        !      & RADGRID%NDGLG,RADGRID%NDLON,RADGRID%NDGSAG,&
+        !      & RADGRID%NDGENG,IDUM,IDUM,RADGRID%NDGSAL,RADGRID%NDGENL,&
+        !      & RADGRID%NDSUR1,RADGRID%NDLSUR,RADGRID%NDGSUR,RADGRID%NGPTOT,IDUM,&
+        !      & RADGRID%NPTRFLOFF,RADGRID%NFRSTLOFF,RADGRID%MYFRSTACTLAT,RADGRID%MYLSTACTLAT,&
+        !      & RADGRID%NSTA,RADGRID%NONL,RADGRID%NLOENG,RADGRID%NPTRFRSTLAT,&
+        !      & RADGRID%NFRSTLAT,RADGRID%NLSTLAT,&
+        !      & RADGRID%RMU,RADGRID%RSQM2,&
+        !      & NROSTA,NROONL,NROOFF,NROEXT,NROCORE,NAROB1,&
+        !      & NROPROCS,NROMPBUFSZ,NRORPT,NROSPT,&
+        !      & IROSENDPOS,IRORECVPOS,IROSENDPTR,IRORECVPTR,IROCOMM,IROMAP,IROMAPLEN)
+        CALL ABOR1('JUSTE APRES CALL RDCSET COMMENTE')
+        WRITE(NULOUT, '("SUECRAD: NAROB1=",I12)')NAROB1
+        ALLOCATE(NROSENDPOS(NROSPT))
+        ALLOCATE(NRORECVPOS(NRORPT))
+        ALLOCATE(NROSENDPTR(NROPROCS + 1))
+        ALLOCATE(NRORECVPTR(NROPROCS + 1))
+        ALLOCATE(NROCOMM(NROPROCS))
+        NROSENDPOS(1:NROSPT) = IROSENDPOS(1:NROSPT)
+        NRORECVPOS(1:NRORPT) = IRORECVPOS(1:NRORPT)
+        NROSENDPTR(1:NROPROCS + 1) = IROSENDPTR(1:NROPROCS + 1)
+        NRORECVPTR(1:NROPROCS + 1) = IRORECVPTR(1:NROPROCS + 1)
+        NROCOMM(1:NROPROCS) = IROCOMM(1:NROPROCS)
+        DEALLOCATE(IROSENDPOS)
+        DEALLOCATE(IRORECVPOS)
+        DEALLOCATE(IROSENDPTR)
+        DEALLOCATE(IRORECVPTR)
+        DEALLOCATE(IROCOMM)
+        DEALLOCATE(IROMAP)
+
+        IF(LLDEBUG)THEN
+          WRITE(NULOUT, '("")')
+          IRIWIDEMAXN = 0
+          IRIWIDEMAXS = 0
+          IRIWIDEMAXW = 0
+          IRIWIDEMAXE = 0
+          IROWIDEMAXN = 0
+          IROWIDEMAXS = 0
+          IROWIDEMAXW = 0
+          IROWIDEMAXE = 0
+          IARIB1MAX = 0
+          IAROB1MAX = 0
+          IWIDE(1) = NRIWIDEN
+          IWIDE(2) = NRIWIDES
+          IWIDE(3) = NRIWIDEW
+          IWIDE(4) = NRIWIDEE
+          IWIDE(5) = NROWIDEN
+          IWIDE(6) = NROWIDES
+          IWIDE(7) = NROWIDEW
+          IWIDE(8) = NROWIDEE
+          IWIDE(9) = NARIB1
+          IWIDE(10) = NAROB1
+          IF(MYPROC /= 1)THEN
+            stop 'Pas pret pour proc > 1'
+            !         CALL MPL_SEND(IWIDE(1:10),KDEST=NPRCIDS(1),KTAG=1,CDSTRING='SUECRAD.W')
+          ENDIF
+          IF(MYPROC == 1)THEN
+            DO JROC = 1, NPROC
+              IF(JROC /= MYPROC)THEN
+                stop 'Pas pret pour proc > 1'
+                !             CALL MPL_RECV(IWIDE(1:10),KSOURCE=NPRCIDS(JROC),KTAG=1,CDSTRING='SUECRAD.W')
+              ENDIF
+              WRITE(NULOUT, '("SUECRAD: PROC=",I5,2X,"NRIWIDEN=",I3,2X,"NROWIDEN=",I3 )')&
+                      & JROC, IWIDE(1), IWIDE(5)
+              WRITE(NULOUT, '("SUECRAD: PROC=",I5,2X,"NRIWIDES=",I3,2X,"NROWIDES=",I3 )')&
+                      & JROC, IWIDE(2), IWIDE(6)
+              WRITE(NULOUT, '("SUECRAD: PROC=",I5,2X,"NRIWIDEW=",I3,2X,"NROWIDEW=",I3 )')&
+                      & JROC, IWIDE(3), IWIDE(7)
+              WRITE(NULOUT, '("SUECRAD: PROC=",I5,2X,"NRIWIDEE=",I3,2X,"NROWIDEE=",I3 )')&
+                      & JROC, IWIDE(4), IWIDE(8)
+              WRITE(NULOUT, '("SUECRAD: PROC=",I5,2X,"NARIB1=",I10,2X,"NAROB1=",I10 )')&
+                      & JROC, IWIDE(9), IWIDE(10)
+              WRITE(NULOUT, '("")')
+              IF(IWIDE(1) > IRIWIDEMAXN) IRIWIDEMAXN = IWIDE(1)
+              IF(IWIDE(2) > IRIWIDEMAXS) IRIWIDEMAXS = IWIDE(2)
+              IF(IWIDE(3) > IRIWIDEMAXW) IRIWIDEMAXW = IWIDE(3)
+              IF(IWIDE(4) > IRIWIDEMAXE) IRIWIDEMAXE = IWIDE(4)
+              IF(IWIDE(5) > IROWIDEMAXN) IROWIDEMAXN = IWIDE(5)
+              IF(IWIDE(6) > IROWIDEMAXS) IROWIDEMAXS = IWIDE(6)
+              IF(IWIDE(7) > IROWIDEMAXW) IROWIDEMAXW = IWIDE(7)
+              IF(IWIDE(8) > IROWIDEMAXE) IROWIDEMAXE = IWIDE(8)
+              IF(IWIDE(9)  > IARIB1MAX) IARIB1MAX = IWIDE(9)
+              IF(IWIDE(10) > IAROB1MAX) IAROB1MAX = IWIDE(10)
+            ENDDO
+            WRITE(NULOUT, '("")')
+            WRITE(NULOUT, '("SUECRAD: NRIWIDEN(MAX)  =",I8)')IRIWIDEMAXN
+            WRITE(NULOUT, '("SUECRAD: NRIWIDES(MAX)  =",I8)')IRIWIDEMAXS
+            WRITE(NULOUT, '("SUECRAD: NRIWIDEW(MAX)  =",I8)')IRIWIDEMAXW
+            WRITE(NULOUT, '("SUECRAD: NRIWIDEE(MAX)  =",I8)')IRIWIDEMAXE
+            WRITE(NULOUT, '("SUECRAD: NROWIDEN(MAX)  =",I8)')IROWIDEMAXN
+            WRITE(NULOUT, '("SUECRAD: NROWIDES(MAX)  =",I8)')IROWIDEMAXS
+            WRITE(NULOUT, '("SUECRAD: NROWIDEW(MAX)  =",I8)')IROWIDEMAXW
+            WRITE(NULOUT, '("SUECRAD: NROWIDEE(MAX)  =",I8)')IROWIDEMAXE
+            WRITE(NULOUT, '("SUECRAD: NARIB1(MAX)    =",I10)')IARIB1MAX
+            WRITE(NULOUT, '("SUECRAD: NAROB1(MAX)    =",I10)')IAROB1MAX
+            WRITE(NULOUT, '("")')
+          ENDIF
+          CALL FLUSH(NULOUT)
+        ENDIF
+
+      ENDIF
+      !    CALL GSTATS(1818,1)      MPL 2.12.08
+
+    ELSE
+
+      WRITE(NULOUT, '("SUECRAD: INVALID VALUE FOR NRADINT=",I6)')NRADINT
+      CALL ABOR1('SUECRAD: NRADINT INVALID')
+
     ENDIF
 
-    RADGRID%NDGSAL=1
-    RADGRID%NDGENL=RADGRID%NLSTLAT(MY_REGION_NS)-RADGRID%NFRSTLOFF
-    RADGRID%NDSUR1=3-MOD(RADGRID%NDLON,2)
-    IDLSUR=MAX(RADGRID%NDLON,2*RADGRID%NSMAX+1)
-    RADGRID%NDLSUR=IDLSUR+RADGRID%NDSUR1
-    RADGRID%MYFRSTACTLAT=RADGRID%NFRSTLAT(MY_REGION_NS)
-    RADGRID%MYLSTACTLAT=RADGRID%NLSTLAT(MY_REGION_NS)
-
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NRESOL_ID    =",I8)')RADGRID%NRESOL_ID
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NSMAX        =",I8)')RADGRID%NSMAX
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NSPEC2       =",I8)')RADGRID%NSPEC2
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NGPTOT       =",I8)')RADGRID%NGPTOT
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NGPTOTG      =",I8)')RADGRID%NGPTOTG
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDGSAL       =",I8)')RADGRID%NDGSAL
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDGENL       =",I8)')RADGRID%NDGENL
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDSUR1       =",I8)')RADGRID%NDSUR1
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDLSUR       =",I8)')RADGRID%NDLSUR
-    WRITE(NULOUT,'("SUECRAD: RADGRID%MYFRSTACTLAT =",I8)')RADGRID%MYFRSTACTLAT
-    WRITE(NULOUT,'("SUECRAD: RADGRID%MYLSTACTLAT  =",I8)')RADGRID%MYLSTACTLAT
-    CALL FLUSH(NULOUT)
-
-    ALLOCATE(RADGRID%NASM0(0:RADGRID%NSPEC2))
-    ALLOCATE(RADGRID%MYMS(RADGRID%NUMP))
-    CALL TRANS_INQ (KRESOL     =RADGRID%NRESOL_ID, &
-     & KASM0      =RADGRID%NASM0, &
-     & KMYMS      =RADGRID%MYMS )  
-
-    ALLOCATE(RADGRID%GELAM(RADGRID%NGPTOT))
-    ALLOCATE(RADGRID%GELAT(RADGRID%NGPTOT))
-    ALLOCATE(RADGRID%GESLO(RADGRID%NGPTOT))
-    ALLOCATE(RADGRID%GECLO(RADGRID%NGPTOT))
-    ALLOCATE(RADGRID%GEMU (RADGRID%NGPTOT))
-
-    IOFF=0
-    ILAT=RADGRID%NPTRFLOFF
-    DO JGLAT=RADGRID%NFRSTLAT(MY_REGION_NS), &
-       & RADGRID%NLSTLAT(MY_REGION_NS)  
-      ZGEMU=RADGRID%RMU(JGLAT)
-      ILAT=ILAT+1
-      ISTLON  = RADGRID%NSTA(ILAT,MY_REGION_EW)
-      IENDLON = ISTLON-1 + RADGRID%NONL(ILAT,MY_REGION_EW)
-
-      DO JLON=ISTLON,IENDLON
-        ZLON=  REAL(JLON-1,JPRB)*2.0_JPRB*RPI &
-         & /REAL(RADGRID%NLOENG(JGLAT),JPRB)  
-        IOFF=IOFF+1
-        RADGRID%GELAM(IOFF) = ZLON
-        RADGRID%GELAT(IOFF) = ASIN(ZGEMU)
-        RADGRID%GESLO(IOFF) = SIN(ZLON)
-        RADGRID%GECLO(IOFF) = COS(ZLON)
-        RADGRID%GEMU (IOFF) = ZGEMU
-      ENDDO
-    ENDDO
-
-    IF( NRADINT == 2 .OR. NRADINT == 3 )THEN
-
-!   For grid point interpolations we need to calculate the halo size
-!   required by each processor
-
-      ALLOCATE(ZLATX(RADGRID%NGPTOTMX))
-      ALLOCATE(ZLONX(RADGRID%NGPTOTMX))
-      DO J=1,RADGRID%NGPTOT
-        ZLATX(J)=RADGRID%GELAT(J)/RPI*2.0_JPRB*90.0
-        ZLONX(J)=(RADGRID%GELAM(J)-RPI)/RPI*180.0
-      ENDDO
-      ZMINRADLAT=MINVAL(ZLATX(1:RADGRID%NGPTOT))
-      ZMAXRADLAT=MAXVAL(ZLATX(1:RADGRID%NGPTOT))
-      ZMINRADLON=MINVAL(ZLONX(1:RADGRID%NGPTOT))
-      ZMAXRADLON=MAXVAL(ZLONX(1:RADGRID%NGPTOT))
-      IF( LLDEBUG )THEN
-        WRITE(NULOUT,'("RADGRID,BEGIN")')
-        IF( MYPROC /= 1 )THEN
-          stop 'Pas pret pour proc > 1'
-!         CALL MPL_SEND(RADGRID%NGPTOT,KDEST=NPRCIDS(1),KTAG=1,CDSTRING='SUECRAD.R')
-!         CALL MPL_SEND(ZLATX(1:RADGRID%NGPTOT),KDEST=NPRCIDS(1),KTAG=2,CDSTRING='SUECRAD.R')
-!         CALL MPL_SEND(ZLONX(1:RADGRID%NGPTOT),KDEST=NPRCIDS(1),KTAG=3,CDSTRING='SUECRAD.R')
-        ENDIF
-        IF( MYPROC == 1 )THEN
-          DO JROC=1,NPROC
-            IF( JROC == MYPROC )THEN
-              DO J=1,RADGRID%NGPTOT
-                WRITE(NULOUT,'(F7.2,2X,F7.2,2X,I6)')ZLATX(J),ZLONX(J),MYPROC
-              ENDDO
-            ELSE
-              stop 'Pas pret pour proc > 1'
-!             CALL MPL_RECV(IGPTOT,KSOURCE=NPRCIDS(JROC),KTAG=1,CDSTRING='SUECRAD.M')
-!             CALL MPL_RECV(ZLATX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=2,CDSTRING='SUECRAD.M')
-!             CALL MPL_RECV(ZLONX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=3,CDSTRING='SUECRAD.M')
-              DO J=1,IGPTOT
-                WRITE(NULOUT,'(F7.2,2X,F7.2,2X,I6)')ZLATX(J),ZLONX(J),JROC
-              ENDDO
-            ENDIF
-          ENDDO
-        ENDIF
-        WRITE(NULOUT,'("RADGRID,END")')
-      ENDIF
-      DEALLOCATE(ZLATX)
-      DEALLOCATE(ZLONX)
-  
-      ALLOCATE(ZLATX(NGPTOTMX))
-      ALLOCATE(ZLONX(NGPTOTMX))
-      DO J=1,NGPTOT
-        ZLATX(J)=GELAT(J)/RPI*2.0_JPRB*90.0
-        ZLONX(J)=(GELAM(J)-RPI)/RPI*180.0
-      ENDDO
-      ZMINMDLLAT=MINVAL(ZLATX(1:NGPTOT))
-      ZMAXMDLLAT=MAXVAL(ZLATX(1:NGPTOT))
-      ZMINMDLLON=MINVAL(ZLONX(1:NGPTOT))
-      ZMAXMDLLON=MAXVAL(ZLONX(1:NGPTOT))
-      IF( LLDEBUG )THEN
-        WRITE(NULOUT,'("MODELGRID,BEGIN")')
-        IF( MYPROC /= 1 )THEN
-          stop 'Pas pret pour proc > 1'
-!         CALL MPL_SEND(NGPTOT,KDEST=NPRCIDS(1),KTAG=1,CDSTRING='SUECRAD')
-!         CALL MPL_SEND(ZLATX(1:NGPTOT),KDEST=NPRCIDS(1),KTAG=2,CDSTRING='SUECRAD')
-!         CALL MPL_SEND(ZLONX(1:NGPTOT),KDEST=NPRCIDS(1),KTAG=3,CDSTRING='SUECRAD')
-!         CALL MPL_SEND(NGLOBALINDEX(1:NGPTOT),KDEST=NPRCIDS(1),KTAG=4,CDSTRING='SUECRAD')
-        ENDIF
-        IF( MYPROC == 1 )THEN
-          DO JROC=1,NPROC
-            IF( JROC == MYPROC )THEN
-              DO J=1,NGPTOT
-                WRITE(NULOUT,'(F7.2,2X,F7.2,2X,I6,2X,I12)')ZLATX(J),ZLONX(J),MYPROC,NGLOBALINDEX(J)
-              ENDDO
-            ELSE
-              stop 'Pas pret pour proc > 1'
-!             CALL MPL_RECV(IGPTOT,KSOURCE=NPRCIDS(JROC),KTAG=1,CDSTRING='SUECRAD')
-!             CALL MPL_RECV(ZLATX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=2,CDSTRING='SUECRAD')
-!             CALL MPL_RECV(ZLONX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=3,CDSTRING='SUECRAD')
-              ALLOCATE(IGLOBALINDEX(1:IGPTOT))
-!             CALL MPL_RECV(IGLOBALINDEX(1:IGPTOT),KSOURCE=NPRCIDS(JROC),KTAG=4,CDSTRING='SUECRAD')
-              DO J=1,IGPTOT
-                WRITE(NULOUT,'(F7.2,2X,F7.2,2X,I6,2X,I12)')ZLATX(J),ZLONX(J),JROC,IGLOBALINDEX(J)
-              ENDDO
-              DEALLOCATE(IGLOBALINDEX)
-            ENDIF
-          ENDDO
-        ENDIF
-        WRITE(NULOUT,'("MODELGRID,END")')
-      ENDIF
-      DEALLOCATE(ZLATX)
-      DEALLOCATE(ZLONX)
-  
-      IF( LLDEBUG )THEN
-        WRITE(NULOUT,'("ZMINRADLAT=",F10.2)')ZMINRADLAT
-        WRITE(NULOUT,'("ZMINMDLLAT=",F10.2)')ZMINMDLLAT
-        WRITE(NULOUT,'("ZMAXRADLAT=",F10.2)')ZMAXRADLAT
-        WRITE(NULOUT,'("ZMAXMDLLAT=",F10.2)')ZMAXMDLLAT
-        WRITE(NULOUT,'("ZMINRADLON=",F10.2)')ZMINRADLON
-        WRITE(NULOUT,'("ZMINMDLLON=",F10.2)')ZMINMDLLON
-        WRITE(NULOUT,'("ZMAXRADLON=",F10.2)')ZMAXRADLON
-        WRITE(NULOUT,'("ZMAXMDLLON=",F10.2)')ZMAXMDLLON
-      ENDIF
-
-      ZLAT=NDGLG/180.
-      ILATS_DIFF_C=CEILING(ABS(ZMINRADLAT-ZMINMDLLAT)*ZLAT)
-      ILATS_DIFF_F=FLOOR  (ABS(ZMINRADLAT-ZMINMDLLAT)*ZLAT)
-      IF( ZMINRADLAT < ZMINMDLLAT )THEN
-        NRIWIDES=JP_MIN_HALO+ILATS_DIFF_C
-      ELSE
-        NRIWIDES=MAX(0,JP_MIN_HALO-ILATS_DIFF_F)
-      ENDIF
-      ILATS_DIFF_C=CEILING(ABS(ZMAXRADLAT-ZMAXMDLLAT)*ZLAT)
-      ILATS_DIFF_F=FLOOR  (ABS(ZMAXRADLAT-ZMAXMDLLAT)*ZLAT)
-      IF( ZMAXRADLAT < ZMAXMDLLAT )THEN
-        NRIWIDEN=MAX(0,JP_MIN_HALO-ILATS_DIFF_F)
-      ELSE
-        NRIWIDEN=JP_MIN_HALO+ILATS_DIFF_C
-      ENDIF
-      ILATS_DIFF_C=CEILING(ABS(ZMINRADLON-ZMINMDLLON)*ZLAT)
-      ILATS_DIFF_F=FLOOR  (ABS(ZMINRADLON-ZMINMDLLON)*ZLAT)
-      IF( ZMINRADLON < ZMINMDLLON )THEN
-        NRIWIDEW=JP_MIN_HALO+ILATS_DIFF_C
-      ELSE
-        NRIWIDEW=MAX(0,JP_MIN_HALO-ILATS_DIFF_F)
-      ENDIF
-      ILATS_DIFF_C=CEILING(ABS(ZMAXRADLON-ZMAXMDLLON)*ZLAT)
-      ILATS_DIFF_F=FLOOR  (ABS(ZMAXRADLON-ZMAXMDLLON)*ZLAT)
-      IF( ZMAXRADLON < ZMAXMDLLON )THEN
-        NRIWIDEE=MAX(0,JP_MIN_HALO-ILATS_DIFF_F)
-      ELSE
-        NRIWIDEE=JP_MIN_HALO+ILATS_DIFF_C
-      ENDIF
-
-      ZLAT=RADGRID%NDGLG/180.
-      ILATS_DIFF_C=CEILING(ABS(ZMINRADLAT-ZMINMDLLAT)*ZLAT)
-      ILATS_DIFF_F=FLOOR  (ABS(ZMINRADLAT-ZMINMDLLAT)*ZLAT)
-      IF( ZMINMDLLAT < ZMINRADLAT )THEN
-        NROWIDES=JP_MIN_HALO+ILATS_DIFF_C
-      ELSE
-        NROWIDES=MAX(0,JP_MIN_HALO-ILATS_DIFF_F)
-      ENDIF
-      ILATS_DIFF_C=CEILING(ABS(ZMAXRADLAT-ZMAXMDLLAT)*ZLAT)
-      ILATS_DIFF_F=FLOOR  (ABS(ZMAXRADLAT-ZMAXMDLLAT)*ZLAT)
-      IF( ZMAXMDLLAT < ZMAXRADLAT )THEN
-        NROWIDEN=MAX(0,JP_MIN_HALO-ILATS_DIFF_F)
-      ELSE
-        NROWIDEN=JP_MIN_HALO+ILATS_DIFF_C
-      ENDIF
-      ILATS_DIFF_C=CEILING(ABS(ZMINRADLON-ZMINMDLLON)*ZLAT)
-      ILATS_DIFF_F=FLOOR  (ABS(ZMINRADLON-ZMINMDLLON)*ZLAT)
-      IF( ZMINMDLLON < ZMINRADLON )THEN
-        NROWIDEW=JP_MIN_HALO+ILATS_DIFF_C
-      ELSE
-        NROWIDEW=MAX(0,JP_MIN_HALO-ILATS_DIFF_F)
-      ENDIF
-      ILATS_DIFF_C=CEILING(ABS(ZMAXRADLON-ZMAXMDLLON)*ZLAT)
-      ILATS_DIFF_F=FLOOR  (ABS(ZMAXRADLON-ZMAXMDLLON)*ZLAT)
-      IF( ZMAXMDLLON < ZMAXRADLON )THEN
-        NROWIDEE=MAX(0,JP_MIN_HALO-ILATS_DIFF_F)
-      ELSE
-        NROWIDEE=JP_MIN_HALO+ILATS_DIFF_C
-      ENDIF
-
+  ENDIF              ! END OF LERADI BLOCK
+
+  !      ----------------------------------------------------------------
+
+  !*       4.    INITIALIZE RADIATION COEFFICIENTS.
+  !              ----------------------------------
+
+  RCDAY = RDAY * RG / RCPD
+  DIFF = 1.66_JPRB
+  R10E = 0.4342945_JPRB
+
+  ! CALL GSTATS(1818,0)    MPL 2.12.08
+  CALL SURDI
+
+  IF (NINHOM == 0) THEN
+    RLWINHF = 1._JPRB
+    RSWINHF = 1._JPRB
+  ENDIF
+
+  !      ----------------------------------------------------------------
+
+  !*       5.    INITIALIZE RADIATION ABSORPTION COEFFICIENTS
+  !              --------------------------------------------
+
+  !*       5.1.  Initialization routine for RRTM
+  !              -------------------------------
+
+  CALL SURRTAB
+  CALL SURRTPK
+  CALL SURRTRF
+  CALL SURRTFTR
+
+  IF (LRRTM) THEN
+    IF (KLEV > JPLAY) THEN
+      WRITE(UNIT = KULOUT, &
+              & FMT = '('' RRTM MAXIMUM NUMBER OF LAYERS IS REACHED'',&
+              & '' CALL ABORT'')')
+      CALL ABOR1(' ABOR1 CALLED SUECRAD')
     ENDIF
 
-    RADGRID%NDGSAH=MAX(RADGRID%NDGSAG,&
-     & RADGRID%NDGSAL+RADGRID%NFRSTLOFF-NROWIDEN)-RADGRID%NFRSTLOFF  
-    RADGRID%NDGENH=MIN(RADGRID%NDGENG,&
-     & RADGRID%NDGENL+RADGRID%NFRSTLOFF+NROWIDES)-RADGRID%NFRSTLOFF  
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDGSAH       =",I8)')RADGRID%NDGSAH
-    WRITE(NULOUT,'("SUECRAD: RADGRID%NDGENH       =",I8)')RADGRID%NDGENH
-
-    IF( NRADINT == 2 .OR. NRADINT == 3 )THEN
-
-      ILBRLATI = MAX(RADGRID%NDGSAG,&
-       & RADGRID%NDGSAL+RADGRID%NFRSTLOFF-NROWIDEN)-RADGRID%NFRSTLOFF  
-      IUBRLATI = MIN(RADGRID%NDGENG,&
-       & RADGRID%NDGENL+RADGRID%NFRSTLOFF+NROWIDES)-RADGRID%NFRSTLOFF  
-      ALLOCATE(RADGRID%RLATI(ILBRLATI:IUBRLATI))
-      ALLOCATE(RADGRID%RIPI0(ILBRLATI:IUBRLATI))
-      ALLOCATE(RADGRID%RIPI1(ILBRLATI:IUBRLATI))
-      ALLOCATE(RADGRID%RIPI2(ILBRLATI:IUBRLATI))
-  
-      DO JGL= ILBRLATI,IUBRLATI
-        IGLGLO=JGL+RADGRID%NFRSTLOFF
-        IF(IGLGLO >= 0.AND.IGLGLO <= RADGRID%NDGLG) THEN
-          ZD1=RADGRID%RLATIG(IGLGLO-1)-RADGRID%RLATIG(IGLGLO)
-          ZD2=RADGRID%RLATIG(IGLGLO-1)-RADGRID%RLATIG(IGLGLO+1)
-          ZD3=RADGRID%RLATIG(IGLGLO-1)-RADGRID%RLATIG(IGLGLO+2)
-          ZD4=RADGRID%RLATIG(IGLGLO  )-RADGRID%RLATIG(IGLGLO+1)
-          ZD5=RADGRID%RLATIG(IGLGLO  )-RADGRID%RLATIG(IGLGLO+2)
-          ZD6=RADGRID%RLATIG(IGLGLO+1)-RADGRID%RLATIG(IGLGLO+2)
-          RADGRID%RIPI0(JGL)=-1.0_JPRB/(ZD1*ZD4*ZD5)
-          RADGRID%RIPI1(JGL)= 1.0_JPRB/(ZD2*ZD4*ZD6)
-          RADGRID%RIPI2(JGL)=-1.0_JPRB/(ZD3*ZD5*ZD6)
-        ENDIF
-        RADGRID%RLATI(JGL)=RADGRID%RLATIG(IGLGLO)
-      ENDDO
-
-      IF( NPROC > 1 )THEN
-        IRIRPTSUR=NGPTOTG
-        IRISPTSUR=2*NGPTOTG
-      ELSE
-        IRIRPTSUR=0
-        IRISPTSUR=0
-      ENDIF
-
-      ALLOCATE(NRISTA(NDGSAL-NRIWIDEN:NDGENL+NRIWIDES))
-      ALLOCATE(NRIONL(NDGSAL-NRIWIDEN:NDGENL+NRIWIDES))
-      ALLOCATE(NRIOFF(NDGSAL-NRIWIDEN:NDGENL+NRIWIDES))
-      ALLOCATE(NRIEXT(1-NDLON:NDLON+NDLON,1-NRIWIDEN:NDGENL+NRIWIDES))
-      ALLOCATE(NRICORE(NGPTOT))
-      ALLOCATE(IRISENDPOS(IRISPTSUR))
-      ALLOCATE(IRIRECVPOS(IRIRPTSUR))
-      ALLOCATE(IRISENDPTR(NPROC+1))
-      ALLOCATE(IRIRECVPTR(NPROC+1))
-      ALLOCATE(IRICOMM(NPROC))
-      ALLOCATE(IRIMAP(4,NDGLG))
-! MPL 1.12.08      
-!     CALL RDCSET('RI',NRIWIDEN,NRIWIDES,NRIWIDEW,NRIWIDEE,&
-!      & IRIRPTSUR,IRISPTSUR,&
-!      & NDGLG,NDLON,NDGSAG,NDGENG,IDUM,IDUM,NDGSAL,NDGENL,&
-!      & NDSUR1,NDLSUR,NDGSUR,NGPTOT,IDUM,&
-!      & NPTRFLOFF,NFRSTLOFF,MYFRSTACTLAT,MYLSTACTLAT,&
-!      & NSTA,NONL,NLOENG,NPTRFRSTLAT,NFRSTLAT,NLSTLAT,&
-!      & RMU,RSQM2,&
-!      & NRISTA,NRIONL,NRIOFF,NRIEXT,NRICORE,NARIB1,&
-!      & NRIPROCS,NRIMPBUFSZ,NRIRPT,NRISPT,&
-!      & IRISENDPOS,IRIRECVPOS,IRISENDPTR,IRIRECVPTR,IRICOMM,IRIMAP,IRIMAPLEN)  
-      CALL ABOR1('JUSTE APRES CALL RDCSET COMMENTE')
-      WRITE(NULOUT,'("SUECRAD: NARIB1=",I12)')NARIB1
-      ALLOCATE(NRISENDPOS(NRISPT))
-      ALLOCATE(NRIRECVPOS(NRIRPT))
-      ALLOCATE(NRISENDPTR(NRIPROCS+1))
-      ALLOCATE(NRIRECVPTR(NRIPROCS+1))
-      ALLOCATE(NRICOMM(NRIPROCS))
-      NRISENDPOS(1:NRISPT)=IRISENDPOS(1:NRISPT)
-      NRIRECVPOS(1:NRIRPT)=IRIRECVPOS(1:NRIRPT)
-      NRISENDPTR(1:NRIPROCS+1)=IRISENDPTR(1:NRIPROCS+1)
-      NRIRECVPTR(1:NRIPROCS+1)=IRIRECVPTR(1:NRIPROCS+1)
-      NRICOMM(1:NRIPROCS)=IRICOMM(1:NRIPROCS)
-      DEALLOCATE(IRISENDPOS)
-      DEALLOCATE(IRIRECVPOS)
-      DEALLOCATE(IRISENDPTR)
-      DEALLOCATE(IRIRECVPTR)
-      DEALLOCATE(IRICOMM)
-      DEALLOCATE(IRIMAP)
-
-      IF( NPROC > 1 )THEN
-        IRORPTSUR=RADGRID%NGPTOTG
-        IROSPTSUR=2*RADGRID%NGPTOTG
-      ELSE
-        IRORPTSUR=0
-        IROSPTSUR=0
-      ENDIF
-
-      ALLOCATE(NROSTA(RADGRID%NDGSAL-NROWIDEN:RADGRID%NDGENL+NROWIDES))
-      ALLOCATE(NROONL(RADGRID%NDGSAL-NROWIDEN:RADGRID%NDGENL+NROWIDES))
-      ALLOCATE(NROOFF(RADGRID%NDGSAL-NROWIDEN:RADGRID%NDGENL+NROWIDES))
-      ALLOCATE(NROEXT(1-RADGRID%NDLON:RADGRID%NDLON+RADGRID%NDLON,&
-       & 1-NROWIDEN:RADGRID%NDGENL+NROWIDES))  
-      ALLOCATE(NROCORE(RADGRID%NGPTOT))
-      ALLOCATE(IROSENDPOS(IROSPTSUR))
-      ALLOCATE(IRORECVPOS(IRORPTSUR))
-      ALLOCATE(IROSENDPTR(NPROC+1))
-      ALLOCATE(IRORECVPTR(NPROC+1))
-      ALLOCATE(IROCOMM(NPROC))
-      ALLOCATE(IROMAP(4,RADGRID%NDGLG))
-! MPL 1.12.08      
-!     CALL RDCSET('RO',NROWIDEN,NROWIDES,NROWIDEW,NROWIDEE,&
-!      & IRORPTSUR,IROSPTSUR,&
-!      & RADGRID%NDGLG,RADGRID%NDLON,RADGRID%NDGSAG,&
-!      & RADGRID%NDGENG,IDUM,IDUM,RADGRID%NDGSAL,RADGRID%NDGENL,&
-!      & RADGRID%NDSUR1,RADGRID%NDLSUR,RADGRID%NDGSUR,RADGRID%NGPTOT,IDUM,&
-!      & RADGRID%NPTRFLOFF,RADGRID%NFRSTLOFF,RADGRID%MYFRSTACTLAT,RADGRID%MYLSTACTLAT,&
-!      & RADGRID%NSTA,RADGRID%NONL,RADGRID%NLOENG,RADGRID%NPTRFRSTLAT,&
-!      & RADGRID%NFRSTLAT,RADGRID%NLSTLAT,&
-!      & RADGRID%RMU,RADGRID%RSQM2,&
-!      & NROSTA,NROONL,NROOFF,NROEXT,NROCORE,NAROB1,&
-!      & NROPROCS,NROMPBUFSZ,NRORPT,NROSPT,&
-!      & IROSENDPOS,IRORECVPOS,IROSENDPTR,IRORECVPTR,IROCOMM,IROMAP,IROMAPLEN)  
-      CALL ABOR1('JUSTE APRES CALL RDCSET COMMENTE')
-      WRITE(NULOUT,'("SUECRAD: NAROB1=",I12)')NAROB1
-      ALLOCATE(NROSENDPOS(NROSPT))
-      ALLOCATE(NRORECVPOS(NRORPT))
-      ALLOCATE(NROSENDPTR(NROPROCS+1))
-      ALLOCATE(NRORECVPTR(NROPROCS+1))
-      ALLOCATE(NROCOMM(NROPROCS))
-      NROSENDPOS(1:NROSPT)=IROSENDPOS(1:NROSPT)
-      NRORECVPOS(1:NRORPT)=IRORECVPOS(1:NRORPT)
-      NROSENDPTR(1:NROPROCS+1)=IROSENDPTR(1:NROPROCS+1)
-      NRORECVPTR(1:NROPROCS+1)=IRORECVPTR(1:NROPROCS+1)
-      NROCOMM(1:NROPROCS)=IROCOMM(1:NROPROCS)
-      DEALLOCATE(IROSENDPOS)
-      DEALLOCATE(IRORECVPOS)
-      DEALLOCATE(IROSENDPTR)
-      DEALLOCATE(IRORECVPTR)
-      DEALLOCATE(IROCOMM)
-      DEALLOCATE(IROMAP)
-
-      IF( LLDEBUG )THEN
-        WRITE(NULOUT,'("")')
-        IRIWIDEMAXN=0
-        IRIWIDEMAXS=0
-        IRIWIDEMAXW=0
-        IRIWIDEMAXE=0
-        IROWIDEMAXN=0
-        IROWIDEMAXS=0
-        IROWIDEMAXW=0
-        IROWIDEMAXE=0
-        IARIB1MAX=0
-        IAROB1MAX=0
-        IWIDE(1)=NRIWIDEN
-        IWIDE(2)=NRIWIDES
-        IWIDE(3)=NRIWIDEW
-        IWIDE(4)=NRIWIDEE
-        IWIDE(5)=NROWIDEN
-        IWIDE(6)=NROWIDES
-        IWIDE(7)=NROWIDEW
-        IWIDE(8)=NROWIDEE
-        IWIDE(9)=NARIB1
-        IWIDE(10)=NAROB1
-        IF( MYPROC /= 1 )THEN
-          stop 'Pas pret pour proc > 1'
-!         CALL MPL_SEND(IWIDE(1:10),KDEST=NPRCIDS(1),KTAG=1,CDSTRING='SUECRAD.W')
-        ENDIF
-        IF( MYPROC == 1 )THEN
-          DO JROC=1,NPROC
-            IF( JROC /= MYPROC )THEN
-              stop 'Pas pret pour proc > 1'
-!             CALL MPL_RECV(IWIDE(1:10),KSOURCE=NPRCIDS(JROC),KTAG=1,CDSTRING='SUECRAD.W')
-            ENDIF
-            WRITE(NULOUT,'("SUECRAD: PROC=",I5,2X,"NRIWIDEN=",I3,2X,"NROWIDEN=",I3 )')&
-             & JROC,IWIDE(1),IWIDE(5)  
-            WRITE(NULOUT,'("SUECRAD: PROC=",I5,2X,"NRIWIDES=",I3,2X,"NROWIDES=",I3 )')&
-             & JROC,IWIDE(2),IWIDE(6)  
-            WRITE(NULOUT,'("SUECRAD: PROC=",I5,2X,"NRIWIDEW=",I3,2X,"NROWIDEW=",I3 )')&
-             & JROC,IWIDE(3),IWIDE(7)  
-            WRITE(NULOUT,'("SUECRAD: PROC=",I5,2X,"NRIWIDEE=",I3,2X,"NROWIDEE=",I3 )')&
-             & JROC,IWIDE(4),IWIDE(8)  
-            WRITE(NULOUT,'("SUECRAD: PROC=",I5,2X,"NARIB1=",I10,2X,"NAROB1=",I10 )')&
-             & JROC,IWIDE(9),IWIDE(10)
-            WRITE(NULOUT,'("")')
-            IF( IWIDE(1) > IRIWIDEMAXN ) IRIWIDEMAXN=IWIDE(1)
-            IF( IWIDE(2) > IRIWIDEMAXS ) IRIWIDEMAXS=IWIDE(2)
-            IF( IWIDE(3) > IRIWIDEMAXW ) IRIWIDEMAXW=IWIDE(3)
-            IF( IWIDE(4) > IRIWIDEMAXE ) IRIWIDEMAXE=IWIDE(4)
-            IF( IWIDE(5) > IROWIDEMAXN ) IROWIDEMAXN=IWIDE(5)
-            IF( IWIDE(6) > IROWIDEMAXS ) IROWIDEMAXS=IWIDE(6)
-            IF( IWIDE(7) > IROWIDEMAXW ) IROWIDEMAXW=IWIDE(7)
-            IF( IWIDE(8) > IROWIDEMAXE ) IROWIDEMAXE=IWIDE(8)
-            IF( IWIDE(9)  > IARIB1MAX  ) IARIB1MAX  =IWIDE(9)
-            IF( IWIDE(10) > IAROB1MAX  ) IAROB1MAX  =IWIDE(10)
-          ENDDO
-          WRITE(NULOUT,'("")')
-          WRITE(NULOUT,'("SUECRAD: NRIWIDEN(MAX)  =",I8)')IRIWIDEMAXN
-          WRITE(NULOUT,'("SUECRAD: NRIWIDES(MAX)  =",I8)')IRIWIDEMAXS
-          WRITE(NULOUT,'("SUECRAD: NRIWIDEW(MAX)  =",I8)')IRIWIDEMAXW
-          WRITE(NULOUT,'("SUECRAD: NRIWIDEE(MAX)  =",I8)')IRIWIDEMAXE
-          WRITE(NULOUT,'("SUECRAD: NROWIDEN(MAX)  =",I8)')IROWIDEMAXN
-          WRITE(NULOUT,'("SUECRAD: NROWIDES(MAX)  =",I8)')IROWIDEMAXS
-          WRITE(NULOUT,'("SUECRAD: NROWIDEW(MAX)  =",I8)')IROWIDEMAXW
-          WRITE(NULOUT,'("SUECRAD: NROWIDEE(MAX)  =",I8)')IROWIDEMAXE
-          WRITE(NULOUT,'("SUECRAD: NARIB1(MAX)    =",I10)')IARIB1MAX
-          WRITE(NULOUT,'("SUECRAD: NAROB1(MAX)    =",I10)')IAROB1MAX
-          WRITE(NULOUT,'("")')
-        ENDIF
-        CALL FLUSH(NULOUT)
-      ENDIF
-
+    ! Read the absorption coefficient data and reduce from 256 to 140 g-points
+
+    CALL RRTM_INIT_140GP
+
+    INBLW = 16
+
+  ELSE
+    INBLW = 6
+
+  ENDIF
+
+  CALL SULWN
+  CALL SUSWN   (NTSW, NSW)
+  CALL SUCLOPN (NTSW, NSW, KLEV)
+
+  !-- routines specific to SRTM
+  IF (LSRTM) THEN
+    NTSW = 14
+    ISW = 14
+    CALL SRTM_INIT
+    CALL SUSRTAER
+    CALL SUSRTCOP
+    WRITE(UNIT = KULOUT, FMT = '(''SRTM Configuration'',L8,3I4)')LSRTM, NTSW, ISW, JPGPT
+
+  ELSE
+    IF (.NOT.LONEWSW .OR. ((NSW /= 2).AND.(NSW /= 4).AND.(NSW /= 6))) THEN
+      WRITE(UNIT = KULOUT, FMT = '(''Wrong SW Configuration'',L8,I3)')LONEWSW, NSW
     ENDIF
-!    CALL GSTATS(1818,1)      MPL 2.12.08
-
+
+    CALL SUSWN   (NTSW, NSW)
+    CALL SUAERSN (NTSW, NSW)
+  ENDIF
+  WRITE(UNIT = KULOUT, FMT = '('' NLW,NTSW,NSW SET EQUAL TO:'',3I3)') INBLW, NTSW, NSW
+
+
+  !-- routine specific to the UV processor
+  IF (LUVPROC) THEN
+    NUVTIM = NUVTIM * 86400
+    CALL SU_UVRAD (NUV)
+  ENDIF
+
+  !      ----------------------------------------------------------------
+
+  !*       6.    INITIALIZE AEROSOL OPTICAL PARAMETERS AND DISTRIBUTION
+  !              ------------------------------------------------------
+
+  !- LW optical properties
+  CALL SUAERL
+  !- SW optical properties moved above
+  !CALL SUAERSN (NTSW,NSW)
+
+  !- horizontal distribution
+  CALL SUAERH
+
+  !- vertical distribution
+  CALL SUAERV (KLEV, PETAH, &
+          & CVDAES, CVDAEL, CVDAEU, CVDAED, &
+          & RCTRBGA, RCVOBGA, RCSTBGA, RCAEOPS, RCAEOPL, RCAEOPU, &
+          & RCAEOPD, RCTRPT, RCAEADK, RCAEADM, RCAEROS &
+          &)
+
+  !-- Overlap function (only used if NOVLP=4)
+  ! Appel supprime par MPL (30042010) car NOVLP=4 pas utilise
+  ! sinon il faudrait calculer le geopotentiel STZ
+  !CALL SUOVLP ( KLEV )
+
+  !-- parameters for prognostic aerosols
+  CALL SU_AERW
+
+  !      ----------------------------------------------------------------
+
+  !*       7.    INITIALIZE SATELLITE GEOMETRICAL/RADIOMETRIC PARAMETERS
+  !              -------------------------------------------------------
+
+  IF (LEPHYS .AND. NMODE > 1) THEN
+    CALL SUSAT
+  ENDIF
+  !CALL GSTATS(1818,1)   MPL 2.12.08
+
+  !      ----------------------------------------------------------------
+
+  !*       8.    INITIALIZE CLIMATOLOGICAL OZONE DISTRIBUTION
+  !              --------------------------------------------
+  !                  (not done here!!!  called from APLPAR as it depends
+  !                     on model pressure levels!)
+
+  !      ----------------------------------------------------------------
+
+  !*       9.    SET UP MODEL CONFIGURATION FOR TIME-SPACE INTERPOLATION
+  !              -------------------------------------------------------
+
+  ZTSTEP = MAX(TSTEP, 1.0_JPRB)
+  ZSTPHR = 3600._JPRB / ZTSTEP
+  IRADFR = NRADFR
+  IF(NRADFR < 0) THEN
+    NRADFR = -NRADFR * ZSTPHR + 0.5_JPRB
+  ENDIF
+  NRADPFR = NRADPFR * NRADFR
+  IF (MOD(NRADPLA, 2) == 0.AND. NRADPLA /= 0) THEN
+    NRADPLA = NRADPLA + 1
+  ENDIF
+
+  IF(NRADUV < 0) THEN
+    NRADUV = -NRADUV * ZSTPHR + 0.5_JPRB
+  ENDIF
+
+  IST1HR = ZSTPHR + 0.05_JPRB
+  ISTNHR = NLNGR1H * ZSTPHR + 0.05_JPRB
+  IF (MOD(3600._JPRB, ZTSTEP) > 0.1_JPRB) THEN
+    801 CONTINUE
+    IST1HR = IST1HR + 1
+    IF (MOD(ISTNHR, IST1HR) /= 0) GO TO 801
+  ENDIF
+  IF (NRADFR == 1) THEN
+    NRADSFR = NRADFR
   ELSE
-
-    WRITE(NULOUT,'("SUECRAD: INVALID VALUE FOR NRADINT=",I6)')NRADINT
-    CALL ABOR1('SUECRAD: NRADINT INVALID')
-
-  ENDIF
-
-ENDIF              ! END OF LERADI BLOCK
-
-!      ----------------------------------------------------------------
-
-!*       4.    INITIALIZE RADIATION COEFFICIENTS.
-!              ----------------------------------
-
-RCDAY   = RDAY * RG / RCPD
-DIFF   = 1.66_JPRB
-R10E   = 0.4342945_JPRB
-
-! CALL GSTATS(1818,0)    MPL 2.12.08
-CALL SURDI
-
-IF (NINHOM == 0) THEN
-  RLWINHF=1._JPRB
-  RSWINHF=1._JPRB
-ENDIF
-
-!      ----------------------------------------------------------------
-
-!*       5.    INITIALIZE RADIATION ABSORPTION COEFFICIENTS
-!              --------------------------------------------
-
-!*       5.1.  Initialization routine for RRTM
-!              -------------------------------
-
-CALL SURRTAB
-CALL SURRTPK
-CALL SURRTRF
-CALL SURRTFTR
-
-IF (LRRTM) THEN
-  IF (KLEV > JPLAY) THEN
-    WRITE(UNIT=KULOUT,&
-     & FMT='('' RRTM MAXIMUM NUMBER OF LAYERS IS REACHED'',&
-     & '' CALL ABORT'')')  
-    CALL ABOR1(' ABOR1 CALLED SUECRAD')
-  ENDIF
-    
-! Read the absorption coefficient data and reduce from 256 to 140 g-points
-
-  CALL RRTM_INIT_140GP
-
-  INBLW=16
-
-ELSE
-  INBLW=6
-
-ENDIF
-
-CALL SULWN
-CALL SUSWN   (NTSW, NSW)
-CALL SUCLOPN (NTSW, NSW, KLEV)
-
-!-- routines specific to SRTM
-IF (LSRTM) THEN
-  NTSW=14
-  ISW =14
-  CALL SRTM_INIT
-  CALL SUSRTAER
-  CALL SUSRTCOP
-  WRITE(UNIT=KULOUT,FMT='(''SRTM Configuration'',L8,3I4)')LSRTM,NTSW,ISW,JPGPT
-
-ELSE
-  IF (.NOT.LONEWSW .OR. ((NSW /= 2).AND.(NSW /= 4).AND.(NSW /= 6)) ) THEN
-    WRITE(UNIT=KULOUT,FMT='(''Wrong SW Configuration'',L8,I3)')LONEWSW,NSW
-  ENDIF
-
-  CALL SUSWN   (NTSW,NSW)
-  CALL SUAERSN (NTSW,NSW)
-ENDIF
-WRITE(UNIT=KULOUT,FMT='('' NLW,NTSW,NSW SET EQUAL TO:'',3I3)') INBLW,NTSW,NSW
-
-
-!-- routine specific to the UV processor
-IF (LUVPROC) THEN
-  NUVTIM = NUVTIM * 86400
-  CALL SU_UVRAD ( NUV )
-ENDIF
-
-!      ----------------------------------------------------------------
-
-!*       6.    INITIALIZE AEROSOL OPTICAL PARAMETERS AND DISTRIBUTION
-!              ------------------------------------------------------
-
-!- LW optical properties
-CALL SUAERL
-!- SW optical properties moved above
-!CALL SUAERSN (NTSW,NSW)
-
-!- horizontal distribution      
-CALL SUAERH
-
-!- vertical distribution
-CALL SUAERV ( KLEV  , PETAH,&
- & CVDAES , CVDAEL , CVDAEU , CVDAED,&
- & RCTRBGA, RCVOBGA, RCSTBGA, RCAEOPS, RCAEOPL, RCAEOPU,&
- & RCAEOPD, RCTRPT , RCAEADK, RCAEADM, RCAEROS &
- & )  
-
-!-- Overlap function (only used if NOVLP=4)
-! Appel supprime par MPL (30042010) car NOVLP=4 pas utilise
-! sinon il faudrait calculer le geopotentiel STZ
-!CALL SUOVLP ( KLEV )
-
-!-- parameters for prognostic aerosols
-CALL SU_AERW
-
-!      ----------------------------------------------------------------
-
-!*       7.    INITIALIZE SATELLITE GEOMETRICAL/RADIOMETRIC PARAMETERS
-!              -------------------------------------------------------
-
-IF (LEPHYS .AND. NMODE > 1) THEN
-  CALL SUSAT
-ENDIF
-!CALL GSTATS(1818,1)   MPL 2.12.08
-
-!      ----------------------------------------------------------------
-
-!*       8.    INITIALIZE CLIMATOLOGICAL OZONE DISTRIBUTION
-!              --------------------------------------------
-!                  (not done here!!!  called from APLPAR as it depends
-!                     on model pressure levels!)
-
-!      ----------------------------------------------------------------
-
-!*       9.    SET UP MODEL CONFIGURATION FOR TIME-SPACE INTERPOLATION
-!              -------------------------------------------------------
-
-ZTSTEP=MAX(TSTEP,1.0_JPRB)
-ZSTPHR=3600._JPRB/ZTSTEP
-IRADFR=NRADFR
-IF(NRADFR < 0) THEN
-  NRADFR=-NRADFR*ZSTPHR+0.5_JPRB
-ENDIF
-NRADPFR=NRADPFR*NRADFR
-IF (MOD(NRADPLA,2) == 0.AND. NRADPLA /= 0) THEN
-  NRADPLA=NRADPLA+1
-ENDIF
-
-IF(NRADUV < 0) THEN
-  NRADUV=-NRADUV*ZSTPHR+0.5_JPRB
-ENDIF
-
-IST1HR=ZSTPHR+0.05_JPRB
-ISTNHR=  NLNGR1H *ZSTPHR+0.05_JPRB
-IF (MOD(3600._JPRB,ZTSTEP) > 0.1_JPRB) THEN
-  801 CONTINUE
-  IST1HR=IST1HR+1
-  IF (MOD(ISTNHR,IST1HR) /= 0) GO TO 801
-ENDIF
-IF (NRADFR == 1) THEN
-  NRADSFR=NRADFR
-ELSE
-  NRADSFR=IST1HR
-ENDIF
-NRADNFR=NRADFR
-
-IF(LRAYFM) THEN
-  NRPROMA=NDLON+6+(1-MOD(NDLON,2))
-ENDIF
-
-!      ----------------------------------------------------------------
-
-!*       10.    ALLOCATE WORK ARRAYS
-!               --------------------
-
-IU = NULOUT
-LLP = NPRINTLEV >= 1.OR. LALLOPR
-
-IF (LEPHYS) THEN
-  ALLOCATE(EMTD(NPROMA,NFLEVG+1,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'EMTD     ',SIZE(EMTD     ),SHAPE(EMTD     )
-  ALLOCATE(TRSW(NPROMA,NFLEVG+1,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'TRSW     ',SIZE(TRSW     ),SHAPE(TRSW     )
-  ALLOCATE(EMTC(NPROMA,NFLEVG+1,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'EMTC     ',SIZE(EMTC     ),SHAPE(EMTC     )
-  ALLOCATE(TRSC(NPROMA,NFLEVG+1,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'TRSC     ',SIZE(TRSC     ),SHAPE(TRSC     )
-  ALLOCATE(SRSWD(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'SRSWD    ',SIZE(SRSWD    ),SHAPE(SRSWD    )
-  ALLOCATE(SRLWD(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'SRLWD    ',SIZE(SRLWD    ),SHAPE(SRLWD    )
-  ALLOCATE(SRSWDCS(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'SRSWDCS  ',SIZE(SRSWDCS  ),SHAPE(SRSWDCS  )
-  ALLOCATE(SRLWDCS(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'SRLWDCS  ',SIZE(SRLWDCS  ),SHAPE(SRLWDCS  )
-  ALLOCATE(SRSWDV(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'SRSWDV   ',SIZE(SRSWDV   ),SHAPE(SRSWDV   )
-  ALLOCATE(SRSWDUV(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'SRSWDUV  ',SIZE(SRSWDUV  ),SHAPE(SRSWDUV  )
-  ALLOCATE(EDRO(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'EDRO     ',SIZE(EDRO     ),SHAPE(EDRO     )
-  ALLOCATE(SRSWPAR(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'SRSWPAR  ',SIZE(SRSWPAR  ),SHAPE(SRSWPAR  )
-  ALLOCATE(SRSWUVB(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'SRSWUVB  ',SIZE(SRSWUVB  ),SHAPE(SRSWUVB  )
-
-ELSEIF(LMPHYS .AND. (LRAYFM.OR.LRAYFM15)) THEN
-  ALLOCATE(EMTD(NPROMA,NFLEVG+1,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'EMTD     ',SIZE(EMTD     ),SHAPE(EMTD     )
-  ALLOCATE(TRSW(NPROMA,NFLEVG+1,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'TRSW     ',SIZE(TRSW     ),SHAPE(TRSW     )
-  ALLOCATE(EMTU(NPROMA,NFLEVG+1,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'EMTC     ',SIZE(EMTU     ),SHAPE(EMTU     )
-  ALLOCATE(RMOON(NPROMA,NGPBLKS))
-  IF(LLP)WRITE(IU,9) 'RMOON    ',SIZE(RMOON    ),SHAPE(RMOON    )
-ENDIF
-ALLOCATE(SRSWPARC(NPROMA,NGPBLKS))
-IF(LLP)WRITE(IU,9) 'SRSWPARC ',SIZE(SRSWPARC ),SHAPE(SRSWPARC )
-ALLOCATE(SRSWTINC(NPROMA,NGPBLKS))
-IF(LLP)WRITE(IU,9) 'SRSWTINC ',SIZE(SRSWTINC ),SHAPE(SRSWTINC )
-
-9 FORMAT(1X,'ARRAY ',A10,' ALLOCATED ',8I8)
-
-!      ----------------------------------------------------------------
-
-!*       10.    PRINT FINAL VALUES.
-!               -------------------
-
-IF (LOUTPUT) THEN
-  WRITE(UNIT=KULOUT,FMT='('' COMMON YOERAD '')')
-  WRITE(UNIT=KULOUT,FMT='('' LERADI  = '',L5 &
-   & ,'' LERAD1H = '',L5,'' LECO2VAR= '',L5,'' LHGHG = '',L5 &
-   & ,'' NLNGR1H = '',I2,'' NRADSFR = '',I2)')&
-   & LERADI,LERAD1H,LECO2VAR,LHGHG,NLNGR1H,NRADSFR  
-  WRITE(UNIT=KULOUT,FMT='('' LEPO3RA  = '',L5,'' YO3%LGP = '',L5 )') LEPO3RA,YO3%LGP
-  WRITE(UNIT=KULOUT,FMT='('' NRADFR  = '',I2 &
-   & ,'' NRADPFR = '',I3 &
-   & ,'' NRADPLA = '',I2 &
-   & ,'' NRINT   = '',I1 &
-   & ,'' NRPROMA = '',I5 &
-   & )')&
-   & NRADFR,NRADPFR,NRADPLA,NRINT, NRPROMA
-  WRITE(UNIT=KULOUT,FMT='('' LERADHS= '',L5 &
-   & ,'' LRRTM = '',L5 &
-   & ,'' LSRTM = '',L5 &
-   & ,'' NMODE = '',I1 &
-   & ,'' NOZOCL= '',I1 &
-   & ,'' NAER  = '',I1 &
-   & ,'' NHINCSOL='',I2 &
-   & )')&
-   & LERADHS,LRRTM,LSRTM,NMODE,NOZOCL,NAER,NHINCSOL
-  IF (.NOT.LHGHG .AND. .NOT.LECO2VAR) WRITE(UNIT=KULOUT,FMT='('' RCCO2= '',E10.3 &
-    &,'' RCCH4= '',E10.3,'' RCN2O= '',E10.3,'' RCCFC11= '',E10.3,'' RCFC12= '',E10.3 &
-    &)')&
-    & RCCO2,RCCH4,RCN2O,RCCFC11,RCCFC12
-  WRITE(UNIT=KULOUT,FMT='('' NINHOM = '',I1 &
-   & ,'' NLAYINH='',I1   &
-   & ,'' RLWINHF='',F4.2 &
-   & ,'' RSWINHF='',F4.2 &
-   & )')&
-   & NINHOM,NLAYINH,RLWINHF,RSWINHF  
-  IF (NPERTAER /= 0 .OR. NPERTOZ /= 0) THEN
-    WRITE(UNIT=KULOUT,FMT='('' NPERTAER= '',I2 &
-   & ,'' LNOTROAER='',L5 &
-   & ,'' NPERTOZ = '',I1 &
-   & ,'' RPERTOZ = '',F5.0 &
-   & )')&
-   & NPERTAER,LNOTROAER,NPERTOZ,RPERTOZ
-  ENDIF
-  WRITE(UNIT=KULOUT,FMT='('' NRADINT = '',I2)')NRADINT
-  WRITE(UNIT=KULOUT,FMT='('' NRADRES = '',I4)')NRADRES
-  WRITE(UNIT=KULOUT,FMT='('' LRADONDEM = '',L5)')LRADONDEM
-  IF( NRADINT > 0 )THEN
-    IDIR=LEN_TRIM(CRTABLEDIR)
-    IFIL=LEN_TRIM(CRTABLEFIL)
-    WRITE(UNIT=KULOUT,FMT='('' CRTABLEDIR = '',A,'' CRTABLEFIL = '',A)')&
-     & CRTABLEDIR(1:IDIR),CRTABLEFIL(1:IFIL)  
-  ENDIF
-  WRITE(UNIT=KULOUT,FMT='('' LCCNL = '',L5 &
-   & ,'' LCCNO = '',L5 &
-   & ,'' RCCNLND= '',F5.0 &
-   & ,'' RCCNSEA= '',F5.0 &
-   & ,'' LE4ALB = '',L5 &
-   &)')&
-   & LCCNL,LCCNO,RCCNLND,RCCNSEA,LE4ALB 
-  IF (LHVOLCA) THEN
-    WRITE(UNIT=KULOUT,FMT='('' HISTORY OF VOLCANIC AEROSOLS= '',L5)')LHVOLCA
-  ENDIF
-  WRITE(UNIT=KULOUT,FMT='('' LONEWSW= '',L5 &
-   & ,'' NRADIP = '',I1 &
-   & ,'' NRADLP = '',I1 &
-   & ,'' NICEOPT= '',I1 &
-   & ,'' NLIQOPT= '',I1 &
-   & ,'' LDIFFC = '',L5 &
-   & )')&
-   & LONEWSW,NRADIP,NRADLP,NICEOPT,NLIQOPT,LDIFFC
-  WRITE(UNIT=KULOUT,FMT='('' WARNING! CLOUD OVERLAP ASSUMPT. IS''&
-   & ,'' NOVLP   = '',I2 &
-   & )')&
-   & NOVLP  
-  IF (LUVPROC) THEN
-    IDAYUV=NUVTIM/86400
-    WRITE(UNIT=KULOUT,FMT='('' LUVPROC = '',L5 &
-   & ,'' LUVTDEP= '',L5 &
-   & ,'' NRADUV = '',I2 &
-   & ,'' NUV = '',I2 &
-   & ,'' NDAYUV = '',I5 &
-   & ,'' RMUZUV = '',E9.3 &
-   & )')&
-   & LUVPROC,LUVTDEP,NRADUV,NUV,IDAYUV,RMUZUV
-    WRITE(UNIT=KULOUT,FMT='('' RUVLAM = '',24F6.1)') (RUVLAM(JUV),JUV=1,NUV) 
-    WRITE(UNIT=KULOUT,FMT='('' JUVLAM = '',24(3X,I1,2X))') (JUVLAM(JUV),JUV=1,NUV) 
-  ENDIF
-  WRITE(UNIT=KULOUT,FMT='('' NMCICA= '',I2 &
-   & )')&
-   & NMCICA
-ENDIF
-
-!     ------------------------------------------------------------------
-
-
-IF (LHOOK) CALL DR_HOOK('SUECRAD',1,ZHOOK_HANDLE)
+    NRADSFR = IST1HR
+  ENDIF
+  NRADNFR = NRADFR
+
+  IF(LRAYFM) THEN
+    NRPROMA = NDLON + 6 + (1 - MOD(NDLON, 2))
+  ENDIF
+
+  !      ----------------------------------------------------------------
+
+  !*       10.    ALLOCATE WORK ARRAYS
+  !               --------------------
+
+  IU = NULOUT
+  LLP = NPRINTLEV >= 1.OR. LALLOPR
+
+  IF (LEPHYS) THEN
+    ALLOCATE(EMTD(NPROMA, NFLEVG + 1, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'EMTD     ', SIZE(EMTD), SHAPE(EMTD)
+    ALLOCATE(TRSW(NPROMA, NFLEVG + 1, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'TRSW     ', SIZE(TRSW), SHAPE(TRSW)
+    ALLOCATE(EMTC(NPROMA, NFLEVG + 1, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'EMTC     ', SIZE(EMTC), SHAPE(EMTC)
+    ALLOCATE(TRSC(NPROMA, NFLEVG + 1, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'TRSC     ', SIZE(TRSC), SHAPE(TRSC)
+    ALLOCATE(SRSWD(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'SRSWD    ', SIZE(SRSWD), SHAPE(SRSWD)
+    ALLOCATE(SRLWD(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'SRLWD    ', SIZE(SRLWD), SHAPE(SRLWD)
+    ALLOCATE(SRSWDCS(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'SRSWDCS  ', SIZE(SRSWDCS), SHAPE(SRSWDCS)
+    ALLOCATE(SRLWDCS(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'SRLWDCS  ', SIZE(SRLWDCS), SHAPE(SRLWDCS)
+    ALLOCATE(SRSWDV(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'SRSWDV   ', SIZE(SRSWDV), SHAPE(SRSWDV)
+    ALLOCATE(SRSWDUV(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'SRSWDUV  ', SIZE(SRSWDUV), SHAPE(SRSWDUV)
+    ALLOCATE(EDRO(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'EDRO     ', SIZE(EDRO), SHAPE(EDRO)
+    ALLOCATE(SRSWPAR(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'SRSWPAR  ', SIZE(SRSWPAR), SHAPE(SRSWPAR)
+    ALLOCATE(SRSWUVB(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'SRSWUVB  ', SIZE(SRSWUVB), SHAPE(SRSWUVB)
+
+  ELSEIF(LMPHYS .AND. (LRAYFM.OR.LRAYFM15)) THEN
+    ALLOCATE(EMTD(NPROMA, NFLEVG + 1, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'EMTD     ', SIZE(EMTD), SHAPE(EMTD)
+    ALLOCATE(TRSW(NPROMA, NFLEVG + 1, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'TRSW     ', SIZE(TRSW), SHAPE(TRSW)
+    ALLOCATE(EMTU(NPROMA, NFLEVG + 1, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'EMTC     ', SIZE(EMTU), SHAPE(EMTU)
+    ALLOCATE(RMOON(NPROMA, NGPBLKS))
+    IF(LLP)WRITE(IU, 9) 'RMOON    ', SIZE(RMOON), SHAPE(RMOON)
+  ENDIF
+  ALLOCATE(SRSWPARC(NPROMA, NGPBLKS))
+  IF(LLP)WRITE(IU, 9) 'SRSWPARC ', SIZE(SRSWPARC), SHAPE(SRSWPARC)
+  ALLOCATE(SRSWTINC(NPROMA, NGPBLKS))
+  IF(LLP)WRITE(IU, 9) 'SRSWTINC ', SIZE(SRSWTINC), SHAPE(SRSWTINC)
+
+  9 FORMAT(1X, 'ARRAY ', A10, ' ALLOCATED ', 8I8)
+
+  !      ----------------------------------------------------------------
+
+  !*       10.    PRINT FINAL VALUES.
+  !               -------------------
+
+  IF (LOUTPUT) THEN
+    WRITE(UNIT = KULOUT, FMT = '('' COMMON YOERAD '')')
+    WRITE(UNIT = KULOUT, FMT = '('' LERADI  = '',L5 &
+            & ,'' LERAD1H = '',L5,'' LECO2VAR= '',L5,'' LHGHG = '',L5 &
+            & ,'' NLNGR1H = '',I2,'' NRADSFR = '',I2)')&
+            & LERADI, LERAD1H, LECO2VAR, LHGHG, NLNGR1H, NRADSFR
+    WRITE(UNIT = KULOUT, FMT = '('' LEPO3RA  = '',L5,'' YO3%LGP = '',L5 )') LEPO3RA, YO3%LGP
+    WRITE(UNIT = KULOUT, FMT = '('' NRADFR  = '',I2 &
+            & ,'' NRADPFR = '',I3 &
+            & ,'' NRADPLA = '',I2 &
+            & ,'' NRINT   = '',I1 &
+            & ,'' NRPROMA = '',I5 &
+            & )')&
+            & NRADFR, NRADPFR, NRADPLA, NRINT, NRPROMA
+    WRITE(UNIT = KULOUT, FMT = '('' LERADHS= '',L5 &
+            & ,'' LRRTM = '',L5 &
+            & ,'' LSRTM = '',L5 &
+            & ,'' NMODE = '',I1 &
+            & ,'' NOZOCL= '',I1 &
+            & ,'' NAER  = '',I1 &
+            & ,'' NHINCSOL='',I2 &
+            & )')&
+            & LERADHS, LRRTM, LSRTM, NMODE, NOZOCL, NAER, NHINCSOL
+    IF (.NOT.LHGHG .AND. .NOT.LECO2VAR) WRITE(UNIT = KULOUT, FMT = '('' RCCO2= '',E10.3 &
+            &,'' RCCH4= '',E10.3,'' RCN2O= '',E10.3,'' RCCFC11= '',E10.3,'' RCFC12= '',E10.3 &
+            &)')&
+            & RCCO2, RCCH4, RCN2O, RCCFC11, RCCFC12
+    WRITE(UNIT = KULOUT, FMT = '('' NINHOM = '',I1 &
+            & ,'' NLAYINH='',I1   &
+            & ,'' RLWINHF='',F4.2 &
+            & ,'' RSWINHF='',F4.2 &
+            & )')&
+            & NINHOM, NLAYINH, RLWINHF, RSWINHF
+    IF (NPERTAER /= 0 .OR. NPERTOZ /= 0) THEN
+      WRITE(UNIT = KULOUT, FMT = '('' NPERTAER= '',I2 &
+              & ,'' LNOTROAER='',L5 &
+              & ,'' NPERTOZ = '',I1 &
+              & ,'' RPERTOZ = '',F5.0 &
+              & )')&
+              & NPERTAER, LNOTROAER, NPERTOZ, RPERTOZ
+    ENDIF
+    WRITE(UNIT = KULOUT, FMT = '('' NRADINT = '',I2)')NRADINT
+    WRITE(UNIT = KULOUT, FMT = '('' NRADRES = '',I4)')NRADRES
+    WRITE(UNIT = KULOUT, FMT = '('' LRADONDEM = '',L5)')LRADONDEM
+    IF(NRADINT > 0)THEN
+      IDIR = LEN_TRIM(CRTABLEDIR)
+      IFIL = LEN_TRIM(CRTABLEFIL)
+      WRITE(UNIT = KULOUT, FMT = '('' CRTABLEDIR = '',A,'' CRTABLEFIL = '',A)')&
+              & CRTABLEDIR(1:IDIR), CRTABLEFIL(1:IFIL)
+    ENDIF
+    WRITE(UNIT = KULOUT, FMT = '('' LCCNL = '',L5 &
+            & ,'' LCCNO = '',L5 &
+            & ,'' RCCNLND= '',F5.0 &
+            & ,'' RCCNSEA= '',F5.0 &
+            & ,'' LE4ALB = '',L5 &
+            &)')&
+            & LCCNL, LCCNO, RCCNLND, RCCNSEA, LE4ALB
+    IF (LHVOLCA) THEN
+      WRITE(UNIT = KULOUT, FMT = '('' HISTORY OF VOLCANIC AEROSOLS= '',L5)')LHVOLCA
+    ENDIF
+    WRITE(UNIT = KULOUT, FMT = '('' LONEWSW= '',L5 &
+            & ,'' NRADIP = '',I1 &
+            & ,'' NRADLP = '',I1 &
+            & ,'' NICEOPT= '',I1 &
+            & ,'' NLIQOPT= '',I1 &
+            & ,'' LDIFFC = '',L5 &
+            & )')&
+            & LONEWSW, NRADIP, NRADLP, NICEOPT, NLIQOPT, LDIFFC
+    WRITE(UNIT = KULOUT, FMT = '('' WARNING! CLOUD OVERLAP ASSUMPT. IS''&
+            & ,'' NOVLP   = '',I2 &
+            & )')&
+            & NOVLP
+    IF (LUVPROC) THEN
+      IDAYUV = NUVTIM / 86400
+      WRITE(UNIT = KULOUT, FMT = '('' LUVPROC = '',L5 &
+              & ,'' LUVTDEP= '',L5 &
+              & ,'' NRADUV = '',I2 &
+              & ,'' NUV = '',I2 &
+              & ,'' NDAYUV = '',I5 &
+              & ,'' RMUZUV = '',E9.3 &
+              & )')&
+              & LUVPROC, LUVTDEP, NRADUV, NUV, IDAYUV, RMUZUV
+      WRITE(UNIT = KULOUT, FMT = '('' RUVLAM = '',24F6.1)') (RUVLAM(JUV), JUV = 1, NUV)
+      WRITE(UNIT = KULOUT, FMT = '('' JUVLAM = '',24(3X,I1,2X))') (JUVLAM(JUV), JUV = 1, NUV)
+    ENDIF
+    WRITE(UNIT = KULOUT, FMT = '('' NMCICA= '',I2 &
+            & )')&
+            & NMCICA
+  ENDIF
+
+  !     ------------------------------------------------------------------
+
+  IF (LHOOK) CALL DR_HOOK('SUECRAD', 1, ZHOOK_HANDLE)
 END SUBROUTINE SUECRAD
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suecrad15.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suecrad15.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suecrad15.F90	(revision 5154)
@@ -78,8 +78,7 @@
 USE YOMPRAD  , ONLY : LODBGRADI,LODBGRADL
 USE YOMRADF  , ONLY : EMTD     ,EMTU      ,TRSW    ,RMOON
+USE lmdz_clesphys
 
 IMPLICIT NONE
-
-include "clesphys.h"
 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suphec.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suphec.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/suphec.F90	(revision 5154)
@@ -88,8 +88,8 @@
 USE YOMCT0  , ONLY  : LSCMEC   ,LROUGH   ,REXTZ0M  ,REXTZ0H
 USE lmdz_vertical_layers, ONLY: ap,bp
+USE lmdz_clesphys
+USE lmdz_yoethf
 
 IMPLICIT NONE
-include "YOETHF.h"
-include "clesphys.h"
 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KULOUT 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw.F90	(revision 5154)
@@ -74,8 +74,7 @@
 ! NSW mis dans .def MPL 20140211
 USE lmdz_writefield_phy, ONLY: writefield_phy
+USE lmdz_clesphys
 
 IMPLICIT NONE
-
-include "clesphys.h"
 
 integer, save :: icount=0
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw.intfb.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw.intfb.h	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw.intfb.h	(revision 5154)
@@ -13,5 +13,6 @@
  & ) 
 USE PARKIND1 ,ONLY : JPIM ,JPRB
-include "clesphys.h"    
+USE lmdz_clesphys
+
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw1s.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw1s.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw1s.F90	(revision 5154)
@@ -73,8 +73,7 @@
 ! NSW mis dans .def MPL 20140211
 USE lmdz_writefield_phy, ONLY: writefield_phy
+USE lmdz_clesphys
 
 IMPLICIT NONE
-
-include "clesphys.h"
 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw1s.intfb.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw1s.intfb.h	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/sw1s.intfb.h	(revision 5154)
@@ -8,5 +8,6 @@
  & ) 
 USE PARKIND1 ,ONLY : JPIM ,JPRB
-include "clesphys.h"
+USE lmdz_clesphys
+
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swclr.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swclr.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swclr.F90	(revision 5154)
@@ -70,7 +70,7 @@
 USE YOERDI   , ONLY : REPCLC
 USE YOERDU   , ONLY : REPSCT
+USE lmdz_clesphys
 
 IMPLICIT NONE
-INCLUDE "clesphys.h"
 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swclr.intfb.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swclr.intfb.h	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swclr.intfb.h	(revision 5154)
@@ -8,5 +8,6 @@
 USE PARKIND1 ,ONLY : JPIM ,JPRB
 USE YOERAD , ONLY : NOVLP 
-include "clesphys.h"
+USE lmdz_clesphys
+
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swni.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swni.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swni.F90	(revision 5154)
@@ -81,8 +81,7 @@
 USE YOERDU   , ONLY : REPLOG   ,REPSCQ   ,REPSC
 USE lmdz_writefield_phy, ONLY: writefield_phy
+USE lmdz_clesphys
 
 IMPLICIT NONE
-
-include "clesphys.h"
 
 character*1 str1
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swni.intfb.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swni.intfb.h	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swni.intfb.h	(revision 5154)
@@ -9,5 +9,6 @@
 USE PARKIND1 ,ONLY : JPIM ,JPRB
 USE YOERAD , ONLY : NOVLP
-include "clesphys.h"
+USE lmdz_clesphys
+
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swr.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swr.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swr.F90	(revision 5154)
@@ -66,9 +66,9 @@
 USE YOEOVLP  , ONLY : RA1OVLP
 USE lmdz_writefield_phy, ONLY: writefield_phy
+USE lmdz_clesphys
 
 IMPLICIT NONE
 
-include "clesphys.h" 
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
+INTEGER(KIND=JPIM),INTENT(IN)    :: KLON
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swr.intfb.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swr.intfb.h	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swr.intfb.h	(revision 5154)
@@ -8,5 +8,6 @@
 USE PARKIND1 ,ONLY : JPIM ,JPRB
 USE YOERAD , ONLY : NOVLP 
-include "clesphys.h"
+USE lmdz_clesphys
+
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swu.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swu.F90	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swu.F90	(revision 5154)
@@ -64,9 +64,9 @@
  & RTDH2O   ,RTDUMG   ,RTH2O    ,RTUMG  
 USE YOEOVLP  , ONLY : RA1OVLP
+USE lmdz_clesphys
 
 IMPLICIT NONE
 
-include "clesphys.h"
-INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
+INTEGER(KIND=JPIM),INTENT(IN)    :: KLON
 INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
 INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swu.intfb.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swu.intfb.h	(revision 5153)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/rrtm/swu.intfb.h	(revision 5154)
@@ -7,5 +7,6 @@
 USE PARKIND1 ,ONLY : JPIM ,JPRB
 USE YOERAD , ONLY : NOVLP
-include "clesphys.h"
+USE lmdz_clesphys
+
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
