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