Sorry for the very basic nature of this question (and it’s general scope) but I have now re-organised the 7000+ lines of code and want to start migrating this across to an F90 file slowly.
To explore this idea I decided to build a basic program file (first few stages of my wrapper program) and came across a few errors/concerns I can’t resolve easily (just ordered 3 books on Fortran, based upon earlier recommendation). Would appreciate pointers…
- I have separated out each variable into it’s own definition; is this the best approach?
- Is it okay to move the module into a separate file and
include
it, where I need it? - Why is epsilon highlighted? I’m assuming a reserved word but the program works!?
- I believe I have defined the argument for record_time correctly (and setting it’s default value), yet I get an error message
87 | subroutine record_time(sf)
| 1
Error: Dummy ‘sf’ at (1) cannot have an initializer
- I also get an error in relation to the calling of this subroutine; why?
79 | record_time("begin")
| 1
Error: Unclassifiable statement at (1)
I have given the whole listing (in case you see something else I should pay attention to)…
module stellar_values
implicit none
integer, parameter :: MJ = 4000
integer, parameter :: MH = 4
integer, parameter :: ME = 9
integer, parameter :: MTAU = 20000
double precision, parameter :: sig = 5.67051d-5
double precision, parameter :: pi = 3.14159265359d0
double precision, parameter :: grav = 6.6704d-8
double precision, parameter :: cc = 2.99792458d10
double precision, parameter :: hmass = 1.6732d-24
double precision, parameter :: xm_sun = 1.989d33 ! Solar Mass (g)
double precision, parameter :: r_sun = 6.9599d10 ! Solar Radius (cm)
double precision, parameter :: xl_sun = 3.83d33 ! Solar Luminosity (erg/s)
double precision, parameter :: yr = 3.1556736d+7 ! yr in sec
double precision, parameter :: xmdot_sunyr = 6.30268d25 ! acc. Rate in M_sun/yr
end module
program main
double precision :: fluxM
double precision :: fluxM1
double precision :: fluxM2
double precision :: deetee
double precision :: tpeak
double precision :: mdotzero
double precision :: mdotstar
double precision :: epsilon
double precision :: tnaught
double precision :: tostar
double precision :: rateunit
double precision :: fluxmin
double precision :: fluxold
double precision :: decel
double precision :: decelr
double precision :: initialrate
double precision :: finalmass
double precision :: fsolmass
double precision :: numru
double precision :: solmass
double precision :: yearins
double precision :: acc
double precision :: mdotstarramped
double precision :: divpart
double precision :: taur
double precision :: tauf
double precision :: taueee
double precision :: tburst
double precision :: fburst
integer :: accmethod
integer :: iacc
integer :: ic
integer :: im
integer :: im1
integer :: steps
integer :: late_evolve
character (1) :: temp1 = ""
logical :: massonly = .FALSE.
if (command_argument_count() == 1) then
call get_command_argument(1, temp1)
if (temp1 == '1') then
massonly = .TRUE.
endif
endif
record_time("begin")
record_time("end")
end program
subroutine record_time(sf)
character (5), intent(in), optional :: sf = "begin"
character (8) :: curdate = "000000:00"
character (10) :: curtime = "000000:00"
logical :: fileexist = .FALSE.
real, save :: start = 0.00
real, save :: finish = 0.00
inquire (file = "data.lst", exist = fileexist)
if (fileexist) then
open(7, file = "data.lst", status = "old", position = "append")
else
open(7, file = "data.lst", status = "new")
end if
call date_and_time(DATE = curdate, TIME = curtime)
if (sf == "begin") then
write (7, *) "Date of run (yyyymmdd) = ", curdate
write (7, *) "Time of run (hhmmss.mmm) = ", curtime
call cpu_time (start)
else
call cpu_time (finish)
open (7, file = "data.lst", position = "append")
write (7, *) "Execution time (s) = ", finish - start
end if
call flush (7)
close (7)
end subroutine
Thank you in advance for any and all advice given (including “Stop asking questions!” or “Give up!” )