/r/fortran

Photograph via snooOG

The choice for high performance (scientific) computing!

Suggested Links:

Other sub-reddits:

If your submission does not appear, please message the moderators!

IRC: freenode, #fortran

/r/fortran

7,474 Subscribers

11

The 'F' Word : Spectrally accurate DG Solver for the compressible Euler Equations in 2-D

Thursday November 14 @ 3pm ET

https://www.youtube.com/watch?v=OjOQhMF36-M

In this livestream, Joe will discuss the implementation of our linear and non-linear Euler equations solvers in 2-D. We'll touch on the concepts of conservative, primitive, and entropy variables and their use in diffusive terms for stabilizing the solver. Although our conservative form solver is not provably stable (yet), we'll demonstrate some simple use cases the illustrate a proof-of-concept for this method. Joe will also discuss the implementation in SELF for both CPU and GPU backends, describing in detail what it takes to make the solver fully resident on the GPU and why this is important for performance. We'll share some visualizations of some newly implemented examples included with SELF and motivate what we have planned for verfication of our implementation.

The only resources for this video are :
The SELF source code: https://github.com/fluidnumerics/self

As usual,

  • To participate in the chat during the stream, you need to subscribe to the Fluid Numerics YouTube channel
  • If you can’t make it to the stream, the video will be posted to YouTube immediately after so that you can watch at a time the best fits your schedule.

How you can help keep these videos going

1 Comment
2024/11/13
22:06 UTC

7

I am getting a strange error when compiling my abcpar.f in gfortran

Compiling .\CHM\VALIEQ\abcpar.f
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dii.inc:30:10:
Error: 'abcpar' of module 'aaa_modules', imported at (1), is also the name of the current program unit
Error: Last command making (build\abcpar.o) returned a bad status
Error: Make execution terminated
* Failed *

C     aaa_modules.f
C  list of 5,000+ interfaces in a module for CHM / DII code compiling
MODULE aaa_modules
implicit none
INTERFACE
SUBROUTINE ABCPAR(ISW,IRETST,IR,IC,PAR,IPHASE)
INTEGER(KIND=8) :: ISW
INTEGER(KIND=8) :: IRETST
INTEGER(KIND=8) :: IR
INTEGER(KIND=8) :: IC
REAL(KIND=8) :: PAR
INTEGER(KIND=8) :: IPHASE
END SUBROUTINE ABCPAR
END INTERFACE
...
END MODULE aaa_modules

SUBROUTINE ABCPAR (ISW, IRETST, IR, IC, PAR, IPHASE)
INCLUDE 'dii.inc'
...
return
end

dii.inc
use aaa_modules
C        force all variables to be declared
implicit none

Apparently, the current subroutine being compiled cannot have an interface in the module being USEd.

The Metcalf Fortran 95 book says that I can exempt the current subroutine from the USE by:

USE module_name, exempt_this_one => name

where name is the name of current subroutine or function without the file suffix and without the path.

Is there any idea how to generalize the "name" without adding a specific use statement for each one of my 5,000+ subroutines ?

Thanks,
Lynn McGuire

6 Comments
2024/11/12
04:46 UTC

95

How did Fortran become a top 10 language again?

I just checked out the latest Tiobe Index to see the most popular programming languages, and I was surprised to see Fortran at number 9. It's popularity has skyrocketed since the end of 2022 after years of stagnation. What's changed?

Are all the AI companies using CUDA Fortran? Is there a big surge in demand for physics and engineering simulations? Did Taylor Swift declare her love of the language?

29 Comments
2024/11/08
20:20 UTC

4

HELP WITH A LAPACK FUNCTION

Guys I need someone to explain me HOW the "dgetrf2" function manage to LU factorize a matrix. Pls help.

11 Comments
2024/11/08
13:33 UTC

11

I don't know how to compile a fortran program in windows.

Hello guys. First let me explain the situation.

My teacher gave us a fortran program to study Boundary Layer theory. I have windows so I tried to execute the program using VS code but it always show me a messege that it says "The IF condition was removed since 2018" or something like that then I tried Eclipse, even the wsl from windows. I would like to know where and how can i open de program.

thanks so much for pay attention

12 Comments
2024/11/07
06:32 UTC

5

Installer for Intel Fortran Compiler Classic

Does anyone here have a copy of the offline installer for Intel OneAPI Fortran version before 2025. I just got an install for Thermal Desktop from my school and it requires Intel Fortran Compiler Classic in the oneAPI HPC Toolkit which was removed last week from Intels website.

