Melvin Brown

84 Reputation

6 Badges

14 years, 44 days

Social Networks and Content at Maplesoft.com

Maple Application Center

MaplePrimes Activity


These are replies submitted by Melvin Brown

@roman_pearce 

Thanks for your help.  (It's getting close to decision time on whether to take the free upgrade to Windows 10 or to stay with Windows 7 for a few more years.)

MRB

@cskoog 

Many thanks; very helpful.

MRB

Thanks, acer.  I'll draw a line under that; it would have been very useful.

MRB

@acer

Ah...  the .mla seems to be in binary (or other obscure format)... at least from viewing in Notepad, it seemed so.  But perhaps there are MAPLE commands that will list the contents of a .mla?  

However, I've just found that one can at least write protect an .mla file

LibraryTools[WriteMode]("/home/user/mylib/MyLib.mla","READONLY");

to guard against accidental corrpution.  I guess one can easily reset the write mode, if necesaary?

MRB

 

 

@acer 

Many thanks. I did appreciate the distinction between those two options, but I was interested to see if it could done with an .mla, partly for security of the code, should that be required.

I'll take a look at the putting the code in the start up code section

MRB

@Carl Love 

@acer

Well, I've just tested this.  Here are my findings:

MAPLE 2015.1 running a Maple worksheet
==========================

I placed the following code in the Start up Code section

libname := libname, "S:/MRBwork/MAPLE/MRBlibrary/BealSearch/BealSearchSp8.mla";
with(BealSearchSp8);

This automatically links in the package I require, when the worksheet starts up.

I then use the Mathematical Expression component to embed a call to a procedure from this package. On pressing return outside the component box, I obtain the expected result.

Fine!

MAPLE Player 2015
=================

However, when I start the same worksheet in MAPLE Player, I have the following response:

0, "permission denied: no read access (%1)", "S:/MRBwork/MAPLE/MRBlibrary/BealSearch/BealSearchSp8.mla"

which presumably comes from the start up code section.

I then find (perhaps unsurprisingly) that the Mathematical Expression component calling the procedure evokes no result at all.

I have taken a look at the permissions on that file and all groups and users have read and read/excute permission.

Are you able to suggest a route forward?

MRB

@acer 

Thanks very much for the helpful tips; I'll work through your suggestions. I've not previously used the Startup Code Region.

MRB

Mac

 

Many thanks for that helpful answer; particularly that A knows about B and C.

 

Cheers MRB

@acer 

This problem of creating a fortran dll for calling in MAPLE is now solved. The solution is explained and exemplified below.

My first attempt at generating dll with fortran g77 failed because g77 does not have a -shared option to generate a dll.

The gfortran complier in the gcc collection does have the -shared option for dll generation. However, my attempt at using gfortran from the MinGw gcc compiler set (under Windows 7) failed to create an executable let alone a dll. I was unable to diagnose the cause.

Finally, I installed Cygwin (on a Windows 7 laptop). This includes the gcc collection of compilers, and I was thus able to successfully generate a dll. A key step was setting an environmental path variable to the cygwin1.dll in C:\cygwin64\bin to enable its link from the .dll to be resolved.

The gfortran compile sequence was as follows: First compile myfunc.c into object code:

gfortan -c myfunc.for

in which myfunc.for defines the FORTRAN function mult(a,b) where a and b are real numbers being multplied together. Then, using gfortran we build a shared library from the object file:

gfortran -shared -o myfunc.dll myfunc.o

The dll is then called up to define a function in MAPLE as follows:

fmult:=define_external(mult,LIB="C:/shared/myfunc.dll",FORTRAN,'a'::(float[4]),'b'::(float[4]),RETURN::(float[4])):

We then find that:

fmult(3, 2.7);
8.10000038146972656

and

[seq(fmult(2*j, 5*(j-1)), j = 1 .. 10)];

[0., 20., 60., 120., 200., 300., 420., 560., 720., 900.]

This completes the example. The difficultly lay not with MAPLE, but with finding and apt implementation of the gcc compiler set.

MRB

 

 

@acer 

Thanks again for engaging with this.    I am running MAPLE 18 under Windows 7.  I was unable to generate a dll using g77, as the latter seems not to recognise the -shared option.  

So I switched to using CYGWIN, and successfully used the -shared option to generated a dll file there:

$ gfortran -c test2.for

$ gfortran -c Mtest.for

$ gfortran -shared -o mult.dll test2.o

However, that dll file was not accepted by MAPLE, in which the line

fmult:=define_external('mult',LIB="c:/shared/mult.dll",FORTRAN,'a'::(float[4]),'b'::(float[4]),RETURN::(float[4]));

produced the following error:

Error, external linking: error loading external library c:/shared/mult.dll: The specified module could not be found.

Am I correct in thinking that a dll generated under CYGWIN will not be correctly parsed by MAPLE running under Windows, which presumably requires a dll targetted at Windows?  Can flags can be used to tell gfortran (under CYGWIN) to generate a dll targetted at Windows? Ideally, I am looking for a working example.

Regards

MRB

 

Thanks for your quick response.  I am working on Windows 7, hence use of dll.    I am also using g77 which appears not to support the -shared option; at least for me on Windows !! I have now separately compiled the main and function fortran files.  However, it remains the case that I am unable to create a dll that does not generate an error from the external function call.

MRB

I have some old (R3,4,5..) MAPLE files of types:

.mwz and .msz

and would like to open these files asndf convert them for viewing in MAPLE 16.

Is the way of doing this?

MRB 

 

 

I have some old (R3,4,5..) MAPLE files of types:

.mwz and .msz

and would like to open these files asndf convert them for viewing in MAPLE 16.

Is the way of doing this?

MRB 

 

 

Thanks; I sent an email asking for help to that email address on Jun 6 2011, but have not yet received a repy!  I have just re-sent that email.

 

MRB

Thanks; I sent an email asking for help to that email address on Jun 6 2011, but have not yet received a repy!  I have just re-sent that email.

 

MRB

1 2 3 4 Page 3 of 4