12 USE iso_c_binding,
ONLY: &
26#include "./base/base_uses.f90"
32 INTEGER,
PARAMETER :: openpmd_access_create = 0
33 INTEGER,
PARAMETER :: openpmd_access_read_only = 1
35 INTEGER,
PARAMETER :: openpmd_type_char = 0
36 INTEGER,
PARAMETER :: openpmd_type_uchar = 1
37 INTEGER,
PARAMETER :: openpmd_type_schar = 2
38 INTEGER,
PARAMETER :: openpmd_type_short = 3
39 INTEGER,
PARAMETER :: openpmd_type_int = 4
40 INTEGER,
PARAMETER :: openpmd_type_long = 5
41 INTEGER,
PARAMETER :: openpmd_type_longlong = 6
42 INTEGER,
PARAMETER :: openpmd_type_ushort = 7
43 INTEGER,
PARAMETER :: openpmd_type_uint = 8
44 INTEGER,
PARAMETER :: openpmd_type_ulong = 9
45 INTEGER,
PARAMETER :: openpmd_type_ulonglong = 10
46 INTEGER,
PARAMETER :: openpmd_type_float = 11
47 INTEGER,
PARAMETER :: openpmd_type_double = 12
48 INTEGER,
PARAMETER :: openpmd_type_long_double = 13
49 INTEGER,
PARAMETER :: openpmd_type_cfloat = 14
50 INTEGER,
PARAMETER :: openpmd_type_cdouble = 15
51 INTEGER,
PARAMETER :: openpmd_type_clong_double = 16
52 INTEGER,
PARAMETER :: openpmd_type_string = 17
53 INTEGER,
PARAMETER :: openpmd_type_vec_char = 18
54 INTEGER,
PARAMETER :: openpmd_type_vec_short = 19
55 INTEGER,
PARAMETER :: openpmd_type_vec_int = 20
56 INTEGER,
PARAMETER :: openpmd_type_vec_long = 21
57 INTEGER,
PARAMETER :: openpmd_type_vec_longlong = 22
58 INTEGER,
PARAMETER :: openpmd_type_vec_uchar = 23
59 INTEGER,
PARAMETER :: openpmd_type_vec_ushort = 24
60 INTEGER,
PARAMETER :: openpmd_type_vec_uint = 25
61 INTEGER,
PARAMETER :: openpmd_type_vec_ulong = 26
62 INTEGER,
PARAMETER :: openpmd_type_vec_ulonglong = 27
63 INTEGER,
PARAMETER :: openpmd_type_vec_float = 28
64 INTEGER,
PARAMETER :: openpmd_type_vec_double = 29
65 INTEGER,
PARAMETER :: openpmd_type_vec_long_double = 30
66 INTEGER,
PARAMETER :: openpmd_type_vec_cfloat = 31
67 INTEGER,
PARAMETER :: openpmd_type_vec_cdouble = 32
68 INTEGER,
PARAMETER :: openpmd_type_vec_clong_double = 33
69 INTEGER,
PARAMETER :: openpmd_type_vec_schar = 34
70 INTEGER,
PARAMETER :: openpmd_type_vec_string = 35
71 INTEGER,
PARAMETER :: openpmd_type_arr_dbl_7 = 36
72 INTEGER,
PARAMETER :: openpmd_type_bool = 37
75 TYPE openpmd_attributable_type
77 TYPE(C_PTR) :: c_ptr = c_null_ptr
79 PROCEDURE,
PUBLIC :: set_attribute_vec_int => openpmd_attributable_set_attribute_vec_int
80 PROCEDURE,
PUBLIC :: series_flush => openpmd_attributable_series_flush
81 END TYPE openpmd_attributable_type
83 TYPE openpmd_series_type
85 TYPE(C_PTR) :: c_ptr = c_null_ptr
87 PROCEDURE,
PUBLIC :: as_pointer
88 PROCEDURE,
PUBLIC :: as_attributable => openpmd_series_as_attributable
89 PROCEDURE,
PUBLIC :: close => openpmd_series_close
90 PROCEDURE,
PUBLIC :: present => openpmd_series_present
91 PROCEDURE,
PUBLIC :: set_software => openpmd_series_set_software
92 PROCEDURE,
PUBLIC :: write_iteration => openpmd_series_write_iteration
93 PROCEDURE,
PUBLIC :: get_iteration => openpmd_series_get_iteration
94 END TYPE openpmd_series_type
96 TYPE openpmd_iteration_type
98 TYPE(C_PTR) :: c_ptr = c_null_ptr
100 PROCEDURE,
PUBLIC :: as_attributable => openpmd_iteration_as_attributable
101 PROCEDURE,
PUBLIC :: get_mesh => openpmd_iteration_get_mesh
102 PROCEDURE,
PUBLIC :: get_particle_species => openpmd_iteration_get_particle_species
103 PROCEDURE,
PUBLIC :: close => openpmd_iteration_close
104 PROCEDURE,
PUBLIC :: open => openpmd_iteration_open
105 PROCEDURE,
PUBLIC :: closed => openpmd_iteration_closed
106 PROCEDURE,
PUBLIC :: set_time_unit_SI => openpmd_iteration_set_time_unit_si
107 PROCEDURE,
PUBLIC :: set_time => openpmd_iteration_set_time
108 END TYPE openpmd_iteration_type
110 TYPE openpmd_mesh_type
112 TYPE(C_PTR) :: c_ptr = c_null_ptr
114 PROCEDURE,
PUBLIC :: as_record_component => openpmd_mesh_as_record_component
115 PROCEDURE,
PUBLIC :: set_axis_labels => openpmd_mesh_set_axis_labels
116 PROCEDURE,
PUBLIC :: set_grid_global_offset => openpmd_mesh_set_grid_global_offset
117 PROCEDURE,
PUBLIC :: set_grid_spacing => openpmd_mesh_set_grid_spacing
118 PROCEDURE,
PUBLIC :: set_grid_unit_SI => openpmd_mesh_set_grid_unit_si
119 PROCEDURE,
PUBLIC :: set_position => openpmd_mesh_set_position
120 PROCEDURE,
PUBLIC :: set_unit_dimension => openpmd_mesh_set_unit_dimension
121 END TYPE openpmd_mesh_type
123 TYPE openpmd_particle_species_type
125 TYPE(C_PTR) :: c_ptr = c_null_ptr
127 PROCEDURE,
PUBLIC :: get_record => openpmd_particle_species_get_record
128 END TYPE openpmd_particle_species_type
130 TYPE openpmd_record_component_type
132 TYPE(C_PTR) :: c_ptr = c_null_ptr
134 PROCEDURE,
PUBLIC :: make_empty => openpmd_record_component_make_empty
135 PROCEDURE,
PUBLIC :: make_constant_zero => openpmd_record_component_make_constant_zero
136 PROCEDURE,
PUBLIC :: reset_dataset => openpmd_record_component_reset_dataset
137 PROCEDURE,
PUBLIC :: set_unit_SI => openpmd_record_component_set_unit_si
138 PROCEDURE,
PRIVATE :: store_chunk_1d_double &
139 => openpmd_record_component_store_chunk_1d_double
140 PROCEDURE,
PUBLIC :: store_chunk_span_1d_double &
141 => openpmd_record_component_store_chunk_span_1d_double
142 PROCEDURE,
PRIVATE :: store_chunk_2d_double &
143 => openpmd_record_component_store_chunk_2d_double
144 PROCEDURE,
PUBLIC :: store_chunk_span_2d_double &
145 => openpmd_record_component_store_chunk_span_2d_double
146 PROCEDURE,
PRIVATE :: store_chunk_3d_double &
147 => openpmd_record_component_store_chunk_3d_double
148 PROCEDURE,
PUBLIC :: store_chunk_span_3d_double &
149 => openpmd_record_component_store_chunk_span_3d_double
150 generic,
PUBLIC :: store_chunk => &
151 store_chunk_1d_double, &
152 store_chunk_2d_double, &
153 store_chunk_3d_double
154 END TYPE openpmd_record_component_type
156 TYPE openpmd_mesh_record_component_type
158 TYPE(C_PTR) :: c_ptr = c_null_ptr
159 END TYPE openpmd_mesh_record_component_type
161 TYPE openpmd_record_type
163 TYPE(C_PTR) :: c_ptr = c_null_ptr
165 PROCEDURE,
PUBLIC :: as_record_component => openpmd_record_as_record_component
166 PROCEDURE,
PUBLIC :: get_component => openpmd_record_get_component
167 PROCEDURE,
PUBLIC :: set_unit_dimension => openpmd_record_set_unit_dimension
168 END TYPE openpmd_record_type
170 TYPE openpmd_dynamic_memory_view_type_1d
172 INTEGER,
DIMENSION(1) :: chunk_extent
173 TYPE(C_PTR) :: c_ptr = c_null_ptr
177 PROCEDURE,
PUBLIC :: resolve_double &
178 => openpmd_dynamic_memory_view_resolve_1d_double
179 END TYPE openpmd_dynamic_memory_view_type_1d
180 TYPE openpmd_dynamic_memory_view_type_2d
182 INTEGER,
DIMENSION(2) :: chunk_extent
183 TYPE(C_PTR) :: c_ptr = c_null_ptr
187 PROCEDURE,
PUBLIC :: resolve_double &
188 => openpmd_dynamic_memory_view_resolve_2d_double
189 END TYPE openpmd_dynamic_memory_view_type_2d
190 TYPE openpmd_dynamic_memory_view_type_3d
192 INTEGER,
DIMENSION(3) :: chunk_extent
193 TYPE(C_PTR) :: c_ptr = c_null_ptr
197 PROCEDURE,
PUBLIC :: resolve_double &
198 => openpmd_dynamic_memory_view_resolve_3d_double
199 END TYPE openpmd_dynamic_memory_view_type_3d
202 PUBLIC :: openpmd_attributable_type
203 PUBLIC :: openpmd_iteration_type
204 PUBLIC :: openpmd_mesh_type
205 PUBLIC :: openpmd_particle_species_type
206 PUBLIC :: openpmd_record_component_type
207 PUBLIC :: openpmd_record_type
208 PUBLIC :: openpmd_series_type, openpmd_series_create
211 PUBLIC :: openpmd_access_create, openpmd_access_read_only
212 PUBLIC :: openpmd_get_default_extension
213 PUBLIC :: openpmd_json_merge
216 PUBLIC :: openpmd_type_arr_dbl_7
217 PUBLIC :: openpmd_type_bool
218 PUBLIC :: openpmd_type_cdouble
219 PUBLIC :: openpmd_type_cfloat
220 PUBLIC :: openpmd_type_char
221 PUBLIC :: openpmd_type_clong_double
222 PUBLIC :: openpmd_type_double
223 PUBLIC :: openpmd_type_float
224 PUBLIC :: openpmd_type_int
225 PUBLIC :: openpmd_type_long
226 PUBLIC :: openpmd_type_long_double
227 PUBLIC :: openpmd_type_longlong
228 PUBLIC :: openpmd_type_schar
229 PUBLIC :: openpmd_type_short
230 PUBLIC :: openpmd_type_string
231 PUBLIC :: openpmd_type_uchar
232 PUBLIC :: openpmd_type_uint
233 PUBLIC :: openpmd_type_ulong
234 PUBLIC :: openpmd_type_ulonglong
235 PUBLIC :: openpmd_type_ushort
236 PUBLIC :: openpmd_type_vec_cdouble
237 PUBLIC :: openpmd_type_vec_cfloat
238 PUBLIC :: openpmd_type_vec_char
239 PUBLIC :: openpmd_type_vec_clong_double
240 PUBLIC :: openpmd_type_vec_double
241 PUBLIC :: openpmd_type_vec_float
242 PUBLIC :: openpmd_type_vec_int
243 PUBLIC :: openpmd_type_vec_long
244 PUBLIC :: openpmd_type_vec_long_double
245 PUBLIC :: openpmd_type_vec_longlong
246 PUBLIC :: openpmd_type_vec_schar
247 PUBLIC :: openpmd_type_vec_short
248 PUBLIC :: openpmd_type_vec_string
249 PUBLIC :: openpmd_type_vec_uchar
250 PUBLIC :: openpmd_type_vec_uint
251 PUBLIC :: openpmd_type_vec_ulong
252 PUBLIC :: openpmd_type_vec_ulonglong
253 PUBLIC :: openpmd_type_vec_ushort
255 PUBLIC :: openpmd_series_as_attributable
256 PUBLIC :: openpmd_iteration_as_attributable
257 PUBLIC :: openpmd_record_component_as_attributable
258 PUBLIC :: openpmd_mesh_as_record_component
259 PUBLIC :: openpmd_record_as_record_component
260 PUBLIC :: openpmd_mesh_as_mesh_record_component
261 PUBLIC :: openpmd_mesh_record_component_as_record_component
262 PUBLIC :: openpmd_dynamic_memory_view_type_1d
263 PUBLIC :: openpmd_dynamic_memory_view_type_2d
264 PUBLIC :: openpmd_dynamic_memory_view_type_3d
277 FUNCTION as_pointer(this)
RESULT(res)
278 CLASS(openpmd_series_type),
INTENT(IN) :: this
282 END FUNCTION as_pointer
284 FUNCTION openpmd_series_as_attributable (this)
RESULT(res)
285 CLASS(openpmd_Series_type),
INTENT(IN) :: this
286 TYPE(openpmd_Attributable_type) :: res
289 SUBROUTINE openpmd_c_series_as_attributable (child, parent) &
290 BIND(C, name="openPMD_Series_upcast_to_Attributable")
292 TYPE(C_PTR),
VALUE :: child
293 TYPE(C_PTR) :: parent
294 END SUBROUTINE openpmd_c_series_as_attributable
297 CALL openpmd_c_series_as_attributable (this%c_ptr, res%c_ptr)
298 END FUNCTION openpmd_series_as_attributable
299 FUNCTION openpmd_iteration_as_attributable (this)
RESULT(res)
300 CLASS(openpmd_Iteration_type),
INTENT(IN) :: this
301 TYPE(openpmd_Attributable_type) :: res
304 SUBROUTINE openpmd_c_iteration_as_attributable (child, parent) &
305 BIND(C, name="openPMD_Iteration_upcast_to_Attributable")
307 TYPE(C_PTR),
VALUE :: child
308 TYPE(C_PTR) :: parent
309 END SUBROUTINE openpmd_c_iteration_as_attributable
312 CALL openpmd_c_iteration_as_attributable (this%c_ptr, res%c_ptr)
313 END FUNCTION openpmd_iteration_as_attributable
314 FUNCTION openpmd_record_component_as_attributable (this)
RESULT(res)
315 CLASS(openpmd_record_component_type),
INTENT(IN) :: this
316 TYPE(openpmd_Attributable_type) :: res
319 SUBROUTINE openpmd_c_record_component_as_attributable (child, parent) &
320 BIND(C, name="openPMD_RecordComponent_upcast_to_Attributable")
322 TYPE(C_PTR),
VALUE :: child
323 TYPE(C_PTR) :: parent
324 END SUBROUTINE openpmd_c_record_component_as_attributable
327 CALL openpmd_c_record_component_as_attributable (this%c_ptr, res%c_ptr)
328 END FUNCTION openpmd_record_component_as_attributable
329 FUNCTION openpmd_mesh_as_record_component (this)
RESULT(res)
330 CLASS(openpmd_Mesh_type),
INTENT(IN) :: this
331 TYPE(openpmd_record_component_type) :: res
334 SUBROUTINE openpmd_c_mesh_as_record_component (child, parent) &
335 BIND(C, name="openPMD_Mesh_upcast_to_RecordComponent")
337 TYPE(C_PTR),
VALUE :: child
338 TYPE(C_PTR) :: parent
339 END SUBROUTINE openpmd_c_mesh_as_record_component
342 CALL openpmd_c_mesh_as_record_component (this%c_ptr, res%c_ptr)
343 END FUNCTION openpmd_mesh_as_record_component
344 FUNCTION openpmd_record_as_record_component (this)
RESULT(res)
345 CLASS(openpmd_Record_type),
INTENT(IN) :: this
346 TYPE(openpmd_record_component_type) :: res
349 SUBROUTINE openpmd_c_record_as_record_component (child, parent) &
350 BIND(C, name="openPMD_Record_upcast_to_RecordComponent")
352 TYPE(C_PTR),
VALUE :: child
353 TYPE(C_PTR) :: parent
354 END SUBROUTINE openpmd_c_record_as_record_component
357 CALL openpmd_c_record_as_record_component (this%c_ptr, res%c_ptr)
358 END FUNCTION openpmd_record_as_record_component
359 FUNCTION openpmd_mesh_as_mesh_record_component (this)
RESULT(res)
360 CLASS(openpmd_Mesh_type),
INTENT(IN) :: this
361 TYPE(openpmd_mesh_record_component_type) :: res
364 SUBROUTINE openpmd_c_mesh_as_mesh_record_component (child, parent) &
365 BIND(C, name="openPMD_Mesh_upcast_to_MeshRecordComponent")
367 TYPE(C_PTR),
VALUE :: child
368 TYPE(C_PTR) :: parent
369 END SUBROUTINE openpmd_c_mesh_as_mesh_record_component
372 CALL openpmd_c_mesh_as_mesh_record_component (this%c_ptr, res%c_ptr)
373 END FUNCTION openpmd_mesh_as_mesh_record_component
374 FUNCTION openpmd_mesh_record_component_as_record_component (this)
RESULT(res)
375 CLASS(openpmd_mesh_record_component_type),
INTENT(IN) :: this
376 TYPE(openpmd_record_component_type) :: res
379 SUBROUTINE openpmd_c_mesh_record_component_as_record_component (child, parent) &
380 BIND(C, name="openPMD_MeshRecordComponent_upcast_to_RecordComponent")
382 TYPE(C_PTR),
VALUE :: child
383 TYPE(C_PTR) :: parent
384 END SUBROUTINE openpmd_c_mesh_record_component_as_record_component
387 CALL openpmd_c_mesh_record_component_as_record_component (this%c_ptr, res%c_ptr)
388 END FUNCTION openpmd_mesh_record_component_as_record_component
395 FUNCTION openpmd_series_present(this)
RESULT(res)
396 CLASS(openpmd_series_type),
INTENT(IN) :: this
398 INTEGER :: res_internal
401 FUNCTION openpmd_c_series_present(series)
RESULT(res) &
402 BIND(C, NAME="openPMD_Series_present")
403 IMPORT :: c_ptr, c_int
404 TYPE(C_PTR),
VALUE,
INTENT(IN) :: series
405 INTEGER(kind=C_INT) :: res
406 END FUNCTION openpmd_c_series_present
409 IF (.NOT. c_associated(this%c_ptr))
THEN
414 res_internal = openpmd_c_series_present(this%c_ptr)
415 res = res_internal /= 0
416 END FUNCTION openpmd_series_present
426 FUNCTION openpmd_series_create(path, access, mpi_comm, config)
RESULT(series)
427 CHARACTER(len=*),
INTENT(IN) :: path
428 INTEGER(kind=C_INT),
INTENT(IN) :: access
429 CLASS(mp_comm_type),
INTENT(in),
OPTIONAL :: mpi_comm
430 CHARACTER(len=*),
INTENT(IN),
OPTIONAL,
TARGET :: config
431 TYPE(openpmd_series_type) :: series
433 TYPE(c_ptr),
SAVE :: comm_c = c_null_ptr
434 CHARACTER(len=default_string_length),
TARGET,
SAVE :: default_config =
"{}"
435 CHARACTER(:),
POINTER :: my_config
444 SUBROUTINE cp2k_c_mpi_comm_f2c(comm_f, comm_c)
bind(C, name="CP2K_MPI_Comm_f2c")
446 INTEGER(kind=C_INT),
VALUE :: comm_f
447 TYPE(c_ptr) :: comm_c
448 END SUBROUTINE cp2k_c_mpi_comm_f2c
451 SUBROUTINE openpmd_c_series_create_mpi(path, access, mpi_comm, config, series) &
452 BIND(C, name="openPMD_Series_create_mpi")
453 IMPORT :: c_ptr, c_char, c_int
454 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: path
455 INTEGER(kind=C_INT),
VALUE :: access
456 TYPE(C_PTR),
value :: mpi_comm
457 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: config
458 TYPE(C_PTR) :: series
459 END SUBROUTINE openpmd_c_series_create_mpi
462 SUBROUTINE openpmd_c_series_create(path, access, config, series) &
463 BIND(C, name="openPMD_Series_create")
464 IMPORT :: c_ptr, c_char, c_int
465 TYPE(C_PTR) :: series
466 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: path
467 INTEGER(kind=C_INT),
VALUE :: access
468 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: config
469 END SUBROUTINE openpmd_c_series_create
472 IF (
PRESENT(config))
THEN
475 my_config => default_config
478 cpassert(.NOT. c_associated(series%c_ptr))
479 IF (
PRESENT(mpi_comm))
THEN
480 CALL cp2k_c_mpi_comm_f2c(mpi_comm%get_handle(), comm_c)
481 CALL openpmd_c_series_create_mpi( &
482 path=trim(path)//c_null_char, &
485 config=my_config//c_null_char, &
488 CALL openpmd_c_series_create( &
489 path=trim(path)//c_null_char, &
491 config=my_config//c_null_char, &
494 cpassert(c_associated(series%c_ptr))
495 END FUNCTION openpmd_series_create
501 SUBROUTINE openpmd_series_close(series)
502 CLASS(openpmd_series_type),
INTENT(INOUT) :: series
509 SUBROUTINE openpmd_c_series_close(series) &
510 BIND(C, name="openPMD_Series_close")
512 TYPE(C_PTR),
VALUE :: series
513 END SUBROUTINE openpmd_c_series_close
516 cpassert(c_associated(series%c_ptr))
517 CALL openpmd_c_series_close(series=series%c_ptr)
518 series%c_ptr = c_null_ptr
519 END SUBROUTINE openpmd_series_close
527 SUBROUTINE openpmd_series_set_software(this, name, version)
528 CLASS(openpmd_series_type),
INTENT(IN) :: this
529 CHARACTER(len=*),
INTENT(IN) :: name
530 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: version
533 SUBROUTINE openpmd_c_series_set_software(series, name, version) &
534 BIND(C, name="openPMD_Series_setSoftware")
535 IMPORT :: c_ptr, c_char
536 TYPE(C_PTR),
VALUE :: series
537 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: name
538 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: version
539 END SUBROUTINE openpmd_c_series_set_software
542 cpassert(c_associated(this%c_ptr))
543 IF (
PRESENT(version))
THEN
544 CALL openpmd_c_series_set_software(this%c_ptr, name//c_null_char, version//c_null_char)
546 CALL openpmd_c_series_set_software(this%c_ptr, name//c_null_char, c_null_char)
548 END SUBROUTINE openpmd_series_set_software
556 FUNCTION openpmd_series_write_iteration(this, index)
RESULT(iteration)
557 CLASS(openpmd_series_type) :: this
558 INTEGER,
TARGET :: index
559 TYPE(openpmd_iteration_type) :: iteration
561 INTEGER(8) :: cast_index
562 INTEGER(kind=C_INT) :: status
564 FUNCTION openpmd_c_series_write_iteration(series, index, iteration)
RESULT(status) &
565 BIND(C, name="openPMD_Series_write_Iteration")
566 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t
567 TYPE(C_PTR),
VALUE :: series
568 INTEGER(kind=C_INT64_T),
VALUE :: index
569 TYPE(C_PTR) :: iteration
570 INTEGER(KIND=C_INT) :: status
571 END FUNCTION openpmd_c_series_write_iteration
574 cpassert(.NOT. c_associated(iteration%c_ptr))
576 status = openpmd_c_series_write_iteration(this%c_ptr, cast_index, iteration%c_ptr)
577 cpassert(c_associated(iteration%c_ptr))
578 END FUNCTION openpmd_series_write_iteration
580 FUNCTION openpmd_series_get_iteration(this, index)
RESULT(iteration)
581 CLASS(openpmd_series_type) :: this
582 INTEGER,
TARGET :: index
583 TYPE(openpmd_iteration_type) :: iteration
585 INTEGER(8) :: cast_index
586 INTEGER(kind=C_INT) :: status
588 FUNCTION openpmd_c_series_get_iteration(series, index, iteration)
RESULT(status) &
589 BIND(C, name="openPMD_Series_get_Iteration")
590 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t
591 TYPE(C_PTR),
VALUE :: series
592 INTEGER(kind=C_INT64_T),
VALUE :: index
593 TYPE(C_PTR) :: iteration
594 INTEGER(KIND=C_INT) :: status
595 END FUNCTION openpmd_c_series_get_iteration
598 cpassert(.NOT. c_associated(iteration%c_ptr))
600 status = openpmd_c_series_get_iteration(this%c_ptr, cast_index, iteration%c_ptr)
601 cpassert(c_associated(iteration%c_ptr))
602 END FUNCTION openpmd_series_get_iteration
608 FUNCTION openpmd_get_default_extension()
RESULT(extension)
609 CHARACTER(len=default_string_length) :: extension
611 CHARACTER(kind=C_CHAR),
POINTER :: c_extension
612 INTEGER(C_SIZE_T) :: length_of_c_string, i
614 FUNCTION openpmd_c_get_default_extension()
RESULT(extension) &
615 BIND(c, name="openPMD_get_default_extension")
617 CHARACTER(kind=C_CHAR),
POINTER :: extension
618 END FUNCTION openpmd_c_get_default_extension
621 FUNCTION get_strlen(c_string)
RESULT(strlen) &
622 BIND(C, NAME="CP2K_strlen")
623 IMPORT :: c_char, c_size_t
624 CHARACTER(kind=C_CHAR),
DIMENSION(*),
INTENT(IN) :: c_string
625 INTEGER(C_SIZE_T) :: strlen
626 END FUNCTION get_strlen
629 c_extension => openpmd_c_get_default_extension()
632 IF (
ASSOCIATED(c_extension))
THEN
634 length_of_c_string = get_strlen(c_extension)
645 extension = trim(adjustl(transfer(c_extension(1:length_of_c_string), extension)))
647 DO i = length_of_c_string + 1, len(extension)
651 END FUNCTION openpmd_get_default_extension
659 SUBROUTINE openpmd_attributable_set_attribute_vec_int(this, name, vec)
660 CLASS(openpmd_attributable_type) :: this
661 CHARACTER(len=*),
INTENT(IN) :: name
662 INTEGER,
DIMENSION(:),
TARGET :: vec
664 INTEGER,
TARGET :: size_
666 SUBROUTINE openpmd_c_attributable_set_attribute_vec_int(attributable, name, vec, length) &
667 BIND(C, NAME="openPMD_attributable_set_attribute_vec_int")
668 IMPORT :: c_char, c_size_t, c_int, c_ptr
669 TYPE(C_PTR),
VALUE :: attributable
670 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: name
671 TYPE(C_PTR),
VALUE :: vec
672 INTEGER(kind=C_INT),
VALUE :: length
673 END SUBROUTINE openpmd_c_attributable_set_attribute_vec_int
677 CALL openpmd_c_attributable_set_attribute_vec_int( &
678 this%c_ptr, name//c_null_char, c_loc(vec(1)), size_)
680 END SUBROUTINE openpmd_attributable_set_attribute_vec_int
682 SUBROUTINE openpmd_attributable_series_flush(this, backendconfig)
683 CLASS(openpmd_attributable_type) :: this
684 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: backendconfig
685 CHARACTER(len=default_string_length),
SAVE :: my_backendconfig =
""
688 SUBROUTINE openpmd_c_attributable_series_flush(attributable, config) &
689 BIND(C, NAME="openPMD_Attributable_series_flush")
690 IMPORT :: c_char, c_size_t, c_int, c_ptr
691 TYPE(C_PTR),
VALUE :: attributable
692 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: config
693 END SUBROUTINE openpmd_c_attributable_series_flush
696 IF (
PRESENT(backendconfig)) my_backendconfig = backendconfig
697 CALL openpmd_c_attributable_series_flush(this%c_ptr, my_backendconfig//c_null_char)
698 END SUBROUTINE openpmd_attributable_series_flush
700 SUBROUTINE openpmd_iteration_set_time_unit_si(this, timeUnitSI)
701 CLASS(openpmd_iteration_type) :: this
702 REAL(kind=c_double),
INTENT(IN),
VALUE :: timeunitsi
705 SUBROUTINE openpmd_c_iteration_set_time_unit_si(iteration, timeUnitSI) &
706 BIND(C, NAME="openPMD_Iteration_setTimeUnitSI")
707 IMPORT :: c_ptr, c_double
708 TYPE(C_PTR),
VALUE :: iteration
709 REAL(kind=c_double),
VALUE :: timeunitsi
710 END SUBROUTINE openpmd_c_iteration_set_time_unit_si
713 CALL openpmd_c_iteration_set_time_unit_si(this%c_ptr, timeunitsi)
714 END SUBROUTINE openpmd_iteration_set_time_unit_si
716 SUBROUTINE openpmd_iteration_set_time(this, time)
717 CLASS(openpmd_iteration_type) :: this
718 REAL(kind=c_double),
INTENT(IN),
VALUE :: time
721 SUBROUTINE openpmd_c_iteration_set_time(iteration, time) &
722 BIND(C, NAME="openPMD_Iteration_setTime")
723 IMPORT :: c_ptr, c_double
724 TYPE(C_PTR),
VALUE :: iteration
725 REAL(kind=c_double),
VALUE :: time
726 END SUBROUTINE openpmd_c_iteration_set_time
729 CALL openpmd_c_iteration_set_time(this%c_ptr, time)
730 END SUBROUTINE openpmd_iteration_set_time
732 FUNCTION openpmd_json_merge(into, from, mpi_comm)
RESULT(merged)
733 CHARACTER(len=*),
INTENT(IN) :: into, from
734 CLASS(mp_comm_type),
INTENT(in),
OPTIONAL :: mpi_comm
735 CHARACTER(:),
ALLOCATABLE :: merged
736 CHARACTER(kind=C_CHAR),
POINTER :: c_merged
737 INTEGER(C_SIZE_T) :: length_of_c_string
738 TYPE(c_ptr),
SAVE :: comm_c = c_null_ptr
748 SUBROUTINE cp2k_c_mpi_comm_f2c(comm_f, comm_c)
bind(C, name="CP2K_MPI_Comm_f2c")
750 INTEGER(kind=C_INT),
VALUE :: comm_f
751 TYPE(c_ptr) :: comm_c
752 END SUBROUTINE cp2k_c_mpi_comm_f2c
755 FUNCTION openpmd_c_json_merge(into, from, mpi_comm)
RESULT(merged) &
756 BIND(C, NAME="openPMD_json_merge")
757 IMPORT :: c_char, c_int, c_ptr
758 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: into, from
759 TYPE(C_PTR),
value :: mpi_comm
760 CHARACTER(kind=C_CHAR),
POINTER :: merged
761 END FUNCTION openpmd_c_json_merge
764 FUNCTION get_strlen(c_string)
RESULT(strlen) &
765 BIND(C, NAME="CP2K_strlen")
766 IMPORT :: c_char, c_size_t
767 CHARACTER(kind=C_CHAR),
DIMENSION(*),
INTENT(IN) :: c_string
768 INTEGER(C_SIZE_T) :: strlen
769 END FUNCTION get_strlen
772 SUBROUTINE free(c_string) &
773 BIND(C, NAME="CP2K_free")
775 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: c_string
779 IF (
PRESENT(mpi_comm))
THEN
780 CALL cp2k_c_mpi_comm_f2c(mpi_comm%get_handle(), comm_c)
782 c_merged => openpmd_c_json_merge(into//c_null_char, from//c_null_char, comm_c)
783 length_of_c_string = get_strlen(c_merged)
784 ALLOCATE (
character(length_of_c_string) :: merged)
785 merged = trim(adjustl(transfer(c_merged(1:length_of_c_string), merged)))
787 END FUNCTION openpmd_json_merge
795 FUNCTION openpmd_iteration_get_mesh(this, name)
RESULT(mesh)
796 CLASS(openpmd_iteration_type) :: this
797 CHARACTER(len=*),
INTENT(IN) :: name
798 TYPE(openpmd_mesh_type) :: mesh
800 INTEGER(kind=C_INT) :: status
802 FUNCTION openpmd_c_iteration_get_mesh(iteration, name, mesh)
RESULT(status) &
803 BIND(C, name="openPMD_Iteration_get_mesh")
804 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
805 TYPE(C_PTR),
VALUE :: iteration
806 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: name
808 INTEGER(KIND=C_INT) :: status
809 END FUNCTION openpmd_c_iteration_get_mesh
812 cpassert(.NOT. c_associated(mesh%c_ptr))
813 status = openpmd_c_iteration_get_mesh(this%c_ptr, name//c_null_char, mesh%c_ptr)
814 cpassert(c_associated(mesh%c_ptr))
815 END FUNCTION openpmd_iteration_get_mesh
823 FUNCTION openpmd_iteration_get_particle_species(this, name)
RESULT(particle_species)
824 CLASS(openpmd_iteration_type) :: this
825 CHARACTER(len=*),
INTENT(IN) :: name
826 TYPE(openpmd_particle_species_type) :: particle_species
828 INTEGER(kind=C_INT) :: status
830 FUNCTION openpmd_c_iteration_get_particle_species(iteration, name, particle_species)
RESULT(status) &
831 BIND(C, name="openPMD_Iteration_get_particle_species")
832 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
833 TYPE(C_PTR),
VALUE :: iteration
834 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: name
835 TYPE(C_PTR) :: particle_species
836 INTEGER(KIND=C_INT) :: status
837 END FUNCTION openpmd_c_iteration_get_particle_species
840 cpassert(.NOT. c_associated(particle_species%c_ptr))
841 status = openpmd_c_iteration_get_particle_species( &
842 this%c_ptr, name//c_null_char, particle_species%c_ptr)
843 cpassert(c_associated(particle_species%c_ptr))
844 END FUNCTION openpmd_iteration_get_particle_species
850 SUBROUTINE openpmd_iteration_open(iteration)
851 CLASS(openpmd_iteration_type),
INTENT(INOUT) :: iteration
858 SUBROUTINE openpmd_c_iteration_open(iteration) &
859 BIND(C, name="openPMD_Iteration_open")
861 TYPE(C_PTR),
VALUE :: iteration
862 END SUBROUTINE openpmd_c_iteration_open
865 cpassert(c_associated(iteration%c_ptr))
866 CALL openpmd_c_iteration_open(iteration=iteration%c_ptr)
867 END SUBROUTINE openpmd_iteration_open
869 SUBROUTINE openpmd_iteration_close(iteration)
870 CLASS(openpmd_iteration_type),
INTENT(INOUT) :: iteration
877 SUBROUTINE openpmd_c_iteration_close(iteration) &
878 BIND(C, name="openPMD_Iteration_close")
880 TYPE(C_PTR),
VALUE :: iteration
881 END SUBROUTINE openpmd_c_iteration_close
884 cpassert(c_associated(iteration%c_ptr))
885 CALL openpmd_c_iteration_close(iteration=iteration%c_ptr)
886 iteration%c_ptr = c_null_ptr
887 END SUBROUTINE openpmd_iteration_close
889 FUNCTION openpmd_iteration_closed(iteration)
RESULT(res)
890 CLASS(openpmd_iteration_type),
INTENT(IN) :: iteration
893 INTEGER(kind=C_INT) :: res_tmp
900 FUNCTION openpmd_c_iteration_closed(iteration)
RESULT(res) &
901 BIND(C, name="openPMD_Iteration_closed")
902 IMPORT :: c_ptr, c_int
903 TYPE(C_PTR),
VALUE :: iteration
904 INTEGER(kind=C_INT) :: res
905 END FUNCTION openpmd_c_iteration_closed
908 cpassert(c_associated(iteration%c_ptr))
909 res_tmp = openpmd_c_iteration_closed(iteration=iteration%c_ptr)
910 IF (res_tmp == 0)
THEN
915 END FUNCTION openpmd_iteration_closed
923 SUBROUTINE openpmd_record_component_make_empty(this, dtype, dimensionality)
924 CLASS(openpmd_record_component_type) :: this
925 INTEGER(kind=C_INT) :: dtype
926 INTEGER :: dimensionality
928 INTEGER(kind=C_INT) :: status
930 FUNCTION openpmd_c_record_component_make_empty(record_component, dtype, dimensionality)
RESULT(status) &
931 BIND(C, name="openPMD_RecordComponent_makeEmpty")
932 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
933 TYPE(C_PTR),
VALUE :: record_component
934 INTEGER(KIND=C_INT),
VALUE :: dtype
935 INTEGER(KIND=C_INT),
VALUE :: dimensionality
936 INTEGER(KIND=C_INT) :: status
937 END FUNCTION openpmd_c_record_component_make_empty
940 status = openpmd_c_record_component_make_empty(this%c_ptr, dtype, dimensionality)
941 END SUBROUTINE openpmd_record_component_make_empty
949 SUBROUTINE openpmd_record_component_make_constant_zero(this, dtype, extent)
950 CLASS(openpmd_record_component_type) :: this
951 INTEGER(kind=C_INT) :: dtype
952 INTEGER,
DIMENSION(:),
TARGET :: extent
954 INTEGER(kind=C_INT) :: status
956 FUNCTION openpmd_c_record_component_make_constant( &
957 record_component, dtype, dimensions, extent, invert, value)
RESULT(status) &
958 BIND(C, name="openPMD_RecordComponent_makeConstant")
959 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
960 TYPE(C_PTR),
VALUE :: record_component
961 INTEGER(KIND=C_INT),
VALUE :: dtype
962 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
963 TYPE(C_PTR),
VALUE :: extent
964 TYPE(C_PTR),
VALUE :: value
965 INTEGER(KIND=C_INT) :: status
966 END FUNCTION openpmd_c_record_component_make_constant
969 status = openpmd_c_record_component_make_constant( &
970 this%c_ptr, dtype,
SIZE(extent), c_loc(extent(1)), 1, c_null_ptr)
971 END SUBROUTINE openpmd_record_component_make_constant_zero
973 SUBROUTINE openpmd_mesh_set_axis_labels(this, labels)
974 CLASS(openpmd_mesh_type) :: this
975 CHARACTER(len=*),
DIMENSION(:) :: labels
978 CHARACTER(len=default_string_length),
ALLOCATABLE,
TARGET :: labels_as_null_terminated_strings(:)
979 TYPE(C_PTR),
ALLOCATABLE,
TARGET :: labels_as_c_strings(:)
982 SUBROUTINE openpmd_c_mesh_set_axis_labels(mesh, labels, len_labels, invert) &
983 BIND(C, NAME="openPMD_Mesh_set_axis_labels")
984 IMPORT :: c_char, c_size_t, c_int, c_ptr
985 TYPE(C_PTR),
VALUE :: mesh
986 TYPE(C_PTR),
VALUE :: labels
987 INTEGER(kind=C_INT),
VALUE :: len_labels, invert
988 END SUBROUTINE openpmd_c_mesh_set_axis_labels
991 ALLOCATE (labels_as_null_terminated_strings(
SIZE(labels)))
992 ALLOCATE (labels_as_c_strings(
SIZE(labels)))
994 DO i = 1,
SIZE(labels)
995 labels_as_null_terminated_strings(i) = trim(labels(i))//c_null_char
996 labels_as_c_strings(i) = c_loc(labels_as_null_terminated_strings(i))
999 CALL openpmd_c_mesh_set_axis_labels(this%c_ptr, c_loc(labels_as_c_strings(1)),
SIZE(labels), invert=1)
1001 DEALLOCATE (labels_as_c_strings)
1002 DEALLOCATE (labels_as_null_terminated_strings)
1003 END SUBROUTINE openpmd_mesh_set_axis_labels
1005 SUBROUTINE openpmd_record_component_reset_dataset(this, dtype, extent, cfg)
1006 CLASS(openpmd_record_component_type) :: this
1007 INTEGER(kind=C_INT) :: dtype
1008 INTEGER,
DIMENSION(:),
TARGET :: extent
1009 CHARACTER(len=*),
OPTIONAL :: cfg
1011 CHARACTER(len=default_string_length),
SAVE :: my_config =
"{}"
1012 INTEGER(kind=C_INT) :: status
1014 FUNCTION openpmd_c_record_component_reset_dataset( &
1015 record_component, dtype, dimensions, extent, invert, cfg)
RESULT(status) &
1016 BIND(C, name="openPMD_RecordComponent_resetDataset")
1017 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1018 TYPE(C_PTR),
VALUE :: record_component
1019 INTEGER(KIND=C_INT),
VALUE :: dtype
1020 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1021 TYPE(C_PTR),
VALUE :: extent
1022 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: cfg
1023 INTEGER(KIND=C_INT) :: status
1024 END FUNCTION openpmd_c_record_component_reset_dataset
1027 IF (
PRESENT(cfg)) my_config = cfg
1029 status = openpmd_c_record_component_reset_dataset( &
1030 this%c_ptr, dtype,
SIZE(extent), c_loc(extent(1)), 1, my_config//c_null_char)
1031 END SUBROUTINE openpmd_record_component_reset_dataset
1033 SUBROUTINE openpmd_record_component_set_unit_si(this, unitSI)
1034 CLASS(openpmd_record_component_type) :: this
1035 REAL(kind=c_double),
INTENT(IN),
VALUE :: unitsi
1038 SUBROUTINE openpmd_c_record_component_set_unit_si(record_component, unitSI) &
1039 BIND(C, NAME="openPMD_RecordComponent_setUnitSI")
1040 IMPORT :: c_ptr, c_double
1041 TYPE(C_PTR),
VALUE :: record_component
1042 REAL(kind=c_double),
VALUE :: unitsi
1043 END SUBROUTINE openpmd_c_record_component_set_unit_si
1046 CALL openpmd_c_record_component_set_unit_si(this%c_ptr, unitsi)
1047 END SUBROUTINE openpmd_record_component_set_unit_si
1050 SUBROUTINE openpmd_record_component_store_chunk_1d_double (record_component, data_, offset)
1051 CLASS(openpmd_record_component_type) :: record_component
1052 REAL(kind=
dp),
TARGET :: data_(:)
1053 INTEGER,
DIMENSION(1),
TARGET :: offset, extent
1055 INTEGER(kind=C_INT) :: status
1058 FUNCTION openpmd_c_record_component_store_chunk( &
1059 record_component, dtype, dimensions, offset, extent, invert, data_)
RESULT(status) &
1060 BIND(C, name="openPMD_RecordComponent_storeChunk")
1061 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1062 TYPE(C_PTR),
VALUE :: record_component
1063 INTEGER(KIND=C_INT),
VALUE :: dtype
1064 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1065 TYPE(C_PTR),
VALUE :: offset, extent
1066 TYPE(C_PTR),
VALUE :: data_
1067 INTEGER(KIND=C_INT) :: status
1068 END FUNCTION openpmd_c_record_component_store_chunk
1071 extent = shape(data_)
1072 status = openpmd_c_record_component_store_chunk( &
1073 record_component%c_ptr, &
1074 openpmd_type_double, &
1081 END SUBROUTINE openpmd_record_component_store_chunk_1d_double
1083 FUNCTION openpmd_record_component_store_chunk_span_1d_double ( &
1084 record_component, offset, extent)
RESULT(memory_view)
1085 CLASS(openpmd_record_component_type) :: record_component
1086 INTEGER,
DIMENSION(1),
TARGET :: offset, extent
1088 TYPE(openpmd_dynamic_memory_view_type_1d) :: memory_view
1090 INTEGER(kind=C_INT) :: status
1093 FUNCTION openpmd_c_record_component_store_chunk_span( &
1094 record_component, dtype, dimensions, offset, extent, invert, memory_view)
RESULT(status) &
1095 BIND(C, name="openPMD_RecordComponent_storeChunkSpan")
1096 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1097 TYPE(C_PTR),
VALUE :: record_component
1098 INTEGER(KIND=C_INT),
VALUE :: dtype
1099 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1100 TYPE(C_PTR),
VALUE :: offset, extent
1101 TYPE(C_PTR) :: memory_view
1102 INTEGER(KIND=C_INT) :: status
1103 END FUNCTION openpmd_c_record_component_store_chunk_span
1106 memory_view%chunk_extent = extent
1107 status = openpmd_c_record_component_store_chunk_span( &
1108 record_component%c_ptr, &
1109 openpmd_type_double, &
1116 END FUNCTION openpmd_record_component_store_chunk_span_1d_double
1118 FUNCTION openpmd_dynamic_memory_view_resolve_1d_double (memory_view, deallocate)
RESULT(buffer)
1119 CLASS(openpmd_dynamic_memory_view_type_1d) :: memory_view
1120 LOGICAL :: deallocate
1121 REAL(kind=
dp),
POINTER :: buffer(:)
1123 INTEGER(kind=C_INT) :: status, deallocate_c
1124 TYPE(C_PTR),
TARGET :: c_buffer
1127 FUNCTION openpmd_c_dynamic_memory_view_resolve(memory_view, deallocate, write_buffer)
RESULT(status) &
1128 BIND(C, name="openPMD_DynamicMemoryView_resolve")
1129 IMPORT :: c_ptr, c_int
1130 TYPE(C_PTR),
VALUE :: memory_view
1131 INTEGER(KIND=C_INT),
VALUE :: deallocate
1132 TYPE(C_PTR) :: write_buffer
1133 INTEGER(KIND=C_INT) :: status
1134 END FUNCTION openpmd_c_dynamic_memory_view_resolve
1137 IF (deallocate)
THEN
1143 status = openpmd_c_dynamic_memory_view_resolve(memory_view%c_ptr, deallocate_c, c_buffer)
1144 CALL c_f_pointer(c_buffer, buffer, memory_view%chunk_extent)
1145 END FUNCTION openpmd_dynamic_memory_view_resolve_1d_double
1147 SUBROUTINE openpmd_record_component_store_chunk_2d_double (record_component, data_, offset)
1148 CLASS(openpmd_record_component_type) :: record_component
1149 REAL(kind=
dp),
TARGET :: data_(:,:)
1150 INTEGER,
DIMENSION(2),
TARGET :: offset, extent
1152 INTEGER(kind=C_INT) :: status
1155 FUNCTION openpmd_c_record_component_store_chunk( &
1156 record_component, dtype, dimensions, offset, extent, invert, data_)
RESULT(status) &
1157 BIND(C, name="openPMD_RecordComponent_storeChunk")
1158 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1159 TYPE(C_PTR),
VALUE :: record_component
1160 INTEGER(KIND=C_INT),
VALUE :: dtype
1161 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1162 TYPE(C_PTR),
VALUE :: offset, extent
1163 TYPE(C_PTR),
VALUE :: data_
1164 INTEGER(KIND=C_INT) :: status
1165 END FUNCTION openpmd_c_record_component_store_chunk
1168 extent = shape(data_)
1169 status = openpmd_c_record_component_store_chunk( &
1170 record_component%c_ptr, &
1171 openpmd_type_double, &
1178 END SUBROUTINE openpmd_record_component_store_chunk_2d_double
1180 FUNCTION openpmd_record_component_store_chunk_span_2d_double ( &
1181 record_component, offset, extent)
RESULT(memory_view)
1182 CLASS(openpmd_record_component_type) :: record_component
1183 INTEGER,
DIMENSION(2),
TARGET :: offset, extent
1185 TYPE(openpmd_dynamic_memory_view_type_2d) :: memory_view
1187 INTEGER(kind=C_INT) :: status
1190 FUNCTION openpmd_c_record_component_store_chunk_span( &
1191 record_component, dtype, dimensions, offset, extent, invert, memory_view)
RESULT(status) &
1192 BIND(C, name="openPMD_RecordComponent_storeChunkSpan")
1193 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1194 TYPE(C_PTR),
VALUE :: record_component
1195 INTEGER(KIND=C_INT),
VALUE :: dtype
1196 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1197 TYPE(C_PTR),
VALUE :: offset, extent
1198 TYPE(C_PTR) :: memory_view
1199 INTEGER(KIND=C_INT) :: status
1200 END FUNCTION openpmd_c_record_component_store_chunk_span
1203 memory_view%chunk_extent = extent
1204 status = openpmd_c_record_component_store_chunk_span( &
1205 record_component%c_ptr, &
1206 openpmd_type_double, &
1213 END FUNCTION openpmd_record_component_store_chunk_span_2d_double
1215 FUNCTION openpmd_dynamic_memory_view_resolve_2d_double (memory_view, deallocate)
RESULT(buffer)
1216 CLASS(openpmd_dynamic_memory_view_type_2d) :: memory_view
1217 LOGICAL :: deallocate
1218 REAL(kind=
dp),
POINTER :: buffer(:,:)
1220 INTEGER(kind=C_INT) :: status, deallocate_c
1221 TYPE(C_PTR),
TARGET :: c_buffer
1224 FUNCTION openpmd_c_dynamic_memory_view_resolve(memory_view, deallocate, write_buffer)
RESULT(status) &
1225 BIND(C, name="openPMD_DynamicMemoryView_resolve")
1226 IMPORT :: c_ptr, c_int
1227 TYPE(C_PTR),
VALUE :: memory_view
1228 INTEGER(KIND=C_INT),
VALUE :: deallocate
1229 TYPE(C_PTR) :: write_buffer
1230 INTEGER(KIND=C_INT) :: status
1231 END FUNCTION openpmd_c_dynamic_memory_view_resolve
1234 IF (deallocate)
THEN
1240 status = openpmd_c_dynamic_memory_view_resolve(memory_view%c_ptr, deallocate_c, c_buffer)
1241 CALL c_f_pointer(c_buffer, buffer, memory_view%chunk_extent)
1242 END FUNCTION openpmd_dynamic_memory_view_resolve_2d_double
1244 SUBROUTINE openpmd_record_component_store_chunk_3d_double (record_component, data_, offset)
1245 CLASS(openpmd_record_component_type) :: record_component
1246 REAL(kind=
dp),
TARGET :: data_(:,:,:)
1247 INTEGER,
DIMENSION(3),
TARGET :: offset, extent
1249 INTEGER(kind=C_INT) :: status
1252 FUNCTION openpmd_c_record_component_store_chunk( &
1253 record_component, dtype, dimensions, offset, extent, invert, data_)
RESULT(status) &
1254 BIND(C, name="openPMD_RecordComponent_storeChunk")
1255 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1256 TYPE(C_PTR),
VALUE :: record_component
1257 INTEGER(KIND=C_INT),
VALUE :: dtype
1258 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1259 TYPE(C_PTR),
VALUE :: offset, extent
1260 TYPE(C_PTR),
VALUE :: data_
1261 INTEGER(KIND=C_INT) :: status
1262 END FUNCTION openpmd_c_record_component_store_chunk
1265 extent = shape(data_)
1266 status = openpmd_c_record_component_store_chunk( &
1267 record_component%c_ptr, &
1268 openpmd_type_double, &
1275 END SUBROUTINE openpmd_record_component_store_chunk_3d_double
1277 FUNCTION openpmd_record_component_store_chunk_span_3d_double ( &
1278 record_component, offset, extent)
RESULT(memory_view)
1279 CLASS(openpmd_record_component_type) :: record_component
1280 INTEGER,
DIMENSION(3),
TARGET :: offset, extent
1282 TYPE(openpmd_dynamic_memory_view_type_3d) :: memory_view
1284 INTEGER(kind=C_INT) :: status
1287 FUNCTION openpmd_c_record_component_store_chunk_span( &
1288 record_component, dtype, dimensions, offset, extent, invert, memory_view)
RESULT(status) &
1289 BIND(C, name="openPMD_RecordComponent_storeChunkSpan")
1290 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1291 TYPE(C_PTR),
VALUE :: record_component
1292 INTEGER(KIND=C_INT),
VALUE :: dtype
1293 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1294 TYPE(C_PTR),
VALUE :: offset, extent
1295 TYPE(C_PTR) :: memory_view
1296 INTEGER(KIND=C_INT) :: status
1297 END FUNCTION openpmd_c_record_component_store_chunk_span
1300 memory_view%chunk_extent = extent
1301 status = openpmd_c_record_component_store_chunk_span( &
1302 record_component%c_ptr, &
1303 openpmd_type_double, &
1310 END FUNCTION openpmd_record_component_store_chunk_span_3d_double
1312 FUNCTION openpmd_dynamic_memory_view_resolve_3d_double (memory_view, deallocate)
RESULT(buffer)
1313 CLASS(openpmd_dynamic_memory_view_type_3d) :: memory_view
1314 LOGICAL :: deallocate
1315 REAL(kind=
dp),
POINTER :: buffer(:,:,:)
1317 INTEGER(kind=C_INT) :: status, deallocate_c
1318 TYPE(C_PTR),
TARGET :: c_buffer
1321 FUNCTION openpmd_c_dynamic_memory_view_resolve(memory_view, deallocate, write_buffer)
RESULT(status) &
1322 BIND(C, name="openPMD_DynamicMemoryView_resolve")
1323 IMPORT :: c_ptr, c_int
1324 TYPE(C_PTR),
VALUE :: memory_view
1325 INTEGER(KIND=C_INT),
VALUE :: deallocate
1326 TYPE(C_PTR) :: write_buffer
1327 INTEGER(KIND=C_INT) :: status
1328 END FUNCTION openpmd_c_dynamic_memory_view_resolve
1331 IF (deallocate)
THEN
1337 status = openpmd_c_dynamic_memory_view_resolve(memory_view%c_ptr, deallocate_c, c_buffer)
1338 CALL c_f_pointer(c_buffer, buffer, memory_view%chunk_extent)
1339 END FUNCTION openpmd_dynamic_memory_view_resolve_3d_double
1347 FUNCTION openpmd_particle_species_get_record(this, name)
RESULT(record)
1348 CLASS(openpmd_particle_species_type) :: this
1349 CHARACTER(len=*),
INTENT(IN) :: name
1350 TYPE(openpmd_record_type) :: record
1352 INTEGER(kind=C_INT) :: status
1354 FUNCTION openpmd_c_particle_species_get_record(particle_species, name, record)
RESULT(status) &
1355 BIND(C, name="openPMD_ParticleSpecies_get_Record")
1356 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1357 TYPE(C_PTR),
VALUE :: particle_species
1358 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: name
1359 TYPE(C_PTR) :: record
1360 INTEGER(KIND=C_INT) :: status
1361 END FUNCTION openpmd_c_particle_species_get_record
1364 cpassert(.NOT. c_associated(record%c_ptr))
1365 status = openpmd_c_particle_species_get_record(this%c_ptr, name//c_null_char, record%c_ptr)
1366 cpassert(c_associated(record%c_ptr))
1367 END FUNCTION openpmd_particle_species_get_record
1375 FUNCTION openpmd_record_get_component(this, name)
RESULT(record_component)
1376 CLASS(openpmd_record_type) :: this
1377 CHARACTER(len=*),
INTENT(IN) :: name
1378 TYPE(openpmd_record_component_type) :: record_component
1380 INTEGER(kind=C_INT) :: status
1382 FUNCTION openpmd_c_record_get_component(record, name, record_component)
RESULT(status) &
1383 BIND(C, name="openPMD_Record_get_Component")
1384 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1385 TYPE(C_PTR),
VALUE :: record
1386 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: name
1387 TYPE(C_PTR) :: record_component
1388 INTEGER(KIND=C_INT) :: status
1389 END FUNCTION openpmd_c_record_get_component
1392 cpassert(.NOT. c_associated(record_component%c_ptr))
1393 status = openpmd_c_record_get_component(this%c_ptr, name//c_null_char, record_component%c_ptr)
1394 cpassert(c_associated(record_component%c_ptr))
1395 END FUNCTION openpmd_record_get_component
1404 SUBROUTINE openpmd_record_set_unit_dimension(this, unitDimension)
1405 CLASS(openpmd_record_type) :: this
1406 REAL(kind=c_double),
DIMENSION(7),
TARGET :: unitdimension
1409 SUBROUTINE openpmd_c_record_set_unit_dimension(record, unitDimension) &
1410 BIND(C, NAME="openPMD_Record_setUnitDimension")
1411 IMPORT :: c_ptr, c_double
1412 TYPE(C_PTR),
VALUE :: record
1413 REAL(kind=c_double),
DIMENSION(*) :: unitdimension
1414 END SUBROUTINE openpmd_c_record_set_unit_dimension
1417 CALL openpmd_c_record_set_unit_dimension(this%c_ptr, unitdimension)
1418 END SUBROUTINE openpmd_record_set_unit_dimension
1421 SUBROUTINE openpmd_mesh_set_grid_global_offset (this, vec)
1422 CLASS(openpmd_mesh_type) :: this
1423 REAL(KIND=
dp),
DIMENSION(:),
TARGET :: vec
1425 INTEGER,
TARGET :: size_
1427 SUBROUTINE openpmd_c_set_vector_attribute(mesh, vec, length, invert) &
1428 BIND(C, NAME="openPMD_Mesh_setGridGlobalOffset")
1429 IMPORT :: c_char, c_size_t, c_int, c_ptr
1430 TYPE(C_PTR),
VALUE :: mesh
1431 TYPE(C_PTR),
VALUE :: vec
1432 INTEGER(kind=C_INT),
VALUE :: length, invert
1433 END SUBROUTINE openpmd_c_set_vector_attribute
1437 CALL openpmd_c_set_vector_attribute(this%c_ptr, c_loc(vec(1)), size_, 1)
1439 END SUBROUTINE openpmd_mesh_set_grid_global_offset
1440 SUBROUTINE openpmd_mesh_set_grid_spacing (this, vec)
1441 CLASS(openpmd_mesh_type) :: this
1442 REAL(KIND=
dp),
DIMENSION(:),
TARGET :: vec
1444 INTEGER,
TARGET :: size_
1446 SUBROUTINE openpmd_c_set_vector_attribute(mesh, vec, length, invert) &
1447 BIND(C, NAME="openPMD_Mesh_setGridSpacing")
1448 IMPORT :: c_char, c_size_t, c_int, c_ptr
1449 TYPE(C_PTR),
VALUE :: mesh
1450 TYPE(C_PTR),
VALUE :: vec
1451 INTEGER(kind=C_INT),
VALUE :: length, invert
1452 END SUBROUTINE openpmd_c_set_vector_attribute
1456 CALL openpmd_c_set_vector_attribute(this%c_ptr, c_loc(vec(1)), size_, 1)
1458 END SUBROUTINE openpmd_mesh_set_grid_spacing
1459 SUBROUTINE openpmd_mesh_set_position (this, vec)
1460 CLASS(openpmd_mesh_type) :: this
1461 REAL(KIND=
dp),
DIMENSION(:),
TARGET :: vec
1463 INTEGER,
TARGET :: size_
1465 SUBROUTINE openpmd_c_set_vector_attribute(mesh, vec, length, invert) &
1466 BIND(C, NAME="openPMD_Mesh_setPosition")
1467 IMPORT :: c_char, c_size_t, c_int, c_ptr
1468 TYPE(C_PTR),
VALUE :: mesh
1469 TYPE(C_PTR),
VALUE :: vec
1470 INTEGER(kind=C_INT),
VALUE :: length, invert
1471 END SUBROUTINE openpmd_c_set_vector_attribute
1475 CALL openpmd_c_set_vector_attribute(this%c_ptr, c_loc(vec(1)), size_, 1)
1477 END SUBROUTINE openpmd_mesh_set_position
1479 SUBROUTINE openpmd_mesh_set_grid_unit_si(this, gridUnitSI)
1480 CLASS(openpmd_mesh_type) :: this
1481 REAL(kind=c_double),
INTENT(IN),
VALUE :: gridunitsi
1484 SUBROUTINE openpmd_c_mesh_set_grid_unit_si(mesh, gridUnitSI) &
1485 BIND(C, NAME="openPMD_Mesh_setGridUnitSI")
1486 IMPORT :: c_ptr, c_double
1487 TYPE(C_PTR),
VALUE :: mesh
1488 REAL(kind=c_double),
VALUE :: gridunitsi
1489 END SUBROUTINE openpmd_c_mesh_set_grid_unit_si
1492 CALL openpmd_c_mesh_set_grid_unit_si(this%c_ptr, gridunitsi)
1493 END SUBROUTINE openpmd_mesh_set_grid_unit_si
1502 SUBROUTINE openpmd_mesh_set_unit_dimension(this, unitDimension)
1503 CLASS(openpmd_mesh_type) :: this
1504 REAL(kind=c_double),
DIMENSION(7),
TARGET :: unitdimension
1507 SUBROUTINE openpmd_c_mesh_set_unit_dimension(mesh, unitDimension) &
1508 BIND(C, NAME="openPMD_Mesh_setUnitDimension")
1509 IMPORT :: c_ptr, c_double
1510 TYPE(C_PTR),
VALUE :: mesh
1511 REAL(kind=c_double),
DIMENSION(*) :: unitdimension
1512 END SUBROUTINE openpmd_c_mesh_set_unit_dimension
1515 CALL openpmd_c_mesh_set_unit_dimension(this%c_ptr, unitdimension)
1516 END SUBROUTINE openpmd_mesh_set_unit_dimension
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public sp
Interface to the message passing library MPI.