Generic output event

Name

Generic output event -- Writing simulation data

Synopsis


#include <gfs.h>


#define     GFS_OUTPUT_CLASS                (klass)
#define     GFS_OUTPUT                      (obj)
#define     GFS_IS_OUTPUT                   (obj)

struct      GfsOutputClass;
struct      GfsOutput;
struct      GfsOutputFile;

GfsOutputClass* gfs_output_class            (void);
void        gfs_output_mute                 (GfsOutput *output);
void        gfs_output_file_close           (GfsOutputFile *file);
GfsOutputFile* gfs_output_file_open         (const gchar *name,
                                             const gchar *mode);

Description

This generic object is a GfsEvent which also defines where to write the data to output.

The syntax in parameter files is as follows:

[ GfsEvent ] FILE

where FILE is either a string defining the file in which to write the output, or a shell-script enclosed within braces to which the output will be piped. Two file names have special meaning: "stderr" and "stdout" for the standard error and standard output respectively.

If a C-like formatting string appears in the file name, it is interpreted as follows:

%dis replaced with the current processor number.
%ldis replaced with the current time step number.
%fis replaced with the current physical time.

Note that most of the C language format specifiers are recognized (i.e. it is possible to use formatting strings like %05.2f etc...).

If the simulation does not start at time zero the existing files are appended otherwise they are overwritten.

The "pipe" feature of GfsOutput can for example be used to do on-the-flight post-processing of the data stream, as in the following example:

  GfsOutputPPM { istep = 1 } { ppmtoy4m -v 0 -F 24:1 | mpeg2enc -v 0 -o vorticity.mpg } { v = Vorticity }

which will convert the PPM stream generated by GfsOutputPPM directly to MPEG using the MJPEG tools collection.

Details

GFS_OUTPUT_CLASS()

#define     GFS_OUTPUT_CLASS(klass)

klass :


GFS_OUTPUT()

#define     GFS_OUTPUT(obj)

obj :


GFS_IS_OUTPUT()

#define     GFS_IS_OUTPUT(obj)

obj :


struct GfsOutputClass

struct GfsOutputClass {

  GfsEventClass parent_class;
};


struct GfsOutput

struct GfsOutput {

  GfsEvent parent;

  GfsOutputFile * file;
  gchar * format;
  GSList * formats;
  gboolean dynamic, first_call;
};


struct GfsOutputFile

struct GfsOutputFile {

  guint refcount;
  gchar * name;
  FILE * fp;
};


gfs_output_class ()

GfsOutputClass* gfs_output_class            (void);

Returns :


gfs_output_mute ()

void        gfs_output_mute                 (GfsOutput *output);

"Mutes" the output defined by output, the event associated with output still takes place but the output itself is redirected to /dev/null.

output :

a GfsOutput.


gfs_output_file_close ()

void        gfs_output_file_close           (GfsOutputFile *file);

Decreases the reference count of file. If it reaches zero the file corresponding to file is closed and file is freed.

file :

a GfsOutputFile.


gfs_output_file_open ()

GfsOutputFile* gfs_output_file_open         (const gchar *name,
                                             const gchar *mode);

Checks whether name has already been opened. If it has, its reference count is incremented and the corresponding GfsOutputFile is returned. If it has not, it is created and opened for writing.

name :

the name of the file to open.

mode :

the fopen mode.

Returns :

the GfsOutputFile of file name.