1
1

Add a thingy to hold some common command line params for many of Open

MPI's executables (e.g., "--universe [universe_name]")

This commit was SVN r1328.
Этот коммит содержится в:
Jeff Squyres 2004-06-16 20:03:05 +00:00
родитель 19ed014922
Коммит 8d30733953
3 изменённых файлов: 125 добавлений и 0 удалений

Просмотреть файл

@ -12,6 +12,7 @@ noinst_LTLIBRARIES = libutil.la
headers = \
argv.h \
cmd_line.h \
common_cmd_line.h \
few.h \
hibit.h \
if.h \
@ -27,6 +28,7 @@ libutil_la_SOURCES = \
$(headers) \
argv.c \
cmd_line.c \
common_cmd_line.c \
few.c \
if.c \
malloc.c \

58
src/util/common_cmd_line.c Обычный файл
Просмотреть файл

@ -0,0 +1,58 @@
/*
* $HEADER
*/
#include "ompi_config.h"
#include "util/common_cmd_line.h"
/*
* Private variables
*/
static bool setup = false;
/*
* The global variable that everyone accesses
*/
ompi_cmd_line_t *ompi_common_cmd_line = NULL;
/*
* Setup the ompi_common_cmd_line variable
*/
int ompi_common_cmd_line_init(int argc, char **argv)
{
if (!setup) {
ompi_common_cmd_line = ompi_cmd_line_create();
/* Setup the options that are allowable */
ompi_cmd_line_make_opt(ompi_common_cmd_line,
'u', "--universe", 1,
"Specify the Open MPI universe");
/* Parse the command line */
ompi_cmd_line_parse(ompi_common_cmd_line, true, argc, argv);
/* Done */
setup = true;
}
return OMPI_SUCCESS;
}
/*
* Free resources associated with the ompi_common_cmd_line variable
*/
int ompi_common_cmd_line_finalize(void)
{
if (setup) {
ompi_cmd_line_free(ompi_common_cmd_line);
setup = false;
}
return OMPI_SUCCESS;
}

65
src/util/common_cmd_line.h Обычный файл
Просмотреть файл

@ -0,0 +1,65 @@
/*
* $HEADER$
*/
/**
* @file
*
* Several command line parameters are common to many/most Open MPI
* executables / commands. This file provides a clearinghouse for
* parsing and holding all these command line options that can be
* retrieved from elsewhere in Open MPI. For example, "--universe
* [name]"
*/
#ifndef OMPI_COMMON_CMD_LINE_H
#define OMPI_COMMON_CMD_LINE_H
#include <util/cmd_line.h>
/**
* Global variable to hold the parsed set of "common" command line
* parameters. This global variable should be treated as a "read
* only" structure -- various entites in Open MPI can read from this
* structure, but should not write to it.
*
* See the interface defined in cmd_line.h for instructions on how to
* access the data in this variable.
*/
extern ompi_cmd_line_t *ompi_common_cmd_line;
/**
* Setup for the command line parameters that are common to all/many
* Open MPI executables (e.g., --universe).
*
* @param argv The argv from main().
* @param argc The argc from main().
*
* @returns OMPI_SUCCESS Always.
*
* This function sets up a ompi_cmd_line_t for all command line
* parameters that are common to a number of Open MPI executables. It
* then parses the argc and argv and puts the results in the gloabl
* ompi_cmd_line_t.
*
* This function is only invoked by the normal startup of an Open MPI
* process; you should not need to invoke it manually. Anyone who
* wants to access the common command line parameters should use the
* global variable ompi_common_cmd_line.
*/
int ompi_common_cmd_line_init(int argc, char **argv);
/**
* Release resources allocated by ompi_common_cmd_line_init().
*
* @returns OMPI_SUCCESS Always.
*
* Self-explanitory; frees the resources associated with the global
* variable ompi_common_cmd_line. This function is invoked by the
* normal shutdown of an Open MPI process; you should not need to
* invoke it manually.
*/
int ompi_common_cmd_line_finalize(void);
#endif /* OMPI_COMMON_CMD_LINE_H */