From ef3df8e3cd1f8e53e6744dd4f3cf3afcd8e90035 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Mon, 28 Nov 2022 14:09:10 -0600 Subject: [PATCH 1/5] chore: update dependencies --- example/print-to-json.f90 | 8 ++-- example/read-from-json.f90 | 19 ++++----- fpm.toml | 10 ++--- src/dag_m.f90 | 5 +-- src/dag_s.f90 | 49 +++++++++++------------ src/vertex_m.f90 | 8 ++-- src/vertex_s.f90 | 81 ++++++++++++++------------------------ test/dag_test.f90 | 18 ++++----- test/main.f90 | 21 ++++++---- 9 files changed, 99 insertions(+), 120 deletions(-) diff --git a/example/print-to-json.f90 b/example/print-to-json.f90 index 468c6f8..09212ec 100644 --- a/example/print-to-json.f90 +++ b/example/print-to-json.f90 @@ -3,12 +3,12 @@ program print_to_json !! !! Compile and run run this program by executing the following !! command from the top-level directory of the dag source tree: - !! + !! !! fpm run --example print-to-json !! use dag_m, only: dag_t use vertex_m, only: vertex_t - use iso_varying_string, only : varying_string, var_str, char + use iso_varying_string, only : varying_string, var_str implicit none character(len=*), parameter :: longest_name = "iso_varying_string" @@ -27,7 +27,7 @@ program print_to_json ,dag_s => findloc(names, "dag_s", dim=1) & ,main => findloc(names, "main", dim=1) & ) - block + block type(dag_t) program_units program_units = dag_t([ & @@ -41,7 +41,7 @@ program print_to_json ]) associate(json_object => program_units%to_json()) - print *, char(json_object%to_expanded_string()) + print *, json_object%to_expanded_string() end associate end block end associate diff --git a/example/read-from-json.f90 b/example/read-from-json.f90 index abdd4b2..5a49384 100644 --- a/example/read-from-json.f90 +++ b/example/read-from-json.f90 @@ -4,10 +4,10 @@ program read_from_json !! Compile and run run this program by executing the following !! command from the top-level directory of the dag source tree: !! - !! fpm run --example read-from-json + !! fpm run --example read-from-json !! use dag_m, only: dag_t - use jsonff, only : parse_json_from_file, json_object_t + use rojff, only : parse_json_from_file, json_object_t use iso_varying_string, only : char implicit none @@ -15,19 +15,20 @@ program read_from_json associate(parsed_json => parse_json_from_file('example/dag-dependencies.json')) if (parsed_json%failed()) then - associate(errors => parsed_json%errors()) - error stop char(errors%to_string()) - end associate + error stop char(parsed_json%errors%to_string()) end if block - class(json_object_t), allocatable :: json_object type(dag_t) dag - json_object = parsed_json%value_() - dag = dag_t(json_object) + select type (obj => parsed_json%value_) + type is (json_object_t) + dag = dag_t(obj) + class default + error stop "json wasn't an object: " // obj%to_compact_string() + end select end block end associate -end program +end program diff --git a/fpm.toml b/fpm.toml index 205ad57..a5d4526 100644 --- a/fpm.toml +++ b/fpm.toml @@ -6,10 +6,10 @@ maintainer = "damian@sourceryinstitute.org" copyright = "2020-2021 Sourcery Institute" [dependencies] -jsonff = {git = "https://gitlab.com/everythingfunctional/jsonff", tag = "v3.0.0"} -erloff = {git = "https://gitlab.com/everythingfunctional/erloff", tag = "v2.1.0"} -iso_varying_string = {git = "https://gitlab.com/everythingfunctional/iso_varying_string", tag = "v2.0.0"} -assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.3.0"} +rojff = { git = "https://gitlab.com/everythingfunctional/rojff", tag = "v1.0.0" } +erloff = { git = "https://gitlab.com/everythingfunctional/erloff", tag = "v2.2.0" } +iso_varying_string = { git = "https://gitlab.com/everythingfunctional/iso_varying_string", tag = "v3.0.4" } +assert = { git = "https://github.com/sourceryinstitute/assert", tag = "1.4.0" } [dev-dependencies] -vegetables = {git = "https://gitlab.com/everythingfunctional/vegetables", tag = "v7.2.1"} +veggies = { git = "https://gitlab.com/everythingfunctional/veggies", tag = "v1.0.5" } diff --git a/src/dag_m.f90 b/src/dag_m.f90 index a172fe9..ae6506a 100644 --- a/src/dag_m.f90 +++ b/src/dag_m.f90 @@ -5,8 +5,7 @@ module dag_m !! date: 2020-Nov-30 !! license: Copyright (c) 2020, Sourcery Institute, BSD 3-clause license Copyright (c) 2018 Jacob Williams use vertex_m, only : vertex_t - use jsonff, only : json_object_t - use iso_varying_string, only : varying_string + use rojff, only : json_object_t implicit none @@ -68,7 +67,7 @@ elemental module function num_vertices(self) end function pure module function depends_on(self, vertex_num) result(dependencies) - !! Result is an array of the vertex numbers that depend on on vertex vertex_num + !! Result is an array of the vertex numbers that depend on on vertex vertex_num implicit none class(dag_t), intent(in) :: self integer, intent(in) :: vertex_num diff --git a/src/dag_s.f90 b/src/dag_s.f90 index 5e9bb53..77152fc 100644 --- a/src/dag_s.f90 +++ b/src/dag_s.f90 @@ -1,22 +1,21 @@ submodule(dag_m) dag_s use assert_m, only : assert - use jsonff, only: & + use rojff, only: & + fallible_json_member_t, & + fallible_json_object_t, & fallible_json_string_t, & fallible_json_value_t, & json_array_t, & - json_element_t, & - json_string_t, & - parse_json - use erloff, only : error_list_t + json_element_t use iso_fortran_env, only: iostat_end - use iso_varying_string, only : varying_string, operator(//), char, get, put, var_str + use iso_varying_string, only : operator(//), char use intrinsic_array_m, only : intrinsic_array_t implicit none type searched_and_ordered_t integer, allocatable, dimension(:) :: s, o - end type + end type contains @@ -109,36 +108,32 @@ end function topological_sort module procedure construct_from_json type(fallible_json_value_t) :: maybe_vertices - type(error_list_t) errors - maybe_vertices = json_object%get_element("vertices") - errors = maybe_vertices%errors() - call assert(.not. errors%has_any(), "dag_s construct_from_json: .not. errors%has_any()", char(errors%to_string())) + maybe_vertices = json_object%get("vertices") + call assert( & + .not. maybe_vertices%errors%has_any(), & + "dag_s construct_from_json: .not. errors%has_any()", & + char(maybe_vertices%errors%to_string())) - select type (vertices => maybe_vertices%value_()) + select type (vertices => maybe_vertices%value_) type is (json_array_t) - dag%vertices = vertex_t(vertices%get_elements()) + dag%vertices = vertex_t(vertices%elements) class default - call assert(.false., "dag%from_json: vertices was not an array", char(vertices%to_compact_string())) + call assert(.false., "dag%from_json: vertices was not an array", vertices%to_compact_string()) end select dag%order = topological_sort(dag) end procedure - module procedure to_json - type(fallible_json_string_t) maybe_key - type(error_list_t) errors - type(json_string_t) vertices_key - type(json_array_t) vertices_value + module procedure to_json + type(fallible_json_object_t) maybe_result - maybe_key = fallible_json_string_t("vertices") - errors = maybe_key%errors() - call assert(.not. errors%has_any(), "dag%to_json: .not. errors%has_any()", char(errors%to_string())) - - vertices_value = json_array_t(json_element_t(self%vertices%to_json())) - vertices_key = maybe_key%string() - json_object = json_object_t([vertices_key], [json_element_t(vertices_value)]) - end procedure + maybe_result = fallible_json_object_t( & + [ fallible_json_member_t("vertices", json_array_t(json_element_t(self%vertices%to_json()))) & + ]) + call assert(.not. maybe_result%errors%has_any(), "dag%to_json: .not. errors%has_any()", char(maybe_result%errors%to_string())) + json_object = maybe_result%object + end procedure module procedure num_vertices num_vertices = size(self%vertices) diff --git a/src/vertex_m.f90 b/src/vertex_m.f90 index 56c8293..c2bcde9 100644 --- a/src/vertex_m.f90 +++ b/src/vertex_m.f90 @@ -4,7 +4,7 @@ module vertex_m !! version: v1.0 !! date: 2020-Nov-30 !! license: Copyright (c) 2020-2021, Sourcery Institute, BSD 3-clause license Copyright (c) 2018 Jacob Williams - use jsonff, only : json_element_t, json_object_t, json_value_t + use rojff, only : json_element_t, json_object_t, json_value_t use iso_varying_string, only : varying_string implicit none @@ -21,10 +21,10 @@ module vertex_m contains procedure :: to_json procedure :: edges - procedure :: label + procedure :: label procedure :: attributes procedure :: edges_allocated - end type + end type interface vertex_t @@ -54,7 +54,7 @@ pure module function construct_from_components(edges, label, attributes) result( end interface interface - + elemental module function edges_allocated(self) result(edges_array_allocated) !! Result is .true. iff the edges component is allocated implicit none diff --git a/src/vertex_s.f90 b/src/vertex_s.f90 index da35a3c..d4fa37a 100644 --- a/src/vertex_s.f90 +++ b/src/vertex_s.f90 @@ -1,13 +1,14 @@ submodule(vertex_m) vertex_s - use jsonff, only : & + use rojff, only : & + fallible_json_member_t, & + fallible_json_object_t, & fallible_json_string_t, & fallible_json_value_t, & json_array_t, & json_number_t, & json_string_t, & json_integer_t - use erloff, only : error_list_t - use iso_varying_string, only : char, assignment(=) + use iso_varying_string, only : assignment(=), char use assert_m, only : assert implicit none @@ -18,36 +19,17 @@ end procedure module procedure to_json - integer i - type(json_string_t) :: edges_key, label_key, label_value - type(json_array_t) :: edges_value - type(error_list_t) :: errors - type(fallible_json_string_t) :: maybe_key, maybe_value - - maybe_key = fallible_json_string_t("edges") - errors = maybe_key%errors() - call assert(.not. errors%has_any(), "vertex%to_json (edges key): .not. errors%has_any()", char(errors%to_string())) - edges_key = maybe_key%string() - - if (allocated(self%edges_)) then - do i = lbound(self%edges_, 1), ubound(self%edges_, 1) - call edges_value%append(json_integer_t(self%edges_(i))) - end do - end if - - maybe_key = fallible_json_string_t("label") - errors = maybe_key%errors() - call assert(.not. errors%has_any(), "vertex%to_json (label key): .not. errors%has_any()", char(errors%to_string())) - label_key = maybe_key%string() - - maybe_value = fallible_json_string_t(self%label()) - errors = maybe_value%errors() - call assert(.not. errors%has_any(), "vertex%to_json (label value): .not. errors%has_any()", char(errors%to_string())) - label_value = maybe_value%string() - - - json_object = json_object_t([label_key, edges_key], [json_element_t(label_value), json_element_t(edges_value)]) - + type(fallible_json_object_t) :: maybe_result + + maybe_result = fallible_json_object_t( & + [ fallible_json_member_t("label", fallible_json_value_t(fallible_json_string_t(self%label_))) & + , fallible_json_member_t("edges", json_array_t(json_element_t(json_integer_t(self%edges_)))) & + ]) + call assert( & + .not. maybe_result%errors%has_any(), & + "vertex%to_json: .not. errors%has_any()", & + char( maybe_result%errors%to_string())) + json_object = maybe_result%object end procedure module procedure construct_from_components @@ -68,7 +50,7 @@ end procedure module procedure from_json_element - vertex = vertex_t(json_element%value_()) + vertex = vertex_t(json_element%json) end procedure module procedure from_json_value @@ -76,37 +58,34 @@ type is (json_object_t) vertex = from_json_object(json_value) class default - call assert(.false., "vertex%from_json_value: vertex was not an object", char(json_value%to_compact_string())) + call assert(.false., "vertex%from_json_value: vertex was not an object", json_value%to_compact_string()) end select end procedure module procedure from_json_object - type(error_list_t) :: errors - type(fallible_json_value_t) :: maybe_edge type(fallible_json_value_t) :: maybe_edges integer :: i - maybe_edges = json_object%get_element("edges") - errors = maybe_edges%errors() - call assert(.not. errors%has_any(), "vertex%from_json: .not. errors%has_any()", char(errors%to_string())) - select type (edges => maybe_edges%value_()) + maybe_edges = json_object%get("edges") + call assert( & + .not. maybe_edges%errors%has_any(), & + "vertex%from_json: .not. errors%has_any()", & + char(maybe_edges%errors%to_string())) + select type (edges => maybe_edges%value_) type is (json_array_t) - allocate(vertex%edges_(edges%length())) - do i = 1, edges%length() - maybe_edge = edges%get_element(i) - errors = maybe_edge%errors() - call assert(.not. errors%has_any(), "vertex%from_json: .not. errors%has_any()", char(errors%to_string())) - select type (edge => maybe_edge%value_()) + allocate(vertex%edges_(size(edges%elements))) + do i = 1, size(edges%elements) + select type (edge => edges%elements(i)%json) type is (json_number_t) - vertex%edges_(i) = int(edge%get_value()) + vertex%edges_(i) = int(edge%number) type is (json_integer_t) - vertex%edges_(i) = edge%get_value() + vertex%edges_(i) = edge%number class default - call assert(.false., "vertex%from_json: edge was not a number", char(edge%to_compact_string())) + call assert(.false., "vertex%from_json: edge was not a number", edge%to_compact_string()) end select end do class default - call assert(.false., "vertex%from_json: edges was not an array", char(edges%to_compact_string())) + call assert(.false., "vertex%from_json: edges was not an array", edges%to_compact_string()) end select end procedure diff --git a/test/dag_test.f90 b/test/dag_test.f90 index a82d24d..2c48e87 100644 --- a/test/dag_test.f90 +++ b/test/dag_test.f90 @@ -2,10 +2,10 @@ module dag_test use dag_m, only: dag_t use erloff, only: error_list_t use vertex_m, only: vertex_t - use vegetables, only: & + use veggies, only: & result_t, test_item_t, assert_equals, describe, it, assert_that, fail, succeed - use iso_varying_string, only : varying_string, var_str, assignment(=), char - use jsonff, only: fallible_json_value_t, json_object_t, parse_json + use iso_varying_string, only : varying_string, var_str, assignment(=) + use rojff, only: fallible_json_value_t, json_object_t, parse_json_from_string !! Test DAG construction, input, and output. implicit none private @@ -91,7 +91,7 @@ pure function remove_whitespace(string) result(no_blanks) character(len=*), intent(in) :: string character(len=:), allocatable :: no_blanks integer i - + no_blanks = '' do i=1, len(string) if (.not. any(string(i:i) == [' ', new_line(' ')])) no_blanks = no_blanks // string(i:i) @@ -114,7 +114,7 @@ function construct_dag_and_json_object() result(result_) dag = module_tree_from_components() json_object = dag%to_json() - result_ = assert_equals(var_str(expected_json), json_object%to_compact_string()) + result_ = assert_equals(expected_json, json_object%to_compact_string()) end function @@ -129,7 +129,6 @@ function component_constructor_sorts() result(result_) function json_constructor_sorts() result(result_) type(result_t) result_ type(dag_t) dag - type(error_list_t) :: errors type(fallible_json_value_t) :: maybe_json character(len=*), parameter :: json_string = & '{"vertices":[' // & @@ -139,9 +138,9 @@ function json_constructor_sorts() result(result_) '{"label":"dag_m","edges":[3]},' // & '{"label":"dag_s","edges":[4,1]}]}' - maybe_json = parse_json(json_string) + maybe_json = parse_json_from_string(json_string) if (.not.maybe_json%failed()) then - select type (json => maybe_json%value_()) + select type (json => maybe_json%value_) type is (json_object_t) dag = dag_t(json) result_ = assert_that(dag%is_sorted_and_acyclic()) @@ -149,8 +148,7 @@ function json_constructor_sorts() result(result_) result_ = fail("json wasn't an object") end select else - errors = maybe_json%errors() - result_ = fail(errors%to_string()) + result_ = fail(maybe_json%errors%to_string()) end if end function diff --git a/test/main.f90 b/test/main.f90 index a2ea3a5..38b46f6 100644 --- a/test/main.f90 +++ b/test/main.f90 @@ -1,13 +1,18 @@ -! Generated by make_vegetable_driver. DO NOT EDIT +! Generated by cart. DO NOT EDIT program main implicit none - call run() + if (.not.run()) stop 1 contains - subroutine run() + function run() result(passed) use dag_test, only: & - dag_dag_construction => test_dag_construction - use vegetables, only: test_item_t, test_that, run_tests + dag_dag_construction => & + test_dag_construction + use veggies, only: test_item_t, test_that, run_tests + + + + logical :: passed type(test_item_t) :: tests type(test_item_t) :: individual_tests(1) @@ -15,6 +20,8 @@ subroutine run() individual_tests(1) = dag_dag_construction() tests = test_that(individual_tests) - call run_tests(tests) - end subroutine + + passed = run_tests(tests) + + end function end program From 854bd98f629f975b7fa99e800825832fef5d6c73 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Mon, 28 Nov 2022 14:15:28 -0600 Subject: [PATCH 2/5] ci: update doc deployment --- .github/workflows/deploy-docs.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 77f13eb..67c529a 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -7,14 +7,18 @@ jobs: Build: runs-on: ubuntu-latest + env: + FC: gfortran + GCC_V: 12 + steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Dependencies Ubuntu run: | sudo apt-get update - sudo apt install -y python-dev python build-essential graphviz + sudo apt install -y gfortran-${GCC_V} python3-dev graphviz sudo pip install ford - name: Build Developer Documenation From ae757a9124d45048cb3976535e854662e77a9797 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Mon, 28 Nov 2022 14:16:31 -0600 Subject: [PATCH 3/5] ci: update doc deploy environment --- .github/workflows/deploy-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 67c529a..683fc92 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: Build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 env: FC: gfortran From 6ad36e112568bee85b0520ec10a13fb14fb4b659 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Mon, 28 Nov 2022 14:21:50 -0600 Subject: [PATCH 4/5] ci: upgrade CI --- .github/workflows/CI.yml | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0ccea5e..084945e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,37 +4,32 @@ on: [push, pull_request] jobs: Build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: fail-fast: false + env: + FC: gfortran + GCC_V: 12 steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v3 - - name: Get Time - id: time - uses: nanzm/get-time-action@v1.0 + - uses: fortran-lang/setup-fpm@v4 with: - format: 'YYYY-MM' + github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup cache for opencoarrays - id: cache-opencoarrays - uses: actions/cache@v2 - with: - path: "OpenCoarrays-2.9.2/" - key: ${{ steps.time.outputs.time }} - - - name: Install GFortran, OpenCoarrays,and fpm + - name: Install Dependencies Ubuntu + if: contains(matrix.os, 'ubuntu') run: | - sudo apt install -y gfortran-11 graphviz - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 \ - --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-11 \ - --slave /usr/bingcov gcov /usr/bin/gcov-11 - if [ ! -d OpenCoarrays-2.9.2 ] ; then wget -P . https://github.com/sourceryinstitute/OpenCoarrays/releases/download/2.9.2/OpenCoarrays-2.9.2.tar.gz && tar -xf OpenCoarrays-2.9.2.tar.gz && cd OpenCoarrays-2.9.2 && TERM=xterm ./install.sh -y; fi - wget https://github.com/fortran-lang/fpm/releases/download/v0.1.3/fpm-0.1.3-linux-x86_64 && sudo cp fpm-0.1.3-linux-x86_64 /usr/local/bin/fpm && sudo chmod a+x /usr/local/bin/fpm + sudo apt-get update + sudo apt install -y gfortran-${GCC_V} + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \ + --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \ + --slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V} - name: Build and test run: | - source OpenCoarrays-2.9.2/prerequisites/installations/opencoarrays/2.9.2/setup.sh - fpm test --compiler caf --runner "cafrun -n 1" + which gfortran + gfortran --version + fpm test From a0561d48b8bf1bce8304b4d192c62f682358d50a Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Mon, 28 Nov 2022 14:37:29 -0600 Subject: [PATCH 5/5] chore: update version --- fpm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpm.toml b/fpm.toml index a5d4526..3d4b5c0 100644 --- a/fpm.toml +++ b/fpm.toml @@ -1,5 +1,5 @@ name = "dag" -version = "2.0.1" +version = "3.0.0" license = "BSD" author = ["Damian Rouson", "Robert Singleterry", "Brad Richardson"] maintainer = "damian@sourceryinstitute.org"