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.
#2720 (Use of non-standard intrinsic function ISNAN) – NEMO

Opened 3 years ago

Closed 3 years ago

#2720 closed Defect (fixed)

Use of non-standard intrinsic function ISNAN

Reported by: smueller Owned by: smueller
Priority: low Milestone:
Component: env Version: v4.0.*
Severity: minor Keywords: compilation, lib_fortran
Cc:

Description

Context

The compilation of source:/NEMO/releases/r4.0/r4.0.6/src/OCE/stpctl.F90#L173 fails on some architectures.

Analysis

The intrinsic function ISNAN is non-standard and does not seem to be supported by all commonly used Fortran compilers. Instead, recent Fortran standards require the availability of the function ieee_is_nan from the intrinsic module ieee_arithmetic.

Recommendation

An optional wrapper function with the name ISNAN that calls the ieee_is_nan function is proposed to be included in source:/NEMO/releases/r4.0/r4.0-HEAD/src/OCE/lib_fortran.F90,

  • src/OCE/lib_fortran.F90

     
    2121   USE in_out_manager  ! I/O manager 
    2222   USE lib_mpp         ! distributed memory computing 
    2323   USE lbclnk          ! ocean lateral boundary conditions 
     24   USE, INTRINSIC :: ieee_arithmetic 
    2425 
    2526   IMPLICIT NONE 
    2627   PRIVATE 
     
    3435#if defined key_nosignedzero 
    3536   PUBLIC SIGN 
    3637#endif 
     38#if defined key_noisnan 
     39   PUBLIC ISNAN 
     40#endif 
    3741 
    3842   INTERFACE glob_sum 
    3943      MODULE PROCEDURE glob_sum_1d, glob_sum_2d, glob_sum_3d 
     
    485489   END FUNCTION SIGN_ARRAY_3D_B 
    486490#endif 
    487491 
     492#if defined key_noisnan 
     493!$AGRIF_DO_NOT_TREAT 
     494   FUNCTION ISNAN(pa) 
     495       USE, INTRINSIC ::   ieee_arithmetic 
     496       REAL(wp), INTENT(in) ::   pa 
     497       LOGICAL ::   ISNAN 
     498       ISNAN = ieee_is_nan(pa) 
     499   END FUNCTION ISNAN 
     500!$AGRIF_END_DO_NOT_TREAT 
     501#endif 
     502 
    488503   !!====================================================================== 
    489504END MODULE lib_fortran 

and to be made available (if defined) in module stpctl through

  • src/OCE/stpctl.F90

     
    2525   USE lib_mpp         ! distributed memory computing 
    2626   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables 
    2727   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy 
    28  
     28   USE lib_fortran 
    2929   USE netcdf          ! NetCDF library 
    3030   IMPLICIT NONE 
    3131   PRIVATE 

This wrapper function can be activated by defining the pre-processor key key_noisnan in architecture files that configure the compilation using Fortran compilers without support for the ISNAN intrinsic function; it is protected from AGRIF pre-processing to avoid problems from using intrinsic module ieee_arithmetic in AGRIF-processed source code.

Commit History (1)

ChangesetAuthorTimeChangeLog
15371smueller2021-10-14T17:02:36+02:00

Optional replacement of non-standard intrinsic function ISNAN (ticket #2720)

Change History (3)

comment:1 Changed 3 years ago by smueller

In 15371:

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

comment:2 Changed 3 years ago by smueller

  • Owner set to smueller
  • Status changed from new to assigned

comment:3 Changed 3 years ago by smueller

  • Resolution set to fixed
  • Status changed from assigned to closed

source:/NEMO/releases/r4.0/r4.0-HEAD@15371 has passed the standard SETTE tests.

Note: See TracTickets for help on using tickets.