- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi every body,
I am a C++ programmer and new to fortran. Could you please let me know how I can slip a long Fortran code in to multiple files, like what we normally in C++ by include?
Thank you,
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran provides the following statement (surprise!)
include character-literal-constant
However, splitting a big source code into chunks and 'include' segments is probably not a good style of programming, and may create many headaches. Consider using modules instead.
Some Fortran compilers, including Intel Fortran also provide C-style preprocessors.
include character-literal-constant
However, splitting a big source code into chunks and 'include' segments is probably not a good style of programming, and may create many headaches. Consider using modules instead.
Some Fortran compilers, including Intel Fortran also provide C-style preprocessors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran supports MODULE syntax, "to group related procedures and data together," along with both its own form of INCLUDE and, for most compilers, a C-compatible form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you! Since I am using this fortran program for ABAQUS (a modeling software), it is necessary the output to be just one obj file. So if I use module, it will be split into multiple obj files. I am not sure if include can help me or not in this regard which is aridiculousness of that modeling software. Shame on its developers! Do you have any other idea?
Thanx!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just do it with INCLUDE as you do in C++.
include 'file1.f90'
include 'file2.f90'
include 'file3.f90'
etc.
include 'file1.f90'
include 'file2.f90'
include 'file3.f90'
etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanx! But it gives me an error as I have introduced a subroutine in the first line of the included file. Anyway, I could solve the problem by changing the project type from a stand-alone to static link library, so all objs are now included in a lib / obj file, which is usable for the modeler software.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Odd - I can't think of a reason why you should get an error assuming each file was compilable on its own. Can you attach a ZIP of an example?

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page