InlineFortran 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ == 1.0.0 / 2006-10-21
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
5
+
@@ -0,0 +1,6 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ demo/hello.rb
6
+ lib/inline/fortran.rb
@@ -0,0 +1,55 @@
1
+ Inline::Fortran by Ryan Davis
2
+ http://www.rubyforge.org/projects/rubyinline
3
+
4
+ == DESCRIPTION:
5
+
6
+ Just because we can... Inline::Fortran.
7
+
8
+ == FEATURES/PROBLEMS:
9
+
10
+ * Very rudimentary right now. Needs some love.
11
+
12
+ == SYNOPSYS:
13
+
14
+ inline :Fortran do |builder|
15
+ builder.subroutine('print_integer', ["void", "int"], <<-END)
16
+ subroutine print_integer( integer )
17
+ integer, intent(in) :: integer
18
+ print *, 'integer: ', integer
19
+ end
20
+ END
21
+ end
22
+
23
+ == REQUIREMENTS:
24
+
25
+ + RubyInline
26
+ + g95 - should support more compilers later.
27
+
28
+ == INSTALL:
29
+
30
+ + sudo gem install InlineFortran
31
+
32
+ == LICENSE:
33
+
34
+ (The MIT License)
35
+
36
+ Copyright (c) 2006 FIX
37
+
38
+ Permission is hereby granted, free of charge, to any person obtaining
39
+ a copy of this software and associated documentation files (the
40
+ 'Software'), to deal in the Software without restriction, including
41
+ without limitation the rights to use, copy, modify, merge, publish,
42
+ distribute, sublicense, and/or sell copies of the Software, and to
43
+ permit persons to whom the Software is furnished to do so, subject to
44
+ the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be
47
+ included in all copies or substantial portions of the Software.
48
+
49
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
50
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
52
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
53
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
54
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
55
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/inline/fortran.rb'
6
+
7
+ Hoe.new('InlineFortran', Inline::Fortran::VERSION) do |p|
8
+ p.rubyforge_name = 'rubyinline'
9
+ p.summary = 'A RubyInline extension for Fortran'
10
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
11
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
12
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
13
+ p.extra_deps << "RubyInline"
14
+ end
15
+
16
+ # vim: syntax=Ruby
@@ -0,0 +1,18 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ require 'rubygems'
4
+ require 'inline/fortran'
5
+
6
+ class FortranTest
7
+ inline :Fortran do |builder|
8
+ builder.subroutine('print_integer', ["void", "int"], <<-END)
9
+ subroutine print_integer( integer )
10
+ integer, intent(in) :: integer
11
+ print *, 'integer: ', integer
12
+ end
13
+ END
14
+ end
15
+ end
16
+
17
+ blah = FortranTest.new
18
+ blah.print_integer(6)
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'inline'
5
+
6
+ module Inline
7
+ class Fortran
8
+
9
+ VERSION = '1.0.0'
10
+
11
+ def initialize(mod)
12
+ @mod = mod
13
+ @functions = {}
14
+ end
15
+
16
+ def subroutine(subroutine_name, c_signature, src)
17
+ @functions[subroutine_name] = [c_signature, src]
18
+ end
19
+
20
+ def load_cache
21
+ return false
22
+ end
23
+
24
+ def build
25
+ c_builder = Inline::C.new(@mod)
26
+
27
+ src_name = "#{Inline.directory}/#{@mod}.f90"
28
+ File.open(src_name, "w") do |f|
29
+ @functions.each do |name, (signature, src)|
30
+
31
+ src.sub!(/#{name}/, "f_#{name}")
32
+
33
+ args = []
34
+ call_args = []
35
+ return_type = signature.shift
36
+
37
+ signature.each_with_index do |arg_type, i|
38
+ args << "#{arg_type} arg#{i}"
39
+ call_args << "&arg#{i}"
40
+ end
41
+
42
+ c_func = "#{return_type} #{name}(#{args.join(', ')})"
43
+ c_builder.c <<-EOF
44
+ #{c_func} {
45
+ f_#{name}(#{call_args.join(', ')});
46
+ }
47
+ EOF
48
+
49
+ f.puts src
50
+ f.puts
51
+ end
52
+ end
53
+
54
+ Dir.chdir File.dirname(src_name) do
55
+ cmd = "g95 -c -fno-underscoring #{File.basename(src_name)}"
56
+ $stderr.puts cmd if $DEBUG
57
+ system cmd
58
+ c_builder.add_link_flags "#{@mod}.o"
59
+ c_builder.add_link_flags "-lf95"
60
+ c_builder.build
61
+ c_builder.load
62
+ end
63
+ end
64
+ def load
65
+ end
66
+ end
67
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: InlineFortran
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2006-10-22 00:00:00 -06:00
8
+ summary: A RubyInline extension for Fortran
9
+ require_paths:
10
+ - lib
11
+ email: ryand-ruby@zenspider.com
12
+ homepage: " http://www.rubyforge.org/projects/rubyinline"
13
+ rubyforge_project: rubyinline
14
+ description: "== FEATURES/PROBLEMS: * Very rudimentary right now. Needs some love. == SYNOPSYS: inline :Fortran do |builder| builder.subroutine('print_integer', [\"void\", \"int\"], <<-END) subroutine print_integer( integer ) integer, intent(in) :: integer print *, 'integer: ', integer end END end == REQUIREMENTS:"
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Ryan Davis
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - demo/hello.rb
37
+ - lib/inline/fortran.rb
38
+ test_files: []
39
+
40
+ rdoc_options: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ requirements: []
49
+
50
+ dependencies:
51
+ - !ruby/object:Gem::Dependency
52
+ name: hoe
53
+ version_requirement:
54
+ version_requirements: !ruby/object:Gem::Version::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 1.1.2
59
+ version:
60
+ - !ruby/object:Gem::Dependency
61
+ name: RubyInline
62
+ version_requirement:
63
+ version_requirements: !ruby/object:Gem::Version::Requirement
64
+ requirements:
65
+ - - ">"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.0.0
68
+ version: