0

I am using a Fortran user subroutine (UMAT) in Abaqus. I use it to run other Abaqus sub-calculations within my main calculation.

The sub-calculation names are variables, so I am defining them this way:

character (len=256) :: strJOB,strOLDJOB
character (len=256) :: strGoToWorkPath,strCommand,strCmdLine
character (len=256) :: temp, strNOEL, strNPT, striCalcs, striCalcsPrev

write(temp, '(i6)') NOEL
read(temp, *) strNOEL
temp = ''
write(temp, '(i6)') NPT
read(temp, *) strNPT
temp = ''
write(temp, '(i6)') iCalcs
read(temp, *) striCalcs
temp = ''
write(temp, '(i6)') (iCalcs-1)
read(temp, *) striCalcsPrev
temp = ''

strJOB = "micro_" // trim(strNOEL) //"_"// trim(strNPT) // "_" // trim(striCalcs)
strOLDJOB = "micro_" // trim(strNOEL) //"_"// trim(strNPT) //"_"// trim(striCalcsPrev)

strGoToWorkPath = "cd C:\AbaqusCalc" 
strCommand = "abaqus interactive job=" // trim(strJOB) // " oldjob=" // trim(strOLDJOB)
strCmdLine = trim(strGoToWorkPath) // ' && ' // trim(strCommand)

And then I just use call system(trim(strCmdLine)) to run my sub-calculation.

What is making me mad is that this works for some sub calculations (sometimes just 1, sometimes 100, it's kinda random), but then I get some error of this kind:

Abaqus Error: The following file(s) could not be located: micro_1_1_1#.odb

where # is always a "strange" character (you can see an example here https://www.dropbox.com/s/82b7u7enlxpc62e/1.jpg?dl=0 ). I can confirm (via debug or writing on a file the character variable strCmdLine) that I am executing correctly with the argument "oldjob=micro_1_1_1", like this:

cd C:\AbaqusCalc && abaqus interactive job=micro_1_1_2 oldjob=micro_1_1_1

In some cases Abaqus can find and process the oldjob (file micro_1_1_1.odb), but in another cases he just sticks that strange character between the end of the filename and the ".odb" extension.

My questions would be:

  • Is this related with the call system() function?
  • Can this be an error related with Abaqus and not with Fortran?
  • Is there any other way that I can use to call my Abaqus calculations, instead of call system?
agentp
  • 6,849
  • 2
  • 19
  • 37
Francisco Cruz
  • 314
  • 3
  • 13
  • 2
    Because 1.jpg and 2.jpg are single output lines, it is probably better to just type the output directly in the question (there is also a "quote" button above the edit window). And is the problem the trailing "_" and "C" after strOLDJOB...? If so, I guess it will also be useful to add this information in your question. – roygvib Sep 14 '15 at 21:24
  • You didn't include how `strJOB` and `strOLDJOB` were set, but it seems that they have some non-alphanumeric garbage at their respective ends. And do you need to call `trim(strCmdLine)` even though you explicitly obtain that string by concatenating two `trim`med strings? – Andras Deak -- Слава Україні Sep 14 '15 at 22:21
  • the trim is not strictly needed because your system shell will not care about the trailing blanks. I dont think that relates to the problem however. – agentp Sep 15 '15 at 01:32
  • you might see if your compiler supports `execute_command_line` – agentp Sep 15 '15 at 01:34
  • It is not just better but **very important** to include the error messages in the question and not as pictures. Others with the same problem should be able to find the question using search engines! Please see http://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors and edit your question. – Vladimir F Героям слава Sep 15 '15 at 09:17
  • Thank you guys for your suggestions. @Andras and@roygvib I have added some more info to my question trying to clarify it. I see your point about the images. However, I have chosen to do it this way because I can't represent here the strange symbols I always get between "micro_1_1_1" and ".odb". Is there any way to represent those by typing them? – Francisco Cruz Sep 15 '15 at 13:31
  • @agentp I can't explain why, but I get an Abaqus error if I don't trim the blanks. And it doesn't recognize `execute_command_line`. – Francisco Cruz Sep 15 '15 at 13:32
  • I @VladimirF I have edited it. Thanks for your suggestion – Francisco Cruz Sep 15 '15 at 13:46
  • Regarding your update: so where is `NOEL`, `iCalcs` and friends coming from? Eventually you *will* have to reveal how your actual string gets its value:P – Andras Deak -- Слава Україні Sep 15 '15 at 16:15
  • I wonder if it could be some Unix vs. Windows end of line issue? E.g., some incompatibility between the string passed by `system` and read from the command-line by Abaqus. – Vladimir F Героям слава Sep 15 '15 at 16:18
  • I have a feeling this is one of those frustrating cases where you have some completely unrelated bug (such as an array out of bounds). Showing the error w/out using trim might be enlightening. The `trim` in `call system` is not needed, nor does trim do anything for the *last item* in each of your string expressions. – agentp Sep 15 '15 at 16:22
  • If you know that you have `(i6)` in your strings, then how about using `(a5)` for reading instead of `*`? – Andras Deak -- Слава Україні Sep 15 '15 at 16:25
  • @agentp if I remove the trim the first five calculations run ok but on the sixth I get: (where ## are two symbols). – Francisco Cruz Sep 15 '15 at 20:27
  • @AndrasDeak it doesn't work, I get the same error. – Francisco Cruz Sep 15 '15 at 20:28
  • Okay, I've just tried it on another computer (sorry, I should have done this before..) and it worked. I'll reinstall VS and Abaqus. Thank you for your support. – Francisco Cruz Sep 15 '15 at 20:32

1 Answers1

0

Just something to try, this construct looks perfectly correct

strJOB = "micro_" // trim(strNOEL) //"_"// trim(strNPT) // "_" // trim(striCalcs)

however it can be done I think more neatly using a single internal write:

write(strJOB,'("micro_",i0,"_",i0,"_",i0)')NOEL,NPT,iCalcs

note the i0 nicely takes care of the blanks and strJOB is blank padded out to 256 characters in both cases.

agentp
  • 6,849
  • 2
  • 19
  • 37