Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Can't link compiled fortran files together

  1. #11
    Join Date
    Jan 2013
    Beans
    13

    Re: Can't link compiled fortran files together

    Quote Originally Posted by sudodus View Post
    Please post your link command line (or makefile)!

    As an example, the -lm option solved the problem with undefined reference in another case (in an Ubuntu Forums thread)

    Code:
    cc -o sqrt sqrt.c -lm
    sorry but by link command line do you mean this?
    Code:
    gfortran -o cor69 lateralf.o qgsjet-II-03.o gheisha_2002d.o

    there are a lot of make file...which one should i post here?

  2. #12
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Can't link compiled fortran files together

    Quote Originally Posted by msgeo View Post
    sorry but by link command line do you mean this?
    Code:
    gfortran -o cor69 lateralf.o qgsjet-II-03.o gheisha_2002d.o

    there are a lot of make file...which one should i post here?
    If you post your makefiles for this particular program (or links to them), it might be easier to help.

    I have two questions before we continue to try other things:

    1. Did you try to repeat (in Ubuntu) the method that worked with fedora 2 .4.22 using gcc commands?
    2. Did you try using the f2c/gcc combination according to this link?

    http://valhalla.fcaglp.unlp.edu.ar/~computacion/Manuales/Online/flinux/index.html

  3. #13
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Can't link compiled fortran files together

    I had some time to fix your program:

    1. Declaration of character variables
    2. Opening of file (not necessary, otherwise the program writes to the file fort.7)
    3. Added a write statement to the terminal write(*,...)

    And simply used
    Code:
     gfortran -o prtime prtime.f
    which compiled and linked a working program for me

    Code:
    C-----------------------------------------------------------------------
    C  PR(INT) TIME
    C
    C  PRINTS PRESENT DATE AND TIME AND GIVES IT IN A FORMAT SUITED FOR THE
    C  RUNHEADER AND EVENTHEADER.
    C  THIS SUBROUTINE IS CALLED FROM AAMAIN AND START.
    C  ARGUMENT:
    C   TTIME  = TIME (YYMMDD)
    C
    C  IF OUR DATE ROUTINE DOES NOT FIT TO YOUR COMPUTER, PLEASE REPLACE
    C  IT BY A SUITABLE ROUTINE OF YOUR SYSTEM
    C  FOR COMPILERS WITH NEWER DATE FUNCTIONS, INCLUDING DEC UNIX f77
    C  AND RECENT GNU g77 >0.5.21 (egcs 1.1.x, gcc 2.95, ...)
    C  IF YOR COMPUTER DOES NOT KNOW SUBROUT. DATE_AND_TIME
    C  REPLACE THIS CALL BY A CALL TO YOUR SYSTEM ROUTINES TO
    C  FILL THE INTEGERS: IYEAR, MONTH, IDAY, IHOUR, IMINU, ISEC
    
          character*8 YYYYMMDD
          character*6 HHMMSS
    
          open(7,file="printed-time.txt")
    
          CALL DATE_AND_TIME( YYYYMMDD, HHMMSS )
          READ(YYYYMMDD,'(I4,2I2)') IYEAR,MONTH,IDAY
          READ(HHMMSS,'(3I2)') IHOUR,IMINU,ISEC
          write(7,100) IDAY,MONTH,IYEAR,IHOUR,IMINU,ISEC
          write(*,100) IDAY,MONTH,IYEAR,IHOUR,IMINU,ISEC
          TTIME = MOD(IYEAR,100)*10000 + MONTH*100 + IDAY
     100  FORMAT(' PRESENT TIME : ',I2.2,'.',I2.2,'.',I4,I4.2,':',I2.2,
         *       ':',I2.2)
    
          RETURN
          END
    Last edited by sudodus; January 22nd, 2013 at 11:06 PM. Reason: removing doublet text

  4. #14
    Join Date
    Jan 2013
    Beans
    13

    Re: Can't link compiled fortran files together

    Quote Originally Posted by sudodus View Post
    I had some time to fix your program:

    1. Declaration of character variables
    2. Opening of file (not necessary, otherwise the program writes to the file fort.7)
    3. Added a write statement to the terminal write(*,...)

    And simply used
    Code:
     gfortran -o prtime prtime.f
    which compiled and linked a working program for me
    Thank you so much for the time you spent on this.
    but the problem seems to be unsolved.


    first to your previous question I should say that I used gcc/f2c combination but that one also gives some errors like this:
    Code:
     
     
    /tmp/fort77-29566-1.c:17864:12: error: conflicting types for ‘fctcos_’
    /tmp/fort77-29566-1.c:17302:33: note: previous declaration of ‘fctcos_’ was here
    /tmp/fort77-29566-1.c:26703:22: error: conflicting types for ‘rtmi_’
    /tmp/fort77-29566-1.c:17296:33: note: previous declaration of ‘rtmi_’ was here
    /usr/bin/f77: aborting compilation
    and about your correction on the PRTIME subroutine I should say that this a only a small part of the program and this is not my program.
    this a scientific program for Simulating cosmic rays.
    that one also comes with some errors:

    Code:
     
          character*8 YYYYMMDD                                              
                              1
    Error: Symbol 'yyyymmdd' at (1) already has basic type of CHARACTER
    lateralf.f:19183.24:
     
          character*6 HHMMSS                                                
                            1
    Error: Symbol 'hhmmss' at (1) already has basic type of CHARACTER
    lateralf.f:35547.10:

    here is the original file:

    http://sdrv.ms/Xwz3il

    and here is some snapshots of the program directory:
    http://sdrv.ms/VRokm2
    http://sdrv.ms/Uilgz3

    also i mentioned earlier that I'm able to compile files with gcc just like fedora but when I try to link files it comes with some errors!
    Last edited by msgeo; January 22nd, 2013 at 09:14 PM.

  5. #15
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Can't link compiled fortran files together

    Quote Originally Posted by msgeo View Post
    first to your previous question I should say that I used gcc/f2c combination but that one also gives some errors like this:
    Code:
     
    /tmp/fort77-29566-1.c:17864:12: error: conflicting types for ‘fctcos_’
    /tmp/fort77-29566-1.c:17302:33: note: previous declaration of ‘fctcos_’ was here
    /tmp/fort77-29566-1.c:26703:22: error: conflicting types for ‘rtmi_’
    /tmp/fort77-29566-1.c:17296:33: note: previous declaration of ‘rtmi_’ was here
    /usr/bin/f77: aborting compilation
    I see. That did not help

    Probably you had some other compiler or linker version or a library available in Fedora, that you don't have (yet) in Ubuntu.
    and about your correction on the PRTIME subroutine I should say that this a only a small part of the program and this is not my program.
    this a scientific program for Simulating cosmic rays.
    that one also comes with some errors:

    Code:
     
          character*8 YYYYMMDD                                              
                              1
    Error: Symbol 'yyyymmdd' at (1) already has basic type of CHARACTER
    lateralf.f:19183.24:
     
          character*6 HHMMSS                                                
                            1
    Error: Symbol 'hhmmss' at (1) already has basic type of CHARACTER
    lateralf.f:35547.10:
    Well, I had only the snippet you posted, and I needed declarations of the character variables to make the compiler happy. Obviously there are some kind of include statements or global statements, that declare the character variables.

    But I would like to know if you can create a working program of the fortran code in post #13 using the command line in the same post. That will show if your compiler and linker have enough 'horsepower' to do that (for example if there is such a time function or subroutine).

    I am running Ubuntu 12.04 LTS 32-bit with pae
    Code:
    uname -a
    Linux ssd-grund 3.2.0-36-generic-pae #57-Ubuntu SMP Tue Jan 8 22:01:06 UTC 2013 i686 i686 i386 GNU/Linux

    here is the original file:

    http://sdrv.ms/Xwz3il

    and here is some snapshots of the program directory:
    http://sdrv.ms/VRokm2
    http://sdrv.ms/Uilgz3

    also i mentioned earlier that I'm able to compile files with gcc just like fedora but when I try to link files it comes with some errors!
    I'll look at that later.

  6. #16
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Can't link compiled fortran files together

    Quote Originally Posted by msgeo View Post
    sorry but by link command line do you mean this?
    Code:
    gfortran -o cor69 lateralf.o qgsjet-II-03.o gheisha_2002d.o

    there are a lot of make file...which one should i post here?
    The .o files are compiled object code files. It might be enough, but you might need some kind of reference to the linker or some libraries (if more than the default ones are needed).

    This could be possible to see in one of the makefiles.
    --
    With the snippet in post #13 it was possible for me to compile to an object file with
    Code:
    gfortran -c prtime.f
    and to link with
    Code:
    gfortran -o prtime-from-o prtime.o
    It created a file identical to the one created directly from the fortran source code file. So yes, it could be possible to link with the command you suggested, at least concerning the prtime subroutine.
    Last edited by sudodus; January 23rd, 2013 at 12:19 AM. Reason: concerning the prtime subroutine

  7. #17
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Can't link compiled fortran files together

    Quote Originally Posted by msgeo View Post
    ...

    here is the original file:

    http://sdrv.ms/Xwz3il

    and here is some snapshots of the program directory:
    http://sdrv.ms/VRokm2
    http://sdrv.ms/Uilgz3

    also i mentioned earlier that I'm able to compile files with gcc just like fedora but when I try to link files it comes with some errors!
    I looked at it. Yes, I could see the whole time subroutine
    Code:
          SUBROUTINE PRTIME( TTIME )
    with declaration of variables, that were not there in the snippet.

    I also had a second look at the command line in post #1

    Code:
    gfortran -o file1.o file2.o file3.o -o outputfilename
    I think you'd make the compiler/linker confused with the two -o options. First you tell it to write the final program to file1.o and then to outputfilename. The correct syntax should be

    Code:
    gfortran -o outputfilename file1.o file2.o file3.o
    The command line in post #11 looks correct.
    Code:
    gfortran -o cor69 lateralf.o qgsjet-II-03.o gheisha_2002d.o
    and I guess this is the real thing

    If you still have problems, maybe you should check, if you have double definitions or calls to the time subroutine, that there is another one, that cannot be resolved.

    What about this one?

    Code:
          INTEGER          ILEFTA,ILEFTB,TIME
          EXTERNAL         TIME
    ...
    C  TIME AT BEGINNING
    
          ILEFTA = TIME()
    ...
    ...
    C  TIME SINCE BEGINNING
    
          ILEFTB = TIME()
    
          TDIFF  = ILEFTB - ILEFTA
    These are not calls to or via PRTIME

  8. #18
    Join Date
    Jan 2013
    Beans
    13

    Re: Can't link compiled fortran files together

    Quote Originally Posted by sudodus View Post

    But I would like to know if you can create a working program of the fortran code in post #13 using the command line in the same post.
    yes.that file compiled and linked successfully with gfortran.

  9. #19
    Join Date
    Jan 2013
    Beans
    13

    Re: Can't link compiled fortran files together

    I'm really grateful for your help...
    this ""time"" function isn't really important but i don't know how to get rid of it!

    just downloaded the fedora 18 to see if i can compile and link files on that

  10. #20
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Can't link compiled fortran files together

    Quote Originally Posted by msgeo View Post
    yes.that file compiled and linked successfully with gfortran.
    Then I think the problem is the call of
    Code:
    TIME()
    So you should make a function or subroutine instead of that to use the same time call as in PRTIME,

    Code:
    CALL DATE_AND_TIME( YYYYMMDD, HHMMSS )
    or some other call to the system time that is supported, and use the output of that instead of the external TIME() call. You should also check what unit it is supposed to be (seconds?)

Page 2 of 3 FirstFirst 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •