Problem with Fortran substring comparison of different length












2














I am reading stdin in a loop and do some comparaison with a bunch of "if" to decide what to do according to the input.



Here is a shortened snippet of the code :



CHARACTER (len= :), allocatable :: input
CHARACTER (len=4096) :: inbuffer ! frustrating but... well, fortran :3

DO

! get input
READ(*, '(a)') inbuffer ! because apparently you can't have allocation on read so you can't just read "input". meh.
input = TRIM(inbuffer)
CALL debug_log(input)

IF(input .EQ. 'uci') THEN
CALL debug_log(" printing uci info")

!isready
ELSE IF(input .EQ. 'isready') THEN
CALL debug_log(" isready -> readyok")
WRITE(*, '(a)') "readyok"

!ucinewgame
ELSE IF(input .EQ. 'ucinewgame') THEN
CALL debug_log("not implemented : reset board and start a new game")

!position
ELSE IF(input(1:8) .EQ. 'position') THEN
CALL debug_log("not implemented : set position")

!quit -> exit main loop
ELSE IF(input .EQ. 'quit') THEN
CALL debug_log(" quit command issued, exiting main loop")
EXIT

!non uci command
!nothing yet

!unknown command
ELSE
CALL debug_log(" ignoring invalid command")
END IF

end do


The input will expect command like "position 123 23415 etc..."



If I type "posi" it's say it's an invalid command as expected.



If I type "position" it say it's not implemented as expected too.



However:




  • If I type "position": I get not implemented

  • Followed by "posi": it says "not implemented" instead of "invalid command"


My guess is that it read 8 character even if the input is only 4 and since the previous command was "position" it make posi + tion = position



Here is some log to demonstrate:



** opening debug file : 20181111 / 223418.127
223418.127 : Initializing Fortiche engine
223418.129 : Entering main loop
223420.859 : posi
223420.859 : ignoring invalid command
223426.467 : xxxxtion
223426.467 : ignoring invalid command
223430.498 : posi
223430.498 : not implemented : set position
223437.323 : xxxxxxxxx
223437.323 : ignoring invalid command
223439.418 : posi
223439.418 : ignoring invalid command
223443.979 : position
223443.979 : not implemented : set position
223447.122 : quit
223447.122 : quit command issued, exiting main loop
223447.122 : closing, bye


xxxxtion + posi = position



Which is clearly wrong but I can understand how it ended up like this.



Should I use something other than .EQ.?
When I print the input it clearly doesn't print the input + whatever garbage was left behind in memory. But it's doing it when comparing string of possibly different length.



What can I do to solve this problem?



I'm not even started with the hardcore parsing and I already have a problem.



I'm using GNU Fortran on Windows.



Yes, it's UCI stuff as Universal Chess Interface.



EDIT : Full source code : https://github.com/ker2x/fortiche (comment the dirty hack at line 107 & 108 to reproduce the problem)










share|improve this question




















  • 1




    It would be good to have a compilable mcve we could try ourselves. This stuff should work and it is not that hard. I wrote a simple Scheme interpretter in Fortran, even parsing can be done. Please try to use capital letters when writing questions and answers here.
    – Vladimir F
    Nov 11 at 22:37


















2














I am reading stdin in a loop and do some comparaison with a bunch of "if" to decide what to do according to the input.



Here is a shortened snippet of the code :



CHARACTER (len= :), allocatable :: input
CHARACTER (len=4096) :: inbuffer ! frustrating but... well, fortran :3

DO

! get input
READ(*, '(a)') inbuffer ! because apparently you can't have allocation on read so you can't just read "input". meh.
input = TRIM(inbuffer)
CALL debug_log(input)

IF(input .EQ. 'uci') THEN
CALL debug_log(" printing uci info")

!isready
ELSE IF(input .EQ. 'isready') THEN
CALL debug_log(" isready -> readyok")
WRITE(*, '(a)') "readyok"

!ucinewgame
ELSE IF(input .EQ. 'ucinewgame') THEN
CALL debug_log("not implemented : reset board and start a new game")

!position
ELSE IF(input(1:8) .EQ. 'position') THEN
CALL debug_log("not implemented : set position")

!quit -> exit main loop
ELSE IF(input .EQ. 'quit') THEN
CALL debug_log(" quit command issued, exiting main loop")
EXIT

!non uci command
!nothing yet

!unknown command
ELSE
CALL debug_log(" ignoring invalid command")
END IF

end do


The input will expect command like "position 123 23415 etc..."



If I type "posi" it's say it's an invalid command as expected.



If I type "position" it say it's not implemented as expected too.



However:




  • If I type "position": I get not implemented

  • Followed by "posi": it says "not implemented" instead of "invalid command"


My guess is that it read 8 character even if the input is only 4 and since the previous command was "position" it make posi + tion = position



Here is some log to demonstrate:



** opening debug file : 20181111 / 223418.127
223418.127 : Initializing Fortiche engine
223418.129 : Entering main loop
223420.859 : posi
223420.859 : ignoring invalid command
223426.467 : xxxxtion
223426.467 : ignoring invalid command
223430.498 : posi
223430.498 : not implemented : set position
223437.323 : xxxxxxxxx
223437.323 : ignoring invalid command
223439.418 : posi
223439.418 : ignoring invalid command
223443.979 : position
223443.979 : not implemented : set position
223447.122 : quit
223447.122 : quit command issued, exiting main loop
223447.122 : closing, bye


xxxxtion + posi = position



Which is clearly wrong but I can understand how it ended up like this.



Should I use something other than .EQ.?
When I print the input it clearly doesn't print the input + whatever garbage was left behind in memory. But it's doing it when comparing string of possibly different length.



What can I do to solve this problem?



I'm not even started with the hardcore parsing and I already have a problem.



I'm using GNU Fortran on Windows.



Yes, it's UCI stuff as Universal Chess Interface.



EDIT : Full source code : https://github.com/ker2x/fortiche (comment the dirty hack at line 107 & 108 to reproduce the problem)










share|improve this question




















  • 1




    It would be good to have a compilable mcve we could try ourselves. This stuff should work and it is not that hard. I wrote a simple Scheme interpretter in Fortran, even parsing can be done. Please try to use capital letters when writing questions and answers here.
    – Vladimir F
    Nov 11 at 22:37
















2












2








2


1





I am reading stdin in a loop and do some comparaison with a bunch of "if" to decide what to do according to the input.



Here is a shortened snippet of the code :



CHARACTER (len= :), allocatable :: input
CHARACTER (len=4096) :: inbuffer ! frustrating but... well, fortran :3

DO

! get input
READ(*, '(a)') inbuffer ! because apparently you can't have allocation on read so you can't just read "input". meh.
input = TRIM(inbuffer)
CALL debug_log(input)

IF(input .EQ. 'uci') THEN
CALL debug_log(" printing uci info")

!isready
ELSE IF(input .EQ. 'isready') THEN
CALL debug_log(" isready -> readyok")
WRITE(*, '(a)') "readyok"

!ucinewgame
ELSE IF(input .EQ. 'ucinewgame') THEN
CALL debug_log("not implemented : reset board and start a new game")

!position
ELSE IF(input(1:8) .EQ. 'position') THEN
CALL debug_log("not implemented : set position")

!quit -> exit main loop
ELSE IF(input .EQ. 'quit') THEN
CALL debug_log(" quit command issued, exiting main loop")
EXIT

!non uci command
!nothing yet

!unknown command
ELSE
CALL debug_log(" ignoring invalid command")
END IF

end do


The input will expect command like "position 123 23415 etc..."



If I type "posi" it's say it's an invalid command as expected.



If I type "position" it say it's not implemented as expected too.



However:




  • If I type "position": I get not implemented

  • Followed by "posi": it says "not implemented" instead of "invalid command"


My guess is that it read 8 character even if the input is only 4 and since the previous command was "position" it make posi + tion = position



