Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to include code snippets in blockquotes #22

Open
ocaisa opened this issue Jul 2, 2020 · 2 comments
Open

How to include code snippets in blockquotes #22

ocaisa opened this issue Jul 2, 2020 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@ocaisa
Copy link
Member

ocaisa commented Jul 2, 2020

It is very tedious to include code snippets in blockquotes but I have a workaround, see the example below

> ## Learn to call the **GPU** package from command-line
>
> In this exercise, we'll deal with a Lennard-Jones (LJ) system as described by the
> following input file. You can vary the system size and the length of the run using the
> variables `x`, `y`, `z`, and `t`. For this exercise, let us choose `x = y = z = 60`. Since
> this is a system with `fcc` lattice, the total number of atoms should be 864,000 for
> the chosen values of `x`, `y`, and `z`. Let, `t` = 500.
> We'll call the **GPU** package from the command-line in this case. Can you prepare a
> job submission file for this system such that it enables to use 2 GPUs with 24 MPI ranks.
> Make sure that the neighbor is built on the CPUs and there is a dynamic load balancing
> between the CPUs and the GPUs.
> ```
> {% capture mycode %}
{% include /snippets/ep05/in.lj %}
{% endcapture %}{{ mycode | strip | newline_to_br | replace: '<br />', '<br />> ' | strip_html | strip }}
> ```
> {: .code}
>
> > ## Solution
> > A job submission script is shown below. Note that the number of MPI ranks is fixe
> > by `#SBATCH --ntasks-per-node=24`. You are requesting for 2 GPUs by using
> > `#SBATCH --gres=gpu:2`. Rest of the input parameters can be passed to the LAMMPS
> > executable using command-line switches. The system size can be chosen using
> > `-v x 60 -v y 60 -v z 60`, length of the run can be decided by `-v t 500`, **GPU**
> > package and the number of GPUs is chosen by `-pk gpu 2`, the **GPU** package
> > related fix/pair styles can be chosen using `-sf gpu`, and other **GPU** package
> > related keywords are chosen using `neigh no newton off split -1.0`. A `no` value of
> > the `neigh` keyword ensures that the neighbor list is built in the *CPUs*. Dynamic
> > load balancing option between CPUs and GPUs is chosen using `split -1.0`.
> {: .solution}
{: .challenge}

Note that replace is key, if the code snippet is in the solution is would change to

{% endcapture %}{{ mycode | strip | newline_to_br | replace: '<br />', '<br />> > ' | strip_html | strip }}
@ocaisa
Copy link
Member Author

ocaisa commented Jul 8, 2020

This didn't work, I had to go another way and create our own custom filter. This is included in #23 and can be used like:

> ```
> {% capture mycode %}
{% include /snippets/ep05/in.lj %}
{% endcapture %}{{ mycode | append_to_newline: "> " }}
> ```
> {: .code}

@ocaisa
Copy link
Member Author

ocaisa commented Jul 9, 2020

The last thing also didn't work on the GitHub site, so I had to revert to the standard filters. I managed to get it to work with

>
> {% capture mycode %}{% include /snippets/ep05/in.lj %}{% endcapture %}
> {% assign lines_of_code = mycode | strip |newline_to_br | strip_newlines | split: "<br />" %}
> ```{% for member in lines_of_code %}
> {{ member }}{% endfor %}
> ```
> {: .source}
>

The syntax is very very picky though, it has to be exactly like that.

@ocaisa ocaisa added the help wanted Extra attention is needed label Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant