- Notifications
You must be signed in to change notification settings - Fork2
An object-oriented, extensible reference-counting utility for Fortran
License
sourceryinstitute/smart-pointers
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
_________ __ / _____/ _____ _____ ________/ |_ \_____ \ / \\__ \\_ __ \ __\ / \ Y Y \/ __ \| | \/| | /_______ /__|_| (____ /__| |__| \/ \/ \/ __________ .__ __ \______ \____ |__| _____/ |_ ___________ ______ | ___/ _ \| |/ \ __\/ __ \_ __ \/ ___/ | | ( <_> ) | | \ | \ ___/| | \/\___ \ |____| \____/|__|___| /__| \___ >__| /____ > \/ \/ \/ \/The Smart-Pointers library tracks references to program resources and automatesthe freeing of those resources if and only if the reference count drops to zero.Most commonly, the reference is a pointer and the resource is memory. In thatcontext, Smart-Pointers help to prevent memory leaks and dangling pointers, whichcommonly causes programs to crash due to memory limitations or segmentation faults,respectively.
To use Smart-Pointers, define a non-abstract derived type that
- Extends Smart-Pointer's
sp_smart_pointer_ttype, - Implements the inherited
freedeferred binding, and - Invokes the inherited
start_countprocedure inside object constructors.
You can then use intrinsic assignments to copy instances of asp_smart_pointer_tchild type, resulting in ashallow copy with the advantage that the targetwill be finalized only when it becomes safe to do so.
See theexample folder for a demonstration of the use of Smart-Pointers.
For more background on the design philosophy and the internal mechanics of SmartPointers, see Rouson et al. (see [1], [2], [3]). This repository's codeoriginated from refactoring the code in those publications to use more up-to-datecoding conventions. For example, this repository separates interface bodiesinto modules and procedure definitions into submodules. This repository alsouses more descriptive nomenclature for the types and procedures.
This repository also adds
- AFortran Package Manager build system,
- Tests based on theSourcery library's unit-testing utility,
- Documentation generated by
fordand deployed to the web via GitHub Actions, and - Quality control via continuous integration testing using GitHub Actions.
Correct execution of the Smart-Pointers library depends critically on comprehensivecompiler support for type finalization. The unit test suite verifies the relevantcompiler standard-conformance, including a test for each scenario in which thethe Fortran 2023 standard requires that an object be finalized. The following compilerspass all Smart-Pointers tests:
| Compiler | Test failures | Version tested |
|---|---|---|
GCCgfortran 🏆 | 0 | 13.1.0 |
LLVMflang 🏆 | 0 | 19.0.0git commit 325f5123 |
NAGnagfor 🏆 | 0 | 7.1 Build 7113 |
The following compilers passmost smart pointers tests:
| Compiler | Test failures | Version tested |
|---|---|---|
Crayftn | 4 | 17.0.0 |
IBMxlf2008_r | 1 | 17.1.0 on AIX |
Intelifort | 1 | 2021.7.0 Build 20220726_000000 |
Intelifx | 1 | 2024.0.0 Build 20231017 |
NVIDIAnvfortran | 2 | 22.7-0 |
The following compiler fails to build Smart-Pointers due to an internal compiler error (ICE):
| Compiler | Test failures | Version tested |
|---|---|---|
AMDflang | N.A. (see Note) | 13.0.0 (AOCC_3.2.0-Build#128 2021_11_12) |
See thetest suite README.md for more details on each compiler's testresults.
On Linux, macOS, or Windows Subsystem for Linux, download, build, and test withthe following shell commands:
git clone https://github.com/sourceryinstitute/smart-pointercd smart-pointerfollowed by one of the commands below corresponding to your compiler choice.
The following compilers pass all Smart-Pointers tests.
fpm testfpm test --compiler flang-newfpm test --compiler nagfor --flag -fppThe following compilers pass most Smart-Pointers tests.
Building withfpm using the CCEftn compiler wrapper requires an additionalwrapper to identify the wrapped compiler. Place a file namedcrayftn.sh at thefront of yourPATH environment variable containing the following contents:
#!/bin/bashftn "$@"Then test with the following command
fpm test --compiler crayftn.shfpm test --archiver ar --compiler xlf2008_r --flag -DXLFfpm test --compiler ifortfpm test --compiler ifx --flag "-check all,nouninit"wherefpm 0.10.0 or later is required and the--flag argument is required to circumvent what appears to be a bug inifx's Memory Sanitizer.
fpm test --compiler nvfortran --flag -MpreprocessThe following compiler cannot build the Smart-Pointers library.
fpm test --compiler flang --flag -cppSee the Smart-Pointers GitHub Pagessite for HTML documentation generated withford.See thedoc/ subdirectory for aPlantUML script that generates the Unified Modeling Language (UML)class diagram below of the three derived types in Smart-Pointers.
About
An object-oriented, extensible reference-counting utility for Fortran
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.