Go to the documentation of this file.
18 character(len=PMC_MAX_FILENAME_LEN) :: in_filename, out_filename
21 integer :: index, i_repeat, i_part, i_spec, out_unit, i_char
22 real(kind=
dp) :: time, del_t
23 character(len=PMC_UUID_LEN) :: uuid
28 opts(1) =
option_s(
"help", .false.,
'h')
29 opts(2) =
option_s(
"output", .true.,
'o')
34 select case(
getopt(
"ho:", opts))
51 if (
optind /= command_argument_count())
then
54 'expected exactly one non-option filename argument')
57 call get_command_argument(
optind, in_filename)
59 if (out_filename ==
"")
then
60 i_char = scan(in_filename,
'.', back=.true.)
62 out_filename = trim(in_filename) //
"_aero_particles.txt"
64 out_filename = trim(in_filename(1:(i_char - 1))) &
65 //
"_aero_particles.txt"
69 call input_state(in_filename, index, time, del_t, i_repeat, uuid, &
70 aero_data=aero_data, aero_state=aero_state)
72 write(*,
'(a)')
"Output file: " // trim(out_filename)
73 write(*,
'(a)')
" Output data is for time = " &
75 write(*,
'(a)')
" Each row of output is one particle."
76 write(*,
'(a)')
" The columns of output are:"
77 write(*,
'(a)')
" column 1: particle ID number"
78 write(*,
'(a)')
" column 2: number concentration (m^{-3})"
79 write(*,
'(a)')
" column 3: particle diameter (m)"
80 write(*,
'(a)')
" column 4: particle total mass (kg)"
82 write(*,
'(a,i2,a,a,a,e10.4,a)')
' column ', i_spec + 4,
': ', &
83 trim(aero_data%name(i_spec)),
' mass (kg) - density = ', &
84 aero_data%density(i_spec),
' (kg/m^3)'
89 write(out_unit,
'(i15,e30.15e3,e30.15e3,e30.15e3)', advance=
'no') &
90 aero_state%apa%particle(i_part)%id, &
92 aero_state%apa%particle(i_part), aero_data), &
96 write(out_unit,
'(e30.15e3)', advance=
'no') &
100 write(out_unit, *)
''
110 write(*,
'(a)')
'Usage: extract_aero_particles [options] <netcdf_prefix>'
112 write(*,
'(a)')
'options are:'
113 write(*,
'(a)')
' -h, --help Print this help message.'
114 write(*,
'(a)')
' -o, --out <file> Output filename.'
116 write(*,
'(a)')
'Examples:'
117 write(*,
'(a)')
' extract_aero_particles data_0001_00000001.nc'
subroutine pmc_mpi_init()
Initialize MPI.
elemental integer function aero_data_n_spec(aero_data)
Return the number of aerosol species, or -1 if uninitialized.
Wrapper functions for MPI.
elemental integer function aero_state_n_part(aero_state)
Return the current number of particles.
subroutine input_state(filename, index, time, del_t, i_repeat, uuid, aero_data, aero_state, gas_data, gas_state, env_state)
Read the current state.
The aero_particle_t structure and associated subroutines.
subroutine open_file_write(filename, unit)
Open a file for writing with an automatically assigned unit and test that it succeeds....
elemental real(kind=dp) function aero_particle_diameter(aero_particle, aero_data)
Total diameter of the particle (m).
character function getopt(optstring, longopts)
subroutine die_msg(code, error_msg)
Error immediately.
integer, parameter dp
Kind of a double precision real number.
The aero_state_t structure and assocated subroutines.
subroutine pmc_mpi_finalize()
Shut down MPI.
character(len=pmc_util_convert_string_len) function real_to_string(val)
Convert a real to a string format.
real(kind=dp) function aero_state_particle_num_conc(aero_state, aero_particle, aero_data)
The number concentration of a single particle (m^{-3}).
program extract_aero_particles
Read NetCDF output files and write out the individual particle masses.
Aerosol material properties and associated data.
Write data in NetCDF format.
elemental real(kind=dp) function aero_particle_species_mass(aero_particle, i_spec, aero_data)
Mass of a single species in the particle (kg).
subroutine close_file(unit)
Close a file and de-assign the unit.
The current collection of aerosol particles.
elemental real(kind=dp) function aero_particle_mass(aero_particle, aero_data)
Total mass of the particle (kg).