Example #1
0
def create():
  out = []
  l = variables.keys()
  l.sort
  main_modules = filter(lambda x: modules[x].is_main, modules)
  finalize = "subroutine irp_finalize_%s\n"%(irp_id)
  for m in filter(lambda x: not modules[x].is_main, modules):
    finalize += " use %s\n"%(modules[m].name)
  for v in l:
    var = variables[v]
    var_in_main = False
    for m in main_modules:
      if var.fmodule == modules[m].name:
        var_in_main = True
        break
    if not var_in_main:
      if var.is_touched:
        out += var.toucher
      if var.dim != []:
        finalize += "  if (allocated(%s)) then\n"%v
        finalize += "    %s_is_built = .False.\n"%var.same_as
        finalize += "    deallocate(%s)\n"%v
        finalize += "  endif\n"
  finalize += "end\n"


  if out != []:
    out = map(lambda x: "%s\n"%(x),out)

  out += finalize
  
  if not same_file(FILENAME,out):
    file = open(FILENAME,'w')
    file.writelines(out)
    file.close()
Example #2
0
def run():
    import parsed_text
    import os, sys
    if os.fork() == 0:
        for v in variables.values():
            do_print(v)
        for s in subroutines.values():
            do_print_subroutines(s)
        sys.exit(0)

    if os.fork() == 0:
        tags = []
        l = variables.keys()
        file = open("irpf90_entities", "w")
        l.sort()
        for v in l:
            do_print_short(file, variables[v])
            line = variables[v].line
            #     tags.append( '%s\t%s\t/%s/;"\n'%(v,line.filename[0],line.text.split('!')[0].strip()) )
            tags.append('%s\t%s\t%d\n' % (v, line.filename[0], line.i))
        file.close()
        l = subroutines.keys()
        for v in l:
            line = subroutines[v].line
            #     tags.append('%s\t%s\t/%s/;"\n'%(v,line.filename,line.text.split('!')[0].strip()))
            tags.append('%s\t%s\t%d\n' % (v, line.filename, line.i))
        tags.sort()
        file = open("tags", "w")
        for line in tags:
            file.write(line)
        file.close()
        sys.exit(0)
Example #3
0
def create():
  out = []
  l = variables.keys()
  l.sort
  main_modules = filter(lambda x: modules[x].is_main, modules)
  finalize = "subroutine irp_finalize_%s\n"%(irp_id)
  for m in filter(lambda x: not modules[x].is_main, modules):
    finalize += " use %s\n"%(modules[m].name)
  for v in l:
    var = variables[v]
    var_in_main = False
    for m in main_modules:
      if var.fmodule == modules[m].name:
        var_in_main = True
        break
    if not var_in_main:
      if var.is_touched:
        out += var.toucher
      if var.dim != []:
        finalize += "  if (allocated(%s)) then\n"%v
        finalize += "    %s_is_built = .False.\n"%var.same_as
        finalize += "    deallocate(%s)\n"%v
        finalize += "  endif\n"
  finalize += "end\n"


  if out != []:
    out = map(lambda x: "%s\n"%(x),out)

  out += finalize
  
  if not same_file(FILENAME,out):
    file = open(FILENAME,'w')
    file.writelines(out)
    file.close()
Example #4
0
def create():
  out_write      = [ "subroutine irp_checkpoint_write" ] 
  l = variables.keys()
  l.sort
  main_modules = filter(lambda x: modules[x].is_main, modules)
  for m in filter(lambda x: not modules[x].is_main, modules):
    out_write   += [ "  use %s"%(modules[m].name) ]
  out_write     += [ "  implicit none" ]
  out_write     += [ "  integer, parameter :: iunit = %d"%(CHECKPOINT_UNIT_NUMBER) ]
  out_write     += [ "  open(unit=%d,file='irp_checkpoint.dat',status='UNKNOWN',action='WRITE')"%(CHECKPOINT_UNIT_NUMBER) ]
  for v in l:
    var = variables[v]
    if var.is_main:
      out_write     += [ "  if (%s_is_built) then"%(v) ]
      for w in [v]+var.others:
        d = variables[w].dim
        if d == []:
          out_write += [ "    write(iunit,*) '%s', 0"%(w) ]
        else:
          out_write += [ "    write(iunit, *) '%s', %d"%(w, len(d)),  
                        "    write(iunit, *) %s"%(",".join(
                        [ "size(%s,%d)"%(w,i+1) for i in range(len(d)) ] ))
                       ]
        out_write   += [ "    write(iunit,*) %s"%(w) ]
      out_write     += [ "  endif" ]
  out_write         += [ "  close(%d)"%(CHECKPOINT_UNIT_NUMBER) ]
  out_write         += [ "end" ]

  out = '\n'.join(out_write)
  if not same_file(FILENAME,out):
    file = open(FILENAME,'w')
    file.writelines(out)
    file.close()
Example #5
0
def create():
    out = []
    l = variables.keys()
    l.sort
    for v in l:
        var = variables[v]
        out += var.locker

    out = map(lambda x: "%s\n" % (x), out)
    if not same_file(FILENAME, out):
        file = open(FILENAME, "w")
        file.writelines(out)
        file.close()
Example #6
0
def run():
  import parsed_text
  import os,sys
  if os.fork() == 0:
    for v in variables.values():
      do_print(v)
    sys.exit(0)

  if os.fork() == 0:
    l = variables.keys()
    file = open("irpf90_entities","w")
    l.sort()
    for v in l:
      do_print_short(file,variables[v])
    file.close()
    sys.exit(0)
Example #7
0
def create():
    out = []
    l = variables.keys()
    l.sort
    for v in l:
        var = variables[v]
        out += var.locker

    out += ["subroutine irp_init_locks_%s()" % (irp_id), " implicit none"]
    for v in l:
        out += ["  call irp_lock_%s(.True.)" % v]
        out += ["  call irp_lock_%s(.False.)" % v]
    out += ["end subroutine"]
    out = map(lambda x: "%s\n" % (x), out)
    if not same_file(FILENAME, out):
        file = open(FILENAME, 'w')
        file.writelines(out)
        file.close()
Example #8
0
def create():
  out = []
  l = variables.keys()
  l.sort
  for v in l:
    var = variables[v]
    out += var.locker

  out += [
"subroutine irp_init_locks_%s()"%(irp_id),
" implicit none" ]
  for v in l:
    out += [ "  call irp_lock_%s(.True.)"%v ]
    out += [ "  call irp_lock_%s(.False.)"%v ]
  out += [ "end subroutine" ]
  out = map(lambda x: "%s\n"%(x),out)
  if not same_file(FILENAME,out):
    file = open(FILENAME,'w')
    file.writelines(out)
    file.close()
Example #9
0
def create():
    out_write = ["subroutine irp_checkpoint_write"]
    l = variables.keys()
    l.sort
    main_modules = filter(lambda x: modules[x].is_main, modules)
    for m in filter(lambda x: not modules[x].is_main, modules):
        out_write += ["  use %s" % (modules[m].name)]
    out_write += ["  implicit none"]
    out_write += [
        "  integer, parameter :: iunit = %d" % (CHECKPOINT_UNIT_NUMBER)
    ]
    out_write += [
        "  open(unit=%d,file='irp_checkpoint.dat',status='UNKNOWN',action='WRITE')"
        % (CHECKPOINT_UNIT_NUMBER)
    ]
    for v in l:
        var = variables[v]
        if var.is_main:
            out_write += ["  if (%s_is_built) then" % (v)]
            for w in [v] + var.others:
                d = variables[w].dim
                if d == []:
                    out_write += ["    write(iunit,*) '%s', 0" % (w)]
                else:
                    out_write += [
                        "    write(iunit, *) '%s', %d" % (w, len(d)),
                        "    write(iunit, *) %s" % (",".join([
                            "size(%s,%d)" % (w, i + 1) for i in range(len(d))
                        ]))
                    ]
                out_write += ["    write(iunit,*) %s" % (w)]
            out_write += ["  endif"]
    out_write += ["  close(%d)" % (CHECKPOINT_UNIT_NUMBER)]
    out_write += ["end"]

    out = '\n'.join(out_write)
    if not same_file(FILENAME, out):
        file = open(FILENAME, 'w')
        file.writelines(out)
        file.close()
Example #10
0
def run():
  import parsed_text
  import os,sys
  pid1 = os.fork()
  if pid1 == 0:
    for v in variables.values():
      do_print(v)
    for s in subroutines.values():
      do_print_subroutines(s)
    sys.exit(0)

  pid2 = os.fork()
  if pid2 == 0:
    tags = []
    l = variables.keys()
    file = open("irpf90_entities","w")
    l.sort()
    for v in l:
      do_print_short(file,variables[v])
      line = variables[v].line
#     tags.append( '%s\t%s\t/%s/;"\n'%(v,line.filename[0],line.text.split('!')[0].strip()) )
      tags.append( '%s\t%s\t%d\n'%(v,line.filename[0],line.i) )
    file.close()
    l = subroutines.keys()
    for v in l:
      line = subroutines[v].line
#     tags.append('%s\t%s\t/%s/;"\n'%(v,line.filename,line.text.split('!')[0].strip()))
      tags.append('%s\t%s\t%d\n'%(v,line.filename,line.i))
    tags.sort()
    file = open("tags","w")
    for line in tags:
      file.write(line)
    file.close()
    sys.exit(0)

  os.waitpid(pid1,0)
  os.waitpid(pid2,0)
Example #11
0
#   LCPQ - IRSAMC - CNRS
#   Universite Paul Sabatier
#   118, route de Narbonne
#   31062 Toulouse Cedex 4
#   [email protected]


from util import *
from irpf90_t import *
from variables import variables
from preprocessed_text import preprocessed_text
from subroutines import subroutines
import regexps, re
import error

vtuple = map(lambda v: (v, variables[v].same_as, variables[v].regexp), variables.keys())
stuple = map(lambda s: (s, subroutines[s].regexp), subroutines.keys())
stuple = filter(lambda s: subroutines[s[0]].is_function, stuple)
re_string_sub = regexps.re_string.sub

regexps_re_string_sub = regexps.re_string.sub
def find_variables_in_line(line):
  assert isinstance(line,Line)
  result = []
  sub_done = False
  buffer = line.lower
  ap = result.append
  for v,same_as,regexp in vtuple:
    if v in buffer:
      if not sub_done:
        buffer = regexps_re_string_sub('',buffer)
Example #12
0
#   LCPQ - IRSAMC - CNRS
#   Universite Paul Sabatier
#   118, route de Narbonne
#   31062 Toulouse Cedex 4
#   [email protected]

from util import *
from irpf90_t import *
from variables import variables
from preprocessed_text import preprocessed_text
from subroutines import subroutines
import regexps, re
import error

vtuple = map(lambda v: (v, variables[v].same_as, variables[v].regexp),
             variables.keys())
stuple = map(lambda s: (s, subroutines[s].regexp), subroutines.keys())
stuple = filter(lambda s: subroutines[s[0]].is_function, stuple)
re_string_sub = regexps.re_string.sub

regexps_re_string_sub = regexps.re_string.sub


def find_variables_in_line(line):
    assert isinstance(line, Line)
    result = []
    sub_done = False
    buffer = line.lower
    ap = result.append
    for v, same_as, regexp in vtuple:
        if v in buffer: