问题
I am writing a DISP subroutine for ABAQUS 6.14, starting with small steps -- trying to open and read the file containing the displacement data. So far I have a fortran script which runs perfectly when configured as an independent program but crashes when ABAQUS runs it as a subroutine. The working version :
PROGRAM DISP
INTEGER nnodes, IOS
PARAMETER (nnodes = 5652)
REAL A(nnodes,4)
WRITE(*,*) 'hello world'
OPEN(UNIT=11,FILE ="displaced_shape.dat",IOSTAT=IOS)
WRITE(*,*) IOS
DO ix = 1,nnodes
READ(11,*) A(ix,:)
END DO
WRITE(*,*) A(2,3)
END PROGRAM DISP
The output of this program is
hello world
0
5.4729998E-04
The subroutine :
SUBROUTINE DISP(U,KSTEP,KINC,TIME,NODE,NOEL,JDOF,COORDS)
INCLUDE 'ABA_PARAM.INC'
DIMENSION U(3),TIME(2),COORDS(3)
INTEGER nnodes, IOS
PARAMETER (nnodes = 5652)
REAL A(nnodes,4)
WRITE(*,*) 'hello world'
OPEN(UNIT=11,FILE ="displaced_shape.dat",IOSTAT=IOS)
WRITE(*,*) IOS
DO ix = 1,nnodes
READ(11,*) A(ix,:)
END DO
WRITE(*,*) A(2,3)
RETURN
END SUBROUTINE DISP
The output of the subroutine is
hello world
0
forrtl: severe (24): end-of-file during read, unit 11
As you can see, the scripts are identical except for the wrapping. I run them from the same folder referencing the same data file. Could it be a matter of fortran version ? The ABAQUS documentation is pretty vague on this.
Any ideas would be greatly appreciated, thanks for your help.
Edit : as may be obvious, the file "displaced_shape.dat" has the format
1 0.1 0.2 0.3
2 0.1 0.2 0.3
....
5652 0.1 0.2 0.3
回答1:
The problem is very likely due to assigning your file unit number to a value that should be reserved for use by Abaqus. According to the docs1 there is a simple fix: For Abaqus/Standard, use a file unit number 15-18 or >100. For Explicit, use 16-18 or >100 ending in 5 through 9 (e.g. 105).
1Abaqus Analysis User's Manual > Introduction > Job Execution > FORTRAN Unit Numbers
回答2:
For others who may come across this problem : the issue is that ABAQUS requires the full path to the file and won't just check the working directory for it. Adding the absolute file path solved the problem.
来源:https://stackoverflow.com/questions/54237675/abaqus-subroutine-runs-when-configured-as-a-program-but-not-as-a-subroutine