[1682] | 1 | !> @file user_statistics.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 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. |
---|
[1036] | 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 | ! |
---|
[2101] | 17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[211] | 21 | ! ----------------- |
---|
[1805] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: user_statistics.f90 2696 2017-12-14 17:12:51Z suehring $ |
---|
| 27 | ! |
---|
[2233] | 28 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 29 | ! Ajdustments for new topography masking |
---|
| 30 | ! |
---|
[2001] | 31 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 32 | ! Forced header and separation lines into 80 columns |
---|
| 33 | ! |
---|
[1805] | 34 | ! 1804 2016-04-05 16:30:18Z maronga |
---|
| 35 | ! Removed code for parameter file check (__check) |
---|
| 36 | ! |
---|
[1784] | 37 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
| 38 | ! netcdf module name changed + related changes |
---|
| 39 | ! |
---|
[1683] | 40 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 41 | ! Code annotations made doxygen readable |
---|
| 42 | ! |
---|
[1354] | 43 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 44 | ! REAL constants provided with KIND-attribute |
---|
| 45 | ! |
---|
[1321] | 46 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 47 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 48 | ! kinds are defined in new module kinds, |
---|
| 49 | ! old module precision_kind is removed, |
---|
| 50 | ! revision history before 2012 removed, |
---|
| 51 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 52 | ! all variable declaration statements |
---|
[211] | 53 | ! |
---|
[1047] | 54 | ! 1046 2012-11-09 14:38:45Z maronga |
---|
| 55 | ! added preprocessor directive for parameter file check |
---|
| 56 | ! |
---|
[1037] | 57 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 58 | ! code put under GPL (PALM 3.9) |
---|
| 59 | ! |
---|
[226] | 60 | ! 211 2008-11-11 04:46:24Z raasch |
---|
| 61 | ! Former file user_interface.f90 split into one file per subroutine |
---|
| 62 | ! |
---|
[211] | 63 | ! Description: |
---|
| 64 | ! ------------ |
---|
[1682] | 65 | !> Calculation of user-defined statistics, i.e. horizontally averaged profiles |
---|
| 66 | !> and time series. |
---|
| 67 | !> This routine is called for every statistic region sr defined by the user, |
---|
| 68 | !> but at least for the region "total domain" (sr=0). |
---|
| 69 | !> See section 3.5.4 on how to define, calculate, and output user defined |
---|
| 70 | !> quantities. |
---|
[211] | 71 | !------------------------------------------------------------------------------! |
---|
[1682] | 72 | SUBROUTINE user_statistics( mode, sr, tn ) |
---|
| 73 | |
---|
[211] | 74 | |
---|
| 75 | USE arrays_3d |
---|
[1320] | 76 | |
---|
[211] | 77 | USE indices |
---|
[1320] | 78 | |
---|
| 79 | USE kinds |
---|
| 80 | |
---|
[1783] | 81 | USE netcdf_interface, & |
---|
| 82 | ONLY: dots_max |
---|
| 83 | |
---|
[678] | 84 | USE pegrid |
---|
[1320] | 85 | |
---|
[211] | 86 | USE statistics |
---|
[1320] | 87 | |
---|
[211] | 88 | USE user |
---|
| 89 | |
---|
| 90 | IMPLICIT NONE |
---|
| 91 | |
---|
[1682] | 92 | CHARACTER (LEN=*) :: mode !< |
---|
[211] | 93 | |
---|
[1682] | 94 | INTEGER(iwp) :: i !< |
---|
| 95 | INTEGER(iwp) :: j !< |
---|
| 96 | INTEGER(iwp) :: k !< |
---|
| 97 | INTEGER(iwp) :: sr !< |
---|
| 98 | INTEGER(iwp) :: tn !< |
---|
[211] | 99 | |
---|
[1320] | 100 | REAL(wp), & |
---|
| 101 | DIMENSION(dots_num_palm+1:dots_max) :: & |
---|
[1682] | 102 | ts_value_l !< |
---|
[211] | 103 | |
---|
[493] | 104 | |
---|
[211] | 105 | IF ( mode == 'profiles' ) THEN |
---|
| 106 | |
---|
| 107 | ! |
---|
| 108 | !-- Sample on how to calculate horizontally averaged profiles of user- |
---|
| 109 | !-- defined quantities. Each quantity is identified by the index |
---|
| 110 | !-- "pr_palm+#" where "#" is an integer starting from 1. These |
---|
| 111 | !-- user-profile-numbers must also be assigned to the respective strings |
---|
| 112 | !-- given by data_output_pr_user in routine user_check_data_output_pr. |
---|
| 113 | ! !$OMP DO |
---|
| 114 | ! DO i = nxl, nxr |
---|
| 115 | ! DO j = nys, nyn |
---|
[2232] | 116 | ! DO k = nzb+1, nzt |
---|
[211] | 117 | !! |
---|
| 118 | !!-- Sample on how to calculate the profile of the resolved-scale |
---|
| 119 | !!-- horizontal momentum flux u*v* |
---|
[2232] | 120 | ! sums_l(k,pr_palm+1,tn) = sums_l(k,pr_palm+1,tn) + & |
---|
| 121 | ! ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - hom(k,1,1,sr) ) *& |
---|
| 122 | ! ( 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - hom(k,1,2,sr) ) & |
---|
| 123 | ! * rmask(j,i,sr) & |
---|
| 124 | ! * MERGE( 1.0_wp, 0.0_wp, & |
---|
| 125 | ! BTEST( wall_flags_0(k,j,i), 0 ) ) |
---|
[211] | 126 | !! |
---|
| 127 | !!-- Further profiles can be defined and calculated by increasing |
---|
| 128 | !!-- the second index of array sums_l (replace ... appropriately) |
---|
[1320] | 129 | ! sums_l(k,pr_palm+2,tn) = sums_l(k,pr_palm+2,tn) + ... & |
---|
[211] | 130 | ! * rmask(j,i,sr) |
---|
| 131 | ! ENDDO |
---|
| 132 | ! ENDDO |
---|
| 133 | ! ENDDO |
---|
| 134 | |
---|
| 135 | ELSEIF ( mode == 'time_series' ) THEN |
---|
| 136 | |
---|
| 137 | ! |
---|
| 138 | !-- Sample on how to add values for the user-defined time series quantities. |
---|
| 139 | !-- These have to be defined before in routine user_init. This sample |
---|
| 140 | !-- creates two time series for the absolut values of the horizontal |
---|
| 141 | !-- velocities u and v. |
---|
[1353] | 142 | ! ts_value_l = 0.0_wp |
---|
[555] | 143 | ! ts_value_l(dots_num_palm+1) = ABS( u_max ) |
---|
| 144 | ! ts_value_l(dots_num_palm+2) = ABS( v_max ) |
---|
[493] | 145 | ! |
---|
| 146 | !-- Collect / send values to PE0, because only PE0 outputs the time series. |
---|
| 147 | !-- CAUTION: Collection is done by taking the sum over all processors. |
---|
| 148 | !-- You may have to normalize this sum, depending on the quantity |
---|
| 149 | !-- that you like to calculate. For serial runs, nothing has to be |
---|
| 150 | !-- done. |
---|
| 151 | !-- HINT: If the time series value that you are calculating has the same |
---|
| 152 | !-- value on all PEs, you can omit the MPI_ALLREDUCE call and |
---|
| 153 | !-- assign ts_value(dots_num_palm+1:,sr) = ts_value_l directly. |
---|
[1804] | 154 | !#if defined( __parallel ) |
---|
[622] | 155 | ! IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[1320] | 156 | ! CALL MPI_ALLREDUCE( ts_value_l(dots_num_palm+1), & |
---|
| 157 | ! ts_value(dots_num_palm+1,sr), & |
---|
| 158 | ! dots_max-dots_num_palm, MPI_REAL, MPI_SUM, comm2d, & |
---|
[493] | 159 | ! ierr ) |
---|
| 160 | !#else |
---|
| 161 | ! ts_value(dots_num_palm+1:,sr) = ts_value_l |
---|
| 162 | !#endif |
---|
[211] | 163 | |
---|
| 164 | ENDIF |
---|
| 165 | |
---|
| 166 | END SUBROUTINE user_statistics |
---|
| 167 | |
---|