Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

assign value to a variable

Youwei_q_
Beginner
861 Views

Hi

I saw some people using => to assign value to a variable, and I couldn't find how => works, anyone can give me some reference of how => works

Thanks

Youwei

0 Kudos
1 Solution
mecej4
Honored Contributor III
861 Views

That is called "pointer assignment". A variable with POINTER attribute may be initially assigned NULL() or may be left undefined. Before that variable can be used, it should be pointer-assigned or allocated. See https://software.intel.com/en-us/node/525487#AC3C6AB9-78CF-402B-9846-3481CCD786D3 .

View solution in original post

0 Kudos
3 Replies
mecej4
Honored Contributor III
862 Views

That is called "pointer assignment". A variable with POINTER attribute may be initially assigned NULL() or may be left undefined. Before that variable can be used, it should be pointer-assigned or allocated. See https://software.intel.com/en-us/node/525487#AC3C6AB9-78CF-402B-9846-3481CCD786D3 .

0 Kudos
Youwei_q_
Beginner
861 Views

thanks mecej4 for you reply.

0 Kudos
jimdempseyatthecove
Honored Contributor III
861 Views

Additional information that you may find useful in the future.

In C a pointer is thought of as a intptr_t sized value holding the address of something pointed to (with type).

In Fortran this is also the case for a scalar or user defined type. However, Fortran also permits pointers to point to sub-sections of arrays such as a pointer to a row or a column or some otherwise peculiar (to C programmers) subsections of an array such as every 3rd element. In the case of the sub-section, the pointer is a intptr_t sized value holding the address of an array descriptor and not directly to the block of data, primarily because the data is not in a contiguous block.

The reason for me mentioning this is to forewarn you that C and Fortran pointers are not necessarily interchangeable.

Jim Dempsey

0 Kudos
Reply