Skip to content

WIP: Changes needed for NAG Compiler#240

Draft
mathomp4 wants to merge 13 commits into
mainfrom
feature/mathomp4/nag-fixes
Draft

WIP: Changes needed for NAG Compiler#240
mathomp4 wants to merge 13 commits into
mainfrom
feature/mathomp4/nag-fixes

Conversation

@mathomp4
Copy link
Copy Markdown
Member

@mathomp4 mathomp4 commented Feb 3, 2022

This PR tracks changes needed to compile GMAO_Shared with the NAG Compiler. NAG is very strict and will not allow the use of Fortran extensions that are endemic to GEOS.


The first category are procedures that are now part of the Fortran Standard that used to be extensions in some compilers:

  • iargc()command_argument_count()
  • getarg()get_command_argument()
  • getenv()get_environment_variable()
  • system()execute_command_line()
  • call exit(0)stop
  • call exit(N)error stop N

NAG also doesn't support (without flags that need to be used everywhere as @tclune can elucidate on) the use of real*4 or real(kind=4). The reason is that NAG does not use 4 for 32-bit real and 8 for 64-bit, instead they use 1 and 2. (The Standard does not specify what "kind" a 32-bit real must be, only that there must be one.) So, many changes are of the type:

  • real*4real(REAL32)
  • real(kind=8)real(kind=REAL64)

@mathomp4 mathomp4 self-assigned this Feb 3, 2022
@mathomp4 mathomp4 added the 0 diff The changes in this pull request have verified to be zero-diff with the target branch. label Feb 3, 2022
@mathomp4 mathomp4 added the Contingent - DNA Do Not Approve (DNA). These changes are contingent on other PRs label Feb 3, 2022
rtodling
rtodling previously approved these changes Sep 22, 2023
Copy link
Copy Markdown
Collaborator

@rtodling rtodling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are fine by me. Branch might need update though.

@mathomp4
Copy link
Copy Markdown
Member Author

These are fine by me. Branch might need update though.

Yeah. I need to revisit this. Files got moved long ago...

I'll put it on the list!

- Fix m_ioutil.F90: Use TRANSFER() intrinsic for type-safe byte swapping
  in swapI4_ and swapI8_ functions instead of direct type punning

- Fix mpi0/mpi0_copy.F90: Implement TRANSFER-based type conversions using
  BLOCK constructs for all non-INTEGER MPI types (REAL, DOUBLE_PRECISION,
  LOGICAL, CHARACTER) to satisfy NAG's strict type checking

- Fix windfix.F90: Correct array section syntax from scalar notation
  (e.g., dglo(1,1,l)) to proper array slices (e.g., dglo(:,:,l)) for
  calls to GETDIV and VELPOT_SP

- Update GMAO_mpeu/CMakeLists.txt: Comment out duplicate MISMATCH flags
  that are now in common_Fortran_flags to avoid compilation errors

All changes maintain backwards compatibility with gfortran and other
compilers while fixing NAG compiler strict type checking issues.
@weiyuan-jiang
Copy link
Copy Markdown
Contributor

I made a new commit but I didn't do the zero test @mathomp4

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

This PR is being prevented from merging because you have added one of our blocking labels: Contingent - DNA, Needs Lead Approval, Contingent -- Do Not Approve. You'll need to remove it before this PR can be merged.

Weiyuan Jiang added 2 commits May 5, 2026 13:26
- GMAO_gfio/CMakeLists.txt: add -wmismatch for legacy NetCDF-2 C API
  routines (NCVDEF, NCAPT, NCVPT, NCAGT, NCVGT, NCVGT1) called with
  varying Fortran types intentionally
- GMAO_hermes/CMakeLists.txt: remove duplicate ${MISMATCH} from
  CMAKE_Fortran_FLAGS_RELEASE (already in common_Fortran_flags); add
  -wmismatch for GFIO_PUTREALATT/GFIO_GETREALATT type-punning
- GMAO_hermes/m_nc_JEDIinc.f90: replace byte-count kind literal real(4)
  with portable real(selected_real_kind(6)) via parameter r4
- GMAO_hermes/m_nc_akbk.f90: replace double precision with real(real64)
  from iso_fortran_env so NF90_PUT_VAR generic resolves correctly
  when compiled with -r8
Comment thread CMakeLists.txt
GMAO_pilgrim
GMAO_etc
GEOS_Util
@GEOS_Util
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems GEOS_Util has been deleted. But this @GEOS_Util should be here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0 diff The changes in this pull request have verified to be zero-diff with the target branch. Contingent - DNA Do Not Approve (DNA). These changes are contingent on other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants