From 5a3af0649a1c4624f1bb1868f79789174a2e637e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 8 Oct 2014 22:56:54 +0200 Subject: [PATCH] Locks initialized in openmp mode --- README.md | 20 +++++++++----------- bin/irpman | 2 +- src/locks.py | 7 +++++++ src/preprocessed_text.py | 2 ++ src/variable.py | 10 +++++----- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3c54fc9..125bb9a 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ IRPF90 IRPF90 is a Fortran90 preprocessor written in Python for programming using the Implicit Reference to Parameters (IRP) method. It simplifies the development of large fortran codes in the field of scientific high performance computing. -![IRPF90 Logo](Irpf90.xpm) - Dependencies ------------ @@ -18,14 +16,14 @@ Installing IRPF90 ``${IRPF90_HOME}`` is the location of your irpf90 directory:: ``` bash - cd ${IRPF90_HOME} - make - cat << EOF >> ${HOME}/.bash_profile - export PYTHONPATH=${IRPF90_HOME}/src:${PYTHONPATH} - export PATH=${IRPF90_HOME}/bin:${PATH} - export MANPATH=${IRPF90_HOME}/man:${MANPATH} - EOF - . ${HOME}/.bash_profile +cd ${IRPF90_HOME} +make +cat << EOF >> ${HOME}/.bash_profile +export PYTHONPATH=${IRPF90_HOME}/src:${PYTHONPATH} +export PATH=${IRPF90_HOME}/bin:${PATH} +export MANPATH=${IRPF90_HOME}/man:${MANPATH} +EOF +source ${HOME}/.bash_profile ``` @@ -35,7 +33,7 @@ Using IRPF90 In an empty directory, run: ``` bash - irpf90 --init +irpf90 --init ``` This command creates a new Makefile suitable for most irpf90 projects. diff --git a/bin/irpman b/bin/irpman index 175af7a..91d463c 100755 --- a/bin/irpman +++ b/bin/irpman @@ -33,7 +33,7 @@ case "$0" in local cur COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} - COMPREPLY=( $(compgen -W "`cat tags | cut -d' ' -f 1`" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "`[[ -f tags ]] && cat tags | cut -d' ' -f 1`" -- "$cur" ) ) } && complete -F _irpman_complete irpman ;; diff --git a/src/locks.py b/src/locks.py index 6d7848e..fff745b 100644 --- a/src/locks.py +++ b/src/locks.py @@ -40,6 +40,13 @@ def create(): 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') diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index e58a8f5..c479f0e 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -627,6 +627,8 @@ def irp_simple_statements(text): temp = [ Program(0,"program irp_program",program_name) ] if command_line.do_profile: temp += [ Simple_line(0,"call irp_init_timer()",line.filename) ] + if command_line.do_openmp: + temp += [ Simple_line(0," call irp_init_locks_%s()"%(irp_id),line.filename) ] temp += [ Call(0," call %s"%(program_name),line.filename) ] if command_line.do_profile: temp += [ Simple_line(0,"call irp_print_timer()",line.filename) ] diff --git a/src/variable.py b/src/variable.py index 3ef4b52..96cc924 100644 --- a/src/variable.py +++ b/src/variable.py @@ -465,7 +465,7 @@ class Variable(object): same_as = self.same_as def check_openmp(): - if not do_openmp: + if not command_line.do_openmp: result = [ "!$ nthreads = omp_get_num_threads()" , "!$ if (nthreads > 1) then" , "!$ print *, irp_here//': Error: Provider in an openMP section'" , @@ -610,7 +610,7 @@ class Variable(object): text = parsed_text.move_to_top(text,Implicit) text = parsed_text.move_to_top(text,Use) text = map(lambda x: x[1], text) - inside_omp = False +# inside_omp = False for line in filter(lambda x: type(x) not in [ Begin_doc, End_doc, Doc], text): if type(line) == Begin_provider: result = [] @@ -630,10 +630,10 @@ class Variable(object): # Detect OpenMP blocks buffer = line.text.lower().split() if buffer[1] == "parallel": - inside_omp = True +# inside_omp = True self._has_openmp = True - if buffer[1] == "end" and buffer[2] == "parallel": - inside_omp = False +# if buffer[1] == "end" and buffer[2] == "parallel": +# inside_omp = False result.append(line.text) else: # if inside_omp: