Index: palm/trunk/SOURCE/boundary_conds.f90
===================================================================
--- palm/trunk/SOURCE/boundary_conds.f90	(revision 4271)
+++ palm/trunk/SOURCE/boundary_conds.f90	(revision 4272)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Further modularization of boundary conditions: moved boundary conditions to
+! respective modules
+! 
+! 4268 2019-10-17 11:29:38Z schwenkel
 ! Removing bulk cloud variables to respective module
 ! 
@@ -68,13 +72,10 @@
         ONLY:  c_u, c_u_m, c_u_m_l, c_v, c_v_m, c_v_m_l, c_w, c_w_m, c_w_m_l,  &
                dzu, pt, pt_init, pt_p, q,                                      &
-               q_p, s, s_p, sa, sa_p, u, u_init, u_m_l, u_m_n,                 &
+               q_p, s, s_p, u, u_init, u_m_l, u_m_n,                 &
                u_m_r, u_m_s, u_p, v, v_init, v_m_l, v_m_n, v_m_r, v_m_s, v_p,  &
                w, w_p, w_m_l, w_m_n, w_m_r, w_m_s
 
-    USE chemistry_model_mod,                                                   &
-        ONLY:  chem_boundary_conds
-
     USE control_parameters,                                                    &
-        ONLY:  air_chemistry, bc_dirichlet_l,                                  &
+        ONLY:  bc_dirichlet_l,                                  &
                bc_dirichlet_s, bc_radiation_l, bc_radiation_n, bc_radiation_r, &
                bc_radiation_s, bc_pt_t_val, bc_q_t_val, bc_s_t_val,            &
@@ -82,6 +83,6 @@
                humidity, ibc_pt_b, ibc_pt_t, ibc_q_b, ibc_q_t, ibc_s_b,        &
                ibc_s_t, ibc_uv_b, ibc_uv_t, intermediate_timestep_count,       &
-               nesting_offline, neutral, nudging, ocean_mode, passive_scalar,  &
-               tsc, salsa, use_cmax
+               nesting_offline, neutral, nudging, passive_scalar,  &
+               tsc, use_cmax
 
     USE grid_variables,                                                        &
@@ -92,7 +93,4 @@
 
     USE kinds
-
-    USE ocean_mod,                                                             &
-        ONLY:  ibc_sa_t
 
     USE pegrid
@@ -101,7 +99,4 @@
         ONLY : nesting_mode
  
-    USE salsa_mod,                                                             &
-        ONLY:  salsa_boundary_conds
-
     USE surface_mod,                                                           &
         ONLY :  bc_h
@@ -188,5 +183,5 @@
              !$ACC PRESENT(bc_h, pt_p)
              DO  m = 1, bc_h(l)%ns
-                i = bc_h(l)%i(m)            
+                i = bc_h(l)%i(m)
                 j = bc_h(l)%j(m)
                 k = bc_h(l)%k(m)
@@ -215,29 +210,4 @@
     ENDIF
 !
-!-- Boundary conditions for salinity
-    IF ( ocean_mode )  THEN
-!
-!--    Bottom boundary: Neumann condition because salinity flux is always
-!--    given.
-       DO  l = 0, 1
-          !$OMP PARALLEL DO PRIVATE( i, j, k )
-          DO  m = 1, bc_h(l)%ns
-             i = bc_h(l)%i(m)
-             j = bc_h(l)%j(m)
-             k = bc_h(l)%k(m)
-             sa_p(k+bc_h(l)%koff,j,i) = sa_p(k,j,i)
-          ENDDO
-       ENDDO
-!
-!--    Top boundary: Dirichlet or Neumann
-       IF ( ibc_sa_t == 0 )  THEN
-           sa_p(nzt+1,:,:) = sa(nzt+1,:,:)
-       ELSEIF ( ibc_sa_t == 1 )  THEN
-           sa_p(nzt+1,:,:) = sa_p(nzt,:,:)
-       ENDIF
-
-    ENDIF
-
-!
 !-- Boundary conditions for total water content,
 !-- bottom and top boundary (see also temperature)
@@ -327,7 +297,4 @@
 !-- Set boundary conditions for subgrid TKE and dissipation (RANS mode)
     CALL tcm_boundary_conds
-!
-!-- Top/bottom boundary conditions for chemical species
-    IF ( air_chemistry )  CALL chem_boundary_conds( 'set_bc_bottomtop' )
 !
 !-- In case of inflow or nest boundary at the south boundary the boundary for v
@@ -386,8 +353,4 @@
        IF ( passive_scalar )  s_p(:,:,nxr+1) = s_p(:,:,nxr)
     ENDIF
-
-!
-!-- Lateral boundary conditions for chemical species
-    IF ( air_chemistry )  CALL chem_boundary_conds( 'set_bc_lateral' )    
 
 !
@@ -883,14 +846,14 @@
           ENDDO
 
