Index: palm/trunk/SOURCE/ocean_mod.f90
===================================================================
--- palm/trunk/SOURCE/ocean_mod.f90	(revision 3567)
+++ palm/trunk/SOURCE/ocean_mod.f90	(revision 3568)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! bugifx: calculate equation of state for seawater even if salinity is switched
+!         off
+! 
+! 3421 2018-10-24 18:39:32Z gronemeier
 ! Renamed output variables
 ! 
@@ -1541,94 +1545,96 @@
 !-- Compute prognostic equations for the ocean mode
 !-- First, start with salinity
-    IF ( .NOT. salinity )  RETURN
-
-    CALL cpu_log( log_point(37), 'sa-equation', 'start' )
-
-!
-!-- sa-tendency terms with communication
-    sbt = tsc(2)
-    IF ( scalar_advec == 'bc-scheme' )  THEN
-
-       IF ( timestep_scheme(1:5) /= 'runge' )  THEN
-!
-!--       Bott-Chlond scheme always uses Euler time step. Thus:
-          sbt = 1.0_wp
+    IF ( salinity )  THEN
+
+       CALL cpu_log( log_point(37), 'sa-equation', 'start' )
+
+!
+!--    sa-tendency terms with communication
+       sbt = tsc(2)
+       IF ( scalar_advec == 'bc-scheme' )  THEN
+
+          IF ( timestep_scheme(1:5) /= 'runge' )  THEN
+!
+!--          Bott-Chlond scheme always uses Euler time step. Thus:
+             sbt = 1.0_wp
+          ENDIF
+          tend = 0.0_wp
+          CALL advec_s_bc( sa, 'sa' )
+
        ENDIF
-       tend = 0.0_wp
-       CALL advec_s_bc( sa, 'sa' )
-
-    ENDIF
-
-!
-!-- sa-tendency terms with no communication
-    IF ( scalar_advec /= 'bc-scheme' )  THEN
-       tend = 0.0_wp
-       IF ( timestep_scheme(1:5) == 'runge' )  THEN
-          IF ( ws_scheme_sca )  THEN
-             CALL advec_s_ws( sa, 'sa' )
+
+!
+!--    sa-tendency terms with no communication
+       IF ( scalar_advec /= 'bc-scheme' )  THEN
+          tend = 0.0_wp
+          IF ( timestep_scheme(1:5) == 'runge' )  THEN
+             IF ( ws_scheme_sca )  THEN
+                CALL advec_s_ws( sa, 'sa' )
+             ELSE
+                CALL advec_s_pw( sa )
+             ENDIF
           ELSE
-             CALL advec_s_pw( sa )
+             CALL advec_s_up( sa )
           ENDIF
-       ELSE
-          CALL advec_s_up( sa )
        ENDIF
-    ENDIF
-
-    CALL diffusion_s( sa,                                                      &
-                      surf_def_h(0)%sasws, surf_def_h(1)%sasws,                &
-                      surf_def_h(2)%sasws,                                     &
-                      surf_lsm_h%sasws,    surf_usm_h%sasws,                   &
-                      surf_def_v(0)%sasws, surf_def_v(1)%sasws,                &
-                      surf_def_v(2)%sasws, surf_def_v(3)%sasws,                &
-                      surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws,                &
-                      surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws,                &
-                      surf_usm_v(0)%sasws, surf_usm_v(1)%sasws,                &
-                      surf_usm_v(2)%sasws, surf_usm_v(3)%sasws )
-
-    CALL user_actions( 'sa-tendency' )
-
-!
-!-- Prognostic equation for salinity
-    DO  i = nxl, nxr
-       DO  j = nys, nyn
-          DO  k = nzb+1, nzt
-             sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) +         &
-                                                   tsc(3) * tsa_m(k,j,i) )     &
-                                               - tsc(5) * rdf_sc(k) *          &
-                                                 ( sa(k,j,i) - sa_init(k) )    &
-                                       )                                       &
-                                         * MERGE( 1.0_wp, 0.0_wp,              &
+
+       CALL diffusion_s( sa,                                                   &
+                         surf_def_h(0)%sasws, surf_def_h(1)%sasws,             &
+                         surf_def_h(2)%sasws,                                  &
+                         surf_lsm_h%sasws,    surf_usm_h%sasws,                &
+                         surf_def_v(0)%sasws, surf_def_v(1)%sasws,             &
+                         surf_def_v(2)%sasws, surf_def_v(3)%sasws,             &
+                         surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws,             &
+                         surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws,             &
+                         surf_usm_v(0)%sasws, surf_usm_v(1)%sasws,             &
+                         surf_usm_v(2)%sasws, surf_usm_v(3)%sasws )
+
+       CALL user_actions( 'sa-tendency' )
+
+!
+!--    Prognostic equation for salinity
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             DO  k = nzb+1, nzt
+                sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) +      &
+                                                      tsc(3) * tsa_m(k,j,i) )  &
+                                                  - tsc(5) * rdf_sc(k) *       &
+                                                    ( sa(k,j,i) - sa_init(k) ) &
+                                          )                                    &
+                                            * MERGE( 1.0_wp, 0.0_wp,           &
                                                BTEST( wall_flags_0(k,j,i), 0 ) &
-                                                )
-             IF ( sa_p(k,j,i) < 0.0_wp )  sa_p(k,j,i) = 0.1_wp * sa(k,j,i)
+                                                   )
+                IF ( sa_p(k,j,i) < 0.0_wp )  sa_p(k,j,i) = 0.1_wp * sa(k,j,i)
+             ENDDO
           ENDDO
        ENDDO
-    ENDDO
-
-!
-!-- Calculate tendencies for the next Runge-Kutta step
-    IF ( timestep_scheme(1:5) == 'runge' )  THEN
-       IF ( intermediate_timestep_count == 1 )  THEN
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb+1, nzt
-                   tsa_m(k,j,i) = tend(k,j,i)
+
+!
+!--    Calculate tendencies for the next Runge-Kutta step
+       IF ( timestep_scheme(1:5) == 'runge' )  THEN
+          IF ( intermediate_timestep_count == 1 )  THEN
+             DO  i = nxl, nxr
+                DO  j = nys, nyn
+                   DO  k = nzb+1, nzt
+                      tsa_m(k,j,i) = tend(k,j,i)
+                   ENDDO
                 ENDDO
              ENDDO
-          ENDDO
-       ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max )&
-       THEN
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb+1, nzt
-                   tsa_m(k,j,i) =   -9.5625_wp * tend(k,j,i) +              &
-                                     5.3125_wp * tsa_m(k,j,i)
+          ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) &
+          THEN
+             DO  i = nxl, nxr
+                DO  j = nys, nyn
+                   DO  k = nzb+1, nzt
+                      tsa_m(k,j,i) =   -9.5625_wp * tend(k,j,i) +              &
+                                        5.3125_wp * tsa_m(k,j,i)
+                   ENDDO
                 ENDDO
              ENDDO
-         ENDDO
+          ENDIF
        ENDIF
-    ENDIF
-
-    CALL cpu_log( log_point(37), 'sa-equation', 'stop' )
+
+       CALL cpu_log( log_point(37), 'sa-equation', 'stop' )
+
+    ENDIF
 
 !
@@ -1704,61 +1710,63 @@
 !-- 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' ) &
-    THEN
-       IF ( ws_scheme_sca )  THEN
-          CALL advec_s_ws( i, j, sa, 'sa', flux_s_sa,  diss_s_sa, flux_l_sa,   &
-                           diss_l_sa, i_omp_start, tn  )
+    IF ( salinity )  THEN
+
+       tend(:,j,i) = 0.0_wp
+       IF ( timestep_scheme(1:5) == 'runge' ) &
+       THEN
+          IF ( ws_scheme_sca )  THEN
+             CALL advec_s_ws( i, j, sa, 'sa', flux_s_sa,  diss_s_sa, flux_l_sa,&
+                              diss_l_sa, i_omp_start, tn  )
+          ELSE
+             CALL advec_s_pw( i, j, sa )
+          ENDIF
        ELSE
-          CALL advec_s_pw( i, j, sa )
+          CALL advec_s_up( i, j, sa )
        ENDIF
