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