weird behaviour

Brooks Moses brooks.moses@codesourcery.com
Fri Aug 3 04:00:00 GMT 2007


Éric Depagne wrote:
> That's the way I call the function:
> 
> contrib=LINE(wave,nlo,nup,hlambda,t(k),ne(k),nh1(k),nhe1(k),frac)

How are these variables declared?

> And that's the first lines of the function:
>       FUNCTION LINE(WAVE,NBLO,NBUP,WAVEH,T,XNE,HNORM,H1FRC,HE1FRC,DOPPLE)
> 
>       REAL KAP0,KAP0RED,KAPRED,KAP0BLUE,KAPBLUE
>       REAL*8 WAVEH,WAVE,WCON,EMERGE,WMERGE,WSHIFT,WTAIL
>       REAL*8 BLUECUT,WLBLUE,REDCUT,WLRED,EMERGEH
>       REAL*8 EHYD(100),CONTH(15)
>       REAL*4 DOPPLE
>       REAL*8 VACAIR
>       real pg
>       LOGICAL FIRST
>       SAVE

In general, it's a good idea to put IMPLICIT NONE at the beginning of 
all declaration blocks, to catch undeclared variables.

In particular, NBLO, NBUP, T, XNE, HNORM, H1FRC, and HE1FRC are not 
declared here, and thus will get an implicit type.  My guess is that 
this does not match the type that they have in the caller, and that the 
mismatch is such that the function's location for DOPPLE is off the end 
of the call stack that the caller supplies.

In any case, reducing this to a minimal complete example should enable 
you to find the problem.  (Steve's suggestions for warning options may 
find the problem as well, though I'm not sure of that in this case.)

- Brooks



More information about the Fortran mailing list