12 USE iso_c_binding,
ONLY: &
26#include "./base/base_uses.f90"
35 INTEGER,
PARAMETER :: openpmd_access_create = 0
36 INTEGER,
PARAMETER :: openpmd_access_read_only = 1
38 INTEGER,
PARAMETER :: openpmd_type_char = 0
39 INTEGER,
PARAMETER :: openpmd_type_uchar = 1
40 INTEGER,
PARAMETER :: openpmd_type_schar = 2
41 INTEGER,
PARAMETER :: openpmd_type_short = 3
42 INTEGER,
PARAMETER :: openpmd_type_int = 4
43 INTEGER,
PARAMETER :: openpmd_type_long = 5
44 INTEGER,
PARAMETER :: openpmd_type_longlong = 6
45 INTEGER,
PARAMETER :: openpmd_type_ushort = 7
46 INTEGER,
PARAMETER :: openpmd_type_uint = 8
47 INTEGER,
PARAMETER :: openpmd_type_ulong = 9
48 INTEGER,
PARAMETER :: openpmd_type_ulonglong = 10
49 INTEGER,
PARAMETER :: openpmd_type_float = 11
50 INTEGER,
PARAMETER :: openpmd_type_double = 12
51 INTEGER,
PARAMETER :: openpmd_type_long_double = 13
52 INTEGER,
PARAMETER :: openpmd_type_cfloat = 14
53 INTEGER,
PARAMETER :: openpmd_type_cdouble = 15
54 INTEGER,
PARAMETER :: openpmd_type_clong_double = 16
55 INTEGER,
PARAMETER :: openpmd_type_string = 17
56 INTEGER,
PARAMETER :: openpmd_type_vec_char = 18
57 INTEGER,
PARAMETER :: openpmd_type_vec_short = 19
58 INTEGER,
PARAMETER :: openpmd_type_vec_int = 20
59 INTEGER,
PARAMETER :: openpmd_type_vec_long = 21
60 INTEGER,
PARAMETER :: openpmd_type_vec_longlong = 22
61 INTEGER,
PARAMETER :: openpmd_type_vec_uchar = 23
62 INTEGER,
PARAMETER :: openpmd_type_vec_ushort = 24
63 INTEGER,
PARAMETER :: openpmd_type_vec_uint = 25
64 INTEGER,
PARAMETER :: openpmd_type_vec_ulong = 26
65 INTEGER,
PARAMETER :: openpmd_type_vec_ulonglong = 27
66 INTEGER,
PARAMETER :: openpmd_type_vec_float = 28
67 INTEGER,
PARAMETER :: openpmd_type_vec_double = 29
68 INTEGER,
PARAMETER :: openpmd_type_vec_long_double = 30
69 INTEGER,
PARAMETER :: openpmd_type_vec_cfloat = 31
70 INTEGER,
PARAMETER :: openpmd_type_vec_cdouble = 32
71 INTEGER,
PARAMETER :: openpmd_type_vec_clong_double = 33
72 INTEGER,
PARAMETER :: openpmd_type_vec_schar = 34
73 INTEGER,
PARAMETER :: openpmd_type_vec_string = 35
74 INTEGER,
PARAMETER :: openpmd_type_arr_dbl_7 = 36
75 INTEGER,
PARAMETER :: openpmd_type_bool = 37
78 TYPE openpmd_attributable_type
80 TYPE(C_PTR) :: c_ptr = c_null_ptr
82 PROCEDURE,
PUBLIC :: set_attribute_vec_int => openpmd_attributable_set_attribute_vec_int
83 PROCEDURE,
PUBLIC :: series_flush => openpmd_attributable_series_flush
84 END TYPE openpmd_attributable_type
86 TYPE openpmd_series_type
88 TYPE(C_PTR) :: c_ptr = c_null_ptr
90 PROCEDURE,
PUBLIC :: as_pointer
91 PROCEDURE,
PUBLIC :: as_attributable => openpmd_series_as_attributable
92 PROCEDURE,
PUBLIC :: close => openpmd_series_close
93 PROCEDURE,
PUBLIC :: present => openpmd_series_present
94 PROCEDURE,
PUBLIC :: set_software => openpmd_series_set_software
95 PROCEDURE,
PUBLIC :: write_iteration => openpmd_series_write_iteration
96 PROCEDURE,
PUBLIC :: get_iteration => openpmd_series_get_iteration
97 END TYPE openpmd_series_type
99 TYPE openpmd_iteration_type
101 TYPE(C_PTR) :: c_ptr = c_null_ptr
103 PROCEDURE,
PUBLIC :: as_attributable => openpmd_iteration_as_attributable
104 PROCEDURE,
PUBLIC :: get_mesh => openpmd_iteration_get_mesh
105 PROCEDURE,
PUBLIC :: get_particle_species => openpmd_iteration_get_particle_species
106 PROCEDURE,
PUBLIC :: close => openpmd_iteration_close
107 PROCEDURE,
PUBLIC :: open => openpmd_iteration_open
108 PROCEDURE,
PUBLIC :: closed => openpmd_iteration_closed
109 PROCEDURE,
PUBLIC :: set_time_unit_SI => openpmd_iteration_set_time_unit_si
110 PROCEDURE,
PUBLIC :: set_time => openpmd_iteration_set_time
111 END TYPE openpmd_iteration_type
113 TYPE openpmd_mesh_type
115 TYPE(C_PTR) :: c_ptr = c_null_ptr
117 PROCEDURE,
PUBLIC :: as_record_component => openpmd_mesh_as_record_component
118 PROCEDURE,
PUBLIC :: set_axis_labels => openpmd_mesh_set_axis_labels
119 PROCEDURE,
PUBLIC :: set_grid_global_offset => openpmd_mesh_set_grid_global_offset
120 PROCEDURE,
PUBLIC :: set_grid_spacing => openpmd_mesh_set_grid_spacing
121 PROCEDURE,
PUBLIC :: set_grid_unit_SI => openpmd_mesh_set_grid_unit_si
122 PROCEDURE,
PUBLIC :: set_position => openpmd_mesh_set_position
123 PROCEDURE,
PUBLIC :: set_unit_dimension => openpmd_mesh_set_unit_dimension
124 END TYPE openpmd_mesh_type
126 TYPE openpmd_particle_species_type
128 TYPE(C_PTR) :: c_ptr = c_null_ptr
130 PROCEDURE,
PUBLIC :: get_record => openpmd_particle_species_get_record
131 END TYPE openpmd_particle_species_type
133 TYPE openpmd_record_component_type
135 TYPE(C_PTR) :: c_ptr = c_null_ptr
137 PROCEDURE,
PUBLIC :: make_empty => openpmd_record_component_make_empty
138 PROCEDURE,
PUBLIC :: make_constant_zero => openpmd_record_component_make_constant_zero
139 PROCEDURE,
PUBLIC :: reset_dataset => openpmd_record_component_reset_dataset
140 PROCEDURE,
PUBLIC :: set_unit_SI => openpmd_record_component_set_unit_si
141 PROCEDURE,
PRIVATE :: store_chunk_1d_double &
142 => openpmd_record_component_store_chunk_1d_double
143 PROCEDURE,
PUBLIC :: store_chunk_span_1d_double &
144 => openpmd_record_component_store_chunk_span_1d_double
145 PROCEDURE,
PRIVATE :: store_chunk_2d_double &
146 => openpmd_record_component_store_chunk_2d_double
147 PROCEDURE,
PUBLIC :: store_chunk_span_2d_double &
148 => openpmd_record_component_store_chunk_span_2d_double
149 PROCEDURE,
PRIVATE :: store_chunk_3d_double &
150 => openpmd_record_component_store_chunk_3d_double
151 PROCEDURE,
PUBLIC :: store_chunk_span_3d_double &
152 => openpmd_record_component_store_chunk_span_3d_double
153 generic,
PUBLIC :: store_chunk => &
154 store_chunk_1d_double, &
155 store_chunk_2d_double, &
156 store_chunk_3d_double
157 END TYPE openpmd_record_component_type
159 TYPE openpmd_mesh_record_component_type
161 TYPE(C_PTR) :: c_ptr = c_null_ptr
162 END TYPE openpmd_mesh_record_component_type
164 TYPE openpmd_record_type
166 TYPE(C_PTR) :: c_ptr = c_null_ptr
168 PROCEDURE,
PUBLIC :: as_record_component => openpmd_record_as_record_component
169 PROCEDURE,
PUBLIC :: get_component => openpmd_record_get_component
170 PROCEDURE,
PUBLIC :: set_unit_dimension => openpmd_record_set_unit_dimension
171 END TYPE openpmd_record_type
173 TYPE openpmd_dynamic_memory_view_type_1d
175 INTEGER,
DIMENSION(1) :: chunk_extent = 0
176 TYPE(C_PTR) :: c_ptr = c_null_ptr
180 PROCEDURE,
PUBLIC :: resolve_double &
181 => openpmd_dynamic_memory_view_resolve_1d_double
182 END TYPE openpmd_dynamic_memory_view_type_1d
183 TYPE openpmd_dynamic_memory_view_type_2d
185 INTEGER,
DIMENSION(2) :: chunk_extent = 0
186 TYPE(C_PTR) :: c_ptr = c_null_ptr
190 PROCEDURE,
PUBLIC :: resolve_double &
191 => openpmd_dynamic_memory_view_resolve_2d_double
192 END TYPE openpmd_dynamic_memory_view_type_2d
193 TYPE openpmd_dynamic_memory_view_type_3d
195 INTEGER,
DIMENSION(3) :: chunk_extent = 0
196 TYPE(C_PTR) :: c_ptr = c_null_ptr
200 PROCEDURE,
PUBLIC :: resolve_double &
201 => openpmd_dynamic_memory_view_resolve_3d_double
202 END TYPE openpmd_dynamic_memory_view_type_3d
205 PUBLIC :: openpmd_attributable_type
206 PUBLIC :: openpmd_iteration_type
207 PUBLIC :: openpmd_mesh_type
208 PUBLIC :: openpmd_particle_species_type
209 PUBLIC :: openpmd_record_component_type
210 PUBLIC :: openpmd_record_type
211 PUBLIC :: openpmd_series_type, openpmd_series_create
214 PUBLIC :: openpmd_access_create, openpmd_access_read_only
215 PUBLIC :: openpmd_get_default_extension
216 PUBLIC :: openpmd_json_merge
219 PUBLIC :: openpmd_type_arr_dbl_7
220 PUBLIC :: openpmd_type_bool
221 PUBLIC :: openpmd_type_cdouble
222 PUBLIC :: openpmd_type_cfloat
223 PUBLIC :: openpmd_type_char
224 PUBLIC :: openpmd_type_clong_double
225 PUBLIC :: openpmd_type_double
226 PUBLIC :: openpmd_type_float
227 PUBLIC :: openpmd_type_int
228 PUBLIC :: openpmd_type_long
229 PUBLIC :: openpmd_type_long_double
230 PUBLIC :: openpmd_type_longlong
231 PUBLIC :: openpmd_type_schar
232 PUBLIC :: openpmd_type_short
233 PUBLIC :: openpmd_type_string
234 PUBLIC :: openpmd_type_uchar
235 PUBLIC :: openpmd_type_uint
236 PUBLIC :: openpmd_type_ulong
237 PUBLIC :: openpmd_type_ulonglong
238 PUBLIC :: openpmd_type_ushort
239 PUBLIC :: openpmd_type_vec_cdouble
240 PUBLIC :: openpmd_type_vec_cfloat
241 PUBLIC :: openpmd_type_vec_char
242 PUBLIC :: openpmd_type_vec_clong_double
243 PUBLIC :: openpmd_type_vec_double
244 PUBLIC :: openpmd_type_vec_float
245 PUBLIC :: openpmd_type_vec_int
246 PUBLIC :: openpmd_type_vec_long
247 PUBLIC :: openpmd_type_vec_long_double
248 PUBLIC :: openpmd_type_vec_longlong
249 PUBLIC :: openpmd_type_vec_schar
250 PUBLIC :: openpmd_type_vec_short
251 PUBLIC :: openpmd_type_vec_string
252 PUBLIC :: openpmd_type_vec_uchar
253 PUBLIC :: openpmd_type_vec_uint
254 PUBLIC :: openpmd_type_vec_ulong
255 PUBLIC :: openpmd_type_vec_ulonglong
256 PUBLIC :: openpmd_type_vec_ushort
258 PUBLIC :: openpmd_series_as_attributable
259 PUBLIC :: openpmd_iteration_as_attributable
260 PUBLIC :: openpmd_record_component_as_attributable
261 PUBLIC :: openpmd_mesh_as_record_component
262 PUBLIC :: openpmd_record_as_record_component
263 PUBLIC :: openpmd_mesh_as_mesh_record_component
264 PUBLIC :: openpmd_mesh_record_component_as_record_component
265 PUBLIC :: openpmd_dynamic_memory_view_type_1d
266 PUBLIC :: openpmd_dynamic_memory_view_type_2d
267 PUBLIC :: openpmd_dynamic_memory_view_type_3d
279 FUNCTION as_pointer(this)
RESULT(res)
280 CLASS(openpmd_series_type),
INTENT(IN) :: this
284 END FUNCTION as_pointer
286 FUNCTION openpmd_series_as_attributable(this)
RESULT(res)
287 CLASS(openpmd_Series_type),
INTENT(IN) :: this
288 TYPE(openpmd_Attributable_type) :: res
291 SUBROUTINE openpmd_c_series_as_attributable(child, parent) &
292 BIND(C, name="openPMD_Series_upcast_to_Attributable")
294 TYPE(C_PTR),
VALUE :: child
295 TYPE(C_PTR) :: parent
296 END SUBROUTINE openpmd_c_series_as_attributable
299 CALL openpmd_c_series_as_attributable(this%c_ptr, res%c_ptr)
300 END FUNCTION openpmd_series_as_attributable
301 FUNCTION openpmd_iteration_as_attributable(this)
RESULT(res)
302 CLASS(openpmd_Iteration_type),
INTENT(IN) :: this
303 TYPE(openpmd_Attributable_type) :: res
306 SUBROUTINE openpmd_c_iteration_as_attributable(child, parent) &
307 BIND(C, name="openPMD_Iteration_upcast_to_Attributable")
309 TYPE(C_PTR),
VALUE :: child
310 TYPE(C_PTR) :: parent
311 END SUBROUTINE openpmd_c_iteration_as_attributable
314 CALL openpmd_c_iteration_as_attributable(this%c_ptr, res%c_ptr)
315 END FUNCTION openpmd_iteration_as_attributable
316 FUNCTION openpmd_record_component_as_attributable(this)
RESULT(res)
317 CLASS(openpmd_record_component_type),
INTENT(IN) :: this
318 TYPE(openpmd_Attributable_type) :: res
321 SUBROUTINE openpmd_c_record_component_as_attributable(child, parent) &
322 BIND(C, name="openPMD_RecordComponent_upcast_to_Attributable")
324 TYPE(C_PTR),
VALUE :: child
325 TYPE(C_PTR) :: parent
326 END SUBROUTINE openpmd_c_record_component_as_attributable
329 CALL openpmd_c_record_component_as_attributable(this%c_ptr, res%c_ptr)
330 END FUNCTION openpmd_record_component_as_attributable
331 FUNCTION openpmd_mesh_as_record_component(this)
RESULT(res)
332 CLASS(openpmd_Mesh_type),
INTENT(IN) :: this
333 TYPE(openpmd_record_component_type) :: res
336 SUBROUTINE openpmd_c_mesh_as_record_component(child, parent) &
337 BIND(C, name="openPMD_Mesh_upcast_to_RecordComponent")
339 TYPE(C_PTR),
VALUE :: child
340 TYPE(C_PTR) :: parent
341 END SUBROUTINE openpmd_c_mesh_as_record_component
344 CALL openpmd_c_mesh_as_record_component(this%c_ptr, res%c_ptr)
345 END FUNCTION openpmd_mesh_as_record_component
346 FUNCTION openpmd_record_as_record_component(this)
RESULT(res)
347 CLASS(openpmd_Record_type),
INTENT(IN) :: this
348 TYPE(openpmd_record_component_type) :: res
351 SUBROUTINE openpmd_c_record_as_record_component(child, parent) &
352 BIND(C, name="openPMD_Record_upcast_to_RecordComponent")
354 TYPE(C_PTR),
VALUE :: child
355 TYPE(C_PTR) :: parent
356 END SUBROUTINE openpmd_c_record_as_record_component
359 CALL openpmd_c_record_as_record_component(this%c_ptr, res%c_ptr)
360 END FUNCTION openpmd_record_as_record_component
361 FUNCTION openpmd_mesh_as_mesh_record_component(this)
RESULT(res)
362 CLASS(openpmd_Mesh_type),
INTENT(IN) :: this
363 TYPE(openpmd_mesh_record_component_type) :: res
366 SUBROUTINE openpmd_c_mesh_as_mesh_record_component(child, parent) &
367 BIND(C, name="openPMD_Mesh_upcast_to_MeshRecordComponent")
369 TYPE(C_PTR),
VALUE :: child
370 TYPE(C_PTR) :: parent
371 END SUBROUTINE openpmd_c_mesh_as_mesh_record_component
374 CALL openpmd_c_mesh_as_mesh_record_component(this%c_ptr, res%c_ptr)
375 END FUNCTION openpmd_mesh_as_mesh_record_component
376 FUNCTION openpmd_mesh_record_component_as_record_component(this)
RESULT(res)
377 CLASS(openpmd_mesh_record_component_type),
INTENT(IN) :: this
378 TYPE(openpmd_record_component_type) :: res
381 SUBROUTINE openpmd_c_mesh_record_component_as_record_component(child, parent) &
382 BIND(C, name="openPMD_MeshRecordComponent_upcast_to_RecordComponent")
384 TYPE(C_PTR),
VALUE :: child
385 TYPE(C_PTR) :: parent
386 END SUBROUTINE openpmd_c_mesh_record_component_as_record_component
389 CALL openpmd_c_mesh_record_component_as_record_component(this%c_ptr, res%c_ptr)
390 END FUNCTION openpmd_mesh_record_component_as_record_component
397 FUNCTION openpmd_series_present(this)
RESULT(res)
398 CLASS(openpmd_series_type),
INTENT(IN) :: this
401 INTEGER :: res_internal
403 FUNCTION openpmd_c_series_present(series)
RESULT(res) &
404 BIND(C, NAME="openPMD_Series_present")
405 IMPORT :: c_ptr, c_int
406 TYPE(C_PTR),
VALUE,
INTENT(IN) :: series
407 INTEGER(KIND=C_INT) :: res
408 END FUNCTION openpmd_c_series_present
411 IF (.NOT. c_associated(this%c_ptr))
THEN
416 res_internal = openpmd_c_series_present(this%c_ptr)
417 res = res_internal /= 0
418 END FUNCTION openpmd_series_present
428 FUNCTION openpmd_series_create(path, access, mpi_comm, config)
RESULT(series)
429 CHARACTER(LEN=*),
INTENT(IN) :: path
430 INTEGER(KIND=C_INT),
INTENT(IN) :: access
431 CLASS(mp_comm_type),
INTENT(IN),
OPTIONAL :: mpi_comm
432 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL,
TARGET :: config
433 TYPE(openpmd_series_type) :: series
435 CHARACTER(:),
POINTER :: my_config
436 CHARACTER(LEN=default_string_length),
SAVE,
TARGET :: default_config =
"{}"
437 TYPE(c_ptr),
SAVE :: comm_c = c_null_ptr
446 SUBROUTINE cp2k_c_mpi_comm_f2c(comm_f, comm_c)
bind(C, name="CP2K_MPI_Comm_f2c")
448 INTEGER(KIND=C_INT),
VALUE :: comm_f
449 TYPE(c_ptr) :: comm_c
450 END SUBROUTINE cp2k_c_mpi_comm_f2c
453 SUBROUTINE openpmd_c_series_create_mpi(path, access, mpi_comm, config, series) &
454 BIND(C, name="openPMD_Series_create_mpi")
455 IMPORT :: c_ptr, c_char, c_int
456 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: path
457 INTEGER(KIND=C_INT),
VALUE :: access
458 TYPE(C_PTR),
value :: mpi_comm
459 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: config
460 TYPE(C_PTR) :: series
461 END SUBROUTINE openpmd_c_series_create_mpi
464 SUBROUTINE openpmd_c_series_create(path, access, config, series) &
465 BIND(C, name="openPMD_Series_create")
466 IMPORT :: c_ptr, c_char, c_int
467 TYPE(C_PTR) :: series
468 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: path
469 INTEGER(KIND=C_INT),
VALUE :: access
470 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: config
471 END SUBROUTINE openpmd_c_series_create
474 IF (
PRESENT(config))
THEN
477 my_config => default_config
480 cpassert(.NOT. c_associated(series%c_ptr))
481 IF (
PRESENT(mpi_comm))
THEN
482 CALL cp2k_c_mpi_comm_f2c(mpi_comm%get_handle(), comm_c)
483 CALL openpmd_c_series_create_mpi( &
484 path=trim(path)//c_null_char, &
487 config=my_config//c_null_char, &
490 CALL openpmd_c_series_create( &
491 path=trim(path)//c_null_char, &
493 config=my_config//c_null_char, &
496 cpassert(c_associated(series%c_ptr))
497 END FUNCTION openpmd_series_create
503 SUBROUTINE openpmd_series_close(series)
504 CLASS(openpmd_series_type),
INTENT(INOUT) :: series
511 SUBROUTINE openpmd_c_series_close(series) &
512 BIND(C, name="openPMD_Series_close")
514 TYPE(C_PTR),
VALUE :: series
515 END SUBROUTINE openpmd_c_series_close
518 cpassert(c_associated(series%c_ptr))
519 CALL openpmd_c_series_close(series=series%c_ptr)
520 series%c_ptr = c_null_ptr
521 END SUBROUTINE openpmd_series_close
529 SUBROUTINE openpmd_series_set_software(this, name, version)
530 CLASS(openpmd_series_type),
INTENT(IN) :: this
531 CHARACTER(LEN=*),
INTENT(IN) :: name
532 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: version
535 SUBROUTINE openpmd_c_series_set_software(series, name, version) &
536 BIND(C, name="openPMD_Series_setSoftware")
537 IMPORT :: c_ptr, c_char
538 TYPE(C_PTR),
VALUE :: series
539 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: name
540 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: version
541 END SUBROUTINE openpmd_c_series_set_software
544 cpassert(c_associated(this%c_ptr))
545 IF (
PRESENT(version))
THEN
546 CALL openpmd_c_series_set_software(this%c_ptr, name//c_null_char, version//c_null_char)
548 CALL openpmd_c_series_set_software(this%c_ptr, name//c_null_char, c_null_char)
550 END SUBROUTINE openpmd_series_set_software
558 FUNCTION openpmd_series_write_iteration(this, index)
RESULT(iteration)
559 CLASS(openpmd_series_type) :: this
560 INTEGER,
TARGET :: index
561 TYPE(openpmd_iteration_type) :: iteration
563 INTEGER(8) :: cast_index
564 INTEGER(KIND=C_INT) :: status
566 FUNCTION openpmd_c_series_write_iteration(series, index, iteration)
RESULT(status) &
567 BIND(C, name="openPMD_Series_write_Iteration")
568 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t
569 TYPE(C_PTR),
VALUE :: series
570 INTEGER(KIND=C_INT64_T),
VALUE :: index
571 TYPE(C_PTR) :: iteration
572 INTEGER(KIND=C_INT) :: status
573 END FUNCTION openpmd_c_series_write_iteration
576 cpassert(.NOT. c_associated(iteration%c_ptr))
578 status = openpmd_c_series_write_iteration(this%c_ptr, cast_index, iteration%c_ptr)
579 cpassert(c_associated(iteration%c_ptr))
580 END FUNCTION openpmd_series_write_iteration
582 FUNCTION openpmd_series_get_iteration(this, index)
RESULT(iteration)
583 CLASS(openpmd_series_type) :: this
584 INTEGER,
TARGET :: index
585 TYPE(openpmd_iteration_type) :: iteration
587 INTEGER(8) :: cast_index
588 INTEGER(KIND=C_INT) :: status
590 FUNCTION openpmd_c_series_get_iteration(series, index, iteration)
RESULT(status) &
591 BIND(C, name="openPMD_Series_get_Iteration")
592 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t
593 TYPE(C_PTR),
VALUE :: series
594 INTEGER(KIND=C_INT64_T),
VALUE :: index
595 TYPE(C_PTR) :: iteration
596 INTEGER(KIND=C_INT) :: status
597 END FUNCTION openpmd_c_series_get_iteration
600 cpassert(.NOT. c_associated(iteration%c_ptr))
602 status = openpmd_c_series_get_iteration(this%c_ptr, cast_index, iteration%c_ptr)
603 cpassert(c_associated(iteration%c_ptr))
604 END FUNCTION openpmd_series_get_iteration
610 FUNCTION openpmd_get_default_extension()
RESULT(extension)
611 CHARACTER(LEN=default_string_length) :: extension
613 CHARACTER(LEN=1, KIND=C_CHAR),
DIMENSION(:), &
614 POINTER :: c_extension_f
616 INTEGER(C_SIZE_T) :: c_extension_length, extension_length
617 TYPE(C_PTR) :: c_extension
619 FUNCTION openpmd_c_get_default_extension()
RESULT(extension) &
620 BIND(c, name="openPMD_get_default_extension")
622 TYPE(C_PTR) :: extension
623 END FUNCTION openpmd_c_get_default_extension
626 FUNCTION get_strlen(c_string)
RESULT(strlen) &
627 BIND(C, NAME="CP2K_strlen")
628 IMPORT :: c_ptr, c_size_t
629 TYPE(C_PTR),
VALUE :: c_string
630 INTEGER(C_SIZE_T) :: strlen
631 END FUNCTION get_strlen
635 c_extension = openpmd_c_get_default_extension()
636 IF (.NOT. c_associated(c_extension))
RETURN
639 c_extension_length = get_strlen(c_extension)
640 CALL c_f_pointer(c_extension, c_extension_f, &
641 shape=[int(c_extension_length) + 1])
642 cpassert(c_extension_f(int(c_extension_length) + 1) == c_null_char)
646 DO i = 1, int(extension_length)
647 extension(i:i) = c_extension_f(i)
650 END FUNCTION openpmd_get_default_extension
658 SUBROUTINE openpmd_attributable_set_attribute_vec_int(this, name, vec)
659 CLASS(openpmd_attributable_type) :: this
660 CHARACTER(LEN=*),
INTENT(IN) :: name
661 INTEGER,
DIMENSION(:),
TARGET :: vec
663 INTEGER,
TARGET :: size_
665 SUBROUTINE openpmd_c_attributable_set_attribute_vec_int(attributable, name, vec, length) &
666 BIND(C, NAME="openPMD_attributable_set_attribute_vec_int")
667 IMPORT :: c_char, c_size_t, c_int, c_ptr
668 TYPE(C_PTR),
VALUE :: attributable
669 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: name
670 TYPE(C_PTR),
VALUE :: vec
671 INTEGER(KIND=C_INT),
VALUE :: length
672 END SUBROUTINE openpmd_c_attributable_set_attribute_vec_int
676 CALL openpmd_c_attributable_set_attribute_vec_int( &
677 this%c_ptr, name//c_null_char, c_loc(vec(1)), size_)
679 END SUBROUTINE openpmd_attributable_set_attribute_vec_int
681 SUBROUTINE openpmd_attributable_series_flush(this, backendconfig)
682 CLASS(openpmd_attributable_type) :: this
683 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: backendconfig
685 CHARACTER(LEN=default_string_length),
SAVE :: my_backendconfig =
""
687 SUBROUTINE openpmd_c_attributable_series_flush(attributable, config) &
688 BIND(C, NAME="openPMD_Attributable_series_flush")
689 IMPORT :: c_char, c_size_t, c_int, c_ptr
690 TYPE(C_PTR),
VALUE :: attributable
691 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: config
692 END SUBROUTINE openpmd_c_attributable_series_flush
695 IF (
PRESENT(backendconfig)) my_backendconfig = backendconfig
696 CALL openpmd_c_attributable_series_flush(this%c_ptr, my_backendconfig//c_null_char)
697 END SUBROUTINE openpmd_attributable_series_flush
699 SUBROUTINE openpmd_iteration_set_time_unit_si(this, timeUnitSI)
700 CLASS(openpmd_iteration_type) :: this
701 REAL(KIND=c_double),
INTENT(IN),
VALUE :: timeunitsi
704 SUBROUTINE openpmd_c_iteration_set_time_unit_si(iteration, timeUnitSI) &
705 BIND(C, NAME="openPMD_Iteration_setTimeUnitSI")
706 IMPORT :: c_ptr, c_double
707 TYPE(C_PTR),
VALUE :: iteration
708 REAL(KIND=c_double),
VALUE :: timeunitsi
709 END SUBROUTINE openpmd_c_iteration_set_time_unit_si
712 CALL openpmd_c_iteration_set_time_unit_si(this%c_ptr, timeunitsi)
713 END SUBROUTINE openpmd_iteration_set_time_unit_si
715 SUBROUTINE openpmd_iteration_set_time(this, time)
716 CLASS(openpmd_iteration_type) :: this
717 REAL(KIND=c_double),
INTENT(IN),
VALUE :: time
720 SUBROUTINE openpmd_c_iteration_set_time(iteration, time) &
721 BIND(C, NAME="openPMD_Iteration_setTime")
722 IMPORT :: c_ptr, c_double
723 TYPE(C_PTR),
VALUE :: iteration
724 REAL(KIND=c_double),
VALUE :: time
725 END SUBROUTINE openpmd_c_iteration_set_time
728 CALL openpmd_c_iteration_set_time(this%c_ptr, time)
729 END SUBROUTINE openpmd_iteration_set_time
731 FUNCTION openpmd_json_merge(into, from, mpi_comm)
RESULT(merged)
732 CHARACTER(LEN=*),
INTENT(IN) :: into, from
733 CLASS(mp_comm_type),
INTENT(IN),
OPTIONAL :: mpi_comm
734 CHARACTER(:),
ALLOCATABLE :: merged
736 CHARACTER(LEN=1, KIND=C_CHAR),
DIMENSION(:), &
737 POINTER :: c_merged_f
739 INTEGER(C_SIZE_T) :: length_of_c_string
740 TYPE(C_PTR) :: c_merged, comm_c
749 SUBROUTINE cp2k_c_mpi_comm_f2c(comm_f, comm_c)
bind(C, name="CP2K_MPI_Comm_f2c")
751 INTEGER(KIND=C_INT),
VALUE :: comm_f
752 TYPE(c_ptr) :: comm_c
753 END SUBROUTINE cp2k_c_mpi_comm_f2c
756 FUNCTION openpmd_c_json_merge(into, from, mpi_comm)
RESULT(merged) &
757 BIND(C, NAME="openPMD_json_merge")
758 IMPORT :: c_char, c_ptr
759 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: into, from
760 TYPE(C_PTR),
VALUE :: mpi_comm
761 TYPE(C_PTR) :: merged
762 END FUNCTION openpmd_c_json_merge
765 FUNCTION get_strlen(c_string)
RESULT(strlen) &
766 BIND(C, NAME="CP2K_strlen")
767 IMPORT :: c_ptr, c_size_t
768 TYPE(C_PTR),
VALUE :: c_string
769 INTEGER(C_SIZE_T) :: strlen
770 END FUNCTION get_strlen
773 SUBROUTINE free(c_string) &
774 BIND(C, NAME="CP2K_free")
776 TYPE(C_PTR),
VALUE :: c_string
781 IF (
PRESENT(mpi_comm))
THEN
782 CALL cp2k_c_mpi_comm_f2c(mpi_comm%get_handle(), comm_c)
785 c_merged = openpmd_c_json_merge( &
786 into//c_null_char, from//c_null_char, comm_c)
787 cpassert(c_associated(c_merged))
789 length_of_c_string = get_strlen(c_merged)
790 CALL c_f_pointer(c_merged, c_merged_f, &
791 shape=[int(length_of_c_string) + 1])
792 cpassert(c_merged_f(int(length_of_c_string) + 1) == c_null_char)
794 ALLOCATE (
CHARACTER(LEN=INT(length_of_c_string)) :: merged)
795 DO i = 1, int(length_of_c_string)
796 merged(i:i) = c_merged_f(i)
800 END FUNCTION openpmd_json_merge
808 FUNCTION openpmd_iteration_get_mesh(this, name)
RESULT(mesh)
809 CLASS(openpmd_iteration_type) :: this
810 CHARACTER(LEN=*),
INTENT(IN) :: name
811 TYPE(openpmd_mesh_type) :: mesh
813 INTEGER(KIND=C_INT) :: status
815 FUNCTION openpmd_c_iteration_get_mesh(iteration, name, mesh)
RESULT(status) &
816 BIND(C, name="openPMD_Iteration_get_mesh")
817 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
818 TYPE(C_PTR),
VALUE :: iteration
819 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: name
821 INTEGER(KIND=C_INT) :: status
822 END FUNCTION openpmd_c_iteration_get_mesh
825 cpassert(.NOT. c_associated(mesh%c_ptr))
826 status = openpmd_c_iteration_get_mesh(this%c_ptr, name//c_null_char, mesh%c_ptr)
827 cpassert(c_associated(mesh%c_ptr))
828 END FUNCTION openpmd_iteration_get_mesh
836 FUNCTION openpmd_iteration_get_particle_species(this, name)
RESULT(particle_species)
837 CLASS(openpmd_iteration_type) :: this
838 CHARACTER(LEN=*),
INTENT(IN) :: name
839 TYPE(openpmd_particle_species_type) :: particle_species
841 INTEGER(KIND=C_INT) :: status
843 FUNCTION openpmd_c_iteration_get_particle_species(iteration, name, particle_species)
RESULT(status) &
844 BIND(C, name="openPMD_Iteration_get_particle_species")
845 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
846 TYPE(C_PTR),
VALUE :: iteration
847 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: name
848 TYPE(C_PTR) :: particle_species
849 INTEGER(KIND=C_INT) :: status
850 END FUNCTION openpmd_c_iteration_get_particle_species
853 cpassert(.NOT. c_associated(particle_species%c_ptr))
854 status = openpmd_c_iteration_get_particle_species( &
855 this%c_ptr, name//c_null_char, particle_species%c_ptr)
856 cpassert(c_associated(particle_species%c_ptr))
857 END FUNCTION openpmd_iteration_get_particle_species
863 SUBROUTINE openpmd_iteration_open(iteration)
864 CLASS(openpmd_iteration_type),
INTENT(INOUT) :: iteration
871 SUBROUTINE openpmd_c_iteration_open(iteration) &
872 BIND(C, name="openPMD_Iteration_open")
874 TYPE(C_PTR),
VALUE :: iteration
875 END SUBROUTINE openpmd_c_iteration_open
878 cpassert(c_associated(iteration%c_ptr))
879 CALL openpmd_c_iteration_open(iteration=iteration%c_ptr)
880 END SUBROUTINE openpmd_iteration_open
882 SUBROUTINE openpmd_iteration_close(iteration)
883 CLASS(openpmd_iteration_type),
INTENT(INOUT) :: iteration
890 SUBROUTINE openpmd_c_iteration_close(iteration) &
891 BIND(C, name="openPMD_Iteration_close")
893 TYPE(C_PTR),
VALUE :: iteration
894 END SUBROUTINE openpmd_c_iteration_close
897 cpassert(c_associated(iteration%c_ptr))
898 CALL openpmd_c_iteration_close(iteration=iteration%c_ptr)
899 iteration%c_ptr = c_null_ptr
900 END SUBROUTINE openpmd_iteration_close
902 FUNCTION openpmd_iteration_closed(iteration)
RESULT(res)
903 CLASS(openpmd_iteration_type),
INTENT(IN) :: iteration
906 INTEGER(KIND=C_INT) :: res_tmp
912 FUNCTION openpmd_c_iteration_closed(iteration)
RESULT(res) &
913 BIND(C, name="openPMD_Iteration_closed")
914 IMPORT :: c_ptr, c_int
915 TYPE(C_PTR),
VALUE :: iteration
916 INTEGER(KIND=C_INT) :: res
917 END FUNCTION openpmd_c_iteration_closed
920 cpassert(c_associated(iteration%c_ptr))
921 res_tmp = openpmd_c_iteration_closed(iteration=iteration%c_ptr)
922 IF (res_tmp == 0)
THEN
927 END FUNCTION openpmd_iteration_closed
935 SUBROUTINE openpmd_record_component_make_empty(this, dtype, dimensionality)
936 CLASS(openpmd_record_component_type) :: this
937 INTEGER(KIND=C_INT) :: dtype
938 INTEGER :: dimensionality
940 INTEGER(KIND=C_INT) :: status
942 FUNCTION openpmd_c_record_component_make_empty(record_component, dtype, dimensionality)
RESULT(status) &
943 BIND(C, name="openPMD_RecordComponent_makeEmpty")
944 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
945 TYPE(C_PTR),
VALUE :: record_component
946 INTEGER(KIND=C_INT),
VALUE :: dtype
947 INTEGER(KIND=C_INT),
VALUE :: dimensionality
948 INTEGER(KIND=C_INT) :: status
949 END FUNCTION openpmd_c_record_component_make_empty
952 status = openpmd_c_record_component_make_empty(this%c_ptr, dtype, dimensionality)
953 END SUBROUTINE openpmd_record_component_make_empty
961 SUBROUTINE openpmd_record_component_make_constant_zero(this, dtype, extent)
962 CLASS(openpmd_record_component_type) :: this
963 INTEGER(KIND=C_INT) :: dtype
964 INTEGER,
DIMENSION(:),
TARGET :: extent
966 INTEGER(KIND=C_INT) :: status
968 FUNCTION openpmd_c_record_component_make_constant( &
969 record_component, dtype, dimensions, extent, invert, value)
RESULT(status) &
970 BIND(C, name="openPMD_RecordComponent_makeConstant")
971 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
972 TYPE(C_PTR),
VALUE :: record_component
973 INTEGER(KIND=C_INT),
VALUE :: dtype
974 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
975 TYPE(C_PTR),
VALUE :: extent
976 TYPE(C_PTR),
VALUE :: value
977 INTEGER(KIND=C_INT) :: status
978 END FUNCTION openpmd_c_record_component_make_constant
981 status = openpmd_c_record_component_make_constant( &
982 this%c_ptr, dtype,
SIZE(extent), c_loc(extent(1)), 1, c_null_ptr)
983 END SUBROUTINE openpmd_record_component_make_constant_zero
985 SUBROUTINE openpmd_mesh_set_axis_labels(this, labels)
986 CLASS(openpmd_mesh_type) :: this
987 CHARACTER(LEN=*),
DIMENSION(:) :: labels
989 CHARACTER(LEN=default_string_length),
ALLOCATABLE,
TARGET :: &
990 labels_as_null_terminated_strings(:)
992 TYPE(C_PTR),
ALLOCATABLE,
TARGET :: labels_as_c_strings(:)
994 SUBROUTINE openpmd_c_mesh_set_axis_labels(mesh, labels, len_labels, invert) &
995 BIND(C, NAME="openPMD_Mesh_set_axis_labels")
996 IMPORT :: c_char, c_size_t, c_int, c_ptr
997 TYPE(C_PTR),
VALUE :: mesh
998 TYPE(C_PTR),
VALUE :: labels
999 INTEGER(KIND=C_INT),
VALUE :: len_labels, invert
1000 END SUBROUTINE openpmd_c_mesh_set_axis_labels
1003 ALLOCATE (labels_as_null_terminated_strings(
SIZE(labels)))
1004 ALLOCATE (labels_as_c_strings(
SIZE(labels)))
1006 DO i = 1,
SIZE(labels)
1007 labels_as_null_terminated_strings(i) = trim(labels(i))//c_null_char
1008 labels_as_c_strings(i) = c_loc(labels_as_null_terminated_strings(i))
1011 CALL openpmd_c_mesh_set_axis_labels(this%c_ptr, c_loc(labels_as_c_strings(1)),
SIZE(labels), invert=1)
1013 DEALLOCATE (labels_as_c_strings)
1014 DEALLOCATE (labels_as_null_terminated_strings)
1015 END SUBROUTINE openpmd_mesh_set_axis_labels
1017 SUBROUTINE openpmd_record_component_reset_dataset(this, dtype, extent, cfg)
1018 CLASS(openpmd_record_component_type) :: this
1019 INTEGER(KIND=C_INT) :: dtype
1020 INTEGER,
DIMENSION(:),
TARGET :: extent
1021 CHARACTER(LEN=*),
OPTIONAL :: cfg
1023 CHARACTER(LEN=default_string_length),
SAVE :: my_config =
"{}"
1024 INTEGER(KIND=C_INT) :: status
1026 FUNCTION openpmd_c_record_component_reset_dataset( &
1027 record_component, dtype, dimensions, extent, invert, cfg)
RESULT(status) &
1028 BIND(C, name="openPMD_RecordComponent_resetDataset")
1029 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1030 TYPE(C_PTR),
VALUE :: record_component
1031 INTEGER(KIND=C_INT),
VALUE :: dtype
1032 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1033 TYPE(C_PTR),
VALUE :: extent
1034 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: cfg
1035 INTEGER(KIND=C_INT) :: status
1036 END FUNCTION openpmd_c_record_component_reset_dataset
1039 IF (
PRESENT(cfg)) my_config = cfg
1041 status = openpmd_c_record_component_reset_dataset( &
1042 this%c_ptr, dtype,
SIZE(extent), c_loc(extent(1)), 1, my_config//c_null_char)
1043 END SUBROUTINE openpmd_record_component_reset_dataset
1045 SUBROUTINE openpmd_record_component_set_unit_si(this, unitSI)
1046 CLASS(openpmd_record_component_type) :: this
1047 REAL(KIND=c_double),
INTENT(IN),
VALUE :: unitsi
1050 SUBROUTINE openpmd_c_record_component_set_unit_si(record_component, unitSI) &
1051 BIND(C, NAME="openPMD_RecordComponent_setUnitSI")
1052 IMPORT :: c_ptr, c_double
1053 TYPE(C_PTR),
VALUE :: record_component
1054 REAL(KIND=c_double),
VALUE :: unitsi
1055 END SUBROUTINE openpmd_c_record_component_set_unit_si
1058 CALL openpmd_c_record_component_set_unit_si(this%c_ptr, unitsi)
1059 END SUBROUTINE openpmd_record_component_set_unit_si
1062 SUBROUTINE openpmd_record_component_store_chunk_1d_double(record_component, data_, offset)
1063 CLASS(openpmd_record_component_type) :: record_component
1064 REAL(kind=
dp),
TARGET :: data_(:)
1065 INTEGER,
DIMENSION(1),
TARGET :: offset
1067 INTEGER(KIND=C_INT) :: status
1068 INTEGER,
DIMENSION(1),
TARGET :: extent
1070 FUNCTION openpmd_c_record_component_store_chunk( &
1071 record_component, dtype, dimensions, offset, extent, invert, data_)
RESULT(status) &
1072 BIND(C, name="openPMD_RecordComponent_storeChunk")
1073 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1074 TYPE(C_PTR),
VALUE :: record_component
1075 INTEGER(KIND=C_INT),
VALUE :: dtype
1076 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1077 TYPE(C_PTR),
VALUE :: offset, extent
1078 TYPE(C_PTR),
VALUE :: data_
1079 INTEGER(KIND=C_INT) :: status
1080 END FUNCTION openpmd_c_record_component_store_chunk
1083 extent = shape(data_)
1084 status = openpmd_c_record_component_store_chunk( &
1085 record_component%c_ptr, &
1086 openpmd_type_double, &
1093 END SUBROUTINE openpmd_record_component_store_chunk_1d_double
1095 FUNCTION openpmd_record_component_store_chunk_span_1d_double( &
1096 record_component, offset, extent)
RESULT(memory_view)
1097 CLASS(openpmd_record_component_type) :: record_component
1098 INTEGER,
DIMENSION(1),
TARGET :: offset, extent
1099 TYPE(openpmd_dynamic_memory_view_type_1d) :: memory_view
1101 INTEGER(KIND=C_INT) :: status
1103 FUNCTION openpmd_c_record_component_store_chunk_span( &
1104 record_component, dtype, dimensions, offset, extent, invert, memory_view)
RESULT(status) &
1105 BIND(C, name="openPMD_RecordComponent_storeChunkSpan")
1106 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1107 TYPE(C_PTR),
VALUE :: record_component
1108 INTEGER(KIND=C_INT),
VALUE :: dtype
1109 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1110 TYPE(C_PTR),
VALUE :: offset, extent
1111 TYPE(C_PTR) :: memory_view
1112 INTEGER(KIND=C_INT) :: status
1113 END FUNCTION openpmd_c_record_component_store_chunk_span
1116 memory_view%chunk_extent = extent
1117 status = openpmd_c_record_component_store_chunk_span( &
1118 record_component%c_ptr, &
1119 openpmd_type_double, &
1126 END FUNCTION openpmd_record_component_store_chunk_span_1d_double
1128 FUNCTION openpmd_dynamic_memory_view_resolve_1d_double(memory_view, DEALLOCATE)
RESULT(buffer)
1129 CLASS(openpmd_dynamic_memory_view_type_1d) :: memory_view
1130 LOGICAL :: deallocate
1131 REAL(kind=
dp),
POINTER :: buffer(:)
1133 INTEGER(KIND=C_INT) :: deallocate_c, status
1134 TYPE(C_PTR),
TARGET :: c_buffer
1136 FUNCTION openpmd_c_dynamic_memory_view_resolve(memory_view, DEALLOCATE, write_buffer)
RESULT(status) &
1137 BIND(C, name="openPMD_DynamicMemoryView_resolve")
1138 IMPORT :: c_ptr, c_int
1139 TYPE(C_PTR),
VALUE :: memory_view
1140 INTEGER(KIND=C_INT),
VALUE :: deallocate
1141 TYPE(C_PTR) :: write_buffer
1142 INTEGER(KIND=C_INT) :: status
1143 END FUNCTION openpmd_c_dynamic_memory_view_resolve
1146 IF (deallocate)
THEN
1152 status = openpmd_c_dynamic_memory_view_resolve(memory_view%c_ptr, deallocate_c, c_buffer)
1153 CALL c_f_pointer(c_buffer, buffer, memory_view%chunk_extent)
1154 END FUNCTION openpmd_dynamic_memory_view_resolve_1d_double
1156 SUBROUTINE openpmd_record_component_store_chunk_2d_double(record_component, data_, offset)
1157 CLASS(openpmd_record_component_type) :: record_component
1158 REAL(kind=
dp),
TARGET :: data_(:,:)
1159 INTEGER,
DIMENSION(2),
TARGET :: offset
1161 INTEGER(KIND=C_INT) :: status
1162 INTEGER,
DIMENSION(2),
TARGET :: extent
1164 FUNCTION openpmd_c_record_component_store_chunk( &
1165 record_component, dtype, dimensions, offset, extent, invert, data_)
RESULT(status) &
1166 BIND(C, name="openPMD_RecordComponent_storeChunk")
1167 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1168 TYPE(C_PTR),
VALUE :: record_component
1169 INTEGER(KIND=C_INT),
VALUE :: dtype
1170 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1171 TYPE(C_PTR),
VALUE :: offset, extent
1172 TYPE(C_PTR),
VALUE :: data_
1173 INTEGER(KIND=C_INT) :: status
1174 END FUNCTION openpmd_c_record_component_store_chunk
1177 extent = shape(data_)
1178 status = openpmd_c_record_component_store_chunk( &
1179 record_component%c_ptr, &
1180 openpmd_type_double, &
1187 END SUBROUTINE openpmd_record_component_store_chunk_2d_double
1189 FUNCTION openpmd_record_component_store_chunk_span_2d_double( &
1190 record_component, offset, extent)
RESULT(memory_view)
1191 CLASS(openpmd_record_component_type) :: record_component
1192 INTEGER,
DIMENSION(2),
TARGET :: offset, extent
1193 TYPE(openpmd_dynamic_memory_view_type_2d) :: memory_view
1195 INTEGER(KIND=C_INT) :: status
1197 FUNCTION openpmd_c_record_component_store_chunk_span( &
1198 record_component, dtype, dimensions, offset, extent, invert, memory_view)
RESULT(status) &
1199 BIND(C, name="openPMD_RecordComponent_storeChunkSpan")
1200 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1201 TYPE(C_PTR),
VALUE :: record_component
1202 INTEGER(KIND=C_INT),
VALUE :: dtype
1203 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1204 TYPE(C_PTR),
VALUE :: offset, extent
1205 TYPE(C_PTR) :: memory_view
1206 INTEGER(KIND=C_INT) :: status
1207 END FUNCTION openpmd_c_record_component_store_chunk_span
1210 memory_view%chunk_extent = extent
1211 status = openpmd_c_record_component_store_chunk_span( &
1212 record_component%c_ptr, &
1213 openpmd_type_double, &
1220 END FUNCTION openpmd_record_component_store_chunk_span_2d_double
1222 FUNCTION openpmd_dynamic_memory_view_resolve_2d_double(memory_view, DEALLOCATE)
RESULT(buffer)
1223 CLASS(openpmd_dynamic_memory_view_type_2d) :: memory_view
1224 LOGICAL :: deallocate
1225 REAL(kind=
dp),
POINTER :: buffer(:,:)
1227 INTEGER(KIND=C_INT) :: deallocate_c, status
1228 TYPE(C_PTR),
TARGET :: c_buffer
1230 FUNCTION openpmd_c_dynamic_memory_view_resolve(memory_view, DEALLOCATE, write_buffer)
RESULT(status) &
1231 BIND(C, name="openPMD_DynamicMemoryView_resolve")
1232 IMPORT :: c_ptr, c_int
1233 TYPE(C_PTR),
VALUE :: memory_view
1234 INTEGER(KIND=C_INT),
VALUE :: deallocate
1235 TYPE(C_PTR) :: write_buffer
1236 INTEGER(KIND=C_INT) :: status
1237 END FUNCTION openpmd_c_dynamic_memory_view_resolve
1240 IF (deallocate)
THEN
1246 status = openpmd_c_dynamic_memory_view_resolve(memory_view%c_ptr, deallocate_c, c_buffer)
1247 CALL c_f_pointer(c_buffer, buffer, memory_view%chunk_extent)
1248 END FUNCTION openpmd_dynamic_memory_view_resolve_2d_double
1250 SUBROUTINE openpmd_record_component_store_chunk_3d_double(record_component, data_, offset)
1251 CLASS(openpmd_record_component_type) :: record_component
1252 REAL(kind=
dp),
TARGET :: data_(:,:,:)
1253 INTEGER,
DIMENSION(3),
TARGET :: offset
1255 INTEGER(KIND=C_INT) :: status
1256 INTEGER,
DIMENSION(3),
TARGET :: extent
1258 FUNCTION openpmd_c_record_component_store_chunk( &
1259 record_component, dtype, dimensions, offset, extent, invert, data_)
RESULT(status) &
1260 BIND(C, name="openPMD_RecordComponent_storeChunk")
1261 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1262 TYPE(C_PTR),
VALUE :: record_component
1263 INTEGER(KIND=C_INT),
VALUE :: dtype
1264 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1265 TYPE(C_PTR),
VALUE :: offset, extent
1266 TYPE(C_PTR),
VALUE :: data_
1267 INTEGER(KIND=C_INT) :: status
1268 END FUNCTION openpmd_c_record_component_store_chunk
1271 extent = shape(data_)
1272 status = openpmd_c_record_component_store_chunk( &
1273 record_component%c_ptr, &
1274 openpmd_type_double, &
1281 END SUBROUTINE openpmd_record_component_store_chunk_3d_double
1283 FUNCTION openpmd_record_component_store_chunk_span_3d_double( &
1284 record_component, offset, extent)
RESULT(memory_view)
1285 CLASS(openpmd_record_component_type) :: record_component
1286 INTEGER,
DIMENSION(3),
TARGET :: offset, extent
1287 TYPE(openpmd_dynamic_memory_view_type_3d) :: memory_view
1289 INTEGER(KIND=C_INT) :: status
1291 FUNCTION openpmd_c_record_component_store_chunk_span( &
1292 record_component, dtype, dimensions, offset, extent, invert, memory_view)
RESULT(status) &
1293 BIND(C, name="openPMD_RecordComponent_storeChunkSpan")
1294 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1295 TYPE(C_PTR),
VALUE :: record_component
1296 INTEGER(KIND=C_INT),
VALUE :: dtype
1297 INTEGER(KIND=C_INT),
VALUE :: dimensions, invert
1298 TYPE(C_PTR),
VALUE :: offset, extent
1299 TYPE(C_PTR) :: memory_view
1300 INTEGER(KIND=C_INT) :: status
1301 END FUNCTION openpmd_c_record_component_store_chunk_span
1304 memory_view%chunk_extent = extent
1305 status = openpmd_c_record_component_store_chunk_span( &
1306 record_component%c_ptr, &
1307 openpmd_type_double, &
1314 END FUNCTION openpmd_record_component_store_chunk_span_3d_double
1316 FUNCTION openpmd_dynamic_memory_view_resolve_3d_double(memory_view, DEALLOCATE)
RESULT(buffer)
1317 CLASS(openpmd_dynamic_memory_view_type_3d) :: memory_view
1318 LOGICAL :: deallocate
1319 REAL(kind=
dp),
POINTER :: buffer(:,:,:)
1321 INTEGER(KIND=C_INT) :: deallocate_c, status
1322 TYPE(C_PTR),
TARGET :: c_buffer
1324 FUNCTION openpmd_c_dynamic_memory_view_resolve(memory_view, DEALLOCATE, write_buffer)
RESULT(status) &
1325 BIND(C, name="openPMD_DynamicMemoryView_resolve")
1326 IMPORT :: c_ptr, c_int
1327 TYPE(C_PTR),
VALUE :: memory_view
1328 INTEGER(KIND=C_INT),
VALUE :: deallocate
1329 TYPE(C_PTR) :: write_buffer
1330 INTEGER(KIND=C_INT) :: status
1331 END FUNCTION openpmd_c_dynamic_memory_view_resolve
1334 IF (deallocate)
THEN
1340 status = openpmd_c_dynamic_memory_view_resolve(memory_view%c_ptr, deallocate_c, c_buffer)
1341 CALL c_f_pointer(c_buffer, buffer, memory_view%chunk_extent)
1342 END FUNCTION openpmd_dynamic_memory_view_resolve_3d_double
1350 FUNCTION openpmd_particle_species_get_record(this, name)
RESULT(record)
1351 CLASS(openpmd_particle_species_type) :: this
1352 CHARACTER(LEN=*),
INTENT(IN) :: name
1353 TYPE(openpmd_record_type) :: record
1355 INTEGER(KIND=C_INT) :: status
1357 FUNCTION openpmd_c_particle_species_get_record(particle_species, name, record)
RESULT(status) &
1358 BIND(C, name="openPMD_ParticleSpecies_get_Record")
1359 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1360 TYPE(C_PTR),
VALUE :: particle_species
1361 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: name
1362 TYPE(C_PTR) :: record
1363 INTEGER(KIND=C_INT) :: status
1364 END FUNCTION openpmd_c_particle_species_get_record
1367 cpassert(.NOT. c_associated(record%c_ptr))
1368 status = openpmd_c_particle_species_get_record(this%c_ptr, name//c_null_char, record%c_ptr)
1369 cpassert(c_associated(record%c_ptr))
1370 END FUNCTION openpmd_particle_species_get_record
1378 FUNCTION openpmd_record_get_component(this, name)
RESULT(record_component)
1379 CLASS(openpmd_record_type) :: this
1380 CHARACTER(LEN=*),
INTENT(IN) :: name
1381 TYPE(openpmd_record_component_type) :: record_component
1383 INTEGER(KIND=C_INT) :: status
1385 FUNCTION openpmd_c_record_get_component(record, name, record_component)
RESULT(status) &
1386 BIND(C, name="openPMD_Record_get_Component")
1387 IMPORT :: c_ptr, c_int64_t, c_int, c_size_t, c_char
1388 TYPE(C_PTR),
VALUE :: record
1389 CHARACTER(KIND=C_CHAR),
DIMENSION(*) :: name
1390 TYPE(C_PTR) :: record_component
1391 INTEGER(KIND=C_INT) :: status
1392 END FUNCTION openpmd_c_record_get_component
1395 cpassert(.NOT. c_associated(record_component%c_ptr))
1396 status = openpmd_c_record_get_component(this%c_ptr, name//c_null_char, record_component%c_ptr)
1397 cpassert(c_associated(record_component%c_ptr))
1398 END FUNCTION openpmd_record_get_component
1407 SUBROUTINE openpmd_record_set_unit_dimension(this, unitDimension)
1408 CLASS(openpmd_record_type) :: this
1409 REAL(KIND=c_double),
DIMENSION(7),
TARGET :: unitdimension
1412 SUBROUTINE openpmd_c_record_set_unit_dimension(record, unitDimension) &
1413 BIND(C, NAME="openPMD_Record_setUnitDimension")
1414 IMPORT :: c_ptr, c_double
1415 TYPE(C_PTR),
VALUE :: record
1416 REAL(KIND=c_double),
DIMENSION(*) :: unitdimension
1417 END SUBROUTINE openpmd_c_record_set_unit_dimension
1420 CALL openpmd_c_record_set_unit_dimension(this%c_ptr, unitdimension)
1421 END SUBROUTINE openpmd_record_set_unit_dimension
1424 SUBROUTINE openpmd_mesh_set_grid_global_offset(this, vec)
1425 CLASS(openpmd_mesh_type) :: this
1426 REAL(KIND=
dp),
DIMENSION(:),
TARGET :: vec
1428 INTEGER,
TARGET :: size_
1430 SUBROUTINE openpmd_c_set_vector_attribute(mesh, vec, length, invert) &
1431 BIND(C, NAME="openPMD_Mesh_setGridGlobalOffset")
1432 IMPORT :: c_char, c_size_t, c_int, c_ptr
1433 TYPE(C_PTR),
VALUE :: mesh
1434 TYPE(C_PTR),
VALUE :: vec
1435 INTEGER(KIND=C_INT),
VALUE :: length, invert
1436 END SUBROUTINE openpmd_c_set_vector_attribute
1440 CALL openpmd_c_set_vector_attribute(this%c_ptr, c_loc(vec(1)), size_, 1)
1442 END SUBROUTINE openpmd_mesh_set_grid_global_offset
1443 SUBROUTINE openpmd_mesh_set_grid_spacing(this, vec)
1444 CLASS(openpmd_mesh_type) :: this
1445 REAL(KIND=
dp),
DIMENSION(:),
TARGET :: vec
1447 INTEGER,
TARGET :: size_
1449 SUBROUTINE openpmd_c_set_vector_attribute(mesh, vec, length, invert) &
1450 BIND(C, NAME="openPMD_Mesh_setGridSpacing")
1451 IMPORT :: c_char, c_size_t, c_int, c_ptr
1452 TYPE(C_PTR),
VALUE :: mesh
1453 TYPE(C_PTR),
VALUE :: vec
1454 INTEGER(KIND=C_INT),
VALUE :: length, invert
1455 END SUBROUTINE openpmd_c_set_vector_attribute
1459 CALL openpmd_c_set_vector_attribute(this%c_ptr, c_loc(vec(1)), size_, 1)
1461 END SUBROUTINE openpmd_mesh_set_grid_spacing
1462 SUBROUTINE openpmd_mesh_set_position(this, vec)
1463 CLASS(openpmd_mesh_type) :: this
1464 REAL(KIND=
dp),
DIMENSION(:),
TARGET :: vec
1466 INTEGER,
TARGET :: size_
1468 SUBROUTINE openpmd_c_set_vector_attribute(mesh, vec, length, invert) &
1469 BIND(C, NAME="openPMD_Mesh_setPosition")
1470 IMPORT :: c_char, c_size_t, c_int, c_ptr
1471 TYPE(C_PTR),
VALUE :: mesh
1472 TYPE(C_PTR),
VALUE :: vec
1473 INTEGER(KIND=C_INT),
VALUE :: length, invert
1474 END SUBROUTINE openpmd_c_set_vector_attribute
1478 CALL openpmd_c_set_vector_attribute(this%c_ptr, c_loc(vec(1)), size_, 1)
1480 END SUBROUTINE openpmd_mesh_set_position
1482 SUBROUTINE openpmd_mesh_set_grid_unit_si(this, gridUnitSI)
1483 CLASS(openpmd_mesh_type) :: this
1484 REAL(KIND=c_double),
INTENT(IN),
VALUE :: gridunitsi
1487 SUBROUTINE openpmd_c_mesh_set_grid_unit_si(mesh, gridUnitSI) &
1488 BIND(C, NAME="openPMD_Mesh_setGridUnitSI")
1489 IMPORT :: c_ptr, c_double
1490 TYPE(C_PTR),
VALUE :: mesh
1491 REAL(KIND=c_double),
VALUE :: gridunitsi
1492 END SUBROUTINE openpmd_c_mesh_set_grid_unit_si
1495 CALL openpmd_c_mesh_set_grid_unit_si(this%c_ptr, gridunitsi)
1496 END SUBROUTINE openpmd_mesh_set_grid_unit_si
1505 SUBROUTINE openpmd_mesh_set_unit_dimension(this, unitDimension)
1506 CLASS(openpmd_mesh_type) :: this
1507 REAL(KIND=c_double),
DIMENSION(7),
TARGET :: unitdimension
1510 SUBROUTINE openpmd_c_mesh_set_unit_dimension(mesh, unitDimension) &
1511 BIND(C, NAME="openPMD_Mesh_setUnitDimension")
1512 IMPORT :: c_ptr, c_double
1513 TYPE(C_PTR),
VALUE :: mesh
1514 REAL(KIND=c_double),
DIMENSION(*) :: unitdimension
1515 END SUBROUTINE openpmd_c_mesh_set_unit_dimension
1518 CALL openpmd_c_mesh_set_unit_dimension(this%c_ptr, unitdimension)
1519 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.