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

Last change on this file since 2157 was 2101, checked in by suehring, 8 years ago

last commit documented

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