Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1DUTILS.h
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1DUTILS.h	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1DUTILS.h	(revision 4368)
@@ -713,5 +713,5 @@
 !!      enddo
       DO iq = 1,nqtot
-        nmq(iq) = trim(tname(iq))
+        nmq(iq) = trim(tracers(iq)%name)
       ENDDO
       print*,'in dyn1deta0 ',fichnom,klon,klev,nqtot
@@ -864,5 +864,5 @@
 !!      nmq(4)="tra2"
       DO iq = 1,nqtot
-        nmq(iq) = trim(tname(iq))
+        nmq(iq) = trim(tracers(iq)%name)
       ENDDO
 
@@ -1708,9 +1708,9 @@
 
 !
-        print *,'dtime, tau ',dtime,tau
-        print *, 'u_targ',u_targ
-        print *, 'v_targ',v_targ
-        print *,'zonal velocity ',u
-        print *,'meridional velocity ',v
+        !print *,'dtime, tau ',dtime,tau
+        !print *, 'u_targ',u_targ
+        !print *, 'v_targ',v_targ
+        !print *,'zonal velocity ',u
+        !print *,'meridional velocity ',v
         DO k = 1,klev
          DO i = 1,klon
@@ -1721,6 +1721,6 @@
             d_v(i,k) = d_v(i,k) + 1./tau*(v_targ(i,k)-v(i,k))
 !
-            print *,' k,u,d_u,v,d_v ',    &
-                      k,u(i,k),d_u(i,k),v(i,k),d_v(i,k)
+!           print *,' k,u,d_u,v,d_v ',    &
+!                     k,u(i,k),d_u(i,k),v(i,k),d_v(i,k)
 !           ENDIF
 !
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_decl_cases.h
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_decl_cases.h	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_decl_cases.h	(revision 4368)
@@ -34,5 +34,5 @@
         real w_mod(llm), t_mod(llm),q_mod(llm)
         real u_mod(llm),v_mod(llm), ht_mod(llm),vt_mod(llm),ug_mod(llm),vg_mod(llm)
-	    real temp_nudg_mod(llm),qv_nudg_mod(llm),u_nudg_mod(llm),v_nudg_mod(llm)
+	    real temp_nudg_mod(llm),qv_nudg_mod(llm),u_nudg_mod(llm),v_nudg_mod(llm)       
         real hq_mod(llm),vq_mod(llm),qv_mod(llm),ql_mod(llm),qt_mod(llm)
         real th_mod(llm)
@@ -286,4 +286,5 @@
         real ug_mod_cas(llm),vg_mod_cas(llm)
         real temp_nudg_mod_cas(llm),qv_nudg_mod_cas(llm),v_nudg_mod_cas(llm),u_nudg_mod_cas(llm)
+        real invtau_temp_nudg_mod_cas(llm),invtau_qv_nudg_mod_cas(llm),invtau_v_nudg_mod_cas(llm),invtau_u_nudg_mod_cas(llm)
         real u_mod_cas(llm),v_mod_cas(llm)
         real omega_mod_cas(llm),tke_mod_cas(llm+1)
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_interp_cases.h
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_interp_cases.h	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_interp_cases.h	(revision 4368)
@@ -10,7 +10,8 @@
 !    &       ,year_ini_cas,day_ju_ini_cas,nt_cas,pdt_cas,nlev_cas                           &
      &       ,nt_cas,nlev_cas                                                               &
-     &       ,ts_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
+     &       ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
      &       ,u_cas,v_cas,ug_cas,vg_cas                                                     &
      &       ,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas                               &
+     &       ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas    &
      &       ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas                                       &
      &       ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas                           &
@@ -18,8 +19,9 @@
      &       ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                                           &
 !
-     &       ,ts_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
+     &       ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
      &       ,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas                              &
      &       ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                                 &
      &       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas           &
+     &       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas  &     
      &       ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                     &
      &       ,du_prof_cas,hu_prof_cas,vu_prof_cas                                           &
@@ -29,5 +31,9 @@
      &       ,sens_prof_cas,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
 ! EV tg instead of ts_cur
-             tg = ts_prof_cas 
+             tg = ts_prof_cas
+             if ((tg .eq. 0.) .and. (tskin_prof_cas .ne. 0.)) then
+                tg=tskin_prof_cas
+              endif
+
 !            psurf=plev_prof_cas(1)
              psurf=ps_prof_cas
@@ -39,4 +45,6 @@
      &         ,ug_prof_cas,vg_prof_cas                                                                   &
      &         ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                       &
+     &         ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &
+
      &         ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                                 &
      &         ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                   &
@@ -47,4 +55,5 @@
      &         ,u_mod_cas,v_mod_cas,ug_mod_cas,vg_mod_cas                                                 &
      &         ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                           &
+     &         ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas   &     
      &         ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                       &
      &         ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                         &
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_nudge_sandu_astex.h
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_nudge_sandu_astex.h	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_nudge_sandu_astex.h	(revision 4368)
@@ -33,10 +33,10 @@
 
 
-	print*,'OLDLMDZ1D IOPH'
-      CALL iophys_ecrit('relax_thl',klev,'relax_thl','m/s',relax_thl)
-      CALL iophys_ecrit('d_t_adv',klev,'d_t_adv','m/s',d_t_adv)
-      CALL iophys_ecrit('temp',klev,'temp','m/s',temp)
-      CALL iophys_ecrit('q',klev,'q','m/s',q(:,1))
-      CALL iophys_ecrit('relax_q',klev,'relax_q','m/s',relax_q(:,1))
-      CALL iophys_ecrit('d_q_adv',klev,'d_q_adv','m/s',d_q_adv(:,1))
+      !	print*,'OLDLMDZ1D IOPH'
+      !      CALL iophys_ecrit('relax_thl',klev,'relax_thl','m/s',relax_thl)
+      !      CALL iophys_ecrit('d_t_adv',klev,'d_t_adv','m/s',d_t_adv)
+      !      CALL iophys_ecrit('temp',klev,'temp','m/s',temp)
+      !      CALL iophys_ecrit('q',klev,'q','m/s',q(:,1))
+      !      CALL iophys_ecrit('relax_q',klev,'relax_q','m/s',relax_q(:,1))
+      !      CALL iophys_ecrit('d_q_adv',klev,'d_q_adv','m/s',d_q_adv(:,1))
 
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_read_forc_cases.h
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_read_forc_cases.h	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/1D_read_forc_cases.h	(revision 4368)
@@ -24,16 +24,18 @@
 !    &       ,year_ini_cas,day_ju_ini_cas,nt_cas,pdt_cas,nlev_cas                           &
      &       ,nt_cas,nlev_cas                                                               &
-     &       ,ts_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
+     &       ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
      &       ,u_cas,v_cas,ug_cas,vg_cas                                                     &
      &       ,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas                               &
-     &       ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas                                       &
+     &       ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas    &
+     &       ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas                               &
      &       ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas                           &
      &       ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,lat_cas,sens_cas,ustar_cas       &
      &       ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                                           &
 !
-     &       ,ts_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
+     &       ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
      &       ,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas                              &
      &       ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                                 &
      &       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas           &
+     &       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &
      &       ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                    &
      &       ,du_prof_cas,hu_prof_cas,vu_prof_cas                                           &
@@ -54,5 +56,5 @@
      &         ,ug_prof_cas,vg_prof_cas                                                                   &
      &       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                         &
-
+     &       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas       &
      &         ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                                 &
      &         ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                   &
@@ -63,4 +65,5 @@
      &         ,u_mod_cas,v_mod_cas,ug_mod_cas,vg_mod_cas                                                 &
      &         ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                           &
+     &         ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas        &
      &         ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                       &
      &         ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                         &
@@ -70,9 +73,15 @@
 
 ! initial and boundary conditions :
-!     tsurf = ts_prof_cas
       psurf = ps_prof_cas
-      !EV tg instead of ts_cur
-      tg = ts_prof_cas 
-      print*, 'tg=', tg
+      if (tskin_prof_cas .NE. 0.) THEN
+          tsurf=tskin_prof_cas
+      endif
+
+      tg = ts_prof_cas
+      if ((tg .eq. 0.) .and. (tskin_prof_cas .NE. 0.)) THEN
+          tg=tskin_prof_cas
+      endif
+
+
 
       do l = 1, llm
@@ -80,4 +89,5 @@
        q(l,1) = qv_mod_cas(l)
        q(l,2) = ql_mod_cas(l)
+       q(l,3) = qi_mod_cas(l)
        u(l) = u_mod_cas(l)
        ug(l)= ug_mod_cas(l)
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/mod_1D_cases_read2.F90
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/mod_1D_cases_read2.F90	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/mod_1D_cases_read2.F90	(revision 4368)
@@ -5,725 +5,712 @@
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!Declarations specifiques au cas standard
-        character*80 :: fich_cas
-! Discr?tisation 
-        integer nlev_cas, nt_cas
-
-
-!profils environnementaux
-        real, allocatable::  plev_cas(:,:),plevh_cas(:)
-        real, allocatable::  ap_cas(:),bp_cas(:)
-
-        real, allocatable::  z_cas(:,:),zh_cas(:)
-        real, allocatable::  t_cas(:,:),q_cas(:,:),qv_cas(:,:),ql_cas(:,:),qi_cas(:,:),rh_cas(:,:)
-        real, allocatable::  th_cas(:,:),thv_cas(:,:),thl_cas(:,:),rv_cas(:,:)
-        real, allocatable::  u_cas(:,:),v_cas(:,:),vitw_cas(:,:),omega_cas(:,:)
-
-!forcing
-        real, allocatable::  ht_cas(:,:),vt_cas(:,:),dt_cas(:,:),dtrad_cas(:,:)
-        real, allocatable::  hth_cas(:,:),vth_cas(:,:),dth_cas(:,:)
-        real, allocatable::  hq_cas(:,:),vq_cas(:,:),dq_cas(:,:)
-        real, allocatable::  hr_cas(:,:),vr_cas(:,:),dr_cas(:,:)
-        real, allocatable::  hu_cas(:,:),vu_cas(:,:),du_cas(:,:)
-        real, allocatable::  hv_cas(:,:),vv_cas(:,:),dv_cas(:,:)
-        real, allocatable::  ug_cas(:,:),vg_cas(:,:)
-        real, allocatable::  lat_cas(:),sens_cas(:),ts_cas(:),ps_cas(:),ustar_cas(:)
-        real, allocatable::  uw_cas(:,:),vw_cas(:,:),q1_cas(:,:),q2_cas(:,:),tke_cas(:)
-
-!champs interpoles
-        real, allocatable::  plev_prof_cas(:)
-        real, allocatable::  t_prof_cas(:)
-        real, allocatable::  theta_prof_cas(:)
-        real, allocatable::  thl_prof_cas(:)
-        real, allocatable::  thv_prof_cas(:)
-        real, allocatable::  q_prof_cas(:)
-        real, allocatable::  qv_prof_cas(:)
-        real, allocatable::  ql_prof_cas(:)
-        real, allocatable::  qi_prof_cas(:)
-        real, allocatable::  rh_prof_cas(:)
-        real, allocatable::  rv_prof_cas(:)
-        real, allocatable::  u_prof_cas(:)
-        real, allocatable::  v_prof_cas(:)        
-        real, allocatable::  vitw_prof_cas(:)
-        real, allocatable::  omega_prof_cas(:)
-        real, allocatable::  ug_prof_cas(:)
-        real, allocatable::  vg_prof_cas(:)
-        real, allocatable::  ht_prof_cas(:)
-        real, allocatable::  hth_prof_cas(:)
-        real, allocatable::  hq_prof_cas(:)
-        real, allocatable::  vt_prof_cas(:)
-        real, allocatable::  vth_prof_cas(:)
-        real, allocatable::  vq_prof_cas(:)
-        real, allocatable::  dt_prof_cas(:)
-        real, allocatable::  dth_prof_cas(:)
-        real, allocatable::  dtrad_prof_cas(:)
-        real, allocatable::  dq_prof_cas(:)
-        real, allocatable::  hu_prof_cas(:)
-        real, allocatable::  hv_prof_cas(:)
-        real, allocatable::  vu_prof_cas(:)
-        real, allocatable::  vv_prof_cas(:)
-        real, allocatable::  du_prof_cas(:)
-        real, allocatable::  dv_prof_cas(:)
-        real, allocatable::  uw_prof_cas(:)
-        real, allocatable::  vw_prof_cas(:)
-        real, allocatable::  q1_prof_cas(:)
-        real, allocatable::  q2_prof_cas(:)
-
-
-        real lat_prof_cas,sens_prof_cas,ts_prof_cas,ps_prof_cas,ustar_prof_cas,tke_prof_cas
-        real o3_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,rugos_cas,sand_cas,clay_cas
-      
+  !Declarations specifiques au cas standard
+  character*80 :: fich_cas
+  ! Discr?tisation 
+  integer nlev_cas, nt_cas
+
+
+  !profils environnementaux
+  real, allocatable::  plev_cas(:,:),plevh_cas(:)
+  real, allocatable::  ap_cas(:),bp_cas(:)
+
+  real, allocatable::  z_cas(:,:),zh_cas(:)
+  real, allocatable::  t_cas(:,:),q_cas(:,:),qv_cas(:,:),ql_cas(:,:),qi_cas(:,:),rh_cas(:,:)
+  real, allocatable::  th_cas(:,:),thv_cas(:,:),thl_cas(:,:),rv_cas(:,:)
+  real, allocatable::  u_cas(:,:),v_cas(:,:),vitw_cas(:,:),omega_cas(:,:)
+
+  !forcing
+  real, allocatable::  ht_cas(:,:),vt_cas(:,:),dt_cas(:,:),dtrad_cas(:,:)
+  real, allocatable::  hth_cas(:,:),vth_cas(:,:),dth_cas(:,:)
+  real, allocatable::  hq_cas(:,:),vq_cas(:,:),dq_cas(:,:)
+  real, allocatable::  hr_cas(:,:),vr_cas(:,:),dr_cas(:,:)
+  real, allocatable::  hu_cas(:,:),vu_cas(:,:),du_cas(:,:)
+  real, allocatable::  hv_cas(:,:),vv_cas(:,:),dv_cas(:,:)
+  real, allocatable::  ug_cas(:,:),vg_cas(:,:)
+  real, allocatable::  lat_cas(:),sens_cas(:),ts_cas(:),ps_cas(:),ustar_cas(:)
+  real, allocatable::  uw_cas(:,:),vw_cas(:,:),q1_cas(:,:),q2_cas(:,:),tke_cas(:)
+
+  !champs interpoles
+  real, allocatable::  plev_prof_cas(:)
+  real, allocatable::  t_prof_cas(:)
+  real, allocatable::  theta_prof_cas(:)
+  real, allocatable::  thl_prof_cas(:)
+  real, allocatable::  thv_prof_cas(:)
+  real, allocatable::  q_prof_cas(:)
+  real, allocatable::  qv_prof_cas(:)
+  real, allocatable::  ql_prof_cas(:)
+  real, allocatable::  qi_prof_cas(:)
+  real, allocatable::  rh_prof_cas(:)
+  real, allocatable::  rv_prof_cas(:)
+  real, allocatable::  u_prof_cas(:)
+  real, allocatable::  v_prof_cas(:)        
+  real, allocatable::  vitw_prof_cas(:)
+  real, allocatable::  omega_prof_cas(:)
+  real, allocatable::  ug_prof_cas(:)
+  real, allocatable::  vg_prof_cas(:)
+  real, allocatable::  ht_prof_cas(:)
+  real, allocatable::  hth_prof_cas(:)
+  real, allocatable::  hq_prof_cas(:)
+  real, allocatable::  vt_prof_cas(:)
+  real, allocatable::  vth_prof_cas(:)
+  real, allocatable::  vq_prof_cas(:)
+  real, allocatable::  dt_prof_cas(:)
+  real, allocatable::  dth_prof_cas(:)
+  real, allocatable::  dtrad_prof_cas(:)
+  real, allocatable::  dq_prof_cas(:)
+  real, allocatable::  hu_prof_cas(:)
+  real, allocatable::  hv_prof_cas(:)
+  real, allocatable::  vu_prof_cas(:)
+  real, allocatable::  vv_prof_cas(:)
+  real, allocatable::  du_prof_cas(:)
+  real, allocatable::  dv_prof_cas(:)
+  real, allocatable::  uw_prof_cas(:)
+  real, allocatable::  vw_prof_cas(:)
+  real, allocatable::  q1_prof_cas(:)
+  real, allocatable::  q2_prof_cas(:)
+
+
+  real lat_prof_cas,sens_prof_cas,ts_prof_cas,ps_prof_cas,ustar_prof_cas,tke_prof_cas
+  real o3_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,rugos_cas,sand_cas,clay_cas
+
 
 
 CONTAINS
 
-SUBROUTINE read_1D_cas
-      implicit none
+  SUBROUTINE read_1D_cas
+    implicit none
 
 #include "netcdf.inc"
 
-      INTEGER nid,rid,ierr
-      INTEGER ii,jj
-
-      fich_cas='setup/cas.nc'
-      print*,'fich_cas ',fich_cas
-      ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
-      print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: GROS Pb opening forcings nc file '
-         write(*,*) NF_STRERROR(ierr)
-         stop ""
-      endif
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lat',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lat'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,ii)
-      print*,'OK1 nid,rid,lat',nid,rid,ii
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lon',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lon'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,jj)
-      print*,'OK2 nid,rid,lat',nid,rid,jj
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lev',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension zz'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
-      print*,'OK3 nid,rid,nlev_cas',nid,rid,nlev_cas
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'time',rid)
-      print*,'nid,rid',nid,rid
-      nt_cas=0
-      IF (ierr.NE.NF_NOERR) THEN
-        stop 'probleme lecture dimension sens'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
-      print*,'OK4 nid,rid,nt_cas',nid,rid,nt_cas
+    INTEGER nid,rid,ierr
+    INTEGER ii,jj
+
+    fich_cas='setup/cas.nc'
+    print*,'fich_cas ',fich_cas
+    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
+    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
+    if (ierr.NE.NF_NOERR) then
+       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
+       write(*,*) NF_STRERROR(ierr)
+       stop ""
+    endif
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lat',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lat'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,ii)
+    print*,'OK1 nid,rid,lat',nid,rid,ii
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lon',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lon'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,jj)
+    print*,'OK2 nid,rid,lat',nid,rid,jj
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lev',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension zz'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
+    print*,'OK3 nid,rid,nlev_cas',nid,rid,nlev_cas
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'time',rid)
+    print*,'nid,rid',nid,rid
+    nt_cas=0
+    IF (ierr.NE.NF_NOERR) THEN
+       stop 'probleme lecture dimension sens'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
+    print*,'OK4 nid,rid,nt_cas',nid,rid,nt_cas
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!profils moyens:
-        allocate(plev_cas(nlev_cas,nt_cas))        
-        allocate(z_cas(nlev_cas,nt_cas))
-        allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
-        allocate(th_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
-        allocate(u_cas(nlev_cas,nt_cas))
-        allocate(v_cas(nlev_cas,nt_cas))
-
-!forcing
-        allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
-        allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
-        allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
-        allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
-        allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
-        allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
-        allocate(vitw_cas(nlev_cas,nt_cas))
-        allocate(ug_cas(nlev_cas,nt_cas))
-        allocate(vg_cas(nlev_cas,nt_cas))
-        allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas))
-        allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
-
-
-!champs interpoles
-        allocate(plev_prof_cas(nlev_cas))
-        allocate(t_prof_cas(nlev_cas))
-        allocate(q_prof_cas(nlev_cas))
-        allocate(u_prof_cas(nlev_cas))
-        allocate(v_prof_cas(nlev_cas))
-
-        allocate(vitw_prof_cas(nlev_cas))
-        allocate(ug_prof_cas(nlev_cas))
-        allocate(vg_prof_cas(nlev_cas))
-        allocate(ht_prof_cas(nlev_cas))
-        allocate(hq_prof_cas(nlev_cas))
-        allocate(hu_prof_cas(nlev_cas))
-        allocate(hv_prof_cas(nlev_cas))
-        allocate(vt_prof_cas(nlev_cas))
-        allocate(vq_prof_cas(nlev_cas))
-        allocate(vu_prof_cas(nlev_cas))
-        allocate(vv_prof_cas(nlev_cas))
-        allocate(dt_prof_cas(nlev_cas))
-        allocate(dtrad_prof_cas(nlev_cas))
-        allocate(dq_prof_cas(nlev_cas))
-        allocate(du_prof_cas(nlev_cas))
-        allocate(dv_prof_cas(nlev_cas))
-        allocate(uw_prof_cas(nlev_cas))
-        allocate(vw_prof_cas(nlev_cas))
-        allocate(q1_prof_cas(nlev_cas))
-        allocate(q2_prof_cas(nlev_cas))
-
-        print*,'Allocations OK'
-        call read_cas2(nid,nlev_cas,nt_cas                                       &
-     &     ,z_cas,plev_cas,t_cas,q_cas,rh_cas,th_cas,rv_cas,u_cas,v_cas         &
-     &     ,ug_cas,vg_cas,vitw_cas,du_cas,hu_cas,vu_cas,dv_cas,hv_cas,vv_cas    &
-     &     ,dt_cas,dtrad_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas                 &
-     &     ,dth_cas,hth_cas,vth_cas,dr_cas,hr_cas,vr_cas,sens_cas,lat_cas,ts_cas&
-     &     ,ustar_cas,uw_cas,vw_cas,q1_cas,q2_cas)
-        print*,'Read cas OK'
-
-
-END SUBROUTINE read_1D_cas
-!**********************************************************************************************
-SUBROUTINE read2_1D_cas
-      implicit none
+    !profils moyens:
+    allocate(plev_cas(nlev_cas,nt_cas))        
+    allocate(z_cas(nlev_cas,nt_cas))
+    allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
+    allocate(th_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
+    allocate(u_cas(nlev_cas,nt_cas))
+    allocate(v_cas(nlev_cas,nt_cas))
+
+    !forcing
+    allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
+    allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
+    allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
+    allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
+    allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
+    allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
+    allocate(vitw_cas(nlev_cas,nt_cas))
+    allocate(ug_cas(nlev_cas,nt_cas))
+    allocate(vg_cas(nlev_cas,nt_cas))
+    allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas))
+    allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
+
+
+    !champs interpoles
+    allocate(plev_prof_cas(nlev_cas))
+    allocate(t_prof_cas(nlev_cas))
+    allocate(q_prof_cas(nlev_cas))
+    allocate(u_prof_cas(nlev_cas))
+    allocate(v_prof_cas(nlev_cas))
+
+    allocate(vitw_prof_cas(nlev_cas))
+    allocate(ug_prof_cas(nlev_cas))
+    allocate(vg_prof_cas(nlev_cas))
+    allocate(ht_prof_cas(nlev_cas))
+    allocate(hq_prof_cas(nlev_cas))
+    allocate(hu_prof_cas(nlev_cas))
+    allocate(hv_prof_cas(nlev_cas))
+    allocate(vt_prof_cas(nlev_cas))
+    allocate(vq_prof_cas(nlev_cas))
+    allocate(vu_prof_cas(nlev_cas))
+    allocate(vv_prof_cas(nlev_cas))
+    allocate(dt_prof_cas(nlev_cas))
+    allocate(dtrad_prof_cas(nlev_cas))
+    allocate(dq_prof_cas(nlev_cas))
+    allocate(du_prof_cas(nlev_cas))
+    allocate(dv_prof_cas(nlev_cas))
+    allocate(uw_prof_cas(nlev_cas))
+    allocate(vw_prof_cas(nlev_cas))
+    allocate(q1_prof_cas(nlev_cas))
+    allocate(q2_prof_cas(nlev_cas))
+
+    print*,'Allocations OK'
+    call read_cas2(nid,nlev_cas,nt_cas                                       &
+         ,z_cas,plev_cas,t_cas,q_cas,rh_cas,th_cas,rv_cas,u_cas,v_cas         &
+         ,ug_cas,vg_cas,vitw_cas,du_cas,hu_cas,vu_cas,dv_cas,hv_cas,vv_cas    &
+         ,dt_cas,dtrad_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas                 &
+         ,dth_cas,hth_cas,vth_cas,dr_cas,hr_cas,vr_cas,sens_cas,lat_cas,ts_cas&
+         ,ustar_cas,uw_cas,vw_cas,q1_cas,q2_cas)
+    print*,'Read cas OK'
+
+
+  END SUBROUTINE read_1D_cas
+  !**********************************************************************************************
+  SUBROUTINE read2_1D_cas
+    implicit none
 
 #include "netcdf.inc"
 
-      INTEGER nid,rid,ierr
-      INTEGER ii,jj
-
-      fich_cas='setup/cas.nc'
-      print*,'fich_cas ',fich_cas
-      ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
-      print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: GROS Pb opening forcings nc file '
-         write(*,*) NF_STRERROR(ierr)
-         stop ""
-      endif
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lat',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lat'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,ii)
-      print*,'OK1 read2: nid,rid,lat',nid,rid,ii
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lon',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lon'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,jj)
-      print*,'OK2 read2: nid,rid,lat',nid,rid,jj
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'nlev',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension nlev'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
-      print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'time',rid)
-      nt_cas=0
-      IF (ierr.NE.NF_NOERR) THEN
-        stop 'Oh probleme lecture dimension time'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
-      print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
+    INTEGER nid,rid,ierr
+    INTEGER ii,jj
+
+    fich_cas='setup/cas.nc'
+    print*,'fich_cas ',fich_cas
+    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
+    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
+    if (ierr.NE.NF_NOERR) then
+       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
+       write(*,*) NF_STRERROR(ierr)
+       stop ""
+    endif
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lat',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lat'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,ii)
+    print*,'OK1 read2: nid,rid,lat',nid,rid,ii
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lon',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lon'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,jj)
+    print*,'OK2 read2: nid,rid,lat',nid,rid,jj
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'nlev',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension nlev'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
+    print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'time',rid)
+    nt_cas=0
+    IF (ierr.NE.NF_NOERR) THEN
+       stop 'Oh probleme lecture dimension time'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
+    print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!profils moyens:
-        allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
-        allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
-        allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
-        allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
-             qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
-        allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
-        allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
-
-!forcing
-        allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
-        allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
-        allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
-        allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
-        allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
-        allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
-        allocate(ug_cas(nlev_cas,nt_cas))
-        allocate(vg_cas(nlev_cas,nt_cas))
-        allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tke_cas(nt_cas))
-        allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
-
-
-
-!champs interpoles
-        allocate(plev_prof_cas(nlev_cas))
-        allocate(t_prof_cas(nlev_cas))
-        allocate(theta_prof_cas(nlev_cas))
-        allocate(thl_prof_cas(nlev_cas))
-        allocate(thv_prof_cas(nlev_cas))
-        allocate(q_prof_cas(nlev_cas))
-        allocate(qv_prof_cas(nlev_cas))
-        allocate(ql_prof_cas(nlev_cas))
-        allocate(qi_prof_cas(nlev_cas))
-        allocate(rh_prof_cas(nlev_cas))
-        allocate(rv_prof_cas(nlev_cas))
-        allocate(u_prof_cas(nlev_cas))
-        allocate(v_prof_cas(nlev_cas))
-        allocate(vitw_prof_cas(nlev_cas))
-        allocate(omega_prof_cas(nlev_cas))
-        allocate(ug_prof_cas(nlev_cas))
-        allocate(vg_prof_cas(nlev_cas))
-        allocate(ht_prof_cas(nlev_cas))
-        allocate(hth_prof_cas(nlev_cas))
-        allocate(hq_prof_cas(nlev_cas))
-        allocate(hu_prof_cas(nlev_cas))
-        allocate(hv_prof_cas(nlev_cas))
-        allocate(vt_prof_cas(nlev_cas))
-        allocate(vth_prof_cas(nlev_cas))
-        allocate(vq_prof_cas(nlev_cas))
-        allocate(vu_prof_cas(nlev_cas))
-        allocate(vv_prof_cas(nlev_cas))
-        allocate(dt_prof_cas(nlev_cas))
-        allocate(dth_prof_cas(nlev_cas))
-        allocate(dtrad_prof_cas(nlev_cas))
-        allocate(dq_prof_cas(nlev_cas))
-        allocate(du_prof_cas(nlev_cas))
-        allocate(dv_prof_cas(nlev_cas))
-        allocate(uw_prof_cas(nlev_cas))
-        allocate(vw_prof_cas(nlev_cas))
-        allocate(q1_prof_cas(nlev_cas))
-        allocate(q2_prof_cas(nlev_cas))
-
-        print*,'Allocations OK'
-        call read2_cas (nid,nlev_cas,nt_cas,                                                                     &
-     &     ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                    &
-     &     ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,ug_cas,vg_cas,du_cas,hu_cas,vu_cas,        &
-     &     dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
-     &     dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tke_cas,                      &
-     &     uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
-     &     o3_cas,rugos_cas,clay_cas,sand_cas)
-        print*,'Read2 cas OK'
-        do ii=1,nlev_cas
-        print*,'apres read2_cas, plev_cas=',ii,plev_cas(ii,1)
-        enddo
-
-
-END SUBROUTINE read2_1D_cas
-
-!**********************************************************************************************
-SUBROUTINE old_read_SCM_cas
-      implicit none
+    !profils moyens:
+    allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
+    allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
+    allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
+    allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
+         qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
+    allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
+    allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
+
+    !forcing
+    allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
+    allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
+    allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
+    allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
+    allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
+    allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
+    allocate(ug_cas(nlev_cas,nt_cas))
+    allocate(vg_cas(nlev_cas,nt_cas))
+    allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tke_cas(nt_cas))
+    allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
+
+
+
+    !champs interpoles
+    allocate(plev_prof_cas(nlev_cas))
+    allocate(t_prof_cas(nlev_cas))
+    allocate(theta_prof_cas(nlev_cas))
+    allocate(thl_prof_cas(nlev_cas))
+    allocate(thv_prof_cas(nlev_cas))
+    allocate(q_prof_cas(nlev_cas))
+    allocate(qv_prof_cas(nlev_cas))
+    allocate(ql_prof_cas(nlev_cas))
+    allocate(qi_prof_cas(nlev_cas))
+    allocate(rh_prof_cas(nlev_cas))
+    allocate(rv_prof_cas(nlev_cas))
+    allocate(u_prof_cas(nlev_cas))
+    allocate(v_prof_cas(nlev_cas))
+    allocate(vitw_prof_cas(nlev_cas))
+    allocate(omega_prof_cas(nlev_cas))
+    allocate(ug_prof_cas(nlev_cas))
+    allocate(vg_prof_cas(nlev_cas))
+    allocate(ht_prof_cas(nlev_cas))
+    allocate(hth_prof_cas(nlev_cas))
+    allocate(hq_prof_cas(nlev_cas))
+    allocate(hu_prof_cas(nlev_cas))
+    allocate(hv_prof_cas(nlev_cas))
+    allocate(vt_prof_cas(nlev_cas))
+    allocate(vth_prof_cas(nlev_cas))
+    allocate(vq_prof_cas(nlev_cas))
+    allocate(vu_prof_cas(nlev_cas))
+    allocate(vv_prof_cas(nlev_cas))
+    allocate(dt_prof_cas(nlev_cas))
+    allocate(dth_prof_cas(nlev_cas))
+    allocate(dtrad_prof_cas(nlev_cas))
+    allocate(dq_prof_cas(nlev_cas))
+    allocate(du_prof_cas(nlev_cas))
+    allocate(dv_prof_cas(nlev_cas))
+    allocate(uw_prof_cas(nlev_cas))
+    allocate(vw_prof_cas(nlev_cas))
+    allocate(q1_prof_cas(nlev_cas))
+    allocate(q2_prof_cas(nlev_cas))
+
+    print*,'Allocations OK'
+    call read2_cas (nid,nlev_cas,nt_cas,                                                                     &
+         ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                    &
+         ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,ug_cas,vg_cas,du_cas,hu_cas,vu_cas,        &
+         dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
+         dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tke_cas,                      &
+         uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
+         o3_cas,rugos_cas,clay_cas,sand_cas)
+    print*,'Read2 cas OK'
+    do ii=1,nlev_cas
+       print*,'apres read2_cas, plev_cas=',ii,plev_cas(ii,1)
+    enddo
+
+
+  END SUBROUTINE read2_1D_cas
+
+  !**********************************************************************************************
+  SUBROUTINE old_read_SCM_cas
+    use netcdf, only: nf90_get_var
+    implicit none
 
 #include "netcdf.inc"
 #include "date_cas.h"
 
