- #1
TamuKevin
- 2
- 0
Fortran Error "Unexpected data declaration statement"
Hi all, I'm writing a program to perform a linear inversion on a set of magnetic data. I'm fairly new to Fortran, but I have coded Fourier and wavelet transformation programs in it. I'm having a problem when trying to declare my variable types. I'm using the "dimension" command as I have in previous programs to define the size of multiple arrays at once. For some reason when it compiles I get the error "Unexpected data declaration statement." The code is more lengthy than this, so I just copied and pasted the parameter declaration into another file, yet the error still exists. Its as if my compiler does not recognize the dimension command, but if I try to compile a previous program that uses it, it does so fine. Also, even if I don't use the dimension command the compiler still finds errors. I'm sure something simple is wrong, I just cannot seem to find it.
Another odd thing to me is if I define P and D in the parameter statement (as I have done in the past) the compiler treating them as real and not integer.
Thank you for any insight on these problems,
TamuKevin
Hi all, I'm writing a program to perform a linear inversion on a set of magnetic data. I'm fairly new to Fortran, but I have coded Fourier and wavelet transformation programs in it. I'm having a problem when trying to declare my variable types. I'm using the "dimension" command as I have in previous programs to define the size of multiple arrays at once. For some reason when it compiles I get the error "Unexpected data declaration statement." The code is more lengthy than this, so I just copied and pasted the parameter declaration into another file, yet the error still exists. Its as if my compiler does not recognize the dimension command, but if I try to compile a previous program that uses it, it does so fine. Also, even if I don't use the dimension command the compiler still finds errors. I'm sure something simple is wrong, I just cannot seem to find it.
[...~/documents/Assignment2] gfortran A2P1test.f
A2P1test.f:26.72:
real, dimension(0:D-1) :: Inp_Data, T, B_obs
1
Error: Unexpected data declaration statement at (1)
A2P1test.f:27.72:
real, dimension(0:P-1) :: Bx, Bz
1
Error: Unexpected data declaration statement at (1)
A2P1test.f:28.72:
real, dimension(0:D-1,0:P-1) :: A
1
Error: Unexpected data declaration statement at (1)
Code:
*This code will perform a linear inversion to a set of magnetic data
*via the use of 2D prisms
*>>>>>>>>>>>>>>>>>>>>>Declare Variable Definitions<<<<<<<<<<<<<<<<<<
*pi= pi
*u_0= permeability of free space
*D= Number of magnetic data
*P= Number of parameters (prisms)
*T= Total field anomaly
*B_obs= Raw data in absolute intensity form
*Bx= Bx to be used in filling matrix A
*Bz= Bz to be used in filling matrix A
*A= Forward problem matrix with physics
*>>>>>>>>>>>>>>>>>>>>>>>>>Declare Variable Types<<<<<<<<<<<<<<<<<<<<<
parameter(pi=3.141592, u_0=1.25663706e-6)
integer D=251
integer P=25
real, dimension(0:D-1) :: Inp_Data, T, B_obs
real, dimension(0:P-1) :: Bx, Bz
real, dimension(0:D-1,0:P-1):: A
*>>>>>>>>>>>>>>>>>>>>>>>Quantify Various Variables<<<<<<<<<<<<<<<<<<
end
Another odd thing to me is if I define P and D in the parameter statement (as I have done in the past) the compiler treating them as real and not integer.
Code:
A2P1test.f:28.24:
real, dimension(0:D-1,0:P-1) :: A
1
Error: Expression at (1) must be of INTEGER type, found REAL
A2P1test.f:28.30:
real, dimension(0:D-1,0:P-1) :: A
1
Error: Expression at (1) must be of INTEGER type, found REAL
A2P1test.f:28.39:
real, dimension(0:D-1,0:P-1) :: A
1
Error: The module or main program array 'a' at (1) must have constant shape
A2P1test.f:26.24:
real, dimension(0:D-1) :: Inp_Data, T, B_obs
1
Error: Expression at (1) must be of INTEGER type, found REAL
A2P1test.f:26.50:
real, dimension(0:D-1) :: Inp_Data, T, B_obs
1
Error: The module or main program array 'b_obs' at (1) must have constant shape
A2P1test.f:27.24:
real, dimension(0:P-1) :: Bx, Bz
1
Error: Expression at (1) must be of INTEGER type, found REAL
A2P1test.f:27.34:
real, dimension(0:P-1) :: Bx, Bz
1
Error: The module or main program array 'bx' at (1) must have constant shape
A2P1test.f:27.24:
real, dimension(0:P-1) :: Bx, Bz
1
Error: Expression at (1) must be of INTEGER type, found REAL
A2P1test.f:27.38:
real, dimension(0:P-1) :: Bx, Bz
1
Error: The module or main program array 'bz' at (1) must have constant shape
A2P1test.f:26.24:
real, dimension(0:D-1) :: Inp_Data, T, B_obs
1
Error: Expression at (1) must be of INTEGER type, found REAL
A2P1test.f:26.40:
real, dimension(0:D-1) :: Inp_Data, T, B_obs
1
Error: The module or main program array 'inp_data' at (1) must have constant shape
A2P1test.f:26.24:
real, dimension(0:D-1) :: Inp_Data, T, B_obs
1
Error: Expression at (1) must be of INTEGER type, found REAL
A2P1test.f:26.43:
real, dimension(0:D-1) :: Inp_Data, T, B_obs
1
Error: The module or main program array 't' at (1) must have constant shape
Code:
*>>>>>>>>>>>>>>>>>>>>>>>>>Declare Variable Types<<<<<<<<<<<<<<<<<<<<<
parameter(pi=3.141592, u_0=1.25663706e-6, D=251, P=25)
* integer D=251
* integer P=25
real, dimension(0:D-1) :: Inp_Data, T, B_obs
real, dimension(0:P-1) :: Bx, Bz
real, dimension(0:D-1,0:P-1) :: A
Thank you for any insight on these problems,
TamuKevin