- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am new using intel fortran to write subroutine for abaqus.
In my subroutine, I need to read some data (this data is pre-generated by matlab) and then pass to other subroutines for calculation. The data I am currently reading is text file, they are quite big and it seems that ABAQUS takes quite some time just reading this file. So I am thinking to use binary files instead.
I have to admit that I am never work with binary file before, a quick check online indicates that I can use .mat file or netcdf format for binary files. But it seems that for both format, we need extra library. But since what I wrote is just a subroutine and the main function is by abaqus, so my questions would be:
1) can I read .mat or .nc file in the abaqus subroutine?
2) if not, do you have any recommendation that how should I read these data in my subroutine to speed up my simulation?
Thanks!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jungao,
In general I would expect that you could read a binary file from a user subroutine used from Abaqus. To get started I would recommend writing a test program to just read the data file. That way you can test reading the data file outside of Abaqus to confirm it works as expected. I'd create a project with a main.f90 program that calls the subroutine that you'll be using from Abaqus to run your tests. The test would also allow you to check the time it takes to read the text format data file and see if binary is really needed.
We have read text data files from within Abaqus user subroutines that worked quickly, so it would be worth a try.
Does the data file change during the Abaqus analysis or does it remain constant? If the data is constant for the Abaqus analysis you could also consider writing the data into the user subroutine directly as assignments to variables or arrays so that you would not need to read the file. If the data goes into an array, you could write the data to each entry of an array within the user subroutine:
x(1) = 1.234 x(2) = 2.34 x(3) = 3.4.5.6 ...
Hope these ideas help.
Regards,
Greg T.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Greg,
Thanks for your reply!
I am now actually testing in in main.90 now. In my case, this array keeps constant in the whole simulation, so I only read it at the first time step and I used save to make it global in fortran.
It seems that when I wrote out the binary file from matlab, I should reshape the array into one row, so that fortran can read it properly.
I put the test example here, in case others are interested.
MATLAB:
U=[1 2 3 4 5] fid=fopen('test.bin','w'); fwrite(fid,U,'float'); fclose(fid); Fortran: PROGRAM test IMPLICIT NONE INTEGER :: io_stat REAL :: U(5) REAL :: OPEN(10, FILE = 'test.bin', STATUS = "OLD", ACCESS = 1"STREAM", FORM = "UNFORMATTED", IOSTAT = io_stat) READ(10, IOSTAT = io_stat) U WRITE(*, *) U CLOSE(10)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page