Here is some log to demonstrate:



** opening debug file : 20181111 / 223418.127
223418.127 : Initializing Fortiche engine
223418.129 : Entering main loop
223420.859 : posi
223420.859 : ignoring invalid command
223426.467 : xxxxtion
223426.467 : ignoring invalid command
223430.498 : posi
223430.498 : not implemented : set position
223437.323 : xxxxxxxxx
223437.323 : ignoring invalid command
223439.418 : posi
223439.418 : ignoring invalid command
223443.979 : position
223443.979 : not implemented : set position
223447.122 : quit
223447.122 : quit command issued, exiting main loop
223447.122 : closing, bye


xxxxtion + posi = position



Which is clearly wrong but I can understand how it ended up like this.



Should I use something other than .EQ.?
When I print the input it clearly doesn't print the input + whatever garbage was left behind in memory. But it's doing it when comparing string of possibly different length.



What can I do to solve this problem?



I'm not even started with the hardcore parsing and I already have a problem.



I'm using GNU Fortran on Windows.



Yes, it's UCI stuff as Universal Chess Interface.



EDIT : Full source code : https://github.com/ker2x/fortiche (comment the dirty hack at line 107 & 108 to reproduce the problem)










share|improve this question















I am reading stdin in a loop and do some comparaison with a bunch of "if" to decide what to do according to the input.



Here is a shortened snippet of the code :



CHARACTER (len= :), allocatable :: input
CHARACTER (len=4096) :: inbuffer ! frustrating but... well, fortran :3

DO

! get input
READ(*, '(a)') inbuffer ! because apparently you can't have allocation on read so you can't just read "input". meh.
input = TRIM(inbuffer)
CALL debug_log(input)

IF(input .EQ. 'uci') THEN
CALL debug_log(" printing uci info")

!isready
ELSE IF(input .EQ. 'isready') THEN
CALL debug_log(" isready -> readyok")
WRITE(*, '(a)') "readyok"

!ucinewgame
ELSE IF(input .EQ. 'ucinewgame') THEN
CALL debug_log("not implemented : reset board and start a new game")

!position
ELSE IF(input(1:8) .EQ. 'position') THEN
CALL debug_log("not implemented : set position")

!quit -> exit main loop
ELSE IF(input .EQ. 'quit') THEN
CALL debug_log(" quit command issued, exiting main loop")
EXIT

!non uci command
!nothing yet

!unknown command
ELSE
CALL debug_log(" ignoring invalid command")
END IF

end do


The input will expect command like "position 123 23415 etc..."



If I type "posi" it's say it's an invalid command as expected.



If I type "position" it say it's not implemented as expected too.



However:




  • If I type "position": I get not implemented

  • Followed by "posi": it says "not implemented" instead of "invalid command"


My guess is that it read 8 character even if the input is only 4 and since the previous command was "position" it make posi + tion = position



Here is some log to demonstrate:



** opening debug file : 20181111 / 223418.127
223418.127 : Initializing Fortiche engine
223418.129 : Entering main loop
223420.859 : posi
223420.859 : ignoring invalid command
223426.467 : xxxxtion
223426.467 : ignoring invalid command
223430.498 : posi
223430.498 : not implemented : set position
223437.323 : xxxxxxxxx
223437.323 : ignoring invalid command
223439.418 : posi
223439.418 : ignoring invalid command
223443.979 : position
223443.979 : not implemented : set position
223447.122 : quit
223447.122 : quit command issued, exiting main loop
223447.122 : closing, bye


xxxxtion + posi = position



Which is clearly wrong but I can understand how it ended up like this.



Should I use something other than .EQ.?
When I print the input it clearly doesn't print the input + whatever garbage was left behind in memory. But it's doing it when comparing string of possibly different length.



What can I do to solve this problem?



I'm not even started with the hardcore parsing and I already have a problem.



I'm using GNU Fortran on Windows.



Yes, it's UCI stuff as Universal Chess Interface.



EDIT : Full source code : https://github.com/ker2x/fortiche (comment the dirty hack at line 107 & 108 to reproduce the problem)







fortran gfortran






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 10:21

























asked Nov 11 at 21:49









ker2x

13718




13718








  • 1




    It would be good to have a compilable mcve we could try ourselves. This stuff should work and it is not that hard. I wrote a simple Scheme interpretter in Fortran, even parsing can be done. Please try to use capital letters when writing questions and answers here.
    – Vladimir F
    Nov 11 at 22:37
















  • 1




    It would be good to have a compilable mcve we could try ourselves. This stuff should work and it is not that hard. I wrote a simple Scheme interpretter in Fortran, even parsing can be done. Please try to use capital letters when writing questions and answers here.
    – Vladimir F
    Nov 11 at 22:37










1




1




It would be good to have a compilable mcve we could try ourselves. This stuff should work and it is not that hard. I wrote a simple Scheme interpretter in Fortran, even parsing can be done. Please try to use capital letters when writing questions and answers here.
– Vladimir F
Nov 11 at 22:37






It would be good to have a compilable mcve we could try ourselves. This stuff should work and it is not that hard. I wrote a simple Scheme interpretter in Fortran, even parsing can be done. Please try to use capital letters when writing questions and answers here.
– Vladimir F
Nov 11 at 22:37














1 Answer
1






active

oldest

votes


















4














Substring references need to have starting and ending positions that are within the limits of the string.



You don't defend against a string that has a length less than eight prior to the substring reference input(1:8) .eq. 'position'.



With input shorter than eight characters, your program is non-conforming, anything can then happen, where anything very reasonably includes the behaviour you see.



Runtime debugging options may help to catch this programming error, depending on the capabilities of your compiler.






share|improve this answer

















  • 1




    Oh, missed the TRIM duing my quick look. Here a compilable code would definitely help.
    – Vladimir F
    Nov 12 at 7:03












  • @VladimirF i edited my post with a link to the full compilable source code github.com/ker2x/fortiche
    – ker2x
    Nov 12 at 10:22










  • i added stuff at line 107 and 108 to temporary solve the problem but it's a dirty hack. comment them to reproduce the problem.
    – ker2x
    Nov 12 at 10:25






  • 1




    The comparison is not the issue, it is the substring. What's best depends on what you want to do, but consider something like input(1:min(len(input),8)), which you might factor out into its own function.
    – IanH
    Nov 12 at 19:37






  • 1




    Two notes/recommendations: Fortran's trim() function is more properly rtrim() in any other language (trims trailing spaces only). adjustl() shifts the string left which appends leading spaces to the end of the string so it's the same length as the original; trim(adjustl(inbuffer)) implements a proper trim function, removing both leading and trailing spaces. Similarly, you can use len_trim(audjustl(inbuffer)) to get the length of the (properly) trimmed string. Second, consider using Fortran's select/case construct instead of cascaded if/then/elseif for clarity.
    – arclight
    Nov 12 at 23:23











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253590%2fproblem-with-fortran-substring-comparison-of-different-length%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Substring references need to have starting and ending positions that are within the limits of the string.



You don't defend against a string that has a length less than eight prior to the substring reference input(1:8) .eq. 'position'.



With input shorter than eight characters, your program is non-conforming, anything can then happen, where anything very reasonably includes the behaviour you see.



Runtime debugging options may help to catch this programming error, depending on the capabilities of your compiler.






share|improve this answer

















  • 1




    Oh, missed the TRIM duing my quick look. Here a compilable code would definitely help.
    – Vladimir F
    Nov 12 at 7:03












  • @VladimirF i edited my post with a link to the full compilable source code github.com/ker2x/fortiche
    – ker2x
    Nov 12 at 10:22










  • i added stuff at line 107 and 108 to temporary solve the problem but it's a dirty hack. comment them to reproduce the problem.
    – ker2x
    Nov 12 at 10:25






  • 1




    The comparison is not the issue, it is the substring. What's best depends on what you want to do, but consider something like input(1:min(len(input),8)), which you might factor out into its own function.
    – IanH
    Nov 12 at 19:37






  • 1




    Two notes/recommendations: Fortran's trim() function is more properly rtrim() in any other language (trims trailing spaces only). adjustl() shifts the string left which appends leading spaces to the end of the string so it's the same length as the original; trim(adjustl(inbuffer)) implements a proper trim function, removing both leading and trailing spaces. Similarly, you can use len_trim(audjustl(inbuffer)) to get the length of the (properly) trimmed string. Second, consider using Fortran's select/case construct instead of cascaded if/then/elseif for clarity.
    – arclight
    Nov 12 at 23:23
















4














Substring references need to have starting and ending positions that are within the limits of the string.



You don't defend against a string that has a length less than eight prior to the substring reference input(1:8) .eq. 'position'.



With input shorter than eight characters, your program is non-conforming, anything can then happen, where anything very reasonably includes the behaviour you see.



Runtime debugging options may help to catch this programming error, depending on the capabilities of your compiler.






share|improve this answer

















  • 1




    Oh, missed the TRIM duing my quick look. Here a compilable code would definitely help.
    – Vladimir F
    Nov 12 at 7:03












  • @VladimirF i edited my post with a link to the full compilable source code github.com/ker2x/fortiche
    – ker2x
    Nov 12 at 10:22










  • i added stuff at line 107 and 108 to temporary solve the problem but it's a dirty hack. comment them to reproduce the problem.
    – ker2x
    Nov 12 at 10:25






  • 1




    The comparison is not the issue, it is the substring. What's best depends on what you want to do, but consider something like input(1:min(len(input),8)), which you might factor out into its own function.
    – IanH
    Nov 12 at 19:37






  • 1




    Two notes/recommendations: Fortran's trim() function is more properly rtrim() in any other language (trims trailing spaces only). adjustl() shifts the string left which appends leading spaces to the end of the string so it's the same length as the original; trim(adjustl(inbuffer)) implements a proper trim function, removing both leading and trailing spaces. Similarly, you can use len_trim(audjustl(inbuffer)) to get the length of the (properly) trimmed string. Second, consider using Fortran's select/case construct instead of cascaded if/then/elseif for clarity.
    – arclight
    Nov 12 at 23:23














4












4








4






Substring references need to have starting and ending positions that are within the limits of the string.



You don't defend against a string that has a length less than eight prior to the substring reference input(1:8) .eq. 'position'.



With input shorter than eight characters, your program is non-conforming, anything can then happen, where anything very reasonably includes the behaviour you see.



Runtime debugging options may help to catch this programming error, depending on the capabilities of your compiler.






share|improve this answer












Substring references need to have starting and ending positions that are within the limits of the string.



You don't defend against a string that has a length less than eight prior to the substring reference input(1:8) .eq. 'position'.



With input shorter than eight characters, your program is non-conforming, anything can then happen, where anything very reasonably includes the behaviour you see.



Runtime debugging options may help to catch this programming error, depending on the capabilities of your compiler.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 22:46









IanH

17.1k22244




17.1k22244








  • 1




    Oh, missed the TRIM duing my quick look. Here a compilable code would definitely help.
    – Vladimir F
    Nov 12 at 7:03












  • @VladimirF i edited my post with a link to the full compilable source code github.com/ker2x/fortiche
    – ker2x
    Nov 12 at 10:22










  • i added stuff at line 107 and 108 to temporary solve the problem but it's a dirty hack. comment them to reproduce the problem.
    – ker2x
    Nov 12 at 10:25






  • 1




    The comparison is not the issue, it is the substring. What's best depends on what you want to do, but consider something like input(1:min(len(input),8)), which you might factor out into its own function.
    – IanH
    Nov 12 at 19:37






  • 1




    Two notes/recommendations: Fortran's trim() function is more properly rtrim() in any other language (trims trailing spaces only). adjustl() shifts the string left which appends leading spaces to the end of the string so it's the same length as the original; trim(adjustl(inbuffer)) implements a proper trim function, removing both leading and trailing spaces. Similarly, you can use len_trim(audjustl(inbuffer)) to get the length of the (properly) trimmed string. Second, consider using Fortran's select/case construct instead of cascaded if/then/elseif for clarity.
    – arclight
    Nov 12 at 23:23














  • 1




    Oh, missed the TRIM duing my quick look. Here a compilable code would definitely help.
    – Vladimir F
    Nov 12 at 7:03












  • @VladimirF i edited my post with a link to the full compilable source code github.com/ker2x/fortiche
    – ker2x
    Nov 12 at 10:22










  • i added stuff at line 107 and 108 to temporary solve the problem but it's a dirty hack. comment them to reproduce the problem.
    – ker2x
    Nov 12 at 10:25






  • 1




    The comparison is not the issue, it is the substring. What's best depends on what you want to do, but consider something like input(1:min(len(input),8)), which you might factor out into its own function.
    – IanH
    Nov 12 at 19:37






  • 1




    Two notes/recommendations: Fortran's trim() function is more properly rtrim() in any other language (trims trailing spaces only). adjustl() shifts the string left which appends leading spaces to the end of the string so it's the same length as the original; trim(adjustl(inbuffer)) implements a proper trim function, removing both leading and trailing spaces. Similarly, you can use len_trim(audjustl(inbuffer)) to get the length of the (properly) trimmed string. Second, consider using Fortran's select/case construct instead of cascaded if/then/elseif for clarity.
    – arclight
    Nov 12 at 23:23








1




1




Oh, missed the TRIM duing my quick look. Here a compilable code would definitely help.
– Vladimir F
Nov 12 at 7:03






Oh, missed the TRIM duing my quick look. Here a compilable code would definitely help.
– Vladimir F
Nov 12 at 7:03














@VladimirF i edited my post with a link to the full compilable source code github.com/ker2x/fortiche
– ker2x
Nov 12 at 10:22




@VladimirF i edited my post with a link to the full compilable source code github.com/ker2x/fortiche
– ker2x
Nov 12 at 10:22












i added stuff at line 107 and 108 to temporary solve the problem but it's a dirty hack. comment them to reproduce the problem.
– ker2x
Nov 12 at 10:25




i added stuff at line 107 and 108 to temporary solve the problem but it's a dirty hack. comment them to reproduce the problem.
– ker2x
Nov 12 at 10:25




1




1




The comparison is not the issue, it is the substring. What's best depends on what you want to do, but consider something like input(1:min(len(input),8)), which you might factor out into its own function.
– IanH
Nov 12 at 19:37




The comparison is not the issue, it is the substring. What's best depends on what you want to do, but consider something like input(1:min(len(input),8)), which you might factor out into its own function.
– IanH
Nov 12 at 19:37




1




1




Two notes/recommendations: Fortran's trim() function is more properly rtrim() in any other language (trims trailing spaces only). adjustl() shifts the string left which appends leading spaces to the end of the string so it's the same length as the original; trim(adjustl(inbuffer)) implements a proper trim function, removing both leading and trailing spaces. Similarly, you can use len_trim(audjustl(inbuffer)) to get the length of the (properly) trimmed string. Second, consider using Fortran's select/case construct instead of cascaded if/then/elseif for clarity.
– arclight
Nov 12 at 23:23




Two notes/recommendations: Fortran's trim() function is more properly rtrim() in any other language (trims trailing spaces only). adjustl() shifts the string left which appends leading spaces to the end of the string so it's the same length as the original; trim(adjustl(inbuffer)) implements a proper trim function, removing both leading and trailing spaces. Similarly, you can use len_trim(audjustl(inbuffer)) to get the length of the (properly) trimmed string. Second, consider using Fortran's select/case construct instead of cascaded if/then/elseif for clarity.
– arclight
Nov 12 at 23:23


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253590%2fproblem-with-fortran-substring-comparison-of-different-length%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

Bicuculline

さくらももこ