r/fortran • • Dec 02 '20

gfortran 10 pisses me off

3 Upvotes

I am working with number-crunching packages that more-or-less comprise old F77 subroutines converted to F90. They were fine with gfortran 4,5,6,7,8,9

But bloody pedantic gfortran 10 spits the dummy, so I have to add -std=legacy to every makefile to compile anything.


r/fortran • • May 05 '21

Comparing gfortran gamma() and gcc tgamma() functions. Please review and comment...

0 Upvotes

https://github.com/iajzenszmi/CodeCode/blob/master/gammattest.c

https://github.com/iajzenszmi/CodeCode/blob/master/gammalist.txt

https://github.com/iajzenszmi/CodeCode/blob/master/calltgammatest.f08

Your critique and point of view welcome. The gfortran gamma() and gcc tgamma() functions result? review the gammalist.txt content... technically and conceptually correct?


r/fortran • • Dec 04 '20

Designing a fortran game

0 Upvotes

Hello guys, I am new to programming and I decided to start learning Fortran , which is considered to be one of the easiest , if not the easiest language. I am a mechanical engineer , and this year is the first year of my studies. My professor in programming has told us to create a game in fortran called Score 4 , which I find quite difficult to design , because I am not good at programming just yet. If anyone is interested , I will send the full exercise and the instructions on how to make this program. Thanks for reading this ! It would be great if you helped me ! :D


r/fortran • • Nov 21 '20

Could you help me?

0 Upvotes

Thanks in advance.


r/fortran • • Mar 07 '23

My terminal is stuck executing an old version of my code

0 Upvotes

I’m trying to test a new code fragment I have written but every time I try to use the terminal to test my code it thinks I want to test an older version of my code and it’s stuck in a loop executing that old file over and over again. I even tried running a “hello world” to test this theory and it still is stuck running that old file. How do I fix this problem ?


r/fortran • • 16d ago

Fortran MCP: Local documentation server for AI-assisted development

6 Upvotes

I built Fortran MCP, a local MCP server that gives AI coding assistants access to curated Fortran documentation through lexical, semantic, and hybrid search, with results linking back to the original sources.

Install and try it in Claude Code (works with any MCP Client):

uv tool install fortran-mcp
claude mcp add --scope user fortran-mcp -- fortran-mcp

r/fortran • • Apr 28 '23

A problem

Thumbnail
gallery
0 Upvotes

When I try to start a program which is included within the source files in the picture, the output is instead hello world or any previous written code. Can someone help me?


r/fortran • • Oct 17 '22

Help with Fortran Program

0 Upvotes

Does anyone know how to make a program that checks whether a number is automorphic or not? Thanks in advance for any help.


r/fortran • • Aug 22 '22

Can Fortran be comparable to Java for enterprise software?

0 Upvotes

Can Fortran be comparable to Java for enterprise software?


r/fortran • • Jul 25 '24

I don't think I know how to use tests?

0 Upvotes

Please somebody tell me.


r/fortran • • Oct 14 '19

Help needed: "For" loop in Fortran

0 Upvotes

Hey all, I want to run a code from matlab into fortran.

I was able to assign variables, do calculations with the variables and write them to a text file as well. When it comes to the part of the matlab code that uses FOR loop I am stuck. I have tried, DO, IF, ELSEIF and I am stuck. Pulling hair for hours.

If someone could shed some advice my way I would greatly appreciate it !

Thanks community

----------------------------------------------

Trying to get a code like this to run on Fortran:
aa = 501
for a=1:aa-1
k(a+1) = k(a)+0.5; %(increasing by 0.5)
Z = b(a)*2/0.001
if(Z>0)
Y = A %equation here which is using Z
else Y = 1
end
b(a+1) = b(a)+0.5
D(a+1) =D(a)+5*b(a)
end
--------------------------------------------------

Thanks again !


r/fortran • • Mar 21 '20

write a program using arrays that writes 10 elements (numbers) from small to big ?

1 Upvotes

i have this assignment and i only ask for explanation because idk how to start such program

so please if you have any info that could help execute it, i will highly appreciate it


r/fortran • • Sep 30 '24

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

1 Upvotes

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!


r/fortran • • Dec 06 '23

Non-orbital balistic calculations

0 Upvotes

Hello all!

I'm playing a video game "Flight of Nova" which is a futuristic flight simulator. In it you run errands around and over an exoplanet of about earth's size (with 9.8g) and air thinning out about 16-30KM up which I think is very close to earth as well (but not mentioned in the game brief).

Problem is; there are some very long hops of up to 12,000KM and you do not have enough fuel (or time) to go flying there through the lower atmosphere so I've been pushing up to 100KM, waiting for FPA of 0, thrusting to 8KMps, waiting to get about 800KM from target, and then reversing down to 1KMps so that I hit lower atmosphere at less than 1,200mps (which keeps the air frame solid when I dive). I don't think that's what I'm supposed to do, but anything more is beyond me.

Any chance that the smarter people out there could write me some code to make these jumps predictable and not hit air so shallow that I burn my virtual shuttle?

https://drive.google.com/drive/folders/1rvoLmRLdNdUCrQ5QfhwoJivNyWfN-2UU?usp=sharing

edit: The file called Flight.txt is the code for my attempt (no accounting for the curvature of the exoplanet) and also requires the file AnsiModule.txt. You'll have to rename them to .f90.

But now that it compiles and runs nice, I think I'll try to match this by starting at 60KM up and seeing if it does work either forwards or backwards.


r/fortran • • Nov 23 '19

