1 | !> @file user_statistics.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
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. |
---|
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 | ! |
---|
17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: user_statistics.f90 2718 2018-01-02 08:49:38Z eckhard $ |
---|
27 | ! Corrected "Former revisions" section |
---|
28 | ! |
---|
29 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
30 | ! Change in file header (GPL part) |
---|
31 | ! |
---|
32 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
33 | ! |
---|
34 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
35 | ! Ajdustments for new topography masking |
---|
36 | ! |
---|
37 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
38 | ! Forced header and separation lines into 80 columns |
---|
39 | ! |
---|
40 | ! 1804 2016-04-05 16:30:18Z maronga |
---|
41 | ! Removed code for parameter file check (__check) |
---|
42 | ! |
---|
43 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
44 | ! netcdf module name changed + related changes |
---|
45 | ! |
---|
46 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
47 | ! Code annotations made doxygen readable |
---|
48 | ! |
---|
49 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
50 | ! REAL constants provided with KIND-attribute |
---|
51 | ! |
---|
52 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
53 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
54 | ! kinds are defined in new module kinds, |
---|
55 | ! old module precision_kind is removed, |
---|
56 | ! revision history before 2012 removed, |
---|
57 | ! comment fields (!:) to be used for variable explanations added to |
---|
58 | ! all variable declaration statements |
---|
59 | ! |
---|
60 | ! 1046 2012-11-09 14:38:45Z maronga |
---|
61 | ! added preprocessor directive for parameter file check |
---|
62 | ! |
---|
63 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
64 | ! code put under GPL (PALM 3.9) |
---|
65 | ! |
---|
66 | ! 211 2008-11-11 04:46:24Z raasch |
---|
67 | ! Former file user_interface.f90 split into one file per subroutine |
---|
68 | ! |
---|
69 | ! Description: |
---|
70 | ! ------------ |
---|
71 | !> Calculation of user-defined statistics, i.e. horizontally averaged profiles |
---|
72 | !> and time series. |
---|
73 | !> This routine is called for every statistic region sr defined by the user, |
---|
74 | !> but at least for the region "total domain" (sr=0). |
---|
75 | !> See section 3.5.4 on how to define, calculate, and output user defined |
---|
76 | !> quantities. |
---|
77 | !------------------------------------------------------------------------------! |
---|
78 | SUBROUTINE user_statistics( mode, sr, tn ) |
---|
79 | |
---|
80 | |
---|
81 | USE arrays_3d |
---|
82 | |
---|
83 | USE indices |
---|
84 | |
---|
85 | USE kinds |
---|
86 | |
---|
87 | USE netcdf_interface, & |
---|
88 | ONLY: dots_max |
---|
89 | |
---|
90 | USE pegrid |
---|
91 | |
---|
92 | USE statistics |
---|
93 | |
---|
94 | USE user |
---|
95 | |
---|
96 | IMPLICIT NONE |
---|
97 | |
---|
98 | CHARACTER (LEN=*) :: mode !< |
---|
99 | |
---|
100 | INTEGER(iwp) :: i !< |
---|
101 | INTEGER(iwp) :: j !< |
---|
102 | INTEGER(iwp) :: k !< |
---|
103 | INTEGER(iwp) :: sr !< |
---|
104 | INTEGER(iwp) :: tn !< |
---|
105 | |
---|
106 | REAL(wp), & |
---|
107 | DIMENSION(dots_num_palm+1:dots_max) :: & |
---|
108 | ts_value_l !< |
---|
109 | |
---|
110 | |
---|
111 | IF ( mode == 'profiles' ) THEN |
---|
112 | |
---|
113 | ! |
---|
114 | !-- Sample on how to calculate horizontally averaged profiles of user- |
---|
115 | !-- defined quantities. Each quantity is identified by the index |
---|
116 | !-- "pr_palm+#" where "#" is an integer starting from 1. These |
---|
117 | !-- user-profile-numbers must also be assigned to the respective strings |
---|
118 | !-- given by data_output_pr_user in routine user_check_data_output_pr. |
---|
119 | ! !$OMP DO |
---|
120 | ! DO i = nxl, nxr |
---|
121 | ! DO j = nys, nyn |
---|
122 | ! DO k = nzb+1, nzt |
---|
123 | !! |
---|
124 | !!-- Sample on how to calculate the profile of the resolved-scale |
---|
125 | !!-- horizontal momentum flux u*v* |
---|
126 | ! sums_l(k,pr_palm+1,tn) = sums_l(k,pr_palm+1,tn) + & |
---|
127 | ! ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,sr) ) *& |
---|
128 | ! ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,sr) ) & |
---|
129 | ! * rmask(j,i,sr) & |
---|
130 | ! * MERGE( 1.0_wp, 0.0_wp, & |
---|
131 | ! BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
132 | !! |
---|
133 | !!-- Further profiles can be defined and calculated by increasing |
---|
134 | !!-- the second index of array sums_l (replace ... appropriately) |
---|
135 | ! sums_l(k,pr_palm+2,tn) = sums_l(k,pr_palm+2,tn) + ... & |
---|
136 | ! * rmask(j,i,sr) |
---|
137 | ! ENDDO |
---|
138 | ! ENDDO |
---|
139 | ! ENDDO |
---|
140 | |
---|
141 | ELSEIF ( mode == 'time_series' ) THEN |
---|
142 | |
---|
143 | ! |
---|
144 | !-- Sample on how to add values for the user-defined time series quantities. |
---|
145 | !-- These have to be defined before in routine user_init. This sample |
---|
146 | !-- creates two time series for the absolut values of the horizontal |
---|
147 | !-- velocities u and v. |
---|
148 | ! ts_value_l = 0.0_wp |
---|
149 | ! ts_value_l(dots_num_palm+1) = ABS( u_max ) |
---|
150 | ! ts_value_l(dots_num_palm+2) = ABS( v_max ) |
---|
151 | ! |
---|
152 | !-- Collect / send values to PE0, because only PE0 outputs the time series. |
---|
153 | !-- CAUTION: Collection is done by taking the sum over all processors. |
---|
154 | !-- You may have to normalize this sum, depending on the quantity |
---|
155 | !-- that you like to calculate. For serial runs, nothing has to be |
---|
156 | !-- done. |
---|
157 | !-- HINT: If the time series value that you are calculating has the same |
---|
158 | !-- value on all PEs, you can omit the MPI_ALLREDUCE call and |
---|
159 | !-- assign ts_value(dots_num_palm+1:,sr) = ts_value_l directly. |
---|
160 | !#if defined( __parallel ) |
---|
161 | ! IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
162 | ! CALL MPI_ALLREDUCE( ts_value_l(dots_num_palm+1), & |
---|
163 | ! ts_value(dots_num_palm+1,sr), & |
---|
164 | ! dots_max-dots_num_palm, MPI_REAL, MPI_SUM, comm2d, & |
---|
165 | ! ierr ) |
---|
166 | !#else |
---|
167 | ! ts_value(dots_num_palm+1:,sr) = ts_value_l |
---|
168 | !#endif |
---|
169 | |
---|
170 | ENDIF |
---|
171 | |
---|
172 | END SUBROUTINE user_statistics |
---|
173 | |
---|