Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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. This tag should be applied to all questions about the Fortran language; other ...

0
votes
0answers
15 views

how to do sorting of distance in 2d array fusing fortran code?

I want to sort the distance. for example r(1,3)< r(1,2) then r(1,3) should come first . input file of dist.txt like this 1,2,3.5 1,3,0.5 1,4,4.7 1,5,4,5 output file of sort.txtshould be like ...
0
votes
1answer
26 views

Return an array of strings of different length in Fortran

I would like to create a type to contain an array of strings in Fortran without explicitly assigning lengths so I can return it from a function. The following is my type: type returnArr ...
0
votes
1answer
71 views

how to debug the error of “Program received signal SIGSEGV: Segmentation fault”

I am running a Fortran exe, and I get the error: set_nml_output Echo NML values to log file only Trying to open namelist log dart_log.nml PE 0: initialize_mpi_utilities: Running with 8 ...
-1
votes
0answers
64 views

cmplx seems returning rank 1 and scalar [on hold]

I have the following issue, i use cmplx(work(2) ,0.d0, 8) where work(2) is supposed to be a REAL*8. I send it to my subroutine where this conversion is supposed to be a COMPLEX(8). I get the ...
1
vote
1answer
57 views

Why do I get Fortran 'End of record' error on PC with Fedora, but not on Macbook?

I have a program which works well when using Macbook, but as soon as I try it on PC with Fedora 28, I get this error: At line 107 of file transport.f08 Fortran runtime error: End of record Error ...
0
votes
0answers
46 views

compiler error from linking library (involving HDF5 library)

I am compiling a Fortran code using CMake on my macbook. The compiler used is Gfortran. My fortran code uses the HDF5 library, which is compiled on my macbook using GNU. When compiling my code, I ...
0
votes
1answer
73 views

Segmentation fault when calling METIS from FORTRAN

I am developing a Fortran 90 program and am linking it with METIS libraries. I am using GNU Fortran 4.8.5 and METIS 5.1.0. I compile my Fortran program with: -fdefault-real-8 -fdefault-integer-8 ...
3
votes
3answers
118 views

How to convert 2D array to 1D array in Fortran code?

How do I convert r(i,j) to a 1D array so that I can sort the number easily? program sort implicit none character CN*8,O*7 integer j,iconf,nconf integer i,nbins,t integer n,nmax,ind,num,b ...
0
votes
1answer
64 views

Gfortran compile Error: Logicals at (1) must be compared with .eqv. instead of ==

I am compiling a fortran code using Gfortran. I never had these compile errors using Intel fortran compilers. The Gfortran compiler is complaining about the use of "==" for if statement comparisons. ...
1
vote
0answers
45 views

Understanding loess delta1 and delta2 combination

I am trying to track down how to get to delta1 and delta2 in the R simpleLoess function that is called by the loess function. In the simpleLoess function there is a call z <- .C(C_loess_raw, y, ...
1
vote
1answer
34 views

Trying to understand why make is failing

I can't use this Makefile to compile "balance_test" ... FLAGS=-g OBJS=balance.o balance_drv.o SRCS=$(OBJS:.o=.F90) balance_test: $(OBJS) gfortran $(FLAGS) -o $@ $(OBJS) balance.mod : ...
1
vote
1answer
27 views

Visual Studio Fortran Stuck at Reassigning values from one variable to another

See attached screenshot. I ran the code, stopped it at a break point, and F11 the steps until the line ccs2 = ccs2_2. I checked both of these variables have the same dimensions, same number of ...
1
vote
1answer
55 views

How to set Fortran Integer kind

program PEU3 integer(kind=7) :: num = 600851475143 integer(kind=7) :: pf, counter This is a section of my fortran code. Num is very large, so I tried to set it to kind = 7, but for some reason It's ...
3
votes
2answers
77 views

Correctly setting random seeds for repeatability

The method for setting random seeds using the Fortran 90 subroutine random_seed is quite straightforward. call random_seed( put=seed ) But I can't find any information about guidelines for setting ...
-2
votes
0answers
37 views

Visual Studio 2017 Error: The operation could not be completed [closed]

A Build=>Batch Build...=>Select All=>Build yields the following error in the output window: Error: The operation could not be completed I'm using Microsoft Visual Studio Community 2017 (version 15.7....
0
votes
0answers
38 views

Can't Open DFLIB.mod

I have received a Fortran code (.f90), which uses DFLIB: use DFlib I am trying to compile the code on Ubuntu 18.04 using gfortran compiler. But, the compilation gets terminated by: Can't open ...
0
votes
0answers
26 views

gprof Fortran Blank Output

In a Makefile, I am compiling and linking some Fortran code on Linux to include gprof for profiling, like so... gfortran -c -Wuninitialized -fno-automatic -fno-range-check -ffixed-line-length-none -...
0
votes
1answer
27 views

Debug fortran code by visualising execution [Ubuntu18.04]

I want to see the step by step execution of a fortran code. I have the option of gdb but i want something more visual inside an editor, something like visual studio code, but faster so that I can ...
0
votes
1answer
25 views

Could not run debugger for fortran. Visual Studio Code

I am trying to debug a fortran file on Visual Studio code(ubuntu 18.04). I have the following installed extensions My launch.json file is the following "version": "0.0.1", "configurations": [ {...
2
votes
1answer
106 views

Random number generator (RNG/PRNG) that returns updated value of seed

I'm trying to write an RNG that also returns the value of the updated seed. The perhaps obvious reason for this is so that new random variables can be added to the program later, without changing the ...
2
votes
1answer
48 views

Do I have to use -fPIC to create a shared object library?

I am using the default gfortran on Ubuntu 18.04. I used the following commands to create a shared object library. gfortran -Wall -g -c myMultiply.f90 gfortran -Wall -g -c mySum.f90 gfortran -shared ...
-1
votes
0answers
34 views

Fortran - Random Number Array generator [duplicate]

I am trying to get a 3D matrix whose elements are 4D-vectors themselves choosen with some characteristics: 1) Their norm is 1 and 2) They are choosen randomly I made this code in Fortran: MODULE ...
0
votes
0answers
60 views

READ format in FORTRAN

I am trying to read a vector components from an external file: imposed.dat (just one line, numbers separated by commas): 0.0585560952144390,0.121244222730239,0.148358440672875,0.169973557163769,0....
-1
votes
0answers
43 views

Slatec bug reporting

Who is in charge of the slatec library? I found a bug and would like to report it. The bug is that in the routine SSMMI2, the variable U should be assumed size, not explicitly sized: REAL B(N), ...
0
votes
1answer
61 views

Error: Unclassifiable statement (decode) on Fortran code

I have a Windows DLL came from a FORTRAN code. The DLL is working but I need to change it and port to Linux. Now I'm trying to wrap it into a Java code using this and trying to compile with gfortran ...
-3
votes
1answer
50 views

Installing gfortran via macports on Mac OS high sierra

My supervisor has asked that I install a fortran compiler on my mac and suggested using macports to install gcc6. I have tried to install gcc6 a number of times but each time it doesn't seem to come ...
0
votes
0answers
37 views

If file exists then continue [duplicate]

I want to check whether a file exists so that I can load it in to my program. In general my files are named as 010, 020, 030 and so on, but depending on a specific case, sometimes some of them are ...
-3
votes
0answers
45 views

is stack facilities is available is FORTRAN 77 because FORTRAN 77 doesn't support recursion?

FORTRAN implementations do not permit recursion because a. they use static allocation for variables b. they use dynamic allocation for variables c. stacks are not available on all machines d. it ...
0
votes
1answer
36 views

Handing optional parameters to subroutines [duplicate]

I have two subroutine. One calls the other and the both have the same optional parameter: program main call a() call a(7) contains subroutine a(var) implicit none integer,...
0
votes
0answers
57 views

Pointers and linkedlist in Fortran

I have the following fortran code: program linkedlist implicit none integer i type list integer :: ind type(list), pointer :: next => null() end type type listptr type(list), pointer ::...
-1
votes
2answers
55 views

gfortran: all terminall output goes to fort.6 instead of terminal

I have a program which contains some output to terminal like this: write(*,*) 'Progress...' When I run it from command line or by double click (I use windows) all terminal output goes to fort.6 file....
2
votes
2answers
67 views

Extract the minor matrix from a 3x3 based on input i,j

For a given 3x3 matrix, for example: A = [3 1 -4 ; 2 5 6 ; 1 4 8] If I need the minor matrix for entry (1,2) Minor = [2 6 ; 1 8] I already wrote a program to read in the matrix from a text file, and ...
0
votes
1answer
44 views

gfortran: error: -fuse-linker-plugin is not supported in the compilation

FLEXPART is a Fortran-based model for the simulation of the emission, transportation, and dispersion of atmospheric species. In the compilation of the source code, I met a strange error. My ...
0
votes
1answer
75 views

Trouble with gfortran : the end-of-file record seems badly recorded with unformatted stream files

I try to generate a Unix text file on my Windows computer. Here is an example of input file "foo" (with Windows end-of-line characters). This file contains 10 lines : line 1 line 2 line 3 line 4 ...
1
vote
2answers
72 views

How can I reduce floating-point error in a cubic equation solver?

I'm using the following algorithm to solve a cubic polynomial equation (x^3 + ax^2 + bx + c = 0): function find_roots(a, b, c, lower_bound, upper_bound) implicit none real*8, intent(in) :: a, ...
1
vote
0answers
27 views

Call a python function from a fortran file converted by f2py

I am converting a large bit of FORTRAN code into python and using certain functions as FORTRAN functions itself and using them as .so files by using f2py3. In one of these modules I am calling a ...
0
votes
1answer
72 views

Calling a fortran dll from python using cffi

I am currently working on a simultion-tool that requires a PDE Solver from a Fortran dll. In order to figure how calling a dll from python I used a simpler function from the same dll but can't get it ...
0
votes
0answers
37 views

How to overwrite file fortran?

I have a problem when running Fortran program on windows (the problem is gone in linux) that i can't overwrite existing file, he give me an error after running the code Program received signal ...
-1
votes
0answers
37 views

Error using HDF5 Fortran examples

I'm using Visual Studio 2015, Intel Visual Fortran 2017 compiler, the HDF5 Windows 10 (64-bit) vs2015 prebuilt-binary. EDIT: version of HDF5 library is 1.10.2 I am attempting to run the create a ...
0
votes
1answer
43 views

Opening and reading a file in Fortran

open(NEWUNIT=fId, file=trim(filename), iostat=ierr, action='READ') if (ierr /= 0) return read(fID,'(A)') dataArray ...
0
votes
0answers
60 views

Fortran how to write non-zero elements

I am trying to debug a huge program not written by me by writing out a large selection of the variables into text files. Some are arrays and some are single values. The arrays were declared with huge ...
1
vote
3answers
69 views

Error: Operands of logical operator '.eq.' at (1) are INTEGER(4)/HOLLERITH

I am new in Fortran. So I need help. I'm using gfortran on SUSE to compile my code and receive the following error: 200 IF ( ID .EQ. 4HEOT ) GO TO 20 1 Error: Operands of logical ...
0
votes
1answer
30 views

Error: 'b' argument of 'sign' intrinsic at (1) must be the same type and kind as 'a'

I am new in Fortran. So I need help. I'm using gfortran on SUSE to compile my code and receive the following error: DELTAL = SIGN (.1,(GFIX-GAMFLT)) 1 Error: 'b' argument of 'sign' intrinsic at (1) ...
0
votes
1answer
36 views

How to change the default gcc complier for python

I have installed gcc 4.9.2 in my computer (mac osx 10.10, 64 bit), while gcc version 4.2 is shown in Python environment. I don't know why this happened. I encountered some issues when calling numpy....
0
votes
0answers
28 views

Differentiate entries in Block Data with a flag in Fortran77

I am initializing a header struct in Fortran 77 in a BLOCK DATA . Whereas I have two versions of this *.f - file. One got an update with new functionality but the old version should be still supported....
1
vote
2answers
44 views

Operands of logical operator '.or.' at (!) are Logical(4)/CHARACTER(1)

I have the following code: print*,"type s for a square and type t for a triangle" read*,fig if(fig =='t' .or. 'T') then print*,"Enter the sides of the triangle" read*,a,b,c area=tri(a,b,c) print*,"...
0
votes
0answers
25 views

Is there any way to load a TRNSYS model to simulink?

I have made the model of a building in trnsys and I want to load this model to Simulink in order to implement there the control of the heating system. Is there any way to extract the model from trnsys ...
0
votes
0answers
58 views

Corrupted Fortran95 read with Multiple Data Type Input

After extended bug-hunting I've narrowed down that the issue appears to be coming from the input file, but my Professor and I have already tackled that avenue extensively, so the trouble might be my ...
0
votes
1answer
38 views

Fortran intermittent type error

I was able to temporarily get some legacy Fortran code running (I was able to step through it with the debugger) in Visual Studio 2017 with the Intel Fortran compiler, until it stopped working ...
1
vote
0answers
51 views

Error “Undefined symbols for architecture i386” when using f2py in Python 3

Following the numpy github issue, I have fixed the bug of TypeError: a bytes-like object is required, not 'str' for f2py. However, when I continued to call the f2py function, an error appears. ## ...