salinity,temprature open boundary

For questions about setting up the basic hydrodynamics. Bathymetry inclusion, tidal boundary conditions, river inclusion and so on..

Moderator: Saheedpp

pooran
Posts: 12
Joined: Fri Nov 06, 2015 5:26 pm
Full name: pooran khedri

salinity,temprature open boundary

Post by pooran »

Hi everyone,
I'm running a model for the Persian Gulf.Now I'm trying to set the open boundary conditions.The model has two open boundaries,the eastern boundary is strait of Hormuz and another one is a river boundary at the North.
I want to set salinity,temprature and river discharge in open boundaries by some external data files (daily average time series).
constant river discharge (constant salinity or tempratuer open boundary)was defined in all default testcases.
I want to set variable data ( salinity,temprature,river discharge ) for open boundaries.
Could you please help me??
Thanks.
Katrijn
Posts: 87
Joined: Fri Nov 29, 2013 3:04 pm
Full name: Katrijn Baetens

Re: salinity,temprature open boundary

Post by Katrijn »

Dear Pooran,

How to include open boundary conditions was explained in another of your forum posts, so I'm not going to repeat the answer here unless something was not clear, than ask again.

I also am going to replace this post, because it is not a bug submission. I am going to move it to basic model set up.

I modified the bohai test case so that it includes three rivers. You can find the modified Usrdef_Model.f90 and Usrdef_Time_Series.f90 files by clicking https://share.naturalsciences.be/d/5c765b8fff/
The password is: Howtoincludeariver
The Usrdef_Time_Series.f90 file is just modified to make the output easier. The defruns file should just contain bohai,,

In the Usrdef_Model.f90 the code you need for including a river (discharge and salinity) is marked between the following comments
!KB river start
!KB river end
So all you need to do is copy paste it into your code

Hope this helps,
Katrijn
Katrijn
Posts: 87
Joined: Fri Nov 29, 2013 3:04 pm
Full name: Katrijn Baetens

Re: salinity,temprature open boundary

Post by Katrijn »

PS: include temperature at the rivers is similar as how to include salinity. try to look up a test case with temperature if you want to know how to include temp
Sou
Posts: 51
Joined: Wed Sep 03, 2014 7:46 pm
Full name: Soudeh Afsharian

Re: salinity,temprature open boundary

Post by Sou »

Thank you Katrijin, but your settings still contain a fixed discharge and not daily discharge from an external file, we have problem in this part not a fixed discharge (rhone test case has the settings for a fixed discharge)what we need is an example of how asking the model to read a daily dscharge!
I did these settings, although it compiles well but doesn't go through the run process....

SUBROUTINE usrdef_2dobc_data(ifil,ciodatetime,data2d,nodat,novars)

USE depths
USE obconds
USE grid
USE gridpars
USE iopars
USE syspars
USE timepars
USE inout_routines, ONLY: close_filepars, open_filepars, close_file, open_file
USE time_routines, ONLY: log_timer_in, log_timer_out, convert_date


IMPLICIT NONE

!
!*Arguments
!
CHARACTER (LEN=lentime), INTENT(INOUT) :: ciodatetime
INTEGER, INTENT(IN) :: ifil, nodat, novars
REAL, INTENT(INOUT), DIMENSION(nodat,novars) :: data2d

!*Local variables
!
INTEGER :: iunit
REAL :: width,qdis,detroit

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


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

CALL open_file(iunit,'DATA/discharge3.csv','IN','A')

READ (iunit,*)
iodatetime(4:7) = 0
READ (iunit,*) iodatetime(1:3),detroit


ciodatetime = convert_date(iodatetime)


!ciodatetime = CStartDateTime

qdis = detroit

width = 2000.0

!Detroit is 10km wide
data2d(1:nobv-1,1) = qdis/(5*width)

!1000 CALL log_timer_out()
!RETURN



!99 modfiles(io_2uvobc,2,1)%iostat = 3
CALL log_timer_out()


RETURN
END SUBROUTINE usrdef_2dobc_data



and this is what I get while I try to run it:

At line 1062 of file Usrdef_Model.f90 (unit = 8, file = 'DATA/discharge3.csv')
Fortran runtime error: End of file


I have attached the file.
Thanks again,
Sue

P.S. I use version 2.4.1 and gfortran compiler.
Attachments
discharge3.xlsx
Daily River discharge
(13.92 KiB) Downloaded 1361 times
Katrijn
Posts: 87
Joined: Fri Nov 29, 2013 3:04 pm
Full name: Katrijn Baetens

Re: salinity,temprature open boundary

Post by Katrijn »

Hi Soudeh,

Since this is the only part of the code you are sendin, I assume everything else was coded correctly.

Below the code I modified (if I understand it correctly).

Hope it helps, let me know if there are bugs remaining

Katrijn

SUBROUTINE usrdef_2dobc_data(ifil,ciodatetime,data2d,nodat,novars)

USE depths
USE obconds
USE grid
USE gridpars
USE iopars
USE syspars
USE timepars
USE inout_routines, ONLY: close_filepars, open_filepars, close_file, open_file
USE time_routines, ONLY: log_timer_in, log_timer_out, convert_date


IMPLICIT NONE

!
!*Arguments
!
CHARACTER (LEN=lentime), INTENT(INOUT) :: ciodatetime
INTEGER, INTENT(IN) :: ifil, nodat, novars
REAL, INTENT(INOUT), DIMENSION(nodat,novars) :: data2d

!*Local variables
!
INTEGER :: iunit
REAL :: width,qdis,detroit

INTEGER, DIMENSION(7) :: iodatetime

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

!KBaetens: you definitely need this if statement as it switches on the status of the open boundary input
!KBaetens: you open the file here because you are not going to open it each time step, once is enough.

IF (modfiles(io_2uvobc,2,1)%iostat.EQ.0) THEN
modfiles(io_2uvobc,2,1)%iostat = 1
CALL open_file(iunit,'DATA/discharge3.csv','IN','A')
READ (iunit,*)
GOTO 1000
ENDIF


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


iodatetime(4:7) = 0
READ (iunit,*) iodatetime(1:3),detroit!

ciodatetime = convert_date(iodatetime)


!ciodatetime = CStartDateTime

qdis = detroit

width = 2000.0

!Detroit is 10km wide
!KBaetens: here I am not completely following why you put 1:nobv-1, I would just put ":", you don't want discharge at the open boundaries but at the rivers.

!data2d(1:nobv-1,1) = qdis/(5*width)
data2d(:,1) = qdis/(5*width)
1000 CALL log_timer_out()
RETURN



!99 modfiles(io_2uvobc,2,1)%iostat = 3
!KBaetens I deleted an extra log_timer_out and a RETURN statements
END SUBROUTINE usrdef_2dobc_data
Sou
Posts: 51
Joined: Wed Sep 03, 2014 7:46 pm
Full name: Soudeh Afsharian

Re: salinity,temprature open boundary

Post by Sou »

Thank you very much Katrijin for your reply. I appreciate your efforts in answering the questions. my only concern is the time, and that's because I ask a question here and after long time struggling and solving the problem then the reply comes. however, I understand that you and your group do your best to keep this forum active and I'm very thankful.

about the variable discharge I did these settings as I found %tlims is the part which set the time reading of a file. but it seems if I ask the model to read the external file independently ( I mean by using : CALL open_file(iunit,'DATA/discharge3.csv','IN','A')), and not through modfiles(io_2uvobc,1:2,1)%filename = 'DATA/discharge4.csv', then
modfiles(io_2uvobc,1,1)%tlims = (/0,int_undef,5760/) !24-hrs is not applicable here.

here is my rest of setting:

!---grid dimensions

