194. Use PACK to select records from an array of derived types.#
topic: Derived types
Note
This tip is a draft1.
With an array of derived types, you can use PACK with a MASK on type components to select records, for example
type :: t integer year, month, day real x end type t
type(t) :: d(1000) print*,pack(d, d%month==3) ! data for March @carbon_app
With an array of derived types, you can use PACK with a MASK on type components to select records, for example
— FortranTip (@fortrantip) April 18, 2022
type :: t
integer year, month, day
real x
end type t
type(t) :: d(1000)
print*,pack(d, d%month==3) ! data for March@carbon_app pic.twitter.com/S1QHRU5ft6
- 1
From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.