Commit 8473db4ac3e66e92754c0c2d122625c1d7581d68

Authored by dumoda01
1 parent f5e580ce
Exists in master and in 1 other branch snow

Les routines nitrate.F90 et ammonium.F90 ont ete transportees de /meanflow a ext…

…ras/bio afin de simplifier la prise en compte des dependences (voir Makefile respectifs). Il n'est donc plus necessaire de modifier le code avant de changer de modele biologique.
src/extras/bio/Makefile
@@ -7,22 +7,31 @@ include ../../Rules.make @@ -7,22 +7,31 @@ include ../../Rules.make
7 7
8 LIB = $(LIBDIR)/libbio$(buildtype).a 8 LIB = $(LIBDIR)/libbio$(buildtype).a
9 9
10 -DOCSRC = bio.F90 \  
11 -bio_var.F90 bio_template.F90 bio_npzd.F90 bio_iow.F90 \  
12 - bio_sed.F90 bio_fasham.F90 bio_ismer.F90\  
13 - bio_save.F90 10 +DOCSRC = bio.F90 \
  11 +bio_var.F90 \
  12 +bio_template.F90 \
  13 +bio_npzd.F90 \
  14 +bio_iow.F90 \
  15 +bio_sed.F90 \
  16 +bio_fasham.F90 \
  17 +bio_ismer.F90 \
  18 +bio_save.F90 \
  19 +nitrate.F90 \
  20 +ammonium.F90
14 21
15 OBJ = \ 22 OBJ = \
16 -${LIB}(bio_var.o) \  
17 -${LIB}(bio_fluxes.o) \  
18 -${LIB}(bio_template.o) \  
19 -${LIB}(bio_npzd.o) \  
20 -${LIB}(bio_iow.o) \  
21 -${LIB}(bio_mab.o) \  
22 -${LIB}(bio_ismer.o) \  
23 -${LIB}(bio_fasham.o) \  
24 -${LIB}(bio_sed.o) \  
25 -${LIB}(bio_save.o) \ 23 +${LIB}(bio_var.o) \
  24 +${LIB}(bio_fluxes.o) \
  25 +${LIB}(bio_template.o) \
  26 +${LIB}(bio_npzd.o) \
  27 +${LIB}(bio_iow.o) \
  28 +${LIB}(bio_mab.o) \
  29 +${LIB}(bio_ismer.o) \
  30 +${LIB}(bio_fasham.o) \
  31 +${LIB}(bio_sed.o) \
  32 +${LIB}(bio_save.o) \
  33 +${LIB}(nitrate.o) \
  34 +${LIB}(ammonium.o) \
26 ${LIB}(bio.o) 35 ${LIB}(bio.o)
27 36
28 all: ${OBJ} 37 all: ${OBJ}
src/extras/bio/ammonium.F90 0 → 100644
@@ -0,0 +1,194 @@ @@ -0,0 +1,194 @@
  1 +!$Id: nitrate.F90,v 1.11 2007-01-06 11:49:15 kbk Exp $
  2 +#include"cppdefs.h"
  3 +!-----------------------------------------------------------------------
  4 +!BOP
  5 +!
  6 +! !ROUTINE: The nitrate equation \label{sec:nitrate}
  7 +!
  8 +! !INTERFACE:
  9 + subroutine ammonium(nlev,dt,cnpar,nus,gams,cc)
  10 +!
  11 +! !DESCRIPTION:
  12 +! This subroutine computes the balance of ammonium in the form
  13 +! \begin{equation}
  14 +! \label{SEq}
  15 +! \dot{S}
  16 +! = {\cal D}_S
  17 +! - \frac{1}{\tau^S_R}(S-S_{obs})
  18 +! \comma
  19 +! \end{equation}
  20 +! where $\dot{S}$ denotes the material derivative of the nitrate $N$, and
  21 +! ${\cal D}_N$ is the sum of the turbulent and viscous transport
  22 +! terms modelled according to
  23 +! \begin{equation}
  24 +! \label{DN}
  25 +! {\cal D}_N
  26 +! = \frstder{z}
  27 +! \left(
  28 +! \left( \nu^N_t + \nu^N \right) \partder{N}{z} - \tilde{\Gamma}_N
  29 +! \right)
  30 +! \point
  31 +! \end{equation}
  32 +! In this equation, $\nu^N_t$ and $\nu^N$ are the turbulent and
  33 +! molecular diffusivities of nitrate, respectively,
  34 +! and $\tilde{\Gamma}_N$
  35 +! denotes the non-local flux of nitrate, see
  36 +! \sect{sec:turbulenceIntro}. In the current version of GOTM,
  37 +! we set $\nu^N_t = \nu^\N$ for simplicity.
  38 +!
  39 +! Horizontal advection is optionally
  40 +! included (see {\tt obs.nml}) by means of prescribed
  41 +! horizontal gradients $\partial_xN$ and $\partial_yN$ and
  42 +! calculated horizontal mean velocities $U$ and $V$.
  43 +! Relaxation with the time scale $\tau^N_R$
  44 +! towards a precribed (changing in time)
  45 +! profile $N_{obs}$ is possible.
  46 +
  47 +! Inner sources or sinks are not considered.
  48 +! The surface freshwater flux is given by means of the precipitation
  49 +! - evaporation data read in as $P-E$ through the {\tt airsea.nml} namelist:
  50 +! \begin{equation}
  51 +! \label{S_sbc}
  52 +! {\cal D}_S = S (P-E),
  53 +! \qquad \mbox{at } z=\zeta,
  54 +! \end{equation}
  55 +! with $P-E$ given as a velocity (note that ${\cal D}_S$ is the flux in the
  56 +! direction of $z$, and thus positive for a \emph{loss} of nitrate) .
  57 +! Diffusion is numerically treated implicitly,
  58 +! see equations (\ref{sigmafirst})-(\ref{sigmalast}).
  59 +! The tri-diagonal matrix is solved then by a simplified Gauss elimination.
  60 +! Vertical advection is included, and it must be non-conservative,
  61 +! which is ensured by setting the local variable {\tt adv\_mode=0},
  62 +! see section \ref{sec:advectionMean} on page \pageref{sec:advectionMean}.
  63 +!
  64 +! !USES:
  65 +
  66 + use meanflow, only: avmola !CHG5
  67 + use meanflow, only: h,u,v,w,amm,avh !CHG5
  68 + use observations, only: dadx,dady,a_adv !CHG5
  69 + use observations, only: w_adv_discr,w_adv_method
  70 + use observations, only: aprof,ARelaxTau !CHG5
  71 + use airsea, only: p_e
  72 + use util, only: Dirichlet,Neumann
  73 + use util, only: oneSided,zeroDivergence
  74 + use bio_var, only: bio_model,numc
  75 +
  76 + IMPLICIT NONE
  77 +!
  78 +
  79 +! !INPUT PARAMETERS:
  80 +
  81 +
  82 +! number of vertical layers
  83 + integer, intent(in) :: nlev
  84 +
  85 +! time step (s)
  86 + REALTYPE, intent(in) :: dt
  87 +
  88 +! numerical "implicitness" parameter
  89 + REALTYPE, intent(in) :: cnpar
  90 +
  91 +! diffusivity of nitrate (m^2/s) (!CHG3 same as salinity)
  92 + REALTYPE, intent(in) :: nus(0:nlev)
  93 +
  94 +! non-local salinity flux (psu m/s)
  95 + REALTYPE, intent(in) :: gams(0:nlev)
  96 +
  97 +! nitrate concentration after bio loop
  98 + REALTYPE, intent(in), optional :: cc(1:numc,0:nlev) !CHG3
  99 +!
  100 +! !REVISION HISTORY:
  101 +! Original author(s): Dany Dumont (dany_dumont@ete.inrs.ca)
  102 +!
  103 +! $Log: nitrate.F90,v $
  104 +! Creation 1.0 2008-06-11 14:27:00 dd
  105 +! based on salinity.F90
  106 +!
  107 +!EOP
  108 +!
  109 +! !LOCAL VARIABLES:
  110 + integer :: adv_mode=0
  111 + integer :: posconc=1
  112 + integer :: i
  113 + integer :: DiffBcup,DiffBcdw
  114 + integer :: AdvBcup,AdvBcdw
  115 + REALTYPE :: DiffSup,DiffSdw
  116 + REALTYPE :: AdvSup,AdvSdw
  117 + REALTYPE :: Lsour(0:nlev)
  118 + REALTYPE :: Qsour(0:nlev)
  119 +!
  120 +!-----------------------------------------------------------------------
  121 +!BOC
  122 +!
  123 +! set boundary conditions
  124 + DiffBcup = Neumann
  125 + DiffBcdw = Neumann
  126 + DiffSup = -1.*amm(nlev)*p_e !CHG5
  127 + DiffSdw = _ZERO_
  128 +
  129 + AdvBcup = zeroDivergence
  130 + AdvBcdw = oneSided
  131 + AdvSup = _ZERO_
  132 + AdvSdw = _ZERO_
  133 +
  134 +! compute total diffusivity
  135 + do i=0,nlev
  136 + avh(i)=nus(i)+avmola !CHG5
  137 + end do
  138 +
  139 +! add contributions to source term
  140 + Lsour=_ZERO_
  141 + Qsour=_ZERO_
  142 +
  143 + do i=1,nlev
  144 +! from non-local turbulence
  145 +#ifdef NONLOCAL
  146 + Qsour(i) = Qsour(i) - ( gams(i) - gams(i-1) )/h(i)
  147 +#endif
  148 + end do
  149 +
  150 +! ... and from lateral advection
  151 + if (a_adv) then
  152 + do i=1,nlev
  153 + Qsour(i) = Qsour(i) - u(i)*dadx(i) - v(i)*dady(i) !CHG5
  154 + end do
  155 + end if
  156 +
  157 +! redefinir amm apres un cyle bio
  158 +#ifdef BIO
  159 +!do i=1,nlev
  160 +! !amm(i) = cc(6,i) ! bio_model=2,4
  161 +! amm(i) = cc(9,i) ! bio_model=6
  162 +!end do
  163 + if (bio_model.eq.2) then
  164 + do i=1,nlev
  165 + amm(i) = cc(6,i)
  166 + end do
  167 + else if (bio_model.eq.4) then
  168 + do i=1,nlev
  169 + amm(i) = cc(6,i)
  170 + end do
  171 + else if (bio_model.eq.6) then
  172 + do i=1,nlev
  173 + amm(i) = cc(9,i)
  174 + end do
  175 + end if
  176 +#endif
  177 +
  178 +! do advection step
  179 + if (w_adv_method .ne. 0) then
  180 + call adv_center(nlev,dt,h,h,w,AdvBcup,AdvBcdw, &
  181 + AdvSup,AdvSdw,w_adv_discr,adv_mode,amm) !CHG5
  182 + end if
  183 +
  184 +! do diffusion step
  185 + call diff_center(nlev,dt,cnpar,posconc,h,DiffBcup,DiffBcdw, &
  186 + DiffSup,DiffSdw,avh,LSour,Qsour,ARelaxTau,aprof,amm) !CHG5
  187 +
  188 + return
  189 + end subroutine ammonium
  190 +!EOC
  191 +
  192 +!-----------------------------------------------------------------------
  193 +! Copyright by the GOTM-team under the GNU Public License - www.gnu.org
  194 +!-----------------------------------------------------------------------
src/extras/bio/nitrate.F90 0 → 100644
@@ -0,0 +1,200 @@ @@ -0,0 +1,200 @@
  1 +!$Id: nitrate.F90,v 1.11 2007-01-06 11:49:15 kbk Exp $
  2 +#include"cppdefs.h"
  3 +!-----------------------------------------------------------------------
  4 +!BOP
  5 +!
  6 +! !ROUTINE: The nitrate equation \label{sec:nitrate}
  7 +!
  8 +! !INTERFACE:
  9 + subroutine nitrate(nlev,dt,cnpar,nus,gams,cc)
  10 +!
  11 +! !DESCRIPTION:
  12 +! This subroutine computes the balance of nitrate in the form
  13 +! \begin{equation}
  14 +! \label{SEq}
  15 +! \dot{S}
  16 +! = {\cal D}_S
  17 +! - \frac{1}{\tau^S_R}(S-S_{obs})
  18 +! \comma
  19 +! \end{equation}
  20 +! where $\dot{S}$ denotes the material derivative of the nitrate $N$, and
  21 +! ${\cal D}_N$ is the sum of the turbulent and viscous transport
  22 +! terms modelled according to
  23 +! \begin{equation}
  24 +! \label{DN}
  25 +! {\cal D}_N
  26 +! = \frstder{z}
  27 +! \left(
  28 +! \left( \nu^N_t + \nu^N \right) \partder{N}{z} - \tilde{\Gamma}_N
  29 +! \right)
  30 +! \point
  31 +! \end{equation}
  32 +! In this equation, $\nu^N_t$ and $\nu^N$ are the turbulent and
  33 +! molecular diffusivities of nitrate, respectively,
  34 +! and $\tilde{\Gamma}_N$
  35 +! denotes the non-local flux of nitrate, see
  36 +! \sect{sec:turbulenceIntro}. In the current version of GOTM,
  37 +! we set $\nu^N_t = \nu^\N$ for simplicity.
  38 +!
  39 +! Horizontal advection is optionally
  40 +! included (see {\tt obs.nml}) by means of prescribed
  41 +! horizontal gradients $\partial_xN$ and $\partial_yN$ and
  42 +! calculated horizontal mean velocities $U$ and $V$.
  43 +! Relaxation with the time scale $\tau^N_R$
  44 +! towards a precribed (changing in time)
  45 +! profile $N_{obs}$ is possible.
  46 +
  47 +! Inner sources or sinks are not considered.
  48 +! The surface freshwater flux is given by means of the precipitation
  49 +! - evaporation data read in as $P-E$ through the {\tt airsea.nml} namelist:
  50 +! \begin{equation}
  51 +! \label{S_sbc}
  52 +! {\cal D}_S = S (P-E),
  53 +! \qquad \mbox{at } z=\zeta,
  54 +! \end{equation}
  55 +! with $P-E$ given as a velocity (note that ${\cal D}_S$ is the flux in the
  56 +! direction of $z$, and thus positive for a \emph{loss} of nitrate) .
  57 +! Diffusion is numerically treated implicitly,
  58 +! see equations (\ref{sigmafirst})-(\ref{sigmalast}).
  59 +! The tri-diagonal matrix is solved then by a simplified Gauss elimination.
  60 +! Vertical advection is included, and it must be non-conservative,
  61 +! which is ensured by setting the local variable {\tt adv\_mode=0},
  62 +! see section \ref{sec:advectionMean} on page \pageref{sec:advectionMean}.
  63 +!
  64 +! !USES:
  65 +
  66 + use meanflow, only: avmoln !CHG3
  67 + use meanflow, only: h,u,v,w,nit,avh !CHG3
  68 + use observations, only: dndx,dndy,n_adv !CHG3
  69 + use observations, only: w_adv_discr,w_adv_method
  70 + use observations, only: nprof,NRelaxTau !CHG3
  71 + use airsea, only: p_e
  72 + use util, only: Dirichlet,Neumann
  73 + use util, only: oneSided,zeroDivergence
  74 + use bio_var, only: bio_model,numc
  75 +
  76 + IMPLICIT NONE
  77 +!
  78 +
  79 +! !INPUT PARAMETERS:
  80 +
  81 +
  82 +! number of vertical layers
  83 + integer, intent(in) :: nlev
  84 +
  85 +! time step (s)
  86 + REALTYPE, intent(in) :: dt
  87 +
  88 +! numerical "implicitness" parameter
  89 + REALTYPE, intent(in) :: cnpar
  90 +
  91 +! diffusivity of nitrate (m^2/s) (!CHG3 same as salinity)
  92 + REALTYPE, intent(in) :: nus(0:nlev)
  93 +
  94 +! non-local salinity flux (psu m/s)
  95 + REALTYPE, intent(in) :: gams(0:nlev)
  96 +
  97 +! nitrate concentration after bio loop
  98 +!DD Not independent of the bio model, only works with 7 compartments model (Fasham)
  99 +! REALTYPE, intent(in), optional :: cc(1:10,0:nlev) !CHG3
  100 + REALTYPE, intent(in), optional :: cc(1:numc,0:nlev) !CHG3
  101 +!
  102 +! !REVISION HISTORY:
  103 +! Original author(s): Dany Dumont (dany_dumont@ete.inrs.ca)
  104 +!
  105 +! $Log: nitrate.F90,v $
  106 +! Creation 1.0 2008-06-11 14:27:00 dd
  107 +! based on salinity.F90
  108 +!
  109 +!EOP
  110 +!
  111 +! !LOCAL VARIABLES:
  112 + integer :: adv_mode=0
  113 + integer :: posconc=1
  114 + integer :: i
  115 + integer :: DiffBcup,DiffBcdw
  116 + integer :: AdvBcup,AdvBcdw
  117 + REALTYPE :: DiffSup,DiffSdw
  118 + REALTYPE :: AdvSup,AdvSdw
  119 + REALTYPE :: Lsour(0:nlev)
  120 + REALTYPE :: Qsour(0:nlev)
  121 +!
  122 +!-----------------------------------------------------------------------
  123 +!BOC
  124 +!
  125 +! set boundary conditions
  126 + DiffBcup = Neumann
  127 + DiffBcdw = Neumann
  128 + DiffSup = -1.*nit(nlev)*p_e !CHG3
  129 + DiffSdw = _ZERO_
  130 +
  131 + AdvBcup = zeroDivergence
  132 + AdvBcdw = oneSided
  133 + AdvSup = _ZERO_
  134 + AdvSdw = _ZERO_
  135 +
  136 +! compute total diffusivity
  137 + do i=0,nlev
  138 + avh(i)=nus(i)+avmoln !CHG3
  139 + end do
  140 +
  141 +! add contributions to source term
  142 + Lsour=_ZERO_
  143 + Qsour=_ZERO_
  144 +
  145 + do i=1,nlev
  146 +! from non-local turbulence
  147 +#ifdef NONLOCAL
  148 + Qsour(i) = Qsour(i) - ( gams(i) - gams(i-1) )/h(i)
  149 +#endif
  150 + end do
  151 +
  152 +! ... and from lateral advection
  153 + if (n_adv) then
  154 + do i=1,nlev
  155 + Qsour(i) = Qsour(i) - u(i)*dndx(i) - v(i)*dndy(i) !CHG3
  156 + end do
  157 + end if
  158 +
  159 +! redefinir nit apres un cyle bio
  160 +#ifdef BIO
  161 +!do i=1,nlev
  162 +! !nit(i) = cc(7,i) ! bio_model=2,4
  163 +! nit(i) = cc(1,i) ! bio_model=1,6
  164 +!end do
  165 + if (bio_model.eq.1) then
  166 + do i=1,nlev
  167 + nit(i) = cc(1,i)
  168 + end do
  169 + else if (bio_model.eq.2) then
  170 + do i=1,nlev
  171 + nit(i) = cc(7,i)
  172 + end do
  173 + else if (bio_model.eq.4) then
  174 + do i=1,nlev
  175 + nit(i) = cc(7,i)
  176 + end do
  177 + else if (bio_model.eq.6) then
  178 + do i=1,nlev
  179 + nit(i) = cc(1,i)
  180 + end do
  181 + end if
  182 +#endif
  183 +
  184 +! do advection step
  185 + if (w_adv_method .ne. 0) then
  186 + call adv_center(nlev,dt,h,h,w,AdvBcup,AdvBcdw, &
  187 + AdvSup,AdvSdw,w_adv_discr,adv_mode,nit) !CHG3
  188 + end if
  189 +
  190 +! do diffusion step
  191 + call diff_center(nlev,dt,cnpar,posconc,h,DiffBcup,DiffBcdw, &
  192 + DiffSup,DiffSdw,avh,LSour,Qsour,NRelaxTau,nprof,nit) !CHG3
  193 +
  194 + return
  195 + end subroutine nitrate
  196 +!EOC
  197 +
  198 +!-----------------------------------------------------------------------
  199 +! Copyright by the GOTM-team under the GNU Public License - www.gnu.org
  200 +!-----------------------------------------------------------------------
src/meanflow/Makefile
@@ -18,8 +18,6 @@ intpressure.F90 \ @@ -18,8 +18,6 @@ intpressure.F90 \
18 friction.F90 \ 18 friction.F90 \
19 temperature.F90 \ 19 temperature.F90 \
20 salinity.F90 \ 20 salinity.F90 \
21 -nitrate.F90 \  
22 -ammonium.F90 \  
23 buoyancy.F90 \ 21 buoyancy.F90 \
24 shear.F90 \ 22 shear.F90 \
25 stratification.F90 \ 23 stratification.F90 \
@@ -38,8 +36,6 @@ ${LIB}(intpressure.o) \ @@ -38,8 +36,6 @@ ${LIB}(intpressure.o) \
38 ${LIB}(friction.o) \ 36 ${LIB}(friction.o) \
39 ${LIB}(temperature.o) \ 37 ${LIB}(temperature.o) \
40 ${LIB}(salinity.o) \ 38 ${LIB}(salinity.o) \
41 -${LIB}(nitrate.o) \  
42 -${LIB}(ammonium.o) \  
43 ${LIB}(stratification.o) \ 39 ${LIB}(stratification.o) \
44 ${LIB}(shear.o) \ 40 ${LIB}(shear.o) \
45 ${LIB}(buoyancy.o) \ 41 ${LIB}(buoyancy.o) \