I have the following module that I have created, called modules.f90
, that contains all of the variables and parameters that I know my current program uses across the entire system…
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 ! Pi
double precision, parameter :: grav = 6.6704d-8
double precision, parameter :: cc = 2.99792458d10
double precision, parameter :: hmass = 1.6732d-24
double precision, parameter :: m_sun = 1.989d33 ! Solar mass (g)
double precision, parameter :: r_sun = 6.9599d10 ! Solar radius (cm)
double precision, parameter :: l_sun = 3.83d33 ! Solar luminosity (erg/s)
double precision, parameter :: yr = 3.1556736d7 ! yr in sec
double precision, parameter :: xmdot_sunyr = 6.30268d25 ! acc. rate in M_sun/yr
character(48) :: sfile, ofile, pfile, lfile, filez
integer :: unitz, start_zones, increment_zones
integer :: iunit, lunit, junit, kunit
integer :: jrit, nrit, model, n, ng, methd, nprob, nmod
integer :: nrec, natm, nadd, nsub, iprt, jatm, katm, latm
integer :: mrec, igrv, massloss, itmin, itmax, iter, itau23
integer :: icv(mtau)
integer, dimension(mh) :: jg, jc
integer, dimension(mj) :: iconvect, ienergy
double precision :: zmass, zflux
double precision :: dflux, xtimod, xcorm, time, dtime, factim, dtmin
double precision :: dtmax,chgmin,chgmax,change, dlmx, dlmn, dpmx
double precision :: dpmn, dxmn, dxmx, dzmax, dzmin, dzdt, dmat, atmn
double precision :: taux, dpat, rlh, crad, cwrk, xh2, ener, arad3, taujk
double precision :: dtmn, dmix, zmmn, zmmx, rhmn, enorm, zmold, zrold
double precision :: zlold, rtau23, rpp, rhe3he3, rcno, r3a, r12a, r16a
double precision :: rcc, rlip, xpd, xpc, xpn, xpo, xpp23
double precision, dimension(10) :: radm, radr
double precision, dimension(15) :: xba, h1, a
double precision, dimension(mh) :: dg, smin, smax, eps, e, g
double precision, dimension(mj) :: grv, zm, dm, hydrogen, deuterium, helium3, helium4
double precision, dimension(mj) :: carbon, nitrogen, oxygen, lithium,erest
double precision, dimension(mj) :: vhydrogen, vdeuterium, vhelium3, vhelium4
double precision, dimension(mj) :: vcarbon, vnitrogen, voxygen, vlithium, verest
double precision, dimension(mtau) :: tau, ttau, rhotau, ptau, rtau
double precision, dimension(mtau) :: zmtau, zatg, zradg, ztrug
double precision, dimension(mh, mh) :: hc, hd, he
double precision, dimension(mj, me) :: element, velement
double precision, dimension(mj, mh) :: x, vx
double precision :: ha(mh, 2 * mh + 1), hw(mh, mh + 1, mj)
double precision :: hx(mh, mh + 1)
double precision :: rhyr(23), thyr(28), auxchyop(23, 28)
double precision :: rhel(25), thel(32), auxcheop(25, 32)
end module
I have tested this slowly and have had success generally with the code, but this was a BIG step, to combine everything into a single block.
Most of the code compiled but when I ran the code, the variables defined within modules.f90
were not holding their values within the calling routine (stelcor.f90
, which has, in each subroutine use stellar_values
)
Since I have implicit
set to none
, the compiler is confirming that all variables are now declared in all routines (the code compiles) and if I physically set values within modules.f90
then the values are accessible in all parts of the calling program (stelcor.f90
).
Yet, if the calling program sets a value, it is only held within that subroutine, and lost on exiting (despite having save
set in all subroutines; and these appearing to be globals).
Equally, arrays are complaining at present, stating that I cannot simply set the array values…
a(1) = 8.9d0
but must use a pointer?
I am compiling the modules.f90
and getting a stellar_values.mod
file, as well as a modules.o
file, by doing this…
gfortran -c modules.f90
I can then compile the main two routines (dummymain,f90
, which uses stelcor.f90
) by doing this…
gfortran stelcor.f90 dummymain.f90
I get the resultant a.out
file.
Am I wildly wrong?