What ChatGPT says about Fortran

I asked ChatGPT about Fortran. The answers may reflect what is believed about Fortran on the Internet. I think the answers are pretty good, although Fortran now has decent support for OOP.

What are the strengths of the Fortran programming language?

Fortran (short for “Formula Translation”) is a general-purpose, compiled programming language that is especially suited to numerical and scientific computing. Some of the strengths of Fortran include:

High performance: Fortran is known for its fast execution speed, making it well-suited for numerical and scientific computations that require a lot of number-crunching.

Widely used in scientific and engineering fields: Fortran is the dominant programming language in many scientific and engineering fields, including physics, chemistry, and meteorology. It is also widely used in the field of finance for financial modeling.

Strong support for parallel processing: Fortran has strong support for parallel processing, making it easier to write code that can take advantage of multiple processors or compute nodes. This makes it well-suited for high-performance computing (HPC) applications.

Wide range of numerical libraries and tools: Fortran has a wide range of libraries and tools available for numerical computing, including linear algebra libraries, optimization libraries, and libraries for solving differential equations.

Long history and strong legacy: Fortran has a long history, with the first version of the language being developed in the 1950s. This means that there is a large body of existing Fortran code and a large community of users who can provide support and advice.

What are the weaknesses of the Fortran programming language?

Some of the weaknesses of the Fortran programming language include:

Limited support for modern programming paradigms: Fortran is primarily a procedural programming language, meaning that it is based on the idea of writing code as a sequence of steps to be executed in order. This can make it difficult to use modern programming paradigms, such as object-oriented programming or functional programming.

Lack of support for newer language features: Fortran has not undergone significant updates in recent years, and as a result, it lacks many of the newer language features that are found in more modern programming languages, such as garbage collection or support for lambda expressions.

Limited support for modern software development practices: Fortran does not have strong support for modern software development practices, such as unit testing or code refactoring. This can make it difficult to write and maintain large, complex Fortran codebases.

Limited use outside of scientific and engineering fields: Fortran is primarily used in scientific and engineering fields, and it is not as widely used in other areas of software development. This can make it difficult to find developers with Fortran experience, and it may be more difficult to find libraries and tools that are compatible with Fortran.

Limited support for modern development environments: Fortran has limited support for modern development environments, such as integrated development environments (IDEs) with features like code completion and refactoring tools. This can make it more difficult to write and debug Fortran code.

1 Like

So the question is, are those weaknesses true?

1 Like

The strengths section reads almost like a transcript of my YouTube video on the topic. The only true statements in the weaknesses section are

And even that last one is debatable, as I’ve heard it is used in financial/trading systems regularly.

1 Like

I will be nitpicky here : The question “What ChatGPT says about Fortran” is, IMHO, more accurate with “What most people wrote about Fortran in public documents - an overview provided by ChatGPT”.

As far I can understand, AI such as ChatGPT are good at providing overviews of “what people wrote” in the public documents used for training. Therefore the absence of financial/trading systems field in the output can be either a hole in the training material of ChatGPT, or an accurate fact about financial/trading applications being dwarfed by scientific applications.

By the way, these AI tools are promising wizards to help newcomers learn about a language. For example this is what I got from the following prompt:

write a Fortran code solving the 2D trajectory of a tennis ball exposed to drag force and gravity

Certainly! Here is a sample Fortran code that solves the 2D trajectory of a tennis ball exposed to drag force and gravity:

