[1682] | 1 | !> @file lpm_data_output_particles.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 | ! |
---|
[3655] | 17 | ! Copyright 1997-2019 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[849] | 20 | ! Current revisions: |
---|
| 21 | ! ------------------ |
---|
[2001] | 22 | ! |
---|
[2716] | 23 | ! |
---|
[849] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: lpm_data_output_particles.f90 3655 2019-01-07 16:51:22Z suehring $ |
---|
[2716] | 27 | ! Corrected "Former revisions" section |
---|
| 28 | ! |
---|
| 29 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 30 | ! Change in file header (GPL part) |
---|
[849] | 31 | ! |
---|
[2716] | 32 | ! 2123 2017-01-18 12:34:59Z hoffmann |
---|
| 33 | ! |
---|
[2123] | 34 | ! 2122 2017-01-18 12:22:54Z hoffmann |
---|
| 35 | ! Calculation of particle ID |
---|
| 36 | ! |
---|
[2001] | 37 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 38 | ! Forced header and separation lines into 80 columns |
---|
| 39 | ! |
---|
[1823] | 40 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 41 | ! Tails removed. Unused variables removed. |
---|
| 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 | ! |
---|
[1360] | 49 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
| 50 | ! netCDF output currently not available |
---|
| 51 | ! output of particle data in binary format adopted to new particle structure |
---|
| 52 | ! |
---|
[1329] | 53 | ! 1327 2014-03-21 11:00:16Z raasch |
---|
| 54 | ! -netcdf output queries |
---|
| 55 | ! |
---|
[1321] | 56 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
| 57 | ! ONLY-attribute added to USE-statements, |
---|
| 58 | ! revision history before 2012 removed |
---|
| 59 | ! |
---|
[1037] | 60 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 61 | ! code put under GPL (PALM 3.9) |
---|
| 62 | ! |
---|
[850] | 63 | ! 849 2012-03-15 10:35:09Z raasch |
---|
| 64 | ! initial revision (former part of advec_particles) |
---|
| 65 | ! |
---|
[849] | 66 | ! 22/02/12 - Initial version |
---|
| 67 | ! |
---|
| 68 | ! Description: |
---|
| 69 | ! ------------ |
---|
[1682] | 70 | !> Write particle data in FORTRAN binary and/or netCDF format |
---|
[849] | 71 | !------------------------------------------------------------------------------! |
---|
[1682] | 72 | SUBROUTINE lpm_data_output_particles |
---|
| 73 | |
---|
[849] | 74 | |
---|
[1320] | 75 | USE control_parameters, & |
---|
[1822] | 76 | ONLY: simulated_time |
---|
[1320] | 77 | |
---|
| 78 | USE cpulog, & |
---|
| 79 | ONLY: cpu_log, log_point_s |
---|
| 80 | |
---|
[1359] | 81 | USE indices, & |
---|
| 82 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
| 83 | |
---|
| 84 | USE kinds |
---|
| 85 | |
---|
[1320] | 86 | USE particle_attributes, & |
---|
[1822] | 87 | ONLY: grid_particles, number_of_particles, particles, prt_count |
---|
[1320] | 88 | |
---|
[849] | 89 | IMPLICIT NONE |
---|
| 90 | |
---|
[1682] | 91 | INTEGER(iwp) :: ip !< |
---|
| 92 | INTEGER(iwp) :: jp !< |
---|
| 93 | INTEGER(iwp) :: kp !< |
---|
[849] | 94 | |
---|
| 95 | CALL cpu_log( log_point_s(40), 'lpm_data_output', 'start' ) |
---|
| 96 | |
---|
| 97 | ! |
---|
| 98 | !-- Attention: change version number for unit 85 (in routine check_open) |
---|
| 99 | !-- whenever the output format for this unit is changed! |
---|
| 100 | CALL check_open( 85 ) |
---|
| 101 | |
---|
[1359] | 102 | WRITE ( 85 ) simulated_time |
---|
| 103 | WRITE ( 85 ) prt_count |
---|
| 104 | |
---|
| 105 | DO ip = nxl, nxr |
---|
| 106 | DO jp = nys, nyn |
---|
| 107 | DO kp = nzb+1, nzt |
---|
| 108 | number_of_particles = prt_count(kp,jp,ip) |
---|
| 109 | particles => grid_particles(kp,jp,ip)%particles(1:number_of_particles) |
---|
| 110 | IF ( number_of_particles <= 0 ) CYCLE |
---|
| 111 | WRITE ( 85 ) particles |
---|
| 112 | ENDDO |
---|
| 113 | ENDDO |
---|
| 114 | ENDDO |
---|
[849] | 115 | |
---|
| 116 | CALL close_file( 85 ) |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | #if defined( __netcdf ) |
---|
[1359] | 120 | ! ! |
---|
| 121 | ! !-- Output in netCDF format |
---|
| 122 | ! CALL check_open( 108 ) |
---|
| 123 | ! |
---|
| 124 | ! ! |
---|
| 125 | ! !-- Update the NetCDF time axis |
---|
| 126 | ! prt_time_count = prt_time_count + 1 |
---|
| 127 | ! |
---|
| 128 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_time_prt, & |
---|
| 129 | ! (/ simulated_time /), & |
---|
| 130 | ! start = (/ prt_time_count /), count = (/ 1 /) ) |
---|
[1783] | 131 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 1 ) |
---|
[1359] | 132 | ! |
---|
| 133 | ! ! |
---|
| 134 | ! !-- Output the real number of particles used |
---|
| 135 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_rnop_prt, & |
---|
| 136 | ! (/ number_of_particles /), & |
---|
| 137 | ! start = (/ prt_time_count /), count = (/ 1 /) ) |
---|
[1783] | 138 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 2 ) |
---|
[1359] | 139 | ! |
---|
| 140 | ! ! |
---|
| 141 | ! !-- Output all particle attributes |
---|
| 142 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(1), particles%age, & |
---|
| 143 | ! start = (/ 1, prt_time_count /), & |
---|
| 144 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 145 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 3 ) |
---|
[1359] | 146 | ! |
---|
[2122] | 147 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(2), particles%user, & |
---|
| 148 | ! start = (/ 1, prt_time_count /), & |
---|
[1359] | 149 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 150 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 4 ) |
---|
[1359] | 151 | ! |
---|
| 152 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(3), particles%origin_x, & |
---|
| 153 | ! start = (/ 1, prt_time_count /), & |
---|
| 154 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 155 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 5 ) |
---|
[1359] | 156 | ! |
---|
| 157 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(4), particles%origin_y, & |
---|
| 158 | ! start = (/ 1, prt_time_count /), & |
---|
| 159 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 160 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 6 ) |
---|
[1359] | 161 | ! |
---|
| 162 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(5), particles%origin_z, & |
---|
| 163 | ! start = (/ 1, prt_time_count /), & |
---|
| 164 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 165 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 7 ) |
---|
[1359] | 166 | ! |
---|
| 167 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(6), particles%radius, & |
---|
| 168 | ! start = (/ 1, prt_time_count /), & |
---|
| 169 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 170 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 8 ) |
---|
[1359] | 171 | ! |
---|
| 172 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(7), particles%speed_x, & |
---|
| 173 | ! start = (/ 1, prt_time_count /), & |
---|
| 174 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 175 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 9 ) |
---|
[1359] | 176 | ! |
---|
| 177 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(8), particles%speed_y, & |
---|
| 178 | ! start = (/ 1, prt_time_count /), & |
---|
| 179 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 180 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 10 ) |
---|
[1359] | 181 | ! |
---|
| 182 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(9), particles%speed_z, & |
---|
| 183 | ! start = (/ 1, prt_time_count /), & |
---|
| 184 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 185 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 11 ) |
---|
[1359] | 186 | ! |
---|
| 187 | ! nc_stat = NF90_PUT_VAR( id_set_prt,id_var_prt(10), & |
---|
| 188 | ! particles%weight_factor, & |
---|
| 189 | ! start = (/ 1, prt_time_count /), & |
---|
| 190 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 191 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 12 ) |
---|
[1359] | 192 | ! |
---|
| 193 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(11), particles%x, & |
---|
| 194 | ! start = (/ 1, prt_time_count /), & |
---|
| 195 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 196 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 13 ) |
---|
[1359] | 197 | ! |
---|
| 198 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(12), particles%y, & |
---|
| 199 | ! start = (/ 1, prt_time_count /), & |
---|
| 200 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 201 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 14 ) |
---|
[1359] | 202 | ! |
---|
| 203 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(13), particles%z, & |
---|
| 204 | ! start = (/ 1, prt_time_count /), & |
---|
| 205 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 206 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 15 ) |
---|
[1359] | 207 | ! |
---|
| 208 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(14), particles%class, & |
---|
| 209 | ! start = (/ 1, prt_time_count /), & |
---|
| 210 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 211 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 16 ) |
---|
[1359] | 212 | ! |
---|
| 213 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(15), particles%group, & |
---|
| 214 | ! start = (/ 1, prt_time_count /), & |
---|
| 215 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 216 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 17 ) |
---|
[1359] | 217 | ! |
---|
| 218 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(16), & |
---|
[2122] | 219 | ! particles%id2, & |
---|
[1359] | 220 | ! start = (/ 1, prt_time_count /), & |
---|
| 221 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 222 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 18 ) |
---|
[1359] | 223 | ! |
---|
[2122] | 224 | ! nc_stat = NF90_PUT_VAR( id_set_prt, id_var_prt(17), particles%id1, & |
---|
[1359] | 225 | ! start = (/ 1, prt_time_count /), & |
---|
| 226 | ! count = (/ maximum_number_of_particles /) ) |
---|
[1783] | 227 | ! CALL netcdf_handle_error( 'lpm_data_output_particles', 19 ) |
---|
[1359] | 228 | ! |
---|
[849] | 229 | #endif |
---|
| 230 | |
---|
| 231 | CALL cpu_log( log_point_s(40), 'lpm_data_output', 'stop' ) |
---|
| 232 | |
---|
| 233 | END SUBROUTINE lpm_data_output_particles |
---|