Error in code?

Error in code?

Hello all,

I can not understand the error in the following code:

CODE

IF(JRCD.NE.0)THEN

1 WRITE(6,*) 'REQUEST ERROR IN USDFLD FOR ELEMENT NUMBER ',

2 NOEL,'INTEGRATION POINT NUMBER ',NPT

I obtain the following error messages, but do not fully under it:

ERROR MESSAGE
cyclic_fatigue_B_Reduced.for(65) : Error: Syntax error, found IDENTIFIER 'WRITE' when expecting one of: ;
1 WRITE(6,*) 'REQUEST ERROR IN USDFLD FOR ELEMENT NUMBER ',
--------^
cyclic_fatigue_B_Reduced.for(65) : Error: Syntax error, found CHARACTER_CONSTANT 'REQUEST ERROR IN USDFLD FOR ELEMENT NUMBER ' when expecting one of: => = . ( %
1 WRITE(6,*) 'REQUEST ERROR IN USDFLD FOR ELEMENT NUMBER ',
-------------------^
cyclic_fatigue_B_Reduced.for(66) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: :: , : )
2 NOEL,'INTEGRATION POINT NUMBER ',NPT
------------------------------------------------^

Any input would be much appreciated. Thanks.

26 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

The "1" in the second statement you have shown is probably in the sixth column (given
yesterday's discussion) so itcontinues the first line. But that is already complete.

Remove that "1" and it will probably work.

Regards,

Arjen

Thanks Arjen,

I already had the column thing sorted in my code (I just copy and pasted the code on the OP which lost the formatting).

Problem solved!

Code changed to

IF(JRCD.NE.0)THEN

WRITE(6,*) 'REQUEST ERROR IN USDFLD FOR ELEMENT NUMBER ',

1 NOEL,'INTEGRATION POINT NUMBER ',NPT

I am curious, looking up the following code I found that DIMENSION e.g.

DIMENSION

ARRAY(15)

"DIMENSION" defines an array, in this case ARRAY(15), why is it not just called "ARRAY" and not "DIMENSION"?

Thanks

DIMENSION is the keyword, ARRAY is the name of the array variable. There is no keyword ARRAY in Fortran

I do not know the historical background for using the word "DIMENSION", but to me it
seems quite apt.

Regards,

Arjen

DIMENSION is an attribute. As with most attributes, it can be used as a separate statement, such as:

DIMENSION ARRAY(15)

This might need a separate type declaration statement if implicit typing was not to be used.

or, in more modern Fortran, in a comma list of attributes:

REAL, DIMENSION(15) :: ARRAY

One can also use:

REAL ARRAY(15)

DIMENSION is one of those attributes where you don't have to use the keyword. In more modern code I'd expect to find it in a comma list of attributes for a single declaration. The DIMENSION statement is a holdover from very early Fortran.

Steve - Intel Developer Support

Thanks for the really interesting input from everyone on this..

I have created an empty text file called STATEV.txt and am trying to write the data stored in STATEV(1) (produced during Abaqus analysis)into the text file. The text fileremains blank. Can anyone help? Thanks.

SUBROUTINE
USDFLD (FIELD,STATEV,PNEWDT,DIRECT,T,CELENT,TIME,DTIME,CMNAME,ORNAME,
NFIELD,NSTATV,NOEL,NPT,LAYER,KSPT,KSTEP,KINC,NDI,NSHR,
COORD,JMAC,JMATYP,MATLAYO,LACCFLA)
c
INCLUDE 'ABA_PARAM.INC'
c
CHARACTER*80
CMNAME,ORNAME
CHARACTER*3FLGRAY(15)
DIMENSION FIELD(NFIELD),STATEV(NSTATV),DIRECT(3,3),T(3,3),TIME
DIMENSION ARRAY(15),JARRAY(15),JMAC(*),JMATYP(*),COORD(*)
c
CALL GETVRM('E',ARRAY,JARRAY,FLGRAY,JRCD,JMAC,JMATYP,
MATLAYO,LACCFLA)
EPS=ABS(ARRAY(1))
c
FIELD(1)=EPS
c
STATEV(1)=FIELD(1)
c
OPEN (unit=1, file='STATEV.txt')
WRITE (1),STATEV(1)
c
RETURN
END

Place a break point on the WRITE statement and see what is in STATEV(1).
What is in STATEV? What type is STATEV (INCLUDE 'ABA_PARAM.INC' may have declared STATEV as character)
Are you looking in the correct directory for STATEV.txt?

Jim Dempsey

www.quickthreadprogramming.com

Hi Jim,

ABA_PARAM.INC is an internal file which includes one of the following in the user subroutine based on the fact that the solver is SINGLE or DOUBLE PRECISION:

parameter (nprecd=1)
or
implicit real*8(a-h,o-z)
parameter (nprecd=2)

I am using this code as a subroutine during and SIMULIA abaqus analysis, so i am not sure how I can use a break point to see what STATEV(1) actually looks like during the analysis?

STATEV(1) is defined as "An array containing the solution-dependant state variable" produced during an analysis run.

In terms of the directory of STATEV(1) I have include the path C:\......\STATEV(1) and still recieve a blank text file at the end of an analysis.

Thanks again for all your help.

Then this means that STATEV is either a REAL*4 or REAL*8 array.
The code you provided should have

a) created an output file of the name specified within the current directory at the time of the OPEN
b) written a floating point value, presumably non-blank
c) closed the file

