Index: trunk/LMDZ.GENERIC/README
===================================================================
--- trunk/LMDZ.GENERIC/README	(revision 2536)
+++ trunk/LMDZ.GENERIC/README	(revision 2537)
@@ -1660,3 +1660,4 @@
 - We also removed the old (obsolete) parameterizations (CKD and PPC) from the code 
 
-
+==16/06/2021 == MT
+- Add the Surface SW spectrum in diagspecVI netcdf output file (useful as a diagnostic of surface radiation condition for e.g. habitability studies)
Index: trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90	(revision 2536)
+++ trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90	(revision 2537)
@@ -11,5 +11,5 @@
           fluxsurf_sw,fluxsurfabs_sw,fluxtop_lw,               &
           fluxabs_sw,fluxtop_dn,                               &
-          OLR_nu,OSR_nu,                                       &
+          OLR_nu,OSR_nu,GSR_nu,                                &
           int_dtaui,int_dtauv,                                 &
           tau_col,cloudfrac,totcloudfrac,                      &
@@ -91,6 +91,7 @@
       REAL,INTENT(OUT) :: fluxabs_sw(ngrid)              ! SW flux absorbed by the planet (W/m2).
       REAL,INTENT(OUT) :: fluxtop_dn(ngrid)              ! Incident top of atmosphere SW flux (W/m2).
