- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I using Fortran to write a subroutine for ABAQUS. ABAQUS requires a .for file for the input and mine is now in .f90 format. Is there an easy way to convert this? I've also attached my subroutine
Your help would be appreciated.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1) Rename your file to have extension .for to indicate a fixed format Fortran source file.
2) The subroutine declaration line is too long for fixed format; split the declaration before column 72 (say after LAYER,). The continuation line needs to have a (non-blank, non-zero) character in column 6 to indicate continuation (I normally use the & character)
3) Convert the tabs in your file to spaces. In VS 2012 do this by select all (CTRL+A), Edit->Advanced->Untabify Selected Lines.
You may want to change your text editor options for Fortran (in Tools->options) to Insert Spaces instead of Keep tabs.
Converted source attached:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the quick reply. Now I get the error:
1>libifcoremt.lib(for_main.obj) : error LNK2019: unresolved external symbol _MAIN__ referenced in function _main
1>Debug\Console1.exe : fatal error LNK1120: 1 unresolved externals
I think it has to do with whether you have a 32bit or 64bit computer, but I don't know how to solve it.
Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I assume this is because your project just contains console1_1.for? If your project is a console application (as I'm assuming from the file name) then you need a program unit that calls your subroutine to resolve the unresolved external.
This might not be what you need to do to call the subroutine from ABAQUS, however, but I have no knowledge of ABAQUS, so someone else would have to answer that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's difficult to believe that Abaqus would care whether a user procedure is written in fixed or free format, unless their include file is written so as to be incompatible with free format.
As your source file appears to be compatible with fixed format, why not either rename it or set the fixed format compile option?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am pretty sure that another option is to provide the compiled object (*.obj) file for the Abaqus user subroutine on the Abaqus command line "user=" option. That way you could compile (but don't link) the console_1.f90 routine as it is without needing to convert to the *.for fixed format. Then specify "user=console_1.obj" on the Abaqus command line when running the analysis so that the object file is used instead of the source file. Abaqus will then link to the obj file during the preprocessing step of the analysis. By only compiling and not linking, you will avoid the linker error you reported, as Abaqus is the "main" program calling the user subroutine.
In the Abaqus documentation: "Abaqus Analysis User's Guide", in section: "3.2.2 Abaqus/Standard, Abaqus/Explicit, and Abaqus/CFD execution", look for the "user" command line option. The description indicates that a source file or object file can be provided, so that indicates you have the option to provide the already compiled object file.
When using a user-defined subroutine with Abaqus I recommend also writing a small "main" program that will call your user subroutine and pass in the necessary input values to test it. Using a main program will allow you to run tests on the user subroutine outside of Abaqus to confirm that the user subroutine is returning the values you expect before running a full FEA.
Regards,
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have to excuse me, I very new to Fortran. How do I get the compiled object file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Google: ifort command line
The top few links will give you some insight.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or you could read the documentation we provide with the product, especially the "Getting Started" topics. But I am also doubtful that Abaqus really forces you to use .for files. I could believe that this is what they use in examples.

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