The important factor is "what was the current directory" at the time of the OPEN?

The current directory is not necessarily the directory where the execuitable is located. In fact the file (as specified in your program) is opened: within the current directory .AND. within the current drive
Each are seperately settable.

It would appear the the file you are looking at is not the file written.
IOW this may have been an older empty file generated at some other time in the location you are looking at (but not the location where the current file is written).

How are you launching the program? If from IDE you can check the properties (default is project folder .NOT. execuitable folder).

Jim Dempsey

www.quickthreadprogramming.com

Hi Jim,

I am not sure what you mean by ""what was the current directory" at the time of the OPEN?"? I have created a STATEV.txt file and placed this into the working directory of the analysis with ABAQUS.

The program is being launch by ABAQUS which calls the subrotuine I have written above during an analysis run. I use the following command in the ABAQUS Command Window to launch the analysis input file (.inp) and subroutine (.for):

abaqus job=model_1 user=Cyclic_Fatigue_B_Reduced

Thanks for all you help.

Your subroutine is not closing the file STATEV.txt. The WRITE is buffered. Should you examine STATEV.txt prior to close then it may be empty. If STATEV.txt is required to remain open (more state variables to be written) consider adding FLUSH(1).

Consider changing the I/O unit number for STATEV.txt from 1 to some number greater than 9. Lower unit numbers are typically reserved for legacy I/O devices. Ignore this if ABAQUS requires STATEV.txt to be located on unit 1. Also, do not use literal unit numbers. Use parameters from shared header or module.

integer, parameter :: uSTATEV = 10
...
OPEN(UNIT=uSTATEV, FILE='STATEV.txt', STATUS='REPLACE')

** or STATUS='OLD' if that is the case

Jim Dempsey

www.quickthreadprogramming.com

Hi everyone,

Still having problems with this, I have updated this in line with the advice from the forum and reference to the following text:

Structured Fortran 77 for engineers and scientists (5th Ed.) Delores M.Etter

INTEGER, PARAMETER :: uSTATEV = 105

101 FORMAT (F12.6)
OPEN (UNIT=105,
1 FILE='C:\.....\STATEV.txt',
2 STATUS='NEW')
WRITE(105,101) STATEV(1)
CLOSE (UNIT=105)

Please note. I have taken into account the .for column formatting in the code.

I would really appreciate any further input or advice. Thanks.

Did you try changing that FILE path name to an actual path, or allowing it to use your current working directory?

Thanks for you response, yes i have tried both and still no success. in the code below:

FILE='C:\.....\STATEV.txt',

I have just shorterned the text on the forum post to make it easier to read. In the real code I have tried both including the full FILE path as well as trying just:

FILE='STATEV.txt',

Still not sure whereI am going wrong. Thanks.

The WRITE statement should not have a continuation character in COL-6.

The syntax is

IF ( CONDITION ) THEN
Statements to execute if CONDITION is .TRUE.
ENDIF

Note that the first and last lines are complete statements by themselves. Likewise, the statements in the IF...ENDIF block are complete statements.

Thanks mecej4, my WRITE STATEMENT does not have a continuation character in COL-6.

Sorry, did I misunderstand your post?

The initiating post of this thread contains:

IF(JRCD.NE.0)THEN

1 WRITE(6,*) 'REQUEST ERROR IN USDFLD FOR ELEMENT NUMBER ',

2 NOEL,'INTEGRATION POINT NUMBER ',NPT

If these are the statements in your program, the '1' at the beginning of the second line should not be there. The error message from the compiler is consistent with such a continuation character having been scanned.

Thanks mecej4, I corrected this before. This still did no solve the problem I am having with not being able to write to the STATEV.txt file. Perhaps the problem is that there is nothing to write to the file, but I just do know about it. I will try write a simple programme to write to a file to test out the code.

 101    FORMAT (F12.6)
        OPEN (UNIT=uSTATEV,
      1 FILE='STATEV.txt',
      2 STATUS='NEW') 
        WRITE (uSTATEV,101) STATEV(1)
        CLOSE (UNIT=uSTATEV)





You will find this forum more helpful if you post complete code instead of fragments, and if you show the actual error messages from the compiler and runtime, instead of simply saying that something "did not work".

When you post code, please use the Syntax Highlighter Tool (the yellow pencil/pen icon).

Thank-you for your advice and support, I have posted the whole subroutine below, is submitted with the abaqus analysis job. I do not recieve any error messages. The problem is I can not seem to produce or write any data in a STATEV.txt file. Really hope that clears up my problem? Thanks.

[fxfortran]       SUBROUTINE USDFLD(FIELD,STATEV,PNEWDT,DIRECT,T,CELENT, 
     1 TIME,DTIME,CMNAME,ORNAME,NFIELD,NSTATV,NOEL,NPT,LAYER, 
     2 KSPT,KSTEP,KINC,NDI,NSHR,COORD,JMAC,JMATYP,MATLAYO,LACCFLA)
c
       INCLUDE 'ABA_PARAM.INC'
c
       CHARACTER*80 CMNAME,ORNAME
       CHARACTER*3  FLGRAY(15)
       DIMENSION FIELD(NFIELD),STATEV(NSTATV),DIRECT(3,3),T(3,3),TIME(2)
       DIMENSION ARRAY(15),JARRAY(15),JMAC(*),JMATYP(*),COORD(*)
       INTEGER, PARAMETER :: uSTATEV = 105
c
c ~~ CALL VALUES FROM ABAQUS ~~
c
c Absolute value of current strain 'E'
c
       CALL GETVRM('E',ARRAY,JARRAY,FLGRAY,JRCD,JMAC,JMATYP, 
     1 MATLAYO,LACCFLA) 
       E11=ARRAY(1) 
c
c Use the strain as a field variable
c
       FIELD(1)=E11   
c
c Store the strain as a solution dependent state variable
c
       STATEV(1)=FIELD(1)
c
c Write the STATEV(1) data to file
c  
  101  FORMAT (F12.6)
c
       OPEN (UNIT=uSTATEV,		
     1 FILE='STATEV.txt',
     2 STATUS='NEW')
       WRITE (uSTATEV,101) STATEV(1)
       CLOSE (UNIT=uSTATEV)
c
c ~~ REPORTING AN ERROR IF IT OCCURS ~~
c
c If error, write comment to .DAT file:
c    
       IF(JRCD.NE.0)THEN
       WRITE(6,*) 'REQUEST ERROR IN USDFLD FOR ELEMENT NUMBER ',
     1      NOEL,'INTEGRATION POINT NUMBER ',NPT
c     
c       - Return Code (0 - no error, 1 - output request error or all components of output request are zero)
c    
      ENDIF
      RETURN
      END[/fxfortran]

The file will be written into whatever is the current working directory when ABAQUS calls your DLL. If you think that ABAQUS has already called and executed your DLL, use Windows file-search to look for the file. Alternatively, as others have pointed out, in the OPEN statement specify a full path for the file rather than just the filename.

I have written some quick code to check my writting to file code works and this seems to work ok (see code below). This writes to a.txt file the value ofx. Therefore,I guess this means that the problem has to lie with the abaqus end?

[fxfortran]c      
      PROGRAM WriteFile
c
      REAL x
      INTEGER :: FILE = 110
c
      PRINT*, 'ENTER VALUE OF X'
      READ*, x
c
  120 FORMAT (F12.6)
      OPEN (UNIT=FILE, FILE='FILE1.txt', STATUS='REPLACE')
      WRITE (FILE, 120) x
      CLOSE (UNIT=FILE)
c      
      END[/fxfortran]

Is it possible for you to attach the actual code for the routinebeing called ? (Please attach rather than paste inline)
There may be something else going on which is not immediately obvious from your description.

Les

Thanks Les,

I have attached the file to this post. I look forward to any input or comments.

Well I don't see anything obviously wrong in the code.
Nothing is explicitly declared so the implicit typing rules apply, does the calling routine pass the correct type andkind for each actual argument?
Iassume E11isin the include file otherwise if it is a local variable it is redundant.
If this is the actual code there are a lot of unused dummy arguments - but heyI see that a lot:-)

Otherwise the problem must lie elsewhere.

Les

Leave a Comment

Please sign in to add a comment. Not a member? Join today