Skip to content

Commit

Permalink
Merge pull request #61 from sourceryinstitute/routine_maintenance
Browse files Browse the repository at this point in the history
Routine Maintenance
  • Loading branch information
rouson committed Dec 7, 2022
2 parents d83d0a4 + a0561d4 commit 2091217
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 146 deletions.
39 changes: 17 additions & 22 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 7 additions & 3 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ on: [push, pull_request]

jobs:
Build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

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
Expand Down
8 changes: 4 additions & 4 deletions example/print-to-json.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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([ &
Expand All @@ -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
Expand Down
19 changes: 10 additions & 9 deletions example/read-from-json.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@ 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


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
12 changes: 6 additions & 6 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name = "dag"
version = "2.0.1"
version = "3.0.0"
license = "BSD"
author = ["Damian Rouson", "Robert Singleterry", "Brad Richardson"]
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" }
5 changes: 2 additions & 3 deletions src/dag_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
49 changes: 22 additions & 27 deletions src/dag_s.f90
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/vertex_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 2091217

Please sign in to comment.