Skip to content

Commit 7d0c8e9

Browse files
authored
Fix rendering issue in documentation. (#2687)
* Fix rendering issue in documentation * Add prompts for NoahmpWriteLand
1 parent 5b9de7f commit 7d0c8e9

File tree

3 files changed

+43
-41
lines changed

3 files changed

+43
-41
lines changed

Docs/sphinx_doc/CouplingToNoahMP.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,16 @@ to configure your LLM environment. You will need API access for your preferred
118118
model (e.g., OpenAI, Argo, etc.). Tutorials are available at
119119
`https://github.com/akashdhruv/codescribe-tutorial <https://github.com/akashdhruv/codescribe-tutorial>`_.
120120

121-
1. Edit the prompt file ``prompts/noahmpio_update.toml`` to specify which
121+
1. Edit the prompt file **prompts/noahmpio_update.toml** to specify which
122122
variables should be exposed to the C++ interface.
123-
2. Run the following commands to generate or update bindings::
124123

125-
# In Submodules/Noah-MP/drivers/erf
124+
2. Run the following commands to generate or update bindings in **Submodules/Noah-MP/drivers/erf**::
125+
126126
code-scribe update NoahmpIO.H NoahmpIO.cpp NoahmpIO_fi.F90 \
127127
-p prompts/noahmpio_update.toml -m <openai|argo-gpt4o|...>
128128

129-
# In Source/LandSurfaceModel/Noah-MP
129+
3. Run the following to generate or update bindings in **Source/LandSurfaceModel/Noah-MP**::
130+
130131
code-scribe update ERF_NOAHMP.cpp \
131132
-p prompts/noahmpio_update.toml -m <openai|argo-gpt4o|...>
132133

@@ -138,9 +139,7 @@ with::
138139

139140
real(kind=C_DOUBLE)
140141

141-
This ensures compatibility with the C++ side.
142-
143-
Alternatively, CodeScribe can perform this update automatically (depending on your
142+
This ensures compatibility with the C++ side. Alternatively, CodeScribe can perform this update automatically (depending on your
144143
model’s context length) using::
145144

146145
code-scribe update NoahmpIOVarType.F90 \
Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Usage: code-scribe update ERF_NOAHMP.cpp \
2+
# -p prompts/noahmpio_update.toml -m <openai|argo|..>
3+
14
[[chat.user]]
2-
content = """
5+
content = '''
36
You are a code-update assistant for extending the ERF-NoahMP C++ driver interface.
47
58
Only edit the appended files. Focus on the coupling logic inside
@@ -12,23 +15,23 @@ patterns used for existing variables such as `U_PHY`, `V_PHY`, `T_PHY`, `QV_CURR
1215
1316
1. Context
1417
15-
- The ERF-NoahMP coupling exchanges field data via `noahmpio_vect`, a per-tile
16-
vector of `NoahmpIO_type` objects. Each object corresponds to a domain tile
17-
in `cons_in`.
18+
- The ERF-NoahMP coupling exchanges field data via `noahmpio_vect`, a per-tile
19+
vector of `NoahmpIO_type` objects. Each object corresponds to a domain tile
20+
in `cons_in`.
1821
19-
- Each time step, `Advance_With_State()` performs the following sequence:
20-
(1) Extract 3D Array4<Real> views from ERF state variables.
21-
(2) Allocate temporary host-accessible FArrayBox buffers (The_Pinned_Arena()).
22-
(3) Launch ParallelFor GPU kernels to copy ERF data into pinned buffers.
23-
(4) Synchronize GPU streams, then perform CPU loops (LoopOnCpu) to copy
24-
those buffers into corresponding NoahMP fields (noahmpio->VAR(i,k,j)).
25-
(5) Call the NoahMP driver (DriverMain()).
26-
(6) Copy computed fluxes and surface variables back from NoahMP to ERF arrays.
22+
- Each time step, `Advance_With_State()` performs the following sequence:
23+
(1) Extract 3D Array4<Real> views from ERF state variables.
24+
(2) Allocate temporary host-accessible FArrayBox buffers (The_Pinned_Arena()).
25+
(3) Launch ParallelFor GPU kernels to copy ERF data into pinned buffers.
26+
(4) Synchronize GPU streams, then perform CPU loops (LoopOnCpu) to copy
27+
those buffers into corresponding NoahMP fields (noahmpio->VAR(i,k,j)).
28+
(5) Call the NoahMP driver (DriverMain()).
29+
(6) Copy computed fluxes and surface variables back from NoahMP to ERF arrays.
2730
28-
- Newly added variables follow the same pattern:
29-
- GPU->Host copy -> LoopOnCpu -> assign to noahmpio->NEWVAR
30-
- DriverMain() executes the Fortran driver
31-
- Host->GPU copy -> ParallelFor -> assign to ERF Array4<Real> fields
31+
- Newly added variables follow the same pattern:
32+
- GPU->Host copy -> LoopOnCpu -> assign to noahmpio->NEWVAR
33+
- DriverMain() executes the Fortran driver
34+
- Host->GPU copy -> ParallelFor -> assign to ERF Array4<Real> fields
3235
3336
2. Task Details
3437
@@ -37,53 +40,53 @@ variables RAINLSM and any other surface fields needed for the ERF side.
3740
3841
Changes Required
3942
40-
- Host buffers
43+
- Host buffers
4144
Add new temporary FArrayBox allocations for each new variable:
42-
FArrayBox tmp_rainlsm(bx, 1, The_Pinned_Arena());
45+
FArrayBox tmp_rainlsm(bx, 1, The_Pinned_Arena());
4346
4447
and retrieve their array handles:
45-
auto const& tmp_rainlsm_arr = tmp_rainlsm.array();
48+
auto const& tmp_rainlsm_arr = tmp_rainlsm.array();
4649
47-
- Device->Host copy (ParallelFor)
50+
- Device->Host copy (ParallelFor)
4851
If the new field originates on the ERF side (e.g., forcing input), copy it from
4952
ERF arrays into the pinned buffer in the existing ParallelFor block.
5053
5154
If it is computed by NoahMP, skip this step and handle it in the post-DriverMain()
5255
copy-back section.
5356
54-
- Host->NoahMP copy (LoopOnCpu)
57+
- Host->NoahMP copy (LoopOnCpu)
5558
After GPU synchronization (Gpu::streamSynchronize()), extend the LoopOnCpu
5659
block that writes to noahmpio fields:
57-
noahmpio->RAINLSM(i,j) = tmp_rainlsm_arr(i,j,0);
60+
noahmpio->RAINLSM(i,j) = tmp_rainlsm_arr(i,j,0);
5861
59-
- Post-DriverMain copy (LoopOnCpu)
62+
- Post-DriverMain copy (LoopOnCpu)
6063
Add the reverse direction: copying noahmpio->RAINLSM values back into the
6164
temporary FArrayBox before GPU upload:
62-
h_rainlsm_arr(i,j,0) = noahmpio->RAINLSM(i,j);
65+
h_rainlsm_arr(i,j,0) = noahmpio->RAINLSM(i,j);
6366
64-
- Host->Device copy-back (ParallelFor)
67+
- Host->Device copy-back (ParallelFor)
6568
Finally, assign results into the correct ERF field:
66-
RAINLSM(i,j,0) = tmp_rainlsm_arr(i,j,0);
69+
RAINLSM(i,j,0) = tmp_rainlsm_arr(i,j,0);
6770
6871
Follow the same block and comment style used for variables like TSK, EMISS,
6972
and HFX.
7073
7174
3. Validation
7275
73-
- Verify that array ranks match (2D for surface variables, 3D for atmospheric variables).
74-
- Ensure the order of CPU/GPU synchronization and host copies is preserved.
75-
- Confirm that noahmpio_vect indexing (idb) and bounds (bx.smallEnd, domain.smallEnd)
76-
remain untouched.
77-
- Maintain one-to-one consistency between ERF arrays and NoahMP I/O variables.
76+
- Verify that array ranks match (2D for surface variables, 3D for atmospheric variables).
77+
- Ensure the order of CPU/GPU synchronization and host copies is preserved.
78+
- Confirm that noahmpio_vect indexing (idb) and bounds (bx.smallEnd, domain.smallEnd)
79+
remain untouched.
80+
- Maintain one-to-one consistency between ERF arrays and NoahMP I/O variables.
7881
7982
4. Actual Task
8083
8184
Modify and link the following variable declared in NoahmpIOVarType.F90 and
8285
allocated in NoahmpIOVarInitMod.F90:
8386
84-
- RAINLSM, 2D array of type real(kind=kind_noahmp), with bounds (XSTART:XEND, YSTART:YEND)
87+
- RAINLSM, 2D array of type real(kind=kind_noahmp), with bounds (XSTART:XEND, YSTART:YEND)
8588
8689
Ensure the field is fully integrated into the ERF-NoahMP coupling sequence
8790
inside Advance_With_State() following the memory flow used for TSK.
8891
89-
"""
92+
'''

0 commit comments

Comments
 (0)