-      INTEGER nid,rid,ierr
-      INTEGER ii,jj,timeid
-      REAL, ALLOCATABLE :: time_val(:)
-
-      print*,'ON EST VRAIMENT LA'
-      fich_cas='cas.nc'
-      print*,'fich_cas ',fich_cas
-      ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
-      print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: GROS Pb opening forcings nc file '
-         write(*,*) NF_STRERROR(ierr)
-         stop ""
-      endif
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lat',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lat'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,ii)
-      print*,'OK1 read2: nid,rid,lat',nid,rid,ii
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lon',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lon'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,jj)
-      print*,'OK2 read2: nid,rid,lat',nid,rid,jj
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lev',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension nlev'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
-      print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
-      IF ( .NOT. ( nlev_cas > 10 .AND. nlev_cas < 1000 )) THEN
-              print*,'Valeur de nlev_cas peu probable'
-              STOP
-      ENDIF
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'time',rid)
-      nt_cas=0
-      IF (ierr.NE.NF_NOERR) THEN
-        stop 'Oh probleme lecture dimension time'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
-      print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
-! Lecture de l'axe des temps
-      print*,'LECTURE DU TEMPS'
-      ierr=NF_INQ_VARID(nid,'time',timeid)
-         if(ierr/=NF_NOERR) then
-           print *,'Variable time manquante dans cas.nc:'
-           ierr=NF_NOERR
-         else
-                 allocate(time_val(nt_cas))
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,timeid,time_val)
-#else
-           ierr = NF_GET_VAR_REAL(nid,timeid,time_val)
-#endif
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de time cas.nc: '
-           endif
-   endif
-   IF (nt_cas>1) THEN
-           pdt_cas=time_val(2)-time_val(1)
-   ELSE
-           pdt_cas=0.
-   ENDIF
+    INTEGER nid,rid,ierr
+    INTEGER ii,jj,timeid
+    REAL, ALLOCATABLE :: time_val(:)
+
+    fich_cas='cas.nc'
+    print*,'fich_cas ',fich_cas
+    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
+    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
+    if (ierr.NE.NF_NOERR) then
+       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
+       write(*,*) NF_STRERROR(ierr)
+       stop ""
+    endif
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lat',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lat'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,ii)
+    print*,'OK1 read2: nid,rid,lat',nid,rid,ii
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lon',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lon'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,jj)
+    print*,'OK2 read2: nid,rid,lat',nid,rid,jj
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lev',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension nlev'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
+    print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
+    IF ( .NOT. ( nlev_cas > 10 .AND. nlev_cas < 1000 )) THEN
+       print*,'Valeur de nlev_cas peu probable'
+       STOP
+    ENDIF
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'time',rid)
+    nt_cas=0
+    IF (ierr.NE.NF_NOERR) THEN
+       stop 'Oh probleme lecture dimension time'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
+    print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
+    ! Lecture de l'axe des temps
+    print*,'LECTURE DU TEMPS'
+    ierr=NF_INQ_VARID(nid,'time',timeid)
+    if(ierr/=NF_NOERR) then
+       print *,'Variable time manquante dans cas.nc:'
+       ierr=NF_NOERR
+    else
+       allocate(time_val(nt_cas))
+       ierr = NF90_GET_VAR(nid,timeid,time_val)
+       if(ierr/=NF_NOERR) then
+          print *,'Pb a la lecture de time cas.nc: '
+       endif
+    endif
+    IF (nt_cas>1) THEN
+       pdt_cas=time_val(2)-time_val(1)
+    ELSE
+       pdt_cas=0.
+    ENDIF
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!profils moyens:
-        allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
-        allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
-        allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
-        allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
-             qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
-        allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
-        allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
-
-!forcing
-        allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
-        allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
-        allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
-        allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
-        allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
-        allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
-        allocate(ug_cas(nlev_cas,nt_cas))
-        allocate(vg_cas(nlev_cas,nt_cas))
-        allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tke_cas(nt_cas))
-        allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
-
-
-
-!champs interpoles
-        allocate(plev_prof_cas(nlev_cas))
-        allocate(t_prof_cas(nlev_cas))
-        allocate(theta_prof_cas(nlev_cas))
-        allocate(thl_prof_cas(nlev_cas))
-        allocate(thv_prof_cas(nlev_cas))
-        allocate(q_prof_cas(nlev_cas))
-        allocate(qv_prof_cas(nlev_cas))
-        allocate(ql_prof_cas(nlev_cas))
-        allocate(qi_prof_cas(nlev_cas))
-        allocate(rh_prof_cas(nlev_cas))
-        allocate(rv_prof_cas(nlev_cas))
-        allocate(u_prof_cas(nlev_cas))
-        allocate(v_prof_cas(nlev_cas))
-        allocate(vitw_prof_cas(nlev_cas))
-        allocate(omega_prof_cas(nlev_cas))
-        allocate(ug_prof_cas(nlev_cas))
-        allocate(vg_prof_cas(nlev_cas))
-        allocate(ht_prof_cas(nlev_cas))
-        allocate(hth_prof_cas(nlev_cas))
-        allocate(hq_prof_cas(nlev_cas))
-        allocate(hu_prof_cas(nlev_cas))
-        allocate(hv_prof_cas(nlev_cas))
-        allocate(vt_prof_cas(nlev_cas))
-        allocate(vth_prof_cas(nlev_cas))
-        allocate(vq_prof_cas(nlev_cas))
-        allocate(vu_prof_cas(nlev_cas))
-        allocate(vv_prof_cas(nlev_cas))
-        allocate(dt_prof_cas(nlev_cas))
-        allocate(dth_prof_cas(nlev_cas))
-        allocate(dtrad_prof_cas(nlev_cas))
-        allocate(dq_prof_cas(nlev_cas))
-        allocate(du_prof_cas(nlev_cas))
-        allocate(dv_prof_cas(nlev_cas))
-        allocate(uw_prof_cas(nlev_cas))
-        allocate(vw_prof_cas(nlev_cas))
-        allocate(q1_prof_cas(nlev_cas))
-        allocate(q2_prof_cas(nlev_cas))
-
-        print*,'Allocations OK'
-        call old_read_SCM (nid,nlev_cas,nt_cas,                                                                     &
-     &     ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                    &
-     &     ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,ug_cas,vg_cas,du_cas,hu_cas,vu_cas,        &
-     &     dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
-     &     dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tke_cas,                      &
-     &     uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
-     &     o3_cas,rugos_cas,clay_cas,sand_cas)
-        print*,'Read2 cas OK'
-        do ii=1,nlev_cas
-        print*,'apres read2_cas, plev_cas=',ii,plev_cas(ii,1)
-        enddo
-
-
-END SUBROUTINE old_read_SCM_cas
+    !profils moyens:
+    allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
+    allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
+    allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
+    allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
+         qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
+    allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
+    allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
+
+    !forcing
+    allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
+    allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
+    allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
+    allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
+    allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
+    allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
+    allocate(ug_cas(nlev_cas,nt_cas))
+    allocate(vg_cas(nlev_cas,nt_cas))
+    allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tke_cas(nt_cas))
+    allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
+
+
+
+    !champs interpoles
+    allocate(plev_prof_cas(nlev_cas))
+    allocate(t_prof_cas(nlev_cas))
+    allocate(theta_prof_cas(nlev_cas))
+    allocate(thl_prof_cas(nlev_cas))
+    allocate(thv_prof_cas(nlev_cas))
+    allocate(q_prof_cas(nlev_cas))
+    allocate(qv_prof_cas(nlev_cas))
+    allocate(ql_prof_cas(nlev_cas))
+    allocate(qi_prof_cas(nlev_cas))
+    allocate(rh_prof_cas(nlev_cas))
+    allocate(rv_prof_cas(nlev_cas))
+    allocate(u_prof_cas(nlev_cas))
+    allocate(v_prof_cas(nlev_cas))
+    allocate(vitw_prof_cas(nlev_cas))
+    allocate(omega_prof_cas(nlev_cas))
+    allocate(ug_prof_cas(nlev_cas))
+    allocate(vg_prof_cas(nlev_cas))
+    allocate(ht_prof_cas(nlev_cas))
+    allocate(hth_prof_cas(nlev_cas))
+    allocate(hq_prof_cas(nlev_cas))
+    allocate(hu_prof_cas(nlev_cas))
+    allocate(hv_prof_cas(nlev_cas))
+    allocate(vt_prof_cas(nlev_cas))
+    allocate(vth_prof_cas(nlev_cas))
+    allocate(vq_prof_cas(nlev_cas))
+    allocate(vu_prof_cas(nlev_cas))
+    allocate(vv_prof_cas(nlev_cas))
+    allocate(dt_prof_cas(nlev_cas))
+    allocate(dth_prof_cas(nlev_cas))
+    allocate(dtrad_prof_cas(nlev_cas))
+    allocate(dq_prof_cas(nlev_cas))
+    allocate(du_prof_cas(nlev_cas))
+    allocate(dv_prof_cas(nlev_cas))
+    allocate(uw_prof_cas(nlev_cas))
+    allocate(vw_prof_cas(nlev_cas))
+    allocate(q1_prof_cas(nlev_cas))
+    allocate(q2_prof_cas(nlev_cas))
+
+    print*,'Allocations OK'
+    call old_read_SCM (nid,nlev_cas,nt_cas,                                                                     &
+         ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                    &
+         ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,ug_cas,vg_cas,du_cas,hu_cas,vu_cas,        &
+         dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
+         dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tke_cas,                      &
+         uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
+         o3_cas,rugos_cas,clay_cas,sand_cas)
+    print*,'Read2 cas OK'
+    do ii=1,nlev_cas
+       print*,'apres read2_cas, plev_cas=',ii,plev_cas(ii,1)
+    enddo
+
+
+  END SUBROUTINE old_read_SCM_cas
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-SUBROUTINE deallocate2_1D_cases
-!profils environnementaux:
-        deallocate(plev_cas,plevh_cas)
-        
-        deallocate(z_cas,zh_cas)
-        deallocate(ap_cas,bp_cas)
-        deallocate(t_cas,q_cas,qv_cas,ql_cas,qi_cas,rh_cas)
-        deallocate(th_cas,thl_cas,thv_cas,rv_cas)
-        deallocate(u_cas,v_cas,vitw_cas,omega_cas)
-        
-!forcing
-        deallocate(ht_cas,vt_cas,dt_cas,dtrad_cas)
-        deallocate(hq_cas,vq_cas,dq_cas)
-        deallocate(hth_cas,vth_cas,dth_cas)
-        deallocate(hr_cas,vr_cas,dr_cas)
-        deallocate(hu_cas,vu_cas,du_cas)
-        deallocate(hv_cas,vv_cas,dv_cas)
-        deallocate(ug_cas)
-        deallocate(vg_cas)
-        deallocate(lat_cas,sens_cas,ts_cas,ps_cas,ustar_cas,tke_cas,uw_cas,vw_cas,q1_cas,q2_cas)
-
-!champs interpoles
-        deallocate(plev_prof_cas)
-        deallocate(t_prof_cas)
-        deallocate(theta_prof_cas)
-        deallocate(thl_prof_cas)
-        deallocate(thv_prof_cas)
-        deallocate(q_prof_cas)
-        deallocate(qv_prof_cas)
-        deallocate(ql_prof_cas)
-        deallocate(qi_prof_cas)
-        deallocate(rh_prof_cas)
-        deallocate(rv_prof_cas)
-        deallocate(u_prof_cas)
-        deallocate(v_prof_cas)
-        deallocate(vitw_prof_cas)
-        deallocate(omega_prof_cas)
-        deallocate(ug_prof_cas)
-        deallocate(vg_prof_cas)
-        deallocate(ht_prof_cas)
-        deallocate(hq_prof_cas)
-        deallocate(hu_prof_cas)
-        deallocate(hv_prof_cas)
-        deallocate(vt_prof_cas)
-        deallocate(vq_prof_cas)
-        deallocate(vu_prof_cas)
-        deallocate(vv_prof_cas)
-        deallocate(dt_prof_cas)
-        deallocate(dtrad_prof_cas)
-        deallocate(dq_prof_cas)
-        deallocate(du_prof_cas)
-        deallocate(dv_prof_cas)
-        deallocate(t_prof_cas)
-        deallocate(u_prof_cas)
-        deallocate(v_prof_cas)
-        deallocate(uw_prof_cas)
-        deallocate(vw_prof_cas)
-        deallocate(q1_prof_cas)
-        deallocate(q2_prof_cas)
-
-END SUBROUTINE deallocate2_1D_cases
+  SUBROUTINE deallocate2_1D_cases
+    !profils environnementaux:
+    deallocate(plev_cas,plevh_cas)
+
+    deallocate(z_cas,zh_cas)
+    deallocate(ap_cas,bp_cas)
+    deallocate(t_cas,q_cas,qv_cas,ql_cas,qi_cas,rh_cas)
+    deallocate(th_cas,thl_cas,thv_cas,rv_cas)
+    deallocate(u_cas,v_cas,vitw_cas,omega_cas)
+
+    !forcing
+    deallocate(ht_cas,vt_cas,dt_cas,dtrad_cas)
+    deallocate(hq_cas,vq_cas,dq_cas)
+    deallocate(hth_cas,vth_cas,dth_cas)
+    deallocate(hr_cas,vr_cas,dr_cas)
+    deallocate(hu_cas,vu_cas,du_cas)
+    deallocate(hv_cas,vv_cas,dv_cas)
+    deallocate(ug_cas)
+    deallocate(vg_cas)
+    deallocate(lat_cas,sens_cas,ts_cas,ps_cas,ustar_cas,tke_cas,uw_cas,vw_cas,q1_cas,q2_cas)
+
+    !champs interpoles
+    deallocate(plev_prof_cas)
+    deallocate(t_prof_cas)
+    deallocate(theta_prof_cas)
+    deallocate(thl_prof_cas)
+    deallocate(thv_prof_cas)
+    deallocate(q_prof_cas)
+    deallocate(qv_prof_cas)
+    deallocate(ql_prof_cas)
+    deallocate(qi_prof_cas)
+    deallocate(rh_prof_cas)
+    deallocate(rv_prof_cas)
+    deallocate(u_prof_cas)
+    deallocate(v_prof_cas)
+    deallocate(vitw_prof_cas)
+    deallocate(omega_prof_cas)
+    deallocate(ug_prof_cas)
+    deallocate(vg_prof_cas)
+    deallocate(ht_prof_cas)
+    deallocate(hq_prof_cas)
+    deallocate(hu_prof_cas)
+    deallocate(hv_prof_cas)
+    deallocate(vt_prof_cas)
+    deallocate(vq_prof_cas)
+    deallocate(vu_prof_cas)
+    deallocate(vv_prof_cas)
+    deallocate(dt_prof_cas)
+    deallocate(dtrad_prof_cas)
+    deallocate(dq_prof_cas)
+    deallocate(du_prof_cas)
+    deallocate(dv_prof_cas)
+    deallocate(t_prof_cas)
+    deallocate(u_prof_cas)
+    deallocate(v_prof_cas)
+    deallocate(uw_prof_cas)
+    deallocate(vw_prof_cas)
+    deallocate(q1_prof_cas)
+    deallocate(q2_prof_cas)
+
+  END SUBROUTINE deallocate2_1D_cases
 
 
 END MODULE mod_1D_cases_read2
 !=====================================================================
-      subroutine read_cas2(nid,nlevel,ntime                          &
-     &     ,zz,pp,temp,qv,rh,theta,rv,u,v,ug,vg,w,                   &
-     &     du,hu,vu,dv,hv,vv,dt,dtrad,ht,vt,dq,hq,vq,                     &
-     &     dth,hth,vth,dr,hr,vr,sens,flat,ts,ustar,uw,vw,q1,q2)
-
-!program reading forcing of the case study
-      implicit none
+subroutine read_cas2(nid,nlevel,ntime                          &
+     ,zz,pp,temp,qv,rh,theta,rv,u,v,ug,vg,w,                   &
+     du,hu,vu,dv,hv,vv,dt,dtrad,ht,vt,dq,hq,vq,                     &
+     dth,hth,vth,dr,hr,vr,sens,flat,ts,ustar,uw,vw,q1,q2)
+
+  !program reading forcing of the case study
+  use netcdf, only: nf90_get_var
+  implicit none
 #include "netcdf.inc"
 
-      integer ntime,nlevel
-
-      real zz(nlevel,ntime)
-      real pp(nlevel,ntime)
-      real temp(nlevel,ntime),qv(nlevel,ntime),rh(nlevel,ntime)
-      real theta(nlevel,ntime),rv(nlevel,ntime)
-      real u(nlevel,ntime)
-      real v(nlevel,ntime)
-      real ug(nlevel,ntime)
-      real vg(nlevel,ntime)
-      real w(nlevel,ntime)
-      real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
-      real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
-      real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
-      real dtrad(nlevel,ntime)
-      real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
-      real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime)
-      real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
-      real flat(ntime),sens(ntime),ts(ntime),ustar(ntime)
-      real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime),resul(nlevel,ntime),resul1(ntime)
-
-
-      integer nid, ierr, ierr1,ierr2,rid,i
-      integer nbvar3d
-      parameter(nbvar3d=39)
-      integer var3didin(nbvar3d)
-      character*5 name_var(1:nbvar3d)
-      data name_var/'zz','pp','temp','qv','rh','theta','rv','u','v','ug','vg','w','advu','hu','vu',&
-     &'advv','hv','vv','advT','hT','vT','advq','hq','vq','advth','hth','vth','advr','hr','vr',&
-     &'radT','uw','vw','q1','q2','sens','flat','ts','ustar'/
-
-       do i=1,nbvar3d
-         print *,'Dans read_cas2, on va lire ',nid,i,name_var(i)
-       enddo
-       do i=1,nbvar3d
-         ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
-         print *,'ierr=',i,ierr,name_var(i),var3didin(i)
-         if(ierr/=NF_NOERR) then
-           print *,'Variable manquante dans cas.nc:',name_var(i)
-         endif
-       enddo
-       do i=1,nbvar3d
-         print *,'Dans read_cas2, on va lire ',var3didin(i),name_var(i)
-         if(i.LE.35) then
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul)
-#endif
-         print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
-         if(ierr/=NF_NOERR) then
-            print *,'Pb a la lecture de cas.nc: ',name_var(i)
-            stop "getvarup"
-         endif
-         else
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul1)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul1)
-#endif
-         print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
-         if(ierr/=NF_NOERR) then
-            print *,'Pb a la lecture de cas.nc: ',name_var(i)
-            stop "getvarup"
-         endif
-         endif
-         select case(i)
-           case(1) ; zz=resul
-           case(2) ; pp=resul
-           case(3) ; temp=resul
-           case(4) ; qv=resul
-           case(5) ; rh=resul
-           case(6) ; theta=resul
-           case(7) ; rv=resul
-           case(8) ; u=resul
-           case(9) ; v=resul
-           case(10) ; ug=resul
-           case(11) ; vg=resul
-           case(12) ; w=resul
-           case(13) ; du=resul
-           case(14) ; hu=resul
-           case(15) ; vu=resul
-           case(16) ; dv=resul
-           case(17) ; hv=resul
-           case(18) ; vv=resul
-           case(19) ; dt=resul
-           case(20) ; ht=resul
-           case(21) ; vt=resul
-           case(22) ; dq=resul
-           case(23) ; hq=resul
-           case(24) ; vq=resul
-           case(25) ; dth=resul
-           case(26) ; hth=resul
-           case(27) ; vth=resul
-           case(28) ; dr=resul
-           case(29) ; hr=resul
-           case(30) ; vr=resul
-           case(31) ; dtrad=resul
-           case(32) ; uw=resul
-           case(33) ; vw=resul
-           case(34) ; q1=resul
-           case(35) ; q2=resul
-           case(36) ; sens=resul1
-           case(37) ; flat=resul1
-           case(38) ; ts=resul1
-           case(39) ; ustar=resul1
-         end select
-       enddo
-
-         return 
-         end subroutine read_cas2
+  integer ntime,nlevel
+
+  real zz(nlevel,ntime)
+  real pp(nlevel,ntime)
+  real temp(nlevel,ntime),qv(nlevel,ntime),rh(nlevel,ntime)
+  real theta(nlevel,ntime),rv(nlevel,ntime)
+  real u(nlevel,ntime)
+  real v(nlevel,ntime)
+  real ug(nlevel,ntime)
+  real vg(nlevel,ntime)
+  real w(nlevel,ntime)
+  real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
+  real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
+  real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
+  real dtrad(nlevel,ntime)
+  real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
+  real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime)
+  real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
+  real flat(ntime),sens(ntime),ts(ntime),ustar(ntime)
+  real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime),resul(nlevel,ntime),resul1(ntime)
+
+
+  integer nid, ierr, ierr1,ierr2,rid,i
+  integer nbvar3d
+  parameter(nbvar3d=39)
+  integer var3didin(nbvar3d)
+  character*5 name_var(1:nbvar3d)
+  data name_var/'zz','pp','temp','qv','rh','theta','rv','u','v','ug','vg','w','advu','hu','vu',&
+       'advv','hv','vv','advT','hT','vT','advq','hq','vq','advth','hth','vth','advr','hr','vr',&
+       'radT','uw','vw','q1','q2','sens','flat','ts','ustar'/
+
+
+  do i=1,nbvar3d
+     print *,'Dans read_cas2, on va lire ',nid,i,name_var(i)
+  enddo
+  do i=1,nbvar3d
+     ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
+     print *,'ierr=',i,ierr,name_var(i),var3didin(i)
+     if(ierr/=NF_NOERR) then
+        print *,'Variable manquante dans cas.nc:',name_var(i)
+     endif
+  enddo
+  do i=1,nbvar3d
+     print *,'Dans read_cas2, on va lire ',var3didin(i),name_var(i)
+     if(i.LE.35) then
+        ierr = NF90_GET_VAR(nid,var3didin(i),resul, count = [1, 1, nlevel, ntime])
+        print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
+        if(ierr/=NF_NOERR) then
+           print *,'Pb a la lecture de cas.nc: ',name_var(i)
+           stop "getvarup"
+        endif
+     else
+        print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
+        ierr = NF90_GET_VAR(nid,var3didin(i),resul1, count = [1, 1, ntime])
+        if(ierr/=NF_NOERR) then
+           print *,'Pb a la lecture de cas.nc: ',name_var(i)
+           stop "getvarup"
+        endif
+     endif
+     select case(i)
+     case(1) ; zz=resul
+     case(2) ; pp=resul
+     case(3) ; temp=resul
+     case(4) ; qv=resul
+     case(5) ; rh=resul
+     case(6) ; theta=resul
+     case(7) ; rv=resul
+     case(8) ; u=resul
+     case(9) ; v=resul
+     case(10) ; ug=resul
+     case(11) ; vg=resul
+     case(12) ; w=resul
+     case(13) ; du=resul
+     case(14) ; hu=resul
+     case(15) ; vu=resul
+     case(16) ; dv=resul
+     case(17) ; hv=resul
+     case(18) ; vv=resul
+     case(19) ; dt=resul
+     case(20) ; ht=resul
+     case(21) ; vt=resul
+     case(22) ; dq=resul
+     case(23) ; hq=resul
+     case(24) ; vq=resul
+     case(25) ; dth=resul
+     case(26) ; hth=resul
+     case(27) ; vth=resul
+     case(28) ; dr=resul
+     case(29) ; hr=resul
+     case(30) ; vr=resul
+     case(31) ; dtrad=resul
+     case(32) ; uw=resul
+     case(33) ; vw=resul
+     case(34) ; q1=resul
+     case(35) ; q2=resul
+     case(36) ; sens=resul1
+     case(37) ; flat=resul1
+     case(38) ; ts=resul1
+     case(39) ; ustar=resul1
+     end select
+  enddo
+
+  return 
+end subroutine read_cas2
 !======================================================================
-      subroutine read2_cas(nid,nlevel,ntime,                                       &
-     &     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,ug,vg,&
-     &     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
-     &     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tke,uw,vw,q1,q2,       &
-     &     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
-     &     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
-
-!program reading forcing of the case study
-      implicit none
+subroutine read2_cas(nid,nlevel,ntime,                                       &
+     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,ug,vg,&
+     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
+     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tke,uw,vw,q1,q2,       &
+     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
+     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
+
+  !program reading forcing of the case study
+  use netcdf, only: nf90_get_var
+  implicit none
 #include "netcdf.inc"
 
-      integer ntime,nlevel
-
-      real ap(nlevel+1),bp(nlevel+1)
-      real zz(nlevel,ntime),zzh(nlevel+1)
-      real pp(nlevel,ntime),pph(nlevel+1)
-      real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
-      real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
-      real u(nlevel,ntime),v(nlevel,ntime)
-      real ug(nlevel,ntime),vg(nlevel,ntime)
-      real vitw(nlevel,ntime),omega(nlevel,ntime)
-      real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
-      real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
-      real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
-      real dtrad(nlevel,ntime)
-      real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
-      real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
-      real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
-      real flat(ntime),sens(ntime),ustar(ntime)
-      real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
-      real ts(ntime),ps(ntime),tke(ntime)
-      real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
-      real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
-
-
-      integer nid, ierr,ierr1,ierr2,rid,i
-      integer nbvar3d
-      parameter(nbvar3d=62)
-      integer var3didin(nbvar3d),missing_var(nbvar3d)
-      character*12 name_var(1:nbvar3d)
-      data name_var/'coor_par_a','coor_par_b','height_h','pressure_h',&
-     &'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','tadv','tadvh','tadvv',&
-     &'qadv','qadvh','qadvv','thadv','thadvh','thadvv','thladvh','radv','radvh','radvv','radcool','q1','q2','ustress','vstress', &
-     'rh',&
-     &'height_f','pressure_f','temp','theta','thv','thl','qv','ql','qi','rv','u','v',&
-     &'sfc_sens_flx','sfc_lat_flx','ts','ps','ustar','tke',&
-     &'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough','o3','rugos','clay','sand'/
-      do i=1,nbvar3d
-        missing_var(i)=0.
-      enddo
-
-!-----------------------------------------------------------------------
-       do i=1,nbvar3d
-         ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
-         if(ierr/=NF_NOERR) then
-           print *,'Variable manquante dans cas.nc:',i,name_var(i)
-           ierr=NF_NOERR
-           missing_var(i)=1
-         else
-!-----------------------------------------------------------------------
-           if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),apbp)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),apbp)
-#endif
+  integer ntime,nlevel
+
+  real ap(nlevel+1),bp(nlevel+1)
+  real zz(nlevel,ntime),zzh(nlevel+1)
+  real pp(nlevel,ntime),pph(nlevel+1)
+  real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
+  real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
+  real u(nlevel,ntime),v(nlevel,ntime)
+  real ug(nlevel,ntime),vg(nlevel,ntime)
+  real vitw(nlevel,ntime),omega(nlevel,ntime)
+  real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
+  real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
+  real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
+  real dtrad(nlevel,ntime)
+  real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
+  real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
+  real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
+  real flat(ntime),sens(ntime),ustar(ntime)
+  real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
+  real ts(ntime),ps(ntime),tke(ntime)
+  real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
+  real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
+
+
+  integer nid, ierr,ierr1,ierr2,rid,i
+  integer nbvar3d
+  parameter(nbvar3d=62)
+  integer var3didin(nbvar3d),missing_var(nbvar3d)
+  character*12 name_var(1:nbvar3d)
+  data name_var/'coor_par_a','coor_par_b','height_h','pressure_h',&
+       'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','tadv','tadvh','tadvv',&
+       'qadv','qadvh','qadvv','thadv','thadvh','thadvv','thladvh','radv','radvh','radvv','radcool','q1','q2','ustress','vstress', &
+       'rh',&
+       'height_f','pressure_f','temp','theta','thv','thl','qv','ql','qi','rv','u','v',&
+       'sfc_sens_flx','sfc_lat_flx','ts','ps','ustar','tke',&
+       'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough','o3','rugos','clay','sand'/
+  do i=1,nbvar3d
+     missing_var(i)=0.
+  enddo
+
+  !-----------------------------------------------------------------------
+  do i=1,nbvar3d
+     ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
+     if(ierr/=NF_NOERR) then
+        print *,'Variable manquante dans cas.nc:',i,name_var(i)
+        ierr=NF_NOERR
+        missing_var(i)=1
+     else
+        !-----------------------------------------------------------------------
+        if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),apbp, count = [1, 1, nlevel + 1])
            print *,'read2_cas(apbp), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -731,11 +718,7 @@
               stop "getvarup"
            endif
-!-----------------------------------------------------------------------
-           else if(i.gt.4.and.i.LE.45) then   ! Lecture des variables en (time,nlevel,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul)
-#endif
+           !-----------------------------------------------------------------------
+        else if(i.gt.4.and.i.LE.45) then   ! Lecture des variables en (time,nlevel,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul, count = [1, 1, nlevel, ntime])
            print *,'read2_cas(resul), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -743,11 +726,7 @@
               stop "getvarup"
            endif
-!-----------------------------------------------------------------------
-           else if (i.gt.45.and.i.LE.51) then   ! Lecture des variables en (time,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul2)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul2)
-#endif
+           !-----------------------------------------------------------------------
+        else if (i.gt.45.and.i.LE.51) then   ! Lecture des variables en (time,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul2, count = [1, 1, ntime])
            print *,'read2_cas(resul2), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -755,11 +734,7 @@
               stop "getvarup"
            endif
-!-----------------------------------------------------------------------
-           else     ! Lecture des constantes (lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul3)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul3)
-#endif
+           !-----------------------------------------------------------------------
+        else     ! Lecture des constantes (lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul3)
            print *,'read2_cas(resul3), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -767,155 +742,152 @@
               stop "getvarup"
            endif
