[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 | ! ----------------- |
---|
[1783] | 21 | ! name change of netcdf routines and module + related changes |
---|
[1329] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: data_output_profiles.f90 1783 2016-03-06 18:36:17Z raasch $ |
---|
| 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 | |
---|
[1783] | 88 | #if defined( __netcdf ) |
---|
| 89 | USE NETCDF |
---|
| 90 | #endif |
---|
[1320] | 91 | |
---|
[1783] | 92 | USE netcdf_interface, & |
---|
| 93 | ONLY: id_set_pr, id_var_dopr, id_var_norm_dopr, id_var_time_pr, & |
---|
| 94 | nc_stat, netcdf_handle_error, output_for_t0 |
---|
| 95 | |
---|
[1] | 96 | USE pegrid |
---|
[1320] | 97 | |
---|
[1] | 98 | USE profil_parameter |
---|
| 99 | |
---|
[1320] | 100 | USE statistics, & |
---|
| 101 | ONLY: flow_statistics_called, hom, hom_sum, pr_palm, statistic_regions |
---|
| 102 | |
---|
[1] | 103 | IMPLICIT NONE |
---|
| 104 | |
---|
| 105 | |
---|
[1682] | 106 | INTEGER(iwp) :: i !< |
---|
| 107 | INTEGER(iwp) :: sr !< |
---|
[1] | 108 | |
---|
| 109 | ! |
---|
| 110 | !-- If required, compute statistics |
---|
| 111 | IF ( .NOT. flow_statistics_called ) CALL flow_statistics |
---|
| 112 | |
---|
| 113 | ! |
---|
| 114 | !-- Flow_statistics has its own CPU time measurement |
---|
| 115 | CALL cpu_log( log_point(15), 'data_output_profiles', 'start' ) |
---|
| 116 | |
---|
| 117 | ! |
---|
| 118 | !-- If required, compute temporal average |
---|
[1353] | 119 | IF ( averaging_interval_pr == 0.0_wp ) THEN |
---|
[1] | 120 | hom_sum(:,:,:) = hom(:,1,:,:) |
---|
| 121 | ELSE |
---|
| 122 | IF ( average_count_pr > 0 ) THEN |
---|
[1322] | 123 | hom_sum = hom_sum / REAL( average_count_pr, KIND=wp ) |
---|
[1] | 124 | ELSE |
---|
| 125 | ! |
---|
| 126 | !-- This case may happen if dt_dopr is changed in the d3par-list of |
---|
| 127 | !-- a restart run |
---|
| 128 | RETURN |
---|
| 129 | ENDIF |
---|
| 130 | ENDIF |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | IF ( myid == 0 ) THEN |
---|
| 134 | |
---|
| 135 | ! |
---|
| 136 | !-- Plot-output for each (sub-)region |
---|
| 137 | |
---|
| 138 | ! |
---|
| 139 | !-- Open file for profile output in NetCDF format |
---|
[1327] | 140 | CALL check_open( 104 ) |
---|
[1] | 141 | |
---|
| 142 | ! |
---|
| 143 | !-- Increment the counter for number of output times |
---|
| 144 | dopr_time_count = dopr_time_count + 1 |
---|
| 145 | |
---|
| 146 | ! |
---|
| 147 | !-- Output of initial profiles |
---|
| 148 | IF ( dopr_time_count == 1 ) THEN |
---|
[345] | 149 | |
---|
| 150 | IF ( .NOT. output_for_t0 ) THEN |
---|
[1] | 151 | |
---|
[345] | 152 | #if defined( __netcdf ) |
---|
[1] | 153 | ! |
---|
[1327] | 154 | !-- Store initial time to time axis, but only if an output |
---|
| 155 | !-- is required for at least one of the profiles. The initial time |
---|
| 156 | !-- is either 0, or, in case of a prerun for coupled atmosphere-ocean |
---|
| 157 | !-- runs, has a negative value |
---|
| 158 | DO i = 1, dopr_n |
---|
| 159 | IF ( dopr_initial_index(i) /= 0 ) THEN |
---|
| 160 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & |
---|
| 161 | (/ -coupling_start_time /), & |
---|
| 162 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 163 | CALL netcdf_handle_error( 'data_output_profiles', 329 ) |
---|
[1327] | 164 | output_for_t0 = .TRUE. |
---|
| 165 | EXIT |
---|
| 166 | ENDIF |
---|
| 167 | ENDDO |
---|
[1] | 168 | |
---|
| 169 | ! |
---|
[1327] | 170 | !-- Store normalization factors |
---|
| 171 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 |
---|
| 172 | (/ hom_sum(nzb,18,normalizing_region) /), & |
---|
| 173 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 174 | CALL netcdf_handle_error( 'data_output_profiles', 330 ) |
---|
[1] | 175 | |
---|
[1327] | 176 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 |
---|
| 177 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & |
---|
[1] | 178 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 179 | CALL netcdf_handle_error( 'data_output_profiles', 331 ) |
---|
[1327] | 180 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 |
---|
| 181 | (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 182 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 183 | CALL netcdf_handle_error( 'data_output_profiles', 332 ) |
---|
[1327] | 184 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 |
---|
| 185 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & |
---|
| 186 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 187 | CALL netcdf_handle_error( 'data_output_profiles', 333 ) |
---|
[1] | 188 | |
---|
[1327] | 189 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), &!ws2tsw |
---|
| 190 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & |
---|
| 191 | hom_sum(nzb+3,pr_palm,normalizing_region) /), & |
---|
| 192 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 193 | CALL netcdf_handle_error( 'data_output_profiles', 334 ) |
---|
[1] | 194 | |
---|
[1327] | 195 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), &!wstsw2 |
---|
| 196 | (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & |
---|
| 197 | hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 198 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 199 | CALL netcdf_handle_error( 'data_output_profiles', 335 ) |
---|
[1] | 200 | |
---|
[1327] | 201 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i |
---|
| 202 | (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & |
---|
| 203 | start = (/ 1 /), count = (/ 1 /) ) |
---|
[1783] | 204 | CALL netcdf_handle_error( 'data_output_profiles', 336 ) |
---|
[345] | 205 | |
---|
[1] | 206 | #endif |
---|
| 207 | ! |
---|
[345] | 208 | !-- Loop over all 1D variables |
---|
| 209 | DO i = 1, dopr_n |
---|
[1] | 210 | |
---|
[345] | 211 | IF ( dopr_initial_index(i) /= 0 ) THEN |
---|
[1] | 212 | |
---|
| 213 | ! |
---|
[345] | 214 | !-- Output for the individual (sub-)regions |
---|
| 215 | DO sr = 0, statistic_regions |
---|
[1] | 216 | |
---|
| 217 | #if defined( __netcdf ) |
---|
| 218 | ! |
---|
[1327] | 219 | !-- Write data to netcdf file |
---|
| 220 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & |
---|
| 221 | hom(nzb:nzt+1,1,dopr_initial_index(i),sr), & |
---|
| 222 | start = (/ 1, 1 /), & |
---|
| 223 | count = (/ nzt-nzb+2, 1 /) ) |
---|
[1783] | 224 | CALL netcdf_handle_error( 'data_output_profiles', 337 ) |
---|
[1] | 225 | #endif |
---|
| 226 | |
---|
[345] | 227 | ENDDO |
---|
[1] | 228 | |
---|
[345] | 229 | ENDIF ! Initial profile available |
---|
[1] | 230 | |
---|
[345] | 231 | ENDDO ! Loop over dopr_n for initial profiles |
---|
[1] | 232 | |
---|
[1327] | 233 | IF ( output_for_t0 ) THEN |
---|
[345] | 234 | dopr_time_count = dopr_time_count + 1 |
---|
| 235 | ENDIF |
---|
[1] | 236 | |
---|
[345] | 237 | END IF |
---|
[1] | 238 | ENDIF ! Initial profiles |
---|
| 239 | |
---|
| 240 | #if defined( __netcdf ) |
---|
[345] | 241 | |
---|
[1] | 242 | ! |
---|
[1327] | 243 | !-- Store time to time axis |
---|
| 244 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_time_pr, & |
---|
| 245 | (/ time_since_reference_point /), & |
---|
| 246 | start = (/ dopr_time_count /), & |
---|
| 247 | count = (/ 1 /) ) |
---|
[1783] | 248 | CALL netcdf_handle_error( 'data_output_profiles', 338 ) |
---|
[1] | 249 | |
---|
| 250 | ! |
---|
[1327] | 251 | !-- Store normalization factors |
---|
| 252 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(1), & ! wpt0 |
---|
| 253 | (/ hom_sum(nzb,18,normalizing_region) /), & |
---|
| 254 | start = (/ dopr_time_count /), & |
---|
| 255 | count = (/ 1 /) ) |
---|
[1783] | 256 | CALL netcdf_handle_error( 'data_output_profiles', 339 ) |
---|
[1] | 257 | |
---|
[1327] | 258 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(2), & ! ws2 |
---|
| 259 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**2 /), & |
---|
| 260 | start = (/ dopr_time_count /), & |
---|
| 261 | count = (/ 1 /) ) |
---|
[1783] | 262 | CALL netcdf_handle_error( 'data_output_profiles', 340 ) |
---|
[1] | 263 | |
---|
[1327] | 264 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(3), & ! tsw2 |
---|
| 265 | (/ hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 266 | start = (/ dopr_time_count /), & |
---|
| 267 | count = (/ 1 /) ) |
---|
[1783] | 268 | CALL netcdf_handle_error( 'data_output_profiles', 341 ) |
---|
[1] | 269 | |
---|
[1327] | 270 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(4), & ! ws3 |
---|
| 271 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 /), & |
---|
| 272 | start = (/ dopr_time_count /), & |
---|
| 273 | count = (/ 1 /) ) |
---|
[1783] | 274 | CALL netcdf_handle_error( 'data_output_profiles', 342 ) |
---|
[1] | 275 | |
---|
[1327] | 276 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(5), & ! ws2tsw |
---|
| 277 | (/ hom_sum(nzb+8,pr_palm,normalizing_region)**3 * & |
---|
| 278 | hom_sum(nzb+3,pr_palm,normalizing_region) /), & |
---|
| 279 | start = (/ dopr_time_count /), & |
---|
| 280 | count = (/ 1 /) ) |
---|
[1783] | 281 | CALL netcdf_handle_error( 'data_output_profiles', 343 ) |
---|
[1] | 282 | |
---|
[1327] | 283 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(6), & ! wstsw2 |
---|
| 284 | (/ hom_sum(nzb+8,pr_palm,normalizing_region) * & |
---|
| 285 | hom_sum(nzb+3,pr_palm,normalizing_region)**2 /), & |
---|
| 286 | start = (/ dopr_time_count /), & |
---|
| 287 | count = (/ 1 /) ) |
---|
[1783] | 288 | CALL netcdf_handle_error( 'data_output_profiles', 344 ) |
---|
[1327] | 289 | |
---|
| 290 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_norm_dopr(7), & ! z_i |
---|
| 291 | (/ hom_sum(nzb+6,pr_palm,normalizing_region) /), & |
---|
| 292 | start = (/ dopr_time_count /), & |
---|
| 293 | count = (/ 1 /) ) |
---|
[1783] | 294 | CALL netcdf_handle_error( 'data_output_profiles', 345 ) |
---|
[1] | 295 | #endif |
---|
| 296 | |
---|
| 297 | ! |
---|
| 298 | !-- Output of the individual (non-initial) profiles |
---|
| 299 | DO i = 1, dopr_n |
---|
| 300 | |
---|
| 301 | ! |
---|
| 302 | !-- Output for the individual (sub-)domains |
---|
| 303 | DO sr = 0, statistic_regions |
---|
| 304 | |
---|
| 305 | #if defined( __netcdf ) |
---|
| 306 | ! |
---|
[1327] | 307 | !-- Write data to netcdf file |
---|
| 308 | nc_stat = NF90_PUT_VAR( id_set_pr, id_var_dopr(i,sr), & |
---|
| 309 | hom_sum(nzb:nzt+1,dopr_index(i),sr),& |
---|
| 310 | start = (/ 1, dopr_time_count /), & |
---|
| 311 | count = (/ nzt-nzb+2, 1 /) ) |
---|
[1783] | 312 | CALL netcdf_handle_error( 'data_output_profiles', 346 ) |
---|
[1] | 313 | #endif |
---|
| 314 | |
---|
| 315 | ENDDO |
---|
| 316 | |
---|
[964] | 317 | ENDDO |
---|
[1] | 318 | |
---|
| 319 | ENDIF ! Output on PE0 |
---|
| 320 | |
---|
| 321 | ! |
---|
| 322 | !-- If averaging has been done above, the summation counter must be re-set. |
---|
[1353] | 323 | IF ( averaging_interval_pr /= 0.0_wp ) THEN |
---|
[1] | 324 | average_count_pr = 0 |
---|
| 325 | ENDIF |
---|
| 326 | |
---|
[1318] | 327 | CALL cpu_log( log_point(15), 'data_output_profiles','stop' ) |
---|
[1] | 328 | |
---|
| 329 | ! |
---|
| 330 | !-- Formats |
---|
| 331 | 100 FORMAT ('#1 ',A,1X,A) |
---|
| 332 | 101 FORMAT (E15.7,1X,E15.7) |
---|
| 333 | 102 FORMAT ('NEXT') |
---|
| 334 | |
---|
| 335 | END SUBROUTINE data_output_profiles |
---|