-      REAL,INTENT(OUT) :: OLR_nu(ngrid,L_NSPECTI)        ! Outgoing LW radition in each band (Normalized to the band width (W/m2/cm-1).
-      REAL,INTENT(OUT) :: OSR_nu(ngrid,L_NSPECTV)        ! Outgoing SW radition in each band (Normalized to the band width (W/m2/cm-1).
+      REAL,INTENT(OUT) :: OLR_nu(ngrid,L_NSPECTI)        ! Outgoing LW radiation in each band (Normalized to the band width (W/m2/cm-1).
+      REAL,INTENT(OUT) :: OSR_nu(ngrid,L_NSPECTV)        ! Outgoing SW radiation in each band (Normalized to the band width (W/m2/cm-1).
+      REAL,INTENT(OUT) :: GSR_nu(ngrid,L_NSPECTV)        ! Surface SW radiation in each band (Normalized to the band width (W/m2/cm-1).
       REAL,INTENT(OUT) :: tau_col(ngrid)                 ! Diagnostic from aeropacity.
       REAL,INTENT(OUT) :: albedo_equivalent(ngrid)       ! Spectrally Integrated Albedo. For Diagnostic. By MT2015
@@ -285,4 +286,5 @@
       OLR_nu(:,:) = 0.
       OSR_nu(:,:) = 0.
+      GSR_nu(:,:) = 0.
 
 !--------------------------------------------------
@@ -911,5 +913,5 @@
             end do
             do nw=1,L_NSPECTV 
-               !GSR_nu(ig,nw)=nfluxgndv_nu(nw)
+               GSR_nu(ig,nw)=nfluxgndv_nu(nw)/DWNV(nw)
                OSR_nu(ig,nw)=nfluxoutv_nu(nw)/DWNV(nw) !JL Normalize to the bandwidth
             end do
Index: trunk/LMDZ.GENERIC/libf/phystd/phys_state_var_mod.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/phys_state_var_mod.F90	(revision 2536)
+++ trunk/LMDZ.GENERIC/libf/phystd/phys_state_var_mod.F90	(revision 2537)
@@ -66,8 +66,9 @@
       real,dimension(:,:),allocatable,save :: OLR_nu        ! Outgoing LW radiation in each band (Normalized to the band width (W/m2/cm-1)).
       real,dimension(:,:),allocatable,save :: OSR_nu        ! Outgoing SW radiation in each band (Normalized to the band width (W/m2/cm-1)).
+      real,dimension(:,:),allocatable,save :: GSR_nu        ! Surface SW (or 'Ground' SW) radiation in each band (Normalized to the band width (W/m2/cm-1)).
       real,dimension(:,:),allocatable,save :: zdtlw         ! LW heating tendencies (K/s).
       real,dimension(:,:),allocatable,save :: zdtsw         ! SW heating tendencies (K/s).
       !real,dimension(:),allocatable,save :: sensibFlux      ! Turbulent flux given by the atmosphere to the surface (W.m-2).
-!$OMP THREADPRIVATE(OLR_nu,OSR_nu,zdtlw,zdtsw)
+!$OMP THREADPRIVATE(OLR_nu,OSR_nu,GSR_nu,zdtlw,zdtsw)
 
       real,dimension(:,:,:),allocatable,save :: int_dtauv   ! VI optical thickness of layers within narrowbands for diags ().
@@ -179,4 +180,5 @@
         ALLOCATE(OLR_nu(klon,L_NSPECTI))
         ALLOCATE(OSR_nu(klon,L_NSPECTV))
+        ALLOCATE(GSR_nu(klon,L_NSPECTV))
         ALLOCATE(int_dtaui(klon,klev,L_NSPECTI))
         ALLOCATE(int_dtauv(klon,klev,L_NSPECTV))
@@ -269,4 +271,5 @@
         DEALLOCATE(OLR_nu)
         DEALLOCATE(OSR_nu)
+        DEALLOCATE(GSR_nu)
         DEALLOCATE(int_dtaui)
         DEALLOCATE(int_dtauv)
Index: trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90	(revision 2536)
+++ trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90	(revision 2537)
@@ -405,5 +405,7 @@
       real fluxsurfabs_sw1(ngrid)  ! For SW/LW flux.
       real tau_col1(ngrid)                                                   ! For aerosol optical depth diagnostic.
-      real OLR_nu1(ngrid,L_NSPECTI), OSR_nu1(ngrid,L_NSPECTV)                ! For Outgoing Radiation diagnostics.
+      real OLR_nu1(ngrid,L_NSPECTI) ! Clear sky TOA LW radiation in each IR band
+      real OSR_nu1(ngrid,L_NSPECTV) ! Clear sky TOA SW radiation in each VI band
+      real GSR_nu1(ngrid,L_NSPECTV) ! Clear sky Surface SW radiation in each VI band
       real int_dtaui1(ngrid,nlayer,L_NSPECTI),int_dtauv1(ngrid,nlayer,L_NSPECTV) ! For optical thickness diagnostics.
       real tf, ntf
@@ -905,5 +907,5 @@
                               zdtlw,zdtsw,fluxsurf_lw,fluxsurf_sw,                &
                               fluxsurfabs_sw,fluxtop_lw,                          &
-                              fluxabs_sw,fluxtop_dn,OLR_nu,OSR_nu,                &
+                              fluxabs_sw,fluxtop_dn,OLR_nu,OSR_nu,GSR_nu,         &
                               int_dtaui,int_dtauv,                                &
                               tau_col,cloudfrac,totcloudfrac,                     &
@@ -916,9 +918,9 @@
                   clearsky=.true.
                   call callcorrk(ngrid,nlayer,pq,nq,qsurf,                           &
-                                 albedo,albedo_equivalent1,emis,mu0,pplev,pplay,pt,   &
+                                 albedo,albedo_equivalent1,emis,mu0,pplev,pplay,pt,  &
                                  tsurf,fract,dist_star,aerosol,muvar,                &
                                  zdtlw1,zdtsw1,fluxsurf_lw1,fluxsurf_sw1,            &
                                  fluxsurfabs_sw1,fluxtop_lw1,                        &
-                                 fluxabs_sw1,fluxtop_dn,OLR_nu1,OSR_nu1,             &
+                                 fluxabs_sw1,fluxtop_dn,OLR_nu1,OSR_nu1,GSR_nu1,     &
                                  int_dtaui1,int_dtauv1,                              &
                                  tau_col1,cloudfrac,totcloudfrac,                    &
@@ -941,5 +943,6 @@
                      zdtsw(ig,1:nlayer) = ntf*zdtsw1(ig,1:nlayer) + tf*zdtsw(ig,1:nlayer)
 
-                     OSR_nu(ig,1:L_NSPECTV) = ntf*OSR_nu1(ig,1:L_NSPECTV) + tf*OSR_nu(ig,1:L_NSPECTV)                       
+                     OSR_nu(ig,1:L_NSPECTV) = ntf*OSR_nu1(ig,1:L_NSPECTV) + tf*OSR_nu(ig,1:L_NSPECTV)       
+                     GSR_nu(ig,1:L_NSPECTV) = ntf*GSR_nu1(ig,1:L_NSPECTV) + tf*GSR_nu(ig,1:L_NSPECTV)                  
                      OLR_nu(ig,1:L_NSPECTI) = ntf*OLR_nu1(ig,1:L_NSPECTI) + tf*OLR_nu(ig,1:L_NSPECTI)                       
                      if (diagdtau) then
@@ -2314,4 +2317,5 @@
          call writediagspecIR(ngrid,"OLR3D","OLR(lon,lat,band)","W/m^2/cm^-1",3,OLR_nu)
          call writediagspecVI(ngrid,"OSR3D","OSR(lon,lat,band)","W/m^2/cm^-1",3,OSR_nu)
+         call writediagspecVI(ngrid,"GSR3D","GSR(lon,lat,band)","W/m^2/cm^-1",3,GSR_nu)
       endif
 
