- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--------------------
Visual fortran 6.6
Windows 2000
Pentium 4
--------------------
I have a question about a common block.
Until Now, I have programmed and compiled fortran programs in the workstation(compacq personal workstation XP 1000).In that I used COMMON like this way.
ROGRAM TEST
IMPLICIT REAL*8 (A-H, O-Z), INTEGER*4 (I-N)
COMMON /INTA/ INA(1000)
COMMON A(1000)
A(1) = 1.0
A(2) = 2.0
INA(1) = 1
INA(2) = 2
CALL HEHE
STOP
END
SUBROUTINE HEHE
IMPLICIT REAL*8 (A-H, O-Z), INTEGER*4 (I-N)
COMMON /INTA/ INA(1)
COMMON A(1)
WRITE(*,*) A(1), A(2)
WRITE(*,*) INA(1), INA(2)
RETURN
END
I declared array as common, COMMON A(1000), COMMON /INTA/ INA(1000) in main program,TEST and COMMON A(1), COMMON /INTA/ INA(1) in the subroutine, HEHE
The result is
1.00000000000000 2.00000000000000
1 2
In visual fortran, there is no error in compile, but error when executed like this
forrtl/
Visual fortran 6.6
Windows 2000
Pentium 4
--------------------
I have a question about a common block.
Until Now, I have programmed and compiled fortran programs in the workstation(compacq personal workstation XP 1000).In that I used COMMON like this way.
ROGRAM TEST
IMPLICIT REAL*8 (A-H, O-Z), INTEGER*4 (I-N)
COMMON /INTA/ INA(1000)
COMMON A(1000)
A(1) = 1.0
A(2) = 2.0
INA(1) = 1
INA(2) = 2
CALL HEHE
STOP
END
SUBROUTINE HEHE
IMPLICIT REAL*8 (A-H, O-Z), INTEGER*4 (I-N)
COMMON /INTA/ INA(1)
COMMON A(1)
WRITE(*,*) A(1), A(2)
WRITE(*,*) INA(1), INA(2)
RETURN
END
I declared array as common, COMMON A(1000), COMMON /INTA/ INA(1000) in main program,TEST and COMMON A(1), COMMON /INTA/ INA(1) in the subroutine, HEHE
The result is
1.00000000000000 2.00000000000000
1 2
In visual fortran, there is no error in compile, but error when executed like this
forrtl/
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
-- continued --
forrtl: severe (161): Program Exception - array bounds exceeded
If COMMON A(1), COMMON /INTA/ INA(1) in the subroutine, HEHE are replaced with COMMON A(1000), COMMON /INTA/ INA(1000) in the subroutine, the same result are given with workstation. But, my program has many this common blocks(COMMON ARRAY(1), initially it declared as COMMON ARRAY(100)). It is time consuming to replace (1) as original array size. And sometimes it is necessary to replace original array size as new array size(larger). In this case, I have to do replacing array size again!! Is there any method? (no need to replace common blocks)
forrtl: severe (161): Program Exception - array bounds exceeded
If COMMON A(1), COMMON /INTA/ INA(1) in the subroutine, HEHE are replaced with COMMON A(1000), COMMON /INTA/ INA(1000) in the subroutine, the same result are given with workstation. But, my program has many this common blocks(COMMON ARRAY(1), initially it declared as COMMON ARRAY(100)). It is time consuming to replace (1) as original array size. And sometimes it is necessary to replace original array size as new array size(larger). In this case, I have to do replacing array size again!! Is there any method? (no need to replace common blocks)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe that the compiler is complaining about the reference to A(2) in your subroutine. The array is declared there as being only 1 element long, and so the index (2) is out-of-range.
I would suggest that you create a fortran 'include' file and place all your common declarations in it, and include the include file in every module that references anything in the common blocks. That way you only need to declare them once (can't get it wrong when you re-declare them since you only declare them once!)
If you need to initialize the contents of common you should use a 'blockdata' module.
I would suggest that you create a fortran 'include' file and place all your common declarations in it, and include the include file in every module that references anything in the common blocks. That way you only need to declare them once (can't get it wrong when you re-declare them since you only declare them once!)
If you need to initialize the contents of common you should use a 'blockdata' module.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page