Questions tagged [fortran2003]

Fortran 2003 is a major revision of Fortran 95 introducing many new features. It was released in 2004 as an ISO standard. It's successor is Fortran 2008. This tag should be used only for those questions which rely on behaviour specific to the Fortran 2003 standard. For such questions the more general Fortran tag should be applied additionally.

This major revision of added major new features to it's predecessor .

144 questions
16
votes
1 answer

Difference between type and class in fortran 2003

I have been told for my PhD that I have to learn fortran 2003 language. I have never used and OOP program before nor fortran. I am trying to understand what the difference between type and class is. I know that classes are declared with the 'TYPE'…
Tori
  • 161
  • 1
  • 4
16
votes
1 answer

Current best method for wrapping Modern Fortran code with Python

I know of, and have used f2py2e to wrap some old Fortran 77 code, but my understanding is that it does not work with newer Fortran 95 code. I've researched what I should use, and have come across fwrap and G3 f2py, neither of which seem to give any…
James Tocknell
  • 494
  • 5
  • 15
15
votes
2 answers

Fortran derived type assignment

Say I have a Fortran derived type type :: atype integer :: n integer :: a(10) integer, allocatable :: b(:) end type and I have two instances of this type type(atype) :: t1, t2 what exactly happens when I do the following…
stiaan
  • 153
  • 1
  • 6
10
votes
1 answer

An optimized implementation of the Heaviside function

I'm would like to (super)optimize an implementation of the Heaviside function. I'm working on a numerical algorithm (in Fortran) where speed is particularly important. This employs the Heaviside function many times, currently implemented by the…
Ed Smith
  • 12,716
  • 2
  • 43
  • 55
9
votes
1 answer

Fortran intrinsic keyword in module use statement

What does it mean when the intrinsic keyword is added to the use statement for a module, as in the following example? use, intrinsic :: iso_c_binding (From 7.1 Overview of Fortran interface, FFTW 3.3.6-pl1) Does it specify that a module of that…
norio
  • 3,652
  • 3
  • 25
  • 33
9
votes
3 answers

What does "array cannot have a deferred shape" mean in fortran?

I have a simple fortran function that computes the Kronecker product: function kron(A, B) implicit none real, intent(in) :: A(:, :), B(:, :) integer :: i, j, ma, na, mb, nb real, dimension(:, :) :: kron ma = ubound(A, 1) na…
Michael A
  • 4,391
  • 8
  • 34
  • 61
8
votes
2 answers

Automatic generation of Fortran 2003 bindings from C library headers (using iso_c_bindings intrinsic module)

Is there a tool to automatically generate Fortan bindings from C library header, using intrinsic iso_c_bindings module from Fortran 2003 standard? I am not interested in translating C to Fortran, but only generating bindings.
Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
8
votes
1 answer

Assigning a Fortran integer value to a malloc-allocated C memory target

Suppose you had created a Fortran array(:) of pointers to memory allocated in C by malloc (as shown in best answer, code repeated below). Is there a way to write an integer value into this allocated memory by using the Fortran array, i.e. the…
BastH
  • 83
  • 4
8
votes
1 answer

Are Fortran's "final" subroutines reliable enough for practical use?

Modern Fortran contains various object-oriented ideas, including a concepts of "destructors" through the FINAL keyword. MODULE mobject TYPE :: tobject ! Data declarations CONTAINS FINAL :: finalize END TYPE CONTAINS SUBROUTINE…
kdb
  • 4,098
  • 26
  • 49
8
votes
3 answers

Is there an alternative to GETCWD() in Fortran 2003-2008

The GNU Extension to the GNU Fortran compiler provides the subroutine GETCWD() that well, gets the current working directory. However, my code has to be portable to the ifort and nagfor compiler as well and I use F2003 features. So, is there an…
LienM
  • 135
  • 1
  • 7
8
votes
2 answers

Nested derived type with overloaded assignment

I have a derived type (wrapper) containing an other derived type (over). For the latter the assignment operator have been overloaded. As the assignment of derived types happens per default componentwise, I'd expect that assigning two instances of…
Bálint Aradi
  • 3,754
  • 16
  • 22
7
votes
3 answers

Direct indexing of function return value in Fortran

Is there possibility to use indexing directly on a function's return value? Something like this: readStr()(2:5) where readStr() is a function which returns a character string or an array. In many other languages it is quite possible, but what about…
hamid attar
  • 388
  • 1
  • 8
6
votes
1 answer

Using scientific notation and underscore kind specifier at the same time for real literals in Fortran

Using scientific notation for floating point literals is easy enough in Fortran: 1.5d-10 would mean a double precision (whatever that means under current Fortran compiler settings) floating point value that approximates 1.5*10^-15. However, the…
uLoop
  • 225
  • 1
  • 8
6
votes
1 answer

Segmentation fault with deferred functions and non_overridable keyword

I am developing an object-oriented Fortran code for numerical optimization with polymorphism supported by abstract types. Because it is a good TDD practice, I'm trying to write all optimization tests in the abstract type class(generic_optimizer),…
Federico Perini
  • 1,414
  • 8
  • 13
6
votes
2 answers

Fortran polymorphism, functions and allocation

I am quite a beginner in OOP with Fortran and I am trying to write a program with procedures that deal with polymorphic variables as arguments. Although my original code is much more complicated (many procedures, several derived types etc), I could…
Reno
  • 81
  • 3
1
2 3
9 10