- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Does anyone know of a simple way, within the FORTRAN language,of establishing if theBACKSPACE command has hit the beginning of a sequential file? I use backspace to look for comments within an engineering analysis input deck. If a line corresponds to a recognised fieldI need to backspace two lines to check for a comment on thepreceeding linefrom which a descriptive text string can be obtained. The comments are not mandatory in these input files so a problem occurs if the first line of the file is not a comment. In this case backspacing once will hit the beginning of the file and the second BACKSPACE will do nothing (IOSTAT is still returned as 0) so there seems to be no way of knowing where you are.Normally after checking for a preceding comment there willfollow two read statements to get you back to where you would have been if you were reading sequentially through the file. This works fine if the first line of the file is a comment (or any line further down the file) but when it is not thetwo reads will cause the second line of the file to be bypassed.
Ideally the BACKSPACE could return a Start_of_File code in a similar way to aREAD statement returning an end of file code when you reach that point. I don't dsee anything in the function references to provide the functionality I am after. The Inquire statement looked a possiblity but the Position returns the settings used to open the file rather than its current position.
Ideally the BACKSPACE could return a Start_of_File code in a similar way to aREAD statement returning an end of file code when you reach that point. I don't dsee anything in the function references to provide the functionality I am after. The Inquire statement looked a possiblity but the Position returns the settings used to open the file rather than its current position.
- Etiquetas:
- Intel® Fortran Compiler
1 Solución
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I suggest you use the GETPOS routine from the "Portability library" for this purpose.
Enlace copiado
3 Respuestas
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I suggest you use the GETPOS routine from the "Portability library" for this purpose.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Prior to backspacing try issuing INQUIRE to obtain POS.
I am not sure if POS is 0-based or 1-based, you can easily determine this.
If/when the inquire indicates the last record read, was the first record of the file, then assume that there is no comment (as it would have to preceed the beginning of the file).
Jim Dempsey
I am not sure if POS is 0-based or 1-based, you can easily determine this.
If/when the inquire indicates the last record read, was the first record of the file, then assume that there is no comment (as it would have to preceed the beginning of the file).
Jim Dempsey
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Thanks Steve,
GetPos is just what I was after.
I think the INQUIRE POS idea only works on files opened with ACCESS='STREAMED' according to documentation.
Thanks again.
GetPos is just what I was after.
I think the INQUIRE POS idea only works on files opened with ACCESS='STREAMED' according to documentation.
Thanks again.
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