ISO/IEC 1539-2:2000
(Main)Information technology — Programming languages — Fortran — Part 2: Varying length character strings
Information technology — Programming languages — Fortran — Part 2: Varying length character strings
This part of ISO/IEC 1539 defines facilities in Fortran for the manipulation of character strings of dynamically variable length. This part of ISO/IEC 1539 provides an auxiliary standard for the version of the Fortran language specified by ISO/IEC 1539-1: 1997 and informally known as Fortran 95. A program that conforms with 1539-2: 1994 also conforms with this standard. This part of ISO/IEC 1539 is an auxiliary standard to that defining Fortran 95 in that it defines additional facilities to those defined intrinsically in the primary language standard. A processor conforming to the Fortran 95 standard is not required also to conform to this part of ISO/IEC 1539. However, conformance to this part of ISO/IEC 1539 assumes conformance to the primary Fortran 95 standard. This part of ISO/IEC 1539 prescribes the name of a Fortran module, the name of a derived data type to be used to represent varying-length strings, the interfaces for the procedures and operators to be provided to manipulate objects of this type, and the semantics that are required for each of the entities made accessible by this module. This part of ISO/IEC 1539 does not prescribe the details of any implementation. Neither the method used to represent the data entities of the defined type nor the algorithms used to implement the procedures or operators whose interfaces are defined by this part of ISO/IEC 1539 are prescribed. A conformant implementation may use any representation and any algorithms, subject only to the requirement that the publicly accessible names and interfaces conform to this part of ISO/IEC 1539, and that the semantics are as required by this part of ISO/IEC 1539 and those of ISO/IEC 1539-1 : 1997. It should be noted that a processor is not required to implement this part of ISO/IEC 1539 in order to be a standard conforming Fortran processor, but if a processor implements facilities for manipulating varying length character strings, it is recommended that this be done in a manner that is conformant with this part of ISO/IEC 1539. A processor conforming to this part of ISO/IEC 1539 may extend the facilities provided for the manipulation of varying length character strings as long as such extensions do not conflict with this part of ISO/IEC 1539 or with ISO/IEC 1539-1 : 1997. A module, written in standard conforming Fortran, is referenced in Annex A. This module illustrates one way in which the facilities described in this part of ISO/IEC 1539 could be provided. This module is both conformant with the requirements of this part of ISO/IEC 1539 and, because it is written in standard conforming Fortran, it provides a portable implementation of the required facilities. This module is referenced for information only and is not intended to constrain implementations in any way. This module is a demonstration that at least one implementation, in standard conforming and hence portable Fortran, is possible. It should be noted that this part of ISO/IEC 1539 defines facilities for dynamically varying length strings of characters of default kind only. Throughout this part of ISO/IEC 1539 all references to intrinsic type CHARACTER should be read as meaning characters of default kind. Similar facilities could be defined for non-default kind characters by a separate, if similar, module for each such character kind. This part of ISO/IEC 1539 has been designed, as far as is reasonable, to provide for varying length character strings the facilities that are available for intrinsic fixed length character strings. All the intrinsic operations and functions that apply to fixed length character strings have extended meanings defined by this part of ISO/IEC 1539 for varying length character strings. Also a small number of additional facilities are defined that are appropriate because of the essential differences between the intrinsic type and the varying length derived data type.
Technologies de l'information — Langages de programmation — Fortran — Partie 2: Chaînes de caractères de longueur variable
General Information
Relations
Standards Content (Sample)
INTERNATIONAL ISO/IEC
STANDARD 1539-2
Second edition
2000-06-01
Information technology — Programming
languages — Fortran —
Part 2:
Varying length character strings
Technologies de l'information — Langages de programmation — Fortran —
Partie 2: Chaînes de caractères de longueur variable
Reference number
©
ISO/IEC 2000
PDF disclaimer
This PDF file may contain embedded typefaces. In accordance with Adobe's licensing policy, this file may be printed or viewed but shall not
be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In downloading this
file, parties accept therein the responsibility of not infringing Adobe's licensing policy. The ISO Central Secretariat accepts no liability in this
area.
Adobe is a trademark of Adobe Systems Incorporated.
Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation parameters
were optimized for printing. Every care has been taken to ensure that the file is suitable for use by ISO member bodies. In the unlikely event
that a problem relating to it is found, please inform the Central Secretariat at the address given below.
© ISO/IEC 2000
All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means, electronic
or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or ISO's member body
in the country of the requester.
ISO copyright office
Case postale 56 � CH-1211 Geneva 20
Tel. + 41 22 749 01 11
Fax + 41 22 734 10 79
E-mail copyright@iso.ch
Web www.iso.ch
Printed in Switzerland
ii © ISO/IEC 2000 – All rights reserved
CONTENTS
1 Scope …………………………………………………………………………………………… 1
2 Normative References …………………………………………………………………………… 2
3 Requirements …………………………………………………………………………………… 3
3.1 The Name of the Module ……………………………………………………………… 3
3.2 The Type ………………………………………………………………………………… 3
3.3 Extended Meanings for Intrinsic Operators …………………………………………… 3
3.3.1 Assignment …………………………………………………………………… 3
3.3.2 Concatenation ………………………………………………………………… 4
3.3.3 Comparisons …………………………………………………………………… 4
3.4 Extended Meanings for Generic Intrinsic Procedures ………………………………… 5
3.4.1 ADJUSTL (string) …………………………………………………………… 5
3.4.2 ADJUSTR (string) …………………………………………………………… 5
3.4.3 CHAR (string [, length]) ……………………………………………………… 5
3.4.4 IACHAR (c) …………………………………………………………………… 6
3.4.5 ICHAR (c) …………………………………………………………………… 6
3.4.6 INDEX (string, substring [, back]) …………………………………………… 6
3.4.7 LEN (string) …………………………………………………………………… 7
3.4.8 LEN_TRIM (string) …………………………………………………………… 7
3.4.9 LGE (string_a, string_b) ……………………………………………………… 7
3.4.10 LGT (string_a, string_b) ……………………………………………………… 7
3.4.11 LLE (string_a, string_b) ……………………………………………………… 8
3.4.12 LLT (string_a, string_b) ……………………………………………………… 8
3.4.13 REPEAT (string, ncopies) …………………………………………………… 9
3.4.14 SCAN (string, set [, back]) …………………………………………………… 9
3.4.15 TRIM (string) ………………………………………………………………… 9
3.4.16 VERIFY (string, set [, back]) ……………………………………………… 10
3.5 Additional Generic Procedure for Type Conversion ………………………………… 10
3.5.1 VAR_STR (char) …………………………………………………………… 10
3.6 Additional Generic Procedures for Input/Output …………………………………… 11
3.6.1 GET (string [, maxlen, iostat]) or
GET (unit, string [, maxlen, iostat]) or
GET (string, set [, separator, maxlen, iostat]) or
GET (unit, string, set [, separator, maxlen, iostat]) ………………………… 11
3.6.2 PUT (string [, iostat]) or PUT (unit, string [, iostat]) ……………………… 12
3.6.3 PUT_LINE (string [, iostat]) or PUT_LINE (unit, string [, iostat]) ………… 12
3.7 Additional Generic Procedures for Substring Manipulation ………………………… 12
3.7.1 EXTRACT (string [, start, finish]) …………………………………………… 13
3.7.2 INSERT (string, start, substring) …………………………………………… 13
3.7.3 REMOVE (string [, start, finish]) …………………………………………… 13
3.7.4 REPLACE (string, start, substring) or
REPLACE (string, start, finish, substring) or
REPLACE (string, target, substring [,every, back]) ………………………… 14
ISO/IEC 2000 – All rights reserved iii
3.7.5 SPLIT (string, word, set [, separator, back]) ………………………………… 15
Annex A (informative). Module ISO_VARYING_STRING……………………………………… 16
Annex B (informative). Two examples …………………………………………………………… 17
B.1 Word count ……………………………………………………………………………… 17
B.2 Vocabulary list …………………………………………………………………………… 18
iv ISO/IEC 2000 – All rights reserved
Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission)
form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC
participate in the development of International Standards through technical committees established by the
respective organization to deal with particular fields of technical activity. ISO and IEC technical committees
collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in
liaison with ISO and IEC, also take part in the work.
International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 3.
In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1.
Draft International Standards adopted by the joint technical committee are circulated to national bodies for voting.
Publication as an International Standard requires approval by at least 75 % of the national bodies casting a vote.
Attention is drawn to the possibility that some of the elements of this part of ISO/IEC 1539 may be the subject of
patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights.
International Standard ISO/IEC 1539-2 was prepared by Joint Technical Committee ISO/IEC JTC 1, Information
technology, Subcommittee SC 22, Programming languages, their environments and system software interfaces.
This second edition cancels and replaces the first edition (ISO/IEC 1539-2:1994), which has been technically
revised. The following summarises the changes made to the facilities provided by this part of ISO/IEC 1539:
The assignment, concatenation, and comparison operations are extended to describe elemental semantics.
CHAR is extended to describe pure semantics.
ADJUSTL, ADJUSTR, EXTRACT, IACHAR, ICHAR, INDEX, INSERT, LEN, LEN_TRIM, LGE, LGT, LLE, LLT,
REMOVE, REPEAT, REPLACE, SCAN, SPLIT, TRIM, VAR_STR, and VERIFY are all extended to describe
elemental semantics.
ISO/IEC 1539 consists of the following parts, under the general title Information technology — Programming
languages — Fortran:
� Part 1: Base language
� Part 2: Varying length character strings
Annexes A and B of this part of ISO/IEC 1539 are for information only.
© ISO/IEC 2000 – All rights reserved v
Introduction
This part of ISO/IEC 1539 has been prepared by ISO/IEC JTC1/SC22/WG5, the technical working group for
the Fortran language. This part of ISO/IEC 1539 is an auxiliary standard to ISO/IEC 1539-1 : 1997, which
defines the latest revision of the Fortran language, and is the first part of the multipart Fortran family of
standards; this part of ISO/IEC 1539 is the second part. The revised language defined by ISO/IEC 1539-1 :
1997 is informally known as Fortran 95.
This part of ISO/IEC 1539 defines the interface and semantics for a module that provides facilities for the
manipulation of character strings of arbitrary and dynamically variable length. Annex A refers to a possible
implementation, in Fortran 95, of a module that conforms to this part of ISO/IEC 1539. It should be noted,
however, that this is purely for purposes of demonstrating the feasibility and portability of this standard. The
actual code is not intended in any way to prescribe the method of implementation, nor is there any implication
that this is in any way an optimal portable implementation. The module is merely a fairly straightforward
demonstration that a portable implementation is possible.
This standard is a development from a previous version known as ISO/IEC 1539-2: 1994 that takes account of
the improvements introduced in Fortran 95. The most significant improvements in Fortran 95 for the present
standard were the introduction of pure and elemental procedures. Since pure and elemental functions can be
used in specification expressions, their introduction in this standard enhances the usability of the standard for
the end user. The ability to define many of the functions specified in this standard to be elemental improves the
compatibility of these functions with similar intrinsic functions defined by the main standard.
The improvements in type initialization provided in Fortran 95 have also enabled the sample implementation
referred to in Annex A to be written in such a way that significant leakage of memory is less likely to occur.
vi ISO/IEC 2000 – All rights reserved
length character strings, it is recommended that this be done in a manner that is conformant with this part of
ISO/IEC 1539.
A processor conforming to this part of ISO/IEC 1539 may extend the facilities provided for the manipulation
of varying length character strings as long as such extensions do not conflict with this part of ISO/IEC 1539 or
with ISO/IEC 1539-1 : 1997.
A module, written in standard conforming Fortran, is referenced in Annex A. This module illustrates one way
in which the facilities described in this part of ISO/IEC 1539 could be provided. This module is both
conformant with the requirements of this part of ISO/IEC 1539 and, because it is written in standard
conforming Fortran, it providesa portable implementation of the required facilities. This module is referenced
for information only and is not intended to constrain implementations in any way. This module is a
demonstration that at least one implementation, in standard conforming and hence portable Fortran, is
possible.
It should be noted that this part of ISO/IEC 1539 defines facilities for dynamically varying length strings of
characters of default kind only. Throughout this part of ISO/IEC 1539 all references to intrinsic type
CHARACTER should be read as meaning characters of default kind. Similar facilities could be defined for
non-default kind characters by a separate, if similar, module for each such character kind.
This part of ISO/IEC 1539 has been designed, as far as is reasonable, to provide for varying length character
strings the facilities that are available for intrinsic fixed length character strings. All the intrinsic operations
and functions that apply to fixed length character strings have extended meanings defined by this part of
ISO/IEC 1539 for varying length character strings. Alsoa small number of additional facilities are defined that
are appropriate because of the essential differences between the intrinsic type and the varying length derived
data type.
2 Normative References
The following normative documents contain provisions which, through reference in this text, constitute
provisions of this part of ISO/IEC 1539. For dated references, subsequent amendments to, or revisions of, any
of these publications do not apply. However, parties to agreements based on this part of ISO/IEC 1539 are
encouraged to investigate the possibility of applying the most recent editions of the normative documents
indicated below. For undated references, the latest edition of the normative document referred to applies.
Members of ISO and IEC maintain registers of currently valid International Standards.
ISO/IEC 646 : 1991 Information technology – ISO 7-bit Coded character set for information interchange.
ISO/IEC 1539-1 : 1997 Information technology – Programming languages – Fortran – Part 1: Base
language.
2 ISO/IEC 2000 – All rights reserved
3 Requirements
3.1 The Name of the Module
The name of the module shall be
ISO_VARYING_STRING
Programs shall be able to access the facilities defined by this part of ISO/IEC 1539 by the inclusion of USE
statements of the form
USE ISO_VARYING_STRING
3.2 The Type
The type shall have the name
VARYING_STRING
Entities of this type shall represent values that are strings of characters of default kind. These character strings
may be of any non-negative length and this length may vary dynamically during the execution of a program.
There shall be no arbitrary upper length limit other than that imposed by the size of the processor and the
complexity of the programs it is able to process. The characters representing the value of the string have
positions 1,2,.,N, where N is the length of the string. The internal structure of the type shall bePRIVATE to
the module.
3.3 Extended Meanings for Intrinsic Operators
The meanings for the intrinsic operators of:
assignment =
concatenation //
comparisons ==, /=, <, <=, >=, >
shall be extended to accept any combination of operands of typeVARYING_STRING and typeCHARACTER.
Note that the equivalent comparison operator forms.EQ.,.NE.,.LT.,.LE.,.GE., and.GT. also have
their meanings extended in this manner.
3.3.1 Assignment
An elemental assignment of the form
var = expr
shall be defined with the following type combinations:
VARYING_STRING andVARYING_STRING
VARYING_STRING andCHARACTER
CHARACTER andVARYING_STRING
Action. The characters that are the value of the expressionexpr become the value of the variablevar. There
are two cases:
Case(i): Where the variable is of typeVARYING_STRING, the length of the variable becomes that of the
ISO/IEC 2000 – All rights reserved 3
expression.
Case(ii): Where the variable is of type CHARACTER, the rules of intrinsic assignment to a Fortran
character variable apply. Namely, if the expression string is longer than the declared length of the
character variable, only the left-most characters are assigned. If the character variable is longer
than that of the string expression, it is padded on the right with blanks.
3.3.2 Concatenation
The elemental concatenation operation
string_a//string_b
shall be defined with the following type combinations:
VARYING_STRING andVARYING_STRING
VARYING_STRING andCHARACTER
CHARACTER andVARYING_STRING
The values of the operands are unchanged by the operation.
Result Characteristics. Of typeVARYING_STRING.
Result Value. The result value is a new string whose characters are the same
...
Questions, Comments and Discussion
Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.