Index: palm/trunk/SOURCE/data_output_tseries.f90
===================================================================
--- palm/trunk/SOURCE/data_output_tseries.f90	(revision 4901)
+++ palm/trunk/SOURCE/data_output_tseries.f90	(revision 1)
@@ -1,34 +1,52 @@
-!> @file data_output_tseries.f90
-!--------------------------------------------------------------------------------------------------!
-! This file is part of the PALM model system.
-!
-! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
-! Public License as published by the Free Software Foundation, either version 3 of the License, or
-! (at your option) any later version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
-! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-! Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with PALM. If not, see
-! <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2021 Leibniz Universitaet Hannover
-!--------------------------------------------------------------------------------------------------!
-!
-! Current revisions:
+ SUBROUTINE data_output_tseries
+
+!------------------------------------------------------------------------------!
+! Actual revisions:
 ! -----------------
 ! 
-! 
+!
 ! Former revisions:
 ! -----------------
-! $Id$
-! file re-formatted to follow the PALM coding standard
-!
-! 4360 2020-01-07 11:25:50Z suehring
-! Corrected "Former revisions" section
-!
-! 3655 2019-01-07 16:51:22Z knoop
-! unused format removed
+! $Log: data_output_tseries.f90,v $
+! Revision 1.13  2006/03/14 12:42:51  raasch
+! Error removed: NetCDF output only if switched on
+!
+! Revision 1.12  2006/02/23 10:30:54  raasch
+! Former routine plot_ts renamed data_output_tseries
+! error number argument for handle_netcdf_error
+! plts_anz renamed dots_n
+!
+! Revision 1.11  2005/05/18 15:50:54  raasch
+! Extensions for NetCDF output
+!
+! Revision 1.10  2003/04/16 13:10:40  raasch
+! Output of Monin Obukhov length included
+!
+! Revision 1.9  2001/03/30 07:45:34  raasch
+! Translation of remaining German identifiers (variables, subroutines, etc.)
+!
+! Revision 1.8  2001/01/22 20:36:59  letzel
+! All comments translated into English.
+!
+! Revision 1.7  2001/01/22 07:42:50  raasch
+! Module test_variables removed
+!
+! Revision 1.6  1999/02/05 09:14:35  raasch
+! Erweiterung fuer Ausgabe von Upstream-Anteilen, Erweiterung von ts_value
+! auf 30 Elemente
+!
+! Revision 1.5  1998/07/06 12:26:59  raasch
+! + USE test_variables
+!
+! Revision 1.4  1998/04/15 11:22:22  raasch
+! Erweiterung der Zeitreihenausgabe auf oberflaechennahe Temperaturen und
+! Waermestroeme
+!
+! Revision 1.3  1998/03/30 11:48:03  raasch
+! Divergenzen stehen jetzt in hom
+!
+! Revision 1.2  1998/03/25 13:56:01  raasch
+! Erweiterungen fuer Gebietsstatistiken,
+! dt in dt_3d umbenannt
 !
 ! Revision 1.1  1998/03/03 08:00:13  raasch
@@ -38,36 +56,22 @@
 ! Description:
 ! ------------
-!> Time series output for PROFIL. Always all time series are stored. A selection can be applied via
-!> the PROFIL-parameters in close_file.
-!--------------------------------------------------------------------------------------------------!
- SUBROUTINE data_output_tseries
-
-
-    USE control_parameters,                                                                        &
-        ONLY:  dots_time_count, time_since_reference_point
-
-    USE cpulog,                                                                                    &
-        ONLY:  cpu_log, log_point
-
-    USE kinds
-
-#if defined( __netcdf )
-    USE NETCDF
-#endif
-    USE netcdf_interface,                                                                          &
-        ONLY:  dots_num, id_set_ts, id_var_dots, id_var_time_ts, nc_stat, netcdf_handle_error
-
+! Time series output for PROFIL. Always all time series are stored. A selection
+! can be applied via the PROFIL-parameters in close_file.
+!------------------------------------------------------------------------------!
+
+    USE control_parameters
+    USE cpulog
+    USE indices
+    USE interfaces
+    USE netcdf_control
     USE pegrid
-
     USE profil_parameter
-
-    USE statistics,                                                                                &
-        ONLY:  flow_statistics_called, statistic_regions, ts_value
+    USE statistics
 
     IMPLICIT NONE
 
 
-    INTEGER(iwp) ::  i  !<
-    INTEGER(iwp) ::  sr !<
+    INTEGER ::  file_id, i, j, sr
+    REAL    ::  ts_value(30)
 
 
@@ -84,20 +88,17 @@
 !
 !--    Open file for time series output in NetCDF format
-       CALL check_open( 105 )
-
-!--    Increment the counter for number of output times
-!--    CAUTION: The following line has to be after the call of the subroutine check_open, since
-!--             check_open resets the counter dots_time_count to 0, if a new file is opened
-       dots_time_count = dots_time_count + 1
-
+       IF ( netcdf_output )  THEN
+          dots_time_count = dots_time_count + 1
+          CALL check_open( 105 )
 #if defined( __netcdf )
 !
-!--    Update the time series time axis
-       nc_stat = NF90_PUT_VAR( id_set_ts, id_var_time_ts,                                          &
-                               (/ time_since_reference_point /),                                   &
-                               start = (/ dots_time_count /),                                      &
-                               count = (/ 1 /) )
-       CALL netcdf_handle_error( 'data_output_tseries', 350 )
+!--       Update the time series time axis
+          nc_stat = NF90_PUT_VAR( id_set_ts, id_var_time_ts,     &
+                                  (/ simulated_time /),          &
+                                  start = (/ dots_time_count /), &
+                                  count = (/ 1 /) )
+          IF (nc_stat /= NF90_NOERR)  CALL handle_netcdf_error( 350 )
 #endif
