text: /* Created by Language version: 6.2.0 */
  /* NOT VECTORIZED */
  #include <stdio.h>
  #include <stdlib.h>
  #include <math.h>
  #include "scoplib_ansi.h"
  #undef PI
  #define nil 0
  #include "md1redef.h"
  #include "section.h"
  #include "nrniv_mf.h"
  #include "md2redef.h"
   
  #if METHOD3
  extern int _method3;
  #endif
  
  #if !NRNGPU
  #undef exp
  #define exp hoc_Exp
  extern double hoc_Exp(double);
  #endif
   
  #define _threadargscomma_ /**/
  #define _threadargs_ /**/
   
  #define _threadargsprotocomma_ /**/
  #define _threadargsproto_ /**/
   	/*SUPPRESS 761*/
  	/*SUPPRESS 762*/
  	/*SUPPRESS 763*/
  	/*SUPPRESS 765*/
  	 extern double *getarg();
   static double *_p; static Datum *_ppvar;
   
  #define t nrn_threads->_t
  #define dt nrn_threads->_dt
  #define gnabar _p[0]
  #define gkbar _p[1]
  #define vtraub _p[2]
  #define m_inf _p[3]
  #define h_inf _p[4]
  #define n_inf _p[5]
  #define tau_m _p[6]
  #define tau_h _p[7]
  #define tau_n _p[8]
  #define m_exp _p[9]
  #define h_exp _p[10]
  #define n_exp _p[11]
  #define m _p[12]
  #define h _p[13]
  #define n _p[14]
  #define ena _p[15]
  #define ek _p[16]
  #define Dm _p[17]
  #define Dh _p[18]
  #define Dn _p[19]
  #define ina _p[20]
  #define ik _p[21]
  #define il _p[22]
  #define tadj _p[23]
  #define _g _p[24]
  #define _ion_ena	*_ppvar[0]._pval
  #define _ion_ina	*_ppvar[1]._pval
  #define _ion_dinadv	*_ppvar[2]._pval
  #define _ion_ek	*_ppvar[3]._pval
  #define _ion_ik	*_ppvar[4]._pval
  #define _ion_dikdv	*_ppvar[5]._pval
   
  #if MAC
  #if !defined(v)
  #define v _mlhv
  #endif
  #if !defined(h)
  #define h _mlhh
  #endif
  #endif
   
  #if defined(__cplusplus)
  extern "C" {
  #endif
   static int hoc_nrnpointerindex =  -1;
   /* external NEURON variables */
   extern double celsius;
   /* declaration of user functions */
   static void _hoc_Exp(void);
   static void _hoc_evaluate_fct(void);
   static void _hoc_states(void);
   static void _hoc_vtrap(void);
   static int _mechtype;
  extern void _nrn_cacheloop_reg(int, int);
  extern void hoc_register_prop_size(int, int, int);
  extern void hoc_register_limits(int, HocParmLimits*);
  extern void hoc_register_units(int, HocParmUnits*);
  extern void nrn_promote(Prop*, int, int);
  extern Memb_func* memb_func;
   extern void _nrn_setdata_reg(int, void(*)(Prop*));
   static void _setdata(Prop* _prop) {
   _p = _prop->param; _ppvar = _prop->dparam;
   }
   static void _hoc_setdata() {
   Prop *_prop, *hoc_getdata_range(int);
   _prop = hoc_getdata_range(_mechtype);
     _setdata(_prop);
   hoc_retpushx(1.);
  }
   /* connect user functions to hoc names */
   static VoidFunc hoc_intfunc[] = {
   "setdata_hh2", _hoc_setdata,
   "Exp_hh2", _hoc_Exp,
   "evaluate_fct_hh2", _hoc_evaluate_fct,
   "states_hh2", _hoc_states,
   "vtrap_hh2", _hoc_vtrap,
   0, 0
  };
  #define Exp Exp_hh2
  #define vtrap vtrap_hh2
   extern double Exp( double );
   extern double vtrap( double , double );
   /* declare global and static user variables */
   /* some parameters have upper and lower limits */
   static HocParmLimits _hoc_parm_limits[] = {
   0,0,0
  };
   static HocParmUnits _hoc_parm_units[] = {
   "gnabar_hh2", "mho/cm2",
   "gkbar_hh2", "mho/cm2",
   "vtraub_hh2", "mV",
   0,0
  };
   static double delta_t = 1;
   static double h0 = 0;
   static double m0 = 0;
   static double n0 = 0;
   static double v = 0;
   /* connect global user variables to hoc */
   static DoubScal hoc_scdoub[] = {
   0,0
  };
   static DoubVec hoc_vdoub[] = {
   0,0,0
  };
   static double _sav_indep;
   static void nrn_alloc(Prop*);
  static void  nrn_init(_NrnThread*, _Memb_list*, int);
  static void nrn_state(_NrnThread*, _Memb_list*, int);
   static void nrn_cur(_NrnThread*, _Memb_list*, int);
  static void  nrn_jacob(_NrnThread*, _Memb_list*, int);
   
  static int _ode_count(int);
   /* connect range variables in _p that hoc is supposed to know about */
   static const char *_mechanism[] = {
   "6.2.0",
  "hh2",
   "gnabar_hh2",
   "gkbar_hh2",
   "vtraub_hh2",
   0,
   "m_inf_hh2",
   "h_inf_hh2",
   "n_inf_hh2",
   "tau_m_hh2",
   "tau_h_hh2",
   "tau_n_hh2",
   "m_exp_hh2",
   "h_exp_hh2",
   "n_exp_hh2",
   0,
   "m_hh2",
   "h_hh2",
   "n_hh2",
   0,
   0};
   static Symbol* _na_sym;
   static Symbol* _k_sym;
   
  extern Prop* need_memb(Symbol*);
  
  static void nrn_alloc(Prop* _prop) {
  	Prop *prop_ion;
  	double *_p; Datum *_ppvar;
   	_p = nrn_prop_data_alloc(_mechtype, 25, _prop);
   	/*initialize range parameters*/
   	gnabar = 0.003;
   	gkbar = 0.005;
   	vtraub = -63;
   	_prop->param = _p;
   	_prop->param_size = 25;
   	_ppvar = nrn_prop_datum_alloc(_mechtype, 6, _prop);
   	_prop->dparam = _ppvar;
   	/*connect ionic variables to this model*/
   prop_ion = need_memb(_na_sym);
   nrn_promote(prop_ion, 0, 1);
   	_ppvar[0]._pval = &prop_ion->param[0]; /* ena */
   	_ppvar[1]._pval = &prop_ion->param[3]; /* ina */
   	_ppvar[2]._pval = &prop_ion->param[4]; /* _ion_dinadv */
   prop_ion = need_memb(_k_sym);
   nrn_promote(prop_ion, 0, 1);
   	_ppvar[3]._pval = &prop_ion->param[0]; /* ek */
   	_ppvar[4]._pval = &prop_ion->param[3]; /* ik */
   	_ppvar[5]._pval = &prop_ion->param[4]; /* _ion_dikdv */
   
  }
   static void _initlists();
   static void _update_ion_pointer(Datum*);
   extern Symbol* hoc_lookup(const char*);
  extern void _nrn_thread_reg(int, int, void(*f)(Datum*));
  extern void _nrn_thread_table_reg(int, void(*)(double*, Datum*, Datum*, _NrnThread*, int));
  extern void hoc_register_tolerance(int, HocStateTolerance*, Symbol***);
  extern void _cvode_abstol( Symbol**, double*, int);
  
   void _HH2_reg() {
  	int _vectorized = 0;
    _initlists();
   	ion_reg("na", -10000.);
   	ion_reg("k", -10000.);
   	_na_sym = hoc_lookup("na_ion");
   	_k_sym = hoc_lookup("k_ion");
   	register_mech(_mechanism, nrn_alloc,nrn_cur, nrn_jacob, nrn_state, nrn_init, hoc_nrnpointerindex, 0);
   _mechtype = nrn_get_mechtype(_mechanism[1]);
       _nrn_setdata_reg(_mechtype, _setdata);
       _nrn_thread_reg(_mechtype, 2, _update_ion_pointer);
    hoc_register_prop_size(_mechtype, 25, 6);
   	hoc_register_cvode(_mechtype, _ode_count, 0, 0, 0);
   	hoc_register_var(hoc_scdoub, hoc_vdoub, hoc_intfunc);
   	ivoc_help("help ?1 hh2 /home/heberto/Downloads/Branco_2010/x86_64/HH2.mod\n");
   hoc_register_limits(_mechtype, _hoc_parm_limits);
   hoc_register_units(_mechtype, _hoc_parm_units);
   }
  static int _reset;
  static char *modelname = "Hippocampal HH channels";
  
  static int error;
  static int _ninits = 0;
  static int _match_recurse=1;
  static void _modl_cleanup(){ _match_recurse=1;}
  static int evaluate_fct(double);
  static int states();
   
  static int  states (  ) {
     evaluate_fct ( _threadargscomma_ v ) ;
     m = m + m_exp * ( m_inf - m ) ;
     h = h + h_exp * ( h_inf - h ) ;
     n = n + n_exp * ( n_inf - n ) ;
     
  /*VERBATIM*/
  	return 0;
    return 0; }
   
  static void _hoc_states(void) {
    double _r;
     _r = 1.;
   states (  );
   hoc_retpushx(_r);
  }
   
  static int  evaluate_fct (  double _lv ) {
     double _la , _lb , _lv2 ;
   _lv2 = _lv - vtraub ;
     _la = 0.32 * vtrap ( _threadargscomma_ 13.0 - _lv2 , 4.0 ) ;
     _lb = 0.28 * vtrap ( _threadargscomma_ _lv2 - 40.0 , 5.0 ) ;
     tau_m = 1.0 / ( _la + _lb ) / tadj ;
     m_inf = _la / ( _la + _lb ) ;
     _la = 0.128 * Exp ( _threadargscomma_ ( 17.0 - _lv2 ) / 18.0 ) ;
     _lb = 4.0 / ( 1.0 + Exp ( _threadargscomma_ ( 40.0 - _lv2 ) / 5.0 ) ) ;
     tau_h = 1.0 / ( _la + _lb ) / tadj ;
     h_inf = _la / ( _la + _lb ) ;
     _la = 0.032 * vtrap ( _threadargscomma_ 15.0 - _lv2 , 5.0 ) ;
     _lb = 0.5 * Exp ( _threadargscomma_ ( 10.0 - _lv2 ) / 40.0 ) ;
     tau_n = 1.0 / ( _la + _lb ) / tadj ;
     n_inf = _la / ( _la + _lb ) ;
     m_exp = 1.0 - Exp ( _threadargscomma_ - dt / tau_m ) ;
     h_exp = 1.0 - Exp ( _threadargscomma_ - dt / tau_h ) ;
     n_exp = 1.0 - Exp ( _threadargscomma_ - dt / tau_n ) ;
      return 0; }
   
  static void _hoc_evaluate_fct(void) {
    double _r;
     _r = 1.;
   evaluate_fct (  *getarg(1) );
   hoc_retpushx(_r);
  }
   
  double vtrap (  double _lx , double _ly ) {
     double _lvtrap;
   if ( fabs ( _lx / _ly ) < 1e-6 ) {
       _lvtrap = _ly * ( 1.0 - _lx / _ly / 2.0 ) ;
       }
     else {
       _lvtrap = _lx / ( Exp ( _threadargscomma_ _lx / _ly ) - 1.0 ) ;
       }
     
  return _lvtrap;
   }
   
  static void _hoc_vtrap(void) {
    double _r;
     _r =  vtrap (  *getarg(1) , *getarg(2) );
   hoc_retpushx(_r);
  }
   
  double Exp (  double _lx ) {
     double _lExp;
   if ( _lx < - 100.0 ) {
       _lExp = 0.0 ;
       }
     else {
       _lExp = exp ( _lx ) ;
       }
     
  return _lExp;
   }
   
  static void _hoc_Exp(void) {
    double _r;
     _r =  Exp (  *getarg(1) );
   hoc_retpushx(_r);
  }
   
  static int _ode_count(int _type){ hoc_execerror("hh2", "cannot be used with CVODE"); return 0;}
   extern void nrn_update_ion_pointer(Symbol*, Datum*, int, int);
   static void _update_ion_pointer(Datum* _ppvar) {
     nrn_update_ion_pointer(_na_sym, _ppvar, 0, 0);
     nrn_update_ion_pointer(_na_sym, _ppvar, 1, 3);
     nrn_update_ion_pointer(_na_sym, _ppvar, 2, 4);
     nrn_update_ion_pointer(_k_sym, _ppvar, 3, 0);
     nrn_update_ion_pointer(_k_sym, _ppvar, 4, 3);
     nrn_update_ion_pointer(_k_sym, _ppvar, 5, 4);
   }
  
  static void initmodel() {
    int _i; double _save;_ninits++;
   _save = t;
   t = 0.0;
  {
    h = h0;
    m = m0;
    n = n0;
   {
     tadj = pow( 3.0 , ( ( celsius - 36.0 ) / 10.0 ) ) ;
     m = 0.0 ;
     h = 0.0 ;
     n = 0.0 ;
     }
    _sav_indep = t; t = _save;
  
  }
  }
  
  static void nrn_init(_NrnThread* _nt, _Memb_list* _ml, int _type){
  Node *_nd; double _v; int* _ni; int _iml, _cntml;
  #if CACHEVEC
      _ni = _ml->_nodeindices;
  #endif
  _cntml = _ml->_nodecount;
  for (_iml = 0; _iml < _cntml; ++_iml) {
   _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
  #if CACHEVEC
    if (use_cachevec) {
      _v = VEC_V(_ni[_iml]);
    }else
  #endif
    {
      _nd = _ml->_nodelist[_iml];
      _v = NODEV(_nd);
    }
   v = _v;
    ena = _ion_ena;
    ek = _ion_ek;
   initmodel();
    }}
  
  static double _nrn_current(double _v){double _current=0.;v=_v;{ {
     ina = gnabar * m * m * m * h * ( v - ena ) ;
     ik = gkbar * n * n * n * n * ( v - ek ) ;
     }
   _current += ina;
   _current += ik;
  
  } return _current;
  }
  
  static void nrn_cur(_NrnThread* _nt, _Memb_list* _ml, int _type){
  Node *_nd; int* _ni; double _rhs, _v; int _iml, _cntml;
  #if CACHEVEC
      _ni = _ml->_nodeindices;
  #endif
  _cntml = _ml->_nodecount;
  for (_iml = 0; _iml < _cntml; ++_iml) {
   _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
  #if CACHEVEC
    if (use_cachevec) {
      _v = VEC_V(_ni[_iml]);
    }else
  #endif
    {
      _nd = _ml->_nodelist[_iml];
      _v = NODEV(_nd);
    }
    ena = _ion_ena;
    ek = _ion_ek;
   _g = _nrn_current(_v + .001);
   	{ double _dik;
   double _dina;
    _dina = ina;
    _dik = ik;
   _rhs = _nrn_current(_v);
    _ion_dinadv += (_dina - ina)/.001 ;
    _ion_dikdv += (_dik - ik)/.001 ;
   	}
   _g = (_g - _rhs)/.001;
    _ion_ina += ina ;
    _ion_ik += ik ;
  #if CACHEVEC
    if (use_cachevec) {
  	VEC_RHS(_ni[_iml]) -= _rhs;
    }else
  #endif
    {
  	NODERHS(_nd) -= _rhs;
    }
   
  }}
  
  static void nrn_jacob(_NrnThread* _nt, _Memb_list* _ml, int _type){
  Node *_nd; int* _ni; int _iml, _cntml;
  #if CACHEVEC
      _ni = _ml->_nodeindices;
  #endif
  _cntml = _ml->_nodecount;
  for (_iml = 0; _iml < _cntml; ++_iml) {
   _p = _ml->_data[_iml];
  #if CACHEVEC
    if (use_cachevec) {
  	VEC_D(_ni[_iml]) += _g;
    }else
  #endif
    {
       _nd = _ml->_nodelist[_iml];
  	NODED(_nd) += _g;
    }
   
  }}
  
  static void nrn_state(_NrnThread* _nt, _Memb_list* _ml, int _type){
   double _break, _save;
  Node *_nd; double _v; int* _ni; int _iml, _cntml;
  #if CACHEVEC
      _ni = _ml->_nodeindices;
  #endif
  _cntml = _ml->_nodecount;
  for (_iml = 0; _iml < _cntml; ++_iml) {
   _p = _ml->_data[_iml]; _ppvar = _ml->_pdata[_iml];
   _nd = _ml->_nodelist[_iml];
  #if CACHEVEC
    if (use_cachevec) {
      _v = VEC_V(_ni[_iml]);
    }else
  #endif
    {
      _nd = _ml->_nodelist[_iml];
      _v = NODEV(_nd);
    }
   _break = t + .5*dt; _save = t;
   v=_v;
  {
    ena = _ion_ena;
    ek = _ion_ek;
   { {
   for (; t < _break; t += dt) {
   error =  states();
   if(error){fprintf(stderr,"at line 68 in file HH2.mod:\n	SOLVE states\n"); nrn_complain(_p); abort_run(error);}
   
  }}
   t = _save;
   }  }}
  
  }
  
  static void terminal(){}
  
  static void _initlists() {
   int _i; static int _first = 1;
    if (!_first) return;
  _first = 0;
  }
  