// It seems these properties need to go after the type-related attributes
for(property <- sym.getProperties) property match {
- case (p: FortranProperty) => attributeStrings +:= p.getName
+ case (p: FortranAttribute) => attributeStrings +:= p.getName
case _ => ()
}
trait FortranProperty extends SymbolProperty {
}
-class AllocatableProperty extends FortranProperty {
+trait FortranAttribute extends FortranProperty {
+ def getName : String
+}
+
+case class AllocatableProperty() extends FortranAttribute {
def getName = "allocatable"
}
+
+case class FortranModule(module: String) extends FortranProperty {
+ def getName = module
+ def getModuleName : String = module
+}
package ofc.codegen
-trait FunctionSignature[R <: Type] {
- def getName: String
+trait FunctionSignature[R <: Type] extends Symbol {
def getReturnType: R
def getParams: Seq[(String, Type)]
}
package ofc.codegen
-trait Statement
+trait Statement {
+ def expressions: Traversable[Expression[_]]
+}
+
class NullStatement extends Statement
def getFortranAttributes = tType.getFortranAttributes + "pointer"
}
-abstract class StructType extends Type
+abstract class StructType extends Type with Symbol {
+ def getFortranAttributes = Set("type(" + getName + ")")
+}
trait TypeBuilder[T <: Type] {
def apply() : T
import ofc.codegen._
object OnetepFunctions {
+
+ // module basis
+
val basis_copy_function_to_box = new FortranSubroutineSignature("basis_copy_function_to_box",
Seq(("fa_box", new ArrayType[FloatType](3)),
("box_n1", new IntType),
("n2", new IntType),
("n3", new IntType)))
+ List(basis_copy_function_to_box, basis_ket_start_wrt_fftbox).map(_.addProperty(new FortranModule("basis")))
+
+ // module fourier
+
val fourier_apply_box_pair = new FortranSubroutineSignature("fourier_apply_box_pair",
Seq(("grid", new CharType),
("dir", new CharType),
("rspc2", new ArrayType[FloatType](3)),
("gspc", new ArrayType[ComplexType](3))))
+ List(fourier_apply_box_pair).map(_.addProperty(new FortranModule("fourier")))
+
val sparse_first_elem_on_node = new FortranFunctionSignature[IntType]("sparse_first_elem_on_node",
Seq(("node", new IntType),
("mat", OnetepTypes.SPAM3),
("jrow", new IntType),
("jcol", new IntType)))
+ List(sparse_first_elem_on_node,
+ sparse_index_length,
+ sparse_generate_index,
+ sparse_atom_of_elem,
+ sparse_put_element_real).map(_.addProperty(new FortranModule("fourier")))
}
new FieldSymbol[PointerType[ArrayType[StructType]]]("spheres", fieldType)
}
- def getFortranAttributes = Set("type(FUNC_BASIS)")
+ def getName = "FUNC_BASIS"
}
object Sphere extends StructType {
}
val offset = new FieldSymbol[IntType]("offset")
-
- def getFortranAttributes = Set("type(SPHERE)")
+ def getName = "SPHERE"
}
object Point extends StructType {
val y = new FieldSymbol[FloatType]("Y")
val z = new FieldSymbol[FloatType]("Z")
val coord = List(x,y,z)
- def getFortranAttributes = Set("type(POINT)")
+ def getName = "POINT"
}
object CellInfo extends StructType {
val pointsInPPD = new FieldSymbol[IntType]("n_pts")
val latticeReciprocal = for(dim <- 1 to 3) yield new FieldSymbol[StructType]("b"+dim, Point)
val weight = new FieldSymbol[FloatType]("weight")
- def getFortranAttributes = Set("type(CELL_INFO)")
+ def getName = "CELL_INFO"
}
object TightBox extends StructType {
val finishPts = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("finish_pts"+dim)}.toSeq
val startPPD = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("start_ppds"+dim)}.toSeq
val finishPPD = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("finish_ppds"+dim)}.toSeq
- def getFortranAttributes = Set("type(FUNCTION_TIGHT_BOX)")
+ def getName = "FUNCTION_TIGHT_BOX"
}
object FFTBoxInfo extends StructType {
val public = new NamedUnboundVarSymbol[StructType]("pub_fftbox", FFTBoxInfo)
val latticeReciprocal = for(dim <- 1 to 3) yield new FieldSymbol[StructType]("b"+dim, Point)
val totalPts = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("total_pt"+dim)}.toSeq
- def getFortranAttributes = Set("type(FFTBOX_INFO)")
+ def getName = "FFTBOX_INFO"
}
object SPAM3 extends StructType {
- def getFortranAttributes = Set("type(SPAM3)")
+ def getName = "SPAM3"
}
}
val pub_my_node_id = new NamedUnboundVarSymbol[IntType]("pub_my_node_id")
val pub_first_atom_on_node = new NamedUnboundVarSymbol[ArrayType[IntType]]("pub_first_atom_on_node", new ArrayType[IntType](1))
val pub_num_atoms_on_node = new NamedUnboundVarSymbol[ArrayType[IntType]]("pub_num_atoms_on_node", new ArrayType[IntType](1))
+
+ List(pub_my_node_id,
+ pub_first_atom_on_node,
+ pub_num_atoms_on_node).map(_.addProperty(new FortranModule("parallel_strategy")))
}