Why is the output format different for two similar Fortran codes?

  • Context: Fortran 
  • Thread starter Thread starter adishpatel
  • Start date Start date
  • Tags Tags
    Fortran
adishpatel
Messages
22
Reaction score
0
So, when I execute my code which is at http://sysden.com/dufing.f

I get the results which are very well organized:
Code:
 PATH  ==========================================================================================

            N         INP       JCASE         JOB        JBIF        ILAM        IJAC          IW
            2           0           3           1           0           2           1         500


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


 ** GPAR   **        EPSG          HG         ITG
               0.1000D-04  0.5000D-03          15


 ** PPAR   **        HMIN          HP        HMAX      FACINC      FACDEC         ITP       NSTEP
               0.1000D-04  0.1000D-01  0.1000D-01  0.2300D+01  0.8000D+00          15          60


 ** EQSOL  **        IODE         LRW         TOL
                        2         100  0.1000D-09
 XBIFUR **** THE BIFURCATION POINT NOT BRACKETED
             AT C( 1) =    0.1498235665D+01   C( 2) =    0.1500000000D+01
             THE EIGENVALUE IS  LAMDA =    0.1018821933D+01    0.0000000000D+00

             AT C( 1) =    0.1498244342D+01   C( 2) =    0.1500000000D+01
             THE EIGENVALUE IS  LAMDA =    0.1018486738D+01    0.0000000000D+00

             AT C( 1) =    0.1500185162D+01   C( 2) =    0.1500000000D+01
             THE EIGENVALUE IS  LAMDA =    0.1075632960D+01    0.0000000000D+00


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


On the other hand, I have a very very similar code with simply some formulas modified, I get the following output (http://sysden.com/Trial.f) :

Code:
 T =  0.1230D+02    X(1) =   -0.6995969146D-16    X(2) =   -0.8397826270D-14
 T =  0.1232D+02    X(1) =   -0.1296208881D-15    X(2) =    0.4397024319D-15
 T =  0.1233D+02    X(1) =   -0.6896299146D-16    X(2) =    0.8521701466D-14
 T =  0.1234D+02    X(1) =    0.4941227263D-16    X(2) =    0.8977390468D-14
 T =  0.1235D+02    X(1) =    0.1241519258D-15    X(2) =    0.1634297191D-14
 T =  0.1237D+02    X(1) =    0.9342308194D-16    X(2) =   -0.6885493191D-14
 T =  0.1238D+02    X(1) =   -0.1172392094D-16    X(2) =   -0.9706719735D-14
 T =  0.1239D+02    X(1) =   -0.1099822134D-15    X(2) =   -0.4513322049D-14
 T =  0.1240D+02    X(1) =   -0.1183246126D-15    X(2) =    0.4526377004D-14
 T =  0.1242D+02    X(1) =   -0.2783645508D-16    X(2) =    0.1001609073D-13
 T =  0.1243D+02    X(1) =    0.8740604234D-16    X(2) =    0.7396635050D-14
 T =  0.1244D+02    X(1) =    0.1334446529D-15    X(2) =   -0.1576740606D-14
 T =  0.1245D+02    X(1) =    0.6687026721D-16    X(2) =   -0.9388969273D-14
 T =  0.1247D+02    X(1) =   -0.5655341949D-16    X(2) =   -0.9486228884D-14
 T =  0.1248D+02    X(1) =   -0.1362274125D-15    X(2) =   -0.1479291222D-14
 T =  0.1249D+02    X(1) =   -0.1012353469D-15    X(2) =    0.7942125660D-14
 T =  0.1250D+02    X(1) =    0.1776983651D-16    X(2) =    0.1091033964D-13
 T =  0.1252D+02    X(1) =    0.1269133235D-15    X(2) =    0.4786738462D-14
 T =  0.1253D+02    X(1) =    0.1303159882D-15    X(2) =   -0.5510440636D-14
 T =  0.1254D+02    X(1) =    0.2519319926D-16    X(2) =   -0.1117597369D-13
 T =  0.1255D+02    X(1) =   -0.9953672094D-16    X(2) =   -0.7583895225D-14
 T =  0.1257D+02    X(1) =   -0.1393567280D-15    X(2) =    0.2126730762D-14


I want my output to be the way it is for the 1st file. Don't understand why the format differs?

I even commented the format bit from the Trail code and it still wouldn't give me the nicely organized results?

Code:
      INDEX=1
      T=0.0D+00
   17 FORMAT(' T =',D12.4,'    X(1) =',D20.10,'    X(2) =',D20.10)
      DO 18,  K=1,1000
         TEND = K*TPER/500
         CALL ODE2(FCN,JAC,IJAC,N,T,X,TEND,INDEX,IER)
         IF (X(1).GT.1.0D+01) GOTO 18
         WRITE(6,17) T,X(11),X(12)
         WRITE(3,*) T,X(11),X(12)
   18 CONTINUE
      STOP
 
The computer will only do what you tell it to do. In the first case, it appears that subroutine PATH gives some output. In the second case, the output is coming from the write statements you wrote.
 
In dufing.f it has

Code:
      lamda = (0.1000d+01, 0.0000d+00)                                                                                          
c                                                                       
      tq(1) = tp(1)                                                     
      tq(2) = tp(2)                                                     
      tq(3) = tp(3)                                                     
      tq(4) = tp(4)                                                     
c                                                                       
      tp(1) = 0.0000d+00                                                
      tp(2) = 0.0000d+00                                                
      tp(3) = 0.0000d+00                                                
      tp(4) = 0.1000d+01

And Trial.f has the following instead:

Code:
C
      DO J=1,N+2
         TQ(J) = TP(J)
      END DO
C
      DO J=1,N+1
         TP(J) = 0.0000d+00
      END DO
      TP(N+2) = 1.0000d+00
C

I even commented out the following from Trial.f to let call path do the job as it does in dufing.f and still the results come out in a different way?

Code:
      INDEX=1
      T=0.0D+00
   17 FORMAT(' T =',D12.4,'    X(1) =',D20.10,'    X(2) =',D20.10)
      DO 18,  K=1,1000
         TEND = K*TPER/500
         CALL ODE2(FCN,JAC,IJAC,N,T,X,TEND,INDEX,IER)
         IF (X(1).GT.1.0D+01) GOTO 18
         WRITE(6,17) T,X(11),X(12)
         WRITE(3,*) T,X(11),X(12)
   18 CONTINUE
      STOP

Subroutine path? There are two instances where we define subroutine in dufing.f and 3 instances where we have "call path". It is the same for Trial.f as well. Also the code is no different than what I mentioned? Am I overlooking something here :O
 
adishpatel said:
In dufing.f it has

Code:
      lamda = (0.1000d+01, 0.0000d+00)                                                                                          
c                                                                       
      tq(1) = tp(1)                                                     
      tq(2) = tp(2)                                                     
      tq(3) = tp(3)                                                     
      tq(4) = tp(4)                                                     
c                                                                       
      tp(1) = 0.0000d+00                                                
      tp(2) = 0.0000d+00                                                
      tp(3) = 0.0000d+00                                                
      tp(4) = 0.1000d+01

And Trial.f has the following instead:

Code:
C
      DO J=1,N+2
         TQ(J) = TP(J)
      END DO
C
      DO J=1,N+1
         TP(J) = 0.0000d+00
      END DO
      TP(N+2) = 1.0000d+00
C
That's irrelevant. It doesn't concern output.

adishpatel said:
I even commented out the following from Trial.f to let call path do the job as it does in dufing.f and still the results come out in a different way?
I have no idea what the PATH subroutine is or does. It is possible that there is a certain variable passed to PATH that controls whether the subroutine produces any output. If you have the source file, you can check to see how PATH produces output. If it's in a library, you have to look at the documentation for that library.
 
I don't think the code shown could have printed the first output. It seems clear that PATH printed the first output. But the "STOP" after the "18 CONTINUE" line stops the program before PATH is executed. There are two write statements before the "STOP" that print the second output.
 
  • Like
Likes   Reactions: 1 person

Similar threads

  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 58 ·
2
Replies
58
Views
5K
  • · Replies 4 ·
Replies
4
Views
9K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K