Package madgraph :: Package iolibs :: Module file_writers :: Class FortranWriter
[hide private]
[frames] | no frames]

Class FortranWriter

source code

object --+        
         |        
      file --+    
             |    
    FileWriter --+
                 |
                FortranWriter

Routines for writing fortran lines. Keeps track of indentation and splitting of long lines

Nested Classes [hide private]
  FortranWriterError
Exception raised if an error occurs in the definition or the execution of a FortranWriter.

Inherited from FileWriter: FileWriterError

Instance Methods [hide private]
 
write_line(self, line)
Write a fortran line, with correct indent and line splits
source code
 
write_comment_line(self, line)
Write a comment line, with correct indent and line splits
source code
 
split_line(self, line, split_characters, line_start)
Split a line if it is longer than self.line_length columns.
source code

Inherited from FileWriter: __init__, write_comments, writelines

Inherited from file: __delattr__, __enter__, __exit__, __getattribute__, __iter__, __new__, __repr__, __setattr__, close, fileno, flush, isatty, next, read, readinto, readline, readlines, seek, tell, truncate, write, xreadlines

Inherited from object: __format__, __hash__, __reduce__, __reduce_ex__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  keyword_pairs = {'^do\\s+': ('^enddo\\s*$', 2), '^if.+then\\s*...
  single_indents = {'^else\\s*$': -2, '^else\\s*if.+then\\s*$': -2}
  number_re = re.compile(r'^(?P<num>\d+)\s+(?P<rest>.*)')
  line_cont_char = '$'
  comment_char = 'c'
  downcase = False
  line_length = 71
  max_split = 10
  split_characters = '+-*/,) '
  comment_split_characters = ' '
  __indent = 0
  __keyword_list = []
  __comment_pattern = re.compile(r'(?i)^(\s*#|c$|(c\s+([^=]|$)))')
Properties [hide private]

Inherited from file: closed, encoding, errors, mode, name, newlines, softspace

Inherited from object: __class__

Method Details [hide private]

write_line(self, line)

source code 

Write a fortran line, with correct indent and line splits

Overrides: FileWriter.write_line

write_comment_line(self, line)

source code 

Write a comment line, with correct indent and line splits

Overrides: FileWriter.write_comment_line

split_line(self, line, split_characters, line_start)

source code 

Split a line if it is longer than self.line_length columns. Split in preferential order according to split_characters, and start each new line with line_start.


Class Variable Details [hide private]

keyword_pairs

Value:
{'^do\\s+': ('^enddo\\s*$', 2),
 '^if.+then\\s*$': ('^endif', 2),
 '^subroutine': ('^end\\s*$', 0),
 'function': ('^end\\s*$', 0)}