Index: palm/trunk/SOURCE/read_3d_binary.f90
===================================================================
--- palm/trunk/SOURCE/read_3d_binary.f90	(revision 2101)
+++ palm/trunk/SOURCE/read_3d_binary.f90	(revision 2232)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Adjustments to new surface concept - move output of surface varariables
+! to surface_mod
 ! 
 ! Former revisions:
@@ -120,15 +121,13 @@
 
     USE arrays_3d,                                                             &
-        ONLY:  e, kh, km, ol, p, pt, q, ql, qc, nr, nrs, nrsws, nrswst,        &
-               prr, precipitation_amount, qr,                                  &
-               qrs, qrsws, qrswst, qs, qsws, qswst, s, sa, saswsb, saswst,     &
-               ss, ssws, sswst, rif_wall, shf, ss, ts, tswst, u, u_m_l, u_m_n, &
-               u_m_r, u_m_s, us, usws, uswst, v, v_m_l, v_m_n, v_m_r, v_m_s,   &
-               vpt, vsws, vswst, w, w_m_l, w_m_n, w_m_r, w_m_s, z0, z0h, z0q
+        ONLY:  e, kh, km, p, pt, q, ql, qc, nr, prr, precipitation_amount, qr, &
+               s, sa, u, u_m_l, u_m_n, u_m_r, u_m_s, v, v_m_l, v_m_n, v_m_r,   &
+               v_m_s, vpt, w, w_m_l, w_m_n, w_m_r, w_m_s
 
     USE averaging
 
     USE control_parameters,                                                    &
-        ONLY:  iran, message_string, outflow_l, outflow_n, outflow_r, outflow_s
+        ONLY:  iran, land_surface, message_string, outflow_l, outflow_n,       &
+               outflow_r, outflow_s
 
     USE cpulog,                                                                &
@@ -142,5 +141,5 @@
 
     USE land_surface_model_mod,                                                &
-        ONLY:  land_surface, lsm_read_restart_data
+        ONLY:  lsm_read_restart_data
 
     USE particle_attributes,                                                   &
@@ -161,4 +160,6 @@
         ONLY:  spectrum_x, spectrum_y
 
+    USE surface_mod,                                                           &
+        ONLY :  surface_read_restart_data
 
     IMPLICIT NONE
@@ -436,4 +437,8 @@
              nync = nynfa(i,k) + offset_ya(i,k)
 
+             write(9,*) "f", nxlf, nxrf, nysf, nynf
+             write(9,*) "c", nxlc, nxrc, nysc, nync
+
+
 
              SELECT CASE ( TRIM( field_chr ) )
@@ -494,23 +499,4 @@
                    nr_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
                                     tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'nrs' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   nrs(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'nrsws' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   nrsws(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'nrswst' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   nrswst(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-                CASE ( 'ol' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ol(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
                 CASE ( 'p' )
@@ -637,19 +623,4 @@
                                     tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
-                CASE ( 'qrs' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qrs(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qrsws' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qrsws(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qrswst' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qrswst(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'ql_c_av' )
                    IF ( .NOT. ALLOCATED( ql_c_av ) )  THEN
@@ -675,14 +646,4 @@
                    ql_vp_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
                                         tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qs' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qs(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'qsws' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qsws(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
                 CASE ( 'qsws_av' )
@@ -694,9 +655,4 @@
                                           tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
-                CASE ( 'qswst' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   qswst(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'qv_av' )
                    IF ( .NOT. ALLOCATED( qv_av ) )  THEN
@@ -722,14 +678,5 @@
                    rho_ocean_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
                                 tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'rif_wall' )
-                   IF ( k == 1 )  THEN
-                      ALLOCATE( tmp_4d(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp, &
-                                       nxl_on_file-nbgp:nxr_on_file+nbgp,1:4) )
-                      READ ( 13 )  tmp_4d
-                   ENDIF
-                   rif_wall(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp,:) = &
-                            tmp_4d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp,:)
-                            
+                           
                 CASE ( 's' )
                    IF ( k == 1 )  READ ( 13 )  tmp_3d
@@ -757,19 +704,4 @@
                    sa_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) = &
                                     tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'saswsb' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   saswsb(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'saswst' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   saswst(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'shf' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   shf(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                      tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
                 CASE ( 'shf_av' )
@@ -811,14 +743,4 @@
                    ENDIF
                    
-                CASE ( 'ss' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ss(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'ssws' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ssws(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'ssws_av' )
                    IF ( .NOT. ALLOCATED( ssws_av ) )  THEN
@@ -828,15 +750,5 @@
                    ssws_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
                                           tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'sswst' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   sswst(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                                          tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp) 
                  
-                CASE ( 'ts' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   ts(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                     tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'ts_av' )
                    IF ( .NOT. ALLOCATED( ts_av ) )  THEN
@@ -847,9 +759,4 @@
                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
-                CASE ( 'tswst' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   tswst(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                         tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'u' )
                    IF ( k == 1 )  READ ( 13 )  tmp_3d
@@ -905,19 +812,4 @@
                    ENDIF
 
-                CASE ( 'us' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   us(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                     tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'usws' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   usws(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'uswst' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   uswst(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'us_av' )
                    IF ( .NOT. ALLOCATED( us_av ) )  THEN
@@ -994,14 +886,4 @@
                                tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
-                CASE ( 'vsws' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   vsws(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                       tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'vswst' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   vswst(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'w' )
                    IF ( k == 1 )  READ ( 13 )  tmp_3d
@@ -1058,9 +940,4 @@
                    DEALLOCATE( tmp_3dwws )
 
-                CASE ( 'z0' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                     tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'z0_av' )
                    IF ( .NOT. ALLOCATED( z0_av ) )  THEN
@@ -1071,9 +948,4 @@
                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
-                CASE ( 'z0h' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0h(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                     tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
                 CASE ( 'z0h_av' )
                    IF ( .NOT. ALLOCATED( z0h_av ) )  THEN
@@ -1083,9 +955,4 @@
                    z0h_av(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
                        tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
-
-                CASE ( 'z0q' )
-                   IF ( k == 1 )  READ ( 13 )  tmp_2d
-                   z0q(nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp)  = &
-                     tmp_2d(nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
 
                 CASE ( 'z0q_av' )
@@ -1128,4 +995,10 @@
 
        ENDDO  ! loop over variables
+!
+!--    Read surface related variables
+       CALL surface_read_restart_data( i, nxlfa, nxl_on_file, nxrfa,           &
+                                       nxr_on_file, nynfa, nyn_on_file, nysfa, &
+                                       nys_on_file, offset_xa, offset_ya,      &
+                                       overlap_count(i) )
 
 !
