source: palm/trunk/SOURCE/user_statistics.f90 @ 1799

Last change on this file since 1799 was 1784, checked in by raasch, 9 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1!> @file user_statistics.f90
2!--------------------------------------------------------------------------------!
3! This file is part of PALM.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms
6! of the GNU General Public License as published by the Free Software Foundation,
7! either version 3 of the License, or (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with
14! PALM. If not, see <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2014 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------!
18!
19! Current revisions:
20! -----------------
21!
22!
23! Former revisions:
24! -----------------
25! $Id: user_statistics.f90 1784 2016-03-06 19:14:40Z gronemeier $
26!
27! 1783 2016-03-06 18:36:17Z raasch
28! netcdf module name changed + related changes
29!
30! 1682 2015-10-07 23:56:08Z knoop
31! Code annotations made doxygen readable
32!
33! 1353 2014-04-08 15:21:23Z heinze
34! REAL constants provided with KIND-attribute
35!
36! 1320 2014-03-20 08:40:49Z raasch
37! kind-parameters added to all INTEGER and REAL declaration statements,
38! kinds are defined in new module kinds,
39! old module precision_kind is removed,
40! revision history before 2012 removed,
41! comment fields (!:) to be used for variable explanations added to
42! all variable declaration statements
43!
44! 1046 2012-11-09 14:38:45Z maronga
45! added preprocessor directive for parameter file check
46!
47! 1036 2012-10-22 13:43:42Z raasch
48! code put under GPL (PALM 3.9)
49!
50! 211 2008-11-11 04:46:24Z raasch
51! Former file user_interface.f90 split into one file per subroutine
52!
53! Description:
54! ------------
55!> Calculation of user-defined statistics, i.e. horizontally averaged profiles
56!> and time series.
57!> This routine is called for every statistic region sr defined by the user,
58!> but at least for the region "total domain" (sr=0).
59!> See section 3.5.4 on how to define, calculate, and output user defined
60!> quantities.
61!------------------------------------------------------------------------------!
62 SUBROUTINE user_statistics( mode, sr, tn )
63 
64
65    USE arrays_3d
66   
67    USE indices
68   
69    USE kinds
70   
71    USE netcdf_interface,                                                      &
72        ONLY:  dots_max
73
74    USE pegrid
75   
76    USE statistics
77   
78    USE user
79
80    IMPLICIT NONE
81
82    CHARACTER (LEN=*) ::  mode   !<
83
84    INTEGER(iwp) ::  i    !<
85    INTEGER(iwp) ::  j    !<
86    INTEGER(iwp) ::  k    !<
87    INTEGER(iwp) ::  sr   !<
88    INTEGER(iwp) ::  tn   !<
89
90    REAL(wp),                                                                  &
91       DIMENSION(dots_num_palm+1:dots_max) ::                                  &
92          ts_value_l   !<
93
94
95    IF ( mode == 'profiles' )  THEN
96
97!
98!--    Sample on how to calculate horizontally averaged profiles of user-
99!--    defined quantities. Each quantity is identified by the index
100!--    "pr_palm+#" where "#" is an integer starting from 1. These
101!--    user-profile-numbers must also be assigned to the respective strings
102!--    given by data_output_pr_user in routine user_check_data_output_pr.
103!       !$OMP DO
104!       DO  i = nxl, nxr
105!          DO  j = nys, nyn
106!             DO  k = nzb_s_inner(j,i)+1, nzt
107!!
108!!--             Sample on how to calculate the profile of the resolved-scale
109!!--             horizontal momentum flux u*v*
110!                sums_l(k,pr_palm+1,tn) = sums_l(k,pr_palm+1,tn) +               &
111!                      ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,sr) ) *     &
112!                      ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,sr) )       &
113!                                                 * rmask(j,i,sr)
114!!
115!!--             Further profiles can be defined and calculated by increasing
116!!--             the second index of array sums_l (replace ... appropriately)
117!                sums_l(k,pr_palm+2,tn) = sums_l(k,pr_palm+2,tn) + ...           &
118!                                         * rmask(j,i,sr)
119!             ENDDO
120!          ENDDO
121!       ENDDO
122
123    ELSEIF ( mode == 'time_series' )  THEN
124
125!
126!--    Sample on how to add values for the user-defined time series quantities.
127!--    These have to be defined before in routine user_init. This sample
128!--    creates two time series for the absolut values of the horizontal
129!--    velocities u and v.
130!       ts_value_l = 0.0_wp
131!       ts_value_l(dots_num_palm+1) = ABS( u_max )
132!       ts_value_l(dots_num_palm+2) = ABS( v_max )
133!
134!--     Collect / send values to PE0, because only PE0 outputs the time series.
135!--     CAUTION: Collection is done by taking the sum over all processors.
136!--              You may have to normalize this sum, depending on the quantity
137!--              that you like to calculate. For serial runs, nothing has to be
138!--              done.
139!--     HINT: If the time series value that you are calculating has the same
140!--           value on all PEs, you can omit the MPI_ALLREDUCE call and
141!--           assign ts_value(dots_num_palm+1:,sr) = ts_value_l directly.
142!#if defined( __parallel ) && ! defined ( __check )
143!       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
144!       CALL MPI_ALLREDUCE( ts_value_l(dots_num_palm+1),                         &
145!                           ts_value(dots_num_palm+1,sr),                        &
146!                           dots_max-dots_num_palm, MPI_REAL, MPI_SUM, comm2d,   &
147!                           ierr )
148!#else
149!       ts_value(dots_num_palm+1:,sr) = ts_value_l
150!#endif
151
152    ENDIF
153
154 END SUBROUTINE user_statistics
155
Note: See TracBrowser for help on using the repository browser.