├── .gitmodules ├── .gitignore ├── test ├── utilities │ ├── utilities_m.f90 │ ├── units_examples_m.f90 │ ├── double_precision_pair_input_m.f90 │ ├── double_precision_generator_m.f90 │ ├── non_zero_double_precision_generator_m.f90 │ ├── double_precision_pair_generator_m.f90 │ ├── non_zero_double_precision_pair_generator_m.f90 │ ├── area_utilities_m.f90 │ ├── mass_utilities_m.f90 │ ├── time_utilities_m.f90 │ ├── angle_utilities_m.f90 │ ├── force_utilities_m.f90 │ ├── power_utilities_m.f90 │ ├── speed_utilities_m.f90 │ ├── amount_utilities_m.f90 │ ├── burnup_utilities_m.f90 │ ├── energy_utilities_m.f90 │ ├── length_utilities_m.f90 │ ├── volume_utilities_m.f90 │ ├── density_utilities_m.f90 │ ├── fluence_utilities_m.f90 │ ├── enthalpy_utilities_m.f90 │ ├── pressure_utilities_m.f90 │ ├── frequency_utilities_m.f90 │ ├── mass_rate_utilities_m.f90 │ ├── molar_mass_utilities_m.f90 │ ├── amount_rate_utilities_m.f90 │ ├── temperature_utilities_m.f90 │ ├── acceleration_utilities_m.f90 │ ├── molar_density_utilities_m.f90 │ ├── specific_heat_utilities_m.f90 │ ├── molar_enthalpy_utilities_m.f90 │ ├── delta_temperature_utilities_m.f90 │ ├── dynamic_viscosity_utilities_m.f90 │ ├── amount_temperature_utilities_m.f90 │ ├── fracture_toughness_utilities_m.f90 │ ├── inverse_molar_mass_utilities_m.f90 │ ├── molar_specific_heat_utilities_m.f90 │ ├── thermal_conductivity_utilities_m.f90 │ ├── energy_per_temperature_utilities_m.f90 │ ├── amount_temperature_rate_utilities_m.f90 │ ├── stress_intensity_factor_utilities_m.f90 │ ├── convective_heat_transfer_utilities_m.f90 │ └── thermal_expansion_coeffecient_utilities_m.f90 └── main.f90 ├── quaff_asserts ├── fpm.toml └── src │ ├── quaff_asserts_m.f90 │ └── area_asserts_m.f90 ├── quaff_garden_asserts ├── fpm.toml └── src │ └── quaff_asserts_m.f90 ├── doc └── front-matter.md ├── .gitlab-ci.yml ├── src └── quaff │ ├── physical_constants.f90 │ ├── utilities_m.f90 │ └── conversion_factors_m.f90 ├── fpm.toml ├── LICENSE ├── CONTRIBUTING.md ├── tools ├── generate-new-quantity.sh └── templates │ └── quantity_utilities_m.f90 ├── example └── main.f90 └── README.md /.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | public/* 3 | -------------------------------------------------------------------------------- /test/utilities/utilities_m.f90: -------------------------------------------------------------------------------- 1 | module test_utilities_m 2 | implicit none 3 | private 4 | public :: combinations 5 | contains 6 | pure recursive function combinations(num_items) result(num_combinations) 7 | integer, intent(in) :: num_items 8 | integer :: num_combinations 9 | 10 | if (num_items <= 1) then 11 | num_combinations = 0 12 | else 13 | num_combinations = num_items - 1 + combinations(num_items - 1) 14 | end if 15 | end function 16 | end module 17 | -------------------------------------------------------------------------------- /quaff_asserts/fpm.toml: -------------------------------------------------------------------------------- 1 | name = "quaff_asserts" 2 | version = "0.7.7" 3 | license = "MIT" 4 | author = "Brad Richardson" 5 | maintainer = "everythingfunctional@protonmail.com" 6 | copyright = "2020 Brad Richardson" 7 | 8 | [dependencies] 9 | quaff = { git = "https://gitlab.com/everythingfunctional/quaff.git" } 10 | iso_varying_string = { git = "https://gitlab.com/everythingfunctional/iso_varying_string.git", tag = "v3.0.2" } 11 | strff = { git = "https://gitlab.com/everythingfunctional/strff.git", tag = "v3.0.4" } 12 | veggies = { git = "https://gitlab.com/everythingfunctional/veggies", tag = "v1.0.3" } 13 | -------------------------------------------------------------------------------- /quaff_garden_asserts/fpm.toml: -------------------------------------------------------------------------------- 1 | name = "quaff_garden_asserts" 2 | version = "0.7.7" 3 | license = "MIT" 4 | author = "Brad Richardson" 5 | maintainer = "everythingfunctional@protonmail.com" 6 | copyright = "2020 Brad Richardson" 7 | 8 | [dependencies] 9 | quaff = { git = "https://gitlab.com/everythingfunctional/quaff.git" } 10 | iso_varying_string = { git = "https://gitlab.com/everythingfunctional/iso_varying_string.git", tag = "v3.0.2" } 11 | strff = { git = "https://gitlab.com/everythingfunctional/strff.git", tag = "v3.0.4" } 12 | garden = { git = "https://gitlab.com/everythingfunctional/garden", tag = "v1.0.3" } 13 | -------------------------------------------------------------------------------- /doc/front-matter.md: -------------------------------------------------------------------------------- 1 | --- 2 | project: Quaff 3 | summary: Quantities for Fortran. Make math with units more convenient. 4 | project_website: https://gitlab.com/everythingfunctional/quaff 5 | author: Brad Richardson 6 | email: everythingfunctional@protonmail.com 7 | website: https://everythingfunctional.com 8 | twitter: https://twitter.com/everythingfunct 9 | github: https://github.com/everythingfunctional 10 | src_dir: ../src 11 | ../quaff_asserts/src 12 | preprocessor: gfortran -E 13 | display: public 14 | protected 15 | private 16 | sort: permission-alpha 17 | output_dir: ../public 18 | graph: true 19 | ... 20 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - test 3 | - documentation 4 | - pages 5 | 6 | test: 7 | stage: test 8 | image: registry.gitlab.com/everythingfunctional/dockerfpm 9 | script: 10 | - fpm test # TODO: run with valgrind once gfortran memory leaks have been fixed, i.e. --runner "valgrind --leak-check=full --error-exitcode=1" 11 | 12 | documentation: 13 | stage: documentation 14 | image: python 15 | script: 16 | - pip install ford 17 | - apt update && apt install -y graphviz gfortran 18 | - ford doc/front-matter.md 19 | artifacts: 20 | paths: 21 | - public 22 | 23 | pages: 24 | stage: pages 25 | dependencies: 26 | - documentation 27 | script: 28 | - echo "Deploying to pages" 29 | artifacts: 30 | paths: 31 | - public 32 | only: 33 | - main 34 | -------------------------------------------------------------------------------- /src/quaff/physical_constants.f90: -------------------------------------------------------------------------------- 1 | module quaff_physical_constants 2 | use quaff_acceleration_m, only: acceleration_t 3 | use quaff_molar_specific_heat_m, only: molar_specific_heat_t 4 | use quaff_pressure_m, only: pressure_t 5 | use quaff_conversion_factors_m, only: & 6 | GRAVITY_ => GRAVITY, & 7 | PASCALS_PER_ATMOSPHERE 8 | 9 | implicit none 10 | 11 | type(pressure_t), parameter :: ATMOSPHERIC_PRESSURE = & 12 | pressure_t(pascals = PASCALS_PER_ATMOSPHERE) 13 | type(acceleration_t), parameter :: GRAVITY = & 14 | acceleration_t(meters_per_square_second = GRAVITY_) 15 | type(molar_specific_heat_t), parameter :: UNIVERSAL_GAS_CONSTANT = & 16 | molar_specific_heat_t(joules_per_kelvin_mol = 8.31446261815324d0) 17 | end module 18 | -------------------------------------------------------------------------------- /fpm.toml: -------------------------------------------------------------------------------- 1 | name = "quaff" 2 | version = "0.7.7" 3 | license = "MIT" 4 | author = "Brad Richardson" 5 | maintainer = "everythingfunctional@protonmail.com" 6 | copyright = "2020 Brad Richardson" 7 | 8 | [dependencies] 9 | erloff = { git = "https://gitlab.com/everythingfunctional/erloff.git", tag = "v2.1.3" } 10 | iso_varying_string = { git = "https://gitlab.com/everythingfunctional/iso_varying_string.git", tag = "v4.0.0" } 11 | parff = { git = "https://gitlab.com/everythingfunctional/parff.git", tag = "v4.0.1" } 12 | strff = { git = "https://gitlab.com/everythingfunctional/strff.git", tag = "v3.1.0" } 13 | 14 | [dev-dependencies] 15 | quaff_asserts = { path = "quaff_asserts" } 16 | veggies = { git = "https://gitlab.com/everythingfunctional/veggies.git", tag = "v1.0.4" } 17 | 18 | [[example]] 19 | name="speed_calculator" 20 | source-dir="example" 21 | main="main.f90" 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Brad Richardson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/utilities/units_examples_m.f90: -------------------------------------------------------------------------------- 1 | module units_examples_m 2 | use veggies, only: example_t 3 | 4 | implicit none 5 | private 6 | public :: units_examples_t 7 | 8 | type :: units_examples_t 9 | private 10 | type(example_t), allocatable :: units_(:) 11 | type(example_t), allocatable :: pairs_(:) 12 | contains 13 | private 14 | procedure, public :: units 15 | procedure, public :: pairs 16 | end type 17 | 18 | interface units_examples_t 19 | module procedure constructor 20 | end interface 21 | contains 22 | function constructor(units, pairs) result(units_examples) 23 | type(example_t), intent(in) :: units(:) 24 | type(example_t), intent(in) :: pairs(:) 25 | type(units_examples_t) :: units_examples 26 | 27 | allocate(units_examples%units_, source = units) 28 | allocate(units_examples%pairs_, source = pairs) 29 | end function 30 | 31 | function units(self) 32 | class(units_examples_t), intent(in) :: self 33 | type(example_t), allocatable :: units(:) 34 | 35 | allocate(units, source = self%units_) 36 | end function 37 | 38 | function pairs(self) 39 | class(units_examples_t), intent(in) :: self 40 | type(example_t), allocatable :: pairs(:) 41 | 42 | allocate(pairs, source = self%pairs_) 43 | end function 44 | end module 45 | -------------------------------------------------------------------------------- /test/utilities/double_precision_pair_input_m.f90: -------------------------------------------------------------------------------- 1 | module double_precision_pair_input_m 2 | use veggies, only: input_t 3 | 4 | implicit none 5 | private 6 | public :: double_precision_pair_input_t 7 | 8 | type, extends(input_t) :: double_precision_pair_input_t 9 | private 10 | double precision :: first_ 11 | double precision :: second__ 12 | contains 13 | private 14 | procedure, public :: first 15 | procedure, public :: second_ 16 | end type 17 | 18 | interface double_precision_pair_input_t 19 | module procedure constructor 20 | end interface 21 | contains 22 | pure function constructor(first, second_) result(double_precision_pair_input) 23 | double precision, intent(in) :: first 24 | double precision, intent(in) :: second_ 25 | type(double_precision_pair_input_t) :: double_precision_pair_input 26 | 27 | double_precision_pair_input%first_ = first 28 | double_precision_pair_input%second__ = second_ 29 | end function 30 | 31 | pure function first(self) 32 | class(double_precision_pair_input_t), intent(in) :: self 33 | double precision :: first 34 | 35 | first = self%first_ 36 | end function 37 | 38 | pure function second_(self) 39 | class(double_precision_pair_input_t), intent(in) :: self 40 | double precision :: second_ 41 | 42 | second_ = self%second__ 43 | end function 44 | end module 45 | -------------------------------------------------------------------------------- /test/utilities/double_precision_generator_m.f90: -------------------------------------------------------------------------------- 1 | module double_precision_generator_m 2 | use quaff_utilities_m, only: effectively_zero 3 | use veggies, only: & 4 | double_precision_input_t, & 5 | generated_t, & 6 | generator_t, & 7 | input_t, & 8 | shrink_result_t, & 9 | get_random_double_precision_with_magnitude, & 10 | shrunk_value, & 11 | simplest_value 12 | 13 | implicit none 14 | private 15 | public :: double_precision_generator_t, DOUBLE_PRECISION_GENERATOR 16 | 17 | type, extends(generator_t) :: double_precision_generator_t 18 | contains 19 | private 20 | procedure, public :: generate 21 | procedure, public, nopass :: shrink 22 | end type 23 | 24 | type(double_precision_generator_t) :: DOUBLE_PRECISION_GENERATOR = & 25 | double_precision_generator_t() 26 | contains 27 | function generate(self) result(random_double) 28 | class(double_precision_generator_t), intent(in) :: self 29 | type(generated_t) :: random_double 30 | 31 | associate(unused => self) 32 | end associate 33 | 34 | random_double = generated_t(double_precision_input_t( & 35 | get_random_double_precision_with_magnitude(1.0d12))) 36 | end function 37 | 38 | function shrink(input) result(shrunk) 39 | class(input_t), intent(in) :: input 40 | type(shrink_result_t) :: shrunk 41 | 42 | select type (input) 43 | type is (double_precision_input_t) 44 | if (effectively_zero(input%input())) then 45 | shrunk = simplest_value(double_precision_input_t(0.0d0)) 46 | else 47 | shrunk = shrunk_value(double_precision_input_t(input%input() / 2.0d0)) 48 | end if 49 | end select 50 | end function 51 | end module 52 | -------------------------------------------------------------------------------- /test/utilities/non_zero_double_precision_generator_m.f90: -------------------------------------------------------------------------------- 1 | module non_zero_double_precision_generator_m 2 | use veggies, only: & 3 | double_precision_input_t, & 4 | generated_t, & 5 | generator_t, & 6 | input_t, & 7 | shrink_result_t, & 8 | get_random_double_precision_with_magnitude, & 9 | shrunk_value, & 10 | simplest_value 11 | 12 | implicit none 13 | private 14 | 15 | type, public, extends(generator_t) :: non_zero_double_precision_generator_t 16 | contains 17 | private 18 | procedure, public :: generate 19 | procedure, public, nopass :: shrink 20 | end type 21 | 22 | type(non_zero_double_precision_generator_t), public :: & 23 | NON_ZERO_DOUBLE_PRECISION_GENERATOR = & 24 | non_zero_double_precision_generator_t() 25 | contains 26 | function generate(self) result(random_double) 27 | class(non_zero_double_precision_generator_t), intent(in) :: self 28 | type(generated_t) :: random_double 29 | 30 | double precision :: value_ 31 | 32 | associate(unused => self) 33 | end associate 34 | 35 | do 36 | value_ = get_random_double_precision_with_magnitude(1.0d12) 37 | if (abs(value_) >= 1.0d0) exit 38 | end do 39 | random_double = generated_t(double_precision_input_t(value_)) 40 | end function 41 | 42 | function shrink(input) result(shrunk) 43 | class(input_t), intent(in) :: input 44 | type(shrink_result_t) :: shrunk 45 | 46 | select type (input) 47 | type is (double_precision_input_t) 48 | if (abs(input%input()) <= 1.0d0) then 49 | shrunk = simplest_value(double_precision_input_t(input%input() / abs(input%input()))) 50 | else 51 | shrunk = shrunk_value(double_precision_input_t(input%input() / 2.0d0)) 52 | end if 53 | end select 54 | end function 55 | end module 56 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: 4 | 5 | - Reporting a bug 6 | - Discussing the current state of the code 7 | - Submitting a fix 8 | - Proposing new features 9 | - Becoming a maintainer 10 | 11 | ## We Develop with Gitlab 12 | 13 | We use gitlab to host code, to track issues and feature requests, as well as accept pull requests. 14 | 15 | ## External Code Changes Happen Through Pull Requests 16 | 17 | Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests: 18 | 19 | 1. Fork the repo and create your branch from `master`. 20 | 2. If you've added code that should be tested, add tests. 21 | 3. If you've changed APIs, update the documentation. 22 | 4. Ensure the test suite passes. 23 | 5. Make sure your code lints. 24 | 6. Issue that pull request! 25 | 26 | ## Any contributions you make will be under the MIT Software License 27 | 28 | In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern. 29 | 30 | ## Report bugs using Gitlab's [issues](https://gitlab.com/everythingfunctional/quaff/issues) 31 | 32 | We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://gitlab.com/everythingfunctional/quaff/issues); it's that easy! 33 | 34 | ## Write bug reports with detail, background, and sample code 35 | 36 | **Great Bug Reports** tend to have: 37 | 38 | - A quick summary and/or background 39 | - Steps to reproduce 40 | - Be specific! 41 | - Give sample code if you can. 42 | - What you expected would happen 43 | - What actually happens 44 | - Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) 45 | 46 | People *love* thorough bug reports. I'm not even kidding. 47 | 48 | ## License 49 | 50 | By contributing, you agree that your contributions will be licensed under its MIT License. 51 | -------------------------------------------------------------------------------- /tools/generate-new-quantity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | quantity_lower="${1}" 4 | QUANTITY_CAPITAL="${2}" 5 | units_lower="${3}" 6 | UNITS_CAPITAL="${4}" 7 | unit_sym="${5}" 8 | 9 | if [[ $# -ne 5 ]]; then 10 | echo "Usage:" 11 | echo " ${0} quantity QUANTITY units UNITS symbol" 12 | exit 13 | fi 14 | 15 | new_module_name="src/quaff/${quantity_lower}_m.f90" 16 | new_test_name="test/${quantity_lower}_test.f90" 17 | new_utilities_name="test/utilities/${quantity_lower}_utilities_m.f90" 18 | new_asserts_name="quaff_asserts/src/${quantity_lower}_asserts_m.f90" 19 | new_garden_asserts_name="quaff_garden_asserts/src/${quantity_lower}_asserts_m.f90" 20 | 21 | sed "s|quantity|${quantity_lower}|g" "tools/templates/quantity_m.f90" \ 22 | | sed "s|QUANTITY|${QUANTITY_CAPITAL}|g" \ 23 | | sed "s|meters|${units_lower}|g" \ 24 | | sed "s|METERS|${UNITS_CAPITAL}|g" \ 25 | | sed "s|SYM|${unit_sym}|g" \ 26 | > "${new_module_name}" 27 | 28 | sed "s|quantity|${quantity_lower}|g" "tools/templates/quantity_test.f90" \ 29 | | sed "s|QUANTITY|${QUANTITY_CAPITAL}|g" \ 30 | | sed "s|meters|${units_lower}|g" \ 31 | | sed "s|METERS|${UNITS_CAPITAL}|g" \ 32 | | sed "s|SYM|${unit_sym}|g" \ 33 | > "${new_test_name}" 34 | 35 | sed "s|quantity|${quantity_lower}|g" "tools/templates/quantity_utilities_m.f90" \ 36 | | sed "s|QUANTITY|${QUANTITY_CAPITAL}|g" \ 37 | | sed "s|meters|${units_lower}|g" \ 38 | | sed "s|METERS|${UNITS_CAPITAL}|g" \ 39 | | sed "s|SYM|${unit_sym}|g" \ 40 | > "${new_utilities_name}" 41 | 42 | sed "s|quantity|${quantity_lower}|g" "tools/templates/quantity_asserts_m.f90" \ 43 | | sed "s|QUANTITY|${QUANTITY_CAPITAL}|g" \ 44 | | sed "s|meters|${units_lower}|g" \ 45 | | sed "s|METERS|${UNITS_CAPITAL}|g" \ 46 | | sed "s|SYM|${unit_sym}|g" \ 47 | > "${new_asserts_name}" 48 | 49 | sed "s|quantity|${quantity_lower}|g" "tools/templates/quantity_garden_asserts_m.f90" \ 50 | | sed "s|QUANTITY|${QUANTITY_CAPITAL}|g" \ 51 | | sed "s|meters|${units_lower}|g" \ 52 | | sed "s|METERS|${UNITS_CAPITAL}|g" \ 53 | | sed "s|SYM|${unit_sym}|g" \ 54 | > "${new_garden_asserts_name}" 55 | -------------------------------------------------------------------------------- /example/main.f90: -------------------------------------------------------------------------------- 1 | program speed_calculator 2 | use erloff, only: error_list_t 3 | use iso_varying_string, only: varying_string, operator(//), get, put_line 4 | use quaff, only: & 5 | fallible_length_t, & 6 | fallible_speed_unit_t, & 7 | fallible_time_t, & 8 | length_t, & 9 | speed_t, & 10 | speed_unit_t, & 11 | time_t, & 12 | parse_length, & 13 | parse_speed_unit, & 14 | parse_time, & 15 | operator(/) 16 | implicit none 17 | 18 | type(length_t) :: distance 19 | type(error_list_t) :: errors 20 | type(fallible_length_t) :: maybe_distance 21 | type(fallible_speed_unit_t) :: maybe_speed_unit 22 | type(fallible_time_t) :: maybe_time 23 | type(varying_string) :: response 24 | type(speed_t) :: speed 25 | class(speed_unit_t), allocatable :: speed_unit 26 | type(time_t) :: time 27 | 28 | do 29 | call put_line("How far did you travel?") 30 | call get(response) 31 | maybe_distance = parse_length(response) 32 | if (maybe_distance%failed()) then 33 | errors = maybe_distance%errors() 34 | call put_line(errors%to_string()) 35 | else 36 | distance = maybe_distance%length() 37 | exit 38 | end if 39 | end do 40 | do 41 | call put_line("How long did it take you?") 42 | call get(response) 43 | maybe_time = parse_time(response) 44 | if (maybe_time%failed()) then 45 | errors = maybe_time%errors() 46 | call put_line(errors%to_string()) 47 | else 48 | time = maybe_time%time() 49 | exit 50 | end if 51 | end do 52 | do 53 | call put_line("What units would you like for output?") 54 | call get(response) 55 | maybe_speed_unit = parse_speed_unit(response) 56 | if (maybe_speed_unit%failed()) then 57 | errors = maybe_speed_unit%errors() 58 | call put_line(errors%to_string()) 59 | else 60 | speed_unit = maybe_speed_unit%unit() 61 | exit 62 | end if 63 | end do 64 | speed = distance / time 65 | call put_line("Speed was " // speed%to_string_in(speed_unit)) 66 | end program 67 | -------------------------------------------------------------------------------- /src/quaff/utilities_m.f90: -------------------------------------------------------------------------------- 1 | module quaff_utilities_m 2 | use erloff, only: message_type_t 3 | use parff, only: parser_output_t, state_t, parse_char 4 | 5 | implicit none 6 | private 7 | public :: & 8 | effectively_zero, & 9 | equal_within_absolute, & 10 | equal_within_relative, & 11 | operator(.safeEq.), & 12 | parse_space, & 13 | PARSE_ERROR, & 14 | UNKNOWN_UNIT 15 | 16 | interface operator(.safeEq.) 17 | module procedure safe_eq 18 | end interface 19 | 20 | double precision, parameter :: MACHINE_EPSILON = epsilon(1.0d0) 21 | 22 | type(message_type_t), parameter :: PARSE_ERROR = & 23 | message_type_t("Parse Error") 24 | type(message_type_t), parameter :: UNKNOWN_UNIT = & 25 | message_type_t("Unknown Unit") 26 | contains 27 | elemental function effectively_zero(a) 28 | double precision, intent(in) :: a 29 | logical :: effectively_zero 30 | 31 | effectively_zero = abs(a) < MACHINE_EPSILON 32 | end function 33 | 34 | pure function equal_within_absolute(a, b, tolerance) 35 | double precision, intent(in) :: a 36 | double precision, intent(in) :: b 37 | double precision, intent(in) :: tolerance 38 | logical :: equal_within_absolute 39 | 40 | equal_within_absolute = abs(a - b) < tolerance 41 | end function 42 | 43 | pure function equal_within_relative(a, b, tolerance) 44 | double precision, intent(in) :: a 45 | double precision, intent(in) :: b 46 | double precision, intent(in) :: tolerance 47 | logical :: equal_within_relative 48 | 49 | if (effectively_zero(a) .and. effectively_zero(b)) then 50 | equal_within_relative = .true. 51 | else 52 | equal_within_relative = & 53 | (abs(a - b) / max(abs(a), abs(b))) < tolerance 54 | end if 55 | end function 56 | 57 | function parse_space(state_) result(result_) 58 | type(state_t), intent(in) :: state_ 59 | type(parser_output_t) :: result_ 60 | 61 | result_ = parse_char(" ", state_) 62 | end function 63 | 64 | elemental function safe_eq(a, b) 65 | double precision, intent(in) :: a 66 | double precision, intent(in) :: b 67 | logical :: safe_eq 68 | 69 | safe_eq = equal_within_relative(a, b, MACHINE_EPSILON) 70 | end function 71 | end module 72 | -------------------------------------------------------------------------------- /test/utilities/double_precision_pair_generator_m.f90: -------------------------------------------------------------------------------- 1 | module double_precision_pair_generator_m 2 | use double_precision_pair_input_m, only: double_precision_pair_input_t 3 | use quaff_utilities_m, only: effectively_zero 4 | use veggies, only: & 5 | generated_t, & 6 | generator_t, & 7 | input_t, & 8 | shrink_result_t, & 9 | get_random_double_precision_with_magnitude, & 10 | shrunk_value, & 11 | simplest_value 12 | 13 | implicit none 14 | private 15 | public :: double_precision_pair_generator_t, DOUBLE_PRECISION_PAIR_GENERATOR 16 | 17 | type, extends(generator_t) :: double_precision_pair_generator_t 18 | contains 19 | private 20 | procedure, public :: generate 21 | procedure, public, nopass :: shrink 22 | end type 23 | 24 | type(double_precision_pair_generator_t) :: DOUBLE_PRECISION_PAIR_GENERATOR = & 25 | double_precision_pair_generator_t() 26 | contains 27 | function generate(self) result(random_double) 28 | class(double_precision_pair_generator_t), intent(in) :: self 29 | type(generated_t) :: random_double 30 | 31 | associate(unused => self) 32 | end associate 33 | 34 | random_double = generated_t(double_precision_pair_input_t( & 35 | get_random_double_precision_with_magnitude(1.0d12), & 36 | get_random_double_precision_with_magnitude(1.0d12))) 37 | end function 38 | 39 | function shrink(input) result(shrunk) 40 | class(input_t), intent(in) :: input 41 | type(shrink_result_t) :: shrunk 42 | 43 | double precision :: new_first 44 | double precision :: new_second 45 | 46 | select type (input) 47 | type is (double_precision_pair_input_t) 48 | if (effectively_zero(input%first())) then 49 | new_first = 0.0d0 50 | if (effectively_zero(input%second_())) then 51 | shrunk = simplest_value(double_precision_pair_input_t(new_first, 0.0d0)) 52 | else 53 | shrunk = shrunk_value(double_precision_pair_input_t(new_first, input%second_() / 2.0d0)) 54 | end if 55 | else 56 | new_first = input%first() / 2.0d0 57 | if (effectively_zero(input%second_())) then 58 | new_second = 0.0d0 59 | else 60 | new_second = input%second_() / 2.0d0 61 | end if 62 | shrunk = shrunk_value(double_precision_pair_input_t(new_first, new_second)) 63 | end if 64 | end select 65 | end function 66 | end module 67 | -------------------------------------------------------------------------------- /test/utilities/non_zero_double_precision_pair_generator_m.f90: -------------------------------------------------------------------------------- 1 | module non_zero_double_precision_pair_generator_m 2 | use double_precision_pair_input_m, only: double_precision_pair_input_t 3 | use veggies, only: & 4 | double_precision_input_t, & 5 | generated_t, & 6 | generator_t, & 7 | input_t, & 8 | shrink_result_t, & 9 | get_random_double_precision_with_magnitude, & 10 | shrunk_value, & 11 | simplest_value 12 | 13 | implicit none 14 | private 15 | public :: & 16 | non_zero_double_precision_pair_generator_t, & 17 | NON_ZERO_DOUBLE_PRECISION_PAIR_GENERATOR 18 | 19 | type, extends(generator_t) :: non_zero_double_precision_pair_generator_t 20 | contains 21 | private 22 | procedure, public :: generate 23 | procedure, public, nopass :: shrink 24 | end type 25 | 26 | type(non_zero_double_precision_pair_generator_t) :: & 27 | NON_ZERO_DOUBLE_PRECISION_PAIR_GENERATOR = & 28 | non_zero_double_precision_pair_generator_t() 29 | contains 30 | function generate(self) result(random_double) 31 | class(non_zero_double_precision_pair_generator_t), intent(in) :: self 32 | type(generated_t) :: random_double 33 | 34 | double precision :: first 35 | double precision :: second_ 36 | 37 | associate(unused => self) 38 | end associate 39 | 40 | do 41 | first = get_random_double_precision_with_magnitude(1.0d12) 42 | if (abs(first) >= 1.0d0) exit 43 | end do 44 | do 45 | second_ = get_random_double_precision_with_magnitude(1.0d12) 46 | if (abs(second_) >= 1.0d0) exit 47 | end do 48 | random_double = generated_t(double_precision_pair_input_t(first, second_)) 49 | end function 50 | 51 | function shrink(input) result(shrunk) 52 | class(input_t), intent(in) :: input 53 | type(shrink_result_t) :: shrunk 54 | 55 | double precision :: new_first 56 | double precision :: new_second 57 | 58 | select type (input) 59 | type is (double_precision_pair_input_t) 60 | if (abs(input%first()) <= 1.0d0) then 61 | new_first = input%first() / abs(input%first()) 62 | if (abs(input%second_()) <= 1.0d0) then 63 | shrunk = simplest_value(double_precision_pair_input_t( & 64 | new_first, input%second_() / abs(input%second_()))) 65 | else 66 | shrunk = shrunk_value(double_precision_pair_input_t( & 67 | new_first, input%second_() / 2.0d0)) 68 | end if 69 | else 70 | new_first = input%first() / 2.0d0 71 | if (abs(input%second_()) <= 1.0d0) then 72 | new_second = input%second_() / abs(input%second_()) 73 | else 74 | new_second = input%second_() / 2.0d0 75 | end if 76 | shrunk = shrunk_value(double_precision_pair_input_t(new_first, new_second)) 77 | end if 78 | end select 79 | end function 80 | end module 81 | -------------------------------------------------------------------------------- /test/utilities/area_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module area_utilities_m 2 | use quaff, only: area_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(area_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(area_unit_t), allocatable :: first_ 22 | class(area_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(area_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(area_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(area_unit_t), intent(in) :: first 53 | class(area_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(area_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(area_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(area_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/mass_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module mass_utilities_m 2 | use quaff, only: mass_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(mass_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(mass_unit_t), allocatable :: first_ 22 | class(mass_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(mass_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(mass_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(mass_unit_t), intent(in) :: first 53 | class(mass_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(mass_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(mass_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(mass_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/time_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module time_utilities_m 2 | use quaff, only: time_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(time_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(time_unit_t), allocatable :: first_ 22 | class(time_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(time_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(time_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(time_unit_t), intent(in) :: first 53 | class(time_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(time_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(time_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(time_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/angle_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module angle_utilities_m 2 | use quaff, only: angle_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(angle_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(angle_unit_t), allocatable :: first_ 22 | class(angle_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(angle_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(angle_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(angle_unit_t), intent(in) :: first 53 | class(angle_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(angle_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(angle_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(angle_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/force_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module force_utilities_m 2 | use quaff, only: force_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(force_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(force_unit_t), allocatable :: first_ 22 | class(force_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(force_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(force_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(force_unit_t), intent(in) :: first 53 | class(force_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(force_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(force_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(force_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/power_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module power_utilities_m 2 | use quaff, only: power_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(power_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(power_unit_t), allocatable :: first_ 22 | class(power_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(power_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(power_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(power_unit_t), intent(in) :: first 53 | class(power_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(power_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(power_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(power_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/speed_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module speed_utilities_m 2 | use quaff, only: speed_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(speed_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(speed_unit_t), allocatable :: first_ 22 | class(speed_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(speed_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(speed_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(speed_unit_t), intent(in) :: first 53 | class(speed_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(speed_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(speed_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(speed_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/amount_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module amount_utilities_m 2 | use quaff, only: amount_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(amount_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(amount_unit_t), allocatable :: first_ 22 | class(amount_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(amount_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(amount_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(amount_unit_t), intent(in) :: first 53 | class(amount_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(amount_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(amount_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(amount_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/burnup_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module burnup_utilities_m 2 | use quaff, only: burnup_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(burnup_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(burnup_unit_t), allocatable :: first_ 22 | class(burnup_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(burnup_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(burnup_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(burnup_unit_t), intent(in) :: first 53 | class(burnup_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(burnup_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(burnup_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(burnup_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/energy_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module energy_utilities_m 2 | use quaff, only: energy_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(energy_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(energy_unit_t), allocatable :: first_ 22 | class(energy_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(energy_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(energy_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(energy_unit_t), intent(in) :: first 53 | class(energy_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(energy_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(energy_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(energy_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/length_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module length_utilities_m 2 | use quaff, only: length_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(length_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(length_unit_t), allocatable :: first_ 22 | class(length_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(length_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(length_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(length_unit_t), intent(in) :: first 53 | class(length_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(length_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(length_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(length_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/volume_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module volume_utilities_m 2 | use quaff, only: volume_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(volume_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(volume_unit_t), allocatable :: first_ 22 | class(volume_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(volume_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(volume_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(volume_unit_t), intent(in) :: first 53 | class(volume_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(volume_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(volume_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(volume_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/density_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module density_utilities_m 2 | use quaff, only: density_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(density_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(density_unit_t), allocatable :: first_ 22 | class(density_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(density_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(density_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(density_unit_t), intent(in) :: first 53 | class(density_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(density_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(density_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(density_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/fluence_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module fluence_utilities_m 2 | use quaff, only: fluence_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(fluence_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(fluence_unit_t), allocatable :: first_ 22 | class(fluence_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(fluence_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(fluence_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(fluence_unit_t), intent(in) :: first 53 | class(fluence_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(fluence_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(fluence_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(fluence_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/enthalpy_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module enthalpy_utilities_m 2 | use quaff, only: enthalpy_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(enthalpy_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(enthalpy_unit_t), allocatable :: first_ 22 | class(enthalpy_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(enthalpy_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(enthalpy_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(enthalpy_unit_t), intent(in) :: first 53 | class(enthalpy_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(enthalpy_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(enthalpy_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(enthalpy_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/pressure_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module pressure_utilities_m 2 | use quaff, only: pressure_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(pressure_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(pressure_unit_t), allocatable :: first_ 22 | class(pressure_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(pressure_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(pressure_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(pressure_unit_t), intent(in) :: first 53 | class(pressure_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(pressure_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(pressure_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(pressure_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /tools/templates/quantity_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module quantity_utilities_m 2 | use quaff, only: quantity_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(quantity_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(quantity_unit_t), allocatable :: first_ 22 | class(quantity_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(quantity_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(quantity_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(quantity_unit_t), intent(in) :: first 53 | class(quantity_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(quantity_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(quantity_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(quantity_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/frequency_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module frequency_utilities_m 2 | use quaff, only: frequency_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(frequency_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(frequency_unit_t), allocatable :: first_ 22 | class(frequency_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(frequency_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(frequency_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(frequency_unit_t), intent(in) :: first 53 | class(frequency_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(frequency_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(frequency_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(frequency_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/mass_rate_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module mass_rate_utilities_m 2 | use quaff, only: mass_rate_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(mass_rate_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(mass_rate_unit_t), allocatable :: first_ 22 | class(mass_rate_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(mass_rate_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(mass_rate_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(mass_rate_unit_t), intent(in) :: first 53 | class(mass_rate_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(mass_rate_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(mass_rate_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(mass_rate_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/molar_mass_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module molar_mass_utilities_m 2 | use quaff, only: molar_mass_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(molar_mass_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(molar_mass_unit_t), allocatable :: first_ 22 | class(molar_mass_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(molar_mass_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(molar_mass_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(molar_mass_unit_t), intent(in) :: first 53 | class(molar_mass_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(molar_mass_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(molar_mass_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(molar_mass_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/amount_rate_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module amount_rate_utilities_m 2 | use quaff, only: amount_rate_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(amount_rate_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(amount_rate_unit_t), allocatable :: first_ 22 | class(amount_rate_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(amount_rate_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(amount_rate_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(amount_rate_unit_t), intent(in) :: first 53 | class(amount_rate_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(amount_rate_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(amount_rate_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(amount_rate_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/temperature_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module temperature_utilities_m 2 | use quaff, only: temperature_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(temperature_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(temperature_unit_t), allocatable :: first_ 22 | class(temperature_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(temperature_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(temperature_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(temperature_unit_t), intent(in) :: first 53 | class(temperature_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(temperature_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(temperature_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(temperature_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/acceleration_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module acceleration_utilities_m 2 | use quaff, only: acceleration_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(acceleration_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(acceleration_unit_t), allocatable :: first_ 22 | class(acceleration_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(acceleration_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(acceleration_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(acceleration_unit_t), intent(in) :: first 53 | class(acceleration_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(acceleration_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(acceleration_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(acceleration_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/molar_density_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module molar_density_utilities_m 2 | use quaff, only: molar_density_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(molar_density_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(molar_density_unit_t), allocatable :: first_ 22 | class(molar_density_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(molar_density_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(molar_density_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(molar_density_unit_t), intent(in) :: first 53 | class(molar_density_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(molar_density_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(molar_density_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(molar_density_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/specific_heat_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module specific_heat_utilities_m 2 | use quaff, only: specific_heat_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(specific_heat_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(specific_heat_unit_t), allocatable :: first_ 22 | class(specific_heat_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(specific_heat_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(specific_heat_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(specific_heat_unit_t), intent(in) :: first 53 | class(specific_heat_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(specific_heat_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(specific_heat_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(specific_heat_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/molar_enthalpy_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module molar_enthalpy_utilities_m 2 | use quaff, only: molar_enthalpy_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(molar_enthalpy_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(molar_enthalpy_unit_t), allocatable :: first_ 22 | class(molar_enthalpy_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(molar_enthalpy_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(molar_enthalpy_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(molar_enthalpy_unit_t), intent(in) :: first 53 | class(molar_enthalpy_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(molar_enthalpy_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(molar_enthalpy_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(molar_enthalpy_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/delta_temperature_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module delta_temperature_utilities_m 2 | use quaff, only: delta_temperature_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(delta_temperature_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(delta_temperature_unit_t), allocatable :: first_ 22 | class(delta_temperature_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(delta_temperature_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(delta_temperature_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(delta_temperature_unit_t), intent(in) :: first 53 | class(delta_temperature_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(delta_temperature_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(delta_temperature_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(delta_temperature_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/dynamic_viscosity_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module dynamic_viscosity_utilities_m 2 | use quaff, only: dynamic_viscosity_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(dynamic_viscosity_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(dynamic_viscosity_unit_t), allocatable :: first_ 22 | class(dynamic_viscosity_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(dynamic_viscosity_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(dynamic_viscosity_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(dynamic_viscosity_unit_t), intent(in) :: first 53 | class(dynamic_viscosity_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(dynamic_viscosity_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(dynamic_viscosity_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(dynamic_viscosity_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/amount_temperature_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module amount_temperature_utilities_m 2 | use quaff, only: amount_temperature_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(amount_temperature_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(amount_temperature_unit_t), allocatable :: first_ 22 | class(amount_temperature_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(amount_temperature_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(amount_temperature_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(amount_temperature_unit_t), intent(in) :: first 53 | class(amount_temperature_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(amount_temperature_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(amount_temperature_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(amount_temperature_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/fracture_toughness_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module fracture_toughness_utilities_m 2 | use quaff, only: fracture_toughness_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(fracture_toughness_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(fracture_toughness_unit_t), allocatable :: first_ 22 | class(fracture_toughness_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(fracture_toughness_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(fracture_toughness_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(fracture_toughness_unit_t), intent(in) :: first 53 | class(fracture_toughness_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(fracture_toughness_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(fracture_toughness_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(fracture_toughness_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/inverse_molar_mass_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module inverse_molar_mass_utilities_m 2 | use quaff, only: inverse_molar_mass_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(inverse_molar_mass_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(inverse_molar_mass_unit_t), allocatable :: first_ 22 | class(inverse_molar_mass_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(inverse_molar_mass_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(inverse_molar_mass_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(inverse_molar_mass_unit_t), intent(in) :: first 53 | class(inverse_molar_mass_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(inverse_molar_mass_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(inverse_molar_mass_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(inverse_molar_mass_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/molar_specific_heat_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module molar_specific_heat_utilities_m 2 | use quaff, only: molar_specific_heat_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(molar_specific_heat_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(molar_specific_heat_unit_t), allocatable :: first_ 22 | class(molar_specific_heat_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(molar_specific_heat_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(molar_specific_heat_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(molar_specific_heat_unit_t), intent(in) :: first 53 | class(molar_specific_heat_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(molar_specific_heat_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(molar_specific_heat_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(molar_specific_heat_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/thermal_conductivity_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module thermal_conductivity_utilities_m 2 | use quaff, only: thermal_conductivity_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(thermal_conductivity_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(thermal_conductivity_unit_t), allocatable :: first_ 22 | class(thermal_conductivity_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(thermal_conductivity_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(thermal_conductivity_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(thermal_conductivity_unit_t), intent(in) :: first 53 | class(thermal_conductivity_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(thermal_conductivity_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(thermal_conductivity_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(thermal_conductivity_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/energy_per_temperature_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module energy_per_temperature_utilities_m 2 | use quaff, only: energy_per_temperature_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(energy_per_temperature_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(energy_per_temperature_unit_t), allocatable :: first_ 22 | class(energy_per_temperature_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(energy_per_temperature_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(energy_per_temperature_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(energy_per_temperature_unit_t), intent(in) :: first 53 | class(energy_per_temperature_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(energy_per_temperature_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(energy_per_temperature_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(energy_per_temperature_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/amount_temperature_rate_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module amount_temperature_rate_utilities_m 2 | use quaff, only: amount_temperature_rate_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(amount_temperature_rate_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(amount_temperature_rate_unit_t), allocatable :: first_ 22 | class(amount_temperature_rate_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(amount_temperature_rate_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(amount_temperature_rate_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(amount_temperature_rate_unit_t), intent(in) :: first 53 | class(amount_temperature_rate_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(amount_temperature_rate_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(amount_temperature_rate_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(amount_temperature_rate_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/stress_intensity_factor_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module stress_intensity_factor_utilities_m 2 | use quaff, only: stress_intensity_factor_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(stress_intensity_factor_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(stress_intensity_factor_unit_t), allocatable :: first_ 22 | class(stress_intensity_factor_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(stress_intensity_factor_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(stress_intensity_factor_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(stress_intensity_factor_unit_t), intent(in) :: first 53 | class(stress_intensity_factor_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(stress_intensity_factor_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(stress_intensity_factor_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(stress_intensity_factor_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/convective_heat_transfer_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module convective_heat_transfer_utilities_m 2 | use quaff, only: convective_heat_transfer_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(convective_heat_transfer_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(convective_heat_transfer_unit_t), allocatable :: first_ 22 | class(convective_heat_transfer_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(convective_heat_transfer_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(convective_heat_transfer_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(convective_heat_transfer_unit_t), intent(in) :: first 53 | class(convective_heat_transfer_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(convective_heat_transfer_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(convective_heat_transfer_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(convective_heat_transfer_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /test/utilities/thermal_expansion_coeffecient_utilities_m.f90: -------------------------------------------------------------------------------- 1 | module thermal_expansion_coefficient_utilities_m 2 | use quaff, only: thermal_expansion_coefficient_unit_t 3 | use test_utilities_m, only: combinations 4 | use units_examples_m, only: units_examples_t 5 | use veggies, only: example_t, input_t 6 | 7 | implicit none 8 | private 9 | public :: units_input_t, units_pair_input_t, make_units_examples 10 | 11 | type, extends(input_t) :: units_input_t 12 | private 13 | class(thermal_expansion_coefficient_unit_t), allocatable :: unit_ 14 | contains 15 | private 16 | procedure, public :: unit 17 | end type 18 | 19 | type, extends(input_t) :: units_pair_input_t 20 | private 21 | class(thermal_expansion_coefficient_unit_t), allocatable :: first_ 22 | class(thermal_expansion_coefficient_unit_t), allocatable :: second__ 23 | contains 24 | private 25 | procedure, public :: first 26 | procedure, public :: second_ 27 | end type 28 | 29 | interface units_input_t 30 | module procedure units_input_constructor 31 | end interface 32 | 33 | interface units_pair_input_t 34 | module procedure units_pair_input_constructor 35 | end interface 36 | contains 37 | function units_input_constructor(unit) result(units_input) 38 | class(thermal_expansion_coefficient_unit_t), intent(in) :: unit 39 | type(units_input_t) :: units_input 40 | 41 | allocate(units_input%unit_, source = unit) 42 | end function 43 | 44 | function unit(self) 45 | class(units_input_t), intent(in) :: self 46 | class(thermal_expansion_coefficient_unit_t), allocatable :: unit 47 | 48 | allocate(unit, source = self%unit_) 49 | end function 50 | 51 | function units_pair_input_constructor(first, second_) result(units_pair_input) 52 | class(thermal_expansion_coefficient_unit_t), intent(in) :: first 53 | class(thermal_expansion_coefficient_unit_t), intent(in) :: second_ 54 | type(units_pair_input_t) :: units_pair_input 55 | 56 | allocate(units_pair_input%first_, source = first) 57 | allocate(units_pair_input%second__, source = second_) 58 | end function 59 | 60 | function first(self) 61 | class(units_pair_input_t), intent(in) :: self 62 | class(thermal_expansion_coefficient_unit_t), allocatable :: first 63 | 64 | allocate(first, source = self%first_) 65 | end function 66 | 67 | function second_(self) 68 | class(units_pair_input_t), intent(in) :: self 69 | class(thermal_expansion_coefficient_unit_t), allocatable :: second_ 70 | 71 | allocate(second_, source = self%second__) 72 | end function 73 | 74 | function make_units_examples(units) result(units_examples) 75 | class(thermal_expansion_coefficient_unit_t), intent(in) :: units(:) 76 | type(units_examples_t) :: units_examples 77 | 78 | integer :: i 79 | integer :: j 80 | integer :: num_pairs 81 | type(example_t), allocatable :: pair_examples(:) 82 | integer :: pair_index 83 | type(example_t) :: single_examples(size(units)) 84 | 85 | single_examples = [(example_t(units_input_t(units(i))), i = 1, size(units))] 86 | num_pairs = combinations(size(units)) 87 | allocate(pair_examples(num_pairs)) 88 | pair_index = 1 89 | do i = 1, size(units) - 1 90 | do j = i + 1, size(units) 91 | pair_examples(pair_index) = example_t(units_pair_input_t( & 92 | units(i), units(j))) 93 | pair_index = pair_index + 1 94 | end do 95 | end do 96 | units_examples = units_examples_t(single_examples, pair_examples) 97 | end function 98 | end module 99 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | quaff 2 | ===== 3 | 4 | [![pipeline status](https://gitlab.com/everythingfunctional/quaff/badges/main/pipeline.svg)](https://gitlab.com/everythingfunctional/quaff/commits/main) 5 | 6 | Quantities for Fortran. Make math with units more convenient. 7 | 8 | This library provides all the functionality necessary to *almost* treat 9 | quantities with units associated with them as though they were just intrinsic 10 | real values. However, since a quantity has it's own unique type, you get some 11 | compile time safety that you don't mix them up in your argument lists, and you 12 | don't have to worry about doing unit conversions or remembering what units you've 13 | stored things in when you start doing math with them. 14 | 15 | The following gives a basic overview of how you use quaff, 16 | but for more detailed information consult the [developer documentation](https://everythingfunctional.gitlab.io/quaff). 17 | 18 | Turning a number into a quantity is as easy as defining what units that number 19 | is in, like `1.0d0.unit.METERS`. And, if you need the number back out, just say 20 | what units you want the value in like `time.in.SECONDS`. 21 | 22 | Once you've got your values in quantities, you can do math with them, and not 23 | have to worry about doing unit conversions. All the possible combinations are 24 | appropriately defined. So, assuming these have the types you'd expect, this will 25 | just work: `speed = length / time`. 26 | 27 | A variety of `to_string` functions are also provided, so converting to strings 28 | in a variety of formats is easy too. `to_string` will use SI units, and 29 | `to_string_in` allows you to specify the units you'd like. There are also 30 | [quaff_gnuplot_units](https://gitlab.com/everythingfunctional/quaff_gnuplot_units) 31 | and [quaff_latex_units](https://gitlab.com/everythingfunctional/quaff_latex_units) 32 | projects for units that provide formats for those. 33 | You can also specify the number of significant digits you'd like for any of them. 34 | 35 | There are `parse_quantity` functions provided for getting a quantity from its 36 | string representation as well. These routines return a `fallible_quantity` 37 | type that may have an `error_list_t`, in case the string could not be properly interpreted. 38 | 39 | Finally, all the `assert_equals` functions are provided for working with the 40 | [Vegetables](https://gitlab.com/everythingfunctional/vegetables) unit testing 41 | framework, so you can use quantities in your tests as well. 42 | 43 | What If You Don't Have What I Need? 44 | ----------------------------------- 45 | 46 | ### New Units 47 | 48 | If a unit you need isn't already defined, you can define your own by simply 49 | defining the conversion factor and strings associated with it. Somewhere, you 50 | just need to have something like the following: 51 | 52 | ```Fortran 53 | type(length_simple_unit_t), parameter :: CENTIMETERS = & 54 | length_simple_unit_t( & 55 | conversion_factor = CENTIMETERS_PER_METER, & 56 | symbol = "cm") 57 | ``` 58 | 59 | Note, that you'll need to provide an array of possible units you'd like to use 60 | that includes your custom units to any `parse_quantity` functions. Otherwise they 61 | won't know about them. You can change the default output units for any quantity 62 | if you'd like as well, since they aren't defined with the `parameter` attribute. 63 | You could do this in some initialization routine in your code. 64 | 65 | ### New Quantities 66 | 67 | A script is provided that will generate a new quantity for you at 68 | `tools/generate-new-quantity.sh`. It just needs to know the name of the quantity 69 | in lower and upper case, the name of its internal units in lower and upper case, 70 | and the symbol, and it will use the templates to generate the new quantity module, 71 | it's tests, and the assertions. You'll just need to define any additional units 72 | you'd like to use, and the interfaces for the `*` and `/` operators if you'd 73 | like it to do the math correctly with other quantities. 74 | 75 | As you can see, if something you need isn't provided, it's highly likely you'll 76 | be able to extend the library without having to actually make any changes to the 77 | upstream code (although pull requests are greatly appreciated :)). See the 78 | [Contributing](CONTRIBUTING.md) file. 79 | -------------------------------------------------------------------------------- /quaff_asserts/src/quaff_asserts_m.f90: -------------------------------------------------------------------------------- 1 | module quaff_asserts_m 2 | use acceleration_asserts_m, only: & 3 | assert_equals, & 4 | assert_equals_within_absolute, & 5 | assert_equals_within_relative 6 | use amount_asserts_m, only: & 7 | assert_equals, & 8 | assert_equals_within_absolute, & 9 | assert_equals_within_relative 10 | use amount_rate_asserts_m, only: & 11 | assert_equals, & 12 | assert_equals_within_absolute, & 13 | assert_equals_within_relative 14 | use amount_temperature_asserts_m, only: & 15 | assert_equals, & 16 | assert_equals_within_absolute, & 17 | assert_equals_within_relative 18 | use amount_temperature_rate_asserts_m, only: & 19 | assert_equals, & 20 | assert_equals_within_absolute, & 21 | assert_equals_within_relative 22 | use angle_asserts_m, only: & 23 | assert_equals, & 24 | assert_equals_within_absolute, & 25 | assert_equals_within_relative 26 | use area_asserts_m, only: & 27 | assert_equals, & 28 | assert_equals_within_absolute, & 29 | assert_equals_within_relative 30 | use burnup_asserts_m, only: & 31 | assert_equals, & 32 | assert_equals_within_absolute, & 33 | assert_equals_within_relative 34 | use convective_heat_transfer_asserts_m, only: & 35 | assert_equals, & 36 | assert_equals_within_absolute, & 37 | assert_equals_within_relative 38 | use delta_temperature_asserts_m, only: & 39 | assert_equals, & 40 | assert_equals_within_absolute, & 41 | assert_equals_within_relative 42 | use density_asserts_m, only: & 43 | assert_equals, & 44 | assert_equals_within_absolute, & 45 | assert_equals_within_relative 46 | use dynamic_viscosity_asserts_m, only: & 47 | assert_equals, & 48 | assert_equals_within_absolute, & 49 | assert_equals_within_relative 50 | use energy_asserts_m, only: & 51 | assert_equals, & 52 | assert_equals_within_absolute, & 53 | assert_equals_within_relative 54 | use energy_per_temperature_asserts_m, only: & 55 | assert_equals, & 56 | assert_equals_within_absolute, & 57 | assert_equals_within_relative 58 | use enthalpy_asserts_m, only: & 59 | assert_equals, & 60 | assert_equals_within_absolute, & 61 | assert_equals_within_relative 62 | use fluence_asserts_m, only: & 63 | assert_equals, & 64 | assert_equals_within_absolute, & 65 | assert_equals_within_relative 66 | use force_asserts_m, only: & 67 | assert_equals, & 68 | assert_equals_within_absolute, & 69 | assert_equals_within_relative 70 | use fracture_toughness_asserts_m, only: & 71 | assert_equals, & 72 | assert_equals_within_absolute, & 73 | assert_equals_within_relative 74 | use inverse_molar_mass_asserts_m, only: & 75 | assert_equals, & 76 | assert_equals_within_absolute, & 77 | assert_equals_within_relative 78 | use length_asserts_m, only: & 79 | assert_equals, & 80 | assert_equals_within_absolute, & 81 | assert_equals_within_relative 82 | use mass_asserts_m, only: & 83 | assert_equals, & 84 | assert_equals_within_absolute, & 85 | assert_equals_within_relative 86 | use mass_rate_asserts_m, only: & 87 | assert_equals, & 88 | assert_equals_within_absolute, & 89 | assert_equals_within_relative 90 | use molar_density_asserts_m, only: & 91 | assert_equals, & 92 | assert_equals_within_absolute, & 93 | assert_equals_within_relative 94 | use molar_enthalpy_asserts_m, only: & 95 | assert_equals, & 96 | assert_equals_within_absolute, & 97 | assert_equals_within_relative 98 | use molar_mass_asserts_m, only: & 99 | assert_equals, & 100 | assert_equals_within_absolute, & 101 | assert_equals_within_relative 102 | use molar_specific_heat_asserts_m, only: & 103 | assert_equals, & 104 | assert_equals_within_absolute, & 105 | assert_equals_within_relative 106 | use power_asserts_m, only: & 107 | assert_equals, & 108 | assert_equals_within_absolute, & 109 | assert_equals_within_relative 110 | use pressure_asserts_m, only: & 111 | assert_equals, & 112 | assert_equals_within_absolute, & 113 | assert_equals_within_relative 114 | use specific_heat_asserts_m, only: & 115 | assert_equals, & 116 | assert_equals_within_absolute, & 117 | assert_equals_within_relative 118 | use speed_asserts_m, only: & 119 | assert_equals, & 120 | assert_equals_within_absolute, & 121 | assert_equals_within_relative 122 | use stress_intensity_factor_asserts_m, only: & 123 | assert_equals, & 124 | assert_equals_within_absolute, & 125 | assert_equals_within_relative 126 | use temperature_asserts_m, only: & 127 | assert_equals, & 128 | assert_equals_within_absolute, & 129 | assert_equals_within_relative 130 | use thermal_conductivity_asserts_m, only: & 131 | assert_equals, & 132 | assert_equals_within_absolute, & 133 | assert_equals_within_relative 134 | use thermal_expansion_coefficient_asserts_m, only: & 135 | assert_equals, & 136 | assert_equals_within_absolute, & 137 | assert_equals_within_relative 138 | use time_asserts_m, only: & 139 | assert_equals, & 140 | assert_equals_within_absolute, & 141 | assert_equals_within_relative 142 | use volume_asserts_m, only: & 143 | assert_equals, & 144 | assert_equals_within_absolute, & 145 | assert_equals_within_relative 146 | use frequency_asserts_m, only: & 147 | assert_equals, & 148 | assert_equals_within_absolute, & 149 | assert_equals_within_relative 150 | end module 151 | -------------------------------------------------------------------------------- /quaff_garden_asserts/src/quaff_asserts_m.f90: -------------------------------------------------------------------------------- 1 | module quaff_asserts_m 2 | use acceleration_asserts_m, only: & 3 | assert_equals, & 4 | assert_equals_within_absolute, & 5 | assert_equals_within_relative 6 | use amount_asserts_m, only: & 7 | assert_equals, & 8 | assert_equals_within_absolute, & 9 | assert_equals_within_relative 10 | use amount_rate_asserts_m, only: & 11 | assert_equals, & 12 | assert_equals_within_absolute, & 13 | assert_equals_within_relative 14 | use amount_temperature_asserts_m, only: & 15 | assert_equals, & 16 | assert_equals_within_absolute, & 17 | assert_equals_within_relative 18 | use amount_temperature_rate_asserts_m, only: & 19 | assert_equals, & 20 | assert_equals_within_absolute, & 21 | assert_equals_within_relative 22 | use angle_asserts_m, only: & 23 | assert_equals, & 24 | assert_equals_within_absolute, & 25 | assert_equals_within_relative 26 | use area_asserts_m, only: & 27 | assert_equals, & 28 | assert_equals_within_absolute, & 29 | assert_equals_within_relative 30 | use burnup_asserts_m, only: & 31 | assert_equals, & 32 | assert_equals_within_absolute, & 33 | assert_equals_within_relative 34 | use convective_heat_transfer_asserts_m, only: & 35 | assert_equals, & 36 | assert_equals_within_absolute, & 37 | assert_equals_within_relative 38 | use delta_temperature_asserts_m, only: & 39 | assert_equals, & 40 | assert_equals_within_absolute, & 41 | assert_equals_within_relative 42 | use density_asserts_m, only: & 43 | assert_equals, & 44 | assert_equals_within_absolute, & 45 | assert_equals_within_relative 46 | use dynamic_viscosity_asserts_m, only: & 47 | assert_equals, & 48 | assert_equals_within_absolute, & 49 | assert_equals_within_relative 50 | use energy_asserts_m, only: & 51 | assert_equals, & 52 | assert_equals_within_absolute, & 53 | assert_equals_within_relative 54 | use energy_per_temperature_asserts_m, only: & 55 | assert_equals, & 56 | assert_equals_within_absolute, & 57 | assert_equals_within_relative 58 | use enthalpy_asserts_m, only: & 59 | assert_equals, & 60 | assert_equals_within_absolute, & 61 | assert_equals_within_relative 62 | use fluence_asserts_m, only: & 63 | assert_equals, & 64 | assert_equals_within_absolute, & 65 | assert_equals_within_relative 66 | use force_asserts_m, only: & 67 | assert_equals, & 68 | assert_equals_within_absolute, & 69 | assert_equals_within_relative 70 | use fracture_toughness_asserts_m, only: & 71 | assert_equals, & 72 | assert_equals_within_absolute, & 73 | assert_equals_within_relative 74 | use inverse_molar_mass_asserts_m, only: & 75 | assert_equals, & 76 | assert_equals_within_absolute, & 77 | assert_equals_within_relative 78 | use length_asserts_m, only: & 79 | assert_equals, & 80 | assert_equals_within_absolute, & 81 | assert_equals_within_relative 82 | use mass_asserts_m, only: & 83 | assert_equals, & 84 | assert_equals_within_absolute, & 85 | assert_equals_within_relative 86 | use mass_rate_asserts_m, only: & 87 | assert_equals, & 88 | assert_equals_within_absolute, & 89 | assert_equals_within_relative 90 | use molar_density_asserts_m, only: & 91 | assert_equals, & 92 | assert_equals_within_absolute, & 93 | assert_equals_within_relative 94 | use molar_enthalpy_asserts_m, only: & 95 | assert_equals, & 96 | assert_equals_within_absolute, & 97 | assert_equals_within_relative 98 | use molar_mass_asserts_m, only: & 99 | assert_equals, & 100 | assert_equals_within_absolute, & 101 | assert_equals_within_relative 102 | use molar_specific_heat_asserts_m, only: & 103 | assert_equals, & 104 | assert_equals_within_absolute, & 105 | assert_equals_within_relative 106 | use power_asserts_m, only: & 107 | assert_equals, & 108 | assert_equals_within_absolute, & 109 | assert_equals_within_relative 110 | use pressure_asserts_m, only: & 111 | assert_equals, & 112 | assert_equals_within_absolute, & 113 | assert_equals_within_relative 114 | use specific_heat_asserts_m, only: & 115 | assert_equals, & 116 | assert_equals_within_absolute, & 117 | assert_equals_within_relative 118 | use speed_asserts_m, only: & 119 | assert_equals, & 120 | assert_equals_within_absolute, & 121 | assert_equals_within_relative 122 | use stress_intensity_factor_asserts_m, only: & 123 | assert_equals, & 124 | assert_equals_within_absolute, & 125 | assert_equals_within_relative 126 | use temperature_asserts_m, only: & 127 | assert_equals, & 128 | assert_equals_within_absolute, & 129 | assert_equals_within_relative 130 | use thermal_conductivity_asserts_m, only: & 131 | assert_equals, & 132 | assert_equals_within_absolute, & 133 | assert_equals_within_relative 134 | use thermal_expansion_coefficient_asserts_m, only: & 135 | assert_equals, & 136 | assert_equals_within_absolute, & 137 | assert_equals_within_relative 138 | use time_asserts_m, only: & 139 | assert_equals, & 140 | assert_equals_within_absolute, & 141 | assert_equals_within_relative 142 | use volume_asserts_m, only: & 143 | assert_equals, & 144 | assert_equals_within_absolute, & 145 | assert_equals_within_relative 146 | use frequency_asserts_m, only: & 147 | assert_equals, & 148 | assert_equals_within_absolute, & 149 | assert_equals_within_relative 150 | end module 151 | -------------------------------------------------------------------------------- /test/main.f90: -------------------------------------------------------------------------------- 1 | ! Generated by cart. DO NOT EDIT 2 | program main 3 | implicit none 4 | 5 | if (.not.run()) stop 1 6 | contains 7 | function run() result(passed) 8 | use acceleration_test, only: & 9 | acceleration_acceleration => & 10 | test_acceleration 11 | use amount_rate_test, only: & 12 | amount_rate_amount_rate => & 13 | test_amount_rate 14 | use amount_temperature_rate_test, only: & 15 | amount_temperature_rate_amount_temperature_rate => & 16 | test_amount_temperature_rate 17 | use amount_temperature_test, only: & 18 | amount_temperature_amount_temperature => & 19 | test_amount_temperature 20 | use amount_test, only: & 21 | amount_amount => & 22 | test_amount 23 | use angle_test, only: & 24 | angle_angle => & 25 | test_angle 26 | use area_test, only: & 27 | area_area => & 28 | test_area 29 | use burnup_test, only: & 30 | burnup_burnup => & 31 | test_burnup 32 | use convective_heat_transfer_test, only: & 33 | convective_heat_transfer_convective_heat_transfer => & 34 | test_convective_heat_transfer 35 | use delta_temperature_test, only: & 36 | delta_temperature_delta_temperature => & 37 | test_delta_temperature 38 | use density_test, only: & 39 | density_density => & 40 | test_density 41 | use dynamic_viscosity_test, only: & 42 | dynamic_viscosity_dynamic_viscosity => & 43 | test_dynamic_viscosity 44 | use energy_per_temperature_test, only: & 45 | energy_per_temperature_energy_per_temperature => & 46 | test_energy_per_temperature 47 | use energy_test, only: & 48 | energy_energy => & 49 | test_energy 50 | use enthalpy_test, only: & 51 | enthalpy_enthalpy => & 52 | test_enthalpy 53 | use fluence_test, only: & 54 | fluence_fluence => & 55 | test_fluence 56 | use force_test, only: & 57 | force_force => & 58 | test_force 59 | use fracture_toughness_test, only: & 60 | fracture_toughness_fracture_toughness => & 61 | test_fracture_toughness 62 | use frequency_test, only: & 63 | frequency_frequency => & 64 | test_frequency 65 | use interquantity_test, only: & 66 | interquantity_interquantity_operators => & 67 | test_interquantity_operators 68 | use inverse_molar_mass_test, only: & 69 | inverse_molar_mass_inverse_molar_mass => & 70 | test_inverse_molar_mass 71 | use length_test, only: & 72 | length_length => & 73 | test_length 74 | use mass_rate_test, only: & 75 | mass_rate_mass_rate => & 76 | test_mass_rate 77 | use mass_test, only: & 78 | mass_mass => & 79 | test_mass 80 | use molar_density_test, only: & 81 | molar_density_molar_density => & 82 | test_molar_density 83 | use molar_enthalpy_test, only: & 84 | molar_enthalpy_molar_enthalpy => & 85 | test_molar_enthalpy 86 | use molar_mass_test, only: & 87 | molar_mass_molar_mass => & 88 | test_molar_mass 89 | use molar_specific_heat_test, only: & 90 | molar_specific_heat_molar_specific_heat => & 91 | test_molar_specific_heat 92 | use power_test, only: & 93 | power_power => & 94 | test_power 95 | use pressure_test, only: & 96 | pressure_pressure => & 97 | test_pressure 98 | use specific_heat_test, only: & 99 | specific_heat_specific_heat => & 100 | test_specific_heat 101 | use speed_test, only: & 102 | speed_speed => & 103 | test_speed 104 | use stress_intensity_factor_test, only: & 105 | stress_intensity_factor_stress_intensity_factor => & 106 | test_stress_intensity_factor 107 | use temperature_test, only: & 108 | temperature_temperature => & 109 | test_temperature 110 | use thermal_conductivity_test, only: & 111 | thermal_conductivity_thermal_conductivity => & 112 | test_thermal_conductivity 113 | use thermal_expansion_coefficient_test, only: & 114 | thermal_expansion_coefficient_thermal_expansion_coefficient => & 115 | test_thermal_expansion_coefficient 116 | use time_test, only: & 117 | time_time => & 118 | test_time 119 | use volume_test, only: & 120 | volume_volume => & 121 | test_volume 122 | use veggies, only: test_item_t, test_that, run_tests 123 | 124 | 125 | 126 | logical :: passed 127 | 128 | type(test_item_t) :: tests 129 | type(test_item_t) :: individual_tests(38) 130 | 131 | individual_tests(1) = acceleration_acceleration() 132 | individual_tests(2) = amount_rate_amount_rate() 133 | individual_tests(3) = amount_temperature_rate_amount_temperature_rate() 134 | individual_tests(4) = amount_temperature_amount_temperature() 135 | individual_tests(5) = amount_amount() 136 | individual_tests(6) = angle_angle() 137 | individual_tests(7) = area_area() 138 | individual_tests(8) = burnup_burnup() 139 | individual_tests(9) = convective_heat_transfer_convective_heat_transfer() 140 | individual_tests(10) = delta_temperature_delta_temperature() 141 | individual_tests(11) = density_density() 142 | individual_tests(12) = dynamic_viscosity_dynamic_viscosity() 143 | individual_tests(13) = energy_per_temperature_energy_per_temperature() 144 | individual_tests(14) = energy_energy() 145 | individual_tests(15) = enthalpy_enthalpy() 146 | individual_tests(16) = fluence_fluence() 147 | individual_tests(17) = force_force() 148 | individual_tests(18) = fracture_toughness_fracture_toughness() 149 | individual_tests(19) = frequency_frequency() 150 | individual_tests(20) = interquantity_interquantity_operators() 151 | individual_tests(21) = inverse_molar_mass_inverse_molar_mass() 152 | individual_tests(22) = length_length() 153 | individual_tests(23) = mass_rate_mass_rate() 154 | individual_tests(24) = mass_mass() 155 | individual_tests(25) = molar_density_molar_density() 156 | individual_tests(26) = molar_enthalpy_molar_enthalpy() 157 | individual_tests(27) = molar_mass_molar_mass() 158 | individual_tests(28) = molar_specific_heat_molar_specific_heat() 159 | individual_tests(29) = power_power() 160 | individual_tests(30) = pressure_pressure() 161 | individual_tests(31) = specific_heat_specific_heat() 162 | individual_tests(32) = speed_speed() 163 | individual_tests(33) = stress_intensity_factor_stress_intensity_factor() 164 | individual_tests(34) = temperature_temperature() 165 | individual_tests(35) = thermal_conductivity_thermal_conductivity() 166 | individual_tests(36) = thermal_expansion_coefficient_thermal_expansion_coefficient() 167 | individual_tests(37) = time_time() 168 | individual_tests(38) = volume_volume() 169 | tests = test_that(individual_tests) 170 | 171 | 172 | passed = run_tests(tests) 173 | 174 | end function 175 | end program 176 | -------------------------------------------------------------------------------- /src/quaff/conversion_factors_m.f90: -------------------------------------------------------------------------------- 1 | module quaff_conversion_factors_m 2 | implicit none 3 | 4 | ! SI Scaling 5 | double precision, parameter :: CENTI_PER_BASE = 100.0d0 6 | double precision, parameter :: MILLI_PER_BASE = 1.0d3 7 | double precision, parameter :: MICRO_PER_BASE = 1.0d6 8 | double precision, parameter :: BASE_PER_KILO = 1.0d3 9 | double precision, parameter :: KILO_PER_BASE = 1.0d0 / BASE_PER_KILO 10 | double precision, parameter :: BASE_PER_MEGA = 1.0d6 11 | double precision, parameter :: MEGA_PER_BASE = 1.0d0 / BASE_PER_MEGA 12 | 13 | ! Length 14 | double precision, parameter :: METERS_PER_INCH = 0.0254d0 15 | double precision, parameter :: INCHES_PER_METER = 1.0d0 / METERS_PER_INCH 16 | double precision, parameter :: INCHES_PER_FOOT = 12.0d0 17 | double precision, parameter :: FEET_PER_INCH = 1.0d0 / INCHES_PER_FOOT 18 | double precision, parameter :: CENTIMETERS_PER_METER = CENTI_PER_BASE 19 | double precision, parameter :: METERS_PER_CENTIMETER = 1.0d0 / CENTIMETERS_PER_METER 20 | double precision, parameter :: FEET_PER_METER = INCHES_PER_METER * FEET_PER_INCH 21 | double precision, parameter :: MICROINCHES_PER_METER = INCHES_PER_METER * MICRO_PER_BASE 22 | double precision, parameter :: MICROMETERS_PER_METER = MICRO_PER_BASE 23 | double precision, parameter :: MILLIMETERS_PER_METER = MILLI_PER_BASE 24 | 25 | ! Mass 26 | double precision, parameter :: KILOGRAMS_PER_POUND = 0.45359237d0 ! Taken from NIST (https://www.nist.gov/physical-measurement-laboratory/nist-guide-si-footnotes#f22) 27 | double precision, parameter :: POUNDS_PER_KILOGRAM = 1.0d0 / KILOGRAMS_PER_POUND 28 | double precision, parameter :: GRAMS_PER_KILOGRAM = BASE_PER_KILO 29 | double precision, parameter :: OUNCES_PER_POUND = 16.0d0 30 | double precision, parameter :: POUNDS_PER_TON = 2000.0d0 31 | double precision, parameter :: TONS_PER_POUND = 1.0d0 / POUNDS_PER_TON 32 | double precision, parameter :: OUNCES_PER_KILOGRAM = POUNDS_PER_KILOGRAM * OUNCES_PER_POUND 33 | double precision, parameter :: TONS_PER_KILOGRAM = TONS_PER_POUND * POUNDS_PER_KILOGRAM 34 | 35 | ! Temperature 36 | double precision, parameter :: CELSIUS_KELVIN_DIFFERENCE = 273.15d0 37 | double precision, parameter :: FAHRENHEIT_RANKINE_DIFFERENCE = 459.67d0 38 | double precision, parameter :: RANKINE_PER_KELVIN = 9.0d0 / 5.0d0 39 | 40 | ! Amount 41 | double precision, parameter :: AVOGADROS_NUMBER = 6.022140857d23 42 | 43 | ! Angle 44 | double precision, parameter :: PI = 3.14159265359d0 45 | double precision, parameter :: DEGREES_PER_RADIAN = 180.0d0 / PI 46 | 47 | ! Time 48 | double precision, parameter :: SECONDS_PER_MINUTE = 60.0d0 49 | double precision, parameter :: MINUTES_PER_HOUR = 60.0d0 50 | double precision, parameter :: HOURS_PER_DAY = 24.0d0 51 | double precision, parameter :: DAYS_PER_HOUR = 1.0d0 / HOURS_PER_DAY 52 | double precision, parameter :: SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR 53 | double precision, parameter :: MICROSECONDS_PER_SECOND = MICRO_PER_BASE 54 | double precision, parameter :: MILLISECONDS_PER_SECOND = MILLI_PER_BASE 55 | double precision, parameter :: MINUTES_PER_SECOND = 1.0d0 / SECONDS_PER_MINUTE 56 | double precision, parameter :: HOURS_PER_SECOND = 1.0d0 / SECONDS_PER_HOUR 57 | double precision, parameter :: DAYS_PER_SECOND = DAYS_PER_HOUR * HOURS_PER_SECOND 58 | double precision, parameter :: DAYS_PER_YEAR = 365.25 59 | double precision, parameter :: SECONDS_PER_YEAR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY * DAYS_PER_YEAR 60 | double precision, parameter :: YEARS_PER_SECOND = 1.0d0 / SECONDS_PER_YEAR 61 | 62 | ! Area 63 | double precision, parameter :: SQUARE_CENTIMETERS_PER_SQUARE_METER = CENTIMETERS_PER_METER**2 64 | double precision, parameter :: SQUARE_INCHES_PER_SQUARE_METER = INCHES_PER_METER**2 65 | double precision, parameter :: SQUARE_FEET_PER_SQUARE_METER = FEET_PER_METER**2 66 | 67 | ! Volume 68 | double precision, parameter :: CUBIC_CENTIMETERS_PER_CUBIC_METER = CENTIMETERS_PER_METER**3 69 | double precision, parameter :: CUBIC_MILLIMETERS_PER_CUBIC_METER = MILLIMETERS_PER_METER**3 70 | double precision, parameter :: LITERS_PER_CUBIC_METER = 1.0d3 71 | 72 | ! Density 73 | double precision, parameter :: GRAMS_PER_CUBIC_METER_PER_KILOGRAMS_PER_CUBIC_METER = GRAMS_PER_KILOGRAM 74 | double precision, parameter :: GRAMS_PER_CUBIC_CENTIMETER_PER_KILOGRAMS_PER_CUBIC_METER = & 75 | GRAMS_PER_KILOGRAM/CUBIC_CENTIMETERS_PER_CUBIC_METER 76 | double precision, parameter :: POUNDS_PER_CUBIC_FOOT_PER_KILOGRAMS_PER_CUBIC_METER = & 77 | POUNDS_PER_KILOGRAM / FEET_PER_METER**3 78 | 79 | ! Molar Mass 80 | double precision, parameter :: GRAMS_PER_MOL_PER_KILOGRAMS_PER_MOL = BASE_PER_KILO 81 | double precision, parameter :: MOLS_PER_GRAM_PER_MOLS_PER_KILOGRAM = 1.d0 / GRAMS_PER_MOL_PER_KILOGRAMS_PER_MOL 82 | 83 | ! Speed 84 | double precision, parameter :: CENTIMETERS_PER_SECOND_PER_METERS_PER_SECOND = CENTIMETERS_PER_METER 85 | double precision, parameter :: FEET_PER_SECOND_PER_METERS_PER_SECOND = FEET_PER_METER 86 | double precision, parameter :: MILLIMETERS_PER_SECOND_PER_METERS_PER_SECOND = MILLIMETERS_PER_METER 87 | 88 | ! Acceleration 89 | double precision, parameter :: GRAVITY = 9.80665d0 ! m/s^2 according to Wikipedia 90 | double precision, parameter :: CENTIMETERS_PER_SQUARE_SECOND_PER_METERS_PER_SQUARE_SECOND = CENTIMETERS_PER_METER 91 | double precision, parameter :: FEET_PER_SQUARE_SECOND_PER_METERS_PER_SQUARE_SECOND = FEET_PER_METER 92 | 93 | ! Force 94 | ! Note: 1 N = 1 (kg m)/s^2 95 | double precision, parameter :: DYNES_PER_NEWTON = & 96 | GRAMS_PER_KILOGRAM * CENTIMETERS_PER_SQUARE_SECOND_PER_METERS_PER_SQUARE_SECOND 97 | double precision, parameter :: KILOPONDS_PER_NEWTON = 1.0d0 / GRAVITY ! 1 kp = 1 kg * gravity 98 | double precision, parameter :: MILLINEWTONS_PER_NEWTON = MILLI_PER_BASE 99 | double precision, parameter :: POUNDS_PER_NEWTON = POUNDS_PER_KILOGRAM / GRAVITY ! 1 lbf = 1 lbm * gravity 100 | 101 | ! Energy 102 | ! Note: 1 J = 1 (N m) 103 | double precision, parameter :: JOULES_PER_CALORIE = 4.1868d0 ! Taken from NIST for "IT" (https://www.nist.gov/physical-measurement-laboratory/nist-guide-si-footnotes#f09) 104 | double precision, parameter :: JOULE_PER_BTU = 1.05505585262d3 ! Taken from NIST for "IT" (https://www.nist.gov/physical-measurement-laboratory/nist-guide-si-footnotes#f09) 105 | double precision, parameter :: CALORIES_PER_JOULE = 1.0d0 / JOULES_PER_CALORIE 106 | double precision, parameter :: BTU_PER_JOULE = 1.0d0 / JOULE_PER_BTU 107 | double precision, parameter :: KILOJOULES_PER_JOULE = KILO_PER_BASE 108 | double precision, parameter :: MEGABTU_PER_JOULE = MEGA_PER_BASE * BTU_PER_JOULE 109 | double precision, parameter :: MEGAWATT_DAYS_PER_JOULE = MEGA_PER_BASE * DAYS_PER_SECOND 110 | double precision, parameter :: POUNDS_FORCE_FOOT_PER_NEWTON_METER = POUNDS_PER_NEWTON * FEET_PER_METER 111 | 112 | ! Power 113 | ! Note: 1 W = 1 J/s 114 | double precision, parameter :: BTU_PER_HOUR_PER_WATT = BTU_PER_JOULE * SECONDS_PER_HOUR 115 | double precision, parameter :: CALORIES_PER_SECOND_PER_WATT = CALORIES_PER_JOULE 116 | double precision, parameter :: MEGABTU_PER_HOUR_PER_WATT = MEGA_PER_BASE * BTU_PER_HOUR_PER_WATT 117 | double precision, parameter :: MEGAWATTS_PER_WATT = MEGA_PER_BASE 118 | 119 | ! Pressure 120 | ! Note: 1 Pa = 1 N/m^2 121 | double precision, parameter :: DYNES_PER_SQUARE_CENTIMETER_PER_PASCAL = DYNES_PER_NEWTON / SQUARE_CENTIMETERS_PER_SQUARE_METER 122 | double precision, parameter :: KILOPASCALS_PER_PASCAL = KILO_PER_BASE 123 | double precision, parameter :: KILOPONDS_PER_SQUARE_CENTIMETER_PER_PASCAL = & 124 | KILOPONDS_PER_NEWTON / SQUARE_CENTIMETERS_PER_SQUARE_METER 125 | double precision, parameter :: MEGAPASCALS_PER_PASCAL = MEGA_PER_BASE 126 | double precision, parameter :: POUNDS_PER_SQUARE_INCH_PER_PASCAL = POUNDS_PER_NEWTON / SQUARE_INCHES_PER_SQUARE_METER 127 | double precision, parameter :: PASCALS_PER_BAR = 100000.0d0 128 | double precision, parameter :: BAR_PER_PASCAL = 1.0d0 / PASCALS_PER_BAR 129 | double precision, parameter :: PASCALS_PER_ATMOSPHERE = 101325.0d0 130 | double precision, parameter :: ATMOSPHERES_PER_PASCAL = 1.0d0 / PASCALS_PER_ATMOSPHERE 131 | double precision, parameter :: KILOPOUNDS_PER_SQUARE_INCH_PER_PASCAL = & 132 | POUNDS_PER_SQUARE_INCH_PER_PASCAL / 1000.0d0 133 | 134 | ! Dynamic Viscosity 135 | double precision, parameter :: MEGAPASCAL_SECONDS_PER_PASCAL_SECOND = MEGA_PER_BASE 136 | 137 | ! Enthalpy 138 | double precision, parameter :: KILOJOULES_PER_KILOGRAM_PER_JOULES_PER_KILOGRAM = KILO_PER_BASE 139 | 140 | ! Burnup 141 | double precision, parameter :: MEGAWATT_DAYS_PER_TON_PER_WATT_SECONDS_PER_KILOGRAM = & 142 | MEGA_PER_BASE * DAYS_PER_SECOND / TONS_PER_KILOGRAM 143 | 144 | ! Thermal Conductivity 145 | double precision, parameter :: CAL_PER_SEC_CM_K_PER_WATTS_PER_METER_KELVIN = & 146 | CALORIES_PER_SECOND_PER_WATT / CENTIMETERS_PER_METER 147 | double precision, parameter :: WATTS_PER_CENTIMETER_KELVIN_PER_WATTS_PER_METER_KELVIN = & 148 | METERS_PER_CENTIMETER 149 | double precision, parameter :: BTU_PER_HOUR_FEET_RANKINE_PER_WATTS_PER_METER_KELVIN = & 150 | BTU_PER_HOUR_PER_WATT / (FEET_PER_METER * RANKINE_PER_KELVIN) 151 | 152 | ! Energy Per Amount 153 | double precision, parameter :: KILOJOULES_PER_MOL_PER_JOULES_PER_MOL = & 154 | KILO_PER_BASE 155 | 156 | ! Energy Per Temperature Amount 157 | double precision, parameter :: KILOJOULES_PER_KELVIN_MOL_PER_JOULES_PER_KELVIN_MOL = & 158 | KILO_PER_BASE 159 | 160 | ! Specific Heat 161 | double precision, parameter :: BTU_PER_POUNDS_RANKINE_PER_JOULES_PER_KILOGRAM_KELVIN = & 162 | BTU_PER_JOULE / POUNDS_PER_KILOGRAM / RANKINE_PER_KELVIN 163 | 164 | ! convective heat transfer 165 | double precision, parameter :: BTU_PER_HR_SQ_FT_RANKINE_PER_WATTS_PER_SQUARE_METER_KELVIN = & 166 | BTU_PER_HOUR_PER_WATT / SQUARE_FEET_PER_SQUARE_METER / RANKINE_PER_KELVIN 167 | 168 | ! thermal expansion coefficient 169 | double precision, parameter :: PER_RANKINE_PER_KELVIN = & 170 | 1 / RANKINE_PER_KELVIN 171 | 172 | ! fluence 173 | double precision, parameter :: PARTICLES_PER_SQUARE_CENTIMETER_PER_PARTICLES_PER_SQUARE_METER = & 174 | 1 / SQUARE_CENTIMETERS_PER_SQUARE_METER 175 | ! fluence 176 | double precision, parameter :: MEGAPASCAL_ROOT_METER_PER_PASCAL_ROOT_METER = & 177 | MEGA_PER_BASE 178 | double precision, parameter :: KSI_ROOT_INCH_PER_PASCAL_ROOT_METER = & 179 | KILO_PER_BASE * POUNDS_PER_SQUARE_INCH_PER_PASCAL / sqrt(INCHES_PER_METER) 180 | 181 | end module 182 | -------------------------------------------------------------------------------- /quaff_asserts/src/area_asserts_m.f90: -------------------------------------------------------------------------------- 1 | module area_asserts_m 2 | use iso_varying_string, only: varying_string, operator(//), var_str 3 | use quaff, only: area_t 4 | use strff, only: to_string 5 | use veggies, only: & 6 | result_t, & 7 | fail, & 8 | make_equals_failure_message, & 9 | make_equals_success_message, & 10 | make_within_failure_message, & 11 | make_within_success_message, & 12 | succeed, & 13 | with_user_message 14 | 15 | implicit none 16 | private 17 | public :: & 18 | assert_equals, & 19 | assert_equals_within_absolute, & 20 | assert_equals_within_relative 21 | 22 | interface assert_equals 23 | module procedure assert_equals_basic 24 | module procedure assert_equals_with_message_c 25 | module procedure assert_equals_with_message_s 26 | module procedure assert_equals_with_messages_cc 27 | module procedure assert_equals_with_messages_cs 28 | module procedure assert_equals_with_messages_sc 29 | module procedure assert_equals_with_messages_ss 30 | end interface 31 | 32 | interface assert_equals_within_absolute 33 | module procedure assert_equals_within_absolute_basic 34 | module procedure assert_equals_within_absolute_with_message_c 35 | module procedure assert_equals_within_absolute_with_message_s 36 | module procedure assert_equals_within_absolute_with_messages_cc 37 | module procedure assert_equals_within_absolute_with_messages_cs 38 | module procedure assert_equals_within_absolute_with_messages_sc 39 | module procedure assert_equals_within_absolute_with_messages_ss 40 | end interface 41 | 42 | interface assert_equals_within_relative 43 | module procedure assert_equals_within_relative_basic 44 | module procedure assert_equals_within_relative_with_message_c 45 | module procedure assert_equals_within_relative_with_message_s 46 | module procedure assert_equals_within_relative_with_messages_cc 47 | module procedure assert_equals_within_relative_with_messages_cs 48 | module procedure assert_equals_within_relative_with_messages_sc 49 | module procedure assert_equals_within_relative_with_messages_ss 50 | end interface 51 | contains 52 | pure function assert_equals_basic(expected, actual) result(result_) 53 | type(area_t), intent(in) :: expected 54 | type(area_t), intent(in) :: actual 55 | type(result_t) :: result_ 56 | 57 | result_ = assert_equals(expected, actual, var_str(""), var_str("")) 58 | end function 59 | 60 | pure function assert_equals_with_message_c( & 61 | expected, actual, message) result(result_) 62 | type(area_t), intent(in) :: expected 63 | type(area_t), intent(in) :: actual 64 | character(len=*), intent(in) :: message 65 | type(result_t) :: result_ 66 | 67 | result_ = assert_equals( & 68 | expected, actual, var_str(message), var_str(message)) 69 | end function 70 | 71 | pure function assert_equals_with_message_s( & 72 | expected, actual, message) result(result_) 73 | type(area_t), intent(in) :: expected 74 | type(area_t), intent(in) :: actual 75 | type(varying_string), intent(in) :: message 76 | type(result_t) :: result_ 77 | 78 | result_ = assert_equals( & 79 | expected, actual, message, message) 80 | end function 81 | 82 | pure function assert_equals_with_messages_cc( & 83 | expected, actual, success_message, failure_message) result(result_) 84 | type(area_t), intent(in) :: expected 85 | type(area_t), intent(in) :: actual 86 | character(len=*), intent(in) :: success_message 87 | character(len=*), intent(in) :: failure_message 88 | type(result_t) :: result_ 89 | 90 | result_ = assert_equals( & 91 | expected, & 92 | actual, & 93 | var_str(success_message), & 94 | var_str(failure_message)) 95 | end function 96 | 97 | pure function assert_equals_with_messages_cs( & 98 | expected, actual, success_message, failure_message) result(result_) 99 | type(area_t), intent(in) :: expected 100 | type(area_t), intent(in) :: actual 101 | character(len=*), intent(in) :: success_message 102 | type(varying_string), intent(in) :: failure_message 103 | type(result_t) :: result_ 104 | 105 | result_ = assert_equals( & 106 | expected, & 107 | actual, & 108 | var_str(success_message), & 109 | failure_message) 110 | end function 111 | 112 | pure function assert_equals_with_messages_sc( & 113 | expected, actual, success_message, failure_message) result(result_) 114 | type(area_t), intent(in) :: expected 115 | type(area_t), intent(in) :: actual 116 | type(varying_string), intent(in) :: success_message 117 | character(len=*), intent(in) :: failure_message 118 | type(result_t) :: result_ 119 | 120 | result_ = assert_equals( & 121 | expected, & 122 | actual, & 123 | success_message, & 124 | var_str(failure_message)) 125 | end function 126 | 127 | pure function assert_equals_with_messages_ss( & 128 | expected, & 129 | actual, & 130 | success_message, & 131 | failure_message) & 132 | result(result_) 133 | type(area_t), intent(in) :: expected 134 | type(area_t), intent(in) :: actual 135 | type(varying_string), intent(in) :: success_message 136 | type(varying_string), intent(in) :: failure_message 137 | type(result_t) :: result_ 138 | 139 | if (expected == actual) then 140 | result_ = succeed(with_user_message( & 141 | make_equals_success_message( & 142 | expected%to_string()), & 143 | success_message)) 144 | else 145 | result_ = fail(with_user_message( & 146 | make_equals_failure_message( & 147 | expected%to_string(), & 148 | actual%to_string()), & 149 | failure_message)) 150 | end if 151 | end function 152 | 153 | pure function assert_equals_within_absolute_basic( & 154 | expected, actual, tolerance) result(result_) 155 | type(area_t), intent(in) :: expected 156 | type(area_t), intent(in) :: actual 157 | type(area_t), intent(in) :: tolerance 158 | type(result_t) :: result_ 159 | 160 | result_ = assert_equals_within_absolute( & 161 | expected, actual, tolerance, var_str(""), var_str("")) 162 | end function 163 | 164 | pure function assert_equals_within_absolute_with_message_c( & 165 | expected, actual, tolerance, message) result(result_) 166 | type(area_t), intent(in) :: expected 167 | type(area_t), intent(in) :: actual 168 | type(area_t), intent(in) :: tolerance 169 | character(len=*), intent(in) :: message 170 | type(result_t) :: result_ 171 | 172 | result_ = assert_equals_within_absolute( & 173 | expected, actual, tolerance, var_str(message), var_str(message)) 174 | end function 175 | 176 | pure function assert_equals_within_absolute_with_message_s( & 177 | expected, actual, tolerance, message) result(result_) 178 | type(area_t), intent(in) :: expected 179 | type(area_t), intent(in) :: actual 180 | type(area_t), intent(in) :: tolerance 181 | type(varying_string), intent(in) :: message 182 | type(result_t) :: result_ 183 | 184 | result_ = assert_equals_within_absolute( & 185 | expected, actual, tolerance, message, message) 186 | end function 187 | 188 | pure function assert_equals_within_absolute_with_messages_cc( & 189 | expected, & 190 | actual, & 191 | tolerance, & 192 | success_message, & 193 | failure_message) & 194 | result(result_) 195 | type(area_t), intent(in) :: expected 196 | type(area_t), intent(in) :: actual 197 | type(area_t), intent(in) :: tolerance 198 | character(len=*), intent(in) :: success_message 199 | character(len=*), intent(in) :: failure_message 200 | type(result_t) :: result_ 201 | 202 | result_ = assert_equals_within_absolute( & 203 | expected, & 204 | actual, & 205 | tolerance, & 206 | var_str(success_message), & 207 | var_str(failure_message)) 208 | end function 209 | 210 | pure function assert_equals_within_absolute_with_messages_cs( & 211 | expected, & 212 | actual, & 213 | tolerance, & 214 | success_message, & 215 | failure_message) & 216 | result(result_) 217 | type(area_t), intent(in) :: expected 218 | type(area_t), intent(in) :: actual 219 | type(area_t), intent(in) :: tolerance 220 | character(len=*), intent(in) :: success_message 221 | type(varying_string), intent(in) :: failure_message 222 | type(result_t) :: result_ 223 | 224 | result_ = assert_equals_within_absolute( & 225 | expected, & 226 | actual, & 227 | tolerance, & 228 | var_str(success_message), & 229 | failure_message) 230 | end function 231 | 232 | pure function assert_equals_within_absolute_with_messages_sc( & 233 | expected, & 234 | actual, & 235 | tolerance, & 236 | success_message, & 237 | failure_message) & 238 | result(result_) 239 | type(area_t), intent(in) :: expected 240 | type(area_t), intent(in) :: actual 241 | type(area_t), intent(in) :: tolerance 242 | type(varying_string), intent(in) :: success_message 243 | character(len=*), intent(in) :: failure_message 244 | type(result_t) :: result_ 245 | 246 | result_ = assert_equals_within_absolute( & 247 | expected, & 248 | actual, & 249 | tolerance, & 250 | success_message, & 251 | var_str(failure_message)) 252 | end function 253 | 254 | pure function assert_equals_within_absolute_with_messages_ss( & 255 | expected, & 256 | actual, & 257 | tolerance, & 258 | success_message, & 259 | failure_message) & 260 | result(result_) 261 | type(area_t), intent(in) :: expected 262 | type(area_t), intent(in) :: actual 263 | type(area_t), intent(in) :: tolerance 264 | type(varying_string), intent(in) :: success_message 265 | type(varying_string), intent(in) :: failure_message 266 | type(result_t) :: result_ 267 | 268 | if (expected%equal(actual, within = tolerance)) then 269 | result_ = succeed(with_user_message( & 270 | make_within_success_message( & 271 | expected%to_string(), & 272 | actual%to_string(), & 273 | tolerance%to_string()), & 274 | success_message)) 275 | else 276 | result_ = fail(with_user_message( & 277 | make_within_failure_message( & 278 | expected%to_string(), & 279 | actual%to_string(), & 280 | tolerance%to_string()), & 281 | failure_message)) 282 | end if 283 | end function 284 | 285 | pure function assert_equals_within_relative_basic( & 286 | expected, actual, tolerance) result(result_) 287 | type(area_t), intent(in) :: expected 288 | type(area_t), intent(in) :: actual 289 | double precision, intent(in) :: tolerance 290 | type(result_t) :: result_ 291 | 292 | result_ = assert_equals_within_relative( & 293 | expected, actual, tolerance, var_str(""), var_str("")) 294 | end function 295 | 296 | pure function assert_equals_within_relative_with_message_c( & 297 | expected, actual, tolerance, message) result(result_) 298 | type(area_t), intent(in) :: expected 299 | type(area_t), intent(in) :: actual 300 | double precision, intent(in) :: tolerance 301 | character(len=*), intent(in) :: message 302 | type(result_t) :: result_ 303 | 304 | result_ = assert_equals_within_relative( & 305 | expected, actual, tolerance, var_str(message), var_str(message)) 306 | end function 307 | 308 | pure function assert_equals_within_relative_with_message_s( & 309 | expected, actual, tolerance, message) result(result_) 310 | type(area_t), intent(in) :: expected 311 | type(area_t), intent(in) :: actual 312 | double precision, intent(in) :: tolerance 313 | type(varying_string), intent(in) :: message 314 | type(result_t) :: result_ 315 | 316 | result_ = assert_equals_within_relative( & 317 | expected, actual, tolerance, message, message) 318 | end function 319 | 320 | pure function assert_equals_within_relative_with_messages_cc( & 321 | expected, & 322 | actual, & 323 | tolerance, & 324 | success_message, & 325 | failure_message) & 326 | result(result_) 327 | type(area_t), intent(in) :: expected 328 | type(area_t), intent(in) :: actual 329 | double precision, intent(in) :: tolerance 330 | character(len=*), intent(in) :: success_message 331 | character(len=*), intent(in) :: failure_message 332 | type(result_t) :: result_ 333 | 334 | result_ = assert_equals_within_relative( & 335 | expected, & 336 | actual, & 337 | tolerance, & 338 | var_str(success_message), & 339 | var_str(failure_message)) 340 | end function 341 | 342 | pure function assert_equals_within_relative_with_messages_cs( & 343 | expected, & 344 | actual, & 345 | tolerance, & 346 | success_message, & 347 | failure_message) & 348 | result(result_) 349 | type(area_t), intent(in) :: expected 350 | type(area_t), intent(in) :: actual 351 | double precision, intent(in) :: tolerance 352 | character(len=*), intent(in) :: success_message 353 | type(varying_string), intent(in) :: failure_message 354 | type(result_t) :: result_ 355 | 356 | result_ = assert_equals_within_relative( & 357 | expected, & 358 | actual, & 359 | tolerance, & 360 | var_str(success_message), & 361 | failure_message) 362 | end function 363 | 364 | pure function assert_equals_within_relative_with_messages_sc( & 365 | expected, & 366 | actual, & 367 | tolerance, & 368 | success_message, & 369 | failure_message) & 370 | result(result_) 371 | type(area_t), intent(in) :: expected 372 | type(area_t), intent(in) :: actual 373 | double precision, intent(in) :: tolerance 374 | type(varying_string), intent(in) :: success_message 375 | character(len=*), intent(in) :: failure_message 376 | type(result_t) :: result_ 377 | 378 | result_ = assert_equals_within_relative( & 379 | expected, & 380 | actual, & 381 | tolerance, & 382 | success_message, & 383 | var_str(failure_message)) 384 | end function 385 | 386 | pure function assert_equals_within_relative_with_messages_ss( & 387 | expected, & 388 | actual, & 389 | tolerance, & 390 | success_message, & 391 | failure_message) & 392 | result(result_) 393 | type(area_t), intent(in) :: expected 394 | type(area_t), intent(in) :: actual 395 | double precision, intent(in) :: tolerance 396 | type(varying_string), intent(in) :: success_message 397 | type(varying_string), intent(in) :: failure_message 398 | type(result_t) :: result_ 399 | 400 | if (expected%equal(actual, within = tolerance)) then 401 | result_ = succeed(with_user_message( & 402 | make_within_success_message( & 403 | expected%to_string(), & 404 | actual%to_string(), & 405 | to_string(tolerance * 100.0d0) // "%"), & 406 | success_message)) 407 | else 408 | result_ = fail(with_user_message( & 409 | make_within_failure_message( & 410 | expected%to_string(), & 411 | actual%to_string(), & 412 | to_string(tolerance * 100.0d0) // "%"), & 413 | failure_message)) 414 | end if 415 | end function 416 | end module 417 | --------------------------------------------------------------------------------