Modernizing an old code is often not an easy task. At least for a beginner. The move from real
to double precision
is not in the spirit of modern Fortran, but until you introduce modules it is OK. When you have modules it is better to do:
module precisions
integer, parameter :: rp = kind(1.d0) !if you insist on double, otherwise use selected_real_kind()
end module
and everywhere use the new kind constant that denotes your real precision:
use precisions
real(rp) :: variables
With the common blocks, the one you showed would be:
module geo_coordsystem
use precisions
implicit none
real(rp) :: rearth
real(rp) :: ellip
real(rp) :: rlatc
real(rp) :: rad
real(rp) :: olat, olon
real(rp) :: aa, bb, bc
real(rp) :: sint, cost
real(rp) :: rotate
integer icoordsystem
end module
Then you use it:
subroutine dist(xlat, xlon, xkm, ykm)
use precisions
use geo_coordsystem
implicit none
You can also continually move you subroutines to modules. Do that in small steps and always check that you didn't introduce some bug.