f



regular expressions in fortran90, 95

Greetings,

Is there any possibility to use the subject?

Thanks a lot in advance.

regards,
Anton.

0
narod (25)
1/21/2004 2:55:02 PM
comp.lang.fortran 11853 articles. 1 followers. Post Follow

6 Replies
640 Views

Similar Articles

[PageSpeed] 22

Anton Ishmurzin wrote:
> 
> Greetings,
> 
> Is there any possibility to use the subject?
> 
> Thanks a lot in advance.
> 
> regards,
> Anton.

I do not know of a ready solution, but it is possible
to take a C library and call that (possibly via a 
few wrapper functions) from Fortran.

(I have contemplated writing such wrapper functions 
but I have not found the energy to actually do it yet ;).

In principle it is no problem - Fortran offers all the
tools you need, but the very task of writing a regular
expressions matcher is mind-boggling.

Regards,

Arjen
0
arjen.markus (2628)
1/22/2004 8:14:14 AM
Arjen Markus (aka Bruce) was almost, but not quite, entirely unlike tea:
> I do not know of a ready solution, but it is possible
> to take a C library and call that (possibly via a 
> few wrapper functions) from Fortran.
> 
> (I have contemplated writing such wrapper functions 
> but I have not found the energy to actually do it yet ;).
> 
> In principle it is no problem - Fortran offers all the
> tools you need, but the very task of writing a regular
> expressions matcher is mind-boggling.

If we could portably use popen(), you could invoke perl :)

-- 
TimC -- http://astronomy.swin.edu.au/staff/tconnors/
If a train station is a place where a train stops, what's a workstation?
0
tconnors (94)
1/22/2004 12:46:17 PM
TimC wrote:
> 
> Arjen Markus (aka Bruce) was almost, but not quite, entirely unlike tea:
> > I do not know of a ready solution, but it is possible
> > to take a C library and call that (possibly via a
> > few wrapper functions) from Fortran.
> >
> > (I have contemplated writing such wrapper functions
> > but I have not found the energy to actually do it yet ;).
> >
> > In principle it is no problem - Fortran offers all the
> > tools you need, but the very task of writing a regular
> > expressions matcher is mind-boggling.
> 
> If we could portably use popen(), you could invoke perl :)
> 

A portable interface between C and Fortran is not that 
difficult :) - it just takes some time to realise.
All the technical stuff can be adequately solved via
"cfortran.h". The interface needs to be defined in 
a way that is comfortable for Fortran programmers.
That is where ingenuity comes along...

As far as popen() is concerned, is that not part of
POSIX? Doesn't  POSIX have a Fortran-component?

Regards,

Arjen
0
arjen.markus (2628)
1/22/2004 1:14:47 PM
> Doesn't  POSIX have a Fortran-component?

It has a Fortran language binding, yes. I'm not sure any (useful)
implementations exist.

	Jan
0
jvorbrueggen (238)
1/22/2004 1:43:54 PM
Anton Ishmurzin <narod@izh.com> wrote in message news:<400E92C6.9000100@izh.com>...
> Greetings,
> 
> Is there any possibility to use the subject?
> 
> Thanks a lot in advance.
> 
> regards,
> Anton.

If you do not need the full power of regular expressions, you can
probably solve your problem using the intrinsic Fortran
string-handling functions, such as

INDEX
VERIFY
SCAN
TRIM
ADJUSTL

The book "The Practice of Programming" by Brian W. Kernighan and Rob
Pike show how MOST of grep can be implemented in a fairly small C
code. If that is all you need, translating their code to Fortran
should not be too hard. The code from his book can be downloaded from
http://cm.bell-labs.com/cm/cs/tpop/code.html .

The book "Software Tools" by Kernighan and Plauger has string-handling
code in RATFOR, which can be translated to Fortran using the RATFOR
preprocessor. The code is at
http://cm.bell-labs.com/cm/cs/who/bwk/toolsbook/index.html , in some
strange format.

"Fortran tools for VAX/VMS and MS-DOS"
Jones and Crabtree (1988) 
is a very good book with lots of string-handling code in Fortran 77

"Algorithms and Data Structures in F and Fortran" 
by Robin Vowels (1988)
has lots of string-handling code in Fortran 90/95
0
beliavsky (2212)
1/22/2004 2:40:51 PM
Jan C Vorbr�ggen (aka Bruce) was almost, but not quite, entirely unlike tea:
>> Doesn't  POSIX have a Fortran-component?
> 
> It has a Fortran language binding, yes. I'm not sure any (useful)
> implementations exist.

There's pxfpopen() in Intel FC. 

It returns a fd, not a lun, so one must do nasty things with dup2(),
in order to be able to use write and read transparently. Why I call
this unportable, is because as it is; I had to perform many unexpected
hacks because of some sub-optimalities in the buffering of Intel's
implementation of write/read (seeking all over the place, unless you
open on a fifo before the dup2, in which case it chooses to read/write
one byte at a time -- yuck)

-- 
TimC -- http://astronomy.swin.edu.au/staff/tconnors/
Kleeneness is next to Godelness.
0
tconnors (94)
1/22/2004 9:12:32 PM
Reply: