28 double precision,
allocatable,
dimension(:) :: temperature
29 double precision,
allocatable,
dimension(:) :: potential_energy
30 double precision,
allocatable,
dimension(:) :: kinetic_energy
31 double precision,
allocatable,
dimension(:) :: internal_energy
32 double precision,
allocatable,
dimension(:,:) :: center_of_mass_velocity
41 integer :: step_offset = -1
42 double precision :: time
43 double precision :: time_offset = -1
50 integer(HID_T) :: group
51 type(h5md_element_t) :: box
52 type(h5md_element_t) :: position
53 type(h5md_element_t) :: image
54 type(h5md_element_t) :: velocity
55 type(h5md_element_t) :: force
56 type(h5md_element_t) :: id
57 type(h5md_element_t) :: species
71 subroutine ps_init(this, h5md_file, name, ps)
73 type(h5md_file_t),
intent(inout) :: h5md_file
74 character(len=*),
intent(in) :: name
80 call h5gcreate_f(h5md_file% particles, name, this% group, this% error)
82 if (this%position_info%store)
then 83 info = this%position_info
84 if ( (info%step_offset < 0) .and. (info%time_offset > 0) .or. &
85 (info%step_offset > 0) .and. (info%time_offset < 0) )
then 86 stop
'use both or neither of step_offset and time_offset in ps_init position' 88 if (iand(info%mode, h5md_time) == h5md_time)
then 89 call this%position%create_time(this% group,
'position', ps% pos, info%mode)
90 else if (iand(info%mode, h5md_linear) == h5md_linear)
then 91 if (info%step_offset > 0)
then 92 call this%position%create_time(this% group,
'position', ps% pos, info%mode, info%step, &
93 info%time, step_offset=info%step_offset, time_offset=info%time_offset)
95 call this%position%create_time(this% group,
'position', ps% pos, info%mode, info%step, &
98 else if (iand(info%mode, h5md_fixed) == h5md_fixed)
then 99 call this%position%create_fixed(this% group,
'position', ps% pos)
101 stop
'unknown storage for position in particle_system_io init' 105 if (this%velocity_info%store)
then 106 info = this%velocity_info
107 if ( (info%step_offset < 0) .and. (info%time_offset > 0) .or. &
108 (info%step_offset > 0) .and. (info%time_offset < 0) )
then 109 stop
'use both or neither of step_offset and time_offset in ps_init velocity' 111 if (iand(info%mode, h5md_time) == h5md_time)
then 112 call this%velocity%create_time(this% group,
'velocity', ps% vel, info%mode)
113 else if (iand(info%mode, h5md_linear) == h5md_linear)
then 114 if (info%step_offset > 0)
then 115 call this%velocity%create_time(this% group,
'velocity', ps% vel, info%mode, info%step, &
116 info%time, step_offset=info%step_offset, time_offset=info%time_offset)
118 call this%velocity%create_time(this% group,
'velocity', ps% vel, info%mode, info%step, &
121 else if (iand(info%mode, h5md_fixed) == h5md_fixed)
then 122 call this%velocity%create_fixed(this% group,
'velocity', ps% vel)
124 stop
'unknown storage for velocity in particle_system_io init' 128 if (this%force_info%store)
then 129 info = this%force_info
130 if ( (info%step_offset < 0) .and. (info%time_offset > 0) .or. &
131 (info%step_offset > 0) .and. (info%time_offset < 0) )
then 132 stop
'use both or neither of step_offset and time_offset in ps_init velocity' 135 if (iand(info%mode, h5md_time) == h5md_time)
then 136 call this%force%create_time(this% group,
'force', ps% vel, info%mode)
137 else if (iand(info%mode, h5md_linear) == h5md_linear)
then 138 if (info%step_offset > 0)
then 139 call this%force%create_time(this% group,
'force', ps% pos, info%mode, info%step, &
140 info%time, step_offset=info%step_offset, time_offset=info%time_offset)
142 call this%force%create_time(this% group,
'force', ps% pos, info%mode, info%step, &
145 else if (iand(info%mode, h5md_fixed) == h5md_fixed)
then 146 call this%force%create_fixed(this% group,
'force', ps% vel)
148 stop
'unknown storage for force in particle_system_io init' 152 if (this%image_info%store)
then 153 info = this%image_info
154 if ( (info%step_offset < 0) .and. (info%time_offset > 0) .or. &
155 (info%step_offset > 0) .and. (info%time_offset < 0) )
then 156 stop
'use both or neither of step_offset and time_offset in ps_init image' 159 if (iand(info%mode, h5md_time) == h5md_time)
then 160 call this%image%create_time(this% group,
'image', ps% image, info%mode)
161 else if (iand(info%mode, h5md_linear) == h5md_linear)
then 162 if (info%step_offset > 0)
then 163 call this%image%create_time(this% group,
'image', ps% image, info%mode, info%step, &
164 info%time, step_offset=info%step_offset, time_offset=info%time_offset)
166 call this%image%create_time(this% group,
'image', ps% image, info%mode, info%step, &
169 else if (iand(info%mode, h5md_fixed) == h5md_fixed)
then 170 call this%image%create_fixed(this% group,
'image', ps% image)
172 stop
'unknown storage for image in particle_system_io init' 176 if (this%id_info%store)
then 178 if ( (info%step_offset < 0) .and. (info%time_offset > 0) .or. &
179 (info%step_offset > 0) .and. (info%time_offset < 0) )
then 180 stop
'use both or neither of step_offset and time_offset in ps_init id' 183 if (iand(info%mode, h5md_time) == h5md_time)
then 184 call this%id%create_time(this% group,
'id', ps% id, info%mode)
185 else if (iand(info%mode, h5md_linear) == h5md_linear)
then 186 if (info%step_offset > 0)
then 187 call this%id%create_time(this% group,
'id', ps% id, info%mode, info%step, &
188 info%time, step_offset=info%step_offset, time_offset=info%time_offset)
190 call this%id%create_time(this% group,
'id', ps% id, info%mode, info%step, &
193 else if (iand(info%mode, h5md_fixed) == h5md_fixed)
then 194 call this%id%create_fixed(this% group,
'id', ps% id)
196 stop
'unknown storage for id in particle_system_io init' 200 if (this%species_info%store)
then 201 info = this%species_info
202 if ( (info%step_offset < 0) .and. (info%time_offset > 0) .or. &
203 (info%step_offset > 0) .and. (info%time_offset < 0) )
then 204 stop
'use both or neither of step_offset and time_offset in ps_init species' 207 if (iand(info%mode, h5md_time) == h5md_time)
then 208 call this%species%create_time(this% group,
'species', ps% species, info%mode)
209 else if (iand(info%mode, h5md_linear) == h5md_linear)
then 210 if (info%step_offset > 0)
then 211 call this%species%create_time(this% group,
'species', ps% species, info%mode, info%step, &
212 info%time, step_offset=info%step_offset, time_offset=info%time_offset)
214 call this%species%create_time(this% group,
'species', ps% species, info%mode, info%step, &
217 else if (iand(info%mode, h5md_fixed) == h5md_fixed)
then 218 call this%species%create_fixed(this% group,
'species', ps% species)
220 stop
'unknown storage for species in particle_system_io init' 229 call this% position% close()
230 call h5gclose_f(this% group, this% error)
234 subroutine thermo_init(this, datafile, n_buffer, step, time, step_offset, time_offset)
236 type(h5md_file_t),
intent(inout) :: datafile
237 integer,
intent(in) :: n_buffer
238 integer,
intent(in) :: step
239 double precision,
intent(in) :: time
240 integer,
intent(in),
optional :: step_offset
241 double precision,
intent(in),
optional :: time_offset
243 type(h5md_element_t) :: e
244 double precision :: dummy, dummy_vec(3)
247 if (n_buffer <= 0) error stop
'n_buffer non-positive in thermo_init' 249 if ( (
present(step_offset) .and. .not.
present(time_offset)) .or. &
250 (.not.
present(step_offset) .and.
present(time_offset)) ) &
252 stop
'in thermo_init, use both or neither of step_offset and time_offset' 255 this% n_buffer = n_buffer
258 mode = ior(h5md_linear, h5md_store_time)
260 allocate(this% temperature(n_buffer))
261 allocate(this% potential_energy(n_buffer))
262 allocate(this% kinetic_energy(n_buffer))
263 allocate(this% internal_energy(n_buffer))
264 allocate(this% center_of_mass_velocity(3,n_buffer))
266 if (
present(step_offset) .and.
present(time_offset))
then 267 call e%create_time(datafile%observables,
'temperature', dummy, mode, step, time, &
268 step_offset=step_offset, time_offset=time_offset)
270 call e%create_time(datafile%observables,
'potential_energy', dummy, mode, step, time, &
271 step_offset=step_offset, time_offset=time_offset)
273 call e%create_time(datafile%observables,
'kinetic_energy', dummy, mode, step, time, &
274 step_offset=step_offset, time_offset=time_offset)
276 call e%create_time(datafile%observables,
'internal_energy', dummy, mode, step, time, &
277 step_offset=step_offset, time_offset=time_offset)
279 call e%create_time(datafile%observables,
'center_of_mass_velocity', dummy_vec, mode, step, time, &
280 step_offset=step_offset, time_offset=time_offset)
283 call e%create_time(datafile%observables,
'temperature', dummy, mode, step, time)
285 call e%create_time(datafile%observables,
'potential_energy', dummy, mode, step, time)
287 call e%create_time(datafile%observables,
'kinetic_energy', dummy, mode, step, time)
289 call e%create_time(datafile%observables,
'internal_energy', dummy, mode, step, time)
291 call e%create_time(datafile%observables,
'center_of_mass_velocity', dummy_vec, mode, step, time)
297 subroutine thermo_append(this, datafile, temperature, potential_energy, kinetic_energy, internal_energy, &
298 center_of_mass_velocity, add, force)
300 type(h5md_file_t),
intent(inout) :: datafile
301 double precision,
intent(in) :: temperature, potential_energy, kinetic_energy, internal_energy
302 double precision,
intent(in) :: center_of_mass_velocity(3)
303 logical,
intent(in),
optional :: add, force
306 type(h5md_element_t) :: e
307 logical :: do_add, do_append
309 if (
present(add))
then 319 this%temperature(i) = temperature
320 this%potential_energy(i) = potential_energy
321 this%kinetic_energy(i) = kinetic_energy
322 this%internal_energy(i) = internal_energy
323 this%center_of_mass_velocity(:,i) = center_of_mass_velocity
326 do_append = (this%idx == this%n_buffer)
328 if (
present(force))
then 329 if ((force) .and. (this%idx>0))
then 335 call e%open_time(datafile%observables,
'temperature')
336 call e%append_buffer(this%temperature, force_size=this%idx)
338 call e%open_time(datafile%observables,
'potential_energy')
339 call e%append_buffer(this%potential_energy, force_size=this%idx)
341 call e%open_time(datafile%observables,
'kinetic_energy')
342 call e%append_buffer(this%kinetic_energy, force_size=this%idx)
344 call e%open_time(datafile%observables,
'internal_energy')
345 call e%append_buffer(this%internal_energy, force_size=this%idx)
347 call e%open_time(datafile%observables,
'center_of_mass_velocity')
348 call e%append_buffer(this%center_of_mass_velocity, force_size=this%idx)
subroutine thermo_append(this, datafile, temperature, potential_energy, kinetic_energy, internal_energy, center_of_mass_velocity, add, force)
Facilities for particle data I/O.
subroutine ps_init(this, h5md_file, name, ps)
subroutine ps_close(this)
subroutine thermo_init(this, datafile, n_buffer, step, time, step_offset, time_offset)