This chapter discusses how MSG handles exceptions. These can arise in a variety of circumstances:
- Attempts to load grids from files that are missing or corrupt.
- Attempts to interpolate at locations outside the bounds of a grid.
- Attempts to interpolate at locations where grid data are missing (so-called
grid voids <grid-voids>
). - Attempts to interpolate with incomplete specification of photospheric parameters.
- Attempts to interpolate for invalid wavelength and/or angle parameters.
When an exception occurs, how it's signaled depends on the language interface being used.
Using the Python interface, exceptions are signaled using the language's built-in exception handling capabilities. The list of exceptions that can be thrown by each function is provided in the python-interface
chapter.
Using the Fortran interface, exceptions are signaled through the optional procedure argument stat
. If this argument is present, then on return it is set to one of the status code values defined in the Fortran parameters <fortran-params>
section. The value :fSTAT_OK
indicates that no problem was encountered; other values signal an exception. If stat
is not present when an exception occurs, then execution halts with an error message printed to standard output.
Using the C interface, exceptions are signaled through the pointer function argument stat
. If this pointer is non-null, then on return the pointer target *stat
is set to one of the status code values defined in the C enums <c-enums>
section. The value :cSTAT_OK
indicates that no problem was encountered; other values signal an exception. If stat
is null when an exception occurs, then execution halts with an error message printed to standard output.