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.
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.