#5 let MIRROR_OPTION be really a run-time option

open
nobody
None
5
2012-12-10
2004-04-19
Anonymous
No

From jean-marie.epitalon@vnumail.com

Pyfort mirror_option has a bug that forces a programmer
to describe valued integers with initialisers of the
form size(array, n) in a non intuitive manner.
This has also another bad effect: this fixes the way
the fortran module can be called.
I mean: the way the subroutine is declared implies that
it will be called using MIRROR option.

Only one line in one source file 'generator.py' needs
to be changed.

I modified this source file and a test file: test/test.py
below is the diff file to be applied as a patch.

===============================

diff -bur Pyfort-8.2-old/generator.py
Pyfort-8.2/generator.py
--- Pyfort-8.2-old/generator.py 2003-10-21
12:42:12.000000000 +0200
+++ Pyfort-8.2/generator.py 2003-10-21
13:04:08.000000000 +0200
@@ -134,7 +134,7 @@
"""\ #define TRANSPOSE_OPTION %(transpose_option)d
#define MIRROR_OPTION %(mirror_option)d
-#define get_fortran_dim(v,n) v->dimensions[(n)-1]
+#define get_fortran_dim(v,n) v->dimensions[(keyoption
& MIRROR_OPTION) ? v->nd - (n) : (n)-1]
"""
D = {'transpose_option':
self.compiler.transpose_option(),
'mirror_option':
self.compiler.mirror_option()}
diff -bur Pyfort-8.2-old/test/test.py
Pyfort-8.2/test/test.py
--- Pyfort-8.2-old/test/test.py 2002-08-15
17:25:44.000000000 +0200
+++ Pyfort-8.2/test/test.py 2003-11-03
17:02:12.000000000 +0100
@@ -41,12 +41,28 @@
bl = list(b)
print two(row_major(al), 2, 3, 4, row_major(bl), 0)

+print "two with mirror option returns"
+a1=transpose(a)
+b1=transpose(b)
+r, c = two(a1, 2, 3, 4, b1, 2)
+print (r, transpose(c))
+
print "copy2(a)"
acopy = copy2(a)
print acopy
print "Again, but using result of previous as input."
print copy2(acopy)

+print "copy2(a) with mirror option"
+TRANSPOSE_OPTION = 1
+MIRROR_OPTION = 2
+set_pyfort_option (MIRROR_OPTION)
+acopy = copy2(a)
+print acopy
+print "Again, but using result of previous as input."
+print copy2(acopy)
+set_pyfort_option (TRANSPOSE_OPTION)
+
ca = x + 1.0j
c = 1 + 4j
print "c, ca", c, ca

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks