From 944d80956eb2bc89fe65f4382a973226b383c6e6 Mon Sep 17 00:00:00 2001 From: Joerg Henrichs Date: Tue, 18 Aug 2026 00:07:39 +1000 Subject: [PATCH 1/3] #522 Support intel-specific inquiry extension. --- src/fparser/two/Fortran2003.py | 19 +++++++++++-- src/fparser/two/tests/test_fortran2003.py | 34 ++++++++++++++++++++++- src/fparser/two/utils.py | 4 +++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/fparser/two/Fortran2003.py b/src/fparser/two/Fortran2003.py index ecc89765..e8ace7a2 100644 --- a/src/fparser/two/Fortran2003.py +++ b/src/fparser/two/Fortran2003.py @@ -9758,6 +9758,13 @@ class Inquire_Spec(KeywordValueBase): # R930 | STREAM = | UNFORMATTED = | WRITE = + If the extension inquiry-directory is enabled, it will also allow + the intel specific arguments: + | DIRECTORY = + | DIRSPEC = + + valid.append(("DIRECTORY", File_Name_Expr)) + valid.append(("DIRSPEC", Scalar_Default_Char_Variable)) The `items` attribute for this class contains (str, instance). @@ -9789,7 +9796,7 @@ def match(string): # The only argument which need not be named is the unit number return "UNIT", File_Unit_Number(string) # We have a keyword-value pair. Check whether it is valid... - for keyword, value in [ + valid = [ ( [ "ACCESS", @@ -9825,13 +9832,21 @@ def match(string): ("IOMSG", Iomsg_Variable), ("FILE", File_Name_Expr), ("UNIT", File_Unit_Number), - ]: + ] + + if "inquire-directory" in EXTENSIONS(): + # Support the intel-specific extension: + valid.append(("DIRECTORY", File_Name_Expr)) + valid.append(("DIRSPEC", Scalar_Default_Char_Variable)) + + for keyword, value in valid: try: obj = KeywordValueBase.match(keyword, value, string, upper_lhs=True) except NoMatchError: obj = None if obj is not None: return obj + return None diff --git a/src/fparser/two/tests/test_fortran2003.py b/src/fparser/two/tests/test_fortran2003.py index cfcefaa1..43f8f129 100644 --- a/src/fparser/two/tests/test_fortran2003.py +++ b/src/fparser/two/tests/test_fortran2003.py @@ -2346,9 +2346,16 @@ def test_inquire_stmt(): assert str(obj) == "INQUIRE(UNIT = get_unit, OPENED = llopn)" -def test_inquire_spec(): +@pytest.mark.parametrize("standard_only", [True, False]) +def test_inquire_spec(monkeypatch, standard_only): """Tests that we recognise the various possible forms of entries in an inquire list (R930).""" + + if standard_only: + # Disable the inquire-directory extension for this test to verify + # that really only standard expressions are accepted + monkeypatch.setattr(utils, "_EXTENSIONS", []) + tcls = Inquire_Spec obj = tcls("1") assert isinstance(obj, tcls), repr(obj) @@ -2373,6 +2380,31 @@ def test_inquire_spec(): assert isinstance(obj, tcls), repr(obj) assert str(obj) == "DIRECT = a" + if standard_only: + with pytest.raises(NoMatchError) as excinfo: + _ = tcls("directory = a") + assert "Inquire_Spec: 'directory = a" in str(excinfo.value) + with pytest.raises(NoMatchError) as excinfo: + _ = tcls("dirspec = a") + assert "Inquire_Spec: 'dirspec = a" in str(excinfo.value) + else: + obj = tcls("directory = a") + assert isinstance(obj, tcls), repr(obj) + assert str(obj) == "DIRECTORY = a" + + obj = tcls("directory = 'some_dir'") + assert isinstance(obj, tcls), repr(obj) + assert str(obj) == "DIRECTORY = 'some_dir'" + + obj = tcls("dirspec = some_var") + assert isinstance(obj, tcls), repr(obj) + assert str(obj) == "DIRSPEC = some_var" + + # Make sure a character constant is not accepted: + with pytest.raises(NoMatchError) as excinfo: + _ = tcls("dirspec = 'a'") + assert "Inquire_Spec: 'dirspec = 'a'" in str(excinfo.value) + def test_inquire_spec_list(): """Tests that we recognise the various possible forms of diff --git a/src/fparser/two/utils.py b/src/fparser/two/utils.py index b7985a80..0fdefa2a 100644 --- a/src/fparser/two/utils.py +++ b/src/fparser/two/utils.py @@ -118,6 +118,10 @@ # With this extension, these statements will be allowed. _EXTENSIONS += ["extended-stop-args"] +# While non-standard, some compilers (Intel at least) support using inquire +# with a directory, using e.g. INQUIRE (DIRECTORY=".", DIRSPEC=C_DIRSPEC, ...) +_EXTENSIONS += ["inquire-directory"] + def EXTENSIONS(): """ From b7e5018b7eb7f46f7b855d1abca1f74171062cb2 Mon Sep 17 00:00:00 2001 From: Joerg Henrichs Date: Tue, 18 Aug 2026 11:45:02 +1000 Subject: [PATCH 2/3] #522 Fixed comments. --- src/fparser/two/Fortran2003.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/fparser/two/Fortran2003.py b/src/fparser/two/Fortran2003.py index e8ace7a2..20acfe27 100644 --- a/src/fparser/two/Fortran2003.py +++ b/src/fparser/two/Fortran2003.py @@ -9758,14 +9758,11 @@ class Inquire_Spec(KeywordValueBase): # R930 | STREAM = | UNFORMATTED = | WRITE = - If the extension inquiry-directory is enabled, it will also allow + If the extension `inquiry-directory` is enabled, it will also allow the intel specific arguments: | DIRECTORY = | DIRSPEC = - valid.append(("DIRECTORY", File_Name_Expr)) - valid.append(("DIRSPEC", Scalar_Default_Char_Variable)) - The `items` attribute for this class contains (str, instance). """ From e69b8dba12708fd981c952ddc7a93690e47aeda0 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Mon, 24 Aug 2026 15:33:09 +0100 Subject: [PATCH 3/3] #523 update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53589708..eb37e020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ Modifications by (in alphabetical order): * P. Vitt, University of Siegen, Germany * A. Voysey, UK Met Office +24/08/2026 PR #523 for #522. Adds an extension to support the (Intel-specific) + 'directory=' and 'dirspec=' arguments to the INQUIRY function. + 16/07/2026 PR #520 for #519. Fix truncation of a character length expression that contains a comma (e.g. the arguments to an intrinsic such as MAX) when the kind appears before the length in a char-selector.