Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An object-oriented, extensible reference-counting utility for Fortran

License

NotificationsYou must be signed in to change notification settings

sourceryinstitute/smart-pointers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  _________                      __                  /   _____/ _____ _____ ________/  |_                \_____  \ /     \\__  \\_  __ \   __\               /        \  Y Y  \/ __ \|  | \/|  |                /_______  /__|_|  (____  /__|   |__|                        \/      \/     \/                           __________      .__        __                       \______   \____ |__| _____/  |_  ___________  ______ |     ___/  _ \|  |/    \   __\/ __ \_  __ \/  ___/ |    |  (  <_> )  |   |  \  | \  ___/|  | \/\___ \  |____|   \____/|__|___|  /__|  \___  >__|  /____  >                        \/          \/           \/                              \/

Overview

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

  1. Extends Smart-Pointer'ssp_smart_pointer_t type,
  2. Implements the inheritedfree deferred binding, and
  3. Invokes the inheritedstart_count procedure 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.

Example

See theexample folder for a demonstration of the use of Smart-Pointers.

Background

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

  1. AFortran Package Manager build system,
  2. Tests based on theSourcery library's unit-testing utility,
  3. Documentation generated byford and deployed to the web via GitHub Actions, and
  4. Quality control via continuous integration testing using GitHub Actions.

Supported Compilers

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:

CompilerTest failuresVersion tested
GCCgfortran 🏆013.1.0
LLVMflang 🏆019.0.0git commit 325f5123
NAGnagfor 🏆07.1 Build 7113

Partially Supported Compilers

The following compilers passmost smart pointers tests:

CompilerTest failuresVersion tested
Crayftn417.0.0
IBMxlf2008_r117.1.0 on AIX
Intelifort12021.7.0 Build 20220726_000000
Intelifx12024.0.0 Build 20231017
NVIDIAnvfortran222.7-0

Unsupported Compiler

The following compiler fails to build Smart-Pointers due to an internal compiler error (ICE):

CompilerTest failuresVersion tested
AMDflangN.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.

Downloading, Building, and Testing

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-pointer

followed by one of the commands below corresponding to your compiler choice.

Fully supported compilers

The following compilers pass all Smart-Pointers tests.

GCCgfortran

fpm test

LLVMflang

fpm test --compiler flang-new

NAGnagfor

fpm test --compiler nagfor --flag -fpp

Partially supported compilers

The following compilers pass most Smart-Pointers tests.

HPE: Cray Compiler Environment (CCE)

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.sh

IBM

fpm test --archiver ar --compiler xlf2008_r --flag -DXLF

Intelifort

fpm test --compiler ifort

Intelifx

fpm 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.

NVIDIAnvfortran

fpm test --compiler nvfortran --flag -Mpreprocess

Unsupported compiler

The following compiler cannot build the Smart-Pointers library.

AMDflang

fpm test --compiler flang --flag -cpp

Documentation

See 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

Stars

Watchers

Forks

Packages

No packages published

Contributors5

Languages


[8]ページ先頭

©2009-2025 Movatter.jp