inslai |
Table of contents
ProcedureINSLAI (Insert at location in an integer array) SUBROUTINE INSLAI ( ELTS, NE, LOC, ARRAY, NA ) AbstractInsert one or more elements into an integer array at the indicated location. Required_ReadingNone. KeywordsARRAY ASSIGNMENT DeclarationsIMPLICIT NONE INTEGER ELTS ( * ) INTEGER NE INTEGER LOC INTEGER ARRAY ( * ) INTEGER NA Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- ELTS I Elements to be inserted. NE I Number of elements to be inserted. LOC I Location of the first inserted element. ARRAY I-O Input/output array. NA I-O Number of elements in the input/output array. Detailed_InputELTS contains one or more elements which are to be inserted into the input array. NE is the number of elements to be inserted. LOC is the location in the array at which the first element of ELTS is to be inserted. LOC must be within the interval [1, NA+1]. To append to ARRAY, set LOC equal to NA+1. ARRAY on input, is the original array. NA on input, is the number of elements in ARRAY. Detailed_OutputARRAY on output, is the original array with the elements of ELT inserted into positions LOC through LOC+NE-1. The original elements in these positions are moved back to make room for the inserted elements. NA on output, is the number of elements in ARRAY. ParametersNone. Exceptions1) The dimension of the array is set equal to zero if its input value is less than one. 2) If LOC is not in the interval [1, NA+1], the error SPICE(INVALIDINDEX) is signaled. 3) If the number of elements to be inserted is less than one, the array is not modified. FilesNone. ParticularsThe elements in positions LOC through LOC+NE-1 are moved back by NE spaces to make room for the new elements, which are then inserted into the vacated spaces. ExamplesLet ELTS(1) = 5 NA = 4 ARRAY(1) = 1 ELTS(2) = 6 ARRAY(2) = 2 ELTS(3) = 7 ARRAY(3) = 3 ARRAY(4) = 4 Then the call CALL INSLAI ( ELTS, 3, 3, ARRAY, NA ) yields the following result: NA = 7 ARRAY(1) = 1 ARRAY(2) = 2 ARRAY(3) = 5 ARRAY(4) = 6 ARRAY(5) = 7 ARRAY(6) = 3 ARRAY(7) = 4 The following calls to INSLAI signal errors. CALL INSLAI ( ELTS, 3, -1, ARRAY, NA ) CALL INSLAI ( ELTS, 3, 6, ARRAY, NA ) CALL INSLAI ( ELTS, 3, 2, ARRAY, -1 ) CALL INSLAI ( ELTS, 3, -1, ARRAY, -1 ) Restrictions1) The array must be large enough to contain both the original and the inserted elements. Literature_ReferencesNone. Author_and_InstitutionJ. Diaz del Rio (ODC Space) H.A. Neilan (JPL) W.L. Taber (JPL) I.M. Underwood (JPL) VersionSPICELIB Version 1.1.0, 13-AUG-2021 (JDR) Added IMPLICIT NONE statement. Edited the header to comply with NAIF standard. SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) Comment section for permuted index source lines was added following the header. SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) (HAN) |
Fri Dec 31 18:36:27 2021