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