New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
#2647 (Derived data type component name shadowing FORTRAN keyword #mixedprecision) – NEMO

Opened 3 years ago

Last modified 2 years ago

#2647 assigned Request

Derived data type component name shadowing FORTRAN keyword #mixedprecision

Reported by: sparonuz Owned by: systeam
Priority: low Milestone:
Component: ICB Version: trunk
Severity: minor Keywords:
Cc:

Description

Context

In file OCE/ICB/icblbc.f90 is declared the following

   TYPE, PUBLIC :: buffer
      INTEGER :: size = 0
      REAL(wp), DIMENSION(:,:), POINTER ::   data
   END TYPE buffer

Both components have a name that shadows an intrinsic statement.
Specifically

Analysis

Even if the compiler does not complain, it is not a good practice and a possible source of error or confusion. It is also a source of disturbance during the parsing part of the mixed precision implementation's workflow.
Even though the second is a Fortran 77 statement, and in some usage is obsolescent, as explained on page 140 of Modern Fortran Explained (Metcalf, Cohen & Reid) in some cases is still needed:

We recommend using the type declaration statement rather than the data statement, but the data statement must be employed when only part of a variable is to be initialised.


(I mentioned this because the authors are members of the WG5, which is responsible for the development of Fortran)

Recommendation

I would rather change the data type to

   TYPE, PUBLIC :: buffer
      INTEGER :: buffer_size = 0
      REAL(wp), DIMENSION(:,:), POINTER ::   buffer_data
   END TYPE buffer

And coherently in the whole file icblbc.f90 (it is the only file where this DS is used).

Commit History (0)

(No commits)

Change History (1)

comment:1 Changed 2 years ago by nemo

  • Owner set to systeam
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.