Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
188 views

I need to produce a static .exe to distribute to users that have no VisualStudio, no Intel Fortran/oneAPI, and no MKL. My code "UgensTester.f90" worked fine since 2010 with yearly updates, ...
Echeban's user avatar
  • 204
0 votes
0 answers
40 views

I read a Fortran code : program t real :: x(5) =[1.,-2.,3.,-4.,5.] real,allocatable :: y(:) y = x ... For me the normal way is allocate(y,source=x) I'm surprised that it works, both ...
Fabien's user avatar
  • 1
0 votes
1 answer
80 views

Passing an allocatable array via actual argument to a subroutine whose corresponding dummy argument is defined as an allocatable array: module m real, allocatable :: a(:,:) end module m module m2 ...
Youjun Hu's user avatar
  • 1,394
1 vote
1 answer
283 views

I have a derived-type with pointer (or allocatable) component type Tmy real, dimension(:), pointer :: vals integer :: nVals end type Tmy And I want to create a parameter, e.g. to pass it to a ...
Roux's user avatar
  • 475
-1 votes
1 answer
231 views

I have a text file with two colums with real numbers. How can I import the numbers from the second colum in an array ? I think I first need to define an allocatble array, then read my text file and ...
Florian Hubart's user avatar
1 vote
2 answers
214 views

I have two programs : 2D and 3D versions. For example, this is a simplified 2D version : program main integer, parameter :: nDim = 2 integer :: size real, dimension(:,:,:), allocatable :: ...
Stef1611's user avatar
  • 2,515
3 votes
2 answers
801 views

I read on many posts on Stack Overflow that an allocatable array is deallocated when it is passed in a subroutine where the dummy argument is intent(out). If I consider the following code : program ...
Stef1611's user avatar
  • 2,515
0 votes
0 answers
212 views

I am converting a legacy code and employing allocatable arrays Now a subroutine(STIFFR) calls another subroutine(RADaU5) which needs workspace and tolerance specifying arrays. Since these depend on ...
cfelix cfelix's user avatar
0 votes
0 answers
334 views

I use Intel Visual Fortran, both IVF2013 and IVF2019. When using allocatable arrays, the program is much slower than the one using static memory allocation. That is to say, if I change from Method 1: ...
Vivey's user avatar
  • 1
1 vote
1 answer
1k views

When a situation such as described in Incorrect fortran errors: allocatable array is already allocated; DEALLOCATE points to an array that cannot be deallocated happens (corrupted memory leaves an ...
Jellby's user avatar
  • 2,714
0 votes
0 answers
205 views

I'm learning Fortran with the book Fortran 90 for scientists and engineers by Brian Hahn. In chapter 9 about arrays, pages 131/132, he gives the following code as an example of dynamic arrays Program ...
Ottmar Schaub's user avatar
1 vote
1 answer
4k views

Now I have one 1024 * 1024 * 1024 array, whose dtype is float32. Firstly I save this array to one file in the format of '.bigfile'. And then I convert this bigfile to the Fortran unformatted file by ...
Stephen Wong's user avatar
2 votes
0 answers
294 views

As per object, I'm struggling understanding the logic behind functions returning allocatable arrays. I like this construct because its clarity compared to subroutines, and because pure functions in ...
Federico Perini's user avatar
1 vote
1 answer
175 views

I wish to create jagged arrays in Fortran with multiple levels of allocation. However I run in to the error of "There is no specific subroutine for the generic ‘new’ at (1)" for both my constructor ...
Jon Bjarke's user avatar
2 votes
1 answer
119 views

I'm trying to build an allocatable array with polymorphic elements. A minimal example is the following : program PolyArray implicit none type basetype integer :: ib end type basetype type, ...
Xiasu Yang's user avatar
1 vote
0 answers
268 views

I have written a very simple module (test.f90) module tt implicit none character(:),allocatable :: hh contains subroutine test() implicit none integer :: i end subroutine end module tt I ...
Guuk's user avatar
  • 609
0 votes
0 answers
245 views

I have a data file containing 4 columns and many rows, I want to allocate the first column to t, second to x, third to y, and fourth to z. And have the data being read by row. So to imagine: **T X Y ...
Matthew19's user avatar
3 votes
2 answers
541 views

This doesn't work program main implicit none integer :: nx = 3 integer :: ny = 5 integer :: nz = 8 real, allocatable, dimension(:,:,:) :: A real, allocatable, dimension(:,:) :: B ...
pablosaa's user avatar
  • 108
7 votes
3 answers
3k views

Let me consider a function returning an allocatable array. Should the array variable holding the result (outside the function) be allocated before an assignment? Consider, e.g., the following program ...
francesco's user avatar
  • 7,617
3 votes
1 answer
47 views

I would like to know why this code returns error in the last print. With gfortran 7.4.0 fails but with ifort 18.0.3 works well. program test implicit none type :: syntax integer, allocatable :: f(:...
franpena's user avatar
  • 151
1 vote
2 answers
1k views

I would like to know whether it is possible in modern Fortran to assign an allocatable array using itself, or part of it, to do it. Here it is a simple example: module modu implicit none type :: t ...
franpena's user avatar
  • 151
1 vote
0 answers
35 views

I have the following very simple code. What I don't understand is after I deallocate my array x, I would assume that my pointer ptr no longer can be dereferenced. However, If you run the program you ...
ATK's user avatar
  • 1,546
1 vote
1 answer
119 views

I have a fortran program that has the structure given below. This program has been crashing with 'Segmentation fault' error, so I did a lot of digging into the root cause. It turns out, in the ...
Curious Leo's user avatar
0 votes
1 answer
975 views

I'm looking for a way to build a tree structure using a User-Defined Type in Fortran 2008. While I can get some basic code working, I'm encountering memory leaks I am unable to pinpoint. The tree ...
dev-zero's user avatar
2 votes
2 answers
1k views

In the project I'm working on, I find myself frequently needing to resize arrays of objects as new objects are created and old ones destroyed. This happens with numerous different derived types ...
A. Graham's user avatar
5 votes
1 answer
981 views

A simple code: program main integer, allocatable :: A(:,:) integer :: B(3,4) B=1 A = B !A will get allocated, with the same shape and bounds as B end program main Compiling the above ...
Youjun Hu's user avatar
  • 1,394
3 votes
1 answer
1k views

I have the following module with an allocatable variable which is defined in the module, allocated in a subroutine, and then also used in a second subroutine called by the first subroutine. In this ...
Herman Toothrot's user avatar
1 vote
1 answer
397 views

In Fortran, if I use an allocatable array that is not allocated in an array assignment, I expect that there will appear some runtime errors. But it turns out that the allocatable array got allocated ...
Youjun Hu's user avatar
  • 1,394
4 votes
1 answer
725 views

When allocating zero-sized arrays in Fortran, I am getting counterintuitive behavior. This code: program test_zerosized implicit none integer, allocatable :: a(:),b(:) allocate(a(0)) print ...
Federico Perini's user avatar
2 votes
0 answers
525 views

I compile the following program with gfortran -g -fcheck=all -Wall bug.F90: program main implicit none real, dimension(:), allocatable :: arr allocate (arr(5)) ! should fail, but ...
letmaik's user avatar
  • 3,560
4 votes
1 answer
1k views

Since Fortran 2003 is it possible to work with variable length character strings. Instead of working in an archaic way and declaring a constant string length I would like to read the character strings ...
circuitbreaker's user avatar
2 votes
0 answers
663 views

I'm having issues with allocatable arrays in f2py. In the code below (stored in mymod.f90), I created two modules, vars and worker: vars stores and allocates the array b worker contains subroutines to ...
John Smith's user avatar
  • 1,253
0 votes
1 answer
748 views

I'm doing an assignment for a class where we need to write a program using allocatable arrays to hold an arbitrary number of x and y data pairs, allocate the extent of the arrays accordingly, and then ...
katlynisgreatlyn's user avatar
2 votes
1 answer
587 views

I make huge use of non-1 indexed ALLOCATABLE arrays, whose actual lower (and thus upper) bounds I want to be known for the procedures they're given to as IN/INOUT args (so I declare these dummy ...
Enlico's user avatar
  • 30.3k
2 votes
2 answers
995 views

I'm struggling with some Modern Fortran wrappers to some MPI scatter/gather routines. I am trying to have a wrapper interface that only has an array on input and returns the MPI-operated result on ...
Federico Perini's user avatar
0 votes
2 answers
2k views

Code: double precision maxstress(w) real, dimension(:), allocatable, save :: han(w) integer jang(w) do i=1,nblock if(maxstress(i) . gt. 1000) then jang(i) =1 han(i) = han(...
H.Jang's user avatar
  • 1
2 votes
0 answers
588 views

I have a parrallel part of a code which uses a THREADPRIVATE ALLOCATABLE array of a derived type which, in turns, contains other ALLOCATABLE variables: MODULE MYMOD TYPE OBJ REAL, DIMENSION(:), ...
Teloze's user avatar
  • 289
2 votes
1 answer
4k views

In fortran it is possible to check if an allocatable array is allocated using the allocated statement: program test_allocated integer :: i = 4 real(4), allocatable :: x(:) print *, 'before ...
user32882's user avatar
  • 6,107
2 votes
2 answers
1k views

I have problem trying to define a subroutine, whose argument contains an allocatable, optional, intent(inout) variable shown below. The code compiles fine, but get runtime error of "Segmentation fault ...
Ruizhi's user avatar
  • 87
1 vote
1 answer
2k views

I am trying to read an ASCII file and am getting errors when compiling such as: Error: Syntax error in READ statement at (1) And Error: Allocatable array 'pos' at (1) must have a deferred shape or ...
Elena.G's user avatar
  • 15
0 votes
2 answers
891 views

I'm trying to use allocatable arrays inside "device" data structures that reside in GPU memory. Code (pasted below) compiles, but gives a segfault. Am I doing something obviously wrong? Module file ...
ansri's user avatar
  • 52
0 votes
1 answer
1k views

Program Main Implicit None Integer, Parameter :: iwp = SELECTED_Real_KIND(15) Integer, allocatable :: Num(:) Num(1)=1 ...... End Program Main When I use allocatable to define a void array 'num' ...
FortranFun's user avatar
2 votes
1 answer
1k views

I can define a user defined data type with allocatable array as its data type. Allocation works perfectly while we are still in the same subroutine. But i don't know how to pass this type of user ...
Pankaj Pandya's user avatar
5 votes
1 answer
639 views

I'd like to know what is the internal memory representation of a fortran allocatable array. I understand this a bit more complex than a raw pointer, since shape and ranks must be stored as well. I ...
Regis Portalez's user avatar
3 votes
1 answer
921 views

I have struggled to find any concrete information where designing a derived type is concerned. I think the best way to discuss this is through a couple of options. I have made up some sections of code ...
Higgy's user avatar
  • 63
6 votes
2 answers
2k views

I am using GNU Fortran (GCC) 4.8.2 I want to read allocatable arrays from a namelist. But I don't know in advance how many elements have to be read into the allocatable array, so I cannot allocate it ...
Antonio Serrano's user avatar
0 votes
1 answer
370 views

In the parallel program I'm writing, I defined a lot of multidimensional allocatable arrays (actually just 1D, 2D or 3D) which are allocated with negative lower bounds during the execution. The reason ...
Enlico's user avatar
  • 30.3k
0 votes
1 answer
443 views

I want to create a derived-type variable (a.k.a. structure or user-defined variable), calculate it in one subroutine and use it in another subroutine. Both components of the structure are allocatable ...
Emily's user avatar
  • 1
3 votes
2 answers
3k views

Generally speaking I want to rename allocatable variables in a derived type that are passed through subroutine arguments. Writing everything with 'derived%type_xx' is not so pleasant. Besides, I don't ...
Ruizhi's user avatar
  • 87
1 vote
1 answer
172 views

The deallocate statement is used to recover storage of an allocatable array that is no more needed. What about non-allocatable arrays? Suppose (in the main and only program) there is a declaration ...
Enlico's user avatar
  • 30.3k