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.
#2644 (Use of a deprecated statement in flodom.F90) – NEMO

Opened 3 years ago

Closed 3 years ago

#2644 closed Defect (fixed)

Use of a deprecated statement in flodom.F90

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

Description

Context

File OCE/FLO/flodom.F90. In function flo_findmesh there are the following lines:

SUBROUTINE flo_findmesh
[...]
!!---------------------------------------------------------------------
!! Statement function
      REAL(dp) ::   fsline
      REAL(dp) ::   psax, psay, psbx, psby, psx, psy
      fsline( psax, psay, psbx, psby, psx, psy ) = psy  * ( psbx - psax )   &
         &                                       - psx  * ( psby - psay )   &
         &                                       + psax *   psby - psay * psbx
!!---------------------------------------------------------------------
[...]
END SUBROUTINE flo_findmesh

I think is challenging to understand how this lines are possibly working. Moreover since fsline is declared as variable but used as function is giving me a hard time when parsing the code for the mixed precision implementation.

Analysis

The declaration is confusing and introduces unnecessary variables in the scope. As the comment highlights it is a statement function, a feature of fortran 77 already declared obsolete in fortran95 as stated here http://fortranwiki.org/fortran/show/Modernizing+Old+Fortran

Statement Functions

Status: These are single statements each of which defines a function for use within the same program unit. They were declared obsolescent in Fortran 95.

Action: Still standard Fortran so can be left alone, but a better replacement is to define internal functions (or subroutines) where the body is not limited to what can be achieved in a single expression.


Recommendation

I would suggest then to create the proper internal function

SUBROUTINE flo_findmesh
[...]
!!---------------------------------------------------------------------
CONTAINS
FUNCTION fsline(psax, psay, psbx, psby, psx, psy)
    REAL(dp), INTENT(IN) :: psax, psay, psbx, psby, psx, psy
    REAL(dp) :: fsline
    fsline = psy  * ( psbx - psax )   &
       &   - psx  * ( psby - psay )   
       &   + psax *   psby - psay * psbx
END FUNCTION fsline
!!---------------------------------------------------------------------
END SUBROUTINE flo_findmesh

Commit History (2)

ChangesetAuthorTimeChangeLog
15235clem2021-09-08T16:07:36+02:00

trunk: solve ticket #2644

15231clem2021-09-08T09:58:57+02:00

4.0-HEAD: small bug fixes following tickets #2644 #2679 #2688

Change History (4)

comment:1 Changed 3 years ago by clem

I concur. I'll do the changes for 4.0-HEAD (only)

comment:2 Changed 3 years ago by clem

In 15231:

Error: Failed to load processor CommitTicketReference
No macro or processor named 'CommitTicketReference' found

comment:3 Changed 3 years ago by clem

In 15235:

Error: Failed to load processor CommitTicketReference
No macro or processor named 'CommitTicketReference' found

comment:4 Changed 3 years ago by clem

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.