The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SkirtCommandLineHandler Class Referencefinal

#include <SkirtCommandLineHandler.hpp>

Public Member Functions

 SkirtCommandLineHandler ()
 
int perform ()
 

Private Member Functions

void addSkiFilesFor (string dirpath, string name)
 
void addSkiFilesFor (string filepath)
 
int doBatch ()
 
int doInteractive ()
 
void doSimulation (size_t index)
 
int doSmileSchema ()
 
void logErrorToFile (const vector< string > &message, string skipath)
 
void printHelp ()
 

Private Attributes

CommandLineArguments _args
 
ConsoleLog _console
 
bool _hasError
 
string _hostUserInfo
 
int _parallelSims
 
string _producerInfo
 
vector< string > _skifiles
 

Detailed Description

This class processes the command line arguments for SKIRT and invokes the appropriate high-level functions to perform the actions requested by the user. When invoked with invalid command line arguments, it prints a brief help message. When invoked without any arguments, it enters interactive mode, constructing a simulation from the user's responses and saving the result in a ski file, without actually performing the simulation. Otherwise, it runs the simulations in the ski files specified on the command line according to the following syntax:

 skirt [-t <threads>] [-s <simulations>] [-d]
       [-b] [-v] [-m] [-e]
       [-k] [-i <dirpath>] [-o <dirpath>]
       [-r] {<filepath>}*

In the simplest case, a <filepath> argument specifies the relative or absolute file path for a single ski file, with or without the ".ski" filename extension. However the filename (not the base path) may also contain ? and * wildcards forming a pattern to match multiple files. If the -r option is present, all directories recursively nested within the base path are searched as well, using the same filename pattern. If the filename contains wildcards or the -r option is present (in other words, if the filepath may match multiple files) the ".ski" filename extension is not automatically added. Furthermore, filepaths containing wildcards should be enclosed in quotes on the command line to avoid expansion of the wildcard pattern by the shell.

For example, to process all "test" ski files inside the "geometry" directory hierarchy, one could specify:

 skirt -s 4 -t 1 -r "/root-test-file-path/geometry/test*.ski"

Constructor & Destructor Documentation

◆ SkirtCommandLineHandler()

SkirtCommandLineHandler::SkirtCommandLineHandler ( )

The constructor obtains the program's command line arguments and issues a welcome message to the console log.

Member Function Documentation

◆ addSkiFilesFor() [1/2]

void SkirtCommandLineHandler::addSkiFilesFor ( string  dirpath,
string  name 
)
private

This function adds the ski filenames corresponding to the specified name pattern inside the specified directory to the internal list. If so requested by the -r option, this function implements recursive descent by calling itself recursively for each subdirectory.

◆ addSkiFilesFor() [2/2]

void SkirtCommandLineHandler::addSkiFilesFor ( string  filepath)
private

This function adds the ski filenames corresponding to the specified filepath to the internal list, after processing any wildcards and performing recursive descent if so requested by the -r option. If no appropriate filenames are found, the function logs a corresponding error message (and leaves the internal list unchanged).

◆ doBatch()

int SkirtCommandLineHandler::doBatch ( )
private

This function scans the filepaths specified on the command line for ski files and performs the corresponding simulations according to the specified command line options. The function returns an appropriate application exit value.

◆ doInteractive()

int SkirtCommandLineHandler::doInteractive ( )
private

This function conducts an interactive session to construct a simulation and save the result in a ski file. The function returns an appropriate application exit value.

◆ doSimulation()

void SkirtCommandLineHandler::doSimulation ( size_t  index)
private

This function actually performs a single simulation constructed from the ski file at the specified index in the internal list.

◆ doSmileSchema()

int SkirtCommandLineHandler::doSmileSchema ( )
private

This function exports a smile schema. This is an undocumented option.

◆ logErrorToFile()

void SkirtCommandLineHandler::logErrorToFile ( const vector< string > &  message,
string  skipath 
)
private

This function logs a simulation construction error to an appropriate emergency log file with a name and location corresponding to the regular simulation log file.

◆ perform()

int SkirtCommandLineHandler::perform ( )

This function processes the command line arguments and invokes the appropriate high-level functions to perform the actions requested by the user. The function returns an appropriate application exit value.

◆ printHelp()

void SkirtCommandLineHandler::printHelp ( )
private

This function prints a brief help message to the console.


The documentation for this class was generated from the following file: