!        Generated by TAPENADE     (INRIA, Ecuador team)
!  tapenade 3.x
!
!  Differentiation of forward_compute in forward (tangent) mode:
!   variations   of useful results: *d *e *f *concold *g *temp
!                *w *headold *x *sdata *head *dbc_data *bcperiod
!                *tempold *propunit *presold *conc *pres *a *b
!                *c doutput
!   with respect to varying inputs: *d *e *f *concold *g *temp
!                *w *headold *x *sdata *head *dbc_data *bcperiod
!                *tempold *propunit *presold *conc *pres *a *b
!                *c dinput
!   RW status of diff variables: *d:in-out *e:in-out *f:in-out
!                *concold:in-out *g:in-out *temp:in-out *w:in-out
!                *headold:in-out *x:in-out *sdata:in-out *head:in-out
!                *dbc_data:in-out *bcperiod:in-out *tempold:in-out
!                *propunit:in-out *tsal:(loc) *presold:in-out *conc:in-out
!                *pres:in-out *a:in-out *b:in-out *c:in-out doutput:out
!                dinput:in (global)thetaf:(loc) (global)thetat:(loc)
!   Plus diff mem management of: d:in e:in f:in concold:in g:in
!                temp:in w:in headold:in x:in sdata:in head:in
!                dbc_data:in bcperiod:in tempold:in propunit:in
!                tsal:in presold:in conc:in pres:in simtime:in
!                a:in b:in c:in
! MIT License
!
! Copyright (c) 2020 SHEMAT-Suite
!
! Permission is hereby granted, free of charge, to any person obtaining a copy
! of this software and associated documentation files (the "Software"), to deal
! in the Software without restriction, including without limitation the rights
! to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
! copies of the Software, and to permit persons to whom the Software is
! furnished to do so, subject to the following conditions:
!
! The above copyright notice and this permission notice shall be included in all
! copies or substantial portions of the Software.
!
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
! SOFTWARE.
!>    @brief dependency wrapper (parameter -> simulation) useful for INVERSE and SIMUL
!>    @param[in] dinput parameter vector for initial setup (dependency vector)
!>    @param[out] doutput simulated/computed data/result values
!>    @param[in] simtime_run start time of the simulation
!>    @param[in] simtime_end finish time of the simulation
!>    @param[in] iter_out inverse iteration, SM realisation
!>    @param[in] iseed 0: FW simulation, 1 .. <mpara>: AD seeding index
!>    @param[in] ismpl local sample index
SUBROUTINE g_FORWARD_COMPUTE(dinput, g_dinput, doutput, g_doutput&
& , simtime_run, simtime_end, iter_out, iseed, ismpl)
  USE ARRAYS

  USE g_ARRAYS

  USE MOD_DATA
  USE MOD_GENRL
  IMPLICIT NONE
  INTEGER :: ismpl
  INTEGER :: i
!       input vector
  DOUBLE PRECISION :: dinput(mpara)
  DOUBLE PRECISION :: g_dinput(mpara)
!       output vector
  DOUBLE PRECISION :: doutput(ndata)
  DOUBLE PRECISION :: g_doutput(ndata)
  DOUBLE PRECISION :: trun, tend
!       parameter declaration
  INTEGER :: iter_out, iseed
  DOUBLE PRECISION :: simtime_run, simtime_end
  EXTERNAL DUMMY
!       benchmark time meassurment stuff
#ifdef BENCH
#endif
!
#ifdef  BENCH
  CALL SYS_CPUTIME(trun)
#endif
!
!       dependency setup of the parameters
  DO i=1,mpara
    CALL g_SET_OPTIP(i, dinput(i), g_dinput(i), ismpl)
  END DO
!       run forward iteration
  CALL g_FORWARD_ITER(simtime_run, simtime_end, iter_out, iseed, ismpl&
&                )
!       copy result values
  g_doutput = 0.D0
  CALL g_DCOPY(ndata, sdata(1, ismpl), g_sdata(1, ismpl), 1, doutput&
&          , g_doutput, 1)
!
!
#ifdef  BENCH
  CALL SYS_CPUTIME(tend)
  WRITE(*, '(1A,I7,1A,F9.2,1A,2F20.2)') '  [T] : component =', iseed, &
& ', time =', tend - trun, ' sec, [run] [end]:', trun, tend
#endif
!
  RETURN
END SUBROUTINE g_FORWARD_COMPUTE

