Skip to content

Commit

Permalink
Merge WRF-PartMC PartMC specific development to PartMC (#168)
Browse files Browse the repository at this point in the history
* added aero_component to aero_particle

* added weight_class to aero_mode to note which weight class particles should be in

* added how to combine arrays of components for coagulation

* removed n_orig_part from aero_particle

* created a Makefile for building partmc for wrf

* added wrf_partmc variables to env_state and output

* added 3d and 4d array handling for netcdf files

* minor changes

* added 3d array handling with mpi

* edit makefile

* added ifdef to turn off dilution

* added PMC_USE_WRF flag

* added WRF CPP flag for special netcdf filenames

* fix error in 5d array pack subroutine

* added some useful debugging to aero_state.F90

* added debugging when sampling particles

* added chamber to Makefile

* added aero_component arrays to output

* modified aerosol input files to add weight classes

* removed left over debugging output

* cleaned up output.F90

* edit aero_dist files to add weight_class_name

* fixed nucleate source and weighting

* removed _SOURCE weighting options

* fixed netcdf array reading subroutines

* fixed env_state_input_netcdf to read WRF specific variables

* changed WRF-partmc output to entire column

* add cpp around wrf partmc output subroutine

* removed unused variables

* minor bug fixes for aero_components

* fixed missing weight class names in mpi functions

* changed gas_data and aero_data to not be arrays in output

* aero component fixes

* disabled per particle coagulation

* aero_id is now 64 bit

* fixed aero id in aero_state

* fixed remaining aero_ids to int64

* use mpi_integer8

* added error particle checking and removal from mosaic

* update env_state probablities to 4d arrays

* change rand_binomial to handle small values of p

* added a few netcdf subroutines

* improvements to aero_data input and output

* added netcdf int64 subroutines

* changes to partmc code for wrf partmc

* added sorting for real values

* changes to aero_state to not track removals in wrf-partmc

* added gsl to makefile

* add threshold for sampling

* fixed cutoff for low number concentration in sampling

* added size factor timescale for sampling

* added missing dependency in Makefile

* change large static character arrays in aero_data to allocatable to avoid compiler warning

* changed output of component array to avoid gcc compile warning

* change to netcdf4 to allow int64 type

* fixed missing weight_class_name for mixing_state test

* added missing weight_class_name to file in camp test

* reenable per particle coagulation

* remove two wrf partmc hacks

* moved particle_error debugging for mosaic to wrf partmc only

* changed aero_particle_zero to allocate component array of size 0 and adjusted coagulation copying of components

* increased maximum aero_component size

* add new way to determine aero_component array in coagulation

* remove component flag option in coagulation

* minor code format fix

* added note to makefile for WRF build and added camp_interface

* update to not require user specified weighting

* change weighting specification in test case inputs

* update inputs and spec files in scenarios for weighting changes

* remove leftover debugging output

* added tracking number of primary particles that make a particle

* change documentation to reflect change in order spec file for do_select_weighting

* clean up commented out code for sampling in aero_state

* fixed long code lines that were my fault

* added create_time to output and input. fixed typos for long line breaking.

* fix documentation for output of aero_state to include component features

* removed unused env_state variable

* remove hardcoded value for weighting

* added weighting testcase

* fix bug

* small bug fixes found after wrf-partmc compile

* update optical wavelengths

* added missing files in wrf-partmc makefile

* optical changes. added deaveraging and new mixing state metric by size

* bug fix and add cell_volume to env_state

* minor changes to optical code

* remove deaveraging

* fix to aero_state_input_netcdf

* add missing files to makefile

* move a few num_conc functions to aero_state

* update code to handle multiple wavelengths

* refactor mixing_state_metric_by_size

* fix spec files for parallel tests

* fix missing do_camp_chem in run_part_opt mpi calls

* clean up debugging code

* add comments about controlling the sampling range of normal distribution

* fix Makefile for wrf-partmc build

* add optical property functions for aerosol state

* set size of arrays in aero_state optical functions

* safeguard against copying aero_state with no particles

* fix dup_all_particles

* add write_real_4d

* fix repeated error codes that I introduced

* Apply formatting suggestions

Co-authored-by: Matthew West <[email protected]>

* move ifdef down a level in aero_state_total_particles_all_proc. fix bug in reading other particle ID

* fix comments. remove code that was no longer used

* improve weighting tests

* improve weighitng tests. add plotting

* remove num_weight_classes argument

* improve aero_state_num_concs_by_source to be weighted correctly

* fix comment in aero_particle_n_components

* rename Makefile to make it more obvious that it belongs only for wrf partmc

* move MAX_AERO_COMPONENT_SIZE to aero_particle.F90

* clean up unused variables

* rename abs and scat size-resolved functions

* improve by_size optical functions

* first pass at fixing n_component functionconfusion

* refactor size selecting code

* change binned analysis code to be more general

* revert to optical true

* change num_primary_parts to n_primary_parts. scale num_concs_by_source by primary parts and components

* randomly select aero_components when exceeding maximum

* allow partmc to get wavelengths of optical properties for multi-wavelength MOSAIC codes

* fix up wavelength in aero_data

* remove unneeded subroutine for wavelengths

* improve multiple wavelength build process

* rename variables regarding threshold sampling

* add comment regarding single wavelength optical subroutine

* improve bin_grid_contains

* fix double counting problem in bin_grid_contains

* handle possible problems in bin_grid_contains

* fix mpi calls for run_part_opt. add uuid comment to mosaic calls

* make camp happy

* fix typo

* fix mosaic aerosol_optical calls

* fix component scaling with sample_source_particle

* rename env_state variables. fix output bug for n_primary_parts

* add file input for column

* remove n_orig_part from output

* fix bin_grid_contains to be consistent with bin_grid_find

* move copy_weight outside of aero_state_sample_particles

* fix code for bin_grid_contains

---------

Co-authored-by: Matthew West <[email protected]>
  • Loading branch information
jcurtis2 and mwest1066 authored Feb 23, 2024
1 parent cfa50cd commit 3aad1f6
Show file tree
Hide file tree
Showing 92 changed files with 4,119 additions and 325 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ scenarios/3_condense/spec/
scenarios/3_condense/temp/
scenarios/3_condense/out/
scenarios/4_chamber/out/
*.o
*.mod
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,14 @@ if(ENABLE_MOSAIC)
PATHS $ENV{MOSAIC_HOME} $ENV{MOSAIC_HOME}/lib)
include_directories(${MOSAIC_INCLUDE_DIR})
add_definitions(-DPMC_USE_MOSAIC)
option(ENABLE_OPT_MULTI_WAVELENGTH
"Enable MOSAIC multiple wavelength for optical calculations" OFF)
if(ENABLE_OPT_MULTI_WAVELENGTH)
add_definitions(-DPMC_USE_MOSAIC_MULTI_OPT)
endif()
endif()


######################################################################
# CAMP

Expand Down Expand Up @@ -169,6 +175,7 @@ add_library(partmclib src/aero_state.F90 src/integer_varray.F90
src/netcdf.F90 src/aero_info.F90 src/aero_info_array.F90
src/nucleate.F90 src/condense.F90 src/fractal.F90 src/chamber.F90
src/camp_interface.F90 src/photolysis.F90 src/sys.F90
src/aero_component.F90
${SUNDIALS_SRC} ${GSL_SRC}
${C_SORT_SRC})

Expand Down
2 changes: 1 addition & 1 deletion scenarios/1_urban_plume/urban_plume.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ output_prefix out/urban_plume # prefix of output files
n_repeat 3 # number of Monte Carlo repeats
n_part 1000 # total number of particles
restart no # whether to restart from saved state (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)

t_max 86400 # total simulation time (s)
del_t 60 # timestep (s)
Expand Down Expand Up @@ -44,6 +45,5 @@ do_nucleation no # whether to do nucleation (yes/no)
rand_init 0 # random initialization (0 to use time)
allow_doubling yes # whether to allow doubling (yes/no)
allow_halving yes # whether to allow halving (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)
record_removals yes # whether to record particle removals (yes/no)
do_parallel no # whether to run in parallel (yes/no)
2 changes: 1 addition & 1 deletion scenarios/2_urban_plume2/urban_plume2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ output_prefix out/urban_plume2 # prefix of output files
n_repeat 1 # number of Monte Carlo repeats
n_part 1000 # total number of particles
restart no # whether to restart from saved state (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)

t_max 172800 # total simulation time (s)
del_t 60 # timestep (s)
Expand Down Expand Up @@ -44,6 +45,5 @@ do_nucleation no # whether to do nucleation (yes/no)
rand_init 0 # random initialization (0 to use time)
allow_doubling yes # whether to allow doubling (yes/no)
allow_halving yes # whether to allow halving (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)
record_removals yes # whether to record particle removals (yes/no)
do_parallel no # whether to run in parallel (yes/no)
2 changes: 1 addition & 1 deletion scenarios/4_chamber/chamber.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ output_prefix out/chamber # prefix of output files
n_repeat 10 # number of Monte Carlo repeats
n_part 10000 # total number of particles
restart no # whether to restart from saved state (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)

