Index: LMDZ4/branches/LMDZ4-dev/libf/phylmd/physiq.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/phylmd/physiq.F	(revision 1259)
+++ LMDZ4/branches/LMDZ4-dev/libf/phylmd/physiq.F	(revision 1263)
@@ -13,6 +13,5 @@
 
       USE ioipsl, only: histbeg, histvert, histdef, histend, histsync,
-     $     histwrite, ju2ymds, ymds2ju
-!JG     $     histwrite, ju2ymds, ymds2ju, ioget_year_len
+     $     histwrite, ju2ymds, ymds2ju, ioget_year_len
       USE comgeomphy
       USE phys_cal_mod
@@ -33,9 +32,11 @@
       USE phys_output_mod
       use open_climoz_m, only: open_climoz ! ozone climatology from a file
-      use regr_pr, only: regr_pr_av
+      use regr_pr_av_m, only: regr_pr_av
       use netcdf95, only: nf95_close
       use mod_phys_lmdz_mpi_data, only: is_mpi_root
       USE aero_mod
       use ozonecm_m, only: ozonecm ! ozone of J.-F. Royer
+      use conf_phys_m, only: conf_phys
+      use radlwsw_m, only: radlwsw
 
       IMPLICIT none
@@ -1093,16 +1094,24 @@
       integer iunit
 
-      logical, save::  read_climoz ! read ozone climatology from a file
-      integer, save:: ncid_climoz ! NetCDF file containing ozone climatology
+      integer, save::  read_climoz ! read ozone climatology
+C     Allowed values are 0, 1 and 2
+C     0: do not read an ozone climatology
+C     1: read a single ozone climatology that will be used day and night
+C     2: read two ozone climatologies, the average day and night
+C     climatology and the daylight climatology
+
+      integer, save:: ncid_climoz ! NetCDF file containing ozone climatologies
 
       real, pointer, save:: press_climoz(:)
-!     edges of pressure intervals for ozone climatology, in Pa, in strictly
+!     edges of pressure intervals for ozone climatologies, in Pa, in strictly
 !     ascending order
 
-      integer,save:: co3i = 0 ! time index in NetCDF file of current ozone field
+      integer, save:: co3i = 0
+!     time index in NetCDF file of current ozone fields
 c$OMP THREADPRIVATE(co3i) 
 
       integer ro3i
-!     required time index in NetCDF file for the ozone field, between 1 and 360
+!     required time index in NetCDF file for the ozone fields, between 1
+!     and 360
 
 #include "YOMCST.h"
@@ -1165,5 +1174,19 @@
       print*, 'Allocation des variables locales et sauvegardees'
       call phys_local_var_init
-      call phys_state_var_init
+c     appel a la lecture du run.def physique
+      call conf_phys(ok_journe, ok_mensuel,
+     .     ok_instan, ok_hf,
+     .     ok_LES,
+     .     solarlong0,seuil_inversion,
+     .     fact_cldcon, facttemps,ok_newmicro,iflag_radia,
+     .     iflag_cldcon,iflag_ratqs,ratqsbas,ratqshaut,tau_ratqs,
+     .     ok_ade, ok_aie, aerosol_couple, 
+     .     flag_aerosol, new_aod,
+     .     bl95_b0, bl95_b1,
+     .     iflag_thermals,nsplit_thermals,tau_thermals,
+     .     iflag_thermals_ed,iflag_thermals_optflux,
+c     nv flags pour la convection et les poches froides
+     .     iflag_coupl,iflag_clos,iflag_wake, read_climoz)
+      call phys_state_var_init(read_climoz)
       print*, '================================================='
 
@@ -1181,5 +1204,5 @@
 	first=.false.
 
-      endif  ! fisrt
+      endif  ! first
 
        modname = 'physiq'
@@ -1209,5 +1232,4 @@
 c
        IF (debut) THEN
-C
 !rv
 cCRinitialisation de wght_th et lalim_conv pour la definition de la couche alimentation 
@@ -1220,6 +1242,4 @@
          rain_con(:)=0.
          snow_con(:)=0.
-         bl95_b0=0.
-         bl95_b1=0.
          topswai(:)=0.
          topswad(:)=0.
@@ -1247,20 +1267,4 @@
          IF (ip_ebil_phy.ge.1) d_h_vcol_phy=0.
 c
-c appel a la lecture du run.def physique
-c
-         call conf_phys(ok_journe, ok_mensuel,
-     .                  ok_instan, ok_hf,
-     .                  ok_LES,
-     .                  solarlong0,seuil_inversion,
-     .                  fact_cldcon, facttemps,ok_newmicro,iflag_radia,
-     .         iflag_cldcon,iflag_ratqs,ratqsbas,ratqshaut,tau_ratqs,
-     .                  ok_ade, ok_aie, aerosol_couple, 
-     .                  flag_aerosol, new_aod,
-     .                  bl95_b0, bl95_b1,
-     .                  iflag_thermals,nsplit_thermals,tau_thermals,
-     .                  iflag_thermals_ed,iflag_thermals_optflux,
-cnv flags pour la convection et les poches froides
-     .                   iflag_coupl,iflag_clos,iflag_wake, read_climoz)
-
       print*,'iflag_coupl,iflag_clos,iflag_wake',
      .   iflag_coupl,iflag_clos,iflag_wake
@@ -1453,5 +1457,5 @@
      &                        ctetaSTD,dtime,ok_veget,
      &                        type_ocean,iflag_pbl,ok_mensuel,ok_journe,
-     &                        ok_hf,ok_instan,ok_LES,ok_ade,ok_aie)
+     &              ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, read_climoz)
 c$OMP END MASTER
 c$OMP BARRIER
@@ -1544,5 +1548,5 @@
 
 C$omp single
-      if (read_climoz) then
+      if (read_climoz >= 1) then
          call open_climoz(ncid_climoz, press_climoz)
       END IF
@@ -1711,13 +1715,9 @@
 c Prescrire l'ozone et calculer l'albedo sur l'ocean.
 c
-      if (read_climoz) then
+      if (read_climoz >= 1) then
 C        Ozone from a file
 !        Update required ozone index:
-!JG : ioget_year_len n'existe pas dans les versions officiels d'ioipsl
-!JG         ro3i = int((days_elapsed + jh_cur - jh_1jan)
-!JG     $        / ioget_year_len(year_cur) * 360.) + 1
-         CALL abort_gcm(modname,
-     $     'JG : read_climoz temporary desactivated',1)
-
+         ro3i = int((days_elapsed + jh_cur - jh_1jan)
+     $        / ioget_year_len(year_cur) * 360.) + 1
          if (ro3i == 361) ro3i = 360
 C        (This should never occur, except perhaps because of roundup
@@ -1725,9 +1725,18 @@
          if (ro3i /= co3i) then
 C           Update ozone field:
-            call regr_pr_av(ncid_climoz, "tro3", julien=ro3i, 
-     &           press_in_edg=press_climoz, paprs=paprs, v3=wo)
+            if (read_climoz == 1) then
+               call regr_pr_av(ncid_climoz, (/"tro3"/), julien=ro3i,
+     $              press_in_edg=press_climoz, paprs=paprs, v3=wo)
+            else
+C              read_climoz == 2
+               call regr_pr_av(ncid_climoz,
+     $              (/"tro3         ", "tro3_daylight"/),
+     $              julien=ro3i, press_in_edg=press_climoz, paprs=paprs,
+     $              v3=wo)
+            end if
 !           Convert from mole fraction of ozone to column density of ozone in a
 !           cell, in kDU:
-            wo = wo * rmo3 / rmd * zmasse / dobson_u / 1e3
+            forall (l = 1: read_climoz) wo(:, :, l) = wo(:, :, l)
+     $           * rmo3 / rmd * zmasse / dobson_u / 1e3
 C           (By regridding ozone values for LMDZ only once every 360th of
 C           year, we have already neglected the variation of pressure in one
@@ -1738,5 +1747,5 @@
       elseif (MOD(itap-1,lmt_pas) == 0) THEN
 C        Once per day, update ozone from Royer:
-         wo = ozonecm(rlat, paprs, rjour=real(days_elapsed+1))
+         wo(:, :, 1) = ozonecm(rlat, paprs, rjour=real(days_elapsed+1))
       ENDIF
 c
@@ -2836,5 +2845,5 @@
      $                          u,
      $                          v,
-     $                          wo,
+     $                          wo(:, :, 1),
      $                          q_seri,
      $                          zxtsol,
@@ -2919,5 +2928,5 @@
      e        (kdlon,kflev,dist, rmu0, fract, solaire,
      e        paprs, pplay,zxtsol,albsol1, albsol2, t_seri,q_seri,
-     e        wo,
+     e        wo(:, :, 1),
      e        cldfra, cldemi, cldtau,
      s        heat,heat0,cool,cool0,radsol,albpla,
@@ -3529,5 +3538,5 @@
 !         close(97)
 C$OMP MASTER
-         if (read_climoz) then
+         if (read_climoz >= 1) then
             if (is_mpi_root) then
                call nf95_close(ncid_climoz)
