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