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 a RAM variable from the variable "one" in Input and increment its elements
     *one++;
     
     // Create a RAM variable from the variable three in Input and multiply its contents by 10
     // Create a RAM variable from the variable four in Input and then add the variable "three" to
     // its contents.
     *four+=*three*=10;   // three=30, four=34