Using MATLAB Build Functions as an Interactive Part of Fortran

While many of you will have a decent idea of ​​what I'm aiming for, just by reading the headline - let me just introduce you a bit more.

I have a Fortran program - it consists of a program, some internal routines, 7 modules with its own procedures and ... uhmm, what is it.

Without going into details, since I don’t think it is necessary at this moment , what would be the easiest way to use the MATLAB construction functions (mainly the plot (x, y) with some settings) as an interactive part of my program? . I am currently using some of my own custom build routines (based on the HPGL and Calcomp routines), but as part of the exercise for my part, I would like to see where it can go and how it will work (is it possible that I suggest ?). Also, how much effort will it take on my part?

I know that this question is described in some detail in many "textbooks" on the net, but for some reason I find it difficult to find really simple but illustrative introductory notes. Therefore, if anyone can post an example or two simple ones, I would be very grateful. Or just take my hand and pass through one working example.

platform: IVF 11.something :) on Win XP SP2, Matlab 2008b

+4
source share
3 answers

Continuing the discussion of DISLIN as a solution, with an answer that does not fit into the comment ...

@M. S. B. - hello. I apologize for the letter in your answer, but these comments are too short, and the answer to the question in the form of an answer with an answer is ... anyway ...

There is a Quick Plot function for DISLIN - only three arguments are required to execute the QPLOT curve: array X, array Y and number N. See chapter 16 of the manual. Plus only a few additional calls for selecting an output device and marking axes. I have not used this, so I do not know how good autoscaling is.

Yes, I know Quickplot and its related routines, but it is too functional for my needs (I can’t change anything), and yes, this autoscaling is a bit strange. In addition, the fields inside the graph are too large.

Or, if you want to use the power of GRAF to customize your graph, there is a GAXPAR routine for automatically creating recommended values. -2, because the first argument LABDIG automatically determines the number of digits in the label labels.

Have you tried routines?

Sorry, I cannot find the GAXPAR procedure that you specified in the dislin index. Are you sure this is called that?

MSB Answer : Yes, I'm sure of writing GAXPAR. This is the last procedure in chapter 4 of the DISLIN 9.5 PDF manual. Perhaps this is a new routine? There is also another way to auto-scale: SETSCL - see Chapter 6.

So far, what I have been doing (except for some duck tape solutions)

use dislin; implicit none real, dimension(5) :: & x = [.5, 2., 3., 4., 5.], & y = [10., 22., 34., 43., 15.] real :: xa, xe, xor, xstp, & ya, ye, yor, ystp call setpag('da4p'); call metafl('xwin'); call disini(); call winkey('return'); call setscl(x,size(x),'x'); call setscl(y,size(y),'y') call axslen(1680,2376) !(8/10)*2100 and 2970, respectively call setgrf('name','name','line','line') call incmrk(1); call hsymbl(3); call graf(xa, xe, xor, xstp, ya, ye, yor, ystp); call curve(x,y,size(x)) call disfin() end 

which puts extreme values ​​right on the axis. Do you know, maybe, how I can get one “extreme marker” on the outside to put some area between the curve and the axis (while preserving the effects of setscl)?

Even if you don’t like the built-in autoscaling, if you are already using DISLIN, speeding up your own autoscaling will be easier than calling Fortran from MATLAB. You can use the built-in Fortran minval and maxval functions to find the smallest and largest values ​​in the data than write a routine to round it to “good” round values. Similarly, a subroutine defines a tick interval.

This is actually not so easy to do (and ideas to prove that I'm wrong will be appreciated). Or should I say that this is easy if you know the approximate range in which your values ​​will lie. But if you do not, and you do not know whether your values ​​will be in the range 13-34 or 1330-3440, then ...

... if I am on the wrong track all the way here, please explain if you are something else. My English is somewhat lacking, so I can only hope that the above is understandable.

Inside the routine for determining the start / end values ​​of a round, you can always scale the actual min / max values ​​from 1 to 10, and then have a table to select good round values, and then drop them back to the desired range.

-

+3
source

The easiest way is to write the Fortran program to a file, and your Matlab program will read these files for the information you want to build. I make most of my number on Linux, so I'm not quite sure how Windows handles one process, writing a file, and the other reading it at the same time.

Something like kludge, although you might want to think about using Matlab to call Fortran (or parts of it) and get the data directly for plotting. In this case, you need to explore the creation of Fortran MEX files in the Matlab documentation. This is relatively easy to do and will satisfy your needs if you would be happy to use Matlab to control the process, and Fortran as a computing service. I would look at examples common with Matlab for simple Fortran MEX files.

Finally, you can call Matlab from your Fortran program, search the documentation for Calling the Matlab Engine. It’s a little harder for me to understand how this can fit your needs, and this is not something that I am very familiar with.

If you post more details again, I can provide more specific advice, but you should probably start rolling up your sleeves and plunging into MEX files.

+4
source

Dump Matlab because it's proprietary, expensive, bloated / slow and the codes are not easy to parallelize.

What you need to do is use something on the lines of DISLIN, PLplot, GINO, gnuplotfortran, etc.

+2
source

Source: https://habr.com/ru/post/1311463/


All Articles