forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

openrw@ routine doesn't return zero

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
onkr



Joined: 24 Feb 2012
Posts: 2

PostPosted: Fri Feb 24, 2012 10:16 pm    Post subject: openrw@ routine doesn't return zero Reply with quote

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
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 1774
Location: Sydney

PostPosted: Sat Feb 25, 2012 2:03 am    Post subject: Reply with quote

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:
Code:

      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
Back to top
View user's profile Send private message
onkr



Joined: 24 Feb 2012
Posts: 2

PostPosted: Mon Feb 27, 2012 4:51 pm    Post subject: Re: Reply with quote

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

JohnCampbell wrote:
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:
Code:

      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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group