diff options
author | Jarrod Millman <millman@berkeley.edu> | 2008-02-08 09:48:31 +0000 |
---|---|---|
committer | Jarrod Millman <millman@berkeley.edu> | 2008-02-08 09:48:31 +0000 |
commit | fb3f711f1a1eafb2895a84a80f88814d7fb9a465 (patch) | |
tree | aab6281c88fd6bed7c74df03562c197d934edd83 /numpy/f2py | |
parent | 2f3f1a8ef977fd04fc40d12ffd05903eb88c8635 (diff) | |
parent | 964727a2c475a7e48e262efc52b51345f51f2522 (diff) | |
download | numpy-fb3f711f1a1eafb2895a84a80f88814d7fb9a465.tar.gz |
Merge revisions 4721:4771 from the trunk
Diffstat (limited to 'numpy/f2py')
-rwxr-xr-x | numpy/f2py/crackfortran.py | 10 | ||||
-rw-r--r-- | numpy/f2py/src/fortranobject.c | 23 |
2 files changed, 23 insertions, 10 deletions
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 0e7dbd44c..48d1eaac5 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -791,7 +791,7 @@ def analyzeline(m,case,line): grouplist[groupcounter]=[] if needinterface: if verbose>1: - outmess('analyzeline: Creating additional interface block.\n',0) + outmess('analyzeline: Creating additional interface block (groupcounter=%s).\n' % (groupcounter),0) groupname[groupcounter]='interface' groupcache[groupcounter]['block']='interface' groupcache[groupcounter]['name']='unknown_interface' @@ -892,6 +892,7 @@ def analyzeline(m,case,line): pl = ch[0] outmess('analyzeline: cannot handle multiple attributes without type specification. Ignoring %r.\n' % (','.join(ch[1:]))) last_name = None + for e in [x.strip() for x in markoutercomma(ll).split('@,@')]: m1=namepattern.match(e) if not m1: @@ -910,11 +911,14 @@ def analyzeline(m,case,line): ap=m.group('this')+pl if _intentcallbackpattern.match(ap): if k not in groupcache[groupcounter]['args']: - if groupcounter>1 and \ - '__user__' in groupcache[groupcounter-2]['name']: + if groupcounter>1: outmess('analyzeline: appending intent(callback) %s'\ ' to %s arguments\n' % (k,groupcache[groupcounter]['name'])) + if '__user__' not in groupcache[groupcounter-2]['name']: + outmess('analyzeline: missing __user__ module (could be nothing)\n') groupcache[groupcounter]['args'].append(k) + else: + errmess('analyzeline: intent(callback) %s is ignored' % (k)) else: errmess('analyzeline: intent(callback) %s is already'\ ' in argument list' % (k)) diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c index ff1eb6252..f6679665e 100644 --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -694,18 +694,20 @@ int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,npy_intp *d npy_intp new_size = 1; int free_axe = -1; int i; + npy_intp d; /* Fill dims where -1 or 0; check dimensions; calc new_size; */ for(i=0;i<arr->nd;++i) { + d = arr->dimensions[i]; if (dims[i] >= 0) { - if (dims[i]!=arr->dimensions[i]) { + if (d>1 && dims[i]!=d) { fprintf(stderr,"%d-th dimension must be fixed to %" NPY_INTP_FMT " but got %" NPY_INTP_FMT "\n", - i,dims[i], arr->dimensions[i]); + i,dims[i], d); return 1; } if (!dims[i]) dims[i] = 1; } else { - dims[i] = arr->dimensions[i] ? arr->dimensions[i] : 1; + dims[i] = d ? d : 1; } new_size *= dims[i]; } @@ -724,16 +726,17 @@ int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,npy_intp *d new_size *= dims[free_axe]; } if (new_size != arr_size) { - fprintf(stderr,"confused: new_size=%" NPY_INTP_FMT - ", arr_size=%" NPY_INTP_FMT " (maybe too many free" + fprintf(stderr,"unexpected array size: new_size=%" NPY_INTP_FMT + ", got array with arr_size=%" NPY_INTP_FMT " (maybe too many free" " indices)\n", new_size,arr_size); return 1; } } else if (rank==arr->nd) { + npy_intp new_size = 1; int i; npy_intp d; for (i=0; i<rank; ++i) { - d = arr->dimensions[i]; + d = arr->dimensions[i]; if (dims[i]>=0) { if (d > 1 && d!=dims[i]) { fprintf(stderr,"%d-th dimension must be fixed to %" NPY_INTP_FMT @@ -743,6 +746,12 @@ int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,npy_intp *d } if (!dims[i]) dims[i] = 1; } else dims[i] = d; + new_size *= dims[i]; + } + if (new_size != arr_size) { + fprintf(stderr,"unexpected array size: new_size=%" NPY_INTP_FMT + ", got array with arr_size=%" NPY_INTP_FMT "\n", new_size,arr_size); + return 1; } } else { /* [[1,2]] -> [[1],[2]] */ int i,j; @@ -782,7 +791,7 @@ int check_and_fix_dimensions(const PyArrayObject* arr,const int rank,npy_intp *d } for (i=0,size=1;i<rank;++i) size *= dims[i]; if (size != arr_size) { - fprintf(stderr,"confused: size=%" NPY_INTP_FMT ", arr_size=%" NPY_INTP_FMT + fprintf(stderr,"unexpected array size: size=%" NPY_INTP_FMT ", arr_size=%" NPY_INTP_FMT ", rank=%d, effrank=%d, arr.nd=%d, dims=[", size,arr_size,rank,effrank,arr->nd); for (i=0;i<rank;++i) fprintf(stderr," %" NPY_INTP_FMT,dims[i]); |