0

I have below code:

program test_random_seed
  implicit none
  real*16:: n , j
  real, Dimension(1,10) :: i

  i = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10]
  
  write(*,101) i
    pause
101 format(F0.5)    
    end program test_random_seed

I got this error message:

error 6366: The shapes of the array expressions do not conform. [I] 

How can I correct it?

7
  • Welcome. Please read How to Ask. You need to explain what is wrong with your code. Are there any error messages? Are the results wrong? Please describe what is the code supposed to do and your problem. Commented Nov 25, 2021 at 14:42
  • BTW, do not use pause, it is a deleted Fortran feature without a clear meaning. If you want to wait for pressing Enter, you can use read *,. Commented Nov 25, 2021 at 14:43
  • error 6366: The shapes of the array expressions do not conform. [I] Commented Nov 25, 2021 at 14:45
  • Use edit to edit important information into the question. Do not use comments. Commented Nov 25, 2021 at 14:46
  • What are you trying to do with this code? You've declared i to be a rank-2 array and assigning to it a rank-1 array. You need these to match - but why have you chosen i to be rank-2 but with extent just 1 in one dimension? Commented Nov 25, 2021 at 14:52

1 Answer 1

2

You are assigning a 1D array literal to 2D 1x10 array.

You can fix it, by slicing the array and assigning to a subarray:

real, Dimension(1,10) :: i

i(1,:) = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10]

Or you can declare the array as a 1D array:

real, Dimension(10) :: i

i = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10]

The solution to choose depends on your ultimate goal.

We have several other questions with the same error message, but a slightly different error that caused it:
Fortran Error # 6366: The shapes of the array expressions do not conform
"Error: The shapes of the array expressions do not conform"

The main issue is the same, the array shapes (number of elements in each dimension and the number of dimensions) must agree.

Sign up to request clarification or add additional context in comments.

3 Comments

Well, I do not know what is the ultimate intention.
Dear Vladimir, do you know what is RANDOM_SEED syntax?
@nimasahakie I do, but this is not the place to write about that. We have many questions and answers that explain it. I would suggest starting with empty call ranom_seed() or with call random_init(.false., .true.) instead. If you have some actual problem, please open a new question and show your code there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.