Next: , Previous: Methods and functions, Up: ncap2 netCDF Arithmetic Processor


4.1.12 RAM variables

RAM variables are used in place of regular variables to speed things up. For example in a loop or where a variable is very frequently referenced. To declare and define a RAM variable simply prefix the variable name with * when the variable is declared/initialized.
To delete a RAM variable (recover some memory) use the ram_delete() method. To convert a RAM variable to a regular disk variable in output use ram_write() method.

The following is valid:

     *temp[$time,$lat,lon]=10.0;     // Cast
     *temp_avg=temp.avg($time);      // Regular assign
     ....
     temp.ram_delete();              // Delete RAM variable
     temp_avg.ram_write();           // Write Variable to output
     

Other Assigns

     // Create and increment a RAM variable from "one" in Input
     *one++;
     // Create RAM variables from the variables three and four in Input.
     // Multiply three by 10 and add it to four.
     *four+=*three*=10; // three=30, four=34