Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Extra bytes when infile is read?

Abby_P_
Beginner
280 Views

Hi,

I have a quick question.. I am trying to copy a file(.exe/ text - could be anything) to the destination.. So wrote a subroutine as follows.. but when i read the infile for the length the value of I is extra 4 bytes..PLease refer to the bold code part... Thanks.. (i.e., blocksize+4.. 65536+4 = 65540).. previously in the digital version of fortran - It was running fine.. I am wondering what has changed now? -- 

int function copyfl (infile, outfile)
use ifwin
use ifport
implicit none

char *(*) infile
char *(*) outfile

int blocksize
parameter (blocksize = 65536)
char *(blocksize) buffer
int *4 dateval
int (HANDLE) fhandle
type (file$info) finfo
int i
int ioerr
logical err /false/
 

open (51, file = infile, status = 'old', iostat = ioerr, access = 'sequential', form = 'formatted', recl = blocksize, blocksize = blocksize, action = 'read', recordtype = 'stream')

if (ioerr <> 0)
  print *, 'ioerr=', ioerr
else
  open (52, file = outfile, status = 'unknown', iostat = ioerr, access = 'sequential', form = 'unformatted', recl = blocksize, action = 'write', recordtype = 'stream')

if (ioerr <> 0)
  print *, 'ioerr=', ioerr
   while (ioerr <> -1)
      read (51, '(Q,A)', iostat = ioerr) i, buffer[:i]
      print *, 'I value', i  (65540)
      if (ioerr is 0)
        print *, 'Block Size value infile', blocksize

        if (i > blocksize + 1)
          print *, 'I value grater than Blocksize1 ', i 
          return

        else
          write (52, iostat = ioerr) buffer[:i]
close (51)
close (52)
return
end

0 Kudos
2 Replies
mecej4
Honored Contributor III
280 Views

Please post the code. The fragments that you showed are not Fortran -- for example, "int" and "char" are not Fortran intrinsic types, and "<>" is not a Fortran operator. If you are using some preprocessor such as Ratfor, you should state so.

0 Kudos
Abby_P_
Beginner
280 Views

Oh yeah.. my bad!! .. We have a seperate preprocessor that we use.. Thanks !! 

 

0 Kudos
Reply