home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!ukma!asuvax!ncar!neit.cgd.ucar.edu!mai
- From: mai@neit.cgd.ucar.edu (Andrew Mai)
- Subject: Re: Print characters on one line without newline...???
- Message-ID: <1992Nov16.203156.1829@ncar.ucar.edu>
- Sender: news@ncar.ucar.edu (USENET Maintenance)
- Organization: Climate and Global Dynamics Division/NCAR, Boulder, CO
- References: <BxtnK6.23s@cs.uiuc.edu>
- Date: Mon, 16 Nov 1992 20:31:56 GMT
- Lines: 50
-
- In article <BxtnK6.23s@cs.uiuc.edu> ctaylor@cs.uiuc.edu
- (Conrad W Taylor) writes:
- >
- > I'm writting this PrintX routine that is to print
- > the letter X n times on one line without any spaces and
- > newline.
-
- The following does what you want and is written in ANSI standard FORTRAN 77.
-
- program test
- call printx(15)
- call printx(80)
- end
- subroutine printx(xcount)
- c
- c Print a space, then xcount X's with a newline at the end
- c
- integer xcount,nd
- character*16 form1,form2
- write(form1,fmt='(a,i1,a)') '(a,i',nd(xcount),',a)'
- write(form2,fmt=form1) '(1x,',xcount,'(''X''))'
- write(6,form2)
- return
- end
- function nd(k)
- c
- c Returns the number of digits in k (plus one for the
- c minus sign if k is negative)
- c
- integer nd,k,l
- nd=1
- l=abs(k)
- 1 if (l.lt.10) goto 2
- nd=nd+1
- l=l/10
- goto 1
- 2 if (k.lt.0) nd=nd+1
- return
- end
-
- OUTPUT:
- XXXXXXXXXXXXXXX
- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-
-
- I don't know an easier way to do this in standard FORTRAN, but someone will
- probably show you.
-
- Andy Mai
- mai@ncar.ucar.edu
-