Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
tclune committed Jun 30, 2022
2 parents bb6129e + 3b4d7f8 commit 3004543
Show file tree
Hide file tree
Showing 26 changed files with 367 additions and 128 deletions.
54 changes: 53 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- "COPYRIGHT"

jobs:
build:
GNU:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -89,3 +89,55 @@ jobs:
path: |
build/**/*.log
Intel:
runs-on: ubuntu-20.04

env:
FC: ifort
CC: icc

name: Intel Fortran
steps:
- name: Install Intel compilers
run: |
cd /tmp
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt install --no-install-recommends intel-oneapi-compiler-fortran intel-oneapi-mpi \
intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic intel-oneapi-mpi-devel
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- name: Compiler Versions
run: |
${FC} --version
cmake --version
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Build GFE Prereqs
run: |
bash ./tools/ci-install-gfe.bash
- name: Build yaFyaml
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_Fortran_COMPILER=${FC} -DCMAKE_INSTALL_PREFIX=${HOME}/Software/yaFyaml -DCMAKE_PREFIX_PATH=${HOME}/Software/GFE
make -j$(nproc)
- name: Build Tests
run: |
cd build
make -j$(nproc) tests
- name: Run Tests
run: |
cd build
ctest -j1 --output-on-failure --repeat until-pass:4
- name: Archive log files on failure
uses: actions/upload-artifact@v2
if: failure()
with:
name: logfiles
path: |
build/**/*.log
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12)

project (YAFYAML
VERSION 1.0.3
VERSION 1.0.4
LANGUAGES Fortran)

# Most users of this software do not (should not?) have permissions to
Expand Down
9 changes: 8 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.0.3] 2022-06-15
## [1.0.4] 2022-06-30

### Fixed

- Fixed bug in Parser.F90 for using alias in a sequence. Isolating test added to test suite.

## [1.0.3] 2022-06-30

### Fixed
- Removed all stop statements and replaced with proper error handling and return codes
- Fixed schemas "to" calls to produce INT64 and REAL64 rather than plain integer and real
- Implemented workarounds for GNU in some unit tests

## [1.0.2] 2022-06-01

### Fixed
Expand Down
1 change: 1 addition & 0 deletions cmake/GNU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(cpp "-cpp")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
set(CMAKE_Fortran_FLAGS "-g -O0 ${cpp} ${traceback} -ffree-line-length-512 ${check_all}")
#set(CMAKE_Fortran_FLAGS "-g -O0 ${cpp} ${traceback} -ffree-line-length-512 ${check_all} -fsanitize=address")


add_definitions(-D_GNU)
4 changes: 2 additions & 2 deletions include/error_handling.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

! Assumes status is passed back in dummy called "rc"
#define __RETURN__(a) call return_rc(a,__FILE__,__LINE__ ___rc___(rc)); __return__
#define __VERIFY__(a) if(verify(a,__FILE__,__LINE__ ___rc___(rc=rc))) __return__
#define __VERIFY2__(msg,a) if(verify(a,__FILE__,__LINE__ ___rc2___(msg,rc))) __return__
#define __VERIFY__(a) if(internal_verify(a,__FILE__,__LINE__ ___rc___(rc=rc))) __return__
#define __VERIFY2__(msg,a) if(internal_verify(a,__FILE__,__LINE__ ___rc2___(msg,rc))) __return__

#define __ASSERT_CODE_AND_LOC_AND_RC__(cond,code,file,line,rc) if(assert(cond,code,file,line ___rc___(rc))) __return__
#define __ASSERT_CODE_AND_LOC__(cond,code,file,line) __ASSERT_CODE_AND_LOC_AND_RC__(cond,code,file,line,rc=rc)
Expand Down
11 changes: 8 additions & 3 deletions src/AbstractSchema.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@ logical function matches(text)
end function matches


logical function to_logical(text)
logical function to_logical(text,rc)
import AbstractSchema
character(*), intent(in) :: text
integer, optional, intent(out) :: rc
end function to_logical

integer function to_integer(text)
integer(kind=INT64) function to_integer(text,rc)
use, intrinsic :: iso_fortran_env, only: INT64
import AbstractSchema
character(*), intent(in) :: text
integer, optional, intent(out) :: rc
end function to_integer

real function to_real(text)
real(kind=REAL64) function to_real(text,rc)
use, intrinsic :: iso_fortran_env, only: REAL64
import AbstractSchema
character(*), intent(in) :: text
integer, optional, intent(out) :: rc
end function to_real

end interface
Expand Down
27 changes: 17 additions & 10 deletions src/CoreSchema.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "error_handling.h"
module fy_CoreSchema
use fy_AbstractSchema
use fy_ErrorHandling
use fy_ErrorCodes
use, intrinsic :: iso_fortran_env, only: REAL64, INT64
implicit none
private

Expand Down Expand Up @@ -268,38 +272,41 @@ end function matches_exponent

end function matches_real

logical function to_logical(text)
logical function to_logical(text,rc)
character(*), intent(in) :: text
integer, optional, intent(out) :: rc

select case (text)
case ('true', 'True', 'TRUE')
to_logical = .true.
case ('false', 'False', 'FALSE')
to_logical = .false.
case default
__FAIL__(YAFYAML_NONSPECIFIC_ERROR)
end select
__RETURN__(YAFYAML_SUCCESS)

end function to_logical

integer function to_integer(text)
integer(kind=INT64) function to_integer(text, rc)
character(*), intent(in) :: text
integer, optional, intent(out) :: rc

integer :: status
read(text,*, iostat=status) to_integer
if (status /= 0) then
error stop 'could not convert to integer'
end if

__VERIFY__(status)
__RETURN__(YAFYAML_SUCCESS)
end function to_integer


real function to_real(text)
real(kind=REAL64) function to_real(text,rc)
character(*), intent(in) :: text
integer, optional, intent(out) :: rc

integer :: status
read(text,*, iostat=status) to_real
if (status /= 0) then
error stop 'could not convert to real'
end if
__VERIFY__(status)
__RETURN__(YAFYAML_SUCCESS)

end function to_real

Expand Down
6 changes: 3 additions & 3 deletions src/ErrorHandling.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module fy_ErrorHandling

public :: throw
public :: assert
public :: verify
public :: internal_verify
public :: return_rc
public :: set_throw_method

Expand Down Expand Up @@ -95,7 +95,7 @@ logical function assert_code(condition, code, filename, line, unusable, err_msg,
end function assert_code


logical function verify(status, filename, line, unusable, err_msg, rc) result(fail)
logical function internal_verify(status, filename, line, unusable, err_msg, rc) result(fail)
integer, intent(in) :: status
character(*), intent(in) :: filename
integer, intent(in) :: line
Expand All @@ -119,7 +119,7 @@ logical function verify(status, filename, line, unusable, err_msg, rc) result(fa
end if

__UNUSED_DUMMY__(unusable)
end function verify
end function internal_verify


subroutine return_rc(status, filename, line, rc)
Expand Down
19 changes: 13 additions & 6 deletions src/FailsafeSchema.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "error_handling.h"
module fy_FailsafeSchema
use fy_AbstractSchema
use fy_ErrorCodes
use fy_ErrorHandling
use, intrinsic :: iso_fortran_env, only: REAL64, INT64
implicit none
private

Expand Down Expand Up @@ -55,19 +59,22 @@ logical function matches_real(text) result(matches)
end function matches_real


logical function to_logical(text)
logical function to_logical(text,rc)
character(*), intent(in) :: text
error stop 'Failsafe schema does not support bool'
integer, optional, intent(out) :: rc
__RETURN__(YAFYAML_NONSPECIFIC_ERROR)
end function to_logical

integer function to_integer(text)
integer(kind=INT64) function to_integer(text,rc)
character(*), intent(in) :: text
error stop 'Failsafe schema does not support integer'
integer, optional, intent(out) :: rc
__RETURN__(YAFYAML_NONSPECIFIC_ERROR)
end function to_integer

real function to_real(text)
real(kind=REAL64) function to_real(text,rc)
character(*), intent(in) :: text
error stop 'Failsafe schema does not support float'
integer, optional, intent(out) :: rc
__RETURN__(YAFYAML_NONSPECIFIC_ERROR)
end function to_real

end module fy_FailsafeSchema
Expand Down
32 changes: 19 additions & 13 deletions src/JSONSchema.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "error_handling.h"
module fy_JSONSchema
use fy_AbstractSchema
use fy_ErrorCodes
use fy_ErrorHandling
use, intrinsic :: iso_fortran_env, only: REAL64, INT64

implicit none
private

Expand Down Expand Up @@ -169,40 +174,41 @@ end function matches_exponent
end function matches_real


logical function to_logical(text)
logical function to_logical(text,rc)
character(*), intent(in) :: text
integer, optional, intent(out) :: rc

select case (text)
case ('true')
to_logical = .true.
case ('false')
to_logical = .false.
end select
__RETURN__(YAFYAML_SUCCESS)

end function to_logical

integer function to_integer(text)
integer(kind=INT64) function to_integer(text,rc)
character(*), intent(in) :: text
integer, optional, intent(out) :: rc

integer :: status
read(text,*, iostat=status) to_integer
if (status /= 0) then
error stop 'could not convert to integer'
end if


read(text,*, iostat=status)
__VERIFY__(status)
__RETURN__(YAFYAML_SUCCESS)
end function to_integer


real function to_real(text)
real(kind=REAL64) function to_real(text,rc)
character(*), intent(in) :: text
integer, optional, intent(out) :: rc

integer :: status

read(text,*, iostat=status) to_real
if (status /= 0) then
error stop 'could not convert to real'
end if

read(text,*, iostat=status)
__VERIFY__(status)
__RETURN__(YAFYAML_SUCCESS)
end function to_real

end module fy_JSONSchema
Expand Down
8 changes: 6 additions & 2 deletions src/Nodes/BoolNode.F90
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,20 @@ subroutine write_node_formatted(this, unit, iotype, v_list, iostat, iomsg)

end subroutine write_node_formatted

subroutine clone(to, from)
subroutine clone(to, from, unusable, rc)
class(BoolNode), intent(out) :: to
class(YAML_Node), intent(in) :: from
class(KeywordEnforcer), optional, intent(in) :: unusable
integer, optional, intent(out) :: rc

select type(from)
type is (BoolNode)
to%value = from%value
class default
error stop "expected bool node"
__FAIL__(YAFYAML_TYPE_MISMATCH)
end select
__RETURN__(YAFYAML_SUCCESS)
__UNUSED_DUMMY__(unusable)

end subroutine clone

Expand Down
8 changes: 6 additions & 2 deletions src/Nodes/FloatNode.F90
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,20 @@ logical function verify_float(this) result(verify)
verify = .true.
end function verify_float

subroutine clone(to, from)
subroutine clone(to, from, unusable, rc)
class(FloatNode), intent(out) :: to
class(YAML_Node), intent(in) :: from
class(KeywordEnforcer), optional, intent(in) :: unusable
integer, optional, intent(out) :: rc

select type(from)
type is (FloatNode)
to%value = from%value
class default
error stop "expected float node"
__FAIL__(YAFYAML_TYPE_MISMATCH)
end select
__RETURN__(YAFYAML_SUCCESS)
__UNUSED_DUMMY__(unusable)

end subroutine clone

Expand Down
Loading

0 comments on commit 3004543

Please sign in to comment.