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 

Using .MOD files in Fortran programs
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


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

PostPosted: Sat Dec 01, 2007 4:35 pm    Post subject: Reply with quote

Instead of using /mod_path on the FTN95 command line (directly or via a Plato build), you can create an environment variable named MOD_PATH and provide the name of a folder or a list of folders (that contains the .MOD files).

Then you will not need to use /mod_path on the command line.

You can use the environment variable when building in a DOS box (using /link) or when building a single program file (without creating a project) in Plato.

If you create a project in Plato then you must add a "Reference" for each relevant .obj file by using the "Project Explorer" window. Alternatively you can build the module(s) into a .DLL or .LIB and reference the library instead.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: Nürnberg, Germany

PostPosted: Mon Dec 03, 2007 11:55 am    Post subject: .LIB and .MOD Reply with quote

Hi Paul,

if I choose a static library (.lib) which includes a module definition, how is this then handled in a new project?

As a result I have the following 2 files for a xml parser:
    1. xmlparse.lib
    2. xmlparse.mod

If I add xmlparser.lib as a reference to my project to I still need the xmlparse.mod file?

I think my questions are very simple and the solution, but it is difficult to exactly unterstand or implement the library concepts without an example. A small example in the documentation will defenitlay help Wink Trying all the possible combinations is also very time consuming.

Jacques
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Dec 03, 2007 5:01 pm    Post subject: Reply with quote

You need the .MOD files at compile time because they provide information for the USE statements in your code.

You would need a reference to the library at link time because this information is required by the linker. For static libraries the object code from the library is built into your executabel by the linker. For a dynamic library the linker adds information to the executable so that the library can be linked dynamically at runtime.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: Nürnberg, Germany

PostPosted: Tue Dec 04, 2007 10:15 am    Post subject: static library Reply with quote

Hi Paul,

I created some static library from the command line using slink
Code:
slink -archive:xmlparser.lib -addobj:xmlparser.obj


Then from Plato Project -> Add References.. I linked to the xmlparser.lib file. This works ok for my application.

For better understanding could you please explain the following:
1. When should I use a static library and when a dll?
2. During a build is the source compiled and link or what happens during a biuld?

Thanks
Jacques
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Dec 04, 2007 1:58 pm    Post subject: Reply with quote

You can also create a static library via a project in Plato.

1. Use a DLL when your library is shared by many executables and you want the executables to be small.

2. To build means to compile any files that have been changed and then link. You can also separately compile any single file.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: Nürnberg, Germany

PostPosted: Thu Dec 06, 2007 12:45 pm    Post subject: dll Reply with quote

Hi Paul,

I tried the dll as well and it works quit well!

What I would like to know is how does the final program (release) knows where to find the dll? I would think that the program will first look in the current directory for the dll. But if more than one program uses the dll it would be better to have a central copy of that. If not in the current directory, how should I solve this?

Must I "register" the dll somehow? I tried regsvr32 xml_parser.dll but get the message that the entry point was not found. What does this mean and how can I solve this?

Jacques
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Dec 06, 2007 1:55 pm    Post subject: Reply with quote

Yes you can put the DLL in the local folder otherwise the usual place is C:\windows\system32 or its equivalent.

Basically any folder that is on the PATH environment variable.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: Nürnberg, Germany

PostPosted: Thu Dec 06, 2007 2:19 pm    Post subject: Reply with quote

Hi Paul,

and what about the entry point that is not found when I use regsvr32?

Jacques
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Dec 06, 2007 6:20 pm    Post subject: Reply with quote

You should not be using regsrv32 in this context.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: Nürnberg, Germany

PostPosted: Fri Dec 07, 2007 9:45 am    Post subject: Reply with quote

Hi Paul,

I understand the concept much better and also tested a dll and lib in a few projects with success. If one knows what to look for you find the information in the documentation.

From another topic http://forums.silverfrost.com/viewtopic.php?t=806 you mentioned to use EXTERNAL rather than a MODULE. There is however nothing the the documentation that explains the capability.

When should I use EXTERNAL or how should I decide wheter to use EXTERNAL or MUDULE?

Jacques
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Dec 08, 2007 12:29 pm    Post subject: Reply with quote

These are standard Fortran keywords that you will find described in a Fortran text book.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: Nürnberg, Germany

PostPosted: Mon Dec 10, 2007 10:34 am    Post subject: Text book Reply with quote

Hi Paul,

do you have any text books thsat you could recommend?

Jacques
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Dec 10, 2007 7:12 pm    Post subject: Reply with quote

"Fortran 95 Explained" by Metcalf and Reid.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
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