0
Program Main

Implicit None
Integer, Parameter :: iwp = SELECTED_Real_KIND(15)
Integer, allocatable :: Num(:)

Num(1)=1

......

End Program Main

When I use allocatable to define a void array 'num' and then run the program, it reveals that error as below

(1)"First-chance exception at 0x00B21147 in Index.exe: 0xC0000005: Access violation writing location 0x00000004"

(2)"If there is a handler for this exception, the program may be safely continued"

enter image description here

2
  • Please copy error messages as text so that they are searchable. Commented Mar 3, 2017 at 20:07
  • The array needs to be allocated first. Try to compile with full debugging settings of your compiler. Commented Mar 3, 2017 at 20:10

1 Answer 1

2

Array Num needs to be allocated first. For example

 allocate(Num(1:10))

end then you can use indexes from 1 to 10 for setting values and reading them.

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

Comments

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.