Operating System - OpenVMS
1752770 Members
5053 Online
108789 Solutions
New Discussion юеВ

Re: Fortran examples using LIB$ and STR$ anyone ?

 
SOLVED
Go to solution

Fortran examples using LIB$ and STR$ anyone ?

Hello Friends,

After five years of VMS blackout, I need to go back to Fortran. As I trashed all my stuff, I feel a bit naked.
Could someone give me some pointers to source code examples using the RTL and STR$ routines please ? (any versions, 77, 90, 95...)

Merci beaucoup.

DTL
7 REPLIES 7
Joseph Huber_1
Honored Contributor
Solution

Re: Fortran examples using LIB$ and STR$ anyone ?

Some of my little fortran programs at
http://www.mpp.mpg.de/~huber/util/
and
http://www.mpp.mpg.de/~huber/util/main/
in particular main/reduce_bookmarks.for, which does string manip in pure Fortran (INDEX,TRIM,LEN_TRIM), without using VMS STR$.
Otherwise use "search *.for str$" to finds its use.

When I have a choice to use Fortran or C for string handling, I prefer Fortran 77+, where strings are intrinsic.

Welcome back in VMS and Fortran!


http://www.mpp.mpg.de/~huber
Hein van den Heuvel
Honored Contributor

Re: Fortran examples using LIB$ and STR$ anyone ?

Salut Didier,

Bienvenue chez le Forum OpenVMS.

As per the C.O.V. comments I still suspect you are better of sticking with DCL or trying a language which can very readily do pattern matching, string manipulation and formating, like Perl.

( Vous voyez, vous ne pouvez pas m'├Г┬йchapper :-)

At any rate, attached a small, fairly practical, Fortan example with some string manipulations and LIB$ calls.
It implements a 'cd' command... migth be handy ?!

Hein.






Re: Fortran examples using LIB$ and STR$ anyone ?

Hi Friends,

Thanks for the answers.
Will look at it.

@Hein :
Well, as I speak DCL as well as French, as soon as I am asked to solve big files processing, I start with DCL coding until the "algorithms" are fine and processing too.

For example, the stuff I'm working on took a bit more than 2 hours with my DCL code to process 20 000 input lines. I just finished a first draft of the Fortran code, doing the same, and run time went to... 7 minutes :-)

See ?

DCL DTL same fight.
Hoff
Honored Contributor

Re: Fortran examples using LIB$ and STR$ anyone ?

What are the project constraints and project requirements here? (There are alternative and arguably better languages around for this task, though I've certainly been on projects where a comparatively poor language choice has been mandated for any of various reasons.)

Fortran and BASIC are comparatively weak in the area of text-handling, and the OpenVMS RTLs are also relatively weak at these and related tasks, too; in aggregate, these tools are adequate for the task, but are not particularly effective.

Python and other and more recent languages are rather better suited for text handling in general. Even C (which features relatively weak text handling capabilities within the core language and the C standard library) has better regular expression (regex) support and a variety of tools and libraries including lex/yacc and flex/bison.

OpenVMS does have lib$table_parse (lib$tparse), if there's some sort of structured grammar in the files involved here. That's certainly callable from Fortran, and I and others have posted examples of using this RTL call on the OpenVMS Freeware and elsewhere.

As for your request for Fortran examples, there are few. HP appears to have discontinued access into the old DEC support databases. The (old) source code examples are apparently no longer directly available, unfortunately. There are various Fortran source code examples in the OpenVMS manuals. For instance:

http://h71000.www7.hp.com/doc/73final/5936/5936pro_007.html

Re: Fortran examples using LIB$ and STR$ anyone ?

Well Hoff, the issue here is a question of time. I have no time and no wish to start learning a new programming language. I'll retire in a few months, you see... :-)

Seriously, This stuff is supposed to be done by tomorrow.

Ah, btw, it was not 20 000 lines but 200 000 !

And the ton of mail I got from my posts (3) gave me inuf stuff to finish this nite.

Thanks to all.

(_@_)
O o
!
\_/
Mike Kier
Valued Contributor

Re: Fortran examples using LIB$ and STR$ anyone ?

Here's one I wrote a while back to sort delimited files (semicolon or comma delimited, e.g.)
Practice Random Acts of VMS Marketing
Hoff
Honored Contributor

Re: Fortran examples using LIB$ and STR$ anyone ?

Options here include libcsv

What amounts to the OpenVMS port (a few lines of DCL to build and test the library) is here:

http://labs.hoffmanlabs.com/node/644

or there's the built-in or add-on libraries that are available in Perl or Python or such, and that were mentioned.

Using lib$table_parse would probably be analogous to nuclear weapon here (if you don't already know how to use it, that is) but would be entirely effective at this task, too. (Where I like this particular tool is around its ability at flagging bad data or bad record formats; it's _really_ good at allowing you to flag or potentially to fix bad data.)

And yes, learning a new language or new tool or a parser does almost certainly require more than DTL's allotted "tomorrow" schedule here.

But the effort spent learning new stuff (tools, languages, platforms, marketing, management skills, parsers, whatever) is good brain exercise and good career exercise, regardless.

And that old and slow DCL prototype? See if the performance problem there was a case of not setting the file allocation size and the file extent size sufficiently large. DCL will be slow, yes, but I've also seen small file extent allocations (which are inexplicably still the default on OpenVMS) severely hamper aggregate performance.)