From 69d34a2ec8f660c8f5c62c793dd672748c77f217 Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Thu, 5 Dec 2024 14:49:37 -0500 Subject: [PATCH] WIP: Fixes needed for flang (#3176) * Fixes needed for flang * Update changelog * Remove general use pfio * Update to changelog to try and trigger CI --- CHANGELOG.md | 1 + generic/AbstractComponent.F90 | 7 ++++--- generic/MAPL_Generic.F90 | 4 +++- gridcomps/History/Sampler/MAPL_EpochSwathMod.F90 | 1 - include/unused_dummy.H | 6 +++++- pfio/AbstractServer.F90 | 9 +++++++++ 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efbb36ca0a13..e55b7840bf5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed issue of some Baselibs builds appearing to support zstandard. This is not possible due to Baselibs building HDF5 and netCDF as static libraries +- Updates to support llvm-flang - Trajectory sampler: fix a bug when group_name does not exist in netCDF file and a bug that omitted the first time point - Fixed a bug where the periodicity around the earth of the lat-lon grid was not being set properly when grid did not span from pole to pole diff --git a/generic/AbstractComponent.F90 b/generic/AbstractComponent.F90 index 094333e88616..c9db2c74a891 100644 --- a/generic/AbstractComponent.F90 +++ b/generic/AbstractComponent.F90 @@ -1,4 +1,5 @@ module mapl_AbstractComponent + use pFlogger, only: t_Logger => Logger implicit none private @@ -96,7 +97,7 @@ subroutine i_RunChild(this, name, clock, phase, unusable, rc) end subroutine i_RunChild subroutine i_SetLogger(this, logger) - use pfl_logger, only: t_Logger => Logger + import t_Logger import AbstractComponent implicit none class(AbstractComponent), intent(inout) :: this @@ -105,7 +106,7 @@ subroutine i_SetLogger(this, logger) end subroutine i_SetLogger function i_GetLogger(this) result(logger) - use pfl_logger, only: t_Logger => Logger + import t_Logger import AbstractComponent implicit none class(t_Logger), pointer :: logger @@ -113,5 +114,5 @@ function i_GetLogger(this) result(logger) end function i_GetLogger end interface - + end module mapl_AbstractComponent diff --git a/generic/MAPL_Generic.F90 b/generic/MAPL_Generic.F90 index 13d2a97122c9..1aa38f283b91 100644 --- a/generic/MAPL_Generic.F90 +++ b/generic/MAPL_Generic.F90 @@ -9805,8 +9805,10 @@ subroutine READIT(WHICH) if (io_rank == 0) then print *,'Using parallel IO for reading file: ',trim(DATAFILE) -#ifdef __NAG_COMPILER_RELEASE +#if defined( __NAG_COMPILER_RELEASE) _FAIL('NAG does not provide ftell. Convert to stream I/O') +#elif defined(__flang__) + _FAIL('flang does not provide ftell. Convert to stream I/O') #else offset = _FTELL(UNIT)+4 #endif diff --git a/gridcomps/History/Sampler/MAPL_EpochSwathMod.F90 b/gridcomps/History/Sampler/MAPL_EpochSwathMod.F90 index cf051b2b66a8..3f692e4b2244 100644 --- a/gridcomps/History/Sampler/MAPL_EpochSwathMod.F90 +++ b/gridcomps/History/Sampler/MAPL_EpochSwathMod.F90 @@ -15,7 +15,6 @@ module MAPL_EpochSwathMod use MAPL_TimeDataMod use MAPL_VerticalDataMod use MAPL_Constants - use pFIO use MAPL_GriddedIOItemVectorMod use MAPL_GriddedIOItemMod use MAPL_ExceptionHandling diff --git a/include/unused_dummy.H b/include/unused_dummy.H index 6d7063924148..6ffecb5dfcf1 100644 --- a/include/unused_dummy.H +++ b/include/unused_dummy.H @@ -10,4 +10,8 @@ #ifdef _UNUSED_DUMMY # undef _UNUSED_DUMMY #endif -#define _UNUSED_DUMMY(x) if (.false.) then; associate (q____ => x); end associate; endif +#if defined(__flang__) +# define _UNUSED_DUMMY(x) if (.false.) then; print*, shape(x); endif +#else +# define _UNUSED_DUMMY(x) if (.false.) then; associate (q____ => x); end associate; endif +#endif diff --git a/pfio/AbstractServer.F90 b/pfio/AbstractServer.F90 index d93911f302b8..519378445683 100644 --- a/pfio/AbstractServer.F90 +++ b/pfio/AbstractServer.F90 @@ -205,7 +205,10 @@ subroutine set_status(this,status) !$omp critical (counter_status) this%status = status + ! llvm-flang has an issue with omp flush of complex data structures +#if !defined(__flang__) !$omp flush (this) +#endif !$omp end critical (counter_status) end subroutine set_status @@ -217,7 +220,10 @@ subroutine update_status(this, rc) !$omp critical (counter_status) this%status = this%status -1 status = this%status + ! llvm-flang has an issue with omp flush of complex data structures +#if !defined(__flang__) !$omp flush (this) +#endif !$omp end critical (counter_status) if (status /= 0) then _RETURN(_SUCCESS) @@ -290,7 +296,10 @@ subroutine set_AllBacklogIsEmpty(this,status) !$omp critical (backlog_status) this%all_backlog_is_empty = status + ! llvm-flang has an issue with omp flush of complex data structures +#if !defined(__flang__) !$omp flush (this) +#endif !$omp end critical (backlog_status) end subroutine set_AllBacklogIsEmpty