forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Probably elementary compilation problem with FTN95

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
DavidColeman



Joined: 06 Apr 2022
Posts: 12

PostPosted: Wed Apr 06, 2022 1:31 pm    Post subject: Probably elementary compilation problem with FTN95 Reply with quote

I want to revive some Fortran programs written in the 1980s, which have survived on paper. I have not used Fortran since. I have tried to compile one of them in fixed format with FTN95. All looks well but it refuses to compile with error messages about invalid characters in the label field and unpaired right bracket. It does not tell me where the errors lie. The original program (on paper), which I have copied exactly, ran perfectly and despite hours of scrutiny I can see neither of these errors. i must be missing something obvious. All suggestions gratefully received.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Apr 06, 2022 1:38 pm    Post subject: Reply with quote

If you are able to zip up the source and data files, upload the zip file to a cloud host (such as Dropbox), enable access to the public and post a link to the hosted zip file in your reply, we can take a look. If you have the scanned source into a PDF file, please provide that file as well.

It would be useful to know what platform (computer, OS, compiler) was used when the program was run in the 1980s.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed Apr 06, 2022 2:41 pm    Post subject: Reply with quote

All compilers should tell you the line numbers of errors that it encounters and FTN95 certainly does so.

If you are using the FTN95 compiler on a command line then by default the line with the error is display first followed by the error report.

If you are using the Plato editor then it will launch FTN95 for you and display the error reports in an "Output" window. Double clicking on the error message will take you to the corresponding line in the code.

If you can't see the "Output" window then use the View menu on the main menu bar and select "Output Results".
Back to top
View user's profile Send private message AIM Address
Robert



Joined: 29 Nov 2006
Posts: 444
Location: Manchester

PostPosted: Wed Apr 06, 2022 3:47 pm    Post subject: Reply with quote

It sounds like you have fixed-format Fortran files. It is easy to end up with characters in the wrong column with fixed format.
Back to top
View user's profile Send private message Visit poster's website
DavidColeman



Joined: 06 Apr 2022
Posts: 12

PostPosted: Wed Apr 06, 2022 6:16 pm    Post subject: Re: Reply with quote

mecej4 wrote:
If you are able to zip up the source and data files, upload the zip file to a cloud host (such as Dropbox), enable access to the public and post a link to the hosted zip file in your reply, we can take a look. If you have the scanned source into a PDF file, please provide that file as well.

It would be useful to know what platform (computer, OS, compiler) was used when the program was run in the 1980s.


Hello again,

Thank you very much for your helpful comments.

I've upload a folder containing the fortran file and the data in excel format. Yes, the file is fixed format, copied 'by hand' from the old paper printout. In fact I have not got as far as trying to make the program read the data as I cannot yet make the program compile. I already have the output on paper; I am trying to make the program work on this (to me ) completely new system so that I can use the program to analyse other data and also learn how to run the other programs.

The error message appeared after line 33. But I removed this and all other commands with text labels and still kept getting the same error message, at the end of the text.

As regards the original platform, that was almost certainly the ICL 2988 mainframe at Oxford University and the program written in Fortran77 (the relevant page of printout is missing). I cannot remember if it was entered by Hollerith cards or at a terminal - I think the latter.

David
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Apr 06, 2022 6:41 pm    Post subject: Reply with quote

Hi David, you wrote that you have uploaded a folder, so the question is, "to which location?" Please note that this forum does not permit you to attach files to our posts and responses. It allows posting short programs (up to about 100 lines) using the Code button, but that is probably not enough.

Please use a program such as 7Zip, Winzip, etc., to create a Zip file containing all the relevant files in your folder. Upload the Zip file to a cloud hosting service such as Google Drive, Onedrive, Dropbox, etc. Many free email services such as Gmail, Outlook, etc., allow this to be done, as well. See https://www.businessinsider.com/how-to-send-zip-file-in-gmail for helpful information on this topic.

Once the zip file has been uploaded, please post a link to it in a reply here.
Back to top
View user's profile Send private message
DavidColeman



Joined: 06 Apr 2022
Posts: 12

PostPosted: Thu Apr 07, 2022 5:15 pm    Post subject: Re: Reply with quote

Hi again, I forgot to include the wetransfer link to the zip. Please find below it:

https://we.tl/t-kR7Zhc71tk



mecej4 wrote:
Hi David, you wrote that you have uploaded a folder, so the question is, "to which location?" Please note that this forum does not permit you to attach files to our posts and responses. It allows posting short programs (up to about 100 lines) using the Code button, but that is probably not enough.

Please use a program such as 7Zip, Winzip, etc., to create a Zip file containing all the relevant files in your folder. Upload the Zip file to a cloud hosting service such as Google Drive, Onedrive, Dropbox, etc. Many free email services such as Gmail, Outlook, etc., allow this to be done, as well. See https://www.businessinsider.com/how-to-send-zip-file-in-gmail for helpful information on this topic.

Once the zip file has been uploaded, please post a link to it in a reply here.
Code:
Code:
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Thu Apr 07, 2022 5:57 pm    Post subject: Reply with quote

As I suspected, many of the statements in your program did not start at the proper columns for fixed format source. Here is a corrected source, which you may copy and paste into a file named, say, mm.f . Note that ".f" indicates fixed format source. I have retained this format since that is probably the only one that is familiar to you. It will be worthwhile for you to switchover to free-form Fortran source, where you do not need to bother counting columns, and you have more flexibility in making the source easier to read and understand.

Code:
      program mxr
      implicit none
C   This is a program for calculating halfmatrices of marital exchange
C   rates between places and using them as input into mdscal and clustan
      integer m, n, i, j, k
      real pmrexm(7,7), rowtot(7), coltot(7), marexm(7,7)
      n=7
      m=n-1
      open(15,file='mm.dat',form='formatted',status='old')
      read(15,1)((marexm(i,j),j=1,n),i=1,n)
      close(15)
    1 format(7f5.0)
      do i=1,n
         rowtot(i) = sum(marexm(i,1:n))
         coltot(i) = sum(marexm(1:n,i))
      end do
      do i=1,n
         do j=1,n
            pmrexm(i,j) = marexm(j,i) + marexm(i,j)/
     1                    ((rowtot(i)+rowtot(j)+coltot(i)+coltot(j))/2)
        end do
      end do
      write(*,6) ((marexm(i,j),j=1,n), i=1,n)
    6 format(1h //5x,' MARRIAGE EXCHANGE INPUT DATA ',//,
     1(2x,7(f5.0,2x))/)
      write (*,2)rowtot
    2 format(5x,' ROW TOTALS OF RAW DATA',  //1x,(7(f5.0,2x))///)
      write (*,3)coltot
    3 format(5x,' COLUMN TOTALS OF RAW DATA',  //1x,(7(f5.0,2x))///)
      do k=1,n
         pmrexm(k,k:n)=0.0
      end do
      write(*,4)((pmrexm(i,j),j=1,m),i=2,n)
    4 format(1h  //5x,' STOCHASTIC HALFMATRIX OF AVERAGED EXCHANGE RATES
     1', //(2x,7f8.5))
      open(7,file='shmatrix.txt',form='formatted',status='replace')
      write(7,5)((pmrexm(i,j),j=1,6),i=2,7)
      close(7)
    5 format (2x,6f8.5)
      stop
      end


I have simplified the program, removing some obsolete features, and made some modifications to suit the Windows OS.

Here is the input data file, mm.dat.

Code:
   42   15    5    7    8    3    8
   12   28    5    4    3    4    6
    1    6    8    3    0    0    1
    7    4    2   23    2    4    4
    3    5    1    1    3    2    2
    6    2    0    1    1   10    1
   10    2    1    2    0    0   12

If you copy/paste both files into a directory, you can compile, link and run the program to create the output file.


Last edited by mecej4 on Fri Apr 08, 2022 4:58 pm; edited 1 time in total
Back to top
View user's profile Send private message
DavidColeman



Joined: 06 Apr 2022
Posts: 12

PostPosted: Fri Apr 08, 2022 2:58 pm    Post subject: Re: Reply with quote

mecej4 wrote:
As I suspected, many of the statements in your program did not start at the proper columns for fixed format source. Here is a corrected source, which you may cut and paste into a file named, say, mm.f . Note that ".f" indicates fixed format source. I have retained this format since that is probably the only one that is familiar to you. It will be worthwhile for you to switchover to free-form Fortran source, where you do not need to bother counting columns, and you have more flexibility in making the source easier to read and understand.

Code:
      program mxr
      implicit none
C   This is a program for calculating halfmatrices of marital exchange
C   rates between places and using them as input into mdscal and clustan
      integer m, n, i, j, k
      real pmrexm(7,7), rowtot(7), coltot(7), marexm(7,7)
      n=7
      m=n-1
      open(15,file='mm.dat',form='formatted',status='old')
      read(15,1)((marexm(i,j),j=1,n),i=1,n)
      close(15)
    1 format(7f5.0)
      do i=1,n
         rowtot(i) = sum(marexm(i,1:n))
         coltot(i) = sum(marexm(1:n,i))
      end do
      do i=1,n
         do j=1,n
            pmrexm(i,j) = marexm(j,i) + marexm(i,j)/
     1                    ((rowtot(i)+rowtot(j)+coltot(i)+coltot(j))/2)
        end do
      end do
      write(*,6) ((marexm(i,j),j=1,n), i=1,n)
    6 format(1h //5x,' MARRIAGE EXCHANGE INPUT DATA ',//,
     1(2x,7(f5.0,2x))/)
      write (*,2)rowtot
    2 format(5x,' ROW TOTALS OF RAW DATA',  //1x,(7(f5.0,2x))///)
      write (*,3)coltot
    3 format(5x,' COLUMN TOTALS OF RAW DATA',  //1x,(7(f5.0,2x))///)
      do k=1,n
         pmrexm(k,k:n)=0.0
      end do
      write(*,4)((pmrexm(i,j),j=1,m),i=2,n)
    4 format(1h  //5x,' STOCHASTIC HALFMATRIX OF AVERAGED EXCHANGE RATES
     1', //(2x,7f8.5))
      open(7,file='shmatrix.txt',form='formatted',status='replace')
      write(7,5)((pmrexm(i,j),j=1,6),i=2,7)
      close(7)
    5 format (2x,6f8.5)
      stop
      end


I have simplified the program, removing some obsolete features, and made some modifications to suit the Windows OS.

Here is the input data file, mm.dat.

Code:
   42   15    5    7    8    3    8
   12   28    5    4    3    4    6
    1    6    8    3    0    0    1
    7    4    2   23    2    4    4
    3    5    1    1    3    2    2
    6    2    0    1    1   10    1
   10    2    1    2    0    0   12

If you copy/paste both files into a directory, you can compile, link and run the program to create the output file.


I am sorry not to have been able to reply sooner. Thank you very much for taking so much trouble to correct and update my old program. I am really very grateful. Following your instructions it has now run, read the data and produced a result. Using your corrections and modifications I shall now be able to bring back to use a number of other programs which have lain dormant for decades. I had tried to use the free format approach, on a different program, but Plato didn't like it so I must do some reading.

very best regards,

David
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Fri Apr 08, 2022 4:22 pm    Post subject: Reply with quote

It was not much trouble.

Below is given a free-form source version of the same program. Save it to a file with ".f90" as the extension before compiling and linking.

It may be helpful to note that the file suffixes ".f" and ".for" only indicate to the compiler that the source file is in fixed form, not that the content of the file conforms to Fortran-77 or some specific standard. Similarly, a file suffix of ".f90" indicates to the compiler that the source file is free form, not that it adheres to the Fortran-90 standard.

Code:
!   This is a program for calculating halfmatrices of marital exchange
!   rates between places and using them as input into mdscal and clustan
!
program mxr
   implicit none
!
   real , dimension(7) :: coltot , rowtot
   integer :: i , j , k , m , n
   real , dimension(7,7) :: marexm , pmrexm
!
   n = 7
   m = n - 1

!
   open(15,file='mm.dat',form='formatted',status='old')
   read(15, '(7F5.0)')((marexm(i,j),j=1,n),i=1,n)
   close(15)
!
   do i = 1 , n
      rowtot(i) = sum(marexm(i,1:n))
      coltot(i) = sum(marexm(1:n,i))
   end do
!
   do i = 1 , n
      do j = 1 , n
         pmrexm(i,j) = marexm(j,i) + marexm(i,j)                     &
                      & /((rowtot(i)+rowtot(j)+coltot(i)+coltot(j))/2)
      end do
      pmrexm(i,i:n) = 0.0
   end do
!
   write(*,1)((marexm(i,j),j=1,n),i=1,n)
   write(*,2)rowtot
   write(*,3)coltot
   write(*,4)((pmrexm(i,j),j=1,m),i=2,n)
!
   open(17,file='shmatrix.txt',form='formatted',status='replace')
   write(17,'(2x,6F8.5)')((pmrexm(i,j),j=1,6),i=2,7)
   close(17)
!
 1 format(' '//5x,' MARRIAGE EXCHANGE INPUT DATA ',//,7(2x,f5.0)/)
 2 format(5x,' ROW TOTALS OF RAW DATA',//1x,(7(f5.0,2x))///)
 3 format(5x,' COLUMN TOTALS OF RAW DATA',//1x,(7(f5.0,2x))///)
 4 format(' '//5x,' STOCHASTIC HALFMATRIX OF AVERAGED EXCHANGE RATES'&
        & ,//(2x,7F8.5))
end program mxr
Back to top
View user's profile Send private message
DavidColeman



Joined: 06 Apr 2022
Posts: 12

PostPosted: Sat Apr 09, 2022 6:07 pm    Post subject: Re: Reply with quote

mecej4 wrote:
It was not much trouble.

Below is given a free-form source version of the same program. Save it to a file with ".f90" as the extension before compiling and linking.

It may be helpful to note that the file suffixes ".f" and ".for" only indicate to the compiler that the source file is in fixed form, not that the content of the file conforms to Fortran-77 or some specific standard. Similarly, a file suffix of ".f90" indicates to the compiler that the source file is free form, not that it adheres to the Fortran-90 standard.

Code:
!   This is a program for calculating halfmatrices of marital exchange
!   rates between places and using them as input into mdscal and clustan
!
program mxr
   implicit none
!
   real , dimension(7) :: coltot , rowtot
   integer :: i , j , k , m , n
   real , dimension(7,7) :: marexm , pmrexm
!
   n = 7
   m = n - 1

!
   open(15,file='mm.dat',form='formatted',status='old')
   read(15, '(7F5.0)')((marexm(i,j),j=1,n),i=1,n)
   close(15)
!
   do i = 1 , n
      rowtot(i) = sum(marexm(i,1:n))
      coltot(i) = sum(marexm(1:n,i))
   end do
!
   do i = 1 , n
      do j = 1 , n
         pmrexm(i,j) = marexm(j,i) + marexm(i,j)                     &
                      & /((rowtot(i)+rowtot(j)+coltot(i)+coltot(j))/2)
      end do
      pmrexm(i,i:n) = 0.0
   end do
!
   write(*,1)((marexm(i,j),j=1,n),i=1,n)
   write(*,2)rowtot
   write(*,3)coltot
   write(*,4)((pmrexm(i,j),j=1,m),i=2,n)
!
   open(17,file='shmatrix.txt',form='formatted',status='replace')
   write(17,'(2x,6F8.5)')((pmrexm(i,j),j=1,6),i=2,7)
   close(17)
!
 1 format(' '//5x,' MARRIAGE EXCHANGE INPUT DATA ',//,7(2x,f5.0)/)
 2 format(5x,' ROW TOTALS OF RAW DATA',//1x,(7(f5.0,2x))///)
 3 format(5x,' COLUMN TOTALS OF RAW DATA',//1x,(7(f5.0,2x))///)
 4 format(' '//5x,' STOCHASTIC HALFMATRIX OF AVERAGED EXCHANGE RATES'&
        & ,//(2x,7F8.5))
end program mxr


Thank you for your further kindness in sending the free format version, and the note on suffixes.

I have run your first, fixed-format version and produced results. Very gratifying.

However I am baffled by my inability to persuade the 'View' tab in Plato to produce a DOS box to repeat that procedure or to link and run another program that I have prepared.. I assume that is the only way of running an .exe program but I wonder what conditions are required to make the DOS box appear. I'm sorry that my learning curve is rather steep.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sat Apr 09, 2022 6:28 pm    Post subject: Reply with quote

Paul Laidler has created several videos on Youtube that may be useful in learning how to use the FTN95 tools.

www.silverfrost.com has lots of documentation that you can view in a browser.

You can use any program editor or Plato. Plato has some additional capabilities for Fortran program development that other editors may not provide. You have to create a project, add one or more Fortran source files to the project, and build. You do not need to open a command window ("DOS Box") for this purpose.

On the other hand, you can do compiling, linking and running completely in a CMD window. Open CMD.EXE from the Windows Start menu, and run the batch file FVARS.BAT that is located in the FTN95 main directory. Then, change to your working directory, and compile, link, etc. For example, the commands

Code:
ftn95 mm1.f /link
mm1


will compile, link and run the program mm1.f .
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group