1,571 questions
-2
votes
0
answers
70
views
WRF 'real.exe' fails with “ERROR while reading namelist domains” even though &domains block looks valid [closed]
I’m running WRF with nested domains (down to ~100 m) and I’m stuck at a namelist parsing error that I can’t get rid of.
Setup
WRF (ARW core) compiled on Linux (Ubuntu, gfortran + OpenMPI)
WPS + WRF ...
0
votes
1
answer
130
views
Fortran90 doesn't compile with gfortran
I am attempting to compile and run a Fortran 90 program using command line (bash). In the past, when I've run gfortran /path/to/file, a file a.out and a file program_name are created, and I can run ...
1
vote
0
answers
69
views
Is it possible to declare a "parameter" in a different file? [duplicate]
In Fortran, parameters are compile-time constants. Let's say I have two files, main.f90 and params.f90. Is it possible for params.f90 to define some parameters that will be used in main.f90?
E.g. in C/...
0
votes
0
answers
122
views
Can gfortran reject code that is not standard Fortran 90?
For educational purposes, I have written some Fortran 90 code that I compile with gfortran. Is there any way I can make sure that the code will not compile if I use any features not supported by ...
0
votes
0
answers
37
views
Error: Unexpected data declaration statement AND symbol has no IMPLICIT type [duplicate]
I'm an amateur in Fortran. I met a strange error when immitating youtube tutorial of FORTRAN in 100 Seconds to write a simple program:
1 program myApp
2 implicit none
3 integer :: jeff
4 jeff =...
0
votes
1
answer
231
views
Fortran 95, How to read blank (letter space) character from the end of the line?
I try to modify my program to read lines that contain blank charaters (written with space) at the end of the line. I'm using Intel compiler (Fortran 95).
In the program i'm using the command line:
...
0
votes
0
answers
328
views
How can I get MPI module to work with Fortran using Code:Blocks on Windows 10?
I have recieved some code from a colleague which is written in Fortan .f90 files, and was used before on Linux. I am trying to get the code to function on Windows 10 using Code::Blocks. The problem is ...
1
vote
1
answer
231
views
Why is this simple Fortran matrix inversion code not returning the expected value with LAPACK?
I'm trying to use the LAPACK package to compute the inverse of a matrix. For this end, I've employed the routines sgetrf and sgetri. However, when testing the code, it doesn't return the expected ...
0
votes
1
answer
100
views
Does Fortran store values in an array differently than a non-array declared variable?
program analysis
implicit none
integer i, j, k, l
double precision a, b, c, d, e
integer binb(1:20),binc(1:20),bind1(1:20),bine(1:20)
real lower(1:20),...
1
vote
1
answer
294
views
Error: 'mask' argument of 'count' intrinsic at (1) must be a logical array
I have recently tried compacting an older version of my program to make it more efficient by using the "count" function. However, when I try to compile the program, I get the error for each ...
1
vote
5
answers
842
views
find and modify highest n values in a 2D array in fortran
I have a 2D real number array and I want to locate the n highest values and assign these highest values to 1 and all others to 0.
The following code does this correctly by using MAXLOC inside a loop ...
1
vote
1
answer
250
views
Including/omitting write statement changes code output in Fortran
I am facing a difficult to debug problem in this Fortran 90 code - keeping or commenting out write(*,*) statements is changing the output of the code! Here are the details and the code (cannot ...
1
vote
3
answers
171
views
How do I nest an array of strings inside another array in Fortran
In my computational methods class, our homework problems are given as Python scripts, however my instructor said as long as we can translate them into our language of choice, we can solve them in our ...
1
vote
0
answers
104
views
Difference in Matrix operations with very small values on Eigen (C++) vs Fortran 90
Why am I getting slightly different results when I do the inverse of a matrix and multiply it by the original matrix? C++ (Eigen Library) vs Fortran (Using old Microsoft Developer Studio, Fortran ...
0
votes
1
answer
116
views
Fortran rounding decimals to .0 from netcdf file
I have a fortran 90 function that is meant to parse a time stamp in the form day as %Y%m%d.%f where %f is fraction of a day /48 and return an array with year, month, day, fraction of day.
function ...
-1
votes
1
answer
161
views
How to find minimum of each column in Fortran and sum op all elements of that column? [closed]
I have a 300x178 matrix and I want to find the minimum of each column of that matrix (1x178). Then I want that, on the location/pixel of the minimum value in each column, the sum is taken from all ...
0
votes
0
answers
174
views
Bisection method in fortran with compilating error
I wrote the following program that find roots of a given function using the bisection method. The program looks like to be correct. But, one error is produced during the compilation process.
MODULE ...
0
votes
0
answers
21
views
Fortran 90 to Fortran 2003 : pointer undefined reference [duplicate]
:)
Currently new to the Fortran language, I am currently on a question of migration from Fortran 90 to Fortran 2003, where a p1 pointer containing itself a p2 pointer generates the error message ...
0
votes
0
answers
502
views
'Random' "Program received signal SIGABRT: Process abort signal." Error
I have a large program (many modules, subroutines) and receive the error "Program received signal SIGABRT: Process abort signal." The odd thing about this error is that it occurs maybe e.g. ...
0
votes
1
answer
1k
views
Differential Equation in Fortran
Today I'm trying to evaluate this differential equation for internal energy in a gas in Fortran 90:
du / dt = dT / dt = - λ / ρ
Where u is the internal energy and λ is the cooling function (and they ...
1
vote
0
answers
69
views
symmetric matrix vector multiplication combined modules
Written two modules:
conjugate gradient method
band matrix-vector multiplication
they work separately (with machine error difference due to addition nonassociativity being around 1e-14 to 1e-15)
But ...
2
votes
1
answer
225
views
How to skip over a fixed set of lines in Fortran? [duplicate]
How do I read only every tenth set of lines in a large file? A simple example is shown below. I thought I could use the increment for the do loop, but it seems that only changes the index T below, but ...
1
vote
2
answers
691
views
There any way to get name of Fortran variable?
I like how it's implemented in Python. Example(Python):
x = 1
y = 2
print(f"{x = }, {y = }")
# x = 1, y = 2
Im want to handle the errors and then print the variable name. Example(Fortran):
...
0
votes
1
answer
294
views
How to remove the empty space in the output columns in Fortran? [duplicate]
I am writing some data in a text file using Fortran code.
The output data I want to have should look like the following.
ITEM: ATOMS id type xs ys zs
1 1 0.004775 0.074550 0.697303
2 1 0.017240 0....
0
votes
0
answers
190
views
Problem with Fortran 90 program for linear system resolution through Cramer's rule
I am writing this linear system solver for an university assignment, and I have incurred in quite a weird problem. I have defined a recursive function
for calculating the determinant of a square ...
4
votes
1
answer
171
views
Fortran Package Manager exclude test code
I've building a library with Fortran Package Manager and it's packing up the test code from test/ as part of the final library - everything works okay but I'd prefer to omit the test code from the ...
3
votes
1
answer
151
views
Fortran Package Manager build 32 bit code
Is there a way to make Fortran Package Manager compile code as 32 bit (i.e. pass -m32 to gfortran?) I can't see anything obvious in the documentation so I've resorted to copying the output running ...
1
vote
1
answer
552
views
Correct way to save constants while using selected_real_kind() in fortran
I am playing around with selected_real_kind() against real(kind=8) to check how much extra processor time I require to improve numerical precision. The set of parameters I use are:
module param
...
1
vote
1
answer
311
views
How to skip sorted part of an array in a sorting program if my array is already partly sorted
So we were taught bubble sort in our class and I have this code
!Sorting n real numbers
program bubblesort
implicit none
integer::i,j,n
integer,allocatable,dimension(:)::A
write(*,*)"Enter ...
3
votes
1
answer
1k
views
Newer gfortran does not compile a Fortran90 code
I have a Fortran90 code that compiles and works great with gfortran 4.8.5. However, when I try to compile it with newer gfortran versions (I've tested from 6.3 to 11.2), it does not work!!
If I don't ...
1
vote
1
answer
343
views
Rank mismatch in function result
I am learning to program in fortran and was making a basic program. In it I am trying to return an array from a function in my program, which is resulting in this error: Interface mismatch in global ...
2
votes
0
answers
39
views
Fortran: modules and array size [duplicate]
I have three pieces of code
Everything in the main.f90 file
program main
implicit none
integer, parameter :: N = 10
real :: x(N), y(N), z(N)
integer :: i
do i = 1, N
x(i) = i
...
0
votes
0
answers
630
views
Problems compiling Amber'18 molecular dynamics code in Ubuntu 20
I'm trying to compile Amber'18 molecular dynamic simulation program.
One can find some installation instructions here: https://ambermd.org/InstUbuntu.php
and in Amber's manual.
I have a problem with ...
2
votes
0
answers
27
views
Fortran Help, open statement error any idea? [duplicate]
I have some Fortran error code in (open) statement like the following:
!IF ITS THE FIRST CALL TO THIS UNIT, DO SOME BOOKKEEPING
IF (INFO(7).GE.0) GO TO 100
!FIRST CALL OF SIMULATION, CALL THE TYPECK ...
1
vote
0
answers
57
views
Nothing happens when I try to run program to calculate mean, variance, and std dev
I am trying to produce the mean, variance and standard deviation of a user input array, but I am trying to keep everything in the subroutine other than gathering the data.
Program dyn_array
implicit ...
0
votes
0
answers
513
views
In function `_start': (.text+0x20): undefined reference to `main' UsingMCX.o: In function
I am trying to compile some Fortran code using intel oneapi compiler (ifort -v 2021.2.0) and linking it with another Fortran library (MultiZ) previously coded. I am using the following makefile:
# ...
0
votes
1
answer
107
views
how to correctly record the counting of averages between the minimum and maximum of the matrix on fortran
I was trying to write a program to calculate the average without considering the minimum and average of the columns, what is the best way to do this? To begin with, I wanted to simply output the ...
1
vote
1
answer
539
views
reading a binary file in Fortran
I am trying to read a binary file consisting of signed 16 bit integers and there are exactly 51840000 of them. The code in C that accomplishes this looks like this:
#include<stdio.h>
#include<...
0
votes
0
answers
161
views
How to determine the number of time steps in Modern Fortran
I need to calculate the number steps to calculate a numerical method in such a way that for i=0 the time be t=tstart and for i=nsteps the time be t=tstop.
I know the real numbers tstart, tstop and dt, ...
0
votes
0
answers
967
views
How can I compute the necessary memory limit for my Fortran code?
I have a Fortran 90 code. I have tried to allocate a r(5000000,5000,3) array with real numbers in my code. After compiling with double precision (I am using gfortran compiler), I received this error:
...
0
votes
1
answer
616
views
"error: implicitly declaring library function 'exit' with type" when configuring NetCDF on Mac
I need to compile the following project on a mac: cost733clas-1.4_rev23.tgz (download link)
The problem is, I have never worked with fortran or C and for the most part just worked with IDE's which ...
1
vote
0
answers
53
views
Correction using error file in Fortran 90
I have two text files. File_1 has huge data in 100 columns(formatted) and file_2 has mistakes in data entry, has 20 columns and first 15 are same format as data and last 5 contains text like "...
0
votes
0
answers
36
views
Free form back to fixed form fortran [duplicate]
So I wrote some Fortran in the .f90 format and I need the file extension to be .f for compilation reason. Im under the assumption that ive written the fortran in iin the newest fortran 90 way and i ...
3
votes
0
answers
220
views
Can a procedure, contained in a module, call another procedure contained in the same module? [duplicate]
Consider a module that generates the first few primes:
module module_primes
contains
function is_prime(n)
! Function to check if a number is prime.
implicit none
integer :: n, m
...
0
votes
2
answers
84
views
What causes fotran ranks not matching error
I have no experience with fortran, but I need to define the variable error.
a = 3.086e18
error = ABS(((xCoord / a)**2 + (9 / 4)*(yCoord / a)**2 + (zCoord / a)**2 -1)**3 - (xCoord / a)**2 * (yCoord / a)...
0
votes
1
answer
889
views
Installing a package and getting error - ld: library not found for -lSystem
I'm trying to install a package through ifort on Mac since it requires ifort to compile and run the code and I am and getting error
ld: library not found for -lSystem
I don't know if oneAPI comes ...
0
votes
1
answer
310
views
Call a StdCall Subroutine in Fortran
I have two subroutines in a DLL. To call them in C#, they are changed to STDCALL like this:
SUBROUTINE MoveToZero(X, N)
!DEC$ ATTRIBUTES DLLEXPORT::MoveToZero
!DEC$ ATTRIBUTES STDCALL,...
0
votes
1
answer
73
views
Fortran90: Scripting of Standard In not working as expected
Working with Fortran90 in Unix...
I have a programme which needs to read in the input parameters from a file "input-deck.par". This filename is currently hard-coded but I want to run a ...
0
votes
0
answers
380
views
How to debug GNU make step by step?
I want to add a new fortran module into an existing fortran90 program. The existing fortran90 program is compiled by firstly running ./configure, then run the make and make install. If I want to ...
0
votes
0
answers
730
views
Current best method for wrapping python code into Fortran subroutine [duplicate]
Currently I am running an atmospheric model which was written by Fortran 90. In some subroutines I made some innovations using python (mainly tensorflow). Now I need to implement this python code into ...