-           endif
-         endif
-!-----------------------------------------------------------------------
-         select case(i)
-           case(1) ; ap=apbp       ! donnees indexees en nlevel+1
-           case(2) ; bp=apbp
-           case(3) ; zzh=apbp
-           case(4) ; pph=apbp
-           case(5) ; vitw=resul    ! donnees indexees en nlevel,time
-           case(6) ; omega=resul
-           case(7) ; ug=resul
-           case(8) ; vg=resul
-           case(9) ; du=resul
-           case(10) ; hu=resul
-           case(11) ; vu=resul
-           case(12) ; dv=resul
-           case(13) ; hv=resul
-           case(14) ; vv=resul
-           case(15) ; dt=resul
-           case(16) ; ht=resul
-           case(17) ; vt=resul
-           case(18) ; dq=resul
-           case(19) ; hq=resul
-           case(20) ; vq=resul
-           case(21) ; dth=resul
-           case(22) ; hth=resul
-           case(23) ; vth=resul
-           case(24) ; hthl=resul
-           case(25) ; dr=resul
-           case(26) ; hr=resul
-           case(27) ; vr=resul
-           case(28) ; dtrad=resul
-           case(29) ; q1=resul
-           case(30) ; q2=resul
-           case(31) ; uw=resul
-           case(32) ; vw=resul
-           case(33) ; rh=resul
-           case(34) ; zz=resul      ! donnees en time,nlevel pour profil initial
-           case(35) ; pp=resul
-           case(36) ; temp=resul
-           case(37) ; theta=resul
-           case(38) ; thv=resul
-           case(39) ; thl=resul
-           case(40) ; qv=resul
-           case(41) ; ql=resul
-           case(42) ; qi=resul
-           case(43) ; rv=resul
-           case(44) ; u=resul
-           case(45) ; v=resul
-           case(46) ; sens=resul2   ! donnees indexees en time
-           case(47) ; flat=resul2
-           case(48) ; ts=resul2
-           case(49) ; ps=resul2
-           case(50) ; ustar=resul2
-           case(51) ; tke=resul2
-           case(52) ; orog_cas=resul3      ! constantes
-           case(53) ; albedo_cas=resul3
-           case(54) ; emiss_cas=resul3
-           case(55) ; t_skin_cas=resul3
-           case(56) ; q_skin_cas=resul3
-           case(57) ; mom_rough=resul3
-           case(58) ; heat_rough=resul3
-           case(59) ; o3_cas=resul3        
-           case(60) ; rugos_cas=resul3
-           case(61) ; clay_cas=resul3
-           case(62) ; sand_cas=resul3
-         end select
-         resul=0.
-         resul1=0.
-         resul2=0.
-         resul3=0.
-       enddo
-!-----------------------------------------------------------------------
-
-
-         return 
-         end subroutine read2_cas
+        endif
+     endif
+     !-----------------------------------------------------------------------
+     select case(i)
+     case(1) ; ap=apbp       ! donnees indexees en nlevel+1
+     case(2) ; bp=apbp
+     case(3) ; zzh=apbp
+     case(4) ; pph=apbp
+     case(5) ; vitw=resul    ! donnees indexees en nlevel,time
+     case(6) ; omega=resul
+     case(7) ; ug=resul
+     case(8) ; vg=resul
+     case(9) ; du=resul
+     case(10) ; hu=resul
+     case(11) ; vu=resul
+     case(12) ; dv=resul
+     case(13) ; hv=resul
+     case(14) ; vv=resul
+     case(15) ; dt=resul
+     case(16) ; ht=resul
+     case(17) ; vt=resul
+     case(18) ; dq=resul
+     case(19) ; hq=resul
+     case(20) ; vq=resul
+     case(21) ; dth=resul
+     case(22) ; hth=resul
+     case(23) ; vth=resul
+     case(24) ; hthl=resul
+     case(25) ; dr=resul
+     case(26) ; hr=resul
+     case(27) ; vr=resul
+     case(28) ; dtrad=resul
+     case(29) ; q1=resul
+     case(30) ; q2=resul
+     case(31) ; uw=resul
+     case(32) ; vw=resul
+     case(33) ; rh=resul
+     case(34) ; zz=resul      ! donnees en time,nlevel pour profil initial
+     case(35) ; pp=resul
+     case(36) ; temp=resul
+     case(37) ; theta=resul
+     case(38) ; thv=resul
+     case(39) ; thl=resul
+     case(40) ; qv=resul
+     case(41) ; ql=resul
+     case(42) ; qi=resul
+     case(43) ; rv=resul
+     case(44) ; u=resul
+     case(45) ; v=resul
+     case(46) ; sens=resul2   ! donnees indexees en time
+     case(47) ; flat=resul2
+     case(48) ; ts=resul2
+     case(49) ; ps=resul2
+     case(50) ; ustar=resul2
+     case(51) ; tke=resul2
+     case(52) ; orog_cas=resul3      ! constantes
+     case(53) ; albedo_cas=resul3
+     case(54) ; emiss_cas=resul3
+     case(55) ; t_skin_cas=resul3
+     case(56) ; q_skin_cas=resul3
+     case(57) ; mom_rough=resul3
+     case(58) ; heat_rough=resul3
+     case(59) ; o3_cas=resul3        
+     case(60) ; rugos_cas=resul3
+     case(61) ; clay_cas=resul3
+     case(62) ; sand_cas=resul3
+     end select
+     resul=0.
+     resul1=0.
+     resul2=0.
+     resul3=0.
+  enddo
+  !-----------------------------------------------------------------------
+
+
+  return 
+end subroutine read2_cas
 
 !======================================================================
-      subroutine old_read_SCM(nid,nlevel,ntime,                                       &
-     &     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,ug,vg,&
-     &     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
-     &     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tke,uw,vw,q1,q2,       &
-     &     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
-     &     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
-
-!program reading forcing of the case study
-      implicit none
+subroutine old_read_SCM(nid,nlevel,ntime,                                       &
+     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,ug,vg,&
+     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
+     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tke,uw,vw,q1,q2,       &
+     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
+     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
+
+  !program reading forcing of the case study
+  use netcdf, only: nf90_get_var
+  implicit none
 #include "netcdf.inc"
 
-      integer ntime,nlevel,k,t
-
-      real ap(nlevel+1),bp(nlevel+1)
-      real zz(nlevel,ntime),zzh(nlevel+1)
-      real pp(nlevel,ntime),pph(nlevel+1)
-!profils initiaux
-      real temp0(nlevel),qv0(nlevel),ql0(nlevel),qi0(nlevel),u0(nlevel),v0(nlevel),tke0(nlevel)
-      real pp0(nlevel)    
-      real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
-      real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
-      real u(nlevel,ntime),v(nlevel,ntime),tke(nlevel,ntime)
-      real ug(nlevel,ntime),vg(nlevel,ntime)
-      real vitw(nlevel,ntime),omega(nlevel,ntime)
-      real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
-      real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
-      real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
-      real dtrad(nlevel,ntime)
-      real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
-      real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
-      real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
-      real flat(ntime),sens(ntime),ustar(ntime)
-      real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
-      real ts(ntime),ps(ntime)
-      real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
-      real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
-
-
-      integer nid, ierr,ierr1,ierr2,rid,i
-      integer nbvar3d
-      parameter(nbvar3d=70)
-      integer var3didin(nbvar3d),missing_var(nbvar3d)
-      character*13 name_var(1:nbvar3d)
-      data name_var/'coor_par_a','coor_par_b','height_h','pressure_h',&
-     &'temp','qv','ql','qi','u','v','tke','pressure',&
-     &'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','tadv','tadvh','tadvv',&
-     &'qvadv','qvadvh','qvadvv','thadv','thadvh','thadvv','thladvh','radv','radvh','radvv','radcool','q1','q2','ustress','vstress', &
-     'rh',&
-     &'height_f','pressure_forc','tempt','theta','thv','thl','qvt','qlt','qit','rv','ut','vt','tket',&
-     &'sfc_sens_flx','sfc_lat_flx','ts','ps','ustar',&
-     &'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough','o3','rugos','clay','sand'/
-      do i=1,nbvar3d
-        missing_var(i)=0.
-      enddo
-
-!-----------------------------------------------------------------------
-
-     print*,'ON EST LA'
-       do i=1,nbvar3d
-         ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
-         if(ierr/=NF_NOERR) then
-           print *,'Variable manquante dans cas.nc:',i,name_var(i)
-           ierr=NF_NOERR
-           missing_var(i)=1
-         else
-!-----------------------------------------------------------------------
-           if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),apbp)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),apbp)
-#endif
+  integer ntime,nlevel,k,t
+
+  real ap(nlevel+1),bp(nlevel+1)
+  real zz(nlevel,ntime),zzh(nlevel+1)
+  real pp(nlevel,ntime),pph(nlevel+1)
+  !profils initiaux
+  real temp0(nlevel),qv0(nlevel),ql0(nlevel),qi0(nlevel),u0(nlevel),v0(nlevel),tke0(nlevel)
+  real pp0(nlevel)    
+  real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
+  real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
+  real u(nlevel,ntime),v(nlevel,ntime),tke(nlevel,ntime)
+  real ug(nlevel,ntime),vg(nlevel,ntime)
+  real vitw(nlevel,ntime),omega(nlevel,ntime)
+  real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
+  real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
+  real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
+  real dtrad(nlevel,ntime)
+  real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
+  real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
+  real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
+  real flat(ntime),sens(ntime),ustar(ntime)
+  real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
+  real ts(ntime),ps(ntime)
+  real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
+  real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
+
+
+  integer nid, ierr,ierr1,ierr2,rid,i
+  integer nbvar3d
+  parameter(nbvar3d=70)
+  integer var3didin(nbvar3d),missing_var(nbvar3d)
+  character*13 name_var(1:nbvar3d)
+  data name_var/'coor_par_a','coor_par_b','height_h','pressure_h',&
+       'temp','qv','ql','qi','u','v','tke','pressure',&
+       'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','tadv','tadvh','tadvv',&
+       'qvadv','qvadvh','qvadvv','thadv','thadvh','thadvv','thladvh','radv','radvh','radvv','radcool','q1','q2','ustress', &
+       'vstress','rh',&
+       'height_f','pressure_forc','tempt','theta','thv','thl','qvt','qlt','qit','rv','ut','vt','tket',&
+       'sfc_sens_flx','sfc_lat_flx','ts','ps','ustar',&
+       'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough','o3','rugos','clay','sand'/
+  do i=1,nbvar3d
+     missing_var(i)=0.
+  enddo
+
+  !-----------------------------------------------------------------------
+
+  print*,'ON EST LA'
+  do i=1,nbvar3d
+     ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
+     if(ierr/=NF_NOERR) then
+        print *,'Variable manquante dans cas.nc:',i,name_var(i)
+        ierr=NF_NOERR
+        missing_var(i)=1
+     else
+        !-----------------------------------------------------------------------
+        if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),apbp)
            print *,'read2_cas(apbp), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -923,11 +895,7 @@
               stop "getvarup"
            endif
-!-----------------------------------------------------------------------
-           else if(i.gt.4.and.i.LE.12) then   ! Lecture des variables en (time,nlevel,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul1)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul1)
-#endif
+           !-----------------------------------------------------------------------
+        else if(i.gt.4.and.i.LE.12) then   ! Lecture des variables en (time,nlevel,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul1)
            print *,'read2_cas(resul1), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -935,12 +903,8 @@
               stop "getvarup"
            endif
-         print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
-!-----------------------------------------------------------------------
-           else if(i.gt.12.and.i.LE.54) then   ! Lecture des variables en (time,nlevel,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul)
-#endif
+           print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
+           !-----------------------------------------------------------------------
+        else if(i.gt.12.and.i.LE.54) then   ! Lecture des variables en (time,nlevel,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul)
            print *,'read2_cas(resul), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -948,12 +912,8 @@
               stop "getvarup"
            endif
-         print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
-!-----------------------------------------------------------------------
-           else if (i.gt.54.and.i.LE.65) then   ! Lecture des variables en (time,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul2)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul2)
-#endif
+           print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
+           !-----------------------------------------------------------------------
+        else if (i.gt.54.and.i.LE.65) then   ! Lecture des variables en (time,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul2)
            print *,'read2_cas(resul2), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -961,12 +921,8 @@
               stop "getvarup"
            endif
-         print*,'Lecture de la variable #i  ',i,name_var(i),minval(resul2),maxval(resul2)
-!-----------------------------------------------------------------------
-           else     ! Lecture des constantes (lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul3)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul3)
-#endif
+           print*,'Lecture de la variable #i  ',i,name_var(i),minval(resul2),maxval(resul2)
+           !-----------------------------------------------------------------------
+        else     ! Lecture des constantes (lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul3)
            print *,'read2_cas(resul3), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -974,546 +930,546 @@
               stop "getvarup"
            endif
-         print*,'Lecture de la variable #i ',i,name_var(i),resul3
-           endif
-         endif
-!-----------------------------------------------------------------------
-         select case(i)
-         !case(1) ; ap=apbp       ! donnees indexees en nlevel+1
-         ! case(2) ; bp=apbp
-           case(3) ; zzh=apbp
-           case(4) ; pph=apbp
-           case(5) ; temp0=resul1    ! donnees initiales
-           case(6) ; qv0=resul1
-           case(7) ; ql0=resul1
-           case(8) ; qi0=resul1
-           case(9) ; u0=resul1
-           case(10) ; v0=resul1
-           case(11) ; tke0=resul1
-           case(12) ; pp0=resul1
-           case(13) ; vitw=resul    ! donnees indexees en nlevel,time
-           case(14) ; omega=resul
-           case(15) ; ug=resul
-           case(16) ; vg=resul
-           case(17) ; du=resul
-           case(18) ; hu=resul
-           case(19) ; vu=resul
-           case(20) ; dv=resul
-           case(21) ; hv=resul
-           case(22) ; vv=resul
-           case(23) ; dt=resul
-           case(24) ; ht=resul
-           case(25) ; vt=resul
-           case(26) ; dq=resul
-           case(27) ; hq=resul
-           case(28) ; vq=resul
-           case(29) ; dth=resul
-           case(30) ; hth=resul
-           case(31) ; vth=resul
-           case(32) ; hthl=resul
-           case(33) ; dr=resul
-           case(34) ; hr=resul
-           case(35) ; vr=resul
-           case(36) ; dtrad=resul
-           case(37) ; q1=resul
-           case(38) ; q2=resul
-           case(39) ; uw=resul
-           case(40) ; vw=resul
-           case(41) ; rh=resul
-           case(42) ; zz=resul      ! donnees en time,nlevel pour profil initial
-           case(43) ; pp=resul
-           case(44) ; temp=resul
-           case(45) ; theta=resul
-           case(46) ; thv=resul
-           case(47) ; thl=resul
-           case(48) ; qv=resul
-           case(49) ; ql=resul
-           case(50) ; qi=resul
-           case(51) ; rv=resul
-           case(52) ; u=resul
-           case(53) ; v=resul
-           case(54) ; tke=resul
-           case(55) ; sens=resul2   ! donnees indexees en time
-           case(56) ; flat=resul2
-           case(57) ; ts=resul2
-           case(58) ; ps=resul2
-           case(59) ; ustar=resul2
-           case(60) ; orog_cas=resul3      ! constantes
-           case(61) ; albedo_cas=resul3
-           case(62) ; emiss_cas=resul3
-           case(63) ; t_skin_cas=resul3
-           case(64) ; q_skin_cas=resul3
-           case(65) ; mom_rough=resul3
-           case(66) ; heat_rough=resul3
-           case(67) ; o3_cas=resul3        
-           case(68) ; rugos_cas=resul3
-           case(69) ; clay_cas=resul3
-           case(70) ; sand_cas=resul3
-         end select
-         resul=0.
-         resul1=0.
-         resul2=0.
-         resul3=0.
-       enddo
-         print*,'Lecture de la variable APRES ,sens ',minval(sens),maxval(sens)
-         print*,'Lecture de la variable APRES ,flat ',minval(flat),maxval(flat)
-
-!CR:ATTENTION EN ATTENTE DE REGLER LA QUESTION DU PAS DE TEMPS INITIAL
-       do t=1,ntime
-          do k=1,nlevel
-             temp(k,t)=temp0(k)
-             qv(k,t)=qv0(k)
-             ql(k,t)=ql0(k)
-             qi(k,t)=qi0(k)
-             u(k,t)=u0(k)
-             v(k,t)=v0(k)
-             tke(k,t)=tke0(k)
-          enddo
-       enddo
-!-----------------------------------------------------------------------
-
-         return 
-         end subroutine old_read_SCM
+           print*,'Lecture de la variable #i ',i,name_var(i),resul3
+        endif
+     endif
+     !-----------------------------------------------------------------------
+     select case(i)
+        !case(1) ; ap=apbp       ! donnees indexees en nlevel+1
+        ! case(2) ; bp=apbp
+     case(3) ; zzh=apbp
+     case(4) ; pph=apbp
+     case(5) ; temp0=resul1    ! donnees initiales
+     case(6) ; qv0=resul1
+     case(7) ; ql0=resul1
+     case(8) ; qi0=resul1
+     case(9) ; u0=resul1
+     case(10) ; v0=resul1
+     case(11) ; tke0=resul1
+     case(12) ; pp0=resul1
+     case(13) ; vitw=resul    ! donnees indexees en nlevel,time
+     case(14) ; omega=resul
+     case(15) ; ug=resul
+     case(16) ; vg=resul
+     case(17) ; du=resul
+     case(18) ; hu=resul
+     case(19) ; vu=resul
+     case(20) ; dv=resul
+     case(21) ; hv=resul
+     case(22) ; vv=resul
+     case(23) ; dt=resul
+     case(24) ; ht=resul
+     case(25) ; vt=resul
+     case(26) ; dq=resul
+     case(27) ; hq=resul
+     case(28) ; vq=resul
+     case(29) ; dth=resul
+     case(30) ; hth=resul
+     case(31) ; vth=resul
+     case(32) ; hthl=resul
+     case(33) ; dr=resul
+     case(34) ; hr=resul
+     case(35) ; vr=resul
+     case(36) ; dtrad=resul
+     case(37) ; q1=resul
+     case(38) ; q2=resul
+     case(39) ; uw=resul
+     case(40) ; vw=resul
+     case(41) ; rh=resul
+     case(42) ; zz=resul      ! donnees en time,nlevel pour profil initial
+     case(43) ; pp=resul
+     case(44) ; temp=resul
+     case(45) ; theta=resul
+     case(46) ; thv=resul
+     case(47) ; thl=resul
+     case(48) ; qv=resul
+     case(49) ; ql=resul
+     case(50) ; qi=resul
+     case(51) ; rv=resul
+     case(52) ; u=resul
+     case(53) ; v=resul
+     case(54) ; tke=resul
+     case(55) ; sens=resul2   ! donnees indexees en time
+     case(56) ; flat=resul2
+     case(57) ; ts=resul2
+     case(58) ; ps=resul2
+     case(59) ; ustar=resul2
+     case(60) ; orog_cas=resul3      ! constantes
+     case(61) ; albedo_cas=resul3
+     case(62) ; emiss_cas=resul3
+     case(63) ; t_skin_cas=resul3
+     case(64) ; q_skin_cas=resul3
+     case(65) ; mom_rough=resul3
+     case(66) ; heat_rough=resul3
+     case(67) ; o3_cas=resul3        
+     case(68) ; rugos_cas=resul3
+     case(69) ; clay_cas=resul3
+     case(70) ; sand_cas=resul3
+     end select
+     resul=0.
+     resul1=0.
+     resul2=0.
+     resul3=0.
+  enddo
+  print*,'Lecture de la variable APRES ,sens ',minval(sens),maxval(sens)
+  print*,'Lecture de la variable APRES ,flat ',minval(flat),maxval(flat)
+
+  !CR:ATTENTION EN ATTENTE DE REGLER LA QUESTION DU PAS DE TEMPS INITIAL
+  do t=1,ntime
+     do k=1,nlevel
+        temp(k,t)=temp0(k)
+        qv(k,t)=qv0(k)
+        ql(k,t)=ql0(k)
+        qi(k,t)=qi0(k)
+        u(k,t)=u0(k)
+        v(k,t)=v0(k)
+        tke(k,t)=tke0(k)
+     enddo
+  enddo
+  !-----------------------------------------------------------------------
+
+  return 
+end subroutine old_read_SCM
 !======================================================================
 
 !======================================================================
-        SUBROUTINE interp_case_time2(day,day1,annee_ref                &
-!    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas      &
-     &         ,nt_cas,nlev_cas                                       &
-     &         ,ts_cas,ps_cas,plev_cas,t_cas,q_cas,u_cas,v_cas               &
-     &         ,ug_cas,vg_cas,vitw_cas,du_cas,hu_cas,vu_cas           &
-     &         ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas   &
-     &         ,dq_cas,hq_cas,vq_cas,lat_cas,sens_cas,ustar_cas       &
-     &         ,uw_cas,vw_cas,q1_cas,q2_cas                           &
-     &         ,ts_prof_cas,plev_prof_cas,t_prof_cas,q_prof_cas       &
-     &         ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas         &
-     &         ,vitw_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas     &
-     &         ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas       &
-     &         ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas    &
-     &         ,hq_prof_cas,vq_prof_cas,lat_prof_cas,sens_prof_cas    &
-     &         ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas)
-          
-
-        implicit none
-
-!---------------------------------------------------------------------------------------
-! Time interpolation of a 2D field to the timestep corresponding to day
-!
-! day: current julian day (e.g. 717538.2)
-! day1: first day of the simulation
-! nt_cas: total nb of data in the forcing 
-! pdt_cas: total time interval (in sec) between 2 forcing data
-!---------------------------------------------------------------------------------------
+SUBROUTINE interp_case_time2(day,day1,annee_ref                &
+     !    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas      &
+     ,nt_cas,nlev_cas                                       &
+     ,ts_cas,ps_cas,plev_cas,t_cas,q_cas,u_cas,v_cas               &
+     ,ug_cas,vg_cas,vitw_cas,du_cas,hu_cas,vu_cas           &
+     ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas   &
+     ,dq_cas,hq_cas,vq_cas,lat_cas,sens_cas,ustar_cas       &
+     ,uw_cas,vw_cas,q1_cas,q2_cas                           &
+     ,ts_prof_cas,plev_prof_cas,t_prof_cas,q_prof_cas       &
+     ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas         &
+     ,vitw_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas     &
+     ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas       &
+     ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas    &
+     ,hq_prof_cas,vq_prof_cas,lat_prof_cas,sens_prof_cas    &
+     ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas)
+
+
+  implicit none
+
+  !---------------------------------------------------------------------------------------
+  ! Time interpolation of a 2D field to the timestep corresponding to day
+  !
+  ! day: current julian day (e.g. 717538.2)
+  ! day1: first day of the simulation
+  ! nt_cas: total nb of data in the forcing 
+  ! pdt_cas: total time interval (in sec) between 2 forcing data
+  !---------------------------------------------------------------------------------------
 
 #include "compar1d.h"
 #include "date_cas.h"
 
-! inputs:
-        integer annee_ref
-        integer nt_cas,nlev_cas
-        real day, day1,day_cas
-        real ts_cas(nt_cas),ps_cas(nt_cas)
-        real plev_cas(nlev_cas,nt_cas)
-        real t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas)
-        real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
-        real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
-        real vitw_cas(nlev_cas,nt_cas)
-        real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
-        real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
-        real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
-        real dtrad_cas(nlev_cas,nt_cas)
-        real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
-        real lat_cas(nt_cas)
-        real sens_cas(nt_cas)
-        real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
-        real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
-
-! outputs:
-        real plev_prof_cas(nlev_cas)
-        real t_prof_cas(nlev_cas),q_prof_cas(nlev_cas)
-        real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
-        real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
-        real vitw_prof_cas(nlev_cas)
-        real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
-        real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
-        real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
-        real dtrad_prof_cas(nlev_cas)
-        real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
-        real lat_prof_cas,sens_prof_cas,ts_prof_cas,ustar_prof_cas
-        real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
-! local:
-        integer it_cas1, it_cas2,k
-        real timeit,time_cas1,time_cas2,frac
-
-
-        print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
-
-! On teste si la date du cas AMMA est correcte.
-! C est pour memoire car en fait les fichiers .def
-! sont censes etre corrects.
-! A supprimer a terme (MPL 20150623)
-!     if ((forcing_type.eq.10).and.(1.eq.0)) then
-! Check that initial day of the simulation consistent with AMMA case:
-!      if (annee_ref.ne.2006) then
-!       print*,'Pour AMMA, annee_ref doit etre 2006'
-!       print*,'Changer annee_ref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
-!       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
-!       print*,'Changer dayref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
-!       print*,'AMMA a fini le 11 juillet'
-!       print*,'Changer dayref ou nday dans run.def'
-!       stop
-!      endif
-!      endif
-
-! Determine timestep relative to the 1st day:
-!       timeit=(day-day1)*86400.
-!       if (annee_ref.eq.1992) then
-!        timeit=(day-day_cas)*86400.
-!       else
-!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
-!       endif
-      timeit=(day-day_ju_ini_cas)*86400
-      print *,'day=',day
-      print *,'day_ju_ini_cas=',day_ju_ini_cas
-      print *,'pdt_cas=',pdt_cas
-      print *,'timeit=',timeit
-      print *,'nt_cas=',nt_cas
-
-! Determine the closest observation times:
-!       it_cas1=INT(timeit/pdt_cas)+1
-!       it_cas2=it_cas1 + 1
-!       time_cas1=(it_cas1-1)*pdt_cas
-!       time_cas2=(it_cas2-1)*pdt_cas
-
-       it_cas1=INT(timeit/pdt_cas)+1
-       IF (it_cas1 .EQ. nt_cas) THEN
-       it_cas2=it_cas1 
-       ELSE
-       it_cas2=it_cas1 + 1
-       ENDIF
-       time_cas1=(it_cas1-1)*pdt_cas
-       time_cas2=(it_cas2-1)*pdt_cas
-       print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
-
-       if (it_cas1 .gt. nt_cas) then
-        write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
-     &        ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
-        stop
-       endif
-
-! time interpolation:
-       IF (it_cas1 .EQ. it_cas2) THEN
-          frac=0.
-       ELSE
-          frac=(time_cas2-timeit)/(time_cas2-time_cas1)
-          frac=max(frac,0.0)
-       ENDIF
-
-       lat_prof_cas = lat_cas(it_cas2)                                       &
-     &          -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
-       sens_prof_cas = sens_cas(it_cas2)                                     &
-     &          -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
-       ts_prof_cas = ts_cas(it_cas2)                                         &
-     &          -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
-       ustar_prof_cas = ustar_cas(it_cas2)                                   &
-     &          -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
-
-       do k=1,nlev_cas
-        plev_prof_cas(k) = plev_cas(k,it_cas2)                               &
-     &          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
-        t_prof_cas(k) = t_cas(k,it_cas2)                               &
-     &          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
-        q_prof_cas(k) = q_cas(k,it_cas2)                               &
-     &          -frac*(q_cas(k,it_cas2)-q_cas(k,it_cas1))
-        u_prof_cas(k) = u_cas(k,it_cas2)                               &
-     &          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
-        v_prof_cas(k) = v_cas(k,it_cas2)                               &
-     &          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
-        ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
-     &          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
-        vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
-     &          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
-        vitw_prof_cas(k) = vitw_cas(k,it_cas2)                               &
-     &          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
-        du_prof_cas(k) = du_cas(k,it_cas2)                                   &
-     &          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
-        hu_prof_cas(k) = hu_cas(k,it_cas2)                                   &
-     &          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
-        vu_prof_cas(k) = vu_cas(k,it_cas2)                                   &
-     &          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
-        dv_prof_cas(k) = dv_cas(k,it_cas2)                                   &
-     &          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
-        hv_prof_cas(k) = hv_cas(k,it_cas2)                                   &
-     &          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
-        vv_prof_cas(k) = vv_cas(k,it_cas2)                                   &
-     &          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
-        dt_prof_cas(k) = dt_cas(k,it_cas2)                                   &
-     &          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
-        ht_prof_cas(k) = ht_cas(k,it_cas2)                                   &
-     &          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
-        vt_prof_cas(k) = vt_cas(k,it_cas2)                                   &
-     &          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
-        dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                                   &
-     &          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
-        dq_prof_cas(k) = dq_cas(k,it_cas2)                                   &
-     &          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
-        hq_prof_cas(k) = hq_cas(k,it_cas2)                                   &
-     &          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
-        vq_prof_cas(k) = vq_cas(k,it_cas2)                                   &
-     &          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
-       uw_prof_cas(k) = uw_cas(k,it_cas2)                                   &
-     &          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
-       vw_prof_cas(k) = vw_cas(k,it_cas2)                                   &
-     &          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
-       q1_prof_cas(k) = q1_cas(k,it_cas2)                                   &
-     &          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
-       q2_prof_cas(k) = q2_cas(k,it_cas2)                                   &
-     &          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
-        enddo
-
-        return
-        END SUBROUTINE interp_case_time2
+  ! inputs:
+  integer annee_ref
+  integer nt_cas,nlev_cas
+  real day, day1,day_cas
+  real ts_cas(nt_cas),ps_cas(nt_cas)
+  real plev_cas(nlev_cas,nt_cas)
+  real t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas)
+  real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
+  real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
+  real vitw_cas(nlev_cas,nt_cas)
+  real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
+  real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
+  real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
+  real dtrad_cas(nlev_cas,nt_cas)
+  real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
+  real lat_cas(nt_cas)
+  real sens_cas(nt_cas)
+  real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
+  real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
+
+  ! outputs:
+  real plev_prof_cas(nlev_cas)
+  real t_prof_cas(nlev_cas),q_prof_cas(nlev_cas)
+  real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
+  real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
+  real vitw_prof_cas(nlev_cas)
+  real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
+  real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
+  real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
+  real dtrad_prof_cas(nlev_cas)
+  real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
+  real lat_prof_cas,sens_prof_cas,ts_prof_cas,ustar_prof_cas
+  real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
+  ! local:
+  integer it_cas1, it_cas2,k
+  real timeit,time_cas1,time_cas2,frac
+
+
+  print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
+
+  ! On teste si la date du cas AMMA est correcte.
+  ! C est pour memoire car en fait les fichiers .def
+  ! sont censes etre corrects.
+  ! A supprimer a terme (MPL 20150623)
+  !     if ((forcing_type.eq.10).and.(1.eq.0)) then
+  ! Check that initial day of the simulation consistent with AMMA case:
+  !      if (annee_ref.ne.2006) then
+  !       print*,'Pour AMMA, annee_ref doit etre 2006'
+  !       print*,'Changer annee_ref dans run.def'
+  !       stop
+  !      endif
+  !      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
+  !       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
+  !       print*,'Changer dayref dans run.def'
+  !       stop
+  !      endif
+  !      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
+  !       print*,'AMMA a fini le 11 juillet'
+  !       print*,'Changer dayref ou nday dans run.def'
+  !       stop
+  !      endif
+  !      endif
+
+  ! Determine timestep relative to the 1st day:
+  !       timeit=(day-day1)*86400.
+  !       if (annee_ref.eq.1992) then
+  !        timeit=(day-day_cas)*86400.
+  !       else
+  !        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+  !       endif
+  timeit=(day-day_ju_ini_cas)*86400
+  print *,'day=',day
+  print *,'day_ju_ini_cas=',day_ju_ini_cas
+  print *,'pdt_cas=',pdt_cas
+  print *,'timeit=',timeit
+  print *,'nt_cas=',nt_cas
+
+  ! Determine the closest observation times:
+  !       it_cas1=INT(timeit/pdt_cas)+1
+  !       it_cas2=it_cas1 + 1
+  !       time_cas1=(it_cas1-1)*pdt_cas
+  !       time_cas2=(it_cas2-1)*pdt_cas
+
+  it_cas1=INT(timeit/pdt_cas)+1
+  IF (it_cas1 .EQ. nt_cas) THEN
+     it_cas2=it_cas1 
+  ELSE
+     it_cas2=it_cas1 + 1
+  ENDIF
+  time_cas1=(it_cas1-1)*pdt_cas
+  time_cas2=(it_cas2-1)*pdt_cas
+  print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
+
+  if (it_cas1 .gt. nt_cas) then
+     write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
+          ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
+     stop
+  endif
+
+  ! time interpolation:
+  IF (it_cas1 .EQ. it_cas2) THEN
+     frac=0.
+  ELSE
+     frac=(time_cas2-timeit)/(time_cas2-time_cas1)
+     frac=max(frac,0.0)
+  ENDIF
+
+  lat_prof_cas = lat_cas(it_cas2)                                       &
+       -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
+  sens_prof_cas = sens_cas(it_cas2)                                     &
+       -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
+  ts_prof_cas = ts_cas(it_cas2)                                         &
+       -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
+  ustar_prof_cas = ustar_cas(it_cas2)                                   &
+       -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
+
+  do k=1,nlev_cas
+     plev_prof_cas(k) = plev_cas(k,it_cas2)                               &
+          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
+     t_prof_cas(k) = t_cas(k,it_cas2)                               &
+          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
+     q_prof_cas(k) = q_cas(k,it_cas2)                               &
+          -frac*(q_cas(k,it_cas2)-q_cas(k,it_cas1))
+     u_prof_cas(k) = u_cas(k,it_cas2)                               &
+          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
+     v_prof_cas(k) = v_cas(k,it_cas2)                               &
+          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
+     ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
+          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
+     vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
+          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
+     vitw_prof_cas(k) = vitw_cas(k,it_cas2)                               &
+          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
+     du_prof_cas(k) = du_cas(k,it_cas2)                                   &
+          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
+     hu_prof_cas(k) = hu_cas(k,it_cas2)                                   &
+          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
+     vu_prof_cas(k) = vu_cas(k,it_cas2)                                   &
+          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
+     dv_prof_cas(k) = dv_cas(k,it_cas2)                                   &
+          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
+     hv_prof_cas(k) = hv_cas(k,it_cas2)                                   &
+          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
+     vv_prof_cas(k) = vv_cas(k,it_cas2)                                   &
+          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
+     dt_prof_cas(k) = dt_cas(k,it_cas2)                                   &
+          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
+     ht_prof_cas(k) = ht_cas(k,it_cas2)                                   &
+          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
+     vt_prof_cas(k) = vt_cas(k,it_cas2)                                   &
+          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
+     dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                                   &
+          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
+     dq_prof_cas(k) = dq_cas(k,it_cas2)                                   &
+          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
+     hq_prof_cas(k) = hq_cas(k,it_cas2)                                   &
+          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
+     vq_prof_cas(k) = vq_cas(k,it_cas2)                                   &
+          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
+     uw_prof_cas(k) = uw_cas(k,it_cas2)                                   &
+          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
+     vw_prof_cas(k) = vw_cas(k,it_cas2)                                   &
+          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
+     q1_prof_cas(k) = q1_cas(k,it_cas2)                                   &
+          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
+     q2_prof_cas(k) = q2_cas(k,it_cas2)                                   &
+          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
+  enddo
+
+  return
+END SUBROUTINE interp_case_time2
 
 !**********************************************************************************************
-        SUBROUTINE interp2_case_time(day,day1,annee_ref                           &
-!    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas                         &
-     &         ,nt_cas,nlev_cas                                                   &
-     &         ,ts_cas,ps_cas,plev_cas,t_cas,theta_cas,thv_cas,thl_cas            &
-     &         ,qv_cas,ql_cas,qi_cas,u_cas,v_cas                                  &
-     &         ,ug_cas,vg_cas,vitw_cas,omega_cas,du_cas,hu_cas,vu_cas             &
-     &         ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas               &
-     &         ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas                      &
-     &         ,lat_cas,sens_cas,ustar_cas                                        &
-     &         ,uw_cas,vw_cas,q1_cas,q2_cas,tke_cas                               &
-!
-     &         ,ts_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas               &
-     &         ,thv_prof_cas,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas     &
-     &         ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                     &
-     &         ,vitw_prof_cas,omega_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas  &
-     &         ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas                   &
-     &         ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas                &
-     &         ,hq_prof_cas,vq_prof_cas,dth_prof_cas,hth_prof_cas,vth_prof_cas    &
-     &         ,lat_prof_cas,sens_prof_cas                                        &
-     &         ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tke_prof_cas)
-          
-
-        implicit none
-
-!---------------------------------------------------------------------------------------
-! Time interpolation of a 2D field to the timestep corresponding to day
-!
-! day: current julian day (e.g. 717538.2)
-! day1: first day of the simulation
-! nt_cas: total nb of data in the forcing 
-! pdt_cas: total time interval (in sec) between 2 forcing data
-!---------------------------------------------------------------------------------------
+SUBROUTINE interp2_case_time(day,day1,annee_ref                           &
+     !    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas                         &
+     ,nt_cas,nlev_cas                                                   &
+     ,ts_cas,ps_cas,plev_cas,t_cas,theta_cas,thv_cas,thl_cas            &
+     ,qv_cas,ql_cas,qi_cas,u_cas,v_cas                                  &
+     ,ug_cas,vg_cas,vitw_cas,omega_cas,du_cas,hu_cas,vu_cas             &
+     ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas               &
+     ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas                      &
+     ,lat_cas,sens_cas,ustar_cas                                        &
+     ,uw_cas,vw_cas,q1_cas,q2_cas,tke_cas                               &
+     !
+     ,ts_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas               &
+     ,thv_prof_cas,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas     &
+     ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                     &
+     ,vitw_prof_cas,omega_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas  &
+     ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas                   &
+     ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas                &
+     ,hq_prof_cas,vq_prof_cas,dth_prof_cas,hth_prof_cas,vth_prof_cas    &
+     ,lat_prof_cas,sens_prof_cas                                        &
+     ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tke_prof_cas)
+
+
+  implicit none
+
+  !---------------------------------------------------------------------------------------
+  ! Time interpolation of a 2D field to the timestep corresponding to day
+  !
+  ! day: current julian day (e.g. 717538.2)
+  ! day1: first day of the simulation
+  ! nt_cas: total nb of data in the forcing 
+  ! pdt_cas: total time interval (in sec) between 2 forcing data
+  !---------------------------------------------------------------------------------------
 
 #include "compar1d.h"
 #include "date_cas.h"
 
-! inputs:
-        integer annee_ref
-        integer nt_cas,nlev_cas
-        real day, day1,day_cas
-        real ts_cas(nt_cas),ps_cas(nt_cas)
-        real plev_cas(nlev_cas,nt_cas)
-        real t_cas(nlev_cas,nt_cas),theta_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas)
-        real qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas),qi_cas(nlev_cas,nt_cas)
-        real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
-        real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
-        real vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas)
-        real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
-        real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
-        real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
-        real dth_cas(nlev_cas,nt_cas),hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas)
-        real dtrad_cas(nlev_cas,nt_cas)
-        real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
-        real lat_cas(nt_cas),sens_cas(nt_cas),tke_cas(nt_cas)
-        real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
-        real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
-
-! outputs:
-        real plev_prof_cas(nlev_cas)
-        real t_prof_cas(nlev_cas),theta_prof_cas(nlev_cas),thl_prof_cas(nlev_cas),thv_prof_cas(nlev_cas)
-        real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
-        real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
-        real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
-        real vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas)
-        real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
-        real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
-        real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
-        real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
-        real dtrad_prof_cas(nlev_cas)
-        real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
-        real lat_prof_cas,sens_prof_cas,tke_prof_cas,ts_prof_cas,ustar_prof_cas
-        real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
-! local:
-        integer it_cas1, it_cas2,k
-        real timeit,time_cas1,time_cas2,frac
-
-
-        print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
-!       do k=1,nlev_cas
-!       print*,'debut de interp2_case_time, plev_cas=',k,plev_cas(k,1)
-!       enddo
-
-! On teste si la date du cas AMMA est correcte.
-! C est pour memoire car en fait les fichiers .def
-! sont censes etre corrects.
-! A supprimer a terme (MPL 20150623)
-!     if ((forcing_type.eq.10).and.(1.eq.0)) then
-! Check that initial day of the simulation consistent with AMMA case:
-!      if (annee_ref.ne.2006) then
-!       print*,'Pour AMMA, annee_ref doit etre 2006'
-!       print*,'Changer annee_ref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
-!       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
-!       print*,'Changer dayref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
-!       print*,'AMMA a fini le 11 juillet'
-!       print*,'Changer dayref ou nday dans run.def'
-!       stop
-!      endif
-!      endif
-
-! Determine timestep relative to the 1st day:
-!       timeit=(day-day1)*86400.
-!       if (annee_ref.eq.1992) then
-!        timeit=(day-day_cas)*86400.
-!       else
-!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
-!       endif
-      timeit=(day-day_ju_ini_cas)*86400
-      print *,'day=',day
-      print *,'day_ju_ini_cas=',day_ju_ini_cas
-      print *,'pdt_cas=',pdt_cas
-      print *,'timeit=',timeit
-      print *,'nt_cas=',nt_cas
-
-! Determine the closest observation times:
-!       it_cas1=INT(timeit/pdt_cas)+1
-!       it_cas2=it_cas1 + 1
-!       time_cas1=(it_cas1-1)*pdt_cas
-!       time_cas2=(it_cas2-1)*pdt_cas
-
-       it_cas1=INT(timeit/pdt_cas)+1
-       IF (it_cas1 .EQ. nt_cas) THEN
-       it_cas2=it_cas1 
-       ELSE
-       it_cas2=it_cas1 + 1
-       ENDIF
-       time_cas1=(it_cas1-1)*pdt_cas
-       time_cas2=(it_cas2-1)*pdt_cas
-      print *,'timeit,pdt_cas,nt_cas=',timeit,pdt_cas,nt_cas
-      print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
-
-       if (it_cas1 .gt. nt_cas) then 
-        write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
-     &        ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
-        stop
-       endif
-
-! time interpolation:
-       IF (it_cas1 .EQ. it_cas2) THEN
-          frac=0.
-       ELSE
-          frac=(time_cas2-timeit)/(time_cas2-time_cas1)
-          frac=max(frac,0.0)
-       ENDIF
-
-       lat_prof_cas = lat_cas(it_cas2)                                   &
-     &          -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
-       sens_prof_cas = sens_cas(it_cas2)                                 &
-     &          -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
-       tke_prof_cas = tke_cas(it_cas2)                                   &
-     &          -frac*(tke_cas(it_cas2)-tke_cas(it_cas1))
-       ts_prof_cas = ts_cas(it_cas2)                                     &
-     &          -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
-       ustar_prof_cas = ustar_cas(it_cas2)                               &
-     &          -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
-
-       do k=1,nlev_cas
-        plev_prof_cas(k) = plev_cas(k,it_cas2)                           &     
-     &          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
-        t_prof_cas(k) = t_cas(k,it_cas2)                                 &        
-     &          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
-        print *,'k,frac,plev_cas1,plev_cas2=',k,frac,plev_cas(k,it_cas1),plev_cas(k,it_cas2)
-        theta_prof_cas(k) = theta_cas(k,it_cas2)                         &                      
-     &          -frac*(theta_cas(k,it_cas2)-theta_cas(k,it_cas1))
-        thv_prof_cas(k) = thv_cas(k,it_cas2)                             &          
-     &          -frac*(thv_cas(k,it_cas2)-thv_cas(k,it_cas1))
-        thl_prof_cas(k) = thl_cas(k,it_cas2)                             &              
-     &          -frac*(thl_cas(k,it_cas2)-thl_cas(k,it_cas1))
-        qv_prof_cas(k) = qv_cas(k,it_cas2)                               &
-     &          -frac*(qv_cas(k,it_cas2)-qv_cas(k,it_cas1))
-        ql_prof_cas(k) = ql_cas(k,it_cas2)                               &
-     &          -frac*(ql_cas(k,it_cas2)-ql_cas(k,it_cas1))
-        qi_prof_cas(k) = qi_cas(k,it_cas2)                               &
-     &          -frac*(qi_cas(k,it_cas2)-qi_cas(k,it_cas1))
-        u_prof_cas(k) = u_cas(k,it_cas2)                                 &
-     &          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
-        v_prof_cas(k) = v_cas(k,it_cas2)                                 &
-     &          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
-        ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
-     &          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
-        vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
-     &          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
-        vitw_prof_cas(k) = vitw_cas(k,it_cas2)                           &
-     &          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
-        omega_prof_cas(k) = omega_cas(k,it_cas2)                         &
-     &          -frac*(omega_cas(k,it_cas2)-omega_cas(k,it_cas1))
-        du_prof_cas(k) = du_cas(k,it_cas2)                               &
-     &          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
-        hu_prof_cas(k) = hu_cas(k,it_cas2)                               &
-     &          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
-        vu_prof_cas(k) = vu_cas(k,it_cas2)                               &
-     &          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
-        dv_prof_cas(k) = dv_cas(k,it_cas2)                               &
-     &          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
-        hv_prof_cas(k) = hv_cas(k,it_cas2)                               &
-     &          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
-        vv_prof_cas(k) = vv_cas(k,it_cas2)                               &
-     &          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
-        dt_prof_cas(k) = dt_cas(k,it_cas2)                               &
-     &          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
-        ht_prof_cas(k) = ht_cas(k,it_cas2)                               &
-     &          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
-        vt_prof_cas(k) = vt_cas(k,it_cas2)                               &
-     &          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
-        dth_prof_cas(k) = dth_cas(k,it_cas2)                             &
-     &          -frac*(dth_cas(k,it_cas2)-dth_cas(k,it_cas1))
-        hth_prof_cas(k) = hth_cas(k,it_cas2)                             &
-     &          -frac*(hth_cas(k,it_cas2)-hth_cas(k,it_cas1))
-        vth_prof_cas(k) = vth_cas(k,it_cas2)                             &
-     &          -frac*(vth_cas(k,it_cas2)-vth_cas(k,it_cas1))
-        dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                         &
-     &          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
-        dq_prof_cas(k) = dq_cas(k,it_cas2)                               &
-     &          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
-        hq_prof_cas(k) = hq_cas(k,it_cas2)                               &
-     &          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
-        vq_prof_cas(k) = vq_cas(k,it_cas2)                               &
-     &          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
-       uw_prof_cas(k) = uw_cas(k,it_cas2)                                &
-     &          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
-       vw_prof_cas(k) = vw_cas(k,it_cas2)                                &
-     &          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
-       q1_prof_cas(k) = q1_cas(k,it_cas2)                                &
-     &          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
-       q2_prof_cas(k) = q2_cas(k,it_cas2)                                &
-     &          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
-        enddo
-
-        return
-        END SUBROUTINE interp2_case_time
+  ! inputs:
+  integer annee_ref
+  integer nt_cas,nlev_cas
+  real day, day1,day_cas
+  real ts_cas(nt_cas),ps_cas(nt_cas)
+  real plev_cas(nlev_cas,nt_cas)
+  real t_cas(nlev_cas,nt_cas),theta_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas)
+  real qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas),qi_cas(nlev_cas,nt_cas)
+  real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
+  real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
+  real vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas)
+  real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
+  real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
+  real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
+  real dth_cas(nlev_cas,nt_cas),hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas)
+  real dtrad_cas(nlev_cas,nt_cas)
+  real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
+  real lat_cas(nt_cas),sens_cas(nt_cas),tke_cas(nt_cas)
+  real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
+  real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
+
+  ! outputs:
+  real plev_prof_cas(nlev_cas)
+  real t_prof_cas(nlev_cas),theta_prof_cas(nlev_cas),thl_prof_cas(nlev_cas),thv_prof_cas(nlev_cas)
+  real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
+  real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
+  real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
+  real vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas)
+  real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
+  real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
+  real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
+  real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
+  real dtrad_prof_cas(nlev_cas)
+  real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
+  real lat_prof_cas,sens_prof_cas,tke_prof_cas,ts_prof_cas,ustar_prof_cas
+  real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
+  ! local:
+  integer it_cas1, it_cas2,k
+  real timeit,time_cas1,time_cas2,frac
+
+
+  print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
+  !       do k=1,nlev_cas
+  !       print*,'debut de interp2_case_time, plev_cas=',k,plev_cas(k,1)
+  !       enddo
+
+  ! On teste si la date du cas AMMA est correcte.
+  ! C est pour memoire car en fait les fichiers .def
+  ! sont censes etre corrects.
+  ! A supprimer a terme (MPL 20150623)
+  !     if ((forcing_type.eq.10).and.(1.eq.0)) then
+  ! Check that initial day of the simulation consistent with AMMA case:
+  !      if (annee_ref.ne.2006) then
+  !       print*,'Pour AMMA, annee_ref doit etre 2006'
+  !       print*,'Changer annee_ref dans run.def'
+  !       stop
+  !      endif
+  !      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
+  !       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
+  !       print*,'Changer dayref dans run.def'
+  !       stop
+  !      endif
+  !      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
+  !       print*,'AMMA a fini le 11 juillet'
+  !       print*,'Changer dayref ou nday dans run.def'
+  !       stop
+  !      endif
+  !      endif
+
+  ! Determine timestep relative to the 1st day:
+  !       timeit=(day-day1)*86400.
+  !       if (annee_ref.eq.1992) then
+  !        timeit=(day-day_cas)*86400.
+  !       else
+  !        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+  !       endif
+  timeit=(day-day_ju_ini_cas)*86400
+  print *,'day=',day
+  print *,'day_ju_ini_cas=',day_ju_ini_cas
+  print *,'pdt_cas=',pdt_cas
+  print *,'timeit=',timeit
+  print *,'nt_cas=',nt_cas
+
+  ! Determine the closest observation times:
+  !       it_cas1=INT(timeit/pdt_cas)+1
+  !       it_cas2=it_cas1 + 1
+  !       time_cas1=(it_cas1-1)*pdt_cas
+  !       time_cas2=(it_cas2-1)*pdt_cas
+
+  it_cas1=INT(timeit/pdt_cas)+1
+  IF (it_cas1 .EQ. nt_cas) THEN
+     it_cas2=it_cas1 
+  ELSE
+     it_cas2=it_cas1 + 1
+  ENDIF
+  time_cas1=(it_cas1-1)*pdt_cas
+  time_cas2=(it_cas2-1)*pdt_cas
+  print *,'timeit,pdt_cas,nt_cas=',timeit,pdt_cas,nt_cas
+  print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
+
+  if (it_cas1 .gt. nt_cas) then 
+     write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
+          ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
+     stop
+  endif
+
+  ! time interpolation:
+  IF (it_cas1 .EQ. it_cas2) THEN
+     frac=0.
+  ELSE
+     frac=(time_cas2-timeit)/(time_cas2-time_cas1)
+     frac=max(frac,0.0)
+  ENDIF
+
+  lat_prof_cas = lat_cas(it_cas2)                                   &
+       -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
+  sens_prof_cas = sens_cas(it_cas2)                                 &
+       -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
+  tke_prof_cas = tke_cas(it_cas2)                                   &
+       -frac*(tke_cas(it_cas2)-tke_cas(it_cas1))
+  ts_prof_cas = ts_cas(it_cas2)                                     &
+       -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
+  ustar_prof_cas = ustar_cas(it_cas2)                               &
+       -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
+
+  do k=1,nlev_cas
+     plev_prof_cas(k) = plev_cas(k,it_cas2)                           &     
+          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
+     t_prof_cas(k) = t_cas(k,it_cas2)                                 &        
+          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
+     print *,'k,frac,plev_cas1,plev_cas2=',k,frac,plev_cas(k,it_cas1),plev_cas(k,it_cas2)
+     theta_prof_cas(k) = theta_cas(k,it_cas2)                         &                      
+          -frac*(theta_cas(k,it_cas2)-theta_cas(k,it_cas1))
+     thv_prof_cas(k) = thv_cas(k,it_cas2)                             &          
+          -frac*(thv_cas(k,it_cas2)-thv_cas(k,it_cas1))
+     thl_prof_cas(k) = thl_cas(k,it_cas2)                             &              
+          -frac*(thl_cas(k,it_cas2)-thl_cas(k,it_cas1))
+     qv_prof_cas(k) = qv_cas(k,it_cas2)                               &
+          -frac*(qv_cas(k,it_cas2)-qv_cas(k,it_cas1))
+     ql_prof_cas(k) = ql_cas(k,it_cas2)                               &
+          -frac*(ql_cas(k,it_cas2)-ql_cas(k,it_cas1))
+     qi_prof_cas(k) = qi_cas(k,it_cas2)                               &
+          -frac*(qi_cas(k,it_cas2)-qi_cas(k,it_cas1))
+     u_prof_cas(k) = u_cas(k,it_cas2)                                 &
+          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
+     v_prof_cas(k) = v_cas(k,it_cas2)                                 &
+          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
+     ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
+          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
+     vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
+          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
+     vitw_prof_cas(k) = vitw_cas(k,it_cas2)                           &
+          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
+     omega_prof_cas(k) = omega_cas(k,it_cas2)                         &
+          -frac*(omega_cas(k,it_cas2)-omega_cas(k,it_cas1))
+     du_prof_cas(k) = du_cas(k,it_cas2)                               &
+          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
+     hu_prof_cas(k) = hu_cas(k,it_cas2)                               &
+          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
+     vu_prof_cas(k) = vu_cas(k,it_cas2)                               &
+          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
+     dv_prof_cas(k) = dv_cas(k,it_cas2)                               &
+          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
+     hv_prof_cas(k) = hv_cas(k,it_cas2)                               &
+          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
+     vv_prof_cas(k) = vv_cas(k,it_cas2)                               &
+          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
+     dt_prof_cas(k) = dt_cas(k,it_cas2)                               &
+          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
+     ht_prof_cas(k) = ht_cas(k,it_cas2)                               &
+          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
+     vt_prof_cas(k) = vt_cas(k,it_cas2)                               &
+          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
+     dth_prof_cas(k) = dth_cas(k,it_cas2)                             &
+          -frac*(dth_cas(k,it_cas2)-dth_cas(k,it_cas1))
+     hth_prof_cas(k) = hth_cas(k,it_cas2)                             &
+          -frac*(hth_cas(k,it_cas2)-hth_cas(k,it_cas1))
+     vth_prof_cas(k) = vth_cas(k,it_cas2)                             &
+          -frac*(vth_cas(k,it_cas2)-vth_cas(k,it_cas1))
+     dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                         &
+          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
+     dq_prof_cas(k) = dq_cas(k,it_cas2)                               &
+          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
+     hq_prof_cas(k) = hq_cas(k,it_cas2)                               &
+          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
+     vq_prof_cas(k) = vq_cas(k,it_cas2)                               &
+          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
+     uw_prof_cas(k) = uw_cas(k,it_cas2)                                &
+          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
+     vw_prof_cas(k) = vw_cas(k,it_cas2)                                &
+          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
+     q1_prof_cas(k) = q1_cas(k,it_cas2)                                &
+          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
+     q2_prof_cas(k) = q2_cas(k,it_cas2)                                &
+          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
+  enddo
+
+  return
+END SUBROUTINE interp2_case_time
 
 !**********************************************************************************************
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/mod_1D_cases_read_std.F90
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/mod_1D_cases_read_std.F90	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/mod_1D_cases_read_std.F90	(revision 4368)
@@ -5,76 +5,79 @@
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!Declarations specifiques au cas standard
-        character*80 :: fich_cas
-! Discr?tisation 
-        integer nlev_cas, nt_cas
-
-
-!profils environnementaux
-        real, allocatable::  plev_cas(:,:),plevh_cas(:)
-        real, allocatable::  ap_cas(:),bp_cas(:)
-
-        real, allocatable::  z_cas(:,:),zh_cas(:)
-        real, allocatable::  t_cas(:,:),q_cas(:,:),qv_cas(:,:),ql_cas(:,:),qi_cas(:,:),rh_cas(:,:)
-        real, allocatable::  th_cas(:,:),thv_cas(:,:),thl_cas(:,:),rv_cas(:,:)
-        real, allocatable::  u_cas(:,:),v_cas(:,:),vitw_cas(:,:),omega_cas(:,:),tke_cas(:,:)
-
-!forcing
-        real, allocatable::  ht_cas(:,:),vt_cas(:,:),dt_cas(:,:),dtrad_cas(:,:)
-        real, allocatable::  hth_cas(:,:),vth_cas(:,:),dth_cas(:,:)
-        real, allocatable::  hq_cas(:,:),vq_cas(:,:),dq_cas(:,:)
-        real, allocatable::  hr_cas(:,:),vr_cas(:,:),dr_cas(:,:)
-        real, allocatable::  hu_cas(:,:),vu_cas(:,:),du_cas(:,:)
-        real, allocatable::  hv_cas(:,:),vv_cas(:,:),dv_cas(:,:)
-        real, allocatable::  ug_cas(:,:),vg_cas(:,:)
-        real, allocatable::  temp_nudg_cas(:,:),qv_nudg_cas(:,:),u_nudg_cas(:,:),v_nudg_cas(:,:)
-        real, allocatable::  lat_cas(:),sens_cas(:),ts_cas(:),ps_cas(:),ustar_cas(:)
-        real, allocatable::  uw_cas(:,:),vw_cas(:,:),q1_cas(:,:),q2_cas(:,:),tkes_cas(:)
-
-!champs interpoles
-        real, allocatable::  plev_prof_cas(:)
-        real, allocatable::  t_prof_cas(:)
-        real, allocatable::  theta_prof_cas(:)
-        real, allocatable::  thl_prof_cas(:)
-        real, allocatable::  thv_prof_cas(:)
-        real, allocatable::  q_prof_cas(:)
-        real, allocatable::  qv_prof_cas(:)
-        real, allocatable::  ql_prof_cas(:)
-        real, allocatable::  qi_prof_cas(:)
-        real, allocatable::  rh_prof_cas(:)
-        real, allocatable::  rv_prof_cas(:)
-        real, allocatable::  u_prof_cas(:)
-        real, allocatable::  v_prof_cas(:)        
-        real, allocatable::  vitw_prof_cas(:)
-        real, allocatable::  omega_prof_cas(:)
-        real, allocatable::  tke_prof_cas(:)
-        real, allocatable::  ug_prof_cas(:)
-        real, allocatable::  vg_prof_cas(:)
-        real, allocatable::  temp_nudg_prof_cas(:),qv_nudg_prof_cas(:),u_nudg_prof_cas(:),v_nudg_prof_cas(:)
-        real, allocatable::  ht_prof_cas(:)
-        real, allocatable::  hth_prof_cas(:)
-        real, allocatable::  hq_prof_cas(:)
-        real, allocatable::  vt_prof_cas(:)
-        real, allocatable::  vth_prof_cas(:)
-        real, allocatable::  vq_prof_cas(:)
-        real, allocatable::  dt_prof_cas(:)
-        real, allocatable::  dth_prof_cas(:)
-        real, allocatable::  dtrad_prof_cas(:)
-        real, allocatable::  dq_prof_cas(:)
-        real, allocatable::  hu_prof_cas(:)
-        real, allocatable::  hv_prof_cas(:)
-        real, allocatable::  vu_prof_cas(:)
-        real, allocatable::  vv_prof_cas(:)
-        real, allocatable::  du_prof_cas(:)
-        real, allocatable::  dv_prof_cas(:)
-        real, allocatable::  uw_prof_cas(:)
-        real, allocatable::  vw_prof_cas(:)
-        real, allocatable::  q1_prof_cas(:)
-        real, allocatable::  q2_prof_cas(:)
-
-
-        real lat_prof_cas,sens_prof_cas,ts_prof_cas,ps_prof_cas,ustar_prof_cas,tkes_prof_cas
-        real o3_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,rugos_cas,sand_cas,clay_cas
-      
+  !Declarations specifiques au cas standard
+  character*80 :: fich_cas
+  ! Discr?tisation 
+  integer nlev_cas, nt_cas
+
+
+  !profils environnementaux
+  real, allocatable::  plev_cas(:,:),plevh_cas(:)
+  real, allocatable::  ap_cas(:),bp_cas(:)
+
+  real, allocatable::  z_cas(:,:),zh_cas(:)
+  real, allocatable::  t_cas(:,:),q_cas(:,:),qv_cas(:,:),ql_cas(:,:),qi_cas(:,:),rh_cas(:,:)
+  real, allocatable::  th_cas(:,:),thv_cas(:,:),thl_cas(:,:),rv_cas(:,:)
+  real, allocatable::  u_cas(:,:),v_cas(:,:),vitw_cas(:,:),omega_cas(:,:),tke_cas(:,:)
+
+  !forcing
+  real, allocatable::  ht_cas(:,:),vt_cas(:,:),dt_cas(:,:),dtrad_cas(:,:)
+  real, allocatable::  hth_cas(:,:),vth_cas(:,:),dth_cas(:,:)
+  real, allocatable::  hq_cas(:,:),vq_cas(:,:),dq_cas(:,:)
+  real, allocatable::  hr_cas(:,:),vr_cas(:,:),dr_cas(:,:)
+  real, allocatable::  hu_cas(:,:),vu_cas(:,:),du_cas(:,:)
+  real, allocatable::  hv_cas(:,:),vv_cas(:,:),dv_cas(:,:)
+  real, allocatable::  ug_cas(:,:),vg_cas(:,:)
+  real, allocatable::  temp_nudg_cas(:,:),qv_nudg_cas(:,:),u_nudg_cas(:,:),v_nudg_cas(:,:)
+  real, allocatable::  invtau_temp_nudg_cas(:,:),invtau_qv_nudg_cas(:,:),invtau_u_nudg_cas(:,:),invtau_v_nudg_cas(:,:)
+  real, allocatable::  lat_cas(:),sens_cas(:),tskin_cas(:),ts_cas(:),ps_cas(:),ustar_cas(:)
+  real, allocatable::  uw_cas(:,:),vw_cas(:,:),q1_cas(:,:),q2_cas(:,:),tkes_cas(:)
+
+  !champs interpoles
+  real, allocatable::  plev_prof_cas(:)
+  real, allocatable::  t_prof_cas(:)
+  real, allocatable::  theta_prof_cas(:)
+  real, allocatable::  thl_prof_cas(:)
+  real, allocatable::  thv_prof_cas(:)
+  real, allocatable::  q_prof_cas(:)
+  real, allocatable::  qv_prof_cas(:)
+  real, allocatable::  ql_prof_cas(:)
+  real, allocatable::  qi_prof_cas(:)
+  real, allocatable::  rh_prof_cas(:)
+  real, allocatable::  rv_prof_cas(:)
+  real, allocatable::  u_prof_cas(:)
+  real, allocatable::  v_prof_cas(:)        
+  real, allocatable::  vitw_prof_cas(:)
+  real, allocatable::  omega_prof_cas(:)
+  real, allocatable::  tke_prof_cas(:)
+  real, allocatable::  ug_prof_cas(:)
+  real, allocatable::  vg_prof_cas(:)
+  real, allocatable::  temp_nudg_prof_cas(:),qv_nudg_prof_cas(:),u_nudg_prof_cas(:),v_nudg_prof_cas(:)
+  real, allocatable::  invtau_temp_nudg_prof_cas(:),invtau_qv_nudg_prof_cas(:),invtau_u_nudg_prof_cas(:),invtau_v_nudg_prof_cas(:)
+
+  real, allocatable::  ht_prof_cas(:)
+  real, allocatable::  hth_prof_cas(:)
+  real, allocatable::  hq_prof_cas(:)
+  real, allocatable::  vt_prof_cas(:)
+  real, allocatable::  vth_prof_cas(:)
+  real, allocatable::  vq_prof_cas(:)
+  real, allocatable::  dt_prof_cas(:)
+  real, allocatable::  dth_prof_cas(:)
+  real, allocatable::  dtrad_prof_cas(:)
+  real, allocatable::  dq_prof_cas(:)
+  real, allocatable::  hu_prof_cas(:)
+  real, allocatable::  hv_prof_cas(:)
+  real, allocatable::  vu_prof_cas(:)
+  real, allocatable::  vv_prof_cas(:)
+  real, allocatable::  du_prof_cas(:)
+  real, allocatable::  dv_prof_cas(:)
+  real, allocatable::  uw_prof_cas(:)
+  real, allocatable::  vw_prof_cas(:)
+  real, allocatable::  q1_prof_cas(:)
+  real, allocatable::  q2_prof_cas(:)
+
+
+  real o3_cas,lat_prof_cas,sens_prof_cas,ts_prof_cas,tskin_prof_cas,ps_prof_cas,ustar_prof_cas,tkes_prof_cas
+  real orog_cas,albedo_cas,emiss_cas,q_skin_cas,mom_rough,heat_rough,rugos_cas,sand_cas,clay_cas
+
 
 
@@ -82,1059 +85,1131 @@
 
 
-!**********************************************************************************************
-SUBROUTINE read_SCM_cas
-      implicit none
+  !**********************************************************************************************
+  SUBROUTINE read_SCM_cas
+    use netcdf, only: nf90_get_var
+    implicit none
 
 #include "netcdf.inc"
 #include "date_cas.h"
 
-      INTEGER nid,rid,ierr
-      INTEGER ii,jj,timeid
-      REAL, ALLOCATABLE :: time_val(:)
-
-      print*,'ON EST VRAIMENT DASN MOD_1D_CASES_READ_STD'
-      fich_cas='cas.nc'
-      print*,'fich_cas ',fich_cas
-      ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
-      print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: GROS Pb opening forcings nc file '
-         write(*,*) NF_STRERROR(ierr)
-         stop ""
-      endif
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lat',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lat'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,ii)
-      print*,'OK1 read2: nid,rid,lat',nid,rid,ii
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lon',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lon'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,jj)
-      print*,'OK2 read2: nid,rid,lat',nid,rid,jj
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lev',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension nlev'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
-      print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
-      IF ( .NOT. ( nlev_cas > 10 .AND. nlev_cas < 200000 )) THEN
-              print*,'Valeur de nlev_cas peu probable'
-              STOP
-      ENDIF
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'time',rid)
-      nt_cas=0
-      IF (ierr.NE.NF_NOERR) THEN
-        stop 'Oh probleme lecture dimension time'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
-      print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
-! Lecture de l'axe des temps
-      print*,'LECTURE DU TEMPS'
-      ierr=NF_INQ_VARID(nid,'time',timeid)
-         if(ierr/=NF_NOERR) then
-           print *,'Variable time manquante dans cas.nc:'
-           ierr=NF_NOERR
-         else
-                 allocate(time_val(nt_cas))
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,timeid,time_val)
-#else
-           ierr = NF_GET_VAR_REAL(nid,timeid,time_val)
-#endif
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de time cas.nc: '
-           endif
-   endif
-   IF (nt_cas>1) THEN
-           pdt_cas=time_val(2)-time_val(1)
-   ELSE
-           pdt_cas=0.
-   ENDIF
+    INTEGER nid,rid,ierr
+    INTEGER ii,jj,timeid
+    REAL, ALLOCATABLE :: time_val(:)
+
+    fich_cas='cas.nc'
+    print*,'fich_cas ',fich_cas
+    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
+    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
+    if (ierr.NE.NF_NOERR) then
+       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
+       write(*,*) NF_STRERROR(ierr)
+       stop ""
+    endif
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lat',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lat'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,ii)
+    print*,'OK1 read_SCM_cas: nid,rid,lat',nid,rid,ii
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lon',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lon'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,jj)
+    print*,'OK2 read_SCM_cas: nid,rid,lat',nid,rid,jj
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lev',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension nlev'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
+    print*,'OK3 read_SCM_cas: nid,rid,nlev_cas',nid,rid,nlev_cas
+    IF ( .NOT. ( nlev_cas > 10 .AND. nlev_cas < 200000 )) THEN
+       print*,'Valeur de nlev_cas peu probable'
+       STOP
+    ENDIF
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'time',rid)
+    nt_cas=0
+    IF (ierr.NE.NF_NOERR) THEN
+       stop 'Oh probleme lecture dimension time'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
+    print*,'OK4 read_SCM_cas: nid,rid,nt_cas',nid,rid,nt_cas
+    ! Lecture de l'axe des temps
+    print*,'LECTURE DU TEMPS'
+    ierr=NF_INQ_VARID(nid,'time',timeid)
+    if(ierr/=NF_NOERR) then
+       print *,'Variable time manquante dans cas.nc:'
+       ierr=NF_NOERR
+    else
+       allocate(time_val(nt_cas))
+       ierr = NF90_GET_VAR(nid,timeid,time_val)
+       if(ierr/=NF_NOERR) then
+          print *,'A Pb a la lecture de time cas.nc: '
+       endif
+    endif
+    IF (nt_cas>1) THEN
+       pdt_cas=time_val(2)-time_val(1)
+    ELSE
+       pdt_cas=0.
+    ENDIF
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!profils moyens:
-        allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
-        allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
-        allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
-        allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
-             qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
-        allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
-        allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
-        allocate(tke_cas(nlev_cas,nt_cas))
-!forcing
-        allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
-        allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
-        allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
-        allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
-        allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
-        allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
-        allocate(ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas))
-        allocate(temp_nudg_cas(nlev_cas,nt_cas),qv_nudg_cas(nlev_cas,nt_cas))
-        allocate(u_nudg_cas(nlev_cas,nt_cas),v_nudg_cas(nlev_cas,nt_cas))
-        allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tkes_cas(nt_cas))
-        allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
-
-
-
-!champs interpoles
-        allocate(plev_prof_cas(nlev_cas))
-        allocate(t_prof_cas(nlev_cas))
-        allocate(theta_prof_cas(nlev_cas))
-        allocate(thl_prof_cas(nlev_cas))
-        allocate(thv_prof_cas(nlev_cas))
-        allocate(q_prof_cas(nlev_cas))
-        allocate(qv_prof_cas(nlev_cas))
-        allocate(ql_prof_cas(nlev_cas))
-        allocate(qi_prof_cas(nlev_cas))
-        allocate(rh_prof_cas(nlev_cas))
-        allocate(rv_prof_cas(nlev_cas))
-        allocate(u_prof_cas(nlev_cas))
-        allocate(v_prof_cas(nlev_cas))
-        allocate(vitw_prof_cas(nlev_cas))
-        allocate(omega_prof_cas(nlev_cas))
-        allocate(tke_prof_cas(nlev_cas))
-        allocate(ug_prof_cas(nlev_cas))
-        allocate(vg_prof_cas(nlev_cas))
-        allocate(temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas))
-        allocate(u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas))
-        allocate(ht_prof_cas(nlev_cas))
-        allocate(hth_prof_cas(nlev_cas))
-        allocate(hq_prof_cas(nlev_cas))
-        allocate(hu_prof_cas(nlev_cas))
-        allocate(hv_prof_cas(nlev_cas))
-        allocate(vt_prof_cas(nlev_cas))
-        allocate(vth_prof_cas(nlev_cas))
-        allocate(vq_prof_cas(nlev_cas))
-        allocate(vu_prof_cas(nlev_cas))
-        allocate(vv_prof_cas(nlev_cas))
-        allocate(dt_prof_cas(nlev_cas))
-        allocate(dth_prof_cas(nlev_cas))
-        allocate(dtrad_prof_cas(nlev_cas))
-        allocate(dq_prof_cas(nlev_cas))
-        allocate(du_prof_cas(nlev_cas))
-        allocate(dv_prof_cas(nlev_cas))
-        allocate(uw_prof_cas(nlev_cas))
-        allocate(vw_prof_cas(nlev_cas))
-        allocate(q1_prof_cas(nlev_cas))
-        allocate(q2_prof_cas(nlev_cas))
-
-        print*,'Allocations OK'
-        CALL read_SCM (nid,nlev_cas,nt_cas,                                                                     &
-     &     ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                   &
-     &     ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,tke_cas,ug_cas,vg_cas,                            &
-     &     temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas,                                                     &
-     &     du_cas,hu_cas,vu_cas,                                                                                &
-     &     dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
-     &     dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tkes_cas,                      &
-     &     uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
-     &     o3_cas,rugos_cas,clay_cas,sand_cas)
-        print*,'read_SCM cas OK'
-        do ii=1,nlev_cas
-        print*,'apres read2_SCM, plev_cas=',ii,plev_cas(ii,1)
-        !print*,'apres read_SCM, plev_cas=',ii,omega_cas(ii,nt_cas/2+1)
-        enddo
-
-
-END SUBROUTINE read_SCM_cas
+    !profils moyens:
+    allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
+    allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
+    allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
+    allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
+         qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
+    allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
+    allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
+    allocate(tke_cas(nlev_cas,nt_cas))
+    !forcing
+    allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
+    allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
+    allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
+    allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
+    allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
+    allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
+    allocate(ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas))
+    allocate(temp_nudg_cas(nlev_cas,nt_cas),qv_nudg_cas(nlev_cas,nt_cas))
+    allocate(u_nudg_cas(nlev_cas,nt_cas),v_nudg_cas(nlev_cas,nt_cas))
+    allocate(invtau_temp_nudg_cas(nlev_cas,nt_cas),invtau_qv_nudg_cas(nlev_cas,nt_cas))
+    allocate(invtau_u_nudg_cas(nlev_cas,nt_cas),invtau_v_nudg_cas(nlev_cas,nt_cas))
+    allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),tskin_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tkes_cas(nt_cas))
+    allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
+
+
+
+    !champs interpoles
+    allocate(plev_prof_cas(nlev_cas))
+    allocate(t_prof_cas(nlev_cas))
+    allocate(theta_prof_cas(nlev_cas))
+    allocate(thl_prof_cas(nlev_cas))
+    allocate(thv_prof_cas(nlev_cas))
+    allocate(q_prof_cas(nlev_cas))
+    allocate(qv_prof_cas(nlev_cas))
+    allocate(ql_prof_cas(nlev_cas))
+    allocate(qi_prof_cas(nlev_cas))
+    allocate(rh_prof_cas(nlev_cas))
+    allocate(rv_prof_cas(nlev_cas))
+    allocate(u_prof_cas(nlev_cas))
+    allocate(v_prof_cas(nlev_cas))
+    allocate(vitw_prof_cas(nlev_cas))
+    allocate(omega_prof_cas(nlev_cas))
+    allocate(tke_prof_cas(nlev_cas))
+    allocate(ug_prof_cas(nlev_cas))
+    allocate(vg_prof_cas(nlev_cas))
+    allocate(temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas))
+    allocate(u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas))
+    allocate(invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas))
+    allocate(invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas))
+    allocate(ht_prof_cas(nlev_cas))
+    allocate(hth_prof_cas(nlev_cas))
+    allocate(hq_prof_cas(nlev_cas))
+    allocate(hu_prof_cas(nlev_cas))
+    allocate(hv_prof_cas(nlev_cas))
+    allocate(vt_prof_cas(nlev_cas))
+    allocate(vth_prof_cas(nlev_cas))
+    allocate(vq_prof_cas(nlev_cas))
+    allocate(vu_prof_cas(nlev_cas))
+    allocate(vv_prof_cas(nlev_cas))
+    allocate(dt_prof_cas(nlev_cas))
+    allocate(dth_prof_cas(nlev_cas))
+    allocate(dtrad_prof_cas(nlev_cas))
+    allocate(dq_prof_cas(nlev_cas))
+    allocate(du_prof_cas(nlev_cas))
+    allocate(dv_prof_cas(nlev_cas))
+    allocate(uw_prof_cas(nlev_cas))
+    allocate(vw_prof_cas(nlev_cas))
+    allocate(q1_prof_cas(nlev_cas))
+    allocate(q2_prof_cas(nlev_cas))
+
+    print*,'Allocations OK'
+    CALL read_SCM (nid,nlev_cas,nt_cas,                                                                     &
+         ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                   &
+         ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,tke_cas,ug_cas,vg_cas,                            &
+         temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas,                                                     &
+         invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas,                         &
+         du_cas,hu_cas,vu_cas,                                                                                &
+         dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
+         dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,tskin_cas,ps_cas,ustar_cas,tkes_cas,            &
+         uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,q_skin_cas,mom_rough,heat_rough, &
+         o3_cas,rugos_cas,clay_cas,sand_cas)
+    print*,'read_SCM cas OK'
+    do ii=1,nlev_cas
+       print*,'apres read_SCM_cas, plev_cas=',ii,plev_cas(ii,1)
+       !print*,'apres read_SCM, plev_cas=',ii,omega_cas(ii,nt_cas/2+1)
+    enddo
+
+
+  END SUBROUTINE read_SCM_cas
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-SUBROUTINE deallocate2_1D_cases
-!profils environnementaux:
-        deallocate(plev_cas,plevh_cas)
-        
-        deallocate(z_cas,zh_cas)
-        deallocate(ap_cas,bp_cas)
-        deallocate(t_cas,q_cas,qv_cas,ql_cas,qi_cas,rh_cas)
-        deallocate(th_cas,thl_cas,thv_cas,rv_cas)
-        deallocate(u_cas,v_cas,vitw_cas,omega_cas,tke_cas)
-        
-!forcing
-        deallocate(ht_cas,vt_cas,dt_cas,dtrad_cas)
-        deallocate(hq_cas,vq_cas,dq_cas)
-        deallocate(hth_cas,vth_cas,dth_cas)
-        deallocate(hr_cas,vr_cas,dr_cas)
-        deallocate(hu_cas,vu_cas,du_cas)
-        deallocate(hv_cas,vv_cas,dv_cas)
-        deallocate(ug_cas)
-        deallocate(vg_cas)
-        deallocate(lat_cas,sens_cas,ts_cas,ps_cas,ustar_cas,tkes_cas,uw_cas,vw_cas,q1_cas,q2_cas)
-
-!champs interpoles
-        deallocate(plev_prof_cas)
-        deallocate(t_prof_cas)
-        deallocate(theta_prof_cas)
-        deallocate(thl_prof_cas)
-        deallocate(thv_prof_cas)
-        deallocate(q_prof_cas)
-        deallocate(qv_prof_cas)
-        deallocate(ql_prof_cas)
-        deallocate(qi_prof_cas)
-        deallocate(rh_prof_cas)
-        deallocate(rv_prof_cas)
-        deallocate(u_prof_cas)
-        deallocate(v_prof_cas)
-        deallocate(vitw_prof_cas)
-        deallocate(omega_prof_cas)
-        deallocate(tke_prof_cas)
-        deallocate(ug_prof_cas)
-        deallocate(vg_prof_cas)
-        deallocate(temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas)
-        deallocate(ht_prof_cas)
-        deallocate(hq_prof_cas)
-        deallocate(hu_prof_cas)
-        deallocate(hv_prof_cas)
-        deallocate(vt_prof_cas)
-        deallocate(vq_prof_cas)
-        deallocate(vu_prof_cas)
-        deallocate(vv_prof_cas)
-        deallocate(dt_prof_cas)
-        deallocate(dtrad_prof_cas)
-        deallocate(dq_prof_cas)
-        deallocate(du_prof_cas)
-        deallocate(dv_prof_cas)
-        deallocate(t_prof_cas)
-        deallocate(u_prof_cas)
-        deallocate(v_prof_cas)
-        deallocate(uw_prof_cas)
-        deallocate(vw_prof_cas)
-        deallocate(q1_prof_cas)
-        deallocate(q2_prof_cas)
-
-END SUBROUTINE deallocate2_1D_cases
-
-
-!=====================================================================
-      SUBROUTINE read_SCM(nid,nlevel,ntime,                                       &
-     &     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,tke,ug,vg,&
-     &     temp_nudg,qv_nudg,u_nudg,v_nudg,                                        &
-     &     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
-     &     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tkes,uw,vw,q1,q2,       &
-     &     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
-     &     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
-
-!program reading forcing of the case study
-      implicit none
+  SUBROUTINE deallocate2_1D_cases
+    !profils environnementaux:
+    deallocate(plev_cas,plevh_cas)
+
+    deallocate(z_cas,zh_cas)
+    deallocate(ap_cas,bp_cas)
+    deallocate(t_cas,q_cas,qv_cas,ql_cas,qi_cas,rh_cas)
+    deallocate(th_cas,thl_cas,thv_cas,rv_cas)
+    deallocate(u_cas,v_cas,vitw_cas,omega_cas,tke_cas)
+
+    !forcing
+    deallocate(ht_cas,vt_cas,dt_cas,dtrad_cas)
+    deallocate(hq_cas,vq_cas,dq_cas)
+    deallocate(hth_cas,vth_cas,dth_cas)
+    deallocate(hr_cas,vr_cas,dr_cas)
+    deallocate(hu_cas,vu_cas,du_cas)
+    deallocate(hv_cas,vv_cas,dv_cas)
+    deallocate(ug_cas)
+    deallocate(vg_cas)
+    deallocate(lat_cas,sens_cas,tskin_cas,ts_cas,ps_cas,ustar_cas,tkes_cas,uw_cas,vw_cas,q1_cas,q2_cas)
+
+    !champs interpoles
+    deallocate(plev_prof_cas)
+    deallocate(t_prof_cas)
+    deallocate(theta_prof_cas)
+    deallocate(thl_prof_cas)
+    deallocate(thv_prof_cas)
+    deallocate(q_prof_cas)
+    deallocate(qv_prof_cas)
+    deallocate(ql_prof_cas)
+    deallocate(qi_prof_cas)
+    deallocate(rh_prof_cas)
+    deallocate(rv_prof_cas)
+    deallocate(u_prof_cas)
+    deallocate(v_prof_cas)
+    deallocate(vitw_prof_cas)
+    deallocate(omega_prof_cas)
+    deallocate(tke_prof_cas)
+    deallocate(ug_prof_cas)
+    deallocate(vg_prof_cas)
+    deallocate(temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas)
+    deallocate(invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas)
+    deallocate(ht_prof_cas)
+    deallocate(hq_prof_cas)
+    deallocate(hu_prof_cas)
+    deallocate(hv_prof_cas)
+    deallocate(vt_prof_cas)
+    deallocate(vq_prof_cas)
+    deallocate(vu_prof_cas)
+    deallocate(vv_prof_cas)
+    deallocate(dt_prof_cas)
+    deallocate(dtrad_prof_cas)
+    deallocate(dq_prof_cas)
+    deallocate(du_prof_cas)
+    deallocate(dv_prof_cas)
+    deallocate(t_prof_cas)
+    deallocate(u_prof_cas)
+    deallocate(v_prof_cas)
+    deallocate(uw_prof_cas)
+    deallocate(vw_prof_cas)
+    deallocate(q1_prof_cas)
+    deallocate(q2_prof_cas)
+
+  END SUBROUTINE deallocate2_1D_cases
+
+
+  !=====================================================================
+  SUBROUTINE read_SCM(nid,nlevel,ntime,                                       &
+       ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,tke,ug,vg,&
+       temp_nudg,qv_nudg,u_nudg,v_nudg,                                        &
+       invtau_temp_nudg,invtau_qv_nudg,invtau_u_nudg,invtau_v_nudg,             &
+       du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
+       dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,tskin,ps,ustar,tkes,uw,vw,q1,q2,       &
+       orog_cas,albedo_cas,emiss_cas,q_skin_cas,mom_rough,          &
+       heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
+
+    !program reading forcing of the case study
+    use netcdf, only: nf90_get_var
+    implicit none
 #include "netcdf.inc"
 #include "compar1d.h"
 
-      integer ntime,nlevel,k,t
-
-      real ap(nlevel+1),bp(nlevel+1)
-      real zz(nlevel,ntime),zzh(nlevel+1)
-      real pp(nlevel,ntime),pph(nlevel+1)
-!profils initiaux
-      real temp0(nlevel),qv0(nlevel),ql0(nlevel),qi0(nlevel),u0(nlevel),v0(nlevel),tke0(nlevel)
-      real pp0(nlevel)    
-      real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
-      real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
-      real u(nlevel,ntime),v(nlevel,ntime),tkes(ntime)
-      real temp_nudg(nlevel,ntime),qv_nudg(nlevel,ntime),u_nudg(nlevel,ntime),v_nudg(nlevel,ntime)
-      real ug(nlevel,ntime),vg(nlevel,ntime)
-      real vitw(nlevel,ntime),omega(nlevel,ntime),tke(nlevel,ntime)
-      real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
-      real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
-      real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
-      real dtrad(nlevel,ntime)
-      real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
-      real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
-      real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
-      real flat(ntime),sens(ntime),ustar(ntime)
-      real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
-      real ts(ntime),ps(ntime)
-      real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
-      real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
-
-
-      integer nid, ierr,ierr1,ierr2,rid,i
-      integer nbvar3d
-      parameter(nbvar3d=74)
-      integer var3didin(nbvar3d),missing_var(nbvar3d)
-      character*13 name_var(1:nbvar3d)
-
-
-      data name_var/ &
-     ! coordonnees pression (n+1 niveaux) #4
-     & 'coor_par_a','coor_par_b','height_h','pressure_h',& ! #1-#4
-     ! coordonnees pression (n niveaux) #8
-     &'temp','qv','ql','qi','u','v','tke','pressure',& ! #5-#12
-     ! coordonnees pression + temps #42
-     &'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','temp_adv','tadvh','tadvv',& !  #13 - #25
-     &'qv_adv','qvadvh','qvadvv','thadv','thadvh','thadvv','thladvh',                             & ! #26 - #32
-     & 'radv','radvh','radvv','radcool','q1','q2','ustress','vstress',                           & ! #33 - #40
-     & 'rh','temp_nudging','qv_nudging','u_nudging','v_nudging',                                       & ! #41-45
-     &'height_f','pressure_forc','tempt','theta','thv','thl','qvt','qlt','qit','rv','ut','vt',   & ! #46-58
-     ! coordonnees temps #12
-     &'tkes','sfc_sens_flx','sfc_lat_flx','ts','ps','ustar',&
-     &'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough',&
-     ! scalaires #4
-     &'o3','rugos','clay','sand'/
-
-!-----------------------------------------------------------------------
-! Checking availability of variable #i in the cas.nc file
-!     missing_var=1 if the variable is missing
-!-----------------------------------------------------------------------
-
-       do i=1,nbvar3d
-         missing_var(i)=0.
-         ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
-         if(ierr/=NF_NOERR) then
-           print *,'Variable manquante dans cas.nc:',i,name_var(i)
-           ierr=NF_NOERR
-           missing_var(i)=1
-         else
-
-!-----------------------------------------------------------------------
-! Activating keys depending on the presence of specific variables in cas.nc
-!-----------------------------------------------------------------------
-if ( 1 == 1 ) THEN
-! A MODIFIER: il faudrait dire nudging_temp mais faut le declarer dans compar1d.h etc...        
-!           if ( name_var(i) == 'temp_nudging' .and. nint(nudging_t)==0) stop 'Nudging inconsistency temp'
-            if ( name_var(i) == 'qv_nudging' .and. nint(nudging_qv)==0) stop 'Nudging inconsistency qv'
-            if ( name_var(i) == 'u_nudging' .and. nint(nudging_u)==0) stop 'Nudging inconsistency u'
-            if ( name_var(i) == 'v_nudging' .and. nint(nudging_u)==0) stop 'Nudging inconsistency v'
-    ELSE
+    integer ntime,nlevel,k,t
+
+    real ap(nlevel+1),bp(nlevel+1)
+    real zz(nlevel,ntime),zzh(nlevel+1)
+    real pp(nlevel,ntime),pph(nlevel+1)
+    !profils initiaux
+    real temp0(nlevel),qv0(nlevel),ql0(nlevel),qi0(nlevel),u0(nlevel),v0(nlevel),tke0(nlevel)
+    real pp0(nlevel)    
+    real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
+    real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
+    real u(nlevel,ntime),v(nlevel,ntime),tkes(ntime)
+    real temp_nudg(nlevel,ntime),qv_nudg(nlevel,ntime),u_nudg(nlevel,ntime),v_nudg(nlevel,ntime)
+    real invtau_temp_nudg(nlevel,ntime),invtau_qv_nudg(nlevel,ntime),invtau_u_nudg(nlevel,ntime),invtau_v_nudg(nlevel,ntime)
+    real ug(nlevel,ntime),vg(nlevel,ntime)
+    real vitw(nlevel,ntime),omega(nlevel,ntime),tke(nlevel,ntime)
+    real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
+    real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
+    real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
+    real dtrad(nlevel,ntime)
+    real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
+    real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
+    real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
+    real flat(ntime),sens(ntime),ustar(ntime)
+    real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
+    real ts(ntime),tskin(ntime),ps(ntime)
+    real orog_cas,albedo_cas,emiss_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
+    real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
+
+
+    integer nid, ierr,ierr1,ierr2,rid,i,int_test
+    integer nbvar3d
+    parameter(nbvar3d=78)
+    integer var3didin(nbvar3d),missing_var(nbvar3d)
+    character*13 name_var(1:nbvar3d)
+
+
+    !      data name_var/ &
+    !     ! coordonnees pression (n+1 niveaux) #4
+    !     & 'coor_par_a','coor_par_b','height_h','pressure_h',& ! #1-#4
+    !     ! coordonnees pression (n niveaux) #8
+    !     &'temp','qv','ql','qi','u','v','tke','pressure',& ! #5-#12
+    !     ! coordonnees pression + temps #42
+    !     &'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','temp_adv','tadvh','tadvv',& !  #13 - #25
+    !     &'qv_adv','qvadvh','qvadvv','thadv','thadvh','thadvv','thladvh',                             & ! #26 - #32
+    !     & 'radv','radvh','radvv','radcool','q1','q2','ustress','vstress',                           & ! #33 - #40
+    !     & 'rh','temp_nudging','qv_nudging','u_nudging','v_nudging',                                       & ! #41-45
+    !     &'height_f','pressure_forc','tempt','theta','thv','thl','qvt','qlt','qit','rv','ut','vt',   & ! #46-58
+    !     ! coordonnees temps #12
+    !     &'tkes','sfc_sens_flx','sfc_lat_flx','ts','ps','ustar',&
+    !     &'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough',&
+    !     ! scalaires #4
+    !     &'o3','rugos','clay','sand'/
+
+
+
+    data name_var/ &
+                                ! coordonnees pression (n+1 niveaux) #4
+         'coor_par_a','coor_par_b','zf','pressure_h',& ! #1-#4
+                                ! coordonnees pression (n niveaux) #8
+         'ta','qv','ql','qi','ua','va','tke','pa',& ! #5-#12
+                                ! coordonnees pression + temps #46
+         'wa','wap','ug','vg','tnua_adv','tnua_advh','tnua_advv','tnva_adv','tnva_advh','tnva_advv','tnta_adv','tnta_advh',& !  #13 - #25
+         'tnta_advv','tnqv_adv','tnqv_advh','tnqv_advv','thadv','thadvh','thadvv','thladvh',                             & ! #26 - #32
+         'radv','radvh','radvv','tnta_rad','q1','q2','ustress','vstress',                           & ! #33 - #40
+         'rh','ta_nud','qv_nud','ua_nud','va_nud',                                       & ! #41-45
+         'zh_forc','pa_forc','tat','thetat','thetavt','thetalt','qvt','qlt','qit','rvt','uat','vat',   & ! #46-57
+         'nudging_constant_ta', 'nudging_constant_qv', 'nudging_constant_ua', 'nudging_constant_va',           & ! # 58-61
+                                ! coordonnees temps #12
+         'tkes','hfss','hfls','ts_forc','tskin','ps_forc','ustar', &                     ! 62-68
+                                  ! scalaires 
+         'orog','albedo','emiss','q_skin','z0','z0h',       &                    ! 69-74
+         'O3','rugos','clay','sand'/                                                      ! 75-78
+
+
+    !-----------------------------------------------------------------------
+    ! First check that we are using a version > v2 of the 1D standard format
+    ! use the difference between 'temp' (old version) and 'ta' (new version)
+    !-----------------------------------------------------------------------
+
+
+    ierr=NF_INQ_VARID(nid,'ta',int_test)
+    if(ierr/=NF_NOERR) then
+       print*, '++++++++++++++++++++++++++++++'
+       print*, 'variable ta missing in cas.nc '
+       print*, 'You are probably using an obsolete version of the 1D cases'
+       print*, 'please dowload the last version of the 1D archive from https://lmdz.lmd.jussieu.fr/pub/'
+       print*, '++++++++++++++++++++++++++++++'
+       CALL abort_gcm ('mod_1D_cases_read_std','bad version of 1D directory',0)
+    endif
+
+    !-----------------------------------------------------------------------
+    ! Checking availability of variable #i in the cas.nc file
+    !     missing_var=1 if the variable is missing
+    !-----------------------------------------------------------------------
+
+    do i=1,nbvar3d
+       missing_var(i)=0.
+       ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
+       print*, 'name_var(i)', name_var(i), var3didin(i)
+       if(ierr/=NF_NOERR) then
+          print *,'Variable manquante dans cas.nc:',i,name_var(i)
+          ierr=NF_NOERR
+          missing_var(i)=1
+       else
+
+          !-----------------------------------------------------------------------
+          ! Activating keys depending on the presence of specific variables in cas.nc
+          !-----------------------------------------------------------------------
+          if ( 1 == 1 ) THEN
+             ! A MODIFIER: il faudrait dire nudging_temp mais faut le declarer dans compar1d.h etc...        
+             !           if ( name_var(i) == 'temp_nudging' .and. nint(nudging_t)==0) stop 'Nudging inconsistency temp'
+             if ( name_var(i) == 'qv_nud' .and. nint(nudging_qv)==0) stop 'Nudging inconsistency qv'
+             if ( name_var(i) == 'ua_nud' .and. nint(nudging_u)==0) stop 'Nudging inconsistency u'
+             if ( name_var(i) == 'va_nud' .and. nint(nudging_v)==0) stop 'Nudging inconsistency v'
+          ELSE
              print*,'GUIDAGE : CONSISTENCY CHECK DEACTIVATED FOR TESTS of SANDU/REF'
-    ENDIF
-
-!-----------------------------------------------------------------------
-! Reading variables 1D (N+1) vertical variables (nlevelp1,lat,lon)
-!-----------------------------------------------------------------------
-           if(i.LE.4) then
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),apbp)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),apbp)
-#endif
-           print *,'read2_cas(apbp), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-
-!-----------------------------------------------------------------------
-!  Reading 1D (N) vertical varialbes    (nlevel,lat,lon)   
-!-----------------------------------------------------------------------
-           else if(i.gt.4.and.i.LE.12) then  
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul1)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul1)
-#endif
-           print *,'read2_cas(resul1), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-         print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
-
-!-----------------------------------------------------------------------
-!  Reading 2D tim-vertical variables  (time,nlevel,lat,lon)
-!  TBD : seems to be the same as above.
-!-----------------------------------------------------------------------
-           else if(i.gt.12.and.i.LE.57) then
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul)
-#endif
-           print *,'read2_cas(resul), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-         print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
-
-!-----------------------------------------------------------------------
-!  Reading 1D time variables (time,lat,lon)
-!-----------------------------------------------------------------------
-           else if (i.gt.57.and.i.LE.63) then
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul2)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul2)
-#endif
-           print *,'read2_cas(resul2), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-         print*,'Lecture de la variable #i  ',i,name_var(i),minval(resul2),maxval(resul2)
-
-!-----------------------------------------------------------------------
-! Reading scalar variables (lat,lon)
-!-----------------------------------------------------------------------
-           else
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul3)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul3)
-#endif
-           print *,'read2_cas(resul3), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-         print*,'Lecture de la variable #i ',i,name_var(i),resul3
-           endif
-         endif
-
-!-----------------------------------------------------------------------
-! Attributing variables
-!-----------------------------------------------------------------------
-         select case(i)
-         !case(1) ; ap=apbp       ! donnees indexees en nlevel+1
-         ! case(2) ; bp=apbp
-           case(3) ; zzh=apbp
-           case(4) ; pph=apbp
-           case(5) ; temp0=resul1    ! donnees initiales
-           case(6) ; qv0=resul1
-           case(7) ; ql0=resul1
-           case(8) ; qi0=resul1
-           case(9) ; u0=resul1
-           case(10) ; v0=resul1
-           case(11) ; tke0=resul1
-           case(12) ; pp0=resul1
-           case(13) ; vitw=resul    ! donnees indexees en nlevel,time
-           case(14) ; omega=resul
-           case(15) ; ug=resul
-           case(16) ; vg=resul
-           case(17) ; du=resul
-           case(18) ; hu=resul
-           case(19) ; vu=resul
-           case(20) ; dv=resul
-           case(21) ; hv=resul
-           case(22) ; vv=resul
-           case(23) ; dt=resul
-           case(24) ; ht=resul
-           case(25) ; vt=resul
-           case(26) ; dq=resul
-           case(27) ; hq=resul
-           case(28) ; vq=resul
-           case(29) ; dth=resul
-           case(30) ; hth=resul
-           case(31) ; vth=resul
-           case(32) ; hthl=resul
-           case(33) ; dr=resul
-           case(34) ; hr=resul
-           case(35) ; vr=resul
-           case(36) ; dtrad=resul
-           case(37) ; q1=resul
-           case(38) ; q2=resul
-           case(39) ; uw=resul
-           case(40) ; vw=resul
-           case(41) ; rh=resul
-           case(42) ; temp_nudg=resul
-           case(43) ; qv_nudg=resul
-           case(44) ; u_nudg=resul
-           case(45) ; v_nudg=resul
-           case(46) ; zz=resul      ! donnees en time,nlevel pour profil initial
-           case(47) ; pp=resul
-           case(48) ; temp=resul
-           case(49) ; theta=resul
-           case(50) ; thv=resul
-           case(51) ; thl=resul
-           case(52) ; qv=resul
-           case(53) ; ql=resul
-           case(54) ; qi=resul
-           case(55) ; rv=resul
-           case(56) ; u=resul
-           case(57) ; v=resul
-           case(58) ; tkes=resul2   ! donnees indexees en time
-           case(59) ; sens=resul2
-           case(60) ; flat=resul2
-           case(61) ; ts=resul2
-           case(62) ; ps=resul2
-           case(63) ; ustar=resul2
-           case(64) ; orog_cas=resul3      ! constantes
-           case(65) ; albedo_cas=resul3
-           case(66) ; emiss_cas=resul3
-           case(67) ; t_skin_cas=resul3
-           case(68) ; q_skin_cas=resul3
-           case(69) ; mom_rough=resul3
-           case(70) ; heat_rough=resul3
-           case(71) ; o3_cas=resul3        
-           case(72) ; rugos_cas=resul3
-           case(73) ; clay_cas=resul3
-           case(74) ; sand_cas=resul3
-         end select
-         resul=0.
-         resul1=0.
-         resul2=0.
-         resul3=0.
+          ENDIF
+
+          !-----------------------------------------------------------------------
+          ! Reading variables 1D (N+1) vertical variables (nlevelp1,lat,lon)
+          !-----------------------------------------------------------------------
+          if(i.LE.4) then
+             ierr = NF90_GET_VAR(nid,var3didin(i),apbp)
+             print *,'read_SCM(apbp), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'B Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+
+             !-----------------------------------------------------------------------
+             !  Reading 1D (N) vertical varialbes    (nlevel,lat,lon)   
+             !-----------------------------------------------------------------------
+          else if(i.gt.4.and.i.LE.12) then  
+             ierr = NF90_GET_VAR(nid,var3didin(i),resul1)
+             print *,'read_SCM(resul1), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'C Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+             print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
+
+             !-----------------------------------------------------------------------
+             !  Reading 2D tim-vertical variables  (time,nlevel,lat,lon)
+             !  TBD : seems to be the same as above.
+             !-----------------------------------------------------------------------
+          else if(i.gt.12.and.i.LE.61) then
+             ierr = NF90_GET_VAR(nid,var3didin(i),resul)
+             print *,'read_SCM(resul), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'D Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+             print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
+
+             !-----------------------------------------------------------------------
+             !  Reading 1D time variables (time,lat,lon)
+             !-----------------------------------------------------------------------
+          else if (i.gt.62.and.i.LE.75) then
+             ierr = NF90_GET_VAR(nid,var3didin(i),resul2)
+             print *,'read_SCM(resul2), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'E Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+             print*,'Lecture de la variable #i  ',i,name_var(i),minval(resul2),maxval(resul2)
+
+             !-----------------------------------------------------------------------
+             ! Reading scalar variables (lat,lon)
+             !-----------------------------------------------------------------------
+          else
+             ierr = NF90_GET_VAR(nid,var3didin(i),resul3)
+             print *,'read_SCM(resul3), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'F Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+             print*,'Lecture de la variable #i ',i,name_var(i),resul3
+          endif
+       endif
+
+       !-----------------------------------------------------------------------
+       ! Attributing variables
+       !-----------------------------------------------------------------------
+       select case(i)
+          !case(1) ; ap=apbp       ! donnees indexees en nlevel+1
+          ! case(2) ; bp=apbp
+       case(3) ; zzh=apbp
+       case(4) ; pph=apbp
+       case(5) ; temp0=resul1    ! donnees initiales
+       case(6) ; qv0=resul1
+       case(7) ; ql0=resul1
+       case(8) ; qi0=resul1
+       case(9) ; u0=resul1
+       case(10) ; v0=resul1
+       case(11) ; tke0=resul1
+       case(12) ; pp0=resul1
+       case(13) ; vitw=resul    ! donnees indexees en nlevel,time
+       case(14) ; omega=resul
+       case(15) ; ug=resul
+       case(16) ; vg=resul
+       case(17) ; du=resul
+       case(18) ; hu=resul
+       case(19) ; vu=resul
+       case(20) ; dv=resul
+       case(21) ; hv=resul
+       case(22) ; vv=resul
+       case(23) ; dt=resul
+       case(24) ; ht=resul
+       case(25) ; vt=resul
+       case(26) ; dq=resul
+       case(27) ; hq=resul
+       case(28) ; vq=resul
+       case(29) ; dth=resul
+       case(30) ; hth=resul
+       case(31) ; vth=resul
+       case(32) ; hthl=resul
+       case(33) ; dr=resul
+       case(34) ; hr=resul
+       case(35) ; vr=resul
+       case(36) ; dtrad=resul
+       case(37) ; q1=resul
+       case(38) ; q2=resul
+       case(39) ; uw=resul
+       case(40) ; vw=resul
+       case(41) ; rh=resul
+       case(42) ; temp_nudg=resul
+       case(43) ; qv_nudg=resul
+       case(44) ; u_nudg=resul
+       case(45) ; v_nudg=resul
+       case(46) ; zz=resul      ! donnees en time,nlevel pour profil initial
+       case(47) ; pp=resul
+       case(48) ; temp=resul
+       case(49) ; theta=resul
+       case(50) ; thv=resul
+       case(51) ; thl=resul
+       case(52) ; qv=resul
+       case(53) ; ql=resul
+       case(54) ; qi=resul
+       case(55) ; rv=resul
+       case(56) ; u=resul
+       case(57) ; v=resul
+       case(58) ; invtau_temp_nudg=resul
+       case(59) ; invtau_qv_nudg=resul
+       case(60) ; invtau_u_nudg=resul
+       case(61) ; invtau_v_nudg=resul
+       case(62) ; tkes=resul2   ! donnees indexees en time
+       case(63) ; sens=resul2
+       case(64) ; flat=resul2
+       case(65) ; ts=resul2
+       case(66) ; tskin=resul2        
+       case(67) ; ps=resul2
+       case(68) ; ustar=resul2
+       case(69) ; orog_cas=resul3      ! constantes
+       case(70) ; albedo_cas=resul3
+       case(71) ; emiss_cas=resul3
+       case(72) ; q_skin_cas=resul3
+       case(73) ; mom_rough=resul3
+       case(74) ; heat_rough=resul3
+       case(75) ; o3_cas=resul3        
+       case(76) ; rugos_cas=resul3
+       case(77) ; clay_cas=resul3
+       case(78) ; sand_cas=resul3
+       end select
+       resul=0.
+       resul1=0.
+       resul2=0.
+       resul3=0.
+    enddo
+    print*,'Lecture de la variable APRES ,sens ',minval(sens),maxval(sens)
+    print*,'Lecture de la variable APRES ,flat ',minval(flat),maxval(flat)
+
+    !CR:ATTENTION EN ATTENTE DE REGLER LA QUESTION DU PAS DE TEMPS INITIAL
+    do t=1,ntime
+       do k=1,nlevel
+          temp(k,t)=temp0(k)
+          qv(k,t)=qv0(k)
+          ql(k,t)=ql0(k)
+          qi(k,t)=qi0(k)
+          u(k,t)=u0(k)
+          v(k,t)=v0(k)
+          tke(k,t)=tke0(k)
        enddo
-         print*,'Lecture de la variable APRES ,sens ',minval(sens),maxval(sens)
-         print*,'Lecture de la variable APRES ,flat ',minval(flat),maxval(flat)
-
-!CR:ATTENTION EN ATTENTE DE REGLER LA QUESTION DU PAS DE TEMPS INITIAL
-       do t=1,ntime
-          do k=1,nlevel
-             temp(k,t)=temp0(k)
-             qv(k,t)=qv0(k)
-             ql(k,t)=ql0(k)
-             qi(k,t)=qi0(k)
-             u(k,t)=u0(k)
-             v(k,t)=v0(k)
-             tke(k,t)=tke0(k)
-          enddo
-       enddo
-       !!!! TRAVAIL : EN FONCTION DES DECISIONS SUR LA SPECIFICATION DE W
-       !!!omega=-vitw*pres*rg/(rd*temp)
-!-----------------------------------------------------------------------
-
-         return 
-         END SUBROUTINE read_SCM
-!======================================================================
-
-!======================================================================
-
-!**********************************************************************************************
-
-!**********************************************************************************************
-        SUBROUTINE interp_case_time_std(day,day1,annee_ref                           &
-!    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas                         &
-     &         ,nt_cas,nlev_cas                                                   &
-     &         ,ts_cas,ps_cas,plev_cas,t_cas,theta_cas,thv_cas,thl_cas            &
-     &         ,qv_cas,ql_cas,qi_cas,u_cas,v_cas                                  &
-     &         ,ug_cas,vg_cas,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas     &
-     &         ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas             &
-     &         ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas               &
-     &         ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas                      &
-     &         ,lat_cas,sens_cas,ustar_cas                                        &
-     &         ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                               &
-!
-     &         ,ts_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas               &
-     &         ,thv_prof_cas,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas     &
-     &         ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                     &
-     &         ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas     &
-     &         ,vitw_prof_cas,omega_prof_cas,tke_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas  &
-     &         ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas                   &
-     &         ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas                &
-     &         ,hq_prof_cas,vq_prof_cas,dth_prof_cas,hth_prof_cas,vth_prof_cas    &
-     &         ,lat_prof_cas,sens_prof_cas                                        &
-     &         ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
-
-
-
-
-
-
-       implicit none
-
-!---------------------------------------------------------------------------------------
-! Time interpolation of a 2D field to the timestep corresponding to day
-!
-! day: current julian day (e.g. 717538.2)
-! day1: first day of the simulation
-! nt_cas: total nb of data in the forcing 
-! pdt_cas: total time interval (in sec) between 2 forcing data
-!---------------------------------------------------------------------------------------
+    enddo
+!!!! TRAVAIL : EN FONCTION DES DECISIONS SUR LA SPECIFICATION DE W
+!!!omega=-vitw*pres*rg/(rd*temp)
+    !-----------------------------------------------------------------------
+
+    return 
+  END SUBROUTINE read_SCM
+  !======================================================================
+
+  !======================================================================
+
+  !**********************************************************************************************
+
+  !**********************************************************************************************
+  SUBROUTINE interp_case_time_std(day,day1,annee_ref                           &
+       !    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas                         &
+       ,nt_cas,nlev_cas                                                   &
+       ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,theta_cas,thv_cas,thl_cas            &
+       ,qv_cas,ql_cas,qi_cas,u_cas,v_cas                                  &
+       ,ug_cas,vg_cas,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas     &
+       ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas     &
+       ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas             &
+       ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas               &
+       ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas                      &
+       ,lat_cas,sens_cas,ustar_cas                                        &
+       ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                               &
+       !
+       ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas               &
+       ,thv_prof_cas,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas     &
+       ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                     &
+       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas     &
+       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas     &     
+       ,vitw_prof_cas,omega_prof_cas,tke_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas  &
+       ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas                   &
+       ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas                &
+       ,hq_prof_cas,vq_prof_cas,dth_prof_cas,hth_prof_cas,vth_prof_cas    &
+       ,lat_prof_cas,sens_prof_cas                                        &
+       ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
+
+
+
+
+
+
+    implicit none
+
+    !---------------------------------------------------------------------------------------
+    ! Time interpolation of a 2D field to the timestep corresponding to day
+    !
+    ! day: current julian day (e.g. 717538.2)
+    ! day1: first day of the simulation
+    ! nt_cas: total nb of data in the forcing 
+    ! pdt_cas: total time interval (in sec) between 2 forcing data
+    !---------------------------------------------------------------------------------------
 
 #include "compar1d.h"
 #include "date_cas.h"
 
-! inputs:
-        integer annee_ref
-        integer nt_cas,nlev_cas
-        real day, day1,day_cas
-        real ts_cas(nt_cas),ps_cas(nt_cas)
-        real plev_cas(nlev_cas,nt_cas)
-        real t_cas(nlev_cas,nt_cas),theta_cas(nlev_cas,nt_cas)
-        real thv_cas(nlev_cas,nt_cas), thl_cas(nlev_cas,nt_cas)
-        real qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas),qi_cas(nlev_cas,nt_cas)
-        real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
-        real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
-        real temp_nudg_cas(nlev_cas,nt_cas),qv_nudg_cas(nlev_cas,nt_cas)
-        real u_nudg_cas(nlev_cas,nt_cas),v_nudg_cas(nlev_cas,nt_cas)
-
-        real vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas),tke_cas(nlev_cas,nt_cas)
-        real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
-        real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
-        real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
-        real dth_cas(nlev_cas,nt_cas),hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas)
-        real dtrad_cas(nlev_cas,nt_cas)
-        real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
-        real lat_cas(nt_cas),sens_cas(nt_cas),tkes_cas(nt_cas)
-        real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
-        real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
-
-! outputs:
-        real plev_prof_cas(nlev_cas)
-        real t_prof_cas(nlev_cas),theta_prof_cas(nlev_cas),thl_prof_cas(nlev_cas),thv_prof_cas(nlev_cas)
-        real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
-        real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
-        real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
-        real temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas)
-        real u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas)
-
-        real vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas),tke_prof_cas(nlev_cas)
-        real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
-        real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
-        real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
-        real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
-        real dtrad_prof_cas(nlev_cas)
-        real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
-        real lat_prof_cas,sens_prof_cas,tkes_prof_cas,ts_prof_cas,ps_prof_cas,ustar_prof_cas
-        real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
-! local:
-        integer it_cas1, it_cas2,k
-        real timeit,time_cas1,time_cas2,frac
-
-
-        print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
-!       do k=1,nlev_cas
-!       print*,'debut de interp2_case_time, plev_cas=',k,plev_cas(k,1)
-!       enddo
-
-! On teste si la date du cas AMMA est correcte.
-! C est pour memoire car en fait les fichiers .def
-! sont censes etre corrects.
-! A supprimer a terme (MPL 20150623)
-!     if ((forcing_type.eq.10).and.(1.eq.0)) then
-! Check that initial day of the simulation consistent with AMMA case:
-!      if (annee_ref.ne.2006) then
-!       print*,'Pour AMMA, annee_ref doit etre 2006'
-!       print*,'Changer annee_ref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
-!       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
-!       print*,'Changer dayref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
-!       print*,'AMMA a fini le 11 juillet'
-!       print*,'Changer dayref ou nday dans run.def'
-!       stop
-!      endif
-!      endif
-
-! Determine timestep relative to the 1st day:
-!       timeit=(day-day1)*86400.
-!       if (annee_ref.eq.1992) then
-!        timeit=(day-day_cas)*86400.
-!       else
-!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
-!       endif
-      timeit=(day-day_ju_ini_cas)*86400
-      print *,'day=',day
-      print *,'day_ju_ini_cas=',day_ju_ini_cas
-      print *,'pdt_cas=',pdt_cas
-      print *,'timeit=',timeit
-      print *,'nt_cas=',nt_cas
-
-! Determine the closest observation times:
-!       it_cas1=INT(timeit/pdt_cas)+1
-!       it_cas2=it_cas1 + 1
-!       time_cas1=(it_cas1-1)*pdt_cas
-!       time_cas2=(it_cas2-1)*pdt_cas
-
-       it_cas1=INT(timeit/pdt_cas)+1
-       IF (it_cas1 .EQ. nt_cas) THEN
+    ! inputs:
+    integer annee_ref
+    integer nt_cas,nlev_cas
+    real day, day1,day_cas
+    real ts_cas(nt_cas),tskin_cas(nt_cas),ps_cas(nt_cas)
+    real plev_cas(nlev_cas,nt_cas)
+    real t_cas(nlev_cas,nt_cas),theta_cas(nlev_cas,nt_cas)
+    real thv_cas(nlev_cas,nt_cas), thl_cas(nlev_cas,nt_cas)
+    real qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas),qi_cas(nlev_cas,nt_cas)
+    real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
+    real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
+    real temp_nudg_cas(nlev_cas,nt_cas),qv_nudg_cas(nlev_cas,nt_cas)
+    real u_nudg_cas(nlev_cas,nt_cas),v_nudg_cas(nlev_cas,nt_cas)
+
+    real invtau_temp_nudg_cas(nlev_cas,nt_cas),invtau_qv_nudg_cas(nlev_cas,nt_cas)
+    real invtau_u_nudg_cas(nlev_cas,nt_cas),invtau_v_nudg_cas(nlev_cas,nt_cas)
+
+    real vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas),tke_cas(nlev_cas,nt_cas)
+    real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
+    real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
+    real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
+    real dth_cas(nlev_cas,nt_cas),hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas)
+    real dtrad_cas(nlev_cas,nt_cas)
+    real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
+    real lat_cas(nt_cas),sens_cas(nt_cas),tkes_cas(nt_cas)
+    real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
+    real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
+
+    ! outputs:
+    real plev_prof_cas(nlev_cas)
+    real t_prof_cas(nlev_cas),theta_prof_cas(nlev_cas),thl_prof_cas(nlev_cas),thv_prof_cas(nlev_cas)
+    real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
+    real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
+    real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
+    real temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas)
+    real u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas)
+
+    real invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas)
+    real invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas)
+
+    real vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas),tke_prof_cas(nlev_cas)
+    real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
+    real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
+    real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
+    real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
+    real dtrad_prof_cas(nlev_cas)
+    real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
+    real lat_prof_cas,sens_prof_cas,tkes_prof_cas,ts_prof_cas,tskin_prof_cas,ps_prof_cas,ustar_prof_cas
+    real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
+    ! local:
+    integer it_cas1, it_cas2,k
+    real timeit,time_cas1,time_cas2,frac
+
+
+    print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
+    !       do k=1,nlev_cas
+    !       print*,'debut de interp2_case_time, plev_cas=',k,plev_cas(k,1)
+    !       enddo
+
+    ! On teste si la date du cas AMMA est correcte.
+    ! C est pour memoire car en fait les fichiers .def
+    ! sont censes etre corrects.
+    ! A supprimer a terme (MPL 20150623)
+    !     if ((forcing_type.eq.10).and.(1.eq.0)) then
+    ! Check that initial day of the simulation consistent with AMMA case:
+    !      if (annee_ref.ne.2006) then
+    !       print*,'Pour AMMA, annee_ref doit etre 2006'
+    !       print*,'Changer annee_ref dans run.def'
+    !       stop
+    !      endif
+    !      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
+    !       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
+    !       print*,'Changer dayref dans run.def'
+    !       stop
+    !      endif
+    !      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
+    !       print*,'AMMA a fini le 11 juillet'
+    !       print*,'Changer dayref ou nday dans run.def'
+    !       stop
+    !      endif
+    !      endif
+
+    ! Determine timestep relative to the 1st day:
+    !       timeit=(day-day1)*86400.
+    !       if (annee_ref.eq.1992) then
+    !        timeit=(day-day_cas)*86400.
+    !       else
+    !        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+    !       endif
+    timeit=(day-day_ju_ini_cas)*86400
+    print *,'day=',day
+    print *,'day_ju_ini_cas=',day_ju_ini_cas
+    print *,'pdt_cas=',pdt_cas
+    print *,'timeit=',timeit
+    print *,'nt_cas=',nt_cas
+
+    ! Determine the closest observation times:
+    !       it_cas1=INT(timeit/pdt_cas)+1
+    !       it_cas2=it_cas1 + 1
+    !       time_cas1=(it_cas1-1)*pdt_cas
+    !       time_cas2=(it_cas2-1)*pdt_cas
+
+    it_cas1=INT(timeit/pdt_cas)+1
+    IF (it_cas1 .EQ. nt_cas) THEN
        it_cas2=it_cas1 
-       ELSE
+    ELSE
        it_cas2=it_cas1 + 1
-       ENDIF
-       time_cas1=(it_cas1-1)*pdt_cas
-       time_cas2=(it_cas2-1)*pdt_cas
-!     print *,'timeit,pdt_cas,nt_cas=',timeit,pdt_cas,nt_cas
-!     print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
-
-       if (it_cas1 .gt. nt_cas) then 
-        write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
-     &        ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
-        stop
-       endif
-
-! time interpolation:
-       IF (it_cas1 .EQ. it_cas2) THEN
-          frac=0.
-       ELSE
-          frac=(time_cas2-timeit)/(time_cas2-time_cas1)
-          frac=max(frac,0.0)
-       ENDIF
-
-       lat_prof_cas = lat_cas(it_cas2)                                   &
-     &          -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
-       sens_prof_cas = sens_cas(it_cas2)                                 &
-     &          -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
-       tkes_prof_cas = tkes_cas(it_cas2)                                   &
-     &          -frac*(tkes_cas(it_cas2)-tkes_cas(it_cas1))
-       ts_prof_cas = ts_cas(it_cas2)                                     &
-     &          -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
-       ps_prof_cas = ps_cas(it_cas2)                                     &
-     &          -frac*(ps_cas(it_cas2)-ps_cas(it_cas1))
-       ustar_prof_cas = ustar_cas(it_cas2)                               &
-     &          -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
-
-       do k=1,nlev_cas
-        plev_prof_cas(k) = plev_cas(k,it_cas2)                           &     
-     &          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
-        t_prof_cas(k) = t_cas(k,it_cas2)                                 &        
-     &          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
-        !print *,'k,frac,plev_cas1,plev_cas2=',k,frac,plev_cas(k,it_cas1),plev_cas(k,it_cas2)
-        theta_prof_cas(k) = theta_cas(k,it_cas2)                         &                      
-     &          -frac*(theta_cas(k,it_cas2)-theta_cas(k,it_cas1))
-        thv_prof_cas(k) = thv_cas(k,it_cas2)                             &          
-     &          -frac*(thv_cas(k,it_cas2)-thv_cas(k,it_cas1))
-        thl_prof_cas(k) = thl_cas(k,it_cas2)                             &              
-     &          -frac*(thl_cas(k,it_cas2)-thl_cas(k,it_cas1))
-        qv_prof_cas(k) = qv_cas(k,it_cas2)                               &
-     &          -frac*(qv_cas(k,it_cas2)-qv_cas(k,it_cas1))
-        ql_prof_cas(k) = ql_cas(k,it_cas2)                               &
-     &          -frac*(ql_cas(k,it_cas2)-ql_cas(k,it_cas1))
-        qi_prof_cas(k) = qi_cas(k,it_cas2)                               &
-     &          -frac*(qi_cas(k,it_cas2)-qi_cas(k,it_cas1))
-        u_prof_cas(k) = u_cas(k,it_cas2)                                 &
-     &          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
-        v_prof_cas(k) = v_cas(k,it_cas2)                                 &
-     &          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
-        ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
-     &          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
-        vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
-     &          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
-        temp_nudg_prof_cas(k) = temp_nudg_cas(k,it_cas2)                    &
-     &          -frac*(temp_nudg_cas(k,it_cas2)-temp_nudg_cas(k,it_cas1))
-        qv_nudg_prof_cas(k) = qv_nudg_cas(k,it_cas2)                        &
-     &          -frac*(qv_nudg_cas(k,it_cas2)-qv_nudg_cas(k,it_cas1))
-        u_nudg_prof_cas(k) = u_nudg_cas(k,it_cas2)                          &
-     &          -frac*(u_nudg_cas(k,it_cas2)-u_nudg_cas(k,it_cas1))
-        v_nudg_prof_cas(k) = v_nudg_cas(k,it_cas2)                          &
-     &          -frac*(v_nudg_cas(k,it_cas2)-v_nudg_cas(k,it_cas1))
-        vitw_prof_cas(k) = vitw_cas(k,it_cas2)                           &
-     &          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
-        omega_prof_cas(k) = omega_cas(k,it_cas2)                         &
-     &          -frac*(omega_cas(k,it_cas2)-omega_cas(k,it_cas1))
-        tke_prof_cas(k) = tke_cas(k,it_cas2)                         &
-     &          -frac*(tke_cas(k,it_cas2)-tke_cas(k,it_cas1))
-        du_prof_cas(k) = du_cas(k,it_cas2)                               &
-     &          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
-        hu_prof_cas(k) = hu_cas(k,it_cas2)                               &
-     &          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
-        vu_prof_cas(k) = vu_cas(k,it_cas2)                               &
-     &          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
-        dv_prof_cas(k) = dv_cas(k,it_cas2)                               &
-     &          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
-        hv_prof_cas(k) = hv_cas(k,it_cas2)                               &
-     &          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
-        vv_prof_cas(k) = vv_cas(k,it_cas2)                               &
-     &          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
-        dt_prof_cas(k) = dt_cas(k,it_cas2)                               &
-     &          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
-        ht_prof_cas(k) = ht_cas(k,it_cas2)                               &
-     &          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
-        vt_prof_cas(k) = vt_cas(k,it_cas2)                               &
-     &          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
-        dth_prof_cas(k) = dth_cas(k,it_cas2)                             &
-     &          -frac*(dth_cas(k,it_cas2)-dth_cas(k,it_cas1))
-        hth_prof_cas(k) = hth_cas(k,it_cas2)                             &
-     &          -frac*(hth_cas(k,it_cas2)-hth_cas(k,it_cas1))
-        vth_prof_cas(k) = vth_cas(k,it_cas2)                             &
-     &          -frac*(vth_cas(k,it_cas2)-vth_cas(k,it_cas1))
-        dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                         &
-     &          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
-        dq_prof_cas(k) = dq_cas(k,it_cas2)                               &
-     &          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
-        hq_prof_cas(k) = hq_cas(k,it_cas2)                               &
-     &          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
-        vq_prof_cas(k) = vq_cas(k,it_cas2)                               &
-     &          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
+    ENDIF
+    time_cas1=(it_cas1-1)*pdt_cas
+    time_cas2=(it_cas2-1)*pdt_cas
+    !     print *,'timeit,pdt_cas,nt_cas=',timeit,pdt_cas,nt_cas
+    !     print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
+
+    if (it_cas1 .gt. nt_cas) then 
+       write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
+            ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
+       stop
+    endif
+
+    ! time interpolation:
+    IF (it_cas1 .EQ. it_cas2) THEN
+       frac=0.
+    ELSE
+       frac=(time_cas2-timeit)/(time_cas2-time_cas1)
+       frac=max(frac,0.0)
+    ENDIF
+
+    lat_prof_cas = lat_cas(it_cas2)                                   &
+         -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
+    sens_prof_cas = sens_cas(it_cas2)                                 &
+         -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
+    tkes_prof_cas = tkes_cas(it_cas2)                                   &
+         -frac*(tkes_cas(it_cas2)-tkes_cas(it_cas1))
+    ts_prof_cas = ts_cas(it_cas2)                                     &
+         -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
+    tskin_prof_cas = tskin_cas(it_cas2)                                     &
+         -frac*(tskin_cas(it_cas2)-tskin_cas(it_cas1))
+    ps_prof_cas = ps_cas(it_cas2)                                     &
+         -frac*(ps_cas(it_cas2)-ps_cas(it_cas1))
+    ustar_prof_cas = ustar_cas(it_cas2)                               &
+         -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
+
+    do k=1,nlev_cas
+       plev_prof_cas(k) = plev_cas(k,it_cas2)                           &     
+            -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
+       t_prof_cas(k) = t_cas(k,it_cas2)                                 &        
+            -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
+       !print *,'k,frac,plev_cas1,plev_cas2=',k,frac,plev_cas(k,it_cas1),plev_cas(k,it_cas2)
+       theta_prof_cas(k) = theta_cas(k,it_cas2)                         &                      
+            -frac*(theta_cas(k,it_cas2)-theta_cas(k,it_cas1))
+       thv_prof_cas(k) = thv_cas(k,it_cas2)                             &          
+            -frac*(thv_cas(k,it_cas2)-thv_cas(k,it_cas1))
+       thl_prof_cas(k) = thl_cas(k,it_cas2)                             &              
+            -frac*(thl_cas(k,it_cas2)-thl_cas(k,it_cas1))
+       qv_prof_cas(k) = qv_cas(k,it_cas2)                               &
+            -frac*(qv_cas(k,it_cas2)-qv_cas(k,it_cas1))
+       ql_prof_cas(k) = ql_cas(k,it_cas2)                               &
+            -frac*(ql_cas(k,it_cas2)-ql_cas(k,it_cas1))
+       qi_prof_cas(k) = qi_cas(k,it_cas2)                               &
+            -frac*(qi_cas(k,it_cas2)-qi_cas(k,it_cas1))
+       u_prof_cas(k) = u_cas(k,it_cas2)                                 &
+            -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
+       v_prof_cas(k) = v_cas(k,it_cas2)                                 &
+            -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
+       ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
+            -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
+       vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
+            -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
+       temp_nudg_prof_cas(k) = temp_nudg_cas(k,it_cas2)                    &
+            -frac*(temp_nudg_cas(k,it_cas2)-temp_nudg_cas(k,it_cas1))
+       qv_nudg_prof_cas(k) = qv_nudg_cas(k,it_cas2)                        &
+            -frac*(qv_nudg_cas(k,it_cas2)-qv_nudg_cas(k,it_cas1))
+       u_nudg_prof_cas(k) = u_nudg_cas(k,it_cas2)                          &
+            -frac*(u_nudg_cas(k,it_cas2)-u_nudg_cas(k,it_cas1))
+       v_nudg_prof_cas(k) = v_nudg_cas(k,it_cas2)                          &
+            -frac*(v_nudg_cas(k,it_cas2)-v_nudg_cas(k,it_cas1))
+       invtau_temp_nudg_prof_cas(k) = invtau_temp_nudg_cas(k,it_cas2)                    &
+            -frac*(invtau_temp_nudg_cas(k,it_cas2)-invtau_temp_nudg_cas(k,it_cas1))
+       invtau_qv_nudg_prof_cas(k) = invtau_qv_nudg_cas(k,it_cas2)                        &
+            -frac*(invtau_qv_nudg_cas(k,it_cas2)-invtau_qv_nudg_cas(k,it_cas1))
+       invtau_u_nudg_prof_cas(k) = invtau_u_nudg_cas(k,it_cas2)                          &
+            -frac*(invtau_u_nudg_cas(k,it_cas2)-invtau_u_nudg_cas(k,it_cas1))
+       invtau_v_nudg_prof_cas(k) = invtau_v_nudg_cas(k,it_cas2)                          &
+            -frac*(invtau_v_nudg_cas(k,it_cas2)-invtau_v_nudg_cas(k,it_cas1))
+       vitw_prof_cas(k) = vitw_cas(k,it_cas2)                           &
+            -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
+       omega_prof_cas(k) = omega_cas(k,it_cas2)                         &
+            -frac*(omega_cas(k,it_cas2)-omega_cas(k,it_cas1))
+       tke_prof_cas(k) = tke_cas(k,it_cas2)                         &
+            -frac*(tke_cas(k,it_cas2)-tke_cas(k,it_cas1))
+       du_prof_cas(k) = du_cas(k,it_cas2)                               &
+            -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
+       hu_prof_cas(k) = hu_cas(k,it_cas2)                               &
+            -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
+       vu_prof_cas(k) = vu_cas(k,it_cas2)                               &
+            -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
+       dv_prof_cas(k) = dv_cas(k,it_cas2)                               &
+            -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
+       hv_prof_cas(k) = hv_cas(k,it_cas2)                               &
+            -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
+       vv_prof_cas(k) = vv_cas(k,it_cas2)                               &
+            -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
+       dt_prof_cas(k) = dt_cas(k,it_cas2)                               &
+            -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
+       ht_prof_cas(k) = ht_cas(k,it_cas2)                               &
+            -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
+       vt_prof_cas(k) = vt_cas(k,it_cas2)                               &
+            -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
+       dth_prof_cas(k) = dth_cas(k,it_cas2)                             &
+            -frac*(dth_cas(k,it_cas2)-dth_cas(k,it_cas1))
+       hth_prof_cas(k) = hth_cas(k,it_cas2)                             &
+            -frac*(hth_cas(k,it_cas2)-hth_cas(k,it_cas1))
+       vth_prof_cas(k) = vth_cas(k,it_cas2)                             &
+            -frac*(vth_cas(k,it_cas2)-vth_cas(k,it_cas1))
+       dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                         &
+            -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
+       dq_prof_cas(k) = dq_cas(k,it_cas2)                               &
+            -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
+       hq_prof_cas(k) = hq_cas(k,it_cas2)                               &
+            -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
+       vq_prof_cas(k) = vq_cas(k,it_cas2)                               &
+            -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
        uw_prof_cas(k) = uw_cas(k,it_cas2)                                &
-     &          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
+            -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
        vw_prof_cas(k) = vw_cas(k,it_cas2)                                &
-     &          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
+            -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
        q1_prof_cas(k) = q1_cas(k,it_cas2)                                &
-     &          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
+            -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
        q2_prof_cas(k) = q2_cas(k,it_cas2)                                &
-     &          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
-        enddo
-
-        return
-        END SUBROUTINE interp_case_time_std
-
-!**********************************************************************************************
-!=====================================================================
-       SUBROUTINE interp2_case_vertical_std(play,plev,nlev_cas,plev_prof_cas                           &
-     &         ,t_prof_cas,th_prof_cas,thv_prof_cas,thl_prof_cas                                       &
-     &         ,qv_prof_cas,ql_prof_cas,qi_prof_cas,u_prof_cas,v_prof_cas                              &
-     &         ,ug_prof_cas,vg_prof_cas                                                                &
-     &         ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                    &
-     &         ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                              &
-     &         ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                &
-     &         ,dt_prof_cas,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas &
-     &         ,dth_prof_cas,hth_prof_cas,vth_prof_cas                                                 &
-!
-     &         ,t_mod_cas,theta_mod_cas,thv_mod_cas,thl_mod_cas                                        &
-     &         ,qv_mod_cas,ql_mod_cas,qi_mod_cas,u_mod_cas,v_mod_cas                                   &
-     &         ,ug_mod_cas,vg_mod_cas                                                                  &
-     &         ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                        &
-     &         ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                    &
-     &         ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                      &
-     &         ,dt_mod_cas,ht_mod_cas,vt_mod_cas,dtrad_mod_cas,dq_mod_cas,hq_mod_cas,vq_mod_cas        &
-     &         ,dth_mod_cas,hth_mod_cas,vth_mod_cas,mxcalc)
- 
-       implicit none
- 
+            -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
+    enddo
+
+    return
+  END SUBROUTINE interp_case_time_std
+
+  !**********************************************************************************************
+  !=====================================================================
+  SUBROUTINE interp2_case_vertical_std(play,plev,nlev_cas,plev_prof_cas                           &
+       ,t_prof_cas,th_prof_cas,thv_prof_cas,thl_prof_cas                                       &
+       ,qv_prof_cas,ql_prof_cas,qi_prof_cas,u_prof_cas,v_prof_cas                              &
+       ,ug_prof_cas,vg_prof_cas                                                                &
+       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                    &
+       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &     
+       ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                              &
+       ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                &
+       ,dt_prof_cas,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas &
+       ,dth_prof_cas,hth_prof_cas,vth_prof_cas                                                 &
+       !
+       ,t_mod_cas,theta_mod_cas,thv_mod_cas,thl_mod_cas                                        &
+       ,qv_mod_cas,ql_mod_cas,qi_mod_cas,u_mod_cas,v_mod_cas                                   &
+       ,ug_mod_cas,vg_mod_cas                                                                  &
+       ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                        &
+       ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas                        &     
+       ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                    &
+       ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                      &
+       ,dt_mod_cas,ht_mod_cas,vt_mod_cas,dtrad_mod_cas,dq_mod_cas,hq_mod_cas,vq_mod_cas        &
+       ,dth_mod_cas,hth_mod_cas,vth_mod_cas,mxcalc)
+
+    implicit none
+
 #include "YOMCST.h"
 #include "dimensions.h"
 
-!-------------------------------------------------------------------------
-! Vertical interpolation of generic case forcing data onto mod_casel levels
-!-------------------------------------------------------------------------
- 
-       integer nlevmax
-       parameter (nlevmax=41)
-       integer nlev_cas,mxcalc
-!       real play(llm), plev_prof(nlevmax) 
-!       real t_prof(nlevmax),q_prof(nlevmax)
-!       real u_prof(nlevmax),v_prof(nlevmax), w_prof(nlevmax)
-!       real ht_prof(nlevmax),vt_prof(nlevmax)
-!       real hq_prof(nlevmax),vq_prof(nlevmax)
- 
-       real play(llm), plev(llm+1), plev_prof_cas(nlev_cas) 
-       real t_prof_cas(nlev_cas),th_prof_cas(nlev_cas),thv_prof_cas(nlev_cas),thl_prof_cas(nlev_cas)
-       real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
-       real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
-       real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas), vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas),tke_prof_cas(nlev_cas)
-       real temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas)
-       real u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas)
-
-       real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
-       real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
-       real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas),dtrad_prof_cas(nlev_cas)
-       real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
-       real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
- 
-       real t_mod_cas(llm),theta_mod_cas(llm),thv_mod_cas(llm),thl_mod_cas(llm)
-       real qv_mod_cas(llm),ql_mod_cas(llm),qi_mod_cas(llm)
-       real u_mod_cas(llm),v_mod_cas(llm)
-       real ug_mod_cas(llm),vg_mod_cas(llm), w_mod_cas(llm),omega_mod_cas(llm),tke_mod_cas(llm+1)
-       real temp_nudg_mod_cas(llm),qv_nudg_mod_cas(llm)
-       real u_nudg_mod_cas(llm),v_nudg_mod_cas(llm)
-       real du_mod_cas(llm),hu_mod_cas(llm),vu_mod_cas(llm)
-       real dv_mod_cas(llm),hv_mod_cas(llm),vv_mod_cas(llm)
-       real dt_mod_cas(llm),ht_mod_cas(llm),vt_mod_cas(llm),dtrad_mod_cas(llm)
-       real dth_mod_cas(llm),hth_mod_cas(llm),vth_mod_cas(llm)
-       real dq_mod_cas(llm),hq_mod_cas(llm),vq_mod_cas(llm)
- 
-       integer l,k,k1,k2
-       real frac,frac1,frac2,fact
- 
-
-
-! for variables defined at the middle of layers
-
-       do l = 1, llm
-
-        if (play(l).ge.plev_prof_cas(nlev_cas)) then
- 
-        mxcalc=l
-!        print *,'debut interp2, mxcalc=',mxcalc
-         k1=0
-         k2=0
-
-         if (play(l).le.plev_prof_cas(1)) then
-
-         do k = 1, nlev_cas-1
-          if (play(l).le.plev_prof_cas(k).and. play(l).gt.plev_prof_cas(k+1)) then
-            k1=k
-            k2=k+1
-          endif
-         enddo
-
-         if (k1.eq.0 .or. k2.eq.0) then
-          write(*,*) 'PB! k1, k2 = ',k1,k2
-          write(*,*) 'l,play(l) = ',l,play(l)/100
-         do k = 1, nlev_cas-1
-          write(*,*) 'k,plev_prof_cas(k) = ',k,plev_prof_cas(k)/100
-         enddo
-         endif
-
-
-
-         frac = (plev_prof_cas(k2)-play(l))/(plev_prof_cas(k2)-plev_prof_cas(k1))
-         
-         t_mod_cas(l)= t_prof_cas(k2) - frac*(t_prof_cas(k2)-t_prof_cas(k1))
-         theta_mod_cas(l)= th_prof_cas(k2) - frac*(th_prof_cas(k2)-th_prof_cas(k1))
-         if(theta_mod_cas(l).NE.0) t_mod_cas(l)= theta_mod_cas(l)*(play(l)/100000.)**(RD/RCPD)
-         thv_mod_cas(l)= thv_prof_cas(k2) - frac*(thv_prof_cas(k2)-thv_prof_cas(k1))
-         thl_mod_cas(l)= thl_prof_cas(k2) - frac*(thl_prof_cas(k2)-thl_prof_cas(k1))
-         qv_mod_cas(l)= qv_prof_cas(k2) - frac*(qv_prof_cas(k2)-qv_prof_cas(k1))
-         ql_mod_cas(l)= ql_prof_cas(k2) - frac*(ql_prof_cas(k2)-ql_prof_cas(k1))
-         qi_mod_cas(l)= qi_prof_cas(k2) - frac*(qi_prof_cas(k2)-qi_prof_cas(k1))
-         u_mod_cas(l)= u_prof_cas(k2) - frac*(u_prof_cas(k2)-u_prof_cas(k1))
-         v_mod_cas(l)= v_prof_cas(k2) - frac*(v_prof_cas(k2)-v_prof_cas(k1))
-         ug_mod_cas(l)= ug_prof_cas(k2) - frac*(ug_prof_cas(k2)-ug_prof_cas(k1))
-         vg_mod_cas(l)= vg_prof_cas(k2) - frac*(vg_prof_cas(k2)-vg_prof_cas(k1))
-         temp_nudg_mod_cas(l)= temp_nudg_prof_cas(k2) - frac*(temp_nudg_prof_cas(k2)-temp_nudg_prof_cas(k1))
-         qv_nudg_mod_cas(l)= qv_nudg_prof_cas(k2) - frac*(qv_nudg_prof_cas(k2)-qv_nudg_prof_cas(k1))
-         u_nudg_mod_cas(l)= u_nudg_prof_cas(k2) - frac*(u_nudg_prof_cas(k2)-u_nudg_prof_cas(k1))
-         v_nudg_mod_cas(l)= v_nudg_prof_cas(k2) - frac*(v_nudg_prof_cas(k2)-v_nudg_prof_cas(k1))
-         w_mod_cas(l)= vitw_prof_cas(k2) - frac*(vitw_prof_cas(k2)-vitw_prof_cas(k1))
-         omega_mod_cas(l)= omega_prof_cas(k2) - frac*(omega_prof_cas(k2)-omega_prof_cas(k1))
-         du_mod_cas(l)= du_prof_cas(k2) - frac*(du_prof_cas(k2)-du_prof_cas(k1))
-         hu_mod_cas(l)= hu_prof_cas(k2) - frac*(hu_prof_cas(k2)-hu_prof_cas(k1))
-         vu_mod_cas(l)= vu_prof_cas(k2) - frac*(vu_prof_cas(k2)-vu_prof_cas(k1))
-         dv_mod_cas(l)= dv_prof_cas(k2) - frac*(dv_prof_cas(k2)-dv_prof_cas(k1))
-         hv_mod_cas(l)= hv_prof_cas(k2) - frac*(hv_prof_cas(k2)-hv_prof_cas(k1))
-         vv_mod_cas(l)= vv_prof_cas(k2) - frac*(vv_prof_cas(k2)-vv_prof_cas(k1))
-         dt_mod_cas(l)= dt_prof_cas(k2) - frac*(dt_prof_cas(k2)-dt_prof_cas(k1))
-         ht_mod_cas(l)= ht_prof_cas(k2) - frac*(ht_prof_cas(k2)-ht_prof_cas(k1))
-         vt_mod_cas(l)= vt_prof_cas(k2) - frac*(vt_prof_cas(k2)-vt_prof_cas(k1))
-         dth_mod_cas(l)= dth_prof_cas(k2) - frac*(dth_prof_cas(k2)-dth_prof_cas(k1))
-         hth_mod_cas(l)= hth_prof_cas(k2) - frac*(hth_prof_cas(k2)-hth_prof_cas(k1))
-         vth_mod_cas(l)= vth_prof_cas(k2) - frac*(vth_prof_cas(k2)-vth_prof_cas(k1))
-         dq_mod_cas(l)= dq_prof_cas(k2) - frac*(dq_prof_cas(k2)-dq_prof_cas(k1))
-         hq_mod_cas(l)= hq_prof_cas(k2) - frac*(hq_prof_cas(k2)-hq_prof_cas(k1))
-         vq_mod_cas(l)= vq_prof_cas(k2) - frac*(vq_prof_cas(k2)-vq_prof_cas(k1))
-         dtrad_mod_cas(l)= dtrad_prof_cas(k2) - frac*(dtrad_prof_cas(k2)-dtrad_prof_cas(k1))
-     
-         else !play>plev_prof_cas(1)
-
-         k1=1
-         k2=2
-         print *,'interp2_vert, k1,k2=',plev_prof_cas(k1),plev_prof_cas(k2)
-         frac1 = (play(l)-plev_prof_cas(k2))/(plev_prof_cas(k1)-plev_prof_cas(k2))
-         frac2 = (play(l)-plev_prof_cas(k1))/(plev_prof_cas(k1)-plev_prof_cas(k2))
-         t_mod_cas(l)= frac1*t_prof_cas(k1) - frac2*t_prof_cas(k2)
-         theta_mod_cas(l)= frac1*th_prof_cas(k1) - frac2*th_prof_cas(k2)
-         if(theta_mod_cas(l).NE.0) t_mod_cas(l)= theta_mod_cas(l)*(play(l)/100000.)**(RD/RCPD)
-         thv_mod_cas(l)= frac1*thv_prof_cas(k1) - frac2*thv_prof_cas(k2)
-         thl_mod_cas(l)= frac1*thl_prof_cas(k1) - frac2*thl_prof_cas(k2)
-         qv_mod_cas(l)= frac1*qv_prof_cas(k1) - frac2*qv_prof_cas(k2)
-         ql_mod_cas(l)= frac1*ql_prof_cas(k1) - frac2*ql_prof_cas(k2)
-         qi_mod_cas(l)= frac1*qi_prof_cas(k1) - frac2*qi_prof_cas(k2)
-         u_mod_cas(l)= frac1*u_prof_cas(k1) - frac2*u_prof_cas(k2)
-         v_mod_cas(l)= frac1*v_prof_cas(k1) - frac2*v_prof_cas(k2)
-         ug_mod_cas(l)= frac1*ug_prof_cas(k1) - frac2*ug_prof_cas(k2)
-         vg_mod_cas(l)= frac1*vg_prof_cas(k1) - frac2*vg_prof_cas(k2)
-         temp_nudg_mod_cas(l)= frac1*temp_nudg_prof_cas(k1) - frac2*temp_nudg_prof_cas(k2)
-         qv_nudg_mod_cas(l)= frac1*qv_nudg_prof_cas(k1) - frac2*qv_nudg_prof_cas(k2)
-         u_nudg_mod_cas(l)= frac1*u_nudg_prof_cas(k1) - frac2*u_nudg_prof_cas(k2)
-         v_nudg_mod_cas(l)= frac1*v_nudg_prof_cas(k1) - frac2*v_nudg_prof_cas(k2)
-         w_mod_cas(l)= frac1*vitw_prof_cas(k1) - frac2*vitw_prof_cas(k2)
-         omega_mod_cas(l)= frac1*omega_prof_cas(k1) - frac2*omega_prof_cas(k2)
-         du_mod_cas(l)= frac1*du_prof_cas(k1) - frac2*du_prof_cas(k2)
-         hu_mod_cas(l)= frac1*hu_prof_cas(k1) - frac2*hu_prof_cas(k2)
-         vu_mod_cas(l)= frac1*vu_prof_cas(k1) - frac2*vu_prof_cas(k2)
-         dv_mod_cas(l)= frac1*dv_prof_cas(k1) - frac2*dv_prof_cas(k2)
-         hv_mod_cas(l)= frac1*hv_prof_cas(k1) - frac2*hv_prof_cas(k2)
-         vv_mod_cas(l)= frac1*vv_prof_cas(k1) - frac2*vv_prof_cas(k2)
-         dt_mod_cas(l)= frac1*dt_prof_cas(k1) - frac2*dt_prof_cas(k2)
-         ht_mod_cas(l)= frac1*ht_prof_cas(k1) - frac2*ht_prof_cas(k2)
-         vt_mod_cas(l)= frac1*vt_prof_cas(k1) - frac2*vt_prof_cas(k2)
-         dth_mod_cas(l)= frac1*dth_prof_cas(k1) - frac2*dth_prof_cas(k2)
-         hth_mod_cas(l)= frac1*hth_prof_cas(k1) - frac2*hth_prof_cas(k2)
-         vth_mod_cas(l)= frac1*vth_prof_cas(k1) - frac2*vth_prof_cas(k2)
-         dq_mod_cas(l)= frac1*dq_prof_cas(k1) - frac2*dq_prof_cas(k2)
-         hq_mod_cas(l)= frac1*hq_prof_cas(k1) - frac2*hq_prof_cas(k2)
-         vq_mod_cas(l)= frac1*vq_prof_cas(k1) - frac2*vq_prof_cas(k2)
-         dtrad_mod_cas(l)= frac1*dtrad_prof_cas(k1) - frac2*dtrad_prof_cas(k2)
-
-         endif ! play.le.plev_prof_cas(1)
-
-        else ! above max altitude of forcing file
- 
-!jyg
-         fact=20.*(plev_prof_cas(nlev_cas)-play(l))/plev_prof_cas(nlev_cas) !jyg
-         fact = max(fact,0.)                                           !jyg
-         fact = exp(-fact)                                             !jyg
-         t_mod_cas(l)= t_prof_cas(nlev_cas)                            !jyg
-         theta_mod_cas(l)= th_prof_cas(nlev_cas)                       !jyg
-         thv_mod_cas(l)= thv_prof_cas(nlev_cas)                        !jyg
-         thl_mod_cas(l)= thl_prof_cas(nlev_cas)                        !jyg
-         qv_mod_cas(l)= qv_prof_cas(nlev_cas)*fact                     !jyg
-         ql_mod_cas(l)= ql_prof_cas(nlev_cas)*fact                     !jyg
-         qi_mod_cas(l)= qi_prof_cas(nlev_cas)*fact                     !jyg
-         u_mod_cas(l)= u_prof_cas(nlev_cas)*fact                       !jyg
-         v_mod_cas(l)= v_prof_cas(nlev_cas)*fact                       !jyg
-         ug_mod_cas(l)= ug_prof_cas(nlev_cas)                          !jyg
-         vg_mod_cas(l)= vg_prof_cas(nlev_cas)                          !jyg
-         temp_nudg_mod_cas(l)= temp_nudg_prof_cas(nlev_cas)            !jyg
-         qv_nudg_mod_cas(l)= qv_nudg_prof_cas(nlev_cas)                !jyg
-         u_nudg_mod_cas(l)= u_nudg_prof_cas(nlev_cas)                  !jyg
-         v_nudg_mod_cas(l)= v_nudg_prof_cas(nlev_cas)                  !jyg
-         thv_mod_cas(l)= thv_prof_cas(nlev_cas)                        !jyg
-         w_mod_cas(l)= 0.0                                             !jyg
-         omega_mod_cas(l)= 0.0                                         !jyg
-         du_mod_cas(l)= du_prof_cas(nlev_cas)*fact 
-         hu_mod_cas(l)= hu_prof_cas(nlev_cas)*fact                     !jyg
-         vu_mod_cas(l)= vu_prof_cas(nlev_cas)*fact                     !jyg
-         dv_mod_cas(l)= dv_prof_cas(nlev_cas)*fact
-         hv_mod_cas(l)= hv_prof_cas(nlev_cas)*fact                     !jyg
-         vv_mod_cas(l)= vv_prof_cas(nlev_cas)*fact                     !jyg
-         dt_mod_cas(l)= dt_prof_cas(nlev_cas) 
-         ht_mod_cas(l)= ht_prof_cas(nlev_cas)                          !jyg
-         vt_mod_cas(l)= vt_prof_cas(nlev_cas)                          !jyg
-         dth_mod_cas(l)= dth_prof_cas(nlev_cas) 
-         hth_mod_cas(l)= hth_prof_cas(nlev_cas)                        !jyg
-         vth_mod_cas(l)= vth_prof_cas(nlev_cas)                        !jyg
-         dq_mod_cas(l)= dq_prof_cas(nlev_cas)*fact 
-         hq_mod_cas(l)= hq_prof_cas(nlev_cas)*fact                     !jyg
-         vq_mod_cas(l)= vq_prof_cas(nlev_cas)*fact                     !jyg
-         dtrad_mod_cas(l)= dtrad_prof_cas(nlev_cas)*fact               !jyg
- 
-        endif ! play
- 
-       enddo ! l
-
-! for variables defined at layer interfaces (EV):
-
-
-       do l = 1, llm+1
-
-        if (plev(l).ge.plev_prof_cas(nlev_cas)) then
-
-         mxcalc=l
-         k1=0
-         k2=0
-
-         if (plev(l).le.plev_prof_cas(1)) then
-
-         do k = 1, nlev_cas-1
-          if (plev(l).le.plev_prof_cas(k).and. plev(l).gt.plev_prof_cas(k+1)) then
-            k1=k
-            k2=k+1
-          endif
-         enddo
-
-         if (k1.eq.0 .or. k2.eq.0) then
-          write(*,*) 'PB! k1, k2 = ',k1,k2
-          write(*,*) 'l,plev(l) = ',l,plev(l)/100
-         do k = 1, nlev_cas-1
-          write(*,*) 'k,plev_prof_cas(k) = ',k,plev_prof_cas(k)/100
-         enddo
-         endif
-
-         frac = (plev_prof_cas(k2)-plev(l))/(plev_prof_cas(k2)-plev_prof_cas(k1))
-         tke_mod_cas(l)= tke_prof_cas(k2) - frac*(tke_prof_cas(k2)-tke_prof_cas(k1))
-         else !play>plev_prof_cas(1)
-         k1=1
-         k2=2
-         tke_mod_cas(l)= frac1*tke_prof_cas(k1) - frac2*tke_prof_cas(k2)
-
-         endif ! plev.le.plev_prof_cas(1)
-
-        else ! above max altitude of forcing file
-
-         tke_mod_cas(l)=0.0
-
-        endif ! plev
-
-       enddo ! l
-
-
-
-          return
-          end SUBROUTINE interp2_case_vertical_std
-!***************************************************************************** 
+    !-------------------------------------------------------------------------
+    ! Vertical interpolation of generic case forcing data onto mod_casel levels
+    !-------------------------------------------------------------------------
+
+    integer nlevmax
+    parameter (nlevmax=41)
+    integer nlev_cas,mxcalc
+    !       real play(llm), plev_prof(nlevmax) 
+    !       real t_prof(nlevmax),q_prof(nlevmax)
+    !       real u_prof(nlevmax),v_prof(nlevmax), w_prof(nlevmax)
+    !       real ht_prof(nlevmax),vt_prof(nlevmax)
+    !       real hq_prof(nlevmax),vq_prof(nlevmax)
+
+    real play(llm), plev(llm+1), plev_prof_cas(nlev_cas) 
+    real t_prof_cas(nlev_cas),th_prof_cas(nlev_cas),thv_prof_cas(nlev_cas),thl_prof_cas(nlev_cas)
+    real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
+    real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
+    real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas), vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas),tke_prof_cas(nlev_cas)
+    real temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas)
+    real u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas)
+    real invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas)
+    real invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas)
+
+    real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
+    real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
+    real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas),dtrad_prof_cas(nlev_cas)
+    real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
+    real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
+
+    real t_mod_cas(llm),theta_mod_cas(llm),thv_mod_cas(llm),thl_mod_cas(llm)
+    real qv_mod_cas(llm),ql_mod_cas(llm),qi_mod_cas(llm)
+    real u_mod_cas(llm),v_mod_cas(llm)
+    real ug_mod_cas(llm),vg_mod_cas(llm), w_mod_cas(llm),omega_mod_cas(llm),tke_mod_cas(llm+1)
+    real temp_nudg_mod_cas(llm),qv_nudg_mod_cas(llm)
+    real u_nudg_mod_cas(llm),v_nudg_mod_cas(llm)
+    real invtau_temp_nudg_mod_cas(llm),invtau_qv_nudg_mod_cas(llm)
+    real invtau_u_nudg_mod_cas(llm),invtau_v_nudg_mod_cas(llm)
+    real du_mod_cas(llm),hu_mod_cas(llm),vu_mod_cas(llm)
+    real dv_mod_cas(llm),hv_mod_cas(llm),vv_mod_cas(llm)
+    real dt_mod_cas(llm),ht_mod_cas(llm),vt_mod_cas(llm),dtrad_mod_cas(llm)
+    real dth_mod_cas(llm),hth_mod_cas(llm),vth_mod_cas(llm)
+    real dq_mod_cas(llm),hq_mod_cas(llm),vq_mod_cas(llm)
+
+    integer l,k,k1,k2
+    real frac,frac1,frac2,fact
+
+
+
+    ! for variables defined at the middle of layers
+
+    do l = 1, llm
+
+       if (play(l).ge.plev_prof_cas(nlev_cas)) then
+
+          mxcalc=l
+          !        print *,'debut interp2, mxcalc=',mxcalc
+          k1=0
+          k2=0
+
+          if (play(l).le.plev_prof_cas(1)) then
+
+             do k = 1, nlev_cas-1
+                if (play(l).le.plev_prof_cas(k).and. play(l).gt.plev_prof_cas(k+1)) then
+                   k1=k
+                   k2=k+1
+                endif
+             enddo
+
+             if (k1.eq.0 .or. k2.eq.0) then
+                write(*,*) 'PB! k1, k2 = ',k1,k2
+                write(*,*) 'l,play(l) = ',l,play(l)/100
+                do k = 1, nlev_cas-1
+                   write(*,*) 'k,plev_prof_cas(k) = ',k,plev_prof_cas(k)/100
+                enddo
+             endif
+
+
+
+             frac = (plev_prof_cas(k2)-play(l))/(plev_prof_cas(k2)-plev_prof_cas(k1))
+
+             t_mod_cas(l)= t_prof_cas(k2) - frac*(t_prof_cas(k2)-t_prof_cas(k1))
+             theta_mod_cas(l)= th_prof_cas(k2) - frac*(th_prof_cas(k2)-th_prof_cas(k1))
+             if(theta_mod_cas(l).NE.0) t_mod_cas(l)= theta_mod_cas(l)*(play(l)/100000.)**(RD/RCPD)
+             thv_mod_cas(l)= thv_prof_cas(k2) - frac*(thv_prof_cas(k2)-thv_prof_cas(k1))
+             thl_mod_cas(l)= thl_prof_cas(k2) - frac*(thl_prof_cas(k2)-thl_prof_cas(k1))
+             qv_mod_cas(l)= qv_prof_cas(k2) - frac*(qv_prof_cas(k2)-qv_prof_cas(k1))
+             ql_mod_cas(l)= ql_prof_cas(k2) - frac*(ql_prof_cas(k2)-ql_prof_cas(k1))
+             qi_mod_cas(l)= qi_prof_cas(k2) - frac*(qi_prof_cas(k2)-qi_prof_cas(k1))
+             u_mod_cas(l)= u_prof_cas(k2) - frac*(u_prof_cas(k2)-u_prof_cas(k1))
+             v_mod_cas(l)= v_prof_cas(k2) - frac*(v_prof_cas(k2)-v_prof_cas(k1))
+             ug_mod_cas(l)= ug_prof_cas(k2) - frac*(ug_prof_cas(k2)-ug_prof_cas(k1))
+             vg_mod_cas(l)= vg_prof_cas(k2) - frac*(vg_prof_cas(k2)-vg_prof_cas(k1))
+             temp_nudg_mod_cas(l)= temp_nudg_prof_cas(k2) - frac*(temp_nudg_prof_cas(k2)-temp_nudg_prof_cas(k1))
+             qv_nudg_mod_cas(l)= qv_nudg_prof_cas(k2) - frac*(qv_nudg_prof_cas(k2)-qv_nudg_prof_cas(k1))
+             u_nudg_mod_cas(l)= u_nudg_prof_cas(k2) - frac*(u_nudg_prof_cas(k2)-u_nudg_prof_cas(k1))
+             v_nudg_mod_cas(l)= v_nudg_prof_cas(k2) - frac*(v_nudg_prof_cas(k2)-v_nudg_prof_cas(k1))
+
+             invtau_temp_nudg_mod_cas(l)= invtau_temp_nudg_prof_cas(k2) &
+                  - frac*(invtau_temp_nudg_prof_cas(k2)-invtau_temp_nudg_prof_cas(k1))
+             invtau_qv_nudg_mod_cas(l)= invtau_qv_nudg_prof_cas(k2) - frac*(invtau_qv_nudg_prof_cas(k2)-invtau_qv_nudg_prof_cas(k1))
+             invtau_u_nudg_mod_cas(l)= invtau_u_nudg_prof_cas(k2) - frac*(invtau_u_nudg_prof_cas(k2)-invtau_u_nudg_prof_cas(k1))
+             invtau_v_nudg_mod_cas(l)= invtau_v_nudg_prof_cas(k2) - frac*(invtau_v_nudg_prof_cas(k2)-invtau_v_nudg_prof_cas(k1))
+
+             w_mod_cas(l)= vitw_prof_cas(k2) - frac*(vitw_prof_cas(k2)-vitw_prof_cas(k1))
+             omega_mod_cas(l)= omega_prof_cas(k2) - frac*(omega_prof_cas(k2)-omega_prof_cas(k1))
+             du_mod_cas(l)= du_prof_cas(k2) - frac*(du_prof_cas(k2)-du_prof_cas(k1))
+             hu_mod_cas(l)= hu_prof_cas(k2) - frac*(hu_prof_cas(k2)-hu_prof_cas(k1))
+             vu_mod_cas(l)= vu_prof_cas(k2) - frac*(vu_prof_cas(k2)-vu_prof_cas(k1))
+             dv_mod_cas(l)= dv_prof_cas(k2) - frac*(dv_prof_cas(k2)-dv_prof_cas(k1))
+             hv_mod_cas(l)= hv_prof_cas(k2) - frac*(hv_prof_cas(k2)-hv_prof_cas(k1))
+             vv_mod_cas(l)= vv_prof_cas(k2) - frac*(vv_prof_cas(k2)-vv_prof_cas(k1))
+             dt_mod_cas(l)= dt_prof_cas(k2) - frac*(dt_prof_cas(k2)-dt_prof_cas(k1))
+             ht_mod_cas(l)= ht_prof_cas(k2) - frac*(ht_prof_cas(k2)-ht_prof_cas(k1))
+             vt_mod_cas(l)= vt_prof_cas(k2) - frac*(vt_prof_cas(k2)-vt_prof_cas(k1))
+             dth_mod_cas(l)= dth_prof_cas(k2) - frac*(dth_prof_cas(k2)-dth_prof_cas(k1))
+             hth_mod_cas(l)= hth_prof_cas(k2) - frac*(hth_prof_cas(k2)-hth_prof_cas(k1))
+             vth_mod_cas(l)= vth_prof_cas(k2) - frac*(vth_prof_cas(k2)-vth_prof_cas(k1))
+             dq_mod_cas(l)= dq_prof_cas(k2) - frac*(dq_prof_cas(k2)-dq_prof_cas(k1))
+             hq_mod_cas(l)= hq_prof_cas(k2) - frac*(hq_prof_cas(k2)-hq_prof_cas(k1))
+             vq_mod_cas(l)= vq_prof_cas(k2) - frac*(vq_prof_cas(k2)-vq_prof_cas(k1))
+             dtrad_mod_cas(l)= dtrad_prof_cas(k2) - frac*(dtrad_prof_cas(k2)-dtrad_prof_cas(k1))
+
+          else !play>plev_prof_cas(1)
+
+             k1=1
+             k2=2
+             print *,'interp2_vert, k1,k2=',plev_prof_cas(k1),plev_prof_cas(k2)
+             frac1 = (play(l)-plev_prof_cas(k2))/(plev_prof_cas(k1)-plev_prof_cas(k2))
+             frac2 = (play(l)-plev_prof_cas(k1))/(plev_prof_cas(k1)-plev_prof_cas(k2))
+             t_mod_cas(l)= frac1*t_prof_cas(k1) - frac2*t_prof_cas(k2)
+             theta_mod_cas(l)= frac1*th_prof_cas(k1) - frac2*th_prof_cas(k2)
+             if(theta_mod_cas(l).NE.0) t_mod_cas(l)= theta_mod_cas(l)*(play(l)/100000.)**(RD/RCPD)
+             thv_mod_cas(l)= frac1*thv_prof_cas(k1) - frac2*thv_prof_cas(k2)
+             thl_mod_cas(l)= frac1*thl_prof_cas(k1) - frac2*thl_prof_cas(k2)
+             qv_mod_cas(l)= frac1*qv_prof_cas(k1) - frac2*qv_prof_cas(k2)
+             ql_mod_cas(l)= frac1*ql_prof_cas(k1) - frac2*ql_prof_cas(k2)
+             qi_mod_cas(l)= frac1*qi_prof_cas(k1) - frac2*qi_prof_cas(k2)
+             u_mod_cas(l)= frac1*u_prof_cas(k1) - frac2*u_prof_cas(k2)
+             v_mod_cas(l)= frac1*v_prof_cas(k1) - frac2*v_prof_cas(k2)
+             ug_mod_cas(l)= frac1*ug_prof_cas(k1) - frac2*ug_prof_cas(k2)
+             vg_mod_cas(l)= frac1*vg_prof_cas(k1) - frac2*vg_prof_cas(k2)
+             temp_nudg_mod_cas(l)= frac1*temp_nudg_prof_cas(k1) - frac2*temp_nudg_prof_cas(k2)
+             qv_nudg_mod_cas(l)= frac1*qv_nudg_prof_cas(k1) - frac2*qv_nudg_prof_cas(k2)
+             u_nudg_mod_cas(l)= frac1*u_nudg_prof_cas(k1) - frac2*u_nudg_prof_cas(k2)
+             v_nudg_mod_cas(l)= frac1*v_nudg_prof_cas(k1) - frac2*v_nudg_prof_cas(k2)
+
+             invtau_temp_nudg_mod_cas(l)= frac1*invtau_temp_nudg_prof_cas(k1) - frac2*invtau_temp_nudg_prof_cas(k2)
+             invtau_qv_nudg_mod_cas(l)= frac1*invtau_qv_nudg_prof_cas(k1) - frac2*invtau_qv_nudg_prof_cas(k2)
+             invtau_u_nudg_mod_cas(l)= frac1*invtau_u_nudg_prof_cas(k1) - frac2*invtau_u_nudg_prof_cas(k2)
+             invtau_v_nudg_mod_cas(l)= frac1*invtau_v_nudg_prof_cas(k1) - frac2*invtau_v_nudg_prof_cas(k2)
+
+             w_mod_cas(l)= frac1*vitw_prof_cas(k1) - frac2*vitw_prof_cas(k2)
+             omega_mod_cas(l)= frac1*omega_prof_cas(k1) - frac2*omega_prof_cas(k2)
+             du_mod_cas(l)= frac1*du_prof_cas(k1) - frac2*du_prof_cas(k2)
+             hu_mod_cas(l)= frac1*hu_prof_cas(k1) - frac2*hu_prof_cas(k2)
+             vu_mod_cas(l)= frac1*vu_prof_cas(k1) - frac2*vu_prof_cas(k2)
+             dv_mod_cas(l)= frac1*dv_prof_cas(k1) - frac2*dv_prof_cas(k2)
+             hv_mod_cas(l)= frac1*hv_prof_cas(k1) - frac2*hv_prof_cas(k2)
+             vv_mod_cas(l)= frac1*vv_prof_cas(k1) - frac2*vv_prof_cas(k2)
+             dt_mod_cas(l)= frac1*dt_prof_cas(k1) - frac2*dt_prof_cas(k2)
+             ht_mod_cas(l)= frac1*ht_prof_cas(k1) - frac2*ht_prof_cas(k2)
+             vt_mod_cas(l)= frac1*vt_prof_cas(k1) - frac2*vt_prof_cas(k2)
+             dth_mod_cas(l)= frac1*dth_prof_cas(k1) - frac2*dth_prof_cas(k2)
+             hth_mod_cas(l)= frac1*hth_prof_cas(k1) - frac2*hth_prof_cas(k2)
+             vth_mod_cas(l)= frac1*vth_prof_cas(k1) - frac2*vth_prof_cas(k2)
+             dq_mod_cas(l)= frac1*dq_prof_cas(k1) - frac2*dq_prof_cas(k2)
+             hq_mod_cas(l)= frac1*hq_prof_cas(k1) - frac2*hq_prof_cas(k2)
+             vq_mod_cas(l)= frac1*vq_prof_cas(k1) - frac2*vq_prof_cas(k2)
+             dtrad_mod_cas(l)= frac1*dtrad_prof_cas(k1) - frac2*dtrad_prof_cas(k2)
+
+          endif ! play.le.plev_prof_cas(1)
+
+       else ! above max altitude of forcing file
+
+          !jyg
+          fact=20.*(plev_prof_cas(nlev_cas)-play(l))/plev_prof_cas(nlev_cas) !jyg
+          fact = max(fact,0.)                                           !jyg
+          fact = exp(-fact)                                             !jyg
+          t_mod_cas(l)= t_prof_cas(nlev_cas)                            !jyg
+          theta_mod_cas(l)= th_prof_cas(nlev_cas)                       !jyg
+          thv_mod_cas(l)= thv_prof_cas(nlev_cas)                        !jyg
+          thl_mod_cas(l)= thl_prof_cas(nlev_cas)                        !jyg
+          qv_mod_cas(l)= qv_prof_cas(nlev_cas)*fact                     !jyg
+          ql_mod_cas(l)= ql_prof_cas(nlev_cas)*fact                     !jyg
+          qi_mod_cas(l)= qi_prof_cas(nlev_cas)*fact                     !jyg
+          u_mod_cas(l)= u_prof_cas(nlev_cas)*fact                       !jyg
+          v_mod_cas(l)= v_prof_cas(nlev_cas)*fact                       !jyg
+          ug_mod_cas(l)= ug_prof_cas(nlev_cas)                          !jyg
+          vg_mod_cas(l)= vg_prof_cas(nlev_cas)                          !jyg
+          temp_nudg_mod_cas(l)= temp_nudg_prof_cas(nlev_cas)            !jyg
+          qv_nudg_mod_cas(l)= qv_nudg_prof_cas(nlev_cas)                !jyg
+          u_nudg_mod_cas(l)= u_nudg_prof_cas(nlev_cas)                  !jyg
+          v_nudg_mod_cas(l)= v_nudg_prof_cas(nlev_cas)                  !jyg
+
+          invtau_temp_nudg_mod_cas(l)= invtau_temp_nudg_prof_cas(nlev_cas)            !jyg
+          invtau_qv_nudg_mod_cas(l)= invtau_qv_nudg_prof_cas(nlev_cas)                !jyg
+          invtau_u_nudg_mod_cas(l)= invtau_u_nudg_prof_cas(nlev_cas)                  !jyg
+          invtau_v_nudg_mod_cas(l)= invtau_v_nudg_prof_cas(nlev_cas)                  !jyg
+
+          thv_mod_cas(l)= thv_prof_cas(nlev_cas)                        !jyg
+          w_mod_cas(l)= 0.0                                             !jyg
+          omega_mod_cas(l)= 0.0                                         !jyg
+          du_mod_cas(l)= du_prof_cas(nlev_cas)*fact 
+          hu_mod_cas(l)= hu_prof_cas(nlev_cas)*fact                     !jyg
+          vu_mod_cas(l)= vu_prof_cas(nlev_cas)*fact                     !jyg
+          dv_mod_cas(l)= dv_prof_cas(nlev_cas)*fact
+          hv_mod_cas(l)= hv_prof_cas(nlev_cas)*fact                     !jyg
+          vv_mod_cas(l)= vv_prof_cas(nlev_cas)*fact                     !jyg
+          dt_mod_cas(l)= dt_prof_cas(nlev_cas) 
+          ht_mod_cas(l)= ht_prof_cas(nlev_cas)                          !jyg
+          vt_mod_cas(l)= vt_prof_cas(nlev_cas)                          !jyg
+          dth_mod_cas(l)= dth_prof_cas(nlev_cas) 
+          hth_mod_cas(l)= hth_prof_cas(nlev_cas)                        !jyg
+          vth_mod_cas(l)= vth_prof_cas(nlev_cas)                        !jyg
+          dq_mod_cas(l)= dq_prof_cas(nlev_cas)*fact 
+          hq_mod_cas(l)= hq_prof_cas(nlev_cas)*fact                     !jyg
+          vq_mod_cas(l)= vq_prof_cas(nlev_cas)*fact                     !jyg
+          dtrad_mod_cas(l)= dtrad_prof_cas(nlev_cas)*fact               !jyg
+
+       endif ! play
+
+    enddo ! l
+
+    ! for variables defined at layer interfaces (EV):
+
+
+    do l = 1, llm+1
+
+       if (plev(l).ge.plev_prof_cas(nlev_cas)) then
+
+          mxcalc=l
+          k1=0
+          k2=0
+
+          if (plev(l).le.plev_prof_cas(1)) then
+
+             do k = 1, nlev_cas-1
+                if (plev(l).le.plev_prof_cas(k).and. plev(l).gt.plev_prof_cas(k+1)) then
+                   k1=k
+                   k2=k+1
+                endif
+             enddo
+
+             if (k1.eq.0 .or. k2.eq.0) then
+                write(*,*) 'PB! k1, k2 = ',k1,k2
+                write(*,*) 'l,plev(l) = ',l,plev(l)/100
+                do k = 1, nlev_cas-1
+                   write(*,*) 'k,plev_prof_cas(k) = ',k,plev_prof_cas(k)/100
+                enddo
+             endif
+
+             frac = (plev_prof_cas(k2)-plev(l))/(plev_prof_cas(k2)-plev_prof_cas(k1))
+             tke_mod_cas(l)= tke_prof_cas(k2) - frac*(tke_prof_cas(k2)-tke_prof_cas(k1))
+          else !play>plev_prof_cas(1)
+             k1=1
+             k2=2
+             frac1 = (play(l)-plev_prof_cas(k2))/(plev_prof_cas(k1)-plev_prof_cas(k2))
+             frac2 = (play(l)-plev_prof_cas(k1))/(plev_prof_cas(k1)-plev_prof_cas(k2))
+             tke_mod_cas(l)= frac1*tke_prof_cas(k1) - frac2*tke_prof_cas(k2)
+
+          endif ! plev.le.plev_prof_cas(1)
+
+       else ! above max altitude of forcing file
+
+          tke_mod_cas(l)=0.0
+
+       endif ! plev
+
+    enddo ! l
+
+
+
+    return
+  end SUBROUTINE interp2_case_vertical_std
+  !***************************************************************************** 
 
 
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_1DUTILS_read_interp.h
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_1DUTILS_read_interp.h	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_1DUTILS_read_interp.h	(revision 4368)
@@ -146,5 +146,5 @@
 !program reading forcings of the TWP-ICE experiment
 
