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
62 env_state%rel_humid = 0d0
63 env_state%pressure = 0d0
64 env_state%longitude = 0d0
65 env_state%latitude = 0d0
66 env_state%altitude = 0d0
67 env_state%start_time = 0d0
68 env_state%start_day = 0
69 env_state%elapsed_time = 0d0
70 env_state%solar_zenith_angle = 0d0
71 env_state%height = 0d0
95 env_state%temp = env_state%temp + env_state_delta%temp
96 env_state%rel_humid = env_state%rel_humid + env_state_delta%rel_humid
97 env_state%pressure = env_state%pressure + env_state_delta%pressure
98 env_state%longitude = env_state%longitude + env_state_delta%longitude
99 env_state%latitude = env_state%latitude + env_state_delta%latitude
100 env_state%altitude = env_state%altitude + env_state_delta%altitude
101 env_state%start_time = env_state%start_time + env_state_delta%start_time
102 env_state%start_day = env_state%start_day + env_state_delta%start_day
103 env_state%elapsed_time = env_state%elapsed_time &
104 + env_state_delta%elapsed_time
105 env_state%solar_zenith_angle = env_state%solar_zenith_angle &
106 + env_state_delta%solar_zenith_angle
107 env_state%height = env_state%height + env_state_delta%height
119 real(kind=dp),
intent(in) :: alpha
121 env_state%temp = env_state%temp * alpha
122 env_state%rel_humid = env_state%rel_humid * alpha
123 env_state%pressure = env_state%pressure * alpha
124 env_state%longitude = env_state%longitude * alpha
125 env_state%latitude = env_state%latitude * alpha
126 env_state%altitude = env_state%altitude * alpha
127 env_state%start_time = env_state%start_time * alpha
128 env_state%start_day = nint(
real(env_state%start_day, kind=dp) * alpha)
129 env_state%elapsed_time = env_state%elapsed_time * alpha
130 env_state%solar_zenith_angle = env_state%solar_zenith_angle * alpha
131 env_state%height = env_state%height * alpha
145 env_to%temp = env_from%temp
146 env_to%rel_humid = env_from%rel_humid
147 env_to%pressure = env_from%pressure
148 env_to%longitude = env_from%longitude
149 env_to%latitude = env_from%latitude
150 env_to%altitude = env_from%altitude
151 env_to%start_time = env_from%start_time
152 env_to%start_day = env_from%start_day
153 env_to%elapsed_time = env_from%elapsed_time
154 env_to%solar_zenith_angle = env_from%solar_zenith_angle
155 env_to%height = env_from%height
168 real(kind=dp),
intent(in) :: dv
175 dmv = dv * const%water_density
177 mv = const%water_molec_weight / (const%univ_gas_const*env_state%temp) * pmv
180 call
warn_msg(980320483,
"relative humidity tried to go negative")
183 env_state%rel_humid = const%univ_gas_const * env_state%temp &
184 / const%water_molec_weight * mv &
198 * 10d0**(7.45d0 * (env_state%temp - const%water_freeze_temp) &
199 / (env_state%temp - 38d0))
225 / (const%univ_gas_const * env_state%temp)
237 env_state_a = 4d0 * const%water_surf_eng * const%water_molec_weight &
238 / (const%univ_gas_const * env_state%temp * const%water_density)
250 real(kind=dp),
intent(in) :: ppb
265 real(kind=dp),
intent(in) :: conc
275 subroutine spec_file_read_env_state(file, env_state)
319 end subroutine spec_file_read_env_state
336 val%temp = val_avg%temp
337 val%rel_humid = val_avg%rel_humid
338 val%pressure = val_avg%pressure
361 val%temp = val_avg%temp
362 val%rel_humid = val_avg%rel_humid
363 val%pressure = val_avg%pressure
399 character,
intent(inout) :: buffer(:)
401 integer,
intent(inout) :: position
406 integer :: prev_position
408 prev_position = position
432 character,
intent(inout) :: buffer(:)
434 integer,
intent(inout) :: position
439 integer :: prev_position
441 prev_position = position
481 subroutine env_state_output_netcdf(env_state, ncid)
486 integer,
intent(in) :: ncid
512 standard_name=
"air_temperature")
514 "relative_humidity", unit=
"1", standard_name=
"relative_humidity")
516 standard_name=
"air_pressure")
518 unit=
"degree_east", standard_name=
"longitude")
520 unit=
"degree_north", standard_name=
"latitude")
522 standard_name=
"altitude")
524 "start_time_of_day", unit=
"s", description=
"time-of-day of " &
525 //
"simulation start in seconds since midnight")
527 "start_day_of_year", &
528 description=
"day-of-year number of simulation start")
530 unit=
"s", description=
"elapsed time since simulation start")
532 "solar_zenith_angle", unit=
"radian", &
533 description=
"current angle from the zenith to the sun")
535 long_name=
"boundary layer mixing height")
537 end subroutine env_state_output_netcdf
547 integer,
intent(in) :: ncid
561 "solar_zenith_angle")
integer function pmc_mpi_pack_size_real(val)
Determines the number of bytes required to pack the given value.
An input file with extra data for printing messages.
integer function pmc_mpi_pack_size_integer(val)
Determines the number of bytes required to pack the given value.
subroutine pmc_mpi_pack_env_state(buffer, position, val)
Packs the given value into the buffer, advancing position.
subroutine pmc_mpi_unpack_real(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
subroutine env_state_scale(env_state, alpha)
env_state *= alpha
The env_state_t structure and associated subroutines.
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_read_integer(ncid, var, name, must_be_present)
Read a single integer from a NetCDF file.
subroutine env_state_add(env_state, env_state_delta)
env_state += env_state_delta
subroutine env_state_change_water_volume(env_state, dv)
Adds the given water volume to the water vapor and updates all environment quantities.
real(kind=dp) function env_state_a(env_state)
Condensation parameter.
subroutine spec_file_read_integer(file, name, var)
Read an integer from a spec file that must have the given name.
subroutine pmc_mpi_pack_integer(buffer, position, val)
Packs the given value into the buffer, advancing position.
real(kind=dp) function env_state_conc_to_ppb(env_state, conc)
Convert (molecules m^{-3}) to (ppb).
Common utility subroutines.
subroutine env_state_mix(val)
Average val over all processes.
Current environment state.
real(kind=dp) function env_state_air_den(env_state)
Air density (kg m^{-3}).
subroutine pmc_mpi_unpack_integer(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
subroutine env_state_deallocate(env_state)
Free all storage.
subroutine pmc_mpi_unpack_env_state(buffer, position, val)
Unpacks the given value from the buffer, advancing position.
integer function pmc_mpi_rank()
Returns the rank of the current process.
Wrapper functions for MPI.
subroutine env_state_input_netcdf(env_state, ncid)
Read full state.
subroutine env_state_copy(env_from, env_to)
env_to = env_from
subroutine pmc_nc_write_real(ncid, var, name, unit, long_name, standard_name, description)
Write a single real to a NetCDF file.
Reading formatted text input.
subroutine warn_msg(code, warning_msg, already_warned)
Prints a warning message.
Wrapper functions for NetCDF. These all take a NetCDF ncid in data mode and return with it again in d...
subroutine pmc_mpi_pack_real(buffer, position, val)
Packs the given value into the buffer, advancing position.
real(kind=dp) function env_state_air_molar_den(env_state)
Air molar density (mol m^{-3}).
real(kind=dp) function env_state_ppb_to_conc(env_state, ppb)
Convert (ppb) to (molecules m^{-3}).
subroutine pmc_nc_write_integer(ncid, var, name, unit, long_name, standard_name, description)
Write a single integer to a NetCDF file.
subroutine env_state_reduce_avg(val)
Average val over all processes, with the result only on the root process.
subroutine pmc_nc_read_real(ncid, var, name, must_be_present)
Read a single real from a NetCDF file.
subroutine env_state_allocate(env_state)
Allocate an empty environment.
real(kind=dp) function env_state_sat_vapor_pressure(env_state)
Computes the current saturation vapor pressure (Pa).
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 spec_file_read_real(file, name, var)
Read a real number from a spec file that must have the given name.
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
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...
integer function pmc_mpi_pack_size_env_state(val)
Determines the number of bytes required to pack the given value.