99
1010// Top-level structure
1111start: block*
12- block: {% for block_name in blocks . keys () %}
13- {{- block_name }}_block
12+ block: {% for block in blocks %}
13+ {{- block.name }}_block
1414{% - if not loop .last %} | {% endif %}
1515{% - endfor %}
1616
1717// Block definitions
18- {% for block_name , meta in block_metadata . items () %}
19- {{ m.block_def(block_name, meta .has_index) }}
18+ {% for block in blocks %}
19+ {{ m.block_def(block.name, block .has_index) }}
2020{% endfor %}
21- {% if block_metadata . values () |selectattr ('has_index' )|list %}
21+ {% if blocks |selectattr ('has_index' )|list %}
2222block_index: integer
2323{% endif %}
2424// Block field lists
25- {% for block_name , meta in block_metadata .items () %}
26- {% if meta .period_groups %}
27- {% set grouped_field_names = meta .period_groups .values ()|first %}
28- {% set field_names = [] %}
29- {% for field_name in meta .fields .keys () %}
30- {% - if field_name not in grouped_field_names %}
31- {% - set _ = field_names .append (field_name ) %}
32- {% - endif %}
33- {% - endfor %}
34- {{ m.field_list(block_name, field_names, meta.recarray_name) }}
25+ {% for block in blocks %}
26+ {% if block .recarrays %}
27+ {% set recarray_name = block .recarrays [0].name %}
28+ {{ m.field_list(block.name, block.standalone_fields, recarray_name) }}
3529{% else %}
36- {{ m.field_list(block_name, meta.fields.keys()|list , none) }}
30+ {{ m.field_list(block.name, block.standalone_fields , none) }}
3731{% endif %}
3832{% endfor %}
3933// Individual field rules
40- {% set grouped_fields = blocks |get_all_grouped_field_names %}
41- {% for field_name , field in fields .items () %}
42- {% if field_name not in grouped_fields %}
34+ {% set generated_rules = [] %}
35+ {% for block in blocks %}
36+ {% for field_name in block .standalone_fields %}
37+ {% if field_name not in generated_rules %}
38+ {% set field = fields [field_name ] %}
4339{% set field_type = field |field_type %}
4440{% if field .type == 'record' and field .children is not none %}
4541{{ m.record_field(field_name, field) }}
@@ -48,11 +44,14 @@ block_index: integer
4844{% else %}
4945{{ m.simple_field(field_name, field, field_type) }}
5046{% endif %}
47+ {% set _ = generated_rules .append (field_name ) %}
5148{% endif %}
5249{% endfor %}
50+ {% endfor %}
5351{# Generate union rules for nested unions within records #}
5452{% set unions_generated = [] %}
55- {% for field_name , field in fields .items () %}
53+ {% for field_name in generated_rules %}
54+ {% set field = fields [field_name ] %}
5655{% if field .type == 'record' and field .children is not none %}
5756{% for child_name , child in field .children .items () %}
5857{% if child .type == 'union' and child_name not in unions_generated %}
@@ -63,10 +62,10 @@ block_index: integer
6362{% endif %}
6463{% endfor %}
6564// Recarray rules for period data (stress_period_data, etc.)
66- {% for block_name , meta in block_metadata . items () %}
67- {% if meta . recarray_name %}
68- {{ meta.recarray_name }}: record+
69- {% endif %}
65+ {% for block in blocks %}
66+ {% for recarray in block . recarrays %}
67+ {{ recarray.name }}: record+
68+ {% endfor %}
7069{% endfor %}
7170
7271%import typed.integer -> integer
0 commit comments