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 terms of the GNU General |
---|
6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
7 | ! (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
11 | ! Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
14 | ! <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! |
---|
17 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: calc_mean_profile.f90 4542 2020-05-19 15:45:12Z hellstea $ |
---|
27 | ! file re-formatted to follow the PALM coding standard |
---|
28 | ! |
---|
29 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
30 | ! Introduction of wall_flags_total_0, which currently sets bits based on static |
---|
31 | ! topography information used in wall_flags_static_0 |
---|
32 | ! |
---|
33 | ! 4329 2019-12-10 15:46:36Z motisi |
---|
34 | ! Renamed wall_flags_0 to wall_flags_static_0 |
---|
35 | ! |
---|
36 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
37 | ! Corrected "Former revisions" section |
---|
38 | ! |
---|
39 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
40 | ! nopointer option removed |
---|
41 | ! |
---|
42 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
43 | ! Initial revision |
---|
44 | ! |
---|
45 | ! Description: |
---|
46 | ! ------------ |
---|
47 | !> Calculate the horizontally averaged vertical temperature profile (pr=4 in case |
---|
48 | !> of potential temperature, 44 in case of virtual potential temperature, and 64 |
---|
49 | !> in case of density (ocean runs)). |
---|
50 | !------------------------------------------------------------------------------! |
---|
51 | MODULE calc_mean_profile_mod |
---|
52 | |
---|
53 | |
---|
54 | PRIVATE |
---|
55 | PUBLIC calc_mean_profile |
---|
56 | |
---|
57 | INTERFACE calc_mean_profile |
---|
58 | MODULE PROCEDURE calc_mean_profile |
---|
59 | END INTERFACE calc_mean_profile |
---|
60 | |
---|
61 | CONTAINS |
---|
62 | |
---|
63 | !--------------------------------------------------------------------------------------------------! |
---|
64 | ! Description: |
---|
65 | ! ------------ |
---|
66 | !> @todo Missing subroutine description. |
---|
67 | !--------------------------------------------------------------------------------------------------! |
---|
68 | SUBROUTINE calc_mean_profile( var, pr ) |
---|
69 | |
---|
70 | USE control_parameters, & |
---|
71 | ONLY: intermediate_timestep_count |
---|
72 | |
---|
73 | USE indices, & |
---|
74 | ONLY: ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb, nzt, wall_flags_total_0 |
---|
75 | |
---|
76 | USE kinds |
---|
77 | |
---|
78 | USE pegrid |
---|
79 | |
---|
80 | USE statistics, & |
---|
81 | ONLY: flow_statistics_called, hom, sums, sums_l |
---|
82 | |
---|
83 | |
---|
84 | IMPLICIT NONE |
---|
85 | |
---|
86 | INTEGER(iwp) :: i !< |
---|
87 | INTEGER(iwp) :: j !< |
---|
88 | INTEGER(iwp) :: k !< |
---|
89 | INTEGER(iwp) :: pr !< |
---|
90 | !$ INTEGER(iwp) :: omp_get_thread_num !< |
---|
91 | INTEGER(iwp) :: tn !< |
---|
92 | |
---|
93 | REAL(wp), DIMENSION(:,:,:), POINTER :: var |
---|
94 | |
---|
95 | ! |
---|
96 | !-- Computation of the horizontally averaged profile of variable var, unless already done by the |
---|
97 | !-- relevant call from flow_statistics. The calculation is done only for the first respective |
---|
98 | !-- intermediate timestep in order to spare communication time and to produce identical model |
---|
99 | !-- results with jobs which are calling flow_statistics at different time intervals. At |
---|
100 | !-- initialization, intermediate_timestep_count = 0 is considered as well. |
---|
101 | |
---|
102 | IF ( .NOT. flow_statistics_called .AND. intermediate_timestep_count <= 1 ) THEN |
---|
103 | |
---|
104 | ! |
---|
105 | !-- Horizontal average of variable var |
---|
106 | tn = 0 ! Default thread number in case of one thread |
---|
107 | !$OMP PARALLEL PRIVATE( i, j, k, tn ) |
---|
108 | !$ tn = omp_get_thread_num() |
---|
109 | sums_l(:,pr,tn) = 0.0_wp |
---|
110 | !$OMP DO |
---|
111 | DO i = nxl, nxr |
---|
112 | DO j = nys, nyn |
---|
113 | DO k = nzb, nzt+1 |
---|
114 | sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i) * MERGE( 1.0_wp, 0.0_wp, & |
---|
115 | BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
116 | ENDDO |
---|
117 | ENDDO |
---|
118 | ENDDO |
---|
119 | !$OMP END PARALLEL |
---|
120 | |
---|
121 | DO i = 1, threads_per_task-1 |
---|
122 | sums_l(:,pr,0) = sums_l(:,pr,0) + sums_l(:,pr,i) |
---|
123 | ENDDO |
---|
124 | |
---|
125 | #if defined( __parallel ) |
---|
126 | |
---|
127 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
128 | CALL MPI_ALLREDUCE( sums_l(nzb,pr,0), sums(nzb,pr), nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d,& |
---|
129 | ierr ) |
---|
130 | |
---|
131 | #else |
---|
132 | |
---|
133 | sums(:,pr) = sums_l(:,pr,0) |
---|
134 | |
---|
135 | #endif |
---|
136 | |
---|
137 | DO k = nzb, nzt+1 |
---|
138 | IF ( ngp_2dh_s_inner(k,0) /= 0 ) THEN |
---|
139 | hom(k,1,pr,0) = sums(k,pr) / ngp_2dh_s_inner(k,0) |
---|
140 | ENDIF |
---|
141 | ENDDO |
---|
142 | |
---|
143 | ENDIF |
---|
144 | |
---|
145 | |
---|
146 | END SUBROUTINE calc_mean_profile |
---|
147 | |
---|
148 | END MODULE calc_mean_profile_mod |
---|