You certainly could just put module thing
end module
before the start of the main program and then use
that module. I would recommend adding a program main
statement as well. I would recommend then putting the module and main program in separate files, and then working to split the module into separate modules with reasonable organization.
It is unusual for code to open itself up.
What do you mean by “initial routine”? The first routine in some source file, or the first routine that will be executed, …?
I have now done exactly that; thank you.
I meant that, on execution, the program would encounter an instruction without any ‘main’ declaration; so…
print *, “hello”
rather than
program main
print *, “hello”
end program
I am aware programs do not just open.
Regarding the original post, I would recommend to not be too aggressive in changes.
I would however recommend one change that will require extensive review of the original code, by placing IMPLICIT NONE as the first line of each routine.
This will also require that all INCLUDE files are enhanced to include explicit type definition of all variables listed, which is ok and preferable for INCLUDE files
IMPLICIT NONE effectively becomes a spelling check for all variables listed in the type declarations.
With most IDE’s this should not be too difficult and could be time well spent for identifying and documenting all variables used in each routine.
Your COMMON include file could become something like:
COMMON / ZONEC / SFILE,OFILE,PFILE,LFILE,FILEZ
character(len=32) :: SFILE,OFILE,PFILE,LFILE,FILEZ
COMMON / ZONES / radM,radR,Nrad, &
& unitz,start_zones,increment_zones,iunit,lunit
real :: radM, radR, unitz, start_zones
integer :: Nrad, increment_zones, iunit, lunit
If I am correct assuming type character for file names, it may be better to not mix character with integer/real variables in the same common. It is acceptable to have two COMMON in the same include file. Converting to character variables where clearly used is also useful and probably shows the original fortran was pre F77.
Note also that with pre Fortran 77, FORTRAN did not use generic intrinsics so if double precision (REAL*8) was used, expect DSIN instead of SIN, FLOAT instead of REAL or DABS instead of ABS. Moving to generic intrinsics is also a useful update that can clarify the code, once the program is basically working.
For the other INCLUDE file you could consider:
INTEGER, PARAMETER :: MJ = 4000
INTEGER, PARAMETER :: MH = 4
INTEGER, PARAMETER :: ME = 9
INTEGER, PARAMETER :: MTAU = 20000
When not using punch cards, code layout becomes a little/lot easier.
Moving to free format gives a longer code line, but can require a lot of care for continuation or FORMAT statements.
There is so much to unpick here; thank you so much!
I will go through this in detail once I have time but just to state that, yes, I am doing ‘implicit none’ for the reason given.