soccer jersey forums.silverfrost.com :: View topic - Case distinction, file creation and modification
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 

Case distinction, file creation and modification

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



Joined: 17 Nov 2011
Posts: 15

PostPosted: Wed Nov 23, 2011 10:18 am    Post subject: Case distinction, file creation and modification Reply with quote

Hello guys,

I would like to check if a file exists, if it is the right calculation case. If it does not exist, it is created und results are stored in there.
This didnt work correctly, at least not when the file already exists.
Here is the code, I hope someone can help me:

Code:

      fexist = .FALSE.
      fright = .FALSE.
      fscat = .TRUE.
     
      IF (fscat) THEN
        INQUIRE (FILE = 'mie_scat_int.asc', EXIST=fexist)
        IF (fexist) THEN
          WRITE(*,*) 'mie_scat_int.asc already exists'
          OPEN(20, FILE = 'mie_scat_int.asc', STATUS = 'UNKNOWN')
          READ (20,*) dummy1
          READ (20,*) dummy2
          READ (20,*) dummy3
          CLOSE (UNIT=20)
          IF ((dummy1==alfamax).AND.(dummy2==alfares).AND.(dummy3==nn)) THEN
            fright = .TRUE.
            WRITE(*,*) 'mie file fits the present analysis'
          ELSE
            fright = .FALSE.
          END IF
        ENDIF
       
        IF (fexist.AND.fright) THEN
          WRITE (*,*) 'mie_scat_int.asc is read'
          OPEN(20, FILE = 'mie_scat_int.asc', STATUS = 'UNKNOWN')
          READ (20,*) dummy1
          READ (20,*) dummy2
          READ (20,*) dummy3
          DO jj = 1,alfares
            DO ii = 1,nn
               READ (20,*) alfa(ii,jj), theta(ii), i1(ii,jj)
            END DO
          END DO
          CLOSE (UNIT=20)
        ELSE
          WRITE (*,*) 'mie_scat_int.asc is created'
          OPEN(20, FILE = 'mie_scat_int.asc', STATUS = 'UNKNOWN')
          WRITE (20,*) alfamax
          WRITE (20,*) alfares
          WRITE (20,*) nn
          DO ii = 1, nn
             theta(ii) = (ii-1)*dang
          END DO
Back to top
View user's profile Send private message
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Wed Nov 23, 2011 6:40 pm    Post subject: Reply with quote

Your INQUIRE implies, that your FTN95 exe is executed from within the directory of the .asc file. Otherwise add the complete path, best like 'd:\...\mie_scat_int.asc'
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2593
Location: Sydney

PostPosted: Thu Nov 24, 2011 1:56 am    Post subject: Reply with quote

Miriam,

I'd recommend that you include IOSTAT=error_code in each I/O statement and manage any non-zero error reports.

Another problem could be your access rights, as you may only have read access. This might be tested by including ACTION='READ' or STATUS='READONLY'.

Only a minor point, use a character variable to store the file name. This can make the code more robust.

You have gone through a range of testing the file accessibility. I'd review the order so you can report the likely access states that could exist.

Having just started to use Windows 7, I'm learning how to access files, in restricted areas. Previously I stored configuration files, like sdbg.ini, in c:\windows or c:\ but am now finding these files have restricted access.
I am looking for a more robust approach for these files in Windows 7.

John
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 -> General 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