Path: utzoo!attcan!uunet!lll-winken!elroy.jpl.nasa.gov!sdd.hp.com!spool.mu.edu!uwm.edu!bionet!agate!ucbvax!bloom-beacon!mintaka!ogicse!milton!seymour From: seymour@milton.u.washington.edu (Richard Seymour) Newsgroups: comp.lang.fortran Subject: Re: Read dimension Message-ID: <17228@milton.u.washington.edu> Date: 27 Feb 91 01:56:09 GMT References: <61477@eerie.acsu.Buffalo.EDU> Organization: University of Washington, Seattle Lines: 48 In article <61477@eerie.acsu.Buffalo.EDU> xiaofei@acsu.buffalo.edu (Xiaofei Wang) writes: >main program >parameter(m=10,n=5) >real a(m,n) >call subroutine(a,b) >end > ... that he'd rather read in the array dimensions, rather than recompile them. As many others posted, there's no precise standard way, other than dimensioning a monster array in the mainline, and then lying to the subroutine and letting it view part of the original monster as the multi-dimensioned. Thusly: main: real x(1000000) read() i,j call subroutine(x,i,j) end sub: subroutine subroutine(x,i,j) dimension x(i,j) .... end That's very portable. A few people mentioned VAXes, but didn't give the VMS-answer: You CAN create a virtual array on the fly. You call the Create-Virtual-Space system service (SYS$CRETVA), giving it two addresses which define the size you want. It returns two virtual address, the first of which you pass to your subroutine as the starting address (the (1,1) location) of your array. Roughly: common/private/where (i like to make private PSECTs) call make_space(where) end subroutine make_space(where) integer*4 want(2),result(2),access,size external sec$m_wrt integer*4 status,sys$cretva read()i,j size=i*j*4 (4 bytes per real datum) want(1)=%LOC(where) want(2)=want(1)+size (number of bytes to create) access=%loc(sec$m_wrt) (request write-access) status=SYS$CRETVA(want,result,access) call subroutine(%VAL(result(1)),i,j) end subroutine subroutine(a,i,j) dimension a(i,j) .... good luck --dick (reaching for his asbestos bvd's...)