source: palm/trunk/SOURCE/calc_mean_profile.f90 @ 4671

Last change on this file since 4671 was 4542, checked in by raasch, 4 years ago

files re-formatted to follow the PALM coding standard, redundant if statement removed

  • Property svn:keywords set to Id
File size: 5.0 KB
RevLine 
[1873]1!> @file calc_mean_profile.f90
[4542]2!--------------------------------------------------------------------------------------------------!
[2696]3! This file is part of the PALM model system.
[1365]4!
[4542]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.
[1365]8!
[4542]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.
[1365]12!
[4542]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/>.
[1365]15!
[4542]16!
[4360]17! Copyright 1997-2020 Leibniz Universitaet Hannover
[4542]18!--------------------------------------------------------------------------------------------------!
[1365]19!
20! Current revisions:
21! -----------------
22!
[2233]23!
[1365]24! Former revisions:
25! -----------------
26! $Id: calc_mean_profile.f90 4542 2020-05-19 15:45:12Z pavelkrc $
[4542]27! file re-formatted to follow the PALM coding standard
28!
29! 4360 2020-01-07 11:25:50Z suehring
[4346]30! Introduction of wall_flags_total_0, which currently sets bits based on static
31! topography information used in wall_flags_static_0
[4542]32!
[4346]33! 4329 2019-12-10 15:46:36Z motisi
[4329]34! Renamed wall_flags_0 to wall_flags_static_0
[4542]35!
[4329]36! 4182 2019-08-22 15:20:23Z scharf
[4182]37! Corrected "Former revisions" section
[4542]38!
[4182]39! 3655 2019-01-07 16:51:22Z knoop
[3636]40! nopointer option removed
[4542]41!
[4182]42! 1365 2014-04-22 15:03:56Z boeske
43! Initial revision
[1365]44!
45! Description:
46! ------------
[1682]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)).
[1365]50!------------------------------------------------------------------------------!
[1682]51 MODULE calc_mean_profile_mod
[1365]52
[4542]53
[1365]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
[4542]63!--------------------------------------------------------------------------------------------------!
[1682]64! Description:
65! ------------
66!> @todo Missing subroutine description.
[4542]67!--------------------------------------------------------------------------------------------------!
[1365]68    SUBROUTINE calc_mean_profile( var, pr )
69
[4542]70       USE control_parameters,                                                                     &
[3241]71           ONLY:  intermediate_timestep_count
[1365]72
[4542]73       USE indices,                                                                                &
74           ONLY:  ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb, nzt, wall_flags_total_0
[1365]75
76       USE kinds
77
78       USE pegrid
79
[4542]80       USE statistics,                                                                             &
[1365]81           ONLY:  flow_statistics_called, hom, sums, sums_l
82
83
84       IMPLICIT NONE
[4542]85
[1682]86       INTEGER(iwp) ::  i                  !<
87       INTEGER(iwp) ::  j                  !<
88       INTEGER(iwp) ::  k                  !<
[4542]89       INTEGER(iwp) ::  pr                 !<
[3241]90!$     INTEGER(iwp) ::  omp_get_thread_num !<
[1682]91       INTEGER(iwp) ::  tn                 !<
[4542]92
[1365]93       REAL(wp), DIMENSION(:,:,:), POINTER ::  var
94
95!
[4542]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
[2696]100!--    initialization, intermediate_timestep_count = 0 is considered as well.
101
[4542]102       IF ( .NOT. flow_statistics_called  .AND.  intermediate_timestep_count <= 1 )  THEN
[1365]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
[2232]113                DO  k = nzb, nzt+1
[4542]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 ) )
[1365]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 )
[4542]128          CALL MPI_ALLREDUCE( sums_l(nzb,pr,0), sums(nzb,pr), nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d,&
129                              ierr )
[1365]130
131#else
132
133          sums(:,pr) = sums_l(:,pr,0)
134
135#endif
136
[1738]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
[1365]142
143       ENDIF
144
145
146    END SUBROUTINE calc_mean_profile
147
[1738]148 END MODULE calc_mean_profile_mod
Note: See TracBrowser for help on using the repository browser.