Index: /trunk/LMDZ.GENERIC/README
===================================================================
--- /trunk/LMDZ.GENERIC/README	(revision 2469)
+++ /trunk/LMDZ.GENERIC/README	(revision 2470)
@@ -1623,2 +1623,7 @@
 ModernTrac bug fix in infotrac from commit r2436 24/11/2020
 Missing log message, see previous commit r2468
+
+== 08/03/2020 == YJ
+global1d and szangle for 1D simulation moved from callcorrk to callkeys
+to defined a consistent 1D sza in physiq_mod used also in chemistry
++ typo
Index: /trunk/LMDZ.GENERIC/libf/dynphy_lonlat/inigeomphy_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 2469)
+++ /trunk/LMDZ.GENERIC/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 2470)
@@ -7,6 +7,5 @@
                      rlatu,rlatv,rlonu,rlonv,aire,cu,cv)
   USE mod_grid_phy_lmdz, ONLY: klon_glo,  & ! number of atmospheric columns (on full grid)
-                               regular_lonlat, &  ! regular longitude-latitude grid type
-                               nbp_lon, nbp_lat, nbp_lev
+                               regular_lonlat  ! regular longitude-latitude grid type
   USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid)
                                 klon_omp_begin, & ! start index of local omp subgrid
@@ -48,5 +47,5 @@
   INTEGER :: ibegin, iend, offset
   INTEGER :: i,j,k
-  CHARACTER (LEN=20) :: modname = 'iniphysiq'
+  CHARACTER (LEN=20) :: modname = 'inigeomphy'
   CHARACTER (LEN=80) :: abort_message
   REAL :: total_area_phy, total_area_dyn
@@ -170,5 +169,5 @@
     total_area_phy=sum(airefi_glo(1:klon_glo))
     IF (total_area_dyn/=total_area_phy) THEN
-      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
+      WRITE (lunout, *) 'inigeomphy: planet total surface discrepancy !!!'
       WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
       WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
Index: /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90	(revision 2469)
+++ /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90	(revision 2470)
@@ -33,5 +33,5 @@
       use callkeys_mod, only: varactive,diurnal,tracer,water,varfixed,satval,diagdtau,    &
                               kastprof,strictboundcorrk,specOLR,CLFvarying,               &
-                              tplanckmin,tplanckmax
+                              tplanckmin,tplanckmax,global1d
       use optcv_mod, only: optcv
       use optci_mod, only: optci
@@ -154,8 +154,4 @@
       INTEGER ig,l,k,nw,iaer
 
-      real,save :: szangle
-      logical,save :: global1d
-!$OMP THREADPRIVATE(szangle,global1d)
-
       real*8,allocatable,save :: taugsurf(:,:)
       real*8,allocatable,save :: taugsurfi(:,:)
@@ -271,25 +267,4 @@
             message='varactive in callcorrk but no h2o_vap tracer.'
             call abort_physic(subname,message,1)
-         endif
-
-         if (ngrid.eq.1) then
-            PRINT*, 'Simulate global averaged conditions ?'
-            global1d = .false. ! default value
-            call getin_p("global1d",global1d)
-            write(*,*) "global1d = ",global1d
-            
-            ! Test of incompatibility : if global1d is true, there should not be any diurnal cycle.
-            if (global1d.and.diurnal) then
-               message='if global1d is true, diurnal must be set to false'
-               call abort_physic(subname,message,1)
-            endif
-
-            if (global1d) then
-               PRINT *,'Solar Zenith angle (deg.) ?'
-               PRINT *,'(assumed for averaged solar flux S/4)'
-               szangle=60.0  ! default value
-               call getin_p("szangle",szangle)
-               write(*,*) "szangle = ",szangle
-            endif
          endif
 
@@ -531,10 +506,5 @@
          ENDDO
 
-      if ((ngrid.eq.1).and.(global1d)) then ! Fixed zenith angle 'szangle' in 1D simulations w/ globally-averaged sunlight.
-         acosz = cos(pi*szangle/180.0)
-         print*,'acosz=',acosz,', szangle=',szangle
-      else
          acosz=mu0(ig) ! Cosine of sun incident angle : 3D simulations or local 1D simulations using latitude.
-      endif
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Index: /trunk/LMDZ.GENERIC/libf/phystd/callkeys_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/callkeys_mod.F90	(revision 2469)
+++ /trunk/LMDZ.GENERIC/libf/phystd/callkeys_mod.F90	(revision 2470)
@@ -64,4 +64,7 @@
       logical,save :: gwd_convective_source
 !$OMP THREADPRIVATE(calllott_nonoro,gwd_convective_source)
+      logical,save :: global1d
+      real,save    :: szangle
+!$OMP THREADPRIVATE(global1d,szangle)
 
       integer,save :: iddist
Index: /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90	(revision 2469)
+++ /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90	(revision 2470)
@@ -8,5 +8,5 @@
   use comsaison_h, only: mu0, fract, dist_star
   use planete_mod
-  use callkeys_mod, only: check_cpp_match, pceil, tstrat, tracer
+  use callkeys_mod, only: check_cpp_match, pceil, tstrat, tracer, global1d
   use inifis_mod, only: inifis
   use comcstfi_mod
@@ -84,5 +84,5 @@
 
   integer ierr
-  logical firstcall,lastcall,global1d
+  logical firstcall,lastcall
 
   character*20,allocatable :: nametrac(:)   ! name of the tracer (no need for adv trac common)
@@ -217,11 +217,4 @@
 
 
-  global1d = .false. ! default value
-  call getin("global1d",global1d)
-  write(*,*) " global1d = ",global1d
-  if(.not.global1d)then
-     print*,'Error, kcm1d must have global1d=.true. in kcm1d.def!'
-     stop
-  end if
 
   psurf_n=100000. ! default value for psurf
@@ -328,4 +321,9 @@
   cpp=1.d-7 !JL because we divide by cpp in inifis, there may be a more elegant solution
   CALL inifis(1,llm,nq,0,86400.0,1,1.0,latitude,longitude,cell_area,rad,g,r,cpp)
+
+  if(.not.global1d)then
+     print*,'Error, kcm1d must have global1d=.true. in kcm1d.def!'
+     stop
+  end if
 
   !write(*,*) 'BASE 1'
Index: /trunk/LMDZ.GENERIC/libf/phystd/inifis_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/inifis_mod.F90	(revision 2469)
+++ /trunk/LMDZ.GENERIC/libf/phystd/inifis_mod.F90	(revision 2470)
@@ -432,4 +432,25 @@
      write(*,*)" haze = ",haze
 
+! Global1D mean and solar zenith angle
+
+     if (ngrid.eq.1) then
+      PRINT*, 'Simulate global averaged conditions ?'
+      global1d = .false. ! default value
+      call getin_p("global1d",global1d)
+      write(*,*) "global1d = ",global1d
+      
+      ! Test of incompatibility : if global1d is true, there should not be any diurnal cycle.
+      if (global1d.and.diurnal) then
+         call abort_physic("inifis",'if global1d is true, diurnal must be set to false',1)
+      endif
+
+      if (global1d) then
+         PRINT *,'Solar Zenith angle (deg.) ?'
+         PRINT *,'(assumed for averaged solar flux S/4)'
+         szangle=60.0  ! default value
+         call getin_p("szangle",szangle)
+         write(*,*) "szangle = ",szangle
+      endif
+   endif
 
 ! Test of incompatibility:
Index: /trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90	(revision 2469)
+++ /trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90	(revision 2470)
@@ -58,5 +58,5 @@
                               startphy_file, testradtimes, tlocked, &
                               tracer, UseTurbDiff, water, watercond, &
-                              waterrain
+                              waterrain, global1d, szangle
       use nonoro_gwd_ran_mod, only: nonoro_gwd_ran
       use conc_mod
@@ -863,4 +863,9 @@
                call mucorr(ngrid,declin,latitude,mu0,fract,10000.,rad,flatten)
                ! WARNING: this function appears not to work in 1D
+
+               if ((ngrid.eq.1).and.(global1d)) then ! Fixed zenith angle 'szangle' in 1D simulations w/ globally-averaged sunlight.
+                  mu0 = cos(pi*szangle/180.0)
+                  !print*,'acosz=',mu0,', szangle=',szangle
+               endif
 
             endif 
Index: /trunk/LMDZ.GENERIC/libf/phystd/profile.F
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/profile.F	(revision 2469)
+++ /trunk/LMDZ.GENERIC/libf/phystd/profile.F	(revision 2470)
@@ -185,5 +185,5 @@
 101   STOP'fichier profile inexistant'
 201   CONTINUE
-      CLOSE(10)
+      CLOSE(11)
 
 c-----------------------------------------------------------------------
Index: /trunk/LMDZ.GENERIC/libf/phystd/thermcell_plume.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/thermcell_plume.F90	(revision 2469)
+++ /trunk/LMDZ.GENERIC/libf/phystd/thermcell_plume.F90	(revision 2470)
@@ -249,5 +249,5 @@
                &          + entr_star(ig,l) * zhl(ig,l))                      &
                &          / (f_star(ig,l+1) + detr_star(ig,l))
-               zqta(ig,l) = (f_star(ig,l) * zqta(ig,l-1) +                    &  ! zqta is set to qt in plume (mixed)
+               zqta(ig,l) = (f_star(ig,l) * zqta(ig,l-1)                      &  ! zqta is set to qt in plume (mixed)
                &          + entr_star(ig,l) * zqt(ig,l))                      &
                &          / (f_star(ig,l+1) + detr_star(ig,l))
