From bleikamp@rsn.hp.com  Fri Jan 17 17:51:08 1997
Received: from hplb.hpl.hp.com (hplb.hpl.hp.com [15.255.59.2]) by dkuug.dk (8.6.12/8.6.12) with ESMTP id RAA13149 for <sc22wg5@dkuug.dk>; Fri, 17 Jan 1997 17:50:52 +0100
Received: from kiwi.rsn.hp.com by hplb.hpl.hp.com; Fri, 17 Jan 1997 16:50:45 GMT
Received: from kiwi (localhost) by kiwi.rsn.hp.com with SMTP
	(1.39.111.2/16.2) id AA247749838; Fri, 17 Jan 1997 10:50:38 -0600
Sender: bleikamp@rsn.hp.com
Message-Id: <32DFADDD.10DD@rsn.hp.com>
Date: Fri, 17 Jan 1997 10:50:37 -0600
From: Richard Bleikamp <bleikamp@rsn.hp.com>
Organization: Hewlett Packard Company
X-Mailer: Mozilla 3.01 (X11; I; HP-UX B.10.01 9000/712)
Mime-Version: 1.0
To: "sc22wg5@dkuug.dk" <sc22wg5@dkuug.dk>
Subject: postscript version of derived type i/o spec.
Content-Type: multipart/mixed; boundary="------------718C5BC2341E"

This is a multi-part message in MIME format.

--------------718C5BC2341E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Miles and Mallory, please add this postscript version to the ftp
servers also.  thanks.

--------------718C5BC2341E
Content-Type: application/postscript; name="97-101.ps"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="97-101.ps"

%!PS-Adobe-3.0
%%BoundingBox: 24 24 588 768
%%Title: enscript output
%%For: Richard Bleikamp,d1w36-r,,
%%Creator: GNU enscript 1.4.0
%%CreationDate: Fri Jan 17 10:46:17 1997
%%Orientation: Portrait
%%Pages: (atend)
%%DocumentMedia: Letter 612 792 0 () ()
%%DocumentNeededResources: (atend)
%%EndComments
%%BeginProlog
%%BeginResource: procset Enscript-Prolog 1.4 0
%
% Procedures.
%

/_S {	% save current state
  /_s save def
} def
/_R {	% restore from saved state
  _s restore
} def

/S {	% showpage protecting gstate
  gsave
  showpage
  grestore
} bind def

/MF {	% fontname newfontname -> -	make a new encoded font
  /newfontname exch def
  /fontname exch def

  /fontdict fontname findfont def
  /newfont fontdict maxlength dict def

  fontdict {
    exch 
    dup /FID eq {
      % skip FID pair
      pop pop
    } {
      % copy to the new font dictionary
      exch newfont 3 1 roll put
    } ifelse
  } forall
  
  newfont /FontName newfontname put

  % insert only valid encoding vectors
  encoding_vector length 256 eq {
    newfont /Encoding encoding_vector put
  } if
  
  newfontname newfont definefont pop
} def

/M {moveto} bind def
/s {show} bind def

/Box {	% x y w h -> -			define box path
  /d_h exch def /d_w exch def /d_y exch def /d_x exch def
  d_x d_y  moveto 
  d_w 0 rlineto 
  0 d_h rlineto 
  d_w neg 0 rlineto 
  closepath
} def

% Highlight bars.
/highlight_bars {	% nlines lineheight output_y_margin gray -> -
  gsave
    setgray
    /ymarg exch def
    /lineheight exch def
    /nlines exch def

    % This 2 is just a magic number to sync highlight lines to text.
    0 d_header_y ymarg sub 2 sub translate
    
    /cw d_output_w cols div def
    /nrows d_output_h ymarg 2 mul sub lineheight div floor def

    % for each column
    0 1 cols 1 sub {
      cw mul /xp exch def

      % for each rows
      0 1 nrows 1 sub {
        /rn exch def 
        rn lineheight mul neg /yp exch def
        rn nlines idiv 2 mod 0 eq {
	  % Draw highlight bar.  4 is just a magic indentation.
	  xp 4 add yp cw 8 sub lineheight neg Box fill	  
	} if
      } for
    } for
    
  grestore
} def

% Line highlight bar.
/line_highlight {	% x y width height gray -> -
  gsave
    /gray exch def
    Box gray setgray fill
  grestore
} def

% Column separator lines.
/column_lines {
  gsave
    .1 setlinewidth
    0 d_footer_h translate
    /cw d_output_w cols div def
    1 1 cols 1 sub {
      cw mul 0 moveto
      0 d_output_h rlineto stroke
    } for
  grestore
} def

% Column borders.
/column_borders {
  gsave
    .1 setlinewidth
    0 d_footer_h moveto 
    0 d_output_h rlineto
    d_output_w 0 rlineto
    0 d_output_h neg rlineto
    closepath stroke
  grestore
} def

% Do the actual underlay drawing
/draw_underlay {
  ul_style 0 eq {
    ul_str true charpath stroke
  } { 
    ul_str show
  } ifelse
} def

% Underlay
/underlay {	% - -> -
  gsave
    0 d_page_h translate
    d_page_h neg d_page_w atan rotate

    ul_gray setgray
    ul_font setfont
    /dw d_page_h dup mul d_page_w dup mul add sqrt def
    ul_str stringwidth pop dw exch sub 2 div ul_ptsize -2 div moveto 
    draw_underlay
  grestore
} def

/user_underlay {	% - -> -
  gsave
    ul_x ul_y translate
    ul_angle rotate
    ul_gray setgray
    ul_font setfont 
    0 0 ul_ptsize 2 div sub moveto 
    draw_underlay
  grestore
} def

% Page prefeed
/page_prefeed {		% bool -> -
  statusdict /prefeed known {
    statusdict exch /prefeed exch put
  } {
    pop
  } ifelse
} def

% EPSF import.

/BeginEPSF {
  /b4_Inc_state save def    		% Save state for cleanup
  /dict_count countdictstack def	% Count objects on dict stack
  /op_count count 1 sub def		% Count objects on operand stack 
  userdict begin
  /showpage { } def
  0 setgray 0 setlinecap
  1 setlinewidth 0 setlinejoin
  10 setmiterlimit [ ] 0 setdash newpath
  /languagelevel where {
    pop languagelevel
    1 ne {
      false setstrokeadjust false setoverprint 
    } if
  } if
} bind def

/EndEPSF {
  count op_count sub { pos } repeat	% Clean up stacks
  countdictstack dict_count sub { end } repeat
  b4_Inc_state restore
} bind def

% Check PostScript language level.
/languagelevel where {
  pop /gs_languagelevel languagelevel def
} {
  /gs_languagelevel 1 def
} ifelse
%%EndResource
%%BeginResource: procset Enscript-Encoding-latin1 1.4 0
/encoding_vector [
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/space        	/exclam       	/quotedbl     	/numbersign   	
/dollar       	/percent      	/ampersand    	/quoteright   	
/parenleft    	/parenright   	/asterisk     	/plus         	
/comma        	/minus        	/period       	/slash        	
/zero         	/one          	/two          	/three        	
/four         	/five         	/six          	/seven        	
/eight        	/nine         	/colon        	/semicolon    	
/less         	/equal        	/greater      	/question     	
/at           	/A            	/B            	/C            	
/D            	/E            	/F            	/G            	
/H            	/I            	/J            	/K            	
/L            	/M            	/N            	/O            	
/P            	/Q            	/R            	/S            	
/T            	/U            	/V            	/W            	
/X            	/Y            	/Z            	/bracketleft  	
/backslash    	/bracketright 	/asciicircum  	/underscore   	
/quoteleft    	/a            	/b            	/c            	
/d            	/e            	/f            	/g            	
/h            	/i            	/j            	/k            	
/l            	/m            	/n            	/o            	
/p            	/q            	/r            	/s            	
/t            	/u            	/v            	/w            	
/x            	/y            	/z            	/braceleft    	
/bar          	/braceright   	/tilde        	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/.notdef      	/.notdef      	/.notdef      	/.notdef      	
/space        	/exclamdown   	/cent         	/sterling     	
/currency     	/yen          	/brokenbar    	/section      	
/dieresis     	/copyright    	/ordfeminine  	/guillemotleft	
/logicalnot   	/hyphen       	/registered   	/macron       	
/degree       	/plusminus    	/twosuperior  	/threesuperior	
/acute        	/mu           	/paragraph    	/bullet       	
/cedilla      	/dotlessi     	/ordmasculine 	/guillemotright	
/onequarter   	/onehalf      	/threequarters	/questiondown 	
/Agrave       	/Aacute       	/Acircumflex  	/Atilde       	
/Adieresis    	/Aring        	/AE           	/Ccedilla     	
/Egrave       	/Eacute       	/Ecircumflex  	/Edieresis    	
/Igrave       	/Iacute       	/Icircumflex  	/Idieresis    	
/Eth          	/Ntilde       	/Ograve       	/Oacute       	
/Ocircumflex  	/Otilde       	/Odieresis    	/multiply     	
/Oslash       	/Ugrave       	/Uacute       	/Ucircumflex  	
/Udieresis    	/Yacute       	/Thorn        	/germandbls   	
/agrave       	/aacute       	/acircumflex  	/atilde       	
/adieresis    	/aring        	/ae           	/ccedilla     	
/egrave       	/eacute       	/ecircumflex  	/edieresis    	
/igrave       	/iacute       	/icircumflex  	/idieresis    	
/eth          	/ntilde       	/ograve       	/oacute       	
/ocircumflex  	/otilde       	/odieresis    	/divide       	
/oslash       	/ugrave       	/uacute       	/ucircumflex  	
/udieresis    	/yacute       	/thorn        	/ydieresis    	
] def
%%EndResource
%%EndProlog
%%BeginSetup
%%IncludeResource: font Courier-Bold
%%IncludeResource: font Courier
/user_header_p false def
/HFpt 10 def
/Courier-Bold /HF-gs-font MF
/HF /HF-gs-font findfont HFpt scalefont def
/Courier /F-gs-font MF
/F-gs-font findfont 10 scalefont setfont
/#copies 1 def
/d_page_w 564 def
/d_page_h 744 def
/d_header_x 0 def
/d_header_y 744 def
/d_header_w 564 def
/d_header_h 0 def
/d_footer_x 0 def
/d_footer_y 0 def
/d_footer_w 564 def
/d_footer_h 0 def
/d_output_w 564 def
/d_output_h 744 def
/cols 1 def
%%EndSetup
%%Page: (1) 1
%%BeginPageSetup
_S
24 24 translate
/pagenum 1 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 731 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 720 M
(                                                         X3J3/97-101) s
5 709 M
(                                                        page 1 of 10) s
5 698 M
(        ) s
5 687 M
(        To: X3J3/WG5) s
5 676 M
(        From: Rich Bleikamp \(/io\)) s
5 665 M
(        Subject: Functional Specification for Derived Type I/O) s
5 654 M
(        Date: Jan. 17, 1997) s
5 643 M
(        ) s
5 632 M
(        Revised version of X3J3/96-177.  Look for "|"s in the left) s
5 621 M
(        margin for significant changes.) s
5 599 M
(        One possible activity for WG5/X3J3 at the Feb. '97 meeting is to) s
5 588 M
(        start on the edits to F95 for this proposal.  Any volunteers?) s
5 566 M
(    |   Changes since 97-177:) s
5 555 M
(    |) s
5 544 M
(    |     - added UNFORMATTED I/O support.  Useful to avoid the) s
5 533 M
(    |       restrictions such as "no pointers", ... which limits) s
5 522 M
(    |       F90 functionality for unformatted derived type I/O.) s
5 511 M
(    |) s
5 500 M
(    |       Since the so-called "user defined formatting routines" now) s
5 489 M
(    |       support unformatted I/O, I have renamed them) s
5 478 M
(    |       "user defined I/O routines".) s
5 467 M
(    |   ) s
5 456 M
(    |     - Allow internal I/O in one of these user-defined I/O) s
5 445 M
(    |       routines.  Or in any routine called therefrom.) s
5 434 M
(    |) s
5 423 M
(    |     - Added a Rationale.) s
5 412 M
(    |) s
5 401 M
(    |     - Added a Conceptual Model \(how will this be implemented\).) s
5 390 M
(    |) s
5 379 M
(    |     - Added a small example routine.) s
5 368 M
(    |) s
5 357 M
(    |) s
5 346 M
(    |   Unresolved Issues) s
5 335 M
(    |) s
5 324 M
(    |     - Should the "err", "eor", and "eof" dummy arguments) s
5 313 M
(    |       be a derived type?  Or is logical type sufficient?) s
5 302 M
(    |) s
5 291 M
(    |     - How can the writer of a user defined I/O routine) s
5 280 M
(    |       debug anything, without the ability to WRITE stuff out?) s
5 269 M
(    |) s
5 258 M
(    |     - Should the I/O statements executed within a user) s
5 247 M
(    |       defined I/O routine be IMPLICITLY non-advancing?) s
5 236 M
(    |       This would only work for sequential formatted I/O.) s
5 225 M
(    |       ) s
5 214 M
(    |       How do we describe UNFORMATTED and direct access I/O?) s
5 203 M
(    |       Non-advancing is only allowed for formatted sequential I/O,) s
5 192 M
(    |       so we need some other term to describe how we insert/extract) s
5 181 M
(    |       characters from the middle of a record in the user defined) s
5 170 M
(    |       I/O routine.) s
5 159 M
(    |) s
5 148 M
(    |       Perhaps we need to describe these nested/recursive) s
5 137 M
(    |       I/O calls in other terms, to avoid confusion with normal) s
5 126 M
(    |       Fortran I/O.  ) s
5 115 M
(    |) s
5 104 M
(    |     - Should we allow a "text error string" to be returned) s
5 93 M
(    |       when an ERR is to be reported, in case the original I/O) s
5 82 M
(    |       statement did not have an ERR= or IOSTAT= ?) s
_R
S
%%Page: (2) 2
%%BeginPageSetup
_S
24 24 translate
/pagenum 2 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                        page 2 of 10) s
5 687 M
(    |) s
5 676 M
(    |     - Should we add an IOSTAT variable, so specific values) s
5 665 M
(    |       can be passed back to the user?) s
5 654 M
(    |) s
5 643 M
(    |     - Having to handle internal and external units separately) s
5 632 M
(    |       is inconvenient.  Should we only pass in a unit ?) s
5 610 M
(        ) s
5 599 M
(        This document is the \(proposed\) functional specification for) s
5 588 M
(        enhanced derived type I/O.  The goals are to provide a powerful) s
5 577 M
(        and portable way to encapsulate I/O support in a MODULE which) s
5 566 M
(        defines a derived type.  This I/O support is provided by) s
5 555 M
(        simple, easy to use extensions to the traditional Fortran) s
5 544 M
(        READ and WRITE statements.) s
5 522 M
(        This specification, in a earlier form, was approved as the) s
5 511 M
(        generally correct approach for supporting derived type I/O) s
5 500 M
(        at X3J3 meeting 139.) s
5 478 M
(        ) s
5 467 M
(        Management Synopsis:) s
5 456 M
(        ) s
5 445 M
(          - The provider of a derived type may also provide two) s
5 434 M
(            I/O routines, called "user defined I/O routines",) s
5 423 M
(            which are called by the Fortran I/O library when) s
5 412 M
(            certain conditions are met.  These user supplied) s
5 401 M
(            routines handle input and output of a list item of derived) s
5 390 M
(            type.  In essense, the effect is as if the user defined) s
5 379 M
(            I/O routines were substituting list items into the) s
5 368 M
(            original I/O list \(where the derived type item was\), and) s
5 357 M
(            adding edit descriptors into the middle of the original) s
5 346 M
(            format specification, under control of the provided) s
5 335 M
(            routines.) s
5 313 M
(          - The F90 way of doing formatted and unformatted I/O) s
5 302 M
(            on derived types still works the same as before.  Only) s
5 291 M
(            the presence of an interface for the appropriate user) s
5 280 M
(            defined I/O routine triggers this new functionality.) s
5 269 M
(        ) s
5 258 M
(          - FORMATs have a new edit descriptor, "DT".  When the) s
5 247 M
(            I/O library encounters this, it must match up with a) s
5 236 M
(            derived type list item.  The I/O library will call a) s
5 225 M
(            user supplied I/O routine, which will actually do the) s
5 214 M
(            I/O.  Typically, the provider of a derived type) s
5 203 M
(            would provide these user defined I/O routines.) s
5 192 M
(        ) s
5 181 M
(          - The user supplied procedures \(one for READs, one for) s
5 170 M
(            WRITEs\), will  be called with a unit number, the) s
5 159 M
(            derived type variable/value, and other  misc.) s
5 148 M
(            information.  The procedure will use normal I/O) s
5 137 M
(            statements \(READ/WRITE\) on the supplied unit to) s
5 126 M
(            read/write the derived type item.) s
5 115 M
(            This use of "recursive" I/O will be restricted  to) s
5 104 M
(    |       this particular feature of the language.  Internal) s
5 93 M
(    |       I/O will be permitted in the user defined I/O) s
5 82 M
(    |       routines.) s
_R
S
%%Page: (3) 3
%%BeginPageSetup
_S
24 24 translate
/pagenum 3 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                        page 3 of 10) s
5 687 M
(        ) s
5 676 M
(          - Full support for complicated data structures is) s
5 665 M
(            provided.  These user defined I/O routines can invoke) s
5 654 M
(            themselves indirectly thru formatted I/O \(to traverse a) s
5 643 M
(            linked list for example\), and can invoke the user defined) s
5 632 M
(            I/O routines for another derived type \(indirectly, thru) s
5 621 M
(            formatted I/O\) to handle nested derived types.) s
5 610 M
(    |       Internal I/O may be used to easily construct character) s
5 599 M
(    |       string values.) s
5 588 M
(               ) s
5 577 M
(          - The user supplied procedures will be able to inquire) s
5 566 M
(            about, and in the most general \(robust\) case, have) s
5 555 M
(            to worry about:) s
5 544 M
(    |          -  Formatted and unformatted I/O) s
5 533 M
(               -  list directed and  namelist I/O) s
5 522 M
(               -  sequential and direct access I/O) s
5 511 M
(               -  non-advancing and advancing I/O) s
5 500 M
(               -  the DELIM= and PAD= values for this file) s
5 489 M
(                 \(accessible via INQUIRE\)) s
5 478 M
(                    ) s
5 467 M
(          - List directed and NAMELIST I/O will also call these) s
5 456 M
(            same user supplied routines under certain, F90) s
5 445 M
(    |       compatible circumstances.  \(when an appropriate interface) s
5 434 M
(    |       is visible\)) s
5 423 M
(        ) s
5 412 M
(        ) s
5 401 M
(        Detailed Specification:) s
5 390 M
(        ) s
5 379 M
(        User defined I/O routines shall have the following) s
5 368 M
(        interface:) s
5 357 M
(        ) s
5 346 M
(          INTERFACE FORMAT \( READ \)) s
5 335 M
(            RECURSIVE SUBROUTINE my_read_routine  \(unit,) s
5 324 M
(                                                   ifu,) s
5 313 M
(                                                   dtv,) s
5 302 M
(                                                   iotype, w, d, m,) s
5 291 M
(                                                   rec, eof, err, eor\)) s
5 280 M
(              INTEGER, OPTIONAL :: unit) s
5 269 M
(              CHARACTER \(LEN=*\), OPTIONAL  :: ifu) s
5 258 M
(              TYPE \(whateveritis\) dtv   ! the derived type value/variable) s
5 247 M
(              CHARACTER \(*\) iotype      ! the edit descriptor string) s
5 236 M
(              INTEGER, OPTIONAL :: w,d,m) s
5 225 M
(              INTEGER, OPTIONAL :: rec) s
5 214 M
(              LOGICAL :: eof, err, eor) s
5 203 M
(            END) s
5 192 M
(          END INTERFACE) s
_R
S
%%Page: (4) 4
%%BeginPageSetup
_S
24 24 translate
/pagenum 4 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                        page 4 of 10) s
5 687 M
(          INTERFACE FORMAT \( WRITE \)) s
5 676 M
(            RECURSIVE  SUBROUTINE my_write_routine \(unit,) s
5 665 M
(                                                    ifu,) s
5 654 M
(                                                    dtv,) s
5 643 M
(                                                    iotype, w, d, m,) s
5 632 M
(                                                    rec, err\)) s
5 621 M
(              INTEGER, OPTIONAL :: unit) s
5 610 M
(              CHARACTER \(LEN=*\), OPTIONAL  :: ifu) s
5 599 M
(              TYPE \(whateveritis\) dtv   ! the derived type value/variable) s
5 588 M
(              CHARACTER \(*\) iotype      ! the edit descriptor string) s
5 577 M
(              INTEGER, OPTIONAL :: w,d,m) s
5 566 M
(              INTEGER, OPTIONAL :: rec) s
5 555 M
(              LOGICAL :: err) s
5 544 M
(            END) s
5 533 M
(          END INTERFACE) s
5 522 M
(        ) s
5 511 M
(        where the actual specific routine names \(my_xxx_routine) s
5 500 M
(        above\) and the dummy argument names may be chosen by the) s
5 489 M
(        user.  These routines shall not be invoked directly by the) s
5 478 M
(        users program.) s
5 467 M
(        ) s
5 456 M
(        The user defined I/O routines are called when:) s
5 434 M
(    |     - for unformatted i/o, list directed, and namelist i/o,) s
5 423 M
(    |       an appropriate interface for the derived type of a) s
5 412 M
(    |       particular list item is visible) s
5 390 M
(    |     - for I/O statements with a <format-specification>,) s
5 379 M
(    |       there must be an appropriate interface AND the) s
5 368 M
(    |       list item must match up with a "DT" edit descriptor.) s
5 346 M
(        What the user defined I/O routines are passed:) s
5 324 M
(        If the original I/O statement specified list directed I/O,) s
5 313 M
(        the "iotype" argument will have the value "LISTDIRECTED".  If) s
5 302 M
(        the original I/O statement specified  NAMELIST I/O, the "iotype") s
5 291 M
(    |   argument will have the  value "NAMELIST".  When the original) s
5 280 M
(    |   I/O statement specified UNFORMATTED I/O, the "iotype" argument) s
5 269 M
(    |   will have the value "UNFORMATTED".) s
5 247 M
(        When the original I/O statement included a) s
5 236 M
(        format-specification, then the user defined I/O) s
5 225 M
(        routines are accessible via the new "DT" edit descriptor.) s
5 203 M
(            A new edit descriptor, "DT", with the usual \(optional\)) s
5 192 M
(            "[w[.d[.m]]]"  widths is provided for use with format) s
5 181 M
(            specifications.  It must match up with a variable/value) s
5 170 M
(            of a derived type.) s
5 159 M
(          ) s
5 148 M
(            The DT characters may be followed by an arbitrary \(up to) s
5 137 M
(            253?\) number of alphabetic characters \(interspersed) s
5 126 M
(            blanks allowed\) \(ex. "DTLNKLST"\).  The entire string of) s
5 115 M
(            alphabetic characters, including the initial "DT", will) s
5 104 M
(            be passed  into the user defined I/O routine \(the "iotype") s
5 93 M
(            argument\).) s
_R
S
%%Page: (5) 5
%%BeginPageSetup
_S
24 24 translate
/pagenum 5 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                        page 5 of 10) s
5 676 M
(            This argument will be converted to UPPERCASE and have all) s
5 665 M
(            blanks removed.  The user can support different types of) s
5 654 M
(            formatting for one derived type via this extended edit) s
5 643 M
(            descriptor.) s
5 632 M
(          ) s
5 621 M
(            For example, the consecutive characters after the "DT") s
5 610 M
(            could be used to request different formatting rules for) s
5 599 M
(            consecutive components in the derived type, or different) s
5 588 M
(            formatting rules for nested derived types, etc.) s
5 577 M
(        ) s
5 566 M
(        If a derived type variable/value is specified in an I/O) s
5 555 M
(        list, and that variable/value will match up with a  "DT") s
5 544 M
(        edit descriptor, the user must have also provided the) s
5 533 M
(        matching  read/write procedure for that derived type , with) s
5 522 M
(        a visible interface thats matches the definition in this) s
5 511 M
(        paper.  These procedures are called the "user defined) s
5 500 M
(        I/O routines".  If such an interface is visible, the) s
5 489 M
(        derived type item may either match a "DT" edit descriptor or) s
5 478 M
(        use original F90 conventions.) s
5 467 M
(        When the user defined I/O routines are called, either) s
5 456 M
(        "unit" or "ifu" will be present, but not both.) s
5 445 M
(        ) s
5 434 M
(        If "unit" is present, the original I/O statement specified) s
5 423 M
(        an external unit \(possibly *\), and all I/O statements for) s
5 412 M
(    |   external units in the user defined I/O routine) s
5 401 M
(    |   \(including INQUIRE\) shall specify this dummy argument for the) s
5 390 M
(    |   UNIT= specifier.    \(we used to only require the same value\)) s
5 379 M
(        ) s
5 368 M
(        The "unit" dummy argument, if present, contains a processor) s
5 357 M
(        dependent value, that may, or may not, be the same unit) s
5 346 M
(        number specified by the user in the original I/O statement.) s
5 335 M
(        ) s
5 324 M
(        Note that an INQUIRE statement cannot be executed when "unit") s
5 313 M
(        is absent.) s
5 291 M
(    |   If "ifu" is present, the original I/O statement specified an) s
5 280 M
(    |   internal unit, and all I/O statements in the user defined) s
5 269 M
(    |   I/O routine shall specify an internal unit specifier.) s
5 258 M
(    |   If the dummy argument "ifu" is used as the unit specifier,) s
5 247 M
(    |   the I/O statement processes the record\(s\) from the original) s
5 236 M
(    |   I/O statement which triggered this user defined I/O routine.) s
5 225 M
(    |   Other internal unit variables will behave as if no other I/O) s
5 214 M
(    |   were active.) s
5 192 M
(    |   Note that "ifu" may not have any obvious relationship with) s
5 181 M
(    |   the internal unit specified in the original I/O statement) s
5 170 M
(    |   \(i.e. "ifu" may not point to the original internal unit) s
5 159 M
(    |    in any discernable manner\).) s
5 148 M
(        ) s
5 137 M
(        If the original I/O statement is a READ statement, the "dtv") s
5 126 M
(        dummy arg should be assigned a value by the user defined) s
5 115 M
(        I/O "read" routine.) s
_R
S
%%Page: (6) 6
%%BeginPageSetup
_S
24 24 translate
/pagenum 6 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                        page 6 of 10) s
5 687 M
(        ) s
5 676 M
(        If the original I/O statement is a WRITE or PRINT, the "dtv") s
5 665 M
(        dummy arg contains the value of the list item from the) s
5 654 M
(        original I/O statement, to be output by the user defined) s
5 643 M
(        I/O routine.) s
5 632 M
(        ) s
5 621 M
(        The "w", "d", and "m" arguments contain the user specified) s
5 610 M
(        values from the FORMAT \(i.e.  FORMAT\(DT12.5.2 \) \).  If the) s
5 599 M
(        user did not specify "w", "d", and/or "m", those dummy) s
5 588 M
(        arguments will not be present.  They will not be present if) s
5 577 M
(        the original I/O statement specified unformatted, list) s
5 566 M
(        directed, or namelist i/o.) s
5 555 M
(        ) s
5 544 M
(        The "rec" dummy arg will be present if the original I/O) s
5 533 M
(        statement contained a REC= sepcifier, and will not be) s
5 522 M
(        present otherwise.  Note that the READ or WRITE statements) s
5 511 M
(        for "unit" or "ifu" contained in the user defined I/O routine) s
5 500 M
(        shall contain a REC=rec specifier if dummy arg "rec" is present,) s
5 489 M
(        and shall not contain a REC= specifier otherwise.) s
5 478 M
(        ) s
5 467 M
(        The user defined I/O routines for reads shall assign) s
5 456 M
(        a value of .FALSE. or .TRUE. to the "end", "err", "eof", and) s
5 445 M
(        "eor" dummy args.   The value assigned to these dummy) s
5 434 M
(        arguments shall determine whether or not the corresponding) s
5 423 M
(        condition will be triggered in the I/O library when the user) s
5 412 M
(        defined I/O routine returns.) s
5 401 M
(        ) s
5 390 M
(        In the absence of an appropriate visible interface in the) s
5 379 M
(    |   scope of  the I/O statement, unformatted, list-directed, and) s
5 368 M
(        namelist I/O will behave as it did in Fortran 90.) s
5 357 M
(        ) s
5 346 M
(        When an appropriate interface is visible for a particular) s
5 335 M
(        derived type, and either:) s
5 324 M
(    |        1. The original I/O statement specified unformatted,) s
5 313 M
(                list directed, or namelist I/O, OR) s
5 302 M
(               ) s
5 291 M
(             2. the original I/O statement specified a FORMAT and) s
5 280 M
(                the list item of derived type matches up with a "DT") s
5 269 M
(                edit descriptor, THEN) s
5 258 M
(        ) s
5 247 M
(        the restrictions on derived  type I/O, such as no private) s
5 236 M
(        components, all components must be defined,  no ultimate) s
5 225 M
(        components with the pointer attribute, etc. do not apply to) s
5 214 M
(        the list item of derived type, but) s
5 203 M
(        the normal rules in F95 still apply, about not referencing) s
5 192 M
(        undefined entities, not referencing/defining POINTERS which) s
5 181 M
(        are not associated, etc.) s
5 170 M
(        ) s
5 159 M
(        If NO appropriate interface is visible for a particular) s
5 148 M
(        derived type, the processor will perform "F90" style I/O,) s
5 137 M
(        and a "DT" edit descriptor which matches that derived type) s
5 126 M
(        list item will cause an error \(at runtime possibly\).) s
5 115 M
(        ) s
5 104 M
(        When F90 style I/O is selected, all the old F90 restrictions) s
5 93 M
(        on derived type list items still apply.) s
_R
S
%%Page: (7) 7
%%BeginPageSetup
_S
24 24 translate
/pagenum 7 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                        page 7 of 10) s
5 687 M
(        ) s
5 676 M
(        The users routine may chose to interpret the "w" argument as) s
5 665 M
(        a field width, but this is NOT required.  If it does so, it) s
5 654 M
(        would be appropriate, but not required, to fill an output) s
5 643 M
(        field with "***"s if the value does not fit.) s
5 632 M
(        ) s
5 621 M
(        When the original I/O statement was a READ, the user defined) s
5 610 M
(        I/O routine may only do READs.  Similarly for WRITE.) s
5 599 M
(        ) s
5 588 M
(        The user defined I/O routines ARE permitted to use a FORMAT with a) s
5 577 M
(        DT edit descriptor, for handling components of the derived) s
5 566 M
(        type which are themselves a derived type.  List directed and) s
5 555 M
(        NAMELIST I/O are also permitted for the "recursive" I/O) s
5 544 M
(        statement.) s
5 533 M
(        ) s
5 522 M
(        WRITE statements contained in the user defined I/O) s
5 511 M
(        routine will insert the characters "written" into the record) s
5 500 M
(        started by the original  WRITE statement, starting at the) s
5 489 M
(        position in the record where the last edit descriptor left) s
5 478 M
(        off.  Record boundaries may be created by WRITE statements) s
5 467 M
(        in the user defined I/O routine.  Non-advancing I/O) s
5 456 M
(        may be used to avoid creating record boundaries.) s
5 445 M
(        ) s
5 434 M
(        READ statements contained in the user defined I/O) s
5 423 M
(        routine for read will "pick up" in the current record, where) s
5 412 M
(        the last edit descriptor from the original I/O statement) s
5 401 M
(        left off.  Multiple records can be read,  and the current) s
5 390 M
(        position can be left within a record by the READ statement) s
5 379 M
(        in the user defined I/O routine, thru the use of non-) s
5 368 M
(        advancing i/o.) s
5 357 M
(        ) s
5 346 M
(        A very robust user defined I/O routine may need to use INQUIRE to) s
5 335 M
(        determine what BLANK=, PAD= and DELIM= are for the specified) s
5 324 M
(        unit.) s
5 313 M
(        ) s
5 302 M
(        Edit descriptors such as BN, BZ, P, etc., are permitted in) s
5 291 M
(        FORMATs in user defined I/O routines, and have the) s
5 280 M
(        same effect as if they had been present in the original) s
5 269 M
(        FORMAT.) s
5 247 M
(    |   READ and WRITE statements executed in a user defined I/O) s
5 236 M
(    |   routine, or executed in a routine called \(directly or) s
5 225 M
(    |   indirectly\) from a user defined I/O routine shall not) s
5 214 M
(    |   have an ASYNCHRONOUS specifier.) s
_R
S
%%Page: (8) 8
%%BeginPageSetup
_S
24 24 translate
/pagenum 8 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                        page 8 of 10) s
5 687 M
(    |   --------------------------------------------------------------) s
5 676 M
(    |   Rationale) s
5 654 M
(    |   The desire to allow users to implement new data types in a) s
5 643 M
(    |   MODULE requires additional language features, including I/O) s
5 632 M
(    |   support.  The provider of a module which implements a new) s
5 621 M
(    |   datatype needs to be able to also provide I/O support.) s
5 610 M
(    |   The approach chosen extends existing Fortran features to) s
5 599 M
(    |   support derived types, is fairly easy to use, bypasses the) s
5 588 M
(    |   restrictions on derived type I/O present in Fortran 90, and) s
5 577 M
(    |   allows the I/O support to be bundled with the MODULE which) s
5 566 M
(    |   supplies the derived type definition and implements the) s
5 555 M
(    |   operations thereon.  This also provides the ability to) s
5 544 M
(    |   protect these I/O operations.) s
5 522 M
(    |   The use of visible interfaces to trigger this functionality) s
5 511 M
(    |   helps preserve Fortran 90 compatability, since no Fortran) s
5 500 M
(    |   program can specify such an interface.) s
5 478 M
(    |   --------------------------------------------------------------) s
5 467 M
(    |   Conceptual Model) s
5 445 M
(    |   The key concept is that the user defined I/O routines can,) s
5 434 M
(    |   more or less, be viewed as  adding individual components into) s
5 423 M
(    |   the middle of the original item list, and edit desciptors into) s
5 412 M
(    |   the middle of the original format-specification \(if any\).  They) s
5 401 M
(    |   also have full control over how input values are processed,) s
5 390 M
(    |   and how values are represented on output.) s
5 379 M
(    |   They can do so in an intelligent, dynamic, and arbitrarily) s
5 368 M
(    |   complex manner.  They can also avoid the restrictions on) s
5 357 M
(    |   F90 derived type I/O \(pointers, etc.\), handle nested) s
5 346 M
(    |   derived types, and support complex data structures) s
5 335 M
(    |   \(such as linked lists\).) s
5 313 M
(    |   The user defined I/O routines provide a familar mechanism,) s
5 302 M
(    |   Fortran I/O statements, to insert data into an output record,) s
5 291 M
(    |   and to retrieve values from an input record.) s
5 269 M
(    |   The user of a derived type uses familiar Fortran syntax) s
5 258 M
(    |   to activate this capability.  Usually, the user only needs) s
5 247 M
(    |   to "USE" the appropriate module, and possibly insert some) s
5 236 M
(    |   "DT" edit descriptors into their format-specifications.) s
5 214 M
(    |   All of the hard work is done by the provider/writer of the) s
5 203 M
(    |   derived type.  Once that hard work is done, many users can) s
5 192 M
(    |   easily adapt their programs to use it.) s
5 170 M
(    |   The interface provides all the information necessary to) s
5 159 M
(    |   accomadate all types of Fortran I/O.  A robust user defined) s
5 148 M
(    |   I/O routine will be quite large, but not necessarily very) s
5 137 M
(    |   complicated.  A simple user-defined I/O routine can be) s
5 126 M
(    |   written quickly, and extended later to handle all the) s
5 115 M
(    |   possible forms of Fortran I/O.) s
5 93 M
(        ) s
_R
S
%%Page: (9) 9
%%BeginPageSetup
_S
24 24 translate
/pagenum 9 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                        page 9 of 10) s
5 687 M
(    |   --------------------------------------------------------------) s
5 676 M
(    |   Example:  \( this has not been syntax checked yet \)) s
5 654 M
(    |   TYPE linkedList) s
5 643 M
(    |     TYPE \(linkedList\), POINTER :: next) s
5 632 M
(    |     INTEGER :: value) s
5 621 M
(    |   END TYPE linkedList) s
5 599 M
(    |   RECURSIVE  SUBROUTINE my_write_routine \(unit,) s
5 588 M
(    |                                           ifu,) s
5 577 M
(    |                                           dtv,) s
5 566 M
(    |                                           iotype, w, d, m,) s
5 555 M
(    |                                           rec, err\)) s
5 544 M
(    |     INTEGER, OPTIONAL :: unit) s
5 533 M
(    |     CHARACTER \(LEN=*\), OPTIONAL  :: ifu) s
5 522 M
(    |     TYPE \(linkedList\), TARGET:: dtv  ! the derived type value) s
5 511 M
(    |     CHARACTER \(*\) iotype             ! the edit descriptor string) s
5 500 M
(    |     INTEGER, OPTIONAL :: w,d,m) s
5 489 M
(    |     INTEGER, OPTIONAL :: rec) s
5 467 M
(    |     TYPE \(linkedList\), POINTER :: ptr) s
5 456 M
(    |     INTEGER :: ww, dd             ! local copies of w,d) s
5 445 M
(    |     CHARACTER \(LEN=20\) :: fmt     ! format specification) s
5 434 M
(    |     ) s
5 423 M
(    |     err = .FALSE.) s
5 401 M
(    |     IF \( iotype == "NAMELIST" \) THEN) s
5 390 M
(    |       ! namelist I/O not supported yet) s
5 379 M
(    |       err = .TRUE.) s
5 368 M
(    |       RETURN) s
5 357 M
(    |     END IF) s
5 335 M
(    |     ! handle the optional "w" and "d" arguments) s
5 324 M
(    |     IF \( present \( w \) \) THEN) s
5 313 M
(    |       ww = w) s
5 302 M
(    |     ELSE) s
5 291 M
(    |       ww = 10) s
5 280 M
(    |     END IF) s
5 258 M
(    |     IF \( present \( d \) \) THEN) s
5 247 M
(    |       dd = d) s
5 236 M
(    |     ELSE) s
5 225 M
(    |       dd = 1) s
5 214 M
(    |     END IF) s
5 192 M
(    |     ! if we will need a format-spec, build it now) s
5 181 M
(    |     IF \( iotype\(1:2\) == "DT" \) THEN) s
5 170 M
(    |       ! build a Format string for use later) s
5 159 M
(    |       write\(fmt, "'\(I',I4,1x,I4,'\)'" \) ww, dd  ! \(Iw.d\)) s
5 148 M
(    |     END IF) s
5 126 M
(    |     ptr => dtv) s
_R
S
%%Page: (10) 10
%%BeginPageSetup
_S
24 24 translate
/pagenum 10 def
/fname (97-101.txt) def
/fdir () def
/ftail (97-101.txt) def
%%EndPageSetup
5 720 M
(                                         ISO/IEC JTC1/SC22/WG5 N1246) s
5 709 M
(                                                         X3J3/97-101) s
5 698 M
(                                                       page 10 of 10) s
5 676 M
(    |     DO            ! main loop down the linked list) s
5 654 M
(    |       IF \( PRESENT \( unit \) \) THEN) s
5 643 M
(    |         ! external I/O) s
5 632 M
(    |         IF \( iotype == "UNFORMATTED"\) THEN) s
5 621 M
(    |           IF \( PRESENT \( rec \) \) THEN) s
5 610 M
(    |             WRITE \(unit, REC=rec, ERR=99\) ptr%value) s
5 599 M
(    |           ELSE) s
5 588 M
(    |             WRITE \(unit, ERR=99\) ptr%value) s
5 577 M
(    |           END IF) s
5 566 M
(    |         ELSE IF \( iotype == "LISTDIRECTED" \) THEN) s
5 555 M
(    |           WRITE \(unit, *, ADVANCE="NO", ERR=99\) ptr%value) s
5 544 M
(    |         ELSE IF \( iotype\(1:2\) == "DT" \) THEN) s
5 533 M
(    |           IF \( PRESENT \( rec \) \) THEN) s
5 522 M
(    |             write\(unit, fmt, REC=rec, ERR=99\) ptr%value) s
5 511 M
(    |           ELSE) s
5 500 M
(    |             write\(unit, fmt, ADVANCE="NO", ERR=99\) ptr%value) s
5 489 M
(    |           END IF) s
5 478 M
(    |         ELSE) s
5 467 M
(    |           ! unrecognized i/o type) s
5 456 M
(    |           GO TO 99) s
5 445 M
(    |         END IF) s
5 434 M
(    |       ELSE) s
5 423 M
(    |         ! assume internal I/O) s
5 412 M
(    |         !   remember, direct access \(rec=\) is prohibited on) s
5 401 M
(    |         !   internal files, simplifies the stuff below) s
5 390 M
(    |         IF \( iotype == "UNFORMATTED"\) THEN) s
5 379 M
(    |           WRITE \(ifu, ERR=99\) ptr%value) s
5 368 M
(    |         ELSE IF \( iotype == "LISTDIRECTED" \) THEN) s
5 357 M
(    |           WRITE \(ifu, *, ADVANCE="NO", ERR=99\) ptr%value) s
5 346 M
(    |         ELSE IF \( iotype\(1:2\) == "DT" \) THEN) s
5 335 M
(    |           write\(ifu, fmt, ADVANCE="NO", ERR=99\) ptr%value) s
5 324 M
(    |         ELSE) s
5 313 M
(    |           ! unrecognized i/o type) s
5 302 M
(    |           GO TO 99) s
5 291 M
(    |         END IF) s
5 280 M
(    |       END IF) s
5 269 M
(    |       IF \( ASSOCIATED \(ptr%next\) \) EXIT) s
5 258 M
(    |     END DO) s
5 247 M
(    |   RETURN          ! normal exit) s
5 225 M
(    |99 err = .TRUE.) s
5 214 M
(    |   RETURN          ! error  exit) s
5 203 M
(        END) s
_R
S
%%Trailer
%%Pages: 10
%%DocumentNeededResources: font Courier-Bold Courier 
%%EOF

--------------718C5BC2341E--

