Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | Tdb | |||
real(kind=r64), | intent(in) | :: | W | |||
real(kind=r64), | intent(in) | :: | Pb | |||
character(len=*), | intent(in), | optional | :: | calledfrom |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
FUNCTION PsyTwbFnTdbWPb(Tdb,W,Pb,calledfrom) RESULT (Twb_result)
! FUNCTION INFORMATION:
! AUTHOR Linda Lawrie/Amir Roth
! DATE WRITTEN August 2011
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! Provide a "cache" of results for the given arguments and wetbulb (twb) output result.
! METHODOLOGY EMPLOYED:
! Use grid shifting and masking to provide hash into the cache. Use Equivalence to
! make Fortran ignore "types".
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
REAL(r64), intent(in) :: Tdb ! dry-bulb temperature {C}
REAL(r64), intent(in) :: W ! humidity ratio
REAL(r64), intent(in) :: Pb ! barometric pressure {Pascals}
character(len=*), intent(in), optional :: calledfrom ! routine this function was called from (error messages)
REAL(r64) :: Twb_result ! result=> Temperature Wet-Bulb {C}
! FUNCTION PARAMETER DEFINITIONS:
integer(i64), parameter :: Grid_Shift=(64 - 12 - twbPrecision_bits)
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
integer(i64) :: Tdb_tag, W_tag, Pb_tag
integer(i64) :: hash
real(r64) :: Tdb_tag_r, w_tag_r, Pb_tag_r
# 1384
Tdb_tag = Transfer(Tdb,Tdb_tag)
W_tag = Transfer(W,W_tag)
Pb_tag = Transfer(Pb,Pb_tag)
!Both Intel & GNU are happy to use .iand.
Tdb_tag = ISHFT(Tdb_tag, -Grid_shift)
W_tag = ISHFT(W_tag, -Grid_shift)
Pb_tag = ISHFT(Pb_tag, -Grid_shift)
hash = IAND(IEOR(Tdb_tag,IEOR(W_tag,Pb_tag)), INT(twbcache_size - 1,i64))
IF (cached_Twb(hash)%iTdb /= Tdb_tag .OR. cached_Twb(hash)%iW /= W_tag .OR. cached_Twb(hash)%iPb /= Pb_tag) THEN
cached_Twb(hash)%iTdb = Tdb_tag
cached_Twb(hash)%iW = W_tag
cached_Twb(hash)%iPb = Pb_tag
Tdb_tag_r = Transfer(ISHFT(Tdb_tag, Grid_shift), Tdb_tag_r)
W_tag_r = Transfer(ISHFT(W_tag, Grid_shift), W_tag_r)
Pb_tag_r = Transfer(ISHFT(Pb_tag, Grid_shift), Pb_tag_r)
IF (PRESENT(calledfrom)) THEN
cached_Twb(hash)%Twb = PsyTwbFnTdbWPb_raw(Tdb_tag_r, W_tag_r, Pb_tag_r,calledfrom)
ELSE
cached_Twb(hash)%Twb = PsyTwbFnTdbWPb_raw(Tdb_tag_r, W_tag_r, Pb_tag_r)
ENDIF
END IF
! Twbresult_last = cached_Twb(hash)%Twb
! Twb_result = Twbresult_last
Twb_result = cached_Twb(hash)%Twb
RETURN
END FUNCTION PsyTwbFnTdbWPb