0

I am trying to study the Fortran source code of my team. In the process of doing that, I came across the below-mentioned statement, can anyone please explain the meaning of this initialization?

real*8, dimension(:,:),pointer :: fm_sol            !   Z
real*8, dimension(:,:),pointer :: tmp_sol           !   temperature
  • 1
    `real*8` is an 8-byte (64-bit) floating point variable, followed by `dimension(:,:)` which is to say it's a 2-dimensional array with no fixed size, because it is defined as a pointer array, so it will take its dimensions from what it's pointing at. The pointer array just has its rank (`2`) and type (`real*8`) - in a sense, it's best read backwards: a pointer to some 2d array of 64-bit floating point. – Grismar Jan 18 '22 at 04:04
  • @Grismar, thanks for your reply. Here what is this random entity `fm_sol` mean? Is this the place where my pointer is pointing? or is it the place where my pointed information is stored? – Mohammed Niyasdeen Jan 18 '22 at 05:12
  • `fm_sol` would be "the thing doing the pointing" somewhere elsewhere in your code, it'll likely be pointed at a sized array of 64-bit floating point numbers before having operations applied to it. – Grismar Jan 18 '22 at 05:19
  • 3
    There are moments when reading a tutorial or a textbook and this is one of them. Becaause this is not just about the syntax but also about explaining what pointers are. It is a broad topic. I linked a question explaining the pointer attribute for structure component but it almost completely applies. It explains where these things it can point to may be. – Vladimir F Героям слава Jan 18 '22 at 07:24
  • 2
    Please note that in Fortran terms your line is no initialization. It is a declaration. Initialization of a pointer looks differently (e.g., `=> null()`). – Vladimir F Героям слава Jan 18 '22 at 07:28
  • 1
    Note also real*8 is not and has never been standard fortran - see https://stackoverflow.com/questions/838310/fortran-90-kind-parameter . And I very much second Valdimir's suggestion to get a book. – Ian Bush Jan 18 '22 at 08:29

0 Answers0