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 

problem on calling a subroutine inside a module

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



Joined: 27 Jun 2014
Posts: 5

PostPosted: Sat Jun 28, 2014 4:16 pm    Post subject: problem on calling a subroutine inside a module Reply with quote

hi everybody
i have problem on calling a subroutine that contains in a module through my main program . this is my simple code :
main program:
----------------------------------
program swapmain
use SWAPMOD ! use statements must come first
real :: a, b
! Read in two values
read(*,*) a, b
call swap(a,b)
write(*,*) a, b
end program swapmain
-----------------------------------
module swapmod
implicit none
contains
! routines provided by this module
subroutine swap(x,y)
real :: x, y, temp
temp = x
x = y
y = temp
end subroutine swap
end module swapmod
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Jun 28, 2014 5:18 pm    Post subject: Reply with quote

You need to put the module before the main program.
Back to top
View user's profile Send private message
mojtaba8726



Joined: 27 Jun 2014
Posts: 5

PostPosted: Sat Jun 28, 2014 6:57 pm    Post subject: Reply with quote

no these codes are separated in two files
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 558

PostPosted: Sat Jun 28, 2014 8:54 pm    Post subject: Reply with quote

a minor point, but what exactly is the 'problem' you have Mo ?
Back to top
View user's profile Send private message
mojtaba8726



Joined: 27 Jun 2014
Posts: 5

PostPosted: Sat Jun 28, 2014 9:15 pm    Post subject: Reply with quote

when i run the main program , error message on the line that calls subroutine appears.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun Jun 29, 2014 7:36 am    Post subject: Reply with quote

Your program runs OK for me.
What is the error message?
Back to top
View user's profile Send private message
mojtaba8726



Joined: 27 Jun 2014
Posts: 5

PostPosted: Sun Jun 29, 2014 11:20 am    Post subject: Reply with quote

error message:
Error 29,call to missing routine:_SWAPMOD!SWAP at 0x00401099
Back to top
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 526
Location: UK

PostPosted: Sun Jun 29, 2014 12:18 pm    Post subject: Reply with quote

Check your PATH (user or system) includes the FTN95 folder.

Try rebuilding dependencies in Plato (Build menu).

Try compiling your module first, then do a build (Build menu).
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
mojtaba8726



Joined: 27 Jun 2014
Posts: 5

PostPosted: Sun Jun 29, 2014 9:26 pm    Post subject: Reply with quote

i checked all the things that you mentioned above, and i still have the problem. my software is plato version 4.63. is this version support the USE statement? by the way i use the free version.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 732

PostPosted: Mon Jun 30, 2014 12:51 am    Post subject: Reply with quote

You said that you have two source files. In order to compile the main program, you would have to compile the file containing the module first. What you probably did was to link only the OBJ file with the main program. The linker would have produced an EXE file and issued an error message, which you may not have seen if you used an IDE.

Compile the two source files. Link the two OBJ files produced to produce the EXE file.
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 -> 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