NcmCfg

NcmCfg — Library configuration and helper functions.

Functions

Types and Values

Description

These functions are used to configure the library, including helper functions related to the library configuration.

Functions

NcmCfgLoggerFunc ()

void
(*NcmCfgLoggerFunc) (const gchar *msg);

ncm_cfg_init ()

void
ncm_cfg_init (void);

Main library configuration function. Must be called before any other function of NumCosmo.

Initializes internal variables and sets all other library number of threads to one.

See also: ncm_cfg_init_full() ncm_cfg_init_full_ptr().


ncm_cfg_init_full_ptr ()

void
ncm_cfg_init_full_ptr (gint *argc,
                       gchar ***argv);

Main library configuration function. Must be called before any other function of NumCosmo.

Initializes internal variables and sets all other library number of threads to one. This function passes the arguments to other libraries, e.g, MPI. If that is not necessary ncm_cfg_init() should be used. This version should be used from C applications passing argc and argv pointers from main.

See also: ncm_cfg_init() ncm_cfg_init_full().

Parameters

argc

a pointer to argc

 

argv

a pointer to argv.

[array length=argc]

ncm_cfg_init_full ()

gchar **
ncm_cfg_init_full (gint argc,
                   gchar **argv);

Main library configuration function. Must be called before any other function of NumCosmo.

Initializes internal variables and sets all other library number of threads to one. This function passes the arguments to other libraries, e.g, MPI. If that is not necessary ncm_cfg_init() should be used. This version is compatible with bindings and can be safely called from other languages.

See also: ncm_cfg_init() ncm_cfg_init_full_ptr().

Parameters

argc

a pointer to argc

 

argv

a pointer to argv.

[array length=argc]

Returns

the possibly modified argv.

[transfer full][array zero-terminated=1]


ncm_cfg_enable_gsl_err_handler ()

void
ncm_cfg_enable_gsl_err_handler (void);

Enables the GSL error handler.


ncm_cfg_register_obj ()

void
ncm_cfg_register_obj (GType obj);

Registers the object obj in the GObject type system.

Parameters

obj

a GType

 

ncm_cfg_mpi_nslaves ()

guint
ncm_cfg_mpi_nslaves (void);

Returns

the total number of available slaves.


ncm_cfg_get_fullpath ()

gchar *
ncm_cfg_get_fullpath (const gchar *filename,
                      ...);

Gets the full path of filename .

Parameters

filename

filename

 

...

a variable number of arguments

 

Returns

the full path of filename .

[transfer full]


ncm_cfg_keyfile_to_arg ()

void
ncm_cfg_keyfile_to_arg (GKeyFile *kfile,
                        const gchar *group_name,
                        GOptionEntry *entries,
                        gchar **argv,
                        gint *argc);

Transforms the entries in a keyfile kfile group group_name into an array of strings representing the command line arguments.

Parameters

kfile

keyfile filename

 

group_name

group name

 

entries

a GOptionEntry

 

argv

an array of strings

 

argc

a pointer to an integer

 

ncm_cfg_entries_to_keyfile ()

void
ncm_cfg_entries_to_keyfile (GKeyFile *kfile,
                            const gchar *group_name,
                            GOptionEntry *entries);

Transforms the entries into a keyfile kfile group group_name .

Parameters

kfile

a GKeyFile

 

group_name

group name

 

entries

a null terminated array of GOptionEntry

 

ncm_cfg_string_to_comment ()

gchar *
ncm_cfg_string_to_comment (const gchar *str);

Transforms str into a comment string.

Parameters

str

a string

 

Returns

a comment string.

[transfer full]


ncm_cfg_get_enum_by_id_name_nick ()

const GEnumValue *
ncm_cfg_get_enum_by_id_name_nick (GType enum_type,
                                  const gchar *id_name_nick);

Gets the enum value from enum_type by id_name_nick .

Parameters

enum_type

enum type GType

 

id_name_nick

id, name or nick

 

Returns

the enum value GEnumValue.

[transfer none]


ncm_cfg_enum_get_value ()

const GEnumValue *
ncm_cfg_enum_get_value (GType enum_type,
                        guint n);

Gets the enum value from enum_type by n .

Parameters

enum_type

enum type GType

 

n

enum value position

 

Returns

the enum value GEnumValue.

[transfer none]


ncm_cfg_enum_print_all ()

void
ncm_cfg_enum_print_all (GType enum_type,
                        const gchar *header);

Prints all enum values from enum_type .

Parameters

enum_type

enum type GType

 

header

header string

 

ncm_cfg_lock_plan_fftw ()

void
ncm_cfg_lock_plan_fftw (void);

Locks the FFTW plan. This is a generic lock for all FFTW plans.


ncm_cfg_unlock_plan_fftw ()

void
ncm_cfg_unlock_plan_fftw (void);

Unlocks the FFTW plan. This is a generic lock for all FFTW plans.


ncm_cfg_load_fftw_wisdom ()

gboolean
ncm_cfg_load_fftw_wisdom (const gchar *filename,
                          ...);

Loads the FFTW wisdom from filename .

Parameters

filename

filename to load the wisdom

 

...

variable number of arguments for filename string

 

Returns

TRUE if the wisdom was loaded.


ncm_cfg_save_fftw_wisdom ()

gboolean
ncm_cfg_save_fftw_wisdom (const gchar *filename,
                          ...);

Saves the current FFTW wisdom to filename .

Parameters

filename

filename to save the wisdom

 

...

variable number of arguments for filename string

 

Returns

TRUE if the wisdom was saved.


ncm_cfg_exists ()

gboolean
ncm_cfg_exists (const gchar *filename,
                ...);

Checks if filename exists in the numcosmo path.

Parameters

filename

filename to search in the numcosmo path.

 

...

a variable number of arguments for filename string.

 

Returns

TRUE if filename exists.


ncm_cfg_set_logfile ()

void
ncm_cfg_set_logfile (gchar *filename);

Sets all log information to filename .

Parameters

filename

name of the log-file

 

ncm_cfg_set_logstream ()

void
ncm_cfg_set_logstream (FILE *stream);

Sets all log information to stream .

Parameters

stream

a stream

 

ncm_cfg_set_log_handler ()

void
ncm_cfg_set_log_handler (NcmCfgLoggerFunc logger);

Sets all log information to stream .

Parameters

logger

a logger function.

[scope notified]

ncm_cfg_set_error_log_handler ()

void
ncm_cfg_set_error_log_handler (NcmCfgLoggerFunc logger);

Sets all log information to stream .

Parameters

logger

a logger function.

[scope notified]

ncm_cfg_set_openmp_nthreads ()

void
ncm_cfg_set_openmp_nthreads (gint n);

Sets OpenMP number of threads to n when available.

Parameters

n

number of threads

 

ncm_cfg_set_openblas_nthreads ()

void
ncm_cfg_set_openblas_nthreads (gint n);

Sets OpenBLAS number of threads to n when available.

Parameters

n

number of threads

 

ncm_cfg_set_blis_nthreads ()

void
ncm_cfg_set_blis_nthreads (gint n);

Sets BLIS number of threads to n when available.

Parameters

n

number of threads

 

ncm_cfg_set_mkl_nthreads ()

void
ncm_cfg_set_mkl_nthreads (gint n);

Sets OpenBLAS number of threads to n when available.

Parameters

n

number of threads

 

ncm_cfg_logfile ()

void
ncm_cfg_logfile (gboolean on);

Enables or disables the log file.

Parameters

on

a gboolean

 

ncm_cfg_logfile_flush ()

void
ncm_cfg_logfile_flush (gboolean on);

Enables or disables the log file flush.

Parameters

on

a gboolean

 

