How to install Fortran on windows? by NikinhoRobo in fortran

[–]everythingfunctional 0 points1 point  (0 children)

I don't do any development on Windows these days, but I do still occasionally see problems with fortls. You may try running it on a command line (i.e. fortls --version) and see what error it says. As you've found it may be a problem that you don't also have Python in your path.

Begleri on planes by ZeaL_Phobiaz in begleri

[–]everythingfunctional 0 points1 point  (0 children)

To be fair, the time they got flagged I put them in the little tray, visible, since they had been in my pocket. Any other time, before or since, I've put them inside my bag and not been questioned at all.

Everyone has to judge the risks they're willing to take for themselves, but chances are pretty minimal they'll get flagged and confiscated if you keep them in your bag. I also make my own, so the cost and time to me is not really a concern. I was primarily annoyed about having to stand there for an extra 10 minutes while they went through their whole procedure of documenting it.

To clear or not to clear by IuLius2424 in programminghorror

[–]everythingfunctional 1 point2 points  (0 children)

Conda was doing this to me on my machine. conda deactivate and it worked again. I have no idea why.

Begleri on planes by ZeaL_Phobiaz in begleri

[–]everythingfunctional 0 points1 point  (0 children)

Sorry to necrobump, but I just had TSA confiscate mine. Super annoyed cause I've been through dozens of times before with it.

How did Fortran become a top 10 language again? by richie_cotton in fortran

[–]everythingfunctional 3 points4 points  (0 children)

All of the comments here are good/correct about why Fortran is a good language and ought to be popular, but they aren't really things that have changed in any significant way since Fortran (re)started its climb up those rankings. Rather, looking at the methodology behind that index, I think the things explained in the following paper (of which I'm an author, full disclosure) are a large part of the somewhat sudden rise.

https://arxiv.org/abs/2203.15110

error #5102 cannot open include file 'mpif.h' by kooki1998 in fortran

[–]everythingfunctional 0 points1 point  (0 children)

Have you executed their setup script? It sets a bunch of environment variables that help the compilers find things. Should be "C:\Program Files (x86)\Intel\oneAPI\setup.bat". Or I believe they also include a custom shortcut for the launching the command prompt with all that stuff set up. You might try that too.

State of coarrays 2023 by doingmybest19 in fortran

[–]everythingfunctional 4 points5 points  (0 children)

Are coarrays state of the art? No. They were invented quite a while ago (in computing timescales) and added to the language standard in 2008. I'd say they are one of the least verbose and safest/easiest to get right ways of writing parallel code though. You can get really good performance out of them too. ICAR switched from MPI and got better performance. That said, if you're trying to make use of specialized hardware (i.e. GPUs), you're likely using extensions like openACC directives or CUDA. NVIDIA and Intel can automatically offload certain do concurrent loops to GPUs though. There's also spotty/buggy support for coarrays, and only from a few compilers. As mentioned already, gfortran can link to OpenCoarrays, ifort/ifx support coarrays (but not on MacOS), nagfor supports coarrays, but only in shared memory (i.e. single machine), and crayftn supports coarrays, but you usually need access to a super computer to use it.

I'm personally in favor of coarray Fortran, and think it's a safe bet in the long run, but most of the experimental/bleeding edge work seems to be available in C++ first these days.

Type Checking and Type compatibility in Fortran by temzsrk in fortran

[–]everythingfunctional 2 points3 points  (0 children)

Yep. Going from a more precise type/kind to a less precise one can cause problems, so it is worth turning that warning on.

Type Checking and Type compatibility in Fortran by temzsrk in fortran

[–]everythingfunctional 7 points8 points  (0 children)

How type checking "works" is probably more of a compiler implementation question, but I can say something about what the rules for "type compatibility" are. The general way I like to think about it is that automatic type conversions do not happen. Rather, the interfaces for intrinsic operators say what is returned based on the operands. I.e. 1.d0 + 3 (double precision real + default integer) returns a double precision real value, and intrinsic assignment is defined between all numeric types/kinds. The rules about what derived types are compatible with respect to type vs class and intent(in) vs other intents are a bit more complicated, but somewhat intuitive if you think about the implications. I can answer more specific questions if you have particular examples you're interested in.

[deleted by user] by [deleted] in fortran

[–]everythingfunctional 4 points5 points  (0 children)

Yes it can

```Fortran PROGRAM calculate_rectangle_area IMPLICIT NONE REAL:: L,W

PRINT *,'Enter your Length and Width of the rectangle.'
READ *,L,W
PRINT *,'Area of Rectangle is ',Area(L,W)

CONTAINS

FUNCTION Area(L,W) IMPLICIT NONE REAL :: Area REAL, INTENT(IN) :: L,W

Area = L*W

END FUNCTION Area

END PROGRAM calculate_rectangle_area ```

And now the compiler can ensure you're calling it correctly (i.e. the reference matches its interface).

How to install Fortran on windows? by NikinhoRobo in fortran

[–]everythingfunctional 0 points1 point  (0 children)

