Index: /palm/trunk/SOURCE/ocean_mod.f90
===================================================================
--- /palm/trunk/SOURCE/ocean_mod.f90	(revision 3302)
+++ /palm/trunk/SOURCE/ocean_mod.f90	(revision 3303)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! salinity allowed to be switched off
+! 
+! 3302 2018-10-03 02:39:40Z raasch
 ! Craik Leibovich force (Stokes drift) + wave breaking effect added
 ! 
@@ -70,4 +73,5 @@
     INTEGER(iwp) ::  sa_vertical_gradient_level_ind(10) = -9999  !< grid index values of sa_vertical_gradient_level(s)
 
+    LOGICAL ::  salinity = .TRUE.             !< switch for using salinity
     LOGICAL ::  stokes_force = .FALSE.        !< switch to switch on the Stokes force
     LOGICAL ::  wave_breaking = .FALSE.       !< switch to switch on wave breaking effects
@@ -500,6 +504,6 @@
 
 
-    NAMELIST /ocean_parameters/  bc_sa_t, bottom_salinityflux, sa_surface,     &
-             sa_vertical_gradient, sa_vertical_gradient_level,                 &
+    NAMELIST /ocean_parameters/  bc_sa_t, bottom_salinityflux, salinity,       &
+             sa_surface, sa_vertical_gradient, sa_vertical_gradient_level,     &
              stokes_waveheight, stokes_wavelength, top_salinityflux,           &
              wall_salinityflux, wave_breaking
@@ -579,4 +583,16 @@
 
     IF ( top_salinityflux == 9999999.9_wp )  constant_top_salinityflux = .FALSE.
+
+    IF ( .NOT. salinity )  THEN
+       IF ( ( bottom_salinityflux /= 0.0_wp  .AND.                             &
+              bottom_salinityflux /= 9999999.9_wp )  .OR.                      &
+            ( top_salinityflux /= 0.0_wp     .AND.                             &
+              top_salinityflux /= 9999999.9_wp ) )                             &
+       THEN
+          message_string = 'salinityflux must not be set for ocean run ' //    &
+                           'without salinity'
+          CALL message( 'check_parameters', 'PA0509', 1, 2, 0, 6, 0 )
+       ENDIF
+    ENDIF
 
     IF ( ibc_sa_t == 1  .AND.  top_salinityflux == 9999999.9_wp )  THEN
@@ -904,5 +920,6 @@
 
     USE indices,                                                               &
-        ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
+        ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,            &
+              wall_flags_0
 
     IMPLICIT NONE
@@ -968,13 +985,14 @@
 
     IF ( found .AND. .NOT. resorted )  THEN
-!       DO  i = nxl, nxr
-!          DO  j = nys, nyn
-!             DO  k = nzb_do, nzt_do
-!                local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
-!                                         REAL( fill_value, KIND = wp ),        &
-!                                         BTEST( wall_flags_0(k,j,i), flag_nr ) )
-!             ENDDO
-!          ENDDO
-!       ENDDO
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             DO  k = nzb_do, nzt_do
+                local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
+                                         REAL( fill_value, KIND = wp ),        &
+                                         BTEST( wall_flags_0(k,j,i), flag_nr ) )
+             ENDDO
+          ENDDO
+       ENDDO
+       resorted = .TRUE.
     ENDIF
  
@@ -1062,8 +1080,7 @@
           DO  j = nys, nyn
              DO  k = nzb_do, nzt_do
-                local_pf(i,j,k) = MERGE(                                       &
-                                   to_be_resorted(k,j,i),                      &
-                                   REAL( fill_value, KIND = wp ),              &
-                                   BTEST( wall_flags_0(k,j,i), flag_nr ) )
+                local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
+                                         REAL( fill_value, KIND = wp ),        &
+                                         BTEST( wall_flags_0(k,j,i), flag_nr ) )
              ENDDO
           ENDDO
@@ -1094,4 +1111,5 @@
        WRITE( io, 3 )  alpha_wave_breaking, timescale_wave_breaking
     ENDIF
+    IF ( .NOT. salinity )  WRITE( io, 4 )
 
 1   FORMAT (//' Ocean settings:'/                                              &
@@ -1103,4 +1121,5 @@
             '        alpha:    ',F4.1/                                         &
             '        timescale:',F5.1,' s')
+4   FORMAT ('    --> prognostic salinity equation is switched off' )
 
  END SUBROUTINE ocean_header
@@ -1123,15 +1142,18 @@
 
 #if defined( __nopointer )
-    ALLOCATE( prho(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                          &
-              rho_ocean(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
-              sa(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                            &
-              sa_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                          &
+    ALLOCATE( prho(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
+              rho_ocean(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                        &
+              sa(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                               &
+              sa_p(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
               tsa_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
 #else
-    ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                        &
-              rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                         &
-              sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                          &
-              sa_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                          &
+    ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
+              rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                            &
+              sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
               sa_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+
+    IF (  salinity )  THEN
+       ALLOCATE( sa_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+    ENDIF
 
     prho => prho_1
@@ -1143,5 +1165,9 @@
 !
 !-- Initial assignment of pointers
-    sa  => sa_1;   sa_p  => sa_2;   tsa_m  => sa_3
+    IF ( salinity )  THEN
+       sa => sa_1;  sa_p => sa_2;  tsa_m => sa_3
+    ELSE
+       sa => sa_1;  sa_p => sa_1;  tsa_m => sa_3
+    ENDIF
 #endif
 
@@ -1213,8 +1239,10 @@
 !--    possible Neumann boundary condition. This is not realized for the ocean
 !--    mode, therefore a dummy argument is used.
-       CALL init_vertical_profiles( sa_vertical_gradient_level_ind,          &
-                                    sa_vertical_gradient_level,              &
-                                    sa_vertical_gradient, sa_init,           &
-                                    sa_surface, dum )
+       IF ( salinity )  THEN
+          CALL init_vertical_profiles( sa_vertical_gradient_level_ind,          &
+                                       sa_vertical_gradient_level,              &
+                                       sa_vertical_gradient, sa_init,           &
+                                       sa_surface, dum )
+       ENDIF
     ENDIF
 
@@ -1467,4 +1495,6 @@
 !-- Compute prognostic equations for the ocean mode
 !-- First, start with salinity
+    IF ( .NOT. salinity )  RETURN
+
     CALL cpu_log( log_point(37), 'sa-equation', 'start' )
 
@@ -1615,4 +1645,6 @@
 !-- Compute prognostic equations for the ocean mode
 !-- First, start with tendency-terms for salinity
+    IF ( .NOT. salinity )  RETURN
+
     tend(:,j,i) = 0.0_wp
     IF ( timestep_scheme(1:5) == 'runge' ) &
@@ -1699,8 +1731,12 @@
 
        CASE ( 0 )
-          sa => sa_1;    sa_p => sa_2
+          IF ( salinity )  THEN
+             sa => sa_1;    sa_p => sa_2
+          ENDIF
 
        CASE ( 1 )
-          sa => sa_2;    sa_p => sa_1
+          IF ( salinity )  THEN
+             sa => sa_2;    sa_p => sa_1
+          ENDIF
 
     END SELECT
@@ -1737,4 +1773,7 @@
        CASE ( 'bottom_salinityflux' )
           READ ( 13 )  bottom_salinityflux
+
+       CASE ( 'salinity' )
+          READ ( 13 )  salinity
 
        CASE ( 'sa_init' )
@@ -1866,4 +1905,7 @@
     CALL wrd_write_string( 'bottom_salinityflux' )
     WRITE ( 14 )  bottom_salinityflux
+
+    CALL wrd_write_string( 'salinity' )
+    WRITE ( 14 )  salinity
 
     CALL wrd_write_string( 'sa_init' )
Index: /palm/trunk/SOURCE/swap_timelevel.f90
===================================================================
--- /palm/trunk/SOURCE/swap_timelevel.f90	(revision 3302)
+++ /palm/trunk/SOURCE/swap_timelevel.f90	(revision 3303)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix for swapping in case of ocean mode
+! 
+! 3294 2018-10-01 02:37:10Z raasch
 ! changes concerning modularization of ocean option
 ! 
@@ -219,5 +222,5 @@
     IF ( gust_module_enabled )                CALL gust_swap_timelevel( 0 )
     IF ( land_surface )                       CALL lsm_swap_timelevel( 0 )
-    IF ( ocean_mode )                         CALL ocean_swap_timelevl( 0 )
+    IF ( ocean_mode )                         CALL ocean_swap_timelevel( 0 )
     CALL tcm_swap_timelevel( 0 )
     IF ( urban_surface )                      CALL usm_swap_timelevel( 0 )
@@ -237,7 +240,4 @@
              pt => pt_1;  pt_p => pt_2
           ENDIF
-          IF ( ocean_mode )  THEN
-             sa => sa_1;  sa_p => sa_2
-          ENDIF
           IF ( humidity )  THEN
              q => q_1;    q_p => q_2
@@ -257,7 +257,4 @@
              pt => pt_2;  pt_p => pt_1
           ENDIF
-          IF ( ocean_mode )  THEN
-             sa => sa_2;  sa_p => sa_1
-          ENDIF
           IF ( humidity )  THEN
              q => q_2;    q_p => q_1
@@ -271,22 +268,26 @@
     END SELECT
 
+    IF ( humidity  .AND.  bulk_cloud_model )  THEN
+       CALL bcm_swap_timelevel( MOD( timestep_count, 2) )
+    ENDIF
+
     IF ( air_chemistry )  CALL chem_swap_timelevel( MOD( timestep_count, 2) )
 
-    CALL tcm_swap_timelevel ( MOD( timestep_count, 2) )
-
-    IF ( humidity  .AND.  bulk_cloud_model )  THEN
-       CALL bcm_swap_timelevel ( MOD( timestep_count, 2) )
+    IF ( gust_module_enabled )  THEN
+       CALL gust_swap_timelevel( MOD( timestep_count, 2) )
     ENDIF
 
     IF ( land_surface )  THEN
-       CALL lsm_swap_timelevel ( MOD( timestep_count, 2) )
-    ENDIF
+       CALL lsm_swap_timelevel( MOD( timestep_count, 2) )
+    ENDIF
+
+    IF ( ocean_mode )  THEN
+       CALL ocean_swap_timelevel( MOD( timestep_count, 2 ) )
+    ENDIF
+
+    CALL tcm_swap_timelevel( MOD( timestep_count, 2) )
 
     IF ( urban_surface )  THEN
-       CALL usm_swap_timelevel ( MOD( timestep_count, 2) )
-    ENDIF
-
-    IF ( gust_module_enabled )  THEN
-       CALL gust_swap_timelevel ( MOD( timestep_count, 2) )
+       CALL usm_swap_timelevel( MOD( timestep_count, 2) )
     ENDIF
 