t_max 20160 # total simulation time (s)
del_t 60 # timestep (s)
Expand Down Expand Up @@ -51,6 +52,5 @@ do_nucleation no # whether to do nucleation (yes/no)
rand_init 7 # random initialization (0 to auto-generate)
allow_doubling yes # whether to allow doubling (yes/no)
allow_halving yes # whether to allow halving (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)
record_removals no # whether to record particle removals (yes/no)
do_parallel no # whether to run in parallel (yes/no)
2 changes: 1 addition & 1 deletion scenarios/5_coag_brownian/example.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ output_prefix out/example # prefix of output files
n_repeat 1 # number of Monte Carlo repeats
n_part 1000 # total number of particles
restart no # whether to restart from saved state (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)

t_max 86400 # total simulation time (s)
del_t 60 # timestep (s)
Expand Down Expand Up @@ -43,6 +44,5 @@ do_nucleation no # whether to do nucleation (yes/no)
rand_init 66 # random initialization (0 to use time)
allow_doubling yes # whether to allow doubling (yes/no)
allow_halving yes # whether to allow halving (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)
record_removals yes # whether to record particle removals (yes/no)
do_parallel no # whether to run in parallel (yes/no)
2 changes: 1 addition & 1 deletion scenarios/6_camp/camp.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ output_prefix out/camp # prefix of output files
n_repeat 1 # number of Monte Carlo repeats
n_part 10000 # total number of particles
restart no # whether to restart from saved state (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)

t_max 86400 # total simulation time (s)
del_t 120 # timestep (s)
Expand Down Expand Up @@ -41,6 +42,5 @@ do_nucleation no # whether to do nucleation (yes/no)
rand_init 0 # random initialization (0 to use time)
allow_doubling no # whether to allow doubling (yes/no)
allow_halving no # whether to allow halving (yes/no)
do_select_weighting no # whether to select weighting explicitly (yes/no)
record_removals yes # whether to record particle removals (yes/no)
do_parallel no # whether to run in parallel (yes/no)
208 changes: 208 additions & 0 deletions src/Makefile.wrf_partmc
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# NOTE: This Makefile is only to be used when compiling PartMC in WRF

LN = ln -sf
MAKE = make -i -r
RM = rm -f

PMC_MODULES = \
aero_binned.o \
aero_component.o \
aero_data.o \
aero_dist.o \
aero_info.o \
aero_info_array.o \
aero_mode.o \
aero_particle.o \
aero_particle_array.o \
aero_state.o \
aero_sorted.o \
aero_weight.o \
aero_weight_array.o \
bin_grid.o \
camp_interface.o \
chamber.o \
coag_kernel.o \
coag_kernel_additive.o \
coag_kernel_brown.o \
coag_kernel_brown_cont.o \
coag_kernel_brown_free.o \
coag_kernel_constant.o \
coag_kernel_sedi.o \
coag_kernel_zero.o \
coagulation.o \
coagulation_dist.o \
condense.o \
constants.o \
env_state.o \
fractal.o \
gas_data.o \
gas_state.o \
integer_rmap.o \
integer_rmap2.o \
integer_varray.o \
mosaic.o \
mpi.o \
netcdf.o \
nucleate.o \
output.o \
photolysis.o \
rand.o \
rand_gsl.o \
scenario.o \
spec_file.o \
spec_line.o \
stats.o \
util.o \
sort.o \
sys.o

OBJS = \

LIBTARGET = libpartmc.a
TARGETDIR = ./
$(LIBTARGET) : $(MODULES) $(PMC_MODULES) $(OBJS)
$(AR) $(ARFLAGS) $(LIBTARGET) $(MODULES) $(PMC_MODULES) \
$(OBJS)
$(RANLIB) $(RANLIBFLAGS) $@

include ../../WRFV3/configure.wrf

all: pmc

pmc: $(PMC_MODULES)

clean:
@ echo 'use the clean script'

# DEPENDENCIES : only dependencies after this line (don't remove the word DEPENDENCIES)

aero_binned.o: bin_grid.o aero_particle.o spec_file.o \
util.o aero_dist.o mpi.o aero_data.o

aero_component.o: util.o mpi.o

aero_data.o: spec_file.o mpi.o util.o fractal.o netcdf.o

aero_dist.o: bin_grid.o util.o constants.o spec_file.o \
aero_data.o aero_mode.o mpi.o rand.o

aero_info.o: util.o spec_file.o mpi.o

aero_info_array.o: aero_info.o util.o spec_file.o mpi.o

aero_mode.o: bin_grid.o util.o constants.o spec_file.o \
aero_data.o aero_weight.o mpi.o rand.o

aero_particle.o: util.o aero_data.o spec_file.o env_state.o \
mpi.o aero_component.o

aero_particle_array.o: aero_particle.o util.o spec_file.o mpi.o

aero_sorted.o: integer_varray.o integer_rmap.o integer_rmap2.o \
aero_particle.o aero_particle_array.o bin_grid.o mpi.o

aero_state.o: aero_particle_array.o aero_sorted.o integer_varray.o \
bin_grid.o aero_data.o aero_particle.o aero_dist.o \
util.o rand.o aero_binned.o mpi.o spec_file.o \
aero_info.o aero_info_array.o aero_weight.o \
aero_weight_array.o

aero_weight.o: util.o constants.o rand.o spec_file.o \
aero_particle.o aero_data.o netcdf.o mpi.o

aero_weight_array.o: util.o constants.o rand.o spec_file.o \
aero_particle.o netcdf.o mpi.o aero_weight.o aero_data.o

bin_grid.o: constants.o util.o spec_file.o mpi.o netcdf.o

camp_interface.o: aero_data.o aero_state.o aero_particle.o constants.o gas_data.o \
gas_state.o util.o

chamber.o: aero_data.o constants.o env_state.o spec_file.o

coag_kernel.o: env_state.o bin_grid.o aero_particle.o \
aero_data.o aero_weight.o aero_weight_array.o coag_kernel_sedi.o \
coag_kernel_additive.o coag_kernel_constant.o \
coag_kernel_brown.o coag_kernel_zero.o \
coag_kernel_brown_free.o coag_kernel_brown_cont.o

coag_kernel_additive.o: bin_grid.o env_state.o util.o \
constants.o aero_binned.o aero_data.o aero_dist.o \
aero_particle.o

coag_kernel_brown.o: env_state.o constants.o util.o \
aero_particle.o

coag_kernel_brown_cont.o: env_state.o constants.o util.o \
aero_particle.o aero_data.o

coag_kernel_brown_free.o: env_state.o constants.o util.o \
aero_particle.o aero_data.o

coag_kernel_constant.o: env_state.o bin_grid.o util.o \
constants.o aero_binned.o aero_data.o aero_dist.o \
aero_data.o aero_particle.o

coag_kernel_sedi.o: env_state.o constants.o aero_data.o \
aero_particle.o

coag_kernel_zero.o: bin_grid.o env_state.o util.o aero_binned.o \
aero_dist.o aero_data.o aero_particle.o scenario.o

coagulation.o: bin_grid.o aero_data.o util.o env_state.o \
aero_state.o aero_weight.o mpi.o coag_kernel.o stats.o \
aero_sorted.o

coagulation_dist.o: bin_grid.o aero_data.o util.o env_state.o \
aero_state.o coagulation.o mpi.o

condense.o: aero_state.o env_state.o aero_data.o util.o aero_particle.o constants.o

constants.o:

env_state.o: constants.o util.o spec_file.o mpi.o netcdf.o

fractal.o: spec_file.o constants.o netcdf.o mpi.o

gas_data.o: spec_file.o mpi.o util.o netcdf.o

gas_state.o:util.o spec_file.o gas_data.o mpi.o netcdf.o env_state.o

integer_rmap.o: integer_varray.o util.o mpi.o

integer_rmap2.o: integer_varray.o util.o mpi.o

integer_varray.o: util.o mpi.o

mosaic.o: aero_data.o aero_state.o constants.o env_state.o \
gas_data.o gas_state.o output.o util.o

mpi.o: util.o

netcdf.o: util.o rand.o

nucleate.o: env_state.o aero_state.o aero_data.o gas_data.o gas_state.o

output.o: bin_grid.o aero_data.o aero_state.o aero_binned.o \
netcdf.o env_state.o util.o gas_data.o mpi.o

photolysis.o: constants.o util.o

rand.o: util.o constants.o mpi.o rand_gsl.o

rand_gsl.o:

scenario.o: gas_state.o aero_dist.o util.o env_state.o \
aero_state.o spec_file.o aero_data.o gas_data.o mpi.o chamber.o

spec_file.o: spec_line.o util.o

spec_line.o: util.o

sort.o:

stats.o: util.o netcdf.o

sys.o:

util.o: constants.o sort.o sys.o
Loading

0 comments on commit 3aad1f6

Please sign in to comment.