! Program to solve the 2D trajectory of a tennis ball exposed to drag force and gravity
program tennis_ball_trajectory
  implicit none

  ! Declare variables
  real, dimension(:), allocatable :: t, x, y, vx, vy, ax, ay  ! time, position, velocity, acceleration
  real :: dt, rho, A, Cd, m, g, v0, theta, x0, y0  ! time step, air density, cross-sectional area, drag coefficient, mass, acceleration due to gravity, initial velocity, initial angle, initial x position, initial y position

  ! Allocate arrays
  allocate(t(0:10000), x(0:10000), y(0:10000), vx(0:10000), vy(0:10000), ax(0:10000), ay(0:10000))

  ! Set constants
  dt = 0.01  ! time step (s)
  rho = 1.2  ! air density (kg/m^3)
  A = 0.0042  ! cross-sectional area (m^2)
  Cd = 0.3  ! drag coefficient
  m = 0.058  ! mass (kg)
  g = 9.81  ! acceleration due to gravity (m/s^2)
  v0 = 20  ! initial velocity (m/s)
  theta = 45  ! initial angle (degrees)
  x0 = 0  ! initial x position (m)
  y0 = 0  ! initial y position (m)

  ! Convert initial angle to radians
  theta = theta * 3.14159 / 180

  ! Set initial values
  t(1) = 0  ! initial time (s)
  x(1) = x0  ! initial x position (m)
  y(1) = y0  ! initial y position (m)
  vx(1) = v0*cos(theta)  ! initial x velocity (m/s)
  vy(1) = v0*sin(theta)  ! initial y velocity (m/s)
  ax(1) = -(Cd*rho*A*vx(1)*abs(vx(1)))/(2*m)  ! initial x acceleration (m/s^2)
  ay(1) = -g-(Cd*rho*A*vy(1)*abs(vy(1)))/(2*m)  ! initial y acceleration (m/s^2)

  ! Loop through time steps
  do i = 2, 10000
    t(i) = t(i-1) + dt  ! update time (s)
    x(i) = x(i-1) + vx(i-1)*dt + 0.5*ax(i-1)*dt**2  ! update x position (m)
    y(i) = y(i-1) + vy(i-1)*dt + 0.5*ay(i-1)*dt**2  ! update y position (m)
    vx(i) = vx(i-1) + ax(i-1)*dt  ! update x velocity (m/s

The real added value is the ability to move from a concept (a tennis ball with gravity and drag force) to these “Intelligent code lines” specific to your problem. It even ‘guessed’ the size, weight, and some acceptable intial conditions missing in the prompt. Students learn fast how to do a loop, but it takes time and pain to get these “Intelligent code lines” right.

Therefore, these tools are promising to help students move from “closed” problems to “open” problems, IMHO. Whe need to learn how to make use of it…

1 Like

i has not been declared:

   37 |   do i = 2, 10000
      |      1
Error: Symbol ‘i’ at (1) has no IMPLICIT type

How do you think ChatGPT works to generate such code? Has it learned the algorithm in another language and translated it into Fortran? (probably that kind of code is available somewhere on the net) Has it some ability to translate physics equations into code? It’s quite mysterious and astonishing… :thinking:

It’s likely a combination of search engine results plus those from initial stages of a composition algorithm. Thus there is little which is truly sentient in the response.

If something doesn’t exist on the internet, for example how to calculate the variability in the solar signal and its effects on earth’s climate (because few if any mainstream institutions are studying it, it goes against the current orthodoxy of exclusively anthropogenic CO2-driven climate change, and the signal is assumed constant in mainstream studies), the search engine would yield poor to no results and the latter won’t matter.

Ouh, vast question :slight_smile: The fun part is I can repeat the same prompt and get slightly different versions.

My current mental model is that chat GPT is doing text completion (like your mail/smartphone) while keeping track of what it already wrote in the past lines/past prompts. The concepts here are expressed in Fortran code, but If I replace “Fortran code” by “french text” (a very barbaric way of expressing ideas, I know, but bear with me), I get:

write a french text solving the 2D trajectory of a tennis ball exposed to drag force and gravity

Voici un texte en français qui résout la trajectoire 2D d’une balle de tennis soumise à une force de traînée et à la gravité :

"Pour résoudre la trajectoire 2D d’une balle de tennis soumise à une force de traînée et à la gravité, nous devons d’abord définir quelques variables et constantes. Nous aurons besoin de la densité de l’air (rho), de la section transversale de la balle (A), du coefficient de traînée (Cd), de la masse de la balle (m), de l’accélération due à la gravité (g), de la vitesse initiale de la balle (v0), de l’angle initial de la balle (theta), de la position initiale en x de la balle (x0) et de la position initiale en y de la balle (y0).

Ensuite, nous devons convertir l’angle initial de la balle en radians et définir les valeurs initiales de la balle en fonction de ces variables et constantes. Nous pouvons utiliser la formule suivante pour calculer la vitesse initiale en x de la balle (vx) et la vitesse initiale en y de la balle (vy) : vx = v0 * cos(theta) et vy = v0 * sin(theta).

Pour calculer l’accélération initiale en x (ax) et en y (ay) de la balle, nous pouvons utiliser les formules suivantes : ax = -(Cd * rho * A * vx * abs(vx))/(2 * m) et ay = -g - (Cd * rho * A * vy * abs(vy))/(2 * m).

Enfin, nous pouvons utiliser une boucle pour mettre à jour la position et la vitesse de la balle à chaque pas de temps en utilisant les formules suivantes : x(i) = x(i-1) + vx(i-1) * dt + 0.5 * ax(i-1) * dt2, y(i) = y(i-1) + vy(i-1) * dt + 0.5 * ay(i-1) * dt2 et vx(i) = vx(i-1) + ax(i-1) * dt, vy(i) = vy(i-1) + ay(i-1) * dt. En utilisant ces formules, nous pouvons obtenir la trajectoire 2D de la balle de tennis soumise à une force de traînée et à la gravité."

Note how , compared to the fortran version, the output is vague (no constants nor initial conditions) with a hint of superiority, in conformity with public french texts standards. This is solid proof we are looking at an imitation game.

I need to learn more about these fancy new tools. If I come across a good reference to grasp what is under the hood, I will post it.

Here is a good read to get the gist of ChatGPT, many thanks to Corentin Lapeyre, my AI guru :
Illustrating Reinforcement Learning from Human Feedback (RLHF) .

1 Like

I agree. It is possible to nudge ChatGPT to use good style. For the prompt

“Write a Fortran program using double precision to compute pi using the Monte Carlo method” it gives

code using default real
program monte_carlo_pi
  implicit none

  integer, parameter :: n = 10000000  ! Number of samples to use in the calculation
  integer :: i, count  ! Loop variables and count of samples inside the circle
  real :: x, y  ! Coordinates of the samples
  real :: pi  ! Approximate value of pi

  ! Initialize the count to zero
  count = 0

  ! Generate n random samples
  do i = 1, n
    x = 2.0 * rand() - 1.0  ! Generate a random value for x in the range [-1, 1]
    y = 2.0 * rand() - 1.0  ! Generate a random value for y in the range [-1, 1]

    ! Check if the sample is inside the circle
    if (x**2 + y**2 <= 1.0) then
      count = count + 1  ! Increment the count if the sample is inside the circle
    endif
  end do

  ! Calculate the approximate value of pi
  pi = 4.0 * count / n

  ! Print the result
  write(*,*) "Approximate value of pi: ", pi
end program monte_carlo_pi

! This program generates n random samples in the range [-1, 1] for both
! the x and y coordinates. It then checks whether each sample is inside
! the unit circle centered at the origin (x = 0, y = 0), by calculating
! the distance of the sample from the origin and checking if it is less
! than or equal to 1. If the sample is inside the circle, the count is
! incremented. Finally, the approximate value of pi is calculated by
! multiplying the count by 4 and dividing by the total number of
! samples.
! 
! The Monte Carlo method works by generating a large number of random
! samples and using the ratio of the number of samples inside the circle
! to the total number of samples to estimate the value of pi. The more
! samples that are used, the more accurate the estimate will be. The
! value of n can be increased to improve the accuracy of the
! approximation.

“Write a Fortran program using double precision to compute pi using the Monte Carlo method” gives

code using hard-coded real KIND of 8
! Write a Fortran program using double precision to compute pi using the Monte Carlo method.

program monte_carlo_pi_double_precision
  implicit none

  integer, parameter :: n = 10000000  ! Number of samples to use in the calculation
  integer :: i, count  ! Loop variables and count of samples inside the circle
  real(kind=8) :: x, y  ! Coordinates of the samples, using double precision
  real(kind=8) :: pi  ! Approximate value of pi, using double precision

  ! Initialize the count to zero
  count = 0

  ! Generate n random samples
  do i = 1, n
    x = 2.0_8 * rand() - 1.0_8  ! Generate a random value for x in the range [-1, 1]
    y = 2.0_8 * rand() - 1.0_8  ! Generate a random value for y in the range [-1, 1]

    ! Check if the sample is inside the circle
    if (x**2 + y**2 <= 1.0_8) then
      count = count + 1  ! Increment the count if the sample is inside the circle
    endif
  end do

  ! Calculate the approximate value of pi
  pi = 4.0_8 * count / n

  ! Print the result
  write(*,*) "Approximate value of pi: ", pi
end program monte_carlo_pi_double_precision

! This program is similar to the one in the previous answer, but it uses double precision for the variables x, y, and pi. The double precision kind value is specified by appending _8 to the value, as in 2.0_8 and 1.0_8.
! 
! Using double precision can improve the accuracy of the approximation, as it allows for a wider range of representable numbers and a higher precision in the calculations. However, it also requires more memory and may be slower than using single precision.

“Write a Fortran program using double precision, using a parameter for the kind value, to compute pi using the Monte Carlo method” gives

code with integer, parameter :: kind_value = 8
! Write a Fortran program using double precision, using a parameter for the kind value, to compute pi using the Monte Carlo method.

! Here is a Fortran program that uses double precision and a parameter for the kind value to approximate the value of pi using the Monte Carlo method:

program monte_carlo_pi_double_precision_parameter
  implicit none

  integer, parameter :: n = 10000000  ! Number of samples to use in the calculation
  integer, parameter :: kind_value = 8  ! Kind value for double precision
  integer :: i, count  ! Loop variables and count of samples inside the circle
  real(kind=kind_value) :: x, y  ! Coordinates of the samples, using double precision
  real(kind=kind_value) :: pi  ! Approximate value of pi, using double precision

  ! Initialize the count to zero
  count = 0

  ! Generate n random samples
  do i = 1, n
    x = 2.0_kind_value * rand() - 1.0_kind_value  ! Generate a random value for x in the range [-1, 1]
    y = 2.0_kind_value * rand() - 1.0_kind_value  ! Generate a random value for y in the range [-1, 1]

    ! Check if the sample is inside the circle
    if (x**2 + y**2 <= 1.0_kind_value) then
      count = count + 1  ! Increment the count if the sample is inside the circle
    endif
  end do

  ! Calculate the approximate value of pi
  pi = 4.0_kind_value * count / n

  ! Print the result
  write(*,*) "Approximate value of pi: ", pi
end program monte_carlo_pi_double_precision_parameter

! This program is similar to the one in the previous answer, but it uses
! a parameter for the kind value, which is defined as kind_value. This
! allows the program to use double precision without hardcoding the kind
! value in the program.
! 
! Using a parameter for the kind value can make the program more
! flexible and easier to modify, as the kind value can be changed in a
! single place rather than throughout the program. It also makes it
! easier to switch between different precision levels, such as single
! precision or quadruple precision, if needed.

ChatGPT is not omniscient about Fortran yet, so I can still justify my existence :). When I told it, “The function rand() is not part of the Fortran 2018 standard. Please write the program using the random_number() intrinsic instead.”

it produced the same program as above, replacing rand with random_number, not recognizing that random_number is a subroutine rather than a function.

It would be interesting to try to find a rarer language where it could not find any text about that…

Anyway, I am impressed by the fact that if I copy/paste a (French or English) sentence into Google, it does not find the source, like it would if we were facing a cheating student.

Yes, bad programming practice, it does not even compile its code to verify if the syntax is correct… :grin: We can justify our existence for now, but that could be a future improvement… :robot:

I understand, it looks like a kind of super search engine, able to compose a text instead of giving an URL with a quote. Anyway, it’s awesome…

To hasten my obsolescence, I can teach GPT about Fortran. It appears that it can learn. When the code it emits is invalid, it is often something that Fortranners have requested as an addition to the language, such as a function that returns multiple variables or an assignment with multiple variables on the LHS. Here is a transcript, with my comments bolded.

How do I return multiple values from a Fortran function?

In Fortran, you can return multiple values from a function by using the RESULT keyword and specifying the variables that you want to return. For example, consider the following function that calculates the sum and product of two numbers:

function sum_and_product(x, y) result(sum, product)
    integer, intent(in) :: x, y
    integer :: sum, product

    sum = x + y
    product = x * y
end function sum_and_product

To use this function, you can call it in a similar way to other functions, but you need to specify variables to receive the returned values:

integer :: a, b, s, p

a = 3
b = 4
call sum_and_product(a, b, s, p)

print *, "The sum is", s
print *, "The product is", p

Thanks, but sum_and_product is a function, not a subroutine, so you don’t invoke it with a call statement.

You are correct! I apologize for the mistake in my previous response. To use a function in Fortran, you do not need to use the CALL statement; you can simply use the function name and pass the arguments in the same way as you would for a subroutine.

For example, to use the sum_and_product function from my previous example, you can simply write:

integer :: a, b, s, p

a = 3
b = 4
s, p = sum_and_product(a, b)

print *, "The sum is", s
print *, "The product is", p

Another problem is that a Fortran function has a single result variable, not multiple results as in the code you presented. Could you rewrite the function to return an array?

Certainly! In Fortran, you can return an array from a function by using the DIMENSION attribute in the function declaration and specifying the size of the array. Here’s an example of how you could rewrite the sum_and_product function to return an array containing both the sum and the product of two numbers:

function sum_and_product(x, y) result(results)
    integer, intent(in) :: x, y
    integer, dimension(2) :: results

    results(1) = x + y
    results(2) = x * y
end function sum_and_product

To use this function, you can call it in a similar way to other functions, but you need to specify an array variable to receive the returned values:

integer :: a, b, results(2)

a = 3
b = 4
results = sum_and_product(a, b)

print *, "The sum is", results(1)
print *, "The product is", results(2)
1 Like

Wow… Is it the ideal student? :sweat_smile:

I remember having discussed with the ELIZA chatbot (psychoanalyst), as a teen, on my Dragon 32, I think (a kind of TRS-80). But here, we can see that ChatGPT is able to learn or to correct its answers, to give us what we expect on that technical subject. Awesome…

So if (someone else?) repeats the same original question, it gives a correct answer now?

I worked on code that had hundreds of functions that returned multiple values via functions and not did not have a single subroutine. It was too old to have been influenced by C ( I know the author only used Fortran) so I think he must have been a fan of functional programming before the term even existed :> At the time it had not even occurred to me a function could return anything other than a result so it was a bit disconcerting at first (this was a long time ago).

ChatGPT correctly inferred argument intents for a simple subroutine.

Add INTENTs for the arguments of the subroutine in the following Fortran code.

program main
implicit none
integer, parameter :: n = 10**6
real :: x(n),mean,sd
call random_number(x)
call normalize(n,x,mean,sd)
print*,"mean, sd =",mean,sd
print*,"after normalizing"
call normalize(n,x,mean,sd)
print*,"mean, sd =",mean,sd
contains
subroutine normalize(n,x,mean,sd)
integer :: n
real    :: x(n)
real    :: mean,sd
mean = sum(x)/n
sd   = sqrt(sum((x-mean)**2)/n)
x    = (x-mean)/sd
end subroutine normalize
end program main

Sure! Here is the updated Fortran code with INTENTs added to the arguments of the subroutine normalize:

program main
implicit none
integer, parameter :: n = 10**6
real :: x(n),mean,sd
call random_number(x)
call normalize(n,x,mean,sd)
print*,"mean, sd =",mean,sd
print*,"after normalizing"
call normalize(n,x,mean,sd)
print*,"mean, sd =",mean,sd
contains
subroutine normalize(n,x,mean,sd)
integer, intent(in) :: n
real, intent(inout) :: x(n)
real, intent(out) :: mean,sd
mean = sum(x)/n
sd = sqrt(sum((x-mean)**2)/n)
x = (x-mean)/sd
end subroutine normalize
end program main

The INTENT attribute specifies the direction of data transfer for an argument in a subroutine or function. In this case, the argument n is an input to the subroutine, so it has the INTENT in. The argument x is both an input and an output of the subroutine, so it has the INTENT inout. The arguments mean and sd are outputs from the subroutine, so they have the INTENT out.

It can replace some simple loops with array operations.

Modify the following Fortran program to compute sumsq using an array operation instead of a loop.

program main
implicit none
integer, parameter :: n = 100
real :: x(n),sumsq
integer :: i
call random_number(x)
sumsq = 0.0
do i=1,n
   sumsq = sumsq + x(i)**2
end do
print*,sumsq
end program main

ChatGPT program:

program main
implicit none
integer, parameter :: n = 100
real :: x(n),sumsq
call random_number(x)
sumsq = sum(x**2)
print*,sumsq
end program main

It can create more complicated array operations given a hint.

Modify the following Fortran program to compute sumsq using the SUM intrinsic function with the MASK argument.

program main
implicit none
integer, parameter :: n = 100
real :: x(n),sumsq
integer :: i
call random_number(x)
sumsq = 0.0
do i=1,n
   if (x(i) > 0.6) sumsq = sumsq + x(i)**2
end do
print*,sumsq
end program main

ChatGPT program, with its commentary:

program main
implicit none
integer, parameter :: n = 100
real :: x(n),sumsq
call random_number(x)
sumsq = sum(x**2, mask=(x > 0.6))
! without the hint about using the MASK argument of SUM, it gives the invalid code
! sumsq = sum((x > 0.6) * x**2)
print*,sumsq/n
end program main

In this modified version of the program, the sum function is used to compute the sum of the squares of the elements of the array x that are greater than 0.6. This is done using the mask argument, which is a logical expression that specifies the elements of the array that should be included in the sum. In this case, the logical expression (x > 0.6) generates an array of logical values, which is then used as the mask to include only the elements of x**2 that are greater than 0.6 in the sum.

1 Like

Opening a new session and repeating the question, now it gives a wrong answer followed (without any further prompts) by a right answer. The transcript is below. So it has learned that Fortran functions can return arrays but has forgotten that they don’t return multiple results or that they are not invoked with call. ChatGPT is ingenious, but it can confidently give wrong answers. Ideally, when presenting code for language X, it would try to compile that code using a free compiler.

How do I return multiple values from a Fortran function?

In Fortran, you can return multiple values from a function using the RESULT statement. The RESULT statement specifies the name of the function and the values that the function should return. Here is an example of a function that returns two values:

FUNCTION add_and_multiply(x, y) RESULT(sum, product)
    IMPLICIT NONE
    INTEGER, INTENT(IN) :: x, y
    INTEGER :: sum, product

    sum = x + y
    product = x * y
END FUNCTION add_and_multiply

You can then call this function and assign the returned values to variables like this:

INTEGER :: a, b, c, d
a = 1
b = 2
CALL add_and_multiply(a, b, c, d)

Alternatively, you can return multiple values from a function using an array as the result. For example:

FUNCTION add_and_multiply(x, y) RESULT(result)
    IMPLICIT NONE
    INTEGER, INTENT(IN) :: x, y
    INTEGER, DIMENSION(2) :: result

    result(1) = x + y
    result(2) = x * y
END FUNCTION add_and_multiply

You can then call this function and assign the returned values to variables like this:

INTEGER, DIMENSION(2) :: result
result = add_and_multiply(a, b)
sum = result(1)
product = result(2)

Interesting. It learned the new correct answer, but has not realized the initial answer was wrong, but considers them alternatives. Hard to give up old habits even if you are a machine, apparently.

Of course, maybe it is just rewriting a new standard for Fortran.

I wonder what it thinks are the most requested features lacking in Fortran. Perhaps it could write proposals for them.

Not sure it could not do it. Considering some of the things it has done, I had to wonder if @certik was kidding or not when he said it finished writing Lfortran :wink:

Anyone asked it to prove the Riemann hypothesis yet?

1 Like

The answer of ChatGPT is largely incorrect but must reflect the data it was trained on:

What are the most requested features lacking in Fortran 2018?

It’s difficult to determine what the most requested features lacking in Fortran 2018 are, as different users may have different needs and priorities. However, some common areas where Fortran users may desire additional features or improvements in Fortran 2018 (or later versions) include:

  1. Object-oriented programming: Fortran does not have native support for object-oriented programming (OOP), although some OOP features can be emulated using module procedures and derived types. Some users may desire more robust OOP support in Fortran.
  2. Interoperability with other languages: Fortran is not as widely used as some other programming languages, and as a result, it may be difficult to interoperate with code written in other languages. Improved interoperability with languages such as C, Python, and Java could make it easier for Fortran users to integrate their code with a wider range of tools and libraries.
  3. Support for modern programming paradigms: Fortran is a relatively old language, and as such, it may not support some of the more modern programming paradigms and techniques that are used in newer languages. Users may desire additional support for concepts such as functional programming and concurrent programming in Fortran.
  4. Improved support for parallelism: Fortran has had support for parallel programming for some time, but it may be difficult for some users to use these features effectively. Improved support for parallelism, including features such as OpenMP, could make it easier for Fortran users to take advantage of multi-core and multi-processor systems.
  5. Improved support for modern hardware and software platforms: Fortran may not have the best support for newer hardware and software platforms, such as GPUs and cloud computing environments. Improved support for these platforms could make it easier for Fortran users to take advantage of the latest technologies.

ETA – it is odd that ChatGPT can answer with misinformation but immediately change its answer when you correct it. Continuing the conversation above:

In some ways your answer is incorrect regarding Fortran 2018. Support for OOP, including single inheritance, was added in the Fortran 2003 standard, as was a protocol for interoperating with C. The Fortran 2008 standard added support for parallel programming through coarrays. From Fortran 95 on you can designate procedures as PURE, a concept of functional programming.

I apologize for any misinformation that I provided in my previous response. You are correct that Fortran has added support for certain features that were previously lacking in previous versions of the language. Fortran 2003 added support for object-oriented programming and interoperability with C, and Fortran 2008 added support for parallel programming through coarrays. In addition, Fortran 95 introduced the concept of pure procedures, which allows for functional programming in the language.

It’s important to note that while Fortran has added support for these features over the years, they may still not be as robust or fully-featured as in other programming languages. Some users may still desire additional support or improvements in these areas in order to make it easier to use Fortran for certain types of programming tasks.

1 Like

Like a lot of the world it seems to be talking about FORTRAN, not Fortran. Maybe that reflects its main source of reference accurately (assumed the www). You didn’t have the shift key locked on, did you? I could be reading too much into it, but that certainly sounds like conversations I have had. As old as FORTRAN, there is the sage expression “garbage in, garbage out”. So far I would rate that as the worst response chatGPT has generated out of those posted. A good reality check for how well it’s answers can be depended on. It mimicked your response like it was the only reference it had for modern features :>. Thanks for the info.

Really odd seeing a machine apologize, and then act so human (refusing to admit it was wrong).

2 Likes