Re: allocating arrays, trouble



On 26 nov, 13:46, "Förster vom Silberwald" <chain_l...@xxxxxxxxxxx>
wrote:
On Nov 26, 12:31 pm, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:





On 26 nov, 12:43, "Förster vom Silberwald" <chain_l...@xxxxxxxxxxx>
wrote:

On Nov 26, 11:20 am, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:

On 26 nov, 11:38, "Förster vom Silberwald" <chain_l...@xxxxxxxxxxx>
wrote:

On Nov 26, 10:26 am, "Wade Ward" <w...@xxxxxxxxxxx> wrote:

real*8, dimension(buff1,buff2) :: ger2

Why the non-portable declaration? Would it work with silverfoerster 95?

Why is it non-portable? What do you mean by silverfoerster 95?

Thanks

"real*8" is a (popular) extension to the FORTRAN 77 standard
for:

double precision

(The "8" refers to the fact that on many machine double
precision reals are implemented with 8 bytes. But that
is not guaranteed.)

Current F90/95/... practice is this:

real(kind=kind(1.0d00))

(or any of a variety of means to determine the kind of
double precision reals).

Regards,

Arjen

hello: thanks for the answer. I saw that real*8 in some codes
colleagues put forward to me (okay, they are using f90 but their code
as far as I can tell is fortran 77).

But anyway: why isn't it possible to pass the buff1 and buff2 variable
and the compiler will allocate memory. I haven't checked it yet but
are you saying that I will go away without any segmentation fault if
using double precision instead of real*8?

I am not saying that I do'nt won't to improve my Fortran. But it is
this: I do not have much time right now to go through a Fortran 90
book because they want to see some results here. We don't even have
any Fortran 90 books here and I had to refresh my Fortran 90 knowledge
by means of the internet. I had some Fortran 90 lectures 10 years ago
(funny enough: I was alone when I took the Fortran 90 classes and the
lecturer were reall happy because nowadays nobody takes any Fortran
classes at all).

It is so hard for me to program in Fortran 90 because I am used to
Scheme (and the very stable and excellent Bigloo compiler) and I miss
so much: lists, map, lamba, etc.

Okay: the one good thing about Fortran 90: a(:,:) = b(1,:)

thanks- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Well, lists can be done via arrays and a bit of care:
passing arrays to subroutines/functions gives you much
freedom.

map: Fortran does this via array expressions
lambda: well, array expressions again ;)
etc.: All I can say is that you need to think in terms of
arrays, rather than lists.

Regards,

Arjen

Hello: thanks.

Is it possible to have an array with different kind of members? e.g.
#((list 1 2 3), 3, (vector 3 4))?

Or do people use a struct in this case in Fortran?

I would like to shape my programming style a bit because I am not at a
point where I pass 10 or more different parameters to subfunctions. I
guess it would be easier to pass just one structure?

I am so much used to this kind of programming (especially when you do
a lot of experimenting): I start out with a function in Scheme and put
some return things into a list (e.g. vectors, and numbers etc.). 1
hour later I can extend the return list by some other stuff without
any hassle. In Fortran 90 I always have to declare and take care of
types and dimensions. This is going to kill me.

How would you this in Fortran: lets say you have a 3 dimensional array
but the 3rd dimension is variable in length? In Scheme I would have a
2 dimensional vector and the 3rd dimension would be a vraiable list or
variable vector?

Thanks- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Well, arrays are collections of data of the same type only,
but nothing prevents you from using an array of derived types
where only one or two entries have a meaning. That would allow
you more flexibility (at the cost of some more programming,
but even that can be remedied!)

Fortran arrays (especially of the pointer variety) can
have any size per dimension:

p => mk_3d_array( third_dim )

function mk_3d_array( dim ) result( p )
real, dimension(:,:,:), pointer :: p

allocate( p(20,20,dim) ) ! Only the 3rd dimension varies

end function

for instance.

Regards,

Arjen
.



Relevant Pages

  • Re: Speed penalty for using allocatable arrays?
    ... "Leading dimension" means dimension 1, ... Fortran compilers, rather than having being left those writing Fortran ... allocation available in Fortran 90/95. ... the arrays are allocated once at the ...
    (comp.lang.fortran)
  • Re: allocating arrays, trouble
    ... as far as I can tell is fortran 77). ... lists can be done via arrays and a bit of care: ... Fortran does this via array expressions ... but the 3rd dimension is variable in length? ...
    (comp.lang.fortran)
  • Re: Could this result in Array Distortion ??
    ... simply insert a Parameter statement in each with the actual arrays ... lists would be a bit shorter and would make future maintenance of the ... In Fortran 66 and 77 ...
    (comp.lang.fortran)
  • Re: Fortran dud ...
    ... Which Fortran version first allowed arrays with a dimension (extent) ... of zero? ...
    (comp.lang.fortran)
  • Re: best practices for structuring ASCII input
    ... I'm maintaining a number of smallengineering/scientific Fortran ... data consists of a mixture of variables, arrays, ... the input files are not human readable. ...
    (comp.lang.fortran)