def setup(self): arg1d = pyf.Argument('charr1', dtype=pyf.CharacterType(fw_ktp='charr_x8', len='20'), dimension=[':'], intent='inout') arg2d = pyf.Argument('charr2', dtype=pyf.CharacterType(fw_ktp='charr_x30', len='30'), dimension=[':'] * 2, intent='inout') fc_arg1d = fc_wrap.ArrayArgWrapper(arg1d) fc_arg2d = fc_wrap.ArrayArgWrapper(arg2d) self.cy_arg1d = cy_wrap.CyCharArrayArgWrapper(fc_arg1d) self.cy_arg2d = cy_wrap.CyCharArrayArgWrapper(fc_arg2d)
def setup(self): self.intents = ('in', 'out', 'inout', None) self.dtypes = [pyf.CharacterType('ch_xX', len='*') for _ in range(4)] self.caws = make_caws(self.dtypes, ['name'] * len(self.dtypes), self.intents) (self.intent_in, self.intent_out, self.intent_inout, self.no_intent) = self.caws
def _get_dtype(typedecl): if not typedecl.is_intrinsic(): raise RuntimeError("only intrinsic types supported ATM... [%s]" % str(typedecl)) length, kind = typedecl.selector if not kind and not length: return name2default[typedecl.name] if length and kind and typedecl.name != 'character': raise RuntimeError("both length and kind specified for " "non-character intrinsic type: " "length: %s kind: %s" % (length, kind)) if typedecl.name == 'character': if length == '*': fw_ktp = '%s_xX' % (typedecl.name) else: fw_ktp = '%s_x%s' % (typedecl.name, length) return pyf.CharacterType(fw_ktp=fw_ktp, len=length, kind=kind) if length and not kind: return name2type[typedecl.name](fw_ktp="%s_x%s" % (typedecl.name, length), length=length) try: int(kind) except ValueError: raise RuntimeError("only integer constant kind " "parameters supported ATM, given '%s'" % kind) if typedecl.name == 'doubleprecision': return pyf.default_dbl return name2type[typedecl.name](fw_ktp="%s_%s" % (typedecl.name, kind), kind=kind)
def test_arg_dstring(self): real_arg_in = pyf.Argument("real_in", pyf.default_real, "in") complex_arg_out = pyf.Argument("cpx_out", pyf.default_complex, 'out') logical_arg_inout = pyf.Argument("lgcl_inout", pyf.default_logical, 'inout') int_arg = pyf.Argument('int_arg', pyf.default_integer) char_arg_out = pyf.Argument("char_arg", pyf.CharacterType("S20", len=20), 'out') char_arg_in = pyf.Argument("char_arg_in", pyf.CharacterType("S20", len=20), 'in') char_star = pyf.Argument("char_star", pyf.CharacterType("star", len="*"), 'out') args = [ real_arg_in, complex_arg_out, logical_arg_inout, int_arg, char_arg_out, char_arg_in, char_star ] fcargs = [fc_wrap.ArgWrapperFactory(arg) for arg in args] cyargs = [cy_wrap.CyArgWrapper(arg) for arg in fcargs] cy_real, cy_cpx, cy_log, cy_int, cy_char_out, cy_char_in, cy_star = cyargs eq_(cy_cpx.in_dstring(), []) eq_(cy_cpx.out_dstring(), ["cpx_out : fwc_complex, intent out"]) eq_(cy_real.out_dstring(), []) eq_(cy_real.in_dstring(), ["real_in : fwr_real, intent in"]) eq_(cy_log.in_dstring(), ["lgcl_inout : fwl_logical, intent inout"]) eq_(cy_log.out_dstring(), ["lgcl_inout : fwl_logical, intent inout"]) eq_(cy_int.in_dstring(), ["int_arg : fwi_integer"]) eq_(cy_int.out_dstring(), ["int_arg : fwi_integer"]) char_in_str = ["char_arg_in : fw_S20, len 20, intent in"] eq_(cy_char_in.in_dstring(), char_in_str) eq_(cy_char_in.out_dstring(), []) char_out_str = ["char_arg : fw_S20, len 20, intent out"] eq_(cy_char_out.in_dstring(), []) eq_(cy_char_out.out_dstring(), char_out_str) star_str = ["char_star : fw_star, len *, intent out"] eq_(cy_star.in_dstring(), star_str) eq_(cy_star.out_dstring(), star_str)
def setup(self): dchar1 = pyf.CharacterType('char_20', len='20') dchar2 = pyf.CharacterType('char_10', len='10') dchar3 = pyf.CharacterType('char_x', len='*') names = ['ch1', 'ch2', 'ch3'] dchs = [dchar1, dchar2, dchar3] inout_args = [ pyf.Argument(name=name, dtype=dch, intent='inout') for (name, dch) in zip(names, dchs) ] self.inout_wraps = [ fc_wrap.ArgWrapperFactory(ioa) for ioa in inout_args ]
def setup(self): self.intents = ('in', 'out', 'inout', None) self.dtypes = [pyf.CharacterType('ch_%d'%d, len=str(d)) \ for d in (10,20,30,40)] self.caws = make_caws(self.dtypes, ['name'] * len(self.dtypes), self.intents) (self.intent_in, self.intent_out, self.intent_inout, self.no_intent) = self.caws
def test_array_dstring(self): real_in = pyf.Argument("real_in", pyf.default_real, "in", dimension=[":", ":"]) complex_out = pyf.Argument("cpx_out", pyf.default_complex, 'out', dimension=["n1:n2+n3"]) logical_inout = pyf.Argument("lgcl_inout", pyf.default_logical, 'inout', dimension=["n1:n2", "*"]) character_inout = pyf.Argument("char_inout", pyf.CharacterType("char", len='*'), 'inout', dimension=[":", ":"]) int_ = pyf.Argument('int_arg', pyf.default_integer, dimension=[":"] * 7) args = [real_in, complex_out, logical_inout, int_, character_inout] fcargs = [fc_wrap.ArgWrapperFactory(arg) for arg in args] cyargs = [cy_wrap.CyArrayArgWrapper(arg) for arg in fcargs] cy_real, cy_cpx, cy_log, cy_int, cy_char = cyargs real_str = ["real_in : fwr_real, 2D array, dimension(:, :), intent in"] eq_(cy_real.in_dstring(), real_str) eq_(cy_real.out_dstring(), []) cpx_str = [ "cpx_out : fwc_complex, 1D array, dimension(n1:n2+n3), intent out" ] eq_(cy_cpx.in_dstring(), cpx_str) eq_(cy_cpx.out_dstring(), cpx_str) log_str = [ "lgcl_inout : fwl_logical, " "2D array, dimension(n1:n2, *), intent inout" ] eq_(cy_log.in_dstring(), log_str) eq_(cy_log.out_dstring(), log_str) int_str = [ "int_arg : fwi_integer, " "7D array, dimension(:, :, :, :, :, :, :)" ] eq_(cy_int.in_dstring(), int_str) eq_(cy_int.out_dstring(), int_str) char_str = [ "char_inout : fw_char, len *, 2D array, dimension(:, :), intent inout" ] eq_(cy_char.in_dstring(), char_str) eq_(cy_char.out_dstring(), char_str)
def setup(self): charr1 = pyf.Argument('charr1', pyf.CharacterType("char_x20", len="20"), dimension=(":", ), intent="inout") charr3 = pyf.Argument('charr3', pyf.CharacterType("char_x30", len="30"), dimension=[':'] * 3, intent="inout") charr_star = pyf.Argument('cs', pyf.CharacterType("char_xX", len="*"), dimension=('n1', ), intent='inout') charr_in = pyf.Argument('charrin', pyf.CharacterType("char_in", len="20"), dimension=(":", ), intent="in") self.fc_charr1 = fc_wrap.CharArrayArgWrapper(charr1) self.fc_charr3 = fc_wrap.CharArrayArgWrapper(charr3) self.fc_charr_star = fc_wrap.CharArrayArgWrapper(charr_star) self.fc_charr_in = fc_wrap.CharArrayArgWrapper(charr_in)
def _set_intern_vars(self): self.len_arg = pyf.Argument(name="%s_len" % self.intern_name, dtype=pyf.dim_dtype, intent='in') self.is_assumed_len = (self.dtype.len == '*') self.orig_len = self.dtype.len if self.is_assumed_len: self.intern_dtype = pyf.CharacterType(self.ktp, len=self.len_arg.name, mangler="%s") else: self.intern_dtype = self.dtype self._set_intern_var()