Method: CodeRunner::Run::FortranNamelist.get_variable_modules
- Defined in:
- lib/coderunner/fortran_namelist.rb
.get_variable_modules(folder = ) ⇒ Object Also known as: gvm
Work out which module a variable is found in
1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 |
# File 'lib/coderunner/fortran_namelist.rb', line 1329 def get_variable_modules(folder=ARGV[2]) text = get_aggregated_source_code_text(folder) #puts text modules = {} regex = /^\s*module\s+(\w+)((?:.|\n)*?)^\s*end\s+module\s+\g<1>/i #regex = /^\s*module\s+(\w+\b)/i p regex text.scan(regex) do p $~[1] modules[$~[1].to_sym] = $~[2] end #pp modules rcp.namelists.each do |nmlist, hash| hash[:variables].each do |var, varhash| #regex = Regexp.new("module\\s+(\\w+)(?:.|\\n)*?public.*?(#{var})(?:.|\\n)*?namelist(#{FORTRAN_SINGLE_LINE})(?:.|\\n)*?end\\s+module\\s+\\1") #regex = Regexp.new("module\\s+(\\w+)(?:.|\\n)*?public.*?(#{var})(?:.|\\n)*?namelist(#{FORTRAN_SINGLE_LINE})") #regex = Regexp.new("public.*?(#{var})(?:.|\\n)*?namelist#{FORTRAN_SINGLE_LINE}#{var}") regex = Regexp.new("namelist#{FORTRAN_SINGLE_LINE}#{var}") #p regex modules.each do |m, mod| mod.scan(regex) do varhash[:module] = m.to_sym end end end end save_namelists end |