Skip to content

Support namelist #1999

Open
Open

Description

Activity

  1. ubaidsk commented on Jul 22, 2023

    @ubaidsk
    Member

    How do we support this? I guess we need a new data structure/node at the ASR Level.

  2. certik commented on Jul 22, 2023

    @certik
    ContributorAuthor

    Yes, I need to think about it. This is very low priority, I think we'll just remove it from fastGPT. I initially thought I would set more variables this way, but it looks like we'll just set them at the command line if needed.

  3. certik commented on Sep 4, 2023

    @certik
    ContributorAuthor

    Duplicate: #1851

  4. certik commented on Mar 18, 2024

    @certik
    ContributorAuthor

    Let's figure out how to represent namelists at the ASR level. It would be good to design them in such a way as to allow (later) to represent any user-defined custom readers/writers for other formats like JSON, TOML, NPY, HDF5, GGUF, etc.

    It looks like the read(u, input_fastGPT) line will read a structure format from the textual input file. One way is to transform it to something like _lfortran_namelist_read(u, "A", A, "B", B, etc.), and it would populate those variables if present in the input file. Similar to how we handle printing.

    See also: j3-fortran/fortran_proposals#331.

  5. certik commented on Mar 19, 2024

    @certik
    ContributorAuthor

    One way that might work: read(u, input_fastGPT) where input_fastGPT is a namelist that contains arrays A, B and an integer i gets transformed into

    _lfortran_namelist_context ctx;
    _lfortran_namelist_read(u, &ctx);
    _lfortran_namelist_read_array_f32(ctx, "A", size(A), A);
    _lfortran_namelist_read_array_f64(ctx, "B", size(B), B);
    _lfortran_namelist_read_i64(ctx, "i", i);

    Let's check how other compilers do this.

  6. certik commented on Jul 19, 2024

    @certik
    ContributorAuthor

    In the first implementation, let's do the following:

    • Introduce FileReadNamelist node that accepts the file (handle) and list of variables to fill in (expr *vars).
    • In the LLVM backend translate this node into _lfortran_namelist_read. Possibly it might translate it to a sequence of calls per Support namelist #1999 (comment).
    • Later, if the namelist itself can be a global module variable, then we need to put it into the symbol table. But when the line read(u, some_namelist) is encountered by the frontend, it would translate it to FileReadNamelist with explicit vars, so it would reuse the previous two points.
  7. added a commit that references this issue on Aug 12, 2024
  8. added a commit that references this issue on Aug 19, 2024
  9. added a commit that references this issue on Dec 25, 2024
  10. ianfr commented on Aug 3, 2025

    @ianfr

    Is this feature being actively worked on?

  11. certik commented on Aug 3, 2025

    @certik
    ContributorAuthor

    Not right now. If you want to send a PR, you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MCLI2Compiling MCLI2 library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions