Text doesn't appear in the console window.

SUBROUTINE CopyInputFile(InDev, OutDev, CaseID)
USE PARAM
USE ioutil,         only : terminate,   toupper,       openfile
USE files,          only : filename,    TempFIleIdx
USE inputcards ,    only : oneline,     probe
USE PE_MOD,         ONLY : PE
IMPLICIT NONE
INTEGER :: InDev, OutDev
CHARACTER(80) :: CaseID

Filename(TempFIleIdx) = trim(CaseId)//trim('.tmp')
IF(PE%SLAVE) RETURN
print *, 'A'
CALL OpenFIle(OutDev, FALSE, FALSE, FALSE, filename(TempFIleIdx))
print *, 'D'
REWIND(INDEV)
DO
  READ(indev,'(a256)',END=6) oneline
  WRITE(OutDev,'(a256)') oneline
  IF(probe.eq.DOT) exit
ENDDO
6 CONTINUE  
CLOSE(OutDev)
REWIND(INDEV)
END SUBROUTINE



SUBROUTINE openfile(indev,IFread,IFbin, IFappend, filename)
use param
USE DFPORT
!      
logical IFex,IFread,IFbin, IFappend
character*80 filename
character(256) filename0
INTEGER :: istat
IF(filename(1:1) .eq. '$') THEN
  istat = GETENVQQ(filename(2:80), filename0)
  IF(istat .EQ. 0) THEN
    mesg='Env. variable does not exist - '//filename
    CALL TERMINATE(mesg)
  ENDIF
ELSE
  filename0 = filename
ENDIF
IF(IFread) then
   inquire(file=filename0,exist=IFex)
   IF(IFex) then !input file
      IF(IFbin) then
!        IF(IFappend) THEN
          open(indev,file=filename0,status='old',form='unformatted')
!        ELSE
!          open(indev,file=filename,status='old',form='unformatted', ACCESS = 'APPEND')
!        ENDIF   
      else
!        IF(IFappend) THEN
!          open(indev,file=filename,status='old', ACCESS = 'APPEND')
!        ELSE
          open(indev,file=filename0,status='old')
!        ENDIF
      ENDIF
   else
      mesg='File does not exist - '//filename0
      CALL terminate(mesg)
   ENDIF
else       !open output file
   IF(IFbin) then
      IF(IFappend) THEN
        open(indev,file=filename0,status='old',form='unformatted', ACCESS = 'APPEND')
      ELSE
        open(indev,file=filename0,status='unknown',form='unformatted')
      ENDIF
   else
     IF(IFappend) THEN
       open(indev,file=filename0,status='old', ACCESS = 'APPEND')
     ELSE
       print *, 'B'
       open(indev,file=filename0,status='unknown') ! THIS IS THE PROBLEM
       print *, 'C'
     ENDIF
   ENDIF
ENDIF
IF(.NOT. IFappend) rewind(indev)
END SUBROUTINE

C, D and all messages followed by them cease to appear in the console window. However, the program is running properly and output file is also normal. What is wrong with that open clause?

What’s indev’s value?

If it’s the same as the OUTPUT_UNIT (stdout) value, which by convention for most compilers is 6, then everything you print to “*” would then be printed to this file.

The INPUT_UNIT (stdin) is usually unit 5 so in this case, all of print * would be printed to stdin.

  • Mat

That’s interesting.

It was 6, as you said.

Changing that fixed the problem.

However, why didn’t the message appear even after I close that indev?

However, why didn’t the message appear even after I close that indev?

Closing unit 6 would close stdout so no more messages.