Changeset 5470


Ignore:
Timestamp:
Jul 7, 2008, 12:18:29 PM (11 years ago)
Author:
ole
Message:

Added verbose flag to c code

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r5466 r5470  
    48384838NORTH_VELOCITY_MUX2_LABEL =  '-n-mux2'   
    48394839
    4840 def read_mux2_py(filenames,weights):
     4840def read_mux2_py(filenames,weights,verbose=False):
    48414841
    48424842    from Numeric import ones,Float,compress,zeros,arange
     
    48464846
    48474847    file_params=-1*ones(3,Float)#[nsta,dt,nt]
    4848     write=0 #if true write txt files to current directory as well
    4849     data=read_mux2(numSrc,filenames,weights,file_params,write)
     4848   
     4849    # Convert verbose to int C flag
     4850    if verbose:
     4851        verbose=1
     4852    else:
     4853        verbose=0
     4854       
     4855    data=read_mux2(numSrc,filenames,weights,file_params,verbose)
    48504856
    48514857    msg='File parameter values were not read in correctly from c file'
     
    50345040    for i,quantity in enumerate(quantities):
    50355041        # For each quantity read the associated list of source mux2 file with extenstion associated with that quantity
    5036         times, latitudes_urs, longitudes_urs, elevation, mux[quantity],starttime = read_mux2_py(files_in[i],weights)
     5042        times, latitudes_urs, longitudes_urs, elevation, mux[quantity],starttime = read_mux2_py(files_in[i],weights,verbose=verbose)
    50375043        if quantity!=quantities[0]:
    50385044            msg='%s, %s and %s have inconsitent gauge data'%(files_in[0],files_in[1],files_in[2])
  • anuga_core/source/anuga/shallow_water/urs_ext.c

    r5469 r5470  
    2929   
    3030    Python call:
    31     read_mux2(numSrc,filenames,weights,file_params,write)
     31    read_mux2(numSrc,filenames,weights,file_params,verbose)
    3232
    3333    NOTE:
     
    4343  float *weights;
    4444  long numSrc;
    45   long write;
     45  long verbose;
    4646
    4747  float **cdata;
     
    5858  // Convert Python arguments to C
    5959  if (!PyArg_ParseTuple(args, "iOOOi",
    60                         &numSrc,&filenames,&pyweights,&file_params,&write)) {                   
     60                        &numSrc,&filenames,&pyweights,&file_params,&verbose)) {                 
    6161                       
    6262    PyErr_SetString(PyExc_RuntimeError,
     
    117117
    118118  // Read in mux2 data from file
    119   cdata=_read_mux2((int)numSrc,muxFileNameArray,weights,(double*)file_params->data,(int)write);
     119  cdata=_read_mux2((int)numSrc,muxFileNameArray,weights,(double*)file_params->data,(int)verbose);
    120120
    121121
     
    181181  free(weights);
    182182  free(muxFileNameArray);
     183  free(cdata);
    183184  return  PyArray_Return(pydata);
    184185
    185186}
    186187
    187 float** _read_mux2(int numSrc, char **muxFileNameArray, float *weights, double *params, int write)
     188float** _read_mux2(int numSrc, char **muxFileNameArray, float *weights, double *params, int verbose)
    188189{
    189190   FILE *fp;
     
    225226   }   
    226227                     
    227    
    228    /* open the first muxfile */
    229    if((fp=fopen(muxFileNameArray[0],"r"))==NULL)
    230    {
     228   if (verbose){
     229     printf("Reading mux header information\n");
     230   }
     231   
     232   /* Open the first muxfile */
     233   if((fp=fopen(muxFileNameArray[0],"r"))==NULL){
    231234      fprintf(stderr, "cannot open file %s\n", muxFileNameArray[0]);
    232235      exit(-1); 
    233236   }
    234237 
    235    /* read in the header */
    236    /*first read the number of stations*/   
     238   /* Read in the header */
     239   /* First read the number of stations*/   
    237240   fread(&nsta0,sizeof(int),1,fp);
    238241   
     
    364367         exit(-1); 
    365368       }
     369       
     370     if (verbose){
     371       printf("Reading mux file %s\n",muxFileName);
     372     }
    366373
    367374     offset=sizeof(int)+nsta0*(sizeof(struct tgsrwg)+2*sizeof(int));
Note: See TracChangeset for help on using the changeset viewer.