Standard-conforming FORTRAN 77 source code is compatible with Sun Fortran 90. Use of non-standard extensions, such as VMS Fortran features, are not compatible and may not compile with Sun Fortran 90.
Both f77 and f90 treat all source lines as if they were lowercase (except in quoted character strings. However, unlike f77, f90 has no -U option to force the compiler to be sensitive to both upper and lower case. This may present a problem when mixing f77 and f90 compiled routines. Since a routine compiled by f90 will treat CALL XyZ the same as CALL XYz, and treat them both as if they were CALL xyz, care must be taken to rearrange the way these calls are made. A similar situation will exist when trying to define entry points in f90 compiled routines that are differentiated by case. The clue to potential problems would be the need to use -U with f77.
To mix f77 and f90 object binaries, link with f90 and the f77 compatibility library, libf77compat, and not with libF77. For example, perform the link step with
f90 ..files.. -lf77compat
even if the main program is an f77 program.
Example: f90 main and f77 subroutine.
demo% cat m.f90 CHARACTER*74 :: c = 'This is a test.' CALL echo1( c ) END demo$ cat s.f SUBROUTINE echo1( a ) CHARACTER*74 a PRINT*, a RETURN END demo% f77 -c -silent s.f demo% f90 m.f90 s.o -lf77compat demo% a.out This is a test. demo%
The FORTRAN 77 library is generally compatible with f90.
Example: f90 main calls a routine from the FORTRAN 77 library.
demo% cat tdtime.f90 REAL e, dtime, t(2) e = dtime( t ) DO i = 1, 100000 as = as + cos(sqrt(float(i))) END DO e = dtime( t ) PRINT *, 'elapsed:', e, ', user:', t(1), ', sys:', t(2) END demo% f90 tdtime.f90 demo% a.out elapsed: 0.14 , user: 0.14 , sys: 0.0E+0 demo%
See dtime(3F).
f77 and f90 are generally I/O compatible for binary I/O, since f90 links to the f77 compatibility library.
Such compatibility includes the following two situations:
In the same program, you can write some records in f90, then read them in f77.
An f90 program can write a file. Then an f77 program can read it.
The numbers read back in may or may not equal the numbers written out.
Unformatted
The numbers read back in do equal the numbers written out.
Floating-point formatted
The numbers read back in can be different from the numbers written out. This is caused by slightly different base conversion routines, or by different conventions for uppercase/lowercase, spaces, plus or minus signs, and so forth.
Examples: 1.0e12, 1.0E12, 1.0E+12
List-directed
The numbers read back in can be different from the numbers written out. This can be caused by various layout conventions with commas, spaces, zeros, repeat factors, and so forth.
Example: '0.0' as compared to '.0'
Example: ' 7' as compared to '7'
Example: '3, 4, 5' as compared to '3 4 5'
Example: '3*0' as compared to '0 0 0'
The above results are from: integer::v(3)=(/0,0,0/); print *,v
Example: '0.333333343' as compared to '0.333333'
The above results are from PRINT *, 1.0/3.0
The Fortran 90 standard supports the following new intrinsic functions that FORTRAN 77 does not have.
If you use one of these names in your program, you must add an EXTERNAL statement to make f90 use your function rather than the intrinsic one.
Fortran 90 intrinsics:
"ADJUSTL,ADJUSTR,ALL,ALLOCATED,ANY,BIT_SIZE,COUNT,CSHIFT, DIGITS,DOT_PRODUCT,EOSHIFT,EPSILON,EXPONENT,HUGE,KIND, LBOUND,LEN_TRIM,MATMUL,MAXEXPONENT,MAXLOC,MAXVAL,MERGE, MINEXPONENT,MINLOC,MINVAL,NEAREST,PACK,PRECISION,PRESENT, PRODUCT,RADIX,RANGE,REPEAT,RESHAPE,RRSPACING,SCALE,SCAN, SELECTED_INT_KIND,SELECTED_REAL_KIND,SET_EXPONENT,SHAPE, SIZE,SPACING,SPREAD,SUM,TINY,TRANSFER,TRANSPOSE,UBOUND, UNPACK,VERIFY"