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