The compiler incorrectly allocates common on the stack when it should allocate it in the data segment. You can force it to allocate the common block in the data segment by using a data statement, but this also causes problems.
As an example, try this program, first as a single file and then split into two files.
program test1
common /fred/ array
integer array(2)
save
array(1)=55
array(2)=66
print *,'Array in main is ',array
call sub1
print *,'Array after call to sub1 is ',array
stop
end
*
subroutine sub1
common /fred/ array
integer array(2)
save
print *,'Array in sub1 is ',array
return
end
The problem keeps S from running under A/UX. Here are tests with A/UX 1.0.1 and A/UX 1.1Beta1:
A/UX 1.0.1
----------
a) Source in same file (f77 foo.f):
Array in main is 55 66
Array in sub1 is 55 66
Array after call to sub1 is 55 66
b) Source in two files (f77 foo.f bar.f):
Array in main is 55 66
Array in sub1 is 55 66
Array after call to sub1 is 55 66
A/UX1.1Beta1
------------
a) Source in same file (f77 foo.f):
Array in main is 55 66
Array in sub1 is 55 66
Array after call to sub1 is 55 66
b) Source in two files (f77 foo.f bar.f):
Array in main is 55 66
Array in sub1 is 0 0
~~~~~~~~~~~~~~~~~~~~~~~
Array after call to sub1 is 55 66
Article Change History:
19 Aug 1994 - Reviewed.
31 Aug 1992 - REVIEWED For technical accuracy
Support Information Services