Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran 77: Recording the output

  1. May 17, 2015 #1
    Hi,
    I am having a bit of trouble trying to record the output from my code and any help is highly appreciated.

    Attached is the code that needs to be looked into (changed extension to .txt from .f as PF wouldn't allow it) and a screenshot of output that I am trying to record.

    What I am trying to do is collate the XMIN (1), XMIN(5) and XMIN(9) together with C(1) output. Similarly, I need to do the same with XMAX and AMP outputs.

    I tried adding the FORMAT and WRITE statements towards the relevant section (now commented out) to do the needful, however there is still no record of it in any of the files propeq.dat, propeq.dat1 and integrate.csv as asked by Fortran to open when running the code.

    Please assist me.

    Thank you for taking your time!
     

    Attached Files:

  2. jcsd
  3. May 17, 2015 #2

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    It's not clear from the OP if these files:

    propeq.dat, propeq.dat1, integrate.csv

    exist before the program is run, or if they are data files to be accessed by the program for creation of other data.

    Since these files are assigned to logical units 1, 2, and 3, respectively, if you want to write any further data to them, then the WRITE statements in your code must use logical units 1, 2, or 3, depending on which file is supposed to receive the data. The WRITE statements presently in your code all use logical unit 6, which is usually reserved for a printer or terminal of some sort. If you change the logical unit numbers in your WRITE statements, you may get a different result.

    Remember, Fortran is not good at reading your mind about what you want a program to do. :rolleyes:
     
  4. May 17, 2015 #3
    I only see two WRITE statements in your program, one writes to unit 6 and the other to unit 3; so, if you intended to create files propeq.dat and propeq.dat1, they may be created because you issued an open command, but you never write anything to them...they will remain empty. If on the other hand, you intended to read data from these two files, well...you never read anything from them .
     
  5. May 17, 2015 #4
    Thank you very much for looking into my problem.

    Based on the suggestions, I modified the code such that the output is written in a new file called xmin.dat

    So, I modified the code as
    Code (Text):

          OPEN(1,file='propeq.dat')
          OPEN(2,file='propeq.dat1')
          OPEN(3,file='integrate.csv')
          OPEN(4,file='xmin.dat')
     
    The governing code for the output shown in the picture is has been modified as:
    Code (Text):

      11  FORMAT(E16.8,',',E16.8,',',E16.8)
          JOB    = 2
          JBIF   = 0
          NSTEP  = 20
          CALL PATH (FCN,JAC,N,IJAC,X,TPER,NP,INP,TP,TQ,LAMDA,
         *           JCASE,JOB,JBIF,ILAM,IER,W,IW)

          WRITE(4,11) C(1),XMIN(1),XMIN(5)
     
    However, that gives the output in xmin.dat as:

    Code (Text):

      0.63781250E+02,  0.00000000E+00,  0.00000000E+00
     
    It should have had varying C values for the first column and the equivalent XMIN(1) and XMIN(5) values. However, that is not the case?
     
  6. May 17, 2015 #5

    Mark44

    Staff: Mentor

    I'm looking only at the code you show above. In this code, the write statement executes once, printing c(1), xmin(1), and xmin(5). None of the lines above it that you show here modifies these arrays. If you expect different output, please show more of your code, especially whatever parts modify these arrays.
     
  7. May 17, 2015 #6

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Mark, check out the OP in this thread.

    An earlier version of the source code was posted there as a text file.
     
  8. May 17, 2015 #7

    Mark44

    Staff: Mentor

    @SteamKing, I realize that, but I didn't want to open that file and search through it. The OP posted some code in post #4, that seemed to be completely unrelated to the output he's getting. My hope was that the OP would post code that is relevant to the output he's getting.
     
  9. May 18, 2015 #8
    @Mark44
    The code below
    Code (Text):

    JOB    = 2
          JBIF   = 0
          NSTEP  = 20
          CALL PATH (FCN,JAC,N,IJAC,X,TPER,NP,INP,TP,TQ,LAMDA,
         *           JCASE,JOB,JBIF,ILAM,IER,W,IW)
     
    Gives the output (mentioned only the first 3 entries as PF wouldn't allow me to add all 20 entries:
    Code (Text):

    PATH  ==========================================================================================

                N         INP       JCASE         JOB        JBIF        ILAM        IJAC          IW
               14           1           2           2           0           1           2        4000


    ** ZPAR   **        EPSZ          HZ         ITZ       METHZ
                   0.1000D-08  0.1000D-04           8           1


    ** GPAR   **        EPSG          HG         ITG
                   0.1000D-03  0.5000D-03          50


    ** PPAR   **        HMIN          HP        HMAX      FACINC      FACDEC         ITP       NSTEP
                   0.1000D-06  0.5000D-03  0.5000D-01  0.2500D+01  0.6000D+00          10          20


    ** EQSOL  **        IODE         LRW         TOL
                            2        2800  0.1000D-09


    ** PMAPC  **        EPSR      DTMAXR         ITR
                   0.1000D-13  0.1000D-02       10000


    PATH    ===================================================================================

            ISTEP        NITZ       ITRED        NITG          HP
                0           0           0           0          0.5000D-03


                X=STATES,  C=PARAMETERS                  EIGENVALUES                  MODULUS
    X(  1) =  0.6687524863445813D-02    LAMDA(  1) = -0.3671D-03  0.0000D+00    0.3671D-03
    X(  2) =  0.1954059714457986D+00    LAMDA(  2) =  0.3735D-03  0.0000D+00    0.3735D-03
    X(  3) =  0.1203695377021602D-01    LAMDA(  3) =  0.2018D-01  0.0000D+00    0.2018D-01
    X(  4) =  0.1025813749659862D+00    LAMDA(  4) = -0.3096D-01  0.4640D-01    0.5578D-01
    X(  5) = -0.4038195425637118D-02    LAMDA(  5) = -0.3096D-01 -0.4640D-01    0.5578D-01
    X(  6) =  0.2553841690311452D-01    LAMDA(  6) = -0.2871D-01  0.5173D-01    0.5916D-01
    X(  7) =  0.1281271824733160D-01    LAMDA(  7) = -0.2871D-01 -0.5173D-01    0.5916D-01
    X(  8) =  0.1087363918469160D+00    LAMDA(  8) = -0.7998D-01 -0.1309D+00    0.1534D+00
    X(  9) = -0.4724621353657919D-02    LAMDA(  9) = -0.7998D-01  0.1309D+00    0.1534D+00
    X( 10) =  0.5775364220406498D-01    LAMDA( 10) = -0.2261D+00 -0.1068D+00    0.2500D+00
    X( 11) =  0.1029880034780272D-01    LAMDA( 11) = -0.2261D+00  0.1068D+00    0.2500D+00
    X( 12) =  0.8089218948932277D-01    LAMDA( 12) =  0.4084D+00  0.0000D+00    0.4084D+00
    X( 13) = -0.3538824581852046D-02    LAMDA( 13) =  0.5889D+00  0.0000D+00    0.5889D+00
          X( 14) =    0.4285991220217371D-01
    C(  1) =  0.6300000000000000D+02
    C(  2) =  0.1460000000000000D+08
          TPER  =    0.1351997893781867D+01    <---  PERIOD OF ORBIT


         TPER =  0.1352D+01      NPOINT =   401               DT =  0.3372D-02

    XMIN( 1) = -0.1120D-01    XMAX( 1) =  0.1121D-01    AMP( 1) =  0.2240D-01
    XMIN( 2) = -0.2167D+00    XMAX( 2) =  0.2166D+00    AMP( 2) =  0.4333D+00
    XMIN( 3) = -0.1619D-01    XMAX( 3) =  0.1619D-01    AMP( 3) =  0.3237D-01
    XMIN( 4) = -0.1558D+00    XMAX( 4) =  0.1558D+00    AMP( 4) =  0.3116D+00
    XMIN( 5) = -0.9914D-02    XMAX( 5) =  0.9912D-02    AMP( 5) =  0.1983D-01
    XMIN( 6) = -0.1315D+00    XMAX( 6) =  0.1315D+00    AMP( 6) =  0.2631D+00
    XMIN( 7) = -0.1720D-01    XMAX( 7) =  0.1720D-01    AMP( 7) =  0.3440D-01
    XMIN( 8) = -0.1642D+00    XMAX( 8) =  0.1642D+00    AMP( 8) =  0.3285D+00
    XMIN( 9) = -0.6371D-02    XMAX( 9) =  0.6371D-02    AMP( 9) =  0.1274D-01
    XMIN(10) = -0.8832D-01    XMAX(10) =  0.8832D-01    AMP(10) =  0.1766D+00
    XMIN(11) = -0.1358D-01    XMAX(11) =  0.1358D-01    AMP(11) =  0.2716D-01
    XMIN(12) = -0.1239D+00    XMAX(12) =  0.1239D+00    AMP(12) =  0.2477D+00
    XMIN(13) = -0.5982D-02    XMAX(13) =  0.5981D-02    AMP(13) =  0.1196D-01
    XMIN(14) = -0.6236D-01    XMAX(14) =  0.6236D-01    AMP(14) =  0.1247D+00


    PATH    ===================================================================================

            ISTEP        NITZ       ITRED        NITG          HP
                1           4           0           0          0.5000D-03


                X=STATES,  C=PARAMETERS                  EIGENVALUES                  MODULUS
    X(  1) =  0.6687624508476302D-02    LAMDA(  1) =  0.6567D-05  0.0000D+00    0.6567D-05
    X(  2) =  0.1954075038026926D+00    LAMDA(  2) = -0.1962D-04  0.0000D+00    0.1962D-04
    X(  3) =  0.1203707304415289D-01    LAMDA(  3) =  0.1479D-01  0.0000D+00    0.1479D-01
    X(  4) =  0.1025819787127586D+00    LAMDA(  4) = -0.3107D-01 -0.4674D-01    0.5613D-01
    X(  5) = -0.4038117439447632D-02    LAMDA(  5) = -0.3107D-01  0.4674D-01    0.5613D-01
    X(  6) =  0.2553922266867070D-01    LAMDA(  6) = -0.2881D-01  0.5158D-01    0.5908D-01
    X(  7) =  0.1281283998686409D-01    LAMDA(  7) = -0.2881D-01 -0.5158D-01    0.5908D-01
    X(  8) =  0.1087371048965056D+00    LAMDA(  8) = -0.8090D-01 -0.1308D+00    0.1538D+00
    X(  9) = -0.4724577549552899D-02    LAMDA(  9) = -0.8090D-01  0.1308D+00    0.1538D+00
    X( 10) =  0.5775419690450188D-01    LAMDA( 10) = -0.2261D+00 -0.1068D+00    0.2500D+00
    X( 11) =  0.1029889146596462D-01    LAMDA( 11) = -0.2261D+00  0.1068D+00    0.2500D+00
    X( 12) =  0.8089305167413362D-01    LAMDA( 12) =  0.4119D+00  0.0000D+00    0.4119D+00
    X( 13) = -0.3538816201506203D-02    LAMDA( 13) =  0.5892D+00  0.0000D+00    0.5892D+00
          X( 14) =    0.4286019559773140D-01
    C(  1) =  0.6300070710895386D+02
    C(  2) =  0.1460000000000000D+08
          TPER  =    0.1351994823535456D+01    <---  PERIOD OF ORBIT


         TPER =  0.1352D+01      NPOINT =   401               DT =  0.3372D-02

    XMIN( 1) = -0.1120D-01    XMAX( 1) =  0.1121D-01    AMP( 1) =  0.2240D-01
    XMIN( 2) = -0.2167D+00    XMAX( 2) =  0.2166D+00    AMP( 2) =  0.4333D+00
    XMIN( 3) = -0.1619D-01    XMAX( 3) =  0.1619D-01    AMP( 3) =  0.3237D-01
    XMIN( 4) = -0.1558D+00    XMAX( 4) =  0.1558D+00    AMP( 4) =  0.3116D+00
    XMIN( 5) = -0.9914D-02    XMAX( 5) =  0.9912D-02    AMP( 5) =  0.1983D-01
    XMIN( 6) = -0.1315D+00    XMAX( 6) =  0.1315D+00    AMP( 6) =  0.2631D+00
    XMIN( 7) = -0.1720D-01    XMAX( 7) =  0.1720D-01    AMP( 7) =  0.3440D-01
    XMIN( 8) = -0.1642D+00    XMAX( 8) =  0.1642D+00    AMP( 8) =  0.3285D+00
    XMIN( 9) = -0.6371D-02    XMAX( 9) =  0.6371D-02    AMP( 9) =  0.1274D-01
    XMIN(10) = -0.8832D-01    XMAX(10) =  0.8832D-01    AMP(10) =  0.1766D+00
    XMIN(11) = -0.1358D-01    XMAX(11) =  0.1358D-01    AMP(11) =  0.2716D-01
    XMIN(12) = -0.1239D+00    XMAX(12) =  0.1239D+00    AMP(12) =  0.2477D+00
    XMIN(13) = -0.5982D-02    XMAX(13) =  0.5982D-02    AMP(13) =  0.1196D-01
    XMIN(14) = -0.6236D-01    XMAX(14) =  0.6236D-01    AMP(14) =  0.1247D+00


          NORMAL OF POINCARE        TANGENT OF PATH           TANGENTVECTOR ACROSS
          NP(  1) =  0.6066D-01  ::  TP(  1) =  0.1409D-03  ::  TQ(  1) =  0.0000D+00
          NP(  2) =  0.5651D+00  ::  TP(  2) =  0.2167D-02  ::  TQ(  2) =  0.0000D+00
          NP(  3) =  0.3185D-01  ::  TP(  3) =  0.1687D-03  ::  TQ(  3) =  0.0000D+00
          NP(  4) = -0.3538D+00  ::  TP(  4) =  0.8538D-03  ::  TQ(  4) =  0.0000D+00
          NP(  5) =  0.7929D-02  ::  TP(  5) =  0.1103D-03  ::  TQ(  5) =  0.0000D+00
          NP(  6) = -0.4628D+00  ::  TP(  6) =  0.1140D-02  ::  TQ(  6) =  0.0000D+00
          NP(  7) =  0.3376D-01  ::  TP(  7) =  0.1722D-03  ::  TQ(  7) =  0.0000D+00
          NP(  8) = -0.3766D+00  ::  TP(  8) =  0.1008D-02  ::  TQ(  8) =  0.0000D+00
          NP(  9) =  0.1793D-01  ::  TP(  9) =  0.6195D-04  ::  TQ(  9) =  0.0000D+00
          NP( 10) =  0.3160D+00  ::  TP( 10) =  0.7845D-03  ::  TQ( 10) =  0.0000D+00
          NP( 11) =  0.2511D-01  ::  TP( 11) =  0.1289D-03  ::  TQ( 11) =  0.0000D+00
          NP( 12) = -0.2776D+00  ::  TP( 12) =  0.1219D-02  ::  TQ( 12) =  0.0000D+00
          NP( 13) =  0.1331D-01  ::  TP( 13) =  0.1185D-04  ::  TQ( 13) =  0.0000D+00
          NP( 14) =  0.1250D+00  ::  TP( 14) =  0.4008D-03  ::  TQ( 14) =  0.0000D+00
                                ::  TP( 15) =  0.1000D+01  ::  TQ( 15) = -0.0000D+00
                                ::  TP( 16) =  0.0000D+00  ::  TQ( 16) =  0.1000D+01


    PATH    ===================================================================================

            ISTEP        NITZ       ITRED        NITG          HP
                2           0           0           0          0.1250D-02


                X=STATES,  C=PARAMETERS                  EIGENVALUES                  MODULUS
    X(  1) =  0.6687800655408725D-02    LAMDA(  1) =  0.3241D-05  0.0000D+00    0.3241D-05
    X(  2) =  0.1954102126228404D+00    LAMDA(  2) = -0.1718D-04  0.0000D+00    0.1718D-04
    X(  3) =  0.1203728389052833D-01    LAMDA(  3) =  0.1471D-01  0.0000D+00    0.1471D-01
    X(  4) =  0.1025830459925002D+00    LAMDA(  4) = -0.3108D-01 -0.4674D-01    0.5613D-01
    X(  5) = -0.4037979579267975D-02    LAMDA(  5) = -0.3108D-01  0.4674D-01    0.5613D-01
    X(  6) =  0.2554064706912509D-01    LAMDA(  6) = -0.2881D-01  0.5158D-01    0.5908D-01
    X(  7) =  0.1281305519177650D-01    LAMDA(  7) = -0.2881D-01 -0.5158D-01    0.5908D-01
    X(  8) =  0.1087383653968960D+00    LAMDA(  8) = -0.8091D-01 -0.1308D+00    0.1538D+00
    X(  9) = -0.4724500114977728D-02    LAMDA(  9) = -0.8091D-01  0.1308D+00    0.1538D+00
    X( 10) =  0.5775517747332081D-01    LAMDA( 10) = -0.2261D+00 -0.1068D+00    0.2500D+00
    X( 11) =  0.1029905253998800D-01    LAMDA( 11) = -0.2261D+00  0.1068D+00    0.2500D+00
    X( 12) =  0.8089457580734497D-01    LAMDA( 12) =  0.4119D+00  0.0000D+00    0.4119D+00
    X( 13) = -0.3538801387309702D-02    LAMDA( 13) =  0.5897D+00  0.0000D+00    0.5897D+00
          X( 14) =    0.4286069656925537D-01
    C(  1) =  0.6300195710263264D+02
    C(  2) =  0.1460000000000000D+08
          TPER  =    0.1351989395779472D+01    <---  PERIOD OF ORBIT


         TPER =  0.1352D+01      NPOINT =   401               DT =  0.3372D-02

    XMIN( 1) = -0.1120D-01    XMAX( 1) =  0.1121D-01    AMP( 1) =  0.2240D-01
    XMIN( 2) = -0.2167D+00    XMAX( 2) =  0.2166D+00    AMP( 2) =  0.4333D+00
    XMIN( 3) = -0.1619D-01    XMAX( 3) =  0.1619D-01    AMP( 3) =  0.3237D-01
    XMIN( 4) = -0.1558D+00    XMAX( 4) =  0.1558D+00    AMP( 4) =  0.3116D+00
    XMIN( 5) = -0.9914D-02    XMAX( 5) =  0.9912D-02    AMP( 5) =  0.1983D-01
    XMIN( 6) = -0.1315D+00    XMAX( 6) =  0.1315D+00    AMP( 6) =  0.2631D+00
    XMIN( 7) = -0.1720D-01    XMAX( 7) =  0.1720D-01    AMP( 7) =  0.3440D-01
    XMIN( 8) = -0.1642D+00    XMAX( 8) =  0.1642D+00    AMP( 8) =  0.3285D+00
    XMIN( 9) = -0.6371D-02    XMAX( 9) =  0.6371D-02    AMP( 9) =  0.1274D-01
    XMIN(10) = -0.8832D-01    XMAX(10) =  0.8832D-01    AMP(10) =  0.1766D+00
    XMIN(11) = -0.1358D-01    XMAX(11) =  0.1358D-01    AMP(11) =  0.2716D-01
    XMIN(12) = -0.1239D+00    XMAX(12) =  0.1239D+00    AMP(12) =  0.2477D+00
    XMIN(13) = -0.5982D-02    XMAX(13) =  0.5982D-02    AMP(13) =  0.1196D-01
    XMIN(14) = -0.6236D-01    XMAX(14) =  0.6236D-01    AMP(14) =  0.1247D+00


    PATH    ===================================================================================

            ISTEP        NITZ       ITRED        NITG          HP
                3           1           0           0          0.3125D-02


                X=STATES,  C=PARAMETERS                  EIGENVALUES                  MODULUS
    X(  1) =  0.6688240648699638D-02    LAMDA(  1) =  0.6644D-05  0.0000D+00    0.6644D-05
    X(  2) =  0.1954169832975369D+00    LAMDA(  2) = -0.1879D-04  0.0000D+00    0.1879D-04
    X(  3) =  0.1203781108208853D-01    LAMDA(  3) =  0.1468D-01  0.0000D+00    0.1468D-01
    X(  4) =  0.1025857147323346D+00    LAMDA(  4) = -0.3110D-01 -0.4674D-01    0.5614D-01
    X(  5) = -0.4037634894291862D-02    LAMDA(  5) = -0.3110D-01  0.4674D-01    0.5614D-01
    X(  6) =  0.2554420706295416D-01    LAMDA(  6) = -0.2881D-01  0.5159D-01    0.5909D-01
    X(  7) =  0.1281359326141893D-01    LAMDA(  7) = -0.2881D-01 -0.5159D-01    0.5909D-01
    X(  8) =  0.1087415163277069D+00    LAMDA(  8) = -0.8092D-01 -0.1308D+00    0.1538D+00
    X(  9) = -0.4724306504956865D-02    LAMDA(  9) = -0.8092D-01  0.1308D+00    0.1538D+00
    X( 10) =  0.5775762842895714D-01    LAMDA( 10) = -0.2261D+00 -0.1069D+00    0.2501D+00
    X( 11) =  0.1029945524716142D-01    LAMDA( 11) = -0.2261D+00  0.1069D+00    0.2501D+00
    X( 12) =  0.8089838456275968D-01    LAMDA( 12) =  0.4120D+00  0.0000D+00    0.4120D+00
    X( 13) = -0.3538764327407433D-02    LAMDA( 13) =  0.5908D+00  0.0000D+00    0.5908D+00
          X( 14) =    0.4286194938097002D-01
    C(  1) =  0.6300508208683575D+02
    C(  2) =  0.1460000000000000D+08
          TPER  =    0.1351975828379028D+01    <---  PERIOD OF ORBIT


         TPER =  0.1352D+01      NPOINT =   401               DT =  0.3372D-02

    XMIN( 1) = -0.1120D-01    XMAX( 1) =  0.1121D-01    AMP( 1) =  0.2240D-01
    XMIN( 2) = -0.2167D+00    XMAX( 2) =  0.2166D+00    AMP( 2) =  0.4333D+00
    XMIN( 3) = -0.1619D-01    XMAX( 3) =  0.1619D-01    AMP( 3) =  0.3237D-01
    XMIN( 4) = -0.1558D+00    XMAX( 4) =  0.1558D+00    AMP( 4) =  0.3117D+00
    XMIN( 5) = -0.9914D-02    XMAX( 5) =  0.9912D-02    AMP( 5) =  0.1983D-01
    XMIN( 6) = -0.1315D+00    XMAX( 6) =  0.1315D+00    AMP( 6) =  0.2631D+00
    XMIN( 7) = -0.1720D-01    XMAX( 7) =  0.1720D-01    AMP( 7) =  0.3440D-01
    XMIN( 8) = -0.1642D+00    XMAX( 8) =  0.1642D+00    AMP( 8) =  0.3285D+00
    XMIN( 9) = -0.6371D-02    XMAX( 9) =  0.6371D-02    AMP( 9) =  0.1274D-01
    XMIN(10) = -0.8832D-01    XMAX(10) =  0.8833D-01    AMP(10) =  0.1766D+00
    XMIN(11) = -0.1358D-01    XMAX(11) =  0.1358D-01    AMP(11) =  0.2716D-01
    XMIN(12) = -0.1239D+00    XMAX(12) =  0.1239D+00    AMP(12) =  0.2477D+00
    XMIN(13) = -0.5982D-02    XMAX(13) =  0.5982D-02    AMP(13) =  0.1196D-01
    XMIN(14) = -0.6236D-01    XMAX(14) =  0.6236D-01    AMP(14) =  0.1247D+00


     
    Rest of the output can be found here: http://pastebin.com/kuQA22vS [Broken]

    What I am trying to achieve here is to get the C(1) values along with specific XMIN values given out by the code. I am required to do the same with XMAX and AMP values.

    The NSTEP = 20 is similar to ISTEP = 20 as shown by the 20 entries above.

    I have attached the code with the modifications I have documented in my post #4.

    Please do let me know if there is anything else that is required.
     

    Attached Files:

    Last edited by a moderator: May 7, 2017
  10. May 18, 2015 #9
    @Mark44
    I believe that you are trying to find the mention in the code regarding XMIN, XMAX and AMP. There isn't. The code is calling the library to give that output. I searched the library for the mention of xmin, xmax and amp and it points to a file called libpath.a

    I have attached the image showing that.
     

    Attached Files:

  11. May 18, 2015 #10

    Mark44

    Staff: Mentor

    My question was about the arrays XMIN, XMAX, and C, the variables you mentioned at the bottom of post #4, which I've copied here.
    Here is the code (below) that you showed in post #4. My issue is that the call to the PATH subroutine doesn't have any of the three arrays you asked about as parameters, so my question is why you would think that this code has anything to do with XMIN, XMAX, and C? If the call to PATH somehow causes changes to XMIN, XMAX, and C, it must be either that these variables are COMMON blocks or that one or more of the formal parameters to PATH are structures that have XMIN, XMAX, and C as members. If there are any other possibilities, I can't think what they might be.

    What I wanted you to do was to show me the code that changes XMIN, XMAX, and C, without me having to dig through and find it myself.
     
  12. May 19, 2015 #11
    Dug through the library and found the code below governing XMIN and XMAX. The changes in C are due to multiple calculations from 84 files in the library. I am unsure on what in particular causes the output above as I am following the guide given to me. If there is some way to figure it out by adding a few lines of code, then I can give that a shot.

    Code (Text):

          SUBROUTINE AMP2 (FCN,JAC,IJAC,N,X,TPER,NPOINT,XMIN,XMAX,AMP,IER)  
    C                                                                      
    C  ----------------  THE AMPLITUDE OF A PERIODIC SOLUTION IS DETERMINED
    C                    BY IS EXTREMAL VALUES IN NPOINTS EQUIDISTANTLY    
    C                    SPACED POINTS (EQUIDISTANT IN TIME).              
    C                                                                      
          IMPLICIT LOGICAL (A-Z)                                            
          EXTERNAL FCN,JAC                                                  
    C                                                                      
          INTEGER N,IJAC,NPOINT,IER                                        
          REAL*8  X(N),TPER,XMIN(N),XMAX(N),AMP(N)                          
    C                                                                      
          INTEGER K,INDEX,IPOINT                                            
          REAL*8  T,DT,TSTOP                                                
    C                                                                      
          IER=0                                                            
    C                                                                      
          IF (NPOINT.LT.10) NPOINT=40                                      
          DT=TPER/DFLOAT(NPOINT)                                            
    C                                                                      
          T=0.0D0                                                          
          DO 10  K=1,N                                                      
             XMIN(K)=X(K)                                                  
             XMAX(K)=X(K)                                                  
       10 CONTINUE                                                          
    C                                                                      
          INDEX=+1                                                          
    C                                                                      
          DO 30  IPOINT=1,NPOINT                                            
             TSTOP=T+DT                                                    
             CALL ODE2(FCN,JAC,IJAC,N,T,X,TSTOP,INDEX,IER)                  
             IF (IER.NE.0) GO TO 9200                                      
    C                                                                      
             DO 20  K=1,N                                                  
                XMIN(K)=DMIN1(XMIN(K),X(K))                                
                XMAX(K)=DMAX1(XMAX(K),X(K))                                
       20    CONTINUE                                                      
       30 CONTINUE                                                          
    C                                                                      
          DO 40  K=1,N                                                      
             AMP(K)=XMAX(K)-XMIN(K)                                        
       40 CONTINUE                                                          
    C                                                                      
          WRITE(6,45) TPER,NPOINT,DT,(K,XMIN(K),K,XMAX(K),K,AMP(K),K=1,N)  
       45 FORMAT(//5X,'TPER =',D12.4,6X,'NPOINT =',I6,15X,'DT =',D12.4//    
         *       (' XMIN(',I2,') =',D12.4,4X,'XMAX(',I2,') =',D12.4,4X,    
         *                                    'AMP(',I2,') =',D12.4   ))    
    C                                                                      
          RETURN                                                            
    C                                                                      
    C                                                                      
    C                                                                      
     9200 IER=200                                                          
          WRITE(6,9205)                                                    
     9205 FORMAT(' AMP2   **** ERROR RETURN FROM ROUTINE CALL')            
          RETURN                                                            
    C                                                                      
          END                                                              

     
     
  13. May 19, 2015 #12

    Mark44

    Staff: Mentor

    @adishpatel,
    I am replying to one of your earlier posts. I believe that you're asking why this code ...
    Code (Text):

    WRITE(4,11) C(1),XMIN(1),XMIN(5)
     
    produces this output
    Code (Text):

      0.63781250E+02,  0.00000000E+00,  0.00000000E+00
     
    Please correct me if this is NOT what you're asking. Assuming that that is where you're having problems, the write statement above prints only one value from each of the arrays, namely C(1), XMIN(1), and XMIN(5). I think you might be misunderstanding a basic concept of arrays.

    If you want to display varying values of your C array, and the corresponding values in the XMIN array (and maybe the XMAX array as well), just use a DO loop to iterate through these arrays.

    Assuming that N represents the number of elements of these arrays, this should work:
    Code (Text):

    DO I = 1, N
       WRITE(4, 11) C(I), XMIN(I), XMAX(I)
    END
     
    Note that the index on the three arrays in the write statement is I, upper case i. Also, I'm pretty sure that Fortran 77 supports the DO loop as I've written it. The older style of DO 40 K=1, N, with a line below it containing 40 CONTINUE is a very ancient style.
     
  14. May 19, 2015 #13

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    The DO structure without specifying a labeled terminal statement is definitely NOT in the Fortran 77 standard.

    http://www.fortran.com/F77_std/rjcnf0001-sh-11.html#sh-11.10

    While the terminal statement in a valid DO loop does not need to be a CONTINUE statement, only certain types of executable statements may terminate a DO loop, as specified in the standard. What you label as "very ancient style" was the standard loop construction for F77.

    As an alternative to constructing a standard DO loop structure for I/O, the use of the implied DO loop was available in F77.

    The DO loop above could just as easily have been replaced by a single WRITE statement:

    Code (Text):

    WRITE(4, 11) (C(I), XMIN(I), XMAX(I), I = 1, N)
     
     
  15. May 20, 2015 #14
    Hi, thank you for your assistance guys.

    @Mark44
    What I believe is that, this code
    Code (Text):

    DO I = 1, N
       WRITE(4, 11) C(I), XMIN(I), XMAX(I)
    END
     
    ..will give me values of....
    C(1), XMIN(1),XMAX(1) as the first line of output.
    C(2), XMIN(2), XMAX(2) as the second line of output
    C(3), XMIN(3), XMAX(3) as the third line of output and so on..

    What I am trying to achieve is to collect N number of iteration values of C(1), XMIN(1), XMIN(5),XMIN(9) which is calculated by the code. None of the output for these arrays are controlled by myself.

    The next task is to collate C(1),XMAX(1),XMAX(5),XMAX(9) and then C(1),AMP(1),AMP(5),AMP(9).

    Regardless, I ran the code and it threw 25+ errors which I am still trying to play with and work out why would that happen.

    @SteamKing
    Having seen your code, I understand that your code does the same?

    For your code to work, I had to define the I array in REAL*8 which gave me an output:
    Code (Text):

    $ make hsr-KP
    gfortran -O -o hsr-KP -L./lib  hsr-KP.f -lpath
    hsr-KP.f:302.23:

           WRITE(4, 11) (C(I), XMIN(I), XMAX(I), I = 1, N)
                           1
    Warning: Legacy Extension: REAL array index at (1)
    hsr-KP.f:302.32:

           WRITE(4, 11) (C(I), XMIN(I), XMAX(I), I = 1, N)
                                    1
    Warning: Legacy Extension: REAL array index at (1)
    hsr-KP.f:302.41:

           WRITE(4, 11) (C(I), XMIN(I), XMAX(I), I = 1, N)
                                             1
    Warning: Legacy Extension: REAL array index at (1)
    hsr-KP.f:302.44:

           WRITE(4, 11) (C(I), XMIN(I), XMAX(I), I = 1, N)
                                                1
    Warning: Deleted feature: Loop variable at (1) must be integer
     
    All I want to do is, record all these specific array values in a nice format instead of everything given out within the terminal window.
    C(1), XMIN(1),XMIN(5),XMIN(9),XMAX(1),XMAX(5),XMAX(9),AMP(1),AMP(5),AMP(9)
     
  16. May 20, 2015 #15

    Mark44

    Staff: Mentor

    What do you mean by "iteration values" of those variables? I thought that C(1), C(2), C(3), etc. were the iteration values. If all you need to do is to print those four values, you can do this:
    WRITE (4, <format line>) C(1), XMIN(1), XMIN(5), XMIN(9)

    Where I have "<format line>" is the line number of a format statement to be used in printing four values of whatever type they are.
    I have no idea what you mean here (above) when you say "collate".
    Use an appropriate FORMAT statement. Do a search for "fortran format" and you should get lots of hits.
     
  17. May 20, 2015 #16

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Since you used an IMPLICIT NONE statement at the beginning of your main program, you must declare the TYPE of each variable to prevent errors like you are getting with the array index variable I. Adding an INTEGER I to the declarations should fix these series of errors. BTW, IMPLICIT NONE is not compliant with the Fortran 77 standard, but is compliant with the Fortran 90 standard. It's not clear to me how gfortran handles this non-standard statement (because I'm not familiar with gfortran).
     
  18. May 20, 2015 #17
    If you look at the output here: http://pastebin.com/kuQA22vS [Broken]

    You'll notice that the values of arrays C(1), XMIN(1),XMIN(5),XMIN(9),XMAX(1),XMAX(5),XMAX(9),AMP(1),AMP(5),AMP(9) are different for every ISTEP. I need to record all these 10 values for N number of ISTEP's.

    So suppose I run the programme till ISTEP = 2000, then I need 2000 values for each of these arrays starting from ISTEP 0..1...2..3..4...2000 (In total, there should be 20,000 values recorded)

    ISTEP = NSTEP in the programme

    I am sorry for not being able to explain it very clearly. Trying me best here :)

    Thank you everyone for helping me out with this once again.
     
    Last edited by a moderator: May 7, 2017
  19. May 20, 2015 #18

    Mark44

    Staff: Mentor

    Are you using a debugger? From what I can see of this program, it's a tangled mess, which is something that I've seen a lot in legacy Fortran programs. For each value of NSTEP, print out the values of the array elements that you listed. Due to the structure of this program, and based on the code you posted in post #1, this will likely be hard to do.

    If you aren't using a debugger, why aren't you doing so?
     
  20. May 20, 2015 #19
    Aah, I see what I missed there. My bad. However, this is not what I am trying to achieve :(. I had initially coded the program with IMPLICIT A-Z which is what the reference guide asked me to do. However, it was very hard for me to spot the errors using that. Then I tried using IMPLICIT NONE suggested by my tutor and that helped me code and debug efficiently.

    @Mark44
    I did initially use a debugger to code the program. This is pretty much the final code as I am able to relate the values to the reference journals. However, I need the data to produce graphs and make analysis.

    Hard but doable is better than me hand picking 20,000 values.

    Anything that you may be able to suggest to accomplish this task?
     
  21. May 20, 2015 #20

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    IMPLICIT A-Z is incomplete. You must include the TYPE which variables starting with the letters A-Z will take. See:

    http://www.fortran.com/F77_std/rjcnf0001-sh-8.html#sh-8.5
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran 77: Recording the output
  1. Fortran 77 output bugs (Replies: 2)

  2. Fortran 77 (Replies: 1)

Loading...