REAL SCAFAC( 10 ) : : : CALL PAR_GDRVR( 'SCALE', 10, 0.0, 2.0, .FALSE., SCAFAC, : NVAL, STATUS )
This time up to ten values may be obtained from parameter SCALE, and stored in the array SCAFAC. All the values must lie in the range 0.0-2.0. Since the number of values is not fixed, there is no dynamic-default argument. PAR_DEF1x can be called prior to PAR_GDRVx, if desired.
If you want an exact number of values, there is a routine to do this for you. For example, suppose that you want red, green, and blue intensities to define a colour, then the following code would obtain exactly three normalised intensities - one for each colour - between zero and one.
* Get an RGB colour. The default is yellow. DEFAUL( 1 ) = 1.0 DEFAUL( 2 ) = 1.0 DEFAUL( 3 ) = 0.0 CALL PAR_GDR1R( 'RGB', 3, DEFAUL, 0.0, 1.0, .FALSE., RGB, STATUS )
The default must be an array. Should you not want a dynamic default in this case, just set the first element of DEFAUL to be negative or greater than one.
From the user's perspective, instructions will be given if additional values are required.
RGB - Red, green, and blue intensities /[1.0,1.0,0.0]/ > 1.0,0,0,0.5 !! SUBPAR: No more than 3 elements are allowed for parameter RGB. RGB - Red, green, and blue intensities /[1.0,1.0,0.0]/ > 1.0,0.0 !! 1 more value is still needed. RGB - Red, green, and blue intensities /[1.0,1.0,0.0]/ > 1.0,0.0,0.0 !! SUBPAR: No more than 1 element is allowed for parameter RGB. RGB - Red, green, and blue intensities /[1.0,1.0,0.0]/ > 0.0
First the user gives too many values, and is told how many to give. Next too few are supplied, so PAR_GDR1R asks for another. Again the user is not paying attention and gives the whole RGB value instead of just the outstanding blue intensity. Finally, the user gives the last value, yielding an RGB of 1.0,0.0,0.0 or the colour red.
Another variation of the theme is when you want to have an exact number of values, and each value is constrained to its own range. For instance, suppose that you wanted to obtain the two-dimensional co-ordinates of a point within a rectangle, whose bounds are known. The following code could obtain the required values, where LBND and UBND define the lower and upper co-ordinates of the rectangle.
DOUBLE PRECISION DEFAUL( 2 ), POS( 2 ) DOUBLE PRECISION LBND( 2 ), UBND( 2 ) : : : * Set the limits of the area in which the point must lie. LBND( 1 ) = 0.0D0 UBND( 1 ) = 50.0D0 LBND( 2 ) = -20.0D0 UBND( 2 ) = 10.0D0 * Get the co-ordinates of the point within the rectangle. There * is no dynamic default because the default violates the range * constraint. DEFAUL( 1 ) = -1.0D0 CALL PAR_GRM1D( 'POSITION', 2, DEFAUL, LBND, UBND, : .FALSE., POS, STATUS )
PAR_GRM1x will inform the user of any value(s) that violate a range,
and prompts for new values. The name is derived from Get with
Ranges for Multiple dimensions.
If you want to constrain each value of an array to its own range, but do not require an exact number of values, there is even a PAR routine to do that. PAR_GRMVx returns up to some maximum number of values of values, each within a defined range. In the following example an application needs integer compression factors (COMPRS) along each of NDIM dimensions. These must be positive and no greater than the size of the array along each dimension, and are set by the CMPMIN and CMPMAX arrays. ACTVAL returns the actual number values obtained from parameter COMPRESS, and in this example, it is used to set no compression for the higher dimensions.
* Set the acceptable range of values from no compression to compress * to a single element in a dimension. DO I = 1, NDIM CMPMIN( I ) = 1 CMPMAX( I ) = DIMS( I ) END DO * Get the compression factors. CALL PAR_GRMVI( 'COMPRESS', NDIM, CMPMIN, CMPMAX, COMPRS, ACTVAL, : STATUS ) * Should less values be supplied than the number of dimensions, do * not compress the higher dimensions. IF ( ACTVAL .LT. NDIM ) THEN DO I = ACTVAL + 1, NDIM COMPRS( I ) = 1 END DO END IF
PAR Interface to the ADAM Parameter System