-    ELSE
-       CALL advec_s_up( i, j, sa )
-    ENDIF
-    CALL diffusion_s( i, j, sa,                                       &
-                      surf_def_h(0)%sasws, surf_def_h(1)%sasws,       &
-                      surf_def_h(2)%sasws,                            &
-                      surf_lsm_h%sasws,    surf_usm_h%sasws,          &
-                      surf_def_v(0)%sasws, surf_def_v(1)%sasws,       &
-                      surf_def_v(2)%sasws, surf_def_v(3)%sasws,       &
-                      surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws,       &
-                      surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws,       &
-                      surf_usm_v(0)%sasws, surf_usm_v(1)%sasws,       &
-                      surf_usm_v(2)%sasws, surf_usm_v(3)%sasws )
-
-    CALL user_actions( i, j, 'sa-tendency' )
-
-!
-!-- Prognostic equation for salinity
-    DO  k = nzb+1, nzt
-
-       sa_p(k,j,i) = sa(k,j,i) + ( dt_3d *                                     &
-                                           ( tsc(2) * tend(k,j,i) +            &
-                                             tsc(3) * tsa_m(k,j,i) )           &
-                                 - tsc(5) * rdf_sc(k)                          &
-                                          * ( sa(k,j,i) - sa_init(k) )         &
-                                 ) * MERGE( 1.0_wp, 0.0_wp,                    &
-                                            BTEST( wall_flags_0(k,j,i), 0 ) )
-
-       IF ( sa_p(k,j,i) < 0.0_wp )  sa_p(k,j,i) = 0.1_wp * sa(k,j,i)
-
-    ENDDO
-
-!
-!-- Calculate tendencies for the next Runge-Kutta step
-    IF ( timestep_scheme(1:5) == 'runge' )  THEN
-       IF ( intermediate_timestep_count == 1 )  THEN
-          DO  k = nzb+1, nzt
-             tsa_m(k,j,i) = tend(k,j,i)
-          ENDDO
-       ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max )&
-       THEN
-          DO  k = nzb+1, nzt
-             tsa_m(k,j,i) =   -9.5625_wp * tend(k,j,i) +              &
-                               5.3125_wp * tsa_m(k,j,i)
-          ENDDO
+       CALL diffusion_s( i, j, sa,                                             &
+                         surf_def_h(0)%sasws, surf_def_h(1)%sasws,             &
+                         surf_def_h(2)%sasws,                                  &
+                         surf_lsm_h%sasws,    surf_usm_h%sasws,                &
+                         surf_def_v(0)%sasws, surf_def_v(1)%sasws,             &
+                         surf_def_v(2)%sasws, surf_def_v(3)%sasws,             &
+                         surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws,             &
+                         surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws,             &
+                         surf_usm_v(0)%sasws, surf_usm_v(1)%sasws,             &
+                         surf_usm_v(2)%sasws, surf_usm_v(3)%sasws )
+
+       CALL user_actions( i, j, 'sa-tendency' )
+
+!
+!--    Prognostic equation for salinity
+       DO  k = nzb+1, nzt
+
+          sa_p(k,j,i) = sa(k,j,i) + ( dt_3d *                                  &
+                                              ( tsc(2) * tend(k,j,i) +         &
+                                                tsc(3) * tsa_m(k,j,i) )        &
+                                    - tsc(5) * rdf_sc(k)                       &
+                                             * ( sa(k,j,i) - sa_init(k) )      &
+                                    ) * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_0(k,j,i), 0 ) )
+
+          IF ( sa_p(k,j,i) < 0.0_wp )  sa_p(k,j,i) = 0.1_wp * sa(k,j,i)
+
+       ENDDO
+
+!
+!--    Calculate tendencies for the next Runge-Kutta step
+       IF ( timestep_scheme(1:5) == 'runge' )  THEN
+          IF ( intermediate_timestep_count == 1 )  THEN
+             DO  k = nzb+1, nzt
+                tsa_m(k,j,i) = tend(k,j,i)
+             ENDDO
+          ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) &
+          THEN
+             DO  k = nzb+1, nzt
+                tsa_m(k,j,i) =   -9.5625_wp * tend(k,j,i) +                    &
+                                  5.3125_wp * tsa_m(k,j,i)
+             ENDDO
+          ENDIF
        ENDIF
+
     ENDIF
 
