Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaasgoyal committed Jun 25, 2024
1 parent a58eb9d commit fcbab92
Showing 1 changed file with 7 additions and 57 deletions.
64 changes: 7 additions & 57 deletions src/offline/cable_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -250,23 +250,13 @@ MODULE cable_output_module
! Some Additional internal variables
INTEGER :: out_timestep ! counter for output time steps

INTERFACE acc_out_var
MODULE PROCEDURE :: acc_out_var_d1
MODULE PROCEDURE :: acc_out_var_d2
END INTERFACE acc_out_var

INTERFACE check_and_write
MODULE PROCEDURE :: check_and_write_d1
MODULE PROCEDURE :: check_and_write_d2
MODULE PROCEDURE :: check_and_write_d1_p
MODULE PROCEDURE :: check_and_write_d2_p
END INTERFACE check_and_write

INTERFACE reset_on_write
MODULE PROCEDURE :: reset_on_write_d1
MODULE PROCEDURE :: reset_on_write_d2
END INTERFACE reset_on_write

INTERFACE generate_out_write_acc
MODULE PROCEDURE :: generate_out_write_acc_d1
MODULE PROCEDURE :: generate_out_write_acc_d2
Expand Down Expand Up @@ -2039,14 +2029,12 @@ SUBROUTINE write_output(dels, ktau, met, canopy, casaflux, casapool, casamet, ss

END SUBROUTINE write_output

PURE FUNCTION acc_out_var_d1(output_var, out_var, acc_val, writenow) RESULT(res)
PURE ELEMENTAL REAL(4) FUNCTION acc_out_var(output_var, out_var, acc_val, writenow) RESULT(res)
LOGICAL, INTENT(IN) :: output_var ! Whether to write the current variable
REAL(4), INTENT(IN) :: out_var(:)
REAL(4), INTENT(IN) :: acc_val(:)
REAL(4), INTENT(IN) :: out_var
REAL(4), INTENT(IN) :: acc_val
LOGICAL, INTENT(IN) :: writenow

REAL(4) :: res(SIZE(out_var))

IF (output_var) THEN
! Accumulate out_var until interval timesteps
res = out_var + acc_val
Expand All @@ -2056,59 +2044,21 @@ PURE FUNCTION acc_out_var_d1(output_var, out_var, acc_val, writenow) RESULT(res)
ELSE
res = out_var
END IF
END FUNCTION acc_out_var_d1
END FUNCTION acc_out_var

PURE FUNCTION acc_out_var_d2(output_var, out_var, acc_val, writenow) RESULT(res)
PURE ELEMENTAL REAL(4) FUNCTION reset_on_write(output_var, out_var, writenow) RESULT(res)
LOGICAL, INTENT(IN) :: output_var ! Whether to write the current variable
REAL(4), INTENT(IN) :: out_var(:, :)
REAL(4), INTENT(IN) :: acc_val(:, :)
REAL(4), INTENT(IN) :: out_var
LOGICAL, INTENT(IN) :: writenow

REAL(4) :: res(SIZE(out_var, DIM=1), SIZE(out_var, DIM=2))

IF (output_var) THEN
! Accumulate out_var until interval timesteps
res = out_var + acc_val
IF (writenow) THEN
res = res/REAL(output%interval, 4)
END IF
ELSE
res = out_var
END IF

END FUNCTION acc_out_var_d2

PURE FUNCTION reset_on_write_d1(output_var, out_var, writenow) RESULT(res)
LOGICAL, INTENT(IN) :: output_var ! Whether to write the current variable
REAL(4), INTENT(IN) :: out_var(:)
LOGICAL, INTENT(IN) :: writenow

REAL(4) :: res(SIZE(out_var))

res = out_var

! Reset the value if it has been written to file
IF (output_var .AND. writenow) THEN
res = 0.0
END IF

END FUNCTION reset_on_write_d1

PURE FUNCTION reset_on_write_d2(output_var, out_var, writenow) RESULT(res)
LOGICAL, INTENT(IN) :: output_var ! Whether to write the current variable
REAL(4), INTENT(IN) :: out_var(:, :)
LOGICAL, INTENT(IN) :: writenow

REAL(4) :: res(SIZE(out_var, DIM=1), SIZE(out_var, DIM=2))

res = out_var

! Reset the value if it has been written to file
IF (output_var .AND. writenow) THEN
res = 0.0
END IF

END FUNCTION reset_on_write_d2
END FUNCTION reset_on_write

SUBROUTINE check_and_write_d1(output_var, varID, vname, out_var, acc_val, vrange, writepatch, out_settings)
LOGICAL, INTENT(IN) :: output_var ! Whether to write the current variable
Expand Down

0 comments on commit fcbab92

Please sign in to comment.