Skip navigation.
Home

Refactoring Fortran Code for Abaqus Finite Element Analysis with the Portable Batch System

Some MS-Windows Win-32 Intel Fortran code was produced with Visual Studio. The user, working on a 3D optimization of bone structure, wanted the code refactored to 64-bit Linux GNU Fortran 90 to be suitable for the Abaqus Finite Element Analysis software, and to be able to run on a cluster. This was in many ways a "first draft" modification of the code and further development is planned. It illustrates a basic introduction to some relatively interesting differences within Fortran and (yet another) practical use of job arrays. The Fortran itself code consisted of several files of around 500 lines each. The largest was 1211 lines. The main Build file would take an Abaqus input file, and rebuild files for testing material blocks of the representative cell. This would be followed by the application of homogenisation theory for 3D optimisation of bone structure.

In terms of basic refactoring, the first discovery is that line continuation in the code was marked with a "1" on the continued line, following the Fortran77 method of placing a character in column 6 of that next line. This generated quite a few compilation errors, not to mention being a little difficult in terms of visually parsing the text on multiline equations. These were replaced with the ampersand on the line that is to be continued, as per the free-form method. Another issue was that comments were also expressed in Fortran 77 style; these replaced with the more contemporary exclamation mark. One file included a dialogue library which fell victim to become a comment.

That really was the easy part. A quirky modification was made for file tests and assignments using logical relationship operators, along with making some modifications to ensure that an outer do-while did not conflict with an inner if-then (a stackoverflow answer was similar). An encounter with field width issues for some critical read variables from the Abaqus input files, alerted us to the difference in the handling of white space. A hack was engaged just to get us through the day, but future development will include the running of a short sed script sed -i 's/ //g' Cell.inp

The build code took an Abaqus input file and rebuilt and generated several new input abaqus files. The homogenisation code was run over these files producing the Abaqus linear dynamics (.sim), output dabase (.odb), and results (fil) files. Because identical tasks were being conducted over multiple files that required the same computational resources this was best expressed through a PBS job array. As licensed software, Abaqus required license requests in addition to the usual resource calls. Deriving from information in a MS-DOS batch file, the following minimal PBS script was produced.


#! /bin/bash
#PBS -l nodes=12
#PBS -l walltime=0:05:00
#PBS -N CellArray
#PBS -W x=GRES:abaqus+14
#PBS -t 1-6
cd $PBS_O_WORKDIR
module load abaqus
./BuildRCTest
abaqus job=CellT${PBS_ARRAYID}.inp interactive
./CalMtrl
rm -f *.dat *.res *.sta *.stt *.com *.msg *.prt *.fin *.sel *.pac *.abq *.mdl

User response: "..

User response: ".. unbelievably, you could be able to transfer a Homogenization code with Visual studio windows platform to Linux gcc compiler. the outcome was amazing and run[s] really fast on Linux based machine."