Ignore:
Timestamp:
Jul 6, 2009, 8:53:19 AM (15 years ago)
Author:
dkearney
Message:

another possible example for accessing input data

Location:
trunk/examples/objects/app-fermi
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/examples/objects/app-fermi/fermi1.cc

    r1541 r1542  
    3232    double f          = 0.0;
    3333
    34     int err           = 0;
    35 
    3634    // create a rappture library from the file filePath
    3735    lib = new Rappture::Library(argv[1]);
     
    4341    }
    4442
     43    lib.value("temperature", &T, "units=K")
     44    lib.value("Ef", &Ef, "units=eV");
    4545
    46     /* Alternative ways to access data
    47 
    48     //////////////////////////////
    49     lib.get("input.number(temperature)").value("K",&T)
    50     lib.get("input.number(Ef)").value("eV",&Ef);
    51     //////////////////////////////
    52 
    53     //////////////////////////////
    54     Rappture::Number *rpT = NULL;
    55     Rappture::Number *rpEf = NULL;
    56     rpT = (Rappture::Number *) lib.get("input.number(temperature)");
    57     rpEf = (Rappture::Number *) lib.get("input.number(Ef)");
    58 
    59     T = rpT->value("K");
    60     Ef = rpEf->value("Ef");
    61     //////////////////////////////
    62 
    63     //////////////////////////////
    64     T = lib.value("input.number(temperature)","units=K")
    65     Ef = lib.value("input.number(Ef)","units=eV");
    66     //////////////////////////////
    67     */
    68 
    69     int err = 0;
    70     err = lib.value("input.number(temperature)", &T, "units=K")
    71     err = lib.value("input.number(Ef)", &Ef, "units=eV");
     46    if (lib.error() != 0) {
     47        // there were errors while retrieving input data values
     48        // dump the tracepack
     49        fprintf(stderr, lib.traceback());
     50        exit(lib.error());
     51    }
    7252
    7353    kT = 8.61734e-5 * T;
Note: See TracChangeset for help on using the changeset viewer.