nc = 194; nr = 88; nz = 25

!---number of open sea boundaries
nosbu = 0; nosbv = 0

!---number of river open boundaries at V-nodes
nrvbv = 6


!---open boundary conditions (2-D)
!River discharge
modfiles(io_2uvobc,1:2,1)%status = 'N'
!modfiles(io_2uvobc,1:2,1)%filename = 'DATA/discharge3.csv'
modfiles(io_2uvobc,1:2,1)%form = 'A'
! input reading every 24hrs (time step =15sec)>>>>>>>>>>>>>
modfiles(io_2uvobc,1,1)%tlims = (/0,int_undef,5760/) !24-hrs




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

!---river mouth


!DETROIT:(6km)

iobv(1)=15
jobv(1)=44

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

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

iobv(4)=18
jobv(4)=40

iobv(5)=19
jobv(5)=40

!Niagara:(600 m)
iobv(6) = 192
jobv(6) = 86


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



!---type and form of output data

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



!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
noprofsd = 1
iprofobv(nobv,1) = 1
indexprof(1,2) = 1
!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


and the rest is what you have told me to do.

I dont get why model doesnt considet the
! input reading every 24hrs (time step =15sec)>>>>>>>>>>>>>
modfiles(io_2uvobc,1,1)%tlims = (/0,int_undef,5760/) !24-hrs
at all.

thank you,
Sue
Katrijn
Posts: 87
Joined: Fri Nov 29, 2013 3:04 pm
Full name: Katrijn Baetens

Re: salinity,temprature open boundary

Post by Katrijn »

Hi Soudeh,
Did you check if the date from the .cvs file is read correctly? Is it compatible with the CStartDateTime of your model set up?

Hope this helps,

Katrijn
Katrijn
Posts: 87
Joined: Fri Nov 29, 2013 3:04 pm
Full name: Katrijn Baetens

Re: salinity,temprature open boundary

Post by Katrijn »

PS:

Can you try to replace the following line of your code?
modfiles(io_2uvobc,1,1)%tlims = (/0,int_undef,5760/) !24-hrs

with

modfiles(io_2uvobc,2,1)%tlims = (/0,int_undef,5760/) !24-hrs

The value 1 denotes the file that creates the specifiers of the parameters, 2 denotes the values itself, it are off course the data you want to update and not the specifiers.

Regards,

Katrijn
Sou
Posts: 51
Joined: Wed Sep 03, 2014 7:46 pm
Full name: Soudeh Afsharian

Re: salinity,temprature open boundary

Post by Sou »

Hi Katrijin,
Thank you.
As I don't have any idea what ifil =1,2... is exactly, so I uses both

modfiles(io_2uvobc,1,1)%tlims = (/0,int_undef,5760/) !24-hrs
modfiles(io_2uvobc,2,1)%tlims = (/0,int_undef,5760/) !24-hrs


in my model.
Also, I substitute all modfiles(io_2uvobc,1:2,1) with modfiles(io_2uvobc,ifil,1).
The model runs but Doesn't consider the
PRINT*, ciodatetime, qdis code in my usrdef_model.f90 file.
I assume substituing 1 and 2 with ifil some how causes this problem and perhaps the model ignores SUBROUTINE usrdef_2dobc_data....
Any idea?
Thank you,

Sue
Attachments
my code.docx
usrdef-model.f90
(23.13 KiB) Downloaded 1384 times
Sou
Posts: 51
Joined: Wed Sep 03, 2014 7:46 pm
Full name: Soudeh Afsharian

Re: salinity,temprature open boundary

Post by Sou »

Katrijn wrote: Sun Jun 11, 2017 10:14 am Hi Soudeh,
Did you check if the date from the .cvs file is read correctly? Is it compatible with the CStartDateTime of your model set up?

Hope this helps,

Katrijn
Yes, it reads correctly but just the first line after the header!
Post Reply