LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What does it mean in GFortran? (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-it-mean-in-gfortran-4175528132/)

AlexBB 12-12-2014 08:16 PM

What does it mean in GFortran?
 
if [ $? -ne 0 ]; then. What does -ne mean? And why is there a semicolon inside? The expression seems to be from a command line argument. You can find a links for fftpack5_prb.sh in the middle of the page. Can anybody interpret it all. Thanks.

Ser Olmy 12-12-2014 08:39 PM

fftpack5_prb.sh is a shell script, not a program written in GFortran.

The -ne comparison operator means "not equal to". The semicolon after the closing bracket is part of the syntax for an if statement in most shells:
Code:

if [ condition ]; then statement(s) ; fi
The $? shell variable contains the exit code for the last command/executable that was run. An exit code of 0 indicates that the program/command completed without errors. In other words, the if statement seems to say: "if the previous program encountered an error and returned a non-zero exit code, do [whatever comes after then]".

AlexBB 12-13-2014 10:23 AM

Thanks. I thought it was a command line argument for a Fortran run main or something. Is it a command line written in shell script? If so where can I read about it?

suicidaleggroll 12-13-2014 10:29 AM

fftpack5_prb.sh is a bash script, indicated by both the filename extension and the "#!/bin/bash" at the top of the script.

Code:

if [ $? -ne 0 ]; then
  do something
fi

is standard bash syntax for checking the exit status of the previously-executed command. If the exit status is not 0, then it does something in response, usually printing an error and exiting.

AlexBB 12-13-2014 12:43 PM

suicidaleggroll, thank you. As always you are on top of the game!!!


All times are GMT -5. The time now is 09:36 PM.