From: monir on
Hello;

1) The program works fine and as desired with the following PAUSE
statement in:
........Pause 'In Sub dCpZeros() 103'
Remove or comment out the PAUSE statement, and the program returns
NaN.
Does this make any sense to anyone ??

2) Apart from temporarily suspending the program execution, DOES Pause
do anything else ??

3) Here's an abbreviated sample code:
(F77, g95)
Program main
.....................
call dCpZeros()
.......................
End main

Subroutine dCpZeros()
......................
do i=1, 9
do j=1, 10
do k=1, 30
......................
call polin2(,,,,x)
call polin2(,,,,y)
call polin2(,,,,z)
.....................
pause 'In Sub dCpZeros() 103'
.....................
print*,' x = ', x
print*,' y = ', y
print*,' z = ', z
end do
end do
end do
...................
Return
End subroutine dCpZeros

4) With the above PAUSE statement in, results are correctly printed
as:
......x = -1.0676971
......y = 0.5480553
......z = -3.2033877

5) Remove or comment out the above Pause statement, re-compile & run,
and the results are printed as:
......x = NaN
......y = 0.5480553
......z = -3.2033877

6) Items 4 & 5 above have been repeated many many times. Same
outcome!
Please keep in mind that Pause is the ONLY statement involved here.
With Pause in, the program returns the correct results, and w/o it
returns NaN.

Is there a likely explanation ??

Your comments would be greatly appreciated.

Regards.
Monir
From: glen herrmannsfeldt on
monir <monirg(a)mondenet.com> wrote:

> 1) The program works fine and as desired with the following PAUSE
> statement in:
> .......Pause 'In Sub dCpZeros() 103'
> Remove or comment out the PAUSE statement, and the program returns
> NaN.
> Does this make any sense to anyone ??

> 2) Apart from temporarily suspending the program execution,
> DOES Pause do anything else ??

It seems that might count as an I/O operation, and also
a subroutine call. If things were wrong on the stack, then
side effects could result.

> 3) Here's an abbreviated sample code:
> (F77, g95)
> Program main
> ....................
> call dCpZeros()
> ......................
> End main

> Subroutine dCpZeros()
> .....................
> do i=1, 9
> do j=1, 10
> do k=1, 30
> .....................
> call polin2(,,,,x)

Why so many commas? I see no interfact to polin2 such
as would be required for optional arguments.

> call polin2(,,,,y)
> call polin2(,,,,z)
> ....................
> pause 'In Sub dCpZeros() 103'

(snip)

-- glen
From: Richard Maine on
glen herrmannsfeldt <gah(a)ugcs.caltech.edu> wrote:

> monir <monirg(a)mondenet.com> wrote:
>
> > 1) The program works fine and as desired with the following PAUSE
> > statement in:
> > .......Pause 'In Sub dCpZeros() 103'
> > Remove or comment out the PAUSE statement, and the program returns
> > NaN.
> > Does this make any sense to anyone ??
>
> > 2) Apart from temporarily suspending the program execution,
> > DOES Pause do anything else ??
>
> It seems that might count as an I/O operation, and also
> a subroutine call. If things were wrong on the stack, then
> side effects could result.

Or there is just the general principle that if you have memory-related
problems such as can be caused by exceeding array bounds or by argument
mismatches, then *ANY* change in the code can move memory around in such
a way as to change the symptoms.

> > call polin2(,,,,x)
>
> Why so many commas? I see no interfact to polin2 such
> as would be required for optional arguments.

An interface wouldn't do any good because that is not how you do
optional arguments in standard Fortran. There are no circumstances under
which that is a valid call statement in standard Fortran.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
From: monir on
On Mar 27, 8:43 pm, nos...(a)see.signature (Richard Maine) wrote:
> glen herrmannsfeldt <g...(a)ugcs.caltech.edu> wrote:
> > monir <mon...(a)mondenet.com> wrote:
>

There're no optional arguments in the abbreviated sample code.
Please replace the representative 3 call polin2() with the actual
calls:

Subroutine dCpZeros()
......................
do i=1, 9
do j=1, 10
do k=1, 30
......................
call polin2(a,b,c,d,x)
call polin2(b,c,d,e,y)
call polin2(c,d,e,f,z)
.....................
pause 'In Sub dCpZeros() 103'
.....................
print*,' x = ', x
print*,' y = ', y
print*,' z = ', z
end do
end do
end do
...................
Return
End subroutine dCpZeros

Regards.
Monir
From: steve on
On Mar 27, 6:22 pm, monir <mon...(a)mondenet.com> wrote:
> On Mar 27, 8:43 pm, nos...(a)see.signature (Richard Maine) wrote:
>
> > glen herrmannsfeldt <g...(a)ugcs.caltech.edu> wrote:
> > > monir <mon...(a)mondenet.com> wrote:
>
> There're no optional arguments in the abbreviated sample code.
> Please replace the representative 3 call polin2() with the actual
> calls:
>
> Subroutine dCpZeros()
> .....................
> do i=1, 9
>    do j=1, 10
>       do k=1, 30
> .....................
>           call polin2(a,b,c,d,x)
>           call polin2(b,c,d,e,y)
>           call polin2(c,d,e,f,z)
> ....................
>           pause 'In Sub dCpZeros() 103'
> ....................
>           print*,' x = ', x
>           print*,' y = ', y
>           print*,' z = ', z
>       end do
>    end do
> end do
> ..................
> Return
> End subroutine dCpZeros
>

I think you need to change line 12 in polin2().

--
steve