Skip to content

Commit

Permalink
Merge pull request #13 from Goddard-Fortran-Ecosystem/develop
Browse files Browse the repository at this point in the history
Various cleanup and fixes.
  • Loading branch information
tclune authored Apr 6, 2020
2 parents 7ca8b24 + f591dc0 commit b12b281
Show file tree
Hide file tree
Showing 26 changed files with 242 additions and 524 deletions.
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# ------------------------------------------------------------------------ #
cmake_minimum_required (VERSION 3.8.0)
project (PFLOGGER
VERSION 1.3.1
VERSION 1.3.3
LANGUAGES Fortran)

set (CMAKE_MODULE_PATH
Expand All @@ -35,7 +35,8 @@ find_package (GFTL REQUIRED)
find_package (GFTL_SHARED REQUIRED)
find_package (YAFYAML REQUIRED)

find_package (MPI)
find_package (MPI QUIET)
find_package (PFUNIT QUIET)

#-----------------------------------
# Set default Fortran compiler flags
Expand All @@ -62,7 +63,6 @@ endif ()
add_subdirectory(src)
add_subdirectory(doc EXCLUDE_FROM_ALL)

find_package (PFUNIT QUIET)
if (PFUNIT_FOUND)
enable_testing()
if (NOT TARGET tests)
Expand All @@ -74,3 +74,12 @@ endif()
add_subdirectory(examples EXCLUDE_FROM_ALL)
add_subdirectory(benchmarks EXCLUDE_FROM_ALL)

# find_package() support
configure_file (PFLOGGERConfig-version.cmake.in ${PROJECT_BINARY_DIR}/PFLOGGERConfig-version.cmake @ONLY)
configure_file (PFLOGGERConfig.cmake.in ${PROJECT_BINARY_DIR}/PFLOGGERConfig.cmake @ONLY)

set (top_dir PFLOGGER-${PFLOGGER_VERSION_MAJOR}.${PFLOGGER_VERSION_MINOR})
install (
FILES ${PROJECT_BINARY_DIR}/PFLOGGERConfig.cmake ${PROJECT_BINARY_DIR}/PFLOGGERConfig-version.cmake
DESTINATION "${top_dir}/cmake")

11 changes: 9 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added


## [1.3.3] - 2020-04-06

### Changed
- Must use true/false instead of .true./.false. for YAML

### Fixed
- Fixed CMake test for support of MPI_ALLOC_MEM
- Improved Cmake handling of mock to allow tests to compile
without linking to MPI
- Added missing init() in Test_MpiLock tests


## [1.3.2] - 2020-03-16

Expand Down
19 changes: 19 additions & 0 deletions PFLOGGERConfig-version.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# my_library-config-version.cmake - checks version: major must match, minor must be less than or equal

set(PACKAGE_VERSION @PFLOGGER_VERSION@)

if (PACKAGE_FIND_VERSION_MAJOR EQUAL 0)
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else()
if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "@PFLOGGER_VERSION_MAJOR@")
if ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL "@PFLOGGER_VERSION_MINOR@")
set(PACKAGE_VERSION_EXACT TRUE)
elseif("${PACKAGE_FIND_VERSION_MINOR}" LESS "@PFLOGGER_VERSION_MINOR@")
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else()
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
else()
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
endif()
7 changes: 7 additions & 0 deletions PFLOGGERConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Package configuration file

