Skip to content

Commit

Permalink
Do not reinitialise the pass struct when using rads_close_pass with k…
Browse files Browse the repository at this point in the history
…eep = .true.

This fixes issue #97.
  • Loading branch information
remkos committed Jun 6, 2016
1 parent cc06763 commit cce4803
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions src/rads.f90
Original file line number Diff line number Diff line change
Expand Up @@ -733,30 +733,25 @@ subroutine rads_init_pass_struct (S, P)
P%S => S
end subroutine rads_init_pass_struct

!****if* rads/rads_free_sat_struct
!****if* rads/rads_free_pass_struct
! SUMMARY
! Free all allocated memory from rads_pass struct and reinitialise
!
! SYNOPSIS
subroutine rads_free_pass_struct (S, P, unlink)
subroutine rads_free_pass_struct (S, P)
type(rads_sat), intent(in) :: S
type(rads_pass), intent(inout) :: P
logical, optional, intent(in) :: unlink
!
! PURPOSE
! This routine frees the <P> struct of type rads_pass. If <unlink>
! is set to .true. the allocated memory is merely unlinked, otherwise
! all allocated memory is destroyed.
! This routine frees the <P> struct of type rads_pass.
! Afterwards the routine reinitialises a clean struct.
!
! ARGUMENT
! S : Satellite/mission dependent structure
! P : Pass dependent structure
!****-------------------------------------------------------------------
integer(fourbyteint) :: ios
if (.not.present(unlink) .or. .not.unlink) then
deallocate (P%history, P%flags, P%tll, stat=ios)
endif
deallocate (P%history, P%flags, P%tll, stat=ios)
call rads_init_pass_struct (S, P)
end subroutine rads_free_pass_struct

Expand Down Expand Up @@ -1277,7 +1272,7 @@ subroutine rads_open_pass (S, P, cycle, pass, rw)
P%pass = pass
ascdes = modulo(pass,2) ! 1 if ascending, 0 if descending

if (rads_verbose >= 2) write (*,'(a,2i5)') 'Checking cycle/pass : ',cycle,pass
if (rads_verbose >= 2) write (*,'(a,a3,2i5)') 'Checking sat/cycle/pass : ',S%sat,cycle,pass

! Do checking on cycle limits
if (cycle < S%cycles(1) .or. cycle > S%cycles(2)) then
Expand Down Expand Up @@ -1528,7 +1523,7 @@ subroutine rads_close_pass (S, P, keep)
! The routine will reset the ncid element of the <P> structure to
! indicate that the passfile is closed.
! If <keep> is set to .true., then the history, flags, time, lat, and lon
! elements the <P> structure are kept. That is they are not deallocated
! elements the <P> structure are kept. I.e., they are not deallocated
! but only their links are removed. Otherwise, they are deallocated along
! with the log entries.
! A second call to rads_close_pass without the keep argment can subsequently
Expand All @@ -1550,7 +1545,7 @@ subroutine rads_close_pass (S, P, keep)
if (ncid > 0 .and. nft(nf90_close(ncid))) S%error = rads_err_nc_close
enddo
P%fileinfo = rads_file (0, '')
call rads_free_pass_struct (S, P, keep)
if (.not.present(keep) .or. .not.keep) call rads_free_pass_struct (S, P)
end subroutine rads_close_pass

!****if* rads/rads_get_var_by_number
Expand Down
2 changes: 1 addition & 1 deletion src/radsxogen.f90
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ subroutine xogen_batch (S1, S2, dt1, dt2)
! Nullify all pointers
nullify (P2, top, prev)

600 format (a,3i6)
600 format (a,2i5,i8)

! Cycle through cycles and passes for S1
do cycle1 = S1%cycles(1), S1%cycles(2)
Expand Down

0 comments on commit cce4803

Please sign in to comment.