To access a previously defined and loaded method the following code is used, usually called from the subroutine NEW_READ,
* Local Variables: INTEGER ARGS(2) ! Function arguments INTEGER OARG ! Return value * Fill in the arguments CALL ADI_NEW0( 'Image', ARGS(1), STATUS ) ARGS(2) = FILE_ID OARG = ADI__NULLID * Invoke the function CALL ADI_FEXEC( 'NewRead', 2, ARGS, OARG, STATUS )
The call to ADI_NEW0 creates a new pointer to an object of type Image, the value of which is stored as the first arguement. The pointer to the file to be accessed is assinged as the second argument (here we assume from a HDS file, which implies the ADI type will be HDSfile.
The previously defined methods are now searched for a fuction which matches the types Image and HDSfile, and as can be seen from above this corresponds to the function NEW1_IMREAD. The subroutine is of the form,
SUBROUTINE NEW1_IMREAD( NARG, ARGS, OARG, STATUS ) ... * Arguments Given: INTEGER NARG, ARGS(*) * Arguments Returned: INTEGER OARG * Status: INTEGER STATUS ! Global status ... DATA_ID = ARGS(1) FILE_ID = ARGS(2) ... c read the information into the data identifier ... CALL ADI_NEWV0I( NELM, OARG, STATUS ) END
Here the return argument is made to point at an integer which holds the number of data points read in. This information can be extracted up return using the following piece of code,
CALL ADI_GET0I( OARG, NELM, STATUS )