Questions tagged [fortran]

Fortran is a general-purpose, procedural, imperative programming language that is especially suited for numeric computation and scientific computing. Since 2003, standard Fortran also supports object-oriented programming. Fortran 2008 introduced coarrays for SPMD parallel programming. This tag should be applied to all questions about the Fortran language; other specific tags can be added for compilers, language revisions and particular aspects of use.

fortran
Filter by
Sorted by
Tagged with
1 vote
0 answers
48 views

MPI4PY doesn't spawn on multiple nodes

I wrote a Python code that spawns N sub-processes to run an executable, child, written in Fortran. I use an MPI Broadcast from the python main to communicate a message (a string that reads CNTRL) to ...
1 vote
0 answers
79 views

Updating old mpi_wrapper subroutines

I am working on some old fortran 90 code which uses wrapper subroutines for mpi commands. The subs have to take in data objects of the same type but of differing rank (0, 1 and 2). Below is given a ...
0 votes
0 answers
32 views

Microsoft Visual Studio Can't find File when using Step In Command

I am currently working on a Fortran code on Microsoft Visual studios 2022. Until recently, I was able to step into different subroutines and suddenly I'm getting an error "___________ not found&...
1 vote
0 answers
115 views

Creating temporary array when declared in a module

I do not understand why gfortran creates a temporary array only in one case. Consider the following program program temporary_arrays use Mvars, only : am use Mtemporaries, only: ...
0 votes
0 answers
57 views

Outout is affected for some weird silly reaons (print command as well as silly declaration of array)

I am new to this community. I am using ifort compiler for my abaqus subroutine. I was using it effortlessly until the last 2 weeks I have been struggling a lot! It is just that my output is affected ...
0 votes
1 answer
78 views

f2py does not output inout as expected

Why does f2py not generate a correct wrapper when dealing with inout params? Here is an example of my function call: io = 7.5 io, out1, out2, out3 = fortran_file.func(5, 2.5, False, io) Here's how ...
0 votes
1 answer
123 views

SYCL: No kernel name was found

There are other similar questions regarding this issue, but their answers do not solve my case: terminate called after throwing an instance of 'sycl::_V1::runtime_error' what(): No kernel named ...
0 votes
0 answers
148 views

Unexpected errors with openmpi running fortran code

I am a mechanical engineering looking to do CFD simulations on HPC machines. Currently, I am programming my procedures within the framework of PARAMESH, which is a fortran library with MPI calls for ...
1 vote
0 answers
61 views

Dealing with assumed-type, assumed-rank dummy arguments

This question is a continuation of my previous post. One question per post, therefore asking a separate question. The accepted answer asserts The compiler documentation's comments about the use of ...
0 votes
0 answers
57 views

How to build a vector based on the elements of another vector in Fortran?

I'm new to Fortran and would like to build a two vectors based on two other vectors. I will explain: The kx and ky vector has 150 elements. I want the vector x_p(i,1) to be a vector with 22500 ...
8 votes
2 answers
3k views

How to get command line arguments of unknown length in Fortran?

I'd like to read in some text strings from the command line used to run a program. I'm using the internal subroutine GET_COMMAND_ARGUMENT in a program that basically is something like: program test ...
0 votes
1 answer
125 views

implicit real - complex conversion in fortran

New standards of fortran are more strict about the mismatches between the calls and the procedure definition. However, there are a lot of legacy codes where, for instance, complex array is viewed as a ...
0 votes
0 answers
51 views

Read binary file containing strings and numbers in Fortran

I am trying to read a binary file in Fortran. The file contains strings and numbers. I know how the binary file was created, since I have the code. Here is the minimal reproducible example of code ...
0 votes
1 answer
99 views

Optimal way to create once, then frequently access to a large array in Fortran

I have a scientific simulation in Fortran. In it, I need to calculate a large array (say 10^5 elements, a size known / that can be preset when writing the code) "once" around the beginning, ...
7 votes
2 answers
4k views

How do you iterate through an array in Fortran?

Say I have real, dimension(0:100) :: realResults and I want to iterate over realResults, ultimately to create json of the array of the form [[x1,y1], [x2,y2], [x3, y3], ... ] I'm pretty sure I want ...
1 vote
0 answers
88 views

Passing allocatable character(:) slices with negative stride segfaults GFortran, Why?

Why does this Fortran program segfault? Is it the compiler, or have I violated the standard - and if so, how? ! gfortran -fcheck=all arrays10.f90 && ./a ! GNU Fortran (GCC) 11.4.0 program ...
0 votes
0 answers
60 views

gfortran not finding pre-compiled module despite -I flag [duplicate]

I am trying to create a folder that contains all the modules I may use. Rather than compiling those modules whenever I need them, I pre-compiled the modules within that folder and would like to use ...
0 votes
0 answers
78 views

Dealing with interface argument type mismatch

As a follow-up to my previous question about passing a subroutine as an argument to another subroutine, the consensus was that I should use an explicit interface. The issue I am running into is ...
0 votes
0 answers
479 views

mpirun: one process terminates but prints no core dump

Folks, I am stumbling upon quite a weird issue. I am running a job with mpirun command: mpirun -np 4 ~/opt/stuff/OSMC Sometimes (the execution depends on a number of random values) one of the ...
0 votes
0 answers
57 views

Passing a subroutine as an arugment to another subroutine [duplicate]

I am trying to pass a Fortran subroutine as an argument to another subroutine. I want to do this so I can write a general module (e.g. for root finding) where I can then define various subroutines to ...
0 votes
0 answers
48 views

Fortran Error: Syntax error in DATA statement at (1) [duplicate]

Recieving error from console, saying i have a syntax error, not quite understanding how because new to fortran data pi, ealf, eals, xray, niter, densi, msi, na 1 /3.14159, 35.0, 22.0, 1486.7, 100, ...
0 votes
0 answers
68 views

Print, write statement in Fortran module, subroutine

I am making a program 'maths.f90' that contains a few definitions:(r,n) that are sent to a fortran module 'geometry.f90' to simply calculate area of circle. Within that module there is a subroutine ...
0 votes
1 answer
128 views

Not-a-number appearing in a Fortran CFD code

I am trying to solve the Euler 1-dimensional equations of fluid flow through a double convergent-divergent nozzle. This is my code in its entirety: module constants double precision ::GAM, GAMM1 ,...
0 votes
1 answer
127 views

Why Intel Fortran + Intel MPI report warn(error) when using MPI_Bcast?

Here is a simple code of fortran with MPI: program mpi_broadcast_example use mpi implicit none integer :: ierr, rank, size, root integer :: a call MPI_Init(ierr) call ...
0 votes
1 answer
74 views

Convert c_int to default kind integer

I know that I can convert an default kind integer to an integer with kind c_int using iso_c_binding and integer(c_int) :: i = int(1, kind = c_int) (or integer(c_int) :: i = 1_c_int). Is there a way to ...
0 votes
0 answers
96 views

How can I adapt such legacy Fortran (f77 like) code to using modules?

I have a scientific simulation program in Fortran. It uses some f90 syntax/capabilities (mainly direct operations on arrays) but is otherwise architecturally f77, ie it's simply a collection of ...
0 votes
0 answers
39 views

Somewhat Variadic function in Modern Fortran [duplicate]

I want to implement a logger functionality in some large Fortran code. To do so, I want to provide the users with a simple 1-line function call, lets say log_info(<list of variables>) that ...
4 votes
1 answer
8k views

Reading strings from unformatted files (variable record length)

I have an unformatted Fortran file, containing strings of different lengths, and I'm having trouble reading these strings with Fortran itself. Sample program: program test implicit none character(...
1 vote
1 answer
89 views

Extended time measurement with CPU_TIME() in fortran with loops located after the last call?

I am trying to measure the time of a given loop with the cpu_time function. The piece of code I am currently testing is as follows. t_start and t_finish are two reals. call cpu_time(t_start) ...
2 votes
1 answer
292 views

mkl_?dnscsr deprecated, what should I use?

MKL's routine mkl_?dnscsr to convert CSR format into dense format is deprecated. Documentation says "Use the matrix manipulation routinesfrom the Intel® oneAPI Math Kernel Library Inspector-...
0 votes
1 answer
77 views

Program in Fortran print different results with each execution [closed]

This program prints different values for the variable ar each time it is run. Nothing was changed in the code between runs. IMPLICIT REAL *8 (A-H,O-Z) PI = 0 PI=4.D0*ATAN(1.D0) ...
0 votes
1 answer
58 views

why is there "WindowsSdkDir" not found warnings when I run ifort compiler from cmd prompt in visual studio

I was using visual studio 2008 with parallel studio xe2011 to do fortran code, sometimes I also use visual studio 2022 community version. I set the cmd prompt for ifort compiler in External Tools and ...
3 votes
3 answers
148 views

How does work the OpenMP "nonmonotonic:dynamic" schedule?

The two main OpenMP loop scheduling options are static and dynamic. The latter can be more efficient if the workloads are not balanced between the iterations, but less efficient in the case of ...
18 votes
9 answers
17k views

GFortran error: ld: library not found for -lSystem when trying to compile

I am getting a strange error when trying to compile a simple fortran-90 file using gfortran. I am working on a macOS mojave system. I have gfortran 8.2.0 installed and I checked to be sure of this by ...
0 votes
0 answers
32 views

I don't know what % means in fortran [duplicate]

I'm a Fortran user While I was studying by looking at other codes, the following grammar came out allocate( set(1)%return (basic)) I wonder what the % in this code means and what function it does
0 votes
1 answer
163 views

Parallellizing N-Body simulation using openmp

I'm trying to parallelize Fortran code for N-body simulation but it always takes longer execution time compared with the sequential version and the execution time increase with increasing the ...
2 votes
1 answer
12k views

uname: command not found

I try to run a makefile and I need to set the path in which the ifort compiler is located. I try the following line: export PATH=$PATH:/opt/intel/Compiler/11.0/081/bin/intel:/usr/bin in a past ...
-1 votes
3 answers
405 views

Extension for Modern-Fortran in Visual Studio Code

I am trying to use Visual Studio (VS) Code to debug and run Fortran. I have already installed the extensions for 'Modern Fortran', 'Fortran Breakpoint Support' and 'fortran'. I also added the ...
4 votes
3 answers
1k views

Write unformatted (binary data) to stdout

I want to write unformatted (binary) data to STDOUT in a Fortran 90 program. I am using AIX Unix and unfortunately it won't let me open unit 6 as "unformatted". I thought I would try and open /dev/...
0 votes
0 answers
43 views

Fortran Importerror that is linked with fortran

I am trying to install MCdisp. After successful compilation, I have ran the jupyter example file. I am getting the issue given below. ImportError Traceback (most recent ...
0 votes
1 answer
96 views

Discard the buffer of a named pipe

I'm reading from a named pipe to communicate with other processes. Under some conditions, I need to discard the buffered input in the named pipe and then continue reading new input. I came up with the ...
0 votes
1 answer
77 views

SCons mwe for a generic Fortran project

I am having a hard time to understand the logic of SCons, even after reading several sources and spending quite some time coding. I have not found any reasonably understandable Fortran project using ...
0 votes
1 answer
61 views

How to define dynamic arrays for intent out in Fortran subroutines and call them in Python using f2py?

I am new to using modern Fortran constructs. I have successfully applied dynamic allocation array as input and have a single output as result as verified and confirmed in this jupyter notebook cell: ...
1 vote
1 answer
86 views

How to call Fortran's FINDLOC within numpy's f2py

I am relatively new to using Fortran 2008 release with new features. For a specific application, the ability to use findloc from Fortran would speed up my code significantly. I am trying to execute ...
0 votes
1 answer
102 views

Breakpoints cannot be set when compiling Fortran with VSCODE

I'm new to Visual Studio Code and I'm having trouble with debugging a Fortran code, as I can't set breakpoints in my code in VS Code in Windows 11 I put the code I used for my tests below. ! main ...
0 votes
1 answer
71 views

How to properly link mkl interfaces with fortls

In my project I'm doing massive use of the blas subroutines under the mkl implementation, I have no problems in compiling the project thanks to the Intel Advisor, but I can't get fortls to recognize ...
1 vote
0 answers
115 views

Why is Compaq Visual Fortran (CVF) running under WinXP so much faster than gfortran or Intel ifort on Win10Pro 64?

Computer: intel i7-7820 OS: Windows 10 pro 64bit and WinXP pro running in Oracle VM Virtual box Fortran Compilers: Compaq Visual Fortran(CVF) Pro. 6.6.C Intel Fortran ifort version 2024.0.2.27 ...
0 votes
1 answer
59 views

Is "MODULE PROCEDURE" used properly in the included code?

We use this code in some testing for SCons, but some recent fixes and trying to compile this in gnufortran seem to indicate that MODULE PROCEDURE MOD_BAR below wouldn't be recognized by the USE ...
1 vote
1 answer
114 views

QR factorization in Fortran

I'm trying to build a program to do the QR factorization of a Matrix I tried this: program QR_Factorization implicit none integer, parameter :: n = 3 real(8), dimension(1:9) :: AA =(/...
0 votes
1 answer
70 views

Fortran compilation using Makefile - Solving a dependency issue

I tried to use the following Makefile to compile a Fortran program that I wrote (AltitudeCalculator.f90), which uses another Fortran module (COESA_module contained in COESA.f90) as dependency: The ...