- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I am looping on IHIST in the open statement below. I want to change the file name 'test100.txt' on the during looping such that I get a set of files at the end such as test101.txt, test102.txt, ..., test1000.txt
Pointing me to a known solution would be much appreciated. Note, I am new to character manipulation in FORTRAN, so do not understand how to formulate this problem
OPEN (UNIT=100+IHIST, FILE='test100.txt', STATUS='UNKNOWN')
Mike
Pointing me to a known solution would be much appreciated. Note, I am new to character manipulation in FORTRAN, so do not understand how to formulate this problem
OPEN (UNIT=100+IHIST, FILE='test100.txt', STATUS='UNKNOWN')
Mike
- Etiquetas:
- Intel® Fortran Compiler
1 Solución
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
WRITE(filename,'(a,i4.4,a)') "TEST",i,".TXT"
will enable you to create filenames from TEST0000.TXT to TEST9999.TXT
I'm not sure if you can specify UNIT=100+IHIST - hopefully someone else will answer that for you.
David
will enable you to create filenames from TEST0000.TXT to TEST9999.TXT
I'm not sure if you can specify UNIT=100+IHIST - hopefully someone else will answer that for you.
David
Enlace copiado
3 Respuestas
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
WRITE(filename,'(a,i4.4,a)') "TEST",i,".TXT"
will enable you to create filenames from TEST0000.TXT to TEST9999.TXT
I'm not sure if you can specify UNIT=100+IHIST - hopefully someone else will answer that for you.
David
will enable you to create filenames from TEST0000.TXT to TEST9999.TXT
I'm not sure if you can specify UNIT=100+IHIST - hopefully someone else will answer that for you.
David
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
For the syntax of the OPEN statement, see section 9.4 of the Standard. You can see there that the unit number is allowed to be specified as a scalar integer expression.
If you must have files named test100.txt,... rather than test0100.txt, ...:
If you must have files named test100.txt,... rather than test0100.txt, ...:
[fortran]character*12 :: filename integer :: iunit if(iunit.LT. 1000)then write(filename,'("TEST",I3,".TXT")')iunit open(unit=iunit+100,file=filename,status='unknown') ... close(unit=iunit) else write(filename,'("TEST",I4,".TXT")')iunit open(unit=iunit+100,file=filename,status='unknown') ... close(unit=iunit) endif [/fortran]
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Or just use the format I0 (that is zero)
Les
Les

Responder
Opciones de temas
- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla