1 | !> @file calc_mean_profile.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: calc_mean_profile.f90 3241 2018-09-12 15:02:00Z banzhafs $ |
---|
27 | ! omp_get_thread_num now declared in openmp directive, |
---|
28 | ! unused variable removed |
---|
29 | ! |
---|
30 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
31 | ! Corrected "Former revisions" section |
---|
32 | ! |
---|
33 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
34 | ! Change in file header (GPL part) |
---|
35 | ! Enable usage also during initialization, required for initialization of |
---|
36 | ! radiation and land-surface model (MS) |
---|
37 | ! |
---|
38 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
39 | ! |
---|
40 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
41 | ! Adjustments to new topography concept |
---|
42 | ! |
---|
43 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
44 | ! Forced header and separation lines into 80 columns |
---|
45 | ! |
---|
46 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
47 | ! Module renamed (removed _mod) |
---|
48 | ! |
---|
49 | ! |
---|
50 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
51 | ! Module renamed |
---|
52 | ! |
---|
53 | ! |
---|
54 | ! 1738 2015-12-18 13:56:05Z raasch |
---|
55 | ! bugfix: if a layer is completely filled with topography, no mean is calculated |
---|
56 | ! |
---|
57 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
58 | ! Code annotations made doxygen readable |
---|
59 | ! |
---|
60 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
61 | ! Initial revision |
---|
62 | ! |
---|
63 | ! Description: |
---|
64 | ! ------------ |
---|
65 | !> Calculate the horizontally averaged vertical temperature profile (pr=4 in case |
---|
66 | !> of potential temperature, 44 in case of virtual potential temperature, and 64 |
---|
67 | !> in case of density (ocean runs)). |
---|
68 | !------------------------------------------------------------------------------! |
---|
69 | MODULE calc_mean_profile_mod |
---|
70 | |
---|
71 | |
---|
72 | PRIVATE |
---|
73 | PUBLIC calc_mean_profile |
---|
74 | |
---|
75 | INTERFACE calc_mean_profile |
---|
76 | MODULE PROCEDURE calc_mean_profile |
---|
77 | END INTERFACE calc_mean_profile |
---|
78 | |
---|
79 | CONTAINS |
---|
80 | |
---|
81 | !------------------------------------------------------------------------------! |
---|
82 | ! Description: |
---|
83 | ! ------------ |
---|
84 | !> @todo Missing subroutine description. |
---|
85 | !------------------------------------------------------------------------------! |
---|
86 | SUBROUTINE calc_mean_profile( var, pr ) |
---|
87 | |
---|
88 | USE control_parameters, & |
---|
89 | ONLY: intermediate_timestep_count |
---|
90 | |
---|
91 | USE indices, & |
---|
92 | ONLY: ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb, nzt, & |
---|
93 | wall_flags_0 |
---|
94 | |
---|
95 | USE kinds |
---|
96 | |
---|
97 | USE pegrid |
---|
98 | |
---|
99 | USE statistics, & |
---|
100 | ONLY: flow_statistics_called, hom, sums, sums_l |
---|
101 | |
---|
102 | |
---|
103 | IMPLICIT NONE |
---|
104 | |
---|
105 | INTEGER(iwp) :: i !< |
---|
106 | INTEGER(iwp) :: j !< |
---|
107 | INTEGER(iwp) :: k !< |
---|
108 | INTEGER(iwp) :: pr !< |
---|
109 | !$ INTEGER(iwp) :: omp_get_thread_num !< |
---|
110 | INTEGER(iwp) :: tn !< |
---|
111 | |
---|
112 | #if defined( __nopointer ) |
---|
113 | REAL(wp), DIMENSION(:,:,:) :: var !< |
---|
114 | #else |
---|
115 | REAL(wp), DIMENSION(:,:,:), POINTER :: var |
---|
116 | #endif |
---|
117 | |
---|
118 | ! |
---|
119 | !-- Computation of the horizontally averaged profile of variable var, unless |
---|
120 | !-- already done by the relevant call from flow_statistics. The calculation |
---|
121 | !-- is done only for the first respective intermediate timestep in order to |
---|
122 | !-- spare communication time and to produce identical model results with jobs |
---|
123 | !-- which are calling flow_statistics at different time intervals. At |
---|
124 | !-- initialization, intermediate_timestep_count = 0 is considered as well. |
---|
125 | |
---|
126 | IF ( .NOT. flow_statistics_called .AND. & |
---|
127 | intermediate_timestep_count <= 1 ) THEN |
---|
128 | |
---|
129 | ! |
---|
130 | !-- Horizontal average of variable var |
---|
131 | tn = 0 ! Default thread number in case of one thread |
---|
132 | !$OMP PARALLEL PRIVATE( i, j, k, tn ) |
---|
133 | !$ tn = omp_get_thread_num() |
---|
134 | sums_l(:,pr,tn) = 0.0_wp |
---|
135 | !$OMP DO |
---|
136 | DO i = nxl, nxr |
---|
137 | DO j = nys, nyn |
---|
138 | DO k = nzb, nzt+1 |
---|
139 | sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i) & |
---|
140 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
141 | BTEST( wall_flags_0(k,j,i), 22 ) ) |
---|
142 | ENDDO |
---|
143 | ENDDO |
---|
144 | ENDDO |
---|
145 | !$OMP END PARALLEL |
---|
146 | |
---|
147 | DO i = 1, threads_per_task-1 |
---|
148 | sums_l(:,pr,0) = sums_l(:,pr,0) + sums_l(:,pr,i) |
---|
149 | ENDDO |
---|
150 | |
---|
151 | #if defined( __parallel ) |
---|
152 | |
---|
153 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
154 | CALL MPI_ALLREDUCE( sums_l(nzb,pr,0), sums(nzb,pr), nzt+2-nzb, & |
---|
155 | MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
156 | |
---|
157 | #else |
---|
158 | |
---|
159 | sums(:,pr) = sums_l(:,pr,0) |
---|
160 | |
---|
161 | #endif |
---|
162 | |
---|
163 | DO k = nzb, nzt+1 |
---|
164 | IF ( ngp_2dh_s_inner(k,0) /= 0 ) THEN |
---|
165 | hom(k,1,pr,0) = sums(k,pr) / ngp_2dh_s_inner(k,0) |
---|
166 | ENDIF |
---|
167 | ENDDO |
---|
168 | |
---|
169 | ENDIF |
---|
170 | |
---|
171 | |
---|
172 | END SUBROUTINE calc_mean_profile |
---|
173 | |
---|
174 | END MODULE calc_mean_profile_mod |
---|