Doxygen Source Code Documentation
nimel.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
Function Documentation
|
\** File : SUMA.c
Input paramters :
Definition at line 3 of file nimel.c. References argc, free, malloc, NI_add_column(), NI_BINARY_MODE, NI_clock_time(), NI_FLOAT, NI_new_data_element(), NI_stream_closenow(), NI_stream_open(), NI_stream_writecheck(), and NI_write_element().
00004 { 00005 int nfl , ii , ct ; 00006 char *sspec ; 00007 NI_element *nel ; 00008 NI_stream ns ; 00009 float *flar ; 00010 00011 if( argc < 3 || strcmp(argv[1],"-help") == 0 ){ 00012 printf("Usage: nimel N streamspec\n") ; exit(0) ; 00013 } 00014 00015 nfl = strtol( argv[1] , NULL , 10) ; 00016 if( nfl < 1 ) nfl = 100000 ; 00017 sspec = argv[2] ; 00018 ns = NI_stream_open( sspec , "w" ) ; 00019 if( ns == NULL ){ 00020 fprintf(stderr,"NI_stream_open fails\n"); exit(1); 00021 } 00022 00023 nel = NI_new_data_element( "Tester" , nfl ) ; 00024 flar = (float *)malloc(sizeof(float)*nfl) ; 00025 for( ii=0 ; ii < nfl ; ii++ ) flar[ii] = (float)ii ; 00026 NI_add_column( nel , NI_FLOAT , flar ) ; 00027 free((void *)flar) ; 00028 00029 while(1){ 00030 ii = NI_stream_writecheck( ns , 666 ) ; 00031 if( ii == 1 ){ fprintf(stderr,"!\n") ; break ; } 00032 if( ii < 0 ){ fprintf(stderr,"BAD writecheck\n"); exit(1); } 00033 fprintf(stderr,".") ; 00034 } 00035 00036 ct = NI_clock_time() ; 00037 NI_write_element( ns , nel , NI_BINARY_MODE ) ; 00038 NI_stream_closenow( ns ) ; 00039 ct = NI_clock_time() - ct ; 00040 fprintf(stderr,"Wrote %d floats in %d ms\n",nfl,ct) ; 00041 exit(0) ; 00042 } |