Skip to content

Commit 928d015

Browse files
authored
Documentation updates for using CodeScribe (#2693)
1 parent fbd6803 commit 928d015

File tree

3 files changed

+47
-23
lines changed

3 files changed

+47
-23
lines changed

Docs/sphinx_doc/CouplingToNoahMP.rst

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Files Overview
3636
responsible for managing mapping data between C++ and Fortran.
3737

3838
NOAHMP Class
39-
----------
39+
------------
4040

4141
The NOAH class serves as the handler for initializing and managing the
4242
data structures required for NOAH-MP operations. It inherits from the
@@ -121,26 +121,51 @@ model (e.g., OpenAI, Argo, etc.). Tutorials are available at
121121
1. Edit the prompt file **prompts/noahmpio_update.toml** to specify which
122122
variables should be exposed to the C++ interface.
123123

124-
2. Run the following commands to generate or update bindings in **Submodules/Noah-MP/drivers/erf**::
124+
2. Run the following commands to generate or update bindings in **Submodules/Noah-MP/drivers/erf** directory:
125+
126+
.. code-block:: bash
125127
126128
code-scribe update NoahmpIO.H NoahmpIO.cpp NoahmpIO_fi.F90 \
127-
-p prompts/noahmpio_update.toml -m <openai|argo-gpt4o|...>
129+
-r prompts/noahmpio_update.toml \
130+
-p "Write a natural language prompt with variable names, dimensions, etc." \
131+
-m <openai|argo-gpt4o|...>
132+
133+
3. Run the following to generate or update bindings in **Source/LandSurfaceModel/Noah-MP** directory:
128134

129-
3. Run the following to generate or update bindings in **Source/LandSurfaceModel/Noah-MP**::
135+
.. code-block:: bash
130136
131137
code-scribe update ERF_NOAHMP.cpp \
132-
-p prompts/noahmpio_update.toml -m <openai|argo-gpt4o|...>
138+
-r prompts/noahmpio_update.toml \
139+
-p "Write a natural language prompt with variable names, dimensions, etc." \
140+
-m <openai|argo-gpt4o|...>
133141
134-
You may need to manually edit **Submodules/Noah-MP/drivers/erf/NoahmpIOVarType.F90** to replace::
142+
You may need to manually edit **Submodules/Noah-MP/drivers/erf/NoahmpIOVarType.F90** to replace:
143+
144+
.. code-block:: fortran
135145
136146
real(kind=kind_noahmp)
137147
138-
with::
148+
with:
149+
150+
.. code-block:: fortran
139151
140152
real(kind=C_DOUBLE)
141153
142154
This ensures compatibility with the C++ side. Alternatively, CodeScribe can perform this update automatically (depending on your
143-
model’s context length) using::
155+
model’s context length) using:
156+
157+
.. code-block:: bash
144158
145159
code-scribe update NoahmpIOVarType.F90 \
146-
-p prompts/noahmpio_update.toml -m <openai|argo-gpt4o|...>
160+
-r prompts/noahmpio_update.toml \
161+
-p "Write a natural language prompt with variable names, dimensions, etc." \
162+
-m <openai|argo-gpt4o|...>
163+
164+
If you want to control Noah-MP plot variables, you can update **Submodules/Noah-MP/drivers/erf/NoahmpWriteLandMod.F90** file:
165+
166+
.. code-block:: bash
167+
168+
code-scribe update NoahmpWriteLandMod.F90 \
169+
-r prompts/noahmpwriteland_update.toml \
170+
-p "Write a natural language prompt with variable names, dimensions, etc." \
171+
-m <openai|argo-gpt4o|...>

Source/LandSurfaceModel/Noah-MP/prompts/noahmpio_update.toml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Usage: code-scribe update ERF_NOAHMP.cpp \
2-
# -p prompts/noahmpio_update.toml -m <openai|argo|..>
2+
# -p prompts/noahmpio_update.toml \
3+
# -p "Write a natural language prompt with variable name dimension etc." \
4+
# -m <openai|argo|..>
35

46
[[chat.user]]
57
content = '''
@@ -36,16 +38,16 @@ patterns used for existing variables such as `U_PHY`, `V_PHY`, `T_PHY`, `QV_CURR
3638
2. Task Details
3739
3840
Update Advance_With_State() to include and correctly link new NoahmpIO
39-
variables RAINLSM and any other surface fields needed for the ERF side.
41+
variables and any other surface fields needed for the ERF side.
4042
4143
Changes Required
4244
4345
- Host buffers
4446
Add new temporary FArrayBox allocations for each new variable:
45-
FArrayBox tmp_rainlsm(bx, 1, The_Pinned_Arena());
47+
FArrayBox tmp_variable(bx, 1, The_Pinned_Arena());
4648
4749
and retrieve their array handles:
48-
auto const& tmp_rainlsm_arr = tmp_rainlsm.array();
50+
auto const& tmp_variable_arr = tmp_rainlsm.array();
4951
5052
- Device->Host copy (ParallelFor)
5153
If the new field originates on the ERF side (e.g., forcing input), copy it from
@@ -57,19 +59,19 @@ copy-back section.
5759
- Host->NoahMP copy (LoopOnCpu)
5860
After GPU synchronization (Gpu::streamSynchronize()), extend the LoopOnCpu
5961
block that writes to noahmpio fields:
60-
noahmpio->RAINLSM(i,j) = tmp_rainlsm_arr(i,j,0);
62+
noahmpio->variable(i,j) = tmp_variable_arr(i,j,0);
6163
6264
- Post-DriverMain copy (LoopOnCpu)
63-
Add the reverse direction: copying noahmpio->RAINLSM values back into the
65+
Add the reverse direction: copying noahmpio->variable values back into the
6466
temporary FArrayBox before GPU upload:
65-
h_rainlsm_arr(i,j,0) = noahmpio->RAINLSM(i,j);
67+
h_variable_arr(i,j,0) = noahmpio->variable(i,j);
6668
6769
- Host->Device copy-back (ParallelFor)
6870
Finally, assign results into the correct ERF field:
69-
RAINLSM(i,j,0) = tmp_rainlsm_arr(i,j,0);
71+
variable(i,j,0) = tmp_variable_arr(i,j,0);
7072
7173
Follow the same block and comment style used for variables like TSK, EMISS,
72-
and HFX.
74+
and HFX, and maintain case sensitivity as it is implemented for other variables.
7375
7476
3. Validation
7577
@@ -81,10 +83,7 @@ and HFX.
8183
8284
4. Actual Task
8385
84-
Modify and link the following variable declared in NoahmpIOVarType.F90 and
85-
allocated in NoahmpIOVarInitMod.F90:
86-
87-
- RAINLSM, 2D array of type real(kind=kind_noahmp), with bounds (XSTART:XEND, YSTART:YEND)
86+
Modify and link the requested variables
8887
8988
Ensure the field is fully integrated into the ERF-NoahMP coupling sequence
9089
inside Advance_With_State() following the memory flow used for TSK.

0 commit comments

Comments
 (0)