/[MITgcm]/MITgcm/pkg/dic/phos_flux.F
ViewVC logotype

Contents of /MITgcm/pkg/dic/phos_flux.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.16 - (show annotations) (download)
Wed Aug 18 12:20:13 2010 UTC (13 years, 8 months ago) by mlosch
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint63, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint62k, checkpoint62j, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, HEAD
Changes since 1.15: +20 -10 lines
  - reduce number of exp-calls in order to improve performance
  - clean up a little (replace fields by their macros, etc.)

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

  ViewVC Help
Powered by ViewVC 1.1.22