Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29275 토론

Compiling without MAIN program to Link with ABAQUS

John_W_2
초급자
2,341 조회수

Greetings,

I'm writing an ABAQUS FILM user subroutine.  The subroutine uses many supporting modules to get the job done, and works well with a dummy driver.  I'm most experienced writing stand-alone code, i..e., main + subs.  How do I compile in Visual Studio to create a single *.obj with only the sub and supporting modules to present to ABAQUS?  Excluding the main dummy program from the build generates an error regarding the missing external routine.  Failing that can I manually concatenate the many obj files VS makes into a single file, or must I concatenate the modules' source code to generate a single obj file?

Also: How can I get Visual Studio to create a makefile (NMAKE?) from the IDE so other users can recompile from the command line?  The HELP leaves me confused.  Creating a Makefile from scratch is always a painful exercise for me, and presenting the many supporting modules to the linker begs for a script.

Thanks,

John W

0 포인트
6 응답
mecej4
명예로운 기여자 III
2,340 조회수

What do you mean by "modules"? If you mean Fortran .MOD files, be aware that Abaqus will have no use for them, nor will the linker. These module files are produced by the compiler and are used by the compiler when compiling other Fortran files that contain USE statements for those modules. 

The other problematic issue could be your desire to generate a single .OBJ file from multiple source files. If that is really required, you can construct a new "container" Fortran source file which has INCLUDE statements for all the other source files. Compiling the container file by itself will produce a single .OBJ file, but for the compilation to succeed you must make sure that each module source is included before that module is invoked in a USE statement. In other words, the order in which the INCLUDE statements are listed is important, and the container file should be written after ascertaining the dependency graph.

Visual Studio no longer generates makefiles. However, there are a number of third party utilities that can scan multiple source files and generate a makefile. See, for example, http://personal.inet.fi/private/erikedelmann/makedepf90/manpage.html .

0 포인트
John_W_2
초급자
2,340 조회수

Thanks for the reply.  I Interpret your "container" source code as a single f90 file with nothing but the include statements in the appropriate order.  Will the compiler still require a main program? It seems like VS provides that functionality when I exclude the dummy main from the build, but I get the "missing external" error.  I expected that I'd have to start a different type of VS Project to get the obj files without a main.  I'm obviously outside my "swim lane."  I'll give the container file a try.

ABAQUS HELP calls for presenting either a *.f or *.obj when invoking the program so it can link in the user sub to make a custom executable.  I've assumed that I only get one since that is all they describe, but have not tried to present a couple dozen.  I'll give it a go - what is the worst that can happen?

I've likely misused the term "module."  I write multiple *.f90 files, each with Module - End Module blocks that contain subs & functions that perform similar/related functions.  They are stand-alone & I then can reuse them more easily.  VS produces an obj file for each.  The "modules" are then "used" in other subs to replace COMMON blocks &/or INCLUDE statements to make the variables and subs/functions available to other subs.  Perhaps not elegant, but it gets the job done.  You've answered the lingering question of what the *.mod file are - I have no intention of presenting them to ABAQUS,

Thanks for the link to 3rd party Makefile utilities - I'll stop looking through HELP.

JWW

0 포인트
mecej4
명예로운 기여자 III
2,340 조회수

I do not use VS to build, perhaps others can guide you better on that topic. However, VS always does separate compile and link steps. In your case, the link step will fail, but the .OBJ that you desire will have been generated. Therefore, apart from the slight unpleasantness of a "Failed" report, do you care? It seems to be that a "do not link" check box is what you need.

You could also choose a library type project. In this case, a library will be created instead of an EXE, and there will be no failure because it is OK for a library to not contain any object with the entry _MAIN__. Again, you ignore the .LIB that is created and simply use the .OBJ. 

0 포인트
IanH
명예로운 기여자 III
2,340 조회수

To compile a set of sources without generating an executable program (and hence without requiring a main program in the source set) use a static library project.  (Something like File > Add > New Project, expand Intel Visual Fortran, select the Library subitem, select "Static Library".)  This type of project generates a lib file that holds all the resulting object code.

Assuming by "compile from the command line" you mean compile without using Visual Studio at all (Visual Studio has a command line interface - see also the MS Build engine) - then Visual Studio no longer has the ability to generate makefiles, if my recollection is correct.  You will need to write the makefile by hand, if that's the build system that you decide to use (there are many options, most of which I think are much better than make alone).

0 포인트
Greg_T_
소중한 기여자 I
2,340 조회수

It looks like it is possible to use a .f90 free format user subroutine in the abaqus command line, if that would be preferable.  According to the Abaqus knowledge base QA article QA00000008251 "Building Abaqus FORTRAN 90 free-format user subroutines and postprocessing programs" there is an addition you can make to the abaqus_v6.env environment file to support the f90 free format in the user subroutine.  There is an example attached to that QA article with the syntax needed for the env file.  Then I think you would be able to concatenate all your f90 routines for the user subroutine into one file (exclude the main.f90), and then use the command line to have abaqus take care of compiling and linking your user subroutine to the analysis: abaqus user=mysub.f90 job=newjob...

I have had good success using the Intel Fortran initialized command window to run abaqus so that all the Fortran environment variables are initialized.  For example, I open: Start->All Programs->Intel Parallel Studio XE 2015->Compiler and Performance Libraries->Command Prompt with Intel Compiler->Intel 64 Visual Studio 2013 mode

0 포인트
dboggs
새로운 기여자 I
2,340 조회수

I'm having trouble understanding the difficulty of compiling a .f90 source file to make a corresponding .obj file without the complication of an exe file.

On my system, I use the VS editor to make the .f90 file (or add an existing source file created elsewhere to the project). Then, in the main menu, select Build > Compile and bingo there is your obj file. Or, in the solution explorer window, right-click on the f90 file and then Compile on the pop-up menu.

I must be missing something...

0 포인트
응답