Skip to main content
Filter by
Sorted by
Tagged with
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 ...
jared's user avatar
  • 8,206
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 ...
Re'em's user avatar
  • 11
0 votes
1 answer
71 views

Optimizing the addition of a symmetric banded matrix stored as a 1D array to a general 2D array

I have a matrix B, a symmetric banded matrix stored as a 1D array, that has to be added to a general matrix A. To illustrate the example let ccc=3, which would imply B is a pentadiagonal matrix, thus ...
ZoiloN's user avatar
  • 1
0 votes
1 answer
121 views

What is the best way to "combine" two Fortran subroutines with very similar functionalities but slight differences?

I have two modules with an init subroutine that look as following: module letter_A contains subroutine a_init() *do something* call my_function(1) print *, "letter A init" end module ...
Yes's user avatar
  • 393
0 votes
1 answer
254 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....
Magic_Number's user avatar
0 votes
0 answers
38 views

What does module procedure do inside interface blocks in Fortran? [duplicate]

My supervisor at university has tasked me with reverse-engineering some Fortran 95 code. I have struggled to find good documentation on it. There's a module that contains this: interface get_HS_blocks ...
Mikkel Rev's user avatar
2 votes
0 answers
25 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 ...
TSC BME's user avatar
  • 21
1 vote
0 answers
54 views

Is there a way to assign values to a multidimensional array in Fortran without using nested loops? [duplicate]

I am trying to assign 216 values from an array to a 6x6x6 matrix in Fortran. This is my code: y = 0 do x = 1,6 do z = 13,18 do x1 = 19,24 y = y+1 ...
VenuVGR's user avatar
  • 11
2 votes
2 answers
222 views

Assign fill value to variable if it does not equal to certain values

I am not pro in Fortran95, but I am writing a code in it and I found that I want to mask the array values with -9999, if it does not have certain values. Example: I have an array 'X' has values vary ...
Piyushkumar Patel's user avatar
1 vote
1 answer
205 views

Problem with writing .dat files using Fortran

I am reading a .txt file and writing to a .dat file for use in GrADS. The .txt file contains 1D data, and my program reads all 123 lines correctly as I checked by printing on screen. However, the ...
Uts_137's user avatar
  • 21
0 votes
0 answers
264 views

Compile Fortran Function using gfortran: object file was built for newer macOS version than being linked

Given a very simple fortran (95) function and a very simple c++ call to the program, I should be able to compile the program using: g++ -c main1.cpp gfortran -c test.f95 g++ main1.o test.o -o run ...
startrekisawsome's user avatar
0 votes
0 answers
44 views

Error: Unclassifiable statement at (1)? At line under do while statement [duplicate]

I was creating a program that would take numbers in a file and average them and create the standard deviation; however, when I compile the program I get an error stating Unclassifiable statement at (1)...
Nik Wrye's user avatar
1 vote
0 answers
491 views

Double precision in Fortran for trignometric functions [duplicate]

I am using the following code to calculate cos for pi/2 in Fortran. program precision_Fortran IMPLICIT NONE !!integer, parameter :: dp = kind(1.0d0) !!Gives same result as line below integer, ...
ZeroTwo's user avatar
  • 317
0 votes
0 answers
29 views

What shall be used in recl when opening a file in unformatted direct access? [duplicate]

I am trying to fully understand how to deal with binary files in Fortran. Specifically, I am reading this https://atmos.washington.edu/~salathe/osx_unix/endian.html which covers how to write binary ...
M.E.'s user avatar
  • 5,281
0 votes
0 answers
84 views

Why I get Corrupted module compiling message while trying to put derived types in a module?

I am learning how to distribute the code across modules in Fortran 95. I have the following code which intends to use two derived types: file_parser_2.f95 program file_parser_2 use ...
M.E.'s user avatar
  • 5,281
0 votes
0 answers
112 views

How to detect end of data in standard input in Fortran 95?

I am trying to read a CSV dataset in Fortran 95. I have originally asked this question which has been marked as duplicate, two posts have been suggested. However, when I incorporate the posts check ...
M.E.'s user avatar
  • 5,281
1 vote
1 answer
257 views

Find an alternative for norm2() and move_alloc() in Fortran 95

I write code based on modern Fortran. For some reason, I want to modify it in a way that is compatible with the old version. Converting from the latest version to version 95 is desirable here. I have ...
MOSTAJKIR's user avatar
1 vote
2 answers
90 views

Fortran Basic Conditional and Loop Code Errors

I'm doing a very basic Fortran tutorial to learn it for grad school and I input the codes for conditionals and loops exactly as they were written in the tutorial but I keep getting the "...
rose_t's user avatar
  • 93
0 votes
1 answer
127 views

Intensity using bessel function tending to infinity

