Fortran 95 question about dimension error

In summary, Error 542, J is appearing in the dimension of a variable despite not being a dummy argument, a variable available through USE or CONTAINS association, a COMMON variable, a PARAMETER, or a PURE FUNCTION. This same error is also occurring for I. The program is using I and J to point to the temperature in length and time T(i,j) for a numerical solution of the heat diffusion equation using the Crank-Nicolson method. Without a listing, it will be difficult to troubleshoot the program.
  • #1
loukoumas
15
0
error 542, J appears in the dimension of a variable,yet is not a dummy argument,a variable available through USE or CONTAINS association,a COMMON variable,a PARAMETER,or a PURE FUNCTION
the same error about I
i am using i,j in order to point the temperature in length and time T(i,j)
it is a numerical solution for the heat diffusion equation that uses the previous and the next value according to length of temperature and the previous value of temperature according to time( Crank-Nicolson method)
 
Technology news on Phys.org
  • #2
It's going to be hard to troubleshoot your program without a listing.
 

Related to Fortran 95 question about dimension error

1. What is a dimension error in Fortran 95?

A dimension error in Fortran 95 occurs when there is a mismatch in the number of elements in an array or matrix. This can happen when trying to perform operations on arrays with different dimensions, or when trying to access elements outside of the specified dimensions.

2. How do I fix a dimension error in Fortran 95?

To fix a dimension error in Fortran 95, you will need to carefully check your code and make sure that all arrays and matrices are properly defined with the correct dimensions. You may also need to use the RESHAPE function to reshape arrays to match the desired dimensions.

3. Can incorrect data types cause a dimension error in Fortran 95?

Yes, incorrect data types can cause a dimension error in Fortran 95. It is important to make sure that all elements in an array or matrix are of the same data type, as mixing data types can lead to dimension errors.

4. How can I prevent dimension errors in Fortran 95?

To prevent dimension errors in Fortran 95, it is important to carefully plan and define all arrays and matrices before using them in your code. You may also want to use the SIZE function to check the dimensions of your arrays and make sure they are consistent throughout your code.

5. Are there any built-in functions in Fortran 95 that can help with dimension errors?

Yes, there are several built-in functions in Fortran 95 that can help with dimension errors. These include the RESHAPE function, which can reshape arrays to match desired dimensions, and the SIZE function, which can be used to check the dimensions of arrays. Additionally, the TRANSFER function can be used to copy elements from one array to another, even if they have different dimensions.

Similar threads

  • Programming and Computer Science
Replies
4
Views
745
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
5
Views
2K
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
15K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
9
Views
4K
  • Programming and Computer Science
Replies
11
Views
11K
  • Programming and Computer Science
Replies
22
Views
4K
  • Programming and Computer Science
Replies
6
Views
3K
Back
Top