[comp.lang.fortran] concantenation of filenames

anand@crysiris.rice.edu (Anand Kolatkar) (12/08/90)

	Hello, I'm new to this newsgroup, and I hope someone can help.
	I am trying to produce many files which are named by  
	consecutive numbers(beginning with 1).  However, when I run the 
	program, I get the name I want concatenated with the input 
	file name (from UNIT=1).

	The segment of the program below shows how I rename each new file
	and tack on the appropriate numeral using encode.
	However, when actually writing the file, the program crashes
	while trying to write to file: 'filename/usr/crys/anand/super/FFT.DAT'.

	Why does this concatenation occur, and how can I fix this?

******	I am programming on a Silicon Graphics IRIS(OS 3.3-UNIX SYSV). *****

	Thanks in advance,

					Anand Kolatkar
				anand@keckiris.rice.edu

	_____________________________________________________________________

	logical*1 filename(16)
	data filename/1h/,1hd,1h/,1ha,1hn,1ha,1hn,1hd,1h/,1hv,1hx,
     @   1hl,1h/,1h ,1h ,1h /

	open (unit=1,file='/usr/crys/anand/super/FFT.DAT',
     $        form='unformatted',status='old')
	write (6,*) 'enter scale'
	read (5,*) sc
	.
	.	stuff deleted
	.
	DO 100 J=1,128
	encode(3,1000,filename(14)) j
1000	format (i3)
		write (6,*) j,smax
		open (unit=2,file=filename,form='unformatted',status='new')
		close (2)
100	continue
--
//     Anand Kolatkar	 	E-mail: anand@crysiris.rice.edu    //
//     Rice University						   //
//     Dept. of Biochemistry and Cell Biology			   //

khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup) (12/08/90)

In article <1990Dec7.173541.2672@rice.edu> anand@crysiris.rice.edu (Anand Kolatkar) writes:


	   logical*1 filename(16)
	   data filename/1h/,1hd,1h/,1ha,1hn,1ha,1hn,1hd,1h/,1hv,1hx,
	@   1hl,1h/,1h ,1h ,1h /


Might have a better chance if you use Fortran 77 standard code.
Consider the following snippet:

        CHARACTER*32 FILENAME

        DO 100 I = 1, 10
           WRITE(FILENAME,'(''MYFILE'',I2.2)'),I
           PRINT*,FILENAME
 100    CONTINUE
        END


f77 bork.f && a.out
bork.f:
 MAIN:
MYFILE01                        
...
MYFILE10                        

As an example.

--
----------------------------------------------------------------
Keith H. Bierman    kbierman@Eng.Sun.COM | khb@chiba.Eng.Sun.COM
SMI 2550 Garcia 12-33			 | (415 336 2648)   
    Mountain View, CA 94043