diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 15152a09ca..bcc3b0f7c1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1561,9 +1561,9 @@ endif() list(APPEND CP2K_SRCS_C ${CP2K_DBM_SRCS_C} ${CP2K_GRID_SRCS_C}) -list(APPEND CP2K_SRCS_F openPMD.F input/cp_output_handling_openpmd.F +list(APPEND CP2K_SRCS_F openpmd_api.F input/cp_output_handling_openpmd.F cp_realspace_grid_openpmd.F pw/realspace_grid_openpmd.F) -list(APPEND CP2K_SRCS_CPP openPMD.cpp) +list(APPEND CP2K_SRCS_CPP openpmd_c_api.cpp) # ############################################################################## # check that the files registered in CMakeLists.txt are all present and return diff --git a/src/input/cp_output_handling_openpmd.F b/src/input/cp_output_handling_openpmd.F index 674e48cc2b..df5576b5b0 100644 --- a/src/input/cp_output_handling_openpmd.F +++ b/src/input/cp_output_handling_openpmd.F @@ -73,16 +73,16 @@ MODULE cp_output_handling_openpmd #ifdef __OPENPMD TYPE :: cp_openpmd_per_call_value_type - TYPE(openpmd_series_type) :: series - TYPE(openpmd_iteration_type) :: iteration - ! TYPE(openpmd_mesh_type) :: mesh - ! TYPE(openpmd_particle_species_type) :: particle_species - CHARACTER(len=default_string_length) :: name_prefix ! e.g. 'WFN_00008_1' + TYPE(openpmd_series_type) :: series = openpmd_series_type() + TYPE(openpmd_iteration_type) :: iteration = openpmd_iteration_type() + ! TYPE(openpmd_mesh_type) :: mesh = openpmd_mesh_type() + ! TYPE(openpmd_particle_species_type) :: particle_species = openpmd_particle_species_type() + CHARACTER(len=default_string_length) :: name_prefix = "" ! e.g. 'WFN_00008_1' END TYPE cp_openpmd_per_call_value_type TYPE :: cp_openpmd_per_call_type - INTEGER :: key ! unit_nr - TYPE(cp_openpmd_per_call_value_type) :: value + INTEGER :: key = -1 ! unit_nr + TYPE(cp_openpmd_per_call_value_type) :: value = cp_openpmd_per_call_value_type() END TYPE cp_openpmd_per_call_type TYPE :: cp_current_iteration_counter_type @@ -93,16 +93,16 @@ MODULE cp_output_handling_openpmd TYPE :: cp_openpmd_per_callsite_value_type ! openPMD output Series. - TYPE(openpmd_series_type) :: output_series + TYPE(openpmd_series_type) :: output_series = openpmd_series_type() ! Information on the last Iteration that was written to, including ! CP2Ks complex Iteration number and its associated contiguous scalar ! openPMD Iteration number. - TYPE(cp_current_iteration_counter_type) :: iteration_counter + TYPE(cp_current_iteration_counter_type) :: iteration_counter = cp_current_iteration_counter_type() END TYPE cp_openpmd_per_callsite_value_type TYPE :: cp_openpmd_per_callsite_type - CHARACTER(len=default_string_length) :: key ! openpmd_basename - TYPE(cp_openpmd_per_callsite_value_type) :: value + CHARACTER(len=default_string_length) :: key = "" ! openpmd_basename + TYPE(cp_openpmd_per_callsite_value_type) :: value = cp_openpmd_per_callsite_value_type() END TYPE cp_openpmd_per_callsite_type !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/src/openPMD.F b/src/openpmd_api.F similarity index 99% rename from src/openPMD.F rename to src/openpmd_api.F index f8ca81001d..7ab32530c1 100644 --- a/src/openPMD.F +++ b/src/openpmd_api.F @@ -5,7 +5,7 @@ ! SPDX-License-Identifier: GPL-2.0-or-later ! !--------------------------------------------------------------------------------------------------! -MODULE openPMD_api +MODULE openpmd_api #ifdef __OPENPMD @@ -1041,4 +1041,4 @@ MODULE openPMD_api #endif ! In two lines of this file, `make pretty` applies a wrong indentation and keeps it for the rest of this file. ! Hence, we end up a bit further to the right than we should. - END MODULE openPMD_api + END MODULE openpmd_api diff --git a/src/openPMD.cpp b/src/openpmd_c_api.cpp similarity index 100% rename from src/openPMD.cpp rename to src/openpmd_c_api.cpp diff --git a/src/qs_scf_post_gpw.F b/src/qs_scf_post_gpw.F index 4fb124f3cc..288e549e60 100644 --- a/src/qs_scf_post_gpw.F +++ b/src/qs_scf_post_gpw.F @@ -233,11 +233,11 @@ MODULE qs_scf_post_gpw ! or not, and on whether it has been activated in the Cube or openPMD variant. ! Create with function cube_or_openpmd(), see there for further details. TYPE cp_section_key - CHARACTER(len=default_string_length) :: relative_section_key ! e.g. PRINT%MO_CUBES - CHARACTER(len=default_string_length) :: absolute_section_key ! e.g. DFT%PRINT%MO_CUBES - CHARACTER(len=7) :: format_name ! 'openPMD' or 'Cube', for logging - INTEGER :: grid_output ! either 1 for grid_output_cubes or 2 for grid_output_openpmd - LOGICAL :: do_output + CHARACTER(len=default_string_length) :: relative_section_key = "" ! e.g. PRINT%MO_CUBES + CHARACTER(len=default_string_length) :: absolute_section_key = "" ! e.g. DFT%PRINT%MO_CUBES + CHARACTER(len=7) :: format_name = "" ! 'openPMD' or 'Cube', for logging + INTEGER :: grid_output = -1 ! either 1 for grid_output_cubes or 2 for grid_output_openpmd + LOGICAL :: do_output = .FALSE. CONTAINS ! Open a file as either Cube or openPMD PROCEDURE, PUBLIC :: print_key_unit_nr => cp_forward_print_key_unit_nr diff --git a/tools/conventions/conventions.supp b/tools/conventions/conventions.supp index f594f542c2..c62d9c641a 100644 --- a/tools/conventions/conventions.supp +++ b/tools/conventions/conventions.supp @@ -38,6 +38,7 @@ cp_lbfgs.F: Found WRITE statement with hardcoded unit in "subsm" https://cp2k.or cp_log_handling.F: Found WRITE statement with hardcoded unit in "cp_int_to_string" https://cp2k.org/conv#c012 cp_log_handling.F: Found WRITE statement with hardcoded unit in "cp_logger_get_default_unit_nr" https://cp2k.org/conv#c012 cp_log_handling.F: Found WRITE statement with hardcoded unit in "cp_real_dp_to_string" https://cp2k.org/conv#c012 +cp_output_handling_openpmd.F: Found type cp_openpmd_per_call_value_type without initializer https://cp2k.org/conv#c016 cp_parser_inpp_methods.F: Found READ with unchecked STAT in "inpp_process_directive" https://cp2k.org/conv#c001 cube_utils.F: Found WRITE statement with hardcoded unit in "return_cube_nonortho" https://cp2k.org/conv#c012 d3_poly.F: Found CALL RANDOM_NUMBER in procedure "poly_random" https://cp2k.org/conv#c104 diff --git a/tools/precommit/precommit.py b/tools/precommit/precommit.py index 17339c35e0..db13b6ab56 100755 --- a/tools/precommit/precommit.py +++ b/tools/precommit/precommit.py @@ -225,12 +225,8 @@ def process_file(fn: str, allow_modifications: bool) -> None: run_remote_tool("clangformat", fn) if re.match(r".*\.(cc|cpp|cxx|hcc|hpp|hxx)$", fn): - if ( - fn.endswith("/torch_c_api.cpp") - or fn.endswith("/ace_c_api.cpp") - or fn.endswith("/openPMD.cpp") - ): - # Begrudgingly tolerated because PyTorch/Ace/openPMD have no C API. + if basename in ["torch_c_api.cpp", "ace_c_api.cpp", "openpmd_c_api.cpp"]: + # Begrudgingly tolerated because some libraries have no C API. run_remote_tool("clangformat", fn) else: raise Exception(f"C++ is not supported.")