[f2py] Fw: Initializing 2D-array whenonly the dimension NxM is passed to subroutine

"kalman_g" <[email protected]> Wed, 10 Nov 2010 13:48:25 -0800
Newsgroups gmane.comp.python.f2py.user
Message-ID <405F846F8C794324AAFA3A9E94BDB018@GsLaptopAcer>
This is a CORRECTED VERSION of an earlier submit ! (Sorry for the earlier mixup)

My QUESTION is:

How can one initialize a 2D-array  INSIDE a sub, when ONLY the dimension NxM of the 2D-array is passed to the subroutine?

#######################################

OS: Windows

The following will NOT compile&link:

See File:  RUN.BAT:
===============
-------
python C:\Python26\Lib\site-packages\numpy\f2py\f2py.py ^
                         --build-dir .\tmp ^
                         --fcompiler=gnu95 ^
                          -c lib1.f90 -m lib1
pause
----------------------------------

See File: LIB1.F90:
================

MODULE lib12

CONTAINS

   !--------------------------------------------
    SUBROUTINE MTX(B,N,M)

     INTEGER, INTENT(IN) ::N,M
     INTEGER, DIMENSION(N,M), INTENT(OUT) :: B 
      INTEGER, DIMENSION(N,M) :: C
     INTEGER :: i,j

    DO i=1,N
        DO=1,M
            C(i,j)=1
        END DO
   END DO

   B=C

   END SUBROUTINE MTX
   !--------------------------------------------------
end MODULE lib12


****************************
Of course, it is a different story when calling the sub as:

SUBROUTINE MTX(A,B,N,M)

with the "pre-initialized" 2D-array: A

INTEGER, DIMENSION(N,M), INTENT(IN) :: A

----

i.e. when an array A is passed to the sub & A was already initialized in the calling module (say, test.py)


******************************

So once again the QUESTION is:

How can one itialize a 2D-array  INSIDE a sub, when only the dimension NxM is passed to subroutine?


*********************************

Thanks

G. Kalman
[email protected]

_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users