Back to home page

MITgcm

 
 

    


File indexing completed on 2023-02-04 06:09:50 UTC

view on githubraw file Latest commit 2e3e8c33 on 2023-02-03 17:26:01 UTC
6d54cf9ca1 Ed H*0001 #include "DIC_OPTIONS.h"
daab022f42 Step*0002 
f84ec16ca2 Jean*0003 CBOP
                0004 C     !ROUTINE: Fe_CHEM
                0005 C     !INTERFACE:
daab022f42 Step*0006       SUBROUTINE Fe_CHEM(
f84ec16ca2 Jean*0007      I           bi,bj, iMin,iMax,jMin,jMax,
85d94247b5 Jean*0008      I           fe,
                0009      O           freefe,
daab022f42 Step*0010      I           myIter, myThid )
f84ec16ca2 Jean*0011 
                0012 C     !DESCRIPTION: \bv
                0013 C     *==========================================================*
                0014 C     | SUBROUTINE Fe_CHEM
                0015 C     | o Calculate L,FeL,Fe concentration
                0016 C     *==========================================================*
                0017 C     \ev
                0018 
                0019 C     !USES:
daab022f42 Step*0020       IMPLICIT NONE
                0021 
                0022 C     == GLobal variables ==
                0023 #include "SIZE.h"
                0024 #include "EEPARAMS.h"
                0025 #include "PARAMS.h"
                0026 #include "GRID.h"
2ef8966791 Davi*0027 #include "DIC_VARS.h"
daab022f42 Step*0028 
f84ec16ca2 Jean*0029 C     !INPUT/OUTPUT PARAMETERS:
                0030 C     == Routine arguments ==
                0031 C     bi, bj              :: current tile indices
                0032 C     iMin,iMax,jMin,jMax :: Range of points for which calculation is performed.
                0033 C     myThid              :: my Thread Id number
                0034       INTEGER bi,bj
                0035       INTEGER iMin,iMax,jMin,jMax
                0036       _RL     fe(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
                0037       _RL freefe(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
                0038       INTEGER myIter, myThid
                0039 CEOP
daab022f42 Step*0040 
49373516f9 Jean*0041 #ifdef ALLOW_FE
f84ec16ca2 Jean*0042 C     !LOCAL VARIABLES:
                0043       INTEGER i,j,k
daab022f42 Step*0044       _RL  lig, FeL
f7bc6bf9ae Step*0045       _RL  tmpfe
2e3e8c330d Jona*0046 #if ( defined MINFE && defined DIC_AD_SAFE )
f84ec16ca2 Jean*0047       _RL thx, thy, theps
                0048 #endif
daab022f42 Step*0049 
f84ec16ca2 Jean*0050 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
                0051 C
                0052 C  ADAPTED FROM PAYAL
                0053 C
                0054 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
daab022f42 Step*0055 
85d94247b5 Jean*0056       DO k=1,Nr
                0057        DO j=1-OLy,sNy+OLy
                0058         DO i=1-OLx,sNx+OLx
                0059           freefe(i,j,k) = 0. _d 0
                0060         ENDDO
                0061        ENDDO
                0062       ENDDO
                0063 
daab022f42 Step*0064 C ligand balance in surface layer
                0065 C in surface layer
                0066 
f84ec16ca2 Jean*0067        DO k=1,Nr
                0068         DO j=jMin,jMax
                0069          DO i=iMin,iMax
                0070           IF ( maskC(i,j,k,bi,bj).GT.0. ) THEN
daab022f42 Step*0071 
f7bc6bf9ae Step*0072 #ifdef DIC_NO_NEG
f84ec16ca2 Jean*0073               tmpfe =MAX( 0. _d 0 , fe(i,j,k) )
f7bc6bf9ae Step*0074 #else
f84ec16ca2 Jean*0075               tmpfe = fe(i,j,k)
f7bc6bf9ae Step*0076 #endif
f84ec16ca2 Jean*0077 
f7bc6bf9ae Step*0078 C   Ligand,FeL,Fe calculation
                0079               lig=(-ligand_stab*tmpfe +
75e97f1e14 Davi*0080      &              ligand_stab*ligand_tot-1. _d 0
f84ec16ca2 Jean*0081      &             +((ligand_stab*tmpfe
75e97f1e14 Davi*0082      &                -ligand_stab*ligand_tot+1. _d 0)**2
                0083      &               +4. _d 0*ligand_stab*ligand_tot)**0.5 _d 0
                0084      &            )/(2. _d 0*ligand_stab)
f84ec16ca2 Jean*0085 
daab022f42 Step*0086               FeL = ligand_tot-lig
f84ec16ca2 Jean*0087               IF (tmpfe.NE.0. _d 0) THEN
                0088                 freefe(i,j,k) = tmpfe -FeL
                0089               ELSE
                0090                 freefe(i,j,k) = 0. _d 0
                0091               ENDIF
9b8a71f139 Step*0092 #ifdef MINFE
2e3e8c330d Jona*0093 #ifdef DIC_AD_SAFE
f84ec16ca2 Jean*0094               thx=freefe(i,j,k)
720e9330bd Step*0095               thy=freefemax
75e97f1e14 Davi*0096               theps=1. _d -8
f84ec16ca2 Jean*0097               freefe(i,j,k) =
75e97f1e14 Davi*0098      &                 ( 1. _d 0 - tanh((thx-thy)/theps) ) * thx/2.+
                0099      &                 ( 1. _d 0 + tanh((thx-thy)/theps) ) * thy/2.
720e9330bd Step*0100 
                0101 #else
f84ec16ca2 Jean*0102               freefe(i,j,k) = MIN(freefe(i,j,k),freefemax)
720e9330bd Step*0103 #endif
f84ec16ca2 Jean*0104               fe(i,j,k) = FeL+freefe(i,j,k)
9b8a71f139 Step*0105 #endif
f84ec16ca2 Jean*0106           ENDIF
daab022f42 Step*0107          ENDDO
                0108         ENDDO
f84ec16ca2 Jean*0109        ENDDO
                0110 
                0111 #endif /* ALLOW_FE */
                0112       RETURN
                0113       END