FORTRAN moving from OpenVMS to AIX

1. Oct 22, 2014

debbieanne

Good day,

I am not familiar with older FORTRAN. We are shutting down an old OpenVMS server and moving to AIX. I am trying to tweak old FORTRAN code that is working fine on OpenVMS to now run on AIX. I have one error left in this code that I can't seem to fix. It is the line that reads
7 FORMAT(5A4,2I5)
The executable hangs on this code. The complete program is below. I would really appreciate any help you can give me.

Code (Fortran):
C  TRIP REPORT
C  TO LIST CATCH NO & WT BY SET FOR EACH SPECIES
C  6  SETS  PER  PAGE
C  FMT
C  1.SPECIES CODE NAME CONVERSION FILE ON DISK
C  2.CARD WITH SHIP NAME(COL 1-20),MINIMUM SET NO(21-25),TRIP NO IN
C  (COL 26-50) (5A4,2I5)
C  3.CATCH CARDS ARE FED SORTED BY SPECIES EX TEMP DISK FILE
C
C  CAN HANDLE UP TO 1000 SETS PER TRIP
DIMENSION NCOM(1000,7),ACOM(1000,7),IVES(5)
DIMENSION JSL(3000),KSL(3000,6)
DIMENSION ISL(240),ISTS(240,1000),ASTS(240,1000),LSET(1000)
CHARACTER*4 KSL,IVES
JJ=0
KKK=0
ISP=0
DO 5 I=1,3000
II=I
4  FORMAT(4X,I4,6A4)
5  CONTINUE
7  FORMAT(5A4,2I5)

DO 8 I=1,140
ISL(I)=0

DO 8 J=1,1000
ISTS(I,J)=0
8  ASTS(I,J)=0.0
DO 9 I=1,1000
9  LSET(I)=0
DO 10 I=1,1000

DO 10 J=1,7
NCOM(I,J)=0
10  ACOM(I,J)=0.0
L=1
18  N=0
IF(ISP)19,19,24
OPEN(8,FILE='SORTEDSDA3A.DAT')
20  FORMAT(6X,I3,71X,I4,I6,F7.2,T1,I1)
IF(ITYPE.NE.6) GO TO 19
NSET=ISET+1-MIN
IF(NSET.GT.JJ)JJ=NSET
IF(ISP.EQ.438.OR.ISP.EQ.794) GO TO 200
IF(ISP.EQ.793.OR.ISP.EQ.889) GO TO 200

IF(ISP.EQ.891.OR.ISP.EQ.890) GO TO 200
IF(ISP.EQ.892) GO TO 200
24  N=N+1
IF(N-1)25,25,30
25  ISL(L)=ISP
JSP=ISP

GO TO 31
30  IF(ISP-JSP)35,31,35
31  ISTS(L,NSET)=ISTS(L,NSET)+INO
ASTS(L,NSET)=ASTS(L,NSET)+AWT
GO TO 19
35  L=L+1
GO TO 18

200 IF(ISP.EQ.438) IS=1
IF(ISP.EQ.794) IS=2
IF(ISP.EQ.793) IS=3
IF(ISP.EQ.889) IS=4
IF(ISP.EQ.891) IS=5
IF(ISP.EQ.890) IS=6

IF(ISP.EQ.892) IS=7
NCOM(NSET,IS)=NCOM(NSET,IS)+INO
ACOM(NSET,IS)=ACOM(NSET,IS)+AWT
GO TO 19
50  LSET(1)=MIN
DO 57 I=2,JJ

57  LSET(I)=MIN-1+I
N=1
KK=6
MM=KK
IZZZZ=0
DO 7071 I=1,240
DO 7071 J=1,1000
7071 IZZZZ=IZZZZ+ISTS(I,J)
IF(IZZZZ.EQ.0) GO TO 100
OPEN(6,FILE='PRINTSCAL.LIS')
59  WRITE(6,60)IVES,ITRIP

