Skip to content

Commit bdfe573

Browse files
committed
cleanup
minor end-of-year cleanup: edits to source code documentation and syntax without external consequences
1 parent 2f657e7 commit bdfe573

File tree

7 files changed

+66
-60
lines changed

7 files changed

+66
-60
lines changed

Asteroids/makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ sphere1d sphere1d_implicit: sphere1d_implicit.o common_subs.o makefile
6767
# body.mod, constants.mod, and allinterfaces.mod in fast_modules_asteroid.f90
6868

6969

70-
%.o: %.f makefile
71-
$(CC) $(CFLAGS) -c $<
72-
7370
%.o: %.for makefile
7471
$(CC) $(CFLAGS) -c $<
7572

Common/CONTENTS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ conductionT2.f90:
2727
version of conductionT that precomputes coefficients
2828

2929
derivs.f90:
30-
first and second derivatives on irregular grid
30+
first and second derivatives on irregularly spaced 1D-grid
3131

3232
grids.f90:
3333
creates appropriate 1D grids, and contains other grid-related functions

Exospheres/CONTENTS.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
Exosphere/
1+
Exospheres/
22

33
Monte-Carlo Model for Surface-bounded Exosphere
44
===============================================
55

66
moon_exo.f90: (main program)
7-
event driven Monte Carlo model for ballistic hops of
8-
water molecules on the lunar surface
7+
event driven Monte Carlo model for ballistic hops of water molecules
8+
and other volatile species on the lunar surface
99

1010
ceres_exo.f90: (main program)
11-
event driven Monte Carlo model for ballistic hops of
12-
water molecules on the Cerean surface;
13-
can be used for other airless bodies as well
11+
event driven Monte Carlo model for ballistic hops of water molecules
12+
and other volatiles species on the surface of Ceres;
13+
can be adapted to other airless bodies as well
1414

1515
body.f90:
1616
body specific input parameters

Exospheres/ceres_exo.f90

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PROGRAM exospherebody
22
!***********************************************************************
3-
! surface temperatures of airless body with H2O exosphere
3+
! H2O exosphere and surface temperatures for airless body
44
!***********************************************************************
55
use grid
66
use body, only: solarDay, dtsec
@@ -15,10 +15,10 @@ PROGRAM exospherebody
1515
real(8), dimension(veclen) :: Tsurf, Qn
1616
real(8) residencetime, HAi
1717

18-
real(8), dimension(np,2) :: p_r ! longitude(1) and latitude(2)
19-
integer, dimension(np) :: p_s ! status 0=on surface, 1=inflight, <0= destroyed or trapped
20-
real(8), dimension(np) :: p_t ! time
21-
integer, dimension(np) :: p_n ! # of hops (diagnostic only)
18+
real(8), dimension(Np,2) :: p_r ! longitude(1) and latitude(2)
19+
integer, dimension(Np) :: p_s ! status 0=on surface, 1=inflight, <0= destroyed or trapped
20+
real(8), dimension(Np) :: p_t ! time
21+
integer, dimension(Np) :: p_n ! # of hops (diagnostic only)
2222

2323
integer, external :: inbox
2424
real(8), external :: residence_time
@@ -40,7 +40,7 @@ PROGRAM exospherebody
4040
print *,'Equilibration time',tequil,' solar days'
4141
print *,'Maximum time',tmax,' solar days',tmax*solarDay/(86400.*365.242),' years'
4242
print *,'grid size',nlon,'x',nlat,'veclen=',veclen
43-
print *,'number of molecules',np
43+
print *,'number of molecules',Np
4444

4545
HAi = 0. ! noon
4646

@@ -51,7 +51,7 @@ PROGRAM exospherebody
5151
! initial configuration
5252
!p_t(:)=0.; p_s(:)=0 ! all particles on surface
5353
p_t(:)=1d99; p_s(:)=-9 ! no particles
54-
!do i=1,np
54+
!do i=1,Np
5555
!p_r(i,1)=360.*ran2(idum)
5656
!p_r(i,2)=0.
5757
!enddo
@@ -62,17 +62,17 @@ PROGRAM exospherebody
6262
open(unit=50,file='particles',status='unknown',action='write')
6363
open(unit=51,file='particles_end',status='unknown',action='write')
6464

65-
!-------loop over time steps
65+
!-------loop over time steps
6666
do n=-nequil,1000000
67-
time =(n+1)*dtsec ! time at n+1
67+
time =(n+1)*dtsec ! time at n+1
6868
if (time>tmax*solarDay) exit
6969

7070
!-- Temperature
7171
call SurfaceTemperature(dtsec,HAi,time,Tsurf,Qn) ! model T
7272
if (n<0) cycle ! skip remainder
7373

7474
! some output
75-
call totalnrs(np,p_s,cc)
75+
call totalnrs(Np,p_s,cc)
7676
print *,time/3600.,'Ten minute call',sum(cc(1:2))
7777
write(30,*) time/3600.,cc(1:2),ccc(1:4),cc_prod_total
7878

@@ -82,7 +82,7 @@ PROGRAM exospherebody
8282
cc_prod_total = cc_prod_total + cc_prod
8383

8484
! update residence times with new temperature
85-
do i=1,np
85+
do i=1,Np
8686
if (p_s(i)==0) then ! on surface
8787
k = inbox(p_r(i,:))
8888
residencetime = residence_time(Tsurf(k))
@@ -91,12 +91,12 @@ PROGRAM exospherebody
9191
enddo
9292

9393
if (n==0) then ! write out initial distribution
94-
!call writeparticles(50,np,p_r,p_s,p_t,p_n)
94+
!call writeparticles(50,Np,p_r,p_s,p_t,p_n)
9595
call writeglobe(20,Tsurf)
9696
endif
9797

9898
! 1 hour of hopping
99-
call montecarlo(np,idum,p_r,p_s,p_t,p_n,Tsurf,dtsec,ccc,Qn)
99+
call montecarlo(Np,idum,p_r,p_s,p_t,p_n,Tsurf,dtsec,ccc,Qn)
100100

101101
call totalnrs(Np,p_s,cc)
102102

Exospheres/montecarlo.f90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! Monte Carlo model of ballistically hopping molecules
22
! each particle has
3-
! x (longitude), y (latitude), status (on surface or in flight),
3+
! x (longitude), y (latitude), status (on surface or in flight),
44
! time (until it arrives on surface or until it will leave the surface)
55

66
module exo_species
@@ -198,18 +198,18 @@ end function residence_timeR
198198
subroutine montecarlo(Np,idum,p_r,p_s,p_t,p_n,Tsurf,dtsec,ccc,Q)
199199
! called once every temperature time step dtsec (e.g., one hour)
200200
implicit none
201-
integer, intent(IN) :: np
201+
integer, intent(IN) :: Np
202202
real(8), intent(IN) :: Tsurf(*), dtsec, Q(*)
203-
integer, intent(INOUT) :: idum, p_s(np), p_n(np), ccc(4)
204-
real(8), intent(INOUT) :: p_r(np,2), p_t(np)
203+
integer, intent(INOUT) :: idum, p_s(Np), p_n(Np), ccc(4)
204+
real(8), intent(INOUT) :: p_r(Np,2), p_t(Np)
205205
integer i, k
206206
real(8) residencetime
207207
logical, parameter :: VERBOSE = .false.
208208
logical, external :: incoldtrap
209209
integer, external :: inbox, insidecoldtrap
210210
real(8), external :: residence_time
211211

212-
do i=1,np
212+
do i=1,Np
213213
if (VERBOSE) print *,'montecarlo: working on particle',i
214214

215215
do ! do this for time interval Dt

Exospheres/moon_exo.f90

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PROGRAM allofmoon
22
!***********************************************************************
3-
! surface temperatures of airless body with H2O exosphere
3+
! H2O exosphere and surface temperatures for the Moon
44
!***********************************************************************
55
use grid
66
use body, only: solarDay, dtsec, Rmoon => Rbody
@@ -12,19 +12,19 @@ PROGRAM allofmoon
1212
integer cc(6), cc_prod, cc_prod_total, ccc(4)
1313
integer :: idum=-92309 ! random number seed
1414
real(8) tmax, time, tequil
15-
real(8), dimension(veclen) :: Tsurf, Qn !, sigma
15+
real(8), dimension(veclen) :: Tsurf, Qn !, sigma
1616
real(8) residencetime, HAi
1717
character(10) ext
1818

19-
real(8), dimension(np,2) :: p_r ! longitude(1) and latitude(2)
20-
integer, dimension(np) :: p_s ! status 0=on surface, 1=inflight, <0= destroyed or trapped
21-
real(8), dimension(np) :: p_t ! time
22-
integer, dimension(np) :: p_n ! # of hops (diagnostic only)
19+
real(8), dimension(Np,2) :: p_r ! longitude(1) and latitude(2)
20+
integer, dimension(Np) :: p_s ! status 0=on surface, 1=inflight, <0= destroyed or trapped
21+
real(8), dimension(Np) :: p_t ! time
22+
integer, dimension(Np) :: p_n ! # of hops (diagnostic only)
2323

2424
integer, external :: inbox
2525
real(8), external :: residence_time
2626
real(8), external :: flux_noatm, ran2
27-
27+
2828
! if used with Diviner surface temperature maps as input
2929
!integer, parameter :: NT=708 ! tied to timestep of 708/(29.53*86400.) = 3596 sec
3030
!real(8) lon(nlon),lat(nlat),Tbig(nlon,nlat,24)
@@ -46,7 +46,7 @@ PROGRAM allofmoon
4646
print *,'Equilibration time',tequil,' lunar days'
4747
print *,'Maximum time',tmax,' lunar days',tmax*solarDay/(86400.*365.242),' years'
4848
print *,'grid size',nlon,'x',nlat,'veclen=',veclen
49-
print *,'number of molecules',np
49+
print *,'number of molecules',Np
5050

5151
HAi = 0. ! noon
5252

@@ -57,10 +57,10 @@ PROGRAM allofmoon
5757
! initial configuration
5858
!p_t(:)=0.; p_s(:)=0 ! all particles on surface
5959
p_t(:)=1d99; p_s(:)=-9 ! no particles
60-
!do i=1,np
61-
!p_r(i,1)=360.*ran2(idum);
60+
!do i=1,Np
61+
!p_r(i,1)=360.*ran2(idum)
6262
!p_r(i,1)=0.
63-
!p_r(i,2)=0.;
63+
!p_r(i,2)=0.
6464
!enddo
6565

6666
open(unit=20,file='Tsurface',status='unknown',action='write')
@@ -75,9 +75,9 @@ PROGRAM allofmoon
7575
! if Diviner surface temperatures are read in
7676
!call readTmaps(nlon,nlat,lon,lat,Tbig)
7777

78-
!-------loop over time steps
78+
!-------loop over time steps
7979
do n=-nequil,1000000
80-
time =(n+1)*dtsec ! time at n+1
80+
time =(n+1)*dtsec ! time at n+1
8181
if (time>tmax*solarDay) exit
8282

8383
!-- Temperature
@@ -86,7 +86,7 @@ PROGRAM allofmoon
8686
if (n<0) cycle ! skip remainder
8787

8888
! some output
89-
call totalnrs(np,p_s,cc)
89+
call totalnrs(Np,p_s,cc)
9090
print *,time/3600.,'One hour call',sum(cc(1:2))
9191
write(30,*) time/3600.,cc(1:2),ccc(1:4),cc_prod_total
9292

@@ -96,7 +96,7 @@ PROGRAM allofmoon
9696
cc_prod_total = cc_prod_total + cc_prod
9797

9898
! update residence times with new temperature
99-
do i=1,np
99+
do i=1,Np
100100
if (p_s(i)==0) then ! on surface
101101
k = inbox(p_r(i,:))
102102
residencetime = residence_time(Tsurf(k))
@@ -105,14 +105,14 @@ PROGRAM allofmoon
105105
enddo
106106

107107
if (n==0) then ! write out initial distribution
108-
!call writeparticles(50,np,p_r,p_s,p_t,p_n)
108+
!call writeparticles(50,Np,p_r,p_s,p_t,p_n)
109109
call writeglobe(20,Tsurf)
110110
endif
111111

112112
write(ext,'(i0.4)') n
113113
call deblank(ext)
114114
!open(unit=27,file='particles.'//ext,status='unknown',action='write')
115-
!call writeparticles(27,np,p_r,p_s,p_t,p_n)
115+
!call writeparticles(27,Np,p_r,p_s,p_t,p_n)
116116
!close(27)
117117
!open(unit=28,file='tsurf.'//ext,status='unknown',action='write')
118118
!call writeglobe(28,Tsurf)
@@ -122,7 +122,7 @@ PROGRAM allofmoon
122122
!endif
123123

124124
! 1 hour of hopping
125-
call montecarlo(np,idum,p_r,p_s,p_t,p_n,Tsurf,dtsec,ccc,Qn)
125+
call montecarlo(Np,idum,p_r,p_s,p_t,p_n,Tsurf,dtsec,ccc,Qn)
126126

127127
call totalnrs(Np,p_s,cc)
128128

@@ -205,8 +205,8 @@ subroutine SurfaceTemperature(dtsec,HAi,time,Tsurf,Qn)
205205
! toy orbit
206206
decl = 0.
207207
sunR = semia
208-
! better orbit
209-
!eps = 1.54*d2r ! lunar obliquity to ecliptic
208+
! better orbit
209+
!eps = 1.54*d2r ! lunar obliquity to ecliptic
210210
!ecc=0.; omega=0.
211211
!call generalorbit(time/86400.,semia,ecc,omega,eps,Ls,decl,sunR)
212212

@@ -272,11 +272,14 @@ subroutine particles2sigma(Np, p_r, p_s, sigma)
272272
integer, intent(IN) :: Np, p_s(Np)
273273
real(8), intent(IN) :: p_r(Np,2)
274274
real(8), intent(OUT) :: sigma(veclen)
275-
integer i, k, nr0(veclen), nr1(veclen), totalnr0, totalnr1
276-
real(8) dA(veclen)
275+
integer i, k, totalnr0, totalnr1
276+
integer, allocatable :: nr0(:), nr1(:)
277+
real(8), allocatable :: dA(:) ! allocation avoids max-stack-var-size warning
277278
logical, save :: FirstCall = .TRUE.
278279
integer, external :: inbox
279280

281+
allocate( nr0(veclen), nr1(veclen), dA(veclen) )
282+
280283
nr0(:)=0; nr1(:)=0
281284
do i=1,Np
282285
if (p_s(i)==0) then
@@ -293,15 +296,15 @@ subroutine particles2sigma(Np, p_r, p_s, sigma)
293296
dA = dA*Rbody**2
294297

295298
sigma(:) = nr0(:)/dA(:)
296-
!sigma(:) = nr1(:)/dA(:)
299+
!sigma(:) = nr1(:)/dA(:)
297300
!print *,'total area',sum(dA)/(4*pi*Rbody**2) ! test
298301
totalnr0 = sum(nr0(:))
299302
totalnr1 = sum(nr1(:))
300303
!print *,'total # particles in particles2sigma:',Np,totalnr0 ! for checking purposes
301304

302305
!where(sigma>maxsigma) maxsigma=sigma
303306

304-
if (FirstCall) then
307+
if (FirstCall) then
305308
open(unit=40,file='sigma.dat',action='write')
306309
FirstCall = .FALSE.
307310
!maxsigma=0.
@@ -310,6 +313,7 @@ subroutine particles2sigma(Np, p_r, p_s, sigma)
310313
endif
311314
write(40,'(*(1x,g11.5))') sigma
312315
close(40)
316+
deallocate(nr0,nr1,dA)
313317
end subroutine particles2sigma
314318

315319

@@ -321,9 +325,11 @@ subroutine fallmap(unit, fall)
321325
implicit none
322326
integer, intent(IN) :: unit, fall(veclen)
323327
integer i,j,k
324-
real(8) sigma(veclen), dA(veclen)
328+
real(8), dimension(:), allocatable :: sigma(:), dA(:)
329+
! allocation avoids max-stack-var-size warning
325330
real(8) longitude(nlon), latitude(nlat)
326331

332+
allocate( sigma(veclen), dA(veclen) )
327333
call areas(dA)
328334
dA = dA*Rmoon**2
329335

@@ -334,13 +340,14 @@ subroutine fallmap(unit, fall)
334340
write(unit,110) 0.,90.,sigma(1)
335341
do j=1,nlat
336342
do i=1,nlon
337-
k = 1 + i + (j-1)*nlon
343+
k = 1 + i + (j-1)*nlon
338344
write(unit,110) longitude(i),latitude(j),sigma(k)
339345
enddo
340346
enddo
341347
write(unit,110) 0.,-90.,sigma(veclen)
342348
110 format (f5.1,1x,f6.2,1x,g10.4)
343349

344350
print *,'Total area',sum(dA)
351+
deallocate( sigma, dA)
345352
end subroutine fallmap
346353

0 commit comments

Comments
 (0)