/r/fortran
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
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,
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
C 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
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?
Guys I need someone to explain me HOW the "dgetrf2" function manage to LU factorize a matrix. Pls help.
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
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.
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,
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
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:
Any Suggestions? And Thanks!
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!
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)
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,
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?
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 !
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
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
Can OpenMP support code such that it works on both with minimal changes? Or is my only option to go with C/C++
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!!
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
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!
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?
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
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
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
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.
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!
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).
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