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 

Library of subroutines

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Plato
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Wed May 24, 2006 3:58 am    Post subject: Library of subroutines Reply with quote

Hi

Does anyone know how to create a library of subroutines on PLATO3 which would then be automatically be accessible by means of a USE statement at the beginning of the program?

I have dozens of subroutines which I use regularly, so what I'd like to do would be to create a library called MAIN containing these subroutines, then at the beginning of a program I would have the statement: USE MAIN

Thereafter I could call any subroutine by saying CALL <name_of _subroutine>

Any help would be greatly appreciated as I have no idea how to do this.

Thanks,

Mikhail Kalashnikov
Back to top
PaulLaidler
Site Admin


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

PostPosted: Wed May 24, 2006 12:39 pm    Post subject: Library of subroutines Reply with quote

Mikhail

The standard approach is to create a dynamic link library (DLL) of external subprograms rather than module procedures. To do this you simply create a project for a DLL rather than an executable.

In another project you can then access the DLL by using a "Reference" in the Project Explorer window. In this situation you do not need a USE statement in the code. External subroutines (in the DLL) can be called without declaring them. Functions should be declared like variables according to their return type, e.g,

REAL x, func
.....
x = func(2.0)

However...

If a call is made to an external subprogram that uses OPTIONAL or KEYWORD arguments or passes arrays that are "assumed shape" (i.e. use a colon rather than a star) then you must provide an INTERFACE that declares the subprogram.
Back to top
View user's profile Send private message AIM Address
Anonymous
Guest





PostPosted: Thu May 25, 2006 3:56 am    Post subject: Library of subroutines Reply with quote

Paul

Thanks very much for your help. However, I am still having some trouble.

I selected "New project" and from there I chose "Fortran DLL".
Then, from the "project" menu, I selected "Add existing item" and selected all of the subroutines and functions which I wanted to include.
These subprograms were then listed in "source files" on the right hand side of the screen.

Next I hit "build" and the compilation completed without any errors.
Then, however a message appeared saying "Cannot create DLL: nothing to export"

What am I missing here?

Sorry about all the questions. I'm new to Fortran.

Thanks again


Mikhail Kalashnikov
Back to top
PaulLaidler
Site Admin


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

PostPosted: Thu May 25, 2006 6:11 am    Post subject: Library of subroutines Reply with quote

In the Project Properties dialog select Configuration Properties->Linker Options->Linker Options->Export all.
Back to top
View user's profile Send private message AIM Address
Anonymous
Guest





PostPosted: Thu May 25, 2006 7:20 am    Post subject: Library of subroutines Reply with quote

Thanks a million Paul!

Mikhail Kalashnikov
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Plato 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