我有问题:当我不知道目录的确切大小或者我不知道 nm 的大小时,是否可以将 do loop(ngal) 的最终值定义为没有确切值的自由参数和新西兰?(如你所愿的整个代码)
integer i,iz,im,ngal,n_thresh,nmax,nz,nm,ok,total,ii,j
integer, dimension(:,:),allocatable :: ngalb
double precision ramin,ramax,decmin,decmax,zmin,zmax,mag_min,mag_max,step,bin,S,dix,fi,Vmax,zbin,magbin
double precision, dimension (:),allocatable :: ra,dec,mag_g,mag_r,mag_i,redshift,zup
double precision, dimension (:,:,:),allocatable :: magb,zb
character plotname*100,zbin_str*4
open(unit=1,file='Lagos12.i.asc')
open(2,file='bin.asc')
open(3,file='mag_vol.asc')
open(4,file='luminosity_func.asc')
ramin=0.0
ramax=2.0
decmin=-2.0
decmax=2.0
zmin=0.0
zmax=3.2
mag_min=13
mag_max=26
step=0.1
bin=0.5
n_thresh=20
allocate (ra(ngal),stat=ok)
allocate (dec(ngal),stat=ok)
allocate (mag_g(ngal),stat=ok)
allocate (mag_r(ngal),stat=ok)
allocate (mag_i(ngal),stat=ok)
allocate (redshift(ngal),stat=ok)
allocate(ngalb(nz,nm),stat=ok)
ngalb=0
do i=1,ngal
read(1,*) ra(i),dec(i),mag_g(i),mag_r(i),mag_i(i),redshift(i)
iz=int((redshift(i)-zmin)/step)+1
im=int((mag_i(i)-mag_min)/bin)+1
ngalb(iz,im)=ngalb(iz,im)+1
enddo
nmax=0
do iz=1,nz
do im=1,nm
nmax=max(nmax,ngalb(iz,im))
enddo
enddo
allocate(magb(nz,nm,nmax),stat=ok)
allocate(zb(nz,nm,nmax),stat=ok)
allocate(zup(nz),stat=ok)
ngalb=0
do i=1,ngal
read(1,*)ra(i),dec(i),mag_g(i),mag_r(i),mag_i(i),redshift(i)
iz=int((redshift(i)-zmin)/step)+1
im=int((mag_i(i)-mag_min)/bin)+1
ngalb(iz,im)=ngalb(iz,im)+1
j=ngalb(iz,im)
magb(iz,im,j)=mag_i(i)
zb(iz,im,j)=redshift(i)
write(2,'(2x,3i5,2x,i5,2x,f10.7,2x,f10.5)')iz,im,j,ngalb(im,iz),magb(im,iz,j),zb(im,iz,j)
enddo
deallocate(magb,zb)
deallocate(ngalb)
deallocate (ra,dec,mag_g,mag_r,mag_i,redshift,zup)