Making it short, my code is supposed to return a txt with my intensity values, instead, for all rs but 0, my intensity returns a value of +infinity. Don't know where my mistake is. This exercise is ...
Gabriel Mendes's user avatar
0 votes
0 answers
34 views

Call several Fortran95 functions in sequence [duplicate]

I have many functions defined as below: function f1(x) result (y) ... end function function f2(x) result (y) ... end function ... function fn(x) result (y) ... end function I'm looking ...
Pedro's user avatar
  • 1,121
0 votes
0 answers
19 views

I have an error in my while condition, what to do?

I'm getting a lot of trouble in this program This Fibonacci sequence should stop when the difference between the division of two consecutive numbers and the aurea ratio is smaller than 10e-6. ...
Gabriel Mendes's user avatar
0 votes
0 answers
250 views

Fortran: Implement a subroutine that accepts another subroutine as an argument in Fortran 90/95

I would like to write a Fortran subroutine that accepts the name of another subroutine as an argument --- imagine that the first subroutine is a PDE solver while the second provides the right-hand ...
Nuno's user avatar
  • 266
0 votes
1 answer
301 views

Declaring types of old F77 functions and subroutines for Fortran 2003 code

We have a new Fortran 2003 code which calls and is linked to a Fortran 77 library (in an external package). Is there any way to write declarations for the F77 functions and subroutines in the external ...
xioxox's user avatar
  • 2,618
1 vote
1 answer
829 views

How to read a special line in .txt file using Fortran?

I have a .txt file, which has next special lines: .... .... !INPUT_PARAMETERS 1 2 5 10 ... ... I want to read numbers after comment line !INPUT_PARAMETERS. So, if i have: integer:: A,B,C,D I want to ...
nuclear_engineer's user avatar
0 votes
0 answers
108 views

Pointer assignment to variable where only dummy is target [duplicate]

To avoid an XY-problem I will first summarize my overall goal. We have a large legacy codebase of fortran77 code, that implemented their own memory allocation. It consists of a 1D Work Array that is ...
mcocdawc's user avatar
  • 1,854
1 vote
1 answer
192 views

PHP Interoperability - Print statements not showing in command line

I am having issues with PHP not returning print statements from Fortran. The idea is that PHP executes a command to compile a Fortran file then runs it. You are asked to input a number via print ...
HRD1997BFBE's user avatar
0 votes
1 answer
101 views

Re-executing statements in Fortran 95

Sorry for the noobie question but I need some help in figuring out how to return execution back to the start of a subroutine after a logical block is done checking user input. Program FibSequence ...
HRD1997BFBE's user avatar
0 votes
1 answer
621 views

"Bus Error" and "munmap_chunk(): Invalid Pointer" in Fortran 95

I'm working on a python project which calls a fortran subroutine via f2py for efficiency reasons. When I execute the code, it fails at seemingly random (non-consistent) points with Segmentation Fault ...
Seabody's user avatar
  • 1,217
1 vote
0 answers
25 views

Unexplicable ambiguous interface [duplicate]

If I overload the constructor of a given type as in the following example, I get an ambigous interface. Since I have clearly different types in the interface, I don't get, why it should be ambiguous. ...
mcocdawc's user avatar
  • 1,854
0 votes
0 answers
71 views

I want to make a matrix(6,6) but it shows me other values (serves for newtonian interpolation)

First, I calculated the lower triangle and the main diagonal values with the formula: f(i,j)=(f(i,j-1))-(f(i-1,j-1))/(x(i)- x(i-j), I made the matrix(6,6) so i can have the main diagonal from it, ...
Raziel Leal's user avatar
0 votes
0 answers
351 views

Smart way to have a Fortran do loop over seperate ranges of the same variable [duplicate]

Imagine I have a do loop over a variable, I. Typically this variable has a range of 1-20 but I want to create a do loop over the range 1-5 and 8-12. I can't create a simple do loop because the ranges ...
Nicholas Bauman's user avatar
0 votes
1 answer
285 views

Subroutine Segmentation Fault

PROGRAM olaf IMPLICIT NONE INTEGER :: i, j, nc, nd,ok,iter REAL :: alph, bet, chi, ninf1, C1, ninf2, C2 REAL, DIMENSION(:), ...
user avatar
1 vote
0 answers
37 views

Static array elements in modern Fortran [duplicate]

For convenience I would like to be able to reference elements of a static look up table implemented as a 1d array like this Item = [1,7,2,5,3](I) Where I is an integer index to the static array in ...
user1383092's user avatar
0 votes
0 answers
111 views

How to avoid do loop for switching matrix index in Fortran?

I would like to know if it is possible to reproduce the following MWE without the do loops. Of course, in this simplistic example I can do it manually to avoid the do loop since the matrices MatA, ...
R. N's user avatar
  • 749
-2 votes
1 answer
98 views

How to obtain the smallest figure out of five figures using OO Fortran

In what way can I get the smallest figure in a given five digit figure. E.g 23764. How do I get 2 being the smallest. Taking the figure as a digit such as 456879, in order to obtain the smallest from ...
Lewa Bammy Stephen's user avatar
0 votes
2 answers
1k views

Maximum value of 64 bit floating point number for overflow detection

I have a seemingly simple problem: I want to detect whether a floating point addition in Fortran will overflow by doing something like the following: real*8 :: a, b, c a = ! some value b = ! some ...
Peter's user avatar
  • 3,059
0 votes
0 answers
378 views

gfortran: Symbol 'grid' has no IMPLICIT type [duplicate]

I'm making a tic tac toe program with a 2D array of characters in a 3x3 shape to hold all the spots on the grid. I've disabled implicit typing with implicit none, but I get errors about my array not ...
Frank Gomes's user avatar
3 votes
1 answer
1k views

How to read the real and complex numbers in a unified way in Fortran?

Suppose I have a data file (fort.100) including the data like, 2.34, 4.5 (23.1,0.3), 4.5 (3.1,0.3), (3.2,1.0) 2.4, (32.2,12.0) how to read these mixed real and complex ...
Orders's user avatar
  • 169
0 votes
0 answers
191 views

Is it possible to parallelize with fortran 95 using mpif90 and mpirun?

I would like to know if it is possible to parallelize a program in fortran 95 using the mpif90 instruction to compile and mpirun to run because I would like to use the FORALL instruction. On the other ...
Math's user avatar
  • 1
0 votes
1 answer
312 views

Fortran code produces runtime error 'operation not supported' when attempting to open a text file

I am trying to run a piece of fortran code written in f95. I have compiled it using gfortran in Ubuntu. In the code there is a command to read in a text file. When I run it, it gives me the following ...
agorapotatoes's user avatar
0 votes
2 answers
588 views

How to get rid of a specific gfortran warning?

I have a warning message which is appearing very frequently in my build log. The warning message is: Named COMMON block ‘<BLOCK_NAME>’ at (1) shall be of the same size as elsewhere ( <SIZE_1&...
Mansoor's user avatar
  • 2,428
1 vote
2 answers
1k views

fortran find series of integers in array

Is there a function or method in Fortran to find as series of integers in an array and return a location in the array or count if matches? (1, 5, 8, 56, 33, 56, 78, 123, 78, 8, 34, 33, 19, 25, 36) ...
mchael's user avatar
  • 13
2 votes
1 answer
158 views

MergeSort vs. antialising rule

I have the following implementation of the MergeSort algorithm in Fortran. My question is about call merge(work(1 : half), A(half + 1:), A). Obviously I have overlapping memory, but from looking at ...
mcocdawc's user avatar
  • 1,854
-2 votes
1 answer
105 views

Extract values from .dat file with fortran, with lines and especific variables

I need take te values of NPNOD, NELEM, and the others. and take the values of the next matrix $DIMENSIONES DEL PROBLEMA DIMENSIONES : NPNOD= 27 , NELEM= 8 , NMATS= 1 , \ ...
Estéfano Muñoz's user avatar
0 votes
1 answer
747 views

Read text file where the columns have specific format

I am working with Fortran and I need to read a file that have 3 columns. The problem is that the 3rd column is a combination of integers, e.g. 120120101, and I need to separate each single value in a ...
Fernando Brito Lopes's user avatar
2 votes
2 answers
185 views

How to do SUM on array from outside file?

I'm newbie college student for programming studies, so recently i have task to calculate matrix from outside files for Gauss Jordan Numeric Method, in the txt file i provide has 10 (x) and (y) data, ...
Arya's user avatar
  • 23
1 vote
0 answers
223 views

Getting a segmentation fault when opening a file that already exists

I was trying to open a file that already exists: program writeeven implicit none logical :: alive inquire(file='even.txt', exist=alive) if (alive) then print *, 'file is ...
Guo Ray's user avatar
  • 11
1 vote
0 answers
342 views

Error in write function. Output file is empty despite successful compilation

I am trying the write function in Fortran. The code is getting compiled and runs without any error but the output file is empty. I'm using the Silverfrost Plato IDE. The file format is .f95. program ...
MShetty's user avatar
  • 11
1 vote
2 answers
187 views

How to read a specific column out of matrix-textfile? without reading whole line?

I have a textfile including thousends of lines and each line have 899 values/columns separated by ';' (but i can change the seperation if needed) Is there a way to read a defined column (i want to ...
Tom Lucas's user avatar
-2 votes
1 answer
274 views

How to fix solution with double integration

The solution for this double integration is -0.083 but in the final compliation it appears -Infinity. It seems that the error is very simple, but I really can't find it. I have been searching ...
Miguel Prats Ulloa's user avatar

1
2 3 4 5
8