# Path: alis/almsgs.py
# class Colors:
# class msgs:
#     def disable(self):
#     def __init__(self):
#     def alisheader(self, prognm, verbose=2):
#     def signal_handler(self, signalnum, handler):
#     def error(self, msg, verbose=None):
#     def info(self, msg, verbose=None):
#     def warn(self, msg, verbose=None):
#     def test(self, msg, verbose=None):
#     def bug(self, msg, verbose=None):
#     def work(self, msg, verbose=None):
#     def input(self):
#     def newline(self,verbose=None):
#     def indent(self,verbose=None):
# 
# Path: alis/alfunc_base.py
# class Base :
#     def __init__(self, prgname="", getinst=False, atomic=None, verbose=2):
#     def call_CPU(self, x, p, ae='em', mkey=None, ncpus=1):
#         def model():
#     def call_GPU(self, x, p, ae='em'):
#     def adjust_fix(self, mp, cntr, jval, parj):
#     def adjust_lim(self, mp, cntr, jval, jind, parj):
#     def getminmax(self, par, fitrng, Nsig=5.0):
#     def load(self, instr, cntr, mp, specid):
#         def check_tied_param(ival, cntr, mps, iind):
#     def parin(self, i, par, parb):
#     def parout(self, params, mp, istart, level, errs=None, reletter=False, conv=None):
#     def set_pinfo(self, pinfo, level, mp, lnk, mnum):
#     def set_vars(self, p, level, mp, ival, wvrng=[0.0,0.0], spid='None', levid=None, nexbin=None, ddpid=None, getinfl=False):
#     def gtoef(self, num, fmt):
#     def tick_info(self, p, level, mp, ival, wvrng=[0.0,0.0], spid='None', levid=None):
# def call(prgname="",getfuncs=False,getinst=False,atomic=None,verbose=2):


import numpy as np
from alis import almsgs
from alis import alfunc_base
        self._keywd   = dict({'specid':[], 'continuum':False, 'blind':False})   # Additional arguments to describe the model --- 'input' cannot be used as a keyword
        self._keych   = dict({'specid':0,  'continuum':0,     'blind':0})       # Require keywd to be changed (1 for yes, 0 for no)
        self._keyfm   = dict({'specid':"", 'continuum':"",    'blind':""})      # Format for the keyword. "" is the Default setting
        self._parid   = ['value']				# Name of each parameter
        self._defpar  = [ 1.0 ]					# Default values for parameters that are not provided
        self._fixpar  = [ None ]				# By default, should these parameters be fixed?
        self._limited = [ [1  ,0  ] ]			# Should any of these parameters be limited from below or above
        self._limits  = [ [0.0,0.0] ]			# What should these limiting values be
        self._svfmt   = [ "{0:.8g}" ]			# Specify the format used to print or save output
        self._prekw   = []						# Specify the keywords to print out before the parameters
        # DON'T CHANGE THE FOLLOWING --- it tells ALIS what parameters are provided by the user.
        tempinput = self._parid+list(self._keych.keys())                             #
        self._keywd['input'] = dict(zip((tempinput),([0]*np.size(tempinput)))) #
        ########################################################################
        #self._kernal  = self.GPU_kernal()		# Get the Source Module for the GPU
        self._verbose = verbose
        # Set the atomic data
        self._atomic = atomic
        if getinst: return

    def GPU_kernal(self):
        return SourceModule("""

            __global__ void cnst(double *model, double *wave, double *params)
            {
            int idx = blockIdx.x + blockIdx.y*gridDim.x + threadIdx.x*gridDim.x*gridDim.y;
            int pidx = blockIdx.y;

            model[idx] = params[pidx];


# Path: alis/almsgs.py
# class Colors:
# class msgs:
#     def disable(self):
#     def __init__(self):
#     def alisheader(self, prognm, verbose=2):
#     def signal_handler(self, signalnum, handler):
#     def error(self, msg, verbose=None):
#     def info(self, msg, verbose=None):
#     def warn(self, msg, verbose=None):
#     def test(self, msg, verbose=None):
#     def bug(self, msg, verbose=None):
#     def work(self, msg, verbose=None):
#     def input(self):
#     def newline(self,verbose=None):
#     def indent(self,verbose=None):
# 
# Path: alis/alfunc_base.py
# class Base :
#     def __init__(self, prgname="", getinst=False, atomic=None, verbose=2):
#     def call_CPU(self, x, p, ae='em', mkey=None, ncpus=1):
#         def model():
#     def call_GPU(self, x, p, ae='em'):
#     def adjust_fix(self, mp, cntr, jval, parj):
#     def adjust_lim(self, mp, cntr, jval, jind, parj):
#     def getminmax(self, par, fitrng, Nsig=5.0):
#     def load(self, instr, cntr, mp, specid):
#         def check_tied_param(ival, cntr, mps, iind):
#     def parin(self, i, par, parb):
#     def parout(self, params, mp, istart, level, errs=None, reletter=False, conv=None):
#     def set_pinfo(self, pinfo, level, mp, lnk, mnum):
#     def set_vars(self, p, level, mp, ival, wvrng=[0.0,0.0], spid='None', levid=None, nexbin=None, ddpid=None, getinfl=False):
#     def gtoef(self, num, fmt):
#     def tick_info(self, p, level, mp, ival, wvrng=[0.0,0.0], spid='None', levid=None):
# def call(prgname="",getfuncs=False,getinst=False,atomic=None,verbose=2):


# Path: alis/alfunc_constant.py
import numpy as np
from alis import almsgs
from alis import alfunc_base

        self._keywd   = dict({'specid':[], 'continuum':False, 'blind':False})   # Additional arguments to describe the model --- 'input' cannot be used as a keyword
        self._keych   = dict({'specid':0,  'continuum':0,     'blind':0})       # Require keywd to be changed (1 for yes, 0 for no)
        self._keyfm   = dict({'specid':"", 'continuum':"",    'blind':""})      # Format for the keyword. "" is the Default setting
        self._parid   = ['value']				# Name of each parameter
        self._defpar  = [ 1.0 ]					# Default values for parameters that are not provided
        self._fixpar  = [ None ]				# By default, should these parameters be fixed?
        self._limited = [ [1  ,0  ] ]			# Should any of these parameters be limited from below or above
        self._limits  = [ [0.0,0.0] ]			# What should these limiting values be
        self._svfmt   = [ "{0:.8g}" ]			# Specify the format used to print or save output
        self._prekw   = []						# Specify the keywords to print out before the parameters
        # DON'T CHANGE THE FOLLOWING --- it tells ALIS what parameters are provided by the user.
        tempinput = self._parid+list(self._keych.keys())                             #
        self._keywd['input'] = dict(zip((tempinput),([0]*np.size(tempinput)))) #
        ########################################################################
        #self._kernal  = self.GPU_kernal()		# Get the Source Module for the GPU
        self._verbose = verbose
        # Set the atomic data
        self._atomic = atomic
        if getinst: return

    def GPU_kernal(self):
        return SourceModule("""

            __global__ void cnst(double *model, double *wave, double *params)
            {
            int idx = blockIdx.x + blockIdx.y*gridDim.x + threadIdx.x*gridDim.x*gridDim.y;
            int pidx = blockIdx.y;

            model[idx] = params[pidx];


            }