cape.cfdx.cmd
: Creating system commands¶
This module creates system commands as lists of strings for binaries or
scripts that require multiple command-line options. It is closely tied
to cape.cfdx.bin
.
Commands are created in the form of a list of strings. This is the
format used in subprocess
commands (with shell=``False``)
and also cape.bin.calli()
, etc. As a very simple example, the
system command "ls -lh"
becomes the list ["ls", "-lh"]
.
Inputs to the functions in this module take one of two forms:
A
cape.options.Options
object or subset thereofKeyword arguments
The first method allows any appropriate Options
interface and
then extracts the appropriate portion. For instance verify()
can
be given either a top-level options object, a "RunControl"
options
interface (e.g. from cape.options.runControl
), or a dict
of options specific to verify
. It does this using the following
Python commands:
opts = opts.get("RunControl", opts) opts = opts.get("verify", opts)
Other functions, such as aflr3()
, rely on the built-in methods of
the cape.cfdx.options.Options
class. For example,
opts.get_aflr3_i(j)
returns the aflr3
input file name for phase
j if opts is in any of the following classes:
Class
Description
All Cape settings
cape.cfdx.options.RunControlOpts
All run settings
AFLR3 settings
- cape.cfdx.cmdgen.aflr3(opts=None, j=0, **kw)¶
Create AFLR3 system command as a list of strings
- Call:
>>> cmdi = aflr3(opts=None, j=0, **kw)
- Inputs:
- opts:
cape.options.Options
Options interface, either global, “RunControl”, or “aflr3”
- j:
int
|None
Phase number
- blc:
bool
Whether or not to generate prism layers
- blr:
float
Boundary layer stretching option
- blds:
float
Initial surface stretching
- cdfr:
float
Maximum geometric stretching
- cdfs: {
None
} | 0 <=float
<=10 Distribution function exclusion zone
- angblisimx:
float
Max BL intersection angle
- opts:
- Outputs:
- Versions:
2016-04-04
@ddalle
: v1.02023-08-18
@ddalle
: v1.1; use isolate_subsection()
- cape.cfdx.cmdgen.append_cmd_if(cmdi: list, opt, app: list, exc=None)¶
Append to command list if value is not False-like
- Call:
>>> append_cmd_if(cmdi, opt, app, exc=None)
- Inputs:
- Versions:
2023-08-19
@ddalle
: v1.0
- cape.cfdx.cmdgen.append_cmd_if_not_none(cmdi: list, opt, app: list, exc=None)¶
Append to command list if value is not
None
- Call:
>>> append_cmd_if_not_none(cmdi, opt, app, exc=None)
- Inputs:
- Versions:
2023-08-19
@ddalle
: v1.0
- cape.cfdx.cmdgen.get_mpi_procs() int ¶
Estimate number of MPI processes available
This works by reading PBS or Slurm environment variables
- Call:
>>> nproc = get_mpi_procs()
- Outputs:
- nproc:
int
Number of CPUs indicated by environment variables
- nproc:
- Versions:
2024-08-08
@ddalle
: v1.0
- cape.cfdx.cmdgen.get_nproc(rc: Options, j: int = 0) int ¶
Get the number of processes available or specified
- cape.cfdx.cmdgen.infix_phase(fname: str, j: int = 0) str ¶
Add a two-digit phase number to file name before final extension
- cape.cfdx.cmdgen.intersect(opts=None, j=0, **kw)¶
Interface to Cart3D binary
intersect
- Call:
>>> cmd = cape.cmd.intesect(opts=None, **kw)
- Inputs:
- Outputs:
- Versions:
2015-02-13
@ddalle
: v1.02023-08-18
@ddalle
: v1.1; use isolate_subsection()
- cape.cfdx.cmdgen.isolate_subsection(opts, cls: type, subsecs: tuple)¶
Get an options class instance for a section or subsection
For example this class can be used to get the
"RunControl"
section whether opts is adict
, overallOptions
instance, or already is an instance ofRunControlOpts
. It allows the user to get the correct section automatically by either using an instance of that section’s class directly or by giving any parent thereof.- Call:
>>> myopts = isolate_subsection(opts, cls, subsecs)
- Inputs:
- Versions:
2023-08-18
@ddalle
: v1.0
- cape.cfdx.cmdgen.mpiexec(opts: OptionsDict | None = None, j: int = 0, **kw) list ¶
Create command [prefix] to run MPI, e.g.
mpiexec -np 10
- Call:
>>> cmdi = aflr3(opts=None, j=0, **kw)
- Inputs:
- opts: {
None
} |OptionsDict
Options interface, either global or “RunControl” section
- j: {
0
} |int
Phase number
- opts: {
- Outputs:
- Versions:
2024-08-08
@ddalle
: v1.02024-10-10
@ddalle
: v1.1; add args and threads
- cape.cfdx.cmdgen.tecmcr(mcr='export-lay.mcr', **kw)¶
Run a Tecplot macro
- cape.cfdx.cmdgen.verify(opts=None, **kw)¶
Generate command for Cart3D executable
verify
- Call:
>>> cmdi = cape.cmd.verify(opts=None, **kw)
- Inputs:
- opts:
cape.options.Options
Options interface
- i: {
"Components.i.tri"
|str
Name of tri file to test
- ascii: {
True
} |False
Flag to consider input file ASCII
- binary:
True
| {False
} Flag to consider input file binary
- opts:
- Outputs:
- Versions:
2015-02-13
@ddalle
: v1.02023-08-18
@ddalle
: v1.1; use isolate_subsection()