! written by nbigen.py
! *** do not edit *** (use nbigen.py instead)
 
subroutine nbi_set_dims(zdims,ierr)
 
  ! retrieve user settable dimensions.
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_dims), intent(in) :: zdims
  integer, intent(out) :: ierr
 
  ierr=0
  if(nbidim_init) then
    write(nonlin,*) '?nbi_set_dims: dimensions already set.'
    ierr=1
    return
  else
    nbidim_init = .TRUE.
  endif
 
  mib = max(2, zdims%mib )
  if(mib.gt.320) then
    write(nonlin,*) "?nbi_set_dims: mib max allowed value is 320."
    ierr = ierr + 1
  endif
  mj = max(2, zdims%mj )
  mig = max(2, zdims%mig )
  if(mig.gt.10) then
    write(nonlin,*) "?nbi_set_dims: mig max allowed value is 10."
    ierr = ierr + 1
  endif
  mis = max(2, zdims%mis )
  if(mis.gt.50) then
    write(nonlin,*) "?nbi_set_dims: mis max allowed value is 50."
    ierr = ierr + 1
  endif
  mibs = max(2, zdims%mibs )
  if(mibs.gt.15) then
    write(nonlin,*) "?nbi_set_dims: mibs max allowed value is 15."
    ierr = ierr + 1
  endif
  mimpt = max(2, zdims%mimpt )
  if(mimpt.gt.300) then
    write(nonlin,*) "?nbi_set_dims: mimpt max allowed value is 300."
    ierr = ierr + 1
  endif
  mmini = max(2, zdims%mmini )
  if(mmini.gt.10) then
    write(nonlin,*) "?nbi_set_dims: mmini max allowed value is 10."
    ierr = ierr + 1
  endif
  mtheta = max(2, zdims%mtheta )
  miefi = max(2, zdims%miefi )
  if(miefi.gt.10) then
    write(nonlin,*) "?nbi_set_dims: miefi max allowed value is 10."
    ierr = ierr + 1
  endif
  med2d = max(2, zdims%med2d )
  mimxba = max(2, zdims%mimxba )
  mimxbe = max(2, zdims%mimxbe )
  mgyro = max(1, zdims%mgyro )
  mimxba0 = max(2, zdims%mimxba0 )
  mimxbe0 = max(2, zdims%mimxbe0 )
  miboxm = max(2, zdims%miboxm )
  if(miboxm.gt.100) then
    write(nonlin,*) "?nbi_set_dims: miboxm max allowed value is 100."
    ierr = ierr + 1
  endif
  mitubem = max(2, zdims%mitubem )
  if(mitubem.gt.200) then
    write(nonlin,*) "?nbi_set_dims: mitubem max allowed value is 200."
    ierr = ierr + 1
  endif
  mituben = max(2, zdims%mituben )
  if(mituben.gt.500) then
    write(nonlin,*) "?nbi_set_dims: mituben max allowed value is 500."
    ierr = ierr + 1
  endif
  if(zdims%mnkaep.gt.0)mnkaep = min(mnkaep, zdims%mnkaep )
  if(mnkaep.gt.10) then
    write(nonlin,*) "?nbi_set_dims: mnkaep max allowed value is 10."
    ierr = ierr + 1
  endif
 
  ! program dimensions derived from user dimensions:
 
  mjeqv = mj
  mjzb = mj
  mjzc = mj
  mtbl = 2*mj
  mjr = 2*mj+5
  mmaxion = 1
  miz = 2
  minbs = 100
  mimaxz = 100
  mireact = 18
  if(mireact.gt.18) then
    write(nonlin,*) "?nbi_set_dims: mireact max allowed value is 18."
    ierr = ierr + 1
  endif
  miplot = 150
  mimxbe1 = mimxbe+1
  nthspl = 51
  nthpmin = 40
  nthpmax = 80
  minspl = 3000
  minbplt = 202
  mtrk = 9*mj
 
end subroutine nbi_set_dims
 
subroutine nbi_set_sys(zblock,ierr)
 
  ! set values for input block: sys
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_sys), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_sys) then
    write(nonlin,*) '?nbi_set_sys: block was already initialized.'
    ierr=1; return
  else
    init_sys = .TRUE.
  endif
 
  runid = zblock%runid
  mission = zblock%mission
  workpath = zblock%workpath
  nonlin = zblock%nonlin
  nseed = zblock%nseed
  nlbout = zblock%nlbout
  lunnbx = zblock%lunnbx
  lunres = zblock%lunres
  mrstrt = zblock%mrstrt
  nclass = zblock%nclass
  only_io = zblock%only_io
  ref_namelist = zblock%ref_namelist
  quasi_check = zblock%quasi_check
  nltest_output = zblock%nltest_output
#ifdef __MPI
    debug_mpi = nltest_output
#else
    debug_mpi = .FALSE.
#endif
  BLK_MPI_BCAST_INT = zblock%BLK_MPI_BCAST_INT
  BLK_MPI_BCAST_R8 = zblock%BLK_MPI_BCAST_R8
 
end subroutine nbi_set_sys
 
subroutine nbi_set_times(zblock,ierr)
 
  ! set values for input block: times
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_times), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_times) then
    write(nonlin,*) '?nbi_set_times: block was already initialized.'
    ierr=1; return
  else
    init_times = .TRUE.
  endif
 
  tbm1 = zblock%tbm1
  tbm2 = zblock%tbm2
 
end subroutine nbi_set_times
 
subroutine nbi_set_grid(zblock,ierr)
 
  ! set values for input block: grid
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_grid), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_grid) then
    write(nonlin,*) '?nbi_set_grid: block was already initialized.'
    ierr=1; return
  else
    init_grid = .TRUE.
  endif
 
  nzones = zblock%nzones
  nzone_fb = zblock%nzone_fb
  nlsym2b = zblock%nlsym2b
  nth0 = zblock%nth0
  xbmbnd = zblock%xbmbnd
  id_mcgrid = zblock%id_mcgrid
  nthets = zblock%nthets
  ebdmax = zblock%ebdmax
  xplasma_in_memory = zblock%xplasma_in_memory
  nznbma = zblock%nznbma
  nznbme = zblock%nznbme
  nznbma0 = zblock%nznbma0
  nznbme0 = zblock%nznbme0
  ngyro = zblock%ngyro
 
end subroutine nbi_set_grid
 
subroutine nbi_add_beams(zblock,ierr)
 
  ! set values for input block: beams
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_beams), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  integer :: iprev,inc
 
  ierr=0
  init_beams = .TRUE.
  inc = zblock%ngmax
  iprev = ngmax
  ngmax = iprev + inc
 
  if (iprev+inc.gt.(mig)) then
    write(nonlin,*) '?nbi_add_beams: maximum length of backz exceeded.'
    write(nonlin,*) ' needed: ',iprev+inc
    write(nonlin,*) ' available: (mig) = ', (mig)
    ierr=1; return
  endif
 
  if (inc.gt.0) then
    backz(iprev+1:iprev+inc) = zblock%backz(1:inc)
  endif
 
  if (inc.gt.0) then
    aplasm(iprev+1:iprev+inc) = zblock%aplasm(1:inc)
  endif
 
  inc = zblock%nbeam
  iprev = nbeam
  nbeam = iprev + inc
 
  if (iprev+inc.gt.(mib)) then
    write(nonlin,*) '?nbi_add_beams: maximum length of xzbeama exceeded.'
    write(nonlin,*) ' needed: ',iprev+inc
    write(nonlin,*) ' available: (mib) = ', (mib)
    ierr=1; return
  endif
 
  if (inc.gt.0) then
    xzbeama(iprev+1:iprev+inc) = zblock%xzbeama(1:inc)
  endif
 
  if (inc.gt.0) then
    abeama(iprev+1:iprev+inc) = zblock%abeama(1:inc)
  endif
 
  if (inc.gt.0) then
    nlco(iprev+1:iprev+inc) = zblock%nlco(1:inc)
  endif
 
  if (inc.gt.0) then
    ntrace(iprev+1:iprev+inc) = zblock%ntrace(1:inc)
  endif
 
  if (inc.gt.0) then
    rtcena(iprev+1:iprev+inc) = zblock%rtcena(1:inc)
  endif
 
  if (inc.gt.0) then
    xlbtna(iprev+1:iprev+inc) = zblock%xlbtna(1:inc)
  endif
 
  if (inc.gt.0) then
    xybsca(iprev+1:iprev+inc) = zblock%xybsca(1:inc)
  endif
 
  if (inc.gt.0) then
    xbzeta(iprev+1:iprev+inc) = zblock%xbzeta(1:inc)
  endif
 
  if (inc.gt.0) then
    nbshapa(iprev+1:iprev+inc) = zblock%nbshapa(1:inc)
  endif
 
  if (inc.gt.0) then
    bmwidra(iprev+1:iprev+inc) = zblock%bmwidra(1:inc)
  endif
 
  if (inc.gt.0) then
    bmwidza(iprev+1:iprev+inc) = zblock%bmwidza(1:inc)
  endif
 
  if (inc.gt.0) then
    divra(iprev+1:iprev+inc) = zblock%divra(1:inc)
  endif
 
  if (inc.gt.0) then
    divza(iprev+1:iprev+inc) = zblock%divza(1:inc)
  endif
 
  if (inc.gt.0) then
    foclra(iprev+1:iprev+inc) = zblock%foclra(1:inc)
  endif
 
  if (inc.gt.0) then
    foclza(iprev+1:iprev+inc) = zblock%foclza(1:inc)
  endif
 
  if (inc.gt.0) then
    nbapsha(iprev+1:iprev+inc) = zblock%nbapsha(1:inc)
  endif
 
  if (inc.gt.0) then
    rapedga(iprev+1:iprev+inc) = zblock%rapedga(1:inc)
  endif
 
  if (inc.gt.0) then
    xzpedga(iprev+1:iprev+inc) = zblock%xzpedga(1:inc)
  endif
 
  if (inc.gt.0) then
    xlbapa(iprev+1:iprev+inc) = zblock%xlbapa(1:inc)
  endif
 
  if (inc.gt.0) then
    xybapa(iprev+1:iprev+inc) = zblock%xybapa(1:inc)
  endif
 
  if (inc.gt.0) then
    xrapoffa(iprev+1:iprev+inc) = zblock%xrapoffa(1:inc)
  endif
 
  if (inc.gt.0) then
    xzapoffa(iprev+1:iprev+inc) = zblock%xzapoffa(1:inc)
  endif
 
  if (inc.gt.0) then
    nbapsh2(iprev+1:iprev+inc) = zblock%nbapsh2(1:inc)
  endif
 
  if (inc.gt.0) then
    rapedg2(iprev+1:iprev+inc) = zblock%rapedg2(1:inc)
  endif
 
  if (inc.gt.0) then
    xzpedg2(iprev+1:iprev+inc) = zblock%xzpedg2(1:inc)
  endif
 
  if (inc.gt.0) then
    xlbapa2(iprev+1:iprev+inc) = zblock%xlbapa2(1:inc)
  endif
 
  if (inc.gt.0) then
    xrapoff2(iprev+1:iprev+inc) = zblock%xrapoff2(1:inc)
  endif
 
  if (inc.gt.0) then
    xzapoff2(iprev+1:iprev+inc) = zblock%xzapoff2(1:inc)
  endif
 
 
end subroutine nbi_add_beams
 
subroutine nbi_add_impurity(zblock,ierr)
 
  ! set values for input block: impurity
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_impurity), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  integer :: iprev,inc
 
  ierr=0
  init_impurity = .TRUE.
  inc = zblock%nrhix
  iprev = nrhix
  nrhix = iprev + inc
 
  if (iprev+inc.gt.(mimpt)) then
    write(nonlin,*) '?nbi_add_impurity: maximum length of xzimpx exceeded.'
    write(nonlin,*) ' needed: ',iprev+inc
    write(nonlin,*) ' available: (mimpt) = ', (mimpt)
    ierr=1; return
  endif
 
  if (inc.gt.0) then
    xzimpx(iprev+1:iprev+inc) = zblock%xzimpx(1:inc)
  endif
 
  if (inc.gt.0) then
    aimpx(iprev+1:iprev+inc) = zblock%aimpx(1:inc)
  endif
 
 
end subroutine nbi_add_impurity
 
subroutine nbi_add_minority(zblock,ierr)
 
  ! set values for input block: minority
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_minority), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  integer :: iprev,inc
 
  ierr=0
  init_minority = .TRUE.
  inc = zblock%nmini
  iprev = nmini
  nmini = iprev + inc
 
  if (iprev+inc.gt.(mmini)) then
    write(nonlin,*) '?nbi_add_minority: maximum length of xzmini exceeded.'
    write(nonlin,*) ' needed: ',iprev+inc
    write(nonlin,*) ' available: (mmini) = ', (mmini)
    ierr=1; return
  endif
 
  if (inc.gt.0) then
    xzmini(iprev+1:iprev+inc) = zblock%xzmini(1:inc)
  endif
 
  if (inc.gt.0) then
    amini(iprev+1:iprev+inc) = zblock%amini(1:inc)
  endif
 
  inc = zblock%nthrf
  iprev = nthrf
  nthrf = iprev + inc
 
 
end subroutine nbi_add_minority
 
subroutine nbi_set_powers(zblock,ierr)
 
  ! set values for input block: powers
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_powers), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_powers) then
    write(nonlin,*) '?nbi_set_powers: block was already initialized.'
    ierr=1; return
  else
    init_powers = .TRUE.
  endif
 
  einjmin(1:nbeam) = zblock%einjmin(1:nbeam)
  einja(1:nbeam) = zblock%einja(1:nbeam)
  pinja(1:nbeam) = zblock%pinja(1:nbeam)
  ffulla(1:nbeam) = zblock%ffulla(1:nbeam)
  fhalfa(1:nbeam) = zblock%fhalfa(1:nbeam)
  orbrzv_toric_Prftot0(1:mibs) = zblock%orbrzv_toric_Prftot0(1:mibs)
  orbrzv_toric_frnm = zblock%orbrzv_toric_frnm
 
end subroutine nbi_set_powers
 
subroutine nbi_set_fusion(zblock,ierr)
 
  ! set values for input block: fusion
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_fusion), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_fusion) then
    write(nonlin,*) '?nbi_set_fusion: block was already initialized.'
    ierr=1; return
  else
    init_fusion = .TRUE.
  endif
 
  nlfhe3 = zblock%nlfhe3
  nlfhe4 = zblock%nlfhe4
  nlfst = zblock%nlfst
  nlfsp = zblock%nlfsp
  nlfsp14 = zblock%nlfsp14
  nlusf3 = zblock%nlusf3
  xdatsf3 = zblock%xdatsf3
  nlusfa = zblock%nlusfa
  xdatsfa = zblock%xdatsfa
  nlusft = zblock%nlusft
  xdatsft = zblock%xdatsft
  nlusfp = zblock%nlusfp
  xdatsfp = zblock%xdatsfp
  nlusfp14 = zblock%nlusfp14
  xdatsp3 = zblock%xdatsp3
  plfhe3 = zblock%plfhe3
  plfhe4 = zblock%plfhe4
  plfst = zblock%plfst
  plfsp = zblock%plfsp
  plfsp14 = zblock%plfsp14
  nlfatom = zblock%nlfatom
 
end subroutine nbi_set_fusion
 
subroutine nbi_set_fpp(zblock,ierr)
 
  ! set values for input block: fpp
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_fpp), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_fpp) then
    write(nonlin,*) '?nbi_set_fpp: block was already initialized.'
    ierr=1; return
  else
    init_fpp = .TRUE.
  endif
 
  nlbfpp = zblock%nlbfpp
 
end subroutine nbi_set_fpp
 
subroutine nbi_set_num(zblock,ierr)
 
  ! set values for input block: num
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_num), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_num) then
    write(nonlin,*) '?nbi_set_num: block was already initialized.'
    ierr=1; return
  else
    init_num = .TRUE.
  endif
 
  cxsplt = zblock%cxsplt
  dxbsmoo = zblock%dxbsmoo
  dxbsm_nc = zblock%dxbsm_nc
  nptcls = zblock%nptcls
  nptclf = zblock%nptclf
  nptclh = zblock%nptclh
  NFAST_MAP = zblock%NFAST_MAP
  xpand_nptcl = zblock%xpand_nptcl
  frac_depmax = zblock%frac_depmax
  frac_dep_lim = zblock%frac_dep_lim
  frac_depmin = zblock%frac_depmin
  frac_orbrr = zblock%frac_orbrr
  nptcl_max = zblock%nptcl_max
  nltrk_dep0 = zblock%nltrk_dep0
  NLDEP0_GATHER = zblock%NLDEP0_GATHER
  ndep0 = zblock%ndep0
  NDEP0_MAX = zblock%NDEP0_MAX
  ndep_set_beam = zblock%ndep_set_beam
  ndep_set_ien = zblock%ndep_set_ien
  nbbcal = zblock%nbbcal
  ncx0 = zblock%ncx0
  nper_cx = zblock%nper_cx
  LEV_NBIDEP = zblock%LEV_NBIDEP
  LEV_TTNUK = zblock%LEV_TTNUK
  LEVMOD_HALO = zblock%LEVMOD_HALO
  NSPLT = zblock%NSPLT
  NSPLT_GEO = zblock%NSPLT_GEO
  NSPLT_KIN = zblock%NSPLT_KIN
  NSPLT_GEN = zblock%NSPLT_GEN
  nmimp = zblock%nmimp
  AIMP = zblock%AIMP
  XZIMP = zblock%XZIMP
  NTEST_MAX = zblock%NTEST_MAX
  BI_MAX_PL = zblock%BI_MAX_PL
  BI_MAX_PR = zblock%BI_MAX_PR
  wghta = zblock%wghta
  goocon = zblock%goocon
  NGOOCON_VPVBIN = zblock%NGOOCON_VPVBIN
  NGOOCON_EBIN = zblock%NGOOCON_EBIN
  NGOOCON_RBIN = zblock%NGOOCON_RBIN
  cxpcon = zblock%cxpcon
  fppcon = zblock%fppcon
  fdtnxy = zblock%fdtnxy
  nchdvp = zblock%nchdvp
  dtn = zblock%dtn
  dt_acc = zblock%dt_acc
  orbrzv_option = zblock%orbrzv_option
  orbrzv_rf_option = zblock%orbrzv_rf_option
  nlmcrf_on = zblock%nlmcrf_on
  orbrzv_nr = zblock%orbrzv_nr
  orbrzv_nz = zblock%orbrzv_nz
  orbrzv_zzerr_con = zblock%orbrzv_zzerr_con
 
end subroutine nbi_set_num
 
subroutine nbi_set_atomic(zblock,ierr)
 
  ! set values for input block: atomic
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_atomic), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_atomic) then
    write(nonlin,*) '?nbi_set_atomic: block was already initialized.'
    ierr=1; return
  else
    init_atomic = .TRUE.
  endif
 
  nsmax = zblock%nsmax
  khalo(1:mis) = zblock%khalo(1:mis)
  dn0out = zblock%dn0out
  nmsigx = zblock%nmsigx
  nlminsv = zblock%nlminsv
  nlebei = zblock%nlebei
  nsigexc = zblock%nsigexc
  xdepmod = zblock%xdepmod
  nlbbcx = zblock%nlbbcx
  nbbcx_avg = zblock%nbbcx_avg
  nbbcx_bb = zblock%nbbcx_bb
  nbfallgr = zblock%nbfallgr
  nlbeamcx = zblock%nlbeamcx
  nlhvion = zblock%nlhvion
 
end subroutine nbi_set_atomic
 
subroutine nbi_set_collid(zblock,ierr)
 
  ! set values for input block: collid
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_collid), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_collid) then
    write(nonlin,*) '?nbi_set_collid: block was already initialized.'
    ierr=1; return
  else
    init_collid = .TRUE.
  endif
 
  xcfanbi = zblock%xcfanbi
  xdfanbi = zblock%xdfanbi
  xefanbi = zblock%xefanbi
  xcfafus = zblock%xcfafus
  xdfafus = zblock%xdfafus
  xefafus = zblock%xefafus
  nlbcde = zblock%nlbcde
  nlbcoh = zblock%nlbcoh
  nlbcpa = zblock%nlbcpa
  nlorbo = zblock%nlorbo
 
end subroutine nbi_set_collid
 
subroutine nbi_set_flr(zblock,ierr)
 
  ! set values for input block: flr
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_flr), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_flr) then
    write(nonlin,*) '?nbi_set_flr: block was already initialized.'
    ierr=1; return
  else
    init_flr = .TRUE.
  endif
 
  nlbflr = zblock%nlbflr
  nlfbmflr = zblock%nlfbmflr
  nlbgflr = zblock%nlbgflr
  gflr_min = zblock%gflr_min
  gflr_rl = zblock%gflr_rl
  gflr_ll = zblock%gflr_ll
  gflr_xv(1:2) = zblock%gflr_xv(1:2)
  gflr_op(1:15) = zblock%gflr_op(1:15)
 
end subroutine nbi_set_flr
 
subroutine nbi_set_saw(zblock,ierr)
 
  ! set values for input block: saw
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_saw), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_saw) then
    write(nonlin,*) '?nbi_set_saw: block was already initialized.'
    ierr=1; return
  else
    init_saw = .TRUE.
  endif
 
  sawflag = zblock%sawflag
  nlsawb = zblock%nlsawb
  nlsawf = zblock%nlsawf
  xswfrac_allfast = zblock%xswfrac_allfast
  xswfrac_beam = zblock%xswfrac_beam
  xswfrac_fusn = zblock%xswfrac_fusn
  nmix_kdsaw = zblock%nmix_kdsaw
  fporcelli = zblock%fporcelli
 
end subroutine nbi_set_saw
 
subroutine nbi_set_adif(zblock,ierr)
 
  ! set values for input block: adif
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_adif), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_adif) then
    write(nonlin,*) '?nbi_set_adif: block was already initialized.'
    ierr=1; return
  else
    init_adif = .TRUE.
  endif
 
  nkaep = zblock%nkaep
  AEP_ASCALE(1:mnkaep) = zblock%AEP_ASCALE(1:mnkaep)
  AEP_USCALE = zblock%AEP_USCALE
  TAEP_FAC(1:mnkaep) = zblock%TAEP_FAC(1:mnkaep)
  nmdifb = zblock%nmdifb
  nkdifb = zblock%nkdifb
  ndifbe = zblock%ndifbe
  fdifbe(1:ndifbe) = zblock%fdifbe(1:ndifbe)
  edifbe(1:ndifbe) = zblock%edifbe(1:ndifbe)
  x_qlim0 = zblock%x_qlim0
  ndifbe_2d = zblock%ndifbe_2d
  dif2d_conv = zblock%dif2d_conv
  dif2d_dpa = zblock%dif2d_dpa
  ngradd_opt = zblock%ngradd_opt
 
end subroutine nbi_set_adif
 
subroutine nbi_set_ripple(zblock,ierr)
 
  ! set values for input block: ripple
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_ripple), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_ripple) then
    write(nonlin,*) '?nbi_set_ripple: block was already initialized.'
    ierr=1; return
  else
    init_ripple = .TRUE.
  endif
 
  nrip = zblock%nrip
  taurip = zblock%taurip
  id_ripple = zblock%id_ripple
  id_ripple2 = zblock%id_ripple2
  ncoils = zblock%ncoils
  ncoils_2 = zblock%ncoils_2
  asrd = zblock%asrd
  bsrd = zblock%bsrd
 
end subroutine nbi_set_ripple
 
subroutine nbi_set_outcon(zblock,ierr)
 
  ! set values for input block: outcon
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_outcon), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_outcon) then
    write(nonlin,*) '?nbi_set_outcon: block was already initialized.'
    ierr=1; return
  else
    init_outcon = .TRUE.
  endif
 
  nerngfi = zblock%nerngfi
  erngfi(1:nerngfi,1:mibs) = zblock%erngfi(1:nerngfi,1:mibs)
  nsdbgb = zblock%nsdbgb
 
end subroutine nbi_set_outcon
 
subroutine nbi_set_fishbone(zblock,ierr)
 
  ! set values for input block: fishbone
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_fishbone), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_fishbone) then
    write(nonlin,*) '?nbi_set_fishbone: block was already initialized.'
    ierr=1; return
  else
    init_fishbone = .TRUE.
  endif
 
  nlfbon = zblock%nlfbon
  fbemin = zblock%fbemin
  fbemax = zblock%fbemax
  fvpvmn = zblock%fvpvmn
  fvpvmx = zblock%fvpvmx
  fbltim = zblock%fbltim
  fshper = zblock%fshper
  fshwid = zblock%fshwid
  tfshon = zblock%tfshon
  tfshof = zblock%tfshof
  xfishmin = zblock%xfishmin
  xfishmax = zblock%xfishmax
  nfbon_vpvopt = zblock%nfbon_vpvopt
  fbtrap_depth = zblock%fbtrap_depth
  nfbon_species = zblock%nfbon_species
 
end subroutine nbi_set_fishbone
 
subroutine nbi_set_box(zblock,ierr)
 
  ! set values for input block: box
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_box), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_box) then
    write(nonlin,*) '?nbi_set_box: block was already initialized.'
    ierr=1; return
  else
    init_box = .TRUE.
  endif
 
  nbbox = zblock%nbbox
  nbsbox(1:nbbox) = zblock%nbsbox(1:nbbox)
  nsample_box(1:nbbox) = zblock%nsample_box(1:nbbox)
  xninja_box(1:nbbox) = zblock%xninja_box(1:nbbox)
  xninjs_box(1:nbbox) = zblock%xninjs_box(1:nbbox)
  xninj_box = zblock%xninj_box
  nbebox(1:nbbox) = zblock%nbebox(1:nbbox)
  nxbox = zblock%nxbox
  nybox = zblock%nybox
  nlbox = zblock%nlbox
  xboxhw = zblock%xboxhw
  yboxhw = zblock%yboxhw
  xlbox1 = zblock%xlbox1
  xlbox2 = zblock%xlbox2
  ndepbox = zblock%ndepbox
 
end subroutine nbi_set_box
 
subroutine nbi_set_tube(zblock,ierr)
 
  ! set values for input block: tube
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_tube), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_tube) then
    write(nonlin,*) '?nbi_set_tube: block was already initialized.'
    ierr=1; return
  else
    init_tube = .TRUE.
  endif
 
  nbtube = zblock%nbtube
  nbstube(1:nbtube) = zblock%nbstube(1:nbtube)
  nbetube(1:nbtube) = zblock%nbetube(1:nbtube)
  Rtube(1:nbtube) = zblock%Rtube(1:nbtube)
  Ytube(1:nbtube) = zblock%Ytube(1:nbtube)
  XZETAtube(1:nbtube) = zblock%XZETAtube(1:nbtube)
  PHItube(1:nbtube) = zblock%PHItube(1:nbtube)
  THETAtube(1:nbtube) = zblock%THETAtube(1:nbtube)
  LMIDtube(1:nbtube) = zblock%LMIDtube(1:nbtube)
  XL1tube(1:nbtube) = zblock%XL1tube(1:nbtube)
  XL2tube(1:nbtube) = zblock%XL2tube(1:nbtube)
  NSEGtube(1:nbtube) = zblock%NSEGtube(1:nbtube)
  RHOtube = zblock%RHOtube
  NDEPtube = zblock%NDEPtube
 
end subroutine nbi_set_tube
 
subroutine nbi_set_misc(zblock,ierr)
 
  ! set values for input block: misc
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_misc), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_misc) then
    write(nonlin,*) '?nbi_set_misc: block was already initialized.'
    ierr=1; return
  else
    init_misc = .TRUE.
  endif
 
  plhgt = zblock%plhgt
  nlcprb = zblock%nlcprb
  nlpsirz = zblock%nlpsirz
  edbfac = zblock%edbfac
  nmcurb = zblock%nmcurb
  nlfdep = zblock%nlfdep
 
end subroutine nbi_set_misc
 
subroutine nbi_set_profiles(zblock,ierr)
 
  ! set values for input block: profiles
 
  use nbi_com
  use nbi_types
  implicit NONE
 
  type (nbitype_profiles), intent(in) :: zblock
  integer, intent(out) :: ierr
 
  ierr=0
  if(init_profiles) then
    write(nonlin,*) '?nbi_set_profiles: block was already initialized.'
    ierr=1; return
  else
    init_profiles = .TRUE.
  endif
 
  id_te = zblock%id_te
  id_ti = zblock%id_ti
  id_tifusn = zblock%id_tifusn
  id_ne = zblock%id_ne
  ng = zblock%ng
  id_nh(1:ngmax) = zblock%id_nh(1:ngmax)
  id_nimp(1:nrhix) = zblock%id_nimp(1:nrhix)
  id_nrf(1:nmini) = zblock%id_nrf(1:nmini)
  id_eperpmin(1:nmini) = zblock%id_eperpmin(1:nmini)
  id_epllmin(1:nmini) = zblock%id_epllmin(1:nmini)
  id_nfast(1:nsfast) = zblock%id_nfast(1:nsfast)
  id_eperpfast(1:nsfast) = zblock%id_eperpfast(1:nsfast)
  id_epllfast(1:nsfast) = zblock%id_epllfast(1:nsfast)
  id_aimp = zblock%id_aimp
  id_zimp = zblock%id_zimp
  id_omega = zblock%id_omega
  id_epot = zblock%id_epot
  id_vpoh = zblock%id_vpoh
  id_curt = zblock%id_curt
  id_difb = zblock%id_difb
  id_velb = zblock%id_velb
  id_difb_bi = zblock%id_difb_bi
  id_velb_bi = zblock%id_velb_bi
  id_difb_fi = zblock%id_difb_fi
  id_velb_fi = zblock%id_velb_fi
  id_fd0(1:nsfast) = zblock%id_fd0(1:nsfast)
  id_fdb(1:nsfast) = zblock%id_fdb(1:nsfast)
  id_fdp(1:nsfast) = zblock%id_fdp(1:nsfast)
  id_fdq(1:nsfast) = zblock%id_fdq(1:nsfast)
  id_fdr(1:nsfast) = zblock%id_fdr(1:nsfast)
  id_fds(1:nsfast) = zblock%id_fds(1:nsfast)
  id_n0(1:nsmax,1:ngmax) = zblock%id_n0(1:nsmax,1:ngmax)
  id_t0(1:nsmax,1:ngmax) = zblock%id_t0(1:nsmax,1:ngmax)
  id_omeg0(1:nsmax,1:ngmax) = zblock%id_omeg0(1:nsmax,1:ngmax)
 
end subroutine nbi_set_profiles
 
