Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
23d2af4
Move towards working compilation
Feb 8, 2021
f9ddde4
Ignore IntelliJ project and cmake-build directories
Feb 8, 2021
423ed5d
correct .f90 -> .F90
Feb 8, 2021
5e5f7dd
Removed compiler warnings - no way to avoid them, and added preproces…
AlexBuccheri Feb 8, 2021
bfd9e94
Deal with compiler warnings in release mode
AlexBuccheri Feb 8, 2021
f6fbf45
return prior to evaluating - minimises overhead
AlexBuccheri Feb 8, 2021
2f3dbf3
Preprocessor settings (missing from last 2 commits)
AlexBuccheri Feb 9, 2021
54585d8
Fully fleshed out CMake
AlexBuccheri Feb 20, 2021
8135e4c
Changed DEBUG back to USE_ASSERT
AlexBuccheri Feb 20, 2021
346df90
Started writing first test - note issues with initialising the MPI en…
AlexBuccheri Feb 20, 2021
ae8da13
Add unit tests once library compilation is tested
AlexBuccheri Feb 20, 2021
992d778
Fixed bug in choice of library name
AlexBuccheri Feb 20, 2021
d488e97
Add getter
AlexBuccheri Feb 20, 2021
eaa7f17
Fixed bugs
AlexBuccheri Feb 20, 2021
4c22536
Project description
AlexBuccheri Feb 20, 2021
181e558
More project description
AlexBuccheri Feb 20, 2021
7452b24
Update
AlexBuccheri Feb 20, 2021
3dc4d20
init-finalise and corresponding tests (note, the tests require more s…
AlexBuccheri Feb 20, 2021
78acdb0
Changed strategy for testing. program is not finding the subroutine i…
AlexBuccheri Feb 20, 2021
623d728
Test builds and runs a dummy assert, however it is not correctly set …
AlexBuccheri Feb 21, 2021
4c11c37
Refactored to use setup, teardown and autogenerate test drivers for o…
AlexBuccheri Feb 21, 2021
d7c5f80
Cleaned up init test
AlexBuccheri Feb 21, 2021
29a0052
Started making init and finalise work for both f08 and f90 mpi bindin…
AlexBuccheri Feb 21, 2021
172a5df
Added important TODO that indicates how to clean things up
AlexBuccheri Feb 21, 2021
6139c9d
Really fleshed out wrapped get_comm and duplicate_comm routines. Beha…
AlexBuccheri Feb 22, 2021
568ac25
Complete overhaul of routines to use setters and getters, and to hide…
AlexBuccheri Feb 27, 2021
dc655ba
Cleaned up docs. Not tested build
AlexBuccheri Feb 27, 2021
6af5ffb
Remove non-existent file from src/CMakeLists.txt
Mar 10, 2021
a7d1cba
Add CMake arguments to README for testing (Zofu) and documentation
Mar 10, 2021
a2b6b51
Added files missing from version control
AlexBuccheri Mar 11, 2021
44142a8
Merge branch 'fix_proposed_structure' of https://github.com/AlexBucch…
AlexBuccheri Mar 11, 2021
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Mac custom attributes file
.DS_Store
.DS_Store

# IntelliJ
.idea/
cmake-build-*/
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ set_target_properties(${TARGET}-static
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY})
target_link_libraries(${TARGET}-static ${LIBS})

# Set fortran preprocessor variables
include(cmake/PreprocessorSettings.cmake)

