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

General Information

Status
Withdrawn
Publication Date
14-Dec-1994
Withdrawal Date
14-Dec-1994
Current Stage
9599 - Withdrawal of International Standard
Start Date
08-Jun-2000
Completion Date
30-Oct-2025
Ref Project

Relations

Standard
ISO/IEC 1539-2:1994 - Information technology -- Programming languages -- FORTRAN
English language
66 pages
sale 15% off
Preview
sale 15% off
Preview

Frequently Asked Questions

ISO/IEC 1539-2:1994 is a standard published by the International Organization for Standardization (ISO). Its full title is "Information technology - Programming languages - FORTRAN - Part 2: Varying length character strings". This standard covers: Information technology - Programming languages - FORTRAN - Part 2: Varying length character strings

Information technology - Programming languages - FORTRAN - Part 2: Varying length character strings

ISO/IEC 1539-2:1994 is classified under the following ICS (International Classification for Standards) categories: 35.060 - Languages used in information technology. The ICS classification helps identify the subject area and facilitates finding related standards.

ISO/IEC 1539-2:1994 has the following relationships with other standards: It is inter standard links to ISO/IEC 1539-2:2000. Understanding these relationships helps ensure you are using the most current and applicable version of the standard.

You can purchase ISO/IEC 1539-2:1994 directly from iTeh Standards. The document is available in PDF format and is delivered instantly after payment. Add the standard to your cart and complete the secure checkout process. iTeh Standards is an authorized distributor of ISO standards.

Standards Content (Sample)


INTERNATIONAL
ISO/IEC
STANDARD
1539-2
First edition
1994-12-15
Information technology - Programming
languages - Fortran -
Part 2:
Varying length Character strings
Technologies de I ‘in forma tion - Langages de program mation -
Fortran -
Partie 2: Chaînes de caractkes de longueur variable
Reference number
ISO/1 EC 1539-2: 1994(E)
ISO/IEC 1539-2 : 1994 (E)
Contents
iii
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
iv
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ,
Section 1 : General. .
l.lScope .
........................................................ 2
1.2 Normative References
Section 2 : Requirements . 3
2.1 TheNameoftheModule. .
22TheType .
...................................... 3
2.3 Extended Meanings for Intrinsic Operators
2.3.1Assignment .
2.3.2 Concatenation . 4
2.3.3 Comparisons . 4
.............................. 4
2.4 Extended Meanings for Generic Intrinsic Procedures
2.4.1 The LEN procedure . 4
CHAR procedure . 4
2.4.2 The
ICHAR procedure . 5
2.4.3 The
IACHAR procedure . 5
2.4.4 The
TRIM procedure . 5
2.4.5 The
LEN TRIM procedure . 6
2.4.6 The -
ADJUSTL procedure . 6
2.4.7 The
ADJUSTR procedure . 6
2.4.8 The
REPEAT procedure . 6
2.4.9 The
2.4.10 Comparison procedures . 7
2.4.11 The INDEX procedure . 7
2.4.12 The SCAN procedure . 7
2.4.13 The VERIFY procedure .
2.5 Additional Generic Procedure for Type Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
VAR STR procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5.1 The
-
2.6 Additional Generic Procedures for Input/Output . . 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GET procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.6.1 The
,.,. 10
2.6.2 The PUT procedure . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.3 The PUT LINE procedure 10
2.7 Additional Genkic Procedures for Substring Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . 11
INSERT procedure . . . 11
2.7.1 The
REPLACE procedure . . 11
2.7.2 The
REMOVE procedure . . 12
2.7.3 The
2.7.4 The EXTRACT procedure . . 13
SPLIT procedure . . . . . 13
2.7.5 The
Annex A : Module ISO-varyingstring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Annex B : Examples . . . . . . . . . . . . . . . . 64
0 ISO/IEC 1994
All rights reserved. Unless otherwise specified, no part of this publication may be
reproduced or utilized in any form or by any means, electronie or mechanical, including
photocopying and microfilm, without Permission in writing from the publisher.
ISO/IEC Copyright Office l Case postale 56 l CH-121 1 Geneve 20 l Switzerland
Printed in Switzerland
ii
ISO/IEC 1539-2 : 1994 (E)
0 ISO/IEC
Foreword
ISO (the International Organization for Standardization) and IEC (the Inter-
national 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.
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.
International Standard ISO/IEC 1539-2 was prepared by Joint Technical
Committee ISO/IEC JTC 1, Information technology.
ISOIIEC 1539 consists of the following Parts, under the general title Information
technology - Programming languages - Fortran:
- Part 1: Core Language Fortran
Part 2: Varying length Character strings
Annexes A and B of this part of ISO/IEC 1539 are for information only.
. . .
ISO/IEC 1539-2 : 1994 (E) 0 ISO/IEC
Introduction
This part of ISO/IEC 1539 has been prepared by ISO/IEC JTCl/SC22/WG5, the technical working
This part of ISO/IEC 1539 is an auxiliary Standard to
group for the Fortran language.
ISO/IEC 1539 : 1991, 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 the above Standard is informally known as Fortran 90.
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 includes
a possible implementation, in Fortran 90, of a module that conforms to this part of ISOREC 1539. It
should be noted, however, that this is purely for purposes of demonstrating the feasibility and
The actual code shown in this annex is not intended in any way to
portability of this Standard.
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.
---.- ~.~~
----pp-
INTERNATIONAL STANDARD 0 ISO/IEC
Iso/IEC 1539-2 : 1994 (El
Information technology
- Programming languages - Fortran -
Part 2:
Varying length Character strings
Section 1: General
1.1 Scope
This part of ISO/IEC 1539 defines facilities for use in Fortran for the manipulation of Character strings
of dynamically variable length. This part of ISODEC 1539 provides an auxiliary Standard for the
version of the Fortran language informally known as Fortran 90. The International Standard defining
this revision of the Fortran language is
ISO/IEC 1539 : 1991 “Programming Language Fortrar?’
This part of ISO/IEC 1539 is an auxiliary Standard to that defining Fortran 90 in that it defines
additional facilities to those defined intrinsically in the primary language Standard. A processor
conforming to the Fortran 90 Standard is not required to also conform to this part of ISO/IEC 1539.
However, conformance to this part of ISO/IEC 1539 assumes conformance to the primary Fortran 90
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 ISOPIEC 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 ISOPLEC 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 : 1991.
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 : 1991.
A module, written in Standard conforming Fortran, is included in Annex A. This module illustrates
one way in which the facilities described in this patt 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
0 ISOAEC
ISO/IEC 1539-2 : 1994 (E)
Standard conforming Fortran, it provides a portable implementation of the required facilities. This
module is included for information only and is not intended to constrain implernentations 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
Throughout this part of ISO/IEC 1539 all references to
strings of characters of default kind only.
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 differentes between the
intrinsic type and the varying length derived data type.
1.2 Normative references
The following Standards contain provisions which, through reference in this text, constitute provisions
of this part of ISO/IEC 1539. At the time of publication, the editions indicated we,re valid. All
Standards are subject to revision, and 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 Standards indicated
below. Members of IEC and ISO maintain registers of currently valid International Standards.
ISO/IEC 646: 199 1, Information technology -
ISO 7-bit coded Character set for information inter-
Change.
ISOIIEC 1539: 199 1, Information technology - Programming languages - Fortran.
ISO/IEC 1539-2 : 1994 (E)
0 ISO/IEC
Section 2 : Requirements
2.1 The Name of the Module
The name of the module shall be
ISOJXRYING~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 ISOJM.RYING-STRING
2.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
1,2,. ,N, where N is the length of the string. The internal structure
value of the string have positions
of the type shall be PRIVATE to the module.
2.3 Extended Meanings for Intrinsic Operators
The meanings for the intrinsic Operators of:
=
assignment
concatenation //
==
, /=, <, <=, >=, >
comparisons
shall be extended to accept any combination of scalar operands of type VARYING-STRING and type
CHARACTER. Note that the equivalent comparison Operator forms .EQ., .NE., ,LT., .LE., .GE., and
.GT. also have their meanings extended in this manner.
2.3.1 Assignment: An assignment of the form
var = expr
shall be defined for scalars with the following type combinations:
= VARYING-STRING
VARYING-STRING
VARYING-STRING = CHARACTER
CHARACTER = VARYING-STRING
Action: The characters that are the value of the expression emr become the value of the
variable var. There are two cases:
Where the variable is of type VARYING STRING, the length of the
Gase(i) -
variable becomes that of the expression.
Where the variable is of type CHARACTER, the rules of intrinsic
Case(ii)
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.
ISO/IEC 1539-2 : 1994 (E) 0 ISO/IEC
2.3.2 Concatenation: The concatenation Operation
string-a // string-b
shall be defined for scalars with the following type combinations:
VARYING-STRING // VARYING-STRING
VARYING-STRING // CHARACTER
CHARACTER // VARYING-STRING
The va . 1 ues of the operands are unchanged by the Operation.
Result Attributes: scalar of ty pe VARYING STRING.
-
Result Value: The result value is a new string whose characters are the Same as those
produced by concatenating the Operand Character strings in the Order given.
2.3.3 Comparisons: Comparisons of the form
string-a ,OP. string-b
where .OP. represents any of the Operators ==, E=, <, x=, >=, or > shall be defined for
scalar operands with the following type combinations:
VARYING-STRING .OP. VARYING-STRING,
VARYING-STRING ,OP. CHARACTER,OT
CHARACTER .OP. VARYING-STRING.
The values of the operands are unchanged by the Operation.
Note that the equivalent Operator forms .EQ., .NE., .LT., . LE., . GE., and . GT. also have
their meanings extended in this manner.
Result Attributes: scalar of type default LOGICAL.
a Stands in the indicated relation to
Result Value: The result value is true if string
-
The collating sequence used for the inequality
string-b and is false otherwise.
comparisons is that defined by the processor for characters of default kind. Ir’ string-a
and string-b are of different lengths, the comparison is done as if the shorter string were
padded on the right with blanks.
2.4 Extended Meanings for Generic Intrinsic Procedures
The generic intrinsic procedures LEN, CHAR, ICHAR, IACHAR, TRIM, LEN TRIM, ADJUSTL, ADJUSTR,
-
REPEAT, LLT, LLE, LGE, LOT, INDEX, SCAN, and VERIFY shall have their meanings extended to include
the appropriate scalar argument type combinations involving VARYING STRING and CHARACTER. The
-
results produced in each case are also scalar.
2.4.1 The LEN procedure: The generic function reference of the form
LEN(string)
shall be added.
Description: returns the length of a Character string.
Argument: string is a scalar of type VARYING-STRING. The argument is unchanged by
the procedure.
Result Attributes: scalar of type default INTEGER.
Result Value: The result value is the number of characters in string.
2.4.2 The CHAR procedure: The generic function references of the form
CHAR(string)
CW(string,length)
shall be added.
Description: converts a varying string value to default Character.

ISO/IEC 1539-2 : 1994 (E)
0 ISO/IEC
Arguments:
string - iS Oftype VARYING-STRING
length - is of type default INTEGER.
The arguments are scalars and are unchanged by the procedure.
Result Attributes: scalar of type default CHARACTER. If length is absent, the result has
the same length as string. If length is present, the result has the length specified by the
arjpnent length.
Result Value:
Gase(i) : If length is absent, the result is a copy of the characters in the
argument string.
Case( ii) If length is present, the result is a copy of the characters in the
argument string that may have been truncated or padded. If string
is longer than length, the result is truncated on the right. If string is
shorter than length, the result is padded on the right with blanks. If
length is less than one, the result is of zero length.
2.4.3 The ICHAR procedure: The generic function reference of the form
IcH24R(c)
shall be added.
Description: retums the Position of a Character in the processor defined collating
sequence.
Argument: c is a scalar of type VARYING-STRING and of length exactly one. The
argument is unchanged by the procedure.
Result Attributes: scalar of type default INTEGER.
Result Value: The result value is the Position of the Character c in the processor defined
collating sequence for default characters. That is, the result value is ICHAR (CHZUZ ( C) ) .
2.4.4 The IACHAR procedure: The generic function reference of the form
IACWiR(c)
shall be added.
Description: retums the Position of a Character in the collating sequence defined by the
International Standard ISO 646 : 1991.
Argument: c is a scalar of type VARYING STRING and of length exactly one. The
-
argument is unchanged by the procedure.
Result Attributes: scalar of type default INTEGER.
Result Value: The result value is the Position of the Character c in the collating sequence
defined by the International Standard ISO 646 : 1991 for default characters. If the
Character c is not defined in the Standard set, the result is processor dependent but is
always equal to IACHAR (CHAR (C ) ) .
2.4.5 The TRIM procedure: The generic function reference of the form
TRIM(string)
shall be added.
Description: removes trailing blanks from a string.
Argument: string is a scalar of type VARYING-STRING. The argument is unchanged by
the procedure.
Result Attributes: scalar of type VARYING STRING.
Result Value: The result value is the same as string except that any trailing blanks have
been deleted. If the argument string contains only blank characters or is of zero length,
the result is a Zero-length string.
0 ISO/IEC
ISO/IEC 1539-2 : 1994 (E)
2.4.6 The LEN-TRIM procedure: The generic function reference of the form
LEN-TRIM(string)
shall be added.
Description: retums the length of a string not counting any trailing blanks.
Argument: string is a scalar of type VARYING-STRING. The argument is unchanged by
the procedure.
Result Attributes: scalar of type default INTEGER.
Result Value: The result value is the Position of the last non-blank Character in string.
If the argument string contains only blank characters or is of zero length, the result is
Zero.
2.4.7 The ADJUSTL procedure: The generic function reference sf the form
ADJUSTL(stringj
shall be added.
Description: adjusts to the left, removing any leading blanks and inserting trailing blanks.
Argument: string is a scalar of type VARYING-STRING. The argument is unchanged by
the procedure.
Result Attributes: scalar of type VARYING STRING.
-
Result Value: The result value is the Same as string except that any leading blanks have
been deleted and the Same number of trailing blanks inserted.
2.4.8 The ADJUSTR procedure: The generic function reference of the form
ADJUSTR(string)
shall be added.
Description: adjusts to the right, removing any trailing blanks and inserting leading
blanks.
Argument: string is a scalar of type VARYING-STRING. The argument is unchanged by
the procedure.
Result Attributes: scalar of type VARYING STRING.
-
Result Value: The result value is the Same as string except that any trailing blanks have
been deleted and the Same number of leading blanks inserted.
2.4.9 The REPEAT procedure: The generic function reference of the form
REPEAT(string,ncogies)
shall be added.
Description: concatenates several copies of a string.
Arguments:
string - iS a SCdX Oftype VARYING-STRING,
ncopies - is a scalar of type default INTEGER.
The value of ncopies must not be negative. The arguments are unchanged by the
procedure.
Result Attributes: scalar of type VARYING STRING.
Result Value: The result value is the string produced by repeated concatenation of the
argument string, producing a string containing ncopies copies of string. If ncogies
is Zero, the result is of zero length.
ISO/IEC 1539-2 : 1994 (E)
0 ISO/IEC
2.4.10 Comparison procedures: The set of generic function references of the form
Lop(string-a,string-b)
shall be added, where op Stands for one of:
LT - less than
LE - less than or equal to
GE - greater than or equal to
GT - greater than
Description: compares the lexical ordering of two strings based on the ISO 646 : 1991
collating sequence.
Arguments: string-a and string-b are scalars of one of the type combinations:
VARYING-STRING and VARYING-STRING,
VARYING-STRING and CHARACTER, or
CHARACTER and VARYING-STRING.
The arguments are unchanged by the procedure.
Result Attributes: scalar of type default LOGICAL.
Result Value: The result value is true if string-a Stands in the indicated relationship to
stringb, and is false otherwise. The collating sequence used to establish the ordering
of characters for these procedures is that of the International Standard ISO 646 : 1991.
If string a and string b are of different lengths, the comparison is done as if the
- -
shorter string were padded on the right with blanks. If either argument contains a Character
c not defined by the Standard, the result value is processor dependent and based on the
collating value for IACHAR (c) . Zero length strings are considered to be lexically equal.
2.4.11 The INDEX procedure: The generic function reference of the form
INDEX(string,substring,back)
shall be added.
Description: retums an integer that is the starting Position of a substring within a string.
Arguments: string and substring are scalars of one of the type combinations:
VARYING-STRING and VARYING-STRING,
CHARACTER and VARYING-STRING, or
VARYING-STRING and CHARACTER.
back - is a scalar of type default LOGICAL and is OPTIONAL.
The arguments are unchanged by the procedure.
Result Attributes: scalar of type default INTEGER.
Result value:
Gase(i) : If back is absent or is present with the value false, the result is the
minimum positive value of I such that,
EXTRACT(string,I,I+LEN(substring)-l)==substring,
or zero if there is no such value.
Zero is retumed if LEN( string) if LEN( substring)==O.
If back is present with the value true, the result is the maximum value
Case( ii)
of I lessthan orequalto LEN(string)-LEN(substring)+l suchthat
EXTRACT(string,I,I+LEN(substring)-l)==substring,
or zero if there is no such value.
Zero is retumed ifmustring) ~~~~(substring) ,and La(string)+l
is retumed if LEN( substring)==O.
2.4.12 The SCAN procedure: The generic function reference of the form
SCA.N(string,set,back)
shall be added.
Description: scans a string for any one of the characters in a set of characters.

0 ISO/IEC
ISO/IEC 1539-2 : 1994 (E)
Arguments: string and set are scalars of one of the type combinations:
VARYING-STRING andVmYING_STRING,
VARYING-STRING and CHARACTER, or
CHARACTER and VARYING-STRING.
back - is a scalar of type default L~GICAL and is OPTIONAL.
The arguments are unchanged by the procedure.
Result Attributes: scalar of type default INTEGER.
Result Value:
back is absent or is present with the value false and if string
Gase(i) : If
contains at least one Character that is in set, the value of the result is
the Position of the left-most Character of string that is in set.
If back is present with the value true and if string contains at least
Case( ii) :
one Character that is in set, the value of the result is the Position of
the right-most Character of string that is in set.
The value of the result is zero if no Character of string is in set or
Case( iii)
if the length of either string or set is Zero.
2.4.13 The VERIFY procedure: The generic function reference of the form
VERIFY(string,set,back)
shall be added.
Description: verifies that a string contains only characters from a given set by scanning
for any Character not in the set.
Arguments: string and set are scalars of one of the type combinations:
VARYING-STRING andVmYING_STRING,
VARYING-STRING and CHARACTER, or
CHARACTER and VARYING-STRING.
is a scalar of type default LOCICAL and is OPTIONAL.
back -

The arguments are unchanged by the procedure.
Result Attributes: scalar of type default INTEGER.
Result Value:
If back is absent or is present with the value false and if string
Gase(i) :
contains at least one Character that is not in set, the value of the result
is the Position of the left-most Character of string that is not in set.
Case(ii) : If back is present with the value true and if string contains at least
one ch aracter that is not in set, the value of the result is the Position
of the right-most Character of string that is not in Set.
Case( iii) : The value of the result is zero if each Character of string is in set or
if the length of string is Zero.
2.5 Additional Generic Procedure for Type Conversion
An additional generic procedure shall be added to convert scalar intrinsic fixed-length Character values
into scalar varying-length string values.
2.5.1 The VAR STR procedure: The generic function reference of the form
-
VAR-STR(char)
shall be provided.
Description: converts an intrinsic fixed-length Character value into the equivalent
varying-length string value.
0 ISO/IEC ISOREC 1539-2 : 1994 (E)
Argument: char is a scalar of type default CHARACTER and may be of any length. ne
argument is unchanged by the procedure.
Result Attributes: scalar of type VARYING STRING.
-
Result Value: The result value is the same string of characters as the argument.
2.6 Additional Generic Procedures for Input/Output
The following additional generic procedures shall be provided to support input and output of
varying-length string values with formatted sequential files.
GET input part or all of a record into a string
PUT append a string to an output record
PUT-LINE - append a string to an output record and end the record
2.6.1 The GET procedure: The generic subroutine references of the forms
CALL GET(string,maxlen,iostat)
CALL GET(unit,string,maxlen,iostat)
CALL GET(string,set,separator,maxlen,iostat)
CALL GET(unit,string,set,separator,maxlen,iostat)
shall be provided.
Description: reads characters from an extemal file into a string.
Arguments:
string - iS Oftype VARYING-STRING,
maxlen - is of type default INTEGER and is OPTIONAL,
unit is of type default INTEGER,
set is either oftype VARYING-STRING or oftype CHARACTER,
separator - is oftype VARYING-STRING and is OPTIONAL,
iostat - is of type default INTEGER and is OPTIONAL.
All arguments are scalar. The argument uit specifies the input unit to be used. It must
be connected to a formatted file for sequential read access. If the argument -it is
omitted, the default input unit is used. The arguments maxlen, unit, and set are
unchanged by the procedure.
Action: The GET procedure Causes characters from the connected file, starting with the
next Character in the current record if there is a current record or the first Character of the
next record if not, to be read and stored in the variable string. The end of record always
terminates the input but input may be terminated before this. If maxlen is present, its
value indicates the maximum number of characters that will be read. If maxlen is less than
or equal to Zero, no characters will be read and string will be set to zero length. If
maxlen is absent, a maximum of HUGE (1) is used. If the argument set is provided, this
specifies a set of characters the occurrence of any of which will terminate the input. This
terminal Character, although read from the input file, will not be included in the result
string. The file Position after the data transfer is complete, is after the last Character that
was read. If the argument segarator is present, the actual Character found which
terminates the transfer is retumed in segarator. If the transfer is terminated other than
by the occurrence of a Character in set, a zero length string is retumed in segarator. If
the transfer is terminated by the end of record being reached, the file is positioned after
the record just read. If present, the argument iostat is used to retum the Status resulting
from the data transfer. A zero value is retumed if a valid read Operation occurs and the
end-of-record is not reached, a positive value if an error occurs, and a negative value if
an end-of-file or end-of-record condition occurs. Note, the negative value retumed for an
0 1s0/IEc
ISO/IEC 1539-2 : 1994 (E)
end-of-file condition must be different from that retumed for an end-of-record condition.
If iostat is absent and an error or end-of-file condition occurs, the program execution is
terminated.
2.6.2 The PUT procedure: The generic subroutine references of the forms
iostat)
CALL PUT(string,
,ring,iostat)
CALL PUT(unit,st
shall be provided.
Description: writes a string to an extemal file.
Arguments:
is either oftype VARYING-STRING ortype CHARACTER,
string -
is of type default INTEGER,
unit
iostat - is of type default INTEGER and is OPTIONAL.
All arguments are scalar. The argument unit specifies the output unit to be used. It must
be connected to a formatted file for sequential write access. If the argument unit is
omitted, the default output unit is used. The arguments wit and string are unchanged
by the procedure.
Action: The PUT procedure Causes the characters of string to be appended to the current
record, if there is a current record, or to the Start of the next record if there is no current
record. The last Character transferred becomes the last Character of the current record,
which is the last record of the file. If present, the argument iostat is used to retum the
Status resulting from the data transfer. A zero value is retumed if a valid write Operation
occurs, and a positive value if an error occurs. If iostat is absent and anything other than
a valid write Operation occurs, the program execution is terminated.
2.6.3 The PUT LINE procedure: The generic subroutine references of the forms
-
CALL PUT-LINE(string,iostat)
CALL PUT-LINE(unit,string,iostat)
shall be provided.
Description: writes a string to an extemal file and ends the record.
Arguments:
string - is either oftype VARYING-STRING ortype CHARACTER
unit is of type default INTEGER
iostat - is of type default INTEGER and is OPTIONAL.
All arguments are scalar. The argument unit specifies the output unit to be used. It must
be connected to a formatted file for sequential write access. If the argument unit is
omitted, the default output unit is used. The arguments unit and string are unchanged
by the procedure.
Action: The PUT LINE procedure Causes the characters of string to be appended to the
-
current record, if there is a current record, or to the Start of the next record if there is no
current record. Following completion of the data transfer, the file is positioned after the
record just written, which becomes the previous and last record of the file. If present, the
argument iostat is used to retum the Status resulting from the data transfer. A zero value
is retumed if a valid write Operation occurs, and a positive value if an error occurs. If
iostat is absent and anything other than a valid write Operation occurs, the program
execution is terminated.
ISOAEC 1539-2 : 1994 (E)
0 ISO/IEC
2.7 Additional Generic Procedures for Substring Manipulation
The following additional generic procedures shall be provided to support the manipulation of scalar
substrings of scalar varying-length strings.
INSERT - insert a substring into a string
replace a substring in a string
REPLACE -
REMOVE - remove a section of a string
EXTRACT - extract a section from a string
SPLIT - Split a string into two at the occurrence of a separator
2.7.1 The INSERT procedure: The generic function reference of the form
INSERT(string,start,substring)
shall be provided.
Description: inserts a substring into a string at a specified Position.
Arguments:
is eithertype VARYING-STRING ortype default CHARACTER,
string -
is type default INTEGER,
Start
substring - is eithertype VARYING-STRING ortype default CHARACTER.
All arguments are scalars. The arguments are unchanged by the procedure.
Result Attributes: scalar of type VARYING STRING.
-
Result Value: The result value is a copy of the characters of the argument string with
the characters of substring inserted into the copy of string before the Character at the
Character Position Start. If Start is greaterthan ~~~(string), the value ~~~(string)+l
is used for Start and substring is appended to the copy of string. If Start is less than
one, the value one is used for Start and substring is inserted before the first Character
ofthe COPY of string.
2.7.2 The REPLACE procedure: The generic function references of the forms
REPLACE(string,start,substring)
REPLACE(string,start,finish,substring)
REPLACE(string,target,substring,every,back)
shall be provided.
Description: replaces a subset of the characters in a string by a given substring. The
subset may be specified either by Position or by content.
Arguments:
string -
is either oftype VARYING-STRING ortype default CHARACTER,
Start is of type default INTEGER,
finish - is of type default INTEGER,
substring - is either oftype VARYING-STRING ortype default CHARACTER,
target - is either oftype VARYING-STRING ortype default CHARACTER,
every is of type default LOGICAL, and is OPTIONAL,
back - is of type default LOGICAL, and is OPTIONAL.
All arguments are scalar. The argument target must not be of zero length. In all cases
the arguments are unchanged by the procedure.
Result Attributes: scalar of type VARYING STRING.
-
0 ISO/IEC
ISO/IEC 1539-2 : 1994 (E)
Result Value: The result value is a copy of the characters in string modified as per one
of the cases below.
For a reference of the form
Gase(i) :
REPIACE (string,start,substring)
the characters of the argument substring are inserted into the copy of
string beginning with the Character at the Character Position Start.
The characters in positions from
starttOMIN(start+LEN(substring)-l,LEN(string))
are deleted. If Start is greater than ~~~(string), the value
~~~(string)+l is used for Start and substring is appended to the
copy of string. If Start is less than one, the value one is used for
Start.
Case( ii) : For a reference of the form
REPLACE(string,start,finish,substring)
the characters in the copy of string between positions Start and
finish, including those at Start and finish, are deleted and replaced
by the characters of substring. If Start is less than one, the value
one is used for Start. If finish is greater than LEN(string), the
value LEN( string) is used for finish. If finishis less than Start,
the characters of substring are inserted before the Character at Start
and no characters are deleted.
For a reference of the form
Case( iii) :
REPLACE (string,target,substring,every,back)
the copy of string is searched for occurrences of target. The search
is done in the backward direction if the argument back is present with
the value true, and in the forward direction otherwise. If target is
found, it is replaced by substring. If every is present with the value
true, the search and replace is continued from the Character following
target in the search direction specified until all occurrences of target
in the copy string are replaced; otherwise only the first occurrence of
target is replaced.
2.7.3 The REMOVE procedure: The generic function reference of the form
REMOvE(string,start,finish)
shall be provided.
Description: removes a specified substring from a string.
Arguments:
is either oftype VARYING-STRING ortype default CHARACTER,
string -
is of type default INTEGER, and is OPTIONAL,
Start
is of type default INTEGER, and is OPTIONAL.
finish -
All arguments are scalars. The arguments are unchanged by the procedure.
Result Attributes: scalar of type VARYING STRING.
-
Result Value: The result value is a copy of the characters of string with the characters
between positions Start and finish, inclusive, removed. If Start is absent or less than
one, the value one is used for Start. If finish is absent or greater than LEN( string) , the
value LEN(string) is used for finish. If finish is less than Start, the characters of
string are delivered unchanged as the result.
0 ISO/IEC ISO/IEC 1539-2 : 1994 (E)
2.7.4 The EXTRACT procedure: The generic function reference of the form
EXTRACT(string,start,finish)
shall be provided.
Description: extracts a specified substring from a string.
Arguments:
string - is either oftype VARYING-STRING ortype default CHARACTER,
Start is of type default INTEGER, and is OPTIONAL,
finish - is of type default INTEGER, and is OPTIONAL.
All arguments are scalars. The arguments are unchanged by the procedure.
Result Attributes: scalar of type VARYING STRING.
-
Result Value: The result value is a copy of the characters of the argument string
between positions Start and finish, inclusive. If Start is absent or less than one, the
value one is used for Start. If finish is absent or greater than ~~~(string) , the value
LEN(string) is used for finish. If finish is less than Start, the result is a Zero-length
string.
2.7.5 The SPLIT procedure: The generic subroutine reference of the form
CALL SPLIT(string,word,set,separator,back)
shall be provided.
Description: Splits a string into a two substrings with the substrings separated by the
occurrence of a Character from a specified separator set.
Arguments:
string - iS Of type VARYING-STRING,
word iS Of type VARYING-STRING,
set is either oftype VARYING-STRING ortype default CHARACTER,
separator - is of typewm~~~~-STRING, and is OPTIONAL,
is of type default LOGICAL, and is OPTIONAL,
back -
All arguments are scalar. The arguments set and back are unchanged by the procedure.
Action: The effect of the procedure is to divide the string at the first occurrence of a
Character that is in set. The string is searched in the forward direction unless back is
present with the value true, in which case the search is in the backward direction. The
characters passed over in the search are retumed in the argument werd and the remainder
of the string, not including the separator Character, is retumed in the argument string. If
no Character from set is found or set is of zero length, the whole string is retumed in
word and string is retumed as zero length. If the argument separater is present, the
actual Character found which separates the werd from the remainder of the string is
retumed in separator. The effect of the procedure is such that, on retum, either
word//separator//string
is the Same as the initial string for a forward search, or
string//separator//word
is the Same as the initial string for a backward search.
0 ISO/IEC
ISO/IEC 1539-2 : 1994 (E)
Annex A
(informative)
Module ISO-varyingstring
The following module is written in Fortran 90, conformant with the language as specified in the
Standard ISO/IEC 1539 : 1991. It is intended to be a portable implementation of a module conformant
with this part of ISO/IEC 1539. It is not intended to be prescriptive of how facilities consistent with
this part of ISO/IEC 1539 should be provided. This module is intended primarily to demonstrate that
portable facilities consistent with the interfaces and semantics required by this part of ISO/IEC 1539
could be provided within the confines of the Fortran language. It is also included as a guide for users
of processors which do not have supplier-provided facilities implementing this part of ISO/IEC 1539.
It should be noted that while every care has been taken by the technical working group to ensure that
this module is a correct implementation of this part of ISO/IEC 1539 in valid Fortran Code, no
guarantee is given or implied that this code will produce correct results, or even that it will execute
on any particular processor. Neither is there any implication that this illustrative module is in any way
an optimal implementation of this Standard; it is merely one fairly straightforward portable module that
is known. to provide a functionally conformant implementation on a few processors.
MODULE XSOJXRYING-STRING
! Written by J.L.Schonfelder
I Incorporating Suggestion8 by C.Tanasescu, C.Weber, J.Wagener and W.Walter,
! and corrections due to L.Moss, M.Cohen, P.Griffiths, B.T.Smith
! and many other members of the committee ISO/IEC JTCl/SC22/WG5
! Version produced (5-Jul-94)
-1-11-111111111-111--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 1
! This module defines the interface and one possible implementation for a 1
! dynamic length Character string facility in Fortran 90. The Fortran 90 1
! language is defined by the Standard ISO/IEC 1539 : 1991. !
! The publicly accessible interface defined by this module is conformant
!
! with the auxiliary Standard, ISO/IEC 1539-2 : 1994.
! The detailed implementation may be considered as an informal definition of !
! the required semantics, and may also be used as a guide to the production !
! of a portable imphmentatiOn. 1
! N.B, Although every care has been taken to produce valid Fortran code in 1
1 construction of this module no guarantee is given or implied that this !
1 Code will work correctly without error on any specific processor, nor !
1 is this implementation intended to be in any way optimal either in use !
1 of storage or CPU cycles. 1
---11111-111111-11---~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 !
PRIVATE
-111-111111111-11----~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 !
! By default all entities declared or defined in this module are private to
!
! the module. Only those entities declared explicitly as being public are !
! accessible to programs using the module. In particular, the procedures and !
! Operators defined herein are xnade accessible via their generic identifiers !
! only; their specific names are private.
!
-1111111-111-111-11--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 1
TYPE VARYING-STRING
PRIVATE
CHARACT
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.

Loading comments...