       subroutine qu2ll2

       implicit none
       include 'param_o.h'
       include 'extra.comm'
       
       real,dimension(0:im+1,0:jm+1,nm,lsm)::fsl,usl,vsl,ull,vll,qsl,tsl,q2sl
       real,dimension(igm,jgm,lsm)::fsl_ll,hgt_ll,usp,vsp,qsl_ll,tsl_ll,q2sl_ll
       real,dimension(jgm,lsm)::usp_avg
       real,dimension(jgm,lsm)::tsl_ll_avg
      
       real,dimension(igm,jgm)::psurf_ll,tsfc_ll,pslp_ll,sfcshx_ll,sfclhx_ll,vegfrc_ll,z0_ll,albedo_ll
       real,dimension(0:im+1,0:jm+1,nm)::tsfc,sfclhx,sfcshx,vegfrc,z0,albedo
      
       real,dimension(0:im+1,0:jm+1,nm)::RSWIN,RSWOUT,RSWTOA,ASWIN,ASWOUT,ASWTOA,rswnet
       real,dimension(0:im+1,0:jm+1,nm)::RLWIN,RLWOUT,RLWTOA,ALWIN,ALWOUT,ALWTOA,rlwnet
       
       
       real,dimension(igm,jgm)::RSWIN_ll,RSWOUT_ll,RSWTOA_ll,ASWIN_ll,ASWOUT_ll,ASWTOA_ll,rswnet_ll
       real,dimension(igm,jgm)::RLWIN_ll,RLWOUT_ll,RLWTOA_ll,ALWIN_ll,ALWOUT_ll,ALWTOA_ll,rlwnet_ll
       
       real,dimension(0:im+1,0:jm+1,nm,lsm)::RSWTT,RLWTT
       real,dimension(igm,jgm,lsm)::RSWTT_ll,RLWTT_ll
       
       real,dimension(0:im+1,0:jm+1,nm)::CUPPT,cfracl,cfracm,cfrach
       real,dimension(igm,jgm)::CUPPT_ll,cfracl_ll,cfracm_ll,cfrach_ll
       
       real,dimension(0:im+1,0:jm+1,nm)::acprec,cuprec,aprec,acsnow,prec
       real,dimension(igm,jgm)::acprec_ll,cuprec_ll,aprec_ll,acsnow_ll,prec_ll
       
       real,dimension(0:im+1,0:jm+1,nm)::SMSTAV,BGROFF,SSROFF
       real,dimension(igm,jgm)::SMSTAV_ll,BGROFF_ll,SSROFF_ll
       
       integer,parameter::nsoil=4
       real,dimension(0:im+1,0:jm+1,nm,nsoil)::stc,smc
       real,dimension(igm,jgm,nsoil)::stc_ll,smc_ll
       
       
       real,dimension(0:im+1,0:jm+1,nm)::tshltr,qshltr,albase,cnvtop,cnvbot,htop,hbot
       real,dimension(igm,jgm)::tshltr_ll,qshltr_ll,albase_ll,cnvtop_ll,cnvbot_ll,htop_ll,hbot_ll
      
       integer,dimension(0:im+1,0:jm+1,nm)::IVGTYP,ISLTYP
       integer,dimension(igm,jgm)::IVGTYP_ll,ISLTYP_ll
       
       real,dimension(0:im+1,0:jm+1,nm)::acfrcv,acfrst,acsnom,cmc,   &
       czen,czmean,epsr,glat,glon,grnflx,mxsnal,potevp,potflx
       
       real,dimension(igm,jgm)::acfrcv_ll,acfrst_ll,acsnom_ll,cmc_ll,   &
       czen_ll,czmean_ll,epsr_ll,glat_ll,glon_ll,grnflx_ll,mxsnal_ll,potevp_ll,potflx_ll
       
       real,dimension(0:im+1,0:jm+1,nm,lm)::omgalf,q2,tcucn,train,div,rtop,htm,vtm, w, dwdt, z
      
real,dimension(igm,jgm,lsm)::omgalf_ll,q2_ll,tcucn_ll,train_ll,div_ll,rtop_ll,htm_ll,vtm_ll, w_ll, dwdt_ll, z_ll
       
       real,dimension(0:im+1,0:jm+1,nm)::qwbs,twbs,sm,fis,q10,th10,qz0,thz0,radot,sigt4,  &
       sfcevp,subshx,snopcx,si,sno,sice,smstot,soiltb,tg,sr,akhs,akms,ths,plm
       
       real,dimension(igm,jgm)::qwbs_ll,twbs_ll,sm_ll,fis_ll,q10_ll,th10_ll,qz0_ll,thz0_ll,  &
       radot_ll,sigt4_ll,sfcevp_ll,subshx_ll,snopcx_ll,si_ll,sno_ll,sice_ll,smstot_ll,soiltb_ll,  &
       tg_ll,sr_ll,akhs_ll,akms_ll,ths_ll,plm_ll
       
       real,dimension(0:im+1,0:jm+1,nm)::u10,v10,uz0,vz0,ustar,u10ll,v10ll,uz0ll,vz0ll
       real,dimension(igm,jgm)::u10_ll,v10_ll,uz0_ll,vz0_ll,ustar_ll
       
       
       integer::l,i,j,n,k
      
      
!+++++++++++++++++++
!    open(1,file='../data_out/tmpfld.dat',form='unformatted')
	open(1,file='/home/lucci/GEF/GEF-reta/GEF_tempo/scratchout/post/tmpfld.dat',form='unformatted')
	do l=1,lsm
	read(1)fsl(:,:,:,l)
	read(1)usl(:,:,:,l)
	read(1)vsl(:,:,:,l)
	read(1)qsl(:,:,:,l) !DRAGAN 23.09.'10
	read(1)tsl(:,:,:,l)
	read(1)q2sl(:,:,:,l)
!non-hydrostatic
        read(1)w(:,:,:,l)
        read(1)dwdt(:,:,:,l)
        read(1)z(:,:,:,l)


!	read(1)tshltr
!	read(1)qshltr
!	read(1)plm
	enddo
    close(1)

	do j=1,jm
	do i=1,im
!	  print *,i,j,q2sl(i,j,3,1)
        enddo
        enddo
!++++++++++++++++++
    open(1,file='/home/lucci/GEF/GEF-reta/GEF_tempo/scratchout/post/tmpsfc.dat',form='unformatted')
	read(1)tsfc
      read(1)tshltr
      read(1)qshltr
      read(1)plm

	read(1)sfclhx  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	read(1)sfcshx   !!!!!!!!!!!!
    read(1)qwbs
    read(1)twbs
	
	read(1)grnflx
	read(1)vegfrc   !!!!!!!!!!!!!
        read(1)IVGTYP
        read(1)ISLTYP
        read(1)glat
        read(1)glon
    read(1)sm	 
!	read(1)htm
!	read(1)vtm
	read(1)sice
	read(1)z0
        read(1)omgalf	
	read(1)albedo
        read(1)albase
        read(1)mxsnal
         
        read(1)czen
        read(1)czmean
    read(1)fis
    read(1)q10    
    read(1)th10    
    read(1)qz0    
    read(1)thz0   
    
   read(1)u10
   read(1)v10
   read(1)uz0
   read(1)vz0
   read(1)ustar
    
    read(1)ths		
   read(1)q2    
   read(1)tcucn    
   read(1)train    
   read(1)div  
   read(1)rtop 
   
   
    close(1)
!+++++++++++++++++++        
    open(2,file='/home/lucci/GEF/GEF-reta/GEF_tempo/scratchout/post/sw_rdtn.dat',form='unformatted')
	read(2)RSWIN
	read(2)RSWOUT
	read(2)RSWTOA   !!!!!!!!!!!!!!!!DRAGAN
	read(2)ASWIN
	read(2)ASWOUT
	
	read(2)ASWTOA
	read(2)rswnet
	read(2)RSWTT
	
    close(2)
!+++++++++++++++++
    open(3,file='/home/lucci/GEF/GEF-reta/GEF_tempo/scratchout/post/lw_rdtn.dat',form='unformatted')
	read(3)RLWIN
	read(3)RLWOUT
	read(3)RLWTOA   !!!!!!!!!!!!!!!!DRAGAN
	read(3)ALWIN
	read(3)ALWOUT
	
	read(3)ALWTOA
	read(3)rlwnet
	read(3)RLWTT
        read(3)epsr	
      read(3)radot   
      read(3)sigt4 
    close(3)


!++++++++++++++++	
	
	
      open(4,file='/home/lucci/GEF/GEF-reta/GEF_tempo/scratchout/post/clouds.dat',form='unformatted')
	read(4)CUPPT
	read(4)cfracl
	read(4)cfracm   !!!!!!!!!!!!!!!!DRAGAN
	read(4)cfrach
        read(4)acfrcv
        read(4)acfrst
      
        read(4)cnvtop
        read(4)cnvbot
!        read(4)htop
!        read(4)hbot 
      close(4)
	
!++++++++++++++++	
 	
      open(5,file='/home/lucci/GEF/GEF-reta/GEF_tempo/scratchout/post/precANDsoil.dat',form='unformatted')
	read(5)acprec
	read(5)cuprec
	read(5)aprec   !!!!!!!!!!!!!!!!DRAGAN
	read(5)acsnow
        read(5)acsnom
	
	read(5)prec
	
	read(5)stc(:,:,:,1)
	read(5)stc(:,:,:,4)
	read(5)smc(:,:,:,1)
	read(5)smc(:,:,:,4)
	
	
	read(5)SMSTAV
	read(5)BGROFF
	read(5)SSROFF
        read(5)cmc
        read(5)potevp
        read(5)potflx	
      read(5)sfcevp
      read(5)subshx
      read(5)snopcx
    
      read(5)si
      read(5)sno
     	 
      read(5)smstot
      read(5)soiltb  !!!!   
!     read(5)tg      !!!!
      read(5)sr 
      read(5)akhs
      read(5)akms	
      close(5)
!+++++++++++++++++
    	
	
	
	
	print *,'tsl,30,14,4,',tsl(30,14,4,17),tsl(30,15,4,17),tsl(31,14,4,17), &
	            tsl(31,15,4,17)
        print *,'tsl,30,14,4,',tsl(30,14,4,16),tsl(30,15,4,16),tsl(31,14,4,16), &
	            tsl(31,15,4,16)
	do n=1,nm
	do i=1,im
	do j=1,jm
!	  print *,i,j,n,usl(i,j,n,1),vsl(i,j,n,1)
        enddo
        enddo
        enddo

 
       if(nm.eq.14)then
!        print *,pslp(34,57,3),pslp(34,58,3),pslp(35,57,3),pslp(35,58,3)
        call octa2llH(fsl, fsl_ll, lsm) 
        call octa2llH(qsl, qsl_ll, lsm) 
        call octa2llH(tsl, tsl_ll, lsm) 
        call octa2llH(q2sl, q2sl_ll, lsm) 
 !!!      call octa2llH(tshltr, tshltr_ll, 1) 
 !!!      call octa2llH(qshltr, qshltr_ll, 1)
!	call octa2llH(plm, plm_ll, 1)
	
	call octa2llH(pint(:,:,:,lp1),psurf_ll,1)
	call octa2llH(pslp,pslp_ll,1)
	call octa2llH(tsfc,tsfc_ll,1)

