Re: Returning a dynamic character array based on input length
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: Returning a dynamic character array based on input length         

Group: comp.lang.fortran · Group Profile
Author: James Parsly
Date: Sep 11, 2008 07:52

Yeah, I've used code called MINOS that works that way. Right at the top it
defines a big
honkin' double precision array and carves it up as needed through
argument association. You have to turn off argument type checking because
it will pass a slice of the big double precision array to a routine and use
it
as integers in the subroutine.

"George McBane" gvsu.edu> wrote in message
news:ga9rr6$75k$2@registered.motzarella.org...
> Richard Maine wrote:
>
>>
>> Yes. Heck, it wasnt too awfully long ago that Fortran had *NO* dynamic
>> allocation of any kind. Dynamic allocation wasn't standard in Fortran
>> until f90. Prior to that, some codes used nonstandard nonportable hacks
>> of various kinds.
>
> I work regularly with a legacy F77 program that has author-written
> DMA. (I'm not the author.)
> The program structure permits a stack sort of allocation.
> At the beginning you allocate one humongous array X, and
> put the array and an integer pointer to the "next available element"
> in common. When you need some more memory, you start loading
> stuff in the next available element, and update the pointer to
> the next place above where you filled. To deallocate, you just set
> the pointer back where it was. You can only free stuff
> from the top of the stack down; no cutting holes in the middle.
> But that's okay for the way this calculation works. To pass a workspace
> array of length 100 to a subroutine, you do
> temp = nextavail
> nextavail = nextavail+100 ! requests allocation
> call checkstorage(nextavail) !checks to make you've not overflowed
> call workroutine(x(temp)) ! passes array address
> nextavail = temp !deallocates
>
> The reason I'm writing this: this simple scheme IS portable.
> I've used it on a dozen architectures with almost as many
> Fortran compilers and it has never caused trouble. So for a limited
> class of needs, there was a portable way to do allocations.
>
> -George <- likes F90 allocations better :-)
no comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Access 97 using ODBC returning SQL server ntext fields dont return the full datamicrosoft.public.sqlserver.odbc ·