Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 3147)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 3152)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! q_surface added
+! 
+! 3147 2018-07-18 22:38:11Z maronga
 ! Added vpt_surface and vpt1
 ! 
@@ -306,4 +309,5 @@
        REAL(wp), DIMENSION(:,:), ALLOCATABLE   ::  rrtm_asdir      !< albedo for shortwave direct radiation, solar angle of 60Â°
 
+       REAL(wp), DIMENSION(:), ALLOCATABLE   ::  q_surface         !< skin-surface mixing ratio
        REAL(wp), DIMENSION(:), ALLOCATABLE   ::  pt_surface        !< skin-surface temperature
        REAL(wp), DIMENSION(:), ALLOCATABLE   ::  vpt_surface       !< skin-surface virtual temperature
@@ -1161,4 +1165,5 @@
           ALLOCATE ( surfaces%qs(1:surfaces%ns)   ) 
           ALLOCATE ( surfaces%qsws(1:surfaces%ns) )      
+          ALLOCATE ( surfaces%q_surface(1:surfaces%ns)   ) 
           ALLOCATE ( surfaces%vpt_surface(1:surfaces%ns) ) 
        ENDIF 
@@ -1417,4 +1422,5 @@
           DEALLOCATE ( surfaces%qs ) 
           DEALLOCATE ( surfaces%qsws )  
+          DEALLOCATE ( surfaces%q_surface   )
           DEALLOCATE ( surfaces%vpt_surface )
        ENDIF 
@@ -1541,4 +1547,5 @@
           ALLOCATE ( surfaces%qs(1:surfaces%ns)          ) 
           ALLOCATE ( surfaces%qsws(1:surfaces%ns)        )   
+          ALLOCATE ( surfaces%q_surface(1:surfaces%ns)   )
           ALLOCATE ( surfaces%vpt_surface(1:surfaces%ns) )            
        ENDIF 
@@ -2093,5 +2100,8 @@
 
              surf%ts(num_h)   = 0.0_wp
-
+!
+!--          Set initial value for surface temperature
+             surf%pt_surface(num_h) = pt_surface
+             
              IF ( humidity )  THEN
                 surf%qs(num_h)   = 0.0_wp
@@ -2116,4 +2126,8 @@
                    
                 ENDIF
+                
+                surf%q_surface(num_h)   = q_surface
+                surf%vpt_surface(num_h) = surf%pt_surface(num_h) *             &
+                                   ( 1.0_wp + 0.61_wp * surf%q_surface(num_h) )
              ENDIF
 
@@ -2123,7 +2137,4 @@
                 IF ( air_chemistry )  surf%css(lsp,num_h) = 0.0_wp
              ENDDO
-!
-!--          Set initial value for surface temperature
-             surf%pt_surface(num_h) = pt_surface
 !
 !--          Inititalize surface fluxes of sensible and latent heat, as well as
@@ -2619,4 +2630,6 @@
                    IF ( ALLOCATED( surf_def_h(l)%pt_surface ) )                &
                       surf_h(l)%pt_surface(mm(l)) = surf_def_h(l)%pt_surface(m)
+                   IF ( ALLOCATED( surf_def_h(l)%q_surface ) )                 &
+                      surf_h(l)%q_surface(mm(l)) = surf_def_h(l)%q_surface(m) 
                    IF ( ALLOCATED( surf_def_h(l)%vpt_surface ) )               &
                       surf_h(l)%vpt_surface(mm(l)) = surf_def_h(l)%vpt_surface(m)                      
@@ -2676,6 +2689,8 @@
                       IF ( ALLOCATED( surf_lsm_h%pt_surface ) )                &
                          surf_h(l)%pt_surface(mm(l)) = surf_lsm_h%pt_surface(m)
+                      IF ( ALLOCATED( surf_def_h(l)%q_surface ) )              &
+                         surf_h(l)%q_surface(mm(l)) = surf_def_h(l)%q_surface(m)
                       IF ( ALLOCATED( surf_def_h(l)%vpt_surface ) )            &
-                      surf_h(l)%vpt_surface(mm(l)) = surf_def_h(l)%vpt_surface(m)
+                         surf_h(l)%vpt_surface(mm(l)) = surf_def_h(l)%vpt_surface(m)
                       IF ( ALLOCATED( surf_lsm_h%usws ) )                      &
                          surf_h(0)%usws(mm(0))    = surf_lsm_h%usws(m)
@@ -2733,4 +2748,6 @@
                       IF ( ALLOCATED( surf_usm_h%pt_surface ) )                &
                          surf_h(l)%pt_surface(mm(l)) = surf_usm_h%pt_surface(m)
+                       IF ( ALLOCATED( surf_usm_h%q_surface ) )                &
+                         surf_h(l)%q_surface(mm(l)) = surf_usm_h%q_surface(m)
                       IF ( ALLOCATED( surf_usm_h%vpt_surface ) )               &
                          surf_h(l)%vpt_surface(mm(l)) = surf_usm_h%vpt_surface(m)
@@ -2831,4 +2848,6 @@
                    IF ( ALLOCATED( surf_def_v(l)%pt_surface ) )                &
                       surf_v(l)%pt_surface(mm(l)) = surf_def_v(l)%pt_surface(m)
+                   IF ( ALLOCATED( surf_def_v(l)%q_surface ) )                 &
+                      surf_v(l)%q_surface(mm(l)) = surf_def_v(l)%q_surface(m)
                    IF ( ALLOCATED( surf_def_v(l)%vpt_surface ) )               &
                       surf_v(l)%vpt_surface(mm(l)) = surf_def_v(l)%vpt_surface(m)
@@ -2889,4 +2908,6 @@
                    IF ( ALLOCATED( surf_lsm_v(l)%pt_surface ) )                &
                       surf_v(l)%pt_surface(mm(l)) = surf_lsm_v(l)%pt_surface(m)
+                   IF ( ALLOCATED( surf_lsm_v(l)%q_surface ) )                 &
+                      surf_v(l)%q_surface(mm(l)) = surf_lsm_v(l)%q_surface(m)
                    IF ( ALLOCATED( surf_lsm_v(l)%vpt_surface ) )               &
                       surf_v(l)%vpt_surface(mm(l)) = surf_lsm_v(l)%vpt_surface(m)
@@ -2951,4 +2972,6 @@
                    IF ( ALLOCATED( surf_usm_v(l)%pt_surface ) )                &
                       surf_v(l)%pt_surface(mm(l)) = surf_usm_v(l)%pt_surface(m)
+                   IF ( ALLOCATED( surf_usm_v(l)%q_surface ) )                 &
+                      surf_v(l)%q_surface(mm(l)) = surf_usm_v(l)%q_surface(m)
                    IF ( ALLOCATED( surf_usm_v(l)%vpt_surface ) )               &
                       surf_v(l)%vpt_surface(mm(l)) = surf_usm_v(l)%vpt_surface(m)
@@ -3092,4 +3115,9 @@
              WRITE ( 14 )  surf_h(l)%pt_surface
           ENDIF
+          
+          IF ( ALLOCATED ( surf_h(l)%q_surface ) )  THEN
+             CALL wrd_write_string( 'surf_h(' // dum // ')%q_surface' ) 
+             WRITE ( 14 )  surf_h(l)%q_surface
+          ENDIF
 
           IF ( ALLOCATED ( surf_h(l)%vpt_surface ) )  THEN
@@ -3224,4 +3252,9 @@
              WRITE ( 14 )  surf_v(l)%pt_surface
           ENDIF 
+          
+          IF ( ALLOCATED ( surf_v(l)%q_surface ) )  THEN
+             CALL wrd_write_string( 'surf_v(' // dum // ')%q_surface' )
+             WRITE ( 14 )  surf_v(l)%q_surface
+          ENDIF
 
           IF ( ALLOCATED ( surf_v(l)%vpt_surface ) )  THEN
@@ -3467,4 +3500,7 @@
              IF ( ALLOCATED( surf_h(0)%pt_surface )  .AND.  kk == 1 )          &
                 READ ( 13 )  surf_h(0)%pt_surface
+          CASE ( 'surf_h(0)%q_surface' )         
+             IF ( ALLOCATED( surf_h(0)%q_surface )  .AND.  kk == 1 )           &
+                READ ( 13 )  surf_h(0)%q_surface
           CASE ( 'surf_h(0)%vpt_surface' )         
              IF ( ALLOCATED( surf_h(0)%vpt_surface )  .AND.  kk == 1 )         &
@@ -3547,6 +3583,9 @@
              IF ( ALLOCATED( surf_h(1)%pt_surface )  .AND.  kk == 1 )          &
                 READ ( 13 )  surf_h(1)%pt_surface
+          CASE ( 'surf_h(1)%q_surface' )         
+             IF ( ALLOCATED( surf_h(1)%q_surface )  .AND.  kk == 1 )           &
+                READ ( 13 )  surf_h(1)%q_surface
           CASE ( 'surf_h(1)%vpt_surface' )         
-             IF ( ALLOCATED( surf_h(1)%vpt_surface )  .AND.  kk == 1 )          &
+             IF ( ALLOCATED( surf_h(1)%vpt_surface )  .AND.  kk == 1 )         &
                 READ ( 13 )  surf_h(1)%vpt_surface
           CASE ( 'surf_h(1)%usws' )         
@@ -3627,6 +3666,9 @@
              IF ( ALLOCATED( surf_h(2)%pt_surface )  .AND.  kk == 1 )          &
                 READ ( 13 )  surf_h(2)%pt_surface
+          CASE ( 'surf_h(2)%q_surface' )         
+             IF ( ALLOCATED( surf_h(2)%q_surface )  .AND.  kk == 1 )           &
+                READ ( 13 )  surf_h(2)%q_surface
           CASE ( 'surf_h(2)%vpt_surface' )         
-             IF ( ALLOCATED( surf_h(2)%vpt_surface )  .AND.  kk == 1 )          &
+             IF ( ALLOCATED( surf_h(2)%vpt_surface )  .AND.  kk == 1 )         &
                 READ ( 13 )  surf_h(2)%vpt_surface
           CASE ( 'surf_h(2)%usws' )         
@@ -3709,6 +3751,9 @@
              IF ( ALLOCATED( surf_v(0)%pt_surface )  .AND.  kk == 1 )          &
                 READ ( 13 )  surf_v(0)%pt_surface
+          CASE ( 'surf_v(0)%q_surface' )         
+             IF ( ALLOCATED( surf_v(0)%q_surface )  .AND.  kk == 1 )           &
+                READ ( 13 )  surf_v(0)%q_surface
           CASE ( 'surf_v(0)%vpt_surface' )         
-             IF ( ALLOCATED( surf_v(0)%vpt_surface )  .AND.  kk == 1 )          &
+             IF ( ALLOCATED( surf_v(0)%vpt_surface )  .AND.  kk == 1 )         &
                 READ ( 13 )  surf_v(0)%vpt_surface
           CASE ( 'surf_v(0)%shf' )         
@@ -3792,4 +3837,7 @@
              IF ( ALLOCATED( surf_v(1)%pt_surface )  .AND.  kk == 1 )          &
                 READ ( 13 )  surf_v(1)%pt_surface
+          CASE ( 'surf_v(1)%q_surface' )         
+             IF ( ALLOCATED( surf_v(1)%q_surface )  .AND.  kk == 1 )           &
+                READ ( 13 )  surf_v(1)%q_surface
           CASE ( 'surf_v(1)%vpt_surface' )         
              IF ( ALLOCATED( surf_v(1)%vpt_surface )  .AND.  kk == 1 )         &
@@ -3875,6 +3923,9 @@
              IF ( ALLOCATED( surf_v(2)%pt_surface )  .AND.  kk == 1 )          &
                 READ ( 13 )  surf_v(2)%pt_surface
+          CASE ( 'surf_v(2)%q_surface' )         
+             IF ( ALLOCATED( surf_v(2)%q_surface )  .AND.  kk == 1 )           &
+                READ ( 13 )  surf_v(2)%q_surface
           CASE ( 'surf_v(2)%vpt_surface' )         
-             IF ( ALLOCATED( surf_v(2)%vpt_surface )  .AND.  kk == 1 )          &
+             IF ( ALLOCATED( surf_v(2)%vpt_surface )  .AND.  kk == 1 )         &
                 READ ( 13 )  surf_v(2)%vpt_surface
           CASE ( 'surf_v(2)%shf' )         
@@ -3958,6 +4009,9 @@
              IF ( ALLOCATED( surf_v(3)%pt_surface )  .AND.  kk == 1 )          &
                 READ ( 13 )  surf_v(3)%pt_surface
+          CASE ( 'surf_v(3)%q_surface' )         
+             IF ( ALLOCATED( surf_v(3)%q_surface )  .AND.  kk == 1 )           &
+                READ ( 13 )  surf_v(3)%q_surface
           CASE ( 'surf_v(3)%vpt_surface' )         
-             IF ( ALLOCATED( surf_v(3)%vpt_surface )  .AND.  kk == 1 )          &
+             IF ( ALLOCATED( surf_v(3)%vpt_surface )  .AND.  kk == 1 )         &
                 READ ( 13 )  surf_v(3)%vpt_surface
           CASE ( 'surf_v(3)%shf' )         
@@ -4154,4 +4208,10 @@
                    surf_target%pt_surface(m_target) = surf_file%pt_surface(m_file)
              ENDIF
+             
+             IF ( INDEX( restart_string(1:length), '%q_surface' ) /= 0 )  THEN 
+                IF ( ALLOCATED( surf_target%q_surface )  .AND.                 &
+                     ALLOCATED( surf_file%q_surface   ) )                      & 
+                   surf_target%q_surface(m_target) = surf_file%q_surface(m_file)
+             ENDIF
 
              IF ( INDEX( restart_string(1:length), '%vpt_surface' ) /= 0 )  THEN 
