From b7ab85315eaed175687ccdc5cc779faee0b281b2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Nov 2011 16:21:26 +0100 Subject: [PATCH] Added vim files, parallel exit OK Version:1.2.6 --- example/uvwt.irp.f | 2 +- packages/irpf90.list | 5 ++++ src/irpf90.py | 3 +++ src/irpf90_t.py | 4 ++++ src/locks.py | 51 ++++++++++++++++++++++++++++++++++++++++ src/preprocessed_text.py | 4 ++-- src/util.py | 10 +++++--- src/version.py | 2 +- src/vim.py | 23 ++++++++++++++++++ vim/irpf90.vim | 7 +++++- 10 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 src/locks.py create mode 100644 src/vim.py diff --git a/example/uvwt.irp.f b/example/uvwt.irp.f index 63655a1..61d061d 100644 --- a/example/uvwt.irp.f +++ b/example/uvwt.irp.f @@ -8,7 +8,7 @@ END_PROVIDER BEGIN_PROVIDER [ integer, v ] v = u2+w+2 -END_PROVIDER +!END_PROVIDER BEGIN_PROVIDER [ integer, u1 ] integer :: fu diff --git a/packages/irpf90.list b/packages/irpf90.list index 20f6d1a..6d39c73 100644 --- a/packages/irpf90.list +++ b/packages/irpf90.list @@ -37,6 +37,7 @@ $prefix=/usr $exec_prefix=/usr $bindir=${exec_prefix}/bin $datadir=${exec_prefix}/share/irpf90/src +$vimdir=${exec_prefix}/share/irpf90/vim $docdir=${prefix}/share/irpf90/doc $mandir=${prefix}/man $srcdir=.. @@ -44,14 +45,18 @@ $srcdir=.. # Executables # ----------- + %system all %description IRP-Fortran90 preprocessor f 0444 root sys ${mandir}/man1/irpf90.1.gz ${srcdir}/man/man1/irpf90.1.gz f 0444 root sys ${mandir}/man1/irpman.1.gz ${srcdir}/man/man1/irpman.1.gz +f 0444 root sys ${vimdir}/irpf90.vim ${srcdir}/vim/irpf90.vim f 0555 root sys ${bindir}/irpf90 ${srcdir}/bin/irpf90 f 0555 root sys ${bindir}/irpman ${srcdir}/bin/irpman f 0555 root sys ${datadir}/ ${srcdir}/src/*.py f 0444 root sys ${docdir}/README ${srcdir}/README f 0444 root sys ${docdir}/LICENSE ${srcdir}/LICENSE +EOF + diff --git a/src/irpf90.py b/src/irpf90.py index f863132..1bf4501 100644 --- a/src/irpf90.py +++ b/src/irpf90.py @@ -26,6 +26,7 @@ +import vim import os,sys wd = os.path.abspath(os.path.dirname(__file__)) sys.setcheckinterval(1000) @@ -34,6 +35,8 @@ sys.path.insert(0,(wd+"/../src/")) def main(): from command_line import command_line + vim.install() + if command_line.do_help: command_line.usage() diff --git a/src/irpf90_t.py b/src/irpf90_t.py index 7508034..261cfb5 100644 --- a/src/irpf90_t.py +++ b/src/irpf90_t.py @@ -78,6 +78,7 @@ class Continue(Line): return "%20s:%5d : %s"%("Continue",self.i,self.text) class Begin_provider(Line): + str = "Provider" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): @@ -264,18 +265,21 @@ class End_select(Line): return "%20s:%5d : %s"%("End_select",self.i,self.text) class Program(Line): + str = "Program" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Program",self.i,self.text) class Subroutine(Line): + str = "Subroutine" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Subroutine",self.i,self.text) class Function(Line): + str = "Function" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): diff --git a/src/locks.py b/src/locks.py new file mode 100644 index 0000000..6d7848e --- /dev/null +++ b/src/locks.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# IRPF90 is a Fortran90 preprocessor written in Python for programming using +# the Implicit Reference to Parameters (IRP) method. +# Copyright (C) 2009 Anthony SCEMAMA +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Anthony Scemama +# LCPQ - IRSAMC - CNRS +# Universite Paul Sabatier +# 118, route de Narbonne +# 31062 Toulouse Cedex 4 +# scemama@irsamc.ups-tlse.fr + + +from command_line import command_line + +from irpf90_t import * +from util import * +from variables import variables +FILENAME=irpdir+'irp_locks.irp.F90' + +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() + +if __name__ == '__main__': + create() + diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index b15c008..56c7911 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -782,8 +782,8 @@ def check_begin_end(text): if type(line) == x: return if type(line) in [ Subroutine, Function, Program, Begin_provider ]: - error.fail(text[begin],type(line)+" is not closed") - error.fail(text[begin],type(line) + " is not closed") + error.fail(text[begin],type(line).str+" is not closed") + error.fail(text[begin],type(line).str + " is not closed") level = 0 diff --git a/src/util.py b/src/util.py index 14f0069..d20ff86 100644 --- a/src/util.py +++ b/src/util.py @@ -166,7 +166,6 @@ def parallel_loop(f,source): result = [] for filename, text in src[thread_id]: result.append( (filename, f(filename,text)) ) - result.sort() if fork == 0: @@ -174,11 +173,16 @@ def parallel_loop(f,source): w.close() os._exit(0) + OK = True + for i in xrange(1,NTHREADS): + if os.waitpid(pidlist[i],0)[1] != 0: + OK = False + if not OK: + sys.exit(1) + for i in xrange(1,NTHREADS): result += pickle.load(r[i]) r[i].close() - if os.waitpid(pidlist[i],0)[1] != 0: - raise OSError return result diff --git a/src/version.py b/src/version.py index a9d254a..fd95535 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.2.5" +version = "1.2.6" diff --git a/src/vim.py b/src/vim.py new file mode 100644 index 0000000..e409eb7 --- /dev/null +++ b/src/vim.py @@ -0,0 +1,23 @@ +#/usr/bin/python + +import os + +def install(): + VIM = os.environ["HOME"]+"/.vim" + try: + if os.access(VIM+"/syntax/irpf90.vim",os.F_OK): + return + if not os.access(VIM,os.F_OK): + os.mkdir(VIM) + file = open(VIM+"/filetype.vim","a") + file.write("au BufRead,BufNewFile *.irp.f setfiletype irpf90") + file.close() + if not os.access(VIM+"/syntax",os.F_OK): + os.mkdir(VIM+"/syntax") + wd = os.path.abspath(os.path.dirname(__file__))+"/../vim" + os.symlink(wd+"/irpf90.vim",VIM+"/syntax/irpf90.vim") + except: + pass + +if __name__ == "__main__": + install() diff --git a/vim/irpf90.vim b/vim/irpf90.vim index 9bb8f32..56e8d87 100644 --- a/vim/irpf90.vim +++ b/vim/irpf90.vim @@ -2,7 +2,7 @@ " Language: IRPF90 " Version: 0.1 " URL: -" Last Change: 2010 Jun. 9 +" Last Change: 2011 Nov. 9 " Maintainer: " Usage: Do :help irpf90-syntax from Vim " Credits: @@ -365,5 +365,10 @@ if !exists("did_irpf90_syn_inits") delcommand HiLink endif +fun! ReadMan() + let s:man_word = expand('') + :exe ":!irpman " . s:man_word +endfun +map K :call ReadMan() " vim: ts=8 tw=132