!++++++++++++++++++++++++++++++++++++++
	 call octa2llH(tshltr, tshltr_ll, 1) 
       call octa2llH(qshltr, qshltr_ll, 1)
	call octa2llH(plm, plm_ll, 1)
	
	call octa2llH(sfclhx,sfclhx_ll,1)
	call octa2llH(sfcshx,sfcshx_ll,1)
   call octa2llH(qwbs,qwbs_ll,1)
   call octa2llH(twbs,twbs_ll,1)     
	
	call octa2llH(grnflx,grnflx_ll,1)
	
	call octa2llH(vegfrc,vegfrc_ll,1)
        call octa2llH(IVGTYP,IVGTYP_ll,1)
        call octa2llH(ISLTYP,ISLTYP_ll,1)
        call octa2llH(glat,glat_ll,1)
        call octa2llH(glon,glon_ll,1)
   call octa2llH(sm,sm_ll,1)		
!   call octa2llH(htm,htm_ll,lsm)
!   call octa2llH(vtm,vtm_ll,lsm)
   call octa2llH(sice,sice_ll,1)
	
	call octa2llH(z0,z0_ll,1)
        call octa2llH(omgalf,omgalf_ll,lsm)
	call octa2llH(albedo,albedo_ll,1)
        call octa2llH(albase,albase_ll,1)
	call octa2llH(mxsnal,mxsnal_ll,1)
	call octa2llH(czen,czen_ll,1)
	call octa2llH(czmean,czmean_ll,1)
   call octa2llH(fis,fis_ll,1)
   call octa2llH(q10,q10_ll,1)
   call octa2llH(th10,th10_ll,1)
   call octa2llH(qz0,qz0_ll,1)
   call octa2llH(thz0,thz0_ll,1)
   
   call octa2llH(ustar,ustar_ll,1)
   
   call octa2llH(ths,ths_ll,1) 	
  
   call octa2llH(q2,q2_ll,lsm)
   call octa2llH(tcucn,tcucn_ll,lsm)
   call octa2llH(train,train_ll,lsm)
   call octa2llH(div,div_ll,lsm)
   call octa2llH(rtop,rtop_ll,lsm) 
!++++++++++++++++++++++++++++++++++++
        call octa2llH(RSWIN,RSWIN_ll,1)
	call octa2llH(RSWOUT,RSWOUT_ll,1)
	call octa2llH(RSWTOA,RSWTOA_ll,1)
	
	call octa2llH(ASWIN,ASWIN_ll,1)
	call octa2llH(ASWOUT,ASWOUT_ll,1)
	call octa2llH(ASWTOA,ASWTOA_ll,1)
	call octa2llH(rswnet,rswnet_ll,1)
	call octa2llH(RSWTT,RSWTT_ll,lsm)
	
!+++++++++++++++++++++++++++++++++++++++
        call octa2llH(RLWIN,RLWIN_ll,1)
	call octa2llH(RLWOUT,RLWOUT_ll,1)
	call octa2llH(RLWTOA,RLWTOA_ll,1)
	
	call octa2llH(ALWIN,ALWIN_ll,1)
	call octa2llH(ALWOUT,ALWOUT_ll,1)
	call octa2llH(ALWTOA,ALWTOA_ll,1)
	call octa2llH(rlwnet,rlwnet_ll,1)
	call octa2llH(RLWTT,RLWTT_ll,lsm) 
        call octa2llH(epsr,epsr_ll,1)
      call octa2llH(radot,radot_ll,1)
      call octa2llH(sigt4,sigt4_ll,1)	
!++++++++++++++++++++++++++++++++++++++       
        call octa2llH(CUPPT,CUPPT_ll,1)
	call octa2llH(cfracl,cfracl_ll,1)
	call octa2llH(cfracm,cfracm_ll,1)
	
	call octa2llH(cfrach,cfrach_ll,1)
        call octa2llH(acfrcv,acfrcv_ll,1)
        call octa2llH(acfrst,acfrst_ll,1)
	
!++++++++++++++++++++++++++++++++++++++	
        call octa2llH(cnvtop,cnvtop_ll,1)
        call octa2llH(cnvbot,cnvbot_ll,1)
!        call octa2llH(htop,htop_ll,1)
!        call octa2llH(hbot,hbot_ll,1)
	
	call octa2llH(acprec,acprec_ll,1)
	call octa2llH(cuprec,cuprec_ll,1)
	call octa2llH(aprec,aprec_ll,1)
	call octa2llH(acsnow,acsnow_ll,1)
        call octa2llH(acsnom,acsnom_ll,1)
	
	call octa2llH(prec,prec_ll,1)
      
	
	
!++++++++++++++++++++++++++++++++++++++
      
        call octa2llH(stc,stc_ll,1)
        call octa2llH(stc,stc_ll,4)
	call octa2llH(smc,smc_ll,1)
	call octa2llH(smc,smc_ll,4)
	call octa2llH(SMSTAV,SMSTAV_ll,1)
	call octa2llH(BGROFF,BGROFF_ll,1)
	call octa2llH(SSROFF,SSROFF_ll,1)
        call octa2llH(cmc,cmc_ll,1)
        call octa2llH(potevp,potevp_ll,1)
        call octa2llH(potflx,potflx_ll,1)	
      call octa2llH(sfcevp,sfcevp_ll,1)
      call octa2llH(subshx,subshx_ll,1)
      call octa2llH(snopcx,snopcx_ll,1)
      call octa2llH(si,si_ll,1)
      call octa2llH(sno,sno_ll,1)
     
      call octa2llH(smstot,smstot_ll,1)
      call octa2llH(soiltb,soiltb_ll,1)
!     call octa2llH(tg,tg_ll,1)
      call octa2llH(sr,sr_ll,1)
      call octa2llH(akhs,akhs_ll,1)
      call octa2llH(akms,akms_ll,1)	
!++++++++++++++++++++++++++++++++++++++
	call llwinds_oc(usl, vsl, ull, vll,lsm)
        call bocovs_oc(ull,im,jm,lsm)
        call bocovs_oc(vll,im,jm,lsm)
        call avrv_oc(ull, usl,lsm)
        call avrv_oc(vll, vsl,lsm)
        usl = usl * .25
        vsl = vsl * .25
        do k=1,nm
	  if(k.eq.1.or.k.eq.2.or.k.eq.7.or.k.eq.8.or.k.eq.9  &
               .or.k.eq.12)then
              usl(1 ,1 ,k,:)=usl(1 ,1 ,k,:)*4./3.
              vsl(1 ,1 ,k,:)=vsl(1 ,1 ,k,:)*4./3.
          endif

	  if(k.eq.1.or.k.eq.4.or.k.eq.6.or.k.eq.7.or.k.eq.11  &
                .or.k.eq.14)then
             usl(im,1 ,k,:)=usl(im,1 ,k,:)*4./3.
             vsl(im,1 ,k,:)=vsl(im,1 ,k,:)*4./3.
          endif

	  if(k.eq.2.or.k.eq.5.or.k.eq.6.or.k.eq.9.or.k.eq.13  &
              .or.k.eq.14)then
             usl(1 ,jm,k,:)=usl(1 ,jm,k,:)*4./3.
             vsl(1 ,jm,k,:)=vsl(1 ,jm,k,:)*4./3.
          endif

	  if(k.eq.4.or.k.eq.5.or.k.eq.8.or.k.eq.11.or.k.eq.12  &
              .or.k.eq.13)then
             usl(im,jm,k,:)=usl(im,jm,k,:)*4./3.
             vsl(im,jm,k,:)=vsl(im,jm,k,:)*4./3.
           endif
        enddo
         
        call octa2llH(usl, usp, lsm) 
        call octa2llH(vsl, vsp, lsm) 
!+++++++++++++++++++++++++++++

!      call llwinds_oc(u10, v10, u10ll, v10ll,1)
!        call bocovs_oc(u10ll,im,jm,1)
!        call bocovs_oc(v10ll,im,jm,1)
!        call avrv_oc(u10ll, u10,1)
!        call avrv_oc(v10ll, v10,1)
!        u10 = u10 * .25
!        v10 = v10 * .25
!        do k=1,nm
!	  if(k.eq.1.or.k.eq.2.or.k.eq.7.or.k.eq.8.or.k.eq.9  &
!               .or.k.eq.12)then
!              u10(1 ,1 ,k)=u10(1 ,1 ,k)*4./3.
!              v10(1 ,1 ,k)=v10(1 ,1 ,k)*4./3.
!          endif
!
!	  if(k.eq.1.or.k.eq.4.or.k.eq.6.or.k.eq.7.or.k.eq.11  &
!                .or.k.eq.14)then
!             u10(im,1 ,k)=u10(im,1 ,k)*4./3.
!             v10(im,1 ,k)=v10(im,1 ,k)*4./3.
!          endif
!
!	  if(k.eq.2.or.k.eq.5.or.k.eq.6.or.k.eq.9.or.k.eq.13  &
!              .or.k.eq.14)then
!             u10(1 ,jm,k)=u10(1 ,jm,k)*4./3.
!             v10(1 ,jm,k)=v10(1 ,jm,k)*4./3.
!          endif
!
!	  if(k.eq.4.or.k.eq.5.or.k.eq.8.or.k.eq.11.or.k.eq.12  &
!              .or.k.eq.13)then
!             u10(im,jm,k)=u10(im,jm,k)*4./3.
!             v10(im,jm,k)=v10(im,jm,k)*4./3.
!           endif
!        enddo
         
        call octa2llH(u10, u10_ll, 1) 
        call octa2llH(v10, v10_ll, 1) 
!++++++++++++++++++++++++++++

!   call llwinds_oc(uz0, vz0, uz0ll, vz0ll,1)
!        call bocovs_oc(uz0ll,im,jm,1)
!        call bocovs_oc(vz0ll,im,jm,1)
!        call avrv_oc(uz0ll, uz0,1)
!        call avrv_oc(v10ll, vz0,1)
!        uz0 = uz0 * .25
!        vz0 = vz0 * .25
!        do k=1,nm
!	  if(k.eq.1.or.k.eq.2.or.k.eq.7.or.k.eq.8.or.k.eq.9  &
!               .or.k.eq.12)then
!              uz0(1 ,1 ,k)=uz0(1 ,1 ,k)*4./3.
!              vz0(1 ,1 ,k)=vz0(1 ,1 ,k)*4./3.
!          endif

!	  if(k.eq.1.or.k.eq.4.or.k.eq.6.or.k.eq.7.or.k.eq.11  &
!                .or.k.eq.14)then
!             uz0(im,1 ,k)=uz0(im,1 ,k)*4./3.
!             vz0(im,1 ,k)=vz0(im,1 ,k)*4./3.
!          endif

!	  if(k.eq.2.or.k.eq.5.or.k.eq.6.or.k.eq.9.or.k.eq.13  &
!              .or.k.eq.14)then
!             uz0(1 ,jm,k)=uz0(1 ,jm,k)*4./3.
!             vz0(1 ,jm,k)=vz0(1 ,jm,k)*4./3.
!          endif

!	  if(k.eq.4.or.k.eq.5.or.k.eq.8.or.k.eq.11.or.k.eq.12  &
!              .or.k.eq.13)then
!             uz0(im,jm,k)=uz0(im,jm,k)*4./3.
!             vz0(im,jm,k)=vz0(im,jm,k)*4./3.
!           endif
!        enddo
         
        call octa2llH(uz0, uz0_ll, 1) 
        call octa2llH(vz0, vz0_ll, 1) 


!+++++
       else if(nm.eq.6)then
        call cube2llH(fsl, fsl_ll, lsm) 
        call cube2llH(qsl, qsl_ll, lsm) 
        call cube2llH(tsl, tsl_ll, lsm) 
        call cube2llH(q2sl, q2sl_ll, lsm) 
!!!        call cube2llH(tshltr, tshltr_ll, 1) 
!!!        call cube2llH(qshltr, qshltr_ll, 1)
!	call cube2llH(plm, plm_ll, 1)
	
	call cube2llH(pint(:,:,:,lp1),psurf_ll,1)
	call cube2llH(pslp,pslp_ll,1)
	call cube2llH(tsfc,tsfc_ll,1)
!non-hydrostatic
        call cube2llH(w, w_ll, lsm)
        call cube2llH(dwdt, dwdt_ll, lsm)
        call cube2llH(z, z_ll, lsm)

!++++++++++++++++++++++++++++++++++++++++++++++++++++++	
	call cube2llH(tshltr, tshltr_ll, 1) 
        call cube2llH(qshltr, qshltr_ll, 1)
	call cube2llH(plm, plm_ll, 1)
	
	call cube2llH(sfclhx,sfclhx_ll,1)
	call cube2llH(sfcshx,sfcshx_ll,1)
   call cube2llH(qwbs,qwbs_ll,1)
   call cube2llH(twbs,twbs_ll,1)	
	call cube2llH(grnflx,grnflx_ll,1)
	call cube2llH(vegfrc,vegfrc_ll,1)
        call cube2llH(IVGTYP,IVGTYP_ll,1)
        call cube2llH(ISLTYP,ISLTYP_ll,1)
	call cube2llH(glat,glat_ll,1)
        call cube2llH(glon,glon_ll,1)
   call cube2llH(sm,sm_ll,1)	
!   call cube2llH(htm,htm_ll,lsm)
!   call cube2llH(vtm,vtm_ll,lsm)
   call cube2llH(sice,sice_ll,1)
	call cube2llH(z0,z0_ll,1)
	call cube2llH(omgalf,omgalf_ll,lsm)
	call cube2llH(albedo,albedo_ll,1)
        call cube2llH(albase,albase_ll,1)
        call cube2llH(mxsnal,mxsnal_ll,1)
	call cube2llH(czen,czen_ll,1)
	call cube2llH(czmean,czmean_ll,1)
   call cube2llH(fis,fis_ll,1)
   call cube2llH(q10,q10_ll,1)
   call cube2llH(th10,th10_ll,1)
   call cube2llH(qz0,qz0_ll,1)
   call cube2llH(thz0,thz0_ll,1)
  call cube2llH(ustar,ustar_ll,1)
  
   call cube2llH(ths,ths_ll,1) 
  
   call cube2llH(q2,q2_ll,lsm)
   call cube2llH(tcucn,tcucn_ll,lsm)
   call cube2llH(train,train_ll,lsm)
   call cube2llH(div,div_ll,lsm)
   call cube2llH(rtop,rtop_ll,lsm) 	
!++++++++++++++++++++++++++++++++++++++++++++++++++++++	
     
        call cube2llH(RSWIN,RSWIN_ll,1)
	call cube2llH(RSWOUT,RSWOUT_ll,1)
	call cube2llH(RSWTOA,RSWTOA_ll,1)
	
	call cube2llH(ASWIN,ASWIN_ll,1)
	call cube2llH(ASWOUT,ASWOUT_ll,1)
	call cube2llH(ASWTOA,ASWTOA_ll,1)
	call cube2llH(rswnet,rswnet_ll,1)
	call cube2llH(RSWTT,RSWTT_ll,lsm)!!!!!!!!!!!!!!!!!???
	
!+++++++++++++++++++++++++++++++++++++++
        call cube2llH(RLWIN,RLWIN_ll,1)
	call cube2llH(RLWOUT,RLWOUT_ll,1)
	call cube2llH(RLWTOA,RLWTOA_ll,1)
	
	call cube2llH(ALWIN,ALWIN_ll,1)
	call cube2llH(ALWOUT,ALWOUT_ll,1)
	call cube2llH(ALWTOA,ALWTOA_ll,1)
	call cube2llH(rlwnet,rlwnet_ll,1)
	call cube2llH(RLWTT,RLWTT_ll,lsm) !!!!!!!!!!???
        call cube2llH(epsr,epsr_ll,1)
    call cube2llH(radot,radot_ll,1)
    call cube2llH(sigt4,sigt4_ll,1)	
!++++++++++++++++++++++++++++++++++++++   
        call cube2llH(CUPPT,CUPPT_ll,1)
	call cube2llH(cfracl,cfracl_ll,1)
	call cube2llH(cfracm,cfracm_ll,1)
	
	call cube2llH(cfrach,cfrach_ll,1)
        call cube2llH(acfrcv,acfrcv_ll,1)
        call cube2llH(acfrst,acfrst_ll,1)
        call cube2llH(cnvtop,cnvtop_ll,1)
        call cube2llH(cnvbot,cnvbot_ll,1)
!        call cube2llH(htop,htop_ll,1)
!        call cube2llH(hbot,hbot_ll,1)
!++++++++++++++++++++++++++++++++++++++    
        call cube2llH(acprec,acprec_ll,1)
	call cube2llH(cuprec,cuprec_ll,1)
	call cube2llH(aprec,aprec_ll,1)
	call cube2llH(acsnow,acsnow_ll,1)
	call cube2llH(acsnom,acsnom_ll,1)
	call cube2llH(prec,prec_ll,1)
!++++++++++++++++++++++++++++++++++++++      
 
        call cube2llH(stc,stc_ll,1)
	call cube2llH(stc,stc_ll,4)
	call cube2llH(smc,smc_ll,1)
	call cube2llH(smc,smc_ll,4)
	call cube2llH(SMSTAV,SMSTAV_ll,1)
	call cube2llH(BGROFF,BGROFF_ll,1)
	call cube2llH(SSROFF,SSROFF_ll,1)
	call cube2llH(cmc,cmc_ll,1)
        call cube2llH(potevp,potevp_ll,1)
        call cube2llH(potflx,potflx_ll,1)
      call cube2llH(sfcevp,sfcevp_ll,1)
      call cube2llH(subshx,subshx_ll,1)
      call cube2llH(snopcx,snopcx_ll,1)
      call cube2llH(si,si_ll,1)
      call cube2llH(sno,sno_ll,1)
     
      call cube2llH(smstot,smstot_ll,1)
      call cube2llH(soiltb,soiltb_ll,1)
!     call cube2llH(tg,tg_ll,1)
      call cube2llH(sr,sr_ll,1)
      call cube2llH(akhs,akhs_ll,1)
      call cube2llH(akms,akms_ll,1)			
!++++++++++++++++++++++++++++++++++++++
 
        call llwinds(usl, vsl, ull, vll,lsm)
        call bocovs(ull,im,jm,lsm)
        call bocovs(vll,im,jm,lsm)
        call avrv(ull, usl,lsm)
        call avrv(vll, vsl,lsm)
        usl = usl * .25
        vsl = vsl * .25
        do k=1,nm
             usl(1 ,1 ,k,:)=usl(1 ,1 ,k,:)*4./3.
             vsl(1 ,1 ,k,:)=vsl(1 ,1 ,k,:)*4./3.
             usl(im,1 ,k,:)=usl(im,1 ,k,:)*4./3.
             vsl(im,1 ,k,:)=vsl(im,1 ,k,:)*4./3.
             usl(1 ,jm,k,:)=usl(1 ,jm,k,:)*4./3.
             vsl(1 ,jm,k,:)=vsl(1 ,jm,k,:)*4./3.
             usl(im,jm,k,:)=usl(im,jm,k,:)*4./3.
             vsl(im,jm,k,:)=vsl(im,jm,k,:)*4./3.
        enddo
         
        call cube2llH(usl, usp, lsm) 
        call cube2llH(vsl, vsp, lsm) 
!++++++++++++++++++++++++++++++++++++++

!        call llwinds(u10, v10, u10ll, v10ll,1)
!        call bocovs(u10ll,im,jm,1)
!        call bocovs(v10ll,im,jm,1)
!        call avrv(u10ll, u10,1)
!        call avrv(v10ll, v10,1)
!        u10 = u10 * .25
!        v10 = v10 * .25
!        do k=1,nm
!             u10(1 ,1 ,k)=u10(1 ,1 ,k)*4./3.
!             v10(1 ,1 ,k)=v10(1 ,1 ,k)*4./3.
!             u10(im,1 ,k)=u10(im,1 ,k)*4./3.
!             v10(im,1 ,k)=v10(im,1 ,k)*4./3.
!             u10(1 ,jm,k)=u10(1 ,jm,k)*4./3.
!             v10(1 ,jm,k)=v10(1 ,jm,k)*4./3.
!             u10(im,jm,k)=u10(im,jm,k)*4./3.
!             v10(im,jm,k)=v10(im,jm,k)*4./3.
!        enddo
!         
        call cube2llH(u10, u10_ll, 1) 
        call cube2llH(v10, v10_ll, 1) 
 
!+++++++++++++++++++++++++++++++++++++
!        call llwinds(uz0, vz0, uz0ll, vz0ll,1)
!        call bocovs(uz0ll,im,jm,1)
!        call bocovs(vz0ll,im,jm,1)
!        call avrv(uz0ll, uz0,1)
!        call avrv(vz0ll, vz0,1)
!        uz0 = uz0 * .25
!        vz0 = vz0 * .25
!        do k=1,nm
!             uz0(1 ,1 ,k)=uz0(1 ,1 ,k)*4./3.
!             vz0(1 ,1 ,k)=vz0(1 ,1 ,k)*4./3.
!             uz0(im,1 ,k)=uz0(im,1 ,k)*4./3.
!            vz0(im,1 ,k)=vz0(im,1 ,k)*4./3.
!             uz0(1 ,jm,k)=uz0(1 ,jm,k)*4./3.
!             vz0(1 ,jm,k)=vz0(1 ,jm,k)*4./3.
!             uz0(im,jm,k)=uz0(im,jm,k)*4./3.
!             vz0(im,jm,k)=vz0(im,jm,k)*4./3.
!        enddo
!         
        call cube2llH(uz0, uz0_ll, 1) 
        call cube2llH(vz0, vz0_ll, 1) 

!+++++++++++++++++++++++++++++++++++++
    
       endif



       hgt_ll=fsl_ll/9.80616
!       print *,usp(82,44,17)

       do l=1,lsm
       do j=1,jgm
         usp_avg(j,l)=0.
	 tsl_ll_avg(j,l)=0.
       do i=1,igm
!       do i=14,250
         usp_avg(j,l)=usp_avg(j,l)+usp(i,j,l)
         tsl_ll_avg(j,l)=tsl_ll_avg(j,l)+tsl_ll(i,j,l)
	 if(l.eq.17.and.j.eq.44)then
!	  print *,i,j,l,tsl_ll(i,j,l),usp_avg(j,l),usp(i,j,l)
         endif
       enddo
!       do i=335,360   !igm
!         usp_avg(j,l)=usp_avg(j,l)+usp(i,j,l)
!         tsl_ll_avg(j,l)=tsl_ll_avg(j,l)+tsl_ll(i,j,l)
!	 if(l.eq.17.and.j.eq.44)then
!	  print *,i,j,l,tsl_ll(i,j,l),usp_avg(j,l),usp(i,j,l)
!         endif
!       enddo

         usp_avg(j,l)=usp_avg(j,l)/igm
!         usp_avg(j,l)=usp_avg(j,l)/237
        tsl_ll_avg(j,l)=tsl_ll_avg(j,l)/igm
!         tsl_ll_avg(j,l)=tsl_ll_avg(j,l)/237
       enddo
       enddo

       do l=lsm-1,lsm
       do j=90,91
!         print *,j,l,tsl_ll_avg(j,l)
       enddo
       enddo
  
  
!= = = = = = = = = = = = = = = = = = = = = = = = = = = 

!VARIABLES WHICH GO TO THE GLOBRUN***.DAT FILES
!DRAGAN 21.09.10.      
  
!= = = = = = = = = = = = = = = = = = = = = = = = = = = 
     
     
       write(9)tsfc_ll(:,:)   !DRAGAN 21.09.

      
       write(9)psurf_ll(:,:)  !DRAGAN 21.09.
       
       
       write(9)pslp_ll(:,:)   !DRAGAN 21.09.
       
!!!       write(9)tshltr_ll(:,:)  !DRAGAN 21.09.
       
       
!!!       write(9)qshltr_ll(:,:)   !DRAGAN 21.09.

 !      write(9)plm_ll(:,:)
!++++++++++++++++++++++++++++++++++++++++++++

   write(9)tshltr_ll(:,:)  !DRAGAN 21.09.
   write(9)qshltr_ll(:,:)   !DRAGAN 21.09.
   write(9)plm_ll(:,:)
      
       write(9)sfclhx_ll(:,:)   !DRAGAN 21.09.
       
       
       write(9)sfcshx_ll(:,:) !DRAGAN 21.09.

    write(9)qwbs_ll(:,:) !DRAGAN 21.09.

    write(9)twbs_ll(:,:) !DRAGAN 21.09.
       
       write(9)grnflx_ll(:,:) !DRAGAN 21.09.

       write(9)vegfrc_ll(:,:) !DRAGAN 21.09.
      
!!!!!!!!       write(9)IVGTYP_ll(:,:) !DRAGAN 21.09.

!!!!!!!!        write(9)ISLTYP_ll(:,:) !DRAGAN 21.09.

!!!!!!!!        write(9)glat_ll(:,:) !DRAGAN 21.09.

!!!!!!!!        write(9)glon_ll(:,:) !DRAGAN 21.09.  
    
    write(9)sm_ll(:,:) !DRAGAN 21.09.   
       
!   do l=1,lsm
!       write(9)htm_ll(:,:,l)  !DRAGAN 17.09.
!       enddo
       
!       do l=1,lsm
!       write(9)vtm_ll(:,:,l)  !DRAGAN 17.09.
!       enddo
       
   
   write(9)sice_ll(:,:)     !DRAGAN 21.09.
   
!!!!!!!!        write(9)z0_ll(:,:)     !DRAGAN 21.09.
       
       write(9)albedo_ll(:,:)     !DRAGAN 21.09.
       
       write(9)albase_ll(:,:)     !DRAGAN 21.09. 
       
!!!!!!!!        write(9)mxsnal_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)czen_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)czmean_ll(:,:)     !DRAGAN 21.09.
    
    write(9)fis_ll(:,:)     !DRAGAN 21.09.
    
      write(9)q10_ll(:,:)     !DRAGAN 21.09.
    
    write(9)th10_ll(:,:)     !DRAGAN 21.09.
    
!!!!!!!!     write(9)qz0_ll(:,:)     !DRAGAN 21.09.
    
!!!!!!!!     write(9)thz0_ll(:,:)     !DRAGAN 21.09.
    
    
!!!!     write(9)u10_ll(:,:)     !DRAGAN 21.09.
    
!!!!     write(9)v10_ll(:,:)     !DRAGAN 21.09.
    
!!!!!!!!     write(9)uz0_ll(:,:)     !DRAGAN 21.09.
    
!!!!!!!!     write(9)vz0_ll(:,:)     !DRAGAN 21.09.
    
    
!!!!!!    write(9)ustar_ll(:,:)     !DRAGAN 21.09.
    
    
    
    
    write(9)ths_ll(:,:)     !DRAGAN 21.09.   

!++++++++++++++++++++++++++++++++++++++++++++       
 !!!!!!!!       write(9)RSWIN_ll(:,:)   !DRAGAN 21.09.
       
!!!!!!!!        write(9)RSWOUT_ll(:,:) !DRAGAN 21.09.

!!!!!!!!        write(9)RSWTOA_ll(:,:) !DRAGAN 21.09.

!!!!!!!!        write(9)ASWIN_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)ASWOUT_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)ASWTOA_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)rswnet_ll(:,:)     !DRAGAN 21.09.
 !++++++++++++
 
!!!!!!!!        write(9)RLWIN_ll(:,:)   !DRAGAN 21.09.
       
!!!!!!!!        write(9)RLWOUT_ll(:,:) !DRAGAN 21.09.

!!!!!!!!        write(9)RLWTOA_ll(:,:) !DRAGAN 21.09.

!!!!!!!!        write(9)ALWIN_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)ALWOUT_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)ALWTOA_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)rlwnet_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!        write(9)epsr_ll(:,:)     !DRAGAN 21.09.
       
!!!!!!!!      write(9)radot_ll(:,:)     !DRAGAN 21.09.
     
      write(9)sigt4_ll(:,:)     !DRAGAN 21.09.   
