Skip to content

Commit

Permalink
Merge branch 'develop' into feature/jk/doc/code_generator
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
mathomp4 committed Oct 30, 2023
2 parents b0d4aca + 5ffa5ea commit 073f2ba
Show file tree
Hide file tree
Showing 25 changed files with 329 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ workflows:
baselibs_version: *baselibs_version
repo: GEOSadas
checkout_fixture: true
#fixture_branch: feature/mathomp4/ignore-heldsuarez
fixture_branch: feature/mathomp4/mapldevelop
checkout_mapl_branch: true
mepodevelop: false
rebuild_procs: 1
Expand Down
36 changes: 29 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add new benchmark to simulation writing a cubed-sphere file using various tunable strategies
- New directory (`docs/tutorial/grid_comps/automatic_code_generator`) containing an example showing how to automatically generate the source code using the `MAPL_GridCompSpecs_ACG.py` tool.

### Changed
- Modified fpp macro `_UNUSED_DUMMY(x) to use ASSOCIATE instead of PRINT. With this change it can be used in PURE procedures.
- Make error handling in Plain_netCDF_Time consistent with MAPL standard error handling
- Extend unit tests for FileSystemUtilities.
- Updated handling of NetCDF time values

### Fixed

### Removed

### Deprecated

## 2023-10-27
## [2.42.0] - 2023-10-27

### Added

- New directory (`docs/tutorial/grid_comps/automatic_code_generator`) containing an example showing how to automatically generate the source code using the `MAPL_GridCompSpecs_ACG.py` tool.
- Various workarounds for building MAPL with MPICH
- Non-support for `C_PTR` in `MPI_Alloc_Mem` ((MPICH Issue #6691)[https://github.com/pmodels/mpich/issues/6691])
- Non-support for `ierror` keyword arguments with `use mpi` ((MPICH Issue #6693)[https://github.com/pmodels/mpich/issues/6693])
- Add new benchmark to simulation writing a cubed-sphere file using various tunable strategies

### Changed

- Modified fpp macro `_UNUSED_DUMMY(x)` to use ASSOCIATE instead of PRINT. With this change it can be used in PURE procedures.
- Make error handling in Plain_netCDF_Time consistent with MAPL standard error handling
- Extend unit tests for FileSystemUtilities.
- Updated handling of NetCDF time values
- Update `components.yaml`
- ESMA_cmake v3.36.0 (Support for SLES15 at NCCS, support for Intel 2021.10)
- ESMA_env v4.20.5 (Support for SLES15 at NCCS)

### Fixed

- Introduced workaround for Intel 2021.10 bug in generic layer.
- Updated write_by_oserver logic so that the decision to write by the oserver is based on whether the output server client is passed in
- Updated CI GEOSadas build to use special branch (as stock ADAS at the moment is too far behind GEOSgcm main)
- Fix incorrect History print during runtime

## [2.41.2] - 2023-10-27

### Fixed

- Fixed missing initialize of pFlogger in a pfio test. Not clear why this was not failing for other compilers - detected with ifort 2021.10.0.

## [2.41.1] - 2023-10-04

Expand Down
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif ()

project (
MAPL
VERSION 2.41.1
VERSION 2.42.0
LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF

# Set the possible values of build type for cmake-gui
Expand Down Expand Up @@ -216,6 +216,16 @@ add_subdirectory (Apps)
add_subdirectory (MAPL_cfio MAPL_cfio_r4)
add_subdirectory (MAPL_cfio MAPL_cfio_r8)

# This tests for various capabilities of the compiler
# We mainly use it for MPICH issues
include(CheckCompilerCapabilities)

# 1. The first workaround is in pfio for https://github.com/pmodels/mpich/issues/6691
# 2. Below is to workaround https://github.com/pmodels/mpich/issues/6693
if(SUPPORT_FOR_MPI_IERROR_KEYWORD)
add_compile_definitions(SUPPORT_FOR_MPI_IERROR_KEYWORD)
endif()

add_subdirectory (pfio)
add_subdirectory (profiler)
add_subdirectory (generic)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ MAPL also has a variety of other auxiliary directories:
9. **docs** - documentation

## Using MAPL

You can find simple examples on how to use MAPL components in ESMF applications at:

[MAPL Tutorial](https://github.com/GEOS-ESM/MAPL/blob/main/docs/tutorial/README.md)
Expand Down
45 changes: 19 additions & 26 deletions base/NCIO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ subroutine MAPL_FieldWriteNCPar(formatter, name, FIELD, ARRDES, HomePE, oClients
type (ESMF_DistGrid) :: distGrid
type (LocalMemReference) :: lMemRef
integer :: size_1d
logical :: have_oclients

call ESMF_FieldGet(field, grid=grid, rc=status)
_VERIFY(STATUS)
Expand All @@ -320,9 +321,7 @@ subroutine MAPL_FieldWriteNCPar(formatter, name, FIELD, ARRDES, HomePE, oClients
call ESMF_DistGridGet(distGrid, delayout=layout, rc=STATUS)
_VERIFY(STATUS)

if( arrdes%write_restart_by_oserver) then
_ASSERT(present(oClients), "output server is needed")
endif
have_oclients = present(oClients)

call ESMF_AttributeGet(field, name='DIMS', value=DIMS, rc=status)
_VERIFY(STATUS)
Expand Down Expand Up @@ -351,7 +350,7 @@ subroutine MAPL_FieldWriteNCPar(formatter, name, FIELD, ARRDES, HomePE, oClients
size_1d = size(var_1d,1)
endif

if (arrdes%write_restart_by_oserver) then
if (have_oclients) then
if( MAPL_AM_I_ROOT()) then
lMemRef = LocalMemReference(pFIO_REAL32,[size_1d])
call c_f_pointer(lMemRef%base_address, gvar_1d, shape=[size_1d])
Expand Down Expand Up @@ -390,7 +389,7 @@ subroutine MAPL_FieldWriteNCPar(formatter, name, FIELD, ARRDES, HomePE, oClients
size_1d = size(vr8_1d,1)
endif

if (arrdes%write_restart_by_oserver) then
if (have_oclients) then
if(MAPL_AM_I_ROOT()) then
lMemRef = LocalMemReference(pFIO_REAL64,[size_1d])
call c_f_pointer(lMemRef%base_address, gvr8_1d, shape=[size_1d])
Expand Down Expand Up @@ -428,7 +427,7 @@ subroutine MAPL_FieldWriteNCPar(formatter, name, FIELD, ARRDES, HomePE, oClients
if (associated(var_2d)) then !ALT: temp kludge
if (DIMS == MAPL_DimsTileOnly .or. DIMS == MAPL_DimsTileTile) then

if (arrdes%write_restart_by_oserver) then
if (have_oclients) then
if(MAPL_AM_I_ROOT()) then
lMemRef = LocalMemReference(pFIO_REAL32,[arrdes%im_world, size(var_2d,2)])
call c_f_pointer(lMemRef%base_address, gvar_2d, shape=[arrdes%im_world, size(var_2d,2)])
Expand Down Expand Up @@ -462,7 +461,7 @@ subroutine MAPL_FieldWriteNCPar(formatter, name, FIELD, ARRDES, HomePE, oClients
if (associated(vr8_2d)) then !ALT: temp kludge
if (DIMS == MAPL_DimsTileOnly .or. DIMS == MAPL_DimsTileTile) then

if (arrdes%write_restart_by_oserver) then
if (have_oclients) then
if( MAPL_AM_I_ROOT() ) then
lMemRef = LocalMemReference(pFIO_REAL64,[arrdes%im_world,size(vr8_2d,2)])
call c_f_pointer(lMemRef%base_address, gvr8_2d, shape=[arrdes%im_world,size(vr8_2d,2)])
Expand Down Expand Up @@ -497,7 +496,7 @@ subroutine MAPL_FieldWriteNCPar(formatter, name, FIELD, ARRDES, HomePE, oClients
if (associated(var_3d)) then !ALT: temp kludge
if (DIMS == MAPL_DimsTileOnly) then

if (arrdes%write_restart_by_oserver) then
if (have_oclients) then
if( MAPL_Am_I_Root() ) then
lMemRef = LocalMemReference(pFIO_REAL32,[arrdes%im_world, size(var_3d,2), size(var_3d,3)])
call c_f_pointer(lMemRef%base_address, gvar_3d, shape=[arrdes%im_world, size(var_3d,2), size(var_3d,3)])
Expand Down Expand Up @@ -536,7 +535,7 @@ subroutine MAPL_FieldWriteNCPar(formatter, name, FIELD, ARRDES, HomePE, oClients
if (associated(vr8_3d)) then !ALT: temp kludge
if (DIMS == MAPL_DimsTileOnly) then

if (arrdes%write_restart_by_oserver) then
if (have_oclients) then
if( MAPL_Am_I_Root() ) then
lMemRef = LocalMemReference(pFIO_REAL64,[arrdes%im_world,size(vr8_3d,2), size(vr8_3d,3)])
call c_f_pointer(lMemRef%base_address, gvr8_3d, shape=[arrdes%im_world,size(vr8_3d,2), size(vr8_3d,3)])
Expand Down Expand Up @@ -619,8 +618,7 @@ subroutine MAPL_VarWriteNCpar_R4_4d(formatter, name, A, ARRDES, oClients, RC)
type(ArrayReference) :: ref

if (present(arrdes)) then
if (arrdes%write_restart_by_oserver) then
_ASSERT(present(oClients), "output server is needed")
if (present(oClients)) then
call MAPL_GridGet(arrdes%grid,globalCellCountPerDim=global_dim,rc=status)
_VERIFY(status)
call MAPL_Grid_interior(arrdes%grid,i1,in,j1,jn)
Expand Down Expand Up @@ -670,8 +668,7 @@ subroutine MAPL_VarWriteNCpar_R8_4d(formatter, name, A, ARRDES, oClients, RC)
integer :: i1, j1, in, jn, global_dim(3)
type(ArrayReference) :: ref

if (arrdes%write_restart_by_oserver) then
_ASSERT(present(oClients), "output server is needed")
if (present(oClients)) then
call MAPL_GridGet(arrdes%grid,globalCellCountPerDim=global_dim,rc=status)
_VERIFY(status)
call MAPL_Grid_interior(arrdes%grid,i1,in,j1,jn)
Expand Down Expand Up @@ -712,8 +709,7 @@ subroutine MAPL_VarWriteNCpar_R4_3d(formatter, name, A, ARRDES, oClients, RC)
type(ArrayReference) :: ref

if (present(arrdes)) then
if (arrdes%write_restart_by_oserver) then
_ASSERT(present(oClients), "output server is needed")
if (present(oclients)) then
call MAPL_GridGet(arrdes%grid,globalCellCountPerDim=global_dim,rc=status)
_VERIFY(status)
call MAPL_Grid_interior(arrdes%grid,i1,in,j1,jn)
Expand Down Expand Up @@ -780,8 +776,7 @@ subroutine MAPL_VarWriteNCpar_R8_3d(formatter, name, A, ARRDES, oClients, RC)
type(ArrayReference) :: ref


if (arrdes%write_restart_by_oserver) then
_ASSERT(present(oClients), "outpur server is needed")
if (present(oclients)) then
call MAPL_GridGet(arrdes%grid,globalCellCountPerDim=global_dim,rc=status)
_VERIFY(status)
call MAPL_Grid_interior(arrdes%grid,i1,in,j1,jn)
Expand Down Expand Up @@ -852,8 +847,7 @@ subroutine MAPL_VarWriteNCpar_R4_2d(formatter, name, A, ARRDES, lev, offset2, oC
integer :: i1, j1, in, jn, global_dim(3)

if (present(arrdes)) then
if(arrdes%write_restart_by_oserver) then
_ASSERT(present(oClients), "output server is needed")
if(present(oClients)) then
call MAPL_GridGet(arrdes%grid,globalCellCountPerDim=global_dim,rc=status)
_VERIFY(status)
call MAPL_Grid_interior(arrdes%grid,i1,in,j1,jn)
Expand Down Expand Up @@ -2342,8 +2336,7 @@ subroutine MAPL_VarWriteNCpar_R8_2d(formatter, name, A, ARRDES, lev, offset2, oC
integer :: i1, j1, in, jn, global_dim(3)

if (present(arrdes)) then
if( arrdes%write_restart_by_oserver) then
_ASSERT(present(oClients), "output server is needed")
if(present(oClients)) then
call MAPL_GridGet(arrdes%grid,globalCellCountPerDim=global_dim,rc=status)
_VERIFY(status)
call MAPL_Grid_interior(arrdes%grid,i1,in,j1,jn)
Expand Down Expand Up @@ -3274,8 +3267,9 @@ subroutine MAPL_BundleWriteNCPar(Bundle, arrdes, CLOCK, filename, oClients, rc)
character(len=ESMF_MAXSTR) :: positive
type(StringVector) :: flip_vars
type(ESMF_Field) :: lons_field, lats_field
logical :: isGridCapture
logical :: isGridCapture, have_oclients
real(kind=ESMF_KIND_R8), pointer :: grid_lons(:,:), grid_lats(:,:), lons_field_ptr(:,:), lats_field_ptr(:,:)
have_oclients = present(oClients)

call ESMF_FieldBundleGet(Bundle,FieldCount=nVars, name=BundleName, rc=STATUS)
_VERIFY(STATUS)
Expand Down Expand Up @@ -3471,7 +3465,7 @@ subroutine MAPL_BundleWriteNCPar(Bundle, arrdes, CLOCK, filename, oClients, rc)
ndims = ndims + 1

!WJ note: if arrdes%write_restart_by_oserver is true, all processors will participate
if (arrdes%writers_comm/=MPI_COMM_NULL .or. arrdes%write_restart_by_oserver) then
if (arrdes%writers_comm/=MPI_COMM_NULL .or. have_oclients ) then

! Create dimensions as needed
if (Have_HorzVert .or. Have_HorzOnly) then
Expand Down Expand Up @@ -3832,8 +3826,7 @@ subroutine MAPL_BundleWriteNCPar(Bundle, arrdes, CLOCK, filename, oClients, rc)
_VERIFY(STATUS)


if (arrdes%write_restart_by_oserver) then
_ASSERT(present(oClients), 'output server is needed')
if (have_oclients) then
call oClients%set_optimal_server(1)
iter = RstCollections%find(trim(BundleName))
if (iter == RstCollections%end()) then
Expand Down Expand Up @@ -3935,7 +3928,7 @@ subroutine MAPL_BundleWriteNCPar(Bundle, arrdes, CLOCK, filename, oClients, rc)
call MAPL_FieldWriteNCPar(formatter, 'lats', lats_field, arrdes, HomePE=mask, oClients=oClients, rc=status)
end if

if (arrdes%write_restart_by_oserver) then
if (have_oclients) then
call oClients%done_collective_stage(_RC)
call oClients%post_wait()
call MPI_Info_free(info, status)
Expand Down
5 changes: 4 additions & 1 deletion benchmarks/io/checkpoint_simulator/checkpoint_simulator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,10 @@ program checkpoint_tester
write(*,'(A,I3)')"Num writers: ",support%num_writers
write(*,'(A,I6)')"Total cores: ",comm_size
write(*,'(A,I6,I6)')"Cube size: ",support%im_world,support%lm
write(*,'(A,L,L,L,L,L,L,L)')"Split file, 3D_gather, chunk, extra, netcdf output, write barrier, do writes: ",support%split_file,support%gather_3d,support%do_chunking,support%extra_info,support%netcdf_writes,support%write_barrier,support%do_writes
write(*,'(A,7(L1))')"Split file, 3D_gather, chunk, extra, netcdf output, write barrier, do writes: ",&
support%split_file, support%gather_3d, &
support%do_chunking,support%extra_info, &
support%netcdf_writes,support%write_barrier, support%do_writes
write(*,'(A,I6)')"Number of trial: ",support%n_trials
write(*,'(A,G16.8)')"Application time: ",application_time
end if
Expand Down
27 changes: 27 additions & 0 deletions cmake/CheckCompilerCapabilities.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
include (CheckFortranSource)

CHECK_FORTRAN_SOURCE_COMPILE (
${CMAKE_CURRENT_LIST_DIR}/support_for_assumed_type.F90
SUPPORT_FOR_ASSUMED_TYPE
)

CHECK_FORTRAN_SOURCE_COMPILE (
${CMAKE_CURRENT_LIST_DIR}/support_for_c_loc_assumed_size.F90
SUPPORT_FOR_C_LOC_ASSUMED_SIZE
)

CHECK_FORTRAN_SOURCE_COMPILE (
${CMAKE_CURRENT_LIST_DIR}/support_for_mpi_alloc_mem_cptr.F90
SUPPORT_FOR_MPI_ALLOC_MEM_CPTR
MPI
)

CHECK_FORTRAN_SOURCE_COMPILE (
${CMAKE_CURRENT_LIST_DIR}/support_for_mpi_ierror_keyword.F90
SUPPORT_FOR_MPI_IERROR_KEYWORD
MPI
)




83 changes: 83 additions & 0 deletions cmake/CheckFortranSource.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
macro (CHECK_FORTRAN_SOURCE_COMPILE file var)

if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Performing Test ${var}")
endif ()

if (${ARGC} GREATER 2)
try_compile (
${var}
${CMAKE_BINARY_DIR}
${file}
CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${MPI_Fortran_FLAGS}"
"-DINCLUDE_DIRECTORIES:LIST=${MPI_Fortran_INCLUDE_DIRS}"
"-DLINK_LIBRARIES:LIST=${MPI_Fortran_LIBRARIES}"
)
else ()

try_compile (
${var}
${CMAKE_BINARY_DIR}
${file}
)
endif ()

if (${var})
if (NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Performing Test ${var}: SUCCESS")
endif ()

add_definitions(-D${var})

else ()

if (NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Performing Test ${var}: FAILURE")
endif ()

endif ()

endmacro (CHECK_FORTRAN_SOURCE_COMPILE)


macro (CHECK_FORTRAN_SOURCE_RUN file var)

if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Performing Test ${var}")
endif ()

try_run (
code_runs
code_compiles
${CMAKE_BINARY_DIR}
${file}
)

if (${code_compiles})
if (${code_runs} EQUAL 0)

if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Performing Test ${var}: SUCCESS")
endif ()

add_definitions(-D${var})

set (${var} 1)

else ()

if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Performing Test ${var}: RUN FAILURE")
endif ()

endif ()

else ()

if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Performing Test ${var}: BUILD FAILURE")
endif ()

endif()

endmacro (CHECK_FORTRAN_SOURCE_RUN)
5 changes: 5 additions & 0 deletions cmake/support_for_assumed_type.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
subroutine foo(x)
type(*) :: x(*)
end subroutine foo
program main
end program main
Loading

0 comments on commit 073f2ba

Please sign in to comment.