PDA

View Full Version : Potential bugs in PPVAL example



mecej4
12-21-2010, 08:47 AM
A recent "bug report" pertaining to FNL version 5 (see https://forums.roguewave.com/showthread.php?945-Bug-with-PPVAl) prompted me to revisit the question in the context of version 7. The problem is as follows.

The Fortran-90 interface to PPVAL has required arguments BREAK and PPCOEF and optional arguments KORDER and NINTV. When the optional arguments are not provided in a call to PPVAL, one assumes, the values of KORDER and NINTV, needed to forward the arguments to the necessary call(s) to the underlying Fortran-77 routine(s), are obtained (I assume, not having access to the source code!) from the actual shape of the assumed shape array argument PPCOEF.

In the example program given in the FNL-7 manual for PPVAL, NINTV is actually obtained from a previous call to BSCPP, and its value may turn out to be less than what a generous declaration for PPCOEF provided for. In this case, the returned interpolated value can be junk.

To reproduce the test problem, I replaced line-36 of the example program in the manual for PPVAL, changing


X = FLOAT(I-1)/FLOAT(NDATA-1)

to

X = 1.0-FLOAT(I-1)/FLOAT(NDATA-1)

and added a WRITE statement to display the value of NPPCF returned by BSCPP. The first few lines of output are as follows:


NPPCF = 17
X S(X) Error
1.000************ -0.896E+36
0.947 2.443 0.000E+00
0.895 2.189 0.000E+00
0.842 1.955 0.000E+00

As suspected, NPPCF is less than the declared second dimension of PPCOEF (20). The value of S(X) for X = 1.000 is junk.

The bug is reproducible with FNL versions 5, 6 and 7. on Windows and Linux. It would be useful to see in the manual mention of the need to supply the otherwise optional arguments when PPCOEF is sized over the minimum required dimensions.

Two simple work-arounds:
provide the optional arguments explicitly
replace PPCOEF on line-39 by PPCOEF(:,:NPPCF)

godsdog
12-23-2010, 11:41 AM
mecej4
I guess, You should have written PPCOEF(:,:NPPCF)

I fully agree with mecej4. It would be very useful to see a warning in manual about possible trap in using of PPVAL.

mecej4
12-24-2010, 06:57 PM
Correct, thanks. I have edited my post, changing NPPCF+1 to NPPCF.