Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-10

procedure calls with variable sized arrays in parameter list?

9 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I have bitten the bullet and decided to manually convert my Fortran code to pascal (see separate thread).
But there are a few things I am not familiar with concerning pascal array handling, which I would like advice for:

This is the start of an example fortran procedure:

subroutine ChleskySolve(a, n, p, b, x)
use GlobalForw, only : Rkind
(Rkind is located in another file as a constant valued 8, so I assume this means that the reals are double size.)
implicit none <== no fortran assumptions of var type based on name

integer, intent(in) :: n
real(Rkind), intent(in) :: a(1:n, 1:n), p(n), b(n) real(Rkind), intent(out) :: x(n)
real(Rkind) :: sum
integer :: i, k

From this I have deduced that a pascal procedure would be declared

something like this:

procedure ChleskySolve(a: array of double; n: integer; p, b: array of
double; var x: array of double);
The fortran specification indicates this concerning the arrays:
a is really 2-dim: array[1..n][1..n] of double;
p,b,x are 1-dim array[1..n] of double;

And x is the array holding the return values.

What is the correct declaration in this case? Open arrays can only be one-dimensional if memory serves me right.
And do I need to declare var for the x array, or are they all supplied by reference?

Bo Berglund

Reply by email

Juha Manninen gmail
to Bo Berglund
Bo Berglund wrote 13 lines
procedure ChleskySolve(a: array of double; n: integer; p, b: array of double; var x: array of double); The fortran specification indicates this concerning the arrays: a is really 2-dim: array[1..n][1..n] of double; p,b,x are 1-dim array[1..n] of double; And x is the array holding the return values. What is the correct declaration in this case? Open arrays can only be one-dimensional if memory serves me right. And do I need to declare var for the x array, or are they all supplied by reference?

Don't use open array parameters for the function.
Instead define types derived from dynamic arrays and use them everywhere.

type
  DoubleArray = array of Double;
  DoubleArray2 = array of array of Double;
...
procedure ChleskySolve(a: DoubleArray; ...
You can use SetLength for both dimensions :
  a2: DoubleArray2;
...
  SetLength(a2, 10);
  SetLength(a2[0], 10);

Juha

Reply by email

Reimar Grabowski
to Bo Berglund: I have bitten the bullet and decided to manually convert my Fortran code to pascal (see…
But there are a few things I am not familiar with concerning pascal array handling, which I would like advice for:

Topic for the fpc list. Yeah, you are new to a lot of stuff and need help and here are the guys that know the answers, but that does not make your mails on topic. It would be nice if you would consider using the fpc list for general pascal questions and get your non-lazarus-related answers somewhere else. I just wanted to tell you this since you see this list as a place to tell you everything about everything. You need to know something about Linux, you post here. You don't get how TortoiseSVN works, you post here. You have problems with Fortran, you post here. I don't want to be rude, but I also want to only read about lazarus related topics on this list. If you absolutely have to post off-topic questions, please at least mark them as [OT].

have a nice day
R.

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Bo Berglund
to Reimar Grabowski
Reimar Grabowski wrote 6 lines
On Fri, 08 Oct 2010 11:55:50 +0200 Bo Berglund wrote: > But there are a few things I am not familiar with concerning pascal > array handling, which I would like advice for: Topic for the fpc list.

Unfortunately the fpc group on GMANE news server does not allow posting. Since I don't have a clever enough mail client for discussion email lists (I have MS Outlook 2003) I am using a news client (Agent) for this communication, but this then needs to go via the GMANE news mirror of the lists. Works fine for the lazarus list but not for fpc.

And I did not realize that pascal is off topic here either. If I compare to the borland groups this would be delphi.general as the most similar one and for sure you post pascal questions there...

Where do I post questions on stuff like using serial ports with Lazarus (or is it maybe with fpc?) or manipulating digital I/O on embedded ARM systems via Lazarus?

Anyway I will take the pascal questions over to Embarcadero. Sorry to have caused inconvenience.

Bo Berglund Developer in Sweden

Reply by email

Sven Barth
to Bo Berglund
Bo Berglund wrote 16 lines
On Fri, 8 Oct 2010 17:23:13 +0200, Reimar Grabowski wrote: > On Fri, 08 Oct 2010 11:55:50 +0200 > Bo Berglund wrote: > >> But there are a few things I am not familiar with concerning pascal >> array handling, which I would like advice for: > Topic for the fpc list. Unfortunately the fpc group on GMANE news server does not allow posting. Since I don't have a clever enough mail client for discussion email lists (I have MS Outlook 2003) I am using a news client (Agent) for this communication, but this then needs to go via the GMANE news mirror of the lists. Works fine for the lazarus list but not for fpc.

What about using Thunderbird? Or aren't you allowed to install other mail clients?

And I did not realize that pascal is off topic here either. If I compare to the borland groups this would be delphi.general as the most similar one and for sure you post pascal questions there...

For general Pascal topics, like your Fortran=>Pascal thread the list fpc-pascal would be more suitable, as it is more related to the language than to the GUI or the IDE.

Where do I post questions on stuff like using serial ports with Lazarus (or is it maybe with fpc?) or manipulating digital I/O on embedded ARM systems via Lazarus?

Your thread about using the serial component should be correct here (although it is a non visual component it is a component after all). Manipulating digital I/O is more a non GUI related topic and thus should be discussed on fpc-pascal.

Anyway I will take the pascal questions over to Embarcadero. Sorry to have caused inconvenience.

I can't talk for others, but at least for me you haven't caused any real inconvenience. If I realize that a topic moves into a direction that I don't want to follow anymore (e.g. its getting boring), I just hit "r" on that thread when new messages arrive and they are all marked as read and I can concentrate on the interesting threads.

Regards,
Sven

Reply by email

waldo kitty
to Bo Berglund: On Fri, 8 Oct 2010 17:23:13 +0200, Reimar Grabowski Unfortunately the fpc group on GMANE…
Bo Berglund wrote 15 lines
On Fri, 8 Oct 2010 17:23:13 +0200, Reimar Grabowski wrote: > On Fri, 08 Oct 2010 11:55:50 +0200 > Bo Berglund wrote: > >> But there are a few things I am not familiar with concerning pascal >> array handling, which I would like advice for: > Topic for the fpc list. Unfortunately the fpc group on GMANE news server does not allow posting. Since I don't have a clever enough mail client for discussion email lists (I have MS Outlook 2003) I am using a news client (Agent) for this communication, but this then needs to go via the GMANE news mirror of the lists. Works fine for the lazarus list but not for fpc.

sounds like something that the GMANE folk should be queried about ;)

And I did not realize that pascal is off topic here either. If I compare to the borland groups this would be delphi.general as the most similar one and for sure you post pascal questions there...

pascal is not "off topic" per se but this area is more devoted to object pascal and LAZARUS related problems and queries...

Show quoted text 6 lines
Where do I post questions on stuff like using serial ports with Lazarus (or is it maybe with fpc?) or manipulating digital I/O on embedded ARM systems via Lazarus? Anyway I will take the pascal questions over to Embarcadero. Sorry to have caused inconvenience.

it is not an inconvenience... more of some folk being "gruff" about topicality... but they do have a point in that this is a LAZARUS list/group and so FPC specific stuff should go in one of the FPC areas... only stuff specific to LAZARUS should be posted in here...

NOTE: like you, i am but just a reader and participant of this list/group... my postings hold no more weight than any other general FPC/Lazarus user in here... the real weight belongs to the LAZ creators, maintainers and the admin(s) of this list...

Reply by email

Sven Barth
to waldo kitty
waldo kitty wrote 18 lines
On 10/8/2010 17:12, Bo Berglund wrote: > On Fri, 8 Oct 2010 17:23:13 +0200, Reimar Grabowski > wrote: > >> On Fri, 08 Oct 2010 11:55:50 +0200 >> Bo Berglund wrote: >> >>> But there are a few things I am not familiar with concerning pascal >>> array handling, which I would like advice for: >> Topic for the fpc list. > > Unfortunately the fpc group on GMANE news server does not allow > posting. Since I don't have a clever enough mail client for discussion > email lists (I have MS Outlook 2003) I am using a news client (Agent) > for this communication, but this then needs to go via the GMANE news > mirror of the lists. Works fine for the lazarus list but not for fpc. sounds like something that the GMANE folk should be queried about ;)

If I remember correctly the only one who can make this decision is Jonas, because he's the list administrator. Some time ago he mentioned why he didn't want to allow posting from GMANE, but he also mentioned that he doesn't know whether his reasons are still valid. (I don't know which message it was though...)

Regards,
Sven

Reply by email

Bo Berglund
to Sven Barth
Sven Barth wrote 6 lines
If I remember correctly the only one who can make this decision is Jonas, because he's the list administrator. Some time ago he mentioned why he didn't want to allow posting from GMANE, but he also mentioned that he doesn't know whether his reasons are still valid. (I don't know which message it was though...)

Today he has changed his mind and told the GMANE people to accept postings to the fpc list, but there is a delay before the list changes. Depending on the situation it may take up to a week.

This lazarus list was also not working for posting when I arrived here some weeks ago, but that was due to an erroneous email setting at GMANE, which was corrected after I complained to them. It now works very good as a News mirror of the list.
Hopefully in a few days the fpc list will also be mirrored like this.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Sven Barth: What about using Thunderbird? Or aren't you allowed to install other mail clients? For…
Sven Barth wrote 10 lines
> Unfortunately the fpc group on GMANE news server does not allow > posting. Since I don't have a clever enough mail client for discussion > email lists (I have MS Outlook 2003) I am using a news client (Agent) > for this communication, but this then needs to go via the GMANE news > mirror of the lists. Works fine for the lazarus list but not for fpc. > What about using Thunderbird? Or aren't you allowed to install other mail clients?

Well, I can't use a separate email client for the mail lists because I have used my Gmail account for that...
I don't want the messages I get via Gmail to wind up in a different mail archive than all other email I get. And I have been using MS Outlook for a very long time now, certainly back into the previous century...

Also I checked Thunderbird for other reasons as a news reader and it did not appeal to me being used to Agent.
Works fine as a mail client for a separate mail account though, but I want to archive the news content so I can get back to it easily and this is so convenient in Agent.

Bo Berglund Developer in Sweden

Reply by email