The U.S. Geological Survey provides the MODFLOW hydrologic model, which is considered an international standard for simulating and predicting groundwater conditions and groundwater/surface interactions.
A search of the USGS website reveals several other interesting Fortran projects, including the Batteries Included Fortran Library (BiF-lib). The actual code can be found here and is under an Apache license. It contains several things you would expect in a standard library.
Does it compile with gfortran with the -std=legacy option? That’s the first thing to try.when something does not compile by default with gfortran. If it still does not compile, can you list the errors?
After checking the errors, this library uses modern fortran features such as do concurrent, functions of the iso_binding_c module and some other intrinsic functions defined in the fortran 2003 and fortran 2008 standard. These features are all available in gfortran 10 but IMO the errors are due to ifort syntax (e.g do concurrent (integer :: i )). It is possible to specify the compiler in the makefile (using make COMPILER=gcc F90=gfortran), but the errors still appear.
I have tried gfortran 8,3 in windows and gfortran 10.2 in a linux box but the errors are still there.
Thanks for the information about the do concurrent in the fortran 2008 standard, I did not know that. However, gfortran shows the do concurrent (integer :: i …) as an error (using gfortran 8.3 in windows and 10.2 in linux) which means that this is not currently implemented in this compiler.
do concurrent was added to GNU Fortran 8. Make sure you use the correct syntax for concurrent do loops:
integer :: i
do concurrent (i = 1:10)
print *, i
end do
Sorry, I missed that the source code uses Intel compiler extensions standard conforming F2008 features that are probably not implemented in GNU Fortran 8. Probably has be to solved manually via search and replace.
@interkosmos Thanks for your reply. Yes, the code that you posted worked fine in gfortran 8.3 and 10.2 I was referring to the syntax do concurrent (integer :: i…) which gfortran shows as an error. And you are right, this can be solved with a search and replace. However, there are other compilation errors that might be caused by some missing features in gfortran.
Well, the following is a conforming program that gfortran does not support, so interested gfortran users can file a request at GCC Bugzilla. Or better yet will be if a lot more Fortran practitioners become highly enthused to contribute to GCC/gfortran as C developers to enhance the front-end for Fortran.
integer :: x(3)
do concurrent ( integer :: i = 1:size(x) )
x(i) = i
end do
print *, "x: ", x
end
C:\Temp>gfortran -c p.f90
p.f90:2:18:
2 | do concurrent ( integer :: i = 1:size(x) )
| 1
Error: Syntax error in DO statement at (1)
p.f90:4:6:
@interkosmos I got the same errors with the pure functions and also with some intrinsic functions due to differences in the precision of the input arguments (iand function with integer16 and integer 32 inputs). It seems that this library compiles with ifort without problem.
No, the Fortran standard permits dummy arguments with VALUE attribute to be used in a variable-definition context provided they are not declared with INTENT(IN) attribute.
The PRETTY_PRINT_TIMER function, at least as shown upthread, looks standard-conformant - again, gfortran does not appear to have caught up with the standard here.
I’ve found non-conformances in BiF-lib. There are equality operators between Integer and Logical. There doesn’t seem to be a way of contacting the author or submitting issues or pull requests.