Method: CodeRunner::Run::FortranNamelist#make_info_file
- Defined in:
- lib/coderunner/fortran_namelist.rb
#make_info_file(file = , strict = true) ⇒ Object
This method takes an input file and generates a CodeRunner info file. It should not be called in a folder where a CodeRunner info file already exists, as it will overwrite that info file with a less complete one.
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 |
# File 'lib/coderunner/fortran_namelist.rb', line 840 def make_info_file(file=ARGV[-1], strict=true) hash = self.class.parse_input_file(file, strict) # species_dependent_namelists = SPECIES_DEPENDENT_NAMELISTS.keys filename = File.dirname(file) + '/code_runner_info.rb' # (puts "Warning: An info file exists: if you continue it will be overwritten, and the original may contain more information. Press enter to continue, Crtl + C to cancel"; gets) if FileTest.exist? filename # pp hash, species_dependent_namelists # run= new(@@runner) hash.each do |namelist, vars| num = nil # ep namelist namelist = namelist.to_s.sub(/\_(?<num>\d+)$/, '').to_sym if $~ # I.e if there was a number at the end of the namelist # ep namelist raise "This namelist: #{namelist} should have an enumerator and does not have one" if not rcp.namelists[namelist][:enumerator] num = $~[:num] end vars.each do |var, value| #ep 'var', var var = (rcp.variable_names_from_code_names[var.to_sym] + (num ? "_#{num}" : "")).to_sym # p var, value set(var, value) end set(:run_name, file.sub(/\.in/, '')) # p 'hello' File.open(filename, 'w'){|file| file.puts info_file} File.open(".code_runner_version.txt", 'w'){|file| file.puts CODE_RUNNER_VERSION} end # end # ep @@variables end |