# Install libraries and modules
# Not sure when this is required: include(GNUInstallDirs)
Expand Down
8 changes: 6 additions & 2 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
-Wcharacter-truncation # Warn when a character assignment will truncate the assigned string.
-Wfunction-elimination # Warn if any calls to impure functions are eliminated by the optimizations
# enabled by the -ffrontend-optimize option
-Wimplicit-interface # Warn if a procedure is called without an explicit interface.
-Wimplicit-procedure # Warn if a procedure is called that has neither an explicit interface nor has been declared as EXTERNAL.
#-Wimplicit-interface # Warn if a procedure is called without an explicit interface.
#-Wimplicit-procedure # Warn if a procedure is called that has neither an explicit interface nor has been declared as EXTERNAL.
-Wuse-without-only # Warn if modules are used without only keyword
-Wunderflow # Produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation.
-Wrealloc-lhs # I assume this warns if the shape of the L.H.S. and R.H.S of an allocatable assignment differ.
Expand All @@ -19,6 +19,10 @@
-pedantic) # Issue warnings for uses of extensions to Fortran i.e. C's #include
# This should be used in conjunction with -std=f95 to f2018

# Removed warnings
# Wimplicit-interface and Wimplicit-procedure are not usable with MPI.
# See: https://stackoverflow.com/questions/41938663/why-does-mpich-3-0s-mpi-module-omit-explicit-interfaces-for-some-procedures

# See https://software.intel.com/content/www/us/en/develop/documentation/fortran-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/compiler-diagnostic-options/warn.html
set(INTEL_WARNINGS
-warn all # Enables all warning messages except errors and stderrors
Expand Down
1 change: 1 addition & 0 deletions cmake/Doxygen.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO(Alex) Replace with FORD
function(enable_doxygen)
option(ENABLE_DOXYGEN "Enable doxygen" OFF)
if (ENABLE_DOXYGEN)
Expand Down
23 changes: 23 additions & 0 deletions cmake/PreprocessorSettings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Set pre-processing variables for shared and static libs

if(CMAKE_BUILD_TYPE MATCHES Debug)
# Preprocessor variable "DEBUG" in the code
set_property(TARGET ${TARGET} APPEND PROPERTY
COMPILE_DEFINITIONS "DEBUG")
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Probs change back to USE_ASSERT. More descriptive


set_property(TARGET ${TARGET}-static APPEND PROPERTY
COMPILE_DEFINITIONS "DEBUG")
endif()

# Provides an option for the user to select as ON or OFF.
#If <variable> is already set as a normal or cache variable, then the command does nothing
option(MPI08 "Use mpi_f08 bindings" ON)

if(MPI08)
# Preprocessor variable "MPI08" in the code
set_property(TARGET ${TARGET} APPEND PROPERTY
COMPILE_DEFINITIONS "MPI08")

set_property(TARGET ${TARGET}-static APPEND PROPERTY
COMPILE_DEFINITIONS "MPI08")
endif()
5 changes: 1 addition & 4 deletions cmake/StandardProjectSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()

# Generate compile_commands.json: Useful for generating source trails
# Test with SourceTrail
# Test with SourceTrail (although this doesn't support fortran as of 2021)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Never tested with fortran
Expand All @@ -40,6 +40,3 @@ IF(ENABLE_IPO)
message(SEND_ERROR "IPO is not supported: ${output}")
endif()
endif()



6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ include_directories("${CMAKE_SOURCE_DIR}/src")

set(SOURCE_CODE
src/mpilib20.F90
src/routines/mpilib20_init_finalise.f90
src/bindings/mpi_bindings.F90
src/asserts.F90
src/routines/mpilib20_init_finalise.F90
src/bindings/mpi_bindings.F90
src/errors_warnings/asserts.F90
PARENT_SCOPE
)
34 changes: 17 additions & 17 deletions src/bindings/mpi_bindings.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
module mpi_bindings

! Default mpi bindings
#ifdef MPI08 then
! TODO MIght be easier to get rid of the use statement
#ifdef MPI08
! TODO Might be easier to get rid of the use statement
use mpi_f08, only: &

! Routines
Expand All @@ -21,14 +21,14 @@ module mpi_bindings
MPI_GROUP_SIZE, &

! Data types
MPI_COMM_WORLD, &
MPI_THREAD_SINGLE
MPI_THREAD_FUNNELED
MPI_THREAD_SERIALIZED
MPI_THREAD_MULTIPLE
MPI_COMM_WORLD, &
MPI_THREAD_SINGLE, &
MPI_THREAD_FUNNELED, &
MPI_THREAD_SERIALIZED, &
MPI_THREAD_MULTIPLE, &

! Derived types
MPI_comm, &
MPI_Comm, &
MPI_Datatype, &
MPI_Errhandler, &
MPI_File, &
Expand All @@ -41,11 +41,11 @@ module mpi_bindings
MPI_Status

implicit none
public
public

! Support for older mpi bindings
#else
! TODO MIght be easier to get rid of the use statement
#else
! TODO Might be easier to get rid of the use statement
use mpi, only: &

! Routines
Expand All @@ -60,9 +60,9 @@ module mpi_bindings

! Data types
MPI_COMM_WORLD, &
MPI_THREAD_SINGLE
MPI_THREAD_FUNNELED
MPI_THREAD_SERIALIZED
MPI_THREAD_SINGLE, &
MPI_THREAD_FUNNELED, &
MPI_THREAD_SERIALIZED, &
MPI_THREAD_MULTIPLE

implicit none
Expand All @@ -75,8 +75,8 @@ module mpi_bindings
! https://github.com/hpc/cce-mpi-openmpi-1.7.1/blob/master/ompi/mpi/fortran/use-mpi-f08-desc/mpi-f08-types.f90

! TODO Document each type
type MPI_comm
integer :: VALUE
type MPI_Comm
integer :: VALUE
end type
type :: MPI_Datatype
integer :: MPI_VAL
Expand Down Expand Up @@ -123,6 +123,6 @@ module mpi_bindings
!integer(C_SIZE_T), private :: c_count
end type MPI_Status

#endif
#endif

end module
13 changes: 12 additions & 1 deletion src/errors_warnings/asserts.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module asserts

contains

#ifdef DEBUG
!> Terminate following a failed assertion
!>
!> @todo Note, this kills ALL mpi processes. One may not want to do this
Expand All @@ -29,6 +30,7 @@ subroutine terminate()
call MPI_ABORT(MPI_COMM_WORLD, error_code_logical, ierr)
!stop error_code_logical
end subroutine terminate
#endif

!> Assert if a logical condition is true
!>
Expand All @@ -38,16 +40,25 @@ end subroutine terminate
subroutine assert_true(logical_condition, message)
!> Condition to test
logical, intent(in) :: logical_condition
#ifdef DEBUG
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Probs change back to USE_ASSRT

!> Optional message for termination
character(len=*), intent(in), optional :: message
#ifdef USE_ASSERT
if (.not. logical_condition) then
if (present(message)) then
write (error_unit, '(/,1x,a)') trim(adjustl(message))
endif
call terminate()
end if
#else
!> Optional message for termination
character(len=*), intent(inout), optional :: message
! Return prior to evaluating anything
return
! Peform a 'nothing' operation after return so Wunused-dummy-argument doesn't
! complain in release mode. Fortran needs C++17's [[maybe_unused]] attribute.
message = merge(message, message, logical_condition)
#endif

end subroutine assert_true

end module asserts
4 changes: 2 additions & 2 deletions src/routines/mpilib20_init_finalise.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
!> to be used as free subroutines.
module mpilib20_init_finalise
use, intrinsic :: iso_fortran_env, only: error_unit
use mpi_bindings, only: MPI_comm, MPI_Group
use mpi_bindings, only : MPI_Comm, MPI_Group
implicit none
private

Expand All @@ -14,7 +14,7 @@ module mpilib20_init_finalise
! TODO. Add get and set
!> MPI environment type
type, public :: mpi_env_type
type(MPI_comm) :: comm !! MPI communicator (integer in older bindings)
type(MPI_Comm) :: comm !! MPI communicator (integer in older bindings)
integer :: process !! Process id (rank)
integer :: n_processes !! Total number of processes
type(MPI_Group) :: group !! Group id (integer in older bindings)
Expand Down