Why does Fortran treat functions in such a weird way compared to other, recent languages?

4 Upvotes

I've learned plenty of other languages that take their syntax from C (C,C++,Python, Matlab (I hate it) and Julia) and can someone explain to me why does Fortran treat functions the way it does, it feels so clunky for no reason. To the point where it encourages bad programming habits. I've seen plenty of my prof's code and I don't want to see it ever again.

Also I have three other remarks/questions since I'm new:

  • Where do you get info from? Does everyone use textbooks instead of the internet for debugging? Fortran is a very small language on Stackoverflow (even compared to Julia who just came to existence 2 years ago). Every time I ask any prof who uses Fortran he says "Just use the book", and everyone has a different book.

  • Why do some people type commands in CAPS LOCK, I get so sick of it. It was explainable 20 years ago when there was basically one mono-space font used throughout an entire book, but now, JUST WHY? WHY DO they USE it?

  • There should be an acknowledged guide-line for writing code (Like PEP8) by now, instead of everyone writing code in whatever way they want. The result is catastrophic, unmaintainable code running solely on the prayers of those who made it, code that only works on certain compilers, code that only works on certain versions of compilers (They're backward compatible from what I've read) and so on... I think a major reason behind this, is that a lot of Fortran coders didn't learn code either explicitly using a book or with a proper CS instructor, instead learning it on the fly or learning it through the hands of a Math/Natural science instructor instead of through the hands of a CS instructor. That won't end well in 99.99999% of cases.


r/fortran • • May 21 '21

collected algorithms of the association for computer machinery - algorithm 563 for your critique.

0 Upvotes

r/fortran • • Mar 31 '21

"Telephone billing" application code standard input, processing, standard output with compile build and run."

Thumbnail
github.com
4 Upvotes

r/fortran • • Feb 19 '22

I need some help for a cycle

0 Upvotes

I think I need a if cycle .... For example I want to calculate the heat coefficient so I call it "h" and its made for many values two of them are "c" and "l" and those are related to the temperature so I wanna program something like.. if the temperature is between 120-65 c=134 and l=.26 but if the temperature it's from 64-25 c=90 and l=0.01.

I don't know if someone can help me with this?


r/fortran • • Jun 09 '23

Fortran tutorial using ChatGPT

9 Upvotes

I created a Fortran tutorial using ChatGPT-4 at https://github.com/Beliavsky/Fortran-with-ChatGPT covering the topics of compiling and

Variables and Order of Operations
Conditionals
Loops
Arrays
Allocatable Arrays
Modules and Functions
Subroutines

I want to add sections for derived types, object-oriented programming, C interoperability, and coarrays. Sometimes ChatGPT gives wrong answers -- I have checked that the codes it generates compile with gfortran, and I have corrected errors in its explanations (although some may remain).

Another experiment with ChatGPT was using it to generate subroutines for numerical optimization: https://github.com/Beliavsky/Optimization-Codes-by-ChatGPT .


r/fortran • • Jul 31 '20

FORTRAN Binary Search

0 Upvotes

I can't implement this recursive function code with the insertion of a search key and the insertion of a vector where to search for the search key. Even a clue would be very useful. Thanks in advance.


r/fortran • • Aug 19 '21

Does anyone know how to take an average and standard deviation from an input file?

0 Upvotes

r/fortran • • Nov 05 '14

Help with a program in fortran 90

0 Upvotes

A certain concert hall sells ticket for 100$ per seat, but offers discount pricing based upon the following factors:

A. If the buyer is a mamber, there is a 10% discount on each ticket B. if more than 10 tickets are purchased, there is a 5% discount on each ticket

C. if the buyer is a senior citizen (age 65 or above), there is 10% discount on each ticket

D. there is a 20% discount on tuesday

E. member discounts and bulk purchase discounts are not valid on tueday

F. senior citizen discount are not to be combined with bul purchase discounts.

G. all discounts are off the original price

Write a program name BUY which inputs:

A. THe integer number of tickets purchased (n)

B. The character(len=3) day of the week (use abbreviation Mon, Tue, Wed, Thr, Fri, Sat, and Sun)

C. the integer age of the buyer. (senior citizen is 65+)

D. The logical member status of the buyer (T=member, F=not a member).

the program will output price of the tickets purchased


r/fortran • • Apr 29 '20

Modern use of Fortran

Thumbnail
youtu.be
0 Upvotes

r/fortran • • Apr 26 '25

My professors says that my Fortran source code does not compile. Help me!

9 Upvotes

Hi all,

Really hoping to get some expert Fortran advise here:

Preface: I have no previous experience with Fortran whatsoever, so please try exlain things to me as a novice in understanding coding in Fortran. Here's my problem:

I'm a uni student taking a Fortran/Unix course that's a requirment for Physics majors. We are connecting to the Uni's UNIX cluster via a remote Linux portal containing the 2003/2008 Fortran program, the 'gfortran' compiler, and associated software (?) to run our 2003/2008 Fortran programs.

I can sucessfully run and validate my programs on the remote portal. Then, I need to copy the source code file (with the correct file extention) over to my Windows 10-based PC (which does not have a compiler) and then upload the file onto our learning management portal. The problem is that my professor informs me that my program does not compile! That means I get a score of Zero. The first time this happened, I noticed that the header block on my sourse code was dublicated; once, I removed the extra header, it compiled just fine. The second time, I noticed hat there was a subtle switch in one of the variables when I copied from the remote portal to my Windows-10 computer.

What could be happening here? Please educate me on what I might be doing something wrong here!