Silverfrost Forums

Welcome to our forums

problem on calling a subroutine inside a module

28 Jun 2014 3:16 #14290

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

28 Jun 2014 4:18 #14291

You need to put the module before the main program.

28 Jun 2014 5:57 #14292

no these codes are separated in two files

28 Jun 2014 8:15 #14293

when i run the main program , error message on the line that calls subroutine appears.

29 Jun 2014 6:36 #14294

Your program runs OK for me. What is the error message?

29 Jun 2014 10:20 #14295

error message: Error 29,call to missing routine:_SWAPMOD!SWAP at 0x00401099

29 Jun 2014 11:18 #14296

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).

29 Jun 2014 8:26 #14297

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.

29 Jun 2014 11:51 #14298

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.

Please login to reply.