From 511ae43bf040d1dbfeccbbf03768c9b2c8d60287 Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Wed, 19 Apr 2023 15:20:28 +0200 Subject: [PATCH 01/15] No dependency test created --- pyutils/tests/f2ser/conftest.py | 4 +++ pyutils/tests/f2ser/test_f2ser_cli.py | 6 +++++ .../fortran/no_deps_subroutine_example.f90 | 25 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 testutils/src/icon4py/testutils/fortran/no_deps_subroutine_example.f90 diff --git a/pyutils/tests/f2ser/conftest.py b/pyutils/tests/f2ser/conftest.py index 3244246c76..3525004f59 100644 --- a/pyutils/tests/f2ser/conftest.py +++ b/pyutils/tests/f2ser/conftest.py @@ -31,3 +31,7 @@ def diffusion_granule(samples_path): @pytest.fixture def diffusion_granule_deps(samples_path): return [samples_path / "derived_types_example.f90"] + +@pytest.fixture +def no_deps_source_file(samples_path): + return samples_path / "no_deps_subroutine_example.f90" diff --git a/pyutils/tests/f2ser/test_f2ser_cli.py b/pyutils/tests/f2ser/test_f2ser_cli.py index 8962ed1c25..d8901cfeac 100644 --- a/pyutils/tests/f2ser/test_f2ser_cli.py +++ b/pyutils/tests/f2ser/test_f2ser_cli.py @@ -33,3 +33,9 @@ def test_cli(diffusion_granule, diffusion_granule_deps, outfile, cli): args = [inp, outfile, "-d", ",".join(deps)] result = cli.invoke(main, args) assert result.exit_code == 0 + +def test_cli_no_deps(no_deps_source_file, outfile, cli): + inp = str(no_deps_source_file) + args = [inp, outfile] + result = cli.invoke(main, args) + assert result.exit_code == 0 diff --git a/testutils/src/icon4py/testutils/fortran/no_deps_subroutine_example.f90 b/testutils/src/icon4py/testutils/fortran/no_deps_subroutine_example.f90 new file mode 100644 index 0000000000..021cb4aa76 --- /dev/null +++ b/testutils/src/icon4py/testutils/fortran/no_deps_subroutine_example.f90 @@ -0,0 +1,25 @@ +MODULE no_deps_example_subroutines + IMPLICIT NONE + + PUBLIC :: no_deps_init, no_deps_run + PRIVATE + + CONTAINS + + SUBROUTINE no_deps_init(a, b, c) + REAL, INTENT(in) :: a + REAL, INTENT(inout) :: b + REAL, INTENT(out) :: c + c = a + b + b = 2.0 * b + END SUBROUTINE no_deps_init + + SUBROUTINE no_deps_run(a, b, c) + REAL, INTENT(in) :: a + REAL, INTENT(inout) :: b + REAL, INTENT(out) :: c + c = a + b + b = 2.0 * b + END SUBROUTINE no_deps_run + +END MODULE no_deps_example_subroutines From 6d5034e288de44e8789376b2df6769687126ede0 Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Wed, 19 Apr 2023 18:38:10 +0200 Subject: [PATCH 02/15] Missing dependency test added --- pyutils/tests/f2ser/test_f2ser_cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyutils/tests/f2ser/test_f2ser_cli.py b/pyutils/tests/f2ser/test_f2ser_cli.py index d8901cfeac..80b1e18eb0 100644 --- a/pyutils/tests/f2ser/test_f2ser_cli.py +++ b/pyutils/tests/f2ser/test_f2ser_cli.py @@ -15,7 +15,7 @@ from click.testing import CliRunner from icon4py.f2ser.cli import main - +from icon4py.f2ser.exceptions import MissingDerivedTypeError @pytest.fixture def outfile(tmp_path): @@ -39,3 +39,9 @@ def test_cli_no_deps(no_deps_source_file, outfile, cli): args = [inp, outfile] result = cli.invoke(main, args) assert result.exit_code == 0 + +def test_cli_missing_deps(diffusion_granule, outfile, cli): + inp = str(diffusion_granule) + args = [inp, outfile] + result = cli.invoke(main, args) + assert result.exception == MissingDerivedTypeError From 853c7bc45b6de2658395c5036ecd63d91d55cf4f Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Thu, 20 Apr 2023 12:41:25 +0200 Subject: [PATCH 03/15] Added test for non existing granule input file --- pyutils/tests/f2ser/conftest.py | 4 ++++ pyutils/tests/f2ser/test_f2ser_cli.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/pyutils/tests/f2ser/conftest.py b/pyutils/tests/f2ser/conftest.py index 3525004f59..734875d839 100644 --- a/pyutils/tests/f2ser/conftest.py +++ b/pyutils/tests/f2ser/conftest.py @@ -35,3 +35,7 @@ def diffusion_granule_deps(samples_path): @pytest.fixture def no_deps_source_file(samples_path): return samples_path / "no_deps_subroutine_example.f90" + +@pytest.fixture +def not_existing_diffusion_granule(samples_path): + return samples_path / "not_existing_file.f90" diff --git a/pyutils/tests/f2ser/test_f2ser_cli.py b/pyutils/tests/f2ser/test_f2ser_cli.py index 80b1e18eb0..2267ac1bc3 100644 --- a/pyutils/tests/f2ser/test_f2ser_cli.py +++ b/pyutils/tests/f2ser/test_f2ser_cli.py @@ -45,3 +45,10 @@ def test_cli_missing_deps(diffusion_granule, outfile, cli): args = [inp, outfile] result = cli.invoke(main, args) assert result.exception == MissingDerivedTypeError + +def test_cli_missing_source(not_existing_diffusion_granule, outfile, cli): + inp = str(not_existing_diffusion_granule) + args = [inp, outfile] + result = cli.invoke(main, args) + error_search = result.stdout.find("Invalid value for \'GRANULE_PATH\'") + assert error_search != -1 From d4807456bb70f238daa6ebb838baf3761c753523 Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Thu, 27 Apr 2023 18:35:12 +0200 Subject: [PATCH 04/15] Fix for source with no external dependencies --- pyutils/src/icon4py/f2ser/parse.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyutils/src/icon4py/f2ser/parse.py b/pyutils/src/icon4py/f2ser/parse.py index af79e52159..29f012b42d 100644 --- a/pyutils/src/icon4py/f2ser/parse.py +++ b/pyutils/src/icon4py/f2ser/parse.py @@ -162,11 +162,12 @@ def _parse_derived_types(self, derived_types: dict) -> dict: MissingDerivedTypeError: If the type definition for a derived type could not be found in any of the dependency files. """ derived_type_defs = {} - for dep in self.dependencies: - parsed = crack(dep) - for block in parsed["body"]: - if block["block"] == "type": - derived_type_defs[block["name"]] = block["vars"] + if self.dependencies: + for dep in self.dependencies: + parsed = crack(dep) + for block in parsed["body"]: + if block["block"] == "type": + derived_type_defs[block["name"]] = block["vars"] for _, subroutine_vars in derived_types.items(): for _, intent_vars in subroutine_vars.items(): From 173f2de5e1ba23de51230d4a21df78c131cf896a Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Fri, 28 Apr 2023 16:12:12 +0200 Subject: [PATCH 05/15] Serialization directives generation test created --- pyutils/tests/f2ser/test_f2ser_codegen.py | 27 ++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pyutils/tests/f2ser/test_f2ser_codegen.py b/pyutils/tests/f2ser/test_f2ser_codegen.py index f00187eb72..6ab1b99cdd 100644 --- a/pyutils/tests/f2ser/test_f2ser_codegen.py +++ b/pyutils/tests/f2ser/test_f2ser_codegen.py @@ -11,10 +11,12 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +import pytest + from icon4py.f2ser.deserialise import ParsedGranuleDeserialiser from icon4py.f2ser.parse import GranuleParser from icon4py.liskov.codegen.serialisation.generate import SerialisationGenerator - +from icon4py.liskov.codegen.types import GeneratedCode def test_deserialiser_diffusion_codegen(diffusion_granule, diffusion_granule_deps): parser = GranuleParser(diffusion_granule, diffusion_granule_deps) @@ -24,3 +26,26 @@ def test_deserialiser_diffusion_codegen(diffusion_granule, diffusion_granule_dep generator = SerialisationGenerator(interface) generated = generator() assert len(generated) == 3 + +@pytest.fixture +def expected_no_deps_serialization_directives(): + serialization_directives = [ + GeneratedCode(startln=12, + source='\n!$ser init directory="." prefix="test"\n\n!$ser savepoint no_deps_init_in\n\n!$ser data a=a\n\n!$ser data b=b'), + GeneratedCode(startln=14, + source='\n!$ser savepoint no_deps_init_out\n\n!$ser data c=c\n\n!$ser data b=b'), + GeneratedCode(startln=20, + source='\n!$ser savepoint no_deps_run_in\n\n!$ser data a=a\n\n!$ser data b=b'), + GeneratedCode(startln=22, + source='\n!$ser savepoint no_deps_run_out\n\n!$ser data c=c\n\n!$ser data b=b')] + return serialization_directives + +def test_deserialiser_no_deps_codegen(no_deps_source_file, diffusion_granule_deps, + expected_no_deps_serialization_directives): + parser = GranuleParser(no_deps_source_file) + parsed = parser.parse() + deserialiser = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test") + interface = deserialiser.deserialise() + generator = SerialisationGenerator(interface) + generated = generator() + assert(generated == expected_no_deps_serialization_directives()) From 55d6591691bd430b32f9f45f8e6755c2a0777e91 Mon Sep 17 00:00:00 2001 From: samkellerhals Date: Tue, 2 May 2023 09:46:14 +0200 Subject: [PATCH 06/15] Add small fixes --- pyutils/tests/f2ser/conftest.py | 2 ++ pyutils/tests/f2ser/test_f2ser_cli.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pyutils/tests/f2ser/conftest.py b/pyutils/tests/f2ser/conftest.py index 734875d839..ff73a38d4f 100644 --- a/pyutils/tests/f2ser/conftest.py +++ b/pyutils/tests/f2ser/conftest.py @@ -32,10 +32,12 @@ def diffusion_granule(samples_path): def diffusion_granule_deps(samples_path): return [samples_path / "derived_types_example.f90"] + @pytest.fixture def no_deps_source_file(samples_path): return samples_path / "no_deps_subroutine_example.f90" + @pytest.fixture def not_existing_diffusion_granule(samples_path): return samples_path / "not_existing_file.f90" diff --git a/pyutils/tests/f2ser/test_f2ser_cli.py b/pyutils/tests/f2ser/test_f2ser_cli.py index 2267ac1bc3..ac544211ea 100644 --- a/pyutils/tests/f2ser/test_f2ser_cli.py +++ b/pyutils/tests/f2ser/test_f2ser_cli.py @@ -17,6 +17,7 @@ from icon4py.f2ser.cli import main from icon4py.f2ser.exceptions import MissingDerivedTypeError + @pytest.fixture def outfile(tmp_path): return str(tmp_path / "gen.f90") @@ -34,21 +35,25 @@ def test_cli(diffusion_granule, diffusion_granule_deps, outfile, cli): result = cli.invoke(main, args) assert result.exit_code == 0 + def test_cli_no_deps(no_deps_source_file, outfile, cli): inp = str(no_deps_source_file) args = [inp, outfile] result = cli.invoke(main, args) assert result.exit_code == 0 + def test_cli_missing_deps(diffusion_granule, outfile, cli): inp = str(diffusion_granule) args = [inp, outfile] result = cli.invoke(main, args) - assert result.exception == MissingDerivedTypeError + assert isinstance(result.exception, MissingDerivedTypeError) + def test_cli_missing_source(not_existing_diffusion_granule, outfile, cli): inp = str(not_existing_diffusion_granule) args = [inp, outfile] result = cli.invoke(main, args) - error_search = result.stdout.find("Invalid value for \'GRANULE_PATH\'") + error_search = result.stdout.find("Invalid value for 'GRANULE_PATH'") assert error_search != -1 + assert isinstance(result.exception, SystemExit) From 48ee72bb90be5284cb8cc9283af4687130fb1ec9 Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Wed, 3 May 2023 17:21:36 +0200 Subject: [PATCH 07/15] Serialization directives generation test created for diffusion granule --- pyutils/tests/f2ser/test_f2ser_codegen.py | 20 ++++++++++++++++--- ...ffusion_serialization_directives.f90.f2ser | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 testutils/src/icon4py/testutils/fortran/expected_diffusion_serialization_directives.f90.f2ser diff --git a/pyutils/tests/f2ser/test_f2ser_codegen.py b/pyutils/tests/f2ser/test_f2ser_codegen.py index 6ab1b99cdd..b00f7c0c38 100644 --- a/pyutils/tests/f2ser/test_f2ser_codegen.py +++ b/pyutils/tests/f2ser/test_f2ser_codegen.py @@ -12,6 +12,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later import pytest +import difflib +from pathlib import Path from icon4py.f2ser.deserialise import ParsedGranuleDeserialiser from icon4py.f2ser.parse import GranuleParser @@ -40,12 +42,24 @@ def expected_no_deps_serialization_directives(): source='\n!$ser savepoint no_deps_run_out\n\n!$ser data c=c\n\n!$ser data b=b')] return serialization_directives -def test_deserialiser_no_deps_codegen(no_deps_source_file, diffusion_granule_deps, - expected_no_deps_serialization_directives): +def test_deserialiser_directives_no_deps_codegen(no_deps_source_file, expected_no_deps_serialization_directives): parser = GranuleParser(no_deps_source_file) parsed = parser.parse() deserialiser = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test") interface = deserialiser.deserialise() generator = SerialisationGenerator(interface) generated = generator() - assert(generated == expected_no_deps_serialization_directives()) + assert(generated == expected_no_deps_serialization_directives) + +def test_deserialiser_directives_diffusion_codegen(diffusion_granule, diffusion_granule_deps, + expected_diffusion_serialization_directives): + parser = GranuleParser(diffusion_granule, diffusion_granule_deps) + parsed = parser.parse() + deserialiser = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test") + interface = deserialiser.deserialise() + generator = SerialisationGenerator(interface) + generated = generator() + reference_str = Path(expected_diffusion_serialization_directives).read_text() + generated_str = ', '.join([str(elem) for elem in generated]) + generated_str = "[" + generated_str + "]\n" + assert(generated_str == reference_str) diff --git a/testutils/src/icon4py/testutils/fortran/expected_diffusion_serialization_directives.f90.f2ser b/testutils/src/icon4py/testutils/fortran/expected_diffusion_serialization_directives.f90.f2ser new file mode 100644 index 0000000000..2b2964cdfb --- /dev/null +++ b/testutils/src/icon4py/testutils/fortran/expected_diffusion_serialization_directives.f90.f2ser @@ -0,0 +1 @@ +[GeneratedCode(startln=280, source='\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_vert_v1\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_vert_v2\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_vert_v1\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_vert_v2\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_cell_v1\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_cell_v2\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_cell_v1\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_cell_v2\n\n !$ser init directory="." prefix="test"\n\n !$ser savepoint diffusion_init_in\n\n !$ser verbatim allocate(edges_primal_normal_vert_v1(size(edges_primal_normal_vert, 1), size(edges_primal_normal_vert, 2), size(edges_primal_normal_vert, 3)))\n !$ser data edges_primal_normal_vert_v1=edges_primal_normal_vert_v1(:,:,:)\n !$ser verbatim deallocate(edges_primal_normal_vert_v1)\n\n !$ser verbatim allocate(edges_primal_normal_vert_v2(size(edges_primal_normal_vert, 1), size(edges_primal_normal_vert, 2), size(edges_primal_normal_vert, 3)))\n !$ser data edges_primal_normal_vert_v2=edges_primal_normal_vert_v2(:,:,:)\n !$ser verbatim deallocate(edges_primal_normal_vert_v2)\n\n !$ser verbatim allocate(edges_dual_normal_vert_v1(size(edges_dual_normal_vert, 1), size(edges_dual_normal_vert, 2), size(edges_dual_normal_vert, 3)))\n !$ser data edges_dual_normal_vert_v1=edges_dual_normal_vert_v1(:,:,:)\n !$ser verbatim deallocate(edges_dual_normal_vert_v1)\n\n !$ser verbatim allocate(edges_dual_normal_vert_v2(size(edges_dual_normal_vert, 1), size(edges_dual_normal_vert, 2), size(edges_dual_normal_vert, 3)))\n !$ser data edges_dual_normal_vert_v2=edges_dual_normal_vert_v2(:,:,:)\n !$ser verbatim deallocate(edges_dual_normal_vert_v2)\n\n !$ser verbatim allocate(edges_primal_normal_cell_v1(size(edges_primal_normal_cell, 1), size(edges_primal_normal_cell, 2), size(edges_primal_normal_cell, 3)))\n !$ser data edges_primal_normal_cell_v1=edges_primal_normal_cell_v1(:,:,:)\n !$ser verbatim deallocate(edges_primal_normal_cell_v1)\n\n !$ser verbatim allocate(edges_primal_normal_cell_v2(size(edges_primal_normal_cell, 1), size(edges_primal_normal_cell, 2), size(edges_primal_normal_cell, 3)))\n !$ser data edges_primal_normal_cell_v2=edges_primal_normal_cell_v2(:,:,:)\n !$ser verbatim deallocate(edges_primal_normal_cell_v2)\n\n !$ser verbatim allocate(edges_dual_normal_cell_v1(size(edges_dual_normal_cell, 1), size(edges_dual_normal_cell, 2), size(edges_dual_normal_cell, 3)))\n !$ser data edges_dual_normal_cell_v1=edges_dual_normal_cell_v1(:,:,:)\n !$ser verbatim deallocate(edges_dual_normal_cell_v1)\n\n !$ser verbatim allocate(edges_dual_normal_cell_v2(size(edges_dual_normal_cell, 1), size(edges_dual_normal_cell, 2), size(edges_dual_normal_cell, 3)))\n !$ser data edges_dual_normal_cell_v2=edges_dual_normal_cell_v2(:,:,:)\n !$ser verbatim deallocate(edges_dual_normal_cell_v2)\n\n !$ser data cvd_o_rd=cvd_o_rd\n\n !$ser data grav=grav\n\n !$ser data jg=jg\n\n !$ser data nproma=nproma\n\n !$ser data nlev=nlev\n\n !$ser data nblks_e=nblks_e\n\n !$ser data nblks_v=nblks_v\n\n !$ser data nblks_c=nblks_c\n\n !$ser data nshift=nshift\n\n !$ser data nshift_total=nshift_total\n\n !$ser data nrdmax=nrdmax\n\n !$ser data ndyn_substeps=ndyn_substeps\n\n !$ser data hdiff_order=hdiff_order\n\n !$ser data itype_comm=itype_comm\n\n !$ser data itype_sher=itype_sher\n\n !$ser data itype_vn_diffu=itype_vn_diffu\n\n !$ser data itype_t_diffu=itype_t_diffu\n\n !$ser data hdiff_smag_z=hdiff_smag_z\n\n !$ser data hdiff_smag_z2=hdiff_smag_z2\n\n !$ser data hdiff_smag_z3=hdiff_smag_z3\n\n !$ser data hdiff_smag_z4=hdiff_smag_z4\n\n !$ser data hdiff_smag_fac=hdiff_smag_fac\n\n !$ser data hdiff_smag_fac2=hdiff_smag_fac2\n\n !$ser data hdiff_smag_fac3=hdiff_smag_fac3\n\n !$ser data hdiff_smag_fac4=hdiff_smag_fac4\n\n !$ser data hdiff_efdt_ratio=hdiff_efdt_ratio\n\n !$ser data k4=k4\n\n !$ser data k4w=k4w\n\n !$ser data nudge_max_coeff=nudge_max_coeff\n\n !$ser data denom_diffu_v=denom_diffu_v\n\n !$ser data p_test_run=p_test_run\n\n !$ser data lphys=lphys\n\n !$ser data lhdiff_rcf=lhdiff_rcf\n\n !$ser data lhdiff_w=lhdiff_w\n\n !$ser data lhdiff_temp=lhdiff_temp\n\n !$ser data l_zdiffu_t=l_zdiffu_t\n\n !$ser data l_limited_area=l_limited_area\n\n !$ser data lfeedback=lfeedback\n\n !$ser data ltkeshs=ltkeshs\n\n !$ser data lsmag_3d=lsmag_3d\n\n !$ser data lvert_nest=lvert_nest\n\n !$ser data ltimer=ltimer\n\n !$ser data ddt_vn_hdf_is_associated=ddt_vn_hdf_is_associated\n\n !$ser data ddt_vn_dyn_is_associated=ddt_vn_dyn_is_associated\n\n IF (SIZE(vct_a) > 0) THEN\n !$ser data vct_a=vct_a(:)\n ELSE\n PRINT *, \'Warning: Array vct_a has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(c_lin_e) > 0) THEN\n !$ser data c_lin_e=c_lin_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array c_lin_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(e_bln_c_s) > 0) THEN\n !$ser data e_bln_c_s=e_bln_c_s(:,:,:)\n ELSE\n PRINT *, \'Warning: Array e_bln_c_s has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(e_bln_c_u) > 0) THEN\n !$ser data e_bln_c_u=e_bln_c_u(:,:,:)\n ELSE\n PRINT *, \'Warning: Array e_bln_c_u has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(e_bln_c_v) > 0) THEN\n !$ser data e_bln_c_v=e_bln_c_v(:,:,:)\n ELSE\n PRINT *, \'Warning: Array e_bln_c_v has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_aw_verts) > 0) THEN\n !$ser data cells_aw_verts=cells_aw_verts(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_aw_verts has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(geofac_div) > 0) THEN\n !$ser data geofac_div=geofac_div(:,:,:)\n ELSE\n PRINT *, \'Warning: Array geofac_div has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(geofac_rot) > 0) THEN\n !$ser data geofac_rot=geofac_rot(:,:,:)\n ELSE\n PRINT *, \'Warning: Array geofac_rot has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(geofac_n2s) > 0) THEN\n !$ser data geofac_n2s=geofac_n2s(:,:,:)\n ELSE\n PRINT *, \'Warning: Array geofac_n2s has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(geofac_grg) > 0) THEN\n !$ser data geofac_grg=geofac_grg(:,:,:,:)\n ELSE\n PRINT *, \'Warning: Array geofac_grg has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(nudgecoeff_e) > 0) THEN\n !$ser data nudgecoeff_e=nudgecoeff_e(:,:)\n ELSE\n PRINT *, \'Warning: Array nudgecoeff_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(rbf_vec_idx_v) > 0) THEN\n !$ser data rbf_vec_idx_v=rbf_vec_idx_v(:,:,:)\n ELSE\n PRINT *, \'Warning: Array rbf_vec_idx_v has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(rbf_vec_blk_v) > 0) THEN\n !$ser data rbf_vec_blk_v=rbf_vec_blk_v(:,:,:)\n ELSE\n PRINT *, \'Warning: Array rbf_vec_blk_v has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(rbf_vec_coeff_v) > 0) THEN\n !$ser data rbf_vec_coeff_v=rbf_vec_coeff_v(:,:,:,:)\n ELSE\n PRINT *, \'Warning: Array rbf_vec_coeff_v has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(enhfac_diffu) > 0) THEN\n !$ser data enhfac_diffu=enhfac_diffu(:)\n ELSE\n PRINT *, \'Warning: Array enhfac_diffu has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_intcoef) > 0) THEN\n !$ser data zd_intcoef=zd_intcoef(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_intcoef has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_geofac) > 0) THEN\n !$ser data zd_geofac=zd_geofac(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_geofac has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_diffcoef) > 0) THEN\n !$ser data zd_diffcoef=zd_diffcoef(:)\n ELSE\n PRINT *, \'Warning: Array zd_diffcoef has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(wgtfac_c) > 0) THEN\n !$ser data wgtfac_c=wgtfac_c(:,:,:)\n ELSE\n PRINT *, \'Warning: Array wgtfac_c has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(wgtfac_e) > 0) THEN\n !$ser data wgtfac_e=wgtfac_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array wgtfac_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(wgtfacq_e) > 0) THEN\n !$ser data wgtfacq_e=wgtfacq_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array wgtfacq_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(wgtfacq1_e) > 0) THEN\n !$ser data wgtfacq1_e=wgtfacq1_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array wgtfacq1_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(ddqz_z_full_e) > 0) THEN\n !$ser data ddqz_z_full_e=ddqz_z_full_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array ddqz_z_full_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(theta_ref_mc) > 0) THEN\n !$ser data theta_ref_mc=theta_ref_mc(:,:,:)\n ELSE\n PRINT *, \'Warning: Array theta_ref_mc has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_indlist) > 0) THEN\n !$ser data zd_indlist=zd_indlist(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_indlist has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_blklist) > 0) THEN\n !$ser data zd_blklist=zd_blklist(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_blklist has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_vertidx) > 0) THEN\n !$ser data zd_vertidx=zd_vertidx(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_vertidx has size 0. Not serializing array.\'\n END IF\n\n !$ser data zd_listdim=zd_listdim\n\n IF (SIZE(edges_start_block) > 0) THEN\n !$ser data edges_start_block=edges_start_block(min_rledge:)\n ELSE\n PRINT *, \'Warning: Array edges_start_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_end_block) > 0) THEN\n !$ser data edges_end_block=edges_end_block(min_rledge:)\n ELSE\n PRINT *, \'Warning: Array edges_end_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_start_index) > 0) THEN\n !$ser data edges_start_index=edges_start_index(min_rledge:)\n ELSE\n PRINT *, \'Warning: Array edges_start_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_end_index) > 0) THEN\n !$ser data edges_end_index=edges_end_index(min_rledge:)\n ELSE\n PRINT *, \'Warning: Array edges_end_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_vertex_idx) > 0) THEN\n !$ser data edges_vertex_idx=edges_vertex_idx(:,:,:)\n ELSE\n PRINT *, \'Warning: Array edges_vertex_idx has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_vertex_blk) > 0) THEN\n !$ser data edges_vertex_blk=edges_vertex_blk(:,:,:)\n ELSE\n PRINT *, \'Warning: Array edges_vertex_blk has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_cell_idx) > 0) THEN\n !$ser data edges_cell_idx=edges_cell_idx(:,:,:)\n ELSE\n PRINT *, \'Warning: Array edges_cell_idx has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_cell_blk) > 0) THEN\n !$ser data edges_cell_blk=edges_cell_blk(:,:,:)\n ELSE\n PRINT *, \'Warning: Array edges_cell_blk has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_tangent_orientation) > 0) THEN\n !$ser data edges_tangent_orientation=edges_tangent_orientation(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_tangent_orientation has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_inv_vert_vert_length) > 0) THEN\n !$ser data edges_inv_vert_vert_length=edges_inv_vert_vert_length(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_inv_vert_vert_length has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_inv_primal_edge_length) > 0) THEN\n !$ser data edges_inv_primal_edge_length=edges_inv_primal_edge_length(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_inv_primal_edge_length has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_inv_dual_edge_length) > 0) THEN\n !$ser data edges_inv_dual_edge_length=edges_inv_dual_edge_length(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_inv_dual_edge_length has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_area_edge) > 0) THEN\n !$ser data edges_area_edge=edges_area_edge(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_area_edge has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_start_block) > 0) THEN\n !$ser data cells_start_block=cells_start_block(min_rlcell:)\n ELSE\n PRINT *, \'Warning: Array cells_start_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_end_block) > 0) THEN\n !$ser data cells_end_block=cells_end_block(min_rlcell:)\n ELSE\n PRINT *, \'Warning: Array cells_end_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_start_index) > 0) THEN\n !$ser data cells_start_index=cells_start_index(min_rlcell:)\n ELSE\n PRINT *, \'Warning: Array cells_start_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_end_index) > 0) THEN\n !$ser data cells_end_index=cells_end_index(min_rlcell:)\n ELSE\n PRINT *, \'Warning: Array cells_end_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_neighbor_idx) > 0) THEN\n !$ser data cells_neighbor_idx=cells_neighbor_idx(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_neighbor_idx has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_neighbor_blk) > 0) THEN\n !$ser data cells_neighbor_blk=cells_neighbor_blk(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_neighbor_blk has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_edge_idx) > 0) THEN\n !$ser data cells_edge_idx=cells_edge_idx(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_edge_idx has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_edge_blk) > 0) THEN\n !$ser data cells_edge_blk=cells_edge_blk(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_edge_blk has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_area) > 0) THEN\n !$ser data cells_area=cells_area(:,:)\n ELSE\n PRINT *, \'Warning: Array cells_area has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(verts_start_block) > 0) THEN\n !$ser data verts_start_block=verts_start_block(min_rlvert:)\n ELSE\n PRINT *, \'Warning: Array verts_start_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(verts_end_block) > 0) THEN\n !$ser data verts_end_block=verts_end_block(min_rlvert:)\n ELSE\n PRINT *, \'Warning: Array verts_end_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(verts_start_index) > 0) THEN\n !$ser data verts_start_index=verts_start_index(min_rlvert:)\n ELSE\n PRINT *, \'Warning: Array verts_start_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(verts_end_index) > 0) THEN\n !$ser data verts_end_index=verts_end_index(min_rlvert:)\n ELSE\n PRINT *, \'Warning: Array verts_end_index has size 0. Not serializing array.\'\n END IF'), GeneratedCode(startln=492, source="\n !$ser savepoint diffusion_run_in\n\n !$ser data jg=jg\n\n !$ser data dtime=dtime\n\n !$ser data linit=linit\n\n IF (SIZE(vt) > 0) THEN\n !$ser data vt=vt(:,:,:)\n ELSE\n PRINT *, 'Warning: Array vt has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(vn) > 0) THEN\n !$ser data vn=vn(:,:,:)\n ELSE\n PRINT *, 'Warning: Array vn has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(w) > 0) THEN\n !$ser data w=w(:,:,:)\n ELSE\n PRINT *, 'Warning: Array w has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(theta_v) > 0) THEN\n !$ser data theta_v=theta_v(:,:,:)\n ELSE\n PRINT *, 'Warning: Array theta_v has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(exner) > 0) THEN\n !$ser data exner=exner(:,:,:)\n ELSE\n PRINT *, 'Warning: Array exner has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(theta_v_ic) > 0) THEN\n !$ser data theta_v_ic=theta_v_ic(:,:,:)\n ELSE\n PRINT *, 'Warning: Array theta_v_ic has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(ddt_vn_dyn) > 0) THEN\n !$ser data ddt_vn_dyn=ddt_vn_dyn(:,:,:)\n ELSE\n PRINT *, 'Warning: Array ddt_vn_dyn has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(ddt_vn_hdf) > 0) THEN\n !$ser data ddt_vn_hdf=ddt_vn_hdf(:,:,:)\n ELSE\n PRINT *, 'Warning: Array ddt_vn_hdf has size 0. Not serializing array.'\n END IF"), GeneratedCode(startln=1965, source="\n !$ser savepoint diffusion_run_out\n\n IF (SIZE(div_ic) > 0) THEN\n !$ser data div_ic=div_ic(:,:,:)\n ELSE\n PRINT *, 'Warning: Array div_ic has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(hdef_ic) > 0) THEN\n !$ser data hdef_ic=hdef_ic(:,:,:)\n ELSE\n PRINT *, 'Warning: Array hdef_ic has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(dwdx) > 0) THEN\n !$ser data dwdx=dwdx(:,:,:)\n ELSE\n PRINT *, 'Warning: Array dwdx has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(dwdy) > 0) THEN\n !$ser data dwdy=dwdy(:,:,:)\n ELSE\n PRINT *, 'Warning: Array dwdy has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(vn) > 0) THEN\n !$ser data vn=vn(:,:,:)\n ELSE\n PRINT *, 'Warning: Array vn has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(w) > 0) THEN\n !$ser data w=w(:,:,:)\n ELSE\n PRINT *, 'Warning: Array w has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(theta_v) > 0) THEN\n !$ser data theta_v=theta_v(:,:,:)\n ELSE\n PRINT *, 'Warning: Array theta_v has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(exner) > 0) THEN\n !$ser data exner=exner(:,:,:)\n ELSE\n PRINT *, 'Warning: Array exner has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(theta_v_ic) > 0) THEN\n !$ser data theta_v_ic=theta_v_ic(:,:,:)\n ELSE\n PRINT *, 'Warning: Array theta_v_ic has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(ddt_vn_dyn) > 0) THEN\n !$ser data ddt_vn_dyn=ddt_vn_dyn(:,:,:)\n ELSE\n PRINT *, 'Warning: Array ddt_vn_dyn has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(ddt_vn_hdf) > 0) THEN\n !$ser data ddt_vn_hdf=ddt_vn_hdf(:,:,:)\n ELSE\n PRINT *, 'Warning: Array ddt_vn_hdf has size 0. Not serializing array.'\n END IF")] From 43d4ce2403b11c2286d00bd9d1b3d6400becdbbf Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Wed, 3 May 2023 17:27:00 +0200 Subject: [PATCH 08/15] Useless import removed --- pyutils/tests/f2ser/test_f2ser_cli.py | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pyutils/tests/f2ser/test_f2ser_cli.py b/pyutils/tests/f2ser/test_f2ser_cli.py index 8962ed1c25..bac94ca8f9 100644 --- a/pyutils/tests/f2ser/test_f2ser_cli.py +++ b/pyutils/tests/f2ser/test_f2ser_cli.py @@ -33,3 +33,33 @@ def test_cli(diffusion_granule, diffusion_granule_deps, outfile, cli): args = [inp, outfile, "-d", ",".join(deps)] result = cli.invoke(main, args) assert result.exit_code == 0 + +def test_cli_no_deps(no_deps_source_file, outfile, cli): + inp = str(no_deps_source_file) + args = [inp, outfile] + result = cli.invoke(main, args) + assert result.exit_code == 0 + +def test_cli_wrong_deps(diffusion_granule, wrong_diffusion_granule_deps, outfile, cli): + inp = str(diffusion_granule) + deps = [str(p) for p in wrong_diffusion_granule_deps] + args = [inp, outfile, "-d", ",".join(deps)] + result = cli.invoke(main, args) + assert result.exit_code == 0 + +def test_cli_missing_deps(diffusion_granule, outfile, cli): + inp = str(diffusion_granule) + args = [inp, outfile] + result = cli.invoke(main, args) + assert result.exception == MissingDerivedTypeError + +def test_cli_wrong_source(not_existing_diffusion_granule, outfile, cli): + inp = str(not_existing_diffusion_granule) + args = [inp, outfile] +# with pytest.raises(Exception) as excinfo: +# cli.invoke(main, args) +# assert "Invalid value for \'GRANULE_PATH\'" in str(excinfo.value) + result = cli.invoke(main, args) + assert isinstance(result.exception, SystemExit) +# error_search = result.stdout.find("Invalid value for \'GRANULE_PATH\'") +# assert error_search != -1 From 7e874168590aa9f4d5e2fe024c3c1cb7b23b3ebd Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Wed, 3 May 2023 17:28:38 +0200 Subject: [PATCH 09/15] Useless import removed --- pyutils/tests/f2ser/test_f2ser_codegen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyutils/tests/f2ser/test_f2ser_codegen.py b/pyutils/tests/f2ser/test_f2ser_codegen.py index b00f7c0c38..a59e56a3a1 100644 --- a/pyutils/tests/f2ser/test_f2ser_codegen.py +++ b/pyutils/tests/f2ser/test_f2ser_codegen.py @@ -12,7 +12,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later import pytest -import difflib +from pathlib import Path from pathlib import Path from icon4py.f2ser.deserialise import ParsedGranuleDeserialiser From 6e9f16cb956eb308fe9977e53c96923c823ad905 Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Wed, 3 May 2023 18:22:30 +0200 Subject: [PATCH 10/15] New interface adopted --- pyutils/tests/f2ser/test_f2ser_codegen.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pyutils/tests/f2ser/test_f2ser_codegen.py b/pyutils/tests/f2ser/test_f2ser_codegen.py index d5e459e5f2..de93560a1c 100644 --- a/pyutils/tests/f2ser/test_f2ser_codegen.py +++ b/pyutils/tests/f2ser/test_f2ser_codegen.py @@ -13,7 +13,6 @@ import pytest from pathlib import Path -from pathlib import Path from icon4py.f2ser.deserialise import ParsedGranuleDeserialiser from icon4py.f2ser.parse import GranuleParser @@ -44,9 +43,9 @@ def expected_no_deps_serialization_directives(): def test_deserialiser_directives_no_deps_codegen(no_deps_source_file, expected_no_deps_serialization_directives): parser = GranuleParser(no_deps_source_file) - parsed = parser.parse() + parsed = parser() deserialiser = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test") - interface = deserialiser.deserialise() + interface = deserialiser() generator = SerialisationGenerator(interface) generated = generator() assert(generated == expected_no_deps_serialization_directives) @@ -54,9 +53,9 @@ def test_deserialiser_directives_no_deps_codegen(no_deps_source_file, expected_n def test_deserialiser_directives_diffusion_codegen(diffusion_granule, diffusion_granule_deps, expected_diffusion_serialization_directives): parser = GranuleParser(diffusion_granule, diffusion_granule_deps) - parsed = parser.parse() + parsed = parser() deserialiser = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test") - interface = deserialiser.deserialise() + interface = deserialiser() generator = SerialisationGenerator(interface) generated = generator() reference_str = Path(expected_diffusion_serialization_directives).read_text() From f3596a9d9fe976d45aa0f8ac7ef4c2dde4c1c1c3 Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Thu, 4 May 2023 12:09:28 +0200 Subject: [PATCH 11/15] Codegen fixtures created --- pyutils/tests/f2ser/conftest.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pyutils/tests/f2ser/conftest.py b/pyutils/tests/f2ser/conftest.py index 3244246c76..04c4e27365 100644 --- a/pyutils/tests/f2ser/conftest.py +++ b/pyutils/tests/f2ser/conftest.py @@ -22,12 +22,22 @@ def samples_path(): return Path(testutils.__file__).parent / "fortran" - @pytest.fixture def diffusion_granule(samples_path): return samples_path / "diffusion_granule.f90" - @pytest.fixture def diffusion_granule_deps(samples_path): return [samples_path / "derived_types_example.f90"] + +@pytest.fixture +def wrong_diffusion_granule_deps(samples_path): + return [samples_path / "wrong_derived_types_example.f90"] + +@pytest.fixture +def no_deps_source_file(samples_path): + return samples_path / "no_deps_subroutine_example.f90" + +@pytest.fixture +def expected_diffusion_serialization_directives(samples_path): + return samples_path / "expected_diffusion_serialization_directives.f90.f2ser" From 6f106b5de4dcf038f9384b872cc8a68bc70b0348 Mon Sep 17 00:00:00 2001 From: Christopher Bignamini Date: Thu, 4 May 2023 14:57:16 +0200 Subject: [PATCH 12/15] Serialization directives reference file created --- .../fortran/no_deps_subroutine_example.f90 | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 testutils/src/icon4py/testutils/fortran/no_deps_subroutine_example.f90 diff --git a/testutils/src/icon4py/testutils/fortran/no_deps_subroutine_example.f90 b/testutils/src/icon4py/testutils/fortran/no_deps_subroutine_example.f90 new file mode 100644 index 0000000000..335bef35a9 --- /dev/null +++ b/testutils/src/icon4py/testutils/fortran/no_deps_subroutine_example.f90 @@ -0,0 +1,26 @@ +MODULE no_deps_example_subroutines + IMPLICIT NONE + + PUBLIC :: no_deps_init, no_deps_run + PRIVATE + + CONTAINS + + SUBROUTINE no_deps_init(a, b, c) + REAL, INTENT(in) :: a + REAL, INTENT(inout) :: b + REAL, INTENT(out) :: c + c = a + b + b = 2.0 * b + END SUBROUTINE no_deps_init + + SUBROUTINE no_deps_run(a, b, c) + REAL, INTENT(in) :: a + REAL, INTENT(inout) :: b + REAL, INTENT(out) :: c + c = a + b + b = 2.0 * b + END SUBROUTINE no_deps_run + +END MODULE no_deps_example_subroutines + From 1e714487e63c989d79ffcb4d57c6e08505e7802a Mon Sep 17 00:00:00 2001 From: samkellerhals Date: Thu, 4 May 2023 15:26:41 +0200 Subject: [PATCH 13/15] Fix tests --- pyutils/tests/f2ser/conftest.py | 9 +- pyutils/tests/f2ser/test_f2ser_cli.py | 23 +- pyutils/tests/f2ser/test_f2ser_codegen.py | 76 +-- .../expected_diffusion_granule_savepoint.f90 | 460 ++++++++++++++++++ ...ffusion_serialization_directives.f90.f2ser | 1 - 5 files changed, 515 insertions(+), 54 deletions(-) create mode 100644 testutils/src/icon4py/testutils/fortran/expected_diffusion_granule_savepoint.f90 delete mode 100644 testutils/src/icon4py/testutils/fortran/expected_diffusion_serialization_directives.f90.f2ser diff --git a/pyutils/tests/f2ser/conftest.py b/pyutils/tests/f2ser/conftest.py index 04c4e27365..283f729468 100644 --- a/pyutils/tests/f2ser/conftest.py +++ b/pyutils/tests/f2ser/conftest.py @@ -22,22 +22,17 @@ def samples_path(): return Path(testutils.__file__).parent / "fortran" + @pytest.fixture def diffusion_granule(samples_path): return samples_path / "diffusion_granule.f90" + @pytest.fixture def diffusion_granule_deps(samples_path): return [samples_path / "derived_types_example.f90"] -@pytest.fixture -def wrong_diffusion_granule_deps(samples_path): - return [samples_path / "wrong_derived_types_example.f90"] @pytest.fixture def no_deps_source_file(samples_path): return samples_path / "no_deps_subroutine_example.f90" - -@pytest.fixture -def expected_diffusion_serialization_directives(samples_path): - return samples_path / "expected_diffusion_serialization_directives.f90.f2ser" diff --git a/pyutils/tests/f2ser/test_f2ser_cli.py b/pyutils/tests/f2ser/test_f2ser_cli.py index bac94ca8f9..860280223f 100644 --- a/pyutils/tests/f2ser/test_f2ser_cli.py +++ b/pyutils/tests/f2ser/test_f2ser_cli.py @@ -15,6 +15,7 @@ from click.testing import CliRunner from icon4py.f2ser.cli import main +from icon4py.f2ser.exceptions import MissingDerivedTypeError @pytest.fixture @@ -34,32 +35,32 @@ def test_cli(diffusion_granule, diffusion_granule_deps, outfile, cli): result = cli.invoke(main, args) assert result.exit_code == 0 + def test_cli_no_deps(no_deps_source_file, outfile, cli): inp = str(no_deps_source_file) args = [inp, outfile] result = cli.invoke(main, args) assert result.exit_code == 0 -def test_cli_wrong_deps(diffusion_granule, wrong_diffusion_granule_deps, outfile, cli): + +def test_cli_wrong_deps(diffusion_granule, samples_path, outfile, cli): inp = str(diffusion_granule) - deps = [str(p) for p in wrong_diffusion_granule_deps] - args = [inp, outfile, "-d", ",".join(deps)] + deps = [str(samples_path / "wrong_derived_types_example.f90")] + args = [inp, outfile, "-d", *deps] result = cli.invoke(main, args) assert result.exit_code == 0 + def test_cli_missing_deps(diffusion_granule, outfile, cli): inp = str(diffusion_granule) args = [inp, outfile] result = cli.invoke(main, args) - assert result.exception == MissingDerivedTypeError + assert isinstance(result.exception, MissingDerivedTypeError) + -def test_cli_wrong_source(not_existing_diffusion_granule, outfile, cli): - inp = str(not_existing_diffusion_granule) +def test_cli_wrong_source(outfile, cli): + inp = str("foo.90") args = [inp, outfile] -# with pytest.raises(Exception) as excinfo: -# cli.invoke(main, args) -# assert "Invalid value for \'GRANULE_PATH\'" in str(excinfo.value) result = cli.invoke(main, args) + assert "Invalid value for 'GRANULE_PATH'" in result.output assert isinstance(result.exception, SystemExit) -# error_search = result.stdout.find("Invalid value for \'GRANULE_PATH\'") -# assert error_search != -1 diff --git a/pyutils/tests/f2ser/test_f2ser_codegen.py b/pyutils/tests/f2ser/test_f2ser_codegen.py index de93560a1c..faf9c03e8d 100644 --- a/pyutils/tests/f2ser/test_f2ser_codegen.py +++ b/pyutils/tests/f2ser/test_f2ser_codegen.py @@ -12,53 +12,59 @@ # SPDX-License-Identifier: GPL-3.0-or-later import pytest -from pathlib import Path from icon4py.f2ser.deserialise import ParsedGranuleDeserialiser from icon4py.f2ser.parse import GranuleParser from icon4py.liskov.codegen.serialisation.generate import SerialisationGenerator from icon4py.liskov.codegen.types import GeneratedCode + def test_deserialiser_diffusion_codegen(diffusion_granule, diffusion_granule_deps): - parser = GranuleParser(diffusion_granule, diffusion_granule_deps) - parsed = parser() - deserialiser = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test") - interface = deserialiser() - generator = SerialisationGenerator(interface) - generated = generator() + parsed = GranuleParser(diffusion_granule, diffusion_granule_deps)() + interface = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test")() + generated = SerialisationGenerator(interface)() assert len(generated) == 3 + @pytest.fixture def expected_no_deps_serialization_directives(): serialization_directives = [ - GeneratedCode(startln=12, - source='\n!$ser init directory="." prefix="test"\n\n!$ser savepoint no_deps_init_in\n\n!$ser data a=a\n\n!$ser data b=b'), - GeneratedCode(startln=14, - source='\n!$ser savepoint no_deps_init_out\n\n!$ser data c=c\n\n!$ser data b=b'), - GeneratedCode(startln=20, - source='\n!$ser savepoint no_deps_run_in\n\n!$ser data a=a\n\n!$ser data b=b'), - GeneratedCode(startln=22, - source='\n!$ser savepoint no_deps_run_out\n\n!$ser data c=c\n\n!$ser data b=b')] + GeneratedCode( + startln=12, + source='\n!$ser init directory="." prefix="test"\n\n!$ser savepoint no_deps_init_in\n\n!$ser data a=a\n\n!$ser data b=b', + ), + GeneratedCode( + startln=14, + source="\n!$ser savepoint no_deps_init_out\n\n!$ser data c=c\n\n!$ser data b=b", + ), + GeneratedCode( + startln=20, + source="\n!$ser savepoint no_deps_run_in\n\n!$ser data a=a\n\n!$ser data b=b", + ), + GeneratedCode( + startln=22, + source="\n!$ser savepoint no_deps_run_out\n\n!$ser data c=c\n\n!$ser data b=b", + ), + ] return serialization_directives -def test_deserialiser_directives_no_deps_codegen(no_deps_source_file, expected_no_deps_serialization_directives): - parser = GranuleParser(no_deps_source_file) - parsed = parser() - deserialiser = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test") - interface = deserialiser() - generator = SerialisationGenerator(interface) - generated = generator() - assert(generated == expected_no_deps_serialization_directives) -def test_deserialiser_directives_diffusion_codegen(diffusion_granule, diffusion_granule_deps, - expected_diffusion_serialization_directives): - parser = GranuleParser(diffusion_granule, diffusion_granule_deps) - parsed = parser() - deserialiser = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test") - interface = deserialiser() - generator = SerialisationGenerator(interface) - generated = generator() - reference_str = Path(expected_diffusion_serialization_directives).read_text() - generated_str = ', '.join([str(elem) for elem in generated]) - generated_str = "[" + generated_str + "]\n" - assert(generated_str == reference_str) +def test_deserialiser_directives_no_deps_codegen( + no_deps_source_file, expected_no_deps_serialization_directives +): + parsed = GranuleParser(no_deps_source_file)() + interface = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test")() + generated = SerialisationGenerator(interface)() + assert generated == expected_no_deps_serialization_directives + + +def test_deserialiser_directives_diffusion_codegen( + diffusion_granule, diffusion_granule_deps, samples_path +): + parsed = GranuleParser(diffusion_granule, diffusion_granule_deps)() + interface = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test")() + generated = SerialisationGenerator(interface)() + reference_savepoint = ( + samples_path / "expected_diffusion_granule_savepoint.f90" + ).read_text() + assert generated[0].source == reference_savepoint.rstrip() diff --git a/testutils/src/icon4py/testutils/fortran/expected_diffusion_granule_savepoint.f90 b/testutils/src/icon4py/testutils/fortran/expected_diffusion_granule_savepoint.f90 new file mode 100644 index 0000000000..6fd964f92a --- /dev/null +++ b/testutils/src/icon4py/testutils/fortran/expected_diffusion_granule_savepoint.f90 @@ -0,0 +1,460 @@ + + !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_vert_v1 + + !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_vert_v2 + + !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_vert_v1 + + !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_vert_v2 + + !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_cell_v1 + + !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_cell_v2 + + !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_cell_v1 + + !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_cell_v2 + + !$ser init directory="." prefix="test" + + !$ser savepoint diffusion_init_in + + !$ser verbatim allocate(edges_primal_normal_vert_v1(size(edges_primal_normal_vert, 1), size(edges_primal_normal_vert, 2), size(edges_primal_normal_vert, 3))) + !$ser data edges_primal_normal_vert_v1=edges_primal_normal_vert_v1(:,:,:) + !$ser verbatim deallocate(edges_primal_normal_vert_v1) + + !$ser verbatim allocate(edges_primal_normal_vert_v2(size(edges_primal_normal_vert, 1), size(edges_primal_normal_vert, 2), size(edges_primal_normal_vert, 3))) + !$ser data edges_primal_normal_vert_v2=edges_primal_normal_vert_v2(:,:,:) + !$ser verbatim deallocate(edges_primal_normal_vert_v2) + + !$ser verbatim allocate(edges_dual_normal_vert_v1(size(edges_dual_normal_vert, 1), size(edges_dual_normal_vert, 2), size(edges_dual_normal_vert, 3))) + !$ser data edges_dual_normal_vert_v1=edges_dual_normal_vert_v1(:,:,:) + !$ser verbatim deallocate(edges_dual_normal_vert_v1) + + !$ser verbatim allocate(edges_dual_normal_vert_v2(size(edges_dual_normal_vert, 1), size(edges_dual_normal_vert, 2), size(edges_dual_normal_vert, 3))) + !$ser data edges_dual_normal_vert_v2=edges_dual_normal_vert_v2(:,:,:) + !$ser verbatim deallocate(edges_dual_normal_vert_v2) + + !$ser verbatim allocate(edges_primal_normal_cell_v1(size(edges_primal_normal_cell, 1), size(edges_primal_normal_cell, 2), size(edges_primal_normal_cell, 3))) + !$ser data edges_primal_normal_cell_v1=edges_primal_normal_cell_v1(:,:,:) + !$ser verbatim deallocate(edges_primal_normal_cell_v1) + + !$ser verbatim allocate(edges_primal_normal_cell_v2(size(edges_primal_normal_cell, 1), size(edges_primal_normal_cell, 2), size(edges_primal_normal_cell, 3))) + !$ser data edges_primal_normal_cell_v2=edges_primal_normal_cell_v2(:,:,:) + !$ser verbatim deallocate(edges_primal_normal_cell_v2) + + !$ser verbatim allocate(edges_dual_normal_cell_v1(size(edges_dual_normal_cell, 1), size(edges_dual_normal_cell, 2), size(edges_dual_normal_cell, 3))) + !$ser data edges_dual_normal_cell_v1=edges_dual_normal_cell_v1(:,:,:) + !$ser verbatim deallocate(edges_dual_normal_cell_v1) + + !$ser verbatim allocate(edges_dual_normal_cell_v2(size(edges_dual_normal_cell, 1), size(edges_dual_normal_cell, 2), size(edges_dual_normal_cell, 3))) + !$ser data edges_dual_normal_cell_v2=edges_dual_normal_cell_v2(:,:,:) + !$ser verbatim deallocate(edges_dual_normal_cell_v2) + + !$ser data cvd_o_rd=cvd_o_rd + + !$ser data grav=grav + + !$ser data jg=jg + + !$ser data nproma=nproma + + !$ser data nlev=nlev + + !$ser data nblks_e=nblks_e + + !$ser data nblks_v=nblks_v + + !$ser data nblks_c=nblks_c + + !$ser data nshift=nshift + + !$ser data nshift_total=nshift_total + + !$ser data nrdmax=nrdmax + + !$ser data ndyn_substeps=ndyn_substeps + + !$ser data hdiff_order=hdiff_order + + !$ser data itype_comm=itype_comm + + !$ser data itype_sher=itype_sher + + !$ser data itype_vn_diffu=itype_vn_diffu + + !$ser data itype_t_diffu=itype_t_diffu + + !$ser data hdiff_smag_z=hdiff_smag_z + + !$ser data hdiff_smag_z2=hdiff_smag_z2 + + !$ser data hdiff_smag_z3=hdiff_smag_z3 + + !$ser data hdiff_smag_z4=hdiff_smag_z4 + + !$ser data hdiff_smag_fac=hdiff_smag_fac + + !$ser data hdiff_smag_fac2=hdiff_smag_fac2 + + !$ser data hdiff_smag_fac3=hdiff_smag_fac3 + + !$ser data hdiff_smag_fac4=hdiff_smag_fac4 + + !$ser data hdiff_efdt_ratio=hdiff_efdt_ratio + + !$ser data k4=k4 + + !$ser data k4w=k4w + + !$ser data nudge_max_coeff=nudge_max_coeff + + !$ser data denom_diffu_v=denom_diffu_v + + !$ser data p_test_run=p_test_run + + !$ser data lphys=lphys + + !$ser data lhdiff_rcf=lhdiff_rcf + + !$ser data lhdiff_w=lhdiff_w + + !$ser data lhdiff_temp=lhdiff_temp + + !$ser data l_zdiffu_t=l_zdiffu_t + + !$ser data l_limited_area=l_limited_area + + !$ser data lfeedback=lfeedback + + !$ser data ltkeshs=ltkeshs + + !$ser data lsmag_3d=lsmag_3d + + !$ser data lvert_nest=lvert_nest + + !$ser data ltimer=ltimer + + !$ser data ddt_vn_hdf_is_associated=ddt_vn_hdf_is_associated + + !$ser data ddt_vn_dyn_is_associated=ddt_vn_dyn_is_associated + + IF (SIZE(vct_a) > 0) THEN + !$ser data vct_a=vct_a(:) + ELSE + PRINT *, 'Warning: Array vct_a has size 0. Not serializing array.' + END IF + + IF (SIZE(c_lin_e) > 0) THEN + !$ser data c_lin_e=c_lin_e(:,:,:) + ELSE + PRINT *, 'Warning: Array c_lin_e has size 0. Not serializing array.' + END IF + + IF (SIZE(e_bln_c_s) > 0) THEN + !$ser data e_bln_c_s=e_bln_c_s(:,:,:) + ELSE + PRINT *, 'Warning: Array e_bln_c_s has size 0. Not serializing array.' + END IF + + IF (SIZE(e_bln_c_u) > 0) THEN + !$ser data e_bln_c_u=e_bln_c_u(:,:,:) + ELSE + PRINT *, 'Warning: Array e_bln_c_u has size 0. Not serializing array.' + END IF + + IF (SIZE(e_bln_c_v) > 0) THEN + !$ser data e_bln_c_v=e_bln_c_v(:,:,:) + ELSE + PRINT *, 'Warning: Array e_bln_c_v has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_aw_verts) > 0) THEN + !$ser data cells_aw_verts=cells_aw_verts(:,:,:) + ELSE + PRINT *, 'Warning: Array cells_aw_verts has size 0. Not serializing array.' + END IF + + IF (SIZE(geofac_div) > 0) THEN + !$ser data geofac_div=geofac_div(:,:,:) + ELSE + PRINT *, 'Warning: Array geofac_div has size 0. Not serializing array.' + END IF + + IF (SIZE(geofac_rot) > 0) THEN + !$ser data geofac_rot=geofac_rot(:,:,:) + ELSE + PRINT *, 'Warning: Array geofac_rot has size 0. Not serializing array.' + END IF + + IF (SIZE(geofac_n2s) > 0) THEN + !$ser data geofac_n2s=geofac_n2s(:,:,:) + ELSE + PRINT *, 'Warning: Array geofac_n2s has size 0. Not serializing array.' + END IF + + IF (SIZE(geofac_grg) > 0) THEN + !$ser data geofac_grg=geofac_grg(:,:,:,:) + ELSE + PRINT *, 'Warning: Array geofac_grg has size 0. Not serializing array.' + END IF + + IF (SIZE(nudgecoeff_e) > 0) THEN + !$ser data nudgecoeff_e=nudgecoeff_e(:,:) + ELSE + PRINT *, 'Warning: Array nudgecoeff_e has size 0. Not serializing array.' + END IF + + IF (SIZE(rbf_vec_idx_v) > 0) THEN + !$ser data rbf_vec_idx_v=rbf_vec_idx_v(:,:,:) + ELSE + PRINT *, 'Warning: Array rbf_vec_idx_v has size 0. Not serializing array.' + END IF + + IF (SIZE(rbf_vec_blk_v) > 0) THEN + !$ser data rbf_vec_blk_v=rbf_vec_blk_v(:,:,:) + ELSE + PRINT *, 'Warning: Array rbf_vec_blk_v has size 0. Not serializing array.' + END IF + + IF (SIZE(rbf_vec_coeff_v) > 0) THEN + !$ser data rbf_vec_coeff_v=rbf_vec_coeff_v(:,:,:,:) + ELSE + PRINT *, 'Warning: Array rbf_vec_coeff_v has size 0. Not serializing array.' + END IF + + IF (SIZE(enhfac_diffu) > 0) THEN + !$ser data enhfac_diffu=enhfac_diffu(:) + ELSE + PRINT *, 'Warning: Array enhfac_diffu has size 0. Not serializing array.' + END IF + + IF (SIZE(zd_intcoef) > 0) THEN + !$ser data zd_intcoef=zd_intcoef(:,:) + ELSE + PRINT *, 'Warning: Array zd_intcoef has size 0. Not serializing array.' + END IF + + IF (SIZE(zd_geofac) > 0) THEN + !$ser data zd_geofac=zd_geofac(:,:) + ELSE + PRINT *, 'Warning: Array zd_geofac has size 0. Not serializing array.' + END IF + + IF (SIZE(zd_diffcoef) > 0) THEN + !$ser data zd_diffcoef=zd_diffcoef(:) + ELSE + PRINT *, 'Warning: Array zd_diffcoef has size 0. Not serializing array.' + END IF + + IF (SIZE(wgtfac_c) > 0) THEN + !$ser data wgtfac_c=wgtfac_c(:,:,:) + ELSE + PRINT *, 'Warning: Array wgtfac_c has size 0. Not serializing array.' + END IF + + IF (SIZE(wgtfac_e) > 0) THEN + !$ser data wgtfac_e=wgtfac_e(:,:,:) + ELSE + PRINT *, 'Warning: Array wgtfac_e has size 0. Not serializing array.' + END IF + + IF (SIZE(wgtfacq_e) > 0) THEN + !$ser data wgtfacq_e=wgtfacq_e(:,:,:) + ELSE + PRINT *, 'Warning: Array wgtfacq_e has size 0. Not serializing array.' + END IF + + IF (SIZE(wgtfacq1_e) > 0) THEN + !$ser data wgtfacq1_e=wgtfacq1_e(:,:,:) + ELSE + PRINT *, 'Warning: Array wgtfacq1_e has size 0. Not serializing array.' + END IF + + IF (SIZE(ddqz_z_full_e) > 0) THEN + !$ser data ddqz_z_full_e=ddqz_z_full_e(:,:,:) + ELSE + PRINT *, 'Warning: Array ddqz_z_full_e has size 0. Not serializing array.' + END IF + + IF (SIZE(theta_ref_mc) > 0) THEN + !$ser data theta_ref_mc=theta_ref_mc(:,:,:) + ELSE + PRINT *, 'Warning: Array theta_ref_mc has size 0. Not serializing array.' + END IF + + IF (SIZE(zd_indlist) > 0) THEN + !$ser data zd_indlist=zd_indlist(:,:) + ELSE + PRINT *, 'Warning: Array zd_indlist has size 0. Not serializing array.' + END IF + + IF (SIZE(zd_blklist) > 0) THEN + !$ser data zd_blklist=zd_blklist(:,:) + ELSE + PRINT *, 'Warning: Array zd_blklist has size 0. Not serializing array.' + END IF + + IF (SIZE(zd_vertidx) > 0) THEN + !$ser data zd_vertidx=zd_vertidx(:,:) + ELSE + PRINT *, 'Warning: Array zd_vertidx has size 0. Not serializing array.' + END IF + + !$ser data zd_listdim=zd_listdim + + IF (SIZE(edges_start_block) > 0) THEN + !$ser data edges_start_block=edges_start_block(min_rledge:) + ELSE + PRINT *, 'Warning: Array edges_start_block has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_end_block) > 0) THEN + !$ser data edges_end_block=edges_end_block(min_rledge:) + ELSE + PRINT *, 'Warning: Array edges_end_block has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_start_index) > 0) THEN + !$ser data edges_start_index=edges_start_index(min_rledge:) + ELSE + PRINT *, 'Warning: Array edges_start_index has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_end_index) > 0) THEN + !$ser data edges_end_index=edges_end_index(min_rledge:) + ELSE + PRINT *, 'Warning: Array edges_end_index has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_vertex_idx) > 0) THEN + !$ser data edges_vertex_idx=edges_vertex_idx(:,:,:) + ELSE + PRINT *, 'Warning: Array edges_vertex_idx has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_vertex_blk) > 0) THEN + !$ser data edges_vertex_blk=edges_vertex_blk(:,:,:) + ELSE + PRINT *, 'Warning: Array edges_vertex_blk has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_cell_idx) > 0) THEN + !$ser data edges_cell_idx=edges_cell_idx(:,:,:) + ELSE + PRINT *, 'Warning: Array edges_cell_idx has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_cell_blk) > 0) THEN + !$ser data edges_cell_blk=edges_cell_blk(:,:,:) + ELSE + PRINT *, 'Warning: Array edges_cell_blk has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_tangent_orientation) > 0) THEN + !$ser data edges_tangent_orientation=edges_tangent_orientation(:,:) + ELSE + PRINT *, 'Warning: Array edges_tangent_orientation has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_inv_vert_vert_length) > 0) THEN + !$ser data edges_inv_vert_vert_length=edges_inv_vert_vert_length(:,:) + ELSE + PRINT *, 'Warning: Array edges_inv_vert_vert_length has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_inv_primal_edge_length) > 0) THEN + !$ser data edges_inv_primal_edge_length=edges_inv_primal_edge_length(:,:) + ELSE + PRINT *, 'Warning: Array edges_inv_primal_edge_length has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_inv_dual_edge_length) > 0) THEN + !$ser data edges_inv_dual_edge_length=edges_inv_dual_edge_length(:,:) + ELSE + PRINT *, 'Warning: Array edges_inv_dual_edge_length has size 0. Not serializing array.' + END IF + + IF (SIZE(edges_area_edge) > 0) THEN + !$ser data edges_area_edge=edges_area_edge(:,:) + ELSE + PRINT *, 'Warning: Array edges_area_edge has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_start_block) > 0) THEN + !$ser data cells_start_block=cells_start_block(min_rlcell:) + ELSE + PRINT *, 'Warning: Array cells_start_block has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_end_block) > 0) THEN + !$ser data cells_end_block=cells_end_block(min_rlcell:) + ELSE + PRINT *, 'Warning: Array cells_end_block has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_start_index) > 0) THEN + !$ser data cells_start_index=cells_start_index(min_rlcell:) + ELSE + PRINT *, 'Warning: Array cells_start_index has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_end_index) > 0) THEN + !$ser data cells_end_index=cells_end_index(min_rlcell:) + ELSE + PRINT *, 'Warning: Array cells_end_index has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_neighbor_idx) > 0) THEN + !$ser data cells_neighbor_idx=cells_neighbor_idx(:,:,:) + ELSE + PRINT *, 'Warning: Array cells_neighbor_idx has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_neighbor_blk) > 0) THEN + !$ser data cells_neighbor_blk=cells_neighbor_blk(:,:,:) + ELSE + PRINT *, 'Warning: Array cells_neighbor_blk has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_edge_idx) > 0) THEN + !$ser data cells_edge_idx=cells_edge_idx(:,:,:) + ELSE + PRINT *, 'Warning: Array cells_edge_idx has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_edge_blk) > 0) THEN + !$ser data cells_edge_blk=cells_edge_blk(:,:,:) + ELSE + PRINT *, 'Warning: Array cells_edge_blk has size 0. Not serializing array.' + END IF + + IF (SIZE(cells_area) > 0) THEN + !$ser data cells_area=cells_area(:,:) + ELSE + PRINT *, 'Warning: Array cells_area has size 0. Not serializing array.' + END IF + + IF (SIZE(verts_start_block) > 0) THEN + !$ser data verts_start_block=verts_start_block(min_rlvert:) + ELSE + PRINT *, 'Warning: Array verts_start_block has size 0. Not serializing array.' + END IF + + IF (SIZE(verts_end_block) > 0) THEN + !$ser data verts_end_block=verts_end_block(min_rlvert:) + ELSE + PRINT *, 'Warning: Array verts_end_block has size 0. Not serializing array.' + END IF + + IF (SIZE(verts_start_index) > 0) THEN + !$ser data verts_start_index=verts_start_index(min_rlvert:) + ELSE + PRINT *, 'Warning: Array verts_start_index has size 0. Not serializing array.' + END IF + + IF (SIZE(verts_end_index) > 0) THEN + !$ser data verts_end_index=verts_end_index(min_rlvert:) + ELSE + PRINT *, 'Warning: Array verts_end_index has size 0. Not serializing array.' + END IF diff --git a/testutils/src/icon4py/testutils/fortran/expected_diffusion_serialization_directives.f90.f2ser b/testutils/src/icon4py/testutils/fortran/expected_diffusion_serialization_directives.f90.f2ser deleted file mode 100644 index 2b2964cdfb..0000000000 --- a/testutils/src/icon4py/testutils/fortran/expected_diffusion_serialization_directives.f90.f2ser +++ /dev/null @@ -1 +0,0 @@ -[GeneratedCode(startln=280, source='\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_vert_v1\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_vert_v2\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_vert_v1\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_vert_v2\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_cell_v1\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_primal_normal_cell_v2\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_cell_v1\n\n !$ser verbatim real, dimension(:,:,:), allocatable :: edges_dual_normal_cell_v2\n\n !$ser init directory="." prefix="test"\n\n !$ser savepoint diffusion_init_in\n\n !$ser verbatim allocate(edges_primal_normal_vert_v1(size(edges_primal_normal_vert, 1), size(edges_primal_normal_vert, 2), size(edges_primal_normal_vert, 3)))\n !$ser data edges_primal_normal_vert_v1=edges_primal_normal_vert_v1(:,:,:)\n !$ser verbatim deallocate(edges_primal_normal_vert_v1)\n\n !$ser verbatim allocate(edges_primal_normal_vert_v2(size(edges_primal_normal_vert, 1), size(edges_primal_normal_vert, 2), size(edges_primal_normal_vert, 3)))\n !$ser data edges_primal_normal_vert_v2=edges_primal_normal_vert_v2(:,:,:)\n !$ser verbatim deallocate(edges_primal_normal_vert_v2)\n\n !$ser verbatim allocate(edges_dual_normal_vert_v1(size(edges_dual_normal_vert, 1), size(edges_dual_normal_vert, 2), size(edges_dual_normal_vert, 3)))\n !$ser data edges_dual_normal_vert_v1=edges_dual_normal_vert_v1(:,:,:)\n !$ser verbatim deallocate(edges_dual_normal_vert_v1)\n\n !$ser verbatim allocate(edges_dual_normal_vert_v2(size(edges_dual_normal_vert, 1), size(edges_dual_normal_vert, 2), size(edges_dual_normal_vert, 3)))\n !$ser data edges_dual_normal_vert_v2=edges_dual_normal_vert_v2(:,:,:)\n !$ser verbatim deallocate(edges_dual_normal_vert_v2)\n\n !$ser verbatim allocate(edges_primal_normal_cell_v1(size(edges_primal_normal_cell, 1), size(edges_primal_normal_cell, 2), size(edges_primal_normal_cell, 3)))\n !$ser data edges_primal_normal_cell_v1=edges_primal_normal_cell_v1(:,:,:)\n !$ser verbatim deallocate(edges_primal_normal_cell_v1)\n\n !$ser verbatim allocate(edges_primal_normal_cell_v2(size(edges_primal_normal_cell, 1), size(edges_primal_normal_cell, 2), size(edges_primal_normal_cell, 3)))\n !$ser data edges_primal_normal_cell_v2=edges_primal_normal_cell_v2(:,:,:)\n !$ser verbatim deallocate(edges_primal_normal_cell_v2)\n\n !$ser verbatim allocate(edges_dual_normal_cell_v1(size(edges_dual_normal_cell, 1), size(edges_dual_normal_cell, 2), size(edges_dual_normal_cell, 3)))\n !$ser data edges_dual_normal_cell_v1=edges_dual_normal_cell_v1(:,:,:)\n !$ser verbatim deallocate(edges_dual_normal_cell_v1)\n\n !$ser verbatim allocate(edges_dual_normal_cell_v2(size(edges_dual_normal_cell, 1), size(edges_dual_normal_cell, 2), size(edges_dual_normal_cell, 3)))\n !$ser data edges_dual_normal_cell_v2=edges_dual_normal_cell_v2(:,:,:)\n !$ser verbatim deallocate(edges_dual_normal_cell_v2)\n\n !$ser data cvd_o_rd=cvd_o_rd\n\n !$ser data grav=grav\n\n !$ser data jg=jg\n\n !$ser data nproma=nproma\n\n !$ser data nlev=nlev\n\n !$ser data nblks_e=nblks_e\n\n !$ser data nblks_v=nblks_v\n\n !$ser data nblks_c=nblks_c\n\n !$ser data nshift=nshift\n\n !$ser data nshift_total=nshift_total\n\n !$ser data nrdmax=nrdmax\n\n !$ser data ndyn_substeps=ndyn_substeps\n\n !$ser data hdiff_order=hdiff_order\n\n !$ser data itype_comm=itype_comm\n\n !$ser data itype_sher=itype_sher\n\n !$ser data itype_vn_diffu=itype_vn_diffu\n\n !$ser data itype_t_diffu=itype_t_diffu\n\n !$ser data hdiff_smag_z=hdiff_smag_z\n\n !$ser data hdiff_smag_z2=hdiff_smag_z2\n\n !$ser data hdiff_smag_z3=hdiff_smag_z3\n\n !$ser data hdiff_smag_z4=hdiff_smag_z4\n\n !$ser data hdiff_smag_fac=hdiff_smag_fac\n\n !$ser data hdiff_smag_fac2=hdiff_smag_fac2\n\n !$ser data hdiff_smag_fac3=hdiff_smag_fac3\n\n !$ser data hdiff_smag_fac4=hdiff_smag_fac4\n\n !$ser data hdiff_efdt_ratio=hdiff_efdt_ratio\n\n !$ser data k4=k4\n\n !$ser data k4w=k4w\n\n !$ser data nudge_max_coeff=nudge_max_coeff\n\n !$ser data denom_diffu_v=denom_diffu_v\n\n !$ser data p_test_run=p_test_run\n\n !$ser data lphys=lphys\n\n !$ser data lhdiff_rcf=lhdiff_rcf\n\n !$ser data lhdiff_w=lhdiff_w\n\n !$ser data lhdiff_temp=lhdiff_temp\n\n !$ser data l_zdiffu_t=l_zdiffu_t\n\n !$ser data l_limited_area=l_limited_area\n\n !$ser data lfeedback=lfeedback\n\n !$ser data ltkeshs=ltkeshs\n\n !$ser data lsmag_3d=lsmag_3d\n\n !$ser data lvert_nest=lvert_nest\n\n !$ser data ltimer=ltimer\n\n !$ser data ddt_vn_hdf_is_associated=ddt_vn_hdf_is_associated\n\n !$ser data ddt_vn_dyn_is_associated=ddt_vn_dyn_is_associated\n\n IF (SIZE(vct_a) > 0) THEN\n !$ser data vct_a=vct_a(:)\n ELSE\n PRINT *, \'Warning: Array vct_a has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(c_lin_e) > 0) THEN\n !$ser data c_lin_e=c_lin_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array c_lin_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(e_bln_c_s) > 0) THEN\n !$ser data e_bln_c_s=e_bln_c_s(:,:,:)\n ELSE\n PRINT *, \'Warning: Array e_bln_c_s has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(e_bln_c_u) > 0) THEN\n !$ser data e_bln_c_u=e_bln_c_u(:,:,:)\n ELSE\n PRINT *, \'Warning: Array e_bln_c_u has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(e_bln_c_v) > 0) THEN\n !$ser data e_bln_c_v=e_bln_c_v(:,:,:)\n ELSE\n PRINT *, \'Warning: Array e_bln_c_v has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_aw_verts) > 0) THEN\n !$ser data cells_aw_verts=cells_aw_verts(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_aw_verts has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(geofac_div) > 0) THEN\n !$ser data geofac_div=geofac_div(:,:,:)\n ELSE\n PRINT *, \'Warning: Array geofac_div has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(geofac_rot) > 0) THEN\n !$ser data geofac_rot=geofac_rot(:,:,:)\n ELSE\n PRINT *, \'Warning: Array geofac_rot has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(geofac_n2s) > 0) THEN\n !$ser data geofac_n2s=geofac_n2s(:,:,:)\n ELSE\n PRINT *, \'Warning: Array geofac_n2s has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(geofac_grg) > 0) THEN\n !$ser data geofac_grg=geofac_grg(:,:,:,:)\n ELSE\n PRINT *, \'Warning: Array geofac_grg has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(nudgecoeff_e) > 0) THEN\n !$ser data nudgecoeff_e=nudgecoeff_e(:,:)\n ELSE\n PRINT *, \'Warning: Array nudgecoeff_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(rbf_vec_idx_v) > 0) THEN\n !$ser data rbf_vec_idx_v=rbf_vec_idx_v(:,:,:)\n ELSE\n PRINT *, \'Warning: Array rbf_vec_idx_v has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(rbf_vec_blk_v) > 0) THEN\n !$ser data rbf_vec_blk_v=rbf_vec_blk_v(:,:,:)\n ELSE\n PRINT *, \'Warning: Array rbf_vec_blk_v has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(rbf_vec_coeff_v) > 0) THEN\n !$ser data rbf_vec_coeff_v=rbf_vec_coeff_v(:,:,:,:)\n ELSE\n PRINT *, \'Warning: Array rbf_vec_coeff_v has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(enhfac_diffu) > 0) THEN\n !$ser data enhfac_diffu=enhfac_diffu(:)\n ELSE\n PRINT *, \'Warning: Array enhfac_diffu has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_intcoef) > 0) THEN\n !$ser data zd_intcoef=zd_intcoef(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_intcoef has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_geofac) > 0) THEN\n !$ser data zd_geofac=zd_geofac(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_geofac has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_diffcoef) > 0) THEN\n !$ser data zd_diffcoef=zd_diffcoef(:)\n ELSE\n PRINT *, \'Warning: Array zd_diffcoef has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(wgtfac_c) > 0) THEN\n !$ser data wgtfac_c=wgtfac_c(:,:,:)\n ELSE\n PRINT *, \'Warning: Array wgtfac_c has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(wgtfac_e) > 0) THEN\n !$ser data wgtfac_e=wgtfac_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array wgtfac_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(wgtfacq_e) > 0) THEN\n !$ser data wgtfacq_e=wgtfacq_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array wgtfacq_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(wgtfacq1_e) > 0) THEN\n !$ser data wgtfacq1_e=wgtfacq1_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array wgtfacq1_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(ddqz_z_full_e) > 0) THEN\n !$ser data ddqz_z_full_e=ddqz_z_full_e(:,:,:)\n ELSE\n PRINT *, \'Warning: Array ddqz_z_full_e has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(theta_ref_mc) > 0) THEN\n !$ser data theta_ref_mc=theta_ref_mc(:,:,:)\n ELSE\n PRINT *, \'Warning: Array theta_ref_mc has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_indlist) > 0) THEN\n !$ser data zd_indlist=zd_indlist(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_indlist has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_blklist) > 0) THEN\n !$ser data zd_blklist=zd_blklist(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_blklist has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(zd_vertidx) > 0) THEN\n !$ser data zd_vertidx=zd_vertidx(:,:)\n ELSE\n PRINT *, \'Warning: Array zd_vertidx has size 0. Not serializing array.\'\n END IF\n\n !$ser data zd_listdim=zd_listdim\n\n IF (SIZE(edges_start_block) > 0) THEN\n !$ser data edges_start_block=edges_start_block(min_rledge:)\n ELSE\n PRINT *, \'Warning: Array edges_start_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_end_block) > 0) THEN\n !$ser data edges_end_block=edges_end_block(min_rledge:)\n ELSE\n PRINT *, \'Warning: Array edges_end_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_start_index) > 0) THEN\n !$ser data edges_start_index=edges_start_index(min_rledge:)\n ELSE\n PRINT *, \'Warning: Array edges_start_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_end_index) > 0) THEN\n !$ser data edges_end_index=edges_end_index(min_rledge:)\n ELSE\n PRINT *, \'Warning: Array edges_end_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_vertex_idx) > 0) THEN\n !$ser data edges_vertex_idx=edges_vertex_idx(:,:,:)\n ELSE\n PRINT *, \'Warning: Array edges_vertex_idx has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_vertex_blk) > 0) THEN\n !$ser data edges_vertex_blk=edges_vertex_blk(:,:,:)\n ELSE\n PRINT *, \'Warning: Array edges_vertex_blk has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_cell_idx) > 0) THEN\n !$ser data edges_cell_idx=edges_cell_idx(:,:,:)\n ELSE\n PRINT *, \'Warning: Array edges_cell_idx has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_cell_blk) > 0) THEN\n !$ser data edges_cell_blk=edges_cell_blk(:,:,:)\n ELSE\n PRINT *, \'Warning: Array edges_cell_blk has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_tangent_orientation) > 0) THEN\n !$ser data edges_tangent_orientation=edges_tangent_orientation(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_tangent_orientation has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_inv_vert_vert_length) > 0) THEN\n !$ser data edges_inv_vert_vert_length=edges_inv_vert_vert_length(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_inv_vert_vert_length has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_inv_primal_edge_length) > 0) THEN\n !$ser data edges_inv_primal_edge_length=edges_inv_primal_edge_length(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_inv_primal_edge_length has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_inv_dual_edge_length) > 0) THEN\n !$ser data edges_inv_dual_edge_length=edges_inv_dual_edge_length(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_inv_dual_edge_length has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(edges_area_edge) > 0) THEN\n !$ser data edges_area_edge=edges_area_edge(:,:)\n ELSE\n PRINT *, \'Warning: Array edges_area_edge has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_start_block) > 0) THEN\n !$ser data cells_start_block=cells_start_block(min_rlcell:)\n ELSE\n PRINT *, \'Warning: Array cells_start_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_end_block) > 0) THEN\n !$ser data cells_end_block=cells_end_block(min_rlcell:)\n ELSE\n PRINT *, \'Warning: Array cells_end_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_start_index) > 0) THEN\n !$ser data cells_start_index=cells_start_index(min_rlcell:)\n ELSE\n PRINT *, \'Warning: Array cells_start_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_end_index) > 0) THEN\n !$ser data cells_end_index=cells_end_index(min_rlcell:)\n ELSE\n PRINT *, \'Warning: Array cells_end_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_neighbor_idx) > 0) THEN\n !$ser data cells_neighbor_idx=cells_neighbor_idx(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_neighbor_idx has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_neighbor_blk) > 0) THEN\n !$ser data cells_neighbor_blk=cells_neighbor_blk(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_neighbor_blk has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_edge_idx) > 0) THEN\n !$ser data cells_edge_idx=cells_edge_idx(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_edge_idx has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_edge_blk) > 0) THEN\n !$ser data cells_edge_blk=cells_edge_blk(:,:,:)\n ELSE\n PRINT *, \'Warning: Array cells_edge_blk has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(cells_area) > 0) THEN\n !$ser data cells_area=cells_area(:,:)\n ELSE\n PRINT *, \'Warning: Array cells_area has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(verts_start_block) > 0) THEN\n !$ser data verts_start_block=verts_start_block(min_rlvert:)\n ELSE\n PRINT *, \'Warning: Array verts_start_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(verts_end_block) > 0) THEN\n !$ser data verts_end_block=verts_end_block(min_rlvert:)\n ELSE\n PRINT *, \'Warning: Array verts_end_block has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(verts_start_index) > 0) THEN\n !$ser data verts_start_index=verts_start_index(min_rlvert:)\n ELSE\n PRINT *, \'Warning: Array verts_start_index has size 0. Not serializing array.\'\n END IF\n\n IF (SIZE(verts_end_index) > 0) THEN\n !$ser data verts_end_index=verts_end_index(min_rlvert:)\n ELSE\n PRINT *, \'Warning: Array verts_end_index has size 0. Not serializing array.\'\n END IF'), GeneratedCode(startln=492, source="\n !$ser savepoint diffusion_run_in\n\n !$ser data jg=jg\n\n !$ser data dtime=dtime\n\n !$ser data linit=linit\n\n IF (SIZE(vt) > 0) THEN\n !$ser data vt=vt(:,:,:)\n ELSE\n PRINT *, 'Warning: Array vt has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(vn) > 0) THEN\n !$ser data vn=vn(:,:,:)\n ELSE\n PRINT *, 'Warning: Array vn has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(w) > 0) THEN\n !$ser data w=w(:,:,:)\n ELSE\n PRINT *, 'Warning: Array w has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(theta_v) > 0) THEN\n !$ser data theta_v=theta_v(:,:,:)\n ELSE\n PRINT *, 'Warning: Array theta_v has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(exner) > 0) THEN\n !$ser data exner=exner(:,:,:)\n ELSE\n PRINT *, 'Warning: Array exner has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(theta_v_ic) > 0) THEN\n !$ser data theta_v_ic=theta_v_ic(:,:,:)\n ELSE\n PRINT *, 'Warning: Array theta_v_ic has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(ddt_vn_dyn) > 0) THEN\n !$ser data ddt_vn_dyn=ddt_vn_dyn(:,:,:)\n ELSE\n PRINT *, 'Warning: Array ddt_vn_dyn has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(ddt_vn_hdf) > 0) THEN\n !$ser data ddt_vn_hdf=ddt_vn_hdf(:,:,:)\n ELSE\n PRINT *, 'Warning: Array ddt_vn_hdf has size 0. Not serializing array.'\n END IF"), GeneratedCode(startln=1965, source="\n !$ser savepoint diffusion_run_out\n\n IF (SIZE(div_ic) > 0) THEN\n !$ser data div_ic=div_ic(:,:,:)\n ELSE\n PRINT *, 'Warning: Array div_ic has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(hdef_ic) > 0) THEN\n !$ser data hdef_ic=hdef_ic(:,:,:)\n ELSE\n PRINT *, 'Warning: Array hdef_ic has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(dwdx) > 0) THEN\n !$ser data dwdx=dwdx(:,:,:)\n ELSE\n PRINT *, 'Warning: Array dwdx has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(dwdy) > 0) THEN\n !$ser data dwdy=dwdy(:,:,:)\n ELSE\n PRINT *, 'Warning: Array dwdy has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(vn) > 0) THEN\n !$ser data vn=vn(:,:,:)\n ELSE\n PRINT *, 'Warning: Array vn has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(w) > 0) THEN\n !$ser data w=w(:,:,:)\n ELSE\n PRINT *, 'Warning: Array w has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(theta_v) > 0) THEN\n !$ser data theta_v=theta_v(:,:,:)\n ELSE\n PRINT *, 'Warning: Array theta_v has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(exner) > 0) THEN\n !$ser data exner=exner(:,:,:)\n ELSE\n PRINT *, 'Warning: Array exner has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(theta_v_ic) > 0) THEN\n !$ser data theta_v_ic=theta_v_ic(:,:,:)\n ELSE\n PRINT *, 'Warning: Array theta_v_ic has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(ddt_vn_dyn) > 0) THEN\n !$ser data ddt_vn_dyn=ddt_vn_dyn(:,:,:)\n ELSE\n PRINT *, 'Warning: Array ddt_vn_dyn has size 0. Not serializing array.'\n END IF\n\n IF (SIZE(ddt_vn_hdf) > 0) THEN\n !$ser data ddt_vn_hdf=ddt_vn_hdf(:,:,:)\n ELSE\n PRINT *, 'Warning: Array ddt_vn_hdf has size 0. Not serializing array.'\n END IF")] From 66952a09eea10dfd7657c638bd57142c2cb91d0f Mon Sep 17 00:00:00 2001 From: samkellerhals Date: Tue, 9 May 2023 16:41:30 +0200 Subject: [PATCH 14/15] Fix tests --- pyutils/tests/f2ser/test_f2ser_codegen.py | 58 ++++- .../expected_diffusion_granule_savepoint.f90 | 212 +++++++++++++++++- 2 files changed, 253 insertions(+), 17 deletions(-) diff --git a/pyutils/tests/f2ser/test_f2ser_codegen.py b/pyutils/tests/f2ser/test_f2ser_codegen.py index faf9c03e8d..b6d0c38ed3 100644 --- a/pyutils/tests/f2ser/test_f2ser_codegen.py +++ b/pyutils/tests/f2ser/test_f2ser_codegen.py @@ -15,14 +15,16 @@ from icon4py.f2ser.deserialise import ParsedGranuleDeserialiser from icon4py.f2ser.parse import GranuleParser -from icon4py.liskov.codegen.serialisation.generate import SerialisationGenerator -from icon4py.liskov.codegen.types import GeneratedCode +from icon4py.liskov.codegen.serialisation.generate import ( + SerialisationCodeGenerator, +) +from icon4py.liskov.codegen.shared.types import GeneratedCode def test_deserialiser_diffusion_codegen(diffusion_granule, diffusion_granule_deps): parsed = GranuleParser(diffusion_granule, diffusion_granule_deps)() interface = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test")() - generated = SerialisationGenerator(interface)() + generated = SerialisationCodeGenerator(interface)() assert len(generated) == 3 @@ -31,19 +33,57 @@ def expected_no_deps_serialization_directives(): serialization_directives = [ GeneratedCode( startln=12, - source='\n!$ser init directory="." prefix="test"\n\n!$ser savepoint no_deps_init_in\n\n!$ser data a=a\n\n!$ser data b=b', + source="\n" + ' !$ser init directory="." prefix="test"\n' + "\n" + " !$ser savepoint no_deps_init_in\n" + "\n" + " PRINT *, 'Serializing a=a'\n" + "\n" + " !$ser data a=a\n" + "\n" + " PRINT *, 'Serializing b=b'\n" + "\n" + " !$ser data b=b", ), GeneratedCode( startln=14, - source="\n!$ser savepoint no_deps_init_out\n\n!$ser data c=c\n\n!$ser data b=b", + source="\n" + " !$ser savepoint no_deps_init_out\n" + "\n" + " PRINT *, 'Serializing c=c'\n" + "\n" + " !$ser data c=c\n" + "\n" + " PRINT *, 'Serializing b=b'\n" + "\n" + " !$ser data b=b", ), GeneratedCode( startln=20, - source="\n!$ser savepoint no_deps_run_in\n\n!$ser data a=a\n\n!$ser data b=b", + source="\n" + " !$ser savepoint no_deps_run_in\n" + "\n" + " PRINT *, 'Serializing a=a'\n" + "\n" + " !$ser data a=a\n" + "\n" + " PRINT *, 'Serializing b=b'\n" + "\n" + " !$ser data b=b", ), GeneratedCode( startln=22, - source="\n!$ser savepoint no_deps_run_out\n\n!$ser data c=c\n\n!$ser data b=b", + source="\n" + " !$ser savepoint no_deps_run_out\n" + "\n" + " PRINT *, 'Serializing c=c'\n" + "\n" + " !$ser data c=c\n" + "\n" + " PRINT *, 'Serializing b=b'\n" + "\n" + " !$ser data b=b", ), ] return serialization_directives @@ -54,7 +94,7 @@ def test_deserialiser_directives_no_deps_codegen( ): parsed = GranuleParser(no_deps_source_file)() interface = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test")() - generated = SerialisationGenerator(interface)() + generated = SerialisationCodeGenerator(interface)() assert generated == expected_no_deps_serialization_directives @@ -63,7 +103,7 @@ def test_deserialiser_directives_diffusion_codegen( ): parsed = GranuleParser(diffusion_granule, diffusion_granule_deps)() interface = ParsedGranuleDeserialiser(parsed, directory=".", prefix="test")() - generated = SerialisationGenerator(interface)() + generated = SerialisationCodeGenerator(interface)() reference_savepoint = ( samples_path / "expected_diffusion_granule_savepoint.f90" ).read_text() diff --git a/testutils/src/icon4py/testutils/fortran/expected_diffusion_granule_savepoint.f90 b/testutils/src/icon4py/testutils/fortran/expected_diffusion_granule_savepoint.f90 index 6fd964f92a..19a3653d97 100644 --- a/testutils/src/icon4py/testutils/fortran/expected_diffusion_granule_savepoint.f90 +++ b/testutils/src/icon4py/testutils/fortran/expected_diffusion_granule_savepoint.f90 @@ -19,440 +19,636 @@ !$ser savepoint diffusion_init_in - !$ser verbatim allocate(edges_primal_normal_vert_v1(size(edges_primal_normal_vert, 1), size(edges_primal_normal_vert, 2), size(edges_primal_normal_vert, 3))) + !$ser verbatim allocate(edges_primal_normal_vert_v1(size(edges_primal_normal_vert, 1),size(edges_primal_normal_vert, 2),size(edges_primal_normal_vert, 3))) !$ser data edges_primal_normal_vert_v1=edges_primal_normal_vert_v1(:,:,:) !$ser verbatim deallocate(edges_primal_normal_vert_v1) - !$ser verbatim allocate(edges_primal_normal_vert_v2(size(edges_primal_normal_vert, 1), size(edges_primal_normal_vert, 2), size(edges_primal_normal_vert, 3))) + !$ser verbatim allocate(edges_primal_normal_vert_v2(size(edges_primal_normal_vert, 1),size(edges_primal_normal_vert, 2),size(edges_primal_normal_vert, 3))) !$ser data edges_primal_normal_vert_v2=edges_primal_normal_vert_v2(:,:,:) !$ser verbatim deallocate(edges_primal_normal_vert_v2) - !$ser verbatim allocate(edges_dual_normal_vert_v1(size(edges_dual_normal_vert, 1), size(edges_dual_normal_vert, 2), size(edges_dual_normal_vert, 3))) + !$ser verbatim allocate(edges_dual_normal_vert_v1(size(edges_dual_normal_vert, 1),size(edges_dual_normal_vert, 2),size(edges_dual_normal_vert, 3))) !$ser data edges_dual_normal_vert_v1=edges_dual_normal_vert_v1(:,:,:) !$ser verbatim deallocate(edges_dual_normal_vert_v1) - !$ser verbatim allocate(edges_dual_normal_vert_v2(size(edges_dual_normal_vert, 1), size(edges_dual_normal_vert, 2), size(edges_dual_normal_vert, 3))) + !$ser verbatim allocate(edges_dual_normal_vert_v2(size(edges_dual_normal_vert, 1),size(edges_dual_normal_vert, 2),size(edges_dual_normal_vert, 3))) !$ser data edges_dual_normal_vert_v2=edges_dual_normal_vert_v2(:,:,:) !$ser verbatim deallocate(edges_dual_normal_vert_v2) - !$ser verbatim allocate(edges_primal_normal_cell_v1(size(edges_primal_normal_cell, 1), size(edges_primal_normal_cell, 2), size(edges_primal_normal_cell, 3))) + !$ser verbatim allocate(edges_primal_normal_cell_v1(size(edges_primal_normal_cell, 1),size(edges_primal_normal_cell, 2),size(edges_primal_normal_cell, 3))) !$ser data edges_primal_normal_cell_v1=edges_primal_normal_cell_v1(:,:,:) !$ser verbatim deallocate(edges_primal_normal_cell_v1) - !$ser verbatim allocate(edges_primal_normal_cell_v2(size(edges_primal_normal_cell, 1), size(edges_primal_normal_cell, 2), size(edges_primal_normal_cell, 3))) + !$ser verbatim allocate(edges_primal_normal_cell_v2(size(edges_primal_normal_cell, 1),size(edges_primal_normal_cell, 2),size(edges_primal_normal_cell, 3))) !$ser data edges_primal_normal_cell_v2=edges_primal_normal_cell_v2(:,:,:) !$ser verbatim deallocate(edges_primal_normal_cell_v2) - !$ser verbatim allocate(edges_dual_normal_cell_v1(size(edges_dual_normal_cell, 1), size(edges_dual_normal_cell, 2), size(edges_dual_normal_cell, 3))) + !$ser verbatim allocate(edges_dual_normal_cell_v1(size(edges_dual_normal_cell, 1),size(edges_dual_normal_cell, 2),size(edges_dual_normal_cell, 3))) !$ser data edges_dual_normal_cell_v1=edges_dual_normal_cell_v1(:,:,:) !$ser verbatim deallocate(edges_dual_normal_cell_v1) - !$ser verbatim allocate(edges_dual_normal_cell_v2(size(edges_dual_normal_cell, 1), size(edges_dual_normal_cell, 2), size(edges_dual_normal_cell, 3))) + !$ser verbatim allocate(edges_dual_normal_cell_v2(size(edges_dual_normal_cell, 1),size(edges_dual_normal_cell, 2),size(edges_dual_normal_cell, 3))) !$ser data edges_dual_normal_cell_v2=edges_dual_normal_cell_v2(:,:,:) !$ser verbatim deallocate(edges_dual_normal_cell_v2) + PRINT *, 'Serializing cvd_o_rd=cvd_o_rd' + !$ser data cvd_o_rd=cvd_o_rd + PRINT *, 'Serializing grav=grav' + !$ser data grav=grav + PRINT *, 'Serializing jg=jg' + !$ser data jg=jg + PRINT *, 'Serializing nproma=nproma' + !$ser data nproma=nproma + PRINT *, 'Serializing nlev=nlev' + !$ser data nlev=nlev + PRINT *, 'Serializing nblks_e=nblks_e' + !$ser data nblks_e=nblks_e + PRINT *, 'Serializing nblks_v=nblks_v' + !$ser data nblks_v=nblks_v + PRINT *, 'Serializing nblks_c=nblks_c' + !$ser data nblks_c=nblks_c + PRINT *, 'Serializing nshift=nshift' + !$ser data nshift=nshift + PRINT *, 'Serializing nshift_total=nshift_total' + !$ser data nshift_total=nshift_total + PRINT *, 'Serializing nrdmax=nrdmax' + !$ser data nrdmax=nrdmax + PRINT *, 'Serializing ndyn_substeps=ndyn_substeps' + !$ser data ndyn_substeps=ndyn_substeps + PRINT *, 'Serializing hdiff_order=hdiff_order' + !$ser data hdiff_order=hdiff_order + PRINT *, 'Serializing itype_comm=itype_comm' + !$ser data itype_comm=itype_comm + PRINT *, 'Serializing itype_sher=itype_sher' + !$ser data itype_sher=itype_sher + PRINT *, 'Serializing itype_vn_diffu=itype_vn_diffu' + !$ser data itype_vn_diffu=itype_vn_diffu + PRINT *, 'Serializing itype_t_diffu=itype_t_diffu' + !$ser data itype_t_diffu=itype_t_diffu + PRINT *, 'Serializing hdiff_smag_z=hdiff_smag_z' + !$ser data hdiff_smag_z=hdiff_smag_z + PRINT *, 'Serializing hdiff_smag_z2=hdiff_smag_z2' + !$ser data hdiff_smag_z2=hdiff_smag_z2 + PRINT *, 'Serializing hdiff_smag_z3=hdiff_smag_z3' + !$ser data hdiff_smag_z3=hdiff_smag_z3 + PRINT *, 'Serializing hdiff_smag_z4=hdiff_smag_z4' + !$ser data hdiff_smag_z4=hdiff_smag_z4 + PRINT *, 'Serializing hdiff_smag_fac=hdiff_smag_fac' + !$ser data hdiff_smag_fac=hdiff_smag_fac + PRINT *, 'Serializing hdiff_smag_fac2=hdiff_smag_fac2' + !$ser data hdiff_smag_fac2=hdiff_smag_fac2 + PRINT *, 'Serializing hdiff_smag_fac3=hdiff_smag_fac3' + !$ser data hdiff_smag_fac3=hdiff_smag_fac3 + PRINT *, 'Serializing hdiff_smag_fac4=hdiff_smag_fac4' + !$ser data hdiff_smag_fac4=hdiff_smag_fac4 + PRINT *, 'Serializing hdiff_efdt_ratio=hdiff_efdt_ratio' + !$ser data hdiff_efdt_ratio=hdiff_efdt_ratio + PRINT *, 'Serializing k4=k4' + !$ser data k4=k4 + PRINT *, 'Serializing k4w=k4w' + !$ser data k4w=k4w + PRINT *, 'Serializing nudge_max_coeff=nudge_max_coeff' + !$ser data nudge_max_coeff=nudge_max_coeff + PRINT *, 'Serializing denom_diffu_v=denom_diffu_v' + !$ser data denom_diffu_v=denom_diffu_v + PRINT *, 'Serializing p_test_run=p_test_run' + !$ser data p_test_run=p_test_run + PRINT *, 'Serializing lphys=lphys' + !$ser data lphys=lphys + PRINT *, 'Serializing lhdiff_rcf=lhdiff_rcf' + !$ser data lhdiff_rcf=lhdiff_rcf + PRINT *, 'Serializing lhdiff_w=lhdiff_w' + !$ser data lhdiff_w=lhdiff_w + PRINT *, 'Serializing lhdiff_temp=lhdiff_temp' + !$ser data lhdiff_temp=lhdiff_temp + PRINT *, 'Serializing l_zdiffu_t=l_zdiffu_t' + !$ser data l_zdiffu_t=l_zdiffu_t + PRINT *, 'Serializing l_limited_area=l_limited_area' + !$ser data l_limited_area=l_limited_area + PRINT *, 'Serializing lfeedback=lfeedback' + !$ser data lfeedback=lfeedback + PRINT *, 'Serializing ltkeshs=ltkeshs' + !$ser data ltkeshs=ltkeshs + PRINT *, 'Serializing lsmag_3d=lsmag_3d' + !$ser data lsmag_3d=lsmag_3d + PRINT *, 'Serializing lvert_nest=lvert_nest' + !$ser data lvert_nest=lvert_nest + PRINT *, 'Serializing ltimer=ltimer' + !$ser data ltimer=ltimer + PRINT *, 'Serializing ddt_vn_hdf_is_associated=ddt_vn_hdf_is_associated' + !$ser data ddt_vn_hdf_is_associated=ddt_vn_hdf_is_associated + PRINT *, 'Serializing ddt_vn_dyn_is_associated=ddt_vn_dyn_is_associated' + !$ser data ddt_vn_dyn_is_associated=ddt_vn_dyn_is_associated + PRINT *, 'Serializing vct_a=vct_a(:)' + IF (SIZE(vct_a) > 0) THEN !$ser data vct_a=vct_a(:) ELSE PRINT *, 'Warning: Array vct_a has size 0. Not serializing array.' END IF + PRINT *, 'Serializing c_lin_e=c_lin_e(:,:,:)' + IF (SIZE(c_lin_e) > 0) THEN !$ser data c_lin_e=c_lin_e(:,:,:) ELSE PRINT *, 'Warning: Array c_lin_e has size 0. Not serializing array.' END IF + PRINT *, 'Serializing e_bln_c_s=e_bln_c_s(:,:,:)' + IF (SIZE(e_bln_c_s) > 0) THEN !$ser data e_bln_c_s=e_bln_c_s(:,:,:) ELSE PRINT *, 'Warning: Array e_bln_c_s has size 0. Not serializing array.' END IF + PRINT *, 'Serializing e_bln_c_u=e_bln_c_u(:,:,:)' + IF (SIZE(e_bln_c_u) > 0) THEN !$ser data e_bln_c_u=e_bln_c_u(:,:,:) ELSE PRINT *, 'Warning: Array e_bln_c_u has size 0. Not serializing array.' END IF + PRINT *, 'Serializing e_bln_c_v=e_bln_c_v(:,:,:)' + IF (SIZE(e_bln_c_v) > 0) THEN !$ser data e_bln_c_v=e_bln_c_v(:,:,:) ELSE PRINT *, 'Warning: Array e_bln_c_v has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_aw_verts=cells_aw_verts(:,:,:)' + IF (SIZE(cells_aw_verts) > 0) THEN !$ser data cells_aw_verts=cells_aw_verts(:,:,:) ELSE PRINT *, 'Warning: Array cells_aw_verts has size 0. Not serializing array.' END IF + PRINT *, 'Serializing geofac_div=geofac_div(:,:,:)' + IF (SIZE(geofac_div) > 0) THEN !$ser data geofac_div=geofac_div(:,:,:) ELSE PRINT *, 'Warning: Array geofac_div has size 0. Not serializing array.' END IF + PRINT *, 'Serializing geofac_rot=geofac_rot(:,:,:)' + IF (SIZE(geofac_rot) > 0) THEN !$ser data geofac_rot=geofac_rot(:,:,:) ELSE PRINT *, 'Warning: Array geofac_rot has size 0. Not serializing array.' END IF + PRINT *, 'Serializing geofac_n2s=geofac_n2s(:,:,:)' + IF (SIZE(geofac_n2s) > 0) THEN !$ser data geofac_n2s=geofac_n2s(:,:,:) ELSE PRINT *, 'Warning: Array geofac_n2s has size 0. Not serializing array.' END IF + PRINT *, 'Serializing geofac_grg=geofac_grg(:,:,:,:)' + IF (SIZE(geofac_grg) > 0) THEN !$ser data geofac_grg=geofac_grg(:,:,:,:) ELSE PRINT *, 'Warning: Array geofac_grg has size 0. Not serializing array.' END IF + PRINT *, 'Serializing nudgecoeff_e=nudgecoeff_e(:,:)' + IF (SIZE(nudgecoeff_e) > 0) THEN !$ser data nudgecoeff_e=nudgecoeff_e(:,:) ELSE PRINT *, 'Warning: Array nudgecoeff_e has size 0. Not serializing array.' END IF + PRINT *, 'Serializing rbf_vec_idx_v=rbf_vec_idx_v(:,:,:)' + IF (SIZE(rbf_vec_idx_v) > 0) THEN !$ser data rbf_vec_idx_v=rbf_vec_idx_v(:,:,:) ELSE PRINT *, 'Warning: Array rbf_vec_idx_v has size 0. Not serializing array.' END IF + PRINT *, 'Serializing rbf_vec_blk_v=rbf_vec_blk_v(:,:,:)' + IF (SIZE(rbf_vec_blk_v) > 0) THEN !$ser data rbf_vec_blk_v=rbf_vec_blk_v(:,:,:) ELSE PRINT *, 'Warning: Array rbf_vec_blk_v has size 0. Not serializing array.' END IF + PRINT *, 'Serializing rbf_vec_coeff_v=rbf_vec_coeff_v(:,:,:,:)' + IF (SIZE(rbf_vec_coeff_v) > 0) THEN !$ser data rbf_vec_coeff_v=rbf_vec_coeff_v(:,:,:,:) ELSE PRINT *, 'Warning: Array rbf_vec_coeff_v has size 0. Not serializing array.' END IF + PRINT *, 'Serializing enhfac_diffu=enhfac_diffu(:)' + IF (SIZE(enhfac_diffu) > 0) THEN !$ser data enhfac_diffu=enhfac_diffu(:) ELSE PRINT *, 'Warning: Array enhfac_diffu has size 0. Not serializing array.' END IF + PRINT *, 'Serializing zd_intcoef=zd_intcoef(:,:)' + IF (SIZE(zd_intcoef) > 0) THEN !$ser data zd_intcoef=zd_intcoef(:,:) ELSE PRINT *, 'Warning: Array zd_intcoef has size 0. Not serializing array.' END IF + PRINT *, 'Serializing zd_geofac=zd_geofac(:,:)' + IF (SIZE(zd_geofac) > 0) THEN !$ser data zd_geofac=zd_geofac(:,:) ELSE PRINT *, 'Warning: Array zd_geofac has size 0. Not serializing array.' END IF + PRINT *, 'Serializing zd_diffcoef=zd_diffcoef(:)' + IF (SIZE(zd_diffcoef) > 0) THEN !$ser data zd_diffcoef=zd_diffcoef(:) ELSE PRINT *, 'Warning: Array zd_diffcoef has size 0. Not serializing array.' END IF + PRINT *, 'Serializing wgtfac_c=wgtfac_c(:,:,:)' + IF (SIZE(wgtfac_c) > 0) THEN !$ser data wgtfac_c=wgtfac_c(:,:,:) ELSE PRINT *, 'Warning: Array wgtfac_c has size 0. Not serializing array.' END IF + PRINT *, 'Serializing wgtfac_e=wgtfac_e(:,:,:)' + IF (SIZE(wgtfac_e) > 0) THEN !$ser data wgtfac_e=wgtfac_e(:,:,:) ELSE PRINT *, 'Warning: Array wgtfac_e has size 0. Not serializing array.' END IF + PRINT *, 'Serializing wgtfacq_e=wgtfacq_e(:,:,:)' + IF (SIZE(wgtfacq_e) > 0) THEN !$ser data wgtfacq_e=wgtfacq_e(:,:,:) ELSE PRINT *, 'Warning: Array wgtfacq_e has size 0. Not serializing array.' END IF + PRINT *, 'Serializing wgtfacq1_e=wgtfacq1_e(:,:,:)' + IF (SIZE(wgtfacq1_e) > 0) THEN !$ser data wgtfacq1_e=wgtfacq1_e(:,:,:) ELSE PRINT *, 'Warning: Array wgtfacq1_e has size 0. Not serializing array.' END IF + PRINT *, 'Serializing ddqz_z_full_e=ddqz_z_full_e(:,:,:)' + IF (SIZE(ddqz_z_full_e) > 0) THEN !$ser data ddqz_z_full_e=ddqz_z_full_e(:,:,:) ELSE PRINT *, 'Warning: Array ddqz_z_full_e has size 0. Not serializing array.' END IF + PRINT *, 'Serializing theta_ref_mc=theta_ref_mc(:,:,:)' + IF (SIZE(theta_ref_mc) > 0) THEN !$ser data theta_ref_mc=theta_ref_mc(:,:,:) ELSE PRINT *, 'Warning: Array theta_ref_mc has size 0. Not serializing array.' END IF + PRINT *, 'Serializing zd_indlist=zd_indlist(:,:)' + IF (SIZE(zd_indlist) > 0) THEN !$ser data zd_indlist=zd_indlist(:,:) ELSE PRINT *, 'Warning: Array zd_indlist has size 0. Not serializing array.' END IF + PRINT *, 'Serializing zd_blklist=zd_blklist(:,:)' + IF (SIZE(zd_blklist) > 0) THEN !$ser data zd_blklist=zd_blklist(:,:) ELSE PRINT *, 'Warning: Array zd_blklist has size 0. Not serializing array.' END IF + PRINT *, 'Serializing zd_vertidx=zd_vertidx(:,:)' + IF (SIZE(zd_vertidx) > 0) THEN !$ser data zd_vertidx=zd_vertidx(:,:) ELSE PRINT *, 'Warning: Array zd_vertidx has size 0. Not serializing array.' END IF + PRINT *, 'Serializing zd_listdim=zd_listdim' + !$ser data zd_listdim=zd_listdim + PRINT *, 'Serializing edges_start_block=edges_start_block(min_rledge:)' + IF (SIZE(edges_start_block) > 0) THEN !$ser data edges_start_block=edges_start_block(min_rledge:) ELSE PRINT *, 'Warning: Array edges_start_block has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_end_block=edges_end_block(min_rledge:)' + IF (SIZE(edges_end_block) > 0) THEN !$ser data edges_end_block=edges_end_block(min_rledge:) ELSE PRINT *, 'Warning: Array edges_end_block has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_start_index=edges_start_index(min_rledge:)' + IF (SIZE(edges_start_index) > 0) THEN !$ser data edges_start_index=edges_start_index(min_rledge:) ELSE PRINT *, 'Warning: Array edges_start_index has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_end_index=edges_end_index(min_rledge:)' + IF (SIZE(edges_end_index) > 0) THEN !$ser data edges_end_index=edges_end_index(min_rledge:) ELSE PRINT *, 'Warning: Array edges_end_index has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_vertex_idx=edges_vertex_idx(:,:,:)' + IF (SIZE(edges_vertex_idx) > 0) THEN !$ser data edges_vertex_idx=edges_vertex_idx(:,:,:) ELSE PRINT *, 'Warning: Array edges_vertex_idx has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_vertex_blk=edges_vertex_blk(:,:,:)' + IF (SIZE(edges_vertex_blk) > 0) THEN !$ser data edges_vertex_blk=edges_vertex_blk(:,:,:) ELSE PRINT *, 'Warning: Array edges_vertex_blk has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_cell_idx=edges_cell_idx(:,:,:)' + IF (SIZE(edges_cell_idx) > 0) THEN !$ser data edges_cell_idx=edges_cell_idx(:,:,:) ELSE PRINT *, 'Warning: Array edges_cell_idx has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_cell_blk=edges_cell_blk(:,:,:)' + IF (SIZE(edges_cell_blk) > 0) THEN !$ser data edges_cell_blk=edges_cell_blk(:,:,:) ELSE PRINT *, 'Warning: Array edges_cell_blk has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_tangent_orientation=edges_tangent_orientation(:,:)' + IF (SIZE(edges_tangent_orientation) > 0) THEN !$ser data edges_tangent_orientation=edges_tangent_orientation(:,:) ELSE PRINT *, 'Warning: Array edges_tangent_orientation has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_inv_vert_vert_length=edges_inv_vert_vert_length(:,:)' + IF (SIZE(edges_inv_vert_vert_length) > 0) THEN !$ser data edges_inv_vert_vert_length=edges_inv_vert_vert_length(:,:) ELSE PRINT *, 'Warning: Array edges_inv_vert_vert_length has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_inv_primal_edge_length=edges_inv_primal_edge_length(:,:)' + IF (SIZE(edges_inv_primal_edge_length) > 0) THEN !$ser data edges_inv_primal_edge_length=edges_inv_primal_edge_length(:,:) ELSE PRINT *, 'Warning: Array edges_inv_primal_edge_length has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_inv_dual_edge_length=edges_inv_dual_edge_length(:,:)' + IF (SIZE(edges_inv_dual_edge_length) > 0) THEN !$ser data edges_inv_dual_edge_length=edges_inv_dual_edge_length(:,:) ELSE PRINT *, 'Warning: Array edges_inv_dual_edge_length has size 0. Not serializing array.' END IF + PRINT *, 'Serializing edges_area_edge=edges_area_edge(:,:)' + IF (SIZE(edges_area_edge) > 0) THEN !$ser data edges_area_edge=edges_area_edge(:,:) ELSE PRINT *, 'Warning: Array edges_area_edge has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_start_block=cells_start_block(min_rlcell:)' + IF (SIZE(cells_start_block) > 0) THEN !$ser data cells_start_block=cells_start_block(min_rlcell:) ELSE PRINT *, 'Warning: Array cells_start_block has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_end_block=cells_end_block(min_rlcell:)' + IF (SIZE(cells_end_block) > 0) THEN !$ser data cells_end_block=cells_end_block(min_rlcell:) ELSE PRINT *, 'Warning: Array cells_end_block has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_start_index=cells_start_index(min_rlcell:)' + IF (SIZE(cells_start_index) > 0) THEN !$ser data cells_start_index=cells_start_index(min_rlcell:) ELSE PRINT *, 'Warning: Array cells_start_index has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_end_index=cells_end_index(min_rlcell:)' + IF (SIZE(cells_end_index) > 0) THEN !$ser data cells_end_index=cells_end_index(min_rlcell:) ELSE PRINT *, 'Warning: Array cells_end_index has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_neighbor_idx=cells_neighbor_idx(:,:,:)' + IF (SIZE(cells_neighbor_idx) > 0) THEN !$ser data cells_neighbor_idx=cells_neighbor_idx(:,:,:) ELSE PRINT *, 'Warning: Array cells_neighbor_idx has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_neighbor_blk=cells_neighbor_blk(:,:,:)' + IF (SIZE(cells_neighbor_blk) > 0) THEN !$ser data cells_neighbor_blk=cells_neighbor_blk(:,:,:) ELSE PRINT *, 'Warning: Array cells_neighbor_blk has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_edge_idx=cells_edge_idx(:,:,:)' + IF (SIZE(cells_edge_idx) > 0) THEN !$ser data cells_edge_idx=cells_edge_idx(:,:,:) ELSE PRINT *, 'Warning: Array cells_edge_idx has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_edge_blk=cells_edge_blk(:,:,:)' + IF (SIZE(cells_edge_blk) > 0) THEN !$ser data cells_edge_blk=cells_edge_blk(:,:,:) ELSE PRINT *, 'Warning: Array cells_edge_blk has size 0. Not serializing array.' END IF + PRINT *, 'Serializing cells_area=cells_area(:,:)' + IF (SIZE(cells_area) > 0) THEN !$ser data cells_area=cells_area(:,:) ELSE PRINT *, 'Warning: Array cells_area has size 0. Not serializing array.' END IF + PRINT *, 'Serializing verts_start_block=verts_start_block(min_rlvert:)' + IF (SIZE(verts_start_block) > 0) THEN !$ser data verts_start_block=verts_start_block(min_rlvert:) ELSE PRINT *, 'Warning: Array verts_start_block has size 0. Not serializing array.' END IF + PRINT *, 'Serializing verts_end_block=verts_end_block(min_rlvert:)' + IF (SIZE(verts_end_block) > 0) THEN !$ser data verts_end_block=verts_end_block(min_rlvert:) ELSE PRINT *, 'Warning: Array verts_end_block has size 0. Not serializing array.' END IF + PRINT *, 'Serializing verts_start_index=verts_start_index(min_rlvert:)' + IF (SIZE(verts_start_index) > 0) THEN !$ser data verts_start_index=verts_start_index(min_rlvert:) ELSE PRINT *, 'Warning: Array verts_start_index has size 0. Not serializing array.' END IF + PRINT *, 'Serializing verts_end_index=verts_end_index(min_rlvert:)' + IF (SIZE(verts_end_index) > 0) THEN !$ser data verts_end_index=verts_end_index(min_rlvert:) ELSE From e1859cb2de90ae3772b08047f4b0cf9784610489 Mon Sep 17 00:00:00 2001 From: samkellerhals Date: Tue, 9 May 2023 16:44:25 +0200 Subject: [PATCH 15/15] Remove print statement --- pyutils/tests/f2ser/test_f2ser_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyutils/tests/f2ser/test_f2ser_cli.py b/pyutils/tests/f2ser/test_f2ser_cli.py index 5932b602df..b32d87e1d9 100644 --- a/pyutils/tests/f2ser/test_f2ser_cli.py +++ b/pyutils/tests/f2ser/test_f2ser_cli.py @@ -65,10 +65,10 @@ def test_cli_wrong_source(outfile, cli): result = cli.invoke(main, args) assert "Invalid value for 'GRANULE_PATH'" in result.output + def test_cli_missing_source(not_existing_diffusion_granule, outfile, cli): inp = str(not_existing_diffusion_granule) args = [inp, outfile] result = cli.invoke(main, args) - print(result.exception) assert isinstance(result.exception, SystemExit) assert "Invalid value for 'GRANULE_PATH'" in result.output