+       ENDIF
 
 !
@@ -105,21 +106,104 @@
 !--    applicable)
        DO  sr = 0, statistic_regions
+!
+!--       Open file for time series output.
+          IF ( profil_output )  THEN
+             file_id = 50 + sr
+             CALL check_open( file_id )
+          ENDIF
+
+!
+!--       Collect and printout all time series quantities in a single line.
+          ts_value(1) = hom(nzb+4,1,var_hom,sr)     ! E
+          ts_value(2) = hom(nzb+5,1,var_hom,sr)     ! E*
+          ts_value(3) = dt_3d
+          ts_value(4) = hom(nzb,1,var_hom,sr)       ! u*
+          ts_value(5) = hom(nzb+3,1,var_hom,sr)     ! th*
+          ts_value(6) = u_max
+          ts_value(7) = v_max
+          ts_value(8) = w_max
+          ts_value(9) = hom(nzb+10,1,var_sum,sr)    ! new divergence
+          ts_value(10) = hom(nzb+9,1,var_hom,sr)    ! old Divergence
+          ts_value(11) = hom(nzb+6,1,var_hom,sr)    ! z_i(1)
+          ts_value(12) = hom(nzb+7,1,var_hom,sr)    ! z_i(2)
+          ts_value(13) = hom(nzb+8,1,var_hom,sr)    ! w*
+          ts_value(14) = hom(nzb,1,16,sr)           ! w'pt'   at k=0
+          ts_value(15) = hom(nzb+1,1,16,sr)         ! w'pt'   at k=1
+          ts_value(16) = hom(nzb+1,1,18,sr)         ! wpt     at k=1
+          ts_value(17) = hom(nzb,1,4,sr)            ! pt(0)
+          ts_value(18) = hom(nzb+1,1,4,sr)          ! pt(zp)
+          ts_value(19) = hom(nzb+9,1,var_hom-1,sr)  ! splptx
+          ts_value(20) = hom(nzb+10,1,var_hom-1,sr) ! splpty
+          ts_value(21) = hom(nzb+11,1,var_hom-1,sr) ! splptz
+          IF ( ts_value(5) /= 0.0 )  THEN
+             ts_value(22) = ts_value(4)**2 / &
+                            ( kappa * g * ts_value(5) / ts_value(18) )  ! L
+          ELSE
+             ts_value(22) = 10000.0
+          ENDIF
 
 #if defined( __netcdf )
-          DO  i = 1, dots_num
-             nc_stat = NF90_PUT_VAR( id_set_ts, id_var_dots(i,sr),                                 &
-                                     (/ ts_value(i,sr) /),                                         &
-                                     start = (/ dots_time_count /),                                &
-                                     count = (/ 1 /) )
-             CALL netcdf_handle_error( 'data_output_tseries', 351 )
-          ENDDO
+          IF ( netcdf_output )  THEN
+             DO  i = 1, dots_num
+                nc_stat = NF90_PUT_VAR( id_set_ts, id_var_dots(i,sr),  &
+                                        (/ ts_value(i) /),             &
+                                        start = (/ dots_time_count /), &
+                                        count = (/ 1 /) )
+                IF ( nc_stat /= NF90_NOERR )  CALL handle_netcdf_error( 351 )
+             ENDDO
+          ENDIF
 #endif
 
-       ENDDO
+          IF ( profil_output )  THEN
+             WRITE ( file_id, 500 )  simulated_time, ts_value(1:22)
+!
+!--          y-value range of the crosses to be drawn by PROFIL
+!--          If required, enlarge them, provided they have not yet been
+!--          specified in
+!--          check_parameters
+             DO  i = 1, dots_n
+
+                j = dots_crossindex(i)
+
+                IF ( cross_ts_uymin(j) == 999.999 )  THEN
+!
+!--                When the value range of the first line in the corresponding
+!--                cross is determined, its value range is simply adopted.
+                   IF ( cross_ts_uymin_computed(j) == 999.999 ) &
+                   THEN
+                      cross_ts_uymin_computed(j) = ts_value(dots_index(i))
+                   ELSE
+                      cross_ts_uymin_computed(j) = &
+                         MIN(cross_ts_uymin_computed(j),ts_value(dots_index(i)))
+                   ENDIF
+                ENDIF
+
+                IF ( cross_ts_uymax(j) == 999.999 )  THEN
+!
+!--                When the value range of the first line in the corresponding
+!--                cross is determined, its value range is simply adopted.
+                   IF ( cross_ts_uymax_computed(j) == 999.999 ) &
+                   THEN
+                      cross_ts_uymax_computed(j) = ts_value(dots_index(i))
+                   ELSE
+                      cross_ts_uymax_computed(j) = &
+                         MAX(cross_ts_uymax_computed(j),ts_value(dots_index(i)))
+                   ENDIF
+                ENDIF
+
+             ENDDO
+
+          ENDIF
+
+       ENDDO   ! Loop of subregions.
 
     ENDIF
 
 
-    CALL cpu_log( log_point(21), 'data_output_tseries', 'stop' )
+    CALL cpu_log( log_point(21), 'data_output_tseries','stop', 'nobarrier' )
+
+!
+!-- formats
+500 FORMAT (23(E15.7,1X))
 
  END SUBROUTINE data_output_tseries
