Software Archive
Read-only legacy content
17061 Discussions

Fix "Error 5 error #6591: An automatic object is invalid in a main program" in Fortran

Huynh_T_
Beginner
2,188 Views

My code as below:

      include 'param.h'
      dimension alpha1(mx)
      open(99,file='checking.dat')

and there is an error: Error 5 error #6591: An automatic object is invalid in a main program.[alpha1]

I cannot understand what I can fix it. Can someone help me?

Thank you.

0 Kudos
1 Reply
Kevin_D_Intel
Employee
2,188 Views

I'd guess that MX has a defined value within param.h, however, the compiler did not find param.h to include it hence the error.

If param.h does not reside in the same directory as the source file from which the code snippet you show comes from then you need to assist the compiler in finding param.h with the appropriate compiler option. Refer to here for some guidance.

0 Kudos
Reply