'************************************************************************************** 'OYASHIO Excel model Ver.50.1: developed by M. Kashiwai (kashwiai@mua.biglobe.ne.jp) ' Original Stella version 35E was developed by D.M. Ware, T. Wada, M. Kashiwai ' Converted to VBA 6.0 Macro on Excel 2002 ' Altered to use Photosynthesis-Light Curve by Platt et. al(1980) ' Verified on Oct.5, 2004 '************************************************************************************** Option Explicit Option Base 1 Sub OYASHIO_Model() '[モデル]: '対象海域:道東海域(面積12,800ku)。 '計算時間:1日ステップ、1年間 '駆動因子:混合層深度(m),混合層深度変化率(m/day), ' 混合層水温(℃),混合層水温変化率(℃/day) '  光合成有効光日射量(μE/u/s) '栄養塩: 窒素(gN/ku)、供給源は混合層内現存量、動物による排泄、混合層底面からの混合。 '生物要素:植物プランクトン、コペポーダ、オキアミ、マイワシ、スケトウダラ。 '漁業:  現存量密度に対する一定の漁獲率による間引き '[準備]: マクロ[Forcing Data]で日付・混合層深度・混合層水温の日別データを作成; '     マクロ[Radiation]で日射量の日別データを作成; ' Excel BookのWorksheet1にデータをコピー; '     Excel Bookのモジュールにこのマクロ[OYASHIO_Model]をインポート; ' Worksheet1につづいてWorksheet2、3,4,5が並ぶようにシートを追加する。 '[実行]: Worksheet1上でマウスクリックをしてシートを選択しておく; ' 生物要素の収支を調べる場合には、調べたい要素[X]の収支項表示スイッチ; '     Show_[X]_Balanceの値を、VisualBasicEditorで、[1]にセットする。 ' [ツール]→[マクロ]→[マクロ]→[OYASHIO_Model]→[実行]。 '[結果]: Worksheet2に初期値・定数値を出力、 ' Worksheet3に各要素の生物量と生産速度を出力; ' Worksheet4に各要素の収支項を出力; ' Worksheet5に系全体の年間収支の総括 ' Worksheet6に各要素の生物量のグラフ; '   (一度データを選んでグラフを作成すればパラメータを変えた実行結果も表示される); 'On Error GoTo Error_Handler '.................Special Functions................... 'L_Limit(A, B) [A]が下限[B]以下で[0],以上で[1]を返すユーザ定義関数。 Dim PAI As Single 'π=4*arctan(I) '....................Conversion Factors.............................. 'Light 1 μE/u/s =0.217 W/m^2 ' 1 MJ/m^2d = 53.3 μE/u/s 'Diatoms 1 g/m^2 = 1 tonne/km^2 ' 1 mg-at Nitrogen/L = 0.014 gN/m^3 ' 1 g Diatom/m^2 = 0.0113 gN/m^2 ' 1 g Chl-a = 1/40 g Carbon ' 1 g Carbon = 0.45 g dry weight ' 1 g dry weight = 0.15 g wet weight 'Copepods 1 g wet weight = 14.8 g Carbon '.............Calculation Control................. Dim T As Integer 'Time variable (day) Dim dtmStart As Date 'Start Date(yyyy/mm/dd) Dim dtmEnd As Date 'End Date (yyyy/mm/dd) Dim N As Integer 'Total number of time steps (day) Dim Row_3 As Integer 'Output Row on Worksheet3 Dim Col_4 As Integer 'Output Column on Worksheet5 Dim Row_4 As Integer 'Output Row on Worksheet5 '........................Forcing Data..... Dim MLD() As Single 'Mixed layer depth (m) Dim DelMLD() As Single 'Daily change of Mixed Layer Depth(m/day) Dim TMP() As Single 'Mixed layer temperature (degC) Dim DelTMP() As Single 'Daily change in Mixed Layer Temperature (degC/day) Dim PAR() As Single 'Surface photo-synthetic active radiation(μE/u/s) '........................Forcing Variables........... Dim Light As Single 'Average light in mixed layer (μE/u/s) Dim Light_Extinc As Single 'Light extinction include phytoplankton self-shading Dim Q10 As Single 'Temperature effect 1 at 17degC and 0.38 at 3degC '........................Nitrogen Variables........... Dim U_Nitrogen As Single: 'Upper layer Nitrogen Concentration (gN/m^3) Dim L_Nitrogen As Single Dim N_Supply As Single Dim N_Flux As Single Dim N_flux_DelMLD_Rate As Single Dim N_flux_Mix_Rate As Single Dim N_Uptake As Single: 'Nitrogen Uptake by Diatoms Dim N_Uptake_Rate As Single Dim N_excrt_Cope_Rate As Single Dim N_excrt_Euph_Rate As Single Dim N_excrt_Sard_Rate As Single Dim Total_N_Flux_DelMLD As Single Dim Total_N_flux_Mixing As Single Dim Total_N_Uptake As Single Dim Total_N_excrt_Cope As Single Dim Total_N_excrt_Euph As Single Dim Total_N_excrt_Sard As Single '...........................Diatoms Variables.................. Dim Diatoms As Single Dim D_Growth_Rate As Single Dim Light_Factor As Single Dim Temp_Factor As Single Dim N_Factor As Single Dim D_Loss As Single Dim D_E_C_Rate As Single Dim D_E_E_Rate As Single Dim D_E_S_Rate As Single Dim D_Sinking_Speed As Single Dim Primary_Production As Single Dim Total_Diatoms_Lost As Single Dim Total_Diatom_Eaten_C As Single Dim Total_Diatom_Eaten_E As Single Dim Total_Diatom_Eaten_S As Single '..............................Copepods Parameter & Variables................... Dim U_Copepods As Single Dim L_Copepods As Single Dim C_Ingestion As Single Dim C_Growth_Rate As Single Dim C_Sink As Single Dim C_Rise As Single Dim C_E_E_Rate As Single Dim C_E_P_Rate As Single Dim C_E_S_Rate As Single Dim C_Production As Single Dim C_Loss As Single Dim Total_Copepods_Eaten_E As Single Dim Total_Copepods_Eaten_P As Single Dim Total_Copepods_Eaten_S As Single Dim Total_Copepods_Lost As Single '.........................Euphausiids Variables.................. Dim Euphausiids As Single Dim L_Euphausiids As Single Dim E_Rise As Single Dim E_Sink As Single Dim Total_E_Eaten_P As Single Dim E_E_P_Rate As Single Dim Total_E_Eaten_Others As Single Dim E_E_O_Rate As Single Dim Total_E_Eaten_S As Single Dim E_E_S_Rate As Single Dim E_Ingestion As Single Dim E_Production As Single Dim E_Growth_Rate As Single '.........................Sardine Variables............... Dim Sardine As Single Dim North_Sardine As Single Dim South_Sardine As Single Dim S_Mig_S_D As Single Dim S_Mig_N_D As Single Dim S_Mig_D_N As Single Dim S_Mig_D_S As Single Dim S_Production As Single Dim S_Growth_Rate As Single Dim S_Growth As Single Dim S_Ingestion As Single Dim Sardine_Catch As Single Dim S_Catch_Rate As Single '.............................Pollock Variables................. Dim Pollock As Single Dim P_Growth As Single Dim P_Naturl_Mort As Single Dim P_Mortality As Single Dim Pollock_Catch As Single Dim P_Catch_Rate As Single Dim P_Ingestion As Single Dim P_Production As Single Dim P_Growth_Rate As Single '........................Setting Parameter Values................ PAI = 4 * Atn(1) 'Control Const dt As Integer = 1 'Length of 1 time step (day) Const Output_Interval As Integer = 5: 'Interval of output (day) Const Show_N_Balance As Integer = 1: 'Switch to show N. Balance Terms if 1 Const Show_D_Balance As Integer = 1: 'Switch to show D. Balance Terms if 1 Const Show_C_Balance As Integer = 1: 'Switch to show C. Balance Terms if 1 Const Show_E_Balance As Integer = 1: 'Switch to show E. Balance Terms if 1 Const Show_S_Balance As Integer = 1: 'Switch to show S. Balance Terms if 1 Const Show_P_Balance As Integer = 1: 'Switch to show P. Balance Terms if 1 'Forcing Const Mix_Rate As Single = 0.3 'Mixing rate at MLD (m/day) 'Light Const K_Attenu As Single = 0.07 'Seawater Attenuation Const K_Shade As Single = 0.06 'Self Shading 'Diatoms Const Max_Photosynth_Rate As Single = 0.25 'Max photosynthesis rate Const Platt_Alpha As Single = 0.0033 'Alpha in Platt photosynthesis curve Const Platt_Betha As Single = 0.000001 'Betha in Platt's photosynthesis curve Const N_HSC As Single = 0.1 'Nitrogen half-saturation constant Const D_Respiration_Rate As Single = 0.1 'Diatoms respiration rate Const D_Loss_Rate As Single = 0.02 Const N_Uptake_Ratio As Single = 0.0115 'Copepods Const C_Growth_Efficiency As Single = 0.35 Const C_Max_Ingest_Rate As Single = 0.35 Const C_Feeding_HSC As Single = 120# Const C_Rise_Rate As Single = 0.04 Const C_Sink_Rate As Single = 0.05 Const C_Loss_Rate As Single = 0.01 Const C_N_Excret_Rate As Single = 0.0017 'Euphausiidz Const E_Growth_Efficiency As Single = 0.3 Const E_Max_Ing_Rate As Single = 0.3 Const E_Feeding_HSC As Single = 70# Const E_Rise_Rate As Single = 0.04 Const E_Sink_Rate As Single = 0.03 Const E_E_O_Pred_Rate As Single = 0.02 Const E_N_Excret_Rate As Single = 0.0017 'Sardine Const S_Growth_Efficiency As Single = 0.25 Const S_Max_Ing_Rate As Single = 0.04 Const S_Feeding_HSC As Single = 200# Const S_Catchability As Single = 0.012 Const S_Mig_Rate As Single = 0.05 Const S_N_Excret_Rate As Single = 0.0017 'Pollock Const P_Growth_Efficiency As Single = 0.2 Const P_Max_Ing_Rate As Single = 0.03 Const P_Forage_CandE_Ratio As Single = 0.76 'Portion of Cope & Euph in Pollock ration Const P_C_Pref As Single = 0.7 Const P_Feeding_HSC As Single = 80# Const P_Catchability As Single = 0.0017 Const P_Naturl_Mort_Rate As Single = 0.0003 '........................Setting Initial Values................ 'Nitrogen 'Standing Stock U_Nitrogen = 0.28 'Base value = 0.28 L_Nitrogen = 0.28 'Base value = 0.28 'Flux Monitering Total_N_Flux_DelMLD = 0# Total_N_flux_Mixing = 0# Total_N_Uptake = 0# Total_N_excrt_Cope = 0# Total_N_excrt_Euph = 0# Total_N_excrt_Sard = 0# 'Diatoms 'Standing Stock Diatoms = 15# 'Base value = 5, Target max value = 340 t/km^2 'Flux Monitering Primary_Production = 0# 'Target annual value = 2370 t/km^2/yr Total_Diatoms_Lost = 0# Total_Diatom_Eaten_C = 0# Total_Diatom_Eaten_E = 0# Total_Diatom_Eaten_S = 0# 'Copepods 'Standing Stock U_Copepods = 0# 'Target max value = 120 t/km^2 at day145 L_Copepods = 80# 'Base value = 30 t/km^2 'Flux Monitering C_Production = 0# 'Target annual total = 400 t/km^2/yr Total_Copepods_Eaten_E = 0# Total_Copepods_Lost = 0# Total_Copepods_Eaten_S = 0# Total_Copepods_Eaten_P = 0# 'Euphausiids 'Standing Stock Euphausiids = 0# 'Target max value = 16? t/km^2 at day280? L_Euphausiids = 40# 'Base value = 15 'Flux Monitering E_Production = 0# 'Target annual total = 55t/km^2/yr Total_E_Eaten_S = 0# Total_E_Eaten_Others = 0# Total_E_Eaten_P = 0# 'Sardine 'Standing Stock Sardine = 0# 'Target max value = 77t/km^2 at day200 South_Sardine = 120# 'Base value = 1172t/km^2 North_Sardine = 0# 'Flux Monitering S_Production = 0# 'Target annual total = 24.5t/km^2/yr Sardine_Catch = 0# 'Target annual total = 70t/km^2/yr 'Pollock 'Standing Stock Pollock = 24# 'Base Value = 24t/km^2 'Flux Monitering P_Production = 0# 'Target annual total = 5t/km^2/yr P_Mortality = 0# Pollock_Catch = 0# 'Target annual total = 5t/km^2/yr '........................Input Forcing Data from Worksheet1................ Worksheets(1).Activate Worksheets(1).Columns(1).Select N = Selection.SpecialCells(xlCellTypeConstants, xlNumbers).Count Worksheets(1).Activate Worksheets(1).Columns(1).Select dtmStart = Worksheets(1).Cells(2, 1).Value dtmEnd = Worksheets(1).Cells(N + 1, 1).Value ReDim MLD(N), DelMLD(N), TMP(N), DelTMP(N), PAR(N) For T = 1 To N TMP(T) = Worksheets(1).Cells(T + 1, 3).Value DelTMP(T) = Worksheets(1).Cells(T + 1, 4).Value MLD(T) = Worksheets(1).Cells(T + 1, 6).Value DelMLD(T) = Worksheets(1).Cells(T + 1, 7).Value PAR(T) = Worksheets(1).Cells(T + 1, 8).Value Next T '.............Output Initial and Parameter Values to Worksheet2....................... 'Worksheet2: Initial Values Worksheets(2).Activate Worksheets(2).Cells(1, 1).Value = "U_Nitrogen" Worksheets(2).Cells(1, 2).Value = U_Nitrogen Worksheets(2).Cells(2, 1).Value = "L_Nitrogen" Worksheets(2).Cells(2, 2).Value = L_Nitrogen Worksheets(2).Cells(3, 1).Value = "Diatoms " Worksheets(2).Cells(3, 2).Value = Diatoms Worksheets(2).Cells(4, 1).Value = "U_Copepods " Worksheets(2).Cells(4, 2).Value = U_Copepods Worksheets(2).Cells(5, 1).Value = "L_Copepods" Worksheets(2).Cells(5, 2).Value = L_Copepods Worksheets(2).Cells(6, 1).Value = "Euphausiids " Worksheets(2).Cells(6, 2).Value = Euphausiids Worksheets(2).Cells(7, 1).Value = "North_Sardine " Worksheets(2).Cells(7, 2).Value = North_Sardine Worksheets(2).Cells(8, 1).Value = "Sardine " Worksheets(2).Cells(8, 2).Value = Sardine Worksheets(2).Cells(9, 1).Value = "South_Sardine " Worksheets(2).Cells(9, 2).Value = South_Sardine Worksheets(2).Cells(10, 1).Value = "Pollock " Worksheets(2).Cells(10, 2).Value = Pollock Worksheets(2).Cells(1, 3).Value = "dt" Worksheets(2).Cells(1, 4).Value = dt Worksheets(2).Cells(2, 3).Value = "Output_Interval" Worksheets(2).Cells(2, 4).Value = Output_Interval Worksheets(2).Cells(3, 3).Value = "Mix_Rate" Worksheets(2).Cells(3, 4).Value = Mix_Rate Worksheets(2).Cells(4, 3).Value = "K_Attenu" Worksheets(2).Cells(4, 4).Value = K_Attenu Worksheets(2).Cells(5, 3).Value = "K_Shade" Worksheets(2).Cells(5, 4).Value = K_Shade Worksheets(2).Cells(6, 3).Value = "Max_Photosynth_Rate" Worksheets(2).Cells(6, 4).Value = Max_Photosynth_Rate Worksheets(2).Cells(7, 3).Value = "Platt_Alpha" Worksheets(2).Cells(7, 4).Value = Platt_Alpha Worksheets(2).Cells(8, 3).Value = "Platt_Betha" Worksheets(2).Cells(8, 4).Value = Platt_Betha Worksheets(2).Cells(9, 3).Value = "N_HSC" Worksheets(2).Cells(9, 4).Value = N_HSC Worksheets(2).Cells(10, 3).Value = "D_Respiration_Rate" Worksheets(2).Cells(10, 4).Value = D_Respiration_Rate Worksheets(2).Cells(11, 3).Value = "D_Loss_Rate" Worksheets(2).Cells(11, 4).Value = D_Loss_Rate Worksheets(2).Cells(12, 3).Value = "N_Uptake_Ratio" Worksheets(2).Cells(12, 4).Value = N_Uptake_Ratio Worksheets(2).Cells(13, 3).Value = "C_Growth_Efficiency" Worksheets(2).Cells(13, 4).Value = C_Growth_Efficiency Worksheets(2).Cells(14, 3).Value = "C_Max_Ingest_Rate" Worksheets(2).Cells(14, 4).Value = C_Max_Ingest_Rate Worksheets(2).Cells(15, 3).Value = "C_Feeding_HSC" Worksheets(2).Cells(15, 4).Value = C_Feeding_HSC Worksheets(2).Cells(16, 3).Value = "C_Rise_Rate" Worksheets(2).Cells(16, 4).Value = C_Rise_Rate Worksheets(2).Cells(17, 3).Value = "C_Sink_Rate" Worksheets(2).Cells(17, 4).Value = C_Sink_Rate Worksheets(2).Cells(18, 3).Value = "C_Loss_Rate" Worksheets(2).Cells(18, 4).Value = C_Loss_Rate Worksheets(2).Cells(19, 3).Value = "C_N_Excret_Rate" Worksheets(2).Cells(19, 4).Value = C_N_Excret_Rate Worksheets(2).Cells(1, 5).Value = "E_Growth_Efficiency" Worksheets(2).Cells(1, 6).Value = E_Growth_Efficiency Worksheets(2).Cells(2, 5).Value = "E_Max_Ing_Rate" Worksheets(2).Cells(2, 6).Value = E_Max_Ing_Rate Worksheets(2).Cells(3, 5).Value = "E_Feeding_HSC" Worksheets(2).Cells(3, 6).Value = E_Feeding_HSC Worksheets(2).Cells(4, 5).Value = "E_Rise_Rate" Worksheets(2).Cells(4, 6).Value = E_Rise_Rate Worksheets(2).Cells(5, 5).Value = "E_Sink_Rate" Worksheets(2).Cells(5, 6).Value = E_Sink_Rate Worksheets(2).Cells(6, 5).Value = "E_E_O_Pred_Rate" Worksheets(2).Cells(6, 6).Value = E_E_O_Pred_Rate Worksheets(2).Cells(7, 5).Value = "E_N_Excret_Rate" Worksheets(2).Cells(7, 6).Value = E_N_Excret_Rate Worksheets(2).Cells(8, 5).Value = "S_Growth_Efficiency" Worksheets(2).Cells(8, 6).Value = S_Growth_Efficiency Worksheets(2).Cells(9, 5).Value = "S_Max_Ing_Rate" Worksheets(2).Cells(9, 6).Value = S_Max_Ing_Rate Worksheets(2).Cells(10, 5).Value = "S_Feeding_HSC" Worksheets(2).Cells(10, 6).Value = S_Feeding_HSC Worksheets(2).Cells(11, 5).Value = "S_Catchability" Worksheets(2).Cells(11, 6).Value = S_Catchability Worksheets(2).Cells(12, 5).Value = "S_Mig_Rate " Worksheets(2).Cells(12, 6).Value = S_Mig_Rate Worksheets(2).Cells(13, 5).Value = "S_N_Excret_Rate" Worksheets(2).Cells(13, 6).Value = S_N_Excret_Rate Worksheets(2).Cells(14, 5).Value = "P_Growth_Efficiency" Worksheets(2).Cells(14, 6).Value = P_Growth_Efficiency Worksheets(2).Cells(15, 5).Value = "P_Max_Ing_Rate" Worksheets(2).Cells(15, 6).Value = P_Max_Ing_Rate Worksheets(2).Cells(16, 5).Value = "P_Forage_CandE_Ratio" Worksheets(2).Cells(16, 6).Value = P_Forage_CandE_Ratio Worksheets(2).Cells(17, 5).Value = "P_C_Pref" Worksheets(2).Cells(17, 6).Value = P_C_Pref Worksheets(2).Cells(18, 5).Value = "P_Feeding_HSC" Worksheets(2).Cells(18, 6).Value = P_Feeding_HSC Worksheets(2).Cells(19, 5).Value = "P_Catchability " Worksheets(2).Cells(19, 6).Value = P_Catchability Worksheets(2).Cells(20, 5).Value = "P_Naturl_Mort_Rate" Worksheets(2).Cells(20, 6).Value = P_Naturl_Mort_Rate Columns("A:A").Select Selection.Columns.AutoFit Columns("C:C").Select Selection.Columns.AutoFit Columns("E:E").Select Selection.Columns.AutoFit '....................Output Titles on Worksheet3....................... 'Worksheet3: Biomass of Functional Groups Worksheets(3).Activate Worksheets(3).Cells(1, 1).Value = "Date" Worksheets(3).Cells(1, 2).Value = "U_Nitrogen" Worksheets(3).Cells(1, 3).Value = "Diatoms" Worksheets(3).Cells(1, 4).Value = "U_Copepods" Worksheets(3).Cells(1, 5).Value = "L_Copepods" Worksheets(3).Cells(1, 6).Value = "Euphausiids" Worksheets(3).Cells(1, 7).Value = "L_Euphausiids" Worksheets(3).Cells(1, 8).Value = "Sardine" Worksheets(3).Cells(1, 9).Value = "N_Sardine" Worksheets(3).Cells(1, 10).Value = "S_Sardine" Worksheets(3).Cells(1, 11).Value = "Pollock" Worksheets(3).Cells(1, 12).Value = "N_Flux" Worksheets(3).Cells(1, 13).Value = "D_Growth_Rate" Worksheets(3).Cells(1, 14).Value = "C_Growth_Rate" Worksheets(3).Cells(1, 15).Value = "E_Growth_Rate" Worksheets(3).Cells(1, 16).Value = "S_Growth_Rate" Worksheets(3).Cells(1, 17).Value = "P_Growth_Rate" 'Worksheet4: Balance Terms 'Nutrient Balance Terms Worksheets(4).Activate Worksheets(4).Cells(1, 1).Value = "Date" Col_4 = 1 If Show_N_Balance = 1 Then Worksheets(4).Cells(1, 2).Value = "N_Flux" Worksheets(4).Cells(1, 3).Value = "N_flux_DelMLD_Rate" Worksheets(4).Cells(1, 4).Value = "N_flux_Mix_Rate" Worksheets(4).Cells(1, 5).Value = "N_Supply" Worksheets(4).Cells(1, 6).Value = "N_Uptake" Worksheets(4).Cells(1, 7).Value = "N_excrt_Cope_Rate" Worksheets(4).Cells(1, 8).Value = "N_excrt_Euph_Rate" Worksheets(4).Cells(1, 9).Value = "N_excrt_Sard_Rate" Col_4 = 9 End If If Show_D_Balance = 1 Then Worksheets(4).Cells(1, Col_4 + 1).Value = "D_Growth_Rate" Worksheets(4).Cells(1, Col_4 + 2).Value = "D_Loss" Worksheets(4).Cells(1, Col_4 + 3).Value = "D_E_C_Rate" Worksheets(4).Cells(1, Col_4 + 4).Value = "D_E_E_Rate" Worksheets(4).Cells(1, Col_4 + 5).Value = "D_E_S_Rate" Col_4 = Col_4 + 5 End If If Show_C_Balance = 1 Then Worksheets(4).Cells(1, Col_4 + 1).Value = "C_Growth_Rate" Worksheets(4).Cells(1, Col_4 + 2).Value = "C_Rise" Worksheets(4).Cells(1, Col_4 + 3).Value = "C_Sink" Worksheets(4).Cells(1, Col_4 + 4).Value = "C_Loss" Worksheets(4).Cells(1, Col_4 + 5).Value = "C_E_E_Rate" Worksheets(4).Cells(1, Col_4 + 6).Value = "C_E_S_Rate" Worksheets(4).Cells(1, Col_4 + 7).Value = "C_E_P_Rate" Col_4 = Col_4 + 7 End If If Show_E_Balance = 1 Then Worksheets(4).Cells(1, Col_4 + 1).Value = "E_Growth_Rate" Worksheets(4).Cells(1, Col_4 + 2).Value = "E_Rise" Worksheets(4).Cells(1, Col_4 + 3).Value = "E_Sink" Worksheets(4).Cells(1, Col_4 + 4).Value = "E_E_S_Rate" Worksheets(4).Cells(1, Col_4 + 5).Value = "E_E_P_Rate" Worksheets(4).Cells(1, Col_4 + 6).Value = "E_E_O_Rate" Col_4 = Col_4 + 6 End If If Show_S_Balance = 1 Then Worksheets(4).Cells(1, Col_4 + 1).Value = "S_Growth_Rate" Worksheets(4).Cells(1, Col_4 + 2).Value = "S_Mig_S_D" Worksheets(4).Cells(1, Col_4 + 3).Value = "S_Mig_N_D" Worksheets(4).Cells(1, Col_4 + 4).Value = "S_Mig_D_N" Worksheets(4).Cells(1, Col_4 + 5).Value = "S_Mig_D_S" Worksheets(4).Cells(1, Col_4 + 6).Value = "S_Catch_Rate" Col_4 = Col_4 + 6 End If If Show_P_Balance = 1 Then Worksheets(4).Cells(1, Col_4 + 1).Value = "P_Growth_Rate" Worksheets(4).Cells(1, Col_4 + 2).Value = "P_Naturl_Mort" Worksheets(4).Cells(1, Col_4 + 3).Value = "P_Catch_Rate" Col_4 = Col_4 + 3 End If '====================Start of MAIN LOOP=========================== For T = 1 To N '....................................Forcing Processes ..................... Light_Extinc = K_Attenu + K_Shade * Diatoms Light = (PAR(T) / (MLD(T) * Light_Extinc)) * (1 - Exp(-Light_Extinc * MLD(T))) Q10 = 0.31 * Exp(0.069 * TMP(T)) '..................................Diatoms Processes .................................. Light_Factor = (1 - Exp(-Platt_Alpha * PAR(T) / Max_Photosynth_Rate)) _ * Exp(-Platt_Betha * PAR(T) / Max_Photosynth_Rate) N_Factor = U_Nitrogen / (N_HSC + U_Nitrogen) D_Growth_Rate = Max_Photosynth_Rate * Q10 * Light_Factor * N_Factor _ * (1# - D_Respiration_Rate) * Diatoms If D_Growth_Rate > 5# Then D_Sinking_Speed = 0.3 Else D_Sinking_Speed = 0.6 End If If Diatoms < 5# Then D_Loss = 0# Else D_Loss = ((D_Sinking_Speed / MLD(T)) + D_Loss_Rate) * Diatoms End If '...........................Copepods Processes ................................. 'Copepods Ingestion If Diatoms > 5# And TMP(T) > 4# Then C_Ingestion = (C_Max_Ingest_Rate * Q10 * U_Copepods) _ * ((Diatoms - 5#) / (C_Feeding_HSC + Diatoms - 5#)) Else C_Ingestion = 0# End If 'Copepods Growth Rate C_Growth_Rate = C_Ingestion * C_Growth_Efficiency 'Copepods Seasonal Vertical Migration among Upper- and Lower-Layer If D_Growth_Rate > 6# Then C_Rise = (C_Rise_Rate * L_Copepods) Else C_Rise = 0# End If If D_Growth_Rate < 2# And U_Copepods > 0# Then C_Sink = (C_Sink_Rate * U_Copepods) Else C_Sink = 0# End If 'Copepods Loss If U_Copepods > 5# Then C_Loss = (C_Loss_Rate * U_Copepods) Else C_Loss = 0# End If 'Copepods feeding on Diatoms If Diatoms > 5# Then D_E_C_Rate = C_Ingestion Else D_E_C_Rate = 0# End If '................................Euphausiids Processes .................................. If TMP(T) > 3# Then E_Ingestion = (E_Max_Ing_Rate * Q10 * ((Diatoms + L_Limit(U_Copepods, 5#) _ * U_Copepods) / (L_Limit(U_Copepods, 5#) * U_Copepods + Diatoms _ + E_Feeding_HSC)) * Euphausiids) Else E_Ingestion = 0# End If 'Euphausiids Growth E_Growth_Rate = E_Ingestion * E_Growth_Efficiency 'Euphausiids Seasonal Vertical Migration If C_Growth_Rate > 0.01 And T < 200 And L_Euphausiids > 0# Then E_Rise = E_Rise_Rate * L_Euphausiids Else E_Rise = 0# End If If C_Growth_Rate < 0.5 And T > 230 And Euphausiids > 0# Then E_Sink = E_Sink_Rate * Euphausiids Else E_Sink = 0# End If 'Euphausiids predation on Diatom and Copepods D_E_E_Rate = (Diatoms / (L_Limit(U_Copepods, 5#) * U_Copepods + Diatoms)) * E_Ingestion C_E_E_Rate = E_Ingestion * L_Limit(U_Copepods, 5#) * U_Copepods _ / (L_Limit(U_Copepods, 5#) * U_Copepods + Diatoms) 'Euphausiids eaten by predator other than sardine and pollock If TMP(T) > 3# And Euphausiids > 0# Then E_E_O_Rate = (E_E_O_Pred_Rate * Euphausiids) Else E_E_O_Rate = 0# End If '................................Sardine Processes ...................................... 'Sardin Ingestion If Sardine > 0# Then S_Ingestion = (S_Max_Ing_Rate * ((Diatoms + L_Limit(U_Copepods, 5#) _ * U_Copepods + Euphausiids) / (Diatoms + L_Limit(U_Copepods, 5#) _ * U_Copepods + Euphausiids + S_Feeding_HSC)) * Sardine) Else S_Ingestion = 0# End If S_Growth_Rate = S_Ingestion * S_Growth_Efficiency If TMP(T) > 10# And TMP(T) < 16# And T >= 96 And T <= 249 Then S_Mig_S_D = (S_Mig_Rate * South_Sardine) Else S_Mig_S_D = 0# End If If TMP(T) >= 16# And T >= 96 And T <= 249 And Sardine > 0# Then S_Mig_D_N = S_Mig_Rate * Sardine Else S_Mig_D_N = 0# End If If TMP(T) < 16# And T > 249 And North_Sardine > 0# Then S_Mig_N_D = S_Mig_Rate * North_Sardine Else S_Mig_N_D = 0# End If If TMP(T) < 13# And T > 249 And Sardine > 0# Then S_Mig_D_S = S_Mig_Rate * Sardine Else S_Mig_D_S = 0# End If If T > 181 And T < 305 And Sardine > 5# Then S_Catch_Rate = (S_Catchability * Sardine) Else S_Catch_Rate = 0# End If If Diatoms > 5# Then D_E_S_Rate = ((Diatoms / (Diatoms + L_Limit(U_Copepods, 5#) * U_Copepods _ + Euphausiids)) * S_Ingestion) Else D_E_S_Rate = 0# End If C_E_S_Rate = S_Ingestion * L_Limit(U_Copepods, 5#) * U_Copepods _ / (Diatoms + Euphausiids + L_Limit(U_Copepods, 5#) * U_Copepods) E_E_S_Rate = S_Ingestion * (Euphausiids / (Diatoms + L_Limit(U_Copepods, 5#) * U_Copepods _ + Euphausiids)) '............................Pollock Processes ................................... P_Ingestion = P_Max_Ing_Rate * Pollock * ((P_C_Pref * L_Limit(U_Copepods, 5#) _ * U_Copepods + Euphausiids) / (P_C_Pref * L_Limit(U_Copepods, 5#) _ * U_Copepods + Euphausiids + P_Feeding_HSC)) / P_Forage_CandE_Ratio P_Growth_Rate = P_Growth_Efficiency * P_Ingestion If U_Copepods < 5# And Euphausiids = 0# Then C_E_P_Rate = 0# E_E_P_Rate = 0# Else C_E_P_Rate = (P_C_Pref * L_Limit(U_Copepods, 5#) * U_Copepods) _ / (P_C_Pref * L_Limit(U_Copepods, 5#) * U_Copepods + Euphausiids) _ * P_Ingestion E_E_P_Rate = P_Ingestion * (Euphausiids) / (P_C_Pref * L_Limit(U_Copepods, 5#) _ * U_Copepods + Euphausiids) End If If T < 152 Or T > 213 Then P_Catch_Rate = (P_Catchability * Pollock) Else P_Catch_Rate = 0# End If If T < 152 Or T > 213 Then P_Catch_Rate = (P_Catchability * Pollock) Else P_Catch_Rate = 0# End If P_Naturl_Mort = P_Naturl_Mort_Rate * Pollock '.................................Nitrogen Processes .......................... N_Supply = (C_N_Excret_Rate * C_Ingestion / MLD(T)) + (E_N_Excret_Rate * E_Ingestion / MLD(T)) _ + (S_N_Excret_Rate * S_Ingestion / MLD(T)) If DelMLD(T) < 0# Then N_Flux = (Mix_Rate * (L_Nitrogen - U_Nitrogen) / MLD(T)) Else N_Flux = ((Mix_Rate + DelMLD(T)) * (L_Nitrogen - U_Nitrogen) / MLD(T)) End If If U_Nitrogen > 0# Then N_Uptake = ((N_Uptake_Ratio * D_Growth_Rate) / MLD(T)) Else N_Uptake = 0# End If 'For Flux monitoring N_excrt_Cope_Rate = C_N_Excret_Rate * C_Ingestion / MLD(T) N_excrt_Euph_Rate = E_N_Excret_Rate * E_Ingestion / MLD(T) N_excrt_Sard_Rate = S_N_Excret_Rate * S_Ingestion / MLD(T) N_flux_DelMLD_Rate = L_Limit(DelMLD(T), 0#) * DelMLD(T) * (L_Nitrogen - U_Nitrogen) _ / MLD(T) N_flux_Mix_Rate = Mix_Rate * (L_Nitrogen - U_Nitrogen) / MLD(T) N_Uptake_Rate = L_Limit(U_Nitrogen, 0#) * N_Uptake_Ratio * D_Growth_Rate / MLD(T) '=====================Integration ========================== ' Integration by Forward Scheme '.......................Nitrogen..................................... U_Nitrogen = U_Nitrogen + (N_Supply + N_Flux - N_Uptake) * dt 'For Flux monitoring Total_N_Flux_DelMLD = Total_N_Flux_DelMLD + (N_flux_DelMLD_Rate) * dt Total_N_flux_Mixing = Total_N_flux_Mixing + (N_flux_Mix_Rate) * dt Total_N_excrt_Cope = Total_N_excrt_Cope + (N_excrt_Cope_Rate) * dt Total_N_excrt_Sard = Total_N_excrt_Sard + (N_excrt_Sard_Rate) * dt Total_N_excrt_Euph = Total_N_excrt_Euph + (N_excrt_Euph_Rate) * dt Total_N_Uptake = Total_N_Uptake + (N_Uptake_Rate) * dt '.........................Diatoms..................................... Diatoms = Diatoms + (D_Growth_Rate - D_Loss - D_E_S_Rate - D_E_E_Rate - D_E_C_Rate) _ * dt 'For Flux monitoring Primary_Production = Primary_Production + (D_Growth_Rate) * dt Total_Diatoms_Lost = Total_Diatoms_Lost + (D_Loss) * dt Total_Diatom_Eaten_C = Total_Diatom_Eaten_C + (D_E_C_Rate) * dt Total_Diatom_Eaten_E = Total_Diatom_Eaten_E + (D_E_E_Rate) * dt Total_Diatom_Eaten_S = Total_Diatom_Eaten_S + (D_E_S_Rate) * dt '.............................Copepods............................... U_Copepods = U_Copepods + (C_Growth_Rate + C_Rise - C_Sink - C_Loss - C_E_S_Rate _ - C_E_E_Rate - C_E_P_Rate) * dt L_Copepods = L_Copepods + (C_Sink - C_Rise) * dt 'For Flux monitoring C_Production = C_Production + (C_Growth_Rate) * dt Total_Copepods_Eaten_E = Total_Copepods_Eaten_E + (C_E_E_Rate) * dt Total_Copepods_Eaten_P = Total_Copepods_Eaten_P + (C_E_P_Rate) * dt Total_Copepods_Eaten_S = Total_Copepods_Eaten_S + (C_E_S_Rate) * dt Total_Copepods_Lost = Total_Copepods_Lost + (C_Loss) * dt '.............................Euphausiids............................. Euphausiids = Euphausiids + (E_Growth_Rate + E_Rise - E_Sink - E_E_P_Rate _ - E_E_O_Rate - E_E_S_Rate) * dt L_Euphausiids = L_Euphausiids + (E_Sink - E_Rise) * dt 'For Flux monitoring E_Production = E_Production + (E_Growth_Rate) * dt Total_E_Eaten_S = Total_E_Eaten_S + (E_E_S_Rate) * dt Total_E_Eaten_P = Total_E_Eaten_P + (E_E_P_Rate) * dt Total_E_Eaten_Others = Total_E_Eaten_Others + (E_E_O_Rate) * dt '..............................Sardine................................ Sardine = Sardine + (S_Mig_N_D + S_Mig_S_D + S_Growth_Rate - S_Mig_D_N - S_Mig_D_S _ - S_Catch_Rate) * dt South_Sardine = South_Sardine + (S_Mig_D_S - S_Mig_S_D) * dt North_Sardine = North_Sardine + (S_Mig_D_N - S_Mig_N_D) * dt 'For Flux monitoring Sardine_Catch = Sardine_Catch + (S_Catch_Rate) * dt S_Production = S_Production + (S_Growth_Rate) * dt '................................Pollock.............................. Pollock = Pollock + (P_Growth_Rate - P_Naturl_Mort - P_Catch_Rate) * dt 'For Flux monitoring P_Production = P_Production + (P_Growth_Rate) * dt Pollock_Catch = Pollock_Catch + (P_Catch_Rate) * dt P_Mortality = P_Mortality + (P_Naturl_Mort) * dt '--------------------------------Output--------------------------------- 'Biomass of Ecosystem Components If T = 1 Then Row_3 = 2 If T Mod Output_Interval = 0 Then Row_3 = Row_3 + 1 If T = 1 Or T Mod Output_Interval = 0 Or T = 365 Then Worksheets(3).Cells(Row_3, 1).Value = T Worksheets(3).Cells(Row_3, 2).Value = U_Nitrogen Worksheets(3).Cells(Row_3, 3).Value = Diatoms Worksheets(3).Cells(Row_3, 4).Value = U_Copepods Worksheets(3).Cells(Row_3, 5).Value = L_Copepods Worksheets(3).Cells(Row_3, 6).Value = Euphausiids Worksheets(3).Cells(Row_3, 7).Value = L_Euphausiids Worksheets(3).Cells(Row_3, 8).Value = Sardine Worksheets(3).Cells(Row_3, 9).Value = North_Sardine Worksheets(3).Cells(Row_3, 10).Value = South_Sardine Worksheets(3).Cells(Row_3, 11).Value = Pollock Worksheets(3).Cells(Row_3, 12).Value = N_Flux Worksheets(3).Cells(Row_3, 13).Value = D_Growth_Rate Worksheets(3).Cells(Row_3, 14).Value = C_Growth_Rate Worksheets(3).Cells(Row_3, 15).Value = E_Growth_Rate Worksheets(3).Cells(Row_3, 16).Value = S_Growth_Rate Worksheets(3).Cells(Row_3, 17).Value = P_Growth_Rate End If 'Worksheet4: Balance Terms 'Nutrient Balance Terms If T = 1 Then Row_4 = 2 If T Mod Output_Interval = 0 Then Row_4 = Row_4 + 1 If T = 1 Or T Mod Output_Interval = 0 Or T = 365 Then Worksheets(4).Activate Worksheets(4).Cells(Row_4, 1).Value = T Col_4 = 1 If Show_N_Balance = 1 Then Worksheets(4).Cells(Row_4, 2).Value = N_Flux Worksheets(4).Cells(Row_4, 3).Value = N_flux_DelMLD_Rate Worksheets(4).Cells(Row_4, 4).Value = N_flux_Mix_Rate Worksheets(4).Cells(Row_4, 5).Value = N_Supply Worksheets(4).Cells(Row_4, 6).Value = N_Uptake Worksheets(4).Cells(Row_4, 7).Value = N_excrt_Cope_Rate Worksheets(4).Cells(Row_4, 8).Value = N_excrt_Euph_Rate Worksheets(4).Cells(Row_4, 9).Value = N_excrt_Sard_Rate Col_4 = 9 End If If Show_D_Balance = 1 Then Worksheets(4).Cells(Row_4, Col_4 + 1).Value = D_Growth_Rate Worksheets(4).Cells(Row_4, Col_4 + 2).Value = D_Loss Worksheets(4).Cells(Row_4, Col_4 + 3).Value = D_E_C_Rate Worksheets(4).Cells(Row_4, Col_4 + 4).Value = D_E_E_Rate Worksheets(4).Cells(Row_4, Col_4 + 5).Value = D_E_S_Rate Col_4 = Col_4 + 5 End If If Show_C_Balance = 1 Then Worksheets(4).Cells(Row_4, Col_4 + 1).Value = C_Growth_Rate Worksheets(4).Cells(Row_4, Col_4 + 2).Value = C_Rise Worksheets(4).Cells(Row_4, Col_4 + 3).Value = C_Sink Worksheets(4).Cells(Row_4, Col_4 + 4).Value = C_Loss Worksheets(4).Cells(Row_4, Col_4 + 5).Value = C_E_E_Rate Worksheets(4).Cells(Row_4, Col_4 + 6).Value = C_E_S_Rate Worksheets(4).Cells(Row_4, Col_4 + 7).Value = C_E_P_Rate Col_4 = Col_4 + 7 End If If Show_E_Balance = 1 Then Worksheets(4).Cells(Row_4, Col_4 + 1).Value = E_Growth_Rate Worksheets(4).Cells(Row_4, Col_4 + 2).Value = E_Rise Worksheets(4).Cells(Row_4, Col_4 + 3).Value = E_Sink Worksheets(4).Cells(Row_4, Col_4 + 4).Value = E_E_S_Rate Worksheets(4).Cells(Row_4, Col_4 + 5).Value = E_E_P_Rate Worksheets(4).Cells(Row_4, Col_4 + 6).Value = E_E_O_Rate Col_4 = Col_4 + 6 End If If Show_S_Balance = 1 Then Worksheets(4).Cells(Row_4, Col_4 + 1).Value = S_Growth_Rate Worksheets(4).Cells(Row_4, Col_4 + 2).Value = S_Mig_S_D Worksheets(4).Cells(Row_4, Col_4 + 3).Value = S_Mig_N_D Worksheets(4).Cells(Row_4, Col_4 + 4).Value = S_Mig_D_N Worksheets(4).Cells(Row_4, Col_4 + 5).Value = S_Mig_D_S Worksheets(4).Cells(Row_4, Col_4 + 6).Value = S_Catch_Rate Col_4 = Col_4 + 6 End If If Show_P_Balance = 1 Then Worksheets(4).Cells(Row_4, Col_4 + 1).Value = P_Growth_Rate Worksheets(4).Cells(Row_4, Col_4 + 2).Value = P_Naturl_Mort Worksheets(4).Cells(Row_4, Col_4 + 3).Value = P_Catch_Rate Col_4 = Col_4 + 3 End If End If Next T '============ End of Main Loop =========================== '....Output Total Mass-Balance of Each Components to Worksheet5.............. 'Worksheet5: Total Annual Mass-Balance Terms Worksheets(5).Activate Worksheets(5).Cells(1, 1).Value = "Total_N_Flux_DelMLD" Worksheets(5).Cells(1, 2).Value = Total_N_Flux_DelMLD Worksheets(5).Cells(2, 1).Value = "Total_N_flux_Mixing" Worksheets(5).Cells(2, 2).Value = Total_N_flux_Mixing Worksheets(5).Cells(3, 1).Value = "Total_N_Uptake" Worksheets(5).Cells(3, 2).Value = Total_N_Uptake Worksheets(5).Cells(4, 1).Value = "Total_N_excrt_Cope" Worksheets(5).Cells(4, 2).Value = Total_N_excrt_Cope Worksheets(5).Cells(5, 1).Value = "Total_N_excrt_Euph" Worksheets(5).Cells(5, 2).Value = Total_N_excrt_Euph Worksheets(5).Cells(6, 1).Value = "Total_N_excrt_Sard" Worksheets(5).Cells(6, 2).Value = Total_N_excrt_Sard Worksheets(5).Cells(8, 1).Value = "Primary_Production" Worksheets(5).Cells(8, 2).Value = Primary_Production Worksheets(5).Cells(9, 1).Value = "Total_Diatoms_Lost" Worksheets(5).Cells(9, 2).Value = Total_Diatoms_Lost Worksheets(5).Cells(10, 1).Value = "Total_Diatom_Eaten_C" Worksheets(5).Cells(10, 2).Value = Total_Diatom_Eaten_C Worksheets(5).Cells(11, 1).Value = "Total_Diatom_Eaten_E" Worksheets(5).Cells(11, 2).Value = Total_Diatom_Eaten_E Worksheets(5).Cells(12, 1).Value = "Total_Diatom_Eaten_S" Worksheets(5).Cells(12, 2).Value = Total_Diatom_Eaten_S Worksheets(5).Cells(1, 3).Value = "C_Production" Worksheets(5).Cells(1, 4).Value = C_Production Worksheets(5).Cells(2, 3).Value = "Total_Copepods_Eaten_E " Worksheets(5).Cells(2, 4).Value = Total_Copepods_Eaten_E Worksheets(5).Cells(3, 3).Value = "Total_Copepods_Eaten_S" Worksheets(5).Cells(3, 4).Value = Total_Copepods_Eaten_S Worksheets(5).Cells(4, 3).Value = "Total_Copepods_Eaten_P" Worksheets(5).Cells(4, 4).Value = Total_Copepods_Eaten_P Worksheets(5).Cells(5, 3).Value = "Total_Copepods_Lost" Worksheets(5).Cells(5, 4).Value = Total_Copepods_Lost Worksheets(5).Cells(7, 3).Value = "E_Production" Worksheets(5).Cells(7, 4).Value = E_Production Worksheets(5).Cells(8, 3).Value = "Total_E_Eaten_S" Worksheets(5).Cells(8, 4).Value = Total_E_Eaten_S Worksheets(5).Cells(9, 3).Value = "Total_E_Eaten_P" Worksheets(5).Cells(9, 4).Value = Total_E_Eaten_P Worksheets(5).Cells(10, 3).Value = "Total_E_Eaten_Others" Worksheets(5).Cells(10, 4).Value = Total_E_Eaten_Others Worksheets(5).Cells(12, 3).Value = "S_Production" Worksheets(5).Cells(12, 4).Value = S_Production Worksheets(5).Cells(13, 3).Value = "Sardine_Catch" Worksheets(5).Cells(13, 4).Value = Sardine_Catch Worksheets(5).Cells(15, 3).Value = "P_Production" Worksheets(5).Cells(15, 4).Value = P_Production Worksheets(5).Cells(16, 3).Value = "P_Mortality" Worksheets(5).Cells(16, 4).Value = P_Mortality Worksheets(5).Cells(17, 3).Value = "Pollock_Catch" Worksheets(5).Cells(17, 4).Value = Pollock_Catch Columns("A:A").Select Selection.Columns.AutoFit Columns("C:C").Select Selection.Columns.AutoFit Exit Sub Error_Handler: Const Title = "エラー" MsgBox "エラーです" & Chr(13) & Chr(13) & _ "エラー番号    =" & Err.Number & Chr(13) & _ "エラー・メッセージ=" & Err.Description End Sub '********************************************************************** Function L_Limit(A!, B!) '++++++++++++++++++++++++++++++++++++++++++++++++++++++ If A! >= B! Then L_Limit = 1# Else L_Limit = 0# End If End Function '++++++++++++++++++++++++++++++++++++++++++++++++++++++