Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
module linking and program compilation (novice question)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Civil Eng  
View profile  
 More options Jun 1, 5:40 am
From: Civil Eng <tanjuoz...@gmail.com>
Date: Mon, 1 Jun 2009 02:40:20 -0700 (PDT)
Local: Mon, Jun 1 2009 5:40 am
Subject: module linking and program compilation (novice question)
hi all,

I'm studying a program which is compiled with G95.In this program each
subroutine/function resides in seperate file (such as getname.f95)
orginal creator has created a mod file (such as main_int.f95) to
compile and run the programs it just calls "Main" in their USE clause
where each subroutine/function is known to compiler at the compile
time.

content of "getname.f95"
SUBROUTINE getname(argv,nlen)
.....
....! Implementations goes here
...
END SUBROUTINE getname

content of main_int.f95
MODULE main
INTERFACE
SUBROUTINE getname(argv,nlen)
.....
..... Implementations for all subroutines goes here
.....
END INTERFACE
END MODULE main

When I compile the main_int.f95 the program creates "main.mod" and
"main_int.o" file and when calling for execution with the following
command
"g95  -o  new_program.exe  C:\source\library\main\main_int.f95     E:
\g95\bin\Projects\P44.f95"

compiler show errors for each called subroutines/functions
"undefined reference to '_getname_'
.....
......
.....

Source code and the program to be executed are in different partition
of hard disk could that be reason of compilation errors ?

Any help will be appreciated

Regards,


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Doug  
View profile  
 More options Jun 1, 7:53 am
From: Doug <t...@sentex.net>
Date: Mon, 1 Jun 2009 04:53:22 -0700 (PDT)
Local: Mon, Jun 1 2009 7:53 am
Subject: Re: module linking and program compilation (novice question)

On Jun 1, 5:40 am, Civil Eng <tanjuoz...@gmail.com> wrote:

If you have another main program, not shown here, you can compile the
components separately.

"g95  -c C:\source\library\main\main_int.f95"
"g95  -c E:\g95\bin\Projects\P44.f95"

If all goes well you will get two object files that you can then link
in a main program. Something like this:

"g95  -o  new_program.exe  main_int.o P44.o" main.f95"

Doug


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Civil Eng  
View profile  
 More options Jun 1, 8:42 am
From: Civil Eng <tanjuoz...@gmail.com>
Date: Mon, 1 Jun 2009 05:42:10 -0700 (PDT)
Local: Mon, Jun 1 2009 8:42 am
Subject: Re: module linking and program compilation (novice question)
hi Doug,

Let's assume that I've two files just "main_int.f95" (module file
where each subroutine/functions is bundled together in that file) and
main program "P44.f95" which uses main.mod in its USE clause to
retrieve necessary subroutine.

content of P44.f95
PROGRAM p44
 USE main
 IMPLICIT NONE
 INTEGER,PARAMETER::iwp=SELECTED_REAL_KIND(15)
 ...........
 ...........
END PROGRAM p44

After compiling these files, I got all required object files
"main.mod", "main_int.o" , "p44.o" under the g95\bin directory

So which command I've to use to link them ?

with command
g95 -o new_program.exe main_int.o P44.o "main.f95"                I
got the same error mesages

with command
g95 -o new_program.exe main_int.o P44.o "Projects\P44.f95"    The
result is same

P.S. I even noticed that this time compiler raises the error mesages
for "P44".o as well
P44.o: P44.f95 : <.text+0x50c> undefined reference to '_getname_'
.....
.....

Thanks in advance


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Civil Eng  
View profile  
 More options Jun 1, 12:47 pm
From: Civil Eng <tanjuoz...@gmail.com>
Date: Mon, 1 Jun 2009 09:47:08 -0700 (PDT)
Local: Mon, Jun 1 2009 12:47 pm
Subject: Re: module linking and program compilation (novice question)
Any help please!!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Civil Eng  
View profile  
 More options Jun 1, 1:19 pm
From: Civil Eng <tanjuoz...@gmail.com>
Date: Mon, 1 Jun 2009 10:19:10 -0700 (PDT)
Local: Mon, Jun 1 2009 1:19 pm
Subject: Re: module linking and program compilation (novice question)
Aggghh Sorry my bad,

Main_int.f95 comprises only from subroutine/function declarations with
variables there are no implementation in that source file so it's kind
of header file. The real implementation of subroutines/functions
resides in seperate file where filename is associated with subroutine
(probably for sake of clarity and flexibility)
The content is "main_int.f95

MODULE main
!
INTERFACE
!
SUBROUTINE bandred(a,d,e)
 IMPLICIT NONE
 INTEGER,PARAMETER::iwp=SELECTED_REAL_KIND(15)
 REAL(iwp),INTENT(IN OUT)::a(:,:)
 REAL(iwp),INTENT(OUT)::d(0:),e(0:)
END SUBROUTINE bandred
....
....
SUBROUTINE getname(argv,nlen)
 IMPLICIT NONE
 INTEGER::narg
 INTEGER,INTENT(OUT)::nlen
 CHARACTER(*),INTENT(OUT)::argv
 INTEGER::lnblnk,iargc
END SUBROUTINE getname
....
....
END INTERFACE
!
END MODULE main

So how am I supposed to compile that file, which has dependency to
each subroutine, and provide input for the main program ?

On 1 Haziran, 19:47, Civil Eng <tanjuoz...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Doug  
View profile  
 More options Jun 1, 3:46 pm
From: Doug <t...@sentex.net>
Date: Mon, 1 Jun 2009 12:46:19 -0700 (PDT)
Local: Mon, Jun 1 2009 3:46 pm
Subject: Re: module linking and program compilation (novice question)

On Jun 1, 1:19 pm, Civil Eng <tanjuoz...@gmail.com> wrote:

In your first post you said "each subroutine/function resides in
seperate file (such as getname.f95)" so you will have to compile each
of these subroutines, or list them all when compiling main_int.f95.

If you have all these files in C:\source\library\main, you should
probably compile your module in that directory:

cd C:\source\library\main
g95  -c main_int.f95 getname.f95 ...  <add the names of all the other
files containing subroutines contained in main_int.f95>

Hope this helps,

Doug


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Civil Eng  
View profile  
 More options Jun 1, 5:01 pm
From: Civil Eng <tanjuoz...@gmail.com>
Date: Mon, 1 Jun 2009 14:01:29 -0700 (PDT)
Local: Mon, Jun 1 2009 5:01 pm
Subject: Re: module linking and program compilation (novice question)
Thanks for your help Doug

> In your first post you said "each subroutine/function resides in
> seperate file (such as getname.f95)" so you will have to compile each
> of these subroutines, or list them all when compiling main_int.f95.

Yes they are. Compiled them with g95 -c .....\main\*.f95

> If you have all these files in C:\source\library\main, you should
> probably compile your module in that directory:

I've compiled the module in that directory as well but result same. It
seems that trying to compile with that module, compiler never
recognize the inlcuded subroutines.

On the contrary compiling with following command everything works
fine, never refering to mod file just dealing with source files
g95 c:\source\library\main\*.f95  P44.f95  -o  MyP44.exe

After googling around for a while I found that "main_int.f95" is
interfaced module it contains only subroutine headers that is
subroutine's name, argument list and declaration of argument types.
AFAIU the purpose of keeping the each subroutine in seperate file is,
to addopt the alterations made to the program more conveniently.   Any
changes that made to those seperate files can easily be updated in
main_int.f95 (I presume that this is benefits of smart-compiling)

The thing that I couldn't figured out is, how to get that worked with
mod file ?

It may seem that I'm dancing around the same issue even I've overcome
it, but I'm sure that one way or the other I'll face in the future so
I prefer to face it now.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google