[1873] | 1 | !> @file calc_mean_profile.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1365] | 4 | ! |
---|
[2000] | 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. |
---|
[1365] | 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 | ! |
---|
[2718] | 17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1365] | 19 | ! |
---|
| 20 | ! Current revisions: |
---|
| 21 | ! ----------------- |
---|
| 22 | ! |
---|
[2233] | 23 | ! |
---|
[1365] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: calc_mean_profile.f90 3241 2018-09-12 15:02:00Z knoop $ |
---|
[3241] | 27 | ! omp_get_thread_num now declared in openmp directive, |
---|
| 28 | ! unused variable removed |
---|
| 29 | ! |
---|
| 30 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 31 | ! Corrected "Former revisions" section |
---|
| 32 | ! |
---|
| 33 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 34 | ! Change in file header (GPL part) |
---|
[2696] | 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 |
---|
[1365] | 39 | ! |
---|
[2233] | 40 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 41 | ! Adjustments to new topography concept |
---|
| 42 | ! |
---|
[2001] | 43 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 44 | ! Forced header and separation lines into 80 columns |
---|
| 45 | ! |
---|
[1874] | 46 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
| 47 | ! Module renamed (removed _mod) |
---|
| 48 | ! |
---|
| 49 | ! |
---|
[1851] | 50 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 51 | ! Module renamed |
---|
| 52 | ! |
---|
| 53 | ! |
---|
[1739] | 54 | ! 1738 2015-12-18 13:56:05Z raasch |
---|
| 55 | ! bugfix: if a layer is completely filled with topography, no mean is calculated |
---|
| 56 | ! |
---|
[1683] | 57 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 58 | ! Code annotations made doxygen readable |
---|
| 59 | ! |
---|
[1366] | 60 | ! 1365 2014-04-22 15:03:56Z boeske |
---|
| 61 | ! Initial revision |
---|
| 62 | ! |
---|
[1365] | 63 | ! Description: |
---|
| 64 | ! ------------ |
---|
[1682] | 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)). |
---|
[1365] | 68 | !------------------------------------------------------------------------------! |
---|
[1682] | 69 | MODULE calc_mean_profile_mod |
---|
| 70 | |
---|
[1365] | 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 | |
---|
[1682] | 81 | !------------------------------------------------------------------------------! |
---|
| 82 | ! Description: |
---|
| 83 | ! ------------ |
---|
| 84 | !> @todo Missing subroutine description. |
---|
| 85 | !------------------------------------------------------------------------------! |
---|
[1365] | 86 | SUBROUTINE calc_mean_profile( var, pr ) |
---|
| 87 | |
---|
| 88 | USE control_parameters, & |
---|
[3241] | 89 | ONLY: intermediate_timestep_count |
---|
[1365] | 90 | |
---|
| 91 | USE indices, & |
---|
[2232] | 92 | ONLY: ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb, nzt, & |
---|
| 93 | wall_flags_0 |
---|
[1365] | 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 | |
---|
[1682] | 105 | INTEGER(iwp) :: i !< |
---|
| 106 | INTEGER(iwp) :: j !< |
---|
| 107 | INTEGER(iwp) :: k !< |
---|
| 108 | INTEGER(iwp) :: pr !< |
---|
[3241] | 109 | !$ INTEGER(iwp) :: omp_get_thread_num !< |
---|
[1682] | 110 | INTEGER(iwp) :: tn !< |
---|
[1365] | 111 | |
---|
| 112 | #if defined( __nopointer ) |
---|
[1682] | 113 | REAL(wp), DIMENSION(:,:,:) :: var !< |
---|
[1365] | 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 |
---|
[2696] | 123 | !-- which are calling flow_statistics at different time intervals. At |
---|
| 124 | !-- initialization, intermediate_timestep_count = 0 is considered as well. |
---|
| 125 | |
---|
[1365] | 126 | IF ( .NOT. flow_statistics_called .AND. & |
---|
[2696] | 127 | intermediate_timestep_count <= 1 ) THEN |
---|
[1365] | 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 |
---|
[2232] | 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 ) ) |
---|
[1365] | 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 | |
---|
[1738] | 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 |
---|
[1365] | 168 | |
---|
| 169 | ENDIF |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | END SUBROUTINE calc_mean_profile |
---|
| 173 | |
---|
[1738] | 174 | END MODULE calc_mean_profile_mod |
---|