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 

Declaration type error and non-writable expression in read

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



Joined: 07 May 2018
Posts: 6

PostPosted: Fri May 17, 2019 6:55 am    Post subject: Declaration type error and non-writable expression in read Reply with quote

Dear all, I need help in resolving the following errors. I have selected part of the code affected as follow:
Line 1: error 452 - Unknown or missing type declaration attribute specification after ','
Line 2: error 566 - '*' must be preceded by an operand
Line 38: error 304 - Non-writable expression in READ statement
Line 38: error 52 - Compilation abandoned

Thank you
Code:
CHARACTER *12,FILE2,FILE3,FILE4,FILE5,FILE8,FILE9
            DIMENSION Z(*,*),GCAL(*,*),GOBS(*,*),DCZ(*,*),ERR(*,*),ZZ(*,*)
C        REAL NOY,NOX,DY,DX,SD,ALPHA,ZLT,GOBS,N,Z,GCAL
C        INTEGER I,J,K
       
          WRITE(*,*)'INPUT FILE NAME ?'
          READ(*,3040)FILE2
          WRITE(*,*)'OUTPUT FILE NAME ?'
          READ(*,3040)FILE8
          WRITE(*,*) 'OUTPUT FILE NAME FOR OBSERVED GRAVITY ANOMALY MAP
    &       SPECIFY .GRD EXTENSION.'
          READ(*,3040)FILE4
          WRITE(*,*) 'OUTPUT FILE NAME FOR CALCULATED GRAVITY ANOMALY
     &       MAP SPECIFY .GRD EXTENSION.'
          READ(*,3040)FILE5
          WRITE(*,*) 'OUTPUT FILE NAME FOR XY PLAN VIEW OF BASEMENT
     &       RELIEF SPECIFY .GRD EXTENSION.'
          READ(*,3040) FILE3
          WRITE(*,*) 'OUTPUT FILE NAME FOR 3-D VIEW OF BASEMENT RELIEF
     &      SPECIFY .GRD EXTENSION.'
          READ(*,3040) FILE9
C       Unit=2 is now changed to unit=8.
          OPEN(UNIT=8,FILE=FILE8,STATUS='UNKNOWN')
          OPEN(UNIT=5,FILE=FILE2,STATUS='UNKNOWN')
          OPEN(UNIT=7,FILE=FILE4,STATUS='UNKNOWN')
          OPEN(UNIT=9,FILE=FILE9,STATUS='UNKNOWN')
          OPEN(UNIT=6,FILE=FILE3,STATUS='UNKNOWN')
C        next OPEN statement is a repetition of FILE8 above            
C         OPEN(UNIT=2,FILE=FILE8,STATUS='UNKNOWN')
          OPEN(UNIT=27,FILE=FILE5,STATUS='UNKNOWN')
          READ(5,*) NY,NX
          READ(5,*) DY,DX
          READ(5,*) SD,A
          READ(5,*) N
          READ(5,*) ZLT
          DO 850 I=1,NY
          READ(5,*)(GOBS(K,I),K=1,NX)
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1124

PostPosted: Fri May 17, 2019 9:22 am    Post subject: Reply with quote

The first line contains an inappropriate ',' before 'FILE1'. The second line contains more leading blanks than needed, and extends beyond column 72.

You can use '*' in declaration statements only for subprogram dummy arguments. You cannot use '*' in line-2 unless the variables in that line have appeared as dummy arguments in a SUBROUTINE or FUNCTION declaration.

It is better to post the whole source. When you post a section, the line numbers for the section no longer match the line numbers in the source file, and the compiler error messages become impossible to reference.

It is not a good idea to use unit numbers 1-9 for external files.
Back to top
View user's profile Send private message
geomarine



Joined: 07 May 2018
Posts: 6

PostPosted: Fri May 17, 2019 10:12 am    Post subject: Reply with quote

Thank you for the comments. Due to length of the code I have it here
https://drive.google.com/open?id=1CQlajRZhT3fsSRu3VU7_eCuIyGErsHo4
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1124

PostPosted: Fri May 17, 2019 11:42 am    Post subject: Reply with quote

The code posted by you at Dropbox is not valid Fortran source.

1. Replace tab characters (Ascii 9) by the appropriate number of spaces and ensure that the modified source code follows Fortran fixed format requirements (statements in cols. 7 to 72, continuation mark in col.6, etc.)

2. Replace CHARACTER on line-28 by CHARACTER*12, or whatever is the expected longest string length, as you did in #1. Without the '*12', the length of the variables is just 1 character, which is definitely insufficient for file names.

3. Replace the array extents '(*,*)' by explicit sizes that are large enough to process the input data. You may have to examine the input data to find out how large. A hint is to try NX and NY large enough, but these are not issues that can be dealt with by people other than the program authors and users.

4. You will be better off if you open existing input files with STATUS='OLD' than with STATUS='UNKNOWN'


Last edited by mecej4 on Sat May 18, 2019 9:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
geomarine



Joined: 07 May 2018
Posts: 6

PostPosted: Fri May 17, 2019 5:00 pm    Post subject: Reply with quote

Thank you for the extensive review. I have been able to compile the code.
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