1 |
C $Header: /u/gcmpack/MITgcm/pkg/dic/phos_flux.F,v 1.15 2010/08/16 10:38:50 mlosch Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "DIC_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: PHOS_FLUX |
8 |
|
9 |
C !INTERFACE: ========================================================== |
10 |
SUBROUTINE PHOS_FLUX( BIOac, pflux, exportflux, |
11 |
I bi,bj,imin,imax,jmin,jmax, |
12 |
I myIter,myTime,myThid) |
13 |
|
14 |
C !DESCRIPTION: |
15 |
C Calculate the PO4 flux to depth from bio activity |
16 |
|
17 |
C !USES: =============================================================== |
18 |
IMPLICIT NONE |
19 |
#include "SIZE.h" |
20 |
#include "DYNVARS.h" |
21 |
#include "EEPARAMS.h" |
22 |
#include "PARAMS.h" |
23 |
#include "GRID.h" |
24 |
#include "DIC_VARS.h" |
25 |
|
26 |
C !INPUT PARAMETERS: =================================================== |
27 |
C myThid :: thread number |
28 |
C myIter :: current timestep |
29 |
C myTime :: current time |
30 |
C BIOac :: biological productivity |
31 |
INTEGER myIter |
32 |
_RL myTime |
33 |
INTEGER myThid |
34 |
_RL BIOac(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
35 |
INTEGER imin, imax, jmin, jmax, bi, bj |
36 |
|
37 |
C !OUTPUT PARAMETERS: =================================================== |
38 |
C pflux :: changes to PO4 due to flux and reminerlization |
39 |
_RL pflux (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
40 |
_RL exportflux(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
41 |
|
42 |
#if (defined ALLOW_PTRACERS && defined DIC_BIOTIC) |
43 |
|
44 |
C !LOCAL VARIABLES: ==================================================== |
45 |
C i,j,k :: loop indices |
46 |
c ko :: loop-within-loop index |
47 |
c bexport :: flux of phosphorus from base each "productive" |
48 |
c layer |
49 |
c depth_l :: depth and lower interface |
50 |
c flux_u, flux_l :: flux through upper and lower interfaces |
51 |
c reminFac :: abbreviation |
52 |
c zbase :: depth of bottom of current productive layer |
53 |
INTEGER I,J,k, ko, kop1 |
54 |
_RL zbase |
55 |
_RL bexport(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
56 |
_RL reminFac |
57 |
_RL depth_l |
58 |
_RL flux_u (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
59 |
_RL flux_l |
60 |
CEOP |
61 |
|
62 |
C- Calculate PO4 flux from base of each layer |
63 |
DO k=1,nlev |
64 |
DO j=jmin,jmax |
65 |
DO i=imin,imax |
66 |
bexport(i,j) = 0. _d 0 |
67 |
IF ( _hFacC(i,j,k,bi,bj).gt.0. _d 0 ) THEN |
68 |
C-- If no layer below initial layer (because of bottom or |
69 |
C-- topography), then remineralize in here |
70 |
IF (k.EQ.Nr) THEN |
71 |
pflux(i,j,k)=pflux(i,j,k)+BIOac(i,j,k)*(1. _d 0-DOPfraction) |
72 |
ELSEIF (hFacC(i,j,k+1,bi,bj).EQ.0. _d 0) THEN |
73 |
pflux(i,j,k)=pflux(i,j,k)+BIOac(i,j,k)*(1. _d 0-DOPfraction) |
74 |
ELSE |
75 |
C- flux out of layer k |
76 |
bexport(i,j)=BIOac(i,j,k)*(1. _d 0-DOPfraction) |
77 |
& *drF(k) * _hFacC(i,j,k,bi,bj) |
78 |
ENDIF |
79 |
ENDIF |
80 |
ENDDO |
81 |
ENDDO |
82 |
C-- If available, flux phosphate downward; |
83 |
C-- calculate flux to each layer from base of k |
84 |
zbase=-rF(k+1) |
85 |
C-- Upper flux |
86 |
DO j=jmin,jmax |
87 |
DO i=imin,imax |
88 |
flux_u(i,j) = bexport(i,j) |
89 |
ENDDO |
90 |
ENDDO |
91 |
C Instead of running the loop to ko=Nr and masking the last |
92 |
C flux_l, let ko reach only Nr-1 and do a special loop for ko=Nr, |
93 |
C in order to save a few expensive exp-function calls |
94 |
DO ko=k+1,Nr-1 |
95 |
kop1 = MIN(Nr,ko+1) |
96 |
#ifndef NONLIN_FRSURF |
97 |
C For the linear free surface, hFacC can be omitted, buying another |
98 |
C performance increase of a factor of six on a vector computer. |
99 |
C For now this is not implemented via run time flags, in order to |
100 |
C avoid making this code too complicated. |
101 |
depth_l = -rF(ko) + drF(ko) |
102 |
C reminFac = (depth_l/zbase)**(-Kremin) |
103 |
C The following form does the same, but is faster |
104 |
reminFac = exp(-Kremin*log(depth_l/zbase)) |
105 |
#endif |
106 |
DO j=jmin,jmax |
107 |
DO i=imin,imax |
108 |
IF ( bexport(i,j) .NE. 0. _d 0 ) THEN |
109 |
C-- Lower flux (no flux to ocean bottom) |
110 |
#ifdef NONLIN_FRSURF |
111 |
depth_l = -rF(ko) + drF(ko) * _hFacC(i,j,ko,bi,bj) |
112 |
C reminFac = (depth_l/zbase)**(-Kremin) |
113 |
C The following form does the same, but is faster |
114 |
reminFac = exp(-Kremin*log(depth_l/zbase)) |
115 |
#endif |
116 |
flux_l = bexport(i,j)*reminFac |
117 |
& *maskC(i,j,kop1,bi,bj) |
118 |
C |
119 |
pflux(i,j,ko)=pflux(i,j,ko) + (flux_u(i,j)-flux_l) |
120 |
& *recip_drF(ko) * _recip_hFacC(i,j,ko,bi,bj) |
121 |
exportflux(i,j,ko)=exportflux(i,j,ko)+flux_u(i,j) |
122 |
C-- Store flux through upper layer for the next k-level |
123 |
flux_u(i,j) = flux_l |
124 |
C endif bexport .ne. 0 |
125 |
ENDIF |
126 |
C i,j-loops |
127 |
ENDDO |
128 |
ENDDO |
129 |
C ko-loop |
130 |
ENDDO |
131 |
C now do ko = Nr |
132 |
ko = Nr |
133 |
flux_l = 0. _d 0 |
134 |
DO j=jmin,jmax |
135 |
DO i=imin,imax |
136 |
pflux(i,j,ko)=pflux(i,j,ko) + (flux_u(i,j)-flux_l) |
137 |
& *recip_drF(ko) * _recip_hFacC(i,j,ko,bi,bj) |
138 |
exportflux(i,j,ko)=exportflux(i,j,ko)+flux_u(i,j) |
139 |
ENDDO |
140 |
ENDDO |
141 |
C k-loop |
142 |
ENDDO |
143 |
c |
144 |
#endif /* defined ALLOW_PTRACERS && defined DIC_BIOTIC */ |
145 |
RETURN |
146 |
END |