C Library Functions - generate_uuid (3)
NAME
generate_uuid(3f) - [M_uuid] generate a UUID (Universally Unique IDentifier) string per RFC 4122
(LICENSE:BSD-4-Clause)
CONTENTS
Synopsis
Description
Authors
Options
Examples
SYNOPSIS
interface:
function generate_uuid(version) result(uuid)
integer, intent(in), optional :: version
character(len=36) :: uuid
DESCRIPTION
A universally unique identifier (UUID) is a 128-bit number used to
identify information in computer systems. When generated according
to standard methods UUIDs are for practical purposes unique.
generate_uuid(3f) converts the UUID to a standard string format
per RFC 4122.
AUTHORS
based on previous work from Alberto Garcia & Jon Wakelin, 2003-2004.
RNG routines from Scott Ladd <scott.ladd@coyotegulch.com>, and
the libFoX library( Toby White <tow@uszla.me.uk>, Gen-Tao Chiang
<gtc25@cam.ac.uk>, Andrew Walker <a.walker@ucl.ac.uk>).
OPTIONS
|
version |
| |
Indicates which standard method as described in RFC 4122
is used to generate the string. Versions 0,1, and 4 are supported.
|
|
0.
|
Nil UUID (ie. 00000000-0000-0000-0000-000000000000)
|
|
1.
|
time-based UUID
|
|
2.
|
Not implemented
|
|
3.
|
Not implemented
|
|
4.
|
pseudo-RNG(Random Number Generator) based
|
|
5.
|
Not implemented
|
|
|
|
EXAMPLES
Sample usage:
program demo_generate_uuid
! generate 36-character UUID string
use M_uuid, only : generate_uuid
implicit none
character(len=36) :: uuid
character(len=4096) :: filename
!
! version 1 (time-based UUID)
uuid=generate_uuid(version=1)
write(*,(a36))uuid
!
! version 4 (pseudo-RNG-based), default
uuid=generate_uuid(version=4)
write(*,(a36))uuid
!
! RFC 4122 defines a Uniform Resource Name (URN) namespace for UUIDs.
write(*,("urn:uuid:",a36))uuid
!
! a good scratch file name
open(file=/tmp/scratch_//uuid,unit=10)
inquire(unit=10,name=filename)
write(*,(*(g0))) trim(filename)
close(unit=10,status=delete)
end program demo_generate_uuid
Results:
> afa6bfb4-65a3-11ef-7251-52dbfec73ce6
> 717b923d-c12f-4d99-6446-21b4fbed1337
> urn:uuid:717b923d-c12f-4d99-6446-21b4fbed1337
> /tmp/scratch_717b923d-c12f-4d99-6446-21b4fbed1337
| Nemo Release 3.1 | generate_uuid (3) | June 29, 2025 |
Generated by manServer 1.08 from b61329da-fc30-4546-ad48-2a538d07c946 using man macros.