[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 3655 2019-01-07 16:51:22Z knoop $ |
---|
[3554] | 27 | ! add variable description |
---|
| 28 | ! |
---|
| 29 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
[3241] | 30 | ! unused format statements removed |
---|
| 31 | ! |
---|
| 32 | ! 2932 2018-03-26 09:39:22Z maronga |
---|
[2932] | 33 | ! renamed d3par to runtime_parameters |
---|
| 34 | ! |
---|
| 35 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 36 | ! Corrected "Former revisions" section |
---|
| 37 | ! |
---|
| 38 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 39 | ! Change in file header (GPL part) |
---|
[1321] | 40 | ! |
---|
[2716] | 41 | ! 2101 2017-01-05 16:42:31Z suehring |
---|
| 42 | ! |
---|
[2027] | 43 | ! 2026 2016-10-18 10:27:02Z suehring |
---|
| 44 | ! Formatting adjustment |
---|
| 45 | ! |
---|
[2001] | 46 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 47 | ! Forced header and separation lines into 80 columns |
---|
| 48 | ! |
---|
[1784] | 49 | ! 1783 2016-03-06 18:36:17Z raasch |
---|
| 50 | ! name change of netcdf routines and module + related changes |
---|
| 51 | ! |
---|
[1683] | 52 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 53 | ! Code annotations made doxygen readable |
---|
| 54 | ! |
---|
[1354] | 55 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 56 | ! REAL constants provided with KIND-attribute |
---|
| 57 | ! |
---|
[1329] | 58 | ! 1327 2014-03-21 11:00:16Z raasch |
---|
| 59 | ! -netcdf output queries |
---|
| 60 | ! |
---|
[1323] | 61 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 62 | ! REAL functions provided with KIND-attribute |
---|
| 63 | ! |
---|
[1321] | 64 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 65 | ! ONLY-attribute added to USE-statements, |
---|
| 66 | ! kind-parameters added to all INTEGER declaration statements, |
---|
| 67 | ! kinds are defined in new module kinds, |
---|
| 68 | ! revision history before 2012 removed, |
---|
| 69 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 70 | ! all variable declaration statements |
---|
[392] | 71 | ! |
---|
[1319] | 72 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 73 | ! barrier argument removed from cpu_log, |
---|
| 74 | ! module interfaces removed |
---|
| 75 | ! |
---|
[1107] | 76 | ! 1106 2013-03-04 05:31:38Z raasch |
---|
| 77 | ! bugfix: initial time for preruns of coupled runs is output as |
---|
| 78 | ! -coupling_start_time |
---|
| 79 | ! |
---|
[1093] | 80 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 81 | ! unused variables removed |
---|
| 82 | ! |
---|
[1037] | 83 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 84 | ! code put under GPL (PALM 3.9) |
---|
| 85 | ! |
---|
[965] | 86 | ! 964 2012-07-26 09:14:24Z raasch |
---|
| 87 | ! code for profil-output removed |
---|
| 88 | ! |
---|
[1] | 89 | ! Revision 1.1 1997/09/12 06:28:48 raasch |
---|
| 90 | ! Initial revision |
---|
| 91 | ! |
---|
| 92 | ! |
---|
| 93 | ! Description: |
---|
| 94 | ! ------------ |
---|
[1682] | 95 | !> Plot output of 1D-profiles for PROFIL |
---|
[1] | 96 | !------------------------------------------------------------------------------! |
---|
[1682] | 97 | SUBROUTINE data_output_profiles |
---|
| 98 | |
---|
[1] | 99 | |
---|
[1320] | 100 | USE control_parameters, & |
---|
| 101 | ONLY: average_count_pr, averaging_interval_pr, coupling_start_time, & |
---|
[1327] | 102 | dopr_n, dopr_time_count, normalizing_region, & |
---|
[1320] | 103 | time_since_reference_point |
---|
| 104 | |
---|
| 105 | USE cpulog, & |
---|
| 106 | ONLY: cpu_log, log_point |
---|
| 107 | |
---|
| 108 | USE indices, & |
---|
| 109 | ONLY: nzb, nzt |
---|
| 110 | |
---|
| 111 | USE kinds |
---|
| 112 | |
---|
[1783] | 113 | #if defined( __netcdf ) |
---|
| 114 | USE NETCDF |
---|
| 115 | #endif |
---|
[1320] | 116 | |
---|
[1783] | 117 | USE netcdf_interface, & |
---|
| 118 | ONLY: id_set_pr, id_var_dopr, id_var_norm_dopr, id_var_time_pr, & |
---|
| 119 | nc_stat, netcdf_handle_error, output_for_t0 |
---|
| 120 | |
---|
[1] | 121 | USE pegrid |
---|
[1320] | 122 | |
---|
[1] | 123 | USE profil_parameter |
---|
| 124 | |
---|
[1320] | 125 | USE statistics, & |
---|
| 126 | ONLY: flow_statistics_called, hom, hom_sum, pr_palm, statistic_regions |
---|
| 127 | |
---|
[1] | 128 | IMPLICIT NONE |
---|
| 129 | |
---|
| 130 | |
---|
[3554] | 131 | INTEGER(iwp) :: i !< loop index |
---|
| 132 | INTEGER(iwp) :: sr !< statistic region index |
---|
[1] | 133 | |
---|
| 134 | ! |
---|
| 135 | !-- If required, compute statistics |
---|
| 136 | IF ( .NOT. flow_statistics_called ) CALL flow_statistics |
---|
| 137 | |
---|
| 138 | ! |
---|
| 139 | !-- Flow_statistics has its own CPU time measurement |
---|
| 140 | CALL cpu_log( log_point(15), 'data_output_profiles', 'start' ) |
---|
| 141 | |
---|
| 142 | ! |
---|
| 143 | !-- If required, compute temporal average |
---|
[1353] | 144 | IF ( averaging_interval_pr == 0.0_wp ) THEN |
---|
[1] | 145 | hom_sum(:,:,:) = hom(:,1,:,:) |
---|
| 146 | ELSE |
---|
| 147 | IF ( average_count_pr > 0 ) THEN |
---|
[1322] | 148 | hom_sum = hom_sum / REAL( average_count_pr, KIND=wp ) |
---|
[1] | 149 | ELSE |
---|
| 150 | ! |
---|
[2932] | 151 | !-- This case may happen if dt_dopr is changed in the |
---|
| 152 | !-- runtime_parameters-list of a restart run |
---|
[1] | 153 | RETURN |
---|
| 154 | ENDIF |
---|
| 155 | ENDIF |
---|
| 156 | |
---|
| 157 | |
---|
| 158 | IF ( myid == 0 ) THEN |
---|
| 159 | |
---|
| 160 | ! |
---|
| 161 | !-- Plot-output for each (sub-)region |
---|
| 162 | |
---|
| 163 | ! |
---|
| 164 | !-- Open file for profile output in NetCDF format |
---|
[1327] | 165 | CALL check_open( 104 ) |
---|
[1] | 166 | |
---|
| 167 | ! |
---|
| 168 | !-- Increment the counter for number of output times |
---|
| 169 | dopr_time_count = dopr_time_count + 1 |
---|
| 170 | |
---|
| 171 | ! |
---|
| 172 | !-- Output of initial profiles |
---|
| 173 | IF ( dopr_time_count == 1 ) THEN |
---|
[345] | 174 | |
---|
| 175 | IF ( .NOT. output_for_t0 ) THEN |
---|
[1] | 176 | |
---|
[345] | 177 | #if defined( __netcdf ) |
---|
[1] | 178 | ! |
---|
[1327] | 179 | !-- Store initial time to time axis, but only if an output |
---|
| 180 | !-- is required for at least one of the profiles. The initial time |
---|
| 181 | !-- is either 0, or, in case of a prerun for coupled atmosphere-ocean |
---|
| 182 | !-- runs, has a negative value |
---|
| 183 | DO i = 1, dopr_n |
---|
[2026] | 184 | IF ( dopr_initial_index(i) /= 0 ) THEN |
---|
| 185 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & |
---|
| 186 | (/ -coupling_start_time /), & |
---|
[1327] | 187 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 188 | CALL netcdf_handle_error( 'data_output_profiles', 329 ) |
---|
[1327] | 189 | output_for_t0 = .TRUE. |
---|
| 190 | EXIT |
---|
| 191 | ENDIF |
---|
| 192 | ENDDO |
---|
[1] | 193 | |
---|
| 194 | ! |
---|
[1327] | 195 | !-- Store normalization factors |
---|
| 196 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 |
---|
| 197 | (/ hom_sum(nzb,18,normalizing_region) /), & |
---|
| 198 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 199 | CALL netcdf_handle_error( 'data_output_profiles', 330 ) |
---|
[1] | 200 | |
---|
[1327] | 201 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 |
---|
| 202 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & |
---|
[1] | 203 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 204 | CALL netcdf_handle_error( 'data_output_profiles', 331 ) |
---|
[1327] | 205 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 |
---|
| 206 | (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 207 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 208 | CALL netcdf_handle_error( 'data_output_profiles', 332 ) |
---|
[1327] | 209 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 |
---|
| 210 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & |
---|
| 211 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 212 | CALL netcdf_handle_error( 'data_output_profiles', 333 ) |
---|
[1] | 213 | |
---|
[1327] | 214 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), &!ws2tsw |
---|
| 215 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & |
---|
| 216 | hom_sum(nzb+3,pr_palm,normalizing_region) /), & |
---|
| 217 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 218 | CALL netcdf_handle_error( 'data_output_profiles', 334 ) |
---|
[1] | 219 | |
---|
[1327] | 220 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), &!wstsw2 |
---|
| 221 | (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & |
---|
| 222 | hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 223 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 224 | CALL netcdf_handle_error( 'data_output_profiles', 335 ) |
---|
[1] | 225 | |
---|
[1327] | 226 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i |
---|
| 227 | (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & |
---|
| 228 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 229 | CALL netcdf_handle_error( 'data_output_profiles', 336 ) |
---|
[345] | 230 | |
---|
[1] | 231 | #endif |
---|
| 232 | ! |
---|
[345] | 233 | !-- Loop over all 1D variables |
---|
| 234 | DO i = 1, dopr_n |
---|
[1] | 235 | |
---|
[345] | 236 | IF ( dopr_initial_index(i) /= 0 ) THEN |
---|
[1] | 237 | |
---|
| 238 | ! |
---|
[345] | 239 | !-- Output for the individual (sub-)regions |
---|
| 240 | DO sr = 0, statistic_regions |
---|
[1] | 241 | |
---|
| 242 | #if defined( __netcdf ) |
---|
| 243 | ! |
---|
[1327] | 244 | !-- Write data to netcdf file |
---|
| 245 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & |
---|
| 246 | hom(nzb:nzt+1,1,dopr_initial_index(i),sr), & |
---|
| 247 | start = (/ 1, 1 /), & |
---|
| 248 | count = (/ nzt-nzb+2, 1 /) ) |
---|
[1783] | 249 | CALL netcdf_handle_error( 'data_output_profiles', 337 ) |
---|
[1] | 250 | #endif |
---|
| 251 | |
---|
[345] | 252 | ENDDO |
---|
[1] | 253 | |
---|
[345] | 254 | ENDIF ! Initial profile available |
---|
[1] | 255 | |
---|
[345] | 256 | ENDDO ! Loop over dopr_n for initial profiles |
---|
[1] | 257 | |
---|
[1327] | 258 | IF ( output_for_t0 ) THEN |
---|
[345] | 259 | dopr_time_count = dopr_time_count + 1 |
---|
| 260 | ENDIF |
---|
[1] | 261 | |
---|
[345] | 262 | END IF |
---|
[1] | 263 | ENDIF ! Initial profiles |
---|
| 264 | |
---|
| 265 | #if defined( __netcdf ) |
---|
[345] | 266 | |
---|
[1] | 267 | ! |
---|
[1327] | 268 | !-- Store time to time axis |
---|
| 269 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & |
---|
| 270 | (/ time_since_reference_point /), & |
---|
| 271 | start = (/ dopr_time_count /), & |
---|
| 272 | count = (/ 1 /) ) |
---|
[1783] | 273 | CALL netcdf_handle_error( 'data_output_profiles', 338 ) |
---|
[1] | 274 | |
---|
| 275 | ! |
---|
[1327] | 276 | !-- Store normalization factors |
---|
| 277 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 |
---|
| 278 | (/ hom_sum(nzb,18,normalizing_region) /), & |
---|
| 279 | start = (/ dopr_time_count /), & |
---|
| 280 | count = (/ 1 /) ) |
---|
[1783] | 281 | CALL netcdf_handle_error( 'data_output_profiles', 339 ) |
---|
[1] | 282 | |
---|
[1327] | 283 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 |
---|
| 284 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & |
---|
| 285 | start = (/ dopr_time_count /), & |
---|
| 286 | count = (/ 1 /) ) |
---|
[1783] | 287 | CALL netcdf_handle_error( 'data_output_profiles', 340 ) |
---|
[1] | 288 | |
---|
[1327] | 289 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 |
---|
| 290 | (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 291 | start = (/ dopr_time_count /), & |
---|
| 292 | count = (/ 1 /) ) |
---|
[1783] | 293 | CALL netcdf_handle_error( 'data_output_profiles', 341 ) |
---|
[1] | 294 | |
---|
[1327] | 295 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 |
---|
| 296 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & |
---|
| 297 | start = (/ dopr_time_count /), & |
---|
| 298 | count = (/ 1 /) ) |
---|
[1783] | 299 | CALL netcdf_handle_error( 'data_output_profiles', 342 ) |
---|
[1] | 300 | |
---|
[1327] | 301 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), & ! ws2tsw |
---|
| 302 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & |
---|
| 303 | hom_sum(nzb+3,pr_palm,normalizing_region) /), & |
---|
| 304 | start = (/ dopr_time_count /), & |
---|
| 305 | count = (/ 1 /) ) |
---|
[1783] | 306 | CALL netcdf_handle_error( 'data_output_profiles', 343 ) |
---|
[1] | 307 | |
---|
[1327] | 308 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), & ! wstsw2 |
---|
| 309 | (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & |
---|
| 310 | hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 311 | start = (/ dopr_time_count /), & |
---|
| 312 | count = (/ 1 /) ) |
---|
[1783] | 313 | CALL netcdf_handle_error( 'data_output_profiles', 344 ) |
---|
[1327] | 314 | |
---|
| 315 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i |
---|
| 316 | (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & |
---|
| 317 | start = (/ dopr_time_count /), & |
---|
| 318 | count = (/ 1 /) ) |
---|
[1783] | 319 | CALL netcdf_handle_error( 'data_output_profiles', 345 ) |
---|
[1] | 320 | #endif |
---|
| 321 | |
---|
| 322 | ! |
---|
| 323 | !-- Output of the individual (non-initial) profiles |
---|
| 324 | DO i = 1, dopr_n |
---|
| 325 | |
---|
| 326 | ! |
---|
| 327 | !-- Output for the individual (sub-)domains |
---|
| 328 | DO sr = 0, statistic_regions |
---|
| 329 | |
---|
| 330 | #if defined( __netcdf ) |
---|
| 331 | ! |
---|
[1327] | 332 | !-- Write data to netcdf file |
---|
| 333 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & |
---|
| 334 | hom_sum(nzb:nzt+1,dopr_index(i),sr),& |
---|
| 335 | start = (/ 1, dopr_time_count /), & |
---|
| 336 | count = (/ nzt-nzb+2, 1 /) ) |
---|
[1783] | 337 | CALL netcdf_handle_error( 'data_output_profiles', 346 ) |
---|
[1] | 338 | #endif |
---|
| 339 | |
---|
| 340 | ENDDO |
---|
| 341 | |
---|
[964] | 342 | ENDDO |
---|
[1] | 343 | |
---|
| 344 | ENDIF ! Output on PE0 |
---|
| 345 | |
---|
| 346 | ! |
---|
| 347 | !-- If averaging has been done above, the summation counter must be re-set. |
---|
[1353] | 348 | IF ( averaging_interval_pr /= 0.0_wp ) THEN |
---|
[1] | 349 | average_count_pr = 0 |
---|
| 350 | ENDIF |
---|
| 351 | |
---|
[1318] | 352 | CALL cpu_log( log_point(15), 'data_output_profiles','stop' ) |
---|
[1] | 353 | |
---|
| 354 | END SUBROUTINE data_output_profiles |
---|