- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reformatting the code for reeadibility
SUBROUTINE RUNTIME INTEGER*2 IYEAR,IMONTH,IDAY,IHOUR,IMIN,ISEC,I100TH CALL GETDAT(IYEAR,IMONTH,IDAY) CALL GETTIM(IHOUR,IMIN,ISEC,I100TH) IF ( IHOUR .LE. 12 ) THEN WRITE(*,9001) IHOUR,IMIN,ISEC,I100TH,IMONTH,IDAY,IYEAR ELSE IHOUR = IHOUR-12 WRITE(*,9002) IHOUR,IMIN,ISEC,I100TH,IMONTH,IDAY,IYEAR ENDIF 9001 FORMAT(/3X,'Time: ',I2.2,':',I2.2,':',I2.2,'.',I2.2,' am', + 3X,'Date: ',I2.2,'-',I2.2,'-',I4.4) 9002 FORMAT(/3X,'Time: ',I2.2,':',I2.2,':',I2.2,'.',I2.2,' pm', + 3X,'Date: ',I2.2,'-',I2.2,'-',I4.4) RETURN END
Your original code was written for 16-bit systems where GETDAT and GETTIM return INTEGER*2 values. The default in Intel Fortran is that these return 32-bit values, so when you called GETDAT with 16-bit variables, storage was corrupted. The error message alerted you to this.
Our documentation for GETDAT says:
All arguments must be of the same integer kind, that is, all must be INTEGER(2) or all must be INTEGER(4).
If INTEGER(2) arguments are passed, you must specify USE IFPORT.
So the solution for you is to either change the INTEGER*2 to INTEGER*4, or add the line "USE IFPORT" immediately after the SUBROUTINE statement. This brings in a generic declaration for GETDAT (and GETTIM) which will select the proper routine to use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much. I am an old Fortran guy, these are new to me. Thanks again. really appreciate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wen C. wrote:
Thank you very much. I am an old Fortran guy, these are new to me. Thanks again. really appreciate.
If you plan to do more with Fortran, please see Dr Fortran blog: https://software.intel.com/en-us/blogs/2013/12/30/doctor-fortran-in-its-a-modern-fortran-world. The books in this blog can quickly bring you up to speed!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page