Skip to content

Add matrix get support #1

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

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ac0c9a4
WIP: Interface for matrix calls
porteri Aug 14, 2018
a94db82
WIP: matrix test
porteri Aug 14, 2018
0b570b5
Can get 2d matrix and array of matrices
porteri Aug 14, 2018
2e6c559
Removed write statement
porteri Aug 14, 2018
2d81c1b
Added ability to determine supplied array lengths
porteri Aug 14, 2018
8ac9898
Print test output on failure with check target
zbeekman Aug 14, 2018
80a1d1d
WIP: Found issue with new logic
porteri Aug 14, 2018
1b60c8d
Write format issue fix
porteri Aug 31, 2018
5e9cebb
Fix bad JSON in test
zbeekman Sep 3, 2018
c1e5bd3
Merge branch 'master' into add_matrix_support
zbeekman Sep 27, 2018
2760dfb
Merge branch 'master' into add_matrix_support
zbeekman Nov 16, 2018
f4d7edc
Fix for undefined variable in test#26
Feb 16, 2019
d0a9718
Merge pull request #2 from nrc-fuels/fix_failing_test
porteri Feb 16, 2019
d99c2ae
Merge branch 'master' into add_matrix_support
Feb 16, 2019
20f7059
Merge fix
Feb 16, 2019
34a446e
Merge branch 'master' of github.com:jacobwilliams/json-fortran into a…
zbeekman Mar 29, 2019
0bf4831
Only install module files, not config dir with IDE
zbeekman Mar 29, 2019
ce9c43b
Merge branch 'module_install_w_IDEs' of github.com:zbeekman/json-fort…
zbeekman Mar 30, 2019
f582c41
Revert "Merge branch 'module_install_w_IDEs' of github.com:zbeekman/j…
zbeekman Apr 5, 2019
cb0838d
Merge branch 'module_install_w_IDEs' into add_matrix_support
zbeekman Apr 5, 2019
d3de9dd
Add option to build and link against OpenCoarrays
zbeekman Jun 20, 2019
1a478b7
Merge tag '7.1.0' of github.com:jacobwilliams/json-fortran into add_m…
zbeekman Jul 22, 2019
414003e
Move matrix test (40.f90) to 41.F90
zbeekman Jul 22, 2019
acf4659
Testing: Use CTest fixtures to manipulate files
zbeekman Jul 22, 2019
96770c1
fixed a dangling pointer in test 10. Fixes #422
jacobwilliams Jul 23, 2019
b41abbb
Merge pull request #423 from jacobwilliams/422-dangling-pointer
jacobwilliams Jul 23, 2019
c5aa7d3
TESTING: Use fixtures to copy and cleanup files
zbeekman Jul 22, 2019
7693a30
Travis-CI: Install jsonlint from node/npm
zbeekman Jul 22, 2019
42e731a
CMake: Don't rely on diff for testing
zbeekman Jul 22, 2019
789e755
Add a config option to compile & link against OC
zbeekman Jul 22, 2019
a7e7978
CHANGELOG: Add entry/comment about OpenCoarrays
zbeekman Jul 23, 2019
ffca283
Merge pull request #421 from nrc-fuels/test-fixtures-413
jacobwilliams Jul 24, 2019
64f1fea
Merge branch 'master' of github.com:jacobwilliams/json-fortran into a…
zbeekman Jul 25, 2019
2f4354b
Fix matrix test name clashes
zbeekman Jul 25, 2019
c80d070
CMake: Remove extra instance of OC linking option
zbeekman Jul 25, 2019
1c46747
Allow ragged edge matrices in `matrix_info`s
zbeekman Aug 1, 2019
0a12758
WIP: Transfering from laptop to work machine
zbeekman Aug 5, 2019
c3bdf40
WIP: Commit unsaved changes to move from laptop
zbeekman Aug 5, 2019
ede35d2
Remove errant string matrix overloads/interfaces
zbeekman Aug 6, 2019
7ee642b
Updating to remove json tests for Windows as a temporary workaround b…
dcolameco Nov 2, 2022
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
17 changes: 16 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ matrix:
- kalakris-cmake
- ubuntu-toolchain-r-test
packages:
- nodejs
- npm
- gfortran-6
- binutils
- cmake
Expand All @@ -44,6 +46,8 @@ matrix:
sources:
- ubuntu-toolchain-r-test
packages:
- nodejs
- npm
- gfortran-6
- binutils
- python-pip
Expand All @@ -64,6 +68,8 @@ matrix:
sources:
- ubuntu-toolchain-r-test
packages:
- nodejs
- npm
- gfortran-7
- binutils
- python-pip
Expand All @@ -82,6 +88,8 @@ matrix:
sources:
- ubuntu-toolchain-r-test
packages:
- nodejs
- npm
- gfortran-8
- binutils
- python-pip
Expand All @@ -100,6 +108,8 @@ matrix:
sources:
- ubuntu-toolchain-r-test
packages:
- nodejs
- npm
- gfortran-9
- binutils
- python-pip
Expand All @@ -126,7 +136,12 @@ install:
- pip install --upgrade graphviz
- (pip install --upgrade FoBiS.py==2.2.8 && FoBiS.py --version)
- (pip install --upgrade ford==6.0.0 && ford --version)
- (pip install --upgrade git+https://github.com/dmeranda/demjson.git && jsonlint --version)
- export NPM_PACKAGES="${HOME}/.npm-packages"
- mkdir "${HOME}/.npm-packages" || true
- npm config set prefix "${HOME}/.npm-packages"
- export PATH="${HOME}/.npm-packages/bin:$PATH"
- npm install -g jsonlint
- jsonlint --version || true # Why would you exit non-zero from --version ???!?!?! wth

before_script:
- |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@

[Complete Changeset](https://github.com/jacobwilliams/json-fortran/compare/7.1.0...HEAD)

**Enhancements:**

- Allow linking to JSON-Fortran from GFortran programs using
[OpenCoarrays](https://github.com/sourceryinstitute/OpenCoarrays#readme)
as the coarray runtime implementation. Use the
`-DJSON_FORTRAN_USE_OpenCoarrays:BOOL=ON` option to cmake to enable
this. (NOTE: The fact that this is required may be a bug in
GFortran.)

### [7.1.0](https://github.com/jacobwilliams/json-fortran/tree/7.1.0) (2019-06-23)

[Complete Changeset](https://github.com/jacobwilliams/json-fortran/compare/7.0.0...7.1.0)
Expand Down
117 changes: 74 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ include ( "cmake/checkOutOfSource.cmake" )
#---------------------
project ( jsonfortran NONE )

if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
option(JSON_FORTRAN_USE_OpenCoarrays
"Build JSON-Fortran with support for linking against OpenCoarray programs" OFF)
endif()
if(JSON_FORTRAN_USE_OpenCoarrays)
find_package(OpenCoarrays)
endif()

#---------------------
# Real and Integer kinds
#---------------------
Expand Down Expand Up @@ -83,7 +91,8 @@ set ( JF_LIB_SRCS src/json_kinds.F90
src/json_value_module.F90
src/json_file_module.F90
src/json_module.F90 )
file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.F90" )
#file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.F90" ) Commented out to remove json test cases for Windows issues with parallel processing
file ( GLOB JF_TEST_SRCS "src/tests/jf_test2_*.F90" )
set ( JF_TEST_UCS4_SUPPORT_SRC "${CMAKE_SOURCE_DIR}/src/tests/introspection/test_iso_10646_support.f90")

#-----------------------------------------
Expand Down Expand Up @@ -161,6 +170,14 @@ endif ()
set ( LIB_NAME ${CMAKE_PROJECT_NAME} )
add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} )
add_library ( ${LIB_NAME}-static STATIC ${JF_LIB_SRCS} )

if(JSON_FORTRAN_USE_OpenCoarrays)
target_link_libraries(${LIB_NAME}
PRIVATE OpenCoarrays::caf_mpi_static)
target_link_libraries(${LIB_NAME}-static
PRIVATE OpenCoarrays::caf_mpi_static)
endif()

set_target_properties ( ${LIB_NAME}-static
PROPERTIES
OUTPUT_NAME ${LIB_NAME}
Expand Down Expand Up @@ -273,14 +290,11 @@ if ( ENABLE_TESTS )
add_dependencies(build_tests ${LIB_NAME} ${LIB_NAME}-static)

find_program ( JSONLINT jsonlint )
find_program ( DIFF diff )
file ( COPY "${CMAKE_SOURCE_DIR}/files"
DESTINATION "${CMAKE_BINARY_DIR}/" )

set ( DATA_DIR "${CMAKE_BINARY_DIR}/files" )
set ( DATA_DIR "${CMAKE_SOURCE_DIR}/files" )

set_directory_properties ( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
"${DATA_DIR}/test2.json;${DATA_DIR}/test4.json;${FORD_CLEAN_OUTPUTS}" )
"${FORD_CLEAN_OUTPUTS}" )

# Validate input
if ( JSONLINT )
Expand All @@ -294,26 +308,38 @@ if ( ENABLE_TESTS )
foreach ( VALID_JSON ${JSON_INPUTS} )
get_filename_component ( TESTNAME "${VALID_JSON}" NAME )
add_test ( NAME validate-${TESTNAME}
WORKING_DIRECTORY "${DATA_DIR}/inputs"
COMMAND ${JSONLINT} "--allow=nonescape-characters" "${VALID_JSON}" )
WORKING_DIRECTORY "${DATA_DIR}/inputs"
COMMAND ${JSONLINT} "--allow=nonescape-characters" "${VALID_JSON}" )
endforeach ()

foreach ( INVALID ${INVALID_JSON} )
get_filename_component ( TESTNAME "${INVALID}" NAME )
add_test ( NAME validate-${TESTNAME}
WORKING_DIRECTORY "${DATA_DIR}/inputs"
COMMAND ${JSONLINT} "${INVALID}" )
WORKING_DIRECTORY "${DATA_DIR}/inputs"
COMMAND ${JSONLINT} "${INVALID}" )
set_property ( TEST validate-${TESTNAME}
PROPERTY
WILL_FAIL TRUE)
PROPERTY
WILL_FAIL TRUE)
endforeach ()
endif ()

add_test(NAME jf-cleanup-fixture
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/files")
set_tests_properties(jf-cleanup-fixture
PROPERTIES FIXTURES_SETUP JF)
add_test(NAME jf-setup-fixture
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${DATA_DIR}" "${CMAKE_BINARY_DIR}/files")
set_tests_properties(jf-setup-fixture
PROPERTIES FIXTURES_SETUP JF
DEPENDS jf-cleanup-fixture)

set ( UNIT_TESTS '' )
foreach ( UNIT_TEST ${JF_TEST_SRCS} )
get_filename_component ( TEST ${UNIT_TEST} NAME_WE )
if(MSVC_IDE)
link_directories(${CMAKE_BINARY_DIR}/lib)
link_directories(${CMAKE_BINARY_DIR}/lib)
endif()
add_executable ( ${TEST} EXCLUDE_FROM_ALL ${UNIT_TEST} )
target_link_libraries ( ${TEST} ${LIB_NAME} )
Expand All @@ -325,52 +351,57 @@ if ( ENABLE_TESTS )
add_test( NAME ${TEST}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
COMMAND ./${TEST})
set_tests_properties( ${TEST}
PROPERTIES FIXTURES_REQUIRED JF)
list ( APPEND UNIT_TESTS ${TEST} )
if ( JSONLINT )
set_property ( TEST ${TEST}
APPEND
PROPERTY DEPENDS validate-input1 validate-input2 )
APPEND
PROPERTY DEPENDS validate-input1 validate-input2 )
endif()
endforeach ( UNIT_TEST )

set_property ( TEST jf_test_03
APPEND
PROPERTY DEPENDS jf_test_02 )
#set_property ( TEST jf_test_03
# APPEND
# PROPERTY DEPENDS jf_test_02 )

# Validate output
file( GLOB EXPECTED_OUTPUTS "${DATA_DIR}/expected-outputs/*.json")
if (NOT ${ENABLE_UNICODE})
list( REMOVE_ITEM EXPECTED_OUTPUTS "${DATA_DIR}/expected-outputs/hello-world-ucs4.json")
endif()
list( REMOVE_ITEM EXPECTED_OUTPUTS "${DATA_DIR}/expected-outputs/example2.json")

if ( JSONLINT )
file ( GLOB JSON_FILES "${DATA_DIR}/*.json" )
foreach ( JSON_FILE ${JSON_FILES} )
foreach ( JSON_FILE ${EXPECTED_OUTPUTS} )
get_filename_component ( TESTNAME ${JSON_FILE} NAME )
add_test ( NAME validate-output-${TESTNAME}
WORKING_DIRECTORY "${DATA_DIR}"
COMMAND ${JSONLINT} "--allow=nonescape-characters" ${TESTNAME} )
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/files"
COMMAND ${JSONLINT} "--allow=nonescape-characters" ${TESTNAME} )
set_property ( TEST validate-output-${TESTNAME}
APPEND
PROPERTY
DEPENDS ${UNIT_TESTS}
REQUIRED_FILES ${JSON_FILES} )
APPEND
PROPERTY
DEPENDS ${UNIT_TESTS})
endforeach ( JSON_FILE )
endif ()

