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