I already found the answer to want I wanted to ask here: Looping over variable file names
But the problem is when I run the program it gave me a strange symbol like a smile.
The code is something like this:
DIMENSION NWGRAIN(NWMAXGRAIN)
CHARACTER*2 FLABEL
NWMAXGRAIN=5
$c GRAINS TO WRITE THE OUTPUT (NW STANDS FOR NUMBER WRITING)
DO I=1,NWMAXGRAIN
NWGRAIN(I)=0
END DO
NWGRAIN(1)=1
NWGRAIN(2)=6
NWGRAIN(3)=100
NWGRAIN(4)=1000
NWGRAIN(5)=1500
DO I=1,NWMAXGRAIN
IUNIT=901+I
flabel=char(nwgrain(i))
OPEN(IUNIT,FILE='DDRX_GRAIN'//FLABEL//'.OUT',
# STATUS='UNKNOWN')
END DO
I want to have several files where I have to write data named 'DDRX_GRAIN1.OUT' , 'DDRX_GRAIN6.OUT' , 'DDRX_GRAIN100.OUT' and so on.
But as you can see it gave me an error where the number is replaced by a smile...
Don't know if it's a joke of my compiler :)
EDIT: I am sorry but I don't understand. As reported in the other topic, I modify my code:
CHARACTER*2 FLABEL,x1
character(len=8) fmt ! format descriptor (italo)
fmt = '(I5.5)' ! an integer of width 5 with zeros at the left
DO I=1,NWMAXGRAIN
IUNIT=901+I
i1=nwgrain(i)
write (x1,fmt) i1 ! converting integer to string using a 'internal file'
OPEN(IUNIT,FILE='DDRX_GRAIN'//trim(x1)//'.OUT',
# STATUS='UNKNOWN')
END DO
The new error is:
forrtl: severe (66): output statement overflows record, unit -5, file Internal Formatted Write