MAPL_EQsatSET Subroutine

public subroutine MAPL_EQsatSET(UseTable, Formulation, Subdivisions, MixingRatio)

The subroutine MAPL_EQsatSET set behavior of MAPL_EQsat. MAPL_EQsatSet can be used to set three parameters that control the behavior of the working routine, MAPL_EQsat.

If UseTable is true, tabled values of the saturation vapor pressures are used, instead of the exact calculations. These tables are automatically generated at a 0.01K resolution for whatever vapor pressure formulation is being used. If never set, MAPL_EQsat will use the tables. If not specified, the table behavior is left unmodified.

Formulation sets the saturation vapor pressure function to use to use in generating tables or for exact calculations. Three formulations of saturation vapor pressure are supported: - the Starr code, as was used in NSIPP-1 (MAPL_UseStarrQsat), - the Goff-Gratch formulation, as used in CAM (MAPL_UseGoffGratchQsat), and - Murphy and Koop (2005, QJRMS) (MAPL_UseMurphyKoopQsat).

If it has not been set, the formulation is Starr (MAPL_UseStarrQsat). If not specified, the formulation is left unmodified.

Subdivisions sets the number of subdivisions per degree in the saturation vapor pressure tables. If never set, it is 100; if not specified, it is left unmodified.

MixingRatio sets whether MAPL_EQsat will return saturation mixing ratio (true) or saturation specific humidity (false) when the pressure is present (see MAPL_EQsat documentation). If never set, it is false; if not specified, it is left unmodified.

MAPL_EQsatSET also initializes the tables. If MAPL_EQsatSET is not called and tables are required, they will be initialized the first time one of the MAPL_EQsat functions is called. The tables are reset with every call to MAPL_EQsatSET.

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: UseTable
integer, intent(in), optional :: Formulation
integer, intent(in), optional :: Subdivisions
logical, intent(in), optional :: MixingRatio

Called by

proc~~mapl_eqsatset~~CalledByGraph proc~mapl_eqsatset MAPL_EQsatSET proc~mapl_eqsatset->proc~mapl_eqsatset program~tstqsat tstqsat program~tstqsat->proc~mapl_eqsatset

Source Code

  subroutine MAPL_EQsatSET(UseTable,Formulation,Subdivisions,MixingRatio)

! !ARGUMENTS:

    logical, optional, intent(IN) :: UseTable
    integer, optional, intent(IN) :: Formulation
    integer, optional, intent(IN) :: Subdivisions
    logical, optional, intent(IN) :: MixingRatio

! Set the global flags

    if(present(UseTable   )) UTBL = UseTable
    if(present(Formulation)) TYPE = Formulation
    if(present(MixingRatio)) MXRT = MixingRatio

    if(present(SubDivisions)) then
       DEGSUBS    =  SubDivisions
       TABLESIZE  =  nint(TMAXTBL-TMINTBL)*DEGSUBS + 1
       DELTA_T    =  1.0 / DEGSUBS
    endif

    if(TYPE/=Starr .and. TYPE/=GOFFGRATCH .and. TYPE/=MurphyKoop) then
       print *, 'Bad argument to MAPL_EQsatSET: FORMULATION=',TYPE
       print *, 'Must be one of: ', Starr, GOFFGRATCH, MurphyKoop
       stop 999
    end if

! Set the formulation dependent limits
    
    if(TYPE==MurphyKoop)  then
       TMIN(ICE  ) =  max(TMINTBL,110._REAL64)
       TMIN(WATER) =  max(TMINTBL,123._REAL64)
    else
       TMIN(WATER) =  TMINLQU
       TMIN(ICE  ) =  TMINICE
    endif

! Initialize or reset the tables, even if not needed.

    if(allocated(ESTBLE)) deallocate(ESTBLE)
    if(allocated(ESTBLW)) deallocate(ESTBLW)

    allocate(ESTBLE(TABLESIZE))
    allocate(ESTBLW(TABLESIZE))

    call ESINIT

    return

  contains
!=======================================================================================

    subroutine ESINIT

! Saturation vapor pressure table initialization. This is invoked if UTBL is true 
! on the first call to any qsat routine or whenever MAPL_QsatSet is called 
! N.B.--Tables are in Pa
 
      integer :: I
      real(kind=REAL64)  :: T
      logical :: UT

! Save the value of UTBL and temporarily set it to false to get the exact
! formulation.

      UT   = UTBL
      UTBL =.false.

! The size of the table and its resolution are currently hardwired.

      do I=1,TABLESIZE
       
         T = (I-1)*DELTA_T + TMINTBL

! The two standard tables. ESTBLW contains saturation vapor pressures over liquid
! for all temperatures. ESTBLE contains saturation vapor pressures over ice for 
! temperatures below 0C and over water above 0C.
       
         ESTBLW(I) = QSATD0(T,OverIce=.false.)
         ESTBLE(I) = QSATD0(T,OverIce=.true. )

      end do

! Reset UTBL to what it was on entry.

      UTBL = UT

! Mark table as initialized

      TableReady = .true.
    
    end subroutine ESINIT

  end subroutine MAPL_EQsatSET