ncm_cfg_logfile_flush_now ()

void
ncm_cfg_logfile_flush_now (void);

Flushes the log file.


ncm_message_str ()

void
ncm_message_str (const gchar *msg);

Logs a message string.

Parameters

msg

a string

 

ncm_message ()

void
ncm_message (const gchar *msg,
             ...);

Logs a message.

Parameters

msg

a string

 

...

a variable number of arguments

 

ncm_string_ww ()

gchar *
ncm_string_ww (const gchar *msg,
               const gchar *first,
               const gchar *rest,
               guint ncols);

Creates a word wrapped string.

Parameters

msg

a string

 

first

a string

 

rest

a string

 

ncols

number of columns

 

Returns

word wraped string msg .

[transfer full]


ncm_message_ww ()

void
ncm_message_ww (const gchar *msg,
                const gchar *first,
                const gchar *rest,
                guint ncols);

Logs a word wrapped message.

Parameters

msg

a string

 

first

a string

 

rest

a string

 

ncols

number of columns

 

ncm_cfg_msg_sepa ()

void
ncm_cfg_msg_sepa (void);

Log a message separator.


ncm_cfg_get_data_filename ()

gchar *
ncm_cfg_get_data_filename (const gchar *filename,
                           gboolean must_exist);

Looks for filename in the data path and returns the full path if found.

Parameters

filename

filename to search in the data path.

 

must_exist

raises an error if filename is not found.

 

Returns

Full path for filename .

[transfer full]


ncm_cfg_get_data_directory ()

gchar *
ncm_cfg_get_data_directory (void);

Gets the data directory path. It first checks the environment variable NCM_CFG_DATA_DIR_ENV, then the package data directory and finally the package source directory. If none of these directories exists, it raises an error.

Returns

Full path for the data directory.

[transfer full]


ncm_cfg_command_line ()

gchar *
ncm_cfg_command_line (gchar *argv[],
                      gint argc);

Converts argv to a single string.

Parameters

argv

array of strings

 

argc

number of strings in argv

 

Returns

a command line string.

[transfer full]


ncm_cfg_array_set_variant ()

void
ncm_cfg_array_set_variant (GArray *a,
                           GVariant *var);

Transfers the data from var to a .

[skip]

Parameters

a

a GArray.

 

var

a variant of array type.

 

ncm_cfg_array_to_variant ()

GVariant *
ncm_cfg_array_to_variant (GArray *a,
                          const GVariantType *etype);

Creates a variant of array type from a .

[skip]

Parameters

a

a GArray.

 

etype

element type.

 

Returns

a variant of array type.

[transfer full]


ncm_cfg_set_fftw_default_flag ()

void
ncm_cfg_set_fftw_default_flag (guint flag,
                               const gdouble timeout);

Sets the default FFTW flag (FFTW_ESTIMATE, FFTW_MEASURE, FFTW_PATIENT, FFTW_EXHAUSTIVE) to be used when building plans. The variable timeout sets the maximum time spended on planners.

Parameters

flag

a FFTW library flag

 

timeout

planner time out in seconds

 

NCM_CHECK_PREPARED()

#define             NCM_CHECK_PREPARED(obj, name)

NCM_FITS_ERROR()

#define             NCM_FITS_ERROR(status)

Types and Values

fftw_default_flags

extern guint fftw_default_flags;

NCM_CFG_DATA_DIR_ENV

#define NCM_CFG_DATA_DIR_ENV "NUMCOSMO_DATA_DIR"

NCM_ZERO_LIMIT

#define NCM_ZERO_LIMIT 1e-13

NCM_DEFAULT_PRECISION

#define NCM_DEFAULT_PRECISION 1e-7

NCM_THREAD_POOL_MAX

#define NCM_THREAD_POOL_MAX 5

mpz_inits

#define mpz_inits ncm_mpz_inits

mpz_clears

#define mpz_clears ncm_mpz_clears