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