LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-04-2016, 12:02 AM   #1
sarasari
LQ Newbie
 
Registered: Feb 2014
Posts: 18

Rep: Reputation: Disabled
Fortran runtime error: Cannot read from file opened for WRITE


Hi Friends,
What is the problem in my statements?


!6. Model I/O file properties
!----------------------------
!
!6.1 Input
!---open boundary conditions (2-D)
modfiles(io_2uvobc,1:2,1)%status = 'N'
modfiles(io_2uvobc,2,1)%form = 'A'
modfiles(io_2uvobc,2,1)%filename = 'DATA/discharge.csv'
modfiles(io_2uvobc,2,1)%tlims = (/0,int_undef,1440/)

!6.2 output

! ---open boundary conditions (2-D)
modfiles(io_2uvobc,1:2,2)%status = 'W'
modfiles(io_2uvobc,1:2,2)%form = 'U'

!
!1. Open file
!------------
!

IF (modfiles(io_2uvobc,ifil,1)%iostat.EQ.0) THEN
CALL open_filepars(modfiles(io_2uvobc,ifil,1))

iunit = modfiles(io_2uvobc,ifil,1)%iunit
modfiles(io_2uvobc,ifil,1)%iostat = 1
READ (iunit,*)
GOTO 1000
ENDIF

ciodatetime = CStartDateTime

!2. Read data
!------------
!
READ(iunit,*) qdis1,qdis2

!---close file
CALL close_filepars(modfiles(io_2uvobc,ifil,1))


I try to add a river discharge file to my program but when I run it, this error comes up:
Fortran runtime error: Cannot read from file opened for WRITE



Thank you,
Sara
 
Old 03-04-2016, 12:13 AM   #2
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 580

Rep: Reputation: 125Reputation: 125
It is a long time since I looked at Fortran and you don't specify the compiler. Do you need to open READWRITE?
 
Old 03-04-2016, 01:42 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,817

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
seeing as code tags were not used

my first guess is the formatting and tabs
 
Old 03-04-2016, 09:01 PM   #4
sarasari
LQ Newbie
 
Registered: Feb 2014
Posts: 18

Original Poster
Rep: Reputation: Disabled
this is the rest of the code that I didn't put in my first post:


1000 CALL log_timer_out()
RETURN
END SUBROUTINE


my compiler is gfortran and the compiling is fine apparently.

John, could you please explain more?
Thanks from both of you,
Sara
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran runtime error: Bad integer for item 1 in list input dstephens54 Linux - Newbie 11 01-26-2016 08:15 PM
[SOLVED] Valgrind reports invalid read/write when C++11-Fortran interoperate when using LAPACK ejspeiro Programming 4 05-19-2014 11:54 AM
[SOLVED] netCDF Fortran 90 Interface (read/write) AQmodeller Programming 1 10-06-2012 04:22 AM
Fortran Runtime error: bad real number in item 1 of list input physicslad78 Linux - Newbie 3 02-14-2011 04:23 PM
Fortran runtime error mkrems Programming 3 06-24-2008 04:42 PM


All times are GMT -5. The time now is 03:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration