Hi there,

I have been struggling recently with the implementation of the UEXTERNALDB and I can't identify the error. I think it might be a syntax error, but since I can't compile my subroutine on demand, the possibilities of what I can test is limited and I believe asking here for someone more familiar with the subroutine can be more productive. Basically, I have to open and read a .dat file with 1881 rows and three columns, the first of which can be ignored. Then I need to export it to another subroutine (which I have placed in the same .for file). My code is as follows:

SUBROUTINE UEXTERNALDB(LOP,LRESTART,TIME,DTIME,KSTEP,KINC)

C

INCLUDE 'ABA_PARAM.INC'

C

DIMENSION TIME(2)

C

REAL dummy

REAL, DIMENSION(1881) :: b

REAL, DIMENSION(1881) :: c

INTEGER ERROR, i

LOGICAL FILE_READ

COMMON /array/ b, c, FILE_READ !Exporting the FILE_READ to keep its value .TRUE.

IF (.NOT. FILE_READ .AND. LOP.EQ.0) THEN !This condition is only met in the very first increment

OPEN(98, FILE="T:\\Pedro\\Data_Bank\\data.dat",

1 STATUS='UNKNOWN', FORM='FORMATTED', IOSTAT=ERROR)

C

IF (ERROR.EQ.0) THEN

DO i = 1, 1881

READ(98, *, IOSTAT=ERROR) dummy, b(i), c(i) ! Is not saving the first column

ENDDO

FILE_READ = .TRUE. !changing boolean so the file is only read once

ELSE

PRINT*, ERROR

ENDIF

CLOSE(98)

ENDIF

RETURN

END

I've tried a few variations of this code, but to no success. For example, I've tried running it without the boolean but the result is the same.

Thank you in advance for any feedback, suggestions or comments!

Edit for extra context:

Basically, the subroutine should go through each row and store the second and third columns in a common block, so that the data can be used in another subroutine. But the data isn't being saved in the block. So when I run the subroutine, nothing happens. There is no compilation error. This is another example I tried and it didn't work either, with a smaller database:

SUBROUTINE UEXTERNALDB(LOP,LRESTART,TIME,DTIME,KSTEP,KINC)

C

INCLUDE 'ABA_PARAM.INC'

C

DIMENSION TIME(2)

C

REAL dummy

INTEGER A, B, C

DIMENSION EARRAY(4,3)

COMMON /Kmatrix/ EARRAY

IF (LOP.EQ.0) THEN

OPEN(15, FILE="T:\\Pedro\\Data_Bank\\data3.dat")

C

READ(15,*) ((EARRAY(B,C), B=1,4), C=1,3)

CLOSE(15, STATUS='KEEP')

ENDIF

RETURN

END

That doesn't work either.

More Pedro Weiss Mattioli's questions See All
Similar questions and discussions