1 | !> @file user_3d_data_averaging.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_3d_data_averaging.f90 3004 2018-04-27 12:33:25Z maronga $ |
---|
27 | ! Further allocation checks implemented |
---|
28 | ! |
---|
29 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
30 | ! Corrected "Former revisions" section |
---|
31 | ! |
---|
32 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
33 | ! Change in file header (GPL part) |
---|
34 | ! |
---|
35 | ! 2101 2017-01-05 16:42:31Z suehring |
---|
36 | ! |
---|
37 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
38 | ! Forced header and separation lines into 80 columns |
---|
39 | ! |
---|
40 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
41 | ! Code annotations made doxygen readable |
---|
42 | ! |
---|
43 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
44 | ! REAL constants provided with KIND-attribute |
---|
45 | ! |
---|
46 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
47 | ! REAL functions provided with KIND-attribute |
---|
48 | ! |
---|
49 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
50 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
51 | ! kinds are defined in new module kinds, |
---|
52 | ! revision history before 2012 removed, |
---|
53 | ! comment fields (!:) to be used for variable explanations added to |
---|
54 | ! all variable declaration statements |
---|
55 | ! |
---|
56 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
57 | ! code put under GPL (PALM 3.9) |
---|
58 | ! |
---|
59 | ! 211 2008-11-11 04:46:24Z raasch |
---|
60 | ! Former file user_interface.f90 split into one file per subroutine |
---|
61 | ! |
---|
62 | ! Description: |
---|
63 | ! ------------ |
---|
64 | !> Sum up and time-average user-defined output quantities as well as allocate |
---|
65 | !> the array necessary for storing the average. |
---|
66 | !------------------------------------------------------------------------------! |
---|
67 | SUBROUTINE user_3d_data_averaging( mode, variable ) |
---|
68 | |
---|
69 | |
---|
70 | USE control_parameters |
---|
71 | |
---|
72 | USE indices |
---|
73 | |
---|
74 | USE kinds |
---|
75 | |
---|
76 | USE user |
---|
77 | |
---|
78 | IMPLICIT NONE |
---|
79 | |
---|
80 | CHARACTER (LEN=*) :: mode !< |
---|
81 | CHARACTER (LEN=*) :: variable !< |
---|
82 | |
---|
83 | INTEGER(iwp) :: i !< |
---|
84 | INTEGER(iwp) :: j !< |
---|
85 | INTEGER(iwp) :: k !< |
---|
86 | |
---|
87 | IF ( mode == 'allocate' ) THEN |
---|
88 | |
---|
89 | SELECT CASE ( TRIM( variable ) ) |
---|
90 | |
---|
91 | ! |
---|
92 | !-- Uncomment and extend the following lines, if necessary. |
---|
93 | !-- The arrays for storing the user defined quantities (here u2_av) have |
---|
94 | !-- to be declared and defined by the user! |
---|
95 | !-- Sample for user-defined output: |
---|
96 | ! CASE ( 'u2' ) |
---|
97 | ! IF ( .NOT. ALLOCATED( u2_av ) ) THEN |
---|
98 | ! ALLOCATE( u2_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
99 | ! ENDIF |
---|
100 | ! u2_av = 0.0_wp |
---|
101 | |
---|
102 | CASE DEFAULT |
---|
103 | CONTINUE |
---|
104 | |
---|
105 | END SELECT |
---|
106 | |
---|
107 | ELSEIF ( mode == 'sum' ) THEN |
---|
108 | |
---|
109 | SELECT CASE ( TRIM( variable ) ) |
---|
110 | |
---|
111 | ! |
---|
112 | !-- Uncomment and extend the following lines, if necessary. |
---|
113 | !-- The arrays for storing the user defined quantities (here u2 and |
---|
114 | !-- u2_av) have to be declared and defined by the user! |
---|
115 | !-- Sample for user-defined output: |
---|
116 | ! CASE ( 'u2' ) |
---|
117 | ! IF ( ALLOCATED( u2_av ) ) THEN |
---|
118 | ! DO i = nxlg, nxrg |
---|
119 | ! DO j = nysg, nyng |
---|
120 | ! DO k = nzb, nzt+1 |
---|
121 | ! u2_av(k,j,i) = u2_av(k,j,i) + u2(k,j,i) |
---|
122 | ! ENDDO |
---|
123 | ! ENDDO |
---|
124 | ! ENDDO |
---|
125 | ! ENDIF |
---|
126 | |
---|
127 | CASE DEFAULT |
---|
128 | CONTINUE |
---|
129 | |
---|
130 | END SELECT |
---|
131 | |
---|
132 | ELSEIF ( mode == 'average' ) THEN |
---|
133 | |
---|
134 | SELECT CASE ( TRIM( variable ) ) |
---|
135 | |
---|
136 | ! |
---|
137 | !-- Uncomment and extend the following lines, if necessary. |
---|
138 | !-- The arrays for storing the user defined quantities (here u2_av) have |
---|
139 | !-- to be declared and defined by the user! |
---|
140 | !-- Sample for user-defined output: |
---|
141 | ! CASE ( 'u2' ) |
---|
142 | ! IF ( ALLOCATED( u2_av ) ) THEN |
---|
143 | ! DO i = nxlg, nxrg |
---|
144 | ! DO j = nysg, nyng |
---|
145 | ! DO k = nzb, nzt+1 |
---|
146 | ! u2_av(k,j,i) = u2_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
147 | ! ENDDO |
---|
148 | ! ENDDO |
---|
149 | ! ENDDO |
---|
150 | ! ENDIF |
---|
151 | |
---|
152 | END SELECT |
---|
153 | |
---|
154 | ENDIF |
---|
155 | |
---|
156 | |
---|
157 | END SUBROUTINE user_3d_data_averaging |
---|