        subroutine surfce

       USE mod_masks
	USE mod_pvrbls
	USE mod_vrbls
	implicit none
	include 'param_o.h'
	include 'params'
	include 'const.h'
	
	integer::i,j,n
        real,dimension(0:im+1,0:jm+1,nm)::tsfc
	real::psfc
	
        do n=1,nm
	do j=1,jm
	do i=1,im
	    
	    psfc=pt+pd(i,j,n)
            TSFC(I,J,n) =THS(I,J,n)*(PSFC/P1000)**CAPA
       
        enddo
        enddo
        enddo
!+++++++++++++++++++++++
        open(1,file='tmpsfc.dat',form='unformatted')
	write(1)tsfc
!jnt      
!jnt      write(1)tshltr
!jnt      write(1)qshltr
!jnt      write(1)plm
!jnt
!jnt
!jnt	write(1)sfclhx   !!!!!!!!!!!!!!!!DRAGAN
!jnt	write(1)sfcshx
!jnt    write(1)qwbs
!jnt    write(1)twbs        
!jnt	
!jnt	write(1)grnflx
!jnt	write(1)vegfrc
!jnt        write(1)IVGTYP
!jnt        write(1)ISLTYP
!jnt        write(1)glat
!jnt        write(1)glon
!jnt    write(1)sm	
!jnt!	write(1)htm 
!jnt!	write(1)vtm
!jnt	write(1)sice
!jnt	write(1)z0
!jnt        write(1)omgalf
!jnt	write(1)albedo
!jnt       
!jnt        write(1)albase
!jnt        write(1)mxsnal
!jnt         
!jnt        write(1)czen
!jnt        write(1)czmean	
!jnt   write(1)fis
!jnt   write(1)q10    
!jnt   write(1)th10    
!jnt   write(1)qz0    
!jnt   write(1)thz0   
!jnt   
!jnt   write(1)u10
!jnt   write(1)v10
!jnt   write(1)uz0
!jnt   write(1)vz0
!jnt   write(1)ustar
!jnt   
!jnt   write(1)ths	
!jnt    
!jnt   write(1)q2    
!jnt   write(1)tcucn    
!jnt   write(1)train    
!jnt   write(1)div  
!jnt   write(1)rtop 
!jnt      close(1)
!jnt!++++++++++++++++++++	
!jnt      open(2,file='./ETAPOST/sw_rdtn.dat',form='unformatted')
!jnt	write(2)RSWIN
!jnt	write(2)RSWOUT
!jnt	write(2)RSWTOA   !!!!!!!!!!!!!!!!DRAGAN
!jnt	write(2)ASWIN
!jnt	write(2)ASWOUT
!jnt	
!jnt	write(2)ASWTOA
!jnt	write(2)rswnet
!jnt	write(2)RSWTT
!jnt	
!jnt      close(2)
!jnt	
!jnt!++++++++++++++++++++++
!jnt      open(3,file='./ETAPOST/lw_rdtn.dat',form='unformatted')
!jnt	write(3)RLWIN
!jnt	write(3)RLWOUT
!jnt	write(3)RLWTOA   !!!!!!!!!!!!!!!!DRAGAN
!jnt	write(3)ALWIN
!jnt	write(3)ALWOUT
!jnt	
!jnt	write(3)ALWTOA
!jnt	write(3)rlwnet
!jnt	write(3)RLWTT
!jnt        write(3)epsr	
!jnt      write(3)radot   
!jnt      write(3)sigt4 
!jnt     
!jnt      close(3)
!jnt
!jnt!+++++++++++++++++++++++	
!jnt      open(4,file='./ETAPOST/clouds.dat',form='unformatted')
!jnt	write(4)CUPPT
!jnt	write(4)cfracl
!jnt	write(4)cfracm   !!!!!!!!!!!!!!!!DRAGAN
!jnt	write(4)cfrach
!jnt        write(4)acfrcv
!jnt        write(4)acfrst
!jnt!    write(4)f_ice
!jnt!    write(4)f_rain
!jnt!    write(4)f_RimeF
!jnt    
!jnt        write(4)cnvtop
!jnt        write(4)cnvbot
!jnt!        write(4)htop
!jnt!        write(4)hbot
!jnt      close(4)
!jnt!+++++++++++++++++++++++	
!jnt      open(5,file='./ETAPOST/precANDsoil.dat',form='unformatted')
!jnt	write(5)acprec
!jnt	write(5)cuprec
!jnt	write(5)aprec   !!!!!!!!!!!!!!!!DRAGAN
!jnt	write(5)acsnow
!jnt	
!jnt        write(5)acsnom	
!jnt	write(5)prec
!jnt	
!jnt	write(5)stc(:,:,:,1)
!jnt	write(5)stc(:,:,:,4)
!jnt	write(5)smc(:,:,:,1)
!jnt	write(5)smc(:,:,:,4)
!jnt	
!jnt	write(5)SMSTAV
!jnt	write(5)BGROFF
!jnt	write(5)SSROFF
!jnt        write(5)cmc
!jnt        write(5)potevp
!jnt        write(5)potflx
!jnt      write(5)sfcevp
!jnt      write(5)subshx
!jnt      write(5)snopcx
!jnt    
!jnt      write(5)si
!jnt      write(5)sno
!jnt     	 
!jnt      write(5)smstot
!jnt      write(5)soiltb  !!!!   
!jnt!     write(5)tg      !!!!
!jnt      write(5)sr 
!jnt      write(5)akhs
!jnt      write(5)akms
!jnt     	
!jnt	
!jnt		
!jnt      close(5)
!++++++++++++++++++++++
       

      end subroutine surfce
