Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running multiple subroutines for analysis 1

Status
Not open for further replies.

yaston4

Mechanical
Jan 9, 2012
130
0
0
GB
I am trying to find some advice on running multiple subroutines for an abaqus analysis.

Should each subroutine have a seperate file or should be subroutines be placed in the same .for file? How should the subroutines be structured within the subroutine. Thanks.
 
Replies continue below

Recommended for you

So is the following format correct... as I want to make sure my methodology is correct. As I can not find a standard for this. I appreciate any input. Thanks

Subroutine One(args)
CODING
Return
End Subroutine One

Subroutine Two(args)
CODING
Return
End Subroutine Two

END
 
your subroutine is correct, but you need one conditional that use the subroutine in every case that you need, for example

if (mat="mat1") then
subroutine One
else (mat="mat2")
subrotuine Two
endif

I use this form and this run...i hope can help you!
 
Thanks lanavi017,

Do you place this about the two subroutines? As when I run this with my input file, it seems that the subroutine fails. I would appreciate some advice on the structure.

e.g.

PROGRAM PROG1

if (mat="mat1") then
subroutine One
else (mat="mat2")
subrotuine Two
endif

Subroutine One(args)
CODING
Return
End Subroutine One

Subroutine Two(args)
CODING
Return
End Subroutine Two

END

Also can this be done without a conditional statement, i.e. I would like both subroutines to run throughout the analysis.
 
Hi,

I would like join to discussion about multiply subroutine.
At the beginning we need to distinguish what kind of subroutine we want to use.
Is it abaqus subroutine (UDISP, UMAT, …) or is it user subroutine wrote to perform specific tasks?

For Abaqus subroutine we have following limitation:
1. each subroutine can be call only one time (all distinguish between different materials
must be perform inside abaqus subroutine with conditional statements (IF, SELECT CASE).

We can do it like this:
Code:
 subroutine UMAT(args)
…
if (cmname == ‘MAT1’) then
  code for mat1 …
else if (cmname == ‘MAT2’) then
  code for mat2 …
end if
…
end subroutine UMAT
We cannot do it like this:
Code:
 subroutine UMAT(args)
…
if (cmname == ‘MAT1’) then
  code for mat1
end if
…
end subroutine UMAT

subroutine UMAT(args)
…
if (cmname == ‘MAT2’) then
  code for mat2
end if
…
end subroutine UMAT
Here is obvious error since FORTRAN does not allow us to have two subroutines with the same name.

2. we must not call one abaqus subroutine from another abaqus subroutine
Following source code is wrong, even FORTRAN compilator will not give us an error. Results for this combination are unpredictable.
Code:
 subroutine UMAT(args)
…
call USDFLD(args)
…
end subroutine UMAT

subroutine USDFLD(args)
…
code for USDFLD
…
end subroutine USDFLD
Of course we can have more than one abaqus subroutine in one file.
Abaqus himself will call both subroutines.
Code:
subroutine UMAT(args)
…
code for UMAT
…
end subroutine UMAT

subroutine USDFLD(args)
…
code for USDFLD
…
end subroutine USDFLD(args)
With user subroutines is easier, we do not have such limitation. We can define both internal and external subroutines.

Code:
subroutine UMAT(args)
…
if (cmname==’MAT1’) then
  call mySubMat1(args) ! call internal subroutine
else if (cmname==’MAT2’) then
  call mySubMat2(args) ! call external subroutine
end if

contains ! define internal subroutine

subroutine mySubMat1(args)
…
code for mySubMat1(args)
…
end subroutine mySubMat1

end subroutine UMAT

! define external subroutine
subroutine mySubMat2(args)
…
code for mySubMat2
…
end subroutine mySubMat2
One more thing I prefer use always internal user subroutine, I had one time problems with arguments passed into external subroutine with gfortran.
But the same source code worked well with Intel fortran. Perhaps it’s something with gfortran settings I do not know.

Regards,
Bartosz
 
Status
Not open for further replies.
Back
Top