[1682] | 1 | !> @file user_3d_data_averaging.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 | ! |
---|
[2718] | 17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[211] | 21 | ! ----------------- |
---|
[1354] | 22 | ! |
---|
[2001] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: user_3d_data_averaging.f90 3004 2018-04-27 12:33:25Z Giersch $ |
---|
[3004] | 27 | ! Further allocation checks implemented |
---|
| 28 | ! |
---|
| 29 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 30 | ! Corrected "Former revisions" section |
---|
| 31 | ! |
---|
| 32 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 33 | ! Change in file header (GPL part) |
---|
[1321] | 34 | ! |
---|
[2716] | 35 | ! 2101 2017-01-05 16:42:31Z suehring |
---|
| 36 | ! |
---|
[2001] | 37 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 38 | ! Forced header and separation lines into 80 columns |
---|
| 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 | ! |
---|
[1323] | 46 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 47 | ! REAL functions provided with KIND-attribute |
---|
| 48 | ! |
---|
[1321] | 49 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 50 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 51 | ! kinds are defined in new module kinds, |
---|
| 52 | ! revision history before 2012 removed, |
---|
| 53 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 54 | ! all variable declaration statements |
---|
[211] | 55 | ! |
---|
[1037] | 56 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 57 | ! code put under GPL (PALM 3.9) |
---|
| 58 | ! |
---|
[226] | 59 | ! 211 2008-11-11 04:46:24Z raasch |
---|
| 60 | ! Former file user_interface.f90 split into one file per subroutine |
---|
| 61 | ! |
---|
[211] | 62 | ! Description: |
---|
| 63 | ! ------------ |
---|
[1682] | 64 | !> Sum up and time-average user-defined output quantities as well as allocate |
---|
| 65 | !> the array necessary for storing the average. |
---|
[211] | 66 | !------------------------------------------------------------------------------! |
---|
[1682] | 67 | SUBROUTINE user_3d_data_averaging( mode, variable ) |
---|
| 68 | |
---|
[211] | 69 | |
---|
| 70 | USE control_parameters |
---|
[1320] | 71 | |
---|
[211] | 72 | USE indices |
---|
[1320] | 73 | |
---|
| 74 | USE kinds |
---|
| 75 | |
---|
[211] | 76 | USE user |
---|
| 77 | |
---|
| 78 | IMPLICIT NONE |
---|
| 79 | |
---|
[1682] | 80 | CHARACTER (LEN=*) :: mode !< |
---|
| 81 | CHARACTER (LEN=*) :: variable !< |
---|
[211] | 82 | |
---|
[1682] | 83 | INTEGER(iwp) :: i !< |
---|
| 84 | INTEGER(iwp) :: j !< |
---|
| 85 | INTEGER(iwp) :: k !< |
---|
[211] | 86 | |
---|
| 87 | IF ( mode == 'allocate' ) THEN |
---|
| 88 | |
---|
| 89 | SELECT CASE ( TRIM( variable ) ) |
---|
| 90 | |
---|
| 91 | ! |
---|
| 92 | !-- Uncomment and extend the following lines, if necessary. |
---|
| 93 | !-- The arrays for storing the user defined quantities (here u2_av) have |
---|
| 94 | !-- to be declared and defined by the user! |
---|
| 95 | !-- Sample for user-defined output: |
---|
| 96 | ! CASE ( 'u2' ) |
---|
| 97 | ! IF ( .NOT. ALLOCATED( u2_av ) ) THEN |
---|
[667] | 98 | ! ALLOCATE( u2_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
[211] | 99 | ! ENDIF |
---|
[1353] | 100 | ! u2_av = 0.0_wp |
---|
[211] | 101 | |
---|
| 102 | CASE DEFAULT |
---|
| 103 | CONTINUE |
---|
| 104 | |
---|
| 105 | END SELECT |
---|
| 106 | |
---|
| 107 | ELSEIF ( mode == 'sum' ) THEN |
---|
| 108 | |
---|
| 109 | SELECT CASE ( TRIM( variable ) ) |
---|
| 110 | |
---|
| 111 | ! |
---|
| 112 | !-- Uncomment and extend the following lines, if necessary. |
---|
| 113 | !-- The arrays for storing the user defined quantities (here u2 and |
---|
| 114 | !-- u2_av) have to be declared and defined by the user! |
---|
| 115 | !-- Sample for user-defined output: |
---|
| 116 | ! CASE ( 'u2' ) |
---|
[3004] | 117 | ! IF ( ALLOCATED( u2_av ) ) THEN |
---|
| 118 | ! DO i = nxlg, nxrg |
---|
| 119 | ! DO j = nysg, nyng |
---|
| 120 | ! DO k = nzb, nzt+1 |
---|
| 121 | ! u2_av(k,j,i) = u2_av(k,j,i) + u2(k,j,i) |
---|
| 122 | ! ENDDO |
---|
[211] | 123 | ! ENDDO |
---|
| 124 | ! ENDDO |
---|
[3004] | 125 | ! ENDIF |
---|
[211] | 126 | |
---|
| 127 | CASE DEFAULT |
---|
| 128 | CONTINUE |
---|
| 129 | |
---|
| 130 | END SELECT |
---|
| 131 | |
---|
| 132 | ELSEIF ( mode == 'average' ) THEN |
---|
| 133 | |
---|
| 134 | SELECT CASE ( TRIM( variable ) ) |
---|
| 135 | |
---|
| 136 | ! |
---|
| 137 | !-- Uncomment and extend the following lines, if necessary. |
---|
| 138 | !-- The arrays for storing the user defined quantities (here u2_av) have |
---|
| 139 | !-- to be declared and defined by the user! |
---|
| 140 | !-- Sample for user-defined output: |
---|
| 141 | ! CASE ( 'u2' ) |
---|
[3004] | 142 | ! IF ( ALLOCATED( u2_av ) ) THEN |
---|
| 143 | ! DO i = nxlg, nxrg |
---|
| 144 | ! DO j = nysg, nyng |
---|
| 145 | ! DO k = nzb, nzt+1 |
---|
| 146 | ! u2_av(k,j,i) = u2_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
| 147 | ! ENDDO |
---|
[211] | 148 | ! ENDDO |
---|
| 149 | ! ENDDO |
---|
[3004] | 150 | ! ENDIF |
---|
[211] | 151 | |
---|
| 152 | END SELECT |
---|
| 153 | |
---|
| 154 | ENDIF |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | END SUBROUTINE user_3d_data_averaging |
---|