Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We could restrict the function so that it only accepts fieldset dataparameters:

Code Block
languagepy
 function wind_speed(u:fieldset, v:fieldset)

This can be useful in some cases, but here for this particular example the functionality is so general that it will work with fieldsets, geopoints, numbers and vectors - so we can leave this restriction out. See the supplied Syntax Sheet for more examples of how to define functions.

...

Now split the macro into file separate files: the wind_speed macro should have the function definition, and the call_wind_speed macro should read the GRIB data, call the function and plot the data (it should not work now, because it cannot find the function).

...

Inclusion does not require the included macro to be a self contained program or function , - any partial fragment of code can be included, for example some variable declarations.

Warning
An include statement is interpreted before the rest of the macro is executed, including lines that precede the include statement. This means that you cannot, for instance, use a dynamically generated path to find the file to be included.

...