diff --git a/doc/source/_static/bib/references.bib b/doc/source/_static/bib/references.bib index 12f378d7..913ca687 100644 --- a/doc/source/_static/bib/references.bib +++ b/doc/source/_static/bib/references.bib @@ -1295,5 +1295,34 @@ @book{monnier2021coursevariational url = {https://www.math.univ-toulouse.fr/~jmonnie/Enseignement/CourseVDA.pdf} } +@article{Astagneau_2022, +author = {Paul C. Astagneau and François Bourgin and Vazken Andréassian and Charles Perrin}, +title = {Catchment response to intense rainfall: Evaluating modelling hypotheses}, +journal = {Hydrological Processes}, +volume = {26}, +number = {e14676}, +year = {2022}, +doi = {10.1080/02626667.2021.1923720}, + +URL = { + https://doi.org/10.1002/hyp.14676 + +}, +eprint = { + https://doi.org/10.1002/hyp.14676 +} +} + +@Article{hess-22-5317-2018, +AUTHOR = {Douinot, A. and Roux, H. and Garambois, P.-A. and Dartus, D.}, +TITLE = {Using a multi-hypothesis framework to improve the understanding of flow dynamics during flash floods}, +JOURNAL = {Hydrology and Earth System Sciences}, +VOLUME = {22}, +YEAR = {2018}, +NUMBER = {10}, +PAGES = {5317--5340}, +URL = {https://hess.copernicus.org/articles/22/5317/2018/}, +DOI = {10.5194/hess-22-5317-2018} +} @Comment{jabref-meta: databaseType:bibtex;} diff --git a/doc/source/math_num_documentation/forward_structure.rst b/doc/source/math_num_documentation/forward_structure.rst index 7249ade9..42144591 100644 --- a/doc/source/math_num_documentation/forward_structure.rst +++ b/doc/source/math_num_documentation/forward_structure.rst @@ -351,8 +351,120 @@ Hydrological processes can be described at pixel scale in `smash` with one of th Same as ``gr4`` transfer, see :ref:`GR4 Transfer ` -.. _math_num_documentation.forward_structure.hydrological_module.gr6: +.. _math_num_documentation.forward_structure.hydrological_module.gr5_ri: + +.. dropdown:: gr5_ri (Génie Rural 5 with rainfall intensity terms) + :animate: fade-in-slide-down + + This hydrological module is derived from the model introduced in :cite:p:`Astagneau_2022`. + + + **Production** + + + In the classical gr production reservoir formulation, the instantaneous production rate is the ratio between the state and the capacity of the reservoir, + :math:`\eta = \left( \frac{h_p}{c_p} \right)^2`. The infiltration flux :math:p_s is obtained by temporal integration as follows: + + .. math:: + :nowrap: + + \begin{eqnarray} + + &p_s = \int_{t-\Delta t}^{t} (1 - \eta) dt \\ + + \end{eqnarray} + + Assuming the neutralized rainfall :math:p_n constant over the current time step and thanks to analytically integrable function, the infiltration flux into the production reservoir is obtained: + + .. math:: + :nowrap: + + \begin{eqnarray} + + &p_s = & c_p \tanh\left(\frac{p_n}{c_p}\right) \frac{1 - \left( \frac{h_p}{c_p} \right)^2}{1 + \frac{h_p}{c_p} \tanh\left( \frac{p_n}{c_p} \right)} \\ + + \end{eqnarray} + + To improve runoff production by a gr reservoir, + even with low production level in dry condition, + in the case of high rainfall intensity, :cite:p:`Astagneau_2022` suggests a modification + of the infiltration rate :math:p_s depending on rainfall intensity :math:p_n: + :math:`\eta = \left( 1 - \gamma \right) \left( \frac{h_p}{c_p} \right)^2 + \gamma` with :math:`\gamma = 1 - \exp(-p_n \times \alpha_1)` + and :math:`\alpha_1` in :math:`mm` per time unit. + + .. math:: + :nowrap: + + \begin{eqnarray} + + &p_s& &=& &\int_{t-\Delta t}^{t} (1 - \eta) dt\\ + + && &=& &\int_{t-\Delta t}^{t} \left(1 - (1-\gamma) \left(\frac{h_p}{c_p} \right)^2 \right) dt - \int_{t-\Delta t}^{t} \gamma dt\\ + + && &=& &\left[ \frac{ c_p }{ \sqrt{1-\gamma} } \tanh \left( \frac{\sqrt{1-\gamma} \ h_p}{c_p} \right) \right]_{t-\Delta t}^t - \gamma \Delta t + + \end{eqnarray} + + + We denote :math:`\lambda := \sqrt{1 - \gamma}`, then + .. math:: + :nowrap: + + \begin{eqnarray} + + \tanh \left( \lambda \frac{h_p + p_n}{c_p} \right) - \tanh\left( \lambda \frac{h_p}{c_p} \right) &=& + \tanh \left( \lambda \frac{p_n}{c_p} \right) \left(1 - \tanh \left( \lambda \frac{h_p + p_n}{c_p} \right) \tanh \left( \lambda \frac{h_p}{c_p} \right) \right) \\ + &=& \tanh \left( \lambda \frac{p_n}{c_p} \right) \left(1 - \frac{ \tanh \left( \lambda \frac{h_p}{c_p} \right) + \tanh \left( \lambda \frac{p_n}{c_p} \right) } { 1 + \tanh \left( \lambda \frac{h_p}{c_p} \right) \tanh \left( \lambda \frac{p_n}{c_p} \right) } \tanh \left( \lambda \frac{h_p}{c_p} \right) \right) \\ + &\sim& \tanh \left( \lambda \frac{p_n}{c_p} \right) \left(1 - \frac{ \lambda \frac{h_p}{c_p} + \tanh \left( \lambda \frac{p_n}{c_p} \right) } { 1 + \lambda \frac{h_p}{c_p} \tanh \left( \lambda \frac{p_n}{c_p} \right) } \lambda \frac{h_p}{c_p} \right) \\ + &=& \tanh \left( \lambda \frac{p_n}{c_p} \right) \frac{1 - \left( \lambda \frac{h_p}{c_p} \right)^2}{1 + \lambda \frac{h_p}{c_p} \tanh \left( \lambda \frac{p_n}{c_p} \right)} + \end{eqnarray} + + Thus + + .. math:: + :nowrap: + + \begin{eqnarray} + + p_s &=& \frac{c_p}{\lambda} \tanh \left( \lambda \frac{p_n}{c_p} \right) \frac{1 - \left( \lambda \frac{h_p}{c_p} \right)^2}{1 + \lambda \frac{h_p}{c_p} \tanh \left( \lambda \frac{p_n}{c_p} \right)} - \gamma \Delta t + \end{eqnarray} + + + .. note:: + + Note that if :math:`\alpha_1 = 0`, we return to the general writting of the instantaneous production rate. + + + **Transfer** + + In context of high rainfall intensities triggering flash flood responses, it is crucial to account for fast dynamics related to surface/hypodermic runoff + and slower responses due to delayed/deeper flows (e.g. :cite:p:`hess-22-5317-2018`). + Following :cite:p:`Astagneau_2022` for a lumped GR model, we introduce at pixel scale in `smash` a function to modify the partitioning between fast + and slower transfert branches depending on rainfall intensity of the current time step only (small pixel size): + + .. math:: + :nowrap: + + \begin{eqnarray} + + &p_{rr}& =& (1 - Q_9)(p_r + p_{erc}) + l_{exc}\\ + &p_{rd}& =& Q_9(p_r + p_{erc}) \\ + &Q_9& =& 0.9 \tanh(\alpha_2 p_n)^2 + 0.1 + + \end{eqnarray} + + with :math:`\alpha_2` in :math:`mm` per time unit. + + + .. note:: + + If :math:`\alpha_2 = 0`, we return to the ``gr-4/gr-5`` writting of the transfer. + If :math:`\alpha_2 = \alpha_1 = 0`, it is equivalent to ``gr-5`` structure. + + + +.. _math_num_documentation.forward_structure.hydrological_module.gr6: .. dropdown:: gr6 (Génie Rural 6) :animate: fade-in-slide-down diff --git a/smash/_constant.py b/smash/_constant.py index a1c3d4dc..4d791cd0 100644 --- a/smash/_constant.py +++ b/smash/_constant.py @@ -64,10 +64,12 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron HYDROLOGICAL_MODULE = [ "gr4", + "gr4_ri", "gr4_mlp", "gr4_ode", "gr4_ode_mlp", "gr5", + "gr5_ri", "gr6", "grc", "grd", @@ -97,10 +99,12 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron HYDROLOGICAL_MODULE, [ ["ci", "cp", "ct", "kexc"], # % gr4 + ["ci", "cp", "ct", "alpha1", "alpha2", "kexc"], # % gr4_ri ["ci", "cp", "ct", "kexc"], # % gr4_mlp ["ci", "cp", "ct", "kexc"], # % gr4_ode ["ci", "cp", "ct", "kexc"], # % gr4_ode_mlp ["ci", "cp", "ct", "kexc", "aexc"], # % gr5 + ["ci", "cp", "ct", "alpha1", "alpha2", "kexc", "aexc"], # % gr5_ri ["ci", "cp", "ct", "be", "kexc", "aexc"], # % gr6 ["ci", "cp", "ct", "cl", "kexc"], # % grc ["cp", "ct"], # % grd @@ -139,10 +143,12 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron HYDROLOGICAL_MODULE, [ ["hi", "hp", "ht"], # % gr4 + ["hi", "hp", "ht"], # % gr4_ri ["hi", "hp", "ht"], # % gr4_mlp ["hi", "hp", "ht"], # % gr4_ode ["hi", "hp", "ht"], # % gr4_ode_mlp ["hi", "hp", "ht"], # % gr5 + ["hi", "hp", "ht"], # % gr5_ri ["hi", "hp", "ht", "he"], # % gr6 ["hi", "hp", "ht", "hl"], # % grc ["hp", "ht"], # % grd @@ -183,10 +189,12 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron HYDROLOGICAL_MODULE, [ ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr4 + ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr4-ri ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr4_mlp ["pn", "en", "lexc", "qt"], # % gr4_ode ["pn", "en", "lexc", "qt"], # % gr4_ode_mlp ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr5 + ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr5-ri ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "pre", "qr", "qd", "qe", "qt"], # % gr6 ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "prl", "qr", "qd", "ql", "qt"], # % grc ["ei", "pn", "en", "pr", "perc", "prr", "qr", "qt"], # % grd @@ -250,13 +258,15 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron RR_PARAMETERS = [ "kmlt", # % ssn - "ci", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc) - "cp", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc, grd) - "ct", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc, grd) + "ci", # % (gr4, gr4_ri, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, grc, gr6) + "cp", # % (gr4, gr4_ri, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, grc, gr6, grd) + "ct", # % (gr4, gr4_ri, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, grc, gr6, grd) + "alpha1", # % (gr4_ri, gr5_ri) + "alpha2", # % (gr4_ri, gr5_ri) "cl", # % grc - "be", # % gr6 - "kexc", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc) - "aexc", # % (gr5, gr6) + "be", # % (gr6) + "kexc", # % (gr4, gr4_ri, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, grc, gr6) + "aexc", # % (gr5, gr5_ri, gr6) "ca", # % loieau "cc", # % loieau "kb", # % loieau @@ -276,9 +286,9 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron RR_STATES = [ "hs", # % ssn - "hi", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc) - "hp", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc, grd) - "ht", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc, grd) + "hi", # % (gr4, gr4_ri, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, grc, gr6) + "hp", # % (gr4, gr4_ri, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, grc, gr6, grd) + "ht", # % (gr4, gr4_ri, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, grc, gr6, grd) "hl", # % grc "he", # % gr6 "ha", # % loieau @@ -302,6 +312,8 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron (0, np.inf), # % ci (0, np.inf), # % cp (0, np.inf), # % ct + (0, np.inf), # % alpha1 + (0, np.inf), # % alpha2 (0, np.inf), # % cl (0, np.inf), # % be (-np.inf, np.inf), # % kexc @@ -361,6 +373,8 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron 1e-6, # % ci 200, # % cp 500, # % ct + 3e-4, # % alpha1 + 1e-3, # % alpha2 500, # % cl 10, # % be 0, # % kexc @@ -418,6 +432,8 @@ def get_neurons_from_hydrological_module(hydrological_module: str, hidden_neuron (1e-6, 1e2), # % ci (1e-6, 1e3), # % cp (1e-6, 1e3), # % ct + (1e-6, 5e-4), # % alpha1 + (1e-5, 1.0), # % alpha2 (1e-6, 1e3), # % cl (1e-3, 20), # % be (-50, 50), # % kexc diff --git a/smash/fcore/forward/forward_db.f90 b/smash/fcore/forward/forward_db.f90 index 9f8182a4..e99d16cb 100644 --- a/smash/fcore/forward/forward_db.f90 +++ b/smash/fcore/forward/forward_db.f90 @@ -13470,6 +13470,260 @@ SUBROUTINE GR_PRODUCTION(fq_ps, fq_es, pn, en, cp, beta, hp, pr, perc) hp = hp_imd - perc*inv_cp END SUBROUTINE GR_PRODUCTION +! Differentiation of gr_ri_production in forward (tangent) mode (with options fixinterface noISIZE context): +! variations of useful results: hp perc pr +! with respect to varying inputs: alpha1 hp en cp pn + SUBROUTINE GR_RI_PRODUCTION_D(pn, pn_d, en, en_d, cp, cp_d, beta, & +& alpha1, alpha1_d, hp, hp_d, pr, pr_d, perc, perc_d, dt) + IMPLICIT NONE + REAL(sp), INTENT(IN) :: pn, en, cp, beta, alpha1 + REAL(sp), INTENT(IN) :: pn_d, en_d, cp_d, alpha1_d + REAL(sp), INTENT(IN) :: dt + REAL(sp), INTENT(INOUT) :: hp + REAL(sp), INTENT(INOUT) :: hp_d + REAL(sp), INTENT(OUT) :: pr, perc + REAL(sp), INTENT(OUT) :: pr_d, perc_d + REAL(sp) :: inv_cp, ps, es, hp_imd + REAL(sp) :: inv_cp_d, ps_d, es_d, hp_imd_d + REAL(sp) :: lambda, gam, inv_lambda + REAL(sp) :: lambda_d, gam_d, inv_lambda_d + INTRINSIC EXP + INTRINSIC SQRT + INTRINSIC TANH + REAL(sp) :: arg1 + REAL(sp) :: arg1_d + REAL(sp) :: arg2 + REAL(sp) :: arg2_d + REAL(sp) :: pwx1 + REAL(sp) :: pwx1_d + REAL(sp) :: pwr1 + REAL(sp) :: pwr1_d + REAL(sp) :: temp + REAL(sp) :: temp0 + REAL(sp) :: temp1 + REAL(sp) :: temp2 + REAL(sp) :: temp3 + REAL(sp) :: temp4 + inv_cp_d = -(cp_d/cp**2) + inv_cp = 1._sp/cp + pr = 0._sp + gam_d = EXP(-(pn*alpha1))*(alpha1*pn_d+pn*alpha1_d) + gam = 1._sp - EXP(-(pn*alpha1)) + temp = SQRT(-gam + 1._sp) + IF (1._sp - gam .EQ. 0.0) THEN + lambda_d = 0.0_4 + ELSE + lambda_d = -(gam_d/(2.0*temp)) + END IF + lambda = temp + inv_lambda_d = -(lambda_d/lambda**2) + inv_lambda = 1._sp/lambda + arg1_d = inv_cp*(pn*lambda_d+lambda*pn_d) + lambda*pn*inv_cp_d + arg1 = lambda*pn*inv_cp + arg2_d = inv_cp*(pn*lambda_d+lambda*pn_d) + lambda*pn*inv_cp_d + arg2 = lambda*pn*inv_cp + temp = TANH(arg2) + temp0 = lambda*hp*temp + 1._sp + temp1 = -(lambda*hp*(lambda*hp)) + 1._sp + temp2 = cp*inv_lambda*temp1 + temp3 = TANH(arg1) + temp4 = temp3*temp2/temp0 + ps_d = (temp2*(1.0-TANH(arg1)**2)*arg1_d+temp3*(temp1*(inv_lambda*& +& cp_d+cp*inv_lambda_d)-cp*inv_lambda*2*lambda*hp*(hp*lambda_d+& +& lambda*hp_d))-temp4*(temp*(hp*lambda_d+lambda*hp_d)+lambda*hp*(1.0& +& -TANH(arg2)**2)*arg2_d))/temp0 - dt*gam_d + ps = temp4 - dt*gam + temp4 = TANH(en*inv_cp) + temp3 = TANH(en*inv_cp) + temp2 = hp*cp*(-hp+2._sp) + temp1 = temp2*temp3/((-hp+1._sp)*temp4+1._sp) + es_d = (temp3*((2._sp-hp)*(cp*hp_d+hp*cp_d)-hp*cp*hp_d)+temp2*(1.0-& +& TANH(en*inv_cp)**2)*(inv_cp*en_d+en*inv_cp_d)-temp1*((1._sp-hp)*(& +& 1.0-TANH(en*inv_cp)**2)*(inv_cp*en_d+en*inv_cp_d)-temp4*hp_d))/((& +& 1._sp-hp)*temp4+1._sp) + es = temp1 + hp_imd_d = hp_d + inv_cp*(ps_d-es_d) + (ps-es)*inv_cp_d + hp_imd = hp + (ps-es)*inv_cp + IF (pn .GT. 0) THEN + pr_d = pn_d - cp*(hp_imd_d-hp_d) - (hp_imd-hp)*cp_d + pr = pn - (hp_imd-hp)*cp + ELSE + pr_d = 0.0_4 + END IF + pwx1_d = 4*hp_imd**3*hp_imd_d/beta**4 + pwx1 = 1._sp + (hp_imd/beta)**4 + pwr1_d = -(0.25_sp*pwx1**(-1.25)*pwx1_d) + pwr1 = pwx1**(-0.25_sp) + perc_d = (1._sp-pwr1)*(cp*hp_imd_d+hp_imd*cp_d) - hp_imd*cp*pwr1_d + perc = hp_imd*cp*(1._sp-pwr1) + hp_d = hp_imd_d - inv_cp*perc_d - perc*inv_cp_d + hp = hp_imd - perc*inv_cp + END SUBROUTINE GR_RI_PRODUCTION_D + +! Differentiation of gr_ri_production in reverse (adjoint) mode (with options fixinterface noISIZE context): +! gradient of useful results: alpha1 hp cp pn perc pr +! with respect to varying inputs: alpha1 hp en cp pn + SUBROUTINE GR_RI_PRODUCTION_B(pn, pn_b, en, en_b, cp, cp_b, beta, & +& alpha1, alpha1_b, hp, hp_b, pr, pr_b, perc, perc_b, dt) + IMPLICIT NONE + REAL(sp), INTENT(IN) :: pn, en, cp, beta, alpha1 + REAL(sp) :: pn_b, en_b, cp_b, alpha1_b + REAL(sp), INTENT(IN) :: dt + REAL(sp), INTENT(INOUT) :: hp + REAL(sp), INTENT(INOUT) :: hp_b + REAL(sp) :: pr, perc + REAL(sp) :: pr_b, perc_b + REAL(sp) :: inv_cp, ps, es, hp_imd + REAL(sp) :: inv_cp_b, ps_b, es_b, hp_imd_b + REAL(sp) :: lambda, gam, inv_lambda + REAL(sp) :: lambda_b, gam_b, inv_lambda_b + INTRINSIC EXP + INTRINSIC SQRT + INTRINSIC TANH + REAL(sp) :: arg1 + REAL(sp) :: arg1_b + REAL(sp) :: arg2 + REAL(sp) :: arg2_b + REAL(sp) :: pwx1 + REAL(sp) :: pwx1_b + REAL(sp) :: pwr1 + REAL(sp) :: pwr1_b + REAL(sp) :: temp + REAL(sp) :: temp_b + REAL(sp) :: temp0 + REAL(sp) :: temp_b0 + REAL(sp) :: temp1 + REAL(sp) :: temp2 + REAL(sp) :: temp3 + REAL(sp) :: temp_b1 + REAL(sp) :: temp4 + REAL(sp) :: temp_b2 + REAL(sp) :: temp_b3 + REAL(sp) :: temp_b4 + REAL(sp) :: temp_b5 + INTEGER :: branch + inv_cp = 1._sp/cp + gam = 1._sp - EXP(-(pn*alpha1)) + lambda = SQRT(1._sp - gam) + inv_lambda = 1._sp/lambda + arg1 = lambda*pn*inv_cp + arg2 = lambda*pn*inv_cp + ps = cp*inv_lambda*TANH(arg1)*(1._sp-(lambda*hp)**2)/(1._sp+lambda*& +& hp*TANH(arg2)) - gam*dt + es = hp*cp*(2._sp-hp)*TANH(en*inv_cp)/(1._sp+(1._sp-hp)*TANH(en*& +& inv_cp)) + hp_imd = hp + (ps-es)*inv_cp + IF (pn .GT. 0) THEN + CALL PUSHCONTROL1B(0) + ELSE + CALL PUSHCONTROL1B(1) + END IF + pwx1 = 1._sp + (hp_imd/beta)**4 + pwr1 = pwx1**(-0.25_sp) + CALL PUSHREAL4(perc) + perc = hp_imd*cp*(1._sp-pwr1) + pwx1 = 1._sp + (hp_imd/beta)**4 + pwr1 = pwx1**(-0.25_sp) + inv_cp = 1._sp/cp + perc_b = perc_b - inv_cp*hp_b + inv_cp_b = -(perc*hp_b) + CALL POPREAL4(perc) + cp_b = cp_b + hp_imd*(1._sp-pwr1)*perc_b + pwr1_b = -(hp_imd*cp*perc_b) + pwx1_b = -(0.25_sp*pwx1**(-1.25)*pwr1_b) + hp_imd_b = hp_b + cp*(1._sp-pwr1)*perc_b + 4*hp_imd**3*pwx1_b/beta**& +& 4 + CALL POPCONTROL1B(branch) + IF (branch .EQ. 0) THEN + pn_b = pn_b + pr_b + hp_imd_b = hp_imd_b - cp*pr_b + hp_b = cp*pr_b + cp_b = cp_b - (hp_imd-hp)*pr_b + ELSE + hp_b = 0.0_4 + END IF + es_b = -(inv_cp*hp_imd_b) + temp4 = TANH(en*inv_cp) + temp3 = (-hp+1._sp)*temp4 + 1._sp + temp1 = TANH(en*inv_cp) + temp0 = hp*cp*(-hp+2._sp) + temp_b1 = es_b/temp3 + temp_b0 = (2._sp-hp)*temp1*temp_b1 + temp_b4 = -(temp0*temp1*temp_b1/temp3) + hp_b = hp_b + hp_imd_b + cp*temp_b0 - hp*cp*temp1*temp_b1 - temp4*& +& temp_b4 + ps_b = inv_cp*hp_imd_b + temp_b = (1.0-TANH(en*inv_cp)**2)*temp0*temp_b1 + temp_b5 = (1.0-TANH(en*inv_cp)**2)*(1._sp-hp)*temp_b4 + en_b = inv_cp*temp_b5 + inv_cp*temp_b + cp_b = cp_b + hp*temp_b0 + arg1 = lambda*pn*inv_cp + arg2 = lambda*pn*inv_cp + inv_lambda = 1._sp/lambda + temp = TANH(arg2) + temp0 = lambda*hp*temp + 1._sp + temp1 = -(lambda*hp*(lambda*hp)) + 1._sp + temp2 = cp*inv_lambda*temp1 + temp3 = TANH(arg1) + temp_b0 = ps_b/temp0 + arg1_b = (1.0-TANH(arg1)**2)*temp2*temp_b0 + temp_b1 = temp3*temp_b0 + temp_b3 = -(temp3*temp2*temp_b0/temp0) + arg2_b = (1.0-TANH(arg2)**2)*lambda*hp*temp_b3 + inv_cp_b = inv_cp_b + (ps-es)*hp_imd_b + en*temp_b5 + en*temp_b + & +& lambda*pn*arg2_b + lambda*pn*arg1_b + cp_b = cp_b + inv_lambda*temp1*temp_b1 - inv_cp_b/cp**2 + inv_lambda_b = cp*temp1*temp_b1 + temp_b2 = -(2*lambda*hp*cp*inv_lambda*temp_b1) + lambda_b = hp*temp*temp_b3 + hp*temp_b2 + pn*inv_cp*arg2_b + pn*& +& inv_cp*arg1_b - inv_lambda_b/lambda**2 + IF (1._sp - gam .EQ. 0.0) THEN + gam_b = -(dt*ps_b) + ELSE + gam_b = -(dt*ps_b) - lambda_b/(2.0*SQRT(1._sp-gam)) + END IF + hp_b = hp_b + lambda*temp*temp_b3 + lambda*temp_b2 + temp_b = -(EXP(-(pn*alpha1))*gam_b) + pn_b = pn_b + lambda*inv_cp*arg2_b + lambda*inv_cp*arg1_b - alpha1*& +& temp_b + alpha1_b = alpha1_b - pn*temp_b + END SUBROUTINE GR_RI_PRODUCTION_B + + SUBROUTINE GR_RI_PRODUCTION(pn, en, cp, beta, alpha1, hp, pr, perc, dt& +& ) + IMPLICIT NONE + REAL(sp), INTENT(IN) :: pn, en, cp, beta, alpha1 + REAL(sp), INTENT(IN) :: dt + REAL(sp), INTENT(INOUT) :: hp + REAL(sp), INTENT(OUT) :: pr, perc + REAL(sp) :: inv_cp, ps, es, hp_imd + REAL(sp) :: lambda, gam, inv_lambda + INTRINSIC EXP + INTRINSIC SQRT + INTRINSIC TANH + REAL(sp) :: arg1 + REAL(sp) :: arg2 + REAL(sp) :: pwx1 + REAL(sp) :: pwr1 + inv_cp = 1._sp/cp + pr = 0._sp + gam = 1._sp - EXP(-(pn*alpha1)) + lambda = SQRT(1._sp - gam) + inv_lambda = 1._sp/lambda + arg1 = lambda*pn*inv_cp + arg2 = lambda*pn*inv_cp + ps = cp*inv_lambda*TANH(arg1)*(1._sp-(lambda*hp)**2)/(1._sp+lambda*& +& hp*TANH(arg2)) - gam*dt + es = hp*cp*(2._sp-hp)*TANH(en*inv_cp)/(1._sp+(1._sp-hp)*TANH(en*& +& inv_cp)) + hp_imd = hp + (ps-es)*inv_cp + IF (pn .GT. 0) pr = pn - (hp_imd-hp)*cp + pwx1 = 1._sp + (hp_imd/beta)**4 + pwr1 = pwx1**(-0.25_sp) + perc = hp_imd*cp*(1._sp-pwr1) + hp = hp_imd - perc*inv_cp + END SUBROUTINE GR_RI_PRODUCTION + ! Differentiation of gr_exchange in forward (tangent) mode (with options fixinterface noISIZE context): ! variations of useful results: l ! with respect to varying inputs: kexc fq_l ht @@ -14803,17 +15057,15 @@ SUBROUTINE GR4_TIME_STEP(setup, mesh, input_data, options, returns, & END DO END SUBROUTINE GR4_TIME_STEP -! Differentiation of gr4_mlp_time_step in forward (tangent) mode (with options fixinterface noISIZE context): +! Differentiation of gr4_ri_time_step in forward (tangent) mode (with options fixinterface noISIZE context): ! variations of useful results: ac_qt ac_hi ac_hp ac_ht -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt - SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & -& returns, time_step, weight_1, weight_1_d, bias_1, bias_1_d, weight_2& -& , weight_2_d, bias_2, bias_2_d, weight_3, weight_3_d, bias_3, & -& bias_3_d, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & -& ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, & -& ac_ht_d, ac_qt, ac_qt_d) +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt + SUBROUTINE GR4_RI_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d& +& , ac_ct, ac_ct_d, ac_alpha1, ac_alpha1_d, ac_alpha2, ac_alpha2_d, & +& ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, ac_ht_d, & +& ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -14821,46 +15073,27 @@ SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1_d - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1_d - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2_d - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2_d - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3_d - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & & ac_ct_d, ac_kexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1_d, & +& ac_alpha2_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & & ac_ht_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_d - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer_d - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d, pn_d, en_d + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd - REAL(sp) :: pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + REAL(sp) :: pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d& +& , split_d + INTRINSIC TANH INTRINSIC MAX REAL(sp) :: temp CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& @@ -14871,9 +15104,7 @@ SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & ac_prcp = ac_prcp + ac_mlt ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp - en_d = 0.0_4 pn_d = 0.0_4 -! Interception with OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -14882,54 +15113,13 @@ SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN CALL GR_INTERCEPTION_D(ac_prcp(k), ac_prcp_d(k), ac_pet(k), & & ac_ci(k), ac_ci_d(k), ac_hi(k), ac_hi_d(k)& -& , pn(k), pn_d(k), en(k), en_d(k)) - ELSE - pn_d(k) = 0.0_4 - pn(k) = 0._sp - en_d(k) = 0.0_4 - en(k) = 0._sp - END IF - END IF - END DO - END DO - output_layer_d = 0.0_4 -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - input_layer_d(:) = (/ac_hp_d(k), ac_ht_d(k), pn_d(k), en_d(k& -& )/) - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP_D(weight_1, weight_1_d, bias_1, bias_1_d, & -& weight_2, weight_2_d, bias_2, bias_2_d, & -& weight_3, weight_3_d, bias_3, bias_3_d, & -& input_layer, input_layer_d, output_layer(:, k)& -& , output_layer_d(:, k)) - ELSE - output_layer_d(:, k) = 0.0_4 - output_layer(:, k) = 0._sp - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL GR_PRODUCTION_D(output_layer(1, k), output_layer_d(1, k& -& ), output_layer(2, k), output_layer_d(2, k), & -& pn(k), pn_d(k), en(k), en_d(k), ac_cp(k), & -& ac_cp_d(k), beta, ac_hp(k), ac_hp_d(k), pr, & -& pr_d, perc, perc_d) - CALL GR_EXCHANGE_D(output_layer(4, k), output_layer_d(4, k)& -& , ac_kexc(k), ac_kexc_d(k), ac_ht(k), ac_ht_d(k& -& ), l, l_d) +& , pn, pn_d, en, en_d) + CALL GR_RI_PRODUCTION_D(pn, pn_d, en, en_d, ac_cp(k), & +& ac_cp_d(k), beta, ac_alpha1(k), & +& ac_alpha1_d(k), ac_hp(k), ac_hp_d(k), pr, & +& pr_d, perc, perc_d, setup%dt) + CALL GR_EXCHANGE_D(0._sp, 0.0_4, ac_kexc(k), ac_kexc_d(k), & +& ac_ht(k), ac_ht_d(k), l, l_d) ELSE pr = 0._sp perc = 0._sp @@ -14938,14 +15128,13 @@ SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & perc_d = 0.0_4 pr_d = 0.0_4 END IF - temp = -(output_layer(3, k)*output_layer(3, k)) + 1._sp - prr_d = 0.9_sp*(temp*(pr_d+perc_d)-(pr+perc)*2*output_layer(3& -& , k)*output_layer_d(3, k)) + l_d - prr = 0.9_sp*(temp*(pr+perc)) + l - temp = 0.9_sp*(output_layer(3, k)*output_layer(3, k)) + 0.1_sp - prd_d = (pr+perc)*0.9_sp*2*output_layer(3, k)*output_layer_d(3& -& , k) + temp*(pr_d+perc_d) - prd = temp*(pr+perc) + split_d = 0.9_sp*2*TANH(ac_alpha2(k)*pn)*(1.0-TANH(ac_alpha2(k& +& )*pn)**2)*(pn*ac_alpha2_d(k)+ac_alpha2(k)*pn_d) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp + prr_d = (1._sp-split)*(pr_d+perc_d) - (pr+perc)*split_d + l_d + prr = (1._sp-split)*(pr+perc) + l + prd_d = (pr+perc)*split_d + split*(pr_d+perc_d) + prd = split*(pr+perc) CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & & ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) IF (0._sp .LT. prd + l) THEN @@ -14964,21 +15153,18 @@ SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO - END SUBROUTINE GR4_MLP_TIME_STEP_D + END SUBROUTINE GR4_RI_TIME_STEP_D -! Differentiation of gr4_mlp_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): -! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt - SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & -& returns, time_step, weight_1, weight_1_b, bias_1, bias_1_b, weight_2& -& , weight_2_b, bias_2, bias_2_b, weight_3, weight_3_b, bias_3, & -& bias_3_b, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & -& ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, & -& ac_ht_b, ac_qt, ac_qt_b) +! Differentiation of gr4_ri_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt + SUBROUTINE GR4_RI_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b& +& , ac_ct, ac_ct_b, ac_alpha1, ac_alpha1_b, ac_alpha2, ac_alpha2_b, & +& ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, ac_ht_b, & +& ac_qt, ac_qt_b) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -14986,47 +15172,28 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)) :: & -& weight_1_b - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(2)) :: bias_1_b - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)) :: & -& weight_2_b - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(3)) :: bias_2_b - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)) :: & -& weight_3_b - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 - REAL(sp), DIMENSION(setup%neurons(4)) :: bias_3_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & & ac_kexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 + REAL(sp), DIMENSION(mesh%nac) :: ac_alpha1_b, ac_alpha2_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & & ac_ht_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_b - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer_b - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b, pn_b, en_b + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd - REAL(sp) :: pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + REAL(sp) :: pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b& +& , split_b + INTRINSIC TANH INTRINSIC MAX + REAL(sp) :: dummydiff_b REAL(sp) :: temp_b INTEGER :: branch CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& @@ -15036,67 +15203,25 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & ac_prcp = ac_prcp + ac_mlt ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp -! Interception with OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0) THEN - CALL PUSHCONTROL2B(0) + CALL PUSHCONTROL1B(0) ELSE k = mesh%rowcol_to_ind_ac(row, col) IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4(en) + CALL PUSHREAL4(pn) CALL PUSHREAL4(ac_hi(k)) CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& -& k), pn(k), en(k)) - CALL PUSHCONTROL2B(2) - ELSE - pn(k) = 0._sp - en(k) = 0._sp - CALL PUSHCONTROL2B(1) - END IF - END IF - END DO - END DO -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0) THEN - CALL PUSHCONTROL2B(0) - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL PUSHREAL4ARRAY(input_layer, setup%neurons(1)) - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & -& weight_3, bias_3, input_layer, output_layer(:, k)& -& ) - CALL PUSHCONTROL2B(2) - ELSE - output_layer(:, k) = 0._sp - CALL PUSHCONTROL2B(1) - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0) THEN - CALL PUSHCONTROL1B(0) - ELSE - CALL PUSHINTEGER4(k) - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN +& k), pn, en) CALL PUSHREAL4(perc) CALL PUSHREAL4(pr) CALL PUSHREAL4(ac_hp(k)) - CALL GR_PRODUCTION(output_layer(1, k), output_layer(2, k), & -& pn(k), en(k), ac_cp(k), beta, ac_hp(k), pr, & -& perc) - CALL GR_EXCHANGE(output_layer(4, k), ac_kexc(k), ac_ht(k), l& -& ) + CALL GR_RI_PRODUCTION(pn, en, ac_cp(k), beta, ac_alpha1(k), & +& ac_hp(k), pr, perc, setup%dt) + CALL GR_EXCHANGE(0._sp, ac_kexc(k), ac_ht(k), l) CALL PUSHCONTROL1B(1) ELSE CALL PUSHREAL4(pr) @@ -15106,9 +15231,11 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & l = 0._sp CALL PUSHCONTROL1B(0) END IF + CALL PUSHREAL4(split) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp CALL PUSHREAL4(prr) - prr = 0.9_sp*(1._sp-output_layer(3, k)**2)*(pr+perc) + l - prd = (0.1_sp+0.9_sp*output_layer(3, k)**2)*(pr+perc) + prr = (1._sp-split)*(pr+perc) + l + prd = split*(pr+perc) CALL PUSHREAL4(ac_ht(k)) CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & & qr) @@ -15121,13 +15248,13 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & END IF END DO END DO - output_layer_b = 0.0_4 - en_b = 0.0_4 + ac_prcp_b = 0.0_4 pn_b = 0.0_4 DO col=mesh%ncol,1,-1 DO row=mesh%nrow,1,-1 CALL POPCONTROL1B(branch) IF (branch .NE. 0) THEN + k = mesh%rowcol_to_ind_ac(row, col) ac_qt_b(k) = mesh%dx(row, col)*1e-3_sp*mesh%dy(row, col)*& & ac_qt_b(k)/setup%dt qr_b = ac_qt_b(k) @@ -15144,89 +15271,47 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & CALL POPREAL4(ac_ht(k)) CALL GR_TRANSFER_B(5._sp, ac_prcp(k), prr, prr_b, ac_ct(k), & & ac_ct_b(k), ac_ht(k), ac_ht_b(k), qr, qr_b) - output_layer_b(3, k) = output_layer_b(3, k) + 2*output_layer(3& -& , k)*0.9_sp*(pr+perc)*prd_b - 2*output_layer(3, k)*(pr+perc)& -& *0.9_sp*prr_b - temp_b = (0.9_sp*output_layer(3, k)**2+0.1_sp)*prd_b - pr_b = temp_b - perc_b = temp_b + split_b = (pr+perc)*prd_b - (pr+perc)*prr_b + pr_b = split*prd_b + (1._sp-split)*prr_b + perc_b = split*prd_b + (1._sp-split)*prr_b CALL POPREAL4(prr) - temp_b = (1._sp-output_layer(3, k)**2)*0.9_sp*prr_b l_b = l_b + prr_b - pr_b = pr_b + temp_b - perc_b = perc_b + temp_b + CALL POPREAL4(split) + temp_b = (1.0-TANH(ac_alpha2(k)*pn)**2)*2*TANH(ac_alpha2(k)*pn& +& )*0.9_sp*split_b + ac_alpha2_b(k) = ac_alpha2_b(k) + pn*temp_b + pn_b = pn_b + ac_alpha2(k)*temp_b CALL POPCONTROL1B(branch) IF (branch .EQ. 0) THEN CALL POPREAL4(perc) CALL POPREAL4(pr) ELSE - CALL GR_EXCHANGE_B(output_layer(4, k), output_layer_b(4, k)& -& , ac_kexc(k), ac_kexc_b(k), ac_ht(k), ac_ht_b(k& -& ), l, l_b) + CALL GR_EXCHANGE_B(0._sp, dummydiff_b, ac_kexc(k), ac_kexc_b& +& (k), ac_ht(k), ac_ht_b(k), l, l_b) CALL POPREAL4(ac_hp(k)) CALL POPREAL4(pr) CALL POPREAL4(perc) - CALL GR_PRODUCTION_B(output_layer(1, k), output_layer_b(1, k& -& ), output_layer(2, k), output_layer_b(2, k), & -& pn(k), pn_b(k), en(k), en_b(k), ac_cp(k), & -& ac_cp_b(k), beta, ac_hp(k), ac_hp_b(k), pr, & -& pr_b, perc, perc_b) - END IF - CALL POPINTEGER4(k) - END IF - END DO - END DO - DO col=mesh%ncol,1,-1 - DO row=mesh%nrow,1,-1 - CALL POPCONTROL2B(branch) - IF (branch .NE. 0) THEN - IF (branch .EQ. 1) THEN - k = mesh%rowcol_to_ind_ac(row, col) - output_layer_b(:, k) = 0.0_4 - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - CALL FORWARD_MLP_B(weight_1, weight_1_b, bias_1, bias_1_b, & -& weight_2, weight_2_b, bias_2, bias_2_b, & -& weight_3, weight_3_b, bias_3, bias_3_b, & -& input_layer, input_layer_b, output_layer(:, k)& -& , output_layer_b(:, k)) - output_layer_b(:, k) = 0.0_4 - CALL POPREAL4ARRAY(input_layer, setup%neurons(1)) - ac_hp_b(k) = ac_hp_b(k) + input_layer_b(1) - ac_ht_b(k) = ac_ht_b(k) + input_layer_b(2) - pn_b(k) = pn_b(k) + input_layer_b(3) - en_b(k) = en_b(k) + input_layer_b(4) - END IF - END IF - END DO - END DO - ac_prcp_b = 0.0_4 - DO col=mesh%ncol,1,-1 - DO row=mesh%nrow,1,-1 - CALL POPCONTROL2B(branch) - IF (branch .NE. 0) THEN - IF (branch .EQ. 1) THEN - k = mesh%rowcol_to_ind_ac(row, col) - en_b(k) = 0.0_4 - pn_b(k) = 0.0_4 - ELSE - k = mesh%rowcol_to_ind_ac(row, col) + CALL GR_RI_PRODUCTION_B(pn, pn_b, en, en_b, ac_cp(k), & +& ac_cp_b(k), beta, ac_alpha1(k), & +& ac_alpha1_b(k), ac_hp(k), ac_hp_b(k), pr, & +& pr_b, perc, perc_b, setup%dt) CALL POPREAL4(ac_hi(k)) + CALL POPREAL4(pn) + CALL POPREAL4(en) CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & & ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& -& , pn(k), pn_b(k), en(k), en_b(k)) - pn_b(k) = 0.0_4 - en_b(k) = 0.0_4 +& , pn, pn_b, en, en_b) + pn_b = 0.0_4 END IF END IF END DO END DO ac_mlt_b = ac_mlt_b + ac_prcp_b - END SUBROUTINE GR4_MLP_TIME_STEP_B + END SUBROUTINE GR4_RI_TIME_STEP_B - SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& -& , time_step, weight_1, bias_1, weight_2, bias_2, weight_3, bias_3, & -& ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) + SUBROUTINE GR4_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_alpha1, ac_alpha2, & +& ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15234,26 +15319,16 @@ SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + INTRINSIC TANH INTRINSIC MAX CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) @@ -15262,7 +15337,6 @@ SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& ac_prcp = ac_prcp + ac_mlt ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp -! Interception with OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -15270,50 +15344,18 @@ SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& k = mesh%rowcol_to_ind_ac(row, col) IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& -& k), pn(k), en(k)) - ELSE - pn(k) = 0._sp - en(k) = 0._sp - END IF - END IF - END DO - END DO -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & -& weight_3, bias_3, input_layer, output_layer(:, k)& -& ) - ELSE - output_layer(:, k) = 0._sp - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL GR_PRODUCTION(output_layer(1, k), output_layer(2, k), & -& pn(k), en(k), ac_cp(k), beta, ac_hp(k), pr, & -& perc) - CALL GR_EXCHANGE(output_layer(4, k), ac_kexc(k), ac_ht(k), l& -& ) +& k), pn, en) + CALL GR_RI_PRODUCTION(pn, en, ac_cp(k), beta, ac_alpha1(k), & +& ac_hp(k), pr, perc, setup%dt) + CALL GR_EXCHANGE(0._sp, ac_kexc(k), ac_ht(k), l) ELSE pr = 0._sp perc = 0._sp l = 0._sp END IF - prr = 0.9_sp*(1._sp-output_layer(3, k)**2)*(pr+perc) + l - prd = (0.1_sp+0.9_sp*output_layer(3, k)**2)*(pr+perc) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp + prr = (1._sp-split)*(pr+perc) + l + prd = split*(pr+perc) CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & & qr) IF (0._sp .LT. prd + l) THEN @@ -15328,16 +15370,19 @@ SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& END IF END DO END DO - END SUBROUTINE GR4_MLP_TIME_STEP + END SUBROUTINE GR4_RI_TIME_STEP -! Differentiation of gr4_ode_time_step in forward (tangent) mode (with options fixinterface noISIZE context): +! Differentiation of gr4_mlp_time_step in forward (tangent) mode (with options fixinterface noISIZE context): ! variations of useful results: ac_qt ac_hi ac_hp ac_ht -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt - SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & -& returns, time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d& -& , ac_ct, ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d& -& , ac_ht, ac_ht_d, ac_qt, ac_qt_d) +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt + SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, weight_1, weight_1_d, bias_1, bias_1_d, weight_2& +& , weight_2_d, bias_2, bias_2_d, weight_3, weight_3_d, bias_3, & +& bias_3_d, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & +& ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, & +& ac_ht_d, ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15345,21 +15390,47 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt - REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d - REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & -& ac_kexc - REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & -& ac_ct_d, ac_kexc_d - REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht - REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & -& ac_ht_d - REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt - REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1_d + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1_d + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2_d + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2_d + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3_d + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & +& ac_ct_d, ac_kexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & +& ac_ht_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_d + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer_d + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d, pn_d, en_d INTEGER :: row, col, k, time_step_returns - REAL(sp) :: l + REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d + INTRINSIC MAX REAL(sp) :: temp CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) @@ -15367,6 +15438,8 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & & , 'pet', ac_pet) ac_prcp_d = ac_mlt_d ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp en_d = 0.0_4 pn_d = 0.0_4 ! Interception with OPENMP @@ -15388,18 +15461,71 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO -! Production and transfer without OPENMP + output_layer_d = 0.0_4 +! Forward MLP without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0)) THEN k = mesh%rowcol_to_ind_ac(row, col) - CALL GR_PRODUCTION_TRANSFER_ODE_D(pn(k), pn_d(k), en(k), en_d(& -& k), ac_cp(k), ac_cp_d(k), ac_ct(k)& -& , ac_ct_d(k), ac_kexc(k), & -& ac_kexc_d(k), ac_hp(k), ac_hp_d(k)& -& , ac_ht(k), ac_ht_d(k), ac_qt(k), & -& ac_qt_d(k), l) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + input_layer_d(:) = (/ac_hp_d(k), ac_ht_d(k), pn_d(k), en_d(k& +& )/) + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP_D(weight_1, weight_1_d, bias_1, bias_1_d, & +& weight_2, weight_2_d, bias_2, bias_2_d, & +& weight_3, weight_3_d, bias_3, bias_3_d, & +& input_layer, input_layer_d, output_layer(:, k)& +& , output_layer_d(:, k)) + ELSE + output_layer_d(:, k) = 0.0_4 + output_layer(:, k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_PRODUCTION_D(output_layer(1, k), output_layer_d(1, k& +& ), output_layer(2, k), output_layer_d(2, k), & +& pn(k), pn_d(k), en(k), en_d(k), ac_cp(k), & +& ac_cp_d(k), beta, ac_hp(k), ac_hp_d(k), pr, & +& pr_d, perc, perc_d) + CALL GR_EXCHANGE_D(output_layer(4, k), output_layer_d(4, k)& +& , ac_kexc(k), ac_kexc_d(k), ac_ht(k), ac_ht_d(k& +& ), l, l_d) + ELSE + pr = 0._sp + perc = 0._sp + l = 0._sp + l_d = 0.0_4 + perc_d = 0.0_4 + pr_d = 0.0_4 + END IF + temp = -(output_layer(3, k)*output_layer(3, k)) + 1._sp + prr_d = 0.9_sp*(temp*(pr_d+perc_d)-(pr+perc)*2*output_layer(3& +& , k)*output_layer_d(3, k)) + l_d + prr = 0.9_sp*(temp*(pr+perc)) + l + temp = 0.9_sp*(output_layer(3, k)*output_layer(3, k)) + 0.1_sp + prd_d = (pr+perc)*0.9_sp*2*output_layer(3, k)*output_layer_d(3& +& , k) + temp*(pr_d+perc_d) + prd = temp*(pr+perc) + CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & +& ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) + IF (0._sp .LT. prd + l) THEN + qd_d = prd_d + l_d + qd = prd + l + ELSE + qd = 0._sp + qd_d = 0.0_4 + END IF + ac_qt_d(k) = qr_d + qd_d + ac_qt(k) = qr + qd ! Transform from mm/dt to m3/s temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt @@ -15407,17 +15533,21 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO - END SUBROUTINE GR4_ODE_TIME_STEP_D + END SUBROUTINE GR4_MLP_TIME_STEP_D -! Differentiation of gr4_ode_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): -! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt - SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & -& returns, time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b& -& , ac_ct, ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b& -& , ac_ht, ac_ht_b, ac_qt, ac_qt_b) +! Differentiation of gr4_mlp_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt + SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, weight_1, weight_1_b, bias_1, bias_1_b, weight_2& +& , weight_2_b, bias_2, bias_2_b, weight_3, weight_3_b, bias_3, & +& bias_3_b, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & +& ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, & +& ac_ht_b, ac_qt, ac_qt_b) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15425,6 +15555,24 @@ SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)) :: & +& weight_1_b + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(2)) :: bias_1_b + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)) :: & +& weight_2_b + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(3)) :: bias_2_b + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)) :: & +& weight_3_b + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(setup%neurons(4)) :: bias_3_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & @@ -15436,16 +15584,27 @@ SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & & ac_ht_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_b + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer_b REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b, pn_b, en_b INTEGER :: row, col, k, time_step_returns - REAL(sp) :: l + REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b + INTRINSIC MAX + REAL(sp) :: temp_b INTEGER :: branch CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'pet', ac_pet) ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp ! Interception with OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow @@ -15467,61 +15626,163 @@ SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & END IF END DO END DO -! Production and transfer without OPENMP +! Forward MLP without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL2B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4ARRAY(input_layer, setup%neurons(1)) + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & +& weight_3, bias_3, input_layer, output_layer(:, k)& +& ) + CALL PUSHCONTROL2B(2) + ELSE + output_layer(:, k) = 0._sp + CALL PUSHCONTROL2B(1) + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0) THEN CALL PUSHCONTROL1B(0) ELSE + CALL PUSHINTEGER4(k) k = mesh%rowcol_to_ind_ac(row, col) - CALL PUSHREAL4(ac_qt(k)) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4(perc) + CALL PUSHREAL4(pr) + CALL PUSHREAL4(ac_hp(k)) + CALL GR_PRODUCTION(output_layer(1, k), output_layer(2, k), & +& pn(k), en(k), ac_cp(k), beta, ac_hp(k), pr, & +& perc) + CALL GR_EXCHANGE(output_layer(4, k), ac_kexc(k), ac_ht(k), l& +& ) + CALL PUSHCONTROL1B(1) + ELSE + CALL PUSHREAL4(pr) + pr = 0._sp + CALL PUSHREAL4(perc) + perc = 0._sp + l = 0._sp + CALL PUSHCONTROL1B(0) + END IF + CALL PUSHREAL4(prr) + prr = 0.9_sp*(1._sp-output_layer(3, k)**2)*(pr+perc) + l + prd = (0.1_sp+0.9_sp*output_layer(3, k)**2)*(pr+perc) CALL PUSHREAL4(ac_ht(k)) - CALL PUSHREAL4(ac_hp(k)) - CALL GR_PRODUCTION_TRANSFER_ODE(pn(k), en(k), ac_cp(k), ac_ct(& -& k), ac_kexc(k), ac_hp(k), ac_ht(k), & -& ac_qt(k), l) -! Transform from mm/dt to m3/s + CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & +& qr) + IF (0._sp .LT. prd + l) THEN + CALL PUSHCONTROL1B(0) + ELSE + CALL PUSHCONTROL1B(1) + END IF CALL PUSHCONTROL1B(1) END IF END DO END DO + output_layer_b = 0.0_4 en_b = 0.0_4 pn_b = 0.0_4 DO col=mesh%ncol,1,-1 DO row=mesh%nrow,1,-1 CALL POPCONTROL1B(branch) IF (branch .NE. 0) THEN - k = mesh%rowcol_to_ind_ac(row, col) ac_qt_b(k) = mesh%dx(row, col)*1e-3_sp*mesh%dy(row, col)*& & ac_qt_b(k)/setup%dt - CALL POPREAL4(ac_hp(k)) - CALL POPREAL4(ac_ht(k)) - CALL POPREAL4(ac_qt(k)) - CALL GR_PRODUCTION_TRANSFER_ODE_B(pn(k), pn_b(k), en(k), en_b(& -& k), ac_cp(k), ac_cp_b(k), ac_ct(k)& -& , ac_ct_b(k), ac_kexc(k), & -& ac_kexc_b(k), ac_hp(k), ac_hp_b(k)& -& , ac_ht(k), ac_ht_b(k), ac_qt(k), & -& ac_qt_b(k), l) + qr_b = ac_qt_b(k) + qd_b = ac_qt_b(k) ac_qt_b(k) = 0.0_4 - END IF - END DO - END DO - ac_prcp_b = 0.0_4 - DO col=mesh%ncol,1,-1 - DO row=mesh%nrow,1,-1 - CALL POPCONTROL2B(branch) - IF (branch .NE. 0) THEN - IF (branch .EQ. 1) THEN - k = mesh%rowcol_to_ind_ac(row, col) - en_b(k) = 0.0_4 - pn_b(k) = 0.0_4 + CALL POPCONTROL1B(branch) + IF (branch .EQ. 0) THEN + prd_b = qd_b + l_b = qd_b ELSE - k = mesh%rowcol_to_ind_ac(row, col) - CALL POPREAL4(ac_hi(k)) - CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & -& ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& + l_b = 0.0_4 + prd_b = 0.0_4 + END IF + CALL POPREAL4(ac_ht(k)) + CALL GR_TRANSFER_B(5._sp, ac_prcp(k), prr, prr_b, ac_ct(k), & +& ac_ct_b(k), ac_ht(k), ac_ht_b(k), qr, qr_b) + output_layer_b(3, k) = output_layer_b(3, k) + 2*output_layer(3& +& , k)*0.9_sp*(pr+perc)*prd_b - 2*output_layer(3, k)*(pr+perc)& +& *0.9_sp*prr_b + temp_b = (0.9_sp*output_layer(3, k)**2+0.1_sp)*prd_b + pr_b = temp_b + perc_b = temp_b + CALL POPREAL4(prr) + temp_b = (1._sp-output_layer(3, k)**2)*0.9_sp*prr_b + l_b = l_b + prr_b + pr_b = pr_b + temp_b + perc_b = perc_b + temp_b + CALL POPCONTROL1B(branch) + IF (branch .EQ. 0) THEN + CALL POPREAL4(perc) + CALL POPREAL4(pr) + ELSE + CALL GR_EXCHANGE_B(output_layer(4, k), output_layer_b(4, k)& +& , ac_kexc(k), ac_kexc_b(k), ac_ht(k), ac_ht_b(k& +& ), l, l_b) + CALL POPREAL4(ac_hp(k)) + CALL POPREAL4(pr) + CALL POPREAL4(perc) + CALL GR_PRODUCTION_B(output_layer(1, k), output_layer_b(1, k& +& ), output_layer(2, k), output_layer_b(2, k), & +& pn(k), pn_b(k), en(k), en_b(k), ac_cp(k), & +& ac_cp_b(k), beta, ac_hp(k), ac_hp_b(k), pr, & +& pr_b, perc, perc_b) + END IF + CALL POPINTEGER4(k) + END IF + END DO + END DO + DO col=mesh%ncol,1,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL2B(branch) + IF (branch .NE. 0) THEN + IF (branch .EQ. 1) THEN + k = mesh%rowcol_to_ind_ac(row, col) + output_layer_b(:, k) = 0.0_4 + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL FORWARD_MLP_B(weight_1, weight_1_b, bias_1, bias_1_b, & +& weight_2, weight_2_b, bias_2, bias_2_b, & +& weight_3, weight_3_b, bias_3, bias_3_b, & +& input_layer, input_layer_b, output_layer(:, k)& +& , output_layer_b(:, k)) + output_layer_b(:, k) = 0.0_4 + CALL POPREAL4ARRAY(input_layer, setup%neurons(1)) + ac_hp_b(k) = ac_hp_b(k) + input_layer_b(1) + ac_ht_b(k) = ac_ht_b(k) + input_layer_b(2) + pn_b(k) = pn_b(k) + input_layer_b(3) + en_b(k) = en_b(k) + input_layer_b(4) + END IF + END IF + END DO + END DO + ac_prcp_b = 0.0_4 + DO col=mesh%ncol,1,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL2B(branch) + IF (branch .NE. 0) THEN + IF (branch .EQ. 1) THEN + k = mesh%rowcol_to_ind_ac(row, col) + en_b(k) = 0.0_4 + pn_b(k) = 0.0_4 + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL POPREAL4(ac_hi(k)) + CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & +& ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& & , pn(k), pn_b(k), en(k), en_b(k)) pn_b(k) = 0.0_4 en_b(k) = 0.0_4 @@ -15530,11 +15791,11 @@ SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & END DO END DO ac_mlt_b = ac_mlt_b + ac_prcp_b - END SUBROUTINE GR4_ODE_TIME_STEP_B + END SUBROUTINE GR4_MLP_TIME_STEP_B - SUBROUTINE GR4_ODE_TIME_STEP(setup, mesh, input_data, options, returns& -& , time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, & -& ac_ht, ac_qt) + SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& +& , time_step, weight_1, bias_1, weight_2, bias_2, weight_3, bias_3, & +& ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15542,19 +15803,34 @@ SUBROUTINE GR4_ODE_TIME_STEP(setup, mesh, input_data, options, returns& TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en INTEGER :: row, col, k, time_step_returns - REAL(sp) :: l + REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd + INTRINSIC MAX CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'pet', ac_pet) ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp ! Interception with OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow @@ -15571,34 +15847,66 @@ SUBROUTINE GR4_ODE_TIME_STEP(setup, mesh, input_data, options, returns& END IF END DO END DO -! Production and transfer without OPENMP +! Forward MLP without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0)) THEN k = mesh%rowcol_to_ind_ac(row, col) - CALL GR_PRODUCTION_TRANSFER_ODE(pn(k), en(k), ac_cp(k), ac_ct(& -& k), ac_kexc(k), ac_hp(k), ac_ht(k), & -& ac_qt(k), l) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & +& weight_3, bias_3, input_layer, output_layer(:, k)& +& ) + ELSE + output_layer(:, k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_PRODUCTION(output_layer(1, k), output_layer(2, k), & +& pn(k), en(k), ac_cp(k), beta, ac_hp(k), pr, & +& perc) + CALL GR_EXCHANGE(output_layer(4, k), ac_kexc(k), ac_ht(k), l& +& ) + ELSE + pr = 0._sp + perc = 0._sp + l = 0._sp + END IF + prr = 0.9_sp*(1._sp-output_layer(3, k)**2)*(pr+perc) + l + prd = (0.1_sp+0.9_sp*output_layer(3, k)**2)*(pr+perc) + CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & +& qr) + IF (0._sp .LT. prd + l) THEN + qd = prd + l + ELSE + qd = 0._sp + END IF + ac_qt(k) = qr + qd ! Transform from mm/dt to m3/s ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col& & )/setup%dt END IF END DO END DO - END SUBROUTINE GR4_ODE_TIME_STEP + END SUBROUTINE GR4_MLP_TIME_STEP -! Differentiation of gr4_ode_mlp_time_step in forward (tangent) mode (with options fixinterface noISIZE context): +! Differentiation of gr4_ode_time_step in forward (tangent) mode (with options fixinterface noISIZE context): ! variations of useful results: ac_qt ac_hi ac_hp ac_ht -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt - SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & -& returns, time_step, weight_1, weight_1_d, bias_1, bias_1_d, weight_2& -& , weight_2_d, bias_2, bias_2_d, weight_3, weight_3_d, bias_3, & -& bias_3_d, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & -& ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, & -& ac_ht_d, ac_qt, ac_qt_d) +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt + SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d& +& , ac_ct, ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d& +& , ac_ht, ac_ht_d, ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15606,24 +15914,6 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1_d - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1_d - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2_d - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2_d - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3_d - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & @@ -15635,12 +15925,6 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & & ac_ht_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_d - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer_d REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d, pn_d, en_d INTEGER :: row, col, k, time_step_returns @@ -15673,43 +15957,18 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO - output_layer_d = 0.0_4 -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - input_layer_d(:) = (/ac_hp_d(k), ac_ht_d(k), pn_d(k), en_d(k& -& )/) - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP_D(weight_1, weight_1_d, bias_1, bias_1_d, & -& weight_2, weight_2_d, bias_2, bias_2_d, & -& weight_3, weight_3_d, bias_3, bias_3_d, & -& input_layer, input_layer_d, output_layer(:, k)& -& , output_layer_d(:, k)) - ELSE - output_layer_d(:, k) = 0.0_4 - output_layer(:, k) = 0._sp - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP +! Production and transfer without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0)) THEN k = mesh%rowcol_to_ind_ac(row, col) - CALL GR_PRODUCTION_TRANSFER_ODE_MLP_D(output_layer(:, k), & -& output_layer_d(:, k), pn(k), & -& pn_d(k), en(k), en_d(k), ac_cp& -& (k), ac_cp_d(k), ac_ct(k), & -& ac_ct_d(k), ac_kexc(k), & -& ac_kexc_d(k), ac_hp(k), & -& ac_hp_d(k), ac_ht(k), ac_ht_d(& -& k), ac_qt(k), ac_qt_d(k), l) + CALL GR_PRODUCTION_TRANSFER_ODE_D(pn(k), pn_d(k), en(k), en_d(& +& k), ac_cp(k), ac_cp_d(k), ac_ct(k)& +& , ac_ct_d(k), ac_kexc(k), & +& ac_kexc_d(k), ac_hp(k), ac_hp_d(k)& +& , ac_ht(k), ac_ht_d(k), ac_qt(k), & +& ac_qt_d(k), l) ! Transform from mm/dt to m3/s temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt @@ -15717,21 +15976,17 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO - END SUBROUTINE GR4_ODE_MLP_TIME_STEP_D + END SUBROUTINE GR4_ODE_TIME_STEP_D -! Differentiation of gr4_ode_mlp_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): -! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt - SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & -& returns, time_step, weight_1, weight_1_b, bias_1, bias_1_b, weight_2& -& , weight_2_b, bias_2, bias_2_b, weight_3, weight_3_b, bias_3, & -& bias_3_b, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & -& ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, & -& ac_ht_b, ac_qt, ac_qt_b) +! Differentiation of gr4_ode_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt + SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b& +& , ac_ct, ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b& +& , ac_ht, ac_ht_b, ac_qt, ac_qt_b) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15739,24 +15994,6 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)) :: & -& weight_1_b - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(2)) :: bias_1_b - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)) :: & -& weight_2_b - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(3)) :: bias_2_b - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)) :: & -& weight_3_b - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 - REAL(sp), DIMENSION(setup%neurons(4)) :: bias_3_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & @@ -15768,12 +16005,6 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & & ac_ht_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_b - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer_b REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b, pn_b, en_b INTEGER :: row, col, k, time_step_returns @@ -15805,29 +16036,7 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & END IF END DO END DO -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0) THEN - CALL PUSHCONTROL2B(0) - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL PUSHREAL4ARRAY(input_layer, setup%neurons(1)) - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & -& weight_3, bias_3, input_layer, output_layer(:, k)& -& ) - CALL PUSHCONTROL2B(2) - ELSE - output_layer(:, k) = 0._sp - CALL PUSHCONTROL2B(1) - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP +! Production and transfer without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -15838,16 +16047,14 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & CALL PUSHREAL4(ac_qt(k)) CALL PUSHREAL4(ac_ht(k)) CALL PUSHREAL4(ac_hp(k)) - CALL GR_PRODUCTION_TRANSFER_ODE_MLP(output_layer(:, k), pn(k)& -& , en(k), ac_cp(k), ac_ct(k), & -& ac_kexc(k), ac_hp(k), ac_ht(k), & -& ac_qt(k), l) + CALL GR_PRODUCTION_TRANSFER_ODE(pn(k), en(k), ac_cp(k), ac_ct(& +& k), ac_kexc(k), ac_hp(k), ac_ht(k), & +& ac_qt(k), l) ! Transform from mm/dt to m3/s CALL PUSHCONTROL1B(1) END IF END DO END DO - output_layer_b = 0.0_4 en_b = 0.0_4 pn_b = 0.0_4 DO col=mesh%ncol,1,-1 @@ -15860,70 +16067,740 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & CALL POPREAL4(ac_hp(k)) CALL POPREAL4(ac_ht(k)) CALL POPREAL4(ac_qt(k)) - CALL GR_PRODUCTION_TRANSFER_ODE_MLP_B(output_layer(:, k), & -& output_layer_b(:, k), pn(k), & -& pn_b(k), en(k), en_b(k), ac_cp& -& (k), ac_cp_b(k), ac_ct(k), & -& ac_ct_b(k), ac_kexc(k), & -& ac_kexc_b(k), ac_hp(k), & -& ac_hp_b(k), ac_ht(k), ac_ht_b(& -& k), ac_qt(k), ac_qt_b(k), l) + CALL GR_PRODUCTION_TRANSFER_ODE_B(pn(k), pn_b(k), en(k), en_b(& +& k), ac_cp(k), ac_cp_b(k), ac_ct(k)& +& , ac_ct_b(k), ac_kexc(k), & +& ac_kexc_b(k), ac_hp(k), ac_hp_b(k)& +& , ac_ht(k), ac_ht_b(k), ac_qt(k), & +& ac_qt_b(k), l) ac_qt_b(k) = 0.0_4 END IF END DO END DO + ac_prcp_b = 0.0_4 DO col=mesh%ncol,1,-1 DO row=mesh%nrow,1,-1 CALL POPCONTROL2B(branch) IF (branch .NE. 0) THEN IF (branch .EQ. 1) THEN k = mesh%rowcol_to_ind_ac(row, col) - output_layer_b(:, k) = 0.0_4 + en_b(k) = 0.0_4 + pn_b(k) = 0.0_4 ELSE k = mesh%rowcol_to_ind_ac(row, col) - CALL FORWARD_MLP_B(weight_1, weight_1_b, bias_1, bias_1_b, & -& weight_2, weight_2_b, bias_2, bias_2_b, & -& weight_3, weight_3_b, bias_3, bias_3_b, & -& input_layer, input_layer_b, output_layer(:, k)& -& , output_layer_b(:, k)) - output_layer_b(:, k) = 0.0_4 - CALL POPREAL4ARRAY(input_layer, setup%neurons(1)) - ac_hp_b(k) = ac_hp_b(k) + input_layer_b(1) - ac_ht_b(k) = ac_ht_b(k) + input_layer_b(2) - pn_b(k) = pn_b(k) + input_layer_b(3) - en_b(k) = en_b(k) + input_layer_b(4) + CALL POPREAL4(ac_hi(k)) + CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & +& ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& +& , pn(k), pn_b(k), en(k), en_b(k)) + pn_b(k) = 0.0_4 + en_b(k) = 0.0_4 END IF END IF END DO END DO - ac_prcp_b = 0.0_4 - DO col=mesh%ncol,1,-1 - DO row=mesh%nrow,1,-1 - CALL POPCONTROL2B(branch) - IF (branch .NE. 0) THEN - IF (branch .EQ. 1) THEN - k = mesh%rowcol_to_ind_ac(row, col) - en_b(k) = 0.0_4 - pn_b(k) = 0.0_4 + ac_mlt_b = ac_mlt_b + ac_prcp_b + END SUBROUTINE GR4_ODE_TIME_STEP_B + + SUBROUTINE GR4_ODE_TIME_STEP(setup, mesh, input_data, options, returns& +& , time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, & +& ac_ht, ac_qt) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: l + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp = ac_prcp + ac_mlt +! Interception with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn(k), en(k)) + ELSE + pn(k) = 0._sp + en(k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + CALL GR_PRODUCTION_TRANSFER_ODE(pn(k), en(k), ac_cp(k), ac_ct(& +& k), ac_kexc(k), ac_hp(k), ac_ht(k), & +& ac_qt(k), l) +! Transform from mm/dt to m3/s + ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col& +& )/setup%dt + END IF + END DO + END DO + END SUBROUTINE GR4_ODE_TIME_STEP + +! Differentiation of gr4_ode_mlp_time_step in forward (tangent) mode (with options fixinterface noISIZE context): +! variations of useful results: ac_qt ac_hi ac_hp ac_ht +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt + SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, weight_1, weight_1_d, bias_1, bias_1_d, weight_2& +& , weight_2_d, bias_2, bias_2_d, weight_3, weight_3_d, bias_3, & +& bias_3_d, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & +& ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, & +& ac_ht_d, ac_qt, ac_qt_d) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1_d + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1_d + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2_d + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2_d + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3_d + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & +& ac_ct_d, ac_kexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & +& ac_ht_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_d + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer_d + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d, pn_d, en_d + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: l + REAL(sp) :: temp + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp_d = ac_mlt_d + ac_prcp = ac_prcp + ac_mlt + en_d = 0.0_4 + pn_d = 0.0_4 +! Interception with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_INTERCEPTION_D(ac_prcp(k), ac_prcp_d(k), ac_pet(k), & +& ac_ci(k), ac_ci_d(k), ac_hi(k), ac_hi_d(k)& +& , pn(k), pn_d(k), en(k), en_d(k)) + ELSE + pn_d(k) = 0.0_4 + pn(k) = 0._sp + en_d(k) = 0.0_4 + en(k) = 0._sp + END IF + END IF + END DO + END DO + output_layer_d = 0.0_4 +! Forward MLP without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + input_layer_d(:) = (/ac_hp_d(k), ac_ht_d(k), pn_d(k), en_d(k& +& )/) + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP_D(weight_1, weight_1_d, bias_1, bias_1_d, & +& weight_2, weight_2_d, bias_2, bias_2_d, & +& weight_3, weight_3_d, bias_3, bias_3_d, & +& input_layer, input_layer_d, output_layer(:, k)& +& , output_layer_d(:, k)) + ELSE + output_layer_d(:, k) = 0.0_4 + output_layer(:, k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + CALL GR_PRODUCTION_TRANSFER_ODE_MLP_D(output_layer(:, k), & +& output_layer_d(:, k), pn(k), & +& pn_d(k), en(k), en_d(k), ac_cp& +& (k), ac_cp_d(k), ac_ct(k), & +& ac_ct_d(k), ac_kexc(k), & +& ac_kexc_d(k), ac_hp(k), & +& ac_hp_d(k), ac_ht(k), ac_ht_d(& +& k), ac_qt(k), ac_qt_d(k), l) +! Transform from mm/dt to m3/s + temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) + ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt + ac_qt(k) = temp*(ac_qt(k)/setup%dt) + END IF + END DO + END DO + END SUBROUTINE GR4_ODE_MLP_TIME_STEP_D + +! Differentiation of gr4_ode_mlp_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt + SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, weight_1, weight_1_b, bias_1, bias_1_b, weight_2& +& , weight_2_b, bias_2, bias_2_b, weight_3, weight_3_b, bias_3, & +& bias_3_b, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & +& ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, & +& ac_ht_b, ac_qt, ac_qt_b) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)) :: & +& weight_1_b + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(2)) :: bias_1_b + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)) :: & +& weight_2_b + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(3)) :: bias_2_b + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)) :: & +& weight_3_b + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(setup%neurons(4)) :: bias_3_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & +& ac_kexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & +& ac_ht_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_b + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer_b + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b, pn_b, en_b + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: l + INTEGER :: branch + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp = ac_prcp + ac_mlt +! Interception with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL2B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4(ac_hi(k)) + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn(k), en(k)) + CALL PUSHCONTROL2B(2) + ELSE + pn(k) = 0._sp + en(k) = 0._sp + CALL PUSHCONTROL2B(1) + END IF + END IF + END DO + END DO +! Forward MLP without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL2B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4ARRAY(input_layer, setup%neurons(1)) + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & +& weight_3, bias_3, input_layer, output_layer(:, k)& +& ) + CALL PUSHCONTROL2B(2) + ELSE + output_layer(:, k) = 0._sp + CALL PUSHCONTROL2B(1) + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL1B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL PUSHREAL4(ac_qt(k)) + CALL PUSHREAL4(ac_ht(k)) + CALL PUSHREAL4(ac_hp(k)) + CALL GR_PRODUCTION_TRANSFER_ODE_MLP(output_layer(:, k), pn(k)& +& , en(k), ac_cp(k), ac_ct(k), & +& ac_kexc(k), ac_hp(k), ac_ht(k), & +& ac_qt(k), l) +! Transform from mm/dt to m3/s + CALL PUSHCONTROL1B(1) + END IF + END DO + END DO + output_layer_b = 0.0_4 + en_b = 0.0_4 + pn_b = 0.0_4 + DO col=mesh%ncol,1,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL1B(branch) + IF (branch .NE. 0) THEN + k = mesh%rowcol_to_ind_ac(row, col) + ac_qt_b(k) = mesh%dx(row, col)*1e-3_sp*mesh%dy(row, col)*& +& ac_qt_b(k)/setup%dt + CALL POPREAL4(ac_hp(k)) + CALL POPREAL4(ac_ht(k)) + CALL POPREAL4(ac_qt(k)) + CALL GR_PRODUCTION_TRANSFER_ODE_MLP_B(output_layer(:, k), & +& output_layer_b(:, k), pn(k), & +& pn_b(k), en(k), en_b(k), ac_cp& +& (k), ac_cp_b(k), ac_ct(k), & +& ac_ct_b(k), ac_kexc(k), & +& ac_kexc_b(k), ac_hp(k), & +& ac_hp_b(k), ac_ht(k), ac_ht_b(& +& k), ac_qt(k), ac_qt_b(k), l) + ac_qt_b(k) = 0.0_4 + END IF + END DO + END DO + DO col=mesh%ncol,1,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL2B(branch) + IF (branch .NE. 0) THEN + IF (branch .EQ. 1) THEN + k = mesh%rowcol_to_ind_ac(row, col) + output_layer_b(:, k) = 0.0_4 + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL FORWARD_MLP_B(weight_1, weight_1_b, bias_1, bias_1_b, & +& weight_2, weight_2_b, bias_2, bias_2_b, & +& weight_3, weight_3_b, bias_3, bias_3_b, & +& input_layer, input_layer_b, output_layer(:, k)& +& , output_layer_b(:, k)) + output_layer_b(:, k) = 0.0_4 + CALL POPREAL4ARRAY(input_layer, setup%neurons(1)) + ac_hp_b(k) = ac_hp_b(k) + input_layer_b(1) + ac_ht_b(k) = ac_ht_b(k) + input_layer_b(2) + pn_b(k) = pn_b(k) + input_layer_b(3) + en_b(k) = en_b(k) + input_layer_b(4) + END IF + END IF + END DO + END DO + ac_prcp_b = 0.0_4 + DO col=mesh%ncol,1,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL2B(branch) + IF (branch .NE. 0) THEN + IF (branch .EQ. 1) THEN + k = mesh%rowcol_to_ind_ac(row, col) + en_b(k) = 0.0_4 + pn_b(k) = 0.0_4 + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL POPREAL4(ac_hi(k)) + CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & +& ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& +& , pn(k), pn_b(k), en(k), en_b(k)) + pn_b(k) = 0.0_4 + en_b(k) = 0.0_4 + END IF + END IF + END DO + END DO + ac_mlt_b = ac_mlt_b + ac_prcp_b + END SUBROUTINE GR4_ODE_MLP_TIME_STEP_B + + SUBROUTINE GR4_ODE_MLP_TIME_STEP(setup, mesh, input_data, options, & +& returns, time_step, weight_1, bias_1, weight_2, bias_2, weight_3, & +& bias_3, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, & +& ac_qt) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: l + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp = ac_prcp + ac_mlt +! Interception with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn(k), en(k)) + ELSE + pn(k) = 0._sp + en(k) = 0._sp + END IF + END IF + END DO + END DO +! Forward MLP without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & +& weight_3, bias_3, input_layer, output_layer(:, k)& +& ) + ELSE + output_layer(:, k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + CALL GR_PRODUCTION_TRANSFER_ODE_MLP(output_layer(:, k), pn(k)& +& , en(k), ac_cp(k), ac_ct(k), & +& ac_kexc(k), ac_hp(k), ac_ht(k), & +& ac_qt(k), l) +! Transform from mm/dt to m3/s + ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col& +& )/setup%dt + END IF + END DO + END DO + END SUBROUTINE GR4_ODE_MLP_TIME_STEP + +! Differentiation of gr5_time_step in forward (tangent) mode (with options fixinterface noISIZE context): +! variations of useful results: ac_qt ac_hi ac_hp ac_ht +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt ac_aexc + SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & +& time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & +& ac_ct_d, ac_kexc, ac_kexc_d, ac_aexc, ac_aexc_d, ac_hi, ac_hi_d, & +& ac_hp, ac_hp_d, ac_ht, ac_ht_d, ac_qt, ac_qt_d) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc, ac_aexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & +& ac_ct_d, ac_kexc_d, ac_aexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & +& ac_ht_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d + INTRINSIC MAX + REAL(sp) :: temp + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp_d = ac_mlt_d + ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_INTERCEPTION_D(ac_prcp(k), ac_prcp_d(k), ac_pet(k), & +& ac_ci(k), ac_ci_d(k), ac_hi(k), ac_hi_d(k)& +& , pn, pn_d, en, en_d) + CALL GR_PRODUCTION_D(0._sp, 0.0_4, 0._sp, 0.0_4, pn, pn_d, & +& en, en_d, ac_cp(k), ac_cp_d(k), beta, ac_hp(k& +& ), ac_hp_d(k), pr, pr_d, perc, perc_d) + CALL GR_THRESHOLD_EXCHANGE_D(ac_kexc(k), ac_kexc_d(k), & +& ac_aexc(k), ac_aexc_d(k), ac_ht(k), & +& ac_ht_d(k), l, l_d) + ELSE + pr = 0._sp + perc = 0._sp + l = 0._sp + l_d = 0.0_4 + perc_d = 0.0_4 + pr_d = 0.0_4 + END IF + prr_d = 0.9_sp*(pr_d+perc_d) + l_d + prr = 0.9_sp*(pr+perc) + l + prd_d = 0.1_sp*(pr_d+perc_d) + prd = 0.1_sp*(pr+perc) + CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & +& ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) + IF (0._sp .LT. prd + l) THEN + qd_d = prd_d + l_d + qd = prd + l + ELSE + qd = 0._sp + qd_d = 0.0_4 + END IF + ac_qt_d(k) = qr_d + qd_d + ac_qt(k) = qr + qd +! Transform from mm/dt to m3/s + temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) + ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt + ac_qt(k) = temp*(ac_qt(k)/setup%dt) + END IF + END DO + END DO + END SUBROUTINE GR5_TIME_STEP_D + +! Differentiation of gr5_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt ac_aexc +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt ac_aexc + SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & +& time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & +& ac_ct_b, ac_kexc, ac_kexc_b, ac_aexc, ac_aexc_b, ac_hi, ac_hi_b, & +& ac_hp, ac_hp_b, ac_ht, ac_ht_b, ac_qt, ac_qt_b) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc, ac_aexc + REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & +& ac_kexc_b, ac_aexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & +& ac_ht_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b + INTRINSIC MAX + REAL(sp) :: dummydiff_b + REAL(sp) :: dummydiff_b0 + INTEGER :: branch + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL1B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4(en) + CALL PUSHREAL4(pn) + CALL PUSHREAL4(ac_hi(k)) + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn, en) + CALL PUSHREAL4(ac_hp(k)) + CALL GR_PRODUCTION(0._sp, 0._sp, pn, en, ac_cp(k), beta, & +& ac_hp(k), pr, perc) + CALL GR_THRESHOLD_EXCHANGE(ac_kexc(k), ac_aexc(k), ac_ht(k)& +& , l) + CALL PUSHCONTROL1B(1) + ELSE + CALL PUSHCONTROL1B(0) + pr = 0._sp + perc = 0._sp + l = 0._sp + END IF + CALL PUSHREAL4(prr) + prr = 0.9_sp*(pr+perc) + l + prd = 0.1_sp*(pr+perc) + CALL PUSHREAL4(ac_ht(k)) + CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & +& qr) + IF (0._sp .LT. prd + l) THEN + CALL PUSHCONTROL1B(0) + ELSE + CALL PUSHCONTROL1B(1) + END IF + CALL PUSHCONTROL1B(1) + END IF + END DO + END DO + ac_prcp_b = 0.0_4 + DO col=mesh%ncol,1,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL1B(branch) + IF (branch .NE. 0) THEN + k = mesh%rowcol_to_ind_ac(row, col) + ac_qt_b(k) = mesh%dx(row, col)*1e-3_sp*mesh%dy(row, col)*& +& ac_qt_b(k)/setup%dt + qr_b = ac_qt_b(k) + qd_b = ac_qt_b(k) + ac_qt_b(k) = 0.0_4 + CALL POPCONTROL1B(branch) + IF (branch .EQ. 0) THEN + prd_b = qd_b + l_b = qd_b ELSE - k = mesh%rowcol_to_ind_ac(row, col) + l_b = 0.0_4 + prd_b = 0.0_4 + END IF + CALL POPREAL4(ac_ht(k)) + CALL GR_TRANSFER_B(5._sp, ac_prcp(k), prr, prr_b, ac_ct(k), & +& ac_ct_b(k), ac_ht(k), ac_ht_b(k), qr, qr_b) + pr_b = 0.1_sp*prd_b + 0.9_sp*prr_b + perc_b = 0.1_sp*prd_b + 0.9_sp*prr_b + CALL POPREAL4(prr) + l_b = l_b + prr_b + CALL POPCONTROL1B(branch) + IF (branch .NE. 0) THEN + CALL GR_THRESHOLD_EXCHANGE_B(ac_kexc(k), ac_kexc_b(k), & +& ac_aexc(k), ac_aexc_b(k), ac_ht(k), & +& ac_ht_b(k), l, l_b) + CALL POPREAL4(ac_hp(k)) + pn_b = 0.0_4 + en_b = 0.0_4 + CALL GR_PRODUCTION_B(0._sp, dummydiff_b, 0._sp, dummydiff_b0& +& , pn, pn_b, en, en_b, ac_cp(k), ac_cp_b(k), & +& beta, ac_hp(k), ac_hp_b(k), pr, pr_b, perc, & +& perc_b) CALL POPREAL4(ac_hi(k)) + CALL POPREAL4(pn) + CALL POPREAL4(en) CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & & ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& -& , pn(k), pn_b(k), en(k), en_b(k)) - pn_b(k) = 0.0_4 - en_b(k) = 0.0_4 +& , pn, pn_b, en, en_b) END IF END IF END DO END DO ac_mlt_b = ac_mlt_b + ac_prcp_b - END SUBROUTINE GR4_ODE_MLP_TIME_STEP_B + END SUBROUTINE GR5_TIME_STEP_B - SUBROUTINE GR4_ODE_MLP_TIME_STEP(setup, mesh, input_data, options, & -& returns, time_step, weight_1, bias_1, weight_2, bias_2, weight_3, & -& bias_3, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, & -& ac_qt) + SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & +& time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_aexc, ac_hi, & +& ac_hp, ac_ht, ac_qt) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15931,32 +16808,22 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & -& ac_kexc +& ac_kexc, ac_aexc REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet INTEGER :: row, col, k, time_step_returns - REAL(sp) :: l + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd + INTRINSIC MAX CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'pet', ac_pet) ac_prcp = ac_prcp + ac_mlt -! Interception with OPENMP +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -15964,57 +16831,43 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP(setup, mesh, input_data, options, & k = mesh%rowcol_to_ind_ac(row, col) IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& -& k), pn(k), en(k)) +& k), pn, en) + CALL GR_PRODUCTION(0._sp, 0._sp, pn, en, ac_cp(k), beta, & +& ac_hp(k), pr, perc) + CALL GR_THRESHOLD_EXCHANGE(ac_kexc(k), ac_aexc(k), ac_ht(k)& +& , l) ELSE - pn(k) = 0._sp - en(k) = 0._sp + pr = 0._sp + perc = 0._sp + l = 0._sp END IF - END IF - END DO - END DO -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & -& weight_3, bias_3, input_layer, output_layer(:, k)& -& ) + prr = 0.9_sp*(pr+perc) + l + prd = 0.1_sp*(pr+perc) + CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & +& qr) + IF (0._sp .LT. prd + l) THEN + qd = prd + l ELSE - output_layer(:, k) = 0._sp + qd = 0._sp END IF - END IF - END DO - END DO -! Production and transfer with OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - CALL GR_PRODUCTION_TRANSFER_ODE_MLP(output_layer(:, k), pn(k)& -& , en(k), ac_cp(k), ac_ct(k), & -& ac_kexc(k), ac_hp(k), ac_ht(k), & -& ac_qt(k), l) + ac_qt(k) = qr + qd ! Transform from mm/dt to m3/s ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col& & )/setup%dt END IF END DO END DO - END SUBROUTINE GR4_ODE_MLP_TIME_STEP + END SUBROUTINE GR5_TIME_STEP -! Differentiation of gr5_time_step in forward (tangent) mode (with options fixinterface noISIZE context): +! Differentiation of gr5_ri_time_step in forward (tangent) mode (with options fixinterface noISIZE context): ! variations of useful results: ac_qt ac_hi ac_hp ac_ht -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt ac_aexc - SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & -& time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & -& ac_ct_d, ac_kexc, ac_kexc_d, ac_aexc, ac_aexc_d, ac_hi, ac_hi_d, & -& ac_hp, ac_hp_d, ac_ht, ac_ht_d, ac_qt, ac_qt_d) +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt ac_aexc + SUBROUTINE GR5_RI_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d& +& , ac_ct, ac_ct_d, ac_alpha1, ac_alpha1_d, ac_alpha2, ac_alpha2_d, & +& ac_kexc, ac_kexc_d, ac_aexc, ac_aexc_d, ac_hi, ac_hi_d, ac_hp, & +& ac_hp_d, ac_ht, ac_ht_d, ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -16028,6 +16881,9 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & & ac_kexc, ac_aexc REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & & ac_ct_d, ac_kexc_d, ac_aexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1_d, & +& ac_alpha2_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & & ac_ht_d @@ -16036,8 +16892,10 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd - REAL(sp) :: pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + REAL(sp) :: pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d& +& , split_d + INTRINSIC TANH INTRINSIC MAX REAL(sp) :: temp CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& @@ -16048,6 +16906,7 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & ac_prcp = ac_prcp + ac_mlt ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp + pn_d = 0.0_4 DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -16057,9 +16916,10 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & CALL GR_INTERCEPTION_D(ac_prcp(k), ac_prcp_d(k), ac_pet(k), & & ac_ci(k), ac_ci_d(k), ac_hi(k), ac_hi_d(k)& & , pn, pn_d, en, en_d) - CALL GR_PRODUCTION_D(0._sp, 0.0_4, 0._sp, 0.0_4, pn, pn_d, & -& en, en_d, ac_cp(k), ac_cp_d(k), beta, ac_hp(k& -& ), ac_hp_d(k), pr, pr_d, perc, perc_d) + CALL GR_RI_PRODUCTION_D(pn, pn_d, en, en_d, ac_cp(k), & +& ac_cp_d(k), beta, ac_alpha1(k), & +& ac_alpha1_d(k), ac_hp(k), ac_hp_d(k), pr, & +& pr_d, perc, perc_d, setup%dt) CALL GR_THRESHOLD_EXCHANGE_D(ac_kexc(k), ac_kexc_d(k), & & ac_aexc(k), ac_aexc_d(k), ac_ht(k), & & ac_ht_d(k), l, l_d) @@ -16071,10 +16931,13 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & perc_d = 0.0_4 pr_d = 0.0_4 END IF - prr_d = 0.9_sp*(pr_d+perc_d) + l_d - prr = 0.9_sp*(pr+perc) + l - prd_d = 0.1_sp*(pr_d+perc_d) - prd = 0.1_sp*(pr+perc) + split_d = 0.9_sp*2*TANH(ac_alpha2(k)*pn)*(1.0-TANH(ac_alpha2(k& +& )*pn)**2)*(pn*ac_alpha2_d(k)+ac_alpha2(k)*pn_d) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp + prr_d = (1._sp-split)*(pr_d+perc_d) - (pr+perc)*split_d + l_d + prr = (1._sp-split)*(pr+perc) + l + prd_d = (pr+perc)*split_d + split*(pr_d+perc_d) + prd = split*(pr+perc) CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & & ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) IF (0._sp .LT. prd + l) THEN @@ -16093,17 +16956,18 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & END IF END DO END DO - END SUBROUTINE GR5_TIME_STEP_D + END SUBROUTINE GR5_RI_TIME_STEP_D -! Differentiation of gr5_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): -! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt ac_aexc -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt ac_aexc - SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & -& time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & -& ac_ct_b, ac_kexc, ac_kexc_b, ac_aexc, ac_aexc_b, ac_hi, ac_hi_b, & -& ac_hp, ac_hp_b, ac_ht, ac_ht_b, ac_qt, ac_qt_b) +! Differentiation of gr5_ri_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt ac_aexc +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt ac_aexc + SUBROUTINE GR5_RI_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b& +& , ac_ct, ac_ct_b, ac_alpha1, ac_alpha1_b, ac_alpha2, ac_alpha2_b, & +& ac_kexc, ac_kexc_b, ac_aexc, ac_aexc_b, ac_hi, ac_hi_b, ac_hp, & +& ac_hp_b, ac_ht, ac_ht_b, ac_qt, ac_qt_b) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -16117,6 +16981,8 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & & ac_kexc, ac_aexc REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & & ac_kexc_b, ac_aexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 + REAL(sp), DIMENSION(mesh%nac) :: ac_alpha1_b, ac_alpha2_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & & ac_ht_b @@ -16125,11 +16991,12 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd - REAL(sp) :: pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + REAL(sp) :: pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b& +& , split_b + INTRINSIC TANH INTRINSIC MAX - REAL(sp) :: dummydiff_b - REAL(sp) :: dummydiff_b0 + REAL(sp) :: temp_b INTEGER :: branch CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) @@ -16151,21 +17018,27 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & CALL PUSHREAL4(ac_hi(k)) CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& & k), pn, en) + CALL PUSHREAL4(perc) + CALL PUSHREAL4(pr) CALL PUSHREAL4(ac_hp(k)) - CALL GR_PRODUCTION(0._sp, 0._sp, pn, en, ac_cp(k), beta, & -& ac_hp(k), pr, perc) + CALL GR_RI_PRODUCTION(pn, en, ac_cp(k), beta, ac_alpha1(k), & +& ac_hp(k), pr, perc, setup%dt) CALL GR_THRESHOLD_EXCHANGE(ac_kexc(k), ac_aexc(k), ac_ht(k)& & , l) CALL PUSHCONTROL1B(1) ELSE - CALL PUSHCONTROL1B(0) + CALL PUSHREAL4(pr) pr = 0._sp + CALL PUSHREAL4(perc) perc = 0._sp l = 0._sp + CALL PUSHCONTROL1B(0) END IF + CALL PUSHREAL4(split) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp CALL PUSHREAL4(prr) - prr = 0.9_sp*(pr+perc) + l - prd = 0.1_sp*(pr+perc) + prr = (1._sp-split)*(pr+perc) + l + prd = split*(pr+perc) CALL PUSHREAL4(ac_ht(k)) CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & & qr) @@ -16179,6 +17052,7 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & END DO END DO ac_prcp_b = 0.0_4 + pn_b = 0.0_4 DO col=mesh%ncol,1,-1 DO row=mesh%nrow,1,-1 CALL POPCONTROL1B(branch) @@ -16200,38 +17074,48 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & CALL POPREAL4(ac_ht(k)) CALL GR_TRANSFER_B(5._sp, ac_prcp(k), prr, prr_b, ac_ct(k), & & ac_ct_b(k), ac_ht(k), ac_ht_b(k), qr, qr_b) - pr_b = 0.1_sp*prd_b + 0.9_sp*prr_b - perc_b = 0.1_sp*prd_b + 0.9_sp*prr_b + split_b = (pr+perc)*prd_b - (pr+perc)*prr_b + pr_b = split*prd_b + (1._sp-split)*prr_b + perc_b = split*prd_b + (1._sp-split)*prr_b CALL POPREAL4(prr) l_b = l_b + prr_b + CALL POPREAL4(split) + temp_b = (1.0-TANH(ac_alpha2(k)*pn)**2)*2*TANH(ac_alpha2(k)*pn& +& )*0.9_sp*split_b + ac_alpha2_b(k) = ac_alpha2_b(k) + pn*temp_b + pn_b = pn_b + ac_alpha2(k)*temp_b CALL POPCONTROL1B(branch) - IF (branch .NE. 0) THEN + IF (branch .EQ. 0) THEN + CALL POPREAL4(perc) + CALL POPREAL4(pr) + ELSE CALL GR_THRESHOLD_EXCHANGE_B(ac_kexc(k), ac_kexc_b(k), & & ac_aexc(k), ac_aexc_b(k), ac_ht(k), & & ac_ht_b(k), l, l_b) CALL POPREAL4(ac_hp(k)) - pn_b = 0.0_4 - en_b = 0.0_4 - CALL GR_PRODUCTION_B(0._sp, dummydiff_b, 0._sp, dummydiff_b0& -& , pn, pn_b, en, en_b, ac_cp(k), ac_cp_b(k), & -& beta, ac_hp(k), ac_hp_b(k), pr, pr_b, perc, & -& perc_b) + CALL POPREAL4(pr) + CALL POPREAL4(perc) + CALL GR_RI_PRODUCTION_B(pn, pn_b, en, en_b, ac_cp(k), & +& ac_cp_b(k), beta, ac_alpha1(k), & +& ac_alpha1_b(k), ac_hp(k), ac_hp_b(k), pr, & +& pr_b, perc, perc_b, setup%dt) CALL POPREAL4(ac_hi(k)) CALL POPREAL4(pn) CALL POPREAL4(en) CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & & ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& & , pn, pn_b, en, en_b) + pn_b = 0.0_4 END IF END IF END DO END DO ac_mlt_b = ac_mlt_b + ac_prcp_b - END SUBROUTINE GR5_TIME_STEP_B + END SUBROUTINE GR5_RI_TIME_STEP_B - SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & -& time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_aexc, ac_hi, & -& ac_hp, ac_ht, ac_qt) + SUBROUTINE GR5_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_alpha1, ac_alpha2, & +& ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -16242,11 +17126,13 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc, ac_aexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + INTRINSIC TANH INTRINSIC MAX CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) @@ -16263,8 +17149,8 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& & k), pn, en) - CALL GR_PRODUCTION(0._sp, 0._sp, pn, en, ac_cp(k), beta, & -& ac_hp(k), pr, perc) + CALL GR_RI_PRODUCTION(pn, en, ac_cp(k), beta, ac_alpha1(k), & +& ac_hp(k), pr, perc, setup%dt) CALL GR_THRESHOLD_EXCHANGE(ac_kexc(k), ac_aexc(k), ac_ht(k)& & , l) ELSE @@ -16272,8 +17158,9 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & perc = 0._sp l = 0._sp END IF - prr = 0.9_sp*(pr+perc) + l - prd = 0.1_sp*(pr+perc) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp + prr = (1._sp-split)*(pr+perc) + l + prd = split*(pr+perc) CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & & qr) IF (0._sp .LT. prd + l) THEN @@ -16288,7 +17175,7 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & END IF END DO END DO - END SUBROUTINE GR5_TIME_STEP + END SUBROUTINE GR5_RI_TIME_STEP ! Differentiation of gr6_time_step in forward (tangent) mode (with options fixinterface noISIZE context): ! variations of useful results: ac_qt ac_he ac_hi ac_hp ac_ht @@ -20666,6 +21553,59 @@ SUBROUTINE SIMULATION_CHECKPOINT_D(setup, mesh, input_data, parameters& checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 rr_parameters_inc = rr_parameters_inc + 4 rr_states_inc = rr_states_inc + 3 + CASE ('gr4_ri') +! 'gr4_ri' module +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+1) + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+2) + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % hi +! % hp +! % ht + CALL GR4_RI_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_d%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+5), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+6), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+6), h1, & +& h1_d, h2, h2_d, h3, h3_d, checkpoint_variable%& +& ac_qtz(:, setup%nqz), checkpoint_variable_d%& +& ac_qtz(:, setup%nqz)) + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+1) = h1_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+2) = h2_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) = h3_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + rr_parameters_inc = rr_parameters_inc + 6 + rr_states_inc = rr_states_inc + 3 CASE ('gr4_mlp') ! 'gr4_mlp' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -20875,7 +21815,63 @@ SUBROUTINE SIMULATION_CHECKPOINT_D(setup, mesh, input_data, parameters& checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) = h3_d checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 - rr_parameters_inc = rr_parameters_inc + 5 + rr_parameters_inc = rr_parameters_inc + 5 + rr_states_inc = rr_states_inc + 3 + CASE ('gr5_ri') +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+1) + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+2) + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % aexc +! % hi +! % hp +! % ht + CALL GR5_RI_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_d%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+5), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+6), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+6), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+7), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+7), h1, & +& h1_d, h2, h2_d, h3, h3_d, checkpoint_variable%& +& ac_qtz(:, setup%nqz), checkpoint_variable_d%& +& ac_qtz(:, setup%nqz)) + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+1) = h1_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+2) = h2_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) = h3_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + rr_parameters_inc = rr_parameters_inc + 7 rr_states_inc = rr_states_inc + 3 CASE ('gr6') ! 'gr6' module @@ -21301,6 +22297,49 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 CALL PUSHCONTROL4B(1) + CASE ('gr4_ri') +! 'gr4_ri' module +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % hi +! % hp +! % ht + CALL PUSHREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & +& SIZE(checkpoint_variable%ac_qtz, 1)) + CALL PUSHREAL4ARRAY(h3, mesh%nac) + CALL PUSHREAL4ARRAY(h2, mesh%nac) + CALL PUSHREAL4ARRAY(h1, mesh%nac) + CALL GR4_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+6), h1, h2& +& , h3, checkpoint_variable%ac_qtz(:, setup%nqz)) + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + CALL PUSHINTEGER4(rr_parameters_inc) + rr_parameters_inc = rr_parameters_inc + 6 + CALL PUSHINTEGER4(rr_states_inc) + rr_states_inc = rr_states_inc + 3 + CALL PUSHCONTROL4B(2) CASE ('gr4_mlp') ! 'gr4_mlp' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21343,7 +22382,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 4 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 - CALL PUSHCONTROL4B(2) + CALL PUSHCONTROL4B(3) CASE ('gr4_ode') ! 'gr4_ode' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21382,7 +22421,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 4 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 - CALL PUSHCONTROL4B(3) + CALL PUSHCONTROL4B(4) CASE ('gr4_ode_mlp') ! 'gr4_ode_mlp' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21426,7 +22465,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 4 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 - CALL PUSHCONTROL4B(4) + CALL PUSHCONTROL4B(5) CASE ('gr5') ! 'gr5' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21466,7 +22505,52 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 5 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 - CALL PUSHCONTROL4B(5) + CALL PUSHCONTROL4B(6) + CASE ('gr5_ri') +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % aexc +! % hi +! % hp +! % ht + CALL PUSHREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & +& SIZE(checkpoint_variable%ac_qtz, 1)) + CALL PUSHREAL4ARRAY(h3, mesh%nac) + CALL PUSHREAL4ARRAY(h2, mesh%nac) + CALL PUSHREAL4ARRAY(h1, mesh%nac) + CALL GR5_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+6), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+7), h1, h2, h3, & +& checkpoint_variable%ac_qtz(:, setup%nqz)) + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + CALL PUSHINTEGER4(rr_parameters_inc) + rr_parameters_inc = rr_parameters_inc + 7 + CALL PUSHINTEGER4(rr_states_inc) + rr_states_inc = rr_states_inc + 3 + CALL PUSHCONTROL4B(7) CASE ('gr6') ! 'gr6' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21514,7 +22598,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 6 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 4 - CALL PUSHCONTROL4B(6) + CALL PUSHCONTROL4B(8) CASE ('grc') ! 'grc' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21559,7 +22643,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 5 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 4 - CALL PUSHCONTROL4B(7) + CALL PUSHCONTROL4B(9) CASE ('grd') ! 'grd' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21587,7 +22671,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 2 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 2 - CALL PUSHCONTROL4B(8) + CALL PUSHCONTROL4B(10) CASE ('loieau') ! 'loieau' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21618,7 +22702,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 3 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 2 - CALL PUSHCONTROL4B(9) + CALL PUSHCONTROL4B(11) CASE ('vic3l') ! 'vic3l' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21674,7 +22758,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 9 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 4 - CALL PUSHCONTROL4B(10) + CALL PUSHCONTROL4B(12) CASE DEFAULT CALL PUSHCONTROL4B(0) END SELECT @@ -21771,60 +22855,125 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& & ac_qz) END IF CALL POPCONTROL4B(branch) - IF (branch .LT. 5) THEN - IF (branch .LT. 2) THEN + IF (branch .LT. 6) THEN + IF (branch .LT. 3) THEN IF (branch .NE. 0) THEN - CALL POPINTEGER4(rr_states_inc) - CALL POPINTEGER4(rr_parameters_inc) - h3_b = 0.0_4 - h3_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3& -& ) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & -& 0.0_4 - h2_b = 0.0_4 - h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2& -& ) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & -& 0.0_4 - h1_b = 0.0_4 - h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1& -& ) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & -& 0.0_4 - CALL POPREAL4ARRAY(h1, mesh%nac) - CALL POPREAL4ARRAY(h2, mesh%nac) - CALL POPREAL4ARRAY(h3, mesh%nac) - CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz)& -& , SIZE(checkpoint_variable%ac_qtz, 1)) - CALL GR4_TIME_STEP_B(setup, mesh, input_data, options, & -& returns, t, checkpoint_variable%ac_mlt, & -& checkpoint_variable_b%ac_mlt, & -& checkpoint_variable%ac_rr_parameters(:, & -& rr_parameters_inc+1), checkpoint_variable_b%& -& ac_rr_parameters(:, rr_parameters_inc+1), & -& checkpoint_variable%ac_rr_parameters(:, & -& rr_parameters_inc+2), checkpoint_variable_b%& -& ac_rr_parameters(:, rr_parameters_inc+2), & -& checkpoint_variable%ac_rr_parameters(:, & -& rr_parameters_inc+3), checkpoint_variable_b%& -& ac_rr_parameters(:, rr_parameters_inc+3), & -& checkpoint_variable%ac_rr_parameters(:, & -& rr_parameters_inc+4), checkpoint_variable_b%& -& ac_rr_parameters(:, rr_parameters_inc+4), h1& -& , h1_b, h2, h2_b, h3, h3_b, & -& checkpoint_variable%ac_qtz(:, setup%nqz), & -& checkpoint_variable_b%ac_qtz(:, setup%nqz)) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) + & -& h3_b - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + & -& h2_b - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & -& h1_b + IF (branch .EQ. 1) THEN + CALL POPINTEGER4(rr_states_inc) + CALL POPINTEGER4(rr_parameters_inc) + h3_b = 0.0_4 + h3_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +3) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& 0.0_4 + h2_b = 0.0_4 + h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +2) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& 0.0_4 + h1_b = 0.0_4 + h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +1) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& 0.0_4 + CALL POPREAL4ARRAY(h1, mesh%nac) + CALL POPREAL4ARRAY(h2, mesh%nac) + CALL POPREAL4ARRAY(h3, mesh%nac) + CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz& +& ), SIZE(checkpoint_variable%ac_qtz, 1)) + CALL GR4_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_b%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_b& +& %ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_b& +& %ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable_b& +& %ac_rr_parameters(:, rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), checkpoint_variable_b& +& %ac_rr_parameters(:, rr_parameters_inc+4), & +& h1, h1_b, h2, h2_b, h3, h3_b, & +& checkpoint_variable%ac_qtz(:, setup%nqz), & +& checkpoint_variable_b%ac_qtz(:, setup%nqz)) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) +& +& h3_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) +& +& h2_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) +& +& h1_b + ELSE + CALL POPINTEGER4(rr_states_inc) + CALL POPINTEGER4(rr_parameters_inc) + h3_b = 0.0_4 + h3_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +3) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& 0.0_4 + h2_b = 0.0_4 + h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +2) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& 0.0_4 + h1_b = 0.0_4 + h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +1) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& 0.0_4 + CALL POPREAL4ARRAY(h1, mesh%nac) + CALL POPREAL4ARRAY(h2, mesh%nac) + CALL POPREAL4ARRAY(h3, mesh%nac) + CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz& +& ), SIZE(checkpoint_variable%ac_qtz, 1)) + CALL GR4_RI_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_b%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+5), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+6), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+6), h1, h1_b, h2, & +& h2_b, h3, h3_b, checkpoint_variable%& +& ac_qtz(:, setup%nqz), & +& checkpoint_variable_b%ac_qtz(:, setup%& +& nqz)) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) +& +& h3_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) +& +& h2_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) +& +& h1_b + END IF END IF - ELSE IF (branch .EQ. 2) THEN + ELSE IF (branch .EQ. 3) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h3_b = 0.0_4 @@ -21880,7 +23029,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b - ELSE IF (branch .EQ. 3) THEN + ELSE IF (branch .EQ. 4) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h3_b = 0.0_4 @@ -21986,8 +23135,8 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b END IF - ELSE IF (branch .LT. 8) THEN - IF (branch .EQ. 5) THEN + ELSE IF (branch .LT. 9) THEN + IF (branch .EQ. 6) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h3_b = 0.0_4 @@ -22034,7 +23183,60 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b - ELSE IF (branch .EQ. 6) THEN + ELSE IF (branch .EQ. 7) THEN + CALL POPINTEGER4(rr_states_inc) + CALL POPINTEGER4(rr_parameters_inc) + h3_b = 0.0_4 + h3_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = 0.0_4 + h2_b = 0.0_4 + h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = 0.0_4 + h1_b = 0.0_4 + h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = 0.0_4 + CALL POPREAL4ARRAY(h1, mesh%nac) + CALL POPREAL4ARRAY(h2, mesh%nac) + CALL POPREAL4ARRAY(h3, mesh%nac) + CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & +& SIZE(checkpoint_variable%ac_qtz, 1)) + CALL GR5_RI_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_b%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+5), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+6), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+6), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+7), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+7), h1& +& , h1_b, h2, h2_b, h3, h3_b, & +& checkpoint_variable%ac_qtz(:, setup%nqz), & +& checkpoint_variable_b%ac_qtz(:, setup%nqz)) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) + & +& h3_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + & +& h2_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & +& h1_b + ELSE CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h4_b = 0.0_4 @@ -22091,7 +23293,9 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b - ELSE + END IF + ELSE IF (branch .LT. 11) THEN + IF (branch .EQ. 9) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h4_b = 0.0_4 @@ -22144,37 +23348,40 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& & h2_b checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & +& h1_b + ELSE + CALL POPINTEGER4(rr_states_inc) + CALL POPINTEGER4(rr_parameters_inc) + h2_b = 0.0_4 + h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = 0.0_4 + h1_b = 0.0_4 + h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = 0.0_4 + CALL POPREAL4ARRAY(h1, mesh%nac) + CALL POPREAL4ARRAY(h2, mesh%nac) + CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & +& SIZE(checkpoint_variable%ac_qtz, 1)) + CALL GRD_TIME_STEP_B(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_b%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+2), h1, & +& h1_b, h2, h2_b, checkpoint_variable%ac_qtz(:, & +& setup%nqz), checkpoint_variable_b%ac_qtz(:, & +& setup%nqz)) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + & +& h2_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b END IF - ELSE IF (branch .EQ. 8) THEN - CALL POPINTEGER4(rr_states_inc) - CALL POPINTEGER4(rr_parameters_inc) - h2_b = 0.0_4 - h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = 0.0_4 - h1_b = 0.0_4 - h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = 0.0_4 - CALL POPREAL4ARRAY(h1, mesh%nac) - CALL POPREAL4ARRAY(h2, mesh%nac) - CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & -& SIZE(checkpoint_variable%ac_qtz, 1)) - CALL GRD_TIME_STEP_B(setup, mesh, input_data, options, returns, & -& t, checkpoint_variable%ac_mlt, & -& checkpoint_variable_b%ac_mlt, checkpoint_variable& -& %ac_rr_parameters(:, rr_parameters_inc+1), & -& checkpoint_variable_b%ac_rr_parameters(:, & -& rr_parameters_inc+1), checkpoint_variable%& -& ac_rr_parameters(:, rr_parameters_inc+2), & -& checkpoint_variable_b%ac_rr_parameters(:, & -& rr_parameters_inc+2), h1, h1_b, h2, h2_b, & -& checkpoint_variable%ac_qtz(:, setup%nqz), & -& checkpoint_variable_b%ac_qtz(:, setup%nqz)) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + h2_b - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + h1_b - ELSE IF (branch .EQ. 9) THEN + ELSE IF (branch .EQ. 11) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h2_b = 0.0_4 @@ -22376,6 +23583,41 @@ SUBROUTINE SIMULATION_CHECKPOINT(setup, mesh, input_data, parameters, & checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 rr_parameters_inc = rr_parameters_inc + 4 rr_states_inc = rr_states_inc + 3 + CASE ('gr4_ri') +! 'gr4_ri' module +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % hi +! % hp +! % ht + CALL GR4_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+6), h1, h2& +& , h3, checkpoint_variable%ac_qtz(:, setup%nqz)) + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + rr_parameters_inc = rr_parameters_inc + 6 + rr_states_inc = rr_states_inc + 3 CASE ('gr4_mlp') ! 'gr4_mlp' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22510,6 +23752,43 @@ SUBROUTINE SIMULATION_CHECKPOINT(setup, mesh, input_data, parameters, & checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 rr_parameters_inc = rr_parameters_inc + 5 rr_states_inc = rr_states_inc + 3 + CASE ('gr5_ri') +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % aexc +! % hi +! % hp +! % ht + CALL GR5_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+6), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+7), h1, h2, h3, & +& checkpoint_variable%ac_qtz(:, setup%nqz)) + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + rr_parameters_inc = rr_parameters_inc + 7 + rr_states_inc = rr_states_inc + 3 CASE ('gr6') ! 'gr6' module ! % To avoid potential aliasing tapenade warning (DF02) diff --git a/smash/fcore/forward/forward_openmp_db.f90 b/smash/fcore/forward/forward_openmp_db.f90 index 6a006d4b..3f08c6d5 100644 --- a/smash/fcore/forward/forward_openmp_db.f90 +++ b/smash/fcore/forward/forward_openmp_db.f90 @@ -13492,6 +13492,267 @@ SUBROUTINE GR_PRODUCTION(fq_ps, fq_es, pn, en, cp, beta, hp, pr, perc) hp = hp_imd - perc*inv_cp END SUBROUTINE GR_PRODUCTION +! Differentiation of gr_ri_production in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): +! variations of useful results: hp perc pr +! with respect to varying inputs: alpha1 hp en cp pn + SUBROUTINE GR_RI_PRODUCTION_D(pn, pn_d, en, en_d, cp, cp_d, beta, & +& alpha1, alpha1_d, hp, hp_d, pr, pr_d, perc, perc_d, dt) + IMPLICIT NONE + REAL(sp), INTENT(IN) :: pn, en, cp, beta, alpha1 + REAL(sp), INTENT(IN) :: pn_d, en_d, cp_d, alpha1_d + REAL(sp), INTENT(IN) :: dt + REAL(sp), INTENT(INOUT) :: hp + REAL(sp), INTENT(INOUT) :: hp_d + REAL(sp), INTENT(OUT) :: pr, perc + REAL(sp), INTENT(OUT) :: pr_d, perc_d + REAL(sp) :: inv_cp, ps, es, hp_imd + REAL(sp) :: inv_cp_d, ps_d, es_d, hp_imd_d + REAL(sp) :: lambda, gam, inv_lambda + REAL(sp) :: lambda_d, gam_d, inv_lambda_d + INTRINSIC EXP + INTRINSIC SQRT + INTRINSIC TANH + REAL(sp) :: arg1 + REAL(sp) :: arg1_d + REAL(sp) :: arg2 + REAL(sp) :: arg2_d + REAL(sp) :: pwx1 + REAL(sp) :: pwx1_d + REAL(sp) :: pwr1 + REAL(sp) :: pwr1_d + REAL(sp) :: temp + REAL(sp) :: temp0 + REAL(sp) :: temp1 + REAL(sp) :: temp2 + REAL(sp) :: temp3 + REAL(sp) :: temp4 + inv_cp_d = -(cp_d/cp**2) + inv_cp = 1._sp/cp + pr = 0._sp + gam_d = EXP(-(pn*alpha1))*(alpha1*pn_d+pn*alpha1_d) + gam = 1._sp - EXP(-(pn*alpha1)) + temp = SQRT(-gam + 1._sp) + IF (1._sp - gam .EQ. 0.0) THEN + lambda_d = 0.0_4 + ELSE + lambda_d = -(gam_d/(2.0*temp)) + END IF + lambda = temp + inv_lambda_d = -(lambda_d/lambda**2) + inv_lambda = 1._sp/lambda + arg1_d = inv_cp*(pn*lambda_d+lambda*pn_d) + lambda*pn*inv_cp_d + arg1 = lambda*pn*inv_cp + arg2_d = inv_cp*(pn*lambda_d+lambda*pn_d) + lambda*pn*inv_cp_d + arg2 = lambda*pn*inv_cp + temp = TANH(arg2) + temp0 = lambda*hp*temp + 1._sp + temp1 = -(lambda*hp*(lambda*hp)) + 1._sp + temp2 = cp*inv_lambda*temp1 + temp3 = TANH(arg1) + temp4 = temp3*temp2/temp0 + ps_d = (temp2*(1.0-TANH(arg1)**2)*arg1_d+temp3*(temp1*(inv_lambda*& +& cp_d+cp*inv_lambda_d)-cp*inv_lambda*2*lambda*hp*(hp*lambda_d+& +& lambda*hp_d))-temp4*(temp*(hp*lambda_d+lambda*hp_d)+lambda*hp*(1.0& +& -TANH(arg2)**2)*arg2_d))/temp0 - dt*gam_d + ps = temp4 - dt*gam + temp4 = TANH(en*inv_cp) + temp3 = TANH(en*inv_cp) + temp2 = hp*cp*(-hp+2._sp) + temp1 = temp2*temp3/((-hp+1._sp)*temp4+1._sp) + es_d = (temp3*((2._sp-hp)*(cp*hp_d+hp*cp_d)-hp*cp*hp_d)+temp2*(1.0-& +& TANH(en*inv_cp)**2)*(inv_cp*en_d+en*inv_cp_d)-temp1*((1._sp-hp)*(& +& 1.0-TANH(en*inv_cp)**2)*(inv_cp*en_d+en*inv_cp_d)-temp4*hp_d))/((& +& 1._sp-hp)*temp4+1._sp) + es = temp1 + hp_imd_d = hp_d + inv_cp*(ps_d-es_d) + (ps-es)*inv_cp_d + hp_imd = hp + (ps-es)*inv_cp + IF (pn .GT. 0) THEN + pr_d = pn_d - cp*(hp_imd_d-hp_d) - (hp_imd-hp)*cp_d + pr = pn - (hp_imd-hp)*cp + ELSE + pr_d = 0.0_4 + END IF + pwx1_d = 4*hp_imd**3*hp_imd_d/beta**4 + pwx1 = 1._sp + (hp_imd/beta)**4 + pwr1_d = -(0.25_sp*pwx1**(-1.25)*pwx1_d) + pwr1 = pwx1**(-0.25_sp) + perc_d = (1._sp-pwr1)*(cp*hp_imd_d+hp_imd*cp_d) - hp_imd*cp*pwr1_d + perc = hp_imd*cp*(1._sp-pwr1) + hp_d = hp_imd_d - inv_cp*perc_d - perc*inv_cp_d + hp = hp_imd - perc*inv_cp + END SUBROUTINE GR_RI_PRODUCTION_D + +! Differentiation of gr_ri_production in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): +! gradient of useful results: alpha1 hp cp pn perc pr +! with respect to varying inputs: alpha1 hp en cp pn + SUBROUTINE GR_RI_PRODUCTION_B(pn, pn_b, en, en_b, cp, cp_b, beta, & +& alpha1, alpha1_b, hp, hp_b, pr, pr_b, perc, perc_b, dt) + IMPLICIT NONE + REAL(sp), INTENT(IN) :: pn, en, cp, beta, alpha1 + REAL(sp) :: pn_b, en_b, cp_b, alpha1_b + REAL(sp), INTENT(IN) :: dt + REAL(sp), INTENT(INOUT) :: hp + REAL(sp), INTENT(INOUT) :: hp_b + REAL(sp) :: pr, perc + REAL(sp) :: pr_b, perc_b + REAL(sp) :: inv_cp, ps, es, hp_imd + REAL(sp) :: inv_cp_b, ps_b, es_b, hp_imd_b + REAL(sp) :: lambda, gam, inv_lambda + REAL(sp) :: lambda_b, gam_b, inv_lambda_b + INTRINSIC EXP + INTRINSIC SQRT + INTRINSIC TANH + REAL(sp) :: arg1 + REAL(sp) :: arg1_b + REAL(sp) :: arg2 + REAL(sp) :: arg2_b + REAL(sp) :: pwx1 + REAL(sp) :: pwx1_b + REAL(sp) :: pwr1 + REAL(sp) :: pwr1_b + REAL(sp) :: temp + REAL(sp) :: temp_b + REAL(sp) :: temp0 + REAL(sp) :: temp_b0 + REAL(sp) :: temp1 + REAL(sp) :: temp2 + REAL(sp) :: temp3 + REAL(sp) :: temp_b1 + REAL(sp) :: temp4 + REAL(sp) :: temp_b2 + REAL(sp) :: temp_b3 + REAL(sp) :: temp_b4 + REAL(sp) :: temp_b5 + INTEGER :: branch + inv_cp = 1._sp/cp + gam = 1._sp - EXP(-(pn*alpha1)) + lambda = SQRT(1._sp - gam) + inv_lambda = 1._sp/lambda + arg1 = lambda*pn*inv_cp + arg2 = lambda*pn*inv_cp + ps = cp*inv_lambda*TANH(arg1)*(1._sp-(lambda*hp)**2)/(1._sp+lambda*& +& hp*TANH(arg2)) - gam*dt + es = hp*cp*(2._sp-hp)*TANH(en*inv_cp)/(1._sp+(1._sp-hp)*TANH(en*& +& inv_cp)) + hp_imd = hp + (ps-es)*inv_cp + IF (pn .GT. 0) THEN + CALL PUSHCONTROL1B(0) + ELSE + CALL PUSHCONTROL1B(1) + END IF + pwx1 = 1._sp + (hp_imd/beta)**4 + pwr1 = pwx1**(-0.25_sp) + CALL PUSHREAL4(perc) + perc = hp_imd*cp*(1._sp-pwr1) + pwx1 = 1._sp + (hp_imd/beta)**4 + pwr1 = pwx1**(-0.25_sp) + inv_cp = 1._sp/cp + perc_b = perc_b - inv_cp*hp_b + inv_cp_b = -(perc*hp_b) + CALL POPREAL4(perc) +!$OMP ATOMIC update + cp_b = cp_b + hp_imd*(1._sp-pwr1)*perc_b + pwr1_b = -(hp_imd*cp*perc_b) + pwx1_b = -(0.25_sp*pwx1**(-1.25)*pwr1_b) + hp_imd_b = hp_b + cp*(1._sp-pwr1)*perc_b + 4*hp_imd**3*pwx1_b/beta**& +& 4 + CALL POPCONTROL1B(branch) + IF (branch .EQ. 0) THEN + pn_b = pn_b + pr_b + hp_imd_b = hp_imd_b - cp*pr_b + hp_b = cp*pr_b +!$OMP ATOMIC update + cp_b = cp_b - (hp_imd-hp)*pr_b + ELSE + hp_b = 0.0_4 + END IF + es_b = -(inv_cp*hp_imd_b) + temp4 = TANH(en*inv_cp) + temp3 = (-hp+1._sp)*temp4 + 1._sp + temp1 = TANH(en*inv_cp) + temp0 = hp*cp*(-hp+2._sp) + temp_b1 = es_b/temp3 + temp_b0 = (2._sp-hp)*temp1*temp_b1 + temp_b4 = -(temp0*temp1*temp_b1/temp3) +!$OMP ATOMIC update + hp_b = hp_b + hp_imd_b + cp*temp_b0 - hp*cp*temp1*temp_b1 - temp4*& +& temp_b4 + ps_b = inv_cp*hp_imd_b + temp_b = (1.0-TANH(en*inv_cp)**2)*temp0*temp_b1 + temp_b5 = (1.0-TANH(en*inv_cp)**2)*(1._sp-hp)*temp_b4 + en_b = inv_cp*temp_b5 + inv_cp*temp_b +!$OMP ATOMIC update + cp_b = cp_b + hp*temp_b0 + arg1 = lambda*pn*inv_cp + arg2 = lambda*pn*inv_cp + inv_lambda = 1._sp/lambda + temp = TANH(arg2) + temp0 = lambda*hp*temp + 1._sp + temp1 = -(lambda*hp*(lambda*hp)) + 1._sp + temp2 = cp*inv_lambda*temp1 + temp3 = TANH(arg1) + temp_b0 = ps_b/temp0 + arg1_b = (1.0-TANH(arg1)**2)*temp2*temp_b0 + temp_b1 = temp3*temp_b0 + temp_b3 = -(temp3*temp2*temp_b0/temp0) + arg2_b = (1.0-TANH(arg2)**2)*lambda*hp*temp_b3 + inv_cp_b = inv_cp_b + (ps-es)*hp_imd_b + en*temp_b5 + en*temp_b + & +& lambda*pn*arg2_b + lambda*pn*arg1_b +!$OMP ATOMIC update + cp_b = cp_b + inv_lambda*temp1*temp_b1 - inv_cp_b/cp**2 + inv_lambda_b = cp*temp1*temp_b1 + temp_b2 = -(2*lambda*hp*cp*inv_lambda*temp_b1) + lambda_b = hp*temp*temp_b3 + hp*temp_b2 + pn*inv_cp*arg2_b + pn*& +& inv_cp*arg1_b - inv_lambda_b/lambda**2 + IF (1._sp - gam .EQ. 0.0) THEN + gam_b = -(dt*ps_b) + ELSE + gam_b = -(dt*ps_b) - lambda_b/(2.0*SQRT(1._sp-gam)) + END IF +!$OMP ATOMIC update + hp_b = hp_b + lambda*temp*temp_b3 + lambda*temp_b2 + temp_b = -(EXP(-(pn*alpha1))*gam_b) + pn_b = pn_b + lambda*inv_cp*arg2_b + lambda*inv_cp*arg1_b - alpha1*& +& temp_b +!$OMP ATOMIC update + alpha1_b = alpha1_b - pn*temp_b + END SUBROUTINE GR_RI_PRODUCTION_B + + SUBROUTINE GR_RI_PRODUCTION(pn, en, cp, beta, alpha1, hp, pr, perc, dt& +& ) + IMPLICIT NONE + REAL(sp), INTENT(IN) :: pn, en, cp, beta, alpha1 + REAL(sp), INTENT(IN) :: dt + REAL(sp), INTENT(INOUT) :: hp + REAL(sp), INTENT(OUT) :: pr, perc + REAL(sp) :: inv_cp, ps, es, hp_imd + REAL(sp) :: lambda, gam, inv_lambda + INTRINSIC EXP + INTRINSIC SQRT + INTRINSIC TANH + REAL(sp) :: arg1 + REAL(sp) :: arg2 + REAL(sp) :: pwx1 + REAL(sp) :: pwr1 + inv_cp = 1._sp/cp + pr = 0._sp + gam = 1._sp - EXP(-(pn*alpha1)) + lambda = SQRT(1._sp - gam) + inv_lambda = 1._sp/lambda + arg1 = lambda*pn*inv_cp + arg2 = lambda*pn*inv_cp + ps = cp*inv_lambda*TANH(arg1)*(1._sp-(lambda*hp)**2)/(1._sp+lambda*& +& hp*TANH(arg2)) - gam*dt + es = hp*cp*(2._sp-hp)*TANH(en*inv_cp)/(1._sp+(1._sp-hp)*TANH(en*& +& inv_cp)) + hp_imd = hp + (ps-es)*inv_cp + IF (pn .GT. 0) pr = pn - (hp_imd-hp)*cp + pwx1 = 1._sp + (hp_imd/beta)**4 + pwr1 = pwx1**(-0.25_sp) + perc = hp_imd*cp*(1._sp-pwr1) + hp = hp_imd - perc*inv_cp + END SUBROUTINE GR_RI_PRODUCTION + ! Differentiation of gr_exchange in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): ! variations of useful results: l ! with respect to varying inputs: kexc fq_l ht @@ -14914,17 +15175,15 @@ SUBROUTINE GR4_TIME_STEP(setup, mesh, input_data, options, returns, & END DO END SUBROUTINE GR4_TIME_STEP -! Differentiation of gr4_mlp_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): +! Differentiation of gr4_ri_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): ! variations of useful results: ac_qt ac_hi ac_hp ac_ht -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt - SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & -& returns, time_step, weight_1, weight_1_d, bias_1, bias_1_d, weight_2& -& , weight_2_d, bias_2, bias_2_d, weight_3, weight_3_d, bias_3, & -& bias_3_d, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & -& ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, & -& ac_ht_d, ac_qt, ac_qt_d) +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt + SUBROUTINE GR4_RI_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d& +& , ac_ct, ac_ct_d, ac_alpha1, ac_alpha1_d, ac_alpha2, ac_alpha2_d, & +& ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, ac_ht_d, & +& ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -14932,46 +15191,27 @@ SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1_d - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1_d - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2_d - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2_d - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3_d - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & & ac_ct_d, ac_kexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1_d, & +& ac_alpha2_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & & ac_ht_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_d - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer_d - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d, pn_d, en_d + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd - REAL(sp) :: pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + REAL(sp) :: pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d& +& , split_d + INTRINSIC TANH INTRINSIC MAX REAL(sp) :: temp CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& @@ -14982,12 +15222,14 @@ SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & ac_prcp = ac_prcp + ac_mlt ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp - en_d = 0.0_4 pn_d = 0.0_4 -! Interception with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & -!$OMP&ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_d, ac_ci_d, ac_hi_d& -!$OMP&, pn_d, en_d), PRIVATE(row, col, k), SCHEDULE(static) +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & +!$OMP&ac_hi, ac_hp, ac_ht, ac_qt), SHARED(ac_prcp_d, ac_ci_d, ac_cp_d, & +!$OMP&ac_ct_d, ac_kexc_d, ac_hi_d, ac_hp_d, ac_ht_d, ac_qt_d), PRIVATE(& +!$OMP&row, col, k, time_step_returns, pn, en, pr, perc, l, prr, prd, qr& +!$OMP&, qd, split), PRIVATE(pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d& +!$OMP&, qr_d, qd_d, split_d), PRIVATE(temp), SCHEDULE(static) DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -14996,110 +15238,58 @@ SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN CALL GR_INTERCEPTION_D(ac_prcp(k), ac_prcp_d(k), ac_pet(k), & & ac_ci(k), ac_ci_d(k), ac_hi(k), ac_hi_d(k)& -& , pn(k), pn_d(k), en(k), en_d(k)) +& , pn, pn_d, en, en_d) + CALL GR_RI_PRODUCTION_D(pn, pn_d, en, en_d, ac_cp(k), & +& ac_cp_d(k), beta, ac_alpha1(k), & +& ac_alpha1_d(k), ac_hp(k), ac_hp_d(k), pr, & +& pr_d, perc, perc_d, setup%dt) + CALL GR_EXCHANGE_D(0._sp, 0.0_4, ac_kexc(k), ac_kexc_d(k), & +& ac_ht(k), ac_ht_d(k), l, l_d) ELSE - pn_d(k) = 0.0_4 - pn(k) = 0._sp - en_d(k) = 0.0_4 - en(k) = 0._sp + pr = 0._sp + perc = 0._sp + l = 0._sp + l_d = 0.0_4 + perc_d = 0.0_4 + pr_d = 0.0_4 END IF - END IF - END DO - END DO - output_layer_d = 0.0_4 -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - input_layer_d(:) = (/ac_hp_d(k), ac_ht_d(k), pn_d(k), en_d(k& -& )/) - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP_D(weight_1, weight_1_d, bias_1, bias_1_d, & -& weight_2, weight_2_d, bias_2, bias_2_d, & -& weight_3, weight_3_d, bias_3, bias_3_d, & -& input_layer, input_layer_d, output_layer(:, k)& -& , output_layer_d(:, k)) + split_d = 0.9_sp*2*TANH(ac_alpha2(k)*pn)*(1.0-TANH(ac_alpha2(k& +& )*pn)**2)*(pn*ac_alpha2_d(k)+ac_alpha2(k)*pn_d) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp + prr_d = (1._sp-split)*(pr_d+perc_d) - (pr+perc)*split_d + l_d + prr = (1._sp-split)*(pr+perc) + l + prd_d = (pr+perc)*split_d + split*(pr_d+perc_d) + prd = split*(pr+perc) + CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & +& ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) + IF (0._sp .LT. prd + l) THEN + qd_d = prd_d + l_d + qd = prd + l ELSE - output_layer_d(:, k) = 0.0_4 - output_layer(:, k) = 0._sp + qd = 0._sp + qd_d = 0.0_4 END IF + ac_qt_d(k) = qr_d + qd_d + ac_qt(k) = qr + qd +! Transform from mm/dt to m3/s + temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) + ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt + ac_qt(k) = temp*(ac_qt(k)/setup%dt) END IF END DO END DO -! Production and transfer with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, output_layer, ac_prcp, ac_pet, ac_cp, beta, ac_ct, & -!$OMP&ac_kexc, ac_hp, ac_ht, ac_qt, pn, en), SHARED(output_layer_d, & -!$OMP&ac_prcp_d, ac_cp_d, ac_ct_d, ac_kexc_d, ac_hp_d, ac_ht_d, ac_qt_d& -!$OMP&, pn_d, en_d), PRIVATE(row, col, k, time_step_returns, pr, perc, l& -!$OMP&, prr, prd, qr, qd), PRIVATE(pr_d, perc_d, l_d, prr_d, prd_d, qr_d& -!$OMP&, qd_d), PRIVATE(temp), SCHEDULE(static) - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL GR_PRODUCTION_D(output_layer(1, k), output_layer_d(1, k& -& ), output_layer(2, k), output_layer_d(2, k), & -& pn(k), pn_d(k), en(k), en_d(k), ac_cp(k), & -& ac_cp_d(k), beta, ac_hp(k), ac_hp_d(k), pr, & -& pr_d, perc, perc_d) - CALL GR_EXCHANGE_D(output_layer(4, k), output_layer_d(4, k)& -& , ac_kexc(k), ac_kexc_d(k), ac_ht(k), ac_ht_d(k& -& ), l, l_d) - ELSE - pr = 0._sp - perc = 0._sp - l = 0._sp - l_d = 0.0_4 - perc_d = 0.0_4 - pr_d = 0.0_4 - END IF - temp = -(output_layer(3, k)*output_layer(3, k)) + 1._sp - prr_d = 0.9_sp*(temp*(pr_d+perc_d)-(pr+perc)*2*output_layer(3& -& , k)*output_layer_d(3, k)) + l_d - prr = 0.9_sp*(temp*(pr+perc)) + l - temp = 0.9_sp*(output_layer(3, k)*output_layer(3, k)) + 0.1_sp - prd_d = (pr+perc)*0.9_sp*2*output_layer(3, k)*output_layer_d(3& -& , k) + temp*(pr_d+perc_d) - prd = temp*(pr+perc) - CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & -& ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) - IF (0._sp .LT. prd + l) THEN - qd_d = prd_d + l_d - qd = prd + l - ELSE - qd = 0._sp - qd_d = 0.0_4 - END IF - ac_qt_d(k) = qr_d + qd_d - ac_qt(k) = qr + qd -! Transform from mm/dt to m3/s - temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) - ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt - ac_qt(k) = temp*(ac_qt(k)/setup%dt) - END IF - END DO - END DO - END SUBROUTINE GR4_MLP_TIME_STEP_D + END SUBROUTINE GR4_RI_TIME_STEP_D -! Differentiation of gr4_mlp_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): -! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt - SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & -& returns, time_step, weight_1, weight_1_b, bias_1, bias_1_b, weight_2& -& , weight_2_b, bias_2, bias_2_b, weight_3, weight_3_b, bias_3, & -& bias_3_b, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & -& ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, & -& ac_ht_b, ac_qt, ac_qt_b) +! Differentiation of gr4_ri_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt + SUBROUTINE GR4_RI_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b& +& , ac_ct, ac_ct_b, ac_alpha1, ac_alpha1_b, ac_alpha2, ac_alpha2_b, & +& ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, ac_ht_b, & +& ac_qt, ac_qt_b) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15107,51 +15297,32 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)) :: & -& weight_1_b - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(2)) :: bias_1_b - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)) :: & -& weight_2_b - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(3)) :: bias_2_b - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)) :: & -& weight_3_b - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 - REAL(sp), DIMENSION(setup%neurons(4)) :: bias_3_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & & ac_kexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 + REAL(sp), DIMENSION(mesh%nac) :: ac_alpha1_b, ac_alpha2_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & & ac_ht_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_b - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer_b - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b, pn_b, en_b + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd - REAL(sp) :: pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + REAL(sp) :: pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b& +& , split_b + INTRINSIC TANH INTRINSIC MAX + REAL(sp) :: dummydiff_b + REAL(sp) :: temp_b INTEGER :: branch INTEGER :: chunk_start INTEGER :: chunk_end - REAL(sp) :: temp_b CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& @@ -15159,60 +15330,11 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & ac_prcp = ac_prcp + ac_mlt ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp -! Interception with OPENMP -!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & -!$OMP&ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), PRIVATE(& -!$OMP&chunk_start, chunk_end) - CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) - DO col=chunk_start,chunk_end - DO row=1,mesh%nrow - IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0) THEN - CALL PUSHCONTROL2B(0) - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL PUSHREAL4(ac_hi(k)) - CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& -& k), pn(k), en(k)) - CALL PUSHCONTROL2B(2) - ELSE - pn(k) = 0._sp - en(k) = 0._sp - CALL PUSHCONTROL2B(1) - END IF - END IF - END DO - END DO -!$OMP END PARALLEL -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0) THEN - CALL PUSHCONTROL2B(0) - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL PUSHREAL4ARRAY(input_layer, setup%neurons(1)) - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & -& weight_3, bias_3, input_layer, output_layer(:, k)& -& ) - CALL PUSHCONTROL2B(2) - ELSE - output_layer(:, k) = 0._sp - CALL PUSHCONTROL2B(1) - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP !$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, output_layer, ac_prcp, ac_pet, ac_cp, beta, ac_ct, & -!$OMP&ac_kexc, ac_hp, ac_ht, ac_qt, pn, en), PRIVATE(row, col, k, & -!$OMP&time_step_returns, pr, perc, l, prr, prd, qr, qd), PRIVATE(& -!$OMP&chunk_start, chunk_end) +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & +!$OMP&ac_hi, ac_hp, ac_ht, ac_qt), PRIVATE(row, col, k, & +!$OMP&time_step_returns, pn, en, pr, perc, l, prr, prd, qr, qd, split), & +!$OMP&PRIVATE(chunk_start, chunk_end) CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) DO col=chunk_start,chunk_end DO row=1,mesh%nrow @@ -15220,17 +15342,19 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & & local_active_cell(row, col) .EQ. 0) THEN CALL PUSHCONTROL1B(0) ELSE - CALL PUSHINTEGER4(k) k = mesh%rowcol_to_ind_ac(row, col) IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4(en) + CALL PUSHREAL4(pn) + CALL PUSHREAL4(ac_hi(k)) + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn, en) CALL PUSHREAL4(perc) CALL PUSHREAL4(pr) CALL PUSHREAL4(ac_hp(k)) - CALL GR_PRODUCTION(output_layer(1, k), output_layer(2, k), & -& pn(k), en(k), ac_cp(k), beta, ac_hp(k), pr, & -& perc) - CALL GR_EXCHANGE(output_layer(4, k), ac_kexc(k), ac_ht(k), l& -& ) + CALL GR_RI_PRODUCTION(pn, en, ac_cp(k), beta, ac_alpha1(k), & +& ac_hp(k), pr, perc, setup%dt) + CALL GR_EXCHANGE(0._sp, ac_kexc(k), ac_ht(k), l) CALL PUSHCONTROL1B(1) ELSE CALL PUSHREAL4(pr) @@ -15240,9 +15364,11 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & l = 0._sp CALL PUSHCONTROL1B(0) END IF + CALL PUSHREAL4(split) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp CALL PUSHREAL4(prr) - prr = 0.9_sp*(1._sp-output_layer(3, k)**2)*(pr+perc) + l - prd = (0.1_sp+0.9_sp*output_layer(3, k)**2)*(pr+perc) + prr = (1._sp-split)*(pr+perc) + l + prd = split*(pr+perc) CALL PUSHREAL4(ac_ht(k)) CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & & qr) @@ -15257,23 +15383,29 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & END DO CALL PUSHREAL4(pr) CALL PUSHREAL4(perc) + CALL PUSHREAL4(pn) CALL PUSHREAL4(prr) - CALL PUSHINTEGER4(k) + CALL PUSHREAL4(split) + CALL PUSHREAL4(en) !$OMP END PARALLEL - output_layer_b = 0.0_4 - en_b = 0.0_4 + ac_prcp_b = 0.0_4 pn_b = 0.0_4 !$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, output_layer, ac_prcp, ac_pet, ac_cp, beta, ac_ct, & -!$OMP&ac_kexc, ac_hp, ac_ht, ac_qt, pn, en), SHARED(output_layer_b, & -!$OMP&ac_prcp_b, ac_cp_b, ac_ct_b, ac_kexc_b, ac_hp_b, ac_ht_b, ac_qt_b& -!$OMP&, pn_b, en_b), PRIVATE(row, col, k, time_step_returns, pr, perc, l& -!$OMP&, prr, prd, qr, qd), PRIVATE(pr_b, perc_b, l_b, prr_b, prd_b, qr_b& -!$OMP&, qd_b), PRIVATE(branch, chunk_end, chunk_start), PRIVATE(temp_b) - CALL POPINTEGER4(k) +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & +!$OMP&ac_hi, ac_hp, ac_ht, ac_qt), SHARED(ac_prcp_b, ac_ci_b, ac_cp_b, & +!$OMP&ac_ct_b, ac_kexc_b, ac_hi_b, ac_hp_b, ac_ht_b, ac_qt_b), PRIVATE(& +!$OMP&row, col, k, time_step_returns, pn, en, pr, perc, l, prr, prd, qr& +!$OMP&, qd, split), PRIVATE(pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b& +!$OMP&, qr_b, qd_b, split_b), PRIVATE(branch, chunk_end, chunk_start), & +!$OMP&PRIVATE(temp_b) + CALL POPREAL4(en) + CALL POPREAL4(split) CALL POPREAL4(prr) + CALL POPREAL4(pn) CALL POPREAL4(perc) CALL POPREAL4(pr) + pn_b = 0.0_4 + en_b = 0.0_4 pr_b = 0.0_4 perc_b = 0.0_4 l_b = 0.0_4 @@ -15281,11 +15413,14 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & prd_b = 0.0_4 qr_b = 0.0_4 qd_b = 0.0_4 + split_b = 0.0_4 + pn_b = 0.0_4 CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) DO col=chunk_end,chunk_start,-1 DO row=mesh%nrow,1,-1 CALL POPCONTROL1B(branch) IF (branch .NE. 0) THEN + k = mesh%rowcol_to_ind_ac(row, col) ac_qt_b(k) = mesh%dx(row, col)*1e-3_sp*mesh%dy(row, col)*& & ac_qt_b(k)/setup%dt qr_b = ac_qt_b(k) @@ -15302,99 +15437,49 @@ SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & CALL POPREAL4(ac_ht(k)) CALL GR_TRANSFER_B(5._sp, ac_prcp(k), prr, prr_b, ac_ct(k), & & ac_ct_b(k), ac_ht(k), ac_ht_b(k), qr, qr_b) -!$OMP ATOMIC update - output_layer_b(3, k) = output_layer_b(3, k) + 2*output_layer(3& -& , k)*0.9_sp*(pr+perc)*prd_b - 2*output_layer(3, k)*(pr+perc)& -& *0.9_sp*prr_b - temp_b = (0.9_sp*output_layer(3, k)**2+0.1_sp)*prd_b - pr_b = temp_b - perc_b = temp_b + split_b = (pr+perc)*prd_b - (pr+perc)*prr_b + pr_b = split*prd_b + (1._sp-split)*prr_b + perc_b = split*prd_b + (1._sp-split)*prr_b CALL POPREAL4(prr) - temp_b = (1._sp-output_layer(3, k)**2)*0.9_sp*prr_b l_b = l_b + prr_b - pr_b = pr_b + temp_b - perc_b = perc_b + temp_b + CALL POPREAL4(split) + temp_b = (1.0-TANH(ac_alpha2(k)*pn)**2)*2*TANH(ac_alpha2(k)*pn& +& )*0.9_sp*split_b +!$OMP ATOMIC update + ac_alpha2_b(k) = ac_alpha2_b(k) + pn*temp_b + pn_b = pn_b + ac_alpha2(k)*temp_b CALL POPCONTROL1B(branch) IF (branch .EQ. 0) THEN CALL POPREAL4(perc) CALL POPREAL4(pr) ELSE - CALL GR_EXCHANGE_B(output_layer(4, k), output_layer_b(4, k)& -& , ac_kexc(k), ac_kexc_b(k), ac_ht(k), ac_ht_b(k& -& ), l, l_b) + CALL GR_EXCHANGE_B(0._sp, dummydiff_b, ac_kexc(k), ac_kexc_b& +& (k), ac_ht(k), ac_ht_b(k), l, l_b) CALL POPREAL4(ac_hp(k)) CALL POPREAL4(pr) CALL POPREAL4(perc) - CALL GR_PRODUCTION_B(output_layer(1, k), output_layer_b(1, k& -& ), output_layer(2, k), output_layer_b(2, k), & -& pn(k), pn_b(k), en(k), en_b(k), ac_cp(k), & -& ac_cp_b(k), beta, ac_hp(k), ac_hp_b(k), pr, & -& pr_b, perc, perc_b) - END IF - CALL POPINTEGER4(k) - END IF - END DO - END DO -!$OMP END PARALLEL - DO col=mesh%ncol,1,-1 - DO row=mesh%nrow,1,-1 - CALL POPCONTROL2B(branch) - IF (branch .NE. 0) THEN - IF (branch .EQ. 1) THEN - k = mesh%rowcol_to_ind_ac(row, col) - output_layer_b(:, k) = 0.0_4 - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - CALL FORWARD_MLP_B(weight_1, weight_1_b, bias_1, bias_1_b, & -& weight_2, weight_2_b, bias_2, bias_2_b, & -& weight_3, weight_3_b, bias_3, bias_3_b, & -& input_layer, input_layer_b, output_layer(:, k)& -& , output_layer_b(:, k)) - output_layer_b(:, k) = 0.0_4 - CALL POPREAL4ARRAY(input_layer, setup%neurons(1)) - ac_hp_b(k) = ac_hp_b(k) + input_layer_b(1) - ac_ht_b(k) = ac_ht_b(k) + input_layer_b(2) - pn_b(k) = pn_b(k) + input_layer_b(3) - en_b(k) = en_b(k) + input_layer_b(4) - END IF - END IF - END DO - END DO - ac_prcp_b = 0.0_4 -!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & -!$OMP&ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_b, ac_ci_b, ac_hi_b& -!$OMP&, pn_b, en_b), PRIVATE(row, col, k), PRIVATE(branch, chunk_end, & -!$OMP&chunk_start) - en_b = 0.0_4 - pn_b = 0.0_4 - CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) - DO col=chunk_end,chunk_start,-1 - DO row=mesh%nrow,1,-1 - CALL POPCONTROL2B(branch) - IF (branch .NE. 0) THEN - IF (branch .EQ. 1) THEN - k = mesh%rowcol_to_ind_ac(row, col) - en_b(k) = 0.0_4 - pn_b(k) = 0.0_4 - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - CALL POPREAL4(ac_hi(k)) - CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & -& ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& -& , pn(k), pn_b(k), en(k), en_b(k)) - pn_b(k) = 0.0_4 - en_b(k) = 0.0_4 + CALL GR_RI_PRODUCTION_B(pn, pn_b, en, en_b, ac_cp(k), & +& ac_cp_b(k), beta, ac_alpha1(k), & +& ac_alpha1_b(k), ac_hp(k), ac_hp_b(k), pr, & +& pr_b, perc, perc_b, setup%dt) + CALL POPREAL4(ac_hi(k)) + CALL POPREAL4(pn) + CALL POPREAL4(en) + CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & +& ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& +& , pn, pn_b, en, en_b) + pn_b = 0.0_4 END IF END IF END DO END DO !$OMP END PARALLEL ac_mlt_b = ac_mlt_b + ac_prcp_b - END SUBROUTINE GR4_MLP_TIME_STEP_B + END SUBROUTINE GR4_RI_TIME_STEP_B - SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& -& , time_step, weight_1, bias_1, weight_2, bias_2, weight_3, bias_3, & -& ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) + SUBROUTINE GR4_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_alpha1, ac_alpha2, & +& ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15402,26 +15487,16 @@ SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + INTRINSIC TANH INTRINSIC MAX CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) @@ -15430,65 +15505,30 @@ SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& ac_prcp = ac_prcp + ac_mlt ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp -! Interception with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & -!$OMP&ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), SCHEDULE(& -!$OMP& static) - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& -& k), pn(k), en(k)) - ELSE - pn(k) = 0._sp - en(k) = 0._sp - END IF - END IF - END DO - END DO -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & -& weight_3, bias_3, input_layer, output_layer(:, k)& -& ) - ELSE - output_layer(:, k) = 0._sp - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP !$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, output_layer, ac_prcp, ac_pet, ac_cp, beta, ac_ct, & -!$OMP&ac_kexc, ac_hp, ac_ht, ac_qt, pn, en), PRIVATE(row, col, k, & -!$OMP&time_step_returns, pr, perc, l, prr, prd, qr, qd), SCHEDULE(static) +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & +!$OMP&ac_hi, ac_hp, ac_ht, ac_qt), PRIVATE(row, col, k, & +!$OMP&time_step_returns, pn, en, pr, perc, l, prr, prd, qr, qd, split), & +!$OMP& SCHEDULE(static) DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0)) THEN k = mesh%rowcol_to_ind_ac(row, col) IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL GR_PRODUCTION(output_layer(1, k), output_layer(2, k), & -& pn(k), en(k), ac_cp(k), beta, ac_hp(k), pr, & -& perc) - CALL GR_EXCHANGE(output_layer(4, k), ac_kexc(k), ac_ht(k), l& -& ) + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn, en) + CALL GR_RI_PRODUCTION(pn, en, ac_cp(k), beta, ac_alpha1(k), & +& ac_hp(k), pr, perc, setup%dt) + CALL GR_EXCHANGE(0._sp, ac_kexc(k), ac_ht(k), l) ELSE pr = 0._sp perc = 0._sp l = 0._sp END IF - prr = 0.9_sp*(1._sp-output_layer(3, k)**2)*(pr+perc) + l - prd = (0.1_sp+0.9_sp*output_layer(3, k)**2)*(pr+perc) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp + prr = (1._sp-split)*(pr+perc) + l + prd = split*(pr+perc) CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & & qr) IF (0._sp .LT. prd + l) THEN @@ -15503,16 +15543,19 @@ SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& END IF END DO END DO - END SUBROUTINE GR4_MLP_TIME_STEP + END SUBROUTINE GR4_RI_TIME_STEP -! Differentiation of gr4_ode_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): +! Differentiation of gr4_mlp_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): ! variations of useful results: ac_qt ac_hi ac_hp ac_ht -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt - SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & -& returns, time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d& -& , ac_ct, ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d& -& , ac_ht, ac_ht_d, ac_qt, ac_qt_d) +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt + SUBROUTINE GR4_MLP_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, weight_1, weight_1_d, bias_1, bias_1_d, weight_2& +& , weight_2_d, bias_2, bias_2_d, weight_3, weight_3_d, bias_3, & +& bias_3_d, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & +& ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, & +& ac_ht_d, ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15520,6 +15563,24 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1_d + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1_d + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2_d + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2_d + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3_d + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & @@ -15531,10 +15592,18 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & & ac_ht_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_d + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer_d REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d, pn_d, en_d INTEGER :: row, col, k, time_step_returns - REAL(sp) :: l + REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d + INTRINSIC MAX REAL(sp) :: temp CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) @@ -15542,12 +15611,14 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & & , 'pet', ac_pet) ac_prcp_d = ac_mlt_d ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp en_d = 0.0_4 pn_d = 0.0_4 ! Interception with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&ac_prcp, ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_d, ac_ci_d& -!$OMP&, ac_hi_d, pn_d, en_d), PRIVATE(row, col, k), SCHEDULE(static) +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & +!$OMP&ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_d, ac_ci_d, ac_hi_d& +!$OMP&, pn_d, en_d), PRIVATE(row, col, k), SCHEDULE(static) DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -15566,18 +15637,78 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO -! Production and transfer without OPENMP + output_layer_d = 0.0_4 +! Forward MLP without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0)) THEN k = mesh%rowcol_to_ind_ac(row, col) - CALL GR_PRODUCTION_TRANSFER_ODE_D(pn(k), pn_d(k), en(k), en_d(& -& k), ac_cp(k), ac_cp_d(k), ac_ct(k)& -& , ac_ct_d(k), ac_kexc(k), & -& ac_kexc_d(k), ac_hp(k), ac_hp_d(k)& -& , ac_ht(k), ac_ht_d(k), ac_qt(k), & -& ac_qt_d(k), l) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + input_layer_d(:) = (/ac_hp_d(k), ac_ht_d(k), pn_d(k), en_d(k& +& )/) + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP_D(weight_1, weight_1_d, bias_1, bias_1_d, & +& weight_2, weight_2_d, bias_2, bias_2_d, & +& weight_3, weight_3_d, bias_3, bias_3_d, & +& input_layer, input_layer_d, output_layer(:, k)& +& , output_layer_d(:, k)) + ELSE + output_layer_d(:, k) = 0.0_4 + output_layer(:, k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, output_layer, ac_prcp, ac_pet, ac_cp, beta, ac_ct, & +!$OMP&ac_kexc, ac_hp, ac_ht, ac_qt, pn, en), SHARED(output_layer_d, & +!$OMP&ac_prcp_d, ac_cp_d, ac_ct_d, ac_kexc_d, ac_hp_d, ac_ht_d, ac_qt_d& +!$OMP&, pn_d, en_d), PRIVATE(row, col, k, time_step_returns, pr, perc, l& +!$OMP&, prr, prd, qr, qd), PRIVATE(pr_d, perc_d, l_d, prr_d, prd_d, qr_d& +!$OMP&, qd_d), PRIVATE(temp), SCHEDULE(static) + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_PRODUCTION_D(output_layer(1, k), output_layer_d(1, k& +& ), output_layer(2, k), output_layer_d(2, k), & +& pn(k), pn_d(k), en(k), en_d(k), ac_cp(k), & +& ac_cp_d(k), beta, ac_hp(k), ac_hp_d(k), pr, & +& pr_d, perc, perc_d) + CALL GR_EXCHANGE_D(output_layer(4, k), output_layer_d(4, k)& +& , ac_kexc(k), ac_kexc_d(k), ac_ht(k), ac_ht_d(k& +& ), l, l_d) + ELSE + pr = 0._sp + perc = 0._sp + l = 0._sp + l_d = 0.0_4 + perc_d = 0.0_4 + pr_d = 0.0_4 + END IF + temp = -(output_layer(3, k)*output_layer(3, k)) + 1._sp + prr_d = 0.9_sp*(temp*(pr_d+perc_d)-(pr+perc)*2*output_layer(3& +& , k)*output_layer_d(3, k)) + l_d + prr = 0.9_sp*(temp*(pr+perc)) + l + temp = 0.9_sp*(output_layer(3, k)*output_layer(3, k)) + 0.1_sp + prd_d = (pr+perc)*0.9_sp*2*output_layer(3, k)*output_layer_d(3& +& , k) + temp*(pr_d+perc_d) + prd = temp*(pr+perc) + CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & +& ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) + IF (0._sp .LT. prd + l) THEN + qd_d = prd_d + l_d + qd = prd + l + ELSE + qd = 0._sp + qd_d = 0.0_4 + END IF + ac_qt_d(k) = qr_d + qd_d + ac_qt(k) = qr + qd ! Transform from mm/dt to m3/s temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt @@ -15585,17 +15716,21 @@ SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO - END SUBROUTINE GR4_ODE_TIME_STEP_D + END SUBROUTINE GR4_MLP_TIME_STEP_D -! Differentiation of gr4_ode_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): -! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt - SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & -& returns, time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b& -& , ac_ct, ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b& -& , ac_ht, ac_ht_b, ac_qt, ac_qt_b) +! Differentiation of gr4_mlp_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt + SUBROUTINE GR4_MLP_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, weight_1, weight_1_b, bias_1, bias_1_b, weight_2& +& , weight_2_b, bias_2, bias_2_b, weight_3, weight_3_b, bias_3, & +& bias_3_b, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & +& ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, & +& ac_ht_b, ac_qt, ac_qt_b) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15603,33 +15738,62 @@ SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt - REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b - REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & -& ac_kexc - REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & -& ac_kexc_b - REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht - REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & -& ac_ht_b - REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt - REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)) :: & +& weight_1_b + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(2)) :: bias_1_b + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)) :: & +& weight_2_b + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(3)) :: bias_2_b + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)) :: & +& weight_3_b + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(setup%neurons(4)) :: bias_3_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & +& ac_kexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & +& ac_ht_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_b + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer_b + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b, pn_b, en_b INTEGER :: row, col, k, time_step_returns - REAL(sp) :: l + REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b + INTRINSIC MAX INTEGER :: branch INTEGER :: chunk_start INTEGER :: chunk_end + REAL(sp) :: temp_b CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'pet', ac_pet) ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp ! Interception with OPENMP -!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&ac_prcp, ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), & -!$OMP&PRIVATE(chunk_start, chunk_end) +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & +!$OMP&ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), PRIVATE(& +!$OMP&chunk_start, chunk_end) CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) DO col=chunk_start,chunk_end DO row=1,mesh%nrow @@ -15651,57 +15815,187 @@ SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & END IF END DO END DO - CALL PUSHREAL4ARRAY(ac_prcp, mesh%nac) - CALL PUSHINTEGER4(time_step) !$OMP END PARALLEL -! Production and transfer without OPENMP +! Forward MLP without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL2B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4ARRAY(input_layer, setup%neurons(1)) + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & +& weight_3, bias_3, input_layer, output_layer(:, k)& +& ) + CALL PUSHCONTROL2B(2) + ELSE + output_layer(:, k) = 0._sp + CALL PUSHCONTROL2B(1) + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, output_layer, ac_prcp, ac_pet, ac_cp, beta, ac_ct, & +!$OMP&ac_kexc, ac_hp, ac_ht, ac_qt, pn, en), PRIVATE(row, col, k, & +!$OMP&time_step_returns, pr, perc, l, prr, prd, qr, qd), PRIVATE(& +!$OMP&chunk_start, chunk_end) + CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) + DO col=chunk_start,chunk_end + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0) THEN CALL PUSHCONTROL1B(0) ELSE + CALL PUSHINTEGER4(k) k = mesh%rowcol_to_ind_ac(row, col) - CALL PUSHREAL4(ac_qt(k)) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4(perc) + CALL PUSHREAL4(pr) + CALL PUSHREAL4(ac_hp(k)) + CALL GR_PRODUCTION(output_layer(1, k), output_layer(2, k), & +& pn(k), en(k), ac_cp(k), beta, ac_hp(k), pr, & +& perc) + CALL GR_EXCHANGE(output_layer(4, k), ac_kexc(k), ac_ht(k), l& +& ) + CALL PUSHCONTROL1B(1) + ELSE + CALL PUSHREAL4(pr) + pr = 0._sp + CALL PUSHREAL4(perc) + perc = 0._sp + l = 0._sp + CALL PUSHCONTROL1B(0) + END IF + CALL PUSHREAL4(prr) + prr = 0.9_sp*(1._sp-output_layer(3, k)**2)*(pr+perc) + l + prd = (0.1_sp+0.9_sp*output_layer(3, k)**2)*(pr+perc) CALL PUSHREAL4(ac_ht(k)) - CALL PUSHREAL4(ac_hp(k)) - CALL GR_PRODUCTION_TRANSFER_ODE(pn(k), en(k), ac_cp(k), ac_ct(& -& k), ac_kexc(k), ac_hp(k), ac_ht(k), & -& ac_qt(k), l) -! Transform from mm/dt to m3/s + CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & +& qr) + IF (0._sp .LT. prd + l) THEN + CALL PUSHCONTROL1B(0) + ELSE + CALL PUSHCONTROL1B(1) + END IF CALL PUSHCONTROL1B(1) END IF END DO END DO + CALL PUSHREAL4(pr) + CALL PUSHREAL4(perc) + CALL PUSHREAL4(prr) + CALL PUSHINTEGER4(k) +!$OMP END PARALLEL + output_layer_b = 0.0_4 en_b = 0.0_4 pn_b = 0.0_4 - DO col=mesh%ncol,1,-1 +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, output_layer, ac_prcp, ac_pet, ac_cp, beta, ac_ct, & +!$OMP&ac_kexc, ac_hp, ac_ht, ac_qt, pn, en), SHARED(output_layer_b, & +!$OMP&ac_prcp_b, ac_cp_b, ac_ct_b, ac_kexc_b, ac_hp_b, ac_ht_b, ac_qt_b& +!$OMP&, pn_b, en_b), PRIVATE(row, col, k, time_step_returns, pr, perc, l& +!$OMP&, prr, prd, qr, qd), PRIVATE(pr_b, perc_b, l_b, prr_b, prd_b, qr_b& +!$OMP&, qd_b), PRIVATE(branch, chunk_end, chunk_start), PRIVATE(temp_b) + CALL POPINTEGER4(k) + CALL POPREAL4(prr) + CALL POPREAL4(perc) + CALL POPREAL4(pr) + pr_b = 0.0_4 + perc_b = 0.0_4 + l_b = 0.0_4 + prr_b = 0.0_4 + prd_b = 0.0_4 + qr_b = 0.0_4 + qd_b = 0.0_4 + CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) + DO col=chunk_end,chunk_start,-1 DO row=mesh%nrow,1,-1 CALL POPCONTROL1B(branch) IF (branch .NE. 0) THEN - k = mesh%rowcol_to_ind_ac(row, col) ac_qt_b(k) = mesh%dx(row, col)*1e-3_sp*mesh%dy(row, col)*& & ac_qt_b(k)/setup%dt - CALL POPREAL4(ac_hp(k)) - CALL POPREAL4(ac_ht(k)) - CALL POPREAL4(ac_qt(k)) - CALL GR_PRODUCTION_TRANSFER_ODE_B(pn(k), pn_b(k), en(k), en_b(& -& k), ac_cp(k), ac_cp_b(k), ac_ct(k)& -& , ac_ct_b(k), ac_kexc(k), & -& ac_kexc_b(k), ac_hp(k), ac_hp_b(k)& -& , ac_ht(k), ac_ht_b(k), ac_qt(k), & -& ac_qt_b(k), l) + qr_b = ac_qt_b(k) + qd_b = ac_qt_b(k) ac_qt_b(k) = 0.0_4 + CALL POPCONTROL1B(branch) + IF (branch .EQ. 0) THEN + prd_b = qd_b + l_b = qd_b + ELSE + l_b = 0.0_4 + prd_b = 0.0_4 + END IF + CALL POPREAL4(ac_ht(k)) + CALL GR_TRANSFER_B(5._sp, ac_prcp(k), prr, prr_b, ac_ct(k), & +& ac_ct_b(k), ac_ht(k), ac_ht_b(k), qr, qr_b) +!$OMP ATOMIC update + output_layer_b(3, k) = output_layer_b(3, k) + 2*output_layer(3& +& , k)*0.9_sp*(pr+perc)*prd_b - 2*output_layer(3, k)*(pr+perc)& +& *0.9_sp*prr_b + temp_b = (0.9_sp*output_layer(3, k)**2+0.1_sp)*prd_b + pr_b = temp_b + perc_b = temp_b + CALL POPREAL4(prr) + temp_b = (1._sp-output_layer(3, k)**2)*0.9_sp*prr_b + l_b = l_b + prr_b + pr_b = pr_b + temp_b + perc_b = perc_b + temp_b + CALL POPCONTROL1B(branch) + IF (branch .EQ. 0) THEN + CALL POPREAL4(perc) + CALL POPREAL4(pr) + ELSE + CALL GR_EXCHANGE_B(output_layer(4, k), output_layer_b(4, k)& +& , ac_kexc(k), ac_kexc_b(k), ac_ht(k), ac_ht_b(k& +& ), l, l_b) + CALL POPREAL4(ac_hp(k)) + CALL POPREAL4(pr) + CALL POPREAL4(perc) + CALL GR_PRODUCTION_B(output_layer(1, k), output_layer_b(1, k& +& ), output_layer(2, k), output_layer_b(2, k), & +& pn(k), pn_b(k), en(k), en_b(k), ac_cp(k), & +& ac_cp_b(k), beta, ac_hp(k), ac_hp_b(k), pr, & +& pr_b, perc, perc_b) + END IF + CALL POPINTEGER4(k) + END IF + END DO + END DO +!$OMP END PARALLEL + DO col=mesh%ncol,1,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL2B(branch) + IF (branch .NE. 0) THEN + IF (branch .EQ. 1) THEN + k = mesh%rowcol_to_ind_ac(row, col) + output_layer_b(:, k) = 0.0_4 + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL FORWARD_MLP_B(weight_1, weight_1_b, bias_1, bias_1_b, & +& weight_2, weight_2_b, bias_2, bias_2_b, & +& weight_3, weight_3_b, bias_3, bias_3_b, & +& input_layer, input_layer_b, output_layer(:, k)& +& , output_layer_b(:, k)) + output_layer_b(:, k) = 0.0_4 + CALL POPREAL4ARRAY(input_layer, setup%neurons(1)) + ac_hp_b(k) = ac_hp_b(k) + input_layer_b(1) + ac_ht_b(k) = ac_ht_b(k) + input_layer_b(2) + pn_b(k) = pn_b(k) + input_layer_b(3) + en_b(k) = en_b(k) + input_layer_b(4) + END IF END IF END DO END DO ac_prcp_b = 0.0_4 -!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&ac_prcp, ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_b, ac_ci_b& -!$OMP&, ac_hi_b, pn_b, en_b), PRIVATE(row, col, k), PRIVATE(branch, & -!$OMP&chunk_end, chunk_start) - CALL POPINTEGER4(time_step) - CALL POPREAL4ARRAY(ac_prcp, mesh%nac) +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & +!$OMP&ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_b, ac_ci_b, ac_hi_b& +!$OMP&, pn_b, en_b), PRIVATE(row, col, k), PRIVATE(branch, chunk_end, & +!$OMP&chunk_start) en_b = 0.0_4 pn_b = 0.0_4 CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) @@ -15727,11 +16021,11 @@ SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & END DO !$OMP END PARALLEL ac_mlt_b = ac_mlt_b + ac_prcp_b - END SUBROUTINE GR4_ODE_TIME_STEP_B + END SUBROUTINE GR4_MLP_TIME_STEP_B - SUBROUTINE GR4_ODE_TIME_STEP(setup, mesh, input_data, options, returns& -& , time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, & -& ac_ht, ac_qt) + SUBROUTINE GR4_MLP_TIME_STEP(setup, mesh, input_data, options, returns& +& , time_step, weight_1, bias_1, weight_2, bias_2, weight_3, bias_3, & +& ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15739,23 +16033,38 @@ SUBROUTINE GR4_ODE_TIME_STEP(setup, mesh, input_data, options, returns& TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en INTEGER :: row, col, k, time_step_returns - REAL(sp) :: l + REAL(sp) :: beta, pr, perc, l, prr, prd, qr, qd + INTRINSIC MAX CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'pet', ac_pet) ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp ! Interception with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&ac_prcp, ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), & -!$OMP& SCHEDULE(static) +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & +!$OMP&ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), SCHEDULE(& +!$OMP& static) DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -15771,34 +16080,70 @@ SUBROUTINE GR4_ODE_TIME_STEP(setup, mesh, input_data, options, returns& END IF END DO END DO -! Production and transfer without OPENMP +! Forward MLP without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0)) THEN k = mesh%rowcol_to_ind_ac(row, col) - CALL GR_PRODUCTION_TRANSFER_ODE(pn(k), en(k), ac_cp(k), ac_ct(& -& k), ac_kexc(k), ac_hp(k), ac_ht(k), & -& ac_qt(k), l) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & +& weight_3, bias_3, input_layer, output_layer(:, k)& +& ) + ELSE + output_layer(:, k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, output_layer, ac_prcp, ac_pet, ac_cp, beta, ac_ct, & +!$OMP&ac_kexc, ac_hp, ac_ht, ac_qt, pn, en), PRIVATE(row, col, k, & +!$OMP&time_step_returns, pr, perc, l, prr, prd, qr, qd), SCHEDULE(static) + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_PRODUCTION(output_layer(1, k), output_layer(2, k), & +& pn(k), en(k), ac_cp(k), beta, ac_hp(k), pr, & +& perc) + CALL GR_EXCHANGE(output_layer(4, k), ac_kexc(k), ac_ht(k), l& +& ) + ELSE + pr = 0._sp + perc = 0._sp + l = 0._sp + END IF + prr = 0.9_sp*(1._sp-output_layer(3, k)**2)*(pr+perc) + l + prd = (0.1_sp+0.9_sp*output_layer(3, k)**2)*(pr+perc) + CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & +& qr) + IF (0._sp .LT. prd + l) THEN + qd = prd + l + ELSE + qd = 0._sp + END IF + ac_qt(k) = qr + qd ! Transform from mm/dt to m3/s ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col& & )/setup%dt END IF END DO END DO - END SUBROUTINE GR4_ODE_TIME_STEP + END SUBROUTINE GR4_MLP_TIME_STEP -! Differentiation of gr4_ode_mlp_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): +! Differentiation of gr4_ode_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): ! variations of useful results: ac_qt ac_hi ac_hp ac_ht -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt - SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & -& returns, time_step, weight_1, weight_1_d, bias_1, bias_1_d, weight_2& -& , weight_2_d, bias_2, bias_2_d, weight_3, weight_3_d, bias_3, & -& bias_3_d, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & -& ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, & -& ac_ht_d, ac_qt, ac_qt_d) +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt + SUBROUTINE GR4_ODE_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d& +& , ac_ct, ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d& +& , ac_ht, ac_ht_d, ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15806,24 +16151,6 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1_d - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1_d - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2_d - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2_d - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3_d - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & @@ -15835,12 +16162,6 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & & ac_ht_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_d - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer_d REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d, pn_d, en_d INTEGER :: row, col, k, time_step_returns @@ -15855,9 +16176,9 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & en_d = 0.0_4 pn_d = 0.0_4 ! Interception with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & -!$OMP&ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_d, ac_ci_d, ac_hi_d& -!$OMP&, pn_d, en_d), PRIVATE(row, col, k), SCHEDULE(static) +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&ac_prcp, ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_d, ac_ci_d& +!$OMP&, ac_hi_d, pn_d, en_d), PRIVATE(row, col, k), SCHEDULE(static) DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -15876,48 +16197,18 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO - output_layer_d = 0.0_4 -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - input_layer_d(:) = (/ac_hp_d(k), ac_ht_d(k), pn_d(k), en_d(k& -& )/) - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP_D(weight_1, weight_1_d, bias_1, bias_1_d, & -& weight_2, weight_2_d, bias_2, bias_2_d, & -& weight_3, weight_3_d, bias_3, bias_3_d, & -& input_layer, input_layer_d, output_layer(:, k)& -& , output_layer_d(:, k)) - ELSE - output_layer_d(:, k) = 0.0_4 - output_layer(:, k) = 0._sp - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, output_layer, ac_cp, ac_ct, ac_kexc, ac_hp, ac_ht, ac_qt& -!$OMP&, pn, en), SHARED(output_layer_d, ac_cp_d, ac_ct_d, ac_kexc_d, & -!$OMP&ac_hp_d, ac_ht_d, ac_qt_d, pn_d, en_d), PRIVATE(row, col, k, & -!$OMP&time_step_returns, l), PRIVATE(temp), SCHEDULE(static) +! Production and transfer without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0)) THEN k = mesh%rowcol_to_ind_ac(row, col) - CALL GR_PRODUCTION_TRANSFER_ODE_MLP_D(output_layer(:, k), & -& output_layer_d(:, k), pn(k), & -& pn_d(k), en(k), en_d(k), ac_cp& -& (k), ac_cp_d(k), ac_ct(k), & -& ac_ct_d(k), ac_kexc(k), & -& ac_kexc_d(k), ac_hp(k), & -& ac_hp_d(k), ac_ht(k), ac_ht_d(& -& k), ac_qt(k), ac_qt_d(k), l) + CALL GR_PRODUCTION_TRANSFER_ODE_D(pn(k), pn_d(k), en(k), en_d(& +& k), ac_cp(k), ac_cp_d(k), ac_ct(k)& +& , ac_ct_d(k), ac_kexc(k), & +& ac_kexc_d(k), ac_hp(k), ac_hp_d(k)& +& , ac_ht(k), ac_ht_d(k), ac_qt(k), & +& ac_qt_d(k), l) ! Transform from mm/dt to m3/s temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt @@ -15925,21 +16216,17 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & END IF END DO END DO - END SUBROUTINE GR4_ODE_MLP_TIME_STEP_D + END SUBROUTINE GR4_ODE_TIME_STEP_D -! Differentiation of gr4_ode_mlp_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): -! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 -! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 -! weight_3 ac_ht ac_mlt - SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & -& returns, time_step, weight_1, weight_1_b, bias_1, bias_1_b, weight_2& -& , weight_2_b, bias_2, bias_2_b, weight_3, weight_3_b, bias_3, & -& bias_3_b, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & -& ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, & -& ac_ht_b, ac_qt, ac_qt_b) +! Differentiation of gr4_ode_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt + SUBROUTINE GR4_ODE_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b& +& , ac_ct, ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b& +& , ac_ht, ac_ht_b, ac_qt, ac_qt_b) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -15947,24 +16234,6 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & TYPE(OPTIONSDT), INTENT(IN) :: options TYPE(RETURNSDT), INTENT(INOUT) :: returns INTEGER, INTENT(IN) :: time_step - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & -& :: weight_1 - REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)) :: & -& weight_1_b - REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 - REAL(sp), DIMENSION(setup%neurons(2)) :: bias_1_b - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & -& :: weight_2 - REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)) :: & -& weight_2_b - REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 - REAL(sp), DIMENSION(setup%neurons(3)) :: bias_2_b - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & -& :: weight_3 - REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)) :: & -& weight_3_b - REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 - REAL(sp), DIMENSION(setup%neurons(4)) :: bias_3_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & @@ -15976,12 +16245,6 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & & ac_ht_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_b - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer_b REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b, pn_b, en_b INTEGER :: row, col, k, time_step_returns @@ -15995,9 +16258,9 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & & , 'pet', ac_pet) ac_prcp = ac_prcp + ac_mlt ! Interception with OPENMP -!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & -!$OMP&ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), PRIVATE(& -!$OMP&chunk_start, chunk_end) +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&ac_prcp, ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), & +!$OMP&PRIVATE(chunk_start, chunk_end) CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) DO col=chunk_start,chunk_end DO row=1,mesh%nrow @@ -16019,38 +16282,13 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & END IF END DO END DO + CALL PUSHREAL4ARRAY(ac_prcp, mesh%nac) + CALL PUSHINTEGER4(time_step) !$OMP END PARALLEL -! Forward MLP without OPENMP +! Production and transfer without OPENMP DO col=1,mesh%ncol DO row=1,mesh%nrow IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0) THEN - CALL PUSHCONTROL2B(0) - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - CALL PUSHREAL4ARRAY(input_layer, setup%neurons(1)) - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & -& weight_3, bias_3, input_layer, output_layer(:, k)& -& ) - CALL PUSHCONTROL2B(2) - ELSE - output_layer(:, k) = 0._sp - CALL PUSHCONTROL2B(1) - END IF - END IF - END DO - END DO -! Production and transfer with OPENMP -!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, output_layer, ac_cp, ac_ct, ac_kexc, ac_hp, ac_ht, ac_qt& -!$OMP&, pn, en), PRIVATE(row, col, k, time_step_returns, l), PRIVATE(& -!$OMP&chunk_start, chunk_end) - CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) - DO col=chunk_start,chunk_end - DO row=1,mesh%nrow - IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& & local_active_cell(row, col) .EQ. 0) THEN CALL PUSHCONTROL1B(0) ELSE @@ -16058,26 +16296,17 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & CALL PUSHREAL4(ac_qt(k)) CALL PUSHREAL4(ac_ht(k)) CALL PUSHREAL4(ac_hp(k)) - CALL GR_PRODUCTION_TRANSFER_ODE_MLP(output_layer(:, k), pn(k)& -& , en(k), ac_cp(k), ac_ct(k), & -& ac_kexc(k), ac_hp(k), ac_ht(k), & -& ac_qt(k), l) + CALL GR_PRODUCTION_TRANSFER_ODE(pn(k), en(k), ac_cp(k), ac_ct(& +& k), ac_kexc(k), ac_hp(k), ac_ht(k), & +& ac_qt(k), l) ! Transform from mm/dt to m3/s CALL PUSHCONTROL1B(1) END IF END DO END DO -!$OMP END PARALLEL - output_layer_b = 0.0_4 en_b = 0.0_4 pn_b = 0.0_4 -!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, output_layer, ac_cp, ac_ct, ac_kexc, ac_hp, ac_ht, ac_qt& -!$OMP&, pn, en), SHARED(output_layer_b, ac_cp_b, ac_ct_b, ac_kexc_b, & -!$OMP&ac_hp_b, ac_ht_b, ac_qt_b, pn_b, en_b), PRIVATE(row, col, k, & -!$OMP&time_step_returns, l), PRIVATE(branch, chunk_end, chunk_start) - CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) - DO col=chunk_end,chunk_start,-1 + DO col=mesh%ncol,1,-1 DO row=mesh%nrow,1,-1 CALL POPCONTROL1B(branch) IF (branch .NE. 0) THEN @@ -16087,48 +16316,23 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & CALL POPREAL4(ac_hp(k)) CALL POPREAL4(ac_ht(k)) CALL POPREAL4(ac_qt(k)) - CALL GR_PRODUCTION_TRANSFER_ODE_MLP_B(output_layer(:, k), & -& output_layer_b(:, k), pn(k), & -& pn_b(k), en(k), en_b(k), ac_cp& -& (k), ac_cp_b(k), ac_ct(k), & -& ac_ct_b(k), ac_kexc(k), & -& ac_kexc_b(k), ac_hp(k), & -& ac_hp_b(k), ac_ht(k), ac_ht_b(& -& k), ac_qt(k), ac_qt_b(k), l) + CALL GR_PRODUCTION_TRANSFER_ODE_B(pn(k), pn_b(k), en(k), en_b(& +& k), ac_cp(k), ac_cp_b(k), ac_ct(k)& +& , ac_ct_b(k), ac_kexc(k), & +& ac_kexc_b(k), ac_hp(k), ac_hp_b(k)& +& , ac_ht(k), ac_ht_b(k), ac_qt(k), & +& ac_qt_b(k), l) ac_qt_b(k) = 0.0_4 END IF END DO END DO -!$OMP END PARALLEL - DO col=mesh%ncol,1,-1 - DO row=mesh%nrow,1,-1 - CALL POPCONTROL2B(branch) - IF (branch .NE. 0) THEN - IF (branch .EQ. 1) THEN - k = mesh%rowcol_to_ind_ac(row, col) - output_layer_b(:, k) = 0.0_4 - ELSE - k = mesh%rowcol_to_ind_ac(row, col) - CALL FORWARD_MLP_B(weight_1, weight_1_b, bias_1, bias_1_b, & -& weight_2, weight_2_b, bias_2, bias_2_b, & -& weight_3, weight_3_b, bias_3, bias_3_b, & -& input_layer, input_layer_b, output_layer(:, k)& -& , output_layer_b(:, k)) - output_layer_b(:, k) = 0.0_4 - CALL POPREAL4ARRAY(input_layer, setup%neurons(1)) - ac_hp_b(k) = ac_hp_b(k) + input_layer_b(1) - ac_ht_b(k) = ac_ht_b(k) + input_layer_b(2) - pn_b(k) = pn_b(k) + input_layer_b(3) - en_b(k) = en_b(k) + input_layer_b(4) - END IF - END IF - END DO - END DO ac_prcp_b = 0.0_4 -!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & -!$OMP&ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_b, ac_ci_b, ac_hi_b& -!$OMP&, pn_b, en_b), PRIVATE(row, col, k), PRIVATE(branch, chunk_end, & -!$OMP&chunk_start) +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&ac_prcp, ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_b, ac_ci_b& +!$OMP&, ac_hi_b, pn_b, en_b), PRIVATE(row, col, k), PRIVATE(branch, & +!$OMP&chunk_end, chunk_start) + CALL POPINTEGER4(time_step) + CALL POPREAL4ARRAY(ac_prcp, mesh%nac) en_b = 0.0_4 pn_b = 0.0_4 CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) @@ -16154,12 +16358,78 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & END DO !$OMP END PARALLEL ac_mlt_b = ac_mlt_b + ac_prcp_b - END SUBROUTINE GR4_ODE_MLP_TIME_STEP_B + END SUBROUTINE GR4_ODE_TIME_STEP_B - SUBROUTINE GR4_ODE_MLP_TIME_STEP(setup, mesh, input_data, options, & -& returns, time_step, weight_1, bias_1, weight_2, bias_2, weight_3, & -& bias_3, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, & -& ac_qt) + SUBROUTINE GR4_ODE_TIME_STEP(setup, mesh, input_data, options, returns& +& , time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, & +& ac_ht, ac_qt) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: l + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp = ac_prcp + ac_mlt +! Interception with OPENMP +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&ac_prcp, ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), & +!$OMP& SCHEDULE(static) + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn(k), en(k)) + ELSE + pn(k) = 0._sp + en(k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + CALL GR_PRODUCTION_TRANSFER_ODE(pn(k), en(k), ac_cp(k), ac_ct(& +& k), ac_kexc(k), ac_hp(k), ac_ht(k), & +& ac_qt(k), l) +! Transform from mm/dt to m3/s + ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col& +& )/setup%dt + END IF + END DO + END DO + END SUBROUTINE GR4_ODE_TIME_STEP + +! Differentiation of gr4_ode_mlp_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): +! variations of useful results: ac_qt ac_hi ac_hp ac_ht +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt + SUBROUTINE GR4_ODE_MLP_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, weight_1, weight_1_d, bias_1, bias_1_d, weight_2& +& , weight_2_d, bias_2, bias_2_d, weight_3, weight_3_d, bias_3, & +& bias_3_d, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & +& ac_ct_d, ac_kexc, ac_kexc_d, ac_hi, ac_hi_d, ac_hp, ac_hp_d, ac_ht, & +& ac_ht_d, ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -16169,33 +16439,742 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP(setup, mesh, input_data, options, & INTEGER, INTENT(IN) :: time_step REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & & :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1_d REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1_d REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & & :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2_d REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2_d REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & & :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3_d REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & +& ac_ct_d, ac_kexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & +& ac_ht_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_d + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer_d + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d, pn_d, en_d + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: l + REAL(sp) :: temp + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp_d = ac_mlt_d + ac_prcp = ac_prcp + ac_mlt + en_d = 0.0_4 + pn_d = 0.0_4 +! Interception with OPENMP +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & +!$OMP&ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_d, ac_ci_d, ac_hi_d& +!$OMP&, pn_d, en_d), PRIVATE(row, col, k), SCHEDULE(static) + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_INTERCEPTION_D(ac_prcp(k), ac_prcp_d(k), ac_pet(k), & +& ac_ci(k), ac_ci_d(k), ac_hi(k), ac_hi_d(k)& +& , pn(k), pn_d(k), en(k), en_d(k)) + ELSE + pn_d(k) = 0.0_4 + pn(k) = 0._sp + en_d(k) = 0.0_4 + en(k) = 0._sp + END IF + END IF + END DO + END DO + output_layer_d = 0.0_4 +! Forward MLP without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + input_layer_d(:) = (/ac_hp_d(k), ac_ht_d(k), pn_d(k), en_d(k& +& )/) + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP_D(weight_1, weight_1_d, bias_1, bias_1_d, & +& weight_2, weight_2_d, bias_2, bias_2_d, & +& weight_3, weight_3_d, bias_3, bias_3_d, & +& input_layer, input_layer_d, output_layer(:, k)& +& , output_layer_d(:, k)) + ELSE + output_layer_d(:, k) = 0.0_4 + output_layer(:, k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, output_layer, ac_cp, ac_ct, ac_kexc, ac_hp, ac_ht, ac_qt& +!$OMP&, pn, en), SHARED(output_layer_d, ac_cp_d, ac_ct_d, ac_kexc_d, & +!$OMP&ac_hp_d, ac_ht_d, ac_qt_d, pn_d, en_d), PRIVATE(row, col, k, & +!$OMP&time_step_returns, l), PRIVATE(temp), SCHEDULE(static) + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + CALL GR_PRODUCTION_TRANSFER_ODE_MLP_D(output_layer(:, k), & +& output_layer_d(:, k), pn(k), & +& pn_d(k), en(k), en_d(k), ac_cp& +& (k), ac_cp_d(k), ac_ct(k), & +& ac_ct_d(k), ac_kexc(k), & +& ac_kexc_d(k), ac_hp(k), & +& ac_hp_d(k), ac_ht(k), ac_ht_d(& +& k), ac_qt(k), ac_qt_d(k), l) +! Transform from mm/dt to m3/s + temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) + ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt + ac_qt(k) = temp*(ac_qt(k)/setup%dt) + END IF + END DO + END DO + END SUBROUTINE GR4_ODE_MLP_TIME_STEP_D + +! Differentiation of gr4_ode_mlp_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct bias_1 +! bias_2 bias_3 ac_qt ac_hi ac_hp weight_1 weight_2 +! weight_3 ac_ht ac_mlt + SUBROUTINE GR4_ODE_MLP_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, weight_1, weight_1_b, bias_1, bias_1_b, weight_2& +& , weight_2_b, bias_2, bias_2_b, weight_3, weight_3_b, bias_3, & +& bias_3_b, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & +& ac_ct_b, ac_kexc, ac_kexc_b, ac_hi, ac_hi_b, ac_hp, ac_hp_b, ac_ht, & +& ac_ht_b, ac_qt, ac_qt_b) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)) :: & +& weight_1_b + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(2)) :: bias_1_b + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)) :: & +& weight_2_b + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(3)) :: bias_2_b + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)) :: & +& weight_3_b + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(setup%neurons(4)) :: bias_3_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & +& ac_kexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & +& ac_ht_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer_b + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer_b + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b, pn_b, en_b + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: l + INTEGER :: branch + INTEGER :: chunk_start + INTEGER :: chunk_end + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp = ac_prcp + ac_mlt +! Interception with OPENMP +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & +!$OMP&ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), PRIVATE(& +!$OMP&chunk_start, chunk_end) + CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) + DO col=chunk_start,chunk_end + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL2B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4(ac_hi(k)) + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn(k), en(k)) + CALL PUSHCONTROL2B(2) + ELSE + pn(k) = 0._sp + en(k) = 0._sp + CALL PUSHCONTROL2B(1) + END IF + END IF + END DO + END DO +!$OMP END PARALLEL +! Forward MLP without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL2B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4ARRAY(input_layer, setup%neurons(1)) + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & +& weight_3, bias_3, input_layer, output_layer(:, k)& +& ) + CALL PUSHCONTROL2B(2) + ELSE + output_layer(:, k) = 0._sp + CALL PUSHCONTROL2B(1) + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, output_layer, ac_cp, ac_ct, ac_kexc, ac_hp, ac_ht, ac_qt& +!$OMP&, pn, en), PRIVATE(row, col, k, time_step_returns, l), PRIVATE(& +!$OMP&chunk_start, chunk_end) + CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) + DO col=chunk_start,chunk_end + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL1B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL PUSHREAL4(ac_qt(k)) + CALL PUSHREAL4(ac_ht(k)) + CALL PUSHREAL4(ac_hp(k)) + CALL GR_PRODUCTION_TRANSFER_ODE_MLP(output_layer(:, k), pn(k)& +& , en(k), ac_cp(k), ac_ct(k), & +& ac_kexc(k), ac_hp(k), ac_ht(k), & +& ac_qt(k), l) +! Transform from mm/dt to m3/s + CALL PUSHCONTROL1B(1) + END IF + END DO + END DO +!$OMP END PARALLEL + output_layer_b = 0.0_4 + en_b = 0.0_4 + pn_b = 0.0_4 +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, output_layer, ac_cp, ac_ct, ac_kexc, ac_hp, ac_ht, ac_qt& +!$OMP&, pn, en), SHARED(output_layer_b, ac_cp_b, ac_ct_b, ac_kexc_b, & +!$OMP&ac_hp_b, ac_ht_b, ac_qt_b, pn_b, en_b), PRIVATE(row, col, k, & +!$OMP&time_step_returns, l), PRIVATE(branch, chunk_end, chunk_start) + CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) + DO col=chunk_end,chunk_start,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL1B(branch) + IF (branch .NE. 0) THEN + k = mesh%rowcol_to_ind_ac(row, col) + ac_qt_b(k) = mesh%dx(row, col)*1e-3_sp*mesh%dy(row, col)*& +& ac_qt_b(k)/setup%dt + CALL POPREAL4(ac_hp(k)) + CALL POPREAL4(ac_ht(k)) + CALL POPREAL4(ac_qt(k)) + CALL GR_PRODUCTION_TRANSFER_ODE_MLP_B(output_layer(:, k), & +& output_layer_b(:, k), pn(k), & +& pn_b(k), en(k), en_b(k), ac_cp& +& (k), ac_cp_b(k), ac_ct(k), & +& ac_ct_b(k), ac_kexc(k), & +& ac_kexc_b(k), ac_hp(k), & +& ac_hp_b(k), ac_ht(k), ac_ht_b(& +& k), ac_qt(k), ac_qt_b(k), l) + ac_qt_b(k) = 0.0_4 + END IF + END DO + END DO +!$OMP END PARALLEL + DO col=mesh%ncol,1,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL2B(branch) + IF (branch .NE. 0) THEN + IF (branch .EQ. 1) THEN + k = mesh%rowcol_to_ind_ac(row, col) + output_layer_b(:, k) = 0.0_4 + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL FORWARD_MLP_B(weight_1, weight_1_b, bias_1, bias_1_b, & +& weight_2, weight_2_b, bias_2, bias_2_b, & +& weight_3, weight_3_b, bias_3, bias_3_b, & +& input_layer, input_layer_b, output_layer(:, k)& +& , output_layer_b(:, k)) + output_layer_b(:, k) = 0.0_4 + CALL POPREAL4ARRAY(input_layer, setup%neurons(1)) + ac_hp_b(k) = ac_hp_b(k) + input_layer_b(1) + ac_ht_b(k) = ac_ht_b(k) + input_layer_b(2) + pn_b(k) = pn_b(k) + input_layer_b(3) + en_b(k) = en_b(k) + input_layer_b(4) + END IF + END IF + END DO + END DO + ac_prcp_b = 0.0_4 +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & +!$OMP&ac_pet, ac_ci, ac_hi, pn, en), SHARED(ac_prcp_b, ac_ci_b, ac_hi_b& +!$OMP&, pn_b, en_b), PRIVATE(row, col, k), PRIVATE(branch, chunk_end, & +!$OMP&chunk_start) + en_b = 0.0_4 + pn_b = 0.0_4 + CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) + DO col=chunk_end,chunk_start,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL2B(branch) + IF (branch .NE. 0) THEN + IF (branch .EQ. 1) THEN + k = mesh%rowcol_to_ind_ac(row, col) + en_b(k) = 0.0_4 + pn_b(k) = 0.0_4 + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + CALL POPREAL4(ac_hi(k)) + CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & +& ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& +& , pn(k), pn_b(k), en(k), en_b(k)) + pn_b(k) = 0.0_4 + en_b(k) = 0.0_4 + END IF + END IF + END DO + END DO +!$OMP END PARALLEL + ac_mlt_b = ac_mlt_b + ac_prcp_b + END SUBROUTINE GR4_ODE_MLP_TIME_STEP_B + + SUBROUTINE GR4_ODE_MLP_TIME_STEP(setup, mesh, input_data, options, & +& returns, time_step, weight_1, bias_1, weight_2, bias_2, weight_3, & +& bias_3, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, & +& ac_qt) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(setup%neurons(2), setup%neurons(1)), INTENT(IN) & +& :: weight_1 + REAL(sp), DIMENSION(setup%neurons(2)), INTENT(IN) :: bias_1 + REAL(sp), DIMENSION(setup%neurons(3), setup%neurons(2)), INTENT(IN) & +& :: weight_2 + REAL(sp), DIMENSION(setup%neurons(3)), INTENT(IN) :: bias_2 + REAL(sp), DIMENSION(setup%neurons(4), setup%neurons(3)), INTENT(IN) & +& :: weight_3 + REAL(sp), DIMENSION(setup%neurons(4)), INTENT(IN) :: bias_3 + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer + REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & +& output_layer + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: l + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp = ac_prcp + ac_mlt +! Interception with OPENMP +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & +!$OMP&ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), SCHEDULE(& +!$OMP& static) + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn(k), en(k)) + ELSE + pn(k) = 0._sp + en(k) = 0._sp + END IF + END IF + END DO + END DO +! Forward MLP without OPENMP + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) + CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & +& weight_3, bias_3, input_layer, output_layer(:, k)& +& ) + ELSE + output_layer(:, k) = 0._sp + END IF + END IF + END DO + END DO +! Production and transfer with OPENMP +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, output_layer, ac_cp, ac_ct, ac_kexc, ac_hp, ac_ht, ac_qt& +!$OMP&, pn, en), PRIVATE(row, col, k, time_step_returns, l), SCHEDULE(& +!$OMP& static) + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + CALL GR_PRODUCTION_TRANSFER_ODE_MLP(output_layer(:, k), pn(k)& +& , en(k), ac_cp(k), ac_ct(k), & +& ac_kexc(k), ac_hp(k), ac_ht(k), & +& ac_qt(k), l) +! Transform from mm/dt to m3/s + ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col& +& )/setup%dt + END IF + END DO + END DO + END SUBROUTINE GR4_ODE_MLP_TIME_STEP + +! Differentiation of gr5_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): +! variations of useful results: ac_qt ac_hi ac_hp ac_ht +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt ac_aexc + SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & +& time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & +& ac_ct_d, ac_kexc, ac_kexc_d, ac_aexc, ac_aexc_d, ac_hi, ac_hi_d, & +& ac_hp, ac_hp_d, ac_ht, ac_ht_d, ac_qt, ac_qt_d) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc, ac_aexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & +& ac_ct_d, ac_kexc_d, ac_aexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & +& ac_ht_d + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_d + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d + INTRINSIC MAX + REAL(sp) :: temp + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp_d = ac_mlt_d + ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & +!$OMP&ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), SHARED(ac_prcp_d, ac_ci_d, & +!$OMP&ac_cp_d, ac_ct_d, ac_kexc_d, ac_aexc_d, ac_hi_d, ac_hp_d, ac_ht_d& +!$OMP&, ac_qt_d), PRIVATE(row, col, k, time_step_returns, pn, en, pr, & +!$OMP&perc, l, prr, prd, qr, qd), PRIVATE(pn_d, en_d, pr_d, perc_d, l_d& +!$OMP&, prr_d, prd_d, qr_d, qd_d), PRIVATE(temp), SCHEDULE(static) + DO col=1,mesh%ncol + DO row=1,mesh%nrow + IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0)) THEN + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL GR_INTERCEPTION_D(ac_prcp(k), ac_prcp_d(k), ac_pet(k), & +& ac_ci(k), ac_ci_d(k), ac_hi(k), ac_hi_d(k)& +& , pn, pn_d, en, en_d) + CALL GR_PRODUCTION_D(0._sp, 0.0_4, 0._sp, 0.0_4, pn, pn_d, & +& en, en_d, ac_cp(k), ac_cp_d(k), beta, ac_hp(k& +& ), ac_hp_d(k), pr, pr_d, perc, perc_d) + CALL GR_THRESHOLD_EXCHANGE_D(ac_kexc(k), ac_kexc_d(k), & +& ac_aexc(k), ac_aexc_d(k), ac_ht(k), & +& ac_ht_d(k), l, l_d) + ELSE + pr = 0._sp + perc = 0._sp + l = 0._sp + l_d = 0.0_4 + perc_d = 0.0_4 + pr_d = 0.0_4 + END IF + prr_d = 0.9_sp*(pr_d+perc_d) + l_d + prr = 0.9_sp*(pr+perc) + l + prd_d = 0.1_sp*(pr_d+perc_d) + prd = 0.1_sp*(pr+perc) + CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & +& ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) + IF (0._sp .LT. prd + l) THEN + qd_d = prd_d + l_d + qd = prd + l + ELSE + qd = 0._sp + qd_d = 0.0_4 + END IF + ac_qt_d(k) = qr_d + qd_d + ac_qt(k) = qr + qd +! Transform from mm/dt to m3/s + temp = 1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col) + ac_qt_d(k) = temp*ac_qt_d(k)/setup%dt + ac_qt(k) = temp*(ac_qt(k)/setup%dt) + END IF + END DO + END DO + END SUBROUTINE GR5_TIME_STEP_D + +! Differentiation of gr5_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt ac_aexc +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt +! ac_hi ac_hp ac_ht ac_mlt ac_aexc + SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & +& time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & +& ac_ct_b, ac_kexc, ac_kexc_b, ac_aexc, ac_aexc_b, ac_hi, ac_hi_b, & +& ac_hp, ac_hp_b, ac_ht, ac_ht_b, ac_qt, ac_qt_b) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt + REAL(sp), DIMENSION(mesh%nac) :: ac_mlt_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & +& ac_kexc, ac_aexc + REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & +& ac_kexc_b, ac_aexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & +& ac_ht_b + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt + REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt_b + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b + INTEGER :: row, col, k, time_step_returns + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b + INTRINSIC MAX + REAL(sp) :: dummydiff_b + REAL(sp) :: dummydiff_b0 + INTEGER :: branch + INTEGER :: chunk_start + INTEGER :: chunk_end + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'prcp', ac_prcp) + CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& +& , 'pet', ac_pet) + ac_prcp = ac_prcp + ac_mlt +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & +!$OMP&ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), PRIVATE(row, col, k, & +!$OMP&time_step_returns, pn, en, pr, perc, l, prr, prd, qr, qd), PRIVATE& +!$OMP&(chunk_start, chunk_end) + CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) + DO col=chunk_start,chunk_end + DO row=1,mesh%nrow + IF (mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& +& local_active_cell(row, col) .EQ. 0) THEN + CALL PUSHCONTROL1B(0) + ELSE + k = mesh%rowcol_to_ind_ac(row, col) + IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN + CALL PUSHREAL4(en) + CALL PUSHREAL4(pn) + CALL PUSHREAL4(ac_hi(k)) + CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& +& k), pn, en) + CALL PUSHREAL4(ac_hp(k)) + CALL GR_PRODUCTION(0._sp, 0._sp, pn, en, ac_cp(k), beta, & +& ac_hp(k), pr, perc) + CALL GR_THRESHOLD_EXCHANGE(ac_kexc(k), ac_aexc(k), ac_ht(k)& +& , l) + CALL PUSHCONTROL1B(1) + ELSE + CALL PUSHCONTROL1B(0) + pr = 0._sp + perc = 0._sp + l = 0._sp + END IF + CALL PUSHREAL4(prr) + prr = 0.9_sp*(pr+perc) + l + prd = 0.1_sp*(pr+perc) + CALL PUSHREAL4(ac_ht(k)) + CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & +& qr) + IF (0._sp .LT. prd + l) THEN + CALL PUSHCONTROL1B(0) + ELSE + CALL PUSHCONTROL1B(1) + END IF + CALL PUSHCONTROL1B(1) + END IF + END DO + END DO + CALL PUSHREAL4(pn) + CALL PUSHREAL4(prr) + CALL PUSHREAL4(en) +!$OMP END PARALLEL + ac_prcp_b = 0.0_4 +!$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & +!$OMP&ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), SHARED(ac_prcp_b, ac_ci_b, & +!$OMP&ac_cp_b, ac_ct_b, ac_kexc_b, ac_aexc_b, ac_hi_b, ac_hp_b, ac_ht_b& +!$OMP&, ac_qt_b), PRIVATE(row, col, k, time_step_returns, pn, en, pr, & +!$OMP&perc, l, prr, prd, qr, qd), PRIVATE(pn_b, en_b, pr_b, perc_b, l_b& +!$OMP&, prr_b, prd_b, qr_b, qd_b), PRIVATE(branch, chunk_end, & +!$OMP&chunk_start) + CALL POPREAL4(en) + CALL POPREAL4(prr) + CALL POPREAL4(pn) + pn_b = 0.0_4 + en_b = 0.0_4 + pr_b = 0.0_4 + perc_b = 0.0_4 + l_b = 0.0_4 + prr_b = 0.0_4 + prd_b = 0.0_4 + qr_b = 0.0_4 + qd_b = 0.0_4 + CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) + DO col=chunk_end,chunk_start,-1 + DO row=mesh%nrow,1,-1 + CALL POPCONTROL1B(branch) + IF (branch .NE. 0) THEN + k = mesh%rowcol_to_ind_ac(row, col) + ac_qt_b(k) = mesh%dx(row, col)*1e-3_sp*mesh%dy(row, col)*& +& ac_qt_b(k)/setup%dt + qr_b = ac_qt_b(k) + qd_b = ac_qt_b(k) + ac_qt_b(k) = 0.0_4 + CALL POPCONTROL1B(branch) + IF (branch .EQ. 0) THEN + prd_b = qd_b + l_b = qd_b + ELSE + l_b = 0.0_4 + prd_b = 0.0_4 + END IF + CALL POPREAL4(ac_ht(k)) + CALL GR_TRANSFER_B(5._sp, ac_prcp(k), prr, prr_b, ac_ct(k), & +& ac_ct_b(k), ac_ht(k), ac_ht_b(k), qr, qr_b) + pr_b = 0.1_sp*prd_b + 0.9_sp*prr_b + perc_b = 0.1_sp*prd_b + 0.9_sp*prr_b + CALL POPREAL4(prr) + l_b = l_b + prr_b + CALL POPCONTROL1B(branch) + IF (branch .NE. 0) THEN + CALL GR_THRESHOLD_EXCHANGE_B(ac_kexc(k), ac_kexc_b(k), & +& ac_aexc(k), ac_aexc_b(k), ac_ht(k), & +& ac_ht_b(k), l, l_b) + CALL POPREAL4(ac_hp(k)) + pn_b = 0.0_4 + en_b = 0.0_4 + CALL GR_PRODUCTION_B(0._sp, dummydiff_b, 0._sp, dummydiff_b0& +& , pn, pn_b, en, en_b, ac_cp(k), ac_cp_b(k), & +& beta, ac_hp(k), ac_hp_b(k), pr, pr_b, perc, & +& perc_b) + CALL POPREAL4(ac_hi(k)) + CALL POPREAL4(pn) + CALL POPREAL4(en) + CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & +& ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& +& , pn, pn_b, en, en_b) + END IF + END IF + END DO + END DO +!$OMP END PARALLEL + ac_mlt_b = ac_mlt_b + ac_prcp_b + END SUBROUTINE GR5_TIME_STEP_B + + SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & +& time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_aexc, ac_hi, & +& ac_hp, ac_ht, ac_qt) + IMPLICIT NONE + TYPE(SETUPDT), INTENT(IN) :: setup + TYPE(MESHDT), INTENT(IN) :: mesh + TYPE(INPUT_DATADT), INTENT(IN) :: input_data + TYPE(OPTIONSDT), INTENT(IN) :: options + TYPE(RETURNSDT), INTENT(INOUT) :: returns + INTEGER, INTENT(IN) :: time_step REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & -& ac_kexc +& ac_kexc, ac_aexc REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt - REAL(sp), DIMENSION(setup%neurons(1)) :: input_layer - REAL(sp), DIMENSION(setup%neurons(setup%n_layers+1), mesh%nac) :: & -& output_layer - REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet, pn, en + REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet INTEGER :: row, col, k, time_step_returns - REAL(sp) :: l + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd + INTRINSIC MAX CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'pet', ac_pet) ac_prcp = ac_prcp + ac_mlt -! Interception with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(mesh, ac_prcp, & -!$OMP&ac_pet, ac_ci, ac_hi, pn, en), PRIVATE(row, col, k), SCHEDULE(& -!$OMP& static) +! Beta percolation parameter is time step dependent + beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp +!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & +!$OMP&ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), PRIVATE(row, col, k, & +!$OMP&time_step_returns, pn, en, pr, perc, l, prr, prd, qr, qd), SCHEDULE& +!$OMP& (static) DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -16203,61 +17182,43 @@ SUBROUTINE GR4_ODE_MLP_TIME_STEP(setup, mesh, input_data, options, & k = mesh%rowcol_to_ind_ac(row, col) IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& -& k), pn(k), en(k)) +& k), pn, en) + CALL GR_PRODUCTION(0._sp, 0._sp, pn, en, ac_cp(k), beta, & +& ac_hp(k), pr, perc) + CALL GR_THRESHOLD_EXCHANGE(ac_kexc(k), ac_aexc(k), ac_ht(k)& +& , l) ELSE - pn(k) = 0._sp - en(k) = 0._sp + pr = 0._sp + perc = 0._sp + l = 0._sp END IF - END IF - END DO - END DO -! Forward MLP without OPENMP - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN - input_layer(:) = (/ac_hp(k), ac_ht(k), pn(k), en(k)/) - CALL FORWARD_MLP(weight_1, bias_1, weight_2, bias_2, & -& weight_3, bias_3, input_layer, output_layer(:, k)& -& ) + prr = 0.9_sp*(pr+perc) + l + prd = 0.1_sp*(pr+perc) + CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & +& qr) + IF (0._sp .LT. prd + l) THEN + qd = prd + l ELSE - output_layer(:, k) = 0._sp + qd = 0._sp END IF - END IF - END DO - END DO -! Production and transfer with OPENMP -!$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, output_layer, ac_cp, ac_ct, ac_kexc, ac_hp, ac_ht, ac_qt& -!$OMP&, pn, en), PRIVATE(row, col, k, time_step_returns, l), SCHEDULE(& -!$OMP& static) - DO col=1,mesh%ncol - DO row=1,mesh%nrow - IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& -& local_active_cell(row, col) .EQ. 0)) THEN - k = mesh%rowcol_to_ind_ac(row, col) - CALL GR_PRODUCTION_TRANSFER_ODE_MLP(output_layer(:, k), pn(k)& -& , en(k), ac_cp(k), ac_ct(k), & -& ac_kexc(k), ac_hp(k), ac_ht(k), & -& ac_qt(k), l) + ac_qt(k) = qr + qd ! Transform from mm/dt to m3/s ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col& & )/setup%dt END IF END DO END DO - END SUBROUTINE GR4_ODE_MLP_TIME_STEP + END SUBROUTINE GR5_TIME_STEP -! Differentiation of gr5_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): +! Differentiation of gr5_ri_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): ! variations of useful results: ac_qt ac_hi ac_hp ac_ht -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt ac_aexc - SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & -& time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d, ac_ct, & -& ac_ct_d, ac_kexc, ac_kexc_d, ac_aexc, ac_aexc_d, ac_hi, ac_hi_d, & -& ac_hp, ac_hp_d, ac_ht, ac_ht_d, ac_qt, ac_qt_d) +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt ac_aexc + SUBROUTINE GR5_RI_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_d, ac_ci, ac_ci_d, ac_cp, ac_cp_d& +& , ac_ct, ac_ct_d, ac_alpha1, ac_alpha1_d, ac_alpha2, ac_alpha2_d, & +& ac_kexc, ac_kexc_d, ac_aexc, ac_aexc_d, ac_hi, ac_hi_d, ac_hp, & +& ac_hp_d, ac_ht, ac_ht_d, ac_qt, ac_qt_d) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -16271,6 +17232,9 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & & ac_kexc, ac_aexc REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci_d, ac_cp_d, & & ac_ct_d, ac_kexc_d, ac_aexc_d + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1_d, & +& ac_alpha2_d REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_d, ac_hp_d, & & ac_ht_d @@ -16279,8 +17243,10 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_d INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd - REAL(sp) :: pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + REAL(sp) :: pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d, qr_d, qd_d& +& , split_d + INTRINSIC TANH INTRINSIC MAX REAL(sp) :: temp CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& @@ -16291,13 +17257,15 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & ac_prcp = ac_prcp + ac_mlt ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp + pn_d = 0.0_4 !$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & -!$OMP&ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), SHARED(ac_prcp_d, ac_ci_d, & -!$OMP&ac_cp_d, ac_ct_d, ac_kexc_d, ac_aexc_d, ac_hi_d, ac_hp_d, ac_ht_d& -!$OMP&, ac_qt_d), PRIVATE(row, col, k, time_step_returns, pn, en, pr, & -!$OMP&perc, l, prr, prd, qr, qd), PRIVATE(pn_d, en_d, pr_d, perc_d, l_d& -!$OMP&, prr_d, prd_d, qr_d, qd_d), PRIVATE(temp), SCHEDULE(static) +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_alpha1, ac_alpha2& +!$OMP&, ac_ct, ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), SHARED(& +!$OMP&ac_prcp_d, ac_ci_d, ac_cp_d, ac_alpha1_d, ac_alpha2_d, ac_ct_d, & +!$OMP&ac_kexc_d, ac_aexc_d, ac_hi_d, ac_hp_d, ac_ht_d, ac_qt_d), PRIVATE& +!$OMP&(row, col, k, time_step_returns, pn, en, pr, perc, l, prr, prd, qr& +!$OMP&, qd, split), PRIVATE(pn_d, en_d, pr_d, perc_d, l_d, prr_d, prd_d& +!$OMP&, qr_d, qd_d, split_d), PRIVATE(temp), SCHEDULE(static) DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -16307,9 +17275,10 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & CALL GR_INTERCEPTION_D(ac_prcp(k), ac_prcp_d(k), ac_pet(k), & & ac_ci(k), ac_ci_d(k), ac_hi(k), ac_hi_d(k)& & , pn, pn_d, en, en_d) - CALL GR_PRODUCTION_D(0._sp, 0.0_4, 0._sp, 0.0_4, pn, pn_d, & -& en, en_d, ac_cp(k), ac_cp_d(k), beta, ac_hp(k& -& ), ac_hp_d(k), pr, pr_d, perc, perc_d) + CALL GR_RI_PRODUCTION_D(pn, pn_d, en, en_d, ac_cp(k), & +& ac_cp_d(k), beta, ac_alpha1(k), & +& ac_alpha1_d(k), ac_hp(k), ac_hp_d(k), pr, & +& pr_d, perc, perc_d, setup%dt) CALL GR_THRESHOLD_EXCHANGE_D(ac_kexc(k), ac_kexc_d(k), & & ac_aexc(k), ac_aexc_d(k), ac_ht(k), & & ac_ht_d(k), l, l_d) @@ -16321,10 +17290,13 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & perc_d = 0.0_4 pr_d = 0.0_4 END IF - prr_d = 0.9_sp*(pr_d+perc_d) + l_d - prr = 0.9_sp*(pr+perc) + l - prd_d = 0.1_sp*(pr_d+perc_d) - prd = 0.1_sp*(pr+perc) + split_d = 0.9_sp*2*TANH(ac_alpha2(k)*pn)*(1.0-TANH(ac_alpha2(k& +& )*pn)**2)*(pn*ac_alpha2_d(k)+ac_alpha2(k)*pn_d) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp + prr_d = (1._sp-split)*(pr_d+perc_d) - (pr+perc)*split_d + l_d + prr = (1._sp-split)*(pr+perc) + l + prd_d = (pr+perc)*split_d + split*(pr_d+perc_d) + prd = split*(pr+perc) CALL GR_TRANSFER_D(5._sp, ac_prcp(k), prr, prr_d, ac_ct(k), & & ac_ct_d(k), ac_ht(k), ac_ht_d(k), qr, qr_d) IF (0._sp .LT. prd + l) THEN @@ -16343,17 +17315,18 @@ SUBROUTINE GR5_TIME_STEP_D(setup, mesh, input_data, options, returns, & END IF END DO END DO - END SUBROUTINE GR5_TIME_STEP_D + END SUBROUTINE GR5_RI_TIME_STEP_D -! Differentiation of gr5_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): -! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt ac_aexc -! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_qt -! ac_hi ac_hp ac_ht ac_mlt ac_aexc - SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & -& time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b, ac_ct, & -& ac_ct_b, ac_kexc, ac_kexc_b, ac_aexc, ac_aexc_b, ac_hi, ac_hi_b, & -& ac_hp, ac_hp_b, ac_ht, ac_ht_b, ac_qt, ac_qt_b) +! Differentiation of gr5_ri_time_step in reverse (adjoint) mode (with options fixinterface noISIZE context OpenMP): +! gradient of useful results: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt ac_aexc +! with respect to varying inputs: ac_kexc ac_ci ac_cp ac_ct ac_alpha1 +! ac_alpha2 ac_qt ac_hi ac_hp ac_ht ac_mlt ac_aexc + SUBROUTINE GR5_RI_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, time_step, ac_mlt, ac_mlt_b, ac_ci, ac_ci_b, ac_cp, ac_cp_b& +& , ac_ct, ac_ct_b, ac_alpha1, ac_alpha1_b, ac_alpha2, ac_alpha2_b, & +& ac_kexc, ac_kexc_b, ac_aexc, ac_aexc_b, ac_hi, ac_hi_b, ac_hp, & +& ac_hp_b, ac_ht, ac_ht_b, ac_qt, ac_qt_b) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -16367,6 +17340,8 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & & ac_kexc, ac_aexc REAL(sp), DIMENSION(mesh%nac) :: ac_ci_b, ac_cp_b, ac_ct_b, & & ac_kexc_b, ac_aexc_b + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 + REAL(sp), DIMENSION(mesh%nac) :: ac_alpha1_b, ac_alpha2_b REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi_b, ac_hp_b, & & ac_ht_b @@ -16375,11 +17350,12 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet REAL(sp), DIMENSION(mesh%nac) :: ac_prcp_b INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd - REAL(sp) :: pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + REAL(sp) :: pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b, qr_b, qd_b& +& , split_b + INTRINSIC TANH INTRINSIC MAX - REAL(sp) :: dummydiff_b - REAL(sp) :: dummydiff_b0 + REAL(sp) :: temp_b INTEGER :: branch INTEGER :: chunk_start INTEGER :: chunk_end @@ -16391,10 +17367,10 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp !$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & -!$OMP&ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), PRIVATE(row, col, k, & -!$OMP&time_step_returns, pn, en, pr, perc, l, prr, prd, qr, qd), PRIVATE& -!$OMP&(chunk_start, chunk_end) +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_alpha1, ac_alpha2& +!$OMP&, ac_ct, ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), PRIVATE(& +!$OMP&row, col, k, time_step_returns, pn, en, pr, perc, l, prr, prd, qr& +!$OMP&, qd, split), PRIVATE(chunk_start, chunk_end) CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) DO col=chunk_start,chunk_end DO row=1,mesh%nrow @@ -16409,21 +17385,27 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & CALL PUSHREAL4(ac_hi(k)) CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& & k), pn, en) + CALL PUSHREAL4(perc) + CALL PUSHREAL4(pr) CALL PUSHREAL4(ac_hp(k)) - CALL GR_PRODUCTION(0._sp, 0._sp, pn, en, ac_cp(k), beta, & -& ac_hp(k), pr, perc) + CALL GR_RI_PRODUCTION(pn, en, ac_cp(k), beta, ac_alpha1(k), & +& ac_hp(k), pr, perc, setup%dt) CALL GR_THRESHOLD_EXCHANGE(ac_kexc(k), ac_aexc(k), ac_ht(k)& & , l) CALL PUSHCONTROL1B(1) ELSE - CALL PUSHCONTROL1B(0) + CALL PUSHREAL4(pr) pr = 0._sp + CALL PUSHREAL4(perc) perc = 0._sp l = 0._sp + CALL PUSHCONTROL1B(0) END IF + CALL PUSHREAL4(split) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp CALL PUSHREAL4(prr) - prr = 0.9_sp*(pr+perc) + l - prd = 0.1_sp*(pr+perc) + prr = (1._sp-split)*(pr+perc) + l + prd = split*(pr+perc) CALL PUSHREAL4(ac_ht(k)) CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & & qr) @@ -16436,22 +17418,30 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & END IF END DO END DO + CALL PUSHREAL4(pr) + CALL PUSHREAL4(perc) CALL PUSHREAL4(pn) CALL PUSHREAL4(prr) + CALL PUSHREAL4(split) CALL PUSHREAL4(en) !$OMP END PARALLEL ac_prcp_b = 0.0_4 + pn_b = 0.0_4 !$OMP PARALLEL NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & -!$OMP&ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), SHARED(ac_prcp_b, ac_ci_b, & -!$OMP&ac_cp_b, ac_ct_b, ac_kexc_b, ac_aexc_b, ac_hi_b, ac_hp_b, ac_ht_b& -!$OMP&, ac_qt_b), PRIVATE(row, col, k, time_step_returns, pn, en, pr, & -!$OMP&perc, l, prr, prd, qr, qd), PRIVATE(pn_b, en_b, pr_b, perc_b, l_b& -!$OMP&, prr_b, prd_b, qr_b, qd_b), PRIVATE(branch, chunk_end, & -!$OMP&chunk_start) +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_alpha1, ac_alpha2& +!$OMP&, ac_ct, ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), SHARED(& +!$OMP&ac_prcp_b, ac_ci_b, ac_cp_b, ac_alpha1_b, ac_alpha2_b, ac_ct_b, & +!$OMP&ac_kexc_b, ac_aexc_b, ac_hi_b, ac_hp_b, ac_ht_b, ac_qt_b), PRIVATE& +!$OMP&(row, col, k, time_step_returns, pn, en, pr, perc, l, prr, prd, qr& +!$OMP&, qd, split), PRIVATE(pn_b, en_b, pr_b, perc_b, l_b, prr_b, prd_b& +!$OMP&, qr_b, qd_b, split_b), PRIVATE(branch, chunk_end, chunk_start), & +!$OMP&PRIVATE(temp_b) CALL POPREAL4(en) + CALL POPREAL4(split) CALL POPREAL4(prr) CALL POPREAL4(pn) + CALL POPREAL4(perc) + CALL POPREAL4(pr) pn_b = 0.0_4 en_b = 0.0_4 pr_b = 0.0_4 @@ -16461,6 +17451,8 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & prd_b = 0.0_4 qr_b = 0.0_4 qd_b = 0.0_4 + split_b = 0.0_4 + pn_b = 0.0_4 CALL GETSTATICSCHEDULE(1, mesh%ncol, 1, chunk_start, chunk_end) DO col=chunk_end,chunk_start,-1 DO row=mesh%nrow,1,-1 @@ -16483,39 +17475,50 @@ SUBROUTINE GR5_TIME_STEP_B(setup, mesh, input_data, options, returns, & CALL POPREAL4(ac_ht(k)) CALL GR_TRANSFER_B(5._sp, ac_prcp(k), prr, prr_b, ac_ct(k), & & ac_ct_b(k), ac_ht(k), ac_ht_b(k), qr, qr_b) - pr_b = 0.1_sp*prd_b + 0.9_sp*prr_b - perc_b = 0.1_sp*prd_b + 0.9_sp*prr_b + split_b = (pr+perc)*prd_b - (pr+perc)*prr_b + pr_b = split*prd_b + (1._sp-split)*prr_b + perc_b = split*prd_b + (1._sp-split)*prr_b CALL POPREAL4(prr) l_b = l_b + prr_b + CALL POPREAL4(split) + temp_b = (1.0-TANH(ac_alpha2(k)*pn)**2)*2*TANH(ac_alpha2(k)*pn& +& )*0.9_sp*split_b +!$OMP ATOMIC update + ac_alpha2_b(k) = ac_alpha2_b(k) + pn*temp_b + pn_b = pn_b + ac_alpha2(k)*temp_b CALL POPCONTROL1B(branch) - IF (branch .NE. 0) THEN + IF (branch .EQ. 0) THEN + CALL POPREAL4(perc) + CALL POPREAL4(pr) + ELSE CALL GR_THRESHOLD_EXCHANGE_B(ac_kexc(k), ac_kexc_b(k), & & ac_aexc(k), ac_aexc_b(k), ac_ht(k), & & ac_ht_b(k), l, l_b) CALL POPREAL4(ac_hp(k)) - pn_b = 0.0_4 - en_b = 0.0_4 - CALL GR_PRODUCTION_B(0._sp, dummydiff_b, 0._sp, dummydiff_b0& -& , pn, pn_b, en, en_b, ac_cp(k), ac_cp_b(k), & -& beta, ac_hp(k), ac_hp_b(k), pr, pr_b, perc, & -& perc_b) + CALL POPREAL4(pr) + CALL POPREAL4(perc) + CALL GR_RI_PRODUCTION_B(pn, pn_b, en, en_b, ac_cp(k), & +& ac_cp_b(k), beta, ac_alpha1(k), & +& ac_alpha1_b(k), ac_hp(k), ac_hp_b(k), pr, & +& pr_b, perc, perc_b, setup%dt) CALL POPREAL4(ac_hi(k)) CALL POPREAL4(pn) CALL POPREAL4(en) CALL GR_INTERCEPTION_B(ac_prcp(k), ac_prcp_b(k), ac_pet(k), & & ac_ci(k), ac_ci_b(k), ac_hi(k), ac_hi_b(k)& & , pn, pn_b, en, en_b) + pn_b = 0.0_4 END IF END IF END DO END DO !$OMP END PARALLEL ac_mlt_b = ac_mlt_b + ac_prcp_b - END SUBROUTINE GR5_TIME_STEP_B + END SUBROUTINE GR5_RI_TIME_STEP_B - SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & -& time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_aexc, ac_hi, & -& ac_hp, ac_ht, ac_qt) + SUBROUTINE GR5_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , time_step, ac_mlt, ac_ci, ac_cp, ac_ct, ac_alpha1, ac_alpha2, & +& ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt) IMPLICIT NONE TYPE(SETUPDT), INTENT(IN) :: setup TYPE(MESHDT), INTENT(IN) :: mesh @@ -16526,11 +17529,13 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_mlt REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_ci, ac_cp, ac_ct, & & ac_kexc, ac_aexc + REAL(sp), DIMENSION(mesh%nac), INTENT(IN) :: ac_alpha1, ac_alpha2 REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_hi, ac_hp, ac_ht REAL(sp), DIMENSION(mesh%nac), INTENT(INOUT) :: ac_qt REAL(sp), DIMENSION(mesh%nac) :: ac_prcp, ac_pet INTEGER :: row, col, k, time_step_returns - REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd + REAL(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + INTRINSIC TANH INTRINSIC MAX CALL GET_AC_ATMOS_DATA_TIME_STEP(setup, mesh, input_data, time_step& & , 'prcp', ac_prcp) @@ -16540,10 +17545,10 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & ! Beta percolation parameter is time step dependent beta = 9._sp/4._sp*(86400._sp/setup%dt)**0.25_sp !$OMP PARALLEL DO NUM_THREADS(options%comm%ncpu), SHARED(setup, mesh, & -!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_ct, ac_kexc, & -!$OMP&ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), PRIVATE(row, col, k, & -!$OMP&time_step_returns, pn, en, pr, perc, l, prr, prd, qr, qd), SCHEDULE& -!$OMP& (static) +!$OMP&returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, ac_alpha1, ac_alpha2& +!$OMP&, ac_ct, ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt), PRIVATE(& +!$OMP&row, col, k, time_step_returns, pn, en, pr, perc, l, prr, prd, qr& +!$OMP&, qd, split), SCHEDULE(static) DO col=1,mesh%ncol DO row=1,mesh%nrow IF (.NOT.(mesh%active_cell(row, col) .EQ. 0 .OR. mesh%& @@ -16552,8 +17557,8 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & IF (ac_prcp(k) .GE. 0._sp .AND. ac_pet(k) .GE. 0._sp) THEN CALL GR_INTERCEPTION(ac_prcp(k), ac_pet(k), ac_ci(k), ac_hi(& & k), pn, en) - CALL GR_PRODUCTION(0._sp, 0._sp, pn, en, ac_cp(k), beta, & -& ac_hp(k), pr, perc) + CALL GR_RI_PRODUCTION(pn, en, ac_cp(k), beta, ac_alpha1(k), & +& ac_hp(k), pr, perc, setup%dt) CALL GR_THRESHOLD_EXCHANGE(ac_kexc(k), ac_aexc(k), ac_ht(k)& & , l) ELSE @@ -16561,8 +17566,9 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & perc = 0._sp l = 0._sp END IF - prr = 0.9_sp*(pr+perc) + l - prd = 0.1_sp*(pr+perc) + split = 0.9_sp*TANH(ac_alpha2(k)*pn)**2 + 0.1_sp + prr = (1._sp-split)*(pr+perc) + l + prd = split*(pr+perc) CALL GR_TRANSFER(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), & & qr) IF (0._sp .LT. prd + l) THEN @@ -16577,7 +17583,7 @@ SUBROUTINE GR5_TIME_STEP(setup, mesh, input_data, options, returns, & END IF END DO END DO - END SUBROUTINE GR5_TIME_STEP + END SUBROUTINE GR5_RI_TIME_STEP ! Differentiation of gr6_time_step in forward (tangent) mode (with options fixinterface noISIZE context OpenMP): ! variations of useful results: ac_qt ac_he ac_hi ac_hp ac_ht @@ -21362,6 +22368,59 @@ SUBROUTINE SIMULATION_CHECKPOINT_D(setup, mesh, input_data, parameters& checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 rr_parameters_inc = rr_parameters_inc + 4 rr_states_inc = rr_states_inc + 3 + CASE ('gr4_ri') +! 'gr4_ri' module +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+1) + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+2) + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % hi +! % hp +! % ht + CALL GR4_RI_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_d%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+5), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+6), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+6), h1, & +& h1_d, h2, h2_d, h3, h3_d, checkpoint_variable%& +& ac_qtz(:, setup%nqz), checkpoint_variable_d%& +& ac_qtz(:, setup%nqz)) + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+1) = h1_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+2) = h2_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) = h3_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + rr_parameters_inc = rr_parameters_inc + 6 + rr_states_inc = rr_states_inc + 3 CASE ('gr4_mlp') ! 'gr4_mlp' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -21571,7 +22630,63 @@ SUBROUTINE SIMULATION_CHECKPOINT_D(setup, mesh, input_data, parameters& checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) = h3_d checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 - rr_parameters_inc = rr_parameters_inc + 5 + rr_parameters_inc = rr_parameters_inc + 5 + rr_states_inc = rr_states_inc + 3 + CASE ('gr5_ri') +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+1) + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+2) + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3_d = checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % aexc +! % hi +! % hp +! % ht + CALL GR5_RI_TIME_STEP_D(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_d%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+5), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+6), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+6), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+7), checkpoint_variable_d%& +& ac_rr_parameters(:, rr_parameters_inc+7), h1, & +& h1_d, h2, h2_d, h3, h3_d, checkpoint_variable%& +& ac_qtz(:, setup%nqz), checkpoint_variable_d%& +& ac_qtz(:, setup%nqz)) + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+1) = h1_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+2) = h2_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable_d%ac_rr_states(:, rr_states_inc+3) = h3_d + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + rr_parameters_inc = rr_parameters_inc + 7 rr_states_inc = rr_states_inc + 3 CASE ('gr6') ! 'gr6' module @@ -21997,6 +23112,49 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 CALL PUSHCONTROL4B(1) + CASE ('gr4_ri') +! 'gr4_ri' module +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % hi +! % hp +! % ht + CALL PUSHREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & +& SIZE(checkpoint_variable%ac_qtz, 1)) + CALL PUSHREAL4ARRAY(h3, mesh%nac) + CALL PUSHREAL4ARRAY(h2, mesh%nac) + CALL PUSHREAL4ARRAY(h1, mesh%nac) + CALL GR4_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+6), h1, h2& +& , h3, checkpoint_variable%ac_qtz(:, setup%nqz)) + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + CALL PUSHINTEGER4(rr_parameters_inc) + rr_parameters_inc = rr_parameters_inc + 6 + CALL PUSHINTEGER4(rr_states_inc) + rr_states_inc = rr_states_inc + 3 + CALL PUSHCONTROL4B(2) CASE ('gr4_mlp') ! 'gr4_mlp' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22039,7 +23197,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 4 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 - CALL PUSHCONTROL4B(2) + CALL PUSHCONTROL4B(3) CASE ('gr4_ode') ! 'gr4_ode' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22078,7 +23236,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 4 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 - CALL PUSHCONTROL4B(3) + CALL PUSHCONTROL4B(4) CASE ('gr4_ode_mlp') ! 'gr4_ode_mlp' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22122,7 +23280,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 4 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 - CALL PUSHCONTROL4B(4) + CALL PUSHCONTROL4B(5) CASE ('gr5') ! 'gr5' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22162,7 +23320,52 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 5 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 3 - CALL PUSHCONTROL4B(5) + CALL PUSHCONTROL4B(6) + CASE ('gr5_ri') +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % aexc +! % hi +! % hp +! % ht + CALL PUSHREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & +& SIZE(checkpoint_variable%ac_qtz, 1)) + CALL PUSHREAL4ARRAY(h3, mesh%nac) + CALL PUSHREAL4ARRAY(h2, mesh%nac) + CALL PUSHREAL4ARRAY(h1, mesh%nac) + CALL GR5_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+6), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+7), h1, h2, h3, & +& checkpoint_variable%ac_qtz(:, setup%nqz)) + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + CALL PUSHINTEGER4(rr_parameters_inc) + rr_parameters_inc = rr_parameters_inc + 7 + CALL PUSHINTEGER4(rr_states_inc) + rr_states_inc = rr_states_inc + 3 + CALL PUSHCONTROL4B(7) CASE ('gr6') ! 'gr6' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22210,7 +23413,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 6 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 4 - CALL PUSHCONTROL4B(6) + CALL PUSHCONTROL4B(8) CASE ('grc') ! 'grc' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22255,7 +23458,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 5 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 4 - CALL PUSHCONTROL4B(7) + CALL PUSHCONTROL4B(9) CASE ('grd') ! 'grd' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22283,7 +23486,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 2 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 2 - CALL PUSHCONTROL4B(8) + CALL PUSHCONTROL4B(10) CASE ('loieau') ! 'loieau' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22314,7 +23517,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 3 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 2 - CALL PUSHCONTROL4B(9) + CALL PUSHCONTROL4B(11) CASE ('vic3l') ! 'vic3l' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -22370,7 +23573,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& rr_parameters_inc = rr_parameters_inc + 9 CALL PUSHINTEGER4(rr_states_inc) rr_states_inc = rr_states_inc + 4 - CALL PUSHCONTROL4B(10) + CALL PUSHCONTROL4B(12) CASE DEFAULT CALL PUSHCONTROL4B(0) END SELECT @@ -22467,60 +23670,125 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& & ac_qz) END IF CALL POPCONTROL4B(branch) - IF (branch .LT. 5) THEN - IF (branch .LT. 2) THEN + IF (branch .LT. 6) THEN + IF (branch .LT. 3) THEN IF (branch .NE. 0) THEN - CALL POPINTEGER4(rr_states_inc) - CALL POPINTEGER4(rr_parameters_inc) - h3_b = 0.0_4 - h3_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3& -& ) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & -& 0.0_4 - h2_b = 0.0_4 - h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2& -& ) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & -& 0.0_4 - h1_b = 0.0_4 - h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1& -& ) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & -& 0.0_4 - CALL POPREAL4ARRAY(h1, mesh%nac) - CALL POPREAL4ARRAY(h2, mesh%nac) - CALL POPREAL4ARRAY(h3, mesh%nac) - CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz)& -& , SIZE(checkpoint_variable%ac_qtz, 1)) - CALL GR4_TIME_STEP_B(setup, mesh, input_data, options, & -& returns, t, checkpoint_variable%ac_mlt, & -& checkpoint_variable_b%ac_mlt, & -& checkpoint_variable%ac_rr_parameters(:, & -& rr_parameters_inc+1), checkpoint_variable_b%& -& ac_rr_parameters(:, rr_parameters_inc+1), & -& checkpoint_variable%ac_rr_parameters(:, & -& rr_parameters_inc+2), checkpoint_variable_b%& -& ac_rr_parameters(:, rr_parameters_inc+2), & -& checkpoint_variable%ac_rr_parameters(:, & -& rr_parameters_inc+3), checkpoint_variable_b%& -& ac_rr_parameters(:, rr_parameters_inc+3), & -& checkpoint_variable%ac_rr_parameters(:, & -& rr_parameters_inc+4), checkpoint_variable_b%& -& ac_rr_parameters(:, rr_parameters_inc+4), h1& -& , h1_b, h2, h2_b, h3, h3_b, & -& checkpoint_variable%ac_qtz(:, setup%nqz), & -& checkpoint_variable_b%ac_qtz(:, setup%nqz)) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) + & -& h3_b - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + & -& h2_b - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & -& h1_b + IF (branch .EQ. 1) THEN + CALL POPINTEGER4(rr_states_inc) + CALL POPINTEGER4(rr_parameters_inc) + h3_b = 0.0_4 + h3_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +3) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& 0.0_4 + h2_b = 0.0_4 + h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +2) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& 0.0_4 + h1_b = 0.0_4 + h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +1) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& 0.0_4 + CALL POPREAL4ARRAY(h1, mesh%nac) + CALL POPREAL4ARRAY(h2, mesh%nac) + CALL POPREAL4ARRAY(h3, mesh%nac) + CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz& +& ), SIZE(checkpoint_variable%ac_qtz, 1)) + CALL GR4_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_b%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_b& +& %ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_b& +& %ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable_b& +& %ac_rr_parameters(:, rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), checkpoint_variable_b& +& %ac_rr_parameters(:, rr_parameters_inc+4), & +& h1, h1_b, h2, h2_b, h3, h3_b, & +& checkpoint_variable%ac_qtz(:, setup%nqz), & +& checkpoint_variable_b%ac_qtz(:, setup%nqz)) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) +& +& h3_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) +& +& h2_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) +& +& h1_b + ELSE + CALL POPINTEGER4(rr_states_inc) + CALL POPINTEGER4(rr_parameters_inc) + h3_b = 0.0_4 + h3_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +3) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& 0.0_4 + h2_b = 0.0_4 + h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +2) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& 0.0_4 + h1_b = 0.0_4 + h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc& +& +1) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& 0.0_4 + CALL POPREAL4ARRAY(h1, mesh%nac) + CALL POPREAL4ARRAY(h2, mesh%nac) + CALL POPREAL4ARRAY(h3, mesh%nac) + CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz& +& ), SIZE(checkpoint_variable%ac_qtz, 1)) + CALL GR4_RI_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_b%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+5), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+6), & +& checkpoint_variable_b%ac_rr_parameters(:& +& , rr_parameters_inc+6), h1, h1_b, h2, & +& h2_b, h3, h3_b, checkpoint_variable%& +& ac_qtz(:, setup%nqz), & +& checkpoint_variable_b%ac_qtz(:, setup%& +& nqz)) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) +& +& h3_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) +& +& h2_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) +& +& h1_b + END IF END IF - ELSE IF (branch .EQ. 2) THEN + ELSE IF (branch .EQ. 3) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h3_b = 0.0_4 @@ -22576,7 +23844,7 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b - ELSE IF (branch .EQ. 3) THEN + ELSE IF (branch .EQ. 4) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h3_b = 0.0_4 @@ -22682,8 +23950,8 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b END IF - ELSE IF (branch .LT. 8) THEN - IF (branch .EQ. 5) THEN + ELSE IF (branch .LT. 9) THEN + IF (branch .EQ. 6) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h3_b = 0.0_4 @@ -22730,7 +23998,60 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b - ELSE IF (branch .EQ. 6) THEN + ELSE IF (branch .EQ. 7) THEN + CALL POPINTEGER4(rr_states_inc) + CALL POPINTEGER4(rr_parameters_inc) + h3_b = 0.0_4 + h3_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = 0.0_4 + h2_b = 0.0_4 + h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = 0.0_4 + h1_b = 0.0_4 + h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = 0.0_4 + CALL POPREAL4ARRAY(h1, mesh%nac) + CALL POPREAL4ARRAY(h2, mesh%nac) + CALL POPREAL4ARRAY(h3, mesh%nac) + CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & +& SIZE(checkpoint_variable%ac_qtz, 1)) + CALL GR5_RI_TIME_STEP_B(setup, mesh, input_data, options, & +& returns, t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_b%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+3), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+4), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+5), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+6), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+6), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+7), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+7), h1& +& , h1_b, h2, h2_b, h3, h3_b, & +& checkpoint_variable%ac_qtz(:, setup%nqz), & +& checkpoint_variable_b%ac_qtz(:, setup%nqz)) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+3) + & +& h3_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + & +& h2_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & +& h1_b + ELSE CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h4_b = 0.0_4 @@ -22787,7 +24108,9 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b - ELSE + END IF + ELSE IF (branch .LT. 11) THEN + IF (branch .EQ. 9) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h4_b = 0.0_4 @@ -22840,37 +24163,40 @@ SUBROUTINE SIMULATION_CHECKPOINT_B(setup, mesh, input_data, parameters& & h2_b checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & & checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & +& h1_b + ELSE + CALL POPINTEGER4(rr_states_inc) + CALL POPINTEGER4(rr_parameters_inc) + h2_b = 0.0_4 + h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = 0.0_4 + h1_b = 0.0_4 + h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = 0.0_4 + CALL POPREAL4ARRAY(h1, mesh%nac) + CALL POPREAL4ARRAY(h2, mesh%nac) + CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & +& SIZE(checkpoint_variable%ac_qtz, 1)) + CALL GRD_TIME_STEP_B(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable_b%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+1), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+2), checkpoint_variable_b%& +& ac_rr_parameters(:, rr_parameters_inc+2), h1, & +& h1_b, h2, h2_b, checkpoint_variable%ac_qtz(:, & +& setup%nqz), checkpoint_variable_b%ac_qtz(:, & +& setup%nqz)) + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + & +& h2_b + checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & +& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + & & h1_b END IF - ELSE IF (branch .EQ. 8) THEN - CALL POPINTEGER4(rr_states_inc) - CALL POPINTEGER4(rr_parameters_inc) - h2_b = 0.0_4 - h2_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = 0.0_4 - h1_b = 0.0_4 - h1_b = checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = 0.0_4 - CALL POPREAL4ARRAY(h1, mesh%nac) - CALL POPREAL4ARRAY(h2, mesh%nac) - CALL POPREAL4ARRAY(checkpoint_variable%ac_qtz(:, setup%nqz), & -& SIZE(checkpoint_variable%ac_qtz, 1)) - CALL GRD_TIME_STEP_B(setup, mesh, input_data, options, returns, & -& t, checkpoint_variable%ac_mlt, & -& checkpoint_variable_b%ac_mlt, checkpoint_variable& -& %ac_rr_parameters(:, rr_parameters_inc+1), & -& checkpoint_variable_b%ac_rr_parameters(:, & -& rr_parameters_inc+1), checkpoint_variable%& -& ac_rr_parameters(:, rr_parameters_inc+2), & -& checkpoint_variable_b%ac_rr_parameters(:, & -& rr_parameters_inc+2), h1, h1_b, h2, h2_b, & -& checkpoint_variable%ac_qtz(:, setup%nqz), & -& checkpoint_variable_b%ac_qtz(:, setup%nqz)) - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+2) + h2_b - checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) = & -& checkpoint_variable_b%ac_rr_states(:, rr_states_inc+1) + h1_b - ELSE IF (branch .EQ. 9) THEN + ELSE IF (branch .EQ. 11) THEN CALL POPINTEGER4(rr_states_inc) CALL POPINTEGER4(rr_parameters_inc) h2_b = 0.0_4 @@ -23072,6 +24398,41 @@ SUBROUTINE SIMULATION_CHECKPOINT(setup, mesh, input_data, parameters, & checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 rr_parameters_inc = rr_parameters_inc + 4 rr_states_inc = rr_states_inc + 3 + CASE ('gr4_ri') +! 'gr4_ri' module +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % hi +! % hp +! % ht + CALL GR4_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+6), h1, h2& +& , h3, checkpoint_variable%ac_qtz(:, setup%nqz)) + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + rr_parameters_inc = rr_parameters_inc + 6 + rr_states_inc = rr_states_inc + 3 CASE ('gr4_mlp') ! 'gr4_mlp' module ! % To avoid potential aliasing tapenade warning (DF02) @@ -23206,6 +24567,43 @@ SUBROUTINE SIMULATION_CHECKPOINT(setup, mesh, input_data, parameters, & checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 rr_parameters_inc = rr_parameters_inc + 5 rr_states_inc = rr_states_inc + 3 + CASE ('gr5_ri') +! % To avoid potential aliasing tapenade warning (DF02) +! % hi + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc+1) +! % hp + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc+2) +! % ht + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc+3) +! % ci +! % cp +! % ct +! % alpha1 +! % alpha2 +! % kexc +! % aexc +! % hi +! % hp +! % ht + CALL GR5_RI_TIME_STEP(setup, mesh, input_data, options, returns& +& , t, checkpoint_variable%ac_mlt, & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+1), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+2), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+3), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+4), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+5), checkpoint_variable%& +& ac_rr_parameters(:, rr_parameters_inc+6), & +& checkpoint_variable%ac_rr_parameters(:, & +& rr_parameters_inc+7), h1, h2, h3, & +& checkpoint_variable%ac_qtz(:, setup%nqz)) + checkpoint_variable%ac_rr_states(:, rr_states_inc+1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc+2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc+3) = h3 + rr_parameters_inc = rr_parameters_inc + 7 + rr_states_inc = rr_states_inc + 3 CASE ('gr6') ! 'gr6' module ! % To avoid potential aliasing tapenade warning (DF02) diff --git a/smash/fcore/forward/md_simulation.f90 b/smash/fcore/forward/md_simulation.f90 index b5f668f5..30d34905 100644 --- a/smash/fcore/forward/md_simulation.f90 +++ b/smash/fcore/forward/md_simulation.f90 @@ -199,6 +199,40 @@ subroutine simulation_checkpoint(setup, mesh, input_data, parameters, output, op rr_parameters_inc = rr_parameters_inc + 4 rr_states_inc = rr_states_inc + 3 + ! 'gr4_ri' module + case ("gr4_ri") + + ! % To avoid potential aliasing tapenade warning (DF02) + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc + 1) ! % hi + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc + 2) ! % hp + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc + 3) ! % ht + + call gr4_ri_time_step( & + setup, & + mesh, & + input_data, & + options, & + returns, & + t, & + checkpoint_variable%ac_mlt, & + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 1), & ! % ci + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 2), & ! % cp + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 3), & ! % ct + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 4), & ! % alpha1 + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 5), & ! % alpha2 + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 6), & ! % kexc + h1, & ! % hi + h2, & ! % hp + h3, & ! % ht + checkpoint_variable%ac_qtz(:, setup%nqz)) + + checkpoint_variable%ac_rr_states(:, rr_states_inc + 1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc + 2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc + 3) = h3 + + rr_parameters_inc = rr_parameters_inc + 6 + rr_states_inc = rr_states_inc + 3 + ! 'gr4_mlp' module case ("gr4_mlp") @@ -340,6 +374,40 @@ subroutine simulation_checkpoint(setup, mesh, input_data, parameters, output, op rr_parameters_inc = rr_parameters_inc + 5 rr_states_inc = rr_states_inc + 3 + case ("gr5_ri") + + ! % To avoid potential aliasing tapenade warning (DF02) + h1 = checkpoint_variable%ac_rr_states(:, rr_states_inc + 1) ! % hi + h2 = checkpoint_variable%ac_rr_states(:, rr_states_inc + 2) ! % hp + h3 = checkpoint_variable%ac_rr_states(:, rr_states_inc + 3) ! % ht + + call gr5_ri_time_step( & + setup, & + mesh, & + input_data, & + options, & + returns, & + t, & + checkpoint_variable%ac_mlt, & + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 1), & ! % ci + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 2), & ! % cp + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 3), & ! % ct + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 4), & ! % alpha1 + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 5), & ! % alpha2 + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 6), & ! % kexc + checkpoint_variable%ac_rr_parameters(:, rr_parameters_inc + 7), & ! % aexc + h1, & ! % hi + h2, & ! % hp + h3, & ! % ht + checkpoint_variable%ac_qtz(:, setup%nqz)) + + checkpoint_variable%ac_rr_states(:, rr_states_inc + 1) = h1 + checkpoint_variable%ac_rr_states(:, rr_states_inc + 2) = h2 + checkpoint_variable%ac_rr_states(:, rr_states_inc + 3) = h3 + + rr_parameters_inc = rr_parameters_inc + 7 + rr_states_inc = rr_states_inc + 3 + ! 'gr6' module case ("gr6") diff --git a/smash/fcore/operator/md_gr_operator.f90 b/smash/fcore/operator/md_gr_operator.f90 index 9060f018..8cb6472e 100644 --- a/smash/fcore/operator/md_gr_operator.f90 +++ b/smash/fcore/operator/md_gr_operator.f90 @@ -91,6 +91,44 @@ subroutine gr_production(fq_ps, fq_es, pn, en, cp, beta, hp, pr, perc) end subroutine gr_production + subroutine gr_ri_production(pn, en, cp, beta, alpha1, hp, pr, perc, dt) + + implicit none + + real(sp), intent(in) :: pn, en, cp, beta, alpha1 + real(sp), intent(in) :: dt + real(sp), intent(inout) :: hp + real(sp), intent(out) :: pr, perc + + real(sp) :: inv_cp, ps, es, hp_imd + real(sp) :: lambda, gam, inv_lambda + + inv_cp = 1._sp/cp + pr = 0._sp + gam = 1._sp - exp(-pn*alpha1) + lambda = sqrt(1._sp - gam) + inv_lambda = 1._sp/lambda + + ps = cp*inv_lambda*tanh(lambda*pn*inv_cp)*(1._sp - (lambda*hp)**2) & + & /(1._sp + lambda*hp*tanh(lambda*pn*inv_cp)) - gam*dt + + es = (hp*cp)*(2._sp - hp)*tanh(en*inv_cp)/ & + & (1._sp + (1._sp - hp)*tanh(en*inv_cp)) + + hp_imd = hp + (ps - es)*inv_cp + + if (pn .gt. 0) then + + pr = pn - (hp_imd - hp)*cp + + end if + + perc = (hp_imd*cp)*(1._sp - (1._sp + (hp_imd/beta)**4)**(-0.25_sp)) + + hp = hp_imd - perc*inv_cp + + end subroutine gr_ri_production + subroutine gr_exchange(fq_l, kexc, ht, l) implicit none @@ -381,6 +419,104 @@ subroutine gr4_time_step(setup, mesh, input_data, options, returns, time_step, a #endif end subroutine gr4_time_step + subroutine gr4_ri_time_step(setup, mesh, input_data, options, returns, time_step, ac_mlt, ac_ci, ac_cp, ac_ct, & + & ac_alpha1, ac_alpha2, ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) + + implicit none + + type(SetupDT), intent(in) :: setup + type(MeshDT), intent(in) :: mesh + type(Input_DataDT), intent(in) :: input_data + type(OptionsDT), intent(in) :: options + type(ReturnsDT), intent(inout) :: returns + integer, intent(in) :: time_step + real(sp), dimension(mesh%nac), intent(in) :: ac_mlt + real(sp), dimension(mesh%nac), intent(in) :: ac_ci, ac_cp, ac_ct, ac_kexc + real(sp), dimension(mesh%nac), intent(in) :: ac_alpha1, ac_alpha2 + real(sp), dimension(mesh%nac), intent(inout) :: ac_hi, ac_hp, ac_ht + real(sp), dimension(mesh%nac), intent(inout) :: ac_qt + + real(sp), dimension(mesh%nac) :: ac_prcp, ac_pet + integer :: row, col, k, time_step_returns + real(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + + call get_ac_atmos_data_time_step(setup, mesh, input_data, time_step, "prcp", ac_prcp) + call get_ac_atmos_data_time_step(setup, mesh, input_data, time_step, "pet", ac_pet) + + ac_prcp = ac_prcp + ac_mlt + + ! Beta percolation parameter is time step dependent + beta = (9._sp/4._sp)*(86400._sp/setup%dt)**0.25_sp +#ifdef _OPENMP + !$OMP parallel do schedule(static) num_threads(options%comm%ncpu) & + !$OMP& shared(setup, mesh, returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, & + !$OMP& ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) & + !$OMP& private(row, col, k, time_step_returns, pn, en, pr, perc, l, prr, prd, qr, qd, split) +#endif + do col = 1, mesh%ncol + do row = 1, mesh%nrow + + if (mesh%active_cell(row, col) .eq. 0 .or. mesh%local_active_cell(row, col) .eq. 0) cycle + + k = mesh%rowcol_to_ind_ac(row, col) + + if (ac_prcp(k) .ge. 0._sp .and. ac_pet(k) .ge. 0._sp) then + + call gr_interception(ac_prcp(k), ac_pet(k), ac_ci(k), & + & ac_hi(k), pn, en) + + call gr_ri_production(pn, en, ac_cp(k), beta, ac_alpha1(k), ac_hp(k), pr, perc, setup%dt) + + call gr_exchange(0._sp, ac_kexc(k), ac_ht(k), l) + + else + + pr = 0._sp + perc = 0._sp + l = 0._sp + + end if + split = 0.9_sp*tanh(ac_alpha2(k)*pn)**2 + 0.1_sp + + prr = (1._sp - split)*(pr + perc) + l + prd = split*(pr + perc) + + call gr_transfer(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), qr) + + qd = max(0._sp, prd + l) + + ac_qt(k) = qr + qd + + ! Transform from mm/dt to m3/s + ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col)/setup%dt + + !$AD start-exclude + !internal fluxes + if (returns%internal_fluxes_flag) then + if (allocated(returns%mask_time_step)) then + if (returns%mask_time_step(time_step)) then + time_step_returns = returns%time_step_to_returns_time_step(time_step) + ! the fluxes of the snow module are the first ones inside internal fluxes + ! due to the building of the modules so n_snow_fluxes + ! moves the index of the array + returns%internal_fluxes( & + row, & + col, & + time_step_returns, & + setup%n_snow_fluxes + 1:setup%n_snow_fluxes + setup%n_hydro_fluxes & + ) = (/pn, en, pr, perc, l, prr, prd, qr, qd, ac_qt(k)/) + end if + end if + end if + !$AD end-exclude + + end do + end do +#ifdef _OPENMP + !$OMP end parallel do +#endif + end subroutine gr4_ri_time_step + subroutine gr4_mlp_time_step(setup, mesh, input_data, options, returns, time_step, weight_1, bias_1, & & weight_2, bias_2, weight_3, bias_3, ac_mlt, ac_ci, ac_cp, ac_ct, ac_kexc, ac_hi, ac_hp, ac_ht, ac_qt) @@ -858,6 +994,105 @@ subroutine gr5_time_step(setup, mesh, input_data, options, returns, time_step, a #endif end subroutine gr5_time_step + subroutine gr5_ri_time_step(setup, mesh, input_data, options, returns, time_step, ac_mlt, ac_ci, ac_cp, ac_ct, & + & ac_alpha1, ac_alpha2, ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt) + + implicit none + + type(SetupDT), intent(in) :: setup + type(MeshDT), intent(in) :: mesh + type(Input_DataDT), intent(in) :: input_data + type(OptionsDT), intent(in) :: options + type(ReturnsDT), intent(inout) :: returns + integer, intent(in) :: time_step + real(sp), dimension(mesh%nac), intent(in) :: ac_mlt + real(sp), dimension(mesh%nac), intent(in) :: ac_ci, ac_cp, ac_ct, ac_kexc, ac_aexc + real(sp), dimension(mesh%nac), intent(in) :: ac_alpha1, ac_alpha2 + real(sp), dimension(mesh%nac), intent(inout) :: ac_hi, ac_hp, ac_ht + real(sp), dimension(mesh%nac), intent(inout) :: ac_qt + + real(sp), dimension(mesh%nac) :: ac_prcp, ac_pet + integer :: row, col, k, time_step_returns + real(sp) :: beta, pn, en, pr, perc, l, prr, prd, qr, qd, split + + call get_ac_atmos_data_time_step(setup, mesh, input_data, time_step, "prcp", ac_prcp) + call get_ac_atmos_data_time_step(setup, mesh, input_data, time_step, "pet", ac_pet) + + ac_prcp = ac_prcp + ac_mlt + + ! Beta percolation parameter is time step dependent + beta = (9._sp/4._sp)*(86400._sp/setup%dt)**0.25_sp + +#ifdef _OPENMP + !$OMP parallel do schedule(static) num_threads(options%comm%ncpu) & + !$OMP& shared(setup, mesh, returns, ac_prcp, ac_pet, ac_ci, ac_cp, beta, & + !$OMP& ac_alpha1, ac_alpha2, ac_ct, ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_qt) & + !$OMP& private(row, col, k, time_step_returns, pn, en, pr, perc, l, prr, prd, qr, qd, split) +#endif + do col = 1, mesh%ncol + do row = 1, mesh%nrow + + if (mesh%active_cell(row, col) .eq. 0 .or. mesh%local_active_cell(row, col) .eq. 0) cycle + + k = mesh%rowcol_to_ind_ac(row, col) + + if (ac_prcp(k) .ge. 0._sp .and. ac_pet(k) .ge. 0._sp) then + + call gr_interception(ac_prcp(k), ac_pet(k), ac_ci(k), & + & ac_hi(k), pn, en) + + call gr_ri_production(pn, en, ac_cp(k), beta, ac_alpha1(k), ac_hp(k), pr, perc, setup%dt) + + call gr_threshold_exchange(ac_kexc(k), ac_aexc(k), ac_ht(k), l) + + else + + pr = 0._sp + perc = 0._sp + l = 0._sp + + end if + + split = 0.9_sp*tanh(ac_alpha2(k)*pn)**2 + 0.1_sp + + prr = (1._sp - split)*(pr + perc) + l + prd = split*(pr + perc) + + call gr_transfer(5._sp, ac_prcp(k), prr, ac_ct(k), ac_ht(k), qr) + + qd = max(0._sp, prd + l) + + ac_qt(k) = qr + qd + + ! Transform from mm/dt to m3/s + ac_qt(k) = ac_qt(k)*1e-3_sp*mesh%dx(row, col)*mesh%dy(row, col)/setup%dt + + !$AD start-exclude + !internal fluxes + if (returns%internal_fluxes_flag) then + if (allocated(returns%mask_time_step)) then + if (returns%mask_time_step(time_step)) then + time_step_returns = returns%time_step_to_returns_time_step(time_step) + ! the fluxes of the snow module are the first ones inside internal fluxes + ! due to the building of the modules so n_snow_fluxes + ! moves the index of the array + returns%internal_fluxes( & + row, & + col, & + time_step_returns, & + setup%n_snow_fluxes + 1:setup%n_snow_fluxes + setup%n_hydro_fluxes & + ) = (/pn, en, pr, perc, l, prr, prd, qr, qd, ac_qt(k)/) + end if + end if + end if + !$AD end-exclude + end do + end do +#ifdef _OPENMP + !$OMP end parallel do +#endif + end subroutine gr5_ri_time_step + subroutine gr6_time_step(setup, mesh, input_data, options, returns, time_step, ac_mlt, ac_ci, ac_cp, ac_ct, & & ac_be, ac_kexc, ac_aexc, ac_hi, ac_hp, ac_ht, ac_he, ac_qt) diff --git a/smash/tests/baseline.hdf5 b/smash/tests/baseline.hdf5 index 5af61754..60aaeb3e 100644 Binary files a/smash/tests/baseline.hdf5 and b/smash/tests/baseline.hdf5 differ diff --git a/smash/tests/diff_baseline.csv b/smash/tests/diff_baseline.csv index 866535ef..eb6a43d0 100644 --- a/smash/tests/diff_baseline.csv +++ b/smash/tests/diff_baseline.csv @@ -1,12 +1,8 @@ -commit 10b2e6d630dd602f840176b838e2f7885e45e761 -Author: Ngo Nghi Truyen Huynh <129378719+nghi-truyen@users.noreply.github.com> -Date: Thu Sep 12 22:35:22 2024 +0200 +commit 9026756332322c49a2c4ee3c5f7359b030906938 +Author: Apolline Elbaz +Date: Mon Sep 16 12:38:24 2024 +0200 - MAINT: change default network for optimization with ann mapping - - - Change default net ann optimize - - Enhance net checking - - Correct/update lez regionalization for ann mapping + change constant for fast tests TEST NAME |STATUS bbox_mesh.active_cell |NON MODIFIED @@ -47,10 +43,10 @@ custom_optimize.zero-gr4-lr.custom_set_12.iter_control |NON MODIFIED custom_optimize.zero-gr4-lr.custom_set_12.iter_cost |NON MODIFIED custom_optimize.zero-gr4-lr.custom_set_12.iter_projg |NON MODIFIED custom_optimize.zero-gr4-lr.custom_set_12.sim_q |NON MODIFIED -custom_optimize.zero-gr4-lr.custom_set_13.iter_control |MODIFIED -custom_optimize.zero-gr4-lr.custom_set_13.iter_cost |MODIFIED -custom_optimize.zero-gr4-lr.custom_set_13.iter_projg |MODIFIED -custom_optimize.zero-gr4-lr.custom_set_13.sim_q |MODIFIED +custom_optimize.zero-gr4-lr.custom_set_13.iter_control |NON MODIFIED +custom_optimize.zero-gr4-lr.custom_set_13.iter_cost |NON MODIFIED +custom_optimize.zero-gr4-lr.custom_set_13.iter_projg |NON MODIFIED +custom_optimize.zero-gr4-lr.custom_set_13.sim_q |NON MODIFIED custom_optimize.zero-gr4-lr.custom_set_2.iter_control |NON MODIFIED custom_optimize.zero-gr4-lr.custom_set_2.iter_cost |NON MODIFIED custom_optimize.zero-gr4-lr.custom_set_2.sim_q |NON MODIFIED @@ -173,6 +169,28 @@ forward_run.zero-gr4_ode_mlp-lr.rr_states.hlr |NON MODIFIED forward_run.zero-gr4_ode_mlp-lr.rr_states.hp |NON MODIFIED forward_run.zero-gr4_ode_mlp-lr.rr_states.ht |NON MODIFIED forward_run.zero-gr4_ode_mlp-lr.sim_q |NON MODIFIED +forward_run.zero-gr4_ri-kw.cost |ADDED +forward_run.zero-gr4_ri-kw.jobs |ADDED +forward_run.zero-gr4_ri-kw.q_domain |ADDED +forward_run.zero-gr4_ri-kw.rr_states.hi |ADDED +forward_run.zero-gr4_ri-kw.rr_states.hp |ADDED +forward_run.zero-gr4_ri-kw.rr_states.ht |ADDED +forward_run.zero-gr4_ri-kw.sim_q |ADDED +forward_run.zero-gr4_ri-lag0.cost |ADDED +forward_run.zero-gr4_ri-lag0.jobs |ADDED +forward_run.zero-gr4_ri-lag0.q_domain |ADDED +forward_run.zero-gr4_ri-lag0.rr_states.hi |ADDED +forward_run.zero-gr4_ri-lag0.rr_states.hp |ADDED +forward_run.zero-gr4_ri-lag0.rr_states.ht |ADDED +forward_run.zero-gr4_ri-lag0.sim_q |ADDED +forward_run.zero-gr4_ri-lr.cost |ADDED +forward_run.zero-gr4_ri-lr.jobs |ADDED +forward_run.zero-gr4_ri-lr.q_domain |ADDED +forward_run.zero-gr4_ri-lr.rr_states.hi |ADDED +forward_run.zero-gr4_ri-lr.rr_states.hlr |ADDED +forward_run.zero-gr4_ri-lr.rr_states.hp |ADDED +forward_run.zero-gr4_ri-lr.rr_states.ht |ADDED +forward_run.zero-gr4_ri-lr.sim_q |ADDED forward_run.zero-gr5-kw.cost |NON MODIFIED forward_run.zero-gr5-kw.jobs |NON MODIFIED forward_run.zero-gr5-kw.q_domain |NON MODIFIED @@ -195,6 +213,28 @@ forward_run.zero-gr5-lr.rr_states.hlr |NON MODIFIED forward_run.zero-gr5-lr.rr_states.hp |NON MODIFIED forward_run.zero-gr5-lr.rr_states.ht |NON MODIFIED forward_run.zero-gr5-lr.sim_q |NON MODIFIED +forward_run.zero-gr5_ri-kw.cost |ADDED +forward_run.zero-gr5_ri-kw.jobs |ADDED +forward_run.zero-gr5_ri-kw.q_domain |ADDED +forward_run.zero-gr5_ri-kw.rr_states.hi |ADDED +forward_run.zero-gr5_ri-kw.rr_states.hp |ADDED +forward_run.zero-gr5_ri-kw.rr_states.ht |ADDED +forward_run.zero-gr5_ri-kw.sim_q |ADDED +forward_run.zero-gr5_ri-lag0.cost |ADDED +forward_run.zero-gr5_ri-lag0.jobs |ADDED +forward_run.zero-gr5_ri-lag0.q_domain |ADDED +forward_run.zero-gr5_ri-lag0.rr_states.hi |ADDED +forward_run.zero-gr5_ri-lag0.rr_states.hp |ADDED +forward_run.zero-gr5_ri-lag0.rr_states.ht |ADDED +forward_run.zero-gr5_ri-lag0.sim_q |ADDED +forward_run.zero-gr5_ri-lr.cost |ADDED +forward_run.zero-gr5_ri-lr.jobs |ADDED +forward_run.zero-gr5_ri-lr.q_domain |ADDED +forward_run.zero-gr5_ri-lr.rr_states.hi |ADDED +forward_run.zero-gr5_ri-lr.rr_states.hlr |ADDED +forward_run.zero-gr5_ri-lr.rr_states.hp |ADDED +forward_run.zero-gr5_ri-lr.rr_states.ht |ADDED +forward_run.zero-gr5_ri-lr.sim_q |ADDED forward_run.zero-gr6-kw.cost |NON MODIFIED forward_run.zero-gr6-kw.jobs |NON MODIFIED forward_run.zero-gr6-kw.q_domain |NON MODIFIED @@ -408,6 +448,39 @@ internal_fluxes.zero-gr4_ode_mlp-lr.lexc |NON MODIFIED internal_fluxes.zero-gr4_ode_mlp-lr.pn |NON MODIFIED internal_fluxes.zero-gr4_ode_mlp-lr.qt |NON MODIFIED internal_fluxes.zero-gr4_ode_mlp-lr.qup |NON MODIFIED +internal_fluxes.zero-gr4_ri-kw.en |ADDED +internal_fluxes.zero-gr4_ri-kw.lexc |ADDED +internal_fluxes.zero-gr4_ri-kw.perc |ADDED +internal_fluxes.zero-gr4_ri-kw.pn |ADDED +internal_fluxes.zero-gr4_ri-kw.pr |ADDED +internal_fluxes.zero-gr4_ri-kw.prd |ADDED +internal_fluxes.zero-gr4_ri-kw.prr |ADDED +internal_fluxes.zero-gr4_ri-kw.qd |ADDED +internal_fluxes.zero-gr4_ri-kw.qim1j |ADDED +internal_fluxes.zero-gr4_ri-kw.qr |ADDED +internal_fluxes.zero-gr4_ri-kw.qt |ADDED +internal_fluxes.zero-gr4_ri-lag0.en |ADDED +internal_fluxes.zero-gr4_ri-lag0.lexc |ADDED +internal_fluxes.zero-gr4_ri-lag0.perc |ADDED +internal_fluxes.zero-gr4_ri-lag0.pn |ADDED +internal_fluxes.zero-gr4_ri-lag0.pr |ADDED +internal_fluxes.zero-gr4_ri-lag0.prd |ADDED +internal_fluxes.zero-gr4_ri-lag0.prr |ADDED +internal_fluxes.zero-gr4_ri-lag0.qd |ADDED +internal_fluxes.zero-gr4_ri-lag0.qr |ADDED +internal_fluxes.zero-gr4_ri-lag0.qt |ADDED +internal_fluxes.zero-gr4_ri-lag0.qup |ADDED +internal_fluxes.zero-gr4_ri-lr.en |ADDED +internal_fluxes.zero-gr4_ri-lr.lexc |ADDED +internal_fluxes.zero-gr4_ri-lr.perc |ADDED +internal_fluxes.zero-gr4_ri-lr.pn |ADDED +internal_fluxes.zero-gr4_ri-lr.pr |ADDED +internal_fluxes.zero-gr4_ri-lr.prd |ADDED +internal_fluxes.zero-gr4_ri-lr.prr |ADDED +internal_fluxes.zero-gr4_ri-lr.qd |ADDED +internal_fluxes.zero-gr4_ri-lr.qr |ADDED +internal_fluxes.zero-gr4_ri-lr.qt |ADDED +internal_fluxes.zero-gr4_ri-lr.qup |ADDED internal_fluxes.zero-gr5-kw.en |NON MODIFIED internal_fluxes.zero-gr5-kw.lexc |NON MODIFIED internal_fluxes.zero-gr5-kw.perc |NON MODIFIED @@ -441,6 +514,39 @@ internal_fluxes.zero-gr5-lr.qd |NON MODIFIED internal_fluxes.zero-gr5-lr.qr |NON MODIFIED internal_fluxes.zero-gr5-lr.qt |NON MODIFIED internal_fluxes.zero-gr5-lr.qup |NON MODIFIED +internal_fluxes.zero-gr5_ri-kw.en |ADDED +internal_fluxes.zero-gr5_ri-kw.lexc |ADDED +internal_fluxes.zero-gr5_ri-kw.perc |ADDED +internal_fluxes.zero-gr5_ri-kw.pn |ADDED +internal_fluxes.zero-gr5_ri-kw.pr |ADDED +internal_fluxes.zero-gr5_ri-kw.prd |ADDED +internal_fluxes.zero-gr5_ri-kw.prr |ADDED +internal_fluxes.zero-gr5_ri-kw.qd |ADDED +internal_fluxes.zero-gr5_ri-kw.qim1j |ADDED +internal_fluxes.zero-gr5_ri-kw.qr |ADDED +internal_fluxes.zero-gr5_ri-kw.qt |ADDED +internal_fluxes.zero-gr5_ri-lag0.en |ADDED +internal_fluxes.zero-gr5_ri-lag0.lexc |ADDED +internal_fluxes.zero-gr5_ri-lag0.perc |ADDED +internal_fluxes.zero-gr5_ri-lag0.pn |ADDED +internal_fluxes.zero-gr5_ri-lag0.pr |ADDED +internal_fluxes.zero-gr5_ri-lag0.prd |ADDED +internal_fluxes.zero-gr5_ri-lag0.prr |ADDED +internal_fluxes.zero-gr5_ri-lag0.qd |ADDED +internal_fluxes.zero-gr5_ri-lag0.qr |ADDED +internal_fluxes.zero-gr5_ri-lag0.qt |ADDED +internal_fluxes.zero-gr5_ri-lag0.qup |ADDED +internal_fluxes.zero-gr5_ri-lr.en |ADDED +internal_fluxes.zero-gr5_ri-lr.lexc |ADDED +internal_fluxes.zero-gr5_ri-lr.perc |ADDED +internal_fluxes.zero-gr5_ri-lr.pn |ADDED +internal_fluxes.zero-gr5_ri-lr.pr |ADDED +internal_fluxes.zero-gr5_ri-lr.prd |ADDED +internal_fluxes.zero-gr5_ri-lr.prr |ADDED +internal_fluxes.zero-gr5_ri-lr.qd |ADDED +internal_fluxes.zero-gr5_ri-lr.qr |ADDED +internal_fluxes.zero-gr5_ri-lr.qt |ADDED +internal_fluxes.zero-gr5_ri-lr.qup |ADDED internal_fluxes.zero-gr6-kw.en |NON MODIFIED internal_fluxes.zero-gr6-kw.lexc |NON MODIFIED internal_fluxes.zero-gr6-kw.perc |NON MODIFIED @@ -691,8 +797,8 @@ net_init.weight_layer_1 |NON MODIFIED net_init.weight_layer_2 |NON MODIFIED net_init.weight_layer_3 |NON MODIFIED net_init.weight_layer_4 |NON MODIFIED -optimize.zero-gr4-kw.ann.control_vector |MODIFIED -optimize.zero-gr4-kw.ann.sim_q |MODIFIED +optimize.zero-gr4-kw.ann.control_vector |NON MODIFIED +optimize.zero-gr4-kw.ann.sim_q |NON MODIFIED optimize.zero-gr4-kw.distributed.control_vector |NON MODIFIED optimize.zero-gr4-kw.distributed.sim_q |NON MODIFIED optimize.zero-gr4-kw.multi-linear.control_vector |NON MODIFIED @@ -701,8 +807,8 @@ optimize.zero-gr4-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4-kw.uniform.control_vector |NON MODIFIED optimize.zero-gr4-kw.uniform.sim_q |NON MODIFIED -optimize.zero-gr4-lag0.ann.control_vector |MODIFIED -optimize.zero-gr4-lag0.ann.sim_q |MODIFIED +optimize.zero-gr4-lag0.ann.control_vector |NON MODIFIED +optimize.zero-gr4-lag0.ann.sim_q |NON MODIFIED optimize.zero-gr4-lag0.distributed.control_vector |NON MODIFIED optimize.zero-gr4-lag0.distributed.sim_q |NON MODIFIED optimize.zero-gr4-lag0.multi-linear.control_vector |NON MODIFIED @@ -711,8 +817,8 @@ optimize.zero-gr4-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4-lag0.uniform.control_vector |NON MODIFIED optimize.zero-gr4-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-gr4-lr.ann.control_vector |MODIFIED -optimize.zero-gr4-lr.ann.sim_q |MODIFIED +optimize.zero-gr4-lr.ann.control_vector |NON MODIFIED +optimize.zero-gr4-lr.ann.sim_q |NON MODIFIED optimize.zero-gr4-lr.distributed.control_vector |NON MODIFIED optimize.zero-gr4-lr.distributed.sim_q |NON MODIFIED optimize.zero-gr4-lr.multi-linear.control_vector |NON MODIFIED @@ -721,8 +827,8 @@ optimize.zero-gr4-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4-lr.uniform.control_vector |NON MODIFIED optimize.zero-gr4-lr.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_mlp-kw.ann.control_vector |MODIFIED -optimize.zero-gr4_mlp-kw.ann.sim_q |MODIFIED +optimize.zero-gr4_mlp-kw.ann.control_vector |NON MODIFIED +optimize.zero-gr4_mlp-kw.ann.sim_q |NON MODIFIED optimize.zero-gr4_mlp-kw.distributed.control_vector |NON MODIFIED optimize.zero-gr4_mlp-kw.distributed.sim_q |NON MODIFIED optimize.zero-gr4_mlp-kw.multi-linear.control_vector |NON MODIFIED @@ -731,8 +837,8 @@ optimize.zero-gr4_mlp-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_mlp-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_mlp-kw.uniform.control_vector |NON MODIFIED optimize.zero-gr4_mlp-kw.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_mlp-lag0.ann.control_vector |MODIFIED -optimize.zero-gr4_mlp-lag0.ann.sim_q |MODIFIED +optimize.zero-gr4_mlp-lag0.ann.control_vector |NON MODIFIED +optimize.zero-gr4_mlp-lag0.ann.sim_q |NON MODIFIED optimize.zero-gr4_mlp-lag0.distributed.control_vector |NON MODIFIED optimize.zero-gr4_mlp-lag0.distributed.sim_q |NON MODIFIED optimize.zero-gr4_mlp-lag0.multi-linear.control_vector |NON MODIFIED @@ -741,8 +847,8 @@ optimize.zero-gr4_mlp-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_mlp-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_mlp-lag0.uniform.control_vector |NON MODIFIED optimize.zero-gr4_mlp-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_mlp-lr.ann.control_vector |MODIFIED -optimize.zero-gr4_mlp-lr.ann.sim_q |MODIFIED +optimize.zero-gr4_mlp-lr.ann.control_vector |NON MODIFIED +optimize.zero-gr4_mlp-lr.ann.sim_q |NON MODIFIED optimize.zero-gr4_mlp-lr.distributed.control_vector |NON MODIFIED optimize.zero-gr4_mlp-lr.distributed.sim_q |NON MODIFIED optimize.zero-gr4_mlp-lr.multi-linear.control_vector |NON MODIFIED @@ -751,8 +857,8 @@ optimize.zero-gr4_mlp-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_mlp-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_mlp-lr.uniform.control_vector |NON MODIFIED optimize.zero-gr4_mlp-lr.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_ode-kw.ann.control_vector |MODIFIED -optimize.zero-gr4_ode-kw.ann.sim_q |MODIFIED +optimize.zero-gr4_ode-kw.ann.control_vector |NON MODIFIED +optimize.zero-gr4_ode-kw.ann.sim_q |NON MODIFIED optimize.zero-gr4_ode-kw.distributed.control_vector |NON MODIFIED optimize.zero-gr4_ode-kw.distributed.sim_q |NON MODIFIED optimize.zero-gr4_ode-kw.multi-linear.control_vector |NON MODIFIED @@ -761,8 +867,8 @@ optimize.zero-gr4_ode-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_ode-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_ode-kw.uniform.control_vector |NON MODIFIED optimize.zero-gr4_ode-kw.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_ode-lag0.ann.control_vector |MODIFIED -optimize.zero-gr4_ode-lag0.ann.sim_q |MODIFIED +optimize.zero-gr4_ode-lag0.ann.control_vector |NON MODIFIED +optimize.zero-gr4_ode-lag0.ann.sim_q |NON MODIFIED optimize.zero-gr4_ode-lag0.distributed.control_vector |NON MODIFIED optimize.zero-gr4_ode-lag0.distributed.sim_q |NON MODIFIED optimize.zero-gr4_ode-lag0.multi-linear.control_vector |NON MODIFIED @@ -771,8 +877,8 @@ optimize.zero-gr4_ode-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_ode-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_ode-lag0.uniform.control_vector |NON MODIFIED optimize.zero-gr4_ode-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_ode-lr.ann.control_vector |MODIFIED -optimize.zero-gr4_ode-lr.ann.sim_q |MODIFIED +optimize.zero-gr4_ode-lr.ann.control_vector |NON MODIFIED +optimize.zero-gr4_ode-lr.ann.sim_q |NON MODIFIED optimize.zero-gr4_ode-lr.distributed.control_vector |NON MODIFIED optimize.zero-gr4_ode-lr.distributed.sim_q |NON MODIFIED optimize.zero-gr4_ode-lr.multi-linear.control_vector |NON MODIFIED @@ -781,8 +887,8 @@ optimize.zero-gr4_ode-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_ode-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_ode-lr.uniform.control_vector |NON MODIFIED optimize.zero-gr4_ode-lr.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_ode_mlp-kw.ann.control_vector |MODIFIED -optimize.zero-gr4_ode_mlp-kw.ann.sim_q |MODIFIED +optimize.zero-gr4_ode_mlp-kw.ann.control_vector |NON MODIFIED +optimize.zero-gr4_ode_mlp-kw.ann.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-kw.distributed.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-kw.distributed.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-kw.multi-linear.control_vector |NON MODIFIED @@ -791,8 +897,8 @@ optimize.zero-gr4_ode_mlp-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-kw.uniform.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-kw.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_ode_mlp-lag0.ann.control_vector |MODIFIED -optimize.zero-gr4_ode_mlp-lag0.ann.sim_q |MODIFIED +optimize.zero-gr4_ode_mlp-lag0.ann.control_vector |NON MODIFIED +optimize.zero-gr4_ode_mlp-lag0.ann.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-lag0.distributed.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-lag0.distributed.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-lag0.multi-linear.control_vector |NON MODIFIED @@ -801,8 +907,8 @@ optimize.zero-gr4_ode_mlp-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-lag0.uniform.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-gr4_ode_mlp-lr.ann.control_vector |MODIFIED -optimize.zero-gr4_ode_mlp-lr.ann.sim_q |MODIFIED +optimize.zero-gr4_ode_mlp-lr.ann.control_vector |NON MODIFIED +optimize.zero-gr4_ode_mlp-lr.ann.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-lr.distributed.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-lr.distributed.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-lr.multi-linear.control_vector |NON MODIFIED @@ -811,8 +917,38 @@ optimize.zero-gr4_ode_mlp-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr4_ode_mlp-lr.uniform.control_vector |NON MODIFIED optimize.zero-gr4_ode_mlp-lr.uniform.sim_q |NON MODIFIED -optimize.zero-gr5-kw.ann.control_vector |MODIFIED -optimize.zero-gr5-kw.ann.sim_q |MODIFIED +optimize.zero-gr4_ri-kw.ann.control_vector |ADDED +optimize.zero-gr4_ri-kw.ann.sim_q |ADDED +optimize.zero-gr4_ri-kw.distributed.control_vector |ADDED +optimize.zero-gr4_ri-kw.distributed.sim_q |ADDED +optimize.zero-gr4_ri-kw.multi-linear.control_vector |ADDED +optimize.zero-gr4_ri-kw.multi-linear.sim_q |ADDED +optimize.zero-gr4_ri-kw.multi-polynomial.control_vector |ADDED +optimize.zero-gr4_ri-kw.multi-polynomial.sim_q |ADDED +optimize.zero-gr4_ri-kw.uniform.control_vector |ADDED +optimize.zero-gr4_ri-kw.uniform.sim_q |ADDED +optimize.zero-gr4_ri-lag0.ann.control_vector |ADDED +optimize.zero-gr4_ri-lag0.ann.sim_q |ADDED +optimize.zero-gr4_ri-lag0.distributed.control_vector |ADDED +optimize.zero-gr4_ri-lag0.distributed.sim_q |ADDED +optimize.zero-gr4_ri-lag0.multi-linear.control_vector |ADDED +optimize.zero-gr4_ri-lag0.multi-linear.sim_q |ADDED +optimize.zero-gr4_ri-lag0.multi-polynomial.control_vector |ADDED +optimize.zero-gr4_ri-lag0.multi-polynomial.sim_q |ADDED +optimize.zero-gr4_ri-lag0.uniform.control_vector |ADDED +optimize.zero-gr4_ri-lag0.uniform.sim_q |ADDED +optimize.zero-gr4_ri-lr.ann.control_vector |ADDED +optimize.zero-gr4_ri-lr.ann.sim_q |ADDED +optimize.zero-gr4_ri-lr.distributed.control_vector |ADDED +optimize.zero-gr4_ri-lr.distributed.sim_q |ADDED +optimize.zero-gr4_ri-lr.multi-linear.control_vector |ADDED +optimize.zero-gr4_ri-lr.multi-linear.sim_q |ADDED +optimize.zero-gr4_ri-lr.multi-polynomial.control_vector |ADDED +optimize.zero-gr4_ri-lr.multi-polynomial.sim_q |ADDED +optimize.zero-gr4_ri-lr.uniform.control_vector |ADDED +optimize.zero-gr4_ri-lr.uniform.sim_q |ADDED +optimize.zero-gr5-kw.ann.control_vector |NON MODIFIED +optimize.zero-gr5-kw.ann.sim_q |NON MODIFIED optimize.zero-gr5-kw.distributed.control_vector |NON MODIFIED optimize.zero-gr5-kw.distributed.sim_q |NON MODIFIED optimize.zero-gr5-kw.multi-linear.control_vector |NON MODIFIED @@ -821,8 +957,8 @@ optimize.zero-gr5-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr5-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr5-kw.uniform.control_vector |NON MODIFIED optimize.zero-gr5-kw.uniform.sim_q |NON MODIFIED -optimize.zero-gr5-lag0.ann.control_vector |MODIFIED -optimize.zero-gr5-lag0.ann.sim_q |MODIFIED +optimize.zero-gr5-lag0.ann.control_vector |NON MODIFIED +optimize.zero-gr5-lag0.ann.sim_q |NON MODIFIED optimize.zero-gr5-lag0.distributed.control_vector |NON MODIFIED optimize.zero-gr5-lag0.distributed.sim_q |NON MODIFIED optimize.zero-gr5-lag0.multi-linear.control_vector |NON MODIFIED @@ -831,8 +967,8 @@ optimize.zero-gr5-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr5-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr5-lag0.uniform.control_vector |NON MODIFIED optimize.zero-gr5-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-gr5-lr.ann.control_vector |MODIFIED -optimize.zero-gr5-lr.ann.sim_q |MODIFIED +optimize.zero-gr5-lr.ann.control_vector |NON MODIFIED +optimize.zero-gr5-lr.ann.sim_q |NON MODIFIED optimize.zero-gr5-lr.distributed.control_vector |NON MODIFIED optimize.zero-gr5-lr.distributed.sim_q |NON MODIFIED optimize.zero-gr5-lr.multi-linear.control_vector |NON MODIFIED @@ -841,8 +977,38 @@ optimize.zero-gr5-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr5-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr5-lr.uniform.control_vector |NON MODIFIED optimize.zero-gr5-lr.uniform.sim_q |NON MODIFIED -optimize.zero-gr6-kw.ann.control_vector |MODIFIED -optimize.zero-gr6-kw.ann.sim_q |MODIFIED +optimize.zero-gr5_ri-kw.ann.control_vector |ADDED +optimize.zero-gr5_ri-kw.ann.sim_q |ADDED +optimize.zero-gr5_ri-kw.distributed.control_vector |ADDED +optimize.zero-gr5_ri-kw.distributed.sim_q |ADDED +optimize.zero-gr5_ri-kw.multi-linear.control_vector |ADDED +optimize.zero-gr5_ri-kw.multi-linear.sim_q |ADDED +optimize.zero-gr5_ri-kw.multi-polynomial.control_vector |ADDED +optimize.zero-gr5_ri-kw.multi-polynomial.sim_q |ADDED +optimize.zero-gr5_ri-kw.uniform.control_vector |ADDED +optimize.zero-gr5_ri-kw.uniform.sim_q |ADDED +optimize.zero-gr5_ri-lag0.ann.control_vector |ADDED +optimize.zero-gr5_ri-lag0.ann.sim_q |ADDED +optimize.zero-gr5_ri-lag0.distributed.control_vector |ADDED +optimize.zero-gr5_ri-lag0.distributed.sim_q |ADDED +optimize.zero-gr5_ri-lag0.multi-linear.control_vector |ADDED +optimize.zero-gr5_ri-lag0.multi-linear.sim_q |ADDED +optimize.zero-gr5_ri-lag0.multi-polynomial.control_vector |ADDED +optimize.zero-gr5_ri-lag0.multi-polynomial.sim_q |ADDED +optimize.zero-gr5_ri-lag0.uniform.control_vector |ADDED +optimize.zero-gr5_ri-lag0.uniform.sim_q |ADDED +optimize.zero-gr5_ri-lr.ann.control_vector |ADDED +optimize.zero-gr5_ri-lr.ann.sim_q |ADDED +optimize.zero-gr5_ri-lr.distributed.control_vector |ADDED +optimize.zero-gr5_ri-lr.distributed.sim_q |ADDED +optimize.zero-gr5_ri-lr.multi-linear.control_vector |ADDED +optimize.zero-gr5_ri-lr.multi-linear.sim_q |ADDED +optimize.zero-gr5_ri-lr.multi-polynomial.control_vector |ADDED +optimize.zero-gr5_ri-lr.multi-polynomial.sim_q |ADDED +optimize.zero-gr5_ri-lr.uniform.control_vector |ADDED +optimize.zero-gr5_ri-lr.uniform.sim_q |ADDED +optimize.zero-gr6-kw.ann.control_vector |NON MODIFIED +optimize.zero-gr6-kw.ann.sim_q |NON MODIFIED optimize.zero-gr6-kw.distributed.control_vector |NON MODIFIED optimize.zero-gr6-kw.distributed.sim_q |NON MODIFIED optimize.zero-gr6-kw.multi-linear.control_vector |NON MODIFIED @@ -851,8 +1017,8 @@ optimize.zero-gr6-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr6-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr6-kw.uniform.control_vector |NON MODIFIED optimize.zero-gr6-kw.uniform.sim_q |NON MODIFIED -optimize.zero-gr6-lag0.ann.control_vector |MODIFIED -optimize.zero-gr6-lag0.ann.sim_q |MODIFIED +optimize.zero-gr6-lag0.ann.control_vector |NON MODIFIED +optimize.zero-gr6-lag0.ann.sim_q |NON MODIFIED optimize.zero-gr6-lag0.distributed.control_vector |NON MODIFIED optimize.zero-gr6-lag0.distributed.sim_q |NON MODIFIED optimize.zero-gr6-lag0.multi-linear.control_vector |NON MODIFIED @@ -861,8 +1027,8 @@ optimize.zero-gr6-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr6-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr6-lag0.uniform.control_vector |NON MODIFIED optimize.zero-gr6-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-gr6-lr.ann.control_vector |MODIFIED -optimize.zero-gr6-lr.ann.sim_q |MODIFIED +optimize.zero-gr6-lr.ann.control_vector |NON MODIFIED +optimize.zero-gr6-lr.ann.sim_q |NON MODIFIED optimize.zero-gr6-lr.distributed.control_vector |NON MODIFIED optimize.zero-gr6-lr.distributed.sim_q |NON MODIFIED optimize.zero-gr6-lr.multi-linear.control_vector |NON MODIFIED @@ -871,8 +1037,8 @@ optimize.zero-gr6-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-gr6-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-gr6-lr.uniform.control_vector |NON MODIFIED optimize.zero-gr6-lr.uniform.sim_q |NON MODIFIED -optimize.zero-grc-kw.ann.control_vector |MODIFIED -optimize.zero-grc-kw.ann.sim_q |MODIFIED +optimize.zero-grc-kw.ann.control_vector |NON MODIFIED +optimize.zero-grc-kw.ann.sim_q |NON MODIFIED optimize.zero-grc-kw.distributed.control_vector |NON MODIFIED optimize.zero-grc-kw.distributed.sim_q |NON MODIFIED optimize.zero-grc-kw.multi-linear.control_vector |NON MODIFIED @@ -881,8 +1047,8 @@ optimize.zero-grc-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-grc-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-grc-kw.uniform.control_vector |NON MODIFIED optimize.zero-grc-kw.uniform.sim_q |NON MODIFIED -optimize.zero-grc-lag0.ann.control_vector |MODIFIED -optimize.zero-grc-lag0.ann.sim_q |MODIFIED +optimize.zero-grc-lag0.ann.control_vector |NON MODIFIED +optimize.zero-grc-lag0.ann.sim_q |NON MODIFIED optimize.zero-grc-lag0.distributed.control_vector |NON MODIFIED optimize.zero-grc-lag0.distributed.sim_q |NON MODIFIED optimize.zero-grc-lag0.multi-linear.control_vector |NON MODIFIED @@ -891,8 +1057,8 @@ optimize.zero-grc-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-grc-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-grc-lag0.uniform.control_vector |NON MODIFIED optimize.zero-grc-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-grc-lr.ann.control_vector |MODIFIED -optimize.zero-grc-lr.ann.sim_q |MODIFIED +optimize.zero-grc-lr.ann.control_vector |NON MODIFIED +optimize.zero-grc-lr.ann.sim_q |NON MODIFIED optimize.zero-grc-lr.distributed.control_vector |NON MODIFIED optimize.zero-grc-lr.distributed.sim_q |NON MODIFIED optimize.zero-grc-lr.multi-linear.control_vector |NON MODIFIED @@ -901,8 +1067,8 @@ optimize.zero-grc-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-grc-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-grc-lr.uniform.control_vector |NON MODIFIED optimize.zero-grc-lr.uniform.sim_q |NON MODIFIED -optimize.zero-grd-kw.ann.control_vector |MODIFIED -optimize.zero-grd-kw.ann.sim_q |MODIFIED +optimize.zero-grd-kw.ann.control_vector |NON MODIFIED +optimize.zero-grd-kw.ann.sim_q |NON MODIFIED optimize.zero-grd-kw.distributed.control_vector |NON MODIFIED optimize.zero-grd-kw.distributed.sim_q |NON MODIFIED optimize.zero-grd-kw.multi-linear.control_vector |NON MODIFIED @@ -911,8 +1077,8 @@ optimize.zero-grd-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-grd-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-grd-kw.uniform.control_vector |NON MODIFIED optimize.zero-grd-kw.uniform.sim_q |NON MODIFIED -optimize.zero-grd-lag0.ann.control_vector |MODIFIED -optimize.zero-grd-lag0.ann.sim_q |MODIFIED +optimize.zero-grd-lag0.ann.control_vector |NON MODIFIED +optimize.zero-grd-lag0.ann.sim_q |NON MODIFIED optimize.zero-grd-lag0.distributed.control_vector |NON MODIFIED optimize.zero-grd-lag0.distributed.sim_q |NON MODIFIED optimize.zero-grd-lag0.multi-linear.control_vector |NON MODIFIED @@ -921,8 +1087,8 @@ optimize.zero-grd-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-grd-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-grd-lag0.uniform.control_vector |NON MODIFIED optimize.zero-grd-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-grd-lr.ann.control_vector |MODIFIED -optimize.zero-grd-lr.ann.sim_q |MODIFIED +optimize.zero-grd-lr.ann.control_vector |NON MODIFIED +optimize.zero-grd-lr.ann.sim_q |NON MODIFIED optimize.zero-grd-lr.distributed.control_vector |NON MODIFIED optimize.zero-grd-lr.distributed.sim_q |NON MODIFIED optimize.zero-grd-lr.multi-linear.control_vector |NON MODIFIED @@ -931,8 +1097,8 @@ optimize.zero-grd-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-grd-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-grd-lr.uniform.control_vector |NON MODIFIED optimize.zero-grd-lr.uniform.sim_q |NON MODIFIED -optimize.zero-loieau-kw.ann.control_vector |MODIFIED -optimize.zero-loieau-kw.ann.sim_q |MODIFIED +optimize.zero-loieau-kw.ann.control_vector |NON MODIFIED +optimize.zero-loieau-kw.ann.sim_q |NON MODIFIED optimize.zero-loieau-kw.distributed.control_vector |NON MODIFIED optimize.zero-loieau-kw.distributed.sim_q |NON MODIFIED optimize.zero-loieau-kw.multi-linear.control_vector |NON MODIFIED @@ -941,8 +1107,8 @@ optimize.zero-loieau-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-loieau-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-loieau-kw.uniform.control_vector |NON MODIFIED optimize.zero-loieau-kw.uniform.sim_q |NON MODIFIED -optimize.zero-loieau-lag0.ann.control_vector |MODIFIED -optimize.zero-loieau-lag0.ann.sim_q |MODIFIED +optimize.zero-loieau-lag0.ann.control_vector |NON MODIFIED +optimize.zero-loieau-lag0.ann.sim_q |NON MODIFIED optimize.zero-loieau-lag0.distributed.control_vector |NON MODIFIED optimize.zero-loieau-lag0.distributed.sim_q |NON MODIFIED optimize.zero-loieau-lag0.multi-linear.control_vector |NON MODIFIED @@ -951,8 +1117,8 @@ optimize.zero-loieau-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-loieau-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-loieau-lag0.uniform.control_vector |NON MODIFIED optimize.zero-loieau-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-loieau-lr.ann.control_vector |MODIFIED -optimize.zero-loieau-lr.ann.sim_q |MODIFIED +optimize.zero-loieau-lr.ann.control_vector |NON MODIFIED +optimize.zero-loieau-lr.ann.sim_q |NON MODIFIED optimize.zero-loieau-lr.distributed.control_vector |NON MODIFIED optimize.zero-loieau-lr.distributed.sim_q |NON MODIFIED optimize.zero-loieau-lr.multi-linear.control_vector |NON MODIFIED @@ -961,8 +1127,8 @@ optimize.zero-loieau-lr.multi-polynomial.control_vector |NON MODIFIED optimize.zero-loieau-lr.multi-polynomial.sim_q |NON MODIFIED optimize.zero-loieau-lr.uniform.control_vector |NON MODIFIED optimize.zero-loieau-lr.uniform.sim_q |NON MODIFIED -optimize.zero-vic3l-kw.ann.control_vector |MODIFIED -optimize.zero-vic3l-kw.ann.sim_q |MODIFIED +optimize.zero-vic3l-kw.ann.control_vector |NON MODIFIED +optimize.zero-vic3l-kw.ann.sim_q |NON MODIFIED optimize.zero-vic3l-kw.distributed.control_vector |NON MODIFIED optimize.zero-vic3l-kw.distributed.sim_q |NON MODIFIED optimize.zero-vic3l-kw.multi-linear.control_vector |NON MODIFIED @@ -971,8 +1137,8 @@ optimize.zero-vic3l-kw.multi-polynomial.control_vector |NON MODIFIED optimize.zero-vic3l-kw.multi-polynomial.sim_q |NON MODIFIED optimize.zero-vic3l-kw.uniform.control_vector |NON MODIFIED optimize.zero-vic3l-kw.uniform.sim_q |NON MODIFIED -optimize.zero-vic3l-lag0.ann.control_vector |MODIFIED -optimize.zero-vic3l-lag0.ann.sim_q |MODIFIED +optimize.zero-vic3l-lag0.ann.control_vector |NON MODIFIED +optimize.zero-vic3l-lag0.ann.sim_q |NON MODIFIED optimize.zero-vic3l-lag0.distributed.control_vector |NON MODIFIED optimize.zero-vic3l-lag0.distributed.sim_q |NON MODIFIED optimize.zero-vic3l-lag0.multi-linear.control_vector |NON MODIFIED @@ -981,8 +1147,8 @@ optimize.zero-vic3l-lag0.multi-polynomial.control_vector |NON MODIFIED optimize.zero-vic3l-lag0.multi-polynomial.sim_q |NON MODIFIED optimize.zero-vic3l-lag0.uniform.control_vector |NON MODIFIED optimize.zero-vic3l-lag0.uniform.sim_q |NON MODIFIED -optimize.zero-vic3l-lr.ann.control_vector |MODIFIED -optimize.zero-vic3l-lr.ann.sim_q |MODIFIED +optimize.zero-vic3l-lr.ann.control_vector |NON MODIFIED +optimize.zero-vic3l-lr.ann.sim_q |NON MODIFIED optimize.zero-vic3l-lr.distributed.control_vector |NON MODIFIED optimize.zero-vic3l-lr.distributed.sim_q |NON MODIFIED optimize.zero-vic3l-lr.multi-linear.control_vector |NON MODIFIED diff --git a/smash/tests/test_constant.py b/smash/tests/test_constant.py index 9d50ae98..f2d9cad5 100644 --- a/smash/tests/test_constant.py +++ b/smash/tests/test_constant.py @@ -51,10 +51,12 @@ def test_module_name(): # % Check hydrological module assert HYDROLOGICAL_MODULE == [ "gr4", + "gr4_ri", "gr4_mlp", "gr4_ode", "gr4_ode_mlp", "gr5", + "gr5_ri", "gr6", "grc", "grd", @@ -88,10 +90,12 @@ def test_module_parameters(): # % Check hydrological module rr parameters assert list(HYDROLOGICAL_MODULE_RR_PARAMETERS.values()) == [ ["ci", "cp", "ct", "kexc"], # % gr4 + ["ci", "cp", "ct", "alpha1", "alpha2", "kexc"], # % gr4_ri ["ci", "cp", "ct", "kexc"], # % gr4_mlp ["ci", "cp", "ct", "kexc"], # % gr4_ode ["ci", "cp", "ct", "kexc"], # % gr4_ode_mlp ["ci", "cp", "ct", "kexc", "aexc"], # % gr5 + ["ci", "cp", "ct", "alpha1", "alpha2", "kexc", "aexc"], # % gr5_ri ["ci", "cp", "ct", "be", "kexc", "aexc"], # % gr6 ["ci", "cp", "ct", "cl", "kexc"], # % grc ["cp", "ct"], # % grd @@ -102,10 +106,12 @@ def test_module_parameters(): # % Check hydrological module rr states assert list(HYDROLOGICAL_MODULE_RR_STATES.values()) == [ ["hi", "hp", "ht"], # % gr4 + ["hi", "hp", "ht"], # % gr4_ri ["hi", "hp", "ht"], # % gr4_mlp ["hi", "hp", "ht"], # % gr4_ode ["hi", "hp", "ht"], # % gr4_ode_mlp ["hi", "hp", "ht"], # % gr5 + ["hi", "hp", "ht"], # % gr5_ri ["hi", "hp", "ht", "he"], # % gr6 ["hi", "hp", "ht", "hl"], # % grc ["hp", "ht"], # % grd @@ -116,10 +122,12 @@ def test_module_parameters(): # % Check hydrological module rr internal fluxes assert list(HYDROLOGICAL_MODULE_RR_INTERNAL_FLUXES.values()) == [ ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr4 + ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr4-ri ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr4_mlp ["pn", "en", "lexc", "qt"], # % gr4_ode ["pn", "en", "lexc", "qt"], # % gr4_ode_mlp ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr5 + ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "qr", "qd", "qt"], # % gr5-ri ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "pre", "qr", "qd", "qe", "qt"], # % gr6 ["pn", "en", "pr", "perc", "lexc", "prr", "prd", "prl", "qr", "qd", "ql", "qt"], # % grc ["ei", "pn", "en", "pr", "perc", "prr", "qr", "qt"], # % grd @@ -146,6 +154,8 @@ def test_parameters(): "ci", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc) "cp", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc, grd) "ct", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc, grd) + "alpha1", # % (gr4_ri, gr5_ri) + "alpha2", # % (gr4_ri, gr5_ri) "cl", # % grc "be", # % gr6 "kexc", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6) @@ -170,9 +180,9 @@ def test_parameters(): # % Check rainfall-runoff states assert RR_STATES == [ "hs", # % ssn - "hi", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc) - "hp", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc, grd) - "ht", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr6, grc, grd) + "hi", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, gr6, grc) + "hp", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, gr6, grc, grd) + "ht", # % (gr4, gr4_mlp, gr4_ode, gr4_ode_mlp, gr5, gr5_ri, gr6, grc, grd) "hl", # % grc "he", # % gr6 "ha", # % loieau @@ -232,6 +242,8 @@ def test_feasible_domain(): (0, np.inf), # % ci (0, np.inf), # % cp (0, np.inf), # % ct + (0, np.inf), # % alpha1 + (0, np.inf), # % alpha2 (0, np.inf), # % cl (0, np.inf), # % be (-np.inf, np.inf), # % kexc @@ -291,6 +303,8 @@ def test_default_parameters(): 1e-6, # % ci 200, # % cp 500, # % ct + 3e-4, # % alpha1 + 1e-3, # % alpha2 500, # % cl 10, # % be 0, # % kexc @@ -350,6 +364,8 @@ def test_default_bounds_parameters(): (1e-6, 1e2), # % ci (1e-6, 1e3), # % cp (1e-6, 1e3), # % ct + (1e-6, 5e-4), # % alpha1 + (1e-5, 1.0), # % alpha2 (1e-6, 1e3), # % cl (1e-3, 20), # % be (-50, 50), # % kexc