# Questions tagged [fortran]

Questions about interfacing Mathematica and Fortran. This also includes conversion of Fortran style numbers to Mathematica style.

53 questions
Filter by
Sorted by
Tagged with
1 vote
111 views

### Exporting a table using Fortran format for numbers [duplicate]

I would like to export in txt or tsv format a table that contains both alphameric and numeric entries, but I would like the numeric entries to be exported in Fortran format. For example 1.234E-9. Is ...
• 4,167
167 views

### Python compatible fortran form for complex numbers

I am trying to use the Mathematica output of a complicated expression as input for python. As suggested in this answer, the FortranForm of an expression already ...
• 63
743 views

### Is it possible to use the DGEEV and DSYEV LAPACK subroutines in Mathematica?

Here is my problem: I'm diagonalizing some matrices using Eigensystem[] to obtain eigenvalues and eigenvectors and I'm diagonalizing the same matrices using a ...
• 191
157 views

### When I transform a long expression into fortranform, the output adds a minus sign at every row. How to fix it?

I try to transform the following expression into fortranform ...
• 1
1 vote
189 views

### Run a code in Fortran, C++, or Python in Wolfram Mathematica 12 on Mac OS [closed]

I would like to run an external code, written in Fortran, C++, or Python, within Wolfram Mathematica 12 on my MAC OS. I looked up on Internet and I tried to read the WSTP documentation on Wolfram ...
• 403
155 views

### ListPlot3D from Data Fortran file

My .dat file (Fortran) consists of data (x y u) as three columns and I would like to plot the variable "u" against the variables "x" and "y&...
1k views

### Passing vectors into a Fortran function and getting out a vector

I am writing a Fortran function that needs to receive two vectors of reals, and as an output, returns a vector. The function could be for example the sum of the two vectors: ...
• 1,099
113 views

### Cannot open Utilities 'FilterOptions'

I'm trying to run a code like this in Mathematica: ...
124 views

### Convert huge (10-100MB of plain text) Mathematica function for external use

I have a huge Mathematica function (plain text ranging 10-100MB) that I am trying to convert to Fortran for external use. I tried using FortranForm, which does most of the work, and cleaned the code ...
• 21
537 views

### Convert Fortran-like number form to traditional number form

What is the most elegant way to convert arbitrary numbers written as (verbatim): 1.13903 e - 08 into traditional Mathematica number form without having to ...
• 39.8k
1 vote
230 views

### How to integrate a function written in fortran that solves a set of nonlinear equations into mathematica?

I am trying to integrate the solver for the set of nonlinear equations link written in Fortran language into mathematica . To do so i developed a function called netlib based on the explanation given ...
• 781
205 views

### Add a suffix to the end of every number in a string [duplicate]

I have some polynomial e.g. $2x^2 + 3x + 4$ In Mathematica I can define this, and convert it to a string simply enough ...
• 197
1 vote
181 views

### Can we link Mathematica and Fortran with WSTP? [closed]

How to link Mathematica and Fortran with WSTP?
448 views

### Mathematica code in fortran [closed]

I have an integral in which the integrand is a combination of ratio of modified bessel function of second kind. I am able to find the solution of this integral with mathematica Nintegrate module with ...
1 vote
337 views

### Printing all elements of table in Fortran form

Let's say I have some Table object. The elements of this table are accessed as Table[[i,j,k]]. For each element in the array I ...
• 197
140 views

### Replacing all integers in a string

Let's say I have some expression like, expr = 1*a + 2*b +3*c + 4*d I want to write this to a string that I can then use in some other Fortran script. I want all ...
• 197
320 views

### How to import a binary data generated by Fortran? [closed]

I have a unformatted binary data file generated by gfortran. However, when the binary data is imported by Mathematica, a correct result is not obtained. This is my fortran code: ...
312 views

### Fortranform output in double precision

I want to take the output in fortran form but written in double precision notation. For example, exp=1 + 8*as^2*Log[2*x] which gives ...
• 1,604
149 views

### Replacement Patterns in FortranForm

I have recently asked a question concerning string replacement rules for FortranForm. This question has been answered by Carl Woll - thanks for that! Now as I was ...
166 views

### how to include conditional statements in FortranForm?

how to to include following formula in the FortranForm in a correct format? ...
• 781
178 views

### Converting subscript in fortranform

i have a matrix like this: F := Table[Subscript[f, i, j], {i, 3}, {j, 3}] c=F.F my question is that how to convert the components of c to this form Subscript[f, ...
• 781
92 views

### possibility of using f2py for interoperability with Fortran

Although interoperability with Fortran could be realised by using LibraryLink (e.g., Linking FORTRAN with Librarylink), the approach is not so straight forward, in ...
• 4,337
360 views

### Import .ini file with text and numbers

I have faced a quite simple problem, but, honestly, I don't know what would be better to do. I have a .ini file generated by a Fortran program with with this type of data: ...
• 33
135 views

### FORTRAN complex number passing to Mathematica through NETLink

I used to use NETLink to call FORTRAN functions or subroutines compiled into a dll file. This works very well until now that I want to call a function which has complex arguments and returns a complex ...
• 1,497
1 vote
162 views

### Call NAG subroutine in Mathematica 10

Is there any package or any other way to call or use NAG library? It was possible in old mathematica?
• 61
199 views

### Problem with Dot and FortranForm

I am trying to convert some set of equations to a form that will be easy for Python to evaluate numerically, hence I am using Mathematica's FortranForm My problem ...
• 1,195
539 views

### Running a Fortran program and getting the results

I'm trying to figure how to make Mathematica interact with a Fortran program that takes 2 parameters in a first input line, 3 parameters in a second input line and produces two lines as outputs. Below ...
• 43
341 views

### Importing a large number of complex matrices from a .DAT file and then numerically analyzing them one by one

I have a .DAT file generated by Fortran in which I have data for $2 \times 2$ matrices. For example, the file takes the form (when I open it in the excel): I have added a snippet beacause the real ...
• 980
445 views

### Integrate fortran function into Mathematica

I was trying to use Fortran function in Mathematica. I was following mainly this answer . My Fortran code looks like this: ...
• 631
94 views

### weird behaviour of Listable fortran Librarylink function: different result each evaluation

I am working with fotran librarylink function currently. In this post, I will show some weird result of Listable fortran librarylink generated by intel compiler under windows (I tried gcc on linux the ...
• 16.9k
1 vote
221 views

### Using .Net link with fortran DLL created by Intel Fortran [closed]

I am following unstable's wonderful answer on .NET and fortran. I can reproduce his result using gfortran without problem. But I want to use Intel Fortran, because gfortran generates slower code on ...
• 16.9k
1 vote
466 views

### What is the equivalent of FORTRAN 77 COMMON BLOCK in Mathematica?

I am in the process of converting a FORTRAN 77 program to Wolfram Language. I have several COMMON BLOCK statements in FORTRAN 77. My question is how to deal with them in Wolfram Language? My ...
• 11
162 views

### Customized FortranForm output

Let's take the following example V = (-G*Mn)/Sqrt[x^2 + y^2 + z^2 + cn^2]; Vx = D[V, x]; FortranForm[Vx] The result is ...
• 8,550
512 views

### Where is f2mma.zip, Fortran to Mathematica converter?

I want to convert the SOFA libraries to Mathematica, and found out about f2mma, a Fortran to Mathematica converter. Google points to many papers about f2mma, but the only link to the software ...
1 vote
453 views

### How to get output in a specified format

In Fortran, we can easily get the stardard and easy output format. Now, we only focus on the Integer output. See here How to realize this kind of output as formatted text file using Mathematica ? (...
• 1,227
708 views

...
• 195
932 views

### Using FortranForm for d0 notation? [duplicate]

When I use FortranForm, it changes 2*a^2 into 2*a**2 which is fine, but if I want the expression in a form such as, 2.d0*a**2 which represents an integer to be ...
• 195
507 views

### Insert a linebreak and character repeatedly into a matrix output which is in fortranForm

Suppose I have a very long string which is a11 element of matrix a11=2*gopsv-2*Bgopsvw+2*acgmops*v+2*cgmopsv*B-2*acgmopsvB+3*gmopsvB-3*BgmopsvwB+m*w2*B +5*acgm2 +opsvB -ac*m2*w2*B +cgm2*opsvB* - 3*...
• 195
389 views

### How to show Output of matrix in FortranForm with "&" character?

I have a matrix. and i have shown the output of matrix one by one element in FortranForm. the problem is i want to put "&" continuation charater in output because when i am copying the data into ...
• 195
419 views

### How to show output of a matrix in m(1,1)=a11 m(1,2)=a12 ...in this way......i have 50 *50 size matrix

How to show output of a matrix in m(1,1)=a11 m(1,2)=a12 ...in this way......i have 50 *50 size matrix so i want to do it efficiently. output to be shown like m(1,1)=a11 (in fortranForm) m(1,2)=a12 ...
• 195
623 views

### Output of matrix in FortranForm

matr2 = Table[FortranForm[matr[[i, j]]], {i, 4}, {j, 6}] but i want output to be more like this matrix(1,1)=a11 output in ...
• 195
2k views

### Formatting Fortran complex number output for use in Mathematica

Here is a list that was orignially output from Fortran. {{"(0.277336296055697, 0.120000000000000E+000)"}, {"(-1.489297392708939E-002, 0.340000000000000E+000)"}} ...
• 1,294
1k views

### Using FortranForm

I need to use in Fortran, matrices that I create in Mathematica, therefore, I need to format them, so that Fortan can understand them. I focus on the simplest example: Let's say I have tha matrix A ...
• 1,294
435 views

### ToExpression and Fortran notation

ToExpression["9.0E-03"] interprets the string as 9*e - 3 instead of what I am expecting: ...
• 451
264 views

### Output most efficient Fortran code by mathematica

I am trying to output most efficient Fortran code by mathematica 9.0 with the method Simon provided: How can I get Mathematica to produce better Fortran code? The expressions is as follows: ...
• 511
1 vote
611 views

### Latest Mathematica 9.0 can't use Format.m to generate optimized Fortran code [closed]

Before updating to Mathematica 9.0, I have successfully generated beautiful Fortran code using Mark Sofroniou's Format.m package, which is posted on MathSource. ...
• 511
964 views

First, the main reference is the thread Linking FORTRAN with Librarylink, which teaches how to make the link between a FORTRAN subroutine and a Mathematica code, by using Librarylink. This must done ...
• 738
3k views

### How to change an expression to Fortran90 form?

I have a large expression produced by Mathematica. To use this expression in my Fortran program I need to change it to a Fortran90 form. I am not satisfied with the ...
• 1,227
15k views

### How to export data files using specific number format

Very often, I have to export data files from Mathematica. These output files contain several columns and hundreds of lines with data. For the sake of the question let's create a sample list: ...
• 8,550