30 real(kind=dp) :: rel_humid
32 real(kind=dp) :: pressure
34 real(kind=dp) :: longitude
36 real(kind=dp) :: latitude
38 real(kind=dp) :: altitude
40 real(kind=dp) :: start_time
44 real(kind=dp) :: elapsed_time
46 real(kind=dp) :: solar_zenith_angle
48 real(kind=dp) :: height
63 env_state%temp = env_state%temp + env_state_delta%temp
64 env_state%rel_humid = env_state%rel_humid + env_state_delta%rel_humid
65 env_state%pressure = env_state%pressure + env_state_delta%pressure
66 env_state%longitude = env_state%longitude + env_state_delta%longitude
67 env_state%latitude = env_state%latitude + env_state_delta%latitude
68 env_state%altitude = env_state%altitude + env_state_delta%altitude
69 env_state%start_time = env_state%start_time + env_state_delta%start_time
70 env_state%start_day = env_state%start_day + env_state_delta%start_day
71 env_state%elapsed_time = env_state%elapsed_time &
72 + env_state_delta%elapsed_time
73 env_state%solar_zenith_angle = env_state%solar_zenith_angle &
74 + env_state_delta%solar_zenith_angle
75 env_state%height = env_state%height + env_state_delta%height
87 real(kind=dp),
intent(in) :: alpha
89 env_state%temp = env_state%temp * alpha
90 env_state%rel_humid = env_state%rel_humid * alpha
91 env_state%pressure = env_state%pressure * alpha
92 env_state%longitude = env_state%longitude * alpha
93 env_state%latitude = env_state%latitude * alpha
94 env_state%altitude = env_state%altitude * alpha
95 env_state%start_time = env_state%start_time * alpha
96 env_state%start_day = nint(
real(env_state%start_day, kind=dp) * alpha)
97 env_state%elapsed_time = env_state%elapsed_time * alpha
98 env_state%solar_zenith_angle = env_state%solar_zenith_angle * alpha
99 env_state%height = env_state%height * alpha
112 real(kind=dp),
intent(in) :: dv
119 dmv = dv *
const%water_density
121 mv =
const%water_molec_weight / (
const%univ_gas_const*env_state%temp) * pmv
124 call warn_msg(980320483,
"relative humidity tried to go negative")
127 env_state%rel_humid =
const%univ_gas_const * env_state%temp &
128 /
const%water_molec_weight * mv &
142 * 10d0**(7.45d0 * (env_state%temp -
const%water_freeze_temp) &
143 / (env_state%temp - 38d0))
169 / (
const%univ_gas_const * env_state%temp)
182 / (
const%univ_gas_const * env_state%temp *
const%water_density)
194 real(kind=dp),
intent(in) :: ppb
209 real(kind=dp),
intent(in) :: conc
219 subroutine spec_file_read_env_state(file, env_state)
263 end subroutine spec_file_read_env_state
279 val%temp = val_avg%temp
280 val%rel_humid = val_avg%rel_humid
281 val%pressure = val_avg%pressure
302 val%temp = val_avg%temp
303 val%rel_humid = val_avg%rel_humid
304 val%pressure = val_avg%pressure
339 character,
intent(inout) :: buffer(:)
341 integer,
intent(inout) :: position
346 integer :: prev_position
348 prev_position = position
372 character,
intent(inout) :: buffer(:)
374 integer,
intent(inout) :: position
379 integer :: prev_position
381 prev_position = position
420 subroutine env_state_output_netcdf(env_state, ncid)
425 integer,
intent(in) :: ncid
451 standard_name=
"air_temperature")
453 "relative_humidity", unit=
"1", standard_name=
"relative_humidity")
455 standard_name=
"air_pressure")
457 unit=
"degree_east", standard_name=
"longitude")
459 unit=
"degree_north", standard_name=
"latitude")
461 standard_name=
"altitude")
463 "start_time_of_day", unit=
"s", description=
"time-of-day of " &
464 //
"simulation start in seconds since midnight")
466 "start_day_of_year", &
467 description=
"day-of-year number of simulation start")
469 unit=
"s", description=
"elapsed time since simulation start")
471 "solar_zenith_angle", unit=
"radian", &
472 description=
"current angle from the zenith to the sun")
474 long_name=
"boundary layer mixing height")
476 end subroutine env_state_output_netcdf
486 integer,
intent(in) :: ncid
500 "solar_zenith_angle")
real(kind=dp) function env_state_air_molar_den(env_state)
Air molar density (mol m^{-3}).
An input file with extra data for printing messages.
Wrapper functions for NetCDF. These all take a NetCDF ncid in data mode and return with it again in d...
real(kind=dp) function env_state_a(env_state)
Condensation parameter.
integer function pmc_mpi_rank()
Returns the rank of the current process.
subroutine env_state_scale(env_state, alpha)
env_state *= alpha
subroutine warn_msg(code, warning_msg, already_warned)
Prints a warning message.
subroutine env_state_reduce_avg(val)
Average val over all processes, with the result only on the root process.
The env_state_t structure and associated subroutines.
integer function pmc_mpi_pack_size_env_state(val)
Determines the number of bytes required to pack the given value.
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
subroutine spec_file_read_real(file, name, var)
Read a real number from a spec file that must have the given name.
subroutine pmc_nc_read_integer(ncid, var, name, must_be_present)
Read a single integer from a NetCDF file.
subroutine spec_file_read_integer(file, name, var)
Read an integer from a spec file that must have the given name.
integer function pmc_mpi_pack_size_real(val)
Determines the number of bytes required to pack the given value.
Current environment state.
subroutine pmc_nc_write_integer(ncid, var, name, unit, long_name, standard_name, description)
Write a single integer to a NetCDF file.
subroutine pmc_mpi_pack_real(buffer, position, val)
Packs the given value into the buffer, advancing position.
subroutine env_state_change_water_volume(env_state, dv)
Adds the given water volume to the water vapor and updates all environment quantities.
subroutine pmc_nc_read_real(ncid, var, name, must_be_present)
Read a single real from a NetCDF file.
subroutine pmc_mpi_pack_integer(buffer, position, val)
Packs the given value into the buffer, advancing position.
real(kind=dp) function env_state_air_den(env_state)
Air density (kg m^{-3}).
Reading formatted text input.
subroutine pmc_mpi_unpack_real(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
subroutine pmc_mpi_reduce_avg_env_state(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on the root process...
subroutine pmc_nc_write_real(ncid, var, name, unit, long_name, standard_name, description)
Write a single real to a NetCDF file.
subroutine env_state_input_netcdf(env_state, ncid)
Read full state.
real(kind=dp) function env_state_conc_to_ppb(env_state, conc)
Convert (molecules m^{-3}) to (ppb).
subroutine pmc_mpi_unpack_env_state(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
integer function pmc_mpi_pack_size_integer(val)
Determines the number of bytes required to pack the given value.
subroutine pmc_mpi_allreduce_average_real(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on all processes...
subroutine pmc_mpi_pack_env_state(buffer, position, val)
Packs the given value into the buffer, advancing position.
subroutine pmc_mpi_unpack_integer(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
subroutine env_state_mix(val)
Average val over all processes.
subroutine pmc_mpi_reduce_avg_real(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on the root process...
type(const_t), save const
Fixed variable for accessing the constant's values.
Common utility subroutines.
Wrapper functions for MPI.
real(kind=dp) function env_state_ppb_to_conc(env_state, ppb)
Convert (ppb) to (molecules m^{-3}).
subroutine env_state_add(env_state, env_state_delta)
env_state += env_state_delta
real(kind=dp) function env_state_sat_vapor_pressure(env_state)
Computes the current saturation vapor pressure (Pa).