60  FORMAT(1H1/////12X,'TABLE 3.  ',5A4,' CRUISE NO.',I4//)
WRITE(6,61)
61  FORMAT(1H ,11X,'..................................................
1........................................................'
)
WRITE(6,62)
62  FORMAT(1H ,73X,'SET NUMBER')

WRITE(6,63)(LSET(IN),IN=N,KK)
63  FORMAT(1H ,36X,6I13)
WRITE(6,64)
64  FORMAT(1H ,11X,'SPECIES NAME',20X,'NO  WT  NO  WT  NO
1  WT  NO  WT  NO  WT  NO  WT'
)
WRITE(6,61)
WRITE(6,65)
65  FORMAT(1H )
K50=0
DO 70 I=1,L
DO 80 K=1,II
IF(ISL(I).EQ.JSL(K))GO TO 81
GO TO 80

81  WRITE(6,245)(KSL(K,M),M=1,6)
245  FORMAT(1H ,11X,6A4,4X)
K50=K50+1
GO TO 82
80  CONTINUE
82  IF(K50.LT.I) GO TO 303

DO 85 J=N,KK
IF(ISTS(I,J))86,86,87
86  IF(ASTS(I,J))85,85,87
87  LL=MM-J+1
GO TO(131,132,133,134,135,136),LL
131  WRITE(6,137)ISTS(I,J),ASTS(I,J)

137  FORMAT(1H+,104X,I6,F7.2)
GO TO 85
132  WRITE(6,138)ISTS(I,J),ASTS(I,J)
138  FORMAT(1H+,91X,I6,F7.2)
GO TO 85
133  WRITE(6,139)ISTS(I,J),ASTS(I,J)

139  FORMAT(1H+,78X,I6,F7.2)
GO TO 85
134  WRITE(6,140)ISTS(I,J),ASTS(I,J)
140  FORMAT(1H+,65X,I6,F7.2)
GO TO 85
135  WRITE(6,141)ISTS(I,J),ASTS(I,J)
141  FORMAT(1H+,52X,I6,F7.2)
GO TO 85
136  WRITE(6,142)ISTS(I,J),ASTS(I,J)
142  FORMAT(1H+,39X,I6,F7.2)
GO TO 85
303  WRITE(6,304) ISL(I)
304  FORMAT(1H ,19X,I5,2X,'SPECIES CODE ERROR')
K50=K50+1
85  CONTINUE
IF(I.EQ.44.OR.I.EQ.88) GO TO 68
GO TO 70
68  IF(I.EQ.L)GO TO 70
WRITE(6,60)IVES,ITRIP

WRITE(6,61)
WRITE(6,62)
WRITE(6,63)(LSET(IN),IN=N,KK)
WRITE(6,64)
WRITE(6,61)
WRITE(6,65)

70  CONTINUE
IF(KKK)71,71,100
71  N=N+6
KK=KK+6
MM=KK
IF(KK-JJ)59,59,72
72  KK=JJ

KKK=10
GO TO 59
100  N=0
WRITE(6,201)IVES,ITRIP
201  FORMAT(1H1/////10X,'TABLE 2.  ',5A4,' CRUISE NO.',I4//)
WRITE(6,202)

202  FORMAT(1H ,9X,109('.'))
WRITE(6,203)
203  FORMAT(1H ,9X,'SET  COD  MENTELLA  MARINUS
1  AM PLAICE  YELLOWTAIL  GREYSOLE  TURBOT'
)
WRITE(6,204)
204  FORMAT(1H ,10X,'NO  NO  WT  NO  WT  NO
WT
1  NO  WT  NO  WT  NO  WT  NO  WT'
)
WRITE(6,202)
DO 250 I=1,JJ
MSET=MIN-1+I
WRITE(6,205)MSET
205  FORMAT(1H ,9X,I3)

DO 249 J=1,7
IF(NCOM(I,J))206,206,207
206  IF(ACOM(I,J))249,249,207
207  GO TO(211,212,213,214,215,216,217),J
211 WRITE(6,221)NCOM(I,J),ACOM(I,J)
221  FORMAT(1H+,13X,I6,F9.2)
GO TO 249

212 WRITE(6,222)NCOM(I,J),ACOM(I,J)
222  FORMAT(1H+,28X,I6,F9.2)
GO TO 249
213 WRITE(6,223)NCOM(I,J),ACOM(I,J)
223  FORMAT(1H+,43X,I6,F9.2)
GO TO 249

214 WRITE(6,224)NCOM(I,J),ACOM(I,J)
224  FORMAT(1H+,58X,I6,F8.2)
GO TO 249
215 WRITE(6,225)NCOM(I,J),ACOM(I,J)
225  FORMAT(1H+,72X,I6,F9.2)
GO TO 249

216 WRITE(6,226)NCOM(I,J),ACOM(I,J)
226  FORMAT(1H+,87X,I6,F9.2)
GO TO 249
217 WRITE(6,227)NCOM(I,J),ACOM(I,J)
227  FORMAT(1H+,102X,I6,F9.2)
249 CONTINUE

IF(I.EQ.44.OR.I.EQ.88) GO TO 251
IF(I.EQ.132.OR.I.EQ.176) GO TO 251
IF(I.EQ.220.OR.I.EQ.264) GO TO 251
IF(I.EQ.308.OR.I.EQ.352) GO TO 251
GO TO 250
251  WRITE(6,201)IVES,ITRIP
WRITE(6,202)
WRITE(6,203)

WRITE(6,204)
WRITE(6,202)
250  CONTINUE
STOP
END

Last edited by a moderator: Oct 22, 2014
2. Oct 22, 2014

Staff: Mentor

Welcome to PF!

Are you sure it isn't waiting for input from you in the terminal window?

3. Oct 22, 2014

debbieanne

On the OpenVMS I don't have to give any input from the keyboard. The fortran program itself is called from a DCL script which I re-wrote to bash. I've included both here. My compiler is gfortran. I use this code to compile: gfortran -std=legacy -ff2c sdetcat.for....I have hard coded paths and data file names in the bash code for now just to get everything working. These will be entered by the user in the finished product. Thanks for your help. It's very much appreciated.

DCL code:

$!$! PROC TO RUN SET DETAIL--CATCH LISTING FOR TRIP REPORT
$! MOD INPUT DATA FILE TO SORT (DATA EX ENTREX)$! MOD VESSEL,SET AND TRIP LINE FOLLOWING RUN STATMENT
$!$! OUTPUT IS TO LASER PRINTER
$! IF DON'T WANT LASER... DELETE ! FROM 2ND LAST LINE$!
$!SORT DATA FILE$!
$SORT/KEY=(POSITION:81,SIZE:4,CHARACTER,ASCENDING)- !! DUA5:[CAHILL.PAT]TRIP232.DAT- !! DUA3:[TUCKER.DATA]07783.SET- COMMON:[DATAPROC.DATA]39140.set- SYS$LOGIN:SORTEDSD3A.DAT
$DEFINE FOR009 common:[dataproc.pgms.SDET]GFSPCY.CODE$DEFINE FOR008 SYS$LOGIN:SORTEDSD3A.DAT$DEFINE FOR006 SYS$LOGIN:PRINTSCAL.LIS$RUN COMMON:[DATAPROC.PGMS.SDET]SDETCAT.EXE
TELEOST 140
$! PRINT/QUE=scs1$print/noflag/copies=1/form=test2/delete FOR006
$PRINT/DELETE FOR006$DELETE SYS$LOGIN:SORTEDSD3A.DAT;* New Bash script to replace DCL code: #!/bin/bash set=39110 mypathone='C:/Documents and Settings/powerda/Desktop/u01/common/DATA/' mypathtwo='C:/Documents and Settings/powerda/Desktop/u01/common/PGMS/SDET/' vessel='Teleost' trip=110 cd 'C:/Documents and Settings/powerda/Desktop/u01/common/DATA/' sort -k1,81n -k1,82n -k1,83n -k1,84n$set.SET | cat > SORTEDSDA3A.DAT

cd 'C:/Documents and Settings/powerda/Desktop/u01/common/PGMS/SDET/'

chmod 777 a.exe
./a.exe

#read -p "Please enter the vessel name. EG. Teleost" $2 #read -p "Please enter the trip number. EG. 110"$3
#Vessel name must begin in column 1. Trip number must begin in column 27

#$vessel$trip

4. Oct 22, 2014

Staff: Mentor

try commenting out the read(*,7) and format line and insert some lines to initialize the 3 variables that it will read in:

IVES=1
MIN=2
ITRIP=3

or whatever values are appropriate.

Also it would help if you used the [ code ] tags to allow the web page to print with proper indentation.

5. Oct 22, 2014

Staff: Mentor

6. Oct 22, 2014

debbieanne

I will do this and get back to you. You've been very helpful. Thanks so much. I have a meeting now but will read the site info you sent me. I had downloaded some manuals from various sites but found that they had different approaches. Probably because of the various versions of FORTRAN available. I will do as you suggest and see what happens. I'll post tomorrow to let you know. Thanks again.

7. Oct 22, 2014

Staff: Mentor

Okay, if I were you I'd convert it to python especially if you're going to be the owner and add lots of commentary to help you and the next programmer maintain it better.

It looks like its simply generating a report of fish catches from some input data?

8. Oct 22, 2014

Staff: Mentor

jedishrfu, I'm pretty sure you've nailed it here. The program is waiting for input.
IVES is a 5-element array where each element is character string with 4 characters. MIN and ITRIP are both integers.

The code gives no clue whatsoever as to what IVES is supposed to contain.

9. Oct 22, 2014

Staff: Mentor

I'm pretty sure that READ statement is for the "CARD WITH SHIP NAME [etc.]" described in the comments at the top of the code. IVES is a 20-character string containing the ship name, and is used along with ITRIP (trip number) to label the output. I suspect "VES" = "vessel", with a prefixed I as if it were an integer variable.

10. Oct 22, 2014

Staff: Mentor

Looking at he bash code shows some added info

Ives = teleost
Itrip=110

11. Oct 22, 2014

Staff: Mentor

Gotta love those variable names!
Code (Text):

IZZZZ
Code (Text):

IF(KKK)71,71,100
71  N=N+6
KK=KK+6
MM=KK
IF(KK-JJ)59,59,72
72  KK=JJ

12. Oct 22, 2014

SteamKing

Staff Emeritus
The code attached to the OP is older than F77, more like Fortran IV, in that it uses Hollerith data instead of the CHARACTER data type. Hollerith can be converted to the more modern CHARACTER data type with a little programming work.

Data appears to be entered thru the default device with logical unit *, which is usually the terminal. The DCL script apparently serves to provide input to the database as well as being used to sort and print the various records.

13. Oct 23, 2014

debbieanne

Thanks all for your input. It has been very helpful to me. This is what I was able to discover using the information in this thread. The line: READ(*,7)IVES,MIN,ITRIP is asking for input of the vessel name beginning in the first column and the trip number beginning in column 27. When I type in Teleost and space over to column 27 and type in 110 (for the trip number) it puts this information in the TABLE 2 header in the proper places and the code continues to run without error. So now all I need is to figure out how to pass the variable contents of ($vessel and$trip) from the bash script to the FORTRAN program line READ(*,7)IVES,MIN,ITRIP. The format line in FORTRAN is fine (FORMAT(5A4,2I5) ).

14. Oct 23, 2014

Seems to me that you should also have your bash script pass in a value for the minimum trip number (MIN), since the READ statement is expecting a value. That's the first of the two I5 (uppercase i) values in the format statement. The second I5 value is for what you're calling $trip. 15. Oct 23, 2014 jtbell Staff: Mentor In a Fortran program running under Unix or Linux, the I/O unit * is probably associated with "standard input" which is normally the console (terminal). In general, to make a shell script (or Perl script) send data to a program's standard input, you can use a "here document." I'll demonstrate it with a simple Fortran program: Code (Text): program hello character*8 name read (*,40) name write (*,50) name 40 format (A8) 50 format (1x, 'Hello, ', A8) end Compile this and run it. It waits for you to enter a name (up to 8 chars), then when you hit 'enter', it displays a message with the name. Here's a bash script that runs this program, feeding the name to it from a variable 'myname' via a here document: Code (Text): #!/bin/bash myname='Joe' ./hello<<EndSTDIN$myname
EndSTDIN

The '<<' after the program name marks the start of a here document. The 'EndSTDIN' is a marker which will indicate the end of input. You can use any string you like for this marker, provided that it doesn't appear in the actual data to be sent via standard input. The data begins on the next line, and is terminated by the marker (on a separate line).

You can also dispense with the variable 'myname' and simply put 'Joe' in the here document.

Code (Text):

#!/bin/bash
./hello<<EndSTDIN
Joe
EndSTDIN

This example works using gfortran under Ubuntu Linux. I hope it works on your system also.

Last edited: Oct 23, 2014