Commit 02f2f632 authored by kbk's avatar kbk
Browse files

support fo nutrient loading in rivers

parent 7418b137
!$Id: rivers.F90,v 1.6 2005-01-13 09:20:46 kbk Exp $
!$Id: rivers.F90,v 1.7 2005-09-23 11:27:43 kbk Exp $
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
......@@ -33,6 +33,11 @@
#ifndef NO_BAROCLINIC
use m3d, only: calc_salt,calc_temp
use variables_3d, only: hn,ssen,T,S
#endif
#ifdef GETM_BIO
use bio, only: bio_calc
use bio_var, only: numc
use variables_3d, only: cc3d
#endif
IMPLICIT NONE
!
......@@ -40,6 +45,9 @@
!
! !PUBLIC DATA MEMBERS:
public init_rivers, do_rivers, clean_rivers
#ifdef GETM_BIO
public init_rivers_bio
#endif
integer, public :: river_method=0,nriver=0,rriver=0
logical,public :: use_river_temp = .false.
logical,public :: use_river_salt = .false.
......@@ -54,6 +62,10 @@
REALTYPE, public,parameter :: temp_missing=-9999.0
REALTYPE, public,parameter :: salt_missing=-9999.0
integer, public, allocatable :: river_split(:)
#ifdef GETM_BIO
REALTYPE, public, allocatable :: river_bio(:,:)
REALTYPE, public, parameter :: bio_missing=-9999.0
#endif
!
! !PRIVATE DATA MEMBERS:
integer :: river_format=2
......@@ -67,7 +79,10 @@
! Original author(s): Karsten Bolding & Hans Burchard
!
! $Log: rivers.F90,v $
! Revision 1.6 2005-01-13 09:20:46 kbk
! Revision 1.7 2005-09-23 11:27:43 kbk
! support fo nutrient loading in rivers
!
! Revision 1.6 2005/01/13 09:20:46 kbk
! support for T and S specifications in rivers - Stips
!
! Revision 1.4 2003/10/14 10:05:54 kbk
......@@ -209,7 +224,7 @@
flow_fraction(n) = _ONE_/ARCD1
end if
else
! LEVEL3 'Outside: river# ',n
LEVEL3 'Outside: river# ',n
end if
end do
......@@ -282,6 +297,59 @@
end subroutine init_rivers
!EOC
#ifdef GETM_BIO
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: init_rivers_bio
!
! !INTERFACE:
subroutine init_rivers_bio()
!
! !DESCRIPTION:
! Allocates memory for storing the biological loads from rivers.
! The variable - river_bio - is initialised to - bio_missing.
!
! !USES:
IMPLICIT NONE
!
! !INPUT PARAMETERS:
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
! !REVISION HISTORY:
! See the log for the module
!
! !LOCAL VARIABLES:
integer :: rc
!EOP
!-------------------------------------------------------------------------
!BOC
#ifdef DEBUG
integer, save :: Ncall = 0
Ncall = Ncall+1
write(debug,*) 'init_rivers_bio() # ',Ncall
#endif
LEVEL1 'init_rivers_bio()'
allocate(river_bio(nriver,numc),stat=rc)
if (rc /= 0) stop 'rivers: Error allocating memory (river_bio)'
river_bio = bio_missing
#ifdef DEBUG
write(debug,*) 'Leaving init_rivers_bio()'
write(debug,*)
#endif
return
end subroutine init_rivers_bio
!EOC
#endif
!-----------------------------------------------------------------------
!BOP
!
......@@ -307,7 +375,7 @@
! See the log for the module
!
! !LOCAL VARIABLES:
integer :: i,j,k,n
integer :: i,j,k,m,n
REALTYPE :: rvol,height
REALTYPE :: svol,tvol,vol
!
......@@ -349,6 +417,18 @@
+ river_temp(n)*macro_height(n)) &
/ (H(i,j)+ssen(i,j)+macro_height(n))
end if
#ifdef GETM_BIO
if (bio_calc) then
do m=1,numc
if ( river_bio(n,m) .ne. bio_missing ) then
cc3d(m,i,j,1:kmax) = &
(cc3d(m,i,j,1:kmax)*(H(i,j)+ssen(i,j)) &
+ river_bio(n,m)*macro_height(n)) &
/ (H(i,j)+ssen(i,j)+macro_height(n))
end if
end do
end if
#endif
! Changes of total and layer height due to river inflow:
hn(i,j,1:kmax) = hn(i,j,1:kmax)/(H(i,j)+ssen(i,j)) &
*(H(i,j)+ssen(i,j)+macro_height(n))
......
!$Id: ncdf_rivers.F90,v 1.6 2005-05-04 11:45:29 kbk Exp $
!$Id: ncdf_rivers.F90,v 1.7 2005-09-23 11:27:43 kbk Exp $
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
......@@ -18,6 +18,11 @@
use rivers, only: ok,rriver,real_river_name,river_split
use rivers, only: temp_missing,salt_missing
use rivers, only: use_river_temp,use_river_salt,river_temp,river_salt
#ifdef GETM_BIO
use bio, only: bio_calc
use bio_var, only: numc,var_names
use rivers, only: river_bio
#endif
IMPLICIT NONE
!
private
......@@ -36,12 +41,19 @@
integer, allocatable :: r_salt(:)
integer, allocatable :: r_temp(:)
REAL_4B, allocatable :: river_times(:)
#ifdef GETM_BIO
integer, allocatable :: bio_id(:,:)
integer, allocatable :: r_bio(:,:)
#endif
!
! !REVISION HISTORY:
! Original author(s): Karsten Bolding & Hans Burchard
!
! $Log: ncdf_rivers.F90,v $
! Revision 1.6 2005-05-04 11:45:29 kbk
! Revision 1.7 2005-09-23 11:27:43 kbk
! support fo nutrient loading in rivers
!
! Revision 1.6 2005/05/04 11:45:29 kbk
! adding model time stamp on IO
!
! Revision 1.5 2005/01/13 09:20:47 kbk
......@@ -92,10 +104,11 @@
! See module for log.
!
! !LOCAL VARIABLES:
integer :: i,j,n
integer :: i,j,m,n
integer :: err
integer :: j1,s1,j2,s2
character(len=256) :: time_units
character(len=256) :: bio_name
!EOP
!-------------------------------------------------------------------------
include "netcdf.inc"
......@@ -120,6 +133,14 @@
allocate(temp_id(rriver),stat=err)
if (err /= 0) stop 'ncdf_river: Error allocating memory (temp_id)'
#ifdef GETM_BIO
allocate(r_bio(rriver,numc),stat=err)
if (err /= 0) stop 'ncdf_river: Error allocating memory (r_bio)'
allocate(bio_id(rriver,numc),stat=err)
if (err /= 0) stop 'ncdf_river: Error allocating memory (bio_id)'
bio_id = -1
#endif
err = nf_open(fn,NCNOWRIT,ncid)
if (err .ne. NF_NOERR) go to 10
......@@ -155,6 +176,19 @@
if (err .ne. NF_NOERR) go to 10
end if
end if
#ifdef GETM_BIO
do m=1,numc
bio_name=trim(real_river_name(n))//'_'//trim(var_names(m))
err = nf_inq_varid(ncid,trim(bio_name),bio_id(n,m))
if (err .ne. NF_NOERR) then
bio_id(n,m) = -1
end if
if ( bio_id(n,m) .ne. -1 ) then
LEVEL4 trim(real_river_name(n)),': ',trim(var_names(m))
end if
end do
#endif
end do
allocate(river_times(textr),stat=err)
......@@ -214,7 +248,7 @@
! See module for log.
!
! !LOCAL VARIABLES:
integer :: i,n,nn,ni,m,indx,err
integer :: i,j,n,nn,ni,m,indx,err
REALTYPE :: t
REAL_4B :: x(1)
logical, save :: first=.true.
......@@ -267,12 +301,24 @@
river_temp(ni+m-1) = x(1)
end do
end if
#ifdef GETM_BIO
do j=1,numc
if (bio_id(nn,j) .gt. 0) then
err = nf_get_vara_real(ncid,bio_id(nn,j),start,edges,x)
if (err .ne. NF_NOERR) go to 10
do m=1,river_split(ni)
river_bio(ni+m-1,j) = x(1)
end do
end if
end do
#endif
end if
nn = nn + 1
ni = ni + river_split(ni)
end if
end do
end if
#else
!AS this is not to be used !
t = loop*timestep
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment