Commit 89524b80 authored by Karsten Bolding's avatar Karsten Bolding

output.F90 updated according to output branch (?)

parent 83deb1fd
......@@ -12,7 +12,9 @@
! !USES:
use time, only: write_time_string,timestep,timestr
use ascii_out
use m2d, only: sealevel_check
#ifndef NO_3D
use m3d, only: calc_salt,calc_temp
use variables_3d, only: do_numerical_analyses
#endif
#ifdef TEST_NESTING
......@@ -39,10 +41,10 @@
logical :: save_mean=.false.
logical :: save_vel=.true.
logical :: destag=.false.
logical :: save_strho=.true.
logical :: save_s=.true.
logical :: save_t=.true.
logical :: save_rho=.true.
logical :: save_strho=.false.
logical :: save_s=.false.
logical :: save_t=.false.
logical :: save_rho=.false.
logical :: save_rad=.false.
logical :: save_turb=.true.
logical :: save_tke=.true.
......@@ -61,6 +63,10 @@
integer :: mean0=0
integer :: meanout=-1
logical :: save_numerical_analyses=.false.
logical,private :: save_restart
integer,private :: firstN=-1
integer,private :: lastN=-1
logical,private :: save_init=.false.
!
! !REVISION HISTORY:
......@@ -79,13 +85,13 @@
! !DESCRIPTION:
!
! !INTERFACE:
subroutine init_output(runid,title,starttime,runtype,dryrun,myid)
subroutine init_output(runid,title,starttime,runtype,dryrun,myid,MinN,MaxN,save_initial)
IMPLICIT NONE
!
! !INPUT PARAMETERS:
character(len=*), intent(in) :: runid,title,starttime
integer, intent(in) :: runtype,myid
logical, intent(in) :: dryrun
integer, intent(in) :: runtype,myid,MinN,MaxN
logical, intent(in) :: dryrun,save_initial
!
! !REVISION HISTORY:
!
......@@ -113,6 +119,10 @@
LEVEL1 'init_output'
firstN = MinN
lastN = MaxN
save_init = save_initial
read(NAMLST, nml=io_spec)
if (hotin_fmt .ne. NETCDF) then
......@@ -133,10 +143,23 @@
if (runtype .eq. 2) then
save_strho = .false.
end if
if (.not. save_strho) then
save_s = .false.
save_t = .false.
save_rho = .false.
end if
#ifndef NO_3D
if (.not. calc_salt) then
save_s = .false.
end if
if (.not. calc_temp) then
save_t = .false.
end if
#endif
if(destag) then
LEVEL2 'de-stag velocities to T-points'
else
......@@ -161,7 +184,8 @@
end if
#endif
if ( hotout(1) .ge. 0) then
save_restart = (hotout(1).ge.0)
if (save_restart) then
if (hotout_fmt .ne. NETCDF) then
STDERR 'Writing of non-netcdf restart files not supported anymore!'
stop
......@@ -257,7 +281,7 @@
!
! !LOCAL VARIABLES:
REALTYPE :: secs
logical :: write_2d,write_3d,write_mean=.false.
logical :: write_2d,write_3d,write_mean=.false.,write_restart=.false.
integer :: dummy
!EOP
!-------------------------------------------------------------------------
......@@ -271,10 +295,25 @@
write_2d = save_2d .and. n .ge. first_2d .and. mod(n,step_2d).eq.0
write_3d = save_3d .and. n .ge. first_3d .and. mod(n,step_3d).eq.0
! TODO: Presently save_init can only be used to switch off initial output.
! Maybe we want to extend this so that save_init=T in any case
! (independent of the checks above) causes initial output?
if (.not.save_init .and. n.eq.firstN-1) then
write_2d = .false.
write_3d = .false.
end if
#ifndef NO_3D
if (meanout .gt. 0 .and. n .gt. mean0) then
write_mean = save_mean .and. (mod(n,meanout) .eq. 0)
! write_mean = save_mean .and. (mod(n-mean0,meanout) .eq. 0)
if (save_mean .and. n.gt.mean0) then
if (meanout .eq. 0) then
write_mean = (n.eq.lastN)
else
write_mean = (mod(n,meanout).eq.0)
!write_mean = (mod(n-mean0,meanout).eq.0)
end if
call calc_mean_fields(n,write_mean)
end if
#endif
......@@ -307,10 +346,19 @@
end if
! Restart file
if ( hotout(1) .gt. 0 ) then
if (hotout(1) .le. n .and. &
n .le. hotout(2) .and. &
mod(n,hotout(3)) .eq. 0) then
if (save_restart) then
if (hotout(1) .eq. 0) then
! Save last restart file
! also works for zero-length simulations (called from init_model)
write_restart = (n.eq.lastN)
else if (firstN .le. n) then ! avoid recreating just read restart file
write_restart = hotout(1).le.n .and. n.le.hotout(2) .and. mod(n,hotout(3)).eq.0
end if
if (write_restart) then
if ( sealevel_check .ne. 0 ) then
LEVEL2 'Checking for NANs before saving hotstart file...'
call sealevel_nan_check()
end if
dummy = n
call restart_file(WRITING,trim(hot_out),dummy,runtype)
end if
......@@ -589,6 +637,7 @@
loop = 0
julianday=jd; secondsofday=secs
end if
firstN = loop+1
mean0 = loop
end if ! READING
......@@ -634,21 +683,6 @@
write(debug,*) 'clean_output() # ',Ncall
#endif
! Save last restart file
if (hotout(1) .eq. 0) then
call restart_file(WRITING,trim(hot_out),loop,runtype)
end if
if (save_mean .and. meanout.eq.0) then
select case (out_fmt)
case(NETCDF)
dummy=-_ZERO_
#ifndef NO_3D
LEVEL3 timestr, ': saving mean fields .... '
call save_mean_ncdf(dummy)
#endif
end select
end if
select case (out_fmt)
case (NETCDF)
......
Markdown is supported
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