Silverfrost Forums

Welcome to our forums

openrw@ routine doesn't return zero

24 Feb 2012 9:16 #9685

Hi,

I am a pretty new user in Fortran and I am trying to use openrw@ routine as follows and it doesn't return zero even though it creates the file. Am I doing something wrong?

Program check implicit none integer handle, error_code character (len=40) dosya1 call openrw@ ('dosya1',handle, error_code) if (error_code.eq.0) then write(,) 'Operation was successfull' else write(,) 'Operation was NOT successfull' end if end

25 Feb 2012 1:03 #9687

You have declared a character variable dosya1, but then used a character constant 'dosya1'. Also, check the kind of handle and error_code. My open routine is:

      subroutine open_salford_io ( file_name, lunit, error_code )
!
!  File I/O using Salford I/O library
!
      character file_name*(*)
      integer*2 lunit, error_code
!
      lunit = -1
      CALL openrw@ (file_name, lunit, error_code)
      write ( *,*) 'OPEN : File ', trim (file_name),' : Handle =', lunit, ' : Error code =', error_code
         if (error_code /= 0) call doserr@ (error_code)
!
      end subroutine open_salford_io
27 Feb 2012 3:51 #9721

I changed the constant to variable and I defined handle and error_code as integer kind 2 which solved the problem. Thanks a lot.

Quoted from JohnCampbell You have declared a character variable dosya1, but then used a character constant 'dosya1'. Also, check the kind of handle and error_code. My open routine is:

      subroutine open_salford_io ( file_name, lunit, error_code )
!
!  File I/O using Salford I/O library
!
      character file_name*(*)
      integer*2 lunit, error_code
!
      lunit = -1
      CALL openrw@ (file_name, lunit, error_code)
      write ( *,*) 'OPEN : File ', trim (file_name),' : Handle =', lunit, ' : Error code =', error_code
         if (error_code /= 0) call doserr@ (error_code)
!
      end subroutine open_salford_io
Please login to reply.