Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gfortran bug for ADVANCE='NO'?

Status
Not open for further replies.

GerritGroot

Technical User
Nov 3, 2006
291
ES
Hi,

I used the following procedure to get some screen feedback.
Code:
SUBROUTINE StartEndInfo(Line,Sort)
IMPLICIT NONE
CHARACTER(LEN=*), INTENT(IN) :: Line
CHARACTER(LEN=*), INTENT(IN) :: Sort
CHARACTER(LEN=60) :: StartLine
CHARACTER(LEN=20) :: EndLine
IF(TRIM(Sort)=='Start')THEN
   StartLine=ADJUSTL(TRIM(Line))
   WRITE(*,ADVANCE='NO',FMT='(A60)')StartLine
ELSE IF(TRIM(Sort)=='End')THEN
   EndLine=ADJUSTR(TRIM(Line))
   WRITE(*,ADVANCE='NO',FMT='(A20)')EndLine
ELSE
   WRITE(*,'(A)')TRIM(Line)
END IF
END SUBROUTINE StartEndInfo
In gfortran 4.6 this gave me the error: "bad file descriptor", but only after having it called several times.
When updated to 4.7, just in case, it just broke down without any message, also after a a few calls to this routine.

Next, I changed it to:
Code:
SUBROUTINE StartEndInfo(Line,Sort)
IMPLICIT NONE
CHARACTER(LEN=*), INTENT(IN) :: Line
CHARACTER(LEN=*), INTENT(IN) :: Sort
CHARACTER(LEN=60) :: StartLine
CHARACTER(LEN=20) :: EndLine
IF(TRIM(Sort)=='Start')THEN
   StartLine=ADJUSTL(TRIM(Line))
!   WRITE(*,ADVANCE='NO',FMT='(A60)')StartLine
   WRITE(*,'(A)')StartLine
ELSE IF(TRIM(Sort)=='End')THEN
!   EndLine=ADJUSTR(TRIM(Line))
!   WRITE(*,ADVANCE='NO',FMT='(A20)')EndLine
   CONTINUE
ELSE
   WRITE(*,'(A)')TRIM(Line)
END IF
END SUBROUTINE StartEndInfo
And the code runs fine.

Is this an error in gfortran? Or am I doing something wrong?

Thanks,

Gerrit

P.S. How do you post source in colors?
 
Sorry for being so quick in posting, the error was somewhere else, it had nothing to do with writing to the screen, though that was where the code broke down.

Apologies,

Gerrit

P.S. How do you post source in colors?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top