fortran 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.
data/History.txt ADDED
@@ -0,0 +1,5 @@
1
+ == 1.0.0 / 2007-07-26
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
5
+
data/License.txt ADDED
@@ -0,0 +1,263 @@
1
+ == LICENSE
2
+
3
+ NASA OPEN SOURCE AGREEMENT VERSION 1.3
4
+
5
+ THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE,
6
+ REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN
7
+ COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE UNITED STATES GOVERNMENT
8
+ AS REPRESENTED BY THE GOVERNMENT AGENCY LISTED BELOW ("GOVERNMENT
9
+ AGENCY"). THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT
10
+ AGENCY, IS AN INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT
11
+ DISTRIBUTIONS OR REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO
12
+ USES, REPRODUCES, DISTRIBUTES, MODIFIES OR REDISTRIBUTES THE SUBJECT
13
+ SOFTWARE, AS DEFINED HEREIN, OR ANY PART THEREOF, IS, BY THAT ACTION,
14
+ ACCEPTING IN FULL THE RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN
15
+ THIS AGREEMENT.
16
+
17
+ Government Agency: NASA Langley Research Center
18
+ Government Agency Original Software Designation: LAR-17081-1
19
+ Government Agency Original Software Title: fUnit
20
+ User Registration Requested: please see clause 3.F.
21
+ Government Agency Point of Contact: please see clause 5.F.
22
+
23
+ 1. DEFINITIONS
24
+
25
+ A. "Contributor" means Government Agency, as the developer of the
26
+ Original Software, and any entity that makes a Modification.
27
+
28
+ B. "Covered Patents" mean patent claims licensable by a Contributor
29
+ that are necessarily infringed by the use or sale of its Modification
30
+ alone or when combined with the Subject Software.
31
+
32
+ C. "Display" means the showing of a copy of the Subject Software,
33
+ either directly or by means of an image, or any other device.
34
+
35
+ D. "Distribution" means conveyance or transfer of the Subject
36
+ Software, regardless of means, to another.
37
+
38
+ E. "Larger Work" means computer software that combines Subject
39
+ Software, or portions thereof, with software separate from the Subject
40
+ Software that is not governed by the terms of this Agreement.
41
+
42
+ F. "Modification" means any alteration of, including addition to or
43
+ deletion from, the substance or structure of either the Original
44
+ Software or Subject Software, and includes derivative works, as that
45
+ term is defined in the Copyright Statute, 17 USC 101. However, the
46
+ act of including Subject Software as part of a Larger Work does not in
47
+ and of itself constitute a Modification.
48
+
49
+ G. "Original Software" means the computer software first released
50
+ under this Agreement by Government Agency with Government Agency
51
+ designation NASA and entitled fUnit, including source code,
52
+ object code and accompanying documentation, if any.
53
+
54
+ H. "Recipient" means anyone who acquires the Subject Software under
55
+ this Agreement, including all Contributors.
56
+
57
+ I. "Redistribution" means Distribution of the Subject Software after a
58
+ Modification has been made.
59
+
60
+ J. "Reproduction" means the making of a counterpart, image or copy of
61
+ the Subject Software.
62
+
63
+ K. "Sale" means the exchange of the Subject Software for money or
64
+ equivalent value.
65
+
66
+ L. "Subject Software" means the Original Software, Modifications, or
67
+ any respective parts thereof.
68
+
69
+ M. "Use" means the application or employment of the Subject Software
70
+ for any purpose.
71
+
72
+ 2. GRANT OF RIGHTS
73
+
74
+ A. Under Non-Patent Rights: Subject to the terms and conditions of
75
+ this Agreement, each Contributor, with respect to its own contribution
76
+ to the Subject Software, hereby grants to each Recipient a
77
+ non-exclusive, world-wide, royalty-free license to engage in the
78
+ following activities pertaining to the Subject Software:
79
+
80
+ 1. Use
81
+ 2. Distribution
82
+ 3. Reproduction
83
+ 4. Modification
84
+ 5. Redistribution
85
+ 6. Display
86
+
87
+ B. Under Patent Rights: Subject to the terms and conditions of this
88
+ Agreement, each Contributor, with respect to its own contribution to
89
+ the Subject Software, hereby grants to each Recipient under Covered
90
+ Patents a non-exclusive, world-wide, royalty-free license to engage in
91
+ the following activities pertaining to the Subject Software:
92
+
93
+ 1. Use
94
+ 2. Distribution
95
+ 3. Reproduction
96
+ 4. Sale
97
+ 5. Offer for Sale
98
+
99
+ C. The rights granted under Paragraph B. also apply to the combination
100
+ of a Contributor's Modification and the Subject Software if, at the
101
+ time the Modification is added by the Contributor, the addition of
102
+ such Modification causes the combination to be covered by the Covered
103
+ Patents. It does not apply to any other combinations that include a
104
+ Modification.
105
+
106
+ D. The rights granted in Paragraphs A. and B. allow the Recipient to
107
+ sublicense those same rights. Such sublicense must be under the same
108
+ terms and conditions of this Agreement.
109
+
110
+ 3. OBLIGATIONS OF RECIPIENT
111
+
112
+ A. Distribution or Redistribution of the Subject Software must be made
113
+ under this Agreement except for additions covered under paragraph 3H.
114
+
115
+ 1. Whenever a Recipient distributes or redistributes the Subject
116
+ Software, a copy of this Agreement must be included with each copy
117
+ of the Subject Software; and
118
+
119
+ 2. If Recipient distributes or redistributes the Subject Software in
120
+ any form other than source code, Recipient must also make the
121
+ source code freely available, and must provide with each copy of
122
+ the Subject Software information on how to obtain the source code
123
+ in a reasonable manner on or through a medium customarily used for
124
+ software exchange.
125
+
126
+ B. Each Recipient must ensure that the following copyright notice
127
+ appears prominently in the Subject Software:
128
+
129
+ Copyright 2007 United States Government as represented by
130
+ NASA Langley Research Center. No copyright is claimed in
131
+ the United States under Title 17, U.S. Code. All Other Rights
132
+ Reserved.
133
+
134
+ C. Each Contributor must characterize its alteration of the Subject
135
+ Software as a Modification and must identify itself as the originator
136
+ of its Modification in a manner that reasonably allows subsequent
137
+ Recipients to identify the originator of the Modification. In
138
+ fulfillment of these requirements, Contributor must include a file
139
+ (e.g., a change log file) that describes the alterations made and the
140
+ date of the alterations, identifies Contributor as originator of the
141
+ alterations, and consents to characterization of the alterations as a
142
+ Modification, for example, by including a statement that the
143
+ Modification is derived, directly or indirectly, from Original
144
+ Software provided by Government Agency. Once consent is granted, it
145
+ may not thereafter be revoked.
146
+
147
+ D. A Contributor may add its own copyright notice to the Subject
148
+ Software. Once a copyright notice has been added to the Subject
149
+ Software, a Recipient may not remove it without the express permission
150
+ of the Contributor who added the notice.
151
+
152
+ E. A Recipient may not make any representation in the Subject Software
153
+ or in any promotional, advertising or other material that may be
154
+ construed as an endorsement by Government Agency or by any prior
155
+ Recipient of any product or service provided by Recipient, or that may
156
+ seek to obtain commercial advantage by the fact of Government Agency's
157
+ or a prior Recipient's participation in this Agreement.
158
+
159
+ F. In an effort to track usage and maintain accurate records of the
160
+ Subject Software, each Recipient, upon receipt of the Subject Software,
161
+ is requested to provide Government Agency, by e-mail to the Government
162
+ Agency Point of Contact listed in clause 5.F., the following information:
163
+ name, institution (if applicable), postal code, and country.
164
+ Recipient's name and personal information shall be used for statistical
165
+ purposes only. Once a Recipient makes a Modification available, it is
166
+ requested that the Recipient inform Government Agency, by e-mail to the
167
+ Government Agency Point of Contact listed in clause 5.F., how to
168
+ access the Modification.
169
+
170
+ G. Each Contributor represents that that its Modification is believed
171
+ to be Contributor's original creation and does not violate any
172
+ existing agreements, regulations, statutes or rules, and further that
173
+ Contributor has sufficient rights to grant the rights conveyed by this
174
+ Agreement.
175
+
176
+ H. A Recipient may choose to offer, and to charge a fee for, warranty,
177
+ support, indemnity and/or liability obligations to one or more other
178
+ Recipients of the Subject Software. A Recipient may do so, however,
179
+ only on its own behalf and not on behalf of Government Agency or any
180
+ other Recipient. Such a Recipient must make it absolutely clear that
181
+ any such warranty, support, indemnity and/or liability obligation is
182
+ offered by that Recipient alone. Further, such Recipient agrees to
183
+ indemnify Government Agency and every other Recipient for any
184
+ liability incurred by them as a result of warranty, support, indemnity
185
+ and/or liability offered by such Recipient.
186
+
187
+ I. A Recipient may create a Larger Work by combining Subject Software
188
+ with separate software not governed by the terms of this agreement and
189
+ distribute the Larger Work as a single product. In such case, the
190
+ Recipient must make sure Subject Software, or portions thereof,
191
+ included in the Larger Work is subject to this Agreement.
192
+
193
+ J. Notwithstanding any provisions contained herein, Recipient is
194
+ hereby put on notice that export of any goods or technical data from
195
+ the United States may require some form of export license from the
196
+ U.S. Government. Failure to obtain necessary export licenses may
197
+ result in criminal liability under U.S. laws. Government Agency
198
+ neither represents that a license shall not be required nor that, if
199
+ required, it shall be issued. Nothing granted herein provides any
200
+ such export license.
201
+
202
+ 4. DISCLAIMER OF WARRANTIES AND LIABILITIES; WAIVER AND INDEMNIFICATION
203
+
204
+ A. No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY
205
+ WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY,
206
+ INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE
207
+ WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF
208
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM
209
+ INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR
210
+ FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO
211
+ THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER,
212
+ CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT
213
+ OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY
214
+ OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.
215
+ FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES
216
+ REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE,
217
+ AND DISTRIBUTES IT "AS IS."
218
+
219
+ B. Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS
220
+ AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND
221
+ SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF
222
+ THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
223
+ EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM
224
+ PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT
225
+ SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED
226
+ STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
227
+ PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE
228
+ REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL
229
+ TERMINATION OF THIS AGREEMENT.
230
+
231
+ 5. GENERAL TERMS
232
+
233
+ A. Termination: This Agreement and the rights granted hereunder will
234
+ terminate automatically if a Recipient fails to comply with these
235
+ terms and conditions, and fails to cure such noncompliance within
236
+ thirty (30) days of becoming aware of such noncompliance. Upon
237
+ termination, a Recipient agrees to immediately cease use and
238
+ distribution of the Subject Software. All sublicenses to the Subject
239
+ Software properly granted by the breaching Recipient shall survive any
240
+ such termination of this Agreement.
241
+
242
+ B. Severability: If any provision of this Agreement is invalid or
243
+ unenforceable under applicable law, it shall not affect the validity
244
+ or enforceability of the remainder of the terms of this Agreement.
245
+
246
+ C. Applicable Law: This Agreement shall be subject to United States
247
+ federal law only for all purposes, including, but not limited to,
248
+ determining the validity of this Agreement, the meaning of its
249
+ provisions and the rights, obligations and remedies of the parties.
250
+
251
+ D. Entire Understanding: This Agreement constitutes the entire
252
+ understanding and agreement of the parties relating to release of the
253
+ Subject Software and may not be superseded, modified or amended except
254
+ by further written agreement duly executed by the parties.
255
+
256
+ E. Binding Authority: By accepting and using the Subject Software
257
+ under this Agreement, a Recipient affirms its authority to bind the
258
+ Recipient to all terms and conditions of this Agreement and that that
259
+ Recipient hereby agrees to all terms and conditions herein.
260
+
261
+ F. Point of Contact: Any Recipient contact with Government Agency is
262
+ to be directed to the designated representative as follows:
263
+ Bil.Kleb@NASA.gov
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/fortran.rb
7
+ test/test_fortran.rb
data/README.txt ADDED
@@ -0,0 +1,26 @@
1
+ fortran
2
+
3
+ * http://rubyforge.org/projects/nasarb
4
+ * http://nasarb.rubyforge.org
5
+ * mailto:Bil.Kleb@NASA.gov
6
+
7
+ == DESCRIPTION:
8
+
9
+ * Provides Fortran 90/95/2003 makefile dependencies.
10
+
11
+ == SYNOPSIS:
12
+
13
+ * <tt>fortran</tt>
14
+
15
+ == REQUIREMENTS:
16
+
17
+ * Ruby with Rubygems
18
+
19
+ == INSTALL:
20
+
21
+ * <tt>sudo gem install fortran</tt>
22
+
23
+ == LICENSE
24
+
25
+ Released under the NASA Open Source Agreement -- see License.txt[link:files/License_txt.html] for details.
26
+
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ $:.unshift File.join( File.dirname(__FILE__), 'lib' )
7
+ require 'fortran'
8
+
9
+ Hoe.new('fortran', Fortran::VERSION) do |p|
10
+ p.rubyforge_name = 'nasarb'
11
+ p.author = ['Bil Kleb','Mike Park','Bill Wood']
12
+ p.email = 'Bil.Kleb@NASA.gov'
13
+ p.summary = 'Fortran 90/95/2003 utilities.'
14
+ p.description = p.paragraphs_of('README.txt', 3..4).join("\n\n")
15
+ p.url = p.paragraphs_of('README.txt', 1).first.gsub(/^\* /, '').split(/\n/)
16
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
17
+ end
data/lib/fortran.rb ADDED
@@ -0,0 +1,134 @@
1
+ module Fortran
2
+
3
+ VERSION = '1.0.0'
4
+
5
+ ##
6
+ # Find Fortran file dependencies
7
+
8
+ class Dependencies
9
+
10
+ OPTIONS = { :search_paths => [ '.', '../lib' ],
11
+ :ignore_files => %r{ },
12
+ :ignore_modules => %r{ },
13
+ :ignore_symlinks => true }
14
+
15
+ USE_MODULE_REGEX = /^\s*use\s+(\w+)/i
16
+ MODULE_DEF_REGEX = /^\s*module\s+(\w+)/i
17
+
18
+ FILE_EXTENSION = /\.f90$/i
19
+
20
+ attr_reader :file_dependencies, :source_files
21
+
22
+ def initialize( config=OPTIONS )
23
+ @config = config
24
+ OPTIONS.each{ |opt,default| @config[opt] = default unless @config.has_key? opt }
25
+ @parsed, @file_dependencies, @source_files = [], {}, []
26
+ @hash = build_hash_of_modules_in_files
27
+ self
28
+ end
29
+
30
+ def modules_used_in( file )
31
+ modules = IO.readlines( file ).map do |line|
32
+ $1.downcase if line.match USE_MODULE_REGEX
33
+ end.uniq.compact
34
+ end
35
+
36
+ def modules_defined_in( file )
37
+ modules = IO.readlines( file ).map do |line|
38
+ $1.downcase if line.match MODULE_DEF_REGEX
39
+ end.uniq.compact
40
+ end
41
+
42
+ def build_dictionary_of_modules( files )
43
+ file_containing_module = {}
44
+ files.each do |file|
45
+ modules_defined_in( file ).each{ |mod| file_containing_module[mod]=file }
46
+ end
47
+ file_containing_module
48
+ end
49
+
50
+ def find_fortran_files
51
+ source = @config[:search_paths].map{ |path| Dir[path+"/*.[fF]90"] }
52
+ source.flatten!.uniq!
53
+ source.delete_if{ |file| File.lstat(file).symlink? } if @config[:ignore_symlinks]
54
+ source.delete_if{ |file| file.match @config[:ignore_files] }
55
+ end
56
+
57
+ def build_hash_of_modules_in_files
58
+ build_dictionary_of_modules find_fortran_files
59
+ end
60
+
61
+ def makefile_dependency_line( source )
62
+ real_source = source.sub(/PHYSICS_DUMMY/,'PHYSICS_MODULES')# FIXME: What's this?!
63
+ source_no_path = File.basename source
64
+ @source_files.push source_no_path.gsub(%r|^.*/|,'')
65
+ output = ''
66
+ if (File.expand_path(source) != File.expand_path(source_no_path))
67
+ output += source_no_path+ ": " + real_source + "\n"
68
+ output += "\tln -sf "+real_source+" .\n"
69
+ end
70
+ output += source.gsub(FILE_EXTENSION, ".o").gsub(%r|^.*/|,'' ) +
71
+ ": " + source.gsub(%r|^.*/|,"" )
72
+ modules_used_in( source ).each do |use|
73
+ unless @hash[use]
74
+ unless use.match @config[:ignore_modules]
75
+ $stderr.puts 'Warning: unable to locate module #{use} used in #{source}.'
76
+ $stderr.puts ' set :search_paths or :ignore_module_regex options.'
77
+ end
78
+ next
79
+ end
80
+ output = output + " \\\n " +
81
+ @hash[use].gsub(FILE_EXTENSION, ".o").gsub(%r|^.*/|,'' )
82
+ end
83
+ output+"\n"
84
+ end
85
+
86
+ def dependencies( start )
87
+ modules = modules_used_in( start )
88
+ @parsed = @parsed || [start]
89
+ new_source_files = modules.collect{ |mod| @hash[mod] }.compact
90
+ makefile_dependency_line(start) +
91
+ new_source_files.collect do |file|
92
+ next if @parsed.include?(file)
93
+ @parsed.push file
94
+ dependencies file
95
+ end.to_s
96
+ end
97
+
98
+ def source_file_dependencies( head_f90 )
99
+ modules_head_uses = modules_used_in( head_f90 )
100
+ required_f90s = modules_head_uses.map{ |mod| @hash[mod] }.compact
101
+ @file_dependencies[head_f90] = required_f90s
102
+ required_f90s.each do |required_f90|
103
+ next if @parsed.include?(required_f90)
104
+ source_file_dependencies( required_f90 )
105
+ end
106
+ @parsed.push head_f90
107
+ end
108
+
109
+ def required_source_files( head_f90 )
110
+ @parsed.clear
111
+ source_file_dependencies( head_f90 )
112
+ sources = []
113
+ until @file_dependencies.empty? do
114
+ no_dependents_pair = @file_dependencies.detect{ |h,d| d == [] }
115
+ no_dependents = no_dependents_pair.first
116
+ sources.push no_dependents
117
+ @file_dependencies.delete(no_dependents){ |el| "#{el} not found" }
118
+ @file_dependencies.each_value{ |deps| deps.delete(no_dependents) }
119
+ end
120
+ sources
121
+ end
122
+
123
+ end
124
+ end
125
+
126
+ #--
127
+ # Copyright 2007 United States Government as represented by
128
+ # NASA Langley Research Center. No copyright is claimed in
129
+ # the United States under Title 17, U.S. Code. All Other Rights
130
+ # Reserved.
131
+ #
132
+ # This file is governed by the NASA Open Source Agreement.
133
+ # See License.txt for details.
134
+ #++
@@ -0,0 +1,173 @@
1
+ require 'test/unit'
2
+ require 'fortran'
3
+ require 'fileutils'
4
+
5
+ class TestFortran < Test::Unit::TestCase
6
+
7
+ def setup
8
+ Dir.mkdir 'DependenciesFixture'
9
+ Dir.chdir 'DependenciesFixture' # FIXME: use block form for readability
10
+ Dir.mkdir 'lib'
11
+ Dir.chdir 'lib'
12
+ File.open('solution.f90','w') do |f|
13
+ f.puts "module solution\nuse area\nend module solution"
14
+ end
15
+ Dir.chdir '..'
16
+ Dir.mkdir 'src'
17
+ Dir.chdir 'src'
18
+ File.open('main.F90','w') do |f|
19
+ f.puts 'program whizzard'
20
+ f.puts " use grid\n use solution\n use circle"
21
+ f.puts 'end program whizzard'
22
+ end
23
+ File.open('grid.f90','w') do |f|
24
+ f.puts "module grid\nuse area\nend module grid"
25
+ end
26
+ File.open('shapes.f90','w') do |f|
27
+ f.puts "module rectangle_fun3d\nend module rectangle_fun3d"
28
+ f.puts "module circle\n use area\nend module circle"
29
+ end
30
+ File.open('area.f90','w'){ |f| f.puts "module area\nend module area" }
31
+ File.open('externalUse.f90','w') do |f|
32
+ f.puts "program user\nuse cantFindModule\nend program"
33
+ end
34
+ @dep = Fortran::Dependencies.new
35
+ end
36
+
37
+ def teardown
38
+ Dir.chdir '../..'
39
+ FileUtils.rm_rf 'DependenciesFixture'
40
+ end
41
+
42
+ def test_finds_which_modules_a_source_file_uses
43
+ assert_equal %w[grid solution circle], @dep.modules_used_in( 'main.F90' )
44
+ end
45
+
46
+ def test_finds_modules_defined_in_source_file
47
+ assert_equal %w[rectangle_fun3d circle],
48
+ @dep.modules_defined_in( 'shapes.f90' )
49
+ end
50
+
51
+ def test_create_module_definition_hash
52
+ assert_equal %w[circle rectangle_fun3d],
53
+ @dep.build_dictionary_of_modules( 'shapes.f90' ).keys.sort
54
+ end
55
+
56
+ def test_locating_all_fortran_files_in_search_path
57
+ files = %w[ ../lib/solution.f90 ./area.f90 ./externalUse.f90
58
+ ./grid.f90 ./main.F90 ./shapes.f90 ]
59
+ @dep.find_fortran_files.each do |file|
60
+ assert files.include?(file)
61
+ end
62
+ end
63
+
64
+ def test_build_hash_with_source_files
65
+ f90 = %w[./grid.f90 ../lib/solution.f90 ./shapes.f90 ./area.f90]
66
+ hash = @dep.build_dictionary_of_modules( f90 )
67
+ assert_equal %w[ ./shapes.f90 ./shapes.f90 ./area.f90
68
+ ../lib/solution.f90 ./grid.f90 ].sort,
69
+ hash.values.sort
70
+ assert_equal %w[ rectangle_fun3d circle area solution grid ].sort,
71
+ hash.keys.sort
72
+ assert_equal hash , @dep.build_hash_of_modules_in_files
73
+ end
74
+
75
+ def test_dependency_generation_elements
76
+ directoryHash = @dep.build_hash_of_modules_in_files
77
+
78
+ source_file = "main.F90"
79
+ modules = @dep.modules_used_in( source_file )
80
+ assert_equal %w[grid solution circle], modules
81
+
82
+ new_source_files = modules.collect{ |mod| directoryHash[mod] }
83
+ assert_equal %w[ ./grid.f90 ../lib/solution.f90 ./shapes.f90],
84
+ new_source_files
85
+
86
+ new_modules = new_source_files.collect do |file|
87
+ @dep.modules_used_in( file )
88
+ end.flatten.uniq
89
+
90
+ assert_equal ["area"], new_modules
91
+ end
92
+
93
+ def test_makefile_dependency_line_generation
94
+ source_file = "main.F90"
95
+ make_golden=String.new <<-GOLDEN
96
+ main.o: main.F90 \\
97
+ grid.o \\
98
+ solution.o \\
99
+ shapes.o
100
+ GOLDEN
101
+ assert_equal make_golden, @dep.makefile_dependency_line(source_file)
102
+ end
103
+
104
+ def test_makefile_dependency_recurses_properly
105
+ make_golden=String.new <<-GOLDEN
106
+ main.o: main.F90 \\
107
+ grid.o \\
108
+ solution.o \\
109
+ shapes.o
110
+ grid.o: grid.f90 \\
111
+ area.o
112
+ area.o: area.f90
113
+ solution.f90: ../lib/solution.f90
114
+ \tln -sf ../lib/solution.f90 .
115
+ solution.o: solution.f90 \\
116
+ area.o
117
+ shapes.o: shapes.f90 \\
118
+ area.o
119
+ GOLDEN
120
+
121
+ gold_split = make_golden.split("\n")
122
+ test_split = @dep.dependencies('main.F90').split("\n")
123
+
124
+ while (gold = gold_split.shift) && (test = test_split.shift)
125
+ assert_equal gold, test
126
+ end
127
+ end
128
+
129
+ def test_source_file_dependency_hash
130
+ @dep.source_file_dependencies('main.F90')
131
+ assert_equal( 5, @dep.file_dependencies.size )
132
+ expected = {
133
+ "./area.f90" => [],
134
+ "./grid.f90" => ["./area.f90"],
135
+ "../lib/solution.f90" => ["./area.f90"],
136
+ "./shapes.f90" => ["./area.f90"],
137
+ "main.F90" => ["./grid.f90", "../lib/solution.f90", "./shapes.f90"]
138
+ }
139
+ assert_equal expected, @dep.file_dependencies
140
+ end
141
+
142
+ def test_finds_required_source_files
143
+ expected = %w[ ./area.f90 ./shapes.f90 ../lib/solution.f90
144
+ ./grid.f90 ./main.F90 ]
145
+ found = @dep.required_source_files('./main.F90')
146
+ assert_equal expected.size, found.size
147
+ assert_equal './main.F90', found.last
148
+ assert_equal './area.f90', found.first
149
+ end
150
+
151
+ def test_finds_required_source_files_unordered
152
+ @dep.dependencies('main.F90')
153
+ sources = @dep.source_files
154
+ expected = %w[ main.F90 grid.f90 area.f90 solution.f90 shapes.f90 ]
155
+ assert_equal expected.size, sources.size
156
+ assert_equal 'shapes.f90', sources.last
157
+ assert_equal 'main.F90', sources.first
158
+ assert_equal expected, sources
159
+ end
160
+
161
+ def test_can_find_required_source_files_twice
162
+ files = %w[ ./main.F90 ./shapes.f90 ./area.f90
163
+ ../lib/solution.f90 ./grid.f90 ]
164
+ @dep.required_source_files('./main.F90')
165
+ assert_equal files.sort, @dep.required_source_files('./main.F90').sort
166
+ end
167
+
168
+ def test_recognizes_external_modules
169
+ file = './externalUse.f90'
170
+ assert_equal [file], @dep.required_source_files(file).sort
171
+ end
172
+
173
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: fortran
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2007-08-01 00:00:00 -04:00
8
+ summary: Fortran 90/95/2003 utilities.
9
+ require_paths:
10
+ - lib
11
+ email: Bil.Kleb@NASA.gov
12
+ homepage: http://rubyforge.org/projects/nasarb
13
+ rubyforge_project: nasarb
14
+ description: "* Provides Fortran 90/95/2003 makefile dependencies. == SYNOPSIS:"
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
+ - Bil Kleb
31
+ - Mike Park
32
+ - Bill Wood
33
+ files:
34
+ - History.txt
35
+ - License.txt
36
+ - Manifest.txt
37
+ - README.txt
38
+ - Rakefile
39
+ - lib/fortran.rb
40
+ - test/test_fortran.rb
41
+ test_files:
42
+ - test/test_fortran.rb
43
+ rdoc_options:
44
+ - --main
45
+ - README.txt
46
+ extra_rdoc_files:
47
+ - History.txt
48
+ - License.txt
49
+ - Manifest.txt
50
+ - README.txt
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ requirements: []
56
+
57
+ dependencies:
58
+ - !ruby/object:Gem::Dependency
59
+ name: hoe
60
+ version_requirement:
61
+ version_requirements: !ruby/object:Gem::Version::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.2.2
66
+ version: