/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/sedutils/getfloor.c

Go to the documentation of this file.
00001 //---
00002 //
00003 // This file is part of sedflux.
00004 //
00005 // sedflux is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // sedflux is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with sedflux; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 //---
00020 
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <unistd.h>
00024 #include <string.h>
00025 #include <glib.h>
00026 #include <utils/utils.h>
00027 #include <sed/sed_sedflux.h>
00028 
00029 int main(int argc,char *argv[])
00030 {
00031    char *rec[] = { "in" , "dx" , "len" , NULL };
00032    FILE *fpout;
00033    char *infile, *outfile;
00034    double *x, *d;
00035    double dx, len;
00036    int i, n;
00037    Eh_args *args;
00038 
00039    args = eh_opts_init(argc,argv);
00040    if ( eh_check_opts( args , rec , NULL , NULL )!=0 )
00041       eh_exit(-1);
00042 
00043    dx      = eh_get_opt_dbl( args , "dx"  , -1   );
00044    len     = eh_get_opt_dbl( args , "len" , -1   );
00045    infile  = eh_get_opt_str( args , "in"  , NULL );
00046    outfile = eh_get_opt_str( args , "out" , NULL );
00047 
00048    if ( !outfile )
00049       fpout = stdout;
00050    else
00051       if ( !(fpout=fopen(outfile,"w")) )
00052          perror(outfile), eh_exit(-1);
00053 
00054    n = (int) (len / dx);
00055 
00056    x = g_new0( double , n );
00057    d = g_new0( double , n );
00058 
00059    for (i=0;i<n;i++)
00060       x[i] = dx*i;
00061 
00062    sed_get_floor_vec(infile,x,n,d,NULL);
00063 
00064    fwrite(d,n,sizeof(double),fpout);
00065 
00066    free(x);
00067    free(d);
00068    g_free(infile);
00069    g_free(outfile);
00070 
00071    return 0;
00072 }
00073 

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