get_filename_component (SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set (PREFIX ${SELF_DIR}/../..)
set (PFLOGGER_TOP_DIR ${PREFIX}/PFLOGGER-@PFLOGGER_VERSION_MAJOR@.@PFLOGGER_VERSION_MINOR@ CACHE PATH "")
include ("${PFLOGGER_TOP_DIR}/cmake/PFLOGGER.cmake")

33 changes: 17 additions & 16 deletions cmake/CheckFortranSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ macro (CHECK_FORTRAN_SOURCE_COMPILE file var)
message (STATUS "Performing Test ${var}")
endif ()

if (${ARGN})
try_compile (
${var}
${CMAKE_BINARY_DIR}
${file}
CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${MPI_Fortran_Flags}"
"-DINCLUDE_DIRECTORIES:LIST=${MPI_Fortran_INCLUDE_PATH}"
"-DLINK_LIBRARIES:LIST=${MPI_Fortran_LIBRARIES}"
)
else ()
try_compile (
${var}
${CMAKE_BINARY_DIR}
${file}
)
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)
Expand Down
5 changes: 3 additions & 2 deletions cmake/Intel.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set (FPP_FLAG "-cpp")
set (CMAKE_Fortran_FLAGS_RELEASE "${FPP_FLAG} -O3 -free -stand f08")
set (SUPPRESS_LINE_LENGTH_WARNING "-diag-disable 5268")
set (CMAKE_Fortran_FLAGS_RELEASE "${FPP_FLAG} -O3 -free -stand f08 ${SUPPRESS_LINE_LENGTH_WARNING}")
set (CMAKE_Fortran_FLAGS_DEBUG "${FPP_FLAG} -O0 -g -traceback \
-check uninit -free -stand f08 -save-temps")
-check uninit -free -stand f08 -save-temps ${SUPPRESS_LINE_LENGTH_WARNING}")

2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_subdirectory(serial)
if (MPI)
if (MPI_FOUND)
add_subdirectory(mpi)
endif()
11 changes: 3 additions & 8 deletions examples/mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
include_directories(${CMAKE_BINARY_DIR}/src)
include_directories(${FTL}/mod)

link_directories(${FTL}/lib)