-#if defined( __parallel )   
+#if defined( __parallel )
           IF ( collective_wait )  CALL MPI_BARRIER( comm1dy, ierr )
           CALL MPI_ALLREDUCE( c_u_m_l(nzb+1), c_u_m(nzb+1), nzt-nzb, MPI_REAL, &
-                              MPI_SUM, comm1dy, ierr )   
+                              MPI_SUM, comm1dy, ierr )
           IF ( collective_wait )  CALL MPI_BARRIER( comm1dy, ierr )
           CALL MPI_ALLREDUCE( c_v_m_l(nzb+1), c_v_m(nzb+1), nzt-nzb, MPI_REAL, &
-                              MPI_SUM, comm1dy, ierr )  
+                              MPI_SUM, comm1dy, ierr )
           IF ( collective_wait )  CALL MPI_BARRIER( comm1dy, ierr )
           CALL MPI_ALLREDUCE( c_w_m_l(nzb+1), c_w_m(nzb+1), nzt-nzb, MPI_REAL, &
-                              MPI_SUM, comm1dy, ierr )  
+                              MPI_SUM, comm1dy, ierr )
 #else
           c_u_m = c_u_m_l
@@ -952,7 +915,3 @@
     ENDIF
 
-    IF ( salsa )  THEN
-       CALL salsa_boundary_conds
-    ENDIF
-
  END SUBROUTINE boundary_conds
Index: palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4271)
+++ palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4272)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! Further modularization of boundary conditions: moved boundary conditions to
+! respective modules
+!
+! 4268 2019-10-17 11:29:38Z schwenkel
 ! Moving module specific boundary conditions from time_integration to module
 ! 
@@ -819,17 +823,23 @@
 
 !
-!--       Boundary conditions for prognostic quantitites of other modules:
-!--       Here, only decycling is carried out
-
-          DO  lsp = 1, nvar
-             lsp_usr = 1
-             DO WHILE ( TRIM( cs_name( lsp_usr ) ) /= 'novalue' )
-                IF ( TRIM( chem_species(lsp)%name ) == TRIM( cs_name(lsp_usr) ) )  THEN
-                   CALL chem_boundary_conds( chem_species(lsp)%conc_p,                          &
-                                             chem_species(lsp)%conc_pr_init )
-                ENDIF
-                lsp_usr = lsp_usr + 1
-             ENDDO
-          ENDDO
+!-- Top/bottom boundary conditions for chemical species
+    CALL chem_boundary_conds( 'set_bc_bottomtop' )
+!
+!-- Lateral boundary conditions for chemical species
+    CALL chem_boundary_conds( 'set_bc_lateral' )
+
+!
+!--  Boundary conditions for prognostic quantitites of other modules:
+!--  Here, only decycling is carried out
+     DO  lsp = 1, nvar
+        lsp_usr = 1
+        DO WHILE ( TRIM( cs_name( lsp_usr ) ) /= 'novalue' )
+           IF ( TRIM( chem_species(lsp)%name ) == TRIM( cs_name(lsp_usr) ) )  THEN
+              CALL chem_boundary_conds( chem_species(lsp)%conc_p,                          &
+                                        chem_species(lsp)%conc_pr_init )
+           ENDIF
+           lsp_usr = lsp_usr + 1
+        ENDDO
+     ENDDO
 
 
Index: palm/trunk/SOURCE/module_interface.f90
===================================================================
--- palm/trunk/SOURCE/module_interface.f90	(revision 4271)
+++ palm/trunk/SOURCE/module_interface.f90	(revision 4272)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Further modularization of boundary conditions: moved boundary conditions to
+! respective modules
+!
+! 4268 2019-10-17 11:29:38Z schwenkel
 ! Introduction of module_interface_boundary_conditions
 ! 
@@ -375,4 +379,5 @@
                ocean_actions,                                                  &
                ocean_prognostic_equations,                                     &
+               ocean_boundary_conditions,                                      &
                ocean_swap_timelevel,                                           &
                ocean_3d_data_averaging,                                        &
@@ -1296,4 +1301,5 @@
     IF ( bulk_cloud_model    )  CALL bcm_boundary_conditions
     IF ( air_chemistry       )  CALL chem_boundary_conditions
+    IF ( ocean_mode          )  CALL ocean_boundary_conditions
     IF ( salsa               )  CALL salsa_boundary_conditions
 
Index: palm/trunk/SOURCE/ocean_mod.f90
===================================================================
--- palm/trunk/SOURCE/ocean_mod.f90	(revision 4271)
+++ palm/trunk/SOURCE/ocean_mod.f90	(revision 4272)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Further modularization of boundary conditions: moved boundary conditions to
+! respective modules
+!
+! 4196 2019-08-29 11:02:06Z gronemeier
 ! Consider rotation of model domain for calculating the Stokes drift
 ! 
@@ -81,4 +85,10 @@
         ONLY:  sums_wssas_ws_l
 
+    USE indices,                                                               &
+        ONLY:  advc_flags_s, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_0
+
+    USE surface_mod,                                                           &
+        ONLY:  bc_h, surf_def_v, surf_def_h, surf_lsm_h, surf_lsm_v,           &
+               surf_usm_h, surf_usm_v
 
     IMPLICIT NONE
@@ -192,4 +202,8 @@
     END INTERFACE ocean_prognostic_equations
 
+    INTERFACE ocean_boundary_conditions
+       MODULE PROCEDURE ocean_boundary_conditions
+    END INTERFACE ocean_boundary_conditions
+
     INTERFACE ocean_swap_timelevel
        MODULE PROCEDURE ocean_swap_timelevel
@@ -236,5 +250,5 @@
            ocean_swap_timelevel, ocean_rrd_global, ocean_rrd_local,            &
            ocean_wrd_global, ocean_wrd_local, ocean_3d_data_averaging,         &
-           stokes_drift_terms, wave_breaking_term
+           ocean_boundary_conditions, stokes_drift_terms, wave_breaking_term
 
 
@@ -257,7 +271,4 @@
     USE indices,                                                               &
         ONLY:  nxl, nxr, nyn, nys, nzb, nzt
-
-    USE surface_mod,                                                           &
-        ONLY :  bc_h
 
     IMPLICIT NONE
@@ -370,7 +381,4 @@
     USE indices,                                                               &
         ONLY:  nzb, nzt
-
-    USE surface_mod,                                                           &
-       ONLY :  bc_h
 
     IMPLICIT NONE
@@ -1585,11 +1593,4 @@
     USE diffusion_s_mod,                                                       &
         ONLY:  diffusion_s
-
-    USE indices,                                                               &
-        ONLY:  advc_flags_s, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_0
-
-    USE surface_mod,                                                           &
-        ONLY:  surf_def_v, surf_def_h, surf_lsm_h, surf_lsm_v, surf_usm_h,     &
-               surf_usm_v
 
     IMPLICIT NONE
@@ -1757,11 +1758,4 @@
     USE diffusion_s_mod,                                                       &
         ONLY:  diffusion_s
-
-    USE indices,                                                               &
-        ONLY:  advc_flags_s, nzb, nzt, wall_flags_0
-
-    USE surface_mod,                                                           &
-        ONLY:  surf_def_v, surf_def_h, surf_lsm_h, surf_lsm_v, surf_usm_h,     &
-               surf_usm_v
 
     IMPLICIT NONE
@@ -1862,4 +1856,41 @@
  END SUBROUTINE ocean_prognostic_equations_ij
 
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Boundary conditions for ocean model
+!------------------------------------------------------------------------------!
+ SUBROUTINE ocean_boundary_conditions
+
+    IMPLICIT NONE
+
+    INTEGER(iwp) ::  i                            !< grid index x direction.
+    INTEGER(iwp) ::  j                            !< grid index y direction.
+    INTEGER(iwp) ::  k                            !< grid index z direction.
+    INTEGER(iwp) ::  l                            !< running index boundary type, for up- and downward-facing walls.
+    INTEGER(iwp) ::  m                            !< running index surface elements.
+
+!
+!--    Boundary conditions for salinity
+!--    Bottom boundary: Neumann condition because salinity flux is always
+!--    given.
+       DO  l = 0, 1
+          !$OMP PARALLEL DO PRIVATE( i, j, k )
+          DO  m = 1, bc_h(l)%ns
+             i = bc_h(l)%i(m)
+             j = bc_h(l)%j(m)
+             k = bc_h(l)%k(m)
+             sa_p(k+bc_h(l)%koff,j,i) = sa_p(k,j,i)
+          ENDDO
+       ENDDO
+!
+!--    Top boundary: Dirichlet or Neumann
+       IF ( ibc_sa_t == 0 )  THEN
+           sa_p(nzt+1,:,:) = sa(nzt+1,:,:)
+       ELSEIF ( ibc_sa_t == 1 )  THEN
+           sa_p(nzt+1,:,:) = sa_p(nzt,:,:)
+       ENDIF
+
+ END SUBROUTINE ocean_boundary_conditions
 
 !------------------------------------------------------------------------------!
Index: palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- palm/trunk/SOURCE/salsa_mod.f90	(revision 4271)
+++ palm/trunk/SOURCE/salsa_mod.f90	(revision 4272)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Further modularization of boundary conditions: moved boundary conditions to
+! respective modules
+!
+! 4270 2019-10-23 10:46:20Z monakurppa
 ! - Implement offline nesting for salsa
 ! - Alphabetic ordering for module interfaces
@@ -8090,4 +8094,8 @@
     INTEGER(iwp) ::  ig              !< index for salsa gases
 
+
+!
+!-- moved from boundary_conds
+    CALL salsa_boundary_conds
 !
 !-- Boundary conditions for prognostic quantitites of other modules:
