Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Converting .f90 file to .for

WESSEL_S_
Beginner
2,030 Views

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.

 

0 Kudos
8 Replies
Mark_Lewy
Valued Contributor I
2,030 Views

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:

347996

0 Kudos
WESSEL_S_
Beginner
2,030 Views

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?

0 Kudos
Mark_Lewy
Valued Contributor I
2,030 Views

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.

0 Kudos
TimP
Honored Contributor III
2,030 Views

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?

0 Kudos
Greg_T_
Valued Contributor I
2,030 Views

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

0 Kudos
WESSEL_S_
Beginner
2,030 Views

You have to excuse me, I very new to Fortran. How do I get the compiled object file?

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,030 Views

Google: ifort command line

The top few links will give you some insight.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
2,030 Views

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.

0 Kudos
Reply