/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,508 Subscribers

6

OpenMP slowing down the run time

Hello, i need help parallelizing this chunk of code, i know having !$omp parallel inside the loop will slow it down so i have to place it outside, but doing so is creating false values

    !$omp parallel  
        do i=1, Nt

            !$omp do private(i1)
            do i1=2, n-1
                         df1(i1)=(f0(i1)-f0(i1-1))/dx
             df2(i1)=(f0(i1+1)-2*f0(i1)+f0(i1-1))/(dx**2)
             F(i1)=-V*df1(i1)+D*df2(i1)
                     end do
            !$omp end do

        ! periodic boundary conditions
            df1(1)=df1(n-1)
            df1(n)=df1(2)
            df2(1)=df2(n-1)
            df2(n)=df2(2)
            F(1)=-V*df1(1)+D*df2(1)
            F(n)=-V*df1(n)+D*df2(n)
        ! time stepping loop, not parallelized
            do j=1, n
                f0(j)=f0(j)+dt*F(j)
            end do

        end do
    !$omp end parallel
9 Comments
2024/12/04
00:38 UTC

13

Can Nvidia Fortran use the GPU in my graphics card?

I program Fortran as a hobby. Can Nvidia Fortran use the GPU in my laptop's Nvidia graphics card? What will happen to my monitor while it does? How difficult is it to set up? Is it fun; is it worth doing if I'm not being required to do it for my job? What performance differences should I expect?

26 Comments
2024/11/24
17:27 UTC

11

memory leaking when binding MPI parallelize to python with f2py

Hi everyone,

I’ve been working on an optimization program to fit experimental results to simulations, and I’ve encountered some challenging issues related to memory management and program structure. I’d appreciate any advice or insights from those with experience in similar setups.

Background

The simulation relies on legacy Fortran code written by my advisor 30–40 years ago. Rewriting the entire codebase is infeasible, but we wanted a more user-friendly interface. Python, combined with Jupyter Notebook, seemed like a great fit since it aligns well with the trends in our field.

To achieve this, I recompiled the Fortran code into a Python module using f2py. On top of that, I parallelized the Fortran code using MPI, which significantly improved computation speed and opened the door to HPC cluster utilization.

However, I’m not an expert in MPI, Python-C/Fortran integration, or memory profiling. While the program works, I’ve encountered issues as I scale up. Here’s the current program structure:

  1. Python Initialization: In the Jupyter Notebook, I initialize the MPI environment using:import mpi4py.MPI as MPI No mpiexec or mpirun is needed for this setup, and this easily compatible with jupyter notebook, which is very convenient. I think this might be running in some kind of “singleton mode,” where only one process is active at this stage.
  2. Simulation Calls: When simulation is needed, I call a Fortran subroutine. This subroutine:
    • Uses MPI_COMM_SPAWN to create child processes.
    • Broadcasts data to these processes.
    • Solves an eigenvalue problem using MKL (CGEEV).
    • Gathers results back to the master process using MPI_GATHERV.
    • Return the results to Python program.

Issues

  1. Memory Leaks: As the program scales up (e.g., larger matrices, more optimization iterations), memory usage increases steadily.
    • Using top, I see the memory usage of mpiexec gradually rise until the program crashes with a segmentation fault.
    • I suspect there’s a memory leak, but I can’t pinpoint the culprit.
  2. Debugging Challenges:
    • Tools like valgrind and Intel Inspector haven’t been helpful so far.
    • Valgrind reports numerous false positives related to malloc, making it hard to filter out real issues.
    • Intel Inspector complains about libc.o, which confuses me.
    • This is my first attempt at memory profiling, so I might be missing something basic.
  3. Performance Overhead:
    • Based on Intel VTune profiling, the frequent spawning and termination of MPI processes seem to create overhead.
    • Parallel efficiency is lower than I expected, and I suspect the structure of the program (repeated spawning) is suboptimal.

Questions

  1. Memory Leaks:
    • Has anyone faced similar memory leak issues when combining MPI, Fortran, and Python?
    • Are there better tools or strategies for profiling memory in such mixed-language programs?
  2. Program Structure:
    • Is using MPI_COMM_SPAWN repeatedly for each simulation call a bad practice?
    • What’s a more efficient way to organize such a program?
  3. General Advice:
    • Are there debugging or performance profiling techniques I’m overlooking?

Some environment information that might be relevant

  • I am running on wsl2 ubuntu 22.04 LTS using windows 10
  • I am using intel oneapi solution 2023.0. I used ifort, intel mpi and MKL.
  • compiler flag is -xHost and -O3 in production code

Any suggestions or guidance would be immensely helpful. Thanks in advance!

11 Comments
2024/11/23
04:25 UTC

5

Why does fortran still have a maxmimum line length?

I mean we dont have to be backwards compatible with punchcards, right?

9 Comments
2024/11/21
08:20 UTC

10

Which version of FORTRAN should I choose for my product?

So basically I am working on implementing a complete parser for FORTRAN, which will be used/deployed as an SaaS product. Now I want to maximize the scope and userbase for the potential product. So I was thinking which version of FORTRAN should I choose?

Some recommendations I've seen are 77, 95 or 2008.

I would love to get some feedback from the FORTRAN community, as I myself cannot make a decision. Thanks.

20 Comments
2024/11/15
15:22 UTC

12

Hurrah !  They added the Break on the nth Call to the Simply Fortran IDE for me !

Hurrah !  They added the Break on the nth Call to the Simply Fortran IDE for me !

"A breakpoint condition was added using the ignore keyword to pass a breakpoint a specified number of times before stopping, a user-requested feature."
   https://simplyfortran.com/news/164/

Thanks,
Lynn

0 Comments
2024/11/15
02:24 UTC

18

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

99

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?

39 Comments
2024/11/08
20:20 UTC

5

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

7

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.

8 Comments
2024/11/07
03:53 UTC

19

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

23

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

6

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

5

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

8

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

10

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

2

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

21

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

5

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

Back To Top