pointers - What does => (equals greater than) mean in Fortran? -
i'm looking through old fortran 90 code , have come across => symbol:
var => item it looks it's being used sort of assignment.
searching google "arrow symbol fortran" or "equals greater symbol fortran" gives me no related material.
=> appears in 6 contexts syntactic element in modern fortran, most, not all, related pointers: pointer assignment; pointer initialization; procedure (pointer) declaration; type-bound procedure declaration; association; renaming.  there close connection between of these.  loosely, in many => can viewed providing alternative temporary or permanent means of referencing entity.   in none, however, => acting operator.1
pointer assignment
pointer assignment 1 of traditional appearances of =>, appearing in fortran 90.  used associate pointer target, , explained in another answer.
use association renaming
renaming of entities use associated involves element => , other appearance in fortran 90/95 code.  such use statements like
use mod_a, c=>a use mod_b, : cc => bb following such use statement module entities a , bb known local names c , cc.
pointer initialization
pointer initialization pointer assignment => appears.  pointer initialization defines initial pointer association of pointer.  see in statements such as
real, target :: real, pointer :: b=>a real, pointer :: c=>null() with explicit initializtion, pointer b here associated a , pointer c unassociated.  these 2 forms helpful in modern fortran in in fortran 90 pointer starts life of undefined association status.  here know b , c have defined pointer association status, , can use associated.
for derived type components such syntax gives default initialization.
procedure declaration
much explicit/default initialization data objects => features in defining initial association of procedure pointer.
procedure(proc_interface), pointer :: proc1 => donkey procedure(proc_interface), pointer :: proc2 => null() here, proc1 again associated procedure donkey , can have such things as
call proc1(...) much when proc1 pointer assigned donkey outside declaration statement.  proc2 is, expected, not associated.
as data object components of derived types => can feature in setting initial association of object-bound procedure
type   procedure(proc_interface), pointer :: proc => donkey end type type-bound procedure declaration
conceptually related above use of => in declaring type-bound procedures.
type  contains   procedure :: proc => donkey   generic :: assignment(=) => type_a_eq end type here in type a proc binding name b%proc (for b entity of type a) procedure reference.  also, through type_a_eq, have defined assignment entities of type a on left-hand side.
association
=> appears in couple of association contexts.  associate , select type constructs associate name selector.
associate (a => 1+2)   ... ! in block have entity named end associate and
class(*) b select type (a => b)   type (real)     ... ! non-polymorphic real here end select these associations differ pointers.  a in associate block needn't (and in example above isn't) variable.
[1]  concept of operator precisely defined in fortran language, such in 3.2.4 of fortran 2008 specification.  unlike many other languages, assignment (with =) not operation, statement.  in c-like languages can have (a=b) expression returning result: not case in fortran.  same holds pointer assignment in fortran.  other cases above wholly distinct idea of assignment.  in fortran, = appearing in initialization not same thing assignment.  => cannot viewed having 1 effect.
Comments
Post a Comment