12#define CAMP_STATE_NUM_ENV_PARAM 2
33 real(kind=dp),
allocatable :: env_var(:)
38 real(kind=dp),
allocatable :: state_var(:)
43 logical,
private :: owns_env_states = .false.
76 type(
env_state_t),
target,
intent(in),
optional :: env_state
80 allocate(new_obj%env_states(1))
83 if (
present(env_state))
then
84 new_obj%env_states(1)%val => env_state
86 allocate(new_obj%env_states(1)%val)
87 new_obj%owns_env_states = .true.
91 allocate(new_obj%env_var(camp_state_num_env_param))
103 integer(kind=i_kind),
intent(in) :: num_cells
105 type(
env_state_ptr),
target,
intent(in),
optional :: env_states(:)
107 integer(kind=i_kind) :: i_cell
113 if (
present(env_states))
then
114 new_obj%env_states => env_states
116 allocate(new_obj%env_states(num_cells))
117 do i_cell = 1, num_cells
118 allocate(new_obj%env_states(i_cell)%val)
120 new_obj%owns_env_states = .true.
124 allocate(new_obj%env_var(camp_state_num_env_param*num_cells))
136 integer :: i_cell, grid_offset
138 do i_cell = 1,
size(this%env_states)
139 grid_offset = (i_cell-1)*camp_state_num_env_param
140 this%env_var(grid_offset+1) = this%env_states(i_cell)%val%temp
141 this%env_var(grid_offset+2) = this%env_states(i_cell)%val%pressure
154 integer(kind=i_kind) :: i_cell
156 if (
allocated(this%env_var))
deallocate(this%env_var)
157 if (
allocated(this%state_var))
deallocate(this%state_var)
158 if (
associated(this%env_states) .and. this%owns_env_states)
then
159 do i_cell = 1,
size(this%env_states)
160 deallocate(this%env_states(i_cell)%val)
162 deallocate(this%env_states)
187 if (
associated(this%val))
deallocate(this%val)
The camp_state_t structure and associated subroutines.
type(camp_state_t) function, pointer constructor_one_cell(env_state)
Constructor for camp_state_t.
elemental subroutine ptr_finalize(this)
Finalize a pointer to a camp state.
elemental subroutine finalize(this)
Finalize the state.
subroutine update_env_state(this)
Update the environmental state array.
elemental subroutine dereference(this)
Deference a pointer to a camp state.
type(camp_state_t) function, pointer constructor_multi_cell(num_cells, env_states)
Constructor for camp_state_t.
The env_state_t structure and associated subroutines.
Wrapper functions for MPI.
Common utility subroutines.
subroutine die_msg(code, error_msg)
Error immediately.
Pointer type for building arrays.
Current environment state.
String type for building arrays of string of various size.