Page 1 of 1

how to set the ifil for the 2uvobc?

Posted: Tue Mar 01, 2016 11:15 pm
by Sou
HI,
I applied a daily river discharge file to my model. my time step is 1min. I asked the program to read the file daily.
I have applied this code but it seems the problem is in "ifil" and/or "iunit. here is the what the computer complains about:
Fortran runtime error: Cannot read from file opened for WRITE

here are my settings:


This is my setting:
!6. Model I/O file properties
!----------------------------
!
!6.1 Input
!---------
!---model grid
modfiles(io_modgrd,1,1)%status = 'N'
modfiles(io_modgrd,1,1)%form = 'A'
modfiles(io_modgrd,1,1)%filename = 'DATA/bathyERIEgrid.dat'

!---open boundary conditions (2-D)
modfiles(io_2uvobc,1:2,1)%status = 'N'
modfiles(io_2uvobc,1:2,1)%form = 'A'
modfiles(io_2uvobc,2,1)%filename = 'DATA/discharge.csv'
modfiles(io_2uvobc,2,1)%tlims = (/0,int_undef,1440/)

!---open boundary conditions (3-D)
modfiles(io_3uvobc,2,1)%status = 'N'

!
!6.2 Output
!----------
!

IF (ciffiles(icif_model)%status.EQ.'W') THEN
! ---model grid
modfiles(io_modgrd,1,2)%status = 'W'
modfiles(io_modgrd,1,2)%form = 'U'
! ---open boundary conditions (2-D)
modfiles(io_2uvobc,1:2,2)%status = 'W'
modfiles(io_2uvobc,1:2,2)%form = 'U'
! ---open boundary conditions (3-D)
modfiles(io_3uvobc,1:2,2)%status = 'W'
modfiles(io_3uvobc,1:2,2)%form = 'A'

ENDIF
.
.
.
.
!
!4. Open boundary locations
!--------------------------
!

!---river mouth
!DETROIT:(6km)
iobv(1)=15
jobv(1)=44

iobv(2)=16
jobv(2)=45

iobv(3)=17
jobv(3)=45

!NIAGARA:(600m)
iobv(4) = 192
jobv(4) = 86
.
.
.
IF (modfiles(io_2uvobc,2,1)%iostat.EQ.0) THEN
CALL open_filepars(modfiles(io_2uvobc,2,1))
iunit = modfiles(io_2uvobc,2,1)%iunit
modfiles(io_2uvobc,2,1)%iostat = 1
READ (iunit,*)
GOTO 1000
ENDIF

ciodatetime = CStartDateTime

!2. Read data
!------------
!

READ(iunit,*) iodatetime(1),iodatetime(2),iodatetime(3),qdis1,dettemp,qdis2,niagtemp

width = 2000.0
data2d(1,3) = qdis1/width
data2d(2,3) = qdis1/width
data2d(3,3) = qdis1/width
data2d(1,4) = qdis2/width

!write(*,*) qdis1,qdis2,data2d(1,3),data2d(2,3),data2d(3,3),data2d(1,4)

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

!.






here are the rest of 2uvobc settings:

.
.
.


SELECT CASE (iddesc)

CASE (io_3uvobc,io_salobc)

noprofsd = 2
iprofobv(1:nobv,1) = (/1,1,1,2/)
indexprof(1:2,2) = (/1,2/)
END SELECT
.
.
.
!---type of conditions at U-open boundaries
!ityp2dobu = 6; iloczobu = 1

!---type of conditions at V-open boundaries
ityp2dobv(1:nobv) = 4; iloczobv = 1

!---type and form of output data

no2dobc(2) = 4
index2dobc(1:4,2) = (/1,2,3,4/)

iobc2dtype(2)= 3


I need to know which part causes the problem


Thanks
Sue

Re: how to set the ifil for the 2uvobc?

Posted: Wed Mar 09, 2016 7:46 am
by Katrijn
Dear Sou,

I don't use the modfiles to read the discharges in my file, I open the file directly.


Here's my code, the data are stored in rivers.loc file. don't forget the USE statement

USE inout_routines, ONLY: close_file, close_filepars, open_file, open_filepars

CALL open_file(iunit,'rivers.loc','IN','A')
READ (iunit,'(/)')
l_310: DO l=1,norivs
READ (iunit,9002) cnode, i, j, dischargedry, dischargerainy
SELECT CASE (runtitle(7:8))
CASE ('vd')
discharge = dischargedry
CASE ('vr')
discharge = dischargerainy
END SELECT
IF (cnode.EQ.'U') THEN
ii = ii + 1
data2d(ii,1) = discharge/widthu
ELSE
jj = jj + 1
data2d(nrvbu+jj,1) = discharge/widthv
ENDIF
END DO l_310
CALL close_file(iunit,'A')

Please let me know if this is the answer you were looking for?

KAtrijn

Re: how to set the ifil for the 2uvobc?

Posted: Tue Mar 15, 2016 11:34 pm
by Sou
Thank you, now could you please help me in setting the reading data time? I want to read it daily and my time step is 60 sec.
What's wrong with this part of code?(I didn't include the whole code)


!---open boundary conditions (2-D)
modfiles(io_2uvobc,1:2,1)%status = 'N'
modfiles(io_2uvobc,1,1)%tlims = (/0,int_undef,1440/)
.
.
.
.
.


!*Local variables
!
INTEGER :: year,month,day, iunit
REAL :: width,qdis1,qdis2,detroitin,watertempdet,niagoutflow
INTEGER, DIMENSION(7) :: iodatetime

procname(pglev+1) = 'usrdef_2dobc_data'
CALL log_timer_in()

IF (modfiles(io_2uvobc,2,1)%iostat.EQ.0) THEN
modfiles(io_2uvobc,2,1)%iostat = 1
GOTO 1000
ENDIF

ciodatetime = CStartDateTime


!---read data
CALL open_file(iunit,'DATA/discharge.dat','IN','A')

READ (iunit,*)
READ (iunit,*) year,month,day, detroitin,watertempdet,niagoutflow

qdis1 = detroitin
qdis2 = niagoutflow

width = 2000.0

!Detroit is 6000m wide
data2d(1:nobv-1,1) = qdis1/width

!Niagara is 600m wide
data2d(nobv,1) = -qdis2/(width*0.33)

print*, nodat, data2d

CALL close_file(iunit,'A')

1000 CALL log_timer_out()


RETURN
END SUBROUTINE usrdef_2dobc_data

Re: how to set the ifil for the 2uvobc?

Posted: Sat Jan 23, 2021 1:07 pm
by danielperez
good good







https://comprarpormayor . cl /46-despedida-de-soltera