[Info-vax] VMS Software Q1 '23 Update

John Reagan xyzzy1959 at gmail.com
Wed Jan 25 19:48:21 EST 2023


On Wednesday, January 25, 2023 at 6:50:20 PM UTC-5, Arne Vajhøj wrote:
> On 1/25/2023 5:55 PM, John Reagan wrote: 
> > G2L recurses down the symbol table and converts the static variables in each block as it finds 
> > them. The difference is that GEM frontends can record the desired offset into the PSECT in 
> > any order. We sort by offset in each block, but we need to hoist all the static variables out in 
> > another pass, sort them, and do them all at the module level. PSECTs are created by the linker. 
> > They exist outside the control of the compiler. 
> > 
> > Here's a nasty Fortran program where each subroutine initializes and reinitializes parts of the 
> > same common block in a particular order. 
> > 
> > subroutine print_common 
> > common /mypsect/ i1,i2 
> > integer*4 :: i1,i2 
> > write (*,10) i1,i2 
> > 10 format (' ',Z8,' ',Z8) 
> > return 
> > end 
> > 
> > subroutine update_longwords 
> > common /mypsect/ i1,i2 
> > c start with putting hex AAAAAAAA into both longwords 
> > integer*4 :: i1='AAAAAAAA'X,i2='AAAAAAAA'X 
> > return 
> > end 
> > 
> > subroutine update_words 
> > c and update bottom words with BBBB 
> > common /mypsect/ w1,w2,w3,w4 
> > integer*2 :: w1,w2='BBBB'X,w3,w4='BBBB'X 
> > return 
> > end 
> > 
> > subroutine update_bytes 
> > c and update bottom bytes with CC 
> > common /mypsect/ b1,b2,b3,b4,b5,b6,b7,b8 
> > integer*1 :: b1,b2,b3,b4='CC'X,b5,b6,b7,b8='CC'X 
> > return 
> > end 
> > 
> > program main 
> > c by now, the two longwords in the common should be 
> > c CCBBAAAA CCBBAAAA 
> > call print_common 
> > end
> That is horrible code IMHO. 
> 
> Initializing the same common block in multiple subroutines 
> is not something I would ever do. 
> 
> I would expect either an error or undefined result due to 
> order of processing being undefined. 
> 
> But then I don't know what the Fortran standard and the 
> VMS Fortran documentation says on the topic. 
> 
> Someone is actually using such constructs? 
> 
> Arne
Well, I expanded it from a customer program.  In the broken compiler, each subroutine
with the partial/overlay initialization appended the values to the end.  The current
Fortran cross-compiler will create a COMMON block that is several times larger by
mistake.  A future compiler will match the Itanium and Alpha output.

Yes, legal Fortran of the day.  I don't get to pick and choose which programs to support.



More information about the Info-vax mailing list