# Check output for differences
if ( DIFF )
file ( GLOB JSON_FILES "${DATA_DIR}/*.json" )
foreach ( JSON_FILE ${JSON_FILES} )
get_filename_component ( JSON_STEM ${JSON_FILE} NAME_WE )
add_test ( NAME regression-${JSON_STEM}.json
WORKING_DIRECTORY "${DATA_DIR}"
COMMAND ${DIFF} -q ${JSON_STEM}.json expected-outputs/${JSON_STEM}.json )
set_property ( TEST regression-${JSON_STEM}.json
APPEND
PROPERTY
DEPENDS ${UNIT_TESTS}
REQUIRED_FILES ${JSON_FILES} )
endforeach ( JSON_FILE )
else ()
message ( WARNING
"For full test coverage diff, or a similar tool must be present on your system" )
endif ()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
set( JSON_FORTRAN_COMPARE_FLAG "--ignore-eol")
endif()

foreach ( JSON_FILE ${EXPECTED_OUTPUTS} )
get_filename_component (OUTPUT ${JSON_FILE} NAME )
add_test ( NAME regression-${OUTPUT}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/files"
COMMAND ${CMAKE_COMMAND} -E compare_files ${JSON_FORTRAN_COMPARE_FLAG} ${OUTPUT} expected-outputs/${OUTPUT} )
set_property ( TEST regression-${OUTPUT}
APPEND
PROPERTY
DEPENDS ${UNIT_TESTS}
REQUIRED_FILES ${EXPECTED_OUTPUTS} )
endforeach ( JSON_FILE )


endif ()

Expand Down
2 changes: 1 addition & 1 deletion files/expected-outputs/test12.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"only one value"
],
"page": [
"The quick brown fox",
"The quick brown fox ",
"jumps over the lazy dog."
]
}
29 changes: 18 additions & 11 deletions files/expected-outputs/test2.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"inputs": {
"t0": 0.1E+0,
"tf": 0.11E+1,
"t0": 0.10000000000000001E+0,
"tf": 0.11000000000000001E+1,
"x0": 0.9999E+4,
"integer_scalar": 1,
"integer_array": [
Expand All @@ -20,7 +20,14 @@
false,
true
],
"null_variable": null
"null_variable": null,
"special chars": "\\ /",
"special chars in key \\ /": "\\ /",
"bspace": "\b",
"horizontal_tab": "\t",
"newline": "\n",
"formfeed": "\f",
"carriage_return": "\r"
},
"trajectory": [
{
Expand Down Expand Up @@ -58,35 +65,35 @@
},
{
"VARIABLE": "Vx",
"UNITS": "km\/s",
"UNITS": "km/s",
"FRAME": "J2000",
"CENTER": "EARTH",
"DATA": [
0.1E-2,
0.2E-2,
0.3E-2
0.30000000000000001E-2
]
},
{
"VARIABLE": "Vy",
"UNITS": "km\/s",
"UNITS": "km/s",
"FRAME": "J2000",
"CENTER": "EARTH",
"DATA": [
0.2E-2,
0.2E-1,
0.3E-2
0.30000000000000001E-2
]
},
{
"VARIABLE": "Vz",
"UNITS": "km\/s",
"UNITS": "km/s",
"FRAME": "J2000",
"CENTER": "EARTH",
"DATA": [
0.3E-2,
0.3E-1,
0.4E-1
0.30000000000000001E-2,
0.29999999999999999E-1,
0.40000000000000001E-1
]
}
]
Expand Down
13 changes: 13 additions & 0 deletions files/expected-outputs/test21.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"value": [
0.14142135623730951E+1,
0.17320508075688772E+1,
0.26457513110645907E+1,
0.14142135623730951E+3,
0.54772255750516615E+3,
0.26457513110645905E+4,
0.17976931348623157E+309,
0.22250738585072014E-307,
0.22204460492503131E-15
]
}
28 changes: 28 additions & 0 deletions files/inputs/test43.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"ragged_matrix": [
[ 0.2 ,0.01 ,0.02, 0.04],
[ 0.2 ,0.01 ,0.02],
[ 50.1 ,30.2],
[ 50.1 ,30.2 ,0.01 ,0.02 ,0.04],
[ 0.2 ,0.01 ,0.02],
[ 0.2 ,0.01 ,0.02 ,0.04]
],

"integer_matrix": [
[ 2, 0, 0, 4],
[ 0, 0, 2],
[ 50, 30],
[ 50, 30, 0, 0 , 4],
[ 0, 0, 2],
[ 2, 1, 0, 4]
],

"logical_matrix": [
[ true, false, false, false],
[ false, true, true],
[ true, true],
[ true, true, false, false, false],
[ true, false, false],
[ true, false, false, false]
]
}
Loading