Skip to content

Commit

Permalink
Finish updating C example
Browse files Browse the repository at this point in the history
[skip-ci]
  • Loading branch information
mdpiper committed Apr 3, 2024
1 parent ac642d3 commit 8d5a121
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions docs/source/example-c.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ Test the BMI
............

At this point,
it's a good idea to run the *bmi-tester* (`GitHub repo <bmi-tester>`_)
it's a good idea to run the *bmi-tester* (`documentation <bmi-tester>`_)
over the model.
The *bmi-tester* exercises each BMI method exposed through Python,
ensuring it works correctly.
Expand All @@ -306,16 +306,16 @@ Create a configuration file for *heat* at the command line with:

.. code:: bash
$ echo "1.5, 8.0, 6, 5" > config.txt
echo "1.5, 8.0, 6, 5" > config.txt
or download the file :download:`config.txt <examples/config.txt>`
(making sure to place it in the ``test`` directory).
or download the file :download:`config.txt <examples/config.txt>`,
making sure to place it in the ``test`` directory.

Run the *bmi-tester*:
From the ``test`` directory, run the *bmi-tester*:

.. code:: bash
$ bmi-test pymt_heatc:HeatModel --config-file=config.txt --root-dir=. -vvv
bmi-test pymt_heatc:HeatC --config-file=config.txt --root-dir=. -vvv
This command sets off a long list of messages,
ending with
Expand Down Expand Up @@ -343,56 +343,55 @@ Recall the *babelizer* outputs the wrapped *heat* model
to the directory ``pymt_heatc``.
Under this directory,
the *babelizer* created a directory for *heat* model metadata,
``meta/HeatModel``.
``meta/HeatC``.
Change back to the ``pymt_heatc`` directory
and view the current metadata:

.. code:: bash
$ cd ../pymt_heatc
$ ls meta/HeatModel/
$ ls meta/HeatC/
api.yaml
The file ``api.yaml`` is automatically generated by the *babelizer*.
To complete the description of the *heat* model,
other metadata files are needed, including:

* :download:`info.yaml <examples/info.yaml>`
* :download:`run.yaml <examples/run.yaml>`
* a :download:`templated model configuration file <examples/heat.txt>`
* :download:`parameters.yaml <examples/parameters.yaml>`
* :download:`info.yaml <examples/c/info.yaml>`
* :download:`run.yaml <examples/c/run.yaml>`
* a :download:`templated model configuration file <examples/c/heat.txt>`
* :download:`parameters.yaml <examples/c/parameters.yaml>`

`Descriptions`_ of these files and their roles
are given in the CSDMS Model Metadata repository.
Download each of the files using the links in the list above
and place them in the ``pymt_heatc/meta/HeatModel`` directory
and place them in the ``pymt_heatc/meta/HeatC`` directory
alongside ``api.yaml``.

Next, install *pymt*:

.. code:: bash
$ conda install -c conda-forge pymt
Then start a Python session and show that the *heat* model
can be called through *pymt*:

.. code:: python
>>> from pymt.models import HeatModel
>>> m = HeatModel()
>>> print(m.name)
from pymt.models import HeatC
m = HeatC()
m.name
You should see:

.. code:: bash
The 2D Heat Equation
A longer example,
:download:`pymt_heatc_ex.py <examples/pymt_heatc_ex.py>`,
:download:`pymt_heatc_ex.py <examples/c/pymt_heatc_ex.py>`,
is included in the documentation.
For easy viewing, it's reproduced here verbatim:

.. include:: examples/pymt_heatc_ex.py
.. include:: examples/c/pymt_heatc_ex.py
:literal:

:download:`Download <examples/pymt_heatc_ex.py>` this Python script,
:download:`Download <examples/c/pymt_heatc_ex.py>` this Python script,
then run it with:

.. code:: bash
Expand All @@ -407,7 +406,7 @@ Using the *babelizer*, we wrapped the *heat* model, which is written in C.
It can now be called as a *pymt* component in Python.

The steps for wrapping a model with the *babelizer* outlined in this example
can also be applied to models written in C++ and Fortran.
can also be applied to models written in C++ and `Fortran`_.


..
Expand All @@ -416,7 +415,8 @@ can also be applied to models written in C++ and Fortran.
.. _bmi-example-c: https://github.com/csdms/bmi-example-c
.. _instructions: https://github.com/csdms/bmi-example-c/blob/master/README.md
.. _Developer Command Prompt: https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs
.. _bmi-tester: https://github.com/csdms/bmi-tester
.. _bmi-tester: https://bmi-tester.readthedocs.io
.. _Python Modeling Tool: https://pymt.readthedocs.io
.. _CSDMS Model Metadata: https://github.com/csdms/model_metadata
.. _Descriptions: https://github.com/csdms/model_metadata/blob/develop/README.rst
.. _Fortran: example-fortran.html

0 comments on commit 8d5a121

Please sign in to comment.