Silverfrost Forums

Welcome to our forums

Attaching a library like NSWC to a Fortran program

23 Apr 2018 12:59 #21910

There is an extensive library NSWC (Naval Surface Warfare Computation) in Fortran for performing matrix manipulation and other complicated mathematical operations.

I would like to know how I can access particular programs within this library from inside a FTN95 program. Example: CALL MTMS(.....) for matrix multiplication.

Thank you.

Bob Frenkel

23 Apr 2018 6:12 #21912

Bob

FTN95 can access certain third party libraries, particularly those written in C/C++. Details for 32 bit libraries can be found in FTN95.chm under Win32 platform->Mixed language programming->Calling C/C++ from FTN95.

Do you have a link to source code for the library that would provide information on how to interface to it?

23 Apr 2018 7:20 #21917

Paul

Thank you for your prompt reply.

When I was at the National Measurement Institute, Australia, it was simple to use the NSWC library. When executing a Fortran programme I would merely need to include the instruction -lnswc.

However, since retiring but still wishing to use Fortran for work with a colleague, I no longer have access to nswc, although I have Plato IDE on my home system and have run a few simple FTN95 programmes successfully.

Right now there is a more complicated programme involving matrices that I would like to run, but I have no access to lnswc.

Any views on how I can access the library? Thanks in advance.

Bob Frenkel

23 Apr 2018 8:54 (Edited: 23 Apr 2018 4:57) #21918

Bob Frenkel posted essentially the same question over 5 years ago:

 https://forums.silverfrost.com/Forum/Topic/2376

This is an old Fortran-66 library, still usable. The source code is available from

 https://github.com/jacobwilliams/nswc/raw/master/src/nswc.f

Manual (dated 1990):

 http://www.dtic.mil/dtic/tr/fulltext/u2/a476840.pdf

The file has already the correct lines selected for the machine constants in subroutines IPMPAR, SPMPAR and IPMPAR. Just compile and link the source file into a DLL:

 ftn95 nswc.f /si /opt /p6
 slink /dll nswc.obj /exportall

From this point on, to link any of your programs that call one of the NSWC routines, simply specify the name of the DLL in the linking command:

 ftn95 myNSWCX.f90
 slink myNSWCX.obj NSWC.DLL

Note that listing the name of the DLL in the SLINK command line serves the same purpose as the Unix Fortran compiler option -lnswc.

You can take the corresponding steps in 64-bit mode, if you prefer.

23 Apr 2018 11:44 #21925

An ideal answer, mecej4.

Please login to reply.