From 8d5a121040902cd409c4ec644e635ad544763840 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Wed, 3 Apr 2024 12:52:16 -0600 Subject: [PATCH] Finish updating C example [skip-ci] --- docs/source/example-c.rst | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/source/example-c.rst b/docs/source/example-c.rst index b9d45ae..4597da6 100644 --- a/docs/source/example-c.rst +++ b/docs/source/example-c.rst @@ -294,7 +294,7 @@ Test the BMI ............ At this point, -it's a good idea to run the *bmi-tester* (`GitHub repo `_) +it's a good idea to run the *bmi-tester* (`documentation `_) over the model. The *bmi-tester* exercises each BMI method exposed through Python, ensuring it works correctly. @@ -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 ` -(making sure to place it in the ``test`` directory). +or download the file :download:`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 @@ -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 ` -* :download:`run.yaml ` -* a :download:`templated model configuration file ` -* :download:`parameters.yaml ` +* :download:`info.yaml ` +* :download:`run.yaml ` +* a :download:`templated model configuration file ` +* :download:`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 `, +:download:`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 ` this Python script, +:download:`Download ` this Python script, then run it with: .. code:: bash @@ -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`_. .. @@ -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