• Fortran application not writing output to one of the .out files

    From Sushant Mehan@21:1/5 to All on Tue Nov 8 10:28:36 2022
    Hi All,

    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue

    Blocks of Code where file was introduced and initiated. There are 300+ fortran files in the project. That's why using only a few blocks if thats helpful
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file with name "instreamP.out is produced with headers, but there is no data in it.

    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.

    Thanks,
    Sushant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jfh@21:1/5 to sushan...@gmail.com on Tue Nov 8 12:54:04 2022
    On Wednesday, November 9, 2022 at 7:28:39 AM UTC+13, sushan...@gmail.com wrote:
    Hi All,

    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue

    Blocks of Code where file was introduced and initiated. There are 300+ fortran files in the project. That's why using only a few blocks if thats helpful
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file with name "instreamP.out is produced with headers, but there is no data in it.

    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.

    Thanks,
    Sushant

    Is the program in fixed or free source form? The * in the two last lines are valid only in fixed source form but the format statement makes me wonder. Are the ends of lines in what you posted (where format 12224 occupies 3 lines) at the ends of lines in
    the actual program? What is format 78 and how were the things written with it declared and evaluated? We could possibly give useful help if provided with a minimal complete program, together with any error messages and warnings it gave at compile time
    and run time. What compiler was used?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to sushan...@gmail.com on Tue Nov 8 14:24:47 2022
    On Tuesday, November 8, 2022 at 10:28:39 AM UTC-8, sushan...@gmail.com wrote:

    (snip)

    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file
    with name "instreamP.out is produced with headers, but there is no data in it.

    Without non-advancing I/O, which yours doesn't have, the least a Fortran WRITE statement can write is a blank line.

    As noted previously, showing the FORMAT statement number 78 would be nice.

    But, most likely, your program isn't exectuting this WRITE statement.

    Easy test is to put a

    STOP 78

    statement after the WRITE statement.

    (The 78 is a reminder of where it stopped.)

    That also guarantees that the output buffer is written out.

    If the STOP 78 statement is not executed, you know it didn't get there.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robin Vowels@21:1/5 to sushan...@gmail.com on Tue Nov 8 18:06:08 2022
    On Wednesday, November 9, 2022 at 5:28:39 AM UTC+11, sushan...@gmail.com wrote:
    Hi All,

    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue

    Blocks of Code where file was introduced and initiated. There are 300+ fortran files in the project. That's why using only a few blocks if thats helpful
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully,

    No it didn't.

    and I ran the project, and my output file with name "instreamP.out is produced with headers, but there is no data in it.

    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.

    You need to show the FORMAT statement 78.
    It would seem that the second WRITE statement is never executed.
    Insert a simple PRINT statement (e,.g., PRINT *, 'GOT HERE')
    just before the second WRITE.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sushant Mehan@21:1/5 to jfh on Tue Nov 8 20:04:00 2022
    On Tuesday, November 8, 2022 at 2:54:06 PM UTC-6, jfh wrote:
    On Wednesday, November 9, 2022 at 7:28:39 AM UTC+13, sushan...@gmail.com wrote:
    Hi All,

    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue

    Blocks of Code where file was introduced and initiated. There are 300+ fortran files in the project. That's why using only a few blocks if thats helpful
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file with name "instreamP.out is produced with headers, but there is no data in it.

    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.

    Thanks,
    Sushant
    Is the program in fixed or free source form? The * in the two last lines are valid only in fixed source form but the format statement makes me wonder. Are the ends of lines in what you posted (where format 12224 occupies 3 lines) at the ends of lines
    in the actual program? What is format 78 and how were the things written with it declared and evaluated? We could possibly give useful help if provided with a minimal complete program, together with any error messages and warnings it gave at compile time
    and run time. What compiler was used?

    That's the problem. I am not getting any error messages. Apologies for my ignorance. I am not aware if the program is fixed or free. Since it is open source, so many people use it, and the convention changes from time to time. Unfortunately, there is no
    option here to link the *.f files else I Would have shared the program.

    But I will try it now by being more detailed
    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)

    The other chunk is
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    These are the only two blocks where the code was called, and no other place it was mentioned. Note: I changed 78 to 79 because 78 was used in another file of the same project.

    I am sorry I want to be more detailed with my problem. If this won't work, I will put my code on google drive and share the link.

    Kindest regards,
    Sushant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sushant Mehan@21:1/5 to All on Tue Nov 8 20:07:58 2022
    On Tuesday, November 8, 2022 at 4:24:50 PM UTC-6, gah4 wrote:
    On Tuesday, November 8, 2022 at 10:28:39 AM UTC-8, sushan...@gmail.com wrote:

    (snip)
    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file with name "instreamP.out is produced with headers, but there is no data in it.
    Without non-advancing I/O, which yours doesn't have, the least a Fortran WRITE
    statement can write is a blank line.

    As noted previously, showing the FORMAT statement number 78 would be nice.

    But, most likely, your program isn't exectuting this WRITE statement.

    Easy test is to put a

    STOP 78

    statement after the WRITE statement.

    (The 78 is a reminder of where it stopped.)

    That also guarantees that the output buffer is written out.

    If the STOP 78 statement is not executed, you know it didn't get there.

    Hi Gah,

    I think you were right. 78 was called in another file of the project. I replaced my 78 with 79 and tried running the project. Again, no error while compiling but the application is still not writing data to the "instreamP.out" file

    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)

    The other chunk is
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    Any recommendations?

    Kindest regards,
    Sushant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sushant Mehan@21:1/5 to Robin Vowels on Tue Nov 8 20:05:44 2022
    On Tuesday, November 8, 2022 at 8:06:10 PM UTC-6, Robin Vowels wrote:
    On Wednesday, November 9, 2022 at 5:28:39 AM UTC+11, sushan...@gmail.com wrote:
    Hi All,

    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue

    Blocks of Code where file was introduced and initiated. There are 300+ fortran files in the project. That's why using only a few blocks if thats helpful
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully,
    No it didn't.
    and I ran the project, and my output file with name "instreamP.out is produced with headers, but there is no data in it.

    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.
    You need to show the FORMAT statement 78.
    It would seem that the second WRITE statement is never executed.
    Insert a simple PRINT statement (e,.g., PRINT *, 'GOT HERE')
    just before the second WRITE.

    Robin,

    It seems you picked something. I saw that format 78 was called in other file. So I made 78 to 79 in my code and called it as follows:
    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)

    The other chunk is
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    Any more suggestions?

    Kindest regards,
    Sushant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to sushan...@gmail.com on Tue Nov 8 20:58:18 2022
    On Tuesday, November 8, 2022 at 8:04:02 PM UTC-8, sushan...@gmail.com wrote:

    (snip)

    That's the problem. I am not getting any error messages.
    Apologies for my ignorance. I am not aware if the program is fixed or free. Since it is open source, so many people use it, and the convention changes from time to time. Unfortunately, there is no option here to link the *.f files else
    I Would have shared the program.

    *.f files usually mean fixed form.

    Statements have to start in column 7 (or more), with blanks or statement
    number before that. But posting software likes to remove blanks at
    the beginning of lines.

    But I will try it now by being more detailed
    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)

    (snip)

    These are the only two blocks where the code was called, and no other place it was mentioned. Note: I changed 78 to 79 because 78 was used in another file of the same project.

    Statement numbers only need to be unique within the same subroutine,
    function or main program. In most cases, that is within one file.

    I am sorry I want to be more detailed with my problem
    If this won't work, I will put my code on google drive and share the link.

    Seems to be some version of SWAT:

    https://swat.tamu.edu/software/archive/

    If you say which one, we can download it from the original source.

    Though it seems that they supply already compiled versions.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Koenig@21:1/5 to Sushant Mehan on Wed Nov 9 06:39:56 2022
    Sushant Mehan <sushantmehan@gmail.com> schrieb:
    On Tuesday, November 8, 2022 at 4:24:50 PM UTC-6, gah4 wrote:
    On Tuesday, November 8, 2022 at 10:28:39 AM UTC-8, sushan...@gmail.com wrote:

    (snip)
    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file >> > with name "instreamP.out is produced with headers, but there is no data in it.
    Without non-advancing I/O, which yours doesn't have, the least a Fortran WRITE
    statement can write is a blank line.

    As noted previously, showing the FORMAT statement number 78 would be nice. >>
    But, most likely, your program isn't exectuting this WRITE statement.

    Easy test is to put a

    STOP 78

    statement after the WRITE statement.

    (The 78 is a reminder of where it stopped.)

    That also guarantees that the output buffer is written out.

    If the STOP 78 statement is not executed, you know it didn't get there.

    Hi Gah,

    I think you were right. 78 was called in another file of the project. I replaced my 78 with 79 and tried running the project. Again, no error while compiling but the application is still not writing data to the "instreamP.out" file

    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)

    The other chunk is
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    Any recommendations?

    Which system and which compiler are you running?

    Is file 178 already open? In this case, calling open just modifies
    the existing connection (which can be confusing). What happens
    if you put a close(178) in front of the open?

    What happens if you put a

    flush 178

    after each write? There was a bug in a version of Darwin which
    impacted gfortran so that it did not flush files at program end.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robin Vowels@21:1/5 to sushan...@gmail.com on Wed Nov 9 02:17:00 2022
    On Wednesday, November 9, 2022 at 3:04:02 PM UTC+11, sushan...@gmail.com wrote:
    On Tuesday, November 8, 2022 at 2:54:06 PM UTC-6, jfh wrote:
    On Wednesday, November 9, 2022 at 7:28:39 AM UTC+13, sushan...@gmail.com wrote:
    Hi All,

    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue

    Blocks of Code where file was introduced and initiated. There are 300+ fortran files in the project. That's why using only a few blocks if thats helpful
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file with name "instreamP.out is produced with headers, but there is no data in it.

    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.

    Thanks,
    Sushant
    Is the program in fixed or free source form? The * in the two last lines are valid only in fixed source form but the format statement makes me wonder. Are the ends of lines in what you posted (where format 12224 occupies 3 lines) at the ends of lines
    in the actual program? What is format 78 and how were the things written with it declared and evaluated? We could possibly give useful help if provided with a minimal complete program, together with any error messages and warnings it gave at compile time
    and run time. What compiler was used?
    That's the problem. I am not getting any error messages. Apologies for my ignorance. I am not aware if the program is fixed or free. Since it is open source, so many people use it, and the convention changes from time to time. Unfortunately, there is
    no option here to link the *.f files else I Would have shared the program.

    But I will try it now by being more detailed
    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)

    The other chunk is
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')
    These are the only two blocks where the code was called, and no other place it was mentioned. Note: I changed 78 to 79 because 78 was used in another file of the same project.
    .
    The OPEN statement must be executed before the WRITE (178 .. statement.
    If it is not, the output will be written to another file, possibly called FOR178.
    .
    I suggested inserting a simple PRINT statement, just before the WRITE statement.
    You need to do this, in order to find out whether the WRITE statement is being executed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From FortranFan@21:1/5 to sushan...@gmail.com on Wed Nov 9 06:04:23 2022
    On Tuesday, November 8, 2022 at 1:28:39 PM UTC-5, sushan...@gmail.com wrote:
    ..
    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue
    ..
    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.


    Hello @sushan...@gmail.com,

    You may also want to inquire at the relatively recent Fortran Discourse site where you can attach Fortran source code with your posts, provide links, include code snippets with syntax highlighting, etc.
    https://fortran-lang.discourse.group/

    Re: learning Fortran, please see this page at fortran-lang.org that provides links to a lot of resources:
    https://fortran-lang.discourse.group/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sushant Mehan@21:1/5 to FortranFan on Wed Nov 9 08:38:40 2022
    On Wednesday, November 9, 2022 at 8:04:25 AM UTC-6, FortranFan wrote:
    On Tuesday, November 8, 2022 at 1:28:39 PM UTC-5, sushan...@gmail.com wrote:
    ..
    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue
    ..
    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.

    Hello @sushan...@gmail.com,

    You may also want to inquire at the relatively recent Fortran Discourse site where you can attach Fortran source code with your posts, provide links, include code snippets with syntax highlighting, etc.
    https://fortran-lang.discourse.group/

    Re: learning Fortran, please see this page at fortran-lang.org that provides links to a lot of resources:
    https://fortran-lang.discourse.group/
    I appreciate the link to the sources. Thanks!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sushant Mehan@21:1/5 to All on Wed Nov 9 08:28:48 2022
    On Tuesday, November 8, 2022 at 10:58:20 PM UTC-6, gah4 wrote:
    On Tuesday, November 8, 2022 at 8:04:02 PM UTC-8, sushan...@gmail.com wrote:

    (snip)
    That's the problem. I am not getting any error messages.
    Apologies for my ignorance. I am not aware if the program is fixed or free. Since it is open source, so many people use it, and the convention changes from time to time. Unfortunately, there is no option here to link the *.f files else
    I Would have shared the program.
    *.f files usually mean fixed form.

    Statements have to start in column 7 (or more), with blanks or statement number before that. But posting software likes to remove blanks at
    the beginning of lines.
    But I will try it now by being more detailed
    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)
    (snip)
    These are the only two blocks where the code was called, and no other place it was mentioned. Note: I changed 78 to 79 because 78 was used in another file of the same project.
    Statement numbers only need to be unique within the same subroutine,
    function or main program. In most cases, that is within one file.
    I am sorry I want to be more detailed with my problem
    If this won't work, I will put my code on google drive and share the link.
    Seems to be some version of SWAT:

    https://swat.tamu.edu/software/archive/

    If you say which one, we can download it from the original source.

    Though it seems that they supply already compiled versions.
    Hi Gah,

    The version I am working on is not public. You can access the code files from here https://drive.google.com/file/d/1fvXani_-iwfwcaabzFEFoFffaLKOZTY5/view?usp=share_link
    The snips I shared were from file readfile.f (L 153- 155) and watqual3.f (L764-768). Since this project's source code files are customized, I must compile them every time I run the project.

    Hope this helps to answer my issue of not writing the data to the output file.

    Thanks,
    Sushant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sushant Mehan@21:1/5 to Thomas Koenig on Wed Nov 9 08:33:20 2022
    On Wednesday, November 9, 2022 at 12:40:00 AM UTC-6, Thomas Koenig wrote:
    Sushant Mehan <sushan...@gmail.com> schrieb:
    On Tuesday, November 8, 2022 at 4:24:50 PM UTC-6, gah4 wrote:
    On Tuesday, November 8, 2022 at 10:28:39 AM UTC-8, sushan...@gmail.com wrote:

    (snip)
    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file
    with name "instreamP.out is produced with headers, but there is no data in it.
    Without non-advancing I/O, which yours doesn't have, the least a Fortran WRITE
    statement can write is a blank line.

    As noted previously, showing the FORMAT statement number 78 would be nice. >>
    But, most likely, your program isn't exectuting this WRITE statement.

    Easy test is to put a

    STOP 78

    statement after the WRITE statement.

    (The 78 is a reminder of where it stopped.)

    That also guarantees that the output buffer is written out.

    If the STOP 78 statement is not executed, you know it didn't get there.

    Hi Gah,

    I think you were right. 78 was called in another file of the project. I replaced my 78 with 79 and tried running the project. Again, no error while compiling but the application is still not writing data to the "instreamP.out" file

    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)

    The other chunk is
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    Any recommendations?
    Which system and which compiler are you running?

    Is file 178 already open? In this case, calling open just modifies
    the existing connection (which can be confusing). What happens
    if you put a close(178) in front of the open?

    What happens if you put a

    flush 178

    after each write? There was a bug in a version of Darwin which
    impacted gfortran so that it did not flush files at program end.

    Thanks, Thomas, for your response. Greatly appreciated. I am compiling code using CodeBlocks 20.3 on Windows 10 machine. and compiler is gfortran. I do not think the 178 is open already.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sushant Mehan@21:1/5 to Robin Vowels on Wed Nov 9 08:41:02 2022
    On Wednesday, November 9, 2022 at 4:17:02 AM UTC-6, Robin Vowels wrote:
    On Wednesday, November 9, 2022 at 3:04:02 PM UTC+11, sushan...@gmail.com wrote:
    On Tuesday, November 8, 2022 at 2:54:06 PM UTC-6, jfh wrote:
    On Wednesday, November 9, 2022 at 7:28:39 AM UTC+13, sushan...@gmail.com wrote:
    Hi All,

    I am beginners in FORTRAN and dealing with huge FORTRAN project. I apologize in the beginning if my question sounded lame. Here is the issue

    Blocks of Code where file was introduced and initiated. There are 300+ fortran files in the project. That's why using only a few blocks if thats helpful
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')

    write (178,78) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux

    The code executed successfully, and I ran the project, and my output file with name "instreamP.out is produced with headers, but there is no data in it.

    I would appreciate any help in this matter. Also, I would appreciate any guidance on learning FORTRAN.

    Thanks,
    Sushant
    Is the program in fixed or free source form? The * in the two last lines are valid only in fixed source form but the format statement makes me wonder. Are the ends of lines in what you posted (where format 12224 occupies 3 lines) at the ends of
    lines in the actual program? What is format 78 and how were the things written with it declared and evaluated? We could possibly give useful help if provided with a minimal complete program, together with any error messages and warnings it gave at
    compile time and run time. What compiler was used?
    That's the problem. I am not getting any error messages. Apologies for my ignorance. I am not aware if the program is fixed or free. Since it is open source, so many people use it, and the convention changes from time to time. Unfortunately, there is
    no option here to link the *.f files else I Would have shared the program.

    But I will try it now by being more detailed
    This is one chunk of code in one file
    write (178,79) curyr,iida,jrch,flow,solpcon,dsolp,orgpcon,dorgp,
    * epc,sedp_benthos(jrch),solp_benp_flux, orgp_benp_flux,
    * solp_orgp_flux
    !! end if
    79 format(3i4,10f12.3)

    The other chunk is
    open (178,file="instreamP.out")
    write (178,12224)
    12224 format ('Year Day Rch flow solp-in solp-out orgp
    -in orgp-out EPC benp solp_benp orgp_benp so
    lp_orgp ')
    These are the only two blocks where the code was called, and no other place it was mentioned. Note: I changed 78 to 79 because 78 was used in another file of the same project.
    .
    The OPEN statement must be executed before the WRITE (178 .. statement.
    If it is not, the output will be written to another file, possibly called FOR178.
    .
    I suggested inserting a simple PRINT statement, just before the WRITE statement.
    You need to do this, in order to find out whether the WRITE statement is being executed.

    This is a great suggestion. I will try this right now and will share how it goes.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Van Buskirk@21:1/5 to All on Wed Nov 9 14:10:19 2022
    "FortranFan" wrote in message news:3f6ce8bd-d99c-4150-a0af-b1099741883fn@googlegroups.com...

    You may also want to inquire at the relatively recent Fortran
    Discourse site where you can attach Fortran source code with
    your posts, provide links, include code snippets with syntax
    highlighting, etc.
    https://fortran-lang.discourse.group/

    Why are you always trying to move users of this group to
    that Fortran discourse group? I took a look at it and a couple
    of threads I noticed was one where apparently the speed of
    the sieve of Eratosthenes was compared with a C++
    implementation, but there was no code visible on the
    forum so you couldn't identify the mistakes in the Fortran
    code. I wrote a sieve at one time that was pretty fast for
    sizes less than about 1.0e12 and maybe posted it here
    but I don't have time and energy right now to search for
    it.
    Another thread was an inquiry that amounted to being
    about procedures with the BIND attribute. I have been
    working on code what needs to pop up OpenGL windows
    to display graphics, so it needs to do stuff like ask the OS
    to initiate a new thread (_beginthreadex), establish thread
    local storage, and set up an OpenGL canvas. OpenGL itself
    needs to be called. How you are supposed to achieve all
    this without the interface capabilities introduced in f2003
    is beyond me, but you wouldn't have a hint of this from
    reading the thread.
    To me, the forum is overall disappointing.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From FortranFan@21:1/5 to James Van Buskirk on Wed Nov 9 15:10:45 2022
    On Wednesday, November 9, 2022 at 4:11:40 PM UTC-5, James Van Buskirk wrote:
    "FortranFan" wrote in message

    news:3f6ce8bd-d99c-4150...@googlegroups.com...
    You may also want to inquire at the relatively recent Fortran
    Discourse site where you can attach Fortran source code with
    your posts, provide links, include code snippets with syntax
    highlighting, etc.
    https://fortran-lang.discourse.group/
    Why are you always trying to move users of this group to
    that Fortran discourse group? ..

    "You talkin' to me"?

    To me, the forum is overall disappointing.

    I think the Fortran Discourse is really a good place for all Fortran-related discussions. It is a very useful site generally and I think it is especially the case for anyone who shares about themselves as "I am beginners in FORTRAN" and "I would
    appreciate any guidance on learning FORTRAN"

    To each their own in terms which online groups they want to use. That's why I merely suggest the Fortran Discourse site to posters, as in "You may also want to inquire at the relatively recent Fortran Discourse site .." I expect the posters will note "
    may" and "also" and appreciate the obvious which is that it's entirely up to them, they can do as they wish .. hopefully they become aware there are more resources out there to help with Fortran.

    I will continue pointing out the Fortran Discourse site to whoever appears to be a new poster on Fortran-related matters.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)