Index: palm/trunk/SOURCE/poismg_mod.f90
===================================================================
--- palm/trunk/SOURCE/poismg_mod.f90	(revision 2298)
+++ palm/trunk/SOURCE/poismg_mod.f90	(revision 2696)
@@ -1,5 +1,5 @@
 !> @file poismg.f90
 !------------------------------------------------------------------------------!
-! This file is part of PALM.
+! This file is part of the PALM model system.
 !
 ! PALM is free software: you can redistribute it and/or modify it under the
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! - Large-scale forcing implemented (MS)
+! 
+! 2298 2017-06-29 09:28:18Z raasch
 ! sendrecv_in_background related parts removed
 ! 
@@ -96,4 +99,9 @@
  MODULE poismg_mod
  
+    USE control_parameters,                                                    &
+        ONLY:  grid_level, force_bound_l, force_bound_n, force_bound_r,        &
+               force_bound_s, forcing, inflow_l, inflow_n, inflow_r, inflow_s, &
+               nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,         &
+               outflow_l, outflow_n, outflow_r, outflow_s
 
     USE cpulog,                                                                &
@@ -274,9 +282,5 @@
 
        USE control_parameters,                                                 &
-           ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, ibc_p_b, ibc_p_t, inflow_l,&
-                  inflow_n, inflow_r, inflow_s, nest_bound_l, nest_bound_n,    &
-                  nest_bound_r, nest_bound_s, outflow_l, outflow_n, outflow_r, &
-                  outflow_s
-
+           ONLY:  bc_lr_cyc, bc_ns_cyc, ibc_p_b, ibc_p_t
        USE grid_variables,                                                     &
            ONLY:  ddx2_mg, ddy2_mg
@@ -347,8 +351,10 @@
 
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l .OR. outflow_l .OR. nest_bound_l )  THEN
+          IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
+               force_bound_l )  THEN
              r(:,:,nxl_mg(l)-1) = r(:,:,nxl_mg(l))
           ENDIF
-          IF ( inflow_r .OR. outflow_r .OR. nest_bound_r )  THEN
+          IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
+               force_bound_r )  THEN
              r(:,:,nxr_mg(l)+1) = r(:,:,nxr_mg(l))
           ENDIF
@@ -356,8 +362,10 @@
 
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n .OR. outflow_n .OR. nest_bound_n )  THEN
+          IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
+               force_bound_n )  THEN
              r(:,nyn_mg(l)+1,:) = r(:,nyn_mg(l),:)
           ENDIF
-          IF ( inflow_s .OR. outflow_s .OR. nest_bound_s )  THEN
+          IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
+               force_bound_s )  THEN
              r(:,nys_mg(l)-1,:) = r(:,nys_mg(l),:)
           ENDIF
@@ -398,8 +406,5 @@
 
        USE control_parameters,                                                 &
-           ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, ibc_p_b, ibc_p_t, inflow_l,&
-                  inflow_n, inflow_r, inflow_s, nest_bound_l, nest_bound_n,    &
-                  nest_bound_r, nest_bound_s, outflow_l, outflow_n, outflow_r, &
-                  outflow_s
+           ONLY:  bc_lr_cyc, bc_ns_cyc, ibc_p_b, ibc_p_t
 
        USE indices,                                                            &
@@ -481,8 +486,10 @@
 !--    Horizontal boundary conditions
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l .OR. outflow_l .OR. nest_bound_l )  THEN
+          IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
+               force_bound_l )  THEN
              f_mg(:,:,nxl_mg(l)-1) = f_mg(:,:,nxl_mg(l))
           ENDIF
-          IF ( inflow_r .OR. outflow_r .OR. nest_bound_r )  THEN
+          IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
+               force_bound_r )  THEN
              f_mg(:,:,nxr_mg(l)+1) = f_mg(:,:,nxr_mg(l))
           ENDIF
@@ -490,8 +497,10 @@
 
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n .OR. outflow_n .OR. nest_bound_n )  THEN
+          IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
+               force_bound_n )  THEN
              f_mg(:,nyn_mg(l)+1,:) = f_mg(:,nyn_mg(l),:)
           ENDIF
-          IF ( inflow_s .OR. outflow_s .OR. nest_bound_s )  THEN
+          IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
+               force_bound_s )  THEN
              f_mg(:,nys_mg(l)-1,:) = f_mg(:,nys_mg(l),:)
           ENDIF
@@ -535,9 +544,5 @@
 
        USE control_parameters,                                                 &
-           ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, ibc_p_b, ibc_p_t, inflow_l,&
-                  inflow_n, inflow_r, inflow_s, nest_bound_l, nest_bound_n,    &
-                  nest_bound_r, nest_bound_s, outflow_l, outflow_n,            &
-                  outflow_r, outflow_s
-
+           ONLY:  bc_lr_cyc, bc_ns_cyc, ibc_p_b, ibc_p_t
        USE indices,                                                            &
            ONLY:  nxl_mg, nxr_mg, nys_mg, nyn_mg, nzb, nzt_mg
@@ -652,8 +657,10 @@
 
        IF ( .NOT. bc_lr_cyc )  THEN
-          IF ( inflow_l .OR. outflow_l .OR. nest_bound_l )  THEN
+          IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
+               force_bound_l )  THEN
              temp(:,:,nxl_mg(l)-1) = temp(:,:,nxl_mg(l))
           ENDIF
-          IF ( inflow_r .OR. outflow_r .OR. nest_bound_r )  THEN
+          IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
+               force_bound_r )  THEN
              temp(:,:,nxr_mg(l)+1) = temp(:,:,nxr_mg(l))
           ENDIF
@@ -661,8 +668,10 @@
 
        IF ( .NOT. bc_ns_cyc )  THEN
-          IF ( inflow_n .OR. outflow_n .OR. nest_bound_n )  THEN
+          IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
+               force_bound_n )  THEN
              temp(:,nyn_mg(l)+1,:) = temp(:,nyn_mg(l),:)
           ENDIF
-          IF ( inflow_s .OR. outflow_s .OR. nest_bound_s )  THEN
+          IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
+               force_bound_s )  THEN
              temp(:,nys_mg(l)-1,:) = temp(:,nys_mg(l),:)
           ENDIF
@@ -705,8 +714,5 @@
 
        USE control_parameters,                                                 &
-           ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, ibc_p_b, ibc_p_t, inflow_l,&
-                  inflow_n, inflow_r, inflow_s, nest_bound_l, nest_bound_n,    &
-                  nest_bound_r, nest_bound_s, ngsrb, outflow_l, outflow_n,     &
-                  outflow_r, outflow_s
+           ONLY:  bc_lr_cyc, bc_ns_cyc, ibc_p_b, ibc_p_t, ngsrb 
 
        USE grid_variables,                                                     &
@@ -961,8 +967,10 @@
 
              IF ( .NOT. bc_lr_cyc )  THEN
-                IF ( inflow_l .OR. outflow_l .OR. nest_bound_l )  THEN
+                IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.       &
+                     force_bound_l )  THEN
                    p_mg(:,:,nxl_mg(l)-1) = p_mg(:,:,nxl_mg(l))
                 ENDIF
-                IF ( inflow_r .OR. outflow_r .OR. nest_bound_r )  THEN
+                IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.       &
+                     force_bound_r )  THEN
                    p_mg(:,:,nxr_mg(l)+1) = p_mg(:,:,nxr_mg(l))
                 ENDIF
@@ -970,8 +978,10 @@
 
              IF ( .NOT. bc_ns_cyc )  THEN
-                IF ( inflow_n .OR. outflow_n .OR. nest_bound_n )  THEN
+                IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.       &
+                     force_bound_n )  THEN
                    p_mg(:,nyn_mg(l)+1,:) = p_mg(:,nyn_mg(l),:)
                 ENDIF
-                IF ( inflow_s .OR. outflow_s .OR. nest_bound_s )  THEN
+                IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.       &
+                     force_bound_s )  THEN
                    p_mg(:,nys_mg(l)-1,:) = p_mg(:,nys_mg(l),:)
                 ENDIF
@@ -1389,9 +1399,7 @@
        USE control_parameters,                                                 &
            ONLY:  bc_lr_dirrad, bc_lr_raddir, bc_ns_dirrad, bc_ns_raddir,      &
-                  gamma_mg, grid_level, grid_level_count, ibc_p_b, ibc_p_t,    &
-                  inflow_l, inflow_n, inflow_r, inflow_s, maximum_grid_level,  &
-                  mg_switch_to_pe0_level, mg_switch_to_pe0, nest_domain,       &
-                  nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,      &
-                  ngsrb, outflow_l, outflow_n, outflow_r, outflow_s
+                  gamma_mg, grid_level_count, ibc_p_b, ibc_p_t,                &
+                  maximum_grid_level,  mg_switch_to_pe0_level,                 &
+                  mg_switch_to_pe0, nest_domain, ngsrb 
 
        USE indices,                                                            &
@@ -1544,4 +1552,7 @@
                 nest_bound_l = .TRUE.
                 nest_bound_r = .TRUE.
+             ELSEIF ( forcing )  THEN
+                force_bound_l = .TRUE.
+                force_bound_r = .TRUE.
              ENDIF
 
@@ -1559,4 +1570,7 @@
                 nest_bound_s = .TRUE.
                 nest_bound_n = .TRUE.
+             ELSEIF ( forcing )  THEN
+                force_bound_s = .TRUE.
+                force_bound_n = .TRUE.
              ENDIF
 
@@ -1626,5 +1640,5 @@
              outflow_n = .FALSE.;  outflow_s = .FALSE.
 !
-!--          In case of nesting, restore lateral boundary conditions
+!--          In case of nesting or forcing, restore lateral boundary conditions
              IF ( nest_domain )  THEN
                 nest_bound_l = .FALSE.
@@ -1632,4 +1646,10 @@
                 nest_bound_s = .FALSE.
                 nest_bound_n = .FALSE.      
+             ENDIF
+             IF ( forcing )  THEN
+                force_bound_l = .FALSE.
+                force_bound_r = .FALSE.
+                force_bound_s = .FALSE.
+                force_bound_n = .FALSE.      
              ENDIF
 
@@ -1641,4 +1661,6 @@
                 ELSEIF ( nest_domain )  THEN
                    nest_bound_l = .TRUE.
+                ELSEIF ( forcing )  THEN
+                   force_bound_l = .TRUE.
                 ENDIF
              ENDIF
@@ -1651,4 +1673,6 @@
                 ELSEIF ( nest_domain )  THEN
                    nest_bound_r = .TRUE.
+                ELSEIF ( forcing )  THEN
+                   force_bound_r = .TRUE.
                 ENDIF
              ENDIF
@@ -1661,4 +1685,6 @@
                 ELSEIF ( nest_domain )  THEN
                    nest_bound_s = .TRUE.
+                ELSEIF ( forcing )  THEN
+                   force_bound_s = .TRUE.
                 ENDIF
              ENDIF
@@ -1671,4 +1697,6 @@
                 ELSEIF ( nest_domain )  THEN
                    nest_bound_n = .TRUE.
+                ELSEIF ( forcing )  THEN
+                   force_bound_n = .TRUE.
                 ENDIF
              ENDIF
@@ -1821,7 +1849,6 @@
        USE control_parameters,                                                 &
            ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, ibc_p_b, ibc_p_t,          &
-                  inflow_l, inflow_n, inflow_r, inflow_s, maximum_grid_level,  &
-                  mg_switch_to_pe0_level, outflow_l, outflow_n, outflow_r,     &
-                  outflow_s, synchronous_exchange
+                  maximum_grid_level,                                          &
+                  mg_switch_to_pe0_level, synchronous_exchange
 
        USE indices,                                                            &