7 Comments
2024/11/07
03:53 UTC

20

The ‘F’ Word : Six ways to implement spectrally accurate vector divergence on CPUs and GPUs

The ‘F’ Word : Six ways to implement spectrally accurate vector divergence on CPUs and GPUs
November 7, 2024

Abstract

In this livestream, Joe will share some of our latest work on finding and optimal implementation for vector divergence in 2-D and 3-D. Specifically, we'll demonstrate how a hand-written HIP kernel that takes advantage of shared memory and the particular memory layout of SELF data structures to achieve near peak performance for these memory-bound kernels. For this video, we'll consider specifically AMD's MI210 and MI300A GPU architectures. To do this, we create a mini-app that depends on SELF where we can experiment with new implementations of the divergence kernel. We'll discuss how to estimate "effective FLOPS" and "effective bandwidth" and will dive into comparisons of these metrics with FLOP and bandwidth metrics diagnosed from AMD's Omniperf profiler.

The only resources for this video are :
The SELF source code: GitHub - FluidNumerics/SELF: Spectral Element Library in Fortran
The SELF-mini-apps source code: GitHub - FluidNumerics/self-mini-apps
Omniperf documentation: Basic usage — Omniperf 2.0.1 documentation

---

As usual,

  • To participate in the chat during the stream, you need to subscribe to the Fluid Numerics YouTube channel
  • If you can’t make it to the stream, the video will be posted to YouTube immediately after so that you can watch at a time the best fits your schedule.
  • We love chatting with you live and can't wait for the discussions with you all.

We are looking for collaborators and innovators to help support and define the future direction for SELF. See details at Spectral Element Library in Fortran - Open Collective

2 Comments
2024/11/06
15:48 UTC

22

Created a Bunch of Basic Projects in Fortran :)

Decided to learn Fortran yesterday during the weekend cus F it, why not, yknow? Basically, I did a bunch of things, like basic data structures, scanning, printing, learnt about data types. I also practiced dynamic memory allocation, control structures, and modular programming with functions and subroutines. This project helped me understand how to manage arrays, handle user input and output, and structure a program effectively. And boy has it been a joy so far.

Hello World Program: https://github.com/lokashrinav/basic-fortran-projects/blob/main/helloWorld.f95

Calculator With Two Numbers: https://github.com/lokashrinav/basic-fortran-projects/blob/main/calc.f95

Temperature Conversion: https://github.com/lokashrinav/basic-fortran-projects/blob/main/tempConv.f95

toDoList: https://github.com/lokashrinav/basic-fortran-projects/blob/main/toDoList.f95

Let me know if you have any feedback. Just a reminder that I didn't implement error handling on a lot of these projects, but plan to do it tmrw.

I probs won't learn Fortran for too long. Maybe for at most another week or so, maybe later in the future as well idrk, cus I don't have that much time, but I hope to do fun math stuff with it with the time I have with it. Here's some cool projects I plan to implement in the next week or so. I don't know how hard the ones labeled > 10 are, so I might not fully implement them, but yeah. Imma have some fun:

  1. Prime Number Checker
  2. Factorial Calculation - Using Recursion
  3. Process series of temperature values
  4. Reading and Writing Text Files
  5. Sorting Algorithm (Bubble Sort)
  6. Matrix Multiplication
  7. Solving a System of Linear Equations - Gaussion Elimination
  8. Root-Finding Algorithm
  9. Simple Plotting of Functions (ASCII Plot)
  10. Fourier Series Calculation - Need to Learn This First
  11. Data Analysis on Weather Data
  12. Projectile Motion Simulation
  13. Heat Distribution in a Rod (1D Heat Equation)

Any Suggestions? And Thanks!

7 Comments
2024/11/02
10:15 UTC

8

if anyone have this book please send it to me . it is available in the google books but i want the offline version

4 Comments
2024/10/26
06:28 UTC

7

Skiping value recording

Hey gang, I currently have the below code set up. The aim is that if the variables HFL, CFL, CCFL cumulatively exceed 100, a data point is not recorded for the dependent variable MEPROD

IF (ABS(HFL+CFL+CCFL -100) .GT. 0.001) END=TRUE

This is in Aspen plus. But it still records it anyway. Do you know how might fix this? I am very new to Fortran. Thanks!

8 Comments
2024/10/24
14:38 UTC

6

Second opinion needed – Is there any way to make this snippet faster?

Hi!

I have written a little snippet of a code that goes through a matrix (real*8 :: C(count,count)) and when it hits a certain point (character(len=10) :: lab(count)), it multiplies this part of the matrix with another (P_mat or D_mat). There is a problem that the C matrix needs to be allocated as its size is not known before runtime and neither is the lab. The locations of the points defined by lab is also not known before runtime.

I am unsure even if loading the statically allocated P_mat, D_mat from dynamically allocated save%R_p and save%R_d helps (it would seem so, but only marginally).

Why am I asking? This snippet of a code will run likely a few billon times in one calculation. Moreover, I am a bit of a self taught Fortran coder and I have only little confidence in my coding perfection – as I learn something new every day.

Thank you for any help!

  implicit none
  use mod, only: lab, count, C_X, C, save, is_implemented

  integer                         :: i
  character(1)                    :: label
  real*8                          :: P_mat(3,3),D_mat(5,5)
  real*8                          :: time_start=0, time_end=0

  call CPU_TIME(time_start)
  C(1:count,1:count)=C_X(1:count,1:count,1)
  P_mat=save%R_p
  D_mat=save%R_d
  i=1
  DO WHILE (i.LE.count)

    lab(i)=ADJUSTL(lab(i))
    label=lab(i)(1:1)
    lab(i)=ADJUSTR(lab(i))

    SELECT CASE (label)
      CASE ('a')
        CONTINUE
      CASE ('b')
        C(i:i+2,1:count)=MATMUL(P_mat,C(i:i+2,1:count))
        i=i+2 
      CASE ('c')
        C(i:i+4,1:count)=MATMUL(D_mat,C(i:i+4,1:count))
        i=i+4
      CASE DEFAULT
        IF(is_implemented) PRINT '(x,3a)','Warning: Mixing for ',label, ' not yet implemented.'
        is_implemented=.FALSE.
    END SELECT
    i=i+1
  ENDDO
  call CPU_TIME(time_end)

 
15 Comments
2024/10/24
09:46 UTC

1

Animation 3D in Fortran compiler 2.00 (with plotter and ibm 1500) is possible?

2 Comments
2024/10/23
12:50 UTC

19

The ‘F’ Word : Using object oriented Fortran and CMake to support GPU acceleration as an optional feature

New stream this week!

October 24, 2024
The ‘F’ Word : Using object oriented Fortran and CMake to support GPU acceleration as an optional feature

Abstract
In this livestream, Joe will review some of the self-imposed design criteria for the Spectral Element Library in Fortran. Specifically, we’ll focus on the desire to provide default CPU-only builds of SELF with the option to build for AMD or Nvidia GPUs. We’ll then discuss the functional design criteria to create an easy to use library to solve conservation laws and layout the basic components of such a library. From here, we’ll take a dive into the SELF source code to show how we meet these design criteria by using Fortran classes and inheritance alongisde conditional build features with CMake.

The only resource for this video is the SELF source code: GitHub - FluidNumerics/SELF: Spectral Element Library in Fortran

As usual,

  • To participate in the chat during the stream, you need to subscribe to the Fluid Numerics YouTube channel
  • If you can’t make it to the stream, the video will be posted to YouTube immediately after so that you can watch at a time the best fits your schedule.

How you can help keep these videos going

0 Comments
2024/10/22
00:49 UTC

0

Columns counter

Guys can you help me writing a code that read a file of integers with more than one row end return the number of columns that compose the file?

13 Comments
2024/10/21
14:05 UTC

6

Running Fortran issues

Hi all, I'm new to Fortran but am planning to use it for a simulation my thesis. My supervisor has asked me to recycle his code from the 80's but I am having trouble running the code. I am currently using Visual Studio Code to run Fortran (not sure if this is my first mistake) and when I compile the code and create an executable it is just printing symbols and nonsense really (see attached). Any help would be hugely appreciated !

snip from executable file

6 Comments
2024/10/19
10:16 UTC

2

Attempting to compile a fortran file for use as a utility program

Hello all,

I don't know any Fortran however I am attempting to compile a file which has many referenced modules and submodules, the last of which seems to be written in C++ which is the (current) final error I'm getting.

I'm attempting to compile a file from https://sourceforge.net/p/wsjt/wsjtx/ci/master/tree/ for use on a raspberry pi. WSJT-X itself can run on the pi, however it takes up a good amount of memory and I want the processed data to be used and sent via another program I'll be writing. I will also be attempting to do this with two other files however I hope that if I can get one working I can figure out the others.

Currently, after a good amount of googling and some chatgpt assistance, After copy/pasting content from 'ft8_params.f90' and 'ft9_testmsg.f90' into ft8code to include less files, I'm using the following command from inside of the wsjt-wsjtx/lib folder to attempt to compile 'ft8code', including the modules and sub modules that it seems to reference.

"gfortran -o ft8/ft8code ft8/ft8code.f90 77bit/packjt77.f90 ft8/encode174_91.f90 fmtmsg.f90 ft8/genft8.f90 chkcall.f90"

I've gotten it down to one error at the moment, pasted below.

/usr/bin/ld: /tmp/ccscrAjy.o: in function `encode174_91_':

encode174_91.f90:(.text+0x458): undefined reference to `crc14'

collect2: error: ld returned 1 exit status

This is where I believe the C++ comes in, as there is a file named 'crc14.cpp' and there are some references to C wrappers in a file called 'crc.f90'.

Is there an easier way to do this perhaps? I apologize in advance for the perhaps not clear post.

Thanks in advance for anyone attempting to help

3 Comments
2024/10/18
23:10 UTC

9

How to debug a mixed C++/Fortran executable where some of the Fortran code is compiled with G77 and has INCLUDE statements?

I've been working on a project where the source code is C++ and Fortran (77). The Fortran code is being compiled with g77 (GNU 3.4.6) and the C/C++ code is being compiled with g++ (GCC 4.4.7). The main function is in the C/C++ code and everything is being linked using g++. This is all being done on a CentOS-6 machine.

Due to various factors outside of my control, I'm unable to update the platform (CentOS-6) or the tools (g77, etc).

I've recently setup a debug build and used GDB to step through the code. However, when getting to the first Fortran function (invoked from C++), GDB goes to the first line of the Fortran function just fine. But, when I step to the next line, which is an INCLUDE statement, GDB throws this message at me...

"Cannot open file: /tmp/ccNWNrGi.f"

I can see the "/tmp/ccNWNrGi.f" file path embedded in the Fortran object file. So, I'm guessing g77 generated a temporary file with the contents of the included file (from the INCLUDE statement) which GDB is unable to find when I'm stepping through the code.

Considering my constraints, using g77 on an old CentOS-6 platform, are there any build flags that I can pass to g77 that would prevent it from creating those temporary files such that GDB can find the actual included file?

EDIT:

I'm able to reproduce the problem using a simple 'hello world' program. Here's the VERBOSE output of the build...

[user@localhost fortran_hw]$ make
g++ -g -O0 -ansi  -c main.c -o main.o
g77 -g -O0 -v -I/home/user/fortran_hw -c hello_fortran.fpp -o hello_fortran.o
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,f77 --disable-libgcj --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-19.el6)
 /usr/libexec/gcc/x86_64-redhat-linux/3.4.6/cc1 -E -traditional-cpp -D_LANGUAGE_FORTRAN -quiet -v -I/home/user/fortran_hw hello_fortran.fpp -mtune=k8 -fworking-directory -O0 -o /tmp/ccbFeXX1.f
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/user/fortran_hw
 /usr/local/include
 /usr/lib/gcc/x86_64-redhat-linux/3.4.6/include
 /usr/include
End of search list.
 /usr/libexec/gcc/x86_64-redhat-linux/3.4.6/f771 /tmp/ccbFeXX1.f -quiet -dumpbase hello_fortran.fpp -mtune=k8 -auxbase-strip hello_fortran.o -g -O0 -version -I/home/user/fortran_hw -o /tmp/ccOjoGwH.s
GNU F77 version 3.4.6 20060404 (Red Hat 3.4.6-19.el6) (x86_64-redhat-linux)
compiled by GNU C version 3.4.6 20060404 (Red Hat 3.4.6-19.el6).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 as -V -Qy -o hello_fortran.o /tmp/ccOjoGwH.s
GNU assembler version 2.20.51.0.2 (x86_64-redhat-linux) using BFD version version 2.20.51.0.2-5.48.el6_10.1 20100205
g++ -g -O0 -mlittle-endian -mwords-little-endian -O main.o hello_fortran.o -lm -lc -L/usr/lib/gcc/x86_64-redhat-linux/3.4.6 -lg2c -o hello

In the case of this 'hello world' example, the Fortran object code (hello_fortran.o) has been created with this file path embedded in it: "/tmp/ccbFeXX1.f". So, it seems like when GDB sees the INCLUDE directive in the Fortran code, it's looking for that "/tmp/ccbFeXX1.f" file instead of the correct Fortran file (device.fpp) in the project folder (/home/user/fortran_hw).

The hello_fortran.fpp file is very basic, looks like this:

      SUBROUTINE  hello_fortran(err)
      IMPLICIT NONE
      INCLUDE  'device.fpp'

      integer*4 err

      write(luo,*)'................................................'
      write(luo,*)'Hello from Fortran!'
      write(luo,*)'................................................'

      err = 0

      END
7 Comments
2024/10/15
23:16 UTC

9

Do I have any options if I want to write a code that runs on both CPU and GPU systems?

Can OpenMP support code such that it works on both with minimal changes? Or is my only option to go with C/C++

9 Comments
2024/10/12
22:13 UTC

3

Trying to install gcc 4 on ubuntu 22

Hello everybody ive been trying to build gcc 4 on an ubuntu 20 server and its been hell is this normal hahaha? (i am a big noob when it comes to that stuff) The build fails on the make step ive scanned the internet but i really haven't found an answer. It seems to give a lot of warnings regarding : warning: ISO C does not support ‘FUNCTION’ predefined identifier [-Wpedantic Most of them ar Werror warnings And after a while the build fails. I was able to build gcc 8 and the newer versions but i need gcc 4 for a model i want to run. Thanks a lot in advance!!

8 Comments
2024/10/10
10:55 UTC

22

The 'F' Word : Shockwaves in 1-D and some major updates to SELF

Hey everyone! I’m back at it. It took some time to getting used to having a young kiddo at home (18 months now! woot!) Kicking things off with a livestream next week.

The ‘F’ Word : Shockwaves in 1-D and some major updates to SELF
October 16, 2024 3PM ET

In this livestream, Joe will discuss shock formation in Burgers equation in 1-D. We will look at how shocks can form and how to predict the shockwave speed. You will learn about how to use explicit laplacian diffusion to stabilize a numerical simulation and we will discuss entropy stable methods briefly. Joe will then do a hands-on walkthrough to show how you can easily implement a solver that runs on GPUs using the Spectral Element Library in Fortran (GitHub - FluidNumerics/SELF: Spectral Element Library in Fortran). We’ll conclude with an overview of some of the updates to SELF since our last livestream (over a year ago!) that the OO Fortran aficionados may enjoy.

You can learn more about SELF and the travelling shockwave example presented in this livestream at https://self.fluidnumerics.com

I’m also looking for folks who want to talk about their Fortran projects on future livestreams. Message me here on reddit if you’re interested in doing a live 30-60 minute chat about your work 

3 Comments
2024/10/08
14:48 UTC

7

Array Common Block Mess

I've been battering away at this problem for the weekend now and although I've made some dents, I can't see a way forward without more help.

I'm trying to run a fortran code called CARLS, using VSCode as an ide. The first subroutine that CARLS calls just functions as a kind of timer, and the second one called START initializes the bulk of the code. Within START, the subroutine MOPEN gets called. This subroutine looks (partially) like this

INCLUDE 'PREC'

INCLUDE 'COPCL'

INCLUDE 'CLU'

INCLUDE 'CBCNST'

INTEGER MDATA(22)

CHARACTER*(*) FILE, STAT0

CHARACTER*10 STAT

SAVE ICALL

DATA ICALL/0/

ICALL = ICALL + 1

IF (ICALL.EQ.1) THEN

DO 100 I = 1, MAXLU

LU(I) = .FALSE.

100 CONTINUE

RDATA=1.0

etc. Upon calling this subroutine, I get a segmentation fault. After lots of debugging statements I narrowed it down to the line LU(I) = .FALSE.

Now, the maximum size of LU is 90 (checked by print statements), and SIZE(LU) does return 90. If i take the exact same IF loop and move it to just before START is called, I don't get the same segmentation fault (but it messes things up later so its not a fix). My issue is, why is LU 'accessible' just before START is called, but causes a crash once inside the subroutine? For reference, here is the relevant section of START subroutine

INCLUDE 'PREC'

INCLUDE 'PARAM'

INCLUDE 'CATOM'

INCLUDE 'CATMOS'

INCLUDE 'CATMO2'

INCLUDE 'CTRAN'

INCLUDE 'CSLINE'

INCLUDE 'CGAUSI'

INCLUDE 'CCONST'

INCLUDE 'CINPUT'

INCLUDE 'CLGMX'

INCLUDE 'CLU'

INCLUDE 'COPCL'

INCLUDE 'CBCNST'

C INITIALISE

C

CALL MCTIME('START ',0,0,3)

CALL MCTIME('INPUT ',0,0,2)

C

C OPEN GLOBAL FILES ALWAYS NEEDED

C

CALL MOPEN(LOUT,'OUT',1,'NEW')

And here is the common block COPCL

C

PARAMETER (MAXLU=90)

LOGICAL LU(MAXLU)

COMMON /COPCL/ LU

Finally, here is common block CLU

C

COMMON /CLU/ LINPUT,LATOM,LATOM2,LATMOS,LDSCAL,LABUND,LOUT,

* LTIME,LRSTRT,LDSCA2,LWMAT,LNIIT,LDUMS,LDUMI,LDUMC,LOPC,LXW,LSW,

* LJNY,LINIT,LPHI,LJOBLO,LATHSE

Chat GPT thinks its an issue with LU not being declared correctly or being interfered with in the code, but as it is a direct call from CARLS subroutine to START subroutine to MOPEN subroutine, I don't see where it could be going wrong. If anyone can see anything obvious that I am missing I would really appreciate any help at all!

11 Comments
2024/10/07
19:14 UTC

10

GNU Fortran and precision

Is there a problem with gfortran.

$ cat example1.f90

Program Test_precision
real x
x = 21.32
write(*,*) "x=",x
end Program Test_precision

$ gfortran example1.f90

$ ./a.out

x= 21.3199997

It was my understanding that Fortran was the language of choice for mathematics once upon a time. I understand that floating point won't have an exact representation and some loss of precision may be unavoidable; however, that seems a bit extreme. I'd at least have expected the last digit to still be a 9 suggesting it was precise to a few more digits internally.

Should I be using any particular flags to increase precision?

7 Comments
2024/10/06
05:03 UTC

4

Is there a way in Fortran to designate an integer value as integer*8 ?

I need many of my integers to be integer*8 in my port to 64 bit. In C/C++ code, I can say 123456L to mean a long long value, generally 64 bit. Is there a corresponding way to do this in Fortran or am I stuck with:

call xyz (1)

subroutine xyz (ivalue)
integer*8 ivalue
...
return end

must be:

integer*8 ivalue
...
ivalue = 1
call xyz (ivalue)

Thanks,
Lynn

15 Comments
2024/10/02
02:58 UTC

0

Is there a way in Fortran to designate an integer value as integer*8 ?

I need many of my integers to be integer*8 in my port to 64 bit. In C/C++ code, I can say 123456L to mean a long long value, generally 64 bit. Is there a corresponding way to do this in Fortran or am I stuck with:

call xyz (1)

subroutine xyz (ivalue)
integer*8 ivalue
...
return

end

must be:

integer*8 ivalue
...
ivalue = 1
call xyz (ivalue)

Thanks,
Lynn

7 Comments
2024/10/02
02:56 UTC

17

Best method to learn Fortran 90

Hey guys, I'm a computer science student, and recently I got enrolled into a scientific project, with a Physics professor, in which I need to learn Fortran 90. However, I only managed to find books at my university that teaches advanced Fortran (like plotting 3d graphs, while I just gotta learn to plot 2d graphs for now), and on Youtube I could only find some hindi tutorials (what didn't help me at all).

Do you guys know any good book or Youtube playlist in which I can learn to program in Fortran 90, and even better, that teaches to plot it anywhere, like GNUplot.

Edit: I already know how to program the basics in Fortran, like hello world and all that stuff (my first official program was a Bháskara calculator. And I need to learn to plot graphs because of that, the professor wants me to plot the graph of the expression the user type on console)

PS: sorry about my English, my mother language is Portuguese

9 Comments
2024/10/01
17:56 UTC

17

Which is easier to use and generates better code: gfortran or Intel Fortran ?

I am using Visual Studio Community version 2019 and Intel Fortran 2021.4.0. The integration between the two is very poor. I have 850,000 lines of F77 code and 50,000 lines of C++ code that I am porting from Open Watcom F77 / C++.

I want to use an IDE since I have over 5,000 source code files.

And Intel Fortran is now telling me that it is due to be replaced with the Intel LLVM Fortran product.

I tried Simply Fortran earlier but I need a more sophisticated visual debugger and the visual debugger in SF does not allow me to stop at the 4,000th call to a specific subroutine.

18 Comments
2024/10/01
01:53 UTC

2

HOW TO INSTAL FORTRAN ON WINDOWS 11 (ENG/ITA)

How do you download and get Fortran working on Windows 11 (Ryzen processor)? I’ve tried following several guides and videos, but I always end up with problems. Can you help me?! The latest error I encountered is this: 'c:\Users\x\OneDrive\Desktop\Fortran\" && gfortran 30-09 -o c:\Users\x\OneDrive\Desktop\Fortran\30-09 && "c:\Users\x\OneDrive\Desktop\Fortran\"c:\Users\x\OneDrive\Desktop\Fortran\30-09 C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main': C:/crossdev/src/mingw-w64-v8-git/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain' collect2.exe: error: ld returned 1 exit status' I'm going crazy!

come si fa a scaricare e far funzionare fortran su windows 11 (processore ryzen). Ho provato a seguire diverse guide e video ma alla fine mi trovo sempre con dei problemi, potete aiutarmi?! l'ultimo errore riscontrato è questo "“c:\Users\x\OneDrive\Desktop\Fortran\" && gfortran 30-09 -o c:\Users\x\OneDrive\Desktop\Fortran\30-09 && "c:\Users\x\OneDrive\Desktop\Fortran\"c:\Users\x\OneDrive\Desktop\Fortran\30-09 C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function main': C:/crossdev/src/mingw-w64-v8-git/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to WinMain' collect2.exe: error: ld returned 1 exit status" sto diventando scemo!

6 Comments
2024/09/30
16:33 UTC

9

How to find out compiler flags that were used when a Fortran library was created (g77)?

I've inherited a project that is delivered with a pre-compiled Fortran library (flib.a). I'd like to be able to recreate the Fortran library from source code.

I've used the following command to dump a list of the object files contained in the library:

ar tv flib.a

I've also found all of the corresponding source code files (*.f) that have the same names as the object files.

What I'd like help with is finding out if there are any known, freely available, Linux tools (e.g. gcc, ar, objdump, etc) that can be used to find out which compiler flags were used to build the object files which were used to create the original Fortran library.

I'm fairly certain that these object files were compiled using 'g77'. So, if I can figure out the correct compiler flags to use, I might be able to recreate Fortran library (flib.a).

5 Comments
2024/09/25
20:57 UTC

5

Fortran - Cramer's Rule

Hi I am learning Fortran in my data science class. I could not understand the part that has bold letters. Please explain this

program CramersRule

! System of equations. 2x2, 3x3

! The main program is written for you. Read through the comments and

! see how the main program works.

! 2 Special Notes!!!!!

! 1: Take note of how the logial variable 'Success' will either write

! the solution or 'No Solution' to the output file.

! 2: Take note of how inside the do loop, allocating and deallocating

! memory for the arrays Matrix1, b, and x are done so the amount of

! memory allocated changes for each system. You cannot allocate more

! memory for an array until currently allocated memory is deallocated.

implicit none

! Declare variable

integer :: n, row, col, i

real, allcatable :: Matrix1(:,:), b(:), x(:)

real :: detA, odetM, determinant

logical :: Success

! Open the input and output files.

open(42,file='Data2.txt')

open(43,file='Data2Out.txt')

! Solve each system in the input files.

do

! Read in size of first system.

read(42,*) n

if (n .eq. 0) exit ! Quit if zero.

! Allocate memory for system, right hand side, and solution vector.

allocate(Matrix1(n,n), b(n), x(n))

! Read in the system. Ask if you do not understand how this works!

do row = 1, n

read(42,*) (Matrix1(row, col), col = 1, n), b(row)

enddo

! Use cramers rule to get solution.

call Cramer(Matrix1, b, n, x, Success)

if (Success) then

! Write solution to file

do row = 1, n

write(43,*) x(row)

enddo

write(43,*)

else ! This happens when there is no unique solution.

write(43,*) 'No Solution'

write(43,*)

endif

! clean up memory and go back up to top for next system.

deallocate(Matrix1, b, x)

enddo

! close files

close(42)

close(43)

end program CramersRule

1 Comment
2024/09/24
03:01 UTC

Back To Top