-!      use netcdf
+        use netcdf, only: nf90_get_var
 
       implicit none
@@ -314,9 +314,5 @@
        enddo
           
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),lat)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(1),lat)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(1),lat)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -325,9 +321,5 @@
 !         write(*,*)'lecture lat ok',lat
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),lon)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(2),lon)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(2),lon)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -336,9 +328,5 @@
 !         write(*,*)'lecture lon ok',lon
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),alt)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(3),alt)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(3),alt)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -347,9 +335,5 @@
 !          write(*,*)'lecture alt ok',alt
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),phis)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(4),phis)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(4),phis)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -358,9 +342,5 @@
 !          write(*,*)'lecture phis ok',phis
           
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),T)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(5),T)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(5),T)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -369,9 +349,5 @@
 !         write(*,*)'lecture T ok'
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),q)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(6),q)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(6),q)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -385,9 +361,5 @@
        enddo
        enddo
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),u)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(7),u)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(7),u)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -396,9 +368,5 @@
 !         write(*,*)'lecture u ok'
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(8),v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(8),v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -407,9 +375,5 @@
 !         write(*,*)'lecture v ok'
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),omega)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(9),omega)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(9),omega)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -424,9 +388,5 @@
        enddo
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),div)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(10),div)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(10),div)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -435,9 +395,5 @@
 !         write(*,*)'lecture div ok'
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),T_adv_h)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(11),T_adv_h)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(11),T_adv_h)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -453,9 +409,5 @@
 
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),T_adv_v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(12),T_adv_v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(12),T_adv_v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -470,9 +422,5 @@
        enddo
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),q_adv_h)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(13),q_adv_h)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(13),q_adv_h)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -488,9 +436,5 @@
 
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(14),q_adv_v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(14),q_adv_v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(14),q_adv_v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -506,59 +450,35 @@
 
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(15),s)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(15),s)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(16),s_adv_h)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(16),s_adv_h)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(17),s_adv_v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(17),s_adv_v)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(18),p_srf_aver)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(18),p_srf_aver)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(19),p_srf_center)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(19),p_srf_center)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(20),T_srf)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(20),T_srf)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(15),s)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(16),s_adv_h)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(17),s_adv_v)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(18),p_srf_aver)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(19),p_srf_center)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(20),T_srf)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -572,5 +492,5 @@
          subroutine catchaxis(nid,ttm,llm,time,lev,ierr)
 
-!         use netcdf
+         use netcdf, only: nf90_get_var
 
          implicit none
@@ -610,11 +530,6 @@
          endif
 
-!#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,timevar,time)
-         ierr = NF_GET_VAR_DOUBLE(nid,levvar,lev)
-!#else
-!        ierr = NF_GET_VAR_REAL(nid,timevar,time)
-!        ierr = NF_GET_VAR_REAL(nid,levvar,lev)
-!#endif
+         ierr = NF90_GET_VAR(nid,timevar,time)
+         ierr = NF90_GET_VAR(nid,levvar,lev)
 
        return
@@ -2255,4 +2170,5 @@
 
 
+      use netcdf, only: nf90_get_var
       implicit none
 
@@ -2364,9 +2280,5 @@
 !      call catchaxis(nid,ntime,nlevel,time,z,ierr)
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),zz)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(1),zz)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(1),zz)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2375,9 +2287,5 @@
 !          write(*,*)'lecture z ok',zz
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),thl)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(2),thl)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(2),thl)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2386,9 +2294,5 @@
 !          write(*,*)'lecture thl ok',thl
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),qt)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(3),qt)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(3),qt)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2397,9 +2301,5 @@
 !          write(*,*)'lecture qt ok',qt
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),u)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(4),u)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(4),u)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2408,9 +2308,5 @@
 !          write(*,*)'lecture u ok',u
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(5),v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(5),v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2419,9 +2315,5 @@
 !          write(*,*)'lecture v ok',v
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),tke)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(6),tke)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(6),tke)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2430,9 +2322,5 @@
 !          write(*,*)'lecture tke ok',tke
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),ug)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(7),ug)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(7),ug)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2441,9 +2329,5 @@
 !          write(*,*)'lecture ug ok',ug
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),vg)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(8),vg)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(8),vg)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2452,9 +2336,5 @@
 !          write(*,*)'lecture vg ok',vg
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),wls)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(9),wls)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(9),wls)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2463,9 +2343,5 @@
 !          write(*,*)'lecture wls ok',wls
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),dqtdx)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(10),dqtdx)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(10),dqtdx)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2474,9 +2350,5 @@
 !          write(*,*)'lecture dqtdx ok',dqtdx
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),dqtdy)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(11),dqtdy)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(11),dqtdy)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2485,9 +2357,5 @@
 !          write(*,*)'lecture dqtdy ok',dqtdy
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),dqtdt)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(12),dqtdt)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(12),dqtdt)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2496,9 +2364,5 @@
 !          write(*,*)'lecture dqtdt ok',dqtdt
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),thl_rad)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(13),thl_rad)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(13),thl_rad)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2517,4 +2381,5 @@
 !program reading initial profils and forcings of the Dice case study
 
+      use netcdf, only: nf90_get_var
 
       implicit none
@@ -2685,9 +2550,5 @@
 !      call catchaxis(nid,ntime,nlevel,time,z,ierr)
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),zz)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(1),zz)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(1),zz)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2696,9 +2557,5 @@
 !          write(*,*)'lecture zz ok',zz
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),pres)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(11),pres)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(11),pres)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2707,9 +2564,5 @@
 !          write(*,*)'lecture pres ok',pres
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),th)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(12),th)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(12),th)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2721,9 +2574,5 @@
            enddo
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),qv)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(13),qv)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(13),qv)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2732,9 +2581,5 @@
 !          write(*,*)'lecture qv ok',qv
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(14),u)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(14),u)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(14),u)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2743,9 +2588,5 @@
 !          write(*,*)'lecture u ok',u
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(15),v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(15),v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(15),v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2754,9 +2595,5 @@
 !          write(*,*)'lecture v ok',v
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(16),o3)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(16),o3)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(16),o3)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2765,9 +2602,5 @@
 !          write(*,*)'lecture o3 ok',o3
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),shf)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(2),shf)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(2),shf)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2776,9 +2609,5 @@
 !          write(*,*)'lecture shf ok',shf
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),lhf)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(3),lhf)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(3),lhf)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2787,9 +2616,5 @@
 !          write(*,*)'lecture lhf ok',lhf
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),lwup)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(4),lwup)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(4),lwup)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2798,9 +2623,5 @@
 !          write(*,*)'lecture lwup ok',lwup
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),swup)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(5),swup)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(5),swup)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2809,9 +2630,5 @@
 !          write(*,*)'lecture swup ok',swup
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),tg)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(6),tg)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(6),tg)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2820,9 +2637,5 @@
 !          write(*,*)'lecture tg ok',tg
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),ustar)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(7),ustar)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(7),ustar)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2831,9 +2644,5 @@
 !          write(*,*)'lecture ustar ok',ustar
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),psurf)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(8),psurf)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(8),psurf)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2842,9 +2651,5 @@
 !          write(*,*)'lecture psurf ok',psurf
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),ug)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(9),ug)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(9),ug)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2853,9 +2658,5 @@
 !          write(*,*)'lecture ug ok',ug
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),vg)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(10),vg)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(10),vg)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2864,9 +2665,5 @@
 !          write(*,*)'lecture vg ok',vg
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(17),hadvt)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(17),hadvt)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(17),hadvt)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2875,9 +2672,5 @@
 !          write(*,*)'lecture hadvt ok',hadvt
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(18),hadvq)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(18),hadvq)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(18),hadvq)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2886,9 +2679,5 @@
 !          write(*,*)'lecture hadvq ok',hadvq
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(19),hadvu)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(19),hadvu)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(19),hadvu)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2897,9 +2686,5 @@
 !          write(*,*)'lecture hadvu ok',hadvu
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(20),hadvv)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(20),hadvv)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(20),hadvv)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2908,9 +2693,5 @@
 !          write(*,*)'lecture hadvv ok',hadvv
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(21),w)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(21),w)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(21),w)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2919,9 +2700,5 @@
 !          write(*,*)'lecture w ok',w
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(22),omega)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(22),omega)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(22),omega)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2938,4 +2715,5 @@
 !program reading initial profils and forcings of the Gabls4 case study
 
+      use netcdf, only: nf90_get_var
 
       implicit none
@@ -3068,149 +2846,89 @@
 !      call catchaxis(nid,ntime,nlevel,time,z,ierr)
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),zz_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(1),zz_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),depth_sn)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(2),depth_sn)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),ug_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(3),ug_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),vg_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(4),vg_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),pf_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(5),pf_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),th_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(6),th_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),t_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(7),t_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),qv_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(8),qv_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),u_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(9),u_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),v_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(10),v_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),hadvt_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(11),hadvt_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),hadvq_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(12),hadvq_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(14),tsnow)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(14),tsnow)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(15),snow_dens)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(15),snow_dens)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(16),tg)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(16),tg)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(1),zz_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(2),depth_sn)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(3),ug_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(4),vg_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(5),pf_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(6),th_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(7),t_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(8),qv_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(9),u_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(10),v_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(11),hadvt_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(12),hadvq_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(14),tsnow)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(15),snow_dens)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(16),tg)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_1D_read_forc_cases.h
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_1D_read_forc_cases.h	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_1D_read_forc_cases.h	(revision 4368)
@@ -843,5 +843,5 @@
       if (forcing_case) then
 
-         write(*,*),'avant call read_1D_cas'
+         write(*,*) 'avant call read_1D_cas'
          call read_1D_cas
          write(*,*) 'Forcing read'
@@ -918,5 +918,5 @@
       if (forcing_case2) then
 
-         write(*,*),'avant call read2_1D_cas'
+         write(*,*) 'avant call read2_1D_cas'
          call read2_1D_cas
          write(*,*) 'Forcing read'
@@ -1017,5 +1017,5 @@
       if (forcing_SCM) then
 
-         write(*,*),'avant call old_read_SCM_cas'
+         write(*,*) 'avant call old_read_SCM_cas'
          call old_read_SCM_cas
          write(*,*) 'Forcing read' 
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_lmdz1d.F90
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_lmdz1d.F90	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_lmdz1d.F90	(revision 4368)
@@ -494,5 +494,5 @@
 !      calend = 'earth_365d'
       if (calend == 'earth_360d') then
-        call ioconf_calendar('360d')
+        call ioconf_calendar('360_day')
         write(*,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
       else if (calend == 'earth_365d') then
@@ -613,5 +613,5 @@
       call init_dimphy1D(1,llm)
       call suphel
-      call infotrac_init 
+      call init_infotrac
 
       if (nqtot>nqmx) STOP 'Augmenter nqmx dans lmdz1d.F'
@@ -889,5 +889,5 @@
         clwcon=0.
         zmax0 = 0.
-        zmea=0.
+        zmea=zsurf
         zstd=0.
         zsig=0.
@@ -1033,5 +1033,7 @@
 !
 !=====================================================================
+#ifdef OUTPUT_PHYS_SCM
        CALL iophys_ini(timestep)
+#endif
 ! START OF THE TEMPORAL LOOP :
 !=====================================================================
@@ -1050,15 +1052,4 @@
 
 !---------------------------------------------------------------------
-! Interpolation of forcings in time and onto model levels
-!---------------------------------------------------------------------
-
-#include "old_1D_interp_cases.h"
-
-      if (forcing_GCM2SCM) then
-        write (*,*) 'forcing_GCM2SCM not yet implemented'
-        stop 'in time loop'
-      endif ! forcing_GCM2SCM
-
-!---------------------------------------------------------------------
 !  Geopotential :
 !---------------------------------------------------------------------
@@ -1069,4 +1060,25 @@
      &    (play(l)-play(l+1))/(play(l)+play(l+1))
         enddo
+
+!---------------------------------------------------------------------
+! Interpolation of forcings in time and onto model levels
+!---------------------------------------------------------------------
+
+#include "old_1D_interp_cases.h"
+
+      if (forcing_GCM2SCM) then
+        write (*,*) 'forcing_GCM2SCM not yet implemented'
+        stop 'in time loop'
+      endif ! forcing_GCM2SCM
+
+!!!!---------------------------------------------------------------------
+!!!!  Geopotential :
+!!!!---------------------------------------------------------------------
+!!!
+!!!        phi(1)=RD*temp(1)*(plev(1)-play(1))/(.5*(plev(1)+play(1)))
+!!!        do l = 1, llm-1
+!!!          phi(l+1)=phi(l)+RD*(temp(l)+temp(l+1))*                           &
+!!!     &    (play(l)-play(l+1))/(play(l)+play(l+1))
+!!!        enddo
 
 !---------------------------------------------------------------------
@@ -1276,7 +1288,8 @@
      &             +dt_cooling(1:mxcalc))  ! Taux de chauffage ou refroid.
 
-print*,'OLDLMDZ1D IOPH'
+#ifdef OUTPUT_PHYS_SCM
       CALL iophys_ecrit('d_t_adv',klev,'d_t_adv','m/s',d_t_adv)
       CALL iophys_ecrit('d_t_nudge',klev,'d_t_nudge','m/s',d_t_nudge)
+#endif
 
       endif  ! forcing_sandu or forcing_astex
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/replay1d.F90
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/replay1d.F90	(revision 4368)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/replay1d.F90	(revision 4368)
@@ -0,0 +1,159 @@
+PROGRAM rejouer
+
+USE mod_const_mpi, ONLY: comm_lmdz
+USE inigeomphy_mod, ONLY: inigeomphy
+USE comvert_mod, ONLY: presnivs
+USE comvert_mod, only :  preff, pa
+USE ioipsl, only: getin
+
+
+
+
+      implicit none
+#include "dimensions.h"
+
+real :: airefi
+real :: zcufi    = 1.
+real :: zcvfi    = 1.
+real :: rlat_rad(1),rlon_rad(1)
+
+integer ntime
+integer jour0,mois0,an0,day_step,anneeref,dayref
+integer klev,klon
+CHARACTER (len=10) :: calend
+CHARACTER(len=20) :: calendrier
+
+
+!---------------------------------------------------------------------
+! L'appel a inigeomphy n'est utile que pour avoir getin_p dans 
+! les initialisations
+!---------------------------------------------------------------------
+  zcufi=1.
+  zcvfi=1.
+  rlat_rad(1)=0.
+  rlon_rad(1)=0.
+
+preff=101325.
+!preff=100000.
+pa=50000.
+  CALL disvert()
+  CALL inigeomphy(1,1,llm, &
+               1, comm_lmdz, &
+           (/rlat_rad(1),0./),(/0./), &
+           (/0.,0./),(/rlon_rad(1),0./),  &
+           (/ (/airefi,0./),(/0.,0./) /), &
+           (/zcufi,0.,0.,0./), &
+           (/zcvfi,0./))
+
+CALL suphel
+!ntime=4320
+ntime=10000000
+dayref=1
+anneeref=2000
+call getin('dayref',dayref)
+call getin('anneeref',anneeref)
+call getin('calend',calend)
+call getin('day_step',day_step)
+calendrier=calend
+if ( calendrier == "earth_360d" ) calendrier="360_day"
+
+
+jour0=dayref
+mois0=(jour0-1)/30+1
+jour0=jour0-30*((jour0-1)/30)
+an0=anneeref
+
+!print*,"REPLAY1D jour0,mois0,an0",jour0,mois0,an0
+
+
+klon=1
+klev=llm
+call iotd_ini('phys.nc',1,1,klev,0.,0.,presnivs,jour0,mois0,an0,0.,86400./day_step,calendrier)
+! Consistent with ... CALL iophys_ini(600.)
+
+!---------------------------------------------------------------------
+! Initialisation de la parametrisation
+!---------------------------------------------------------------------
+call get_ini_module
+
+!---------------------------------------------------------------------
+! Boucle en temps sur l'appel à la parametrisation
+!---------------------------------------------------------------------
+call call_param_replay(klon,klev)
+
+end
+
+!---------------------------------------------------------------------
+!/////////////////////////////////////////////////////////////////////
+!/////////////////////////////////////////////////////////////////////
+!     routine additionnelles utiles, prises dans 1DUTILS.h
+!/////////////////////////////////////////////////////////////////////
+!/////////////////////////////////////////////////////////////////////
+!---------------------------------------------------------------------
+
+!=======================================================================
+      SUBROUTINE abort_gcm(modname, message, ierr)
+      USE IOIPSL
+! Stops the simulation cleanly, closing files and printing various
+! comments
+!=======================================================================
+!
+!  Input: modname = name of calling program
+!         message = stuff to print
+!         ierr    = severity of situation ( = 0 normal )
+ 
+      character(len=*) modname
+      integer ierr
+      character(len=*) message
+ 
+      write(*,*) 'in abort_gcm'
+      call histclo
+      write(*,*) 'out of histclo'
+      write(*,*) 'Stopping in ', modname
+      write(*,*) 'Reason = ',message
+      call getin_dump
+!
+      if (ierr .eq. 0) then
+        write(*,*) 'Everything is cool'
+      else
+        write(*,*) 'Houston, we have a problem ', ierr
+      endif
+      STOP
+      END
+
+!=======================================================================
+      SUBROUTINE gr_dyn_fi(nfield,im,jm,ngrid,pdyn,pfi)
+      IMPLICIT NONE
+!   passage d'un champ de la grille scalaire a la grille physique
+!=======================================================================
+ 
+!-----------------------------------------------------------------------
+!   declarations:
+!   -------------
+ 
+      INTEGER im,jm,ngrid,nfield
+      REAL pdyn(im,jm,nfield)
+      REAL pfi(ngrid,nfield)
+ 
+      INTEGER j,ifield,ig
+ 
+!-----------------------------------------------------------------------
+!   calcul:
+!   -------
+ 
+      IF(ngrid.NE.2+(jm-2)*(im-1).AND.ngrid.NE.1)                          &
+     &    STOP 'probleme de dim'
+!   traitement des poles
+      CALL SCOPY(nfield,pdyn,im*jm,pfi,ngrid)
+      CALL SCOPY(nfield,pdyn(1,jm,1),im*jm,pfi(ngrid,1),ngrid)
+ 
+!   traitement des point normaux
+      DO ifield=1,nfield
+         DO j=2,jm-1
+            ig=2+(j-2)*(im-1)
+            CALL SCOPY(im-1,pdyn(1,j,ifield),1,pfi(ig,ifield),1)
+         ENDDO
+      ENDDO
+ 
+      RETURN
+      END
Index: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/scm.F90
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/scm.F90	(revision 4013)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/scm.F90	(revision 4368)
@@ -327,5 +327,5 @@
 !      calend = 'earth_365d'
       if (calend == 'earth_360d') then
-        call ioconf_calendar('360d')
+        call ioconf_calendar('360_day')
         write(*,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
       else if (calend == 'earth_365d') then
@@ -393,5 +393,5 @@
       call init_dimphy1D(1,llm)
       call suphel
-      call infotrac_init 
+      call init_infotrac
 
       if (nqtot>nqmx) STOP 'Augmenter nqmx dans lmdz1d.F'
@@ -496,11 +496,4 @@
         stop 'in initialization'
       endif ! forcing_GCM2SCM
-
-      print*,'mxcalc=',mxcalc
-!     print*,'zlay=',zlay(mxcalc)
-!      print*,'play=',play(mxcalc)
-
-!! When surface temperature is forced
-      tg= tsurf ! surface T used in read_tsurf1d
 
 
@@ -654,5 +647,5 @@
         clwcon=0.
         zmax0 = 0.
-        zmea=0.
+        zmea=zsurf
         zstd=0.
         zsig=0.
@@ -815,6 +808,8 @@
 !  Geopotential :
 !---------------------------------------------------------------------
-!        phis(1)=zsurf*RG
+        phis(1)=zsurf*RG
 !        phi(1)=phis(1)+RD*temp(1)*(plev(1)-play(1))/(.5*(plev(1)+play(1)))
+
+        ! Calculate geopotential from the ground surface since phi and phis are added in physiq_mod
         phi(1)=RD*temp(1)*(plev(1)-play(1))/(.5*(plev(1)+play(1)))
 
@@ -823,5 +818,4 @@
      &    (play(l)-play(l+1))/(play(l)+play(l+1))
         enddo
-
 
 !---------------------------------------------------------------------
@@ -852,7 +846,5 @@
       d_t_adv(:)=d_t_adv(:)+d_t_vert_adv(:)
       d_q_adv(:,1)=d_q_adv(:,1)+d_q_vert_adv(:,1)
-
-      print*,'OMEGA ',w_adv(10),z_adv(10)
-
+   
    ENDIF
 
@@ -938,4 +930,6 @@
 !---------------------------------------------------------------------
 !  Nudging
+!  EV: rewrite the section to account for a time- and height-varying
+!  nudging
 !---------------------------------------------------------------------
       d_t_nudge(:) = 0.
@@ -943,13 +937,56 @@
       d_v_nudge(:) = 0.
       d_q_nudge(:,:) = 0.
+
       DO l=1,llm
-         IF ( play(l) < p_nudging_u .AND. nint(nudging_u) /= 0 ) &
+
+         IF (nudging_u .LT. 0) THEN
+              
+             d_u_nudge(l)=(u_nudg_mod_cas(l)-u(l))*invtau_u_nudg_mod_cas(l)
+       
+         ELSE
+
+             IF ( play(l) < p_nudging_u .AND. nint(nudging_u) /= 0 ) &
              & d_u_nudge(l)=(u_nudg_mod_cas(l)-u(l))/nudging_u
-         IF ( play(l) < p_nudging_v .AND. nint(nudging_v) /= 0 ) &
+
+         ENDIF 
+
+
+         IF (nudging_v .LT. 0) THEN
+              
+             d_v_nudge(l)=(v_nudg_mod_cas(l)-v(l))*invtau_v_nudg_mod_cas(l)
+       
+         ELSE
+
+
+             IF ( play(l) < p_nudging_v .AND. nint(nudging_v) /= 0 ) &
              & d_v_nudge(l)=(v_nudg_mod_cas(l)-v(l))/nudging_v
-         IF ( play(l) < p_nudging_t .AND. nint(nudging_t) /= 0 ) &
+
+         ENDIF
+
+
+         IF (nudging_t .LT. 0) THEN
+              
+             d_t_nudge(l)=(temp_nudg_mod_cas(l)-temp(l))*invtau_temp_nudg_mod_cas(l)
+       
+         ELSE
+
+
+             IF ( play(l) < p_nudging_t .AND. nint(nudging_t) /= 0 ) &
              & d_t_nudge(l)=(temp_nudg_mod_cas(l)-temp(l))/nudging_t
-         IF ( play(l) < p_nudging_qv .AND. nint(nudging_qv) /= 0 ) &
+
+          ENDIF
+
+
+         IF (nudging_qv .LT. 0) THEN
+              
+             d_q_nudge(l,1)=(qv_nudg_mod_cas(l)-q(l,1))*invtau_qv_nudg_mod_cas(l)
+       
+         ELSE
+
+             IF ( play(l) < p_nudging_qv .AND. nint(nudging_qv) /= 0 ) &
              & d_q_nudge(l,1)=(qv_nudg_mod_cas(l)-q(l,1))/nudging_qv
+
+         ENDIF
+
       ENDDO
 
@@ -957,4 +994,5 @@
 !  Optional outputs
 !---------------------------------------------------------------------
+
 #ifdef OUTPUT_PHYS_SCM
       CALL iophys_ecrit('w_adv',klev,'w_adv','K/day',w_adv)
