Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!sdd.hp.com!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!strath-cs!expya!exua!JRowe From: JRowe@exua.exeter.ac.uk (John Rowe) Newsgroups: comp.lang.fortran Subject: Re: beyond the debate.....HELP!!! (and my opinions...) Message-ID: Date: 4 Dec 90 17:47:18 GMT References: <48577@eerie.acsu.Buffalo.EDU> Sender: JRowe@exua.exeter.ac.uk Organization: Computer Unit. - University of Exeter. UK Lines: 54 In-reply-to: v087mxgb@ubvmsa.cc.buffalo.edu's message of 1 Dec 90 06:25:04 GMT I think you're doomed on this one. As I understand it you have A(M,N) and you're trying to send A(J,1), A(J,2) ... A(J,N) to a subroutine as a one dimensional array (if you were trying to send A(1,I), A(2,I) .. A(M,I) that's easy but I'm sure you know that!). A one dimensional array consists of N contiguous values, ie ARRAY(K) is stored immediately after ARRAY(K-1) and immediately before ARRAY(K+1). Your 2-D array is stored as A(1,1), A(2,1), A(3,1) ... A(M,1), A(1,2), A(2,2), etc so you're trying to access every M'th value. I assume you can't conveniently reverse the order of A's subscripts in the main program (or get the compiler to do it for you) so I should take the simple but nasty way you sugested of creating a temporary array. You COULD recode your subroutine so that references to ARRAY(K) are replaced by ARRAY(1 + (K-1)*MLOCAL) where MLOCAL is either 1 or M; ie from: FUNCTION FRED(ARRAY) typical line: ARRAY(K) = REAL(K) to: FUNCTION FRED2(ARRAY,MLOCAL) typical line: ARRAY(1 + (K-1)*MLOCAL) = REAL(K) You can do this quite mechanically and be sure it will work (but see pedantic footnote below). You could even have a dummy routine FRED(ARRAY) which just calls FRED2(ARRAY,1) to avoid changing the rest of your code (or two entry points, aaarghh, no!). But it is very messy and probably slower to execute as well. Only consider something like this if: a) it is time critical and b) N is so large that it's time consuming to create a dummy array and c) you only access a small number of elements of ARRAY in FRED So do it your way. Sorry to be so unhelpful. Pedantic footnote? Well, if you do this and you want strict FORTRAN 77 compatibility you may need to change the size you declare ARRAY to be in FRED2 so that all the ARRAY(1 +(K-1)*MLOCAL)s don't overrun the size of ARRAY as declared in FRED2. But you'll probably get away without it. And FORTRAN v c? Well, we find our 'standard' matrix crunching codes don't need anything FORTRAN doesn't have but some of our more unusual codes do. But _EVERTHING_ needs complex numbers. You can't call c a suitable scientific/mathematical language if it doesn't even implement the entire number set. John Rowe Computational Physics Group Exeter University England Brought to you by Super Global Mega Corp .com