[Info-vax] Text processing examples with Fortran requested
Kier, Mike
mkier at affiniongroup.com
Mon Nov 16 12:50:14 EST 2009
Michael Kraemer M.Kraemer at gsi.de wrote:
>Richard B. Gilbert schrieb:
>
>> It doesn't dynamically allocate anything at all. At least it didn't the
>> last time I used Fortran.
>
>I know, but in text processing it may bite you first.
>
>> Dynamic memory allocation is a "C" thing.
>
>It's not a C only thing.
>
>> IMHO it's a useless hangover on a virtual memory system.
>
>Huh? You need memory allocation just everywhere.
>Just think of avoiding buffer overflows by always
>providing buffers of the right length.
>
>> On machines
>> with small address spaces it can be a life saver. These days PCs
>> support 4GB of RAM and 12 bit or 16 bit machines are mostly antiques.
>
>This only shifts the problem from 640kB to 4GB,
>one never has enough RAM.
>
>> "Pocket" computers may still need to worry about it.
Sigh. Fortran-90 and Fortran-95 compilers have been around for well over a decade.
Fortran does allocate dynamic memory. It also has pointers. Two types, in fact, on DEC Fortran. It picked up modules and operator overloading and variable scoping along the way, too.
It can even allocate up into 64-bit space (without the programmer having to call LIB$ or SYS$ routines, but they are available, too).
And I've even had occasion to use VMS dynamic strings by constructing my own descriptors - just making sure to move the end result into a normal static string before invoking any Fortran I/O or intrinsic functions - but it sure makes using the STR$ routines a lot easier.
We have literally over a thousand Fortran programs running business processing from ETL through database query and update and reporting, both massive batch scenarios run by DECscheduler, and interactive jobs using TDMS or DECForms.
Excerpt from one that I'm currently working on:
!DEC$ Attributes ADDRESS64 :: Rec_Array
Record /DePers_MEMMST_str/ Rec_Array(:)
Target Rec_Array
Allocatable Rec_Array
Record /DePers_MEMMST_str/ Rec
Pointer Rec
.
.
.
! Allocate our array
Allocate (Rec_Array(1:CHUNK_SIZE), Stat=status)
Select Case (status)
Case (SUCCESS); Continue
Case DEFAULT
Write (Unit=ttyout, Fmt=992) status
error_flag = .TRUE.
Exit Main_Loop
End Select
.
.
.
! Point to the current record
Rec => Rec_Array(ii)
--
Mike Kier
More information about the Info-vax
mailing list