Ignore:
Timestamp:
04/18/12 15:16:17 (13 years ago)
Author:
Mathieu Morlighem
Message:

Using FetchData to recover Options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/modules/Xy2ll/Xy2ll.cpp

    r11933 r12049  
    1212        int     nx,ny,ncoord;
    1313        int     sgn;
    14 
    1514        Options* options=NULL;
    1615        double   cm=0.,sp=0.;
     
    2524        /*checks on arguments on the matlab side: */
    2625        if (nlhs > NLHS) {
    27                 Xy2llUsage();
    28                 _error_("Xy2ll usage error");
     26                Xy2llUsage(); _error_("Xy2ll usage error");
    2927        }
    3028        if (nrhs < NRHS) {
    31                 Xy2llUsage();
    32                 _error_("Xy2ll usage error");
     29                Xy2llUsage(); _error_("Xy2ll usage error");
    3330        }
    3431
    3532        /*Input datasets: */
    36         if (verbose) printf("Fetching inputs:\n");
    3733        FetchData(&x,&nx,X_IN);
    38         if (verbose)
    39                 if   (nx == 1) printf("  x=%g\n",x[0]);
    40                 else           printf("  x=[%d values]\n",nx);
    41 //      for (i=0; i<nx; i++) printf("  x[%d]=%g\n",i,x[i]);
    4234        FetchData(&y,&ny,Y_IN);
    43         if (verbose)
    44                 if   (ny == 1) printf("  y=%g\n",y[0]);
    45                 else           printf("  y=[%d values]\n",ny);
    46 //      for (i=0; i<ny; i++) printf("  y[%d]=%g\n",i,y[i]);
    4735        FetchData(&sgn,SGN_IN);
    48         if (verbose) printf("  sgn=%d\n",sgn);
     36        FetchData(&options,NRHS,nrhs,prhs);
    4937
    50         if (verbose) printf("Parsing options:\n");
    51         options=new Options(NRHS,nrhs,prhs);
    52         if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
    5338        /*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
    5439        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
     
    6045
    6146        /*some checks*/
    62         if (verbose) printf("Checking inputs:\n");
    63 
    6447        if   (nx != ny) _error_("Must have same number of x[%d] and y[%d] coordinates.",nx,ny);
    6548        else            ncoord=nx;
     
    6851        if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
    6952
    70         lat=(double *)xmalloc(ncoord*sizeof(double));
    71         lon=(double *)xmalloc(ncoord*sizeof(double));
     53        lat=(double*)mxMalloc(ncoord*sizeof(double));
     54        lon=(double*)mxMalloc(ncoord*sizeof(double));
    7255
    7356        /* Run core computations: */
    7457        if (verbose) printf("Calling core:\n");
    7558        if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
    76                 iret=Xy2llx(lat,lon,
    77                                         x,y,ncoord,
    78                                         sgn,cm,sp);
     59                iret=Xy2llx(lat,lon,x,y,ncoord,sgn,cm,sp);
    7960        else
    80                 iret=Xy2llx(lat,lon,
    81                                         x,y,ncoord,
    82                                         sgn);
    83         if (verbose) printf("  iret=%d\n",iret);
     61                iret=Xy2llx(lat,lon,x,y,ncoord,sgn);
    8462
    8563        /*Write data: */
     
    9472}
    9573
    96 void Xy2llUsage(void)
    97 {
     74void Xy2llUsage(void){
    9875        _printf_(true,"Xy2ll - x/y to lat/long coordinate transformation module:\n");
    9976        _printf_(true,"\n");
Note: See TracChangeset for help on using the changeset viewer.