C+ C NAME: C SplineGridX C PURPOSE: C Interpolation of 2D arrays in horizontal direction. C CATEGORY: C Interpolation using natural spline C CALLING SEQUENCE: subroutine SplineGridX(iFlag,XN1,XN2,XM1,XM2,NX,NY,ZN,MX,ZM) C INPUTS: C iFlag integer 1st bit set: flag bad point in output ZM if C nearest grid point in input ZN is bad. C C 2nd bit set: if the range [XM1,XM2] extends C outside [XN1,XN2] then x-coordinates outside C [XN1,XN2] are mapped back inside C by a mod (XN2-XN1) operation. C C XN1 real x-coordinate of 1st column of input ZN C XN2 real x-coordinate of last column of input ZN C XM1 real x-coordinate of 1st column of output ZM C XM2 real x-coordinate of last column of output ZM C NX integer horizontal dimensions of ZN C NY integer vertical dimensions of ZN C ZN(NX,NY) real fnc-values C MX integer new horizontal dimension C OUTPUTS: C ZM(MX,NY) real interpolated fnc-values C CALLS: C ArrR4Step, Say, SplineX C RESTRICTIONS: C The in- and output user-coordinate ranges must be non-zero C PROCEDURE: C > 1st bit of iFlag is set: for each grid point of the output grid the C nearest grid point of the output grid is determined. If this nearest C point was flagged (contained value BadR4()) then the value of the C output grid is also flagged. C !! `Nearest' means the nearest grid point in the C horizontal direction only (along a single row); C > For each row in ZN a spline is calculated, using all valid fnc-values C in that row. The ordinate for the spline is assumed to run from C XN1 to XN2. The spline is then used to interpolate fnc-values in C evenly spaced ordinate values between XM1 and XM2. C > If the row dimension is not changed, SplineGridX and has the effect of C filling in the invalid function values (if 1st bit of iFlag is set) C MODIFICATION HISTORY: C JUL-1993, Paul Hick (UCSD/CASS) C APR-1994, Paul Hick (UCSD/CASS) C added argument bFlag to control flagging of function values in the output array C MAY-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C added arguments MX and ZM to allow changes in horizontal dimension C Note that the old functionality is retained by setting MX=NX, ZM=ZN C Changed logical argument bFlag to integer argument iFlag. The original bFlag C functionality is now controlled by the first bit in iFlag. The second bit C is now used to contol the mod( XN2-XN1) ) behavior. C- integer iFlag real XN1 real XN2 real XM1 real XM2 integer NX integer NY real ZN(NX,NY) ! Input data array integer MX real ZM(MX,NY) ! Output data array character cSay*11 /'SplineGridX'/ parameter (NMAX = 1000) real XN(NMAX) real XM(NMAX) if (max(NX,MX) .gt. NMAX) call Say(cSay,'E','Not enough','scratch space. Increase parameter NMAX') call ArrR4Step(XN1,(XN2-XN1)/(NX-1),NX,XN) ! Input X-coordinates call ArrR4Step(XM1,(XM2-XM1)/(MX-1),MX,XM) ! Output X-coordinates call SplineX(iFlag,NX,XN,MX,XM,NY,ZN,ZM) return end