Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

assignment should be modifieds program to read a file input of 255 characters or

ID: 3764464 • Letter: A

Question

assignment should be modifieds program to read a file input of 255 characters or less till the program runs. do not need to make another file to make this program work. Just make a blank one with a name for the program to grab and put into the program

exception: file name entered blank, then input might be from standard which is default input as it does .

program to read a file input of 255 characters untill the program runs

This is my assignment, not sure what my professor really is asking for,

but sure that this is not working when I attempt to excute.

Your assignment is to add optional file input and output functionality to the utility program ExtractDesign.

The functionality must remain the same with the exception that input or output may be optionally redirected to files and your program shall conform to the Homework Submission Requirements.

The program shall attempt to read an input file name until the file opens successfully.

(Microsoft states that the maximum length of Windows file names is 255 characters.)

An exception is that if the file name entered is blank, then input shall be from standard (default) input as it does now.

The program shall attempt to read an output file name until the file opens successfully.

An exception is that if the file name entered is blank, then output shall be to standard (default) output as it does now.

It is fortran

Explanation / Answer

module read_file_module

   implicit none

contains

   subroutine read_file (UnitNum, FileName, NumRows, NumCols, Array )

      integer, intent (in) :: UnitNum
      character (len=*), intent (in) :: FileName
      integer, intent (in) :: NumRows, NumCols
      real, dimension (1:NumRows, 1:NumCols), intent (out) :: Array

      character (len=300) :: line
      integer :: i, j

      open (unit=UnitNum, file=FileName, status='old', action='read' )

      ReadComments: do
         read (UnitNum, '(A)') line
         if (line (1:1) /= "#") exit ReadComments
      end do ReadComments

      backspace (UnitNum)

      do i=1, NumRows
         read (UnitNum, *) (Array (i, j), j=1,NumCols)
      end do

      close (UnitNum)

      return

   end subroutine read_file

end module read_file_module