From e13e08853490b4dc14fd83a2bf9ac9957a129fae Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Sat, 18 Nov 2023 15:15:42 -0600 Subject: [PATCH 1/4] added a new test Fixes #546 --- fpm.toml | 7 +- src/tests/jf_test_50.F90 | 94 +++++++++++++++++++ .../jsonfortrantest/jsonfortrantest.vfproj | 1 + 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/tests/jf_test_50.F90 diff --git a/fpm.toml b/fpm.toml index 605d4de22..6d5543f9b 100644 --- a/fpm.toml +++ b/fpm.toml @@ -256,4 +256,9 @@ main = "jf_test_48.F90" [[test]] name = "jf_test_49" source-dir = "src/tests" -main = "jf_test_49.F90" \ No newline at end of file +main = "jf_test_49.F90" + +[[test]] +name = "jf_test_50" +source-dir = "src/tests" +main = "jf_test_50.F90" \ No newline at end of file diff --git a/src/tests/jf_test_50.F90 b/src/tests/jf_test_50.F90 new file mode 100644 index 000000000..e4fb7669e --- /dev/null +++ b/src/tests/jf_test_50.F90 @@ -0,0 +1,94 @@ +!***************************************************************************************** +!> +! Module for the 50th unit test. See Issue #546. + +module jf_test_50_mod + + use json_module, wp => json_RK, IK => json_IK, LK => json_LK, CK => json_CK + use, intrinsic :: iso_fortran_env , only: error_unit, output_unit + + implicit none + + private + public :: test_50 + +contains + + subroutine test_50(error_cnt) + + !! 50th unit test. see Issue #546 + + integer,intent(out) :: error_cnt + + real(wp),dimension(6,6),parameter :: pcir = reshape(& + [0.00_wp, 0.35_wp, 0.15_wp, 0.00_wp, 0.50_wp, 0.00_wp, & ! these are the columns + 1.00_wp, 0.00_wp, 0.00_wp, 0.25_wp, 0.00_wp, 0.00_wp, & + 0.00_wp, 0.00_wp, 0.00_wp, 1.00_wp, 0.00_wp, 0.00_wp, & + 0.00_wp, 0.90_wp, 0.55_wp, 0.00_wp, 0.00_wp, 0.90_wp, & + 0.00_wp, 0.00_wp, 0.30_wp, 0.00_wp, 0.00_wp, 0.70_wp, & + 0.00_wp, 0.00_wp, 0.00_wp, 1.10_wp, 0.50_wp, 0.00_wp], [6,6]) + + type(json_core) :: json + type(json_value),pointer :: p + + call json%initialize(compress_vectors = .true.) ! so it will print each col on one line + + call json%create_object(p,'') !create the root + call json_value_add_real_vec_2d(json, p, 'Pcir', pcir, by_col=.true.) + call json%print(p) + + error_cnt = 0 + + end subroutine test_50 + + subroutine json_value_add_real_vec_2d(json, p, name, val, by_col) + + implicit none + + class(json_core),intent(inout) :: json + type(json_value),pointer :: p + character(kind=CK,len=*),intent(in) :: name !! name of the variable + real(wp),dimension(:,:),intent(in) :: val !! value + logical,intent(in) :: by_col !! if true, write by column. if false, write by row + + type(json_value),pointer :: var + integer(IK) :: i !! counter + + !create a variable as an array: + call json%create_array(var,name) + + !populate as an array of arrays: + if (by_col) then + do i=1,size(val,2) + call json%add(var, CK_'', val(:,i)) + end do + else + do i=1,size(val,1) + call json%add(var, CK_'', val(i,:)) + end do + end if + + !add it: + call json%add(p, var) + + end subroutine json_value_add_real_vec_2d + +end module jf_test_50_mod +!***************************************************************************************** + +!***************************************************************************************** +#ifndef INTEGRATED_TESTS +program jf_test_50 + + use jf_test_50_mod , only: test_50 + + implicit none + integer :: n_errors + + call test_50(n_errors) + if (n_errors /= 0) stop 1 + +end program jf_test_50 +#endif +!***************************************************************************************** + diff --git a/visual_studio/jsonfortrantest/jsonfortrantest.vfproj b/visual_studio/jsonfortrantest/jsonfortrantest.vfproj index 9eda34b59..f3474f95d 100644 --- a/visual_studio/jsonfortrantest/jsonfortrantest.vfproj +++ b/visual_studio/jsonfortrantest/jsonfortrantest.vfproj @@ -95,5 +95,6 @@ + From 3603368479a9e4f02c3f4460a0950087e3304a57 Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Sat, 25 May 2024 09:40:12 -0500 Subject: [PATCH 2/4] test fix --- src/tests/jf_test_50.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/jf_test_50.F90 b/src/tests/jf_test_50.F90 index e4fb7669e..f2742de9b 100644 --- a/src/tests/jf_test_50.F90 +++ b/src/tests/jf_test_50.F90 @@ -34,7 +34,7 @@ subroutine test_50(error_cnt) call json%initialize(compress_vectors = .true.) ! so it will print each col on one line call json%create_object(p,'') !create the root - call json_value_add_real_vec_2d(json, p, 'Pcir', pcir, by_col=.true.) + call json_value_add_real_vec_2d(json, p, CK_'Pcir', pcir, by_col=.true.) call json%print(p) error_cnt = 0 @@ -48,7 +48,7 @@ subroutine json_value_add_real_vec_2d(json, p, name, val, by_col) class(json_core),intent(inout) :: json type(json_value),pointer :: p character(kind=CK,len=*),intent(in) :: name !! name of the variable - real(wp),dimension(:,:),intent(in) :: val !! value + real(wp),dimension(:,:),intent(in) :: val !! value logical,intent(in) :: by_col !! if true, write by column. if false, write by row type(json_value),pointer :: var From 4dfc05f6112c434b5ce602e184c8b95ada0a9914 Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Sat, 25 May 2024 09:47:04 -0500 Subject: [PATCH 3/4] CI version bumps --- .github/workflows/CI.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 838a3f56a..318759b9c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,7 +23,7 @@ jobs: run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4.1.6 with: submodules: recursive @@ -34,12 +34,12 @@ jobs: cmake-version: '3.19.x' - name: Install Python - uses: actions/setup-python@v4 # Use pip to install latest CMake, & FORD/Jin2For, etc. + uses: actions/setup-python@v5.1.0 # Use pip to install latest CMake, & FORD/Jin2For, etc. with: python-version: ${{ matrix.python-version }} - name: Setup Graphviz - uses: ts-graphviz/setup-graphviz@v1 + uses: ts-graphviz/setup-graphviz@v2.0.2 - name: Install Python dependencies if: contains( matrix.os, 'ubuntu') From 1f01ab13a9044ef1272c5fe8d34510d94e9c6fd1 Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Sat, 25 May 2024 10:34:25 -0500 Subject: [PATCH 4/4] more CI bumps and removed depreciated set-output --- .github/workflows/CI.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 318759b9c..16c970759 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,7 +20,8 @@ jobs: - name: Set vars id: vars - run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + # run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} # this is depreciated: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ + run: echo "name=tag::${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - name: Checkout code uses: actions/checkout@v4.1.6 @@ -29,7 +30,7 @@ jobs: - name: Setup cmake if: contains( matrix.gcc_v, 9 ) - uses: jwlawson/actions-setup-cmake@v1.13 + uses: jwlawson/actions-setup-cmake@v2.0.2 with: cmake-version: '3.19.x'