Skip to main content

Questions tagged [fortran]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
189 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 ...
David Keith's user avatar
  • 4,724
6 votes
1 answer
215 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 ...
sqrt6's user avatar
  • 63
20 votes
1 answer
944 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 ...
User3000's user avatar
  • 311
0 votes
1 answer
248 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 ...
Yong's user avatar
  • 1
1 vote
1 answer
211 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 ...
VDF's user avatar
  • 453
2 votes
3 answers
184 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&...
Mohamed Hajjaj's user avatar
3 votes
2 answers
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: ...
Denis Cousineau's user avatar
0 votes
0 answers
139 views

Cannot open Utilities 'FilterOptions'

I'm trying to run a code like this in Mathematica: ...
Linus's user avatar
  • 3
2 votes
0 answers
126 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 ...
lll's user avatar
  • 21
6 votes
3 answers
617 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 ...
David G. Stork's user avatar
1 vote
0 answers
237 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 ...
user49047's user avatar
  • 811
2 votes
2 answers
224 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 ...
user1887919's user avatar
1 vote
0 answers
186 views

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

How to link Mathematica and Fortran with WSTP?
Prabhakar Namdev's user avatar
2 votes
2 answers
476 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 ...
Prabhakar Namdev's user avatar
1 vote
1 answer
375 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 ...
user1887919's user avatar
0 votes
2 answers
144 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 ...
user1887919's user avatar
3 votes
0 answers
349 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: ...
finalboss's user avatar
2 votes
0 answers
348 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 ...
BabaYaga's user avatar
  • 1,907
2 votes
1 answer
197 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 ...
Flo Ragossnig's user avatar
0 votes
1 answer
168 views

how to include conditional statements in FortranForm?

how to to include following formula in the FortranForm in a correct format? ...
user49047's user avatar
  • 811
3 votes
1 answer
181 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, ...
user49047's user avatar
  • 811
2 votes
0 answers
95 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 ...
sunt05's user avatar
  • 4,367
3 votes
2 answers
375 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: ...
Alex's user avatar
  • 33
3 votes
0 answers
141 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 ...
unstable's user avatar
  • 1,507
1 vote
0 answers
164 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?
NRS's user avatar
  • 61
2 votes
2 answers
206 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 ...
ThunderBiggi's user avatar
  • 1,205
3 votes
1 answer
562 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 ...
lgcm's user avatar
  • 43
0 votes
1 answer
369 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 ...
Junaid Aftab's user avatar
  • 1,000
1 vote
0 answers
520 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: ...
Moonwalk's user avatar
  • 661
4 votes
0 answers
96 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 ...
matheorem's user avatar
  • 17.4k
1 vote
0 answers
229 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 ...
matheorem's user avatar
  • 17.4k
1 vote
1 answer
485 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 ...
Villisla's user avatar
5 votes
1 answer
166 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 ...
Vaggelis_Z's user avatar
  • 8,830
8 votes
0 answers
531 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 ...
user avatar
1 vote
1 answer
489 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 ? (...
Orders's user avatar
  • 1,247
2 votes
1 answer
780 views

How to convert integer value into real value like 2 into 2.d0 in output of matrix in FortranForm?

...
Amandeep's user avatar
  • 195
3 votes
1 answer
949 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 ...
Amandeep's user avatar
  • 195
2 votes
1 answer
518 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*...
Amandeep's user avatar
  • 195
4 votes
2 answers
413 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 ...
Amandeep's user avatar
  • 195
0 votes
2 answers
431 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 ...
Amandeep's user avatar
  • 195
0 votes
2 answers
669 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 ...
Amandeep's user avatar
  • 195
0 votes
3 answers
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)"}} ...
Mencia's user avatar
  • 1,364
2 votes
1 answer
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 ...
Mencia's user avatar
  • 1,364
2 votes
2 answers
457 views

ToExpression and Fortran notation

ToExpression["9.0E-03"] interprets the string as 9*e - 3 instead of what I am expecting: ...
user1541776's user avatar
7 votes
0 answers
267 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: ...
Tang Laoya's user avatar
1 vote
1 answer
617 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. ...
Tang Laoya's user avatar
13 votes
1 answer
983 views

How to load FORTRAN libraries through Librarylink

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 ...
fcpenha's user avatar
  • 738
9 votes
3 answers
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 ...
Orders's user avatar
  • 1,247
19 votes
6 answers
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: ...
Vaggelis_Z's user avatar
  • 8,830
27 votes
2 answers
4k views

How can I get Mathematica to produce better Fortran code?

I am new to Mathematica and I am trying to get to it to produce some expressions in Fortran code. However, it seems that Mathematica will output duplicated expressions, that is, expressions the need ...
Tang Laoya's user avatar