Skip to content

Commit

Permalink
rename env_state variables. fix output bug for n_primary_parts
Browse files Browse the repository at this point in the history
  • Loading branch information
jcurtis2 committed Feb 9, 2024
1 parent e5eb7d3 commit 726fbf6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 35 deletions.
4 changes: 4 additions & 0 deletions src/aero_state.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3094,6 +3094,7 @@ subroutine aero_state_input_netcdf(aero_state, ncid, aero_data)
integer, allocatable :: aero_component_source_num(:)
integer, allocatable :: aero_component_len(:)
integer, allocatable :: aero_component_start_ind(:)
integer, allocatable :: aero_particle_n_primary_parts(:)
real(kind=dp), allocatable :: aero_component_create_time(:)
integer :: i_comp

Expand All @@ -3114,6 +3115,8 @@ subroutine aero_state_input_netcdf(aero_state, ncid, aero_data)
"aero_particle_mass")
call pmc_nc_read_integer_2d(ncid, aero_n_orig_part, &
"aero_n_orig_part")
call pmc_nc_read_integer_1d(ncid, aero_particle_n_primary_parts, &
"aero_particle_n_primary_parts")
call pmc_nc_read_integer_1d(ncid, aero_component_particle_num, &
"aero_component_particle_num")
call pmc_nc_read_integer_1d(ncid, aero_component_source_num, &
Expand Down Expand Up @@ -3160,6 +3163,7 @@ subroutine aero_state_input_netcdf(aero_state, ncid, aero_data)
do i_part = 1,n_part
call aero_particle_zero(aero_particle, aero_data)
aero_particle%vol = aero_particle_mass(i_part, :) / aero_data%density
aero_particle%n_primary_parts = aero_particle_n_primary_parts(i_part)
if (allocated(aero_particle%component)) &
deallocate(aero_particle%component)
allocate(aero_particle%component(aero_component_len(i_part)))
Expand Down
62 changes: 31 additions & 31 deletions src/env_state.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ module pmc_env_state
!> Altitude (m).
real(kind=dp) :: altitude
#ifdef PMC_USE_WRF
!> Lower boundary altitude (m).
!> Height of lower edge of grid cell (m).
real(kind=dp) :: z_min
!> Upper boundary altitude (m).
!> Height of upper edge of grid cell (m).
real(kind=dp) :: z_max
!> Specific volume (m^3 kg^{-1}).
real(kind=dp) :: rrho
!> Inverse density (m^3 kg^{-1}).
real(kind=dp) :: inverse_density
!> Grid cell volume.
real(kind=dp) :: cell_volume
!> East-West index.
integer :: ix
!> North-South index.
integer :: iy
!> Top-Bottom index.
integer :: iz
!> East-West index for grid cell.
integer :: cell_ix
!> North-South index for grid cell.
integer :: cell_iy
!> Top-Bottom index for grid cell.
integer :: cell_iz
!> Eddy diffusivity coefficient (m^2 s^{-2}).
real(kind=dp) :: diff_coef
!> Transfer probability in all directions due to advection.
Expand Down Expand Up @@ -371,11 +371,11 @@ integer function pmc_mpi_pack_size_env_state(val)
#ifdef PMC_USE_WRF
+ pmc_mpi_pack_size_real(val%z_min) &
+ pmc_mpi_pack_size_real(val%z_max) &
+ pmc_mpi_pack_size_real(val%rrho) &
+ pmc_mpi_pack_size_real(val%inverse_density) &
+ pmc_mpi_pack_size_real(val%cell_volume) &
+ pmc_mpi_pack_size_integer(val%ix) &
+ pmc_mpi_pack_size_integer(val%iy) &
+ pmc_mpi_pack_size_integer(val%iz) &
+ pmc_mpi_pack_size_integer(val%cell_ix) &
+ pmc_mpi_pack_size_integer(val%cell_iy) &
+ pmc_mpi_pack_size_integer(val%cell_iz) &
+ pmc_mpi_pack_size_real(val%diff_coef) &
+ pmc_mpi_pack_size_real_array_4d(val%prob_advection) &
+ pmc_mpi_pack_size_real_array_4d(val%prob_diffusion) &
Expand Down Expand Up @@ -414,11 +414,11 @@ subroutine pmc_mpi_pack_env_state(buffer, position, val)
#ifdef PMC_USE_WRF
call pmc_mpi_pack_real(buffer, position, val%z_min)
call pmc_mpi_pack_real(buffer, position, val%z_max)
call pmc_mpi_pack_real(buffer, position, val%rrho)
call pmc_mpi_pack_real(buffer, position, val%inverse_density)
call pmc_mpi_pack_real(buffer, position, val%cell_volume)
call pmc_mpi_pack_integer(buffer, position, val%ix)
call pmc_mpi_pack_integer(buffer, position, val%iy)
call pmc_mpi_pack_integer(buffer, position, val%iz)
call pmc_mpi_pack_integer(buffer, position, val%cell_ix)
call pmc_mpi_pack_integer(buffer, position, val%cell_iy)
call pmc_mpi_pack_integer(buffer, position, val%cell_iz)
call pmc_mpi_pack_real(buffer, position, val%diff_coef)
call pmc_mpi_pack_real_array_4d(buffer, position, val%prob_advection)
call pmc_mpi_pack_real_array_4d(buffer, position, val%prob_diffusion)
Expand Down Expand Up @@ -460,11 +460,11 @@ subroutine pmc_mpi_unpack_env_state(buffer, position, val)
#ifdef PMC_USE_WRF
call pmc_mpi_unpack_real(buffer, position, val%z_min)
call pmc_mpi_unpack_real(buffer, position, val%z_max)
call pmc_mpi_unpack_real(buffer, position, val%rrho)
call pmc_mpi_unpack_real(buffer, position, val%inverse_density)
call pmc_mpi_unpack_real(buffer, position, val%cell_volume)
call pmc_mpi_unpack_integer(buffer, position, val%ix)
call pmc_mpi_unpack_integer(buffer, position, val%iy)
call pmc_mpi_unpack_integer(buffer, position, val%iz)
call pmc_mpi_unpack_integer(buffer, position, val%cell_ix)
call pmc_mpi_unpack_integer(buffer, position, val%cell_iy)
call pmc_mpi_unpack_integer(buffer, position, val%cell_iz)
call pmc_mpi_unpack_real(buffer, position, val%diff_coef)
call pmc_mpi_unpack_real_array_4d(buffer, position, val%prob_advection)
call pmc_mpi_unpack_real_array_4d(buffer, position, val%prob_diffusion)
Expand Down Expand Up @@ -550,15 +550,15 @@ subroutine env_state_output_netcdf(env_state, ncid)
unit="m", standard_name="bottom_altitude")
call pmc_nc_write_real(ncid, env_state%z_max, "top_boundary_altitude", &
unit="m", standard_name="top_altitude")
call pmc_nc_write_real(ncid, env_state%rrho, "specific_volume", &
unit="m3kg-1", standard_name="specific_volume")
call pmc_nc_write_real(ncid, env_state%inverse_density, "inverse_density", &
unit="m3kg-1", standard_name="inverse_density")
call pmc_nc_write_real(ncid, env_state%cell_volume, "cell_volume", &
unit="m3", standard_name="cell_volume")
call pmc_nc_write_integer(ncid,env_state%ix,"x_index", &
call pmc_nc_write_integer(ncid,env_state%cell_ix,"x_index", &
description="east-west index of WRF domain")
call pmc_nc_write_integer(ncid,env_state%iy,"y_index", &
call pmc_nc_write_integer(ncid,env_state%cell_iy,"y_index", &
description="north-south index of WRF domain")
call pmc_nc_write_integer(ncid,env_state%iz,"z_index", &
call pmc_nc_write_integer(ncid,env_state%cell_iz,"z_index", &
description="top-bottom index of WRF domain")
call pmc_nc_write_real(ncid, env_state%diff_coef, "eddy_diff", &
unit="m2s-1", description="eddy diffusion coefficient")
Expand Down Expand Up @@ -598,11 +598,11 @@ subroutine env_state_input_netcdf(env_state, ncid)
#ifdef PMC_USE_WRF
call pmc_nc_read_real(ncid, env_state%z_min, "bottom_boundary_altitude")
call pmc_nc_read_real(ncid, env_state%z_max, "top_boundary_altitude")
call pmc_nc_read_real(ncid, env_state%rrho, "specific_volume")
call pmc_nc_read_real(ncid, env_state%inverse_density, "inverse_density")
call pmc_nc_read_real(ncid, env_state%cell_volume, "cell_volume")
call pmc_nc_read_integer(ncid,env_state%ix,"x_index")
call pmc_nc_read_integer(ncid,env_state%iy,"y_index")
call pmc_nc_read_integer(ncid,env_state%iz,"z_index")
call pmc_nc_read_integer(ncid,env_state%cell_ix,"x_index")
call pmc_nc_read_integer(ncid,env_state%cell_iy,"y_index")
call pmc_nc_read_integer(ncid,env_state%cell_iz,"z_index")
call pmc_nc_read_real(ncid, env_state%diff_coef, "eddy_diff")
#endif
call pmc_nc_read_real(ncid, env_state%start_time, &
Expand Down
6 changes: 3 additions & 3 deletions src/output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,8 @@ subroutine output_column_to_file(prefix, aero_data, aero_state, gas_data, &
integer :: k

#ifdef PMC_USE_WRF
write(filename,'(a,a,i3.3,a,i3.3,a,i8.8,a)') trim(prefix), &
'_', env_state(1)%ix, '_', env_state(1)%iy, '_', index, '.nc'
write(filename,'(a,a,i3.3,a,i3.3,a,i8.8,a)') trim(prefix), '_', &
env_state(1)%cell_ix, '_', env_state(1)%cell_iy, '_', index, '.nc'
call pmc_nc_open_write(filename, ncid)
call pmc_nc_write_info(ncid, uuid, &
"WRF-PartMC version " // trim(PARTMC_VERSION), write_rank, &
Expand All @@ -881,7 +881,7 @@ subroutine output_column_to_file(prefix, aero_data, aero_state, gas_data, &

do k = 1,nz
call pmc_nc_check_msg(nf90_redef(ncid),'in define mode for level')
write(group_name,'(a,i2.2)') 'level_', env_state(k)%iz
write(group_name,'(a,i2.2)') 'level_', env_state(k)%cell_iz
call pmc_nc_check_msg(nf90_def_grp(ncid, group_name, ncid_group), &
'creating level group')
call pmc_nc_check_msg(nf90_enddef(ncid),'end define mode for level')
Expand Down
2 changes: 1 addition & 1 deletion src/scenario.F90
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ subroutine scenario_update_aero_state(scenario, delta_t, env_state, &

#ifdef PMC_USE_WRF
call aero_weight_array_scale(aero_state%awa, &
old_env_state%rrho * (1.0d0 / env_state%rrho))
old_env_state%inverse_density * (1.0d0 / env_state%inverse_density))
#else
! update computational volume
call aero_weight_array_scale(aero_state%awa, &
Expand Down

0 comments on commit 726fbf6

Please sign in to comment.