Index: palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 2001)
+++ palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 2003)
@@ -21,5 +21,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Humidity and passive scalar also separated in nesting mode 
 ! 
 ! Former revisions:
@@ -123,6 +123,6 @@
    USE arrays_3d,                                                               &
         ONLY:  dzu, dzw, e, e_p, e_1, e_2, pt, pt_p, pt_1, pt_2, q, q_p, q_1,   &
-               q_2, u, u_p, u_1, u_2, v, v_p, v_1, v_2, w, w_p, w_1, w_2, zu,   &
-               zw, z0
+               q_2, s, s_2, u, u_p, u_1, u_2, v, v_p, v_1, v_2, w, w_p, w_1, w_2,  &
+               zu, zw, z0
 #endif
 
@@ -243,4 +243,5 @@
     REAL(wp), SAVE, DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  wc   !:
     REAL(wp), SAVE, DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  qc   !:
+    REAL(wp), SAVE, DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  sc   !:
 
 !
@@ -915,6 +916,9 @@
           CALL pmc_set_dataarray_name( 'coarse', 'pt' ,'fine', 'pt', ierr )
        ENDIF
-       IF ( humidity  .OR.  passive_scalar )  THEN
+       IF ( humidity )  THEN
           CALL pmc_set_dataarray_name( 'coarse', 'q'  ,'fine', 'q',  ierr )
+       ENDIF
+       IF ( passive_scalar )  THEN
+          CALL pmc_set_dataarray_name( 'coarse', 's'  ,'fine', 's',  ierr )
        ENDIF
 
@@ -2521,4 +2525,5 @@
     IF ( TRIM(name) == "pt" )  p_3d => pt
     IF ( TRIM(name) == "q"  )  p_3d => q
+    IF ( TRIM(name) == "s"  )  p_3d => s
 !
 !-- Next line is just an example for a 2D array (not active for coupling!)
@@ -2552,4 +2557,5 @@
     IF ( TRIM(name) == "pt" )  p_3d_sec => pt_2
     IF ( TRIM(name) == "q"  )  p_3d_sec => q_2
+    IF ( TRIM(name) == "s"  )  p_3d_sec => s_2
 
     IF ( ASSOCIATED( p_3d ) )  THEN
@@ -2623,4 +2629,7 @@
        IF ( .NOT. ALLOCATED( qc ) ) ALLOCATE( qc(0:nzc+1, js:je, is:ie) )
        p_3d => qc
+    ELSEIF ( TRIM( name ) == "s")  THEN
+       IF ( .NOT. ALLOCATED( sc ) ) ALLOCATE( sc(0:nzc+1, js:je, is:ie) )
+       p_3d => sc
     !ELSEIF (trim(name) == "z0") then
        !IF (.not.allocated(z0c))  allocate(z0c(js:je, is:ie))
@@ -2722,6 +2731,10 @@
                                       r1yo, r2yo, r1zo, r2zo, nzb_s_inner, 's' )
        ENDIF
-       IF ( humidity  .OR.  passive_scalar )  THEN
+       IF ( humidity )  THEN
           CALL pmci_interp_tril_all ( q, qc, ico, jco, kco, r1xo, r2xo, r1yo,   &
+                                      r2yo, r1zo, r2zo, nzb_s_inner, 's' )
+       ENDIF
+       IF ( passive_scalar )  THEN
+          CALL pmci_interp_tril_all ( s, sc, ico, jco, kco, r1xo, r2xo, r1yo,   &
                                       r2yo, r1zo, r2zo, nzb_s_inner, 's' )
        ENDIF
@@ -3367,6 +3380,12 @@
                                           nzt_topo_nestbc_l, 'l', 's' )
              ENDIF
-             IF ( humidity  .OR.  passive_scalar )  THEN
+             IF ( humidity )  THEN
                 CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo,     &
+                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
+                                          logc_u_l, logc_ratio_u_l,             &
+                                          nzt_topo_nestbc_l, 'l', 's' )
+             ENDIF
+             IF ( passive_scalar )  THEN
+                CALL pmci_interp_tril_lr( s, sc, ico, jco, kco, r1xo, r2xo,     &
                                           r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
                                           logc_u_l, logc_ratio_u_l,             &
@@ -3382,6 +3401,9 @@
                    CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'l', 's' )
                 ENDIF
-                IF ( humidity  .OR.  passive_scalar )  THEN
+                IF ( humidity )  THEN
                    CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'l', 's' )
+                ENDIF
+                IF ( passive_scalar )  THEN
+                   CALL pmci_extrap_ifoutflow_lr( s, nzb_s_inner, 'l', 's' )
                 ENDIF
              ENDIF
@@ -3414,6 +3436,12 @@
                                           nzt_topo_nestbc_r, 'r', 's' )
              ENDIF
-             IF ( humidity  .OR.  passive_scalar )  THEN
+             IF ( humidity )  THEN
                 CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo,     &
+                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
+                                          logc_u_r, logc_ratio_u_r,             &
+                                          nzt_topo_nestbc_r, 'r', 's' )
+             ENDIF
+             IF ( passive_scalar )  THEN
+                CALL pmci_interp_tril_lr( s, sc, ico, jco, kco, r1xo, r2xo,     &
                                           r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
                                           logc_u_r, logc_ratio_u_r,             &
@@ -3429,6 +3457,9 @@
                    CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'r', 's' )
                 ENDIF
-                IF ( humidity  .OR.  passive_scalar )  THEN
+                IF ( humidity )  THEN
                    CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'r', 's' )
+                ENDIF
+                IF ( passive_scalar )  THEN
+                   CALL pmci_extrap_ifoutflow_lr( s, nzb_s_inner, 'r', 's' )
                 ENDIF
              ENDIF
@@ -3461,6 +3492,12 @@
                                           nzt_topo_nestbc_s, 's', 's' )
              ENDIF
-             IF ( humidity  .OR.  passive_scalar )  THEN
+             IF ( humidity )  THEN
                 CALL pmci_interp_tril_sn( q, qc, ico, jco, kco, r1xo, r2xo,     &
+                                          r1yo,r2yo, r1zo, r2zo, nzb_s_inner,   &
+                                          logc_u_s, logc_ratio_u_s,             &
+                                          nzt_topo_nestbc_s, 's', 's' )
+             ENDIF
+             IF ( passive_scalar )  THEN
+                CALL pmci_interp_tril_sn( s, sc, ico, jco, kco, r1xo, r2xo,     &
                                           r1yo,r2yo, r1zo, r2zo, nzb_s_inner,   &
                                           logc_u_s, logc_ratio_u_s,             &
@@ -3476,6 +3513,9 @@
                    CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 's', 's' )
                 ENDIF
-                IF ( humidity  .OR.  passive_scalar )  THEN
+                IF ( humidity )  THEN
                    CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 's', 's' )
+                ENDIF
+                IF ( passive_scalar )  THEN
+                   CALL pmci_extrap_ifoutflow_sn( s, nzb_s_inner, 's', 's' )
                 ENDIF
              ENDIF
@@ -3508,6 +3548,12 @@
                                           nzt_topo_nestbc_n, 'n', 's' )
              ENDIF
-             IF ( humidity  .OR.  passive_scalar )  THEN
+             IF ( humidity )  THEN
                 CALL pmci_interp_tril_sn( q, qc, ico, jco, kco, r1xo, r2xo,     &
+                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
+                                          logc_u_n, logc_ratio_u_n,             &
+                                          nzt_topo_nestbc_n, 'n', 's' )
+             ENDIF
+             IF ( passive_scalar )  THEN
+                CALL pmci_interp_tril_sn( s, sc, ico, jco, kco, r1xo, r2xo,     &
                                           r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
                                           logc_u_n, logc_ratio_u_n,             &
@@ -3523,6 +3569,9 @@
                    CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 'n', 's' )
                 ENDIF
-                IF ( humidity  .OR.  passive_scalar )  THEN
+                IF ( humidity )  THEN
                    CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 'n', 's' )
+                ENDIF
+                IF ( passive_scalar )  THEN
+                   CALL pmci_extrap_ifoutflow_sn( s, nzb_s_inner, 'n', 's' )
                 ENDIF
 
@@ -3547,6 +3596,10 @@
                                    r2yo, r1zo, r2zo, 's' )
        ENDIF
-       IF ( humidity .OR. passive_scalar )  THEN
+       IF ( humidity )  THEN
           CALL pmci_interp_tril_t( q, qc, ico, jco, kco, r1xo, r2xo, r1yo,      &
+                                   r2yo, r1zo, r2zo, 's' )
+       ENDIF
+       IF ( passive_scalar )  THEN
+          CALL pmci_interp_tril_t( s, sc, ico, jco, kco, r1xo, r2xo, r1yo,      &
                                    r2yo, r1zo, r2zo, 's' )
        ENDIF
@@ -3560,6 +3613,9 @@
              CALL pmci_extrap_ifoutflow_t( pt, 's' )
           ENDIF
-          IF ( humidity  .OR.  passive_scalar )  THEN
+          IF ( humidity )  THEN
              CALL pmci_extrap_ifoutflow_t( q, 's' )
+          ENDIF
+          IF ( passive_scalar )  THEN
+             CALL pmci_extrap_ifoutflow_t( s, 's' )
           ENDIF
        ENDIF
@@ -3586,6 +3642,10 @@
                                   kfuo, ijfc_s, 's' )
       ENDIF
-      IF ( humidity  .OR.  passive_scalar )  THEN
+      IF ( humidity )  THEN
          CALL pmci_anterp_tophat( q, qc, kctu, iflo, ifuo, jflo, jfuo, kflo,    &
+                                  kfuo, ijfc_s, 's' )
+      ENDIF
+      IF ( passive_scalar )  THEN
+         CALL pmci_anterp_tophat( s, sc, kctu, iflo, ifuo, jflo, jfuo, kflo,    &
                                   kfuo, ijfc_s, 's' )
       ENDIF
