Error which appears in one program
Author Message
Error which appears in one program

Dear all ;

I use the following subroutine in 2 programs.
in one of the programs it can be compiled without any error and in the
other one it makes a lot of errors.

SUBROUTINE LAGZO(N,X,W)

!       =========================================================
!       Purpose : Compute the zeros of Laguerre polynomial Ln(x)
!                 in the interval [0,], and the corresponding
!                 weighting coefficients for Gauss-Laguerre
!                 integration
!       Input :   n    --- Order of the Laguerre polynomial
!                 X(n) --- Zeros of the Laguerre polynomial
!                 W(n) --- Corresponding weighting coefficients
!       =========================================================

IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(N),W(N)
HN=1.0D0/N
DO 35 NR=1,N
IF (NR.EQ.1) Z=HN
IF (NR.GT.1) Z=X(NR-1)+HN*NR**1.27D0
IT=0
10         IT=IT+1
Z0=Z
P=1.0D0
DO 15 I=1,NR-1
15            P=P*(Z-X(I))
F0=1.0D0
F1=1.0D0-Z
DO 20 K=2,N
PF=((2.0D0*K-1.0D0-Z)*F1-(K-1.0D0)*F0)/K
PD=K/Z*(PF-F1)
F0=F1
20            F1=PF
FD=PF/P
Q=0.0D0
DO 30 I=1,NR-1
WP=1.0D0
DO 25 J=1,NR-1
IF (J.EQ.I) GO TO 25
WP=WP*(Z-X(J))
25            CONTINUE
Q=Q+WP
30         CONTINUE
GD=(PD-Q*FD)/P
Z=Z-FD/GD
IF (IT.LE.40.AND.DABS((Z-Z0)/Z).GT.1.0D-15) GO TO 10
X(NR)=Z
W(NR)=1.0D0/(Z*PD*PD)
35      CONTINUE
RETURN
END
+++++++++++++++++++++++++++++++++++

ifort test.f90
**************************
errors:

fortcom: Error: test.f90, line 23: A specification statement cannot
appear in the executable section.
SUBROUTINE LAGZO(N,X,W)
------^
fortcom: Error: test.f90, line 35: A specification statement cannot
appear in the executable section.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
--------^
fortcom: Error: test.f90, line 36: A specification statement cannot
appear in the executable section.
DIMENSION X(N),W(N)
--------^
fortcom: Error: test.f90, line 37: This name does not have a type, and
must have an explicit type.   [HN]
HN=1.0D0/N
--------^
fortcom: Error: test.f90, line 38: This name does not have a type, and
must have an explicit type.   [NR]
DO 35 NR=1,N
--------------^
fortcom: Error: test.f90, line 38: An INTEGER or REAL data type is
required in this context.   [NR]
DO 35 NR=1,N
--------------^
fortcom: Error: test.f90, line 39: This name does not have a type, and
must have an explicit type.   [Z]
IF (NR.EQ.1) Z=HN
------------------------^
fortcom: Error: test.f90, line 41: This name does not have a type, and
must have an explicit type.   [IT]
IT=0
-----------^
fortcom: Error: test.f90, line 43: This name does not have a type, and
must have an explicit type.   [Z0]
Z0=Z
-----------^
fortcom: Error: test.f90, line 44: This name does not have a type, and
must have an explicit type.   [P]
P=1.0D0
-----------^
fortcom: Error: test.f90, line 47: This name does not have a type, and
must have an explicit type.   [F0]
F0=1.0D0
-----------^
fortcom: Error: test.f90, line 48: This name does not have a type, and
must have an explicit type.   [F1]
F1=1.0D0-Z
-----------^
fortcom: Error: test.f90, line 49: This name does not have a type, and
must have an explicit type.   [K]
DO 20 K=2,N
-----------------^
fortcom: Error: test.f90, line 49: An INTEGER or REAL data type is
required in this context.   [K]
DO 20 K=2,N
-----------------^
fortcom: Error: test.f90, line 50: This name does not have a type, and
must have an explicit type.   [PF]
PF=((2.0D0*K-1.0D0-Z)*F1-(K-1.0D0)*F0)/K
--------------^
fortcom: Error: test.f90, line 51: This name does not have a type, and
must have an explicit type.   [PD]
PD=K/Z*(PF-F1)
--------------^
fortcom: Error: test.f90, line 54: This name does not have a type, and
must have an explicit type.   [FD]
FD=PF/P
-----------^
fortcom: Error: test.f90, line 55: This name does not have a type, and
must have an explicit type.   [Q]
Q=0.0D0
-----------^
fortcom: Error: test.f90, line 57: This name does not have a type, and
must have an explicit type.   [WP]
WP=1.0D0
--------------^
fortcom: Error: test.f90, line 58: This name does not have a type, and
must have an explicit type.   [J]
DO 25 J=1,NR-1
--------------------^
fortcom: Error: test.f90, line 58: An INTEGER or REAL data type is
required in this context.   [J]
DO 25 J=1,NR-1
--------------------^
fortcom: Error: test.f90, line 64: This name does not have a type, and
must have an explicit type.   [GD]
GD=(PD-Q*FD)/P
-----------^
fortcom: Warning: test.f90, line 66: This argument's data type is
incompatible with this intrinsic procedure; procedure assumed
EXTERNAL.   [DABS]
IF (IT.LE.40.AND.DABS((Z-Z0)/Z).GT.1.0D-15) GO TO 10
---------------------------------------^
fortcom: Error: test.f90, line 66: This name does not have a type, and
must have an explicit type.   [DABS]
IF (IT.LE.40.AND.DABS((Z-Z0)/Z).GT.1.0D-15) GO TO 10
----------------------------^
fortcom: Error: test.f90, line 70: A RETURN statement is invalid in
the main program.
RETURN
--------^
fortcom: Error: test.f90, line 83: This name does not have a type, and
must have an explicit type.   [BESJ0]
func=(besj0(x)*besj1(x))/(x*2*exp(-x))
---------------^
fortcom: Error: test.f90, line 83: This name does not have a type, and
must have an explicit type.   [BESJ1]
func=(besj0(x)*besj1(x))/(x*2*exp(-x))
------------------------^
compilation aborted for test.f90 (code 1)

Is there anyone can explain the reason for me?

Fatemeh

Sun, 04 Sep 2011 17:49:29 GMT
Error which appears in one program
Hello,
its hard to guess from your question what you are doing.
Are you including the subroutine within another one?

It seems to me that you need a much more structured way to learn fortran
and programming, at the moment it looks like trial and (mainly) error.

Alois

Sun, 04 Sep 2011 18:00:49 GMT
Error which appears in one program

Quote:
> Hello,
> its hard to guess from your question what you are doing.
> Are you including the subroutine within another one?

> It seems to me that you need a much more structured way to learn Fortran
> and programming, at the moment it looks like trial and (mainly) error.

> Alois

I write a simple program and after that I put the mentioned
subroutine. I don't have any problem in compiling.
again I write another program and put the subroutine at the end.  but
now the compiler cannot recognize the type of variables in the
subroutine.
I think the problem comes from the first lines of subroutine :
IMPLICIT DOUBLE PRECISION (A-H,O-Z)

but I cannot guess that what happened that I see the errors only in
one program?

Sun, 04 Sep 2011 18:24:29 GMT
Error which appears in one program

[snip]

Quote:

> ifort test.f90
> **************************
> errors:

> fortcom: Error: test.f90, line 23: A specification statement cannot
> appear in the executable section.
>       SUBROUTINE LAGZO(N,X,W)
> ------^
> fortcom: Error: test.f90, line 35: A specification statement cannot
> appear in the executable section.
>         IMPLICIT DOUBLE PRECISION (A-H,O-Z)
> --------^

[snip]

Do you have a forgotten or misplaced "end" statement ?

Sun, 04 Sep 2011 18:52:44 GMT
Error which appears in one program

Quote:

> [snip]

> > ifort test.f90
> > **************************
> > errors:

> > fortcom: Error: test.f90, line 23: A specification statement cannot
> > appear in the executable section.
> >       SUBROUTINE LAGZO(N,X,W)
> > ------^
> > fortcom: Error: test.f90, line 35: A specification statement cannot
> > appear in the executable section.
> >         IMPLICIT DOUBLE PRECISION (A-H,O-Z)
> > --------^

> [snip]

> Do you have a forgotten or misplaced "end" statement ?

yes. I had missed the "end" which caused the error.
Thanks

Sun, 04 Sep 2011 19:04:17 GMT
Error which appears in one program

Quote:

> > Hello,
> > its hard to guess from your question what you are doing.
> > Are you including the subroutine within another one?

> > It seems to me that you need a much more structured way to learn Fortran
> > and programming, at the moment it looks like trial and (mainly) error.

> > Alois

> I write a simple program and after that I put the mentioned
> subroutine. I don't have any problem in compiling.

Are you certain that you really want to integrate this function?

func=(besj0(x)*besj1(x))/(x*2*exp(-x))

Note the exp(-x) term in the *denominator*.

1. I thought Gauss-Laguerre integration was designed to deal with
functions of the form

Integral [0,inf) f(x) exp(-x) dx

2. In the original form, f(x) = g(x) * exp(x). This grows (in absolute
value) without bound AND it oscillates.

3. besj0(x)*besj1(x)/(2*x) is well behaved, except for a singularity
at zero which can be dealt with.

4. besj0(x)*besj1(x)/(2*x) * exp(-x) is also well behaved. In fact it
decays even more rapidly towards zero than the last expression.

--- e

Mon, 05 Sep 2011 03:11:30 GMT
Error which appears in one program

Quote:

> > > It seems to me that you need a much more structured way to learn Fortran
> > > and programming, at the moment it looks like trial and (mainly) error.
> Are you certain that you really want to integrate this function?

> ?func=(besj0(x)*besj1(x))/(x*2*exp(-x))

> Note the exp(-x) term in the *denominator*.

This makes even *less* sense. Usually when doing Gauss-Laguerre
integration, you are integrating a function

f(x) = g(x) * exp(-x)

The approximation is sum of w[i] * g(x[i]). Note that the factor exp(-
x) is removed from f(x).

If you are dividing by exp(-x) to compensate for the implied
multiplication by exp(-x), then you are really integrating

besj0(x)*besj1(x)/(x*2). If so, then you can use a normal numerical
integration technique, integrating from epsilon to some_finite_number.

--- e

Mon, 05 Sep 2011 04:19:16 GMT

 Page 1 of 1 [ 7 post ]

Relevant Pages