[1682] | 1 | !> @file data_output_profiles.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 | ! |
---|
[3655] | 17 | ! Copyright 1997-2019 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[254] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[2001] | 22 | ! |
---|
[2027] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: data_output_profiles.f90 4180 2019-08-21 14:37:54Z scharf $ |
---|
[3554] | 27 | ! add variable description |
---|
| 28 | ! |
---|
[1321] | 29 | ! |
---|
[1] | 30 | ! Description: |
---|
| 31 | ! ------------ |
---|
[1682] | 32 | !> Plot output of 1D-profiles for PROFIL |
---|
[1] | 33 | !------------------------------------------------------------------------------! |
---|
[1682] | 34 | SUBROUTINE data_output_profiles |
---|
| 35 | |
---|
[1] | 36 | |
---|
[1320] | 37 | USE control_parameters, & |
---|
| 38 | ONLY: average_count_pr, averaging_interval_pr, coupling_start_time, & |
---|
[1327] | 39 | dopr_n, dopr_time_count, normalizing_region, & |
---|
[1320] | 40 | time_since_reference_point |
---|
| 41 | |
---|
| 42 | USE cpulog, & |
---|
| 43 | ONLY: cpu_log, log_point |
---|
| 44 | |
---|
| 45 | USE indices, & |
---|
| 46 | ONLY: nzb, nzt |
---|
| 47 | |
---|
| 48 | USE kinds |
---|
| 49 | |
---|
[1783] | 50 | #if defined( __netcdf ) |
---|
| 51 | USE NETCDF |
---|
| 52 | #endif |
---|
[1320] | 53 | |
---|
[1783] | 54 | USE netcdf_interface, & |
---|
| 55 | ONLY: id_set_pr, id_var_dopr, id_var_norm_dopr, id_var_time_pr, & |
---|
| 56 | nc_stat, netcdf_handle_error, output_for_t0 |
---|
| 57 | |
---|
[1] | 58 | USE pegrid |
---|
[1320] | 59 | |
---|
[1] | 60 | USE profil_parameter |
---|
| 61 | |
---|
[1320] | 62 | USE statistics, & |
---|
| 63 | ONLY: flow_statistics_called, hom, hom_sum, pr_palm, statistic_regions |
---|
| 64 | |
---|
[1] | 65 | IMPLICIT NONE |
---|
| 66 | |
---|
| 67 | |
---|
[3554] | 68 | INTEGER(iwp) :: i !< loop index |
---|
| 69 | INTEGER(iwp) :: sr !< statistic region index |
---|
[1] | 70 | |
---|
| 71 | ! |
---|
| 72 | !-- If required, compute statistics |
---|
| 73 | IF ( .NOT. flow_statistics_called ) CALL flow_statistics |
---|
| 74 | |
---|
| 75 | ! |
---|
| 76 | !-- Flow_statistics has its own CPU time measurement |
---|
| 77 | CALL cpu_log( log_point(15), 'data_output_profiles', 'start' ) |
---|
| 78 | |
---|
| 79 | ! |
---|
| 80 | !-- If required, compute temporal average |
---|
[1353] | 81 | IF ( averaging_interval_pr == 0.0_wp ) THEN |
---|
[1] | 82 | hom_sum(:,:,:) = hom(:,1,:,:) |
---|
| 83 | ELSE |
---|
| 84 | IF ( average_count_pr > 0 ) THEN |
---|
[1322] | 85 | hom_sum = hom_sum / REAL( average_count_pr, KIND=wp ) |
---|
[1] | 86 | ELSE |
---|
| 87 | ! |
---|
[2932] | 88 | !-- This case may happen if dt_dopr is changed in the |
---|
| 89 | !-- runtime_parameters-list of a restart run |
---|
[1] | 90 | RETURN |
---|
| 91 | ENDIF |
---|
| 92 | ENDIF |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | IF ( myid == 0 ) THEN |
---|
| 96 | |
---|
| 97 | ! |
---|
| 98 | !-- Plot-output for each (sub-)region |
---|
| 99 | |
---|
| 100 | ! |
---|
| 101 | !-- Open file for profile output in NetCDF format |
---|
[1327] | 102 | CALL check_open( 104 ) |
---|
[1] | 103 | |
---|
| 104 | ! |
---|
| 105 | !-- Increment the counter for number of output times |
---|
| 106 | dopr_time_count = dopr_time_count + 1 |
---|
| 107 | |
---|
| 108 | ! |
---|
| 109 | !-- Output of initial profiles |
---|
| 110 | IF ( dopr_time_count == 1 ) THEN |
---|
[345] | 111 | |
---|
| 112 | IF ( .NOT. output_for_t0 ) THEN |
---|
[1] | 113 | |
---|
[345] | 114 | #if defined( __netcdf ) |
---|
[1] | 115 | ! |
---|
[1327] | 116 | !-- Store initial time to time axis, but only if an output |
---|
| 117 | !-- is required for at least one of the profiles. The initial time |
---|
| 118 | !-- is either 0, or, in case of a prerun for coupled atmosphere-ocean |
---|
| 119 | !-- runs, has a negative value |
---|
| 120 | DO i = 1, dopr_n |
---|
[2026] | 121 | IF ( dopr_initial_index(i) /= 0 ) THEN |
---|
| 122 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & |
---|
| 123 | (/ -coupling_start_time /), & |
---|
[1327] | 124 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 125 | CALL netcdf_handle_error( 'data_output_profiles', 329 ) |
---|
[1327] | 126 | output_for_t0 = .TRUE. |
---|
| 127 | EXIT |
---|
| 128 | ENDIF |
---|
| 129 | ENDDO |
---|
[1] | 130 | |
---|
| 131 | ! |
---|
[1327] | 132 | !-- Store normalization factors |
---|
| 133 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 |
---|
| 134 | (/ hom_sum(nzb,18,normalizing_region) /), & |
---|
| 135 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 136 | CALL netcdf_handle_error( 'data_output_profiles', 330 ) |
---|
[1] | 137 | |
---|
[1327] | 138 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 |
---|
| 139 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & |
---|
[1] | 140 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 141 | CALL netcdf_handle_error( 'data_output_profiles', 331 ) |
---|
[1327] | 142 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 |
---|
| 143 | (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 144 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 145 | CALL netcdf_handle_error( 'data_output_profiles', 332 ) |
---|
[1327] | 146 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 |
---|
| 147 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & |
---|
| 148 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 149 | CALL netcdf_handle_error( 'data_output_profiles', 333 ) |
---|
[1] | 150 | |
---|
[1327] | 151 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), &!ws2tsw |
---|
| 152 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & |
---|
| 153 | hom_sum(nzb+3,pr_palm,normalizing_region) /), & |
---|
| 154 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 155 | CALL netcdf_handle_error( 'data_output_profiles', 334 ) |
---|
[1] | 156 | |
---|
[1327] | 157 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), &!wstsw2 |
---|
| 158 | (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & |
---|
| 159 | hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 160 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 161 | CALL netcdf_handle_error( 'data_output_profiles', 335 ) |
---|
[1] | 162 | |
---|
[1327] | 163 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i |
---|
| 164 | (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & |
---|
| 165 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 166 | CALL netcdf_handle_error( 'data_output_profiles', 336 ) |
---|
[345] | 167 | |
---|
[1] | 168 | #endif |
---|
| 169 | ! |
---|
[345] | 170 | !-- Loop over all 1D variables |
---|
| 171 | DO i = 1, dopr_n |
---|
[1] | 172 | |
---|
[345] | 173 | IF ( dopr_initial_index(i) /= 0 ) THEN |
---|
[1] | 174 | |
---|
| 175 | ! |
---|
[345] | 176 | !-- Output for the individual (sub-)regions |
---|
| 177 | DO sr = 0, statistic_regions |
---|
[1] | 178 | |
---|
| 179 | #if defined( __netcdf ) |
---|
| 180 | ! |
---|
[1327] | 181 | !-- Write data to netcdf file |
---|
| 182 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & |
---|
| 183 | hom(nzb:nzt+1,1,dopr_initial_index(i),sr), & |
---|
| 184 | start = (/ 1, 1 /), & |
---|
| 185 | count = (/ nzt-nzb+2, 1 /) ) |
---|
[1783] | 186 | CALL netcdf_handle_error( 'data_output_profiles', 337 ) |
---|
[1] | 187 | #endif |
---|
| 188 | |
---|
[345] | 189 | ENDDO |
---|
[1] | 190 | |
---|
[345] | 191 | ENDIF ! Initial profile available |
---|
[1] | 192 | |
---|
[345] | 193 | ENDDO ! Loop over dopr_n for initial profiles |
---|
[1] | 194 | |
---|
[1327] | 195 | IF ( output_for_t0 ) THEN |
---|
[345] | 196 | dopr_time_count = dopr_time_count + 1 |
---|
| 197 | ENDIF |
---|
[1] | 198 | |
---|
[345] | 199 | END IF |
---|
[1] | 200 | ENDIF ! Initial profiles |
---|
| 201 | |
---|
| 202 | #if defined( __netcdf ) |
---|
[345] | 203 | |
---|
[1] | 204 | ! |
---|
[1327] | 205 | !-- Store time to time axis |
---|
| 206 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & |
---|
| 207 | (/ time_since_reference_point /), & |
---|
| 208 | start = (/ dopr_time_count /), & |
---|
| 209 | count = (/ 1 /) ) |
---|
[1783] | 210 | CALL netcdf_handle_error( 'data_output_profiles', 338 ) |
---|
[1] | 211 | |
---|
| 212 | ! |
---|
[1327] | 213 | !-- Store normalization factors |
---|
| 214 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 |
---|
| 215 | (/ hom_sum(nzb,18,normalizing_region) /), & |
---|
| 216 | start = (/ dopr_time_count /), & |
---|
| 217 | count = (/ 1 /) ) |
---|
[1783] | 218 | CALL netcdf_handle_error( 'data_output_profiles', 339 ) |
---|
[1] | 219 | |
---|
[1327] | 220 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 |
---|
| 221 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & |
---|
| 222 | start = (/ dopr_time_count /), & |
---|
| 223 | count = (/ 1 /) ) |
---|
[1783] | 224 | CALL netcdf_handle_error( 'data_output_profiles', 340 ) |
---|
[1] | 225 | |
---|
[1327] | 226 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 |
---|
| 227 | (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 228 | start = (/ dopr_time_count /), & |
---|
| 229 | count = (/ 1 /) ) |
---|
[1783] | 230 | CALL netcdf_handle_error( 'data_output_profiles', 341 ) |
---|
[1] | 231 | |
---|
[1327] | 232 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 |
---|
| 233 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & |
---|
| 234 | start = (/ dopr_time_count /), & |
---|
| 235 | count = (/ 1 /) ) |
---|
[1783] | 236 | CALL netcdf_handle_error( 'data_output_profiles', 342 ) |
---|
[1] | 237 | |
---|
[1327] | 238 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), & ! ws2tsw |
---|
| 239 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & |
---|
| 240 | hom_sum(nzb+3,pr_palm,normalizing_region) /), & |
---|
| 241 | start = (/ dopr_time_count /), & |
---|
| 242 | count = (/ 1 /) ) |
---|
[1783] | 243 | CALL netcdf_handle_error( 'data_output_profiles', 343 ) |
---|
[1] | 244 | |
---|
[1327] | 245 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), & ! wstsw2 |
---|
| 246 | (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & |
---|
| 247 | hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 248 | start = (/ dopr_time_count /), & |
---|
| 249 | count = (/ 1 /) ) |
---|
[1783] | 250 | CALL netcdf_handle_error( 'data_output_profiles', 344 ) |
---|
[1327] | 251 | |
---|
| 252 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i |
---|
| 253 | (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & |
---|
| 254 | start = (/ dopr_time_count /), & |
---|
| 255 | count = (/ 1 /) ) |
---|
[1783] | 256 | CALL netcdf_handle_error( 'data_output_profiles', 345 ) |
---|
[1] | 257 | #endif |
---|
| 258 | |
---|
| 259 | ! |
---|
| 260 | !-- Output of the individual (non-initial) profiles |
---|
| 261 | DO i = 1, dopr_n |
---|
| 262 | |
---|
| 263 | ! |
---|
| 264 | !-- Output for the individual (sub-)domains |
---|
| 265 | DO sr = 0, statistic_regions |
---|
| 266 | |
---|
| 267 | #if defined( __netcdf ) |
---|
| 268 | ! |
---|
[1327] | 269 | !-- Write data to netcdf file |
---|
| 270 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & |
---|
| 271 | hom_sum(nzb:nzt+1,dopr_index(i),sr),& |
---|
| 272 | start = (/ 1, dopr_time_count /), & |
---|
| 273 | count = (/ nzt-nzb+2, 1 /) ) |
---|
[1783] | 274 | CALL netcdf_handle_error( 'data_output_profiles', 346 ) |
---|
[1] | 275 | #endif |
---|
| 276 | |
---|
| 277 | ENDDO |
---|
| 278 | |
---|
[964] | 279 | ENDDO |
---|
[1] | 280 | |
---|
| 281 | ENDIF ! Output on PE0 |
---|
| 282 | |
---|
| 283 | ! |
---|
| 284 | !-- If averaging has been done above, the summation counter must be re-set. |
---|
[1353] | 285 | IF ( averaging_interval_pr /= 0.0_wp ) THEN |
---|
[1] | 286 | average_count_pr = 0 |
---|
| 287 | ENDIF |
---|
| 288 | |
---|
[1318] | 289 | CALL cpu_log( log_point(15), 'data_output_profiles','stop' ) |
---|
[1] | 290 | |
---|
| 291 | END SUBROUTINE data_output_profiles |
---|