# Need to access cfg files when running examples.
file (GLOB CONFIG_INPUTS "${CMAKE_CURRENT_SOURCE_DIR}/*.cfg")
file (COPY ${CONFIG_INPUTS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

if (MPI)
if (MPI_FOUND)

add_executable(sharedFileHandle.x sharedFileHandle.F90)
target_link_libraries(sharedFileHandle.x logger ftl ${MPI_Fortran_LIBRARIES})
target_link_libraries(sharedFileHandle.x pflogger MPI::MPI_Fortran)

add_executable(complexMpi.x complexMpi.F90)
target_link_libraries(complexMpi.x logger ftl ${MPI_Fortran_LIBRARIES})
target_link_libraries(complexMpi.x pflogger MPI::MPI_Fortran)

endif()

14 changes: 7 additions & 7 deletions examples/mpi/all_in_one.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ locks:
formatters:
basic:
class: Formatter
format: '%(name)a~: %(levelName)a~: %(message)a'
format: '%(name)a~: %(level_name)a~: %(message)a'
mpi:
class: MpiFormatter
format: '%(mpi_rank)i4.4~: %(name)~: %(levelName)a~: %(message)a'
format: '%(mpi_rank)i4.4~: %(name)~: %(level_name)a~: %(message)a'
comm: MPI_COMM_WORLD
column:
class: Formatter
format: '(%(i)i3.3,%(j)i3.3): %(levelName)'
format: '(%(i)i3.3,%(j)i3.3): %(level_name)'

handlers:
console:
Expand Down Expand Up @@ -56,22 +56,22 @@ handlers:
level: DEBUG

root:
parallel: .true.
parallel: true
handlers: [warnings,errors]
level: WARNING

loggers:

main:
parallel: .false.
parallel: false
comm: MPI_COMM_WORLD
level: INFO

parallel:
parallel: .true.
parallel: true
handlers: [mpi_debug,mpi_shared]
lock: mpi
propagate: .false.
propagate: false
level: DEBUG

main.A:
Expand Down
30 changes: 24 additions & 6 deletions examples/mpi/complexMpi.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
subroutine sub_A()
use FTL_String_mod
use PFL_String
use pflogger

integer :: i
Expand All @@ -9,19 +9,27 @@ subroutine sub_A()
log => logging%get_logger('main.A')
plog => logging%get_logger('parallel.A')

print*,__FILE__,__LINE__
call log%info('at line: %i3.3 in file: %a', __LINE__,String(__FILE__))
print*,__FILE__,__LINE__
call log%debug('inside sub_A')
print*,__FILE__,__LINE__
call plog%info('at line: %i3.3 in file: %a', __LINE__,String(__FILE__))
print*,__FILE__,__LINE__
call plog%debug('inside sub_A')
print*,__FILE__,__LINE__

print*,__FILE__,__LINE__
call log%warning('empty procedure')
print*,__FILE__,__LINE__
call log%info('at line: %i3.3 in file: %a', __LINE__,String(__FILE__))
print*,__FILE__,__LINE__

end subroutine sub_A


subroutine sub_B()
use FTL_String_mod
use PFL_String
use pflogger

integer :: i
Expand All @@ -42,31 +50,41 @@ end subroutine sub_B


program main
use FTL_String_mod
use PFL_String
use pflogger
use FTL_YAML_Parser_mod
use FTL_Config_mod
implicit none

integer :: ier
class (Logger), pointer :: log
integer :: rc
integer :: rank

call mpi_init(ier)

block
use mpi
call mpi_comm_rank(MPI_COMM_WORLD, rank, rc)
end block
call initialize() ! init logger

print*,__FILE__,__LINE__
call logging%load_file('all_in_one.cfg')
print*,__FILE__,__LINE__,rank

log => logging%get_logger('main')
print*,__FILE__,__LINE__, rank

call log%info('at line: %i3.3 in file: %a', __LINE__,string(__FILE__))
print*,__FILE__,__LINE__, rank
call sub_A()
print*,__FILE__,__LINE__, rank

call log%info('at line: %i3.3 in file: %a', __LINE__,string(__FILE__))
print*,__FILE__,__LINE__, rank
call sub_B()
print*,__FILE__,__LINE__, rank

call log%info('at line: %i3.3 in file: %a', __LINE__,string(__FILE__))
print*,__FILE__,__LINE__, rank
call mpi_finalize(ier)

end program main
Expand Down
3 changes: 2 additions & 1 deletion examples/mpi/sharedFileHandle.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ program main

loggerA => logging%get_logger('A')

fmtr = Formatter('%(message) %(rank)')
fmtr = newFormatter('%(message) %(rank)')

fh = FileHandler('foo.txt', delay=.true.)
call fh%set_formatter(fmtr)
call fh%set_lock(MpiLock(MPI_COMM_WORLD))
Expand Down
6 changes: 1 addition & 5 deletions examples/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ file (GLOB CONFIG_INPUTS "${CMAKE_CURRENT_SOURCE_DIR}/*.cfg")
file (COPY ${CONFIG_INPUTS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

add_executable(complex.x complex.F90)
target_link_libraries(complex.x logger ftl)

if (MPI)
target_link_libraries(complex.x logger ftl ${MPI_Fortran_LIBRARIES})
endif ()
target_link_libraries(complex.x pflogger)

12 changes: 5 additions & 7 deletions examples/serial/complex.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
subroutine sub_A()
use FTL_String_mod
use pfl_String
use pflogger

integer :: i
Expand All @@ -18,7 +18,7 @@ end subroutine sub_A


subroutine sub_B()
use FTL_String_mod
use pfl_String
use pflogger

integer :: i
Expand All @@ -27,20 +27,18 @@ subroutine sub_B()

log => logging%get_logger('main.B')

call log%debug('at line: %i3.3 in file: %a', __LINE__,string(__FILE__))
call log%debug('at line: %i3.3 in file: %a', __LINE__,String(__FILE__))
call log%info('inside sub_B')

call log%error('this procedure is empty as well')
call log%debug('at line: %i3.3 in file: %a', __LINE__,string(__FILE__))
call log%debug('at line: %i3.3 in file: %a', __LINE__,String(__FILE__))

end subroutine sub_B


program main
use FTL_String_mod
use pfl_String
use pflogger
use FTL_YAML_Parser_mod
use FTL_Config_mod
implicit none

integer :: ier
Expand Down
Loading

0 comments on commit b12b281

Please sign in to comment.