home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!hirchert
- From: hirchert@ncsa.uiuc.edu (Kurt Hirchert)
- Subject: Re: Variable repeat count specifier for FORMAT statments
- References: <1992Jul23.215113.16531@jhunix.hcf.jhu.edu>
- Message-ID: <1992Jul24.012058.21162@ncsa.uiuc.edu>
- Originator: hirchert@pluto.ncsa.uiuc.edu
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Organization: Nat'l Ctr for Supercomp App (NCSA) @ University of Illinois
- Distribution: na
- Date: Fri, 24 Jul 1992 01:20:58 GMT
- Lines: 32
-
- In article <1992Jul23.215113.16531@jhunix.hcf.jhu.edu> psun@jhunix.hcf.jhu.edu (Peter Sun) writes:
- >My apologies if this questions seems trivial, but I've tried to find the
- >answer in so many places. I need to know how to give a variable as the
- >number of repeat counts to a format field descriptor statement. For
- >example I know on VAX/VMS this can be done with something like:
- >
- > write (*, '(<n>(I8))')
- >
- >which will repeat the format descriptor I8 n number of times, but I haven't
- >found this portable to other compilers. Namely, the MIPS Fortran 77
- >compiler for the SGI IRIS system. Is there a standard for this? Or is it
- >just compiler dependent.
-
- This is a VAX extension. It is not standard, but in most cases there are
- standard replacements.
-
- In this case, I would simply replace <n> with a large number; the format
- interpreter will ignore the excess repetitions of (I8). In more complex
- situations, I would build the format on the fly:
-
- character*80 fmt
- ...
- write (fmt,'(a,i3,a)') '(',n,'(I8))'
- write (*,fmt) whatever_it_is_you_wanted_to_write
-
- The first write statement creates in the variable fmt a copy of your
- example format with the current value of n replacing <n>. The second
- write then uses the variable fmt as the format to write whatever it was
- that you originally wanted to write.
- --
- Kurt W. Hirchert hirchert@ncsa.uiuc.edu
- National Center for Supercomputing Applications
-