/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/plume/plumemain.c

Go to the documentation of this file.
00001 #include "plumevars.h"
00002 #include "plumeinput.h"
00003 #include "plume_local.h"
00004 
00005 #include "glib.h"
00006 #include <utils/utils.h>
00007 #include <sed/sed_sedflux.h>
00008 
00009 static gchar*   in_file    = NULL;
00010 static gchar*   out_file   = NULL;
00011 static gchar*   flood_file = NULL;
00012 static gchar*   data_file  = NULL;
00013 static gboolean version    = FALSE;
00014 static gboolean verbose    = FALSE;
00015 
00016 static GOptionEntry entries[] =
00017 {
00018    { "in-file"    , 'i' , 0 , G_OPTION_ARG_FILENAME , &in_file    , "Initialization file" , "<file>" } ,
00019    { "out-file"   , 'o' , 0 , G_OPTION_ARG_FILENAME , &out_file   , "Output file"         , "<file>" } ,
00020    { "flood-file" , 'f' , 0 , G_OPTION_ARG_FILENAME , &flood_file , "Flood file"          , "<file>" } ,
00021    { "data-file"  , 'd' , 0 , G_OPTION_ARG_FILENAME , &data_file  , "Data file"           , "<file>" } ,
00022    { "verbose"    , 'V' , 0 , G_OPTION_ARG_NONE     , &verbose    , "Be verbose"          , NULL     } ,
00023    { "version"    , 'v' , 0 , G_OPTION_ARG_NONE     , &version    , "Print version number and exit" , NULL     } ,
00024    { NULL }
00025 };
00026 
00027 gint
00028 main(int argc, char *argv[])
00029 {
00030    GError* error = NULL;
00031 
00032  //  g_thread_init( NULL );
00033    eh_init_glib();
00034 
00035    { /* Parse command line options */
00036       GOptionContext* context = g_option_context_new( "Run hypopycnal flow model." );
00037    
00038       g_option_context_add_main_entries( context , entries , NULL );
00039    
00040       if ( !g_option_context_parse( context , &argc , &argv , &error ) )
00041          eh_error( "Error parsing command line arguments: %s" , error->message );
00042    }
00043 
00044    if ( version )
00045    { /* Print version and exit */
00046       eh_fprint_version_info( stdout , "plume" , PLUME_MAJOR_VERSION , PLUME_MINOR_VERSION , PLUME_MICRO_VERSION );
00047       eh_exit( 0 );
00048    }
00049 
00050    if ( !error )
00051    { /* Run the model */
00052       Sed_hydro*      flood_arr = NULL;
00053       Sed_hydro*      r         = NULL;
00054       Plume_param_st* param     = NULL;
00055       double**        deposit   = NULL;
00056       gint            len       = 0;
00057       gint            n_grains  = 0;
00058 
00059       if ( !error ) param     = plume_scan_parameter_file( in_file    , &error );
00060       if ( !error ) flood_arr = sed_hydro_scan           ( flood_file , &error );
00061 
00062       if ( !error )
00063          for ( r=flood_arr ; *r ; r++ )
00064          {
00065             if ( verbose ) sed_hydro_fprint( stderr , *r );
00066 
00067             deposit = plume_wrapper( *r , param , &len , &n_grains );
00068             if ( data_file ) plume_print_data( data_file , deposit , len , n_grains );
00069 
00070             eh_free_2( deposit );
00071          }
00072 
00073       sed_hydro_array_destroy( flood_arr );
00074 
00075       eh_exit_on_error( error , "sakura" );
00076    }
00077 
00078    return EXIT_SUCCESS;
00079 }
00080 

Generated on Fri Jan 4 18:04:15 2008 for sedflux by  doxygen 1.5.2