Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7560023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:47:26+00:00 2026-05-30T12:47:26+00:00

I am currently working on a FORTRAN program that is to read an input

  • 0

I am currently working on a FORTRAN program that is to read an input file. Once reading the input file, the first line of the file contains an integer representing the amount of matrices in the file. The second line contains how many rows and columns each matrix has. the rest of the lines contain the matrices themselves. The program will read in each matrix and write it to an output file as well as calculate the sum of all the matrices. When reading in the matrix data I keep receiving these two errors

Code: READ(1,*,END=99)(DIMENSIONS(I), I=1,2)

Error: Constants and expressions are invalid in read-only I/O lists.

Error2: This label is undefined [99]

My code is:

  *START OF CODE
  PROGRAM MAIN

  *DECLARATIONS
  INTEGER EXISTS, DONE, NUM, DIMENSIONS*2, USED
  INTEGER I,J, TEMPMAT(10,10), SUM(10,10),OVER
  CHARACTER INNAME*30, OUTNAME*30
  *INITIALIZATIONS
  INNAME='NULL.DOC'
  EXISTS=0
  DONE=0
  I=0
  J=0
  OVER=0
  USED=0
  NUM=1
  *FORMATS
  5     FORMAT(' ','SUM OF 'I2,X,'MATRICIES')
  *MAIN CODE
  *DO (0)

  *DO WHILE(1) INPUT NAME !EXIST AND != QUIT
   DO WHILE(EXISTS.EQ.0.OR.INNAME.EQ.'QUIT'.OR.INNAME.EQ.'Q')
  *PROMPT FOR NAME OF FILE AND INPUT
  PRINT *,'PLEASE INPUT A FILE NAME INCLUDING AN EXTENSION'
  PRINT *,'ENTER QUIT OR Q TO EXIT'
  READ (*,*) INNAME

  *TEST FOR FILE
  INQUIRE(FILE=INNAME, EXIST=EXISTS)
  PRINT *, 'INPUT FILE EXSISTS'
  *IF EXIST=FALSE, DISPLAY MESSAGE 
  IF(.NOT.EXISTS) THEN
  PRINT *,'FILE DOES NOT EXIST, PLEASE TRY AGAIN'

  *ELSE EXIST=TRUE, OPEN (UNIT=1)
  ELSE 
  OPEN(UNIT=1, FILE=INNAME, STATUS='OLD')
  END IF
  *END DO(1)      
  END DO
  *ASK CHOICES FOR OUTPUT
  PRINT *,'PLEASE ENTER A NAME FOR AN OUTPUT FILE W/ EXTENSION'
  PRINT *,'ENTER QUIT OR Q TO EXIT'
  READ(*,*)OUTNAME

  IF(OUTNAME.EQ.'Q'.OR.OUTNAME.EQ.'QUIT')THEN
    DONE=1
  END IF
  *CHECK IF DONE (IF 1)
  IF(DONE.EQ.0)THEN
  *OPEN THE OUTPUT FILE DO(2)
        DO WHILE(USED.EQ.0)
            INQUIRE(FILE=OUTNAME,EXIST=EXISTS)
            PRINT *, 'OUTPUT FILE EXSITS'
  *OPEN IF FOR IF FILE ALREADY EXISTS
            IF(EXISTS.EQ.1)THEN
                DO WHILE(OVER.LT.1.OR.OVER.GT.2)
                PRINT *,'FILE ALREADY EXISTS. DO YOU WANT TO OVERWRITE?'
                PRINT *,'SELECT 1 FOR YES OR 2 FOR NO'
                SELECT CASE(OVER)
                CASE(1)
                    OPEN(UNIT=2,FILE=OUTNAME,STATUS='OLD')
                    USED=1            
                CASE(2)
  *DO NOTHING  
                CASE DEFAULT
                    PRINT *, 'THAT WAS NOT EVEN AN VALID INPUT, TRY AGAIN'
  *END SELECT
                END SELECT 
  *END IF FOR IF FILE ALREADY EXISTS AMD OPEN IF DID NOT EXIST, END DO(2)
                END DO
            END IF
            OPEN(UNIT=2,FILE=OUTNAME,STATUS='NEW')                   
  *READ IN 1 INTEGER (MAXIMUM VALUE OF 10) FOR # OF MATRICIES IN FILE
            READ(1,*) NUM
            PRINT *, 'THE NUMBER OF MATRICIES: ', NUM
  *READ IN 2 INTEGERS, 1=ROWS, 2=COLUMNS MAX OF 10 FOR EACH
            READ(1,*,END=99)(DIMENSIONS(I), I=1,2)
  *DO WHILE MORE MATRICIES EXIST DO(3)
            DO WHILE(NUM.GT.0)
  *READ THE MATRIX IN DO(4)
                DO J=1,DIMENSIONS(1)
                    READ(1,*,END=99)(TEMPMAT(J,I),I=1,DIMENSIONS(2))
  *END DO (4)
                END DO   
  *ADD MATRIX TO SUM MATRIX
  *DO(5)(6)
                DO J=1,10
                    DO I=1,10
                        SUM(J,I)=SUM(J,I)+TEMPMAT(J,I)
  *END DO(5)(6) 
                    END DO
                END DO
  *PRINT CURRENT MATRIX TO FILE W/ HEADER 'MATRIX X'
  *DO(6)
                DO J=1,DIMENSIONS(1)
                    WRITE(2,*)(TEMPMAT(J,I),I=1,DIMENSIONS(2))
  *END DO(6)
                END DO  
  *WRITE HEADING 'SUM OF ALL N MATRICES'
                WRITE(2,*)5,NUM
                NUM=NUM-1
  *END DO(3)
            END DO
  *END DO(0)
  END DO
  *PRINT SUM OF MATRICES
  *DO(7)
  DO J=1,10
    WRITE(2,*)(SUM(J,I),I=1,10)
  *END DO(7)
  END DO 
  END IF
  *STOP
  STOP
  *END
  END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:47:27+00:00Added an answer on May 30, 2026 at 12:47 pm

    Dimensions is declared in a peculiar way. Try dimensions (2). Maybe this has something to do with it since the line with the error message is the first to use dimensions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on program that must read data from a XML stream
im currently working in a simple program that implements plugins whith dll libraries (using
Am currently working on an application that requires users to submit posts and comments
I'm currently working on creating a new C# project that needs to interact with
Am currently working on a site that uses a lot of cfwindow objects and
Im currently working on a project that requires the following. I need to be
Im currently working on an RMI client that will talk to an RMI server
Im currently working on a c# project that uses another .net library. This library
Were currently working on a script that reads the current users information from out
Currently working on a snippet to input variables in which a user changes a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.