Commit 94dc5d8c authored by dingwell's avatar dingwell
Browse files

Cleaned up indentation and debug messages

parent b064b5b9
......@@ -55,6 +55,7 @@ program flexwrf
! from WRF. *
! 2015-06-05 A. Dingwell: Added module netcdf_output_mod, updated calls *
! new/renamed subroutines. *
! 2015-07-10 A. Dingwell: Cleaned up indentation, added debug messages *
! *
!*******************************************************************************
! *
......@@ -63,8 +64,6 @@ program flexwrf
! Constants: *
! *
!*******************************************************************************
use point_mod
use par_mod
use com_mod
......@@ -84,8 +83,8 @@ program flexwrf
integer :: inext,inextp,ma(55),iff
! integer, dimension(MPI_STATUS_SIZE) :: status
integer :: myid,ntasks,islave
! integer, parameter :: master=0, mstgtag1=11, msgtag2=12
integer :: ierr
! integer, parameter :: master=0, mstgtag1=11, msgtag2=12
integer :: ierr
real, external :: ran3 ! added by mc to use RAN3 using the original JB random number system
integer, allocatable :: seed(:) ! here and below further variable used by the MT generator
......@@ -94,82 +93,85 @@ program flexwrf
type (mt_state) :: mts (0: MAX_STREAM)
character :: nummpi_id*2 !for test on pc
! if (myid.eq.0) then
!let's comment the line above to let each node reading and making the same
!thing.
! if (myid.eq.0) then
!let's comment the line above to let each node reading and making the same
!thing.
! save inext,inextp,ma,iff
!save inext,inextp,ma,iff
iff=0
! call MPI_INIT( ierr )
! call MPI_COMM_RANK ( MPI_COMM_WORLD, myid, ierr )
! call MPI_COMM_SIZE ( MPI_COMM_WORLD, ntasks, ierr )
if (command_argument_count().eq.0) then
print*,'the input file used is flexwrf.input in the ' // &
'local folder of the executable'
inputname='flexwrf.input'
endif
if (command_argument_count().gt.0) then
call get_command_argument(1,inputname,len2,ierr)
print*,'the input file used is ' // inputname
endif
!call MPI_INIT( ierr )
!call MPI_COMM_RANK ( MPI_COMM_WORLD, myid, ierr )
!call MPI_COMM_SIZE ( MPI_COMM_WORLD, ntasks, ierr )
if (command_argument_count().eq.0) then
print*,'the input file used is flexwrf.input in the ' // &
'local folder of the executable'
inputname='flexwrf.input'
endif
if (command_argument_count().gt.0) then
call get_command_argument(1,inputname,len2,ierr)
print*,'the input file used is ' // inputname
endif
! Generate a large number of random numbers
!******************************************
if (newrandomgen.eq.0) then
! idummy = -320-(myid*4049)
idummy = -320
do j=1,maxomp
write(*,*) "Pre-generating random numbers"
if (newrandomgen.eq.0) then
!idummy = -320-(myid*4049)
idummy = -320
do j=1,maxomp
do i=1,maxrand-1,2
ii=i+(j-1)*maxrand
ii=i+(j-1)*maxrand
call gasdev1(idummy,rannumb(ii),rannumb(ii+1),inext,inextp,ma,iff)
enddo
enddo
ii=maxrand*maxomp
call gasdev1(idummy,rannumb(ii),rannumb(ii-1),inext,inextp,ma,iff)
! print*,'rand',myid
! print*,rannumb(1:5)
! call ranlux(uniform_rannumb,maxrandomp) ! this generate a uniform
! distribution
else
idummy=254 !+myid*443 !different seed for different mpi processes are produced so indepedent stream for any mpi process suing RANLUX are certain
call RLUXGO(3,idummy,0,0) ! this set the luxury level to 3 and initalize the generator for any myid
do i=1,maxrand-1,2
enddo
ii=maxrand*maxomp
call gasdev1(idummy,rannumb(ii),rannumb(ii-1),inext,inextp,ma,iff)
!print*,'rand',myid
!print*,rannumb(1:5)
!call ranlux(uniform_rannumb,maxrandomp) ! this generate a uniform
!distribution
else
idummy=254 !+myid*443 !different seed for different mpi processes are produced so indepedent stream for any mpi process suing RANLUX are certain
call RLUXGO(3,idummy,0,0) ! this set the luxury level to 3 and initalize the generator for any myid
do i=1,maxrand-1,2
call gasdevlux2R(rannumb(i),rannumb(i+1)) !this will generate a guassian distribution
end do
call gasdevlux2R(rannumb(maxrand),rannumb(maxrand-1))
! Generate a stream of uniform deviate random numbers to be used for CBL
call ranlux(uniform_rannumb,maxrand) ! this generate a uniform distribution
!----- comment by MC: now initialize the mersenne twister generator for a number
!max_stream of possible streams
!----- to be called subsequently by any openmp process activated. note RANLUX
!above is suppose to be the best generator
!----- but it is slower than mersenne twister and moreover it would require some
!adaptation for workiong with openmp processes
!do this on any mpi_process taht will have a copy of all the MT generator
!initialization
! set parameters
call set_mt19937
! initialize MT state type
call new (mts(0))
call init (mts(0),iseed) !iseed unique and defined above. note that the lenght of the period of the master stream is about 2^19000
! initialize additional streams from the master. this is done jumping
! between different points in the stream any child stream has period
! 2^256
do id=1, MAX_STREAM
call create_stream (mts(0),mts(id),id)
end do
end if
end do
call gasdevlux2R(rannumb(maxrand),rannumb(maxrand-1))
! Generate a stream of uniform deviate random numbers to be used for CBL
call ranlux(uniform_rannumb,maxrand) ! this generate a uniform distribution
!----- comment by MC: now initialize the mersenne twister generator for a number
!max_stream of possible streams
!----- to be called subsequently by any openmp process activated. note RANLUX
!above is suppose to be the best generator
!----- but it is slower than mersenne twister and moreover it would require some
!adaptation for workiong with openmp processes
!do this on any mpi_process taht will have a copy of all the MT generator
!initialization
! set parameters
write(*,*) "Calling set_mt19937"
call set_mt19937
! initialize MT state type
write(*,*) "Calling new (mts(0))"
call new (mts(0))
write(*,*) "Calling init (mts(0),iseed)"
call init (mts(0),iseed) !iseed unique and defined above. note that the lenght of the period of the master stream is about 2^19000
! initialize additional streams from the master. this is done jumping
! between different points in the stream any child stream has period
! 2^256
write(*,*) "Generating additional streams"
do id=1, MAX_STREAM
call create_stream (mts(0),mts(id),id)
end do
end if
! Read the unified input file - jdf
!***************************
!**********************************
write(*,*) "Calling readinput"
call readinput
! Get terrain and dry deposition resistances
......@@ -192,38 +194,34 @@ program flexwrf
! Convert the release point coordinates from geografical to grid coordinates
!***************************************************************************
call coordtrafo
call coordtrafo
! Initialize all particles to non-existent
!*****************************************
! do j=1,maxpart
! itra1(j)=-999999999
! enddo
! For continuation of previous run, read in particle positions
!*************************************************************
if (ipin.eq.1) then
call readpartpositions
else
numpart=0
if (ipin.eq.1) then
call readpartpositions
else
numpart=0
numparticlecount=0
endif
endif
! Calculate volume, surface area, etc., of all output grid cells
!***************************************************************
! if (myid.eq.0) then
if (outgrid_option.eq.0) then
call outgrid_init_irreg
if (nested_output.eq.1) call outgrid_init_nest_irreg !need to be fixed
elseif (outgrid_option.eq.1) then
call outgrid_init_reg
if (nested_output.eq.1) call outgrid_init_nest_reg !need to be fixed
endif
if (outgrid_option.eq.0) then
call outgrid_init_irreg
if (nested_output.eq.1) call outgrid_init_nest_irreg !need to be fixed
elseif (outgrid_option.eq.1) then
call outgrid_init_reg
if (nested_output.eq.1) call outgrid_init_nest_reg !need to be fixed
endif
! endif
......@@ -231,64 +229,64 @@ program flexwrf
!******************
if (OHREA.eqv..TRUE.) &
call readohfield
call readohfield
! Write basic information on the simulation to a file "header"
! and open files that are to be kept open throughout the simulation
!******************************************************************
if (iouttype.eq.2 .and. ipout.gt.0) call writeheader
! if (myid.eq.0) then
if (iouttype.eq.0 .or. iouttype.eq.1) then ! binary or ascii output
call writeheader
if (nested_output.eq.1) call writeheader_nest() !need to be fixed
else ! netcdf output
call nc_create_header_outfile(0,0)
if (nested_output.eq.1) call nc_create_header_outfile(0,1)
endif !iouttype
! open(unitdates,file=path(2)(1:length(2))//'dates')
open(unitdates,file=path(1)(1:length(1))//'dates')
call openreceptors
if ((iout.eq.4).or.(iout.eq.5)) call openouttraj
if (iouttype.eq.2 .and. ipout.gt.0) call writeheader
! if (myid.eq.0) then
if (iouttype.eq.0 .or. iouttype.eq.1) then ! binary or ascii output
call writeheader
if (nested_output.eq.1) call writeheader_nest() !need to be fixed
else ! netcdf output
call nc_create_header_outfile(0,0)
if (nested_output.eq.1) call nc_create_header_outfile(0,1)
endif !iouttype
! open(unitdates,file=path(2)(1:length(2))//'dates')
open(unitdates,file=path(1)(1:length(1))//'dates')
call openreceptors
if ((iout.eq.4).or.(iout.eq.5)) call openouttraj
! endif
! Releases can only start and end at discrete times (multiples of lsynctime)
!***************************************************************************
do i=1,numpoint
ireleasestart(i)=nint(real(ireleasestart(i))/ &
real(lsynctime))*lsynctime
ireleaseend(i)=nint(real(ireleaseend(i))/ &
real(lsynctime))*lsynctime
enddo
do i=1,numpoint
ireleasestart(i)=nint(real(ireleasestart(i))/ &
real(lsynctime))*lsynctime
ireleaseend(i)=nint(real(ireleaseend(i))/ &
real(lsynctime))*lsynctime
enddo
! Initialize cloud-base mass fluxes for the convection scheme
!************************************************************
do jy=0,nymin1
do ix=0,nxmin1
cbaseflux(ix,jy)=0.
do jy=0,nymin1
do ix=0,nxmin1
cbaseflux(ix,jy)=0.
end do
end do
do inest=1,numbnests
do jy=0,nyn(inest)-1
do ix=0,nxn(inest)-1
cbasefluxn(ix,jy,inest)=0.
do inest=1,numbnests
do jy=0,nyn(inest)-1
do ix=0,nxn(inest)-1
cbasefluxn(ix,jy,inest)=0.
end do
end do
end do
end do
! Calculate particle trajectories
!********************************
! endif !if condition on myid
! call MPI_BARRIER(MPI_COMM_WORLD,ierr)
if (option_verbose.ge.1) write(*,*) "Starting timemanager"
if (option_verbose.ge.10) write(*,*) "Starting timemanager"
call timemanager(mts)
write(*,'(/a/)') 'CONGRATULATIONS: YOU HAVE SUCCESSFULLY ' // &
'COMPLETED A FLEXPART_WRF MODEL RUN!'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment