C $Header: /home/ubuntu/mnt/e9_copy/MITgcm_contrib/bling/pkg/bling_light.F,v 1.1 2014/05/23 17:33:43 mmazloff Exp $ C $Name: $ #include "BLING_OPTIONS.h" CBOP subroutine BLING_LIGHT( U irr_eff, I bi, bj, imin, imax, jmin, jmax, I myIter, myTime, myThid ) C ================================================================= C | subroutine bling_light C | o calculate effective light for phytoplankton growth C | There are multiple types of light. C | - irr_inst is the instantaneous irradiance field. C | - irr_mix is the same, but with the irr_inst averaged throughout C | the mixed layer. This quantity is intended to represent the C | light to which phytoplankton subject to turbulent transport in C | the mixed-layer would be exposed. C | - irr_mem is a temporally smoothed field carried between C | timesteps, to represent photoadaptation. C | - irr_eff is the effective irradiance for photosynthesis, C | given either by irr_inst or irr_mix, depending on model C | options and location. C ================================================================= implicit none C === Global variables === C irr_inst :: Instantaneous irradiance C irr_mem :: Phyto irradiance memory #include "SIZE.h" #include "EEPARAMS.h" #include "PARAMS.h" #include "FFIELDS.h" #include "GRID.h" #include "DYNVARS.h" #include "BLING_VARS.h" #include "PTRACERS_SIZE.h" #include "PTRACERS_PARAMS.h" #ifdef ALLOW_AUTODIFF_TAMC # include "tamc.h" #endif C === Routine arguments === C bi,bj :: tile indices C iMin,iMax :: computation domain: 1rst index range C jMin,jMax :: computation domain: 2nd index range C myTime :: current time C myIter :: current timestep C myThid :: thread Id. number INTEGER bi, bj, imin, imax, jmin, jmax INTEGER myThid INTEGER myIter _RL myTime C === Output === C irr_eff :: effective light for photosynthesis _RL irr_eff (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) C === Local variables === _RL solar, albedo _RL dayfrac, yday, delta _RL lat, sun1, dayhrs _RL cosz, frac, fluxi _RL atten _RL irr_surf (1-OLx:sNx+OLx,1-OLy:sNy+OLy) #ifdef ML_MEAN_LIGHT _RL irr_mix (1-OLx:sNx+OLx,1-OLy:sNy+OLy) _RL SumMLIrr _RL SumMLDepth _RL dens_surf (1-OLx:sNx+OLx,1-OLy:sNy+OLy) _RL dens_z (1-OLx:sNx+OLx,1-OLy:sNy+OLy) _RL delta_dens(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) #endif #ifndef READ_PAR #ifndef USE_QSW _RL sfac (1-OLy:sNy+OLy) #endif #endif integer i,j,k CEOP #ifdef ML_MEAN_LIGHT c --------------------------------------------------------------------- c Mixed layer depth c Surface density CALL FIND_RHO_2D( I 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, 1, I theta(1-OLx,1-OLy,1,bi,bj), salt(1-OLx,1-OLy,1,bi,bj), O dens_surf, I 1, bi, bj, myThid ) DO k=1,Nr DO j=jmin,jmax DO i=imin,imax if (k.eq.1) then delta_dens(i,j,1) = 0. _d 0 else delta_dens(i,j,k) = 9999. _d 0 endif ENDDO ENDDO ENDDO DO k = 2,Nr c Potential density CALL FIND_RHO_2D( I 1-OLx, sNx+OLx, 1-OLy, sNy+OLy, 1, I theta(1-OLx,1-OLy,k,bi,bj), salt(1-OLx,1-OLy,k,bi,bj), O dens_z, I k, bi, bj, myThid ) DO j=jmin,jmax DO i=imin,imax IF (hFacC(i,j,k,bi,bj) .gt. 0. _d 0) THEN delta_dens(i,j,k) = dens_z(i,j)-dens_surf(i,j) ENDIF ENDDO ENDDO ENDDO #endif c --------------------------------------------------------------------- c Surface insolation #ifndef USE_EXFQSW c From pkg/dic/dic_insol c find light as function of date and latitude c based on paltridge and parson solar = 1360. _d 0 !solar constant albedo = 0.6 _d 0 !planetary albedo C Case where a 2-d output array is needed: for now, stop here. IF ( usingCurvilinearGrid .OR. rotateGrid ) THEN STOP 'ABNORMAL END: S/R INSOL: 2-D output not implemented' ENDIF C find day (****NOTE for year starting in winter*****) dayfrac=mod(myTime,360. _d 0*86400. _d 0) & /(360. _d 0*86400. _d 0) !fraction of year yday = 2. _d 0*PI*dayfrac !convert to radians delta = (0.006918 _d 0 & -(0.399912 _d 0*cos(yday)) !cosine zenith angle & +(0.070257 _d 0*sin(yday)) !(paltridge+platt) & -(0.006758 _d 0*cos(2. _d 0*yday)) & +(0.000907 _d 0*sin(2. _d 0*yday)) & -(0.002697 _d 0*cos(3. _d 0*yday)) & +(0.001480 _d 0*sin(3. _d 0*yday)) ) DO j=1-OLy,sNy+OLy C latitude in radians lat=YC(1,j,1,bj)*deg2rad C latitute in radians, backed out from coriolis parameter C (makes latitude independent of grid) IF ( usingCartesianGrid .OR. usingCylindricalGrid ) & lat = asin( fCori(1,j,1,bj)/(2. _d 0*omega) ) sun1 = -sin(delta)/cos(delta) * sin(lat)/cos(lat) IF (sun1.LE.-0.999 _d 0) sun1=-0.999 _d 0 IF (sun1.GE. 0.999 _d 0) sun1= 0.999 _d 0 dayhrs = abs(acos(sun1)) cosz = ( sin(delta)*sin(lat)+ !average zenith angle & (cos(delta)*cos(lat)*sin(dayhrs)/dayhrs) ) IF (cosz.LE.5. _d -3) cosz= 5. _d -3 frac = dayhrs/PI !fraction of daylight in day C daily average photosynthetically active solar radiation just below surface fluxi = solar*(1. _d 0-albedo)*cosz*frac*parfrac C convert to sfac sfac(j) = MAX(1. _d -5,fluxi) ENDDO !j #endif c --------------------------------------------------------------------- c instantaneous light, mixed layer averaged light C$TAF LOOP = parallel DO j=jmin,jmax C$TAF LOOP = parallel DO i=imin,imax c Photosynthetically-available radiations (PAR) #ifdef USE_EXFQSW irr_surf(i,j) = max(0. _d 0, & -parfrac*Qsw(i,j,bi,bj)*maskC(i,j,1,bi,bj)) #else irr_surf(i,j) = sfac(j) #endif IF ( .NOT. QSW_underice ) THEN c if using Qsw but not seaice/thsice or coupled, then c ice fraction needs to be taken into account irr_surf(i,j) = irr_surf(i,j)*(1. _d 0 - FIce(i,j,bi,bj)) ENDIF #ifdef ML_MEAN_LIGHT SumMLIrr = 0. _d 0 SumMLDepth = 0. _d 0 #endif c C$TAF init ml_stuff = static, Nr DO k=1,Nr c C$TAF STORE SumMLDepth = ml_stuff IF (hFacC(i,j,k,bi,bj).gt.0) THEN IF (k.eq.1) THEN c Light attenuation in middle of top layer atten = k0*drF(1)/2. _d 0*hFacC(i,j,1,bi,bj) irr_inst(i,j,1,bi,bj) = irr_surf(i,j)*exp(-atten) ELSE c Attenuation from one more layer atten = k0*drF(k)/2. _d 0*hFacC(i,j,k,bi,bj) & + k0*drF(k-1)/2. _d 0*hFacC(i,j,k-1,bi,bj) irr_inst(i,j,k,bi,bj) = & irr_inst(i,j,k-1,bi,bj)*exp(-atten) ENDIF #ifdef ML_MEAN_LIGHT c Mean irradiance in the mixed layer IF (delta_dens(i,j,k) .LT. 0.03 _d 0) then SumMLIrr = SumMLIrr+drF(k)*irr_inst(i,j,k,bi,bj) SumMLDepth = SumMLDepth+drF(k) irr_mix(i,j) = SumMLIrr/SumMLDepth ENDIF #endif ENDIF ENDDO ENDDO ENDDO c --------------------------------------------------------------------- C Phytoplankton photoadaptation to local light level DO k=1,Nr DO j=jmin,jmax DO i=imin,imax irr_eff(i,j,k) = irr_inst(i,j,k,bi,bj) #ifdef ML_MEAN_LIGHT c Inside mixed layer, effective light is set to mean mixed layer light IF (delta_dens(i,j,k) .LT. 0.03 _d 0) THEN irr_eff(i,j,k) = irr_mix(i,j) ENDIF #endif irr_mem(i,j,k,bi,bj) = irr_mem(i,j,k,bi,bj) + & (irr_eff(i,j,k) - irr_mem(i,j,k,bi,bj))* & min( 1. _d 0, gamma_irr_mem*PTRACERS_dTLev(k) ) ENDDO ENDDO ENDDO RETURN END