21 character(len=1000) :: in_filename, out_prefix
28 integer :: n_bin, index, i_repeat, output_type
29 real(kind=dp) :: d_min, d_max, time, del_t
30 character(len=1000) :: tmp_str
31 logical :: record_removals, dry_volume, bin_center, record_optical
32 logical :: preserve_number
33 character(len=PMC_UUID_LEN) :: uuid
36 if (command_argument_count() .ne. 8)
then
37 write(6,*)
'Usage: bin_average_size <d_min> <d_max> <n_bin> ' &
38 //
'<"wet" or "dry"> <"center" or "average"> ' &
39 //
'<"number" or "volume"> ' &
40 //
'<input_filename> <output_prefix>'
42 write(6,*)
' d_min: minimum bin diameter (m)'
43 write(6,*)
' d_max: maximum bin diameter (m)'
44 write(6,*)
' n_bin: number of bins'
45 write(6,*)
' wet/dry: average wet or dry sizes'
46 write(6,*)
' center/average: set new sizes to bin centers, ' &
47 //
'or to average sizes'
48 write(6,*)
' number/volume: preserve number or volume'
49 write(6,*)
' input_filename: like scenario_0001_00000001.nc'
50 write(6,*)
' output_prefix: like scenario_size_average'
53 call get_command_argument(1, tmp_str)
55 call get_command_argument(2, tmp_str)
57 call get_command_argument(3, tmp_str)
59 call get_command_argument(4, tmp_str)
60 if (trim(tmp_str) ==
"wet")
then
62 elseif (trim(tmp_str) ==
"dry")
then
65 write(6,*)
'Argument 4 must be "wet" or "dry", not ' &
69 call get_command_argument(5, tmp_str)
70 if (trim(tmp_str) ==
"center")
then
72 elseif (trim(tmp_str) ==
"average")
then
75 write(6,*)
'Argument 5 must be "center" or "average", not ' &
79 call get_command_argument(6, tmp_str)
80 if (trim(tmp_str) ==
"number")
then
81 preserve_number = .true.
82 elseif (trim(tmp_str) ==
"volume")
then
83 preserve_number = .false.
85 write(6,*)
'Argument 6 must be "number" or "volume", not ' &
89 call get_command_argument(7, in_filename)
90 call get_command_argument(8, out_prefix)
104 call
input_state(in_filename, index, time, del_t, i_repeat, uuid, &
105 aero_data, aero_state, gas_data, gas_state, env_state)
112 bin_center, preserve_number)
114 output_type = output_type_single
115 record_removals = .false.
116 record_optical = .true.
117 call
output_state(out_prefix, output_type, aero_data, aero_state, &
118 gas_data, gas_state, env_state, index, time, del_t, i_repeat, &
119 record_removals, record_optical, uuid)
subroutine aero_state_bin_average_size(aero_state, bin_grid, aero_data, bin_center, preserve_number)
Set each aerosol particle to have its original species ratios, but total volume given by the average ...
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_data_t structure and associated subroutines.
The env_state_t structure and associated subroutines.
subroutine aero_state_allocate(aero_state)
Allocates aerosol arrays.
subroutine bin_grid_make(bin_grid, type, n_bin, min, max)
Generates the bin grid given the range and number of bins.
subroutine pmc_mpi_finalize()
Shut down MPI.
subroutine output_state(prefix, output_type, aero_data, aero_state, gas_data, gas_state, env_state, index, time, del_t, i_repeat, record_removals, record_optical, uuid)
Write the current state.
subroutine pmc_mpi_init()
Initialize MPI.
subroutine gas_data_deallocate(gas_data)
Free all storage.
subroutine bin_grid_allocate(bin_grid)
Allocates a bin_grid.
The gas_data_t structure and associated subroutines.
real(kind=dp) elemental function diam2rad(d)
Convert diameter (m) to radius (m).
integer function string_to_integer(string)
Convert a string to an integer.
subroutine aero_data_deallocate(aero_data)
Frees all storage.
Current environment state.
subroutine env_state_deallocate(env_state)
Free all storage.
The aero_state_t structure and assocated subroutines.
subroutine gas_state_deallocate(gas_state)
Free all storage.
The gas_state_t structure and associated subroutines.
subroutine gas_state_allocate(gas_state)
Allocate storage for gas species.
The current collection of aerosol particles.
subroutine aero_state_make_dry(aero_state, aero_data)
Make all particles dry (water set to zero).
1D grid, either logarithmic or linear.
The bin_grid_t structure and associated subroutines.
subroutine aero_state_deallocate(aero_state)
Deallocates a previously allocated aerosol.
program bin_average_size
Read a NetCDF file, average the size of all particles within each bin, and write the data out as anot...
subroutine gas_data_allocate(gas_data)
Allocate storage for gas species.
Current state of the gas mixing ratios in the system.
subroutine aero_data_allocate(aero_data)
Allocate storage for aero_data.
subroutine env_state_allocate(env_state)
Allocate an empty environment.
Aerosol material properties and associated data.
real(kind=dp) function string_to_real(string)
Convert a string to a real.
subroutine bin_grid_deallocate(bin_grid)
Frees all memory.
Write data in NetCDF format.