[UP]


Manual Reference Pages  - use (7)

NAME

use(7f) - [FORTRAN] gives a program unit accessibility to public entities in a module.

CONTENTS

Synopsis
Description
Examples
See Also

SYNOPSIS

USE [, mode-nature ::] namespace [, rename-list]
USE [, mode-nature ::] namespace [,ONLY: only-list]

DESCRIPTION

The USE statement makes the specified namespace accessible to the current scoping unit. It also provides a means of renaming or limiting the accessibility of entities in the namespace.

WHERE:
mode-nature
  Is INTRINSIC or NON_INTRINSIC. If INTRINSIC is used, namespace must be the name of an intrinsic module. If NON_INTRINSIC is used, namespace must be the name of an nonintrinsic module. If mod-nature is not specified, namespace must be the name of an intrinsic or nonintrinsic module. If both are provided, the nonintrinsic module is used. It is an error to specify a user module and an intrinsic module of the same name in the same program unit.
namespace
  is a publicly accessible namespace; ie. it is the name of a module.
rename-list
  is a comma-separated list of local-name => use-name
only-list
  is a comma-separated list of access-id or [local-name => use-name]

                 local-name      is the local name for the entity specified by use-name
                                 Is the name of the entity in the program unit using the module or is
                                 "OPERATOR (op-name)", where op-name is the name of a defined operator
                                 in the program unit using the module.
                 use-name        is the name of a public entity in the specified namespace
                 access-id       is use-name or generic-spec
                 generic-spec    is generic-name
                                 or OPERATOR (defined-operator)
                                 or ASSIGNMENT (=)

generic-name is the name of a generic procedure

defined-operator is one of the intrinsic operators

or .op-name.

.op-name. is a user-defined name for the operation

    REMARKS

rename-list and ONLY: only-list may only appear if the namespace being used was implemented with Fortran for .NET

A USE statement without ONLY provides access to all PUBLIC entities in the specified namespace.

A USE statement with ONLY provides access only to those entities that appear in the only-list.

If more than one USE statement appears in a scoping unit, the rename-lists and only-lists are treated as one concatenated rename-list.

If two or more generic interfaces that are accessible in the same scoping unit have the same name, same operator, or are assignments, they are interpreted as a single generic interface.

Two or more accessible entities, other than generic interfaces, can have the same name only if no entity is referenced by this name in the scoping unit.

If local-name is absent, the use-name is available by use association.

An entity can be accessed by more than one local-name.

A local-name must not be declared with different attributes in the scoping unit that contains the USE statement, except that it can appear in a PUBLIC or PRIVATE statement in the scoping unit of a module.

Forward references to modules are not allowed. That is, if a module is used in the same source file in which it resides, the module program unit must appear before its use.

EXAMPLES

Samples:

   module example ! example is the namespace name
      type type1 ! type1 is the class prototype name
      contains
         procedure, nopass :: static_method1
      end type type1
      type type2 ! type1 is the class prototype name
      contains
         procedure, nopass :: static_method2
      end type type2
   contains
      subroutine static_method1(arg)
         integer :: arg
         ! code to implement method goes here
      end subroutine static_method1
      subroutine static_method2(arg)
         integer :: arg
         ! code to implement method goes here
      end subroutine static_method2
   end module example

use example ! all public objects in namespace example available

use example, only: type1 ! class prototype type1 available, ! class prototype type2 not available

! within this scoping unit, type1 is referred to as "mytype" use example, mytype => type1

SEE ALSO


use (7) March 19, 2019
Generated by manServer 1.08 from 4fed53c8-2513-4f58-8a98-e4cfa3af6685 using man macros.