Fortran 90 beginners tutorial - Part I - hello world, programs and modules

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ธ.ค. 2024

ความคิดเห็น • 38

  • @richardjones7984
    @richardjones7984 6 หลายเดือนก่อน

    A very nice introduction to Fortran 90. It was well explained at the right pace and covered exactly what I need to know to get some Fortran utilities working. You covered the part that others leave out. One point I would like to make is about "Best Practice". I'm an old school programmer and we knew what we were doing with the "sloppy code" because we were careful with our code. A few years ago there was a problem at a major footwear company when the overnight processing extended to mid morning and lost them a lot of sales. I was asked to check the code to see if I could speed it up. The bad code was written in SQL and was to generally accepted "Best Practice" standards. I restructured the code using basic Data Processing principles (1970s) and SQL code written in original IBM SQL syntax. (Optimal machine code for that machine). This made it run 9 times faster, saved 7 hours processing and meant the tills worked when the shops opened. The "expert" SQL coders who maintained the original SQL code said that what I had done was not "Best Practice" and that it was "wrong" but the management were delighted with the increase sales.

  • @grumpyoldman7166
    @grumpyoldman7166 10 หลายเดือนก่อน

    Thanks for the video, from a "Fortran For Humans" grognard. I was looking for a quick refresher on Fortran and this seems to be it.

  • @ElementResources-rp8ox
    @ElementResources-rp8ox ปีที่แล้ว

    Hi Prof. Very nice presentation. Clear and useful. Thank you. I will watch all four. Cheers!

  • @nikolaoskouvatsos9222
    @nikolaoskouvatsos9222 ปีที่แล้ว

    Very nice presentation. I am completely new to Fortran and I found this tutorial very helpful, thank you! Moving on to part II now. :)

  • @Venefica
    @Venefica 2 ปีที่แล้ว

    Excited to watch this; I never knew that learning about astrophysics was going to be why I needed to learn Fortran, but I knew I would have to someday. Supposedly knowing some LOGO is helpful, so that's a plus for me.

  • @mr.curious1714
    @mr.curious1714 2 ปีที่แล้ว

    You are doing great work, I love your fortran video

  • @filip8985
    @filip8985 3 ปีที่แล้ว

    thank you for this, my uni lecturer is pretty useless at teaching how to code, he basically gave us his pi calculator as the first bit of code weve ever seen and told us to try out a bunch of functions, which i didnt even know how to do that, but now i do!

  • @Nl-nn3ds
    @Nl-nn3ds ปีที่แล้ว

    The problem is that old fortran ignores spaces. Thus “do 30 i =1.20” is interpreted as setting a variable as in “do30i = 1.20” where “do30i” is a legal floating point variable. FORTRAN is a two pass compiler which is why you do not have to give the code a function prototype.

  • @sarkersaadahmed
    @sarkersaadahmed 7 หลายเดือนก่อน

    i was wondering if oyu have to know fortran before hand

  • @adampax
    @adampax 4 ปีที่แล้ว

    Great video! Can you explain how to get that fortran syntax highlighting with atom

    • @DanielPriceAstro
      @DanielPriceAstro  4 ปีที่แล้ว

      yes just click on "settings"->"install" and install the "language-fortran" package. You might also find the "linter-gfortran" package useful, which shows you code problems on-the-fly.

  • @ankitapaul1319
    @ankitapaul1319 2 ปีที่แล้ว

    Thank u sir, I have a problem during opening a file inside the program of a simple x.f90 file in my mac, how to solve this problem?please help me

  • @richardbennett4365
    @richardbennett4365 ปีที่แล้ว

    Why does GCC's Fortran compiler give a different answer for 4*atan(1) than Wolfram Alpha?
    How would one know which one is correct? This man's example program overestimates the value of pi. Why?

  • @akinseyefamutimi4717
    @akinseyefamutimi4717 4 ปีที่แล้ว

    on the atom text editor at the bottom right-hand side, what do you change it to because I can't find FORTRAN there, mine is still showing Plain text. Thanks for your prompt response

  • @studymood7401
    @studymood7401 3 ปีที่แล้ว

    PLS HELP!
    what should I do when it says "nothing is register" in the Terminal ?

  • @adventuresinphysics5069
    @adventuresinphysics5069 2 ปีที่แล้ว

    Even when I do gfortran -o maths geometry.f90 maths.f90 I get same the same error that " cannot open file geometry.mod for reading at (1): no such file or directory exists"

  • @johnpsihias5168
    @johnpsihias5168 2 ปีที่แล้ว

    Hello professor I really need advice on how I can download FORTRAN on my MacBook .How can I download it ?

    • @DanielPriceAstro
      @DanielPriceAstro  2 ปีที่แล้ว +1

      first install "homebrew" (brew.sh) then open a terminal and type "brew install gcc" and you should have gfortran working from a terminal. If you are not used to working from the terminal I would recommend taking a basic unix tutorial first.

  • @bryantk2413
    @bryantk2413 3 ปีที่แล้ว

    Amazing set of videos! Now I know what the Makefile is doing! Also, my ~1,200 line Fortran code is now 80 lines with the use of modules :) Thanks! Out of curiosity, is there a way to organize all of the modules and use them from a different directory? My working directory is getting a little cluttered with all of the *.o and *.mod files along with the data? Appreciate any help :) and looking forward to your other videos which look interesting!

    • @DanielPriceAstro
      @DanielPriceAstro  3 ปีที่แล้ว +3

      yes, just add the line VPATH=dir1 dir2 to the top of the Makefile, where dir1 and dir2 are the name of the subdirectories where your source code files are located

    • @bryantk2413
      @bryantk2413 3 ปีที่แล้ว +1

      @@DanielPriceAstro Thank you Thank you! You are the Best!

  • @LinhNguyen-no7qc
    @LinhNguyen-no7qc 4 หลายเดือนก่อน

    Thank you so much!

  • @yassinaarif3379
    @yassinaarif3379 4 ปีที่แล้ว

    Good evening my teacher
    can you help me

  • @sarkersaadahmed
    @sarkersaadahmed 7 หลายเดือนก่อน

    program loop
    implicit none
    real :: i
    do i = 1, 25
    print*, i
    end do
    end program loop in this code i have instigated i as a real value and it still ouputs a real value

  • @JuanPerez-jj7nx
    @JuanPerez-jj7nx 3 ปีที่แล้ว

    Could you make a video explaining how to install a compiler and IDE for Fortran on a Mac M1? 😌😌😌😌

    • @DanielPriceAstro
      @DanielPriceAstro  ปีที่แล้ว +1

      install homebrew (google for it)->type "brew install gfortran" into the terminal->download VSCode or Cursor AI or other text editor with IDE-like capabilities

  • @Swamtrooper8
    @Swamtrooper8 4 ปีที่แล้ว

    Hello,
    I want to make a guess about the bug in this do loop. Maybe because 1.20 is a real and not an integer it can not be assigned to the implicit i. So I would guess i was implicit initialized with a value of 0. As 1.20 can not be assigned it will stay 0 and is printed like that. As the loop has no further steps to do, it will finish.
    Thanks for the tutorial! And greetings from Darmstadt (Germany)!
    PS: Is the tutorials PDF public or is there away to receive it for strictly private use?

    • @Swamtrooper8
      @Swamtrooper8 4 ปีที่แล้ว

      Just found the link to the PDF in the comments of the second video. Thanks!

    • @DanielPriceAstro
      @DanielPriceAstro  4 ปีที่แล้ว

      you're half way there. The key is that FORTRAN allowed spaces in variable names, whereas these are not allowed in modern Fortran. So the =1.20 is treated as an assignment to a variable (hint: starting with d makes it a real if implicit types are allowed). For the pdf, it is available from my web page: users.monash.edu.au/~dprice/teaching/fortran/lab-Fortran.pdf

    • @Swamtrooper8
      @Swamtrooper8 4 ปีที่แล้ว

      @@DanielPriceAstro so 1.20 is assigned to the variable 'do 30 i' . 'i' as a counter variable holds 0 by default and the leading 30 in front of 'continue' is ommit due to its position?

    • @DanielPriceAstro
      @DanielPriceAstro  4 ปีที่แล้ว

      @@Swamtrooper8 correct !

    • @Swamtrooper8
      @Swamtrooper8 4 ปีที่แล้ว

      @@DanielPriceAstro Thanks a lot! It is always nice to learn something new!

  • @richardbennett4365
    @richardbennett4365 ปีที่แล้ว

    But why???
    Why does the error statement complain about a named 'constant,' but the type declaration uses the keyword 'parameter?'
    It is not consistent. Why isn't the declaration using the keyword, 'constnt' if that's what the compiler believes it is and calls it such?
    Else, why isn't then the error statement informing about a parameter instead of a constant?
    Come on! It's 2023 and how long have these boffins been writing errors statements and revising Fortran? More than 50 years?

  • @Patrick-vv3ig
    @Patrick-vv3ig ปีที่แล้ว

    "If you haven't done any programming before", you shouldn't be taking a Fortran 90 course to start with it.

  • @santosvishwa9168
    @santosvishwa9168 2 ปีที่แล้ว

    Hi Professor, I am a beginner in Fortran and learning it by myself. The below code gives me error and
    Stackoverlfow has not been able to give me any meaningful help. Can you help me with this?
    Filename: Univariate_search.f90
    ----------------------------------------------------------
    Compiling with gfortran
    12 | f(x,y) = 2.0*x**2 + 2.0*y**2
    | 1
    Error: Unclassifiable statement at (1)
    Compiling with ifort
    error #6410: This name has not been declared as an array or a function. [F]
    f(x,y) = 2.0*x**2 + 2.0*y**2
    ^
    compilation aborted for new.f90 (code 1)
    ------------------------------------------------------------------------------------------------------
    program Univariate_search
    implicit none
    real :: a,x,y,x0,y0,f
    !initialise the variables
    x0=0.0
    y0=0.0
    !define the functions
    f(x,y) = 2.0*x**2 + 2.0*y**2
    a=f(x0,y0)
    print*, a
    end program

    • @Nl-nn3ds
      @Nl-nn3ds ปีที่แล้ว

      you did not define a function correctly.
      try this:
      program Univariate_search
      implicit none
      real :: a,x,y,x0,y0,f
      !initialise the variables
      x0 = 0.0
      y0 = 0.0
      !error: define the functions
      ! error: f(x,y) = 2.0*x**2 + 2.0*y**2
      a = f(x0,y0)
      print*, a
      end program Univariate_search
      real function f(x,y)
      real x,y,z
      z = 2.0 * x**2 + 2.0 * y**2
      f = z
      return
      end function f