Re: [fpc-pascal] FORTRAN from FreePascal

2017-11-18 Thread Adriaan van Os

Mark Morgan Lloyd wrote:
I think that conventional wisdom is that if somebody's written numerical 
analysis code you don't change it gratuitously, since any alterations 
will change rounding errors etc. For some reason, that seems to apply 
particularly to FORTRAN programs :-)


The reason being explained here 



Regards,

Adriaan van Os

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FORTRAN from FreePascal

2017-11-18 Thread Adriaan van Os

Mark Morgan Lloyd wrote:

Except that when you're calling into a DLL (.so on Linux etc.) I don't 
think you have much chance of seeing the inside of the library code. 


On Mac OS X, which is actually a BSD UNIX, I debug plug-in code all the time. 
Not an issue at all.

Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Seek to EOF of file of byte

2017-11-18 Thread Mark Morgan Lloyd

On 18/11/17 21:15, pasc...@piments.com wrote:
On 18/11/17 20:27, Mark Morgan Lloyd wrote:> because the program is 
being viewed critically by the ALGOL programmer > whose code

Algol, one my all time favourite languages.
while  wendif  fi
why is this not universally adopted?
I still comment my C code with  fi's and wend's to keep track of what a 
bunch of curly braces actually refer to.


/Don't/ get me going, particularly here. Basically, because Wirth threw 
his toys out of the pram when ALGOL-W was rejected, and rushed out 
Pascal as an alternative without looking at the few bits of ALGOL-68 
which were useful for something. He didn't come to his senses until 
Modula-2 or his involvement with Ada (I'm not sure which came first) but 
by then the damage was done.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Seek to EOF of file of byte

2017-11-18 Thread pascalX

On 18/11/17 20:27, Mark Morgan Lloyd wrote:
because the program is being viewed critically by the ALGOL programmer 
whose code


Algol, one my all time favourite languages.

while  wend
if  fi

why is this not universally adopted?

I still comment my C code with  fi's and wend's to keep track of what a 
bunch of curly braces actually refer to.


C : a high level language with power of assembler and the readability of 
   assembler.


Python : a high level language with the readability of assembler and 
performance of MSBASIC.


;)

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FORTRAN from FreePascal

2017-11-18 Thread pascalX

On 18/11/17 20:14, Mark Morgan Lloyd wrote:
I think that conventional wisdom is that if somebody's written numerical 
analysis code you don't change it gratuitously, since any alterations 
will change rounding errors etc. For some reason, that seems to apply 
particularly to FORTRAN programs :-)



If you have no working knowledge of the language it is written in 
conventional wisdom is that you don't  change anything, gratuitously or 
otherwise.


to make any use of this code without understanding any of  it,  you will 
need some pretty thorough documentation of what it does, including 
accuracy, limitations and caveats.


My reaction to being presented with such a situation would be to dust 
off my 1980s punch card FORTRAN IV code, get up to speed and try to 
understand the code before attempting to use it.


Either that or you pay someone with the requisite knowledge to do the job.


my2c.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Seek to EOF of file of byte

2017-11-18 Thread Mark Morgan Lloyd

On 18/11/17 19:30, Graeme Geldenhuys wrote:
On 2017-11-18 15:44, Mark Morgan Lloyd wrote:> How should one do this?> 
https://www.freepascal.org/docs-html/current/rtl/system/seekeof.html> 
implies that it's only for text files, Seek(f, FileSize(f)) seems 
excessive.


Just curious, why would you consider the "old technology" instead of 
using TFileStream (or any of the other TStream descendants).
I'm actually busy converting some old apps that used "t: Text" style 
coding, and replacing it with more modern Stream-style code, and it 
works really well. Streams are so much more flexible.


With your propensity for "I wouldn't start from here" answers I'm 
surprised you're not on CIX :-)


Basically, because the program is being viewed critically by the ALGOL 
programmer whose code I'm converting, and a number of other people of a 
comparable generation and background. So while I'm using OO fairly 
heavily and threads where the architecture makes them appropriate ** I'm 
trying not to change stuff gratuitously.


** The original code tried to simulate up to 2x CPUs and up to 4x IOPs 
using a single thread. I'm trying to do it properly.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FORTRAN from FreePascal

2017-11-18 Thread Mark Morgan Lloyd

On 18/11/17 19:45, Bo Berglund wrote:

On Sat, 18 Nov 2017 17:06:25 +, Mark Morgan 
Lloyd wrote:

I find myself wondering, in part due to conversations elsewhere: can the >Lazarus 
IDE do anything at all sane with a FORTRAN routine called from >Pascal?

In the D7 application written in ObjectPascal calls were made into theFORTRAN 
created DLL:s referencing multi-dimensional arrays of data.Fortran processes 
the inversion and returns modified/new array output.So as long as the interface 
is like this and the calling conventionsare OK it should work also from 
Lazarus/FPC.


Except that when you're calling into a DLL (.so on Linux etc.) I don't 
think you have much chance of seeing the inside of the library code. 
With a statically-linked program it should be possible.


A friend-of-a-friend has a certain amount of legacy FORTRAN, so this is 
something that I really must find the time to try at some point.


I think that conventional wisdom is that if somebody's written numerical 
analysis code you don't change it gratuitously, since any alterations 
will change rounding errors etc. For some reason, that seems to apply 
particularly to FORTRAN programs :-)


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FORTRAN from FreePascal

2017-11-18 Thread Bo Berglund
On Sat, 18 Nov 2017 17:06:25 +, Mark Morgan Lloyd
 wrote:

>I find myself wondering, in part due to conversations elsewhere: can the 
>Lazarus IDE do anything at all sane with a FORTRAN routine called from 
>Pascal?

In the D7 application written in ObjectPascal calls were made into the
FORTRAN created DLL:s referencing multi-dimensional arrays of data.
Fortran processes the inversion and returns modified/new array output.
So as long as the interface is like this and the calling conventions
are OK it should work also from Lazarus/FPC.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Seek to EOF of file of byte

2017-11-18 Thread Graeme Geldenhuys

On 2017-11-18 15:44, Mark Morgan Lloyd wrote:

How should one do this?
https://www.freepascal.org/docs-html/current/rtl/system/seekeof.html
implies that it's only for text files, Seek(f, FileSize(f)) seems excessive.



Just curious, why would you consider the "old technology" instead of 
using TFileStream (or any of the other TStream descendants).


I'm actually busy converting some old apps that used "t: Text" style 
coding, and replacing it with more modern Stream-style code, and it 
works really well. Streams are so much more flexible.



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FORTRAN from FreePascal

2017-11-18 Thread Adriaan van Os

Mark Morgan Lloyd wrote:
I find myself wondering, in part due to conversations elsewhere: can the 
Lazarus IDE do anything at all sane with a FORTRAN routine called from 
Pascal?


It's not different from a call to C or any other compiled language. And with regard to debugging, I 
think it will be no problem either, apart from Windows, where there are different object formats, 
different debuggign formats and diffferent linkers for various languages.


Regards,

Adriaan van Os

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FORTRAN from FreePascal

2017-11-18 Thread Mark Morgan Lloyd

On 18/11/17 16:45, Adriaan van Os wrote:

Bo Berglund wrote:
I would very much want to convert them into DLL:s programmed in 
Pascal> instead so they can be maintained for new Windows versions 
(and use 64> bit for example).
Well, you would have to do that by hand. And you need sufficient 
understanding of Fortran to know what you are doing. I am not aware of a 
Fortran to Pascal converter. But why do that if Fortran compilers are 
available ? And even if a Fortran compiler wouldn't exist, there is a 
Fortran to C converter, named f2c. See for example 



I find myself wondering, in part due to conversations elsewhere: can the 
Lazarus IDE do anything at all sane with a FORTRAN routine called from 
Pascal?


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FORTRAN from FreePascal

2017-11-18 Thread Adriaan van Os

Bo Berglund wrote:


I would very much want to convert them into DLL:s programmed in Pascal
instead so they can be maintained for new Windows versions (and use 64
bit for example).


Well, you would have to do that by hand. And you need sufficient understanding of Fortran to know 
what you are doing. I am not aware of a Fortran to Pascal converter. But why do that if Fortran 
compilers are available ? And even if a Fortran compiler wouldn't exist, there is a Fortran to C 
converter, named f2c. See for example  where it reads


This README file describes how we transform LAPACK from FORTRAN into ANSI C,
and how to maintain it.

In addition to the routines translated from SRC, one needs to have
f2c.h available to compile C source; this is in F2CLIBS. The library
F2CLIBS/libF77.a needs to be linked with all routines as well. The library
F2CLIB/libI77.a needs to be linked when running the TESTING or TIMING
code, but not when using SRC code alone.

The basic translation is done by the Fortran-to-C translator f2c, which
was written by David Gay at Bell Labs, with subsequent cleanup to improve
readability.  The software in the SRC directory, which contains the LAPACK
library proper (i.e. no testing code, timing code, or BLAS), is cleaned up
most completely, and so is easiest to read. We exploit the facts that these
routines do almost no I/O (the few lines of I/O in xLAMCH and XERBLA have
the ungainly f2c output replaced by hand; see below), and that they have a
standard format for leading comments. The routines in TESTING, TIMING and
BLAS are translated, but not cleaned up completely, and so they work but are
not as easy to read.

etcetera.

Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Seek to EOF of file of byte

2017-11-18 Thread Mark Morgan Lloyd
How should one do this? 
https://www.freepascal.org/docs-html/current/rtl/system/seekeof.html 
implies that it's only for text files, Seek(f, FileSize(f)) seems excessive.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal