Silverfrost Forums

Welcome to our forums

Declaration type error and non-writable expression in read

17 May 2019 5:55 #23599

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

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)
17 May 2019 8:22 #23600

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.

17 May 2019 9:12 #23601

Thank you for the comments. Due to length of the code I have it here https://drive.google.com/open?id=1CQlajRZhT3fsSRu3VU7_eCuIyGErsHo4

17 May 2019 10:42 (Edited: 18 May 2019 8:43) #23602

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'

17 May 2019 4:00 #23603

Thank you for the extensive review. I have been able to compile the code.

Please login to reply.