!++++++++++++      
       
       write(9)CUPPT_ll(:,:)     !DRAGAN 21.09.
       
       write(9)cfracl_ll(:,:)     !DRAGAN 21.09.
       
       write(9)cfracm_ll(:,:)     !DRAGAN 21.09.
       
       write(9)cfrach_ll(:,:)     !DRAGAN 21.09.
    
       write(9)acfrcv_ll(:,:)     !DRAGAN 21.09.
       
       write(9)acfrst_ll(:,:)     !DRAGAN 21.09.
    
       write(9)cnvtop_ll(:,:)     !DRAGAN 21.09.
       
       write(9)cnvbot_ll(:,:)     !DRAGAN 21.09.
       
!       write(9)htop_ll(:,:)     !DRAGAN 21.09.
       
!       write(9)hbot_ll(:,:)     !DRAGAN 21.09.


!++++++++++++
       write(9)acprec_ll(:,:)     !DRAGAN 21.09.
       
       write(9)cuprec_ll(:,:)     !DRAGAN 21.09.
       
       write(9)aprec_ll(:,:)     !DRAGAN 21.09.
       
       write(9)acsnow_ll(:,:)     !DRAGAN 21.09.

       write(9)acsnom_ll(:,:)     !DRAGAN 21.09.
      
       write(9)prec_ll(:,:)     !DRAGAN 21.09.

!++++++++++++
       
       
       write(9)stc_ll(:,:,1)     !DRAGAN 21.09.
       
       write(9)stc_ll(:,:,4)     !DRAGAN 21.09.
       
       write(9)smc_ll(:,:,1)     !DRAGAN 21.09.
      
       write(9)smc_ll(:,:,4)     !DRAGAN 21.09.

       write(9)SMSTAV_ll(:,:)     !DRAGAN 21.09.

       write(9)BGROFF_ll(:,:)     !DRAGAN 21.09.

       write(9)SSROFF_ll(:,:)     !DRAGAN 21.09.
       
       write(9)cmc_ll(:,:)     !DRAGAN 21.09.

       write(9)potevp_ll(:,:)     !DRAGAN 21.09.

       write(9)potflx_ll(:,:)     !DRAGAN 21.09.
      
      write(9)sfcevp_ll(:,:)     !DRAGAN 21.09.
     
      write(9)subshx_ll(:,:)     !DRAGAN 21.09.
     
      write(9)snopcx_ll(:,:)     !DRAGAN 21.09.
     
      write(9)si_ll(:,:)     !DRAGAN 21.09.
     
      write(9)sno_ll(:,:)     !DRAGAN 21.09.
     
     
     
      write(9)smstot_ll(:,:)     !DRAGAN 21.09.
     
      write(9)soiltb_ll(:,:)     !DRAGAN 21.09.
     
!     write(9)tg_ll(:,:)     !DRAGAN 21.09.
     
      write(9)sr_ll(:,:)     !DRAGAN 21.09.
     
!!!!!!!!      write(9)akhs_ll(:,:)     !DRAGAN 21.09.  
       
!!!!!!!!      write(9)akms_ll(:,:)     !DRAGAN 21.09.  

!++++++++++++
       do l=1,lsm
!!!!!!!!        write(9)RSWTT_ll(:,:,l)  !DRAGAN 17.09.
       enddo
      
       do l=1,lsm
!!!!!!!!        write(9)RLWTT_ll(:,:,l)  !DRAGAN 17.09.
       enddo

       do l=1,lsm
!!!!!!!!        write(9)omgalf_ll(:,:,l)  !DRAGAN 17.09.
       enddo

       do l=1,lsm
!!!!!!!!        write(9)q2_ll(:,:,l)  !DRAGAN 17.09.
       enddo
       
       do l=1,lsm
!!!!!!!!        write(9)tcucn_ll(:,:,l)  !DRAGAN 17.09.
       enddo
       
       do l=1,lsm
!!!!!!!!        write(9)train_ll(:,:,l)  !DRAGAN 17.09.
       enddo
       
       do l=1,lsm
       write(9)div_ll(:,:,l)  !DRAGAN 17.09.
       enddo
       
       do l=1,lsm
       write(9)rtop_ll(:,:,l)  !DRAGAN 17.09.
       enddo


!++++++++++++++      
      do l=1,lsm
       write(9)w_ll(:,:,l)  !DRAGAN 2016
       enddo
       
       do l=1,lsm
       write(9)dwdt_ll(:,:,l)  !DRAGAN 2016
       enddo
       
       do l=1,lsm
       write(9)z_ll(:,:,l)  !DRAGAN 2016
       enddo
      
      
       do l=1,lsm
       write(9)hgt_ll(:,:,l)  !DRAGAN 17.09.
       enddo
       
       do l=1,lsm
       write(9)tsl_ll(:,:,l)  !DRAGAN 21.09.
       enddo
       
       do l=1,lsm
       write(9)fsl_ll(:,:,l)  !DRAGAN 21.09.
       enddo
       
       do l=1,lsm
       write(9)qsl_ll(:,:,l)  !DRAGAN 21.09.
       enddo
       
       do l=1,lsm
       write(9)q2sl_ll(:,:,l) !DRAGAN 21.09.
       enddo
       
       do l=1,lsm
       write(9)usp(:,:,l)     !DRAGAN 21.09.
       enddo
       
       do l=1,lsm
       write(9)vsp(:,:,l)     !DRAGAN 21.09.
       enddo
       
       
!= = = = = = = =  = = = = = = = = = = = = = = = = = =       
       
       
       
       
!         write(10)hgt_ll(:,:,10)         !DRAGAN 17.09
!         write(10)hgt_ll(:,:,4)
!DRAGAN 17.09       write(9)tsl_ll_avg
!DRAGAN 17.09.       write(9)usp_avg

!DRAGAN 20.09.      print *,'igm=',igm, 'jgm=',jgm

       end subroutine qu2ll2
