calls of rsnap and wsnap

6 views
Skip to first unread message

MR

unread,
Nov 5, 2012, 9:06:01 AM11/5/12
to pencil-co...@googlegroups.com
Is there a reason to write calls of rsnap and wsnap in the form 

rsnap('var.dat',f(:,:,:,1:mvar_in),mvar_in)

instead of simply

rsnap('var.dat',f,mvar_in)

?
At least g95 and gfortran do not complain if mvar_in used for the declaration
of the dummy parameter corresponding to f within rsnap/wsnap is smaller than
mfarray. In any case, this declaration could be rewritten as f(mx,my,mz,*)
as the array is always referred to with explicit indices for the last dimension.
The present notation seems to break the auto-test for sample no-modules on some platforms.

Cheers,
Matthias

Wolfgang Dobler

unread,
Nov 5, 2012, 9:17:42 AM11/5/12
to pencil-co...@googlegroups.com, Mir selbst
MR writes:
> Is there a reason to write calls of rsnap and wsnap in the form
>
>
> rsnap('var.dat',f(:,:,:,1:mvar_in),mvar_in)
>
>
> instead of simply
>
>
> rsnap('var.dat',f,mvar_in)

There is some virtue in restricting the available slots to those that are
really needed.

BUT: Array slices as arguments may
- either lead to copying of large arrays,
- or the subroutine could touch the whole f array anyway.

So it is probably wiser to change the calling sequence according to your
suggestion.


W o l f g a n g

Philippe Bourdin

unread,
Nov 5, 2012, 9:48:16 AM11/5/12
to pencil-co...@googlegroups.com

Hello all,

Matthias wrote:
> > Is there a reason to write calls of rsnap and wsnap in the form
> > rsnap('var.dat',f(:,:,:,1:mvar_in),mvar_in)
> > instead of simply
> > rsnap('var.dat',f,mvar_in)

Wolfgang wrote:
> So it is probably wiser to change the calling sequence according to your
> suggestion.

I agree, passing sub-arrays is always sub-optimal, because it very
likely translates to implicit copying of memory.

(And: because mixing of fixed-size and variable-(implicit-)size size
dimensions in one array is not allowed in F95, this proposal falls out.)

I will adapt the IO-modules accordingly, after some days have passed and
if no more comments are made on this issue - it should be a quick fix.

Thanks and best regards,

Philippe.


Reply all
Reply to author
Forward
0 new messages