Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to allow aggressive debug flags with NAG. #1538

Merged
merged 3 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- History GC
- MemUtils
- `register_generic_entry_points`
- Implemented workaround for NAG related to ArrayReference use in GriddedIO.
- Implemented workarounds to avoid needing `-dusty` for NAG. (Related PR in ESMA_CMake.)

## [Unreleased]

Expand Down
7 changes: 7 additions & 0 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ set (srcs
VarspecDescription.F90
)

# We don't want to disable good NAG debugging flags everywhere, but we still need to do it for
# interfaces (e.g. MPI) that allow multiple types for the same argument (eg buffer).
if (DUSTY)
set_property( SOURCE ExtDataDriverMod.F90 ExtDataDriverGridComp.F90
PROPERTY COMPILE_FLAGS ${DUSTY})
endif ()

if (BUILD_WITH_FLAP)

ecbuild_add_executable (TARGET ExtDataDriver.x SOURCES ${srcs})
Expand Down
1 change: 0 additions & 1 deletion base/Base.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module MAPLBase_Mod
use MAPL_SunMod
use MAPL_LocStreamMod
use MAPL_InterpMod
use MAPL_HeapMod
use MAPL_SatVaporMod
use MAPL_MemUtilsMod
use MAPL_HashMod
Expand Down
7 changes: 7 additions & 0 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ esma_add_library(
esmf NetCDF::NetCDF_Fortran MPI::MPI_Fortran
TYPE ${MAPL_LIBRARY_TYPE})

# We don't want to disable good NAG debugging flags everywhere, but we still need to do it for
# interfaces (e.g. MPI) that allow multiple types for the same argument (eg buffer).
if (DUSTY)
set_property( SOURCE MAPL_Comms.F90 FileIOShared.F90 BinIO.F90 NCIO.F90
PROPERTY COMPILE_FLAGS ${DUSTY})
endif ()

# CMake has an OpenMP issue with NAG Fortran: https://gitlab.kitware.com/cmake/cmake/-/issues/21280
if (NOT CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
target_link_libraries(${this} PRIVATE OpenMP::OpenMP_Fortran)
Expand Down
7 changes: 7 additions & 0 deletions gridcomps/Cap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ endif()

esma_add_library (${this} SRCS ${srcs} DEPENDENCIES MAPL.shared MAPL.constants MAPL.base MAPL.profiler MAPL.history
MAPL.ExtData ${EXTDATA2G_TARGET} TYPE ${MAPL_LIBRARY_TYPE})
# We don't want to disable good NAG debugging flags everywhere, but we still need to do it for
# interfaces (e.g. MPI) that allow multiple types for the same argument (eg buffer).
if (DUSTY)
set_property( SOURCE MAPL_CapGridComp.F90 MAPL_NUOPCWrapperMod.F90
PROPERTY COMPILE_FLAGS ${DUSTY})
endif ()

target_link_libraries (${this} PUBLIC GFTL::gftl GFTL_SHARED::gftl-shared esmf NetCDF::NetCDF_Fortran
PRIVATE MPI::MPI_Fortran $<$<BOOL:${BUILD_WITH_FLAP}>:FLAP::FLAP>)

Expand Down
2 changes: 1 addition & 1 deletion gridcomps/Cap/MAPL_CapGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ subroutine print_throughput(rc)
LOOP_THROUGHPUT,INST_THROUGHPUT,RUN_THROUGHPUT,HRS_R,MIN_R,SEC_R,&
mem_committed_percent,mem_used_percent
1000 format(1x,'AGCM Date: ',i4.4,'/',i2.2,'/',i2.2,2x,'Time: ',i2.2,':',i2.2,':',i2.2, &
2x,'Throughput(days/day)[Avg Tot Run]: ',f8.1,1x,f8.1,1x,f8.1,2x,'TimeRemaining(Est) ',i3.3,':'i2.2,':',i2.2,2x, &
2x,'Throughput(days/day)[Avg Tot Run]: ',f8.1,1x,f8.1,1x,f8.1,2x,'TimeRemaining(Est) ',i3.3,':',i2.2,':',i2.2,2x, &
f5.1,'% : ',f5.1,'% Mem Comm:Used')

_RETURN(_SUCCESS)
Expand Down
2 changes: 1 addition & 1 deletion gridcomps/History/MAPL_HistoryGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2592,7 +2592,7 @@ subroutine Initialize ( gc, import, dumexport, clock, rc )
write (*,'(A)',ADVANCE='NO') ' Fields: '
do m=1,list(n)%field_set%nfields
if( trim(list(n)%field_set%fields(3,m)).ne.BLANK ) then
write (*,'(A,X)',ADVANCE='NO') trim(list(n)%field_set%fields(3,m))
write (*,'(A,1X)',ADVANCE='NO') trim(list(n)%field_set%fields(3,m))
endif
enddo
! Now advance the write
Expand Down
21 changes: 16 additions & 5 deletions griddedio/GriddedIO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ subroutine bundlepost(this,filename,oClients,rc)

this%times = this%timeInfo%compute_time_vector(this%metadata,rc=status)
_VERIFY(status)
ref = ArrayReference(this%times)
associate (times => this%times)
ref = ArrayReference(times)
end associate
call oClients%stage_nondistributed_data(this%write_collection_id,trim(filename),'time',ref)

tindex = size(this%times)
Expand Down Expand Up @@ -745,7 +747,9 @@ subroutine stage2DLatLon(this, fileName, oClients, rc)
farrayPtr=ptr2d, rc=status)
_VERIFY(STATUS)
this%lons=ptr2d*MAPL_RADIANS_TO_DEGREES
ref = ArrayReference(this%lons)
associate (lons => this%lons)
ref = ArrayReference(lons)
end associate
call oClients%collective_stage_data(this%write_collection_id,trim(filename),'lons', &
ref,start=localStart, global_start=GlobalStart, global_count=GlobalCount)
call ESMF_GridGetCoord(this%output_grid, localDE=0, coordDim=2, &
Expand All @@ -754,7 +758,10 @@ subroutine stage2DLatLon(this, fileName, oClients, rc)
_VERIFY(STATUS)
if (.not.allocated(this%lats)) allocate(this%lats(size(ptr2d,1),size(ptr2d,2)))
this%lats=ptr2d*MAPL_RADIANS_TO_DEGREES
ref = ArrayReference(this%lats)
associate (lats => this%lats)
ref = ArrayReference(lats)
end associate

call oClients%collective_stage_data(this%write_collection_id,trim(filename),'lats', &
ref,start=localStart, global_start=GlobalStart, global_count=GlobalCount)
deallocate(LocalStart,GlobalStart,GlobalCount)
Expand All @@ -775,7 +782,9 @@ subroutine stage2DLatLon(this, fileName, oClients, rc)
farrayPtr=ptr2d, rc=status)
_VERIFY(STATUS)
this%corner_lons=ptr2d*MAPL_RADIANS_TO_DEGREES
ref = ArrayReference(this%corner_lons)
associate (corner_lons => this%corner_lons)
ref = ArrayReference(corner_lons)
end associate
call oClients%collective_stage_data(this%write_collection_id,trim(filename),'corner_lons', &
ref,start=localStart, global_start=GlobalStart, global_count=GlobalCount)
call ESMF_GridGetCoord(this%output_grid, localDE=0, coordDim=2, &
Expand All @@ -784,7 +793,9 @@ subroutine stage2DLatLon(this, fileName, oClients, rc)
_VERIFY(STATUS)
if (.not.allocated(this%corner_lats)) allocate(this%corner_lats(size(ptr2d,1),size(ptr2d,2)))
this%corner_lats=ptr2d*MAPL_RADIANS_TO_DEGREES
ref = ArrayReference(this%corner_lats)
associate (corner_lats => this%corner_lats)
ref = ArrayReference(corner_lats)
end associate
call oClients%collective_stage_data(this%write_collection_id,trim(filename),'corner_lats', &
ref,start=localStart, global_start=GlobalStart, global_count=GlobalCount)
end if
Expand Down
8 changes: 8 additions & 0 deletions pfio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ set (srcs
)

esma_add_library (${this} SRCS ${srcs} DEPENDENCIES MAPL.shared MAPL.profiler NetCDF::NetCDF_Fortran TYPE ${MAPL_LIBRARY_TYPE})

# We don't want to disable good NAG debugging flags everywhere, but we still need to do it for
# interfaces (e.g. MPI) that allow multiple types for the same argument (eg buffer).
if (DUSTY)
set_property( SOURCE DirectoryService.F90 MultiCommServer.F90 MultiGroupServer.F90 MultiLayerServer.F90 pfio_writer.F90
PROPERTY COMPILE_FLAGS ${DUSTY})
endif ()

target_link_libraries (${this} PUBLIC GFTL_SHARED::gftl-shared PRIVATE MPI::MPI_Fortran)
# CMake has an OpenMP issue with NAG Fortran: https://gitlab.kitware.com/cmake/cmake/-/issues/21280
if (NOT CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
Expand Down
8 changes: 7 additions & 1 deletion shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set (srcs
MAPL_DirPath.F90
ErrorHandling.F90
MAPL_Hash.F90
MAPL_HeapMod.F90
KeywordEnforcer.F90
MAPL_LoadBalance.F90
MAPL_MinMax.F90
Expand All @@ -31,6 +30,13 @@ set (srcs

esma_add_library (${this} SRCS ${srcs} DEPENDENCIES MAPL.constants GFTL_SHARED::gftl-shared MPI::MPI_Fortran PFLOGGER::pflogger TYPE ${MAPL_LIBRARY_TYPE})

# We don't want to disable good NAG debugging flags everywhere, but we still need to do it for
# interfaces (e.g. MPI) that allow multiple types for the same argument (eg buffer).
if (DUSTY)
set_property( SOURCE Shmem/Shmem.F90 Shmem/Shmem_implementation.F90
PROPERTY COMPILE_FLAGS ${DUSTY})
endif ()

target_include_directories (${this} PUBLIC $<BUILD_INTERFACE:${MAPL_SOURCE_DIR}/include>)

target_compile_definitions(${this} PRIVATE SYSTEM_DSO_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}")
Expand Down
17 changes: 17 additions & 0 deletions shared/MAPL_Sort.F90
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ module MAPL_SortMod

module procedure SORT2AS
module procedure SORT2AL
end interface MAPL_Sort

interface
subroutine qsorts(a, b, r, n) bind(C,name="QSORTS")
use, intrinsic :: iso_fortran_env, only: INT32
integer(kind=INT32), intent(inout) :: a(*)
type(*), intent(inout) :: b(*)
integer, value, intent(in) :: r
integer, value, intent(in) :: n
end subroutine qsorts
subroutine qsortl(a, b, r, n) bind(C,name="QSORTL")
use, intrinsic :: iso_fortran_env, only: INT64
integer(kind=INT64), intent(inout) :: a(*)
type(*), intent(inout) :: b(*)
integer, value, intent(in) :: r
integer, value, intent(in) :: n
end subroutine qsortl
end interface

contains
Expand Down
1 change: 0 additions & 1 deletion shared/MaplShared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module MaplShared
use mapl_LoadBalanceMod
use mapl_KeywordEnforcerMod
use mapl_InterpMod
use mapl_HeapMod
use mapl_HashMod
use mapl_ErrorHandlingMod
use mapl_DirPathMod
Expand Down
2 changes: 1 addition & 1 deletion shared/Shmem/Shmem.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ module MAPL_Shmem
use, intrinsic :: ISO_C_BINDING
use, intrinsic :: ISO_FORTRAN_ENV, only: REAL64, REAL32
use MAPL_Constants
use MPI

implicit none
private

include 'mpif.h'

public :: MAPL_GetNodeInfo
public :: MAPL_CoresPerNodeGet
Expand Down
32 changes: 16 additions & 16 deletions shared/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,32 @@ void QuickSortS(int a[], int b[], int l, int r, int m, int n)



// FORTRAN INTERFACES
// Fortran INTERFACES

void QSORT0(long long a[], int *r) {
void QSORT0(long long a[], int r) {
int *b=NULL;
(void)QuickSort(a,b,0,*r-1,*r,0);
(void)QuickSort(a,b,0,r-1,r,0);
}

void QSORTL(long long a[], int b[], int *r, int *n) {
(void)QuickSort(a,b,0,*r-1,*r,*n);
void QSORTL(long long a[], int b[], int r, int n) {
(void)QuickSort(a,b,0,r-1,r,n);
}

void QSORTS (int a[], int b[], int *r, int *n) {
(void)QuickSortS(a,b,0,*r-1,*r,*n);
void QSORTS (int a[], int b[], int r, int n) {
(void)QuickSortS(a,b,0,r-1,r,n);
}

// Extra aliases for other loaders

void qsort0 (long long a[], int *r ) { (void)QSORT0(a ,r ); }
void qsortl (long long a[], int b[], int *r, int *n) { (void)QSORTL(a,b,r,n); }
void qsorts (int a[], int b[], int *r, int *n) { (void)QSORTS(a,b,r,n); }
void qsort0 (long long a[], int r ) { (void)QSORT0(a ,r ); }
void qsortl (long long a[], int b[], int r, int n) { (void)QSORTL(a,b,r,n); }
void qsorts (int a[], int b[], int r, int n) { (void)QSORTS(a,b,r,n); }

void QSORT0_(long long a[], int *r ) { (void)QSORT0(a ,r ); }
void QSORTL_(long long a[], int b[], int *r, int *n) { (void)QSORTL(a,b,r,n); }
void QSORTS_(int a[], int b[], int *r, int *n) { (void)QSORTS(a,b,r,n); }
void QSORT0_(long long a[], int r ) { (void)QSORT0(a ,r ); }
void QSORTL_(long long a[], int b[], int r, int n) { (void)QSORTL(a,b,r,n); }
void QSORTS_(int a[], int b[], int r, int n) { (void)QSORTS(a,b,r,n); }

void qsort0_(long long a[], int *r ) { (void)QSORT0(a, r ); }
void qsortl_(long long a[], int b[], int *r, int *n) { (void)QSORTL(a,b,r,n); }
void qsorts_(int a[], int b[], int *r, int *n) { (void)QSORTS(a,b,r,n); }
void qsort0_(long long a[], int r ) { (void)QSORT0(a, r ); }
void qsortl_(long long a[], int b[], int r, int n) { (void)QSORTL(a,b,r,n); }
void qsorts_(int a[], int b[], int r, int n) { (void)QSORTS(a,b,r,n); }