17 character(len=PMC_MAX_FILENAME_LEN) :: in_prefix, out_filename
18 character(len=PMC_MAX_FILENAME_LEN),
allocatable :: filename_list(:)
22 integer :: index, out_unit
23 integer :: i_file, n_file, i_spec
24 real(kind=
dp) :: time, del_t
25 character(len=PMC_UUID_LEN) :: uuid, run_uuid
26 real(kind=
dp),
allocatable :: times(:), time_num_concs(:), time_mass_concs(:)
27 real(kind=
dp),
allocatable :: time_species_concs(:,:)
32 opts(1) =
option_s(
"help", .false.,
'h')
33 opts(2) =
option_s(
"output", .true.,
'o')
38 select case(
getopt(
"ho:", opts))
55 if (
optind /= command_argument_count())
then
57 call die_msg(959981535,
'expected exactly one non-option prefix argument')
60 call get_command_argument(
optind, in_prefix)
62 if (out_filename ==
"")
then
63 out_filename = trim(in_prefix) //
"_aero_time.txt"
66 allocate(filename_list(0))
68 n_file =
size(filename_list)
70 "no NetCDF files found with prefix: " // trim(in_prefix))
73 bin_grid=bin_grid, aero_data=aero_data, aero_binned=aero_binned)
76 allocate(times(n_file))
77 allocate(time_num_concs(n_file))
78 allocate(time_mass_concs(n_file))
83 bin_grid=bin_grid, aero_data=aero_data, aero_binned=aero_binned)
86 "UUID mismatch between " // trim(filename_list(1)) //
" and " &
87 // trim(filename_list(i_file)))
90 time_num_concs(i_file) = sum(aero_binned%num_conc * bin_grid%widths)
92 time_species_concs(i_file, :) = sum(aero_binned%vol_conc &
93 * bin_grid%widths(1), 1) * aero_data%density
94 time_mass_concs(i_file) = sum(time_species_concs(i_file, :))
97 write(*,
'(a,a)')
"Output file: ", trim(out_filename)
98 write(*,
'(a)')
" Each row of output is one time."
99 write(*,
'(a)')
" The columns of output are:"
100 write(*,
'(a)')
" column 1: time (s)"
101 write(*,
'(a)')
" column 2: aerosol number concentration (#/m^3)"
102 write(*,
'(a)')
" column 3: aerosol mass concentration (kg/m^3)"
104 write(*,
'(a,i2,a,a,a)')
" column ", i_spec + 3,
": aerosol ", &
105 trim(aero_data%name(i_spec)),
" concentration (kg/m^3)"
110 write(out_unit,
'(e30.15e3)', advance=
'no') times(i_file)
111 write(out_unit,
'(e30.15e3)', advance=
'no') time_num_concs(i_file)
112 write(out_unit,
'(e30.15e3)', advance=
'no') time_mass_concs(i_file)
114 write(out_unit,
'(e30.15e3)', advance=
'no') &
115 time_species_concs(i_file, i_spec)
117 write(out_unit,
'(a)')
''
122 deallocate(time_num_concs)
123 deallocate(time_mass_concs)
124 deallocate(time_species_concs)
125 deallocate(filename_list)
133 write(*,
'(a)')
'Usage: extract_sectional_aero_time [options] ' &
136 write(*,
'(a)')
'options are:'
137 write(*,
'(a)')
' -h, --help Print this help message.'
138 write(*,
'(a)')
' -o, --out <file> Output filename.'
140 write(*,
'(a)')
'Examples:'
141 write(*,
'(a)')
' extract_sectional_aero_time data_0001'