Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between USE and CALL 1

Status
Not open for further replies.

hswshock

Technical User
Apr 12, 2011
6
US
According to the subject, I am wondering the difference between USE and CALL. I know USE is used with SUBROUTINE to call for codes. But I am not clear with CALL statement. I am a beginner of fortran, may need your help in future times. Thanks.
 
These are two completely different statements:

First is for using a module in a program, or subroutine
[tt]USE module[/tt]

Second is for calling subroutine
[tt]CALL subroutine(arg_1,..,arg_n)[/tt]
 
hi,mikrom

you mean CALL is to implant another program into the current program,right? However,USE can be used in the same program and implant modules from current program.
 
For your better understanding look at the simple example from this older thread:

In the example above, there is a module csv_mod and the main program csv_read written in the source file csv_read.f95.
In the module csv_mod there are 2 subroutines declared:
parse_header and parse_data

Now, to make the subroutines from the module available to our main program, we have first to USE the module and then we can CALL the subroutines where we need them:
Code:
...
program csv_read
  use csv_mod
...
      call parse_header(separator, adjustl(trim(line)), csv_header)
...
      call parse_data(separator, adjustl(trim(line)), csv_data, nr)
...
end program csv_read

Next, I suggest you try to create a simple program with modules because learning by doing is the best method I know.
:)
 
Clear about it. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top