Read substrings from a string containing multiplication [duplicate]












2
















This question already has an answer here:




  • '*' and '/' not recognized on input by a read statement

    2 answers




I am a scientist programming in Fortran, and I came up with a strange behaviour. In one of my programs I have a string containing several "words", and I want to read all words as substrings. The first word starts with an integer and a wildcard, like "2*something".



When I perform an internal read on that string, I expect to read all wods, but instead, the READ function repeatedly reads the first substring. I do not understand why, nor how to avoid this behaviour.



Below is a minimalist sample program that reproduces this behaviour. I would expect it to read the three substrings and to print "3*a b c" on the screen. Instead, I get "a a a".



What am I doing wrong? Can you please help me and explain what is going on?



I am compiling my programs under GNU/Linux x64 with Gfortran 7.3 (7.3.0-27ubuntu1~18.04).



PROGRAM testread

IMPLICIT NONE
CHARACTER(LEN=1024):: string
CHARACTER(LEN=16):: v1, v2, v3

string="3*a b c"

READ(string,*) v1, v2, v3

PRINT*, v1, v2, v3

END PROGRAM testread









share|improve this question















marked as duplicate by francescalus fortran
Users with the  fortran badge can single-handedly close fortran questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 21 at 21:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





migrated from superuser.com Jan 21 at 15:58


This question came from our site for computer enthusiasts and power users.



















  • Steve gave you the answer of why you are getting the results you observe. You might consider using the index intrinsic function to split string into substrings. You can do something like n = index(string, ' '); v1 = string(1:n-1). I'll leave to you to figure out how to get the other substrings.

    – evets
    Jan 21 at 18:02


















2
















This question already has an answer here:




  • '*' and '/' not recognized on input by a read statement

    2 answers




I am a scientist programming in Fortran, and I came up with a strange behaviour. In one of my programs I have a string containing several "words", and I want to read all words as substrings. The first word starts with an integer and a wildcard, like "2*something".



When I perform an internal read on that string, I expect to read all wods, but instead, the READ function repeatedly reads the first substring. I do not understand why, nor how to avoid this behaviour.



Below is a minimalist sample program that reproduces this behaviour. I would expect it to read the three substrings and to print "3*a b c" on the screen. Instead, I get "a a a".



What am I doing wrong? Can you please help me and explain what is going on?



I am compiling my programs under GNU/Linux x64 with Gfortran 7.3 (7.3.0-27ubuntu1~18.04).



PROGRAM testread

IMPLICIT NONE
CHARACTER(LEN=1024):: string
CHARACTER(LEN=16):: v1, v2, v3

string="3*a b c"

READ(string,*) v1, v2, v3

PRINT*, v1, v2, v3

END PROGRAM testread









share|improve this question















marked as duplicate by francescalus fortran
Users with the  fortran badge can single-handedly close fortran questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 21 at 21:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





migrated from superuser.com Jan 21 at 15:58


This question came from our site for computer enthusiasts and power users.



















  • Steve gave you the answer of why you are getting the results you observe. You might consider using the index intrinsic function to split string into substrings. You can do something like n = index(string, ' '); v1 = string(1:n-1). I'll leave to you to figure out how to get the other substrings.

    – evets
    Jan 21 at 18:02
















2












2








2









This question already has an answer here:




  • '*' and '/' not recognized on input by a read statement

    2 answers




I am a scientist programming in Fortran, and I came up with a strange behaviour. In one of my programs I have a string containing several "words", and I want to read all words as substrings. The first word starts with an integer and a wildcard, like "2*something".



When I perform an internal read on that string, I expect to read all wods, but instead, the READ function repeatedly reads the first substring. I do not understand why, nor how to avoid this behaviour.



Below is a minimalist sample program that reproduces this behaviour. I would expect it to read the three substrings and to print "3*a b c" on the screen. Instead, I get "a a a".



What am I doing wrong? Can you please help me and explain what is going on?



I am compiling my programs under GNU/Linux x64 with Gfortran 7.3 (7.3.0-27ubuntu1~18.04).



PROGRAM testread

IMPLICIT NONE
CHARACTER(LEN=1024):: string
CHARACTER(LEN=16):: v1, v2, v3

string="3*a b c"

READ(string,*) v1, v2, v3

PRINT*, v1, v2, v3

END PROGRAM testread









share|improve this question

















This question already has an answer here:




  • '*' and '/' not recognized on input by a read statement

    2 answers




I am a scientist programming in Fortran, and I came up with a strange behaviour. In one of my programs I have a string containing several "words", and I want to read all words as substrings. The first word starts with an integer and a wildcard, like "2*something".



When I perform an internal read on that string, I expect to read all wods, but instead, the READ function repeatedly reads the first substring. I do not understand why, nor how to avoid this behaviour.



Below is a minimalist sample program that reproduces this behaviour. I would expect it to read the three substrings and to print "3*a b c" on the screen. Instead, I get "a a a".



What am I doing wrong? Can you please help me and explain what is going on?



I am compiling my programs under GNU/Linux x64 with Gfortran 7.3 (7.3.0-27ubuntu1~18.04).



PROGRAM testread

IMPLICIT NONE
CHARACTER(LEN=1024):: string
CHARACTER(LEN=16):: v1, v2, v3

string="3*a b c"

READ(string,*) v1, v2, v3

PRINT*, v1, v2, v3

END PROGRAM testread




This question already has an answer here:




  • '*' and '/' not recognized on input by a read statement

    2 answers








string fortran gfortran






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 21 at 17:57









Steve Lionel

3,738925




3,738925










asked Jan 21 at 14:48









Konrad-3559Konrad-3559

111




111




marked as duplicate by francescalus fortran
Users with the  fortran badge can single-handedly close fortran questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 21 at 21:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





migrated from superuser.com Jan 21 at 15:58


This question came from our site for computer enthusiasts and power users.









marked as duplicate by francescalus fortran
Users with the  fortran badge can single-handedly close fortran questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 21 at 21:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





migrated from superuser.com Jan 21 at 15:58


This question came from our site for computer enthusiasts and power users.















  • Steve gave you the answer of why you are getting the results you observe. You might consider using the index intrinsic function to split string into substrings. You can do something like n = index(string, ' '); v1 = string(1:n-1). I'll leave to you to figure out how to get the other substrings.

    – evets
    Jan 21 at 18:02





















  • Steve gave you the answer of why you are getting the results you observe. You might consider using the index intrinsic function to split string into substrings. You can do something like n = index(string, ' '); v1 = string(1:n-1). I'll leave to you to figure out how to get the other substrings.

    – evets
    Jan 21 at 18:02



















Steve gave you the answer of why you are getting the results you observe. You might consider using the index intrinsic function to split string into substrings. You can do something like n = index(string, ' '); v1 = string(1:n-1). I'll leave to you to figure out how to get the other substrings.

– evets
Jan 21 at 18:02







Steve gave you the answer of why you are getting the results you observe. You might consider using the index intrinsic function to split string into substrings. You can do something like n = index(string, ' '); v1 = string(1:n-1). I'll leave to you to figure out how to get the other substrings.

– evets
Jan 21 at 18:02














2 Answers
2






active

oldest

votes


















4














You are using list-directed input (the * format specifier). In list-directed input, a number (n) followed by an asterisk means "repeat this item n times", so it is processed as if the input was a a a b c. You would need to have as input '3*a' b c to get what you want.



I will use this as another opportunity to point out that list-directed I/O is sometimes the wrong choice as its inherent flexibility may not be what you want. That it has rules for things like repeat counts, null values, and undelimited strings is often a surprise to programmers. I also often see programmers complaining that list-directed input did not give an error when expected, because the compiler had an extension or the programmer didn't understand just how liberal the feature can be.



I suggest you pick up a Fortran language reference and carefully read the section on list-directed I/O. You may find you need to use an explicit format or change your program's expectations.






share|improve this answer


























  • Thank you very much, that explains my problem. Since I don't know the length of substrings, I cannot use a formatted read. I will embedd each substring into single quotes as a workaround.

    – Konrad-3559
    Jan 22 at 18:19





















2














Following the answer of @SteveLionel, here is the relevant part of the reference on list-directed sequential READ statements (in this case, for Intel Fortran, but you could find it for your specific compiler and it won't be much different).




A character string does not need delimiting apostrophes or quotation marks if the corresponding I/O list item is of type default character, and the following is true:



The character string does not contain a blank, comma (,), or slash ( / ).



The character string is not continued across a record boundary.



The first nonblank character in the string is not an apostrophe or a quotation mark.



The leading character is not a string of digits followed by an asterisk.



A nondelimited character string is terminated by the first blank, comma, slash, or end-of-record encountered. Apostrophes and quotation marks within nondelimited character strings are transferred as is.




In total, there are 4 forms of sequential read statements in Fortran, and you may choose the option that best fits your need:





  1. Formatted Sequential Read:



    To use this you change the * to an actual format specifier. If you know the length of the strings at advance, this would be as easy as '(a3,a2,a2)'. Or, you could come with a format specifier that matches your data, but this generally demands you knowing the length or format of stuff.




  2. Formatted Sequential List-Directed:



    You are currently using this option (the * format descriptor). As we already showed you, this kind of I/O comes with a lot of magic and surprising behavior. What is hitting you is the n*cte thing, that is interpreted as n repetitions of cte literal.
    As said by Steve Lionel, you could put quotation marks around the problematic word, so it will be parsed as one-piece. Or, as proposed by @evets, you could split or break your string using the intrinsics index or scan. Another option could be changing your wildcard from asterisk to anything else.




  3. Formatted Namelist:



    Well, that could be an option if your data was (or could be) presented in the namelist format, but I really think it's not your case.




  4. Unformatted:



    This may not apply to your case because you are reading from a character variable, and an internal READ statement can only be formatted.




Otherwise, you could split your string by means of a function instead of a I/O operation. There is no intrinsic for this, but you could come with one without much trouble (see this thread for reference). As you may have noted already, manipulating strings in fortran is... awkward, at least. There are some libraries out there (like this) that may be useful if you are doing lots of string stuff in Fortran.






share|improve this answer






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    You are using list-directed input (the * format specifier). In list-directed input, a number (n) followed by an asterisk means "repeat this item n times", so it is processed as if the input was a a a b c. You would need to have as input '3*a' b c to get what you want.



    I will use this as another opportunity to point out that list-directed I/O is sometimes the wrong choice as its inherent flexibility may not be what you want. That it has rules for things like repeat counts, null values, and undelimited strings is often a surprise to programmers. I also often see programmers complaining that list-directed input did not give an error when expected, because the compiler had an extension or the programmer didn't understand just how liberal the feature can be.



    I suggest you pick up a Fortran language reference and carefully read the section on list-directed I/O. You may find you need to use an explicit format or change your program's expectations.






    share|improve this answer


























    • Thank you very much, that explains my problem. Since I don't know the length of substrings, I cannot use a formatted read. I will embedd each substring into single quotes as a workaround.

      – Konrad-3559
      Jan 22 at 18:19


















    4














    You are using list-directed input (the * format specifier). In list-directed input, a number (n) followed by an asterisk means "repeat this item n times", so it is processed as if the input was a a a b c. You would need to have as input '3*a' b c to get what you want.



    I will use this as another opportunity to point out that list-directed I/O is sometimes the wrong choice as its inherent flexibility may not be what you want. That it has rules for things like repeat counts, null values, and undelimited strings is often a surprise to programmers. I also often see programmers complaining that list-directed input did not give an error when expected, because the compiler had an extension or the programmer didn't understand just how liberal the feature can be.



    I suggest you pick up a Fortran language reference and carefully read the section on list-directed I/O. You may find you need to use an explicit format or change your program's expectations.






    share|improve this answer


























    • Thank you very much, that explains my problem. Since I don't know the length of substrings, I cannot use a formatted read. I will embedd each substring into single quotes as a workaround.

      – Konrad-3559
      Jan 22 at 18:19
















    4












    4








    4







    You are using list-directed input (the * format specifier). In list-directed input, a number (n) followed by an asterisk means "repeat this item n times", so it is processed as if the input was a a a b c. You would need to have as input '3*a' b c to get what you want.



    I will use this as another opportunity to point out that list-directed I/O is sometimes the wrong choice as its inherent flexibility may not be what you want. That it has rules for things like repeat counts, null values, and undelimited strings is often a surprise to programmers. I also often see programmers complaining that list-directed input did not give an error when expected, because the compiler had an extension or the programmer didn't understand just how liberal the feature can be.



    I suggest you pick up a Fortran language reference and carefully read the section on list-directed I/O. You may find you need to use an explicit format or change your program's expectations.






    share|improve this answer















    You are using list-directed input (the * format specifier). In list-directed input, a number (n) followed by an asterisk means "repeat this item n times", so it is processed as if the input was a a a b c. You would need to have as input '3*a' b c to get what you want.



    I will use this as another opportunity to point out that list-directed I/O is sometimes the wrong choice as its inherent flexibility may not be what you want. That it has rules for things like repeat counts, null values, and undelimited strings is often a surprise to programmers. I also often see programmers complaining that list-directed input did not give an error when expected, because the compiler had an extension or the programmer didn't understand just how liberal the feature can be.



    I suggest you pick up a Fortran language reference and carefully read the section on list-directed I/O. You may find you need to use an explicit format or change your program's expectations.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 21 at 17:59

























    answered Jan 21 at 17:53









    Steve LionelSteve Lionel

    3,738925




    3,738925













    • Thank you very much, that explains my problem. Since I don't know the length of substrings, I cannot use a formatted read. I will embedd each substring into single quotes as a workaround.

      – Konrad-3559
      Jan 22 at 18:19





















    • Thank you very much, that explains my problem. Since I don't know the length of substrings, I cannot use a formatted read. I will embedd each substring into single quotes as a workaround.

      – Konrad-3559
      Jan 22 at 18:19



















    Thank you very much, that explains my problem. Since I don't know the length of substrings, I cannot use a formatted read. I will embedd each substring into single quotes as a workaround.

    – Konrad-3559
    Jan 22 at 18:19







    Thank you very much, that explains my problem. Since I don't know the length of substrings, I cannot use a formatted read. I will embedd each substring into single quotes as a workaround.

    – Konrad-3559
    Jan 22 at 18:19















    2














    Following the answer of @SteveLionel, here is the relevant part of the reference on list-directed sequential READ statements (in this case, for Intel Fortran, but you could find it for your specific compiler and it won't be much different).




    A character string does not need delimiting apostrophes or quotation marks if the corresponding I/O list item is of type default character, and the following is true:



    The character string does not contain a blank, comma (,), or slash ( / ).



    The character string is not continued across a record boundary.



    The first nonblank character in the string is not an apostrophe or a quotation mark.



    The leading character is not a string of digits followed by an asterisk.



    A nondelimited character string is terminated by the first blank, comma, slash, or end-of-record encountered. Apostrophes and quotation marks within nondelimited character strings are transferred as is.




    In total, there are 4 forms of sequential read statements in Fortran, and you may choose the option that best fits your need:





    1. Formatted Sequential Read:



      To use this you change the * to an actual format specifier. If you know the length of the strings at advance, this would be as easy as '(a3,a2,a2)'. Or, you could come with a format specifier that matches your data, but this generally demands you knowing the length or format of stuff.




    2. Formatted Sequential List-Directed:



      You are currently using this option (the * format descriptor). As we already showed you, this kind of I/O comes with a lot of magic and surprising behavior. What is hitting you is the n*cte thing, that is interpreted as n repetitions of cte literal.
      As said by Steve Lionel, you could put quotation marks around the problematic word, so it will be parsed as one-piece. Or, as proposed by @evets, you could split or break your string using the intrinsics index or scan. Another option could be changing your wildcard from asterisk to anything else.




    3. Formatted Namelist:



      Well, that could be an option if your data was (or could be) presented in the namelist format, but I really think it's not your case.




    4. Unformatted:



      This may not apply to your case because you are reading from a character variable, and an internal READ statement can only be formatted.




    Otherwise, you could split your string by means of a function instead of a I/O operation. There is no intrinsic for this, but you could come with one without much trouble (see this thread for reference). As you may have noted already, manipulating strings in fortran is... awkward, at least. There are some libraries out there (like this) that may be useful if you are doing lots of string stuff in Fortran.






    share|improve this answer




























      2














      Following the answer of @SteveLionel, here is the relevant part of the reference on list-directed sequential READ statements (in this case, for Intel Fortran, but you could find it for your specific compiler and it won't be much different).




      A character string does not need delimiting apostrophes or quotation marks if the corresponding I/O list item is of type default character, and the following is true:



      The character string does not contain a blank, comma (,), or slash ( / ).



      The character string is not continued across a record boundary.



      The first nonblank character in the string is not an apostrophe or a quotation mark.



      The leading character is not a string of digits followed by an asterisk.



      A nondelimited character string is terminated by the first blank, comma, slash, or end-of-record encountered. Apostrophes and quotation marks within nondelimited character strings are transferred as is.




      In total, there are 4 forms of sequential read statements in Fortran, and you may choose the option that best fits your need:





      1. Formatted Sequential Read:



        To use this you change the * to an actual format specifier. If you know the length of the strings at advance, this would be as easy as '(a3,a2,a2)'. Or, you could come with a format specifier that matches your data, but this generally demands you knowing the length or format of stuff.




      2. Formatted Sequential List-Directed:



        You are currently using this option (the * format descriptor). As we already showed you, this kind of I/O comes with a lot of magic and surprising behavior. What is hitting you is the n*cte thing, that is interpreted as n repetitions of cte literal.
        As said by Steve Lionel, you could put quotation marks around the problematic word, so it will be parsed as one-piece. Or, as proposed by @evets, you could split or break your string using the intrinsics index or scan. Another option could be changing your wildcard from asterisk to anything else.




      3. Formatted Namelist:



        Well, that could be an option if your data was (or could be) presented in the namelist format, but I really think it's not your case.




      4. Unformatted:



        This may not apply to your case because you are reading from a character variable, and an internal READ statement can only be formatted.




      Otherwise, you could split your string by means of a function instead of a I/O operation. There is no intrinsic for this, but you could come with one without much trouble (see this thread for reference). As you may have noted already, manipulating strings in fortran is... awkward, at least. There are some libraries out there (like this) that may be useful if you are doing lots of string stuff in Fortran.






      share|improve this answer


























        2












        2








        2







        Following the answer of @SteveLionel, here is the relevant part of the reference on list-directed sequential READ statements (in this case, for Intel Fortran, but you could find it for your specific compiler and it won't be much different).




        A character string does not need delimiting apostrophes or quotation marks if the corresponding I/O list item is of type default character, and the following is true:



        The character string does not contain a blank, comma (,), or slash ( / ).



        The character string is not continued across a record boundary.



        The first nonblank character in the string is not an apostrophe or a quotation mark.



        The leading character is not a string of digits followed by an asterisk.



        A nondelimited character string is terminated by the first blank, comma, slash, or end-of-record encountered. Apostrophes and quotation marks within nondelimited character strings are transferred as is.




        In total, there are 4 forms of sequential read statements in Fortran, and you may choose the option that best fits your need:





        1. Formatted Sequential Read:



          To use this you change the * to an actual format specifier. If you know the length of the strings at advance, this would be as easy as '(a3,a2,a2)'. Or, you could come with a format specifier that matches your data, but this generally demands you knowing the length or format of stuff.




        2. Formatted Sequential List-Directed:



          You are currently using this option (the * format descriptor). As we already showed you, this kind of I/O comes with a lot of magic and surprising behavior. What is hitting you is the n*cte thing, that is interpreted as n repetitions of cte literal.
          As said by Steve Lionel, you could put quotation marks around the problematic word, so it will be parsed as one-piece. Or, as proposed by @evets, you could split or break your string using the intrinsics index or scan. Another option could be changing your wildcard from asterisk to anything else.




        3. Formatted Namelist:



          Well, that could be an option if your data was (or could be) presented in the namelist format, but I really think it's not your case.




        4. Unformatted:



          This may not apply to your case because you are reading from a character variable, and an internal READ statement can only be formatted.




        Otherwise, you could split your string by means of a function instead of a I/O operation. There is no intrinsic for this, but you could come with one without much trouble (see this thread for reference). As you may have noted already, manipulating strings in fortran is... awkward, at least. There are some libraries out there (like this) that may be useful if you are doing lots of string stuff in Fortran.






        share|improve this answer













        Following the answer of @SteveLionel, here is the relevant part of the reference on list-directed sequential READ statements (in this case, for Intel Fortran, but you could find it for your specific compiler and it won't be much different).




        A character string does not need delimiting apostrophes or quotation marks if the corresponding I/O list item is of type default character, and the following is true:



        The character string does not contain a blank, comma (,), or slash ( / ).



        The character string is not continued across a record boundary.



        The first nonblank character in the string is not an apostrophe or a quotation mark.



        The leading character is not a string of digits followed by an asterisk.



        A nondelimited character string is terminated by the first blank, comma, slash, or end-of-record encountered. Apostrophes and quotation marks within nondelimited character strings are transferred as is.




        In total, there are 4 forms of sequential read statements in Fortran, and you may choose the option that best fits your need:





        1. Formatted Sequential Read:



          To use this you change the * to an actual format specifier. If you know the length of the strings at advance, this would be as easy as '(a3,a2,a2)'. Or, you could come with a format specifier that matches your data, but this generally demands you knowing the length or format of stuff.




        2. Formatted Sequential List-Directed:



          You are currently using this option (the * format descriptor). As we already showed you, this kind of I/O comes with a lot of magic and surprising behavior. What is hitting you is the n*cte thing, that is interpreted as n repetitions of cte literal.
          As said by Steve Lionel, you could put quotation marks around the problematic word, so it will be parsed as one-piece. Or, as proposed by @evets, you could split or break your string using the intrinsics index or scan. Another option could be changing your wildcard from asterisk to anything else.




        3. Formatted Namelist:



          Well, that could be an option if your data was (or could be) presented in the namelist format, but I really think it's not your case.




        4. Unformatted:



          This may not apply to your case because you are reading from a character variable, and an internal READ statement can only be formatted.




        Otherwise, you could split your string by means of a function instead of a I/O operation. There is no intrinsic for this, but you could come with one without much trouble (see this thread for reference). As you may have noted already, manipulating strings in fortran is... awkward, at least. There are some libraries out there (like this) that may be useful if you are doing lots of string stuff in Fortran.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 21 at 19:33









        Rodrigo RodriguesRodrigo Rodrigues

        3,1221721




        3,1221721















            Popular posts from this blog

            How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

            is 'sed' thread safe

            How to make a Squid Proxy server?