What is the cause of these error- symbol 'x1' has no implicit type?

Click For Summary
SUMMARY

The error "symbol 'x1' has no implicit type" in Fortran occurs when variables are used without proper declaration in the scope where they are referenced. In this discussion, users identified that the variables x1, t1, c, and x2 were declared within the subroutine but not in the main program or other subroutines. This oversight leads to compilation errors. The solution involves ensuring that all variables are declared consistently across the main program and subroutines to avoid implicit type issues.

PREREQUISITES
  • Understanding of Fortran variable declaration and scope
  • Familiarity with subroutine and main program structure in Fortran
  • Basic knowledge of compilation errors and debugging techniques
  • Experience with Fortran compilers and their error messages
NEXT STEPS
  • Review Fortran variable scope and declaration rules
  • Learn about the implications of implicit typing in Fortran
  • Explore debugging techniques for Fortran compilation errors
  • Study best practices for structuring Fortran programs with subroutines
USEFUL FOR

This discussion is beneficial for beginner and intermediate Fortran programmers, software developers working with scientific computing, and anyone troubleshooting compilation errors in Fortran code.

s_hy
Messages
57
Reaction score
0
Hi all,

i am beginner in fortran and linux. I have wrote codes for 1d scalar wave as below:

SUBROUTINE fd1d (x_num,x1,x2,t_num,t1,t2,c,u_x1,u_x2,u_t1,ut_t1,u)
implicit none
integer (kind=2) t_num,x_num,t,x
real (kind=4) alpha,c,t_delta,t1,t2,u(t_num+1,x_num+1),ut(x_num+1),x_delta,x1,x2
t_delta = (t2-t1)/real(t_num,kind=4)
x_delta = (x2-x1)/real(x_num,kind=4)
alpha = c*t_delta/x_delta
write ( *,'(a)')''
write ( *,'a,g14.6)') 'Stability condition ALPHA = C * DT/DX = ',alpha
Open (103, FILE='parameters.DAT',status='old')
Open(90, File = "abc.dat", ACCESS = 'APPEND')

!the boundary conditions
call u_x1 ( t_num,x_num,u )
call u_x2 ( t_num,x_num,u )

!the initial data
call u_t1 ( t_num,x_num,u )
call ut_t1( x_num,ut )

t=1
do x=2, x_num
u(t+1,x) = alpha**2 * u(t,x+1) / 2.0D+00 + ( 1.0D+00-alpha**2 ) * u(t,x) &
+ alpha**2 * u(t,x-1) / 2.0D+00 + t_delta * ut(x)
end do

!All subsequent steps in time rely on two previous rows of solution data

do t=2, t_num
do x=2, x_num
u(t+1,x) = alpha**2 * u(t, x+1) + 2.0D+00 * (1.0D+00-alpha**2) * u(t, x) &
+ alpha**2 * u(t, x-1) - u(t-1,x)
end do
end do
return
end SUBROUTINE fd1d


when i am trying to compile, there are errors referring to all parameters which is "symbol 'x1' (and t1, c, x2...) has no implicit type. What is that mean?
 
Technology news on Phys.org
The variables that you list (x1, t1, c, and x2) are declared in the subroutine you showed, so my guess is that the error arises in some other part of your program, a part you didn't show us. Are these variables being used elsewhere in your program? If so, they probably aren't being declared in those places.

What we aren't seeing is the main program and the four subroutines that are called in the code above, plus whatever else makes up the entire program.

The compiler or linker probably gave more information than you showed, such as the line number at which the error occurred. That information can help you narrow down the source of the problem.
 
thank you for ur time mark44. the list of subroutines that i didn't list here are quite long, might be bothering. I have found out the problem and finally have succeed to compile it without any error.

thanks again
 
Hi guys,

Mark44 said:
The variables that you list (x1, t1, c, and x2) are declared in the subroutine you showed, so my guess is that the error arises in some other part of your program, a part you didn't show us.

The variables were re declared in the subroutine after being passed from the main program.

s_hy, see what happens when you change types between the main and the subroutine for future reference.

The windows wobble bug was similar and caused approx 60,000 programs to have errors when run in win 2000 (NT). The win com/com+ model created an extra thread on early dual processor systems that ran out after 8 ocurrences of a subroutine type change error.
 
Last edited:

Similar threads

  • · Replies 9 ·
Replies
9
Views
9K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
6K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
3
Views
2K
  • · Replies 75 ·
3
Replies
75
Views
7K