This is part of the HicEst documentation
ALLOCATE: Expand Array or String Dimensions
If memory runs short in running a script, the allocated array or string lengths can be expanded.
⇾Home
⇾Contents
⇾more Programming
⇾ Examples
Bookmarks:
⇾dynamically_increase_string_length
⇾equivalence
⇾increase_array_size
⇾named_substrings
⇾rename_part_of_an_array
⇾reshape_matrix
increase_array_size
to a new size of rows*columns:
bytes_allocated = ALLOCATE( name, columns [, rows])
if rows is omitted, its value is internally set to 1
ALLOCATE can be used to
reshape_matrix
by retaining the value of rows*columns.
This includes the reshape of a vector to a matrix (rows present)
or of a matrix to a vector. (rows not present)
REAL
:: vec(1)
! initially 1 element only
ALLOCATE( vec, 10 )
! increase to 10 elements
ALLOCATE( vec, 2*
LEN
(vec) )
! double the current length
ALLOCATE( vec, 2,
LEN
(vec)/2 )
! reshape vec to a 2 column matrix
ALLOCATE( vec,
LEN
(vec) )
! reshape to a vector
rename_part_of_an_array
ALIAS
( vec, 11, sub_vec, 5 )
! rename vec(11...15) to sub_vec
this has the functionality of
equivalence
in Fortran
the current values of name are retained when ALLOCATE is executed
⇾ len(vec) to get the current length of vec
⇾ Len_trim(vec) to get the length of vec when stripped of trailing zeros
dynamically_increase_string_length
to new_length:
bytes_allocated = ALLOCATE( name, new_length )
CHARACTER
:: txt = 'abc'
! initial length is 3
ALLOCATE(txt, 20)
! txt length increased to 20
ALLOCATE(txt, 2*
LEN
(txt) )
! txt length is doubled
named_substrings
ALIAS
( string, 11, sub_string, 5 )
! rename string(11:15) to sub_string
this has the functionality of
equivalence
in Fortran
the current values of name are retained when ALLOCATE is executed
⇾ len(string) to get the current length of string
⇾ len_trim(string) to get the length of string when stripped of trailing blanks
⇾
Support HicEst
⇾
Impressum
©2000-2019 Georg Petrich, HicEst Instant Prototype Computing. All rights reserved.