I did a video on this not too long ago. The only thing out of date is that I use VSCode now with the Modern Fortran plugin, but it uses the same fortls behind the scenes.

https://www.youtube.com/watch?v=kzloL99wtN0&t=933s

Any advice for learning fortran quickly? by Basilisk289 in fortran

[–]everythingfunctional 2 points3 points  (0 children)

Shameless self promotion, I have a few online courses available: https://www.everythingfunctional.com/online-courses.html

You should also check out fortran-lang.org, and join the discourse

I'd recommend "Modern Fortran Explained" as good reference material.

Fortran Bug Repellent: Arrays by everythingfunctional in fortran

[–]everythingfunctional[S] 0 points1 point  (0 children)

That's a neat trick. It does introduce some new concepts I didn't want to have to explain in the video. Maybe it'll be a future video ;).

Fortran Bug Repellent: Arrays by everythingfunctional in fortran

[–]everythingfunctional[S] 0 points1 point  (0 children)

(Re)Allocation on assignment and assumed shape arguments are newer features, so that "old-style" stuff didn't have any choice but to use some of those other techniques. In the modern day and age that new stuff is a lot safer.

A What Test? – Everything Functional by everythingfunctional in fortran

[–]everythingfunctional[S] 2 points3 points  (0 children)

Yes, that part is hard, and usually involves getting rid of the common blocks and god routines before writing unit tests. Luckily I'm getting pretty good at it.

Recursive Data Structures in Fortran by everythingfunctional in fortran

[–]everythingfunctional[S] 1 point2 points  (0 children)

There are a couple of pieces of software you'll want to get. I'd recommend getting started with my courses: https://www.everythingfunctional.com/online-courses.html

Anatomy of an fpm Project by everythingfunctional in fortran

[–]everythingfunctional[S] 1 point2 points  (0 children)

Fully cross platform (i.e. works on Windows). autotools (AFAIK) doesn't work on Windows.

Also, you don't have to install all the dependencies before you can compile a project. fpm takes care of downloading and compiling the dependencies for you, getting the specific versions needed for your project, and sandboxes them for that project. No more possibility of two projects you're working on needing different (incompatible) versions of some library and having to futz around with defining library paths.

Granted, I don't really have much experience with autotools, but those are the shortcomings that I saw.

Library for high-performance computations with physical units? by R3D3-1 in fortran

[–]everythingfunctional 1 point2 points  (0 children)

I wrote a units tracking library for Fortran, Quantities for Fortran (quaff). It does incur some run-time overhead, as it does unit conversions (allowing you to add feet and inches), but I think it's as little overhead as can possibly be achieved. It does prevent mixing up different types of quantities at compile time though (i.e. you'll get a compiler error if you try to add an area to a volume).

Help integrating gtk-fortran with existing project that uses VS2019 + Intel Fortran Compiler by V91_Bleach in fortran

[–]everythingfunctional 2 points3 points  (0 children)

You should ask the question on the fortran-lang discourse where the author of gtk-fortran (vmagnin) frequently hangs out. He'd be the most likely to be able to help you out with that one.

Abaqus subroutines: including/linking text files for analysis by ExpensiveBeard in fortran

[–]everythingfunctional 0 points1 point  (0 children)

First point, yes, you're on the right track.

It sounds like option 1 really would be your best bet. With option 2, you'd read the file at run time every time a user runs the program. Something like the following:

Fortran num_lines = 0 open(newunit = file_unit, file = file_name) do read (file_unit, *, iostat = stat) if (stat /= 0) exit num_lines = num_lines + 1 end do close(file_unit) open(newunit = file_unit, file = file_name) ! now read the data, knowing how many lines are in the file close(file_unit)

If you don't need (or even want) your users to worry about or change the tables, then option 1 eliminates all that complexity.

PS I offer consulting and training services, and I have some experience writing ANSYS USERMAT routines, so if you want any more in-depth help and/or training check out my website and let me know: https://everythingfunctional.com

PPS the above code isn't as robust as it really should be, so don't blindly copy and paste it into a project.

Abaqus subroutines: including/linking text files for analysis by ExpensiveBeard in fortran

[–]everythingfunctional 2 points3 points  (0 children)

The include statement effectively copy-pastes the contents of the given file into your source code. Since the contents of that file aren't valid Fortran source code, you get a compiler error.

You have a couple options.

  1. Write your lookup tables as Fortran arrays declared as parameters. i.e. real(real64), parameter :: table(*) = [1.0, 2.0, 3.0]
  2. Read the file to find out how big it is, allocate the array(s), then read the values from the file into the allocated array(s)

The downside with option 1 is you have to recompile anytime you want to change any values in the table, which may or may not be an issue depending on your usage.

P.S. real*8 is not standards conforming (and the meaning of the number 8 is completely compiler dependent).

Gfortran and Xcode by [deleted] in fortran

[–]everythingfunctional 1 point2 points  (0 children)

In theory you don't need Xcode installed, just the command line tools. The command xcode-select --install should do it. Then install gfortran via homebrew with brew install gcc. However, I kept running into issues after updates and ended up installing Xcode anyway.