<commit_before>MODULE Simple_Physics
!JOY adding binding and c-binding module

use iso_c_binding
implicit none
contains

subroutine simple_physics_func (pcols, pver, dtime, lat, t, q, u, v, pmid, pint, &
        pdel, rpdel, ps, precl, test,&
        do_lsc, do_pbl, do_surf_flux,&
        do_qflux, do_momflux, do_tflux,&
        use_ts_ext, ts) bind(c,name='dcmipSimplePhysics')
    !JOY adding new variables
!----------------------------------------------------------------------- 
! 
! Purpose: Simple Physics Package
!
! Author: <NAME> (University of Michigan, <EMAIL>)
!         version 5 
!         July/8/2012
!
!  Change log:
!  v2: removal of some NCAR CAM-specific 'use' associations
!  v3: corrected precl(i) computation, the precipitation rate is now computed via a vertical integral, the previous single-level computation in v2 was a bug
!  v3: corrected dtdt(i,1) computation, the term '-(i,1)' was missing the temperature variable: '-t(i,1)'
!  v4: modified and enhanced parameter list to make the routine truly standalone, the number of columns and vertical levels have been added: pcols, pver
!  v4: 'ncol' has been removed, 'pcols' is used instead
!  v5: the sea surface temperature (SST) field Tsurf is now an array, the SST now depends on the latitude
!  v5: addition of the latitude array 'lat' and the flag 'test' in the parameter list
!      if test = 0: constant SST is used, correct setting for the tropical cyclone test case 5-1
!      if test = 1: newly added latitude-dependent SST is used, correct setting for the moist baroclinic wave test with simple-physics (test 4-3)
! 
! Description: Includes large-scale precipitation, surface fluxes and
!              boundary-leyer mixing. The processes are time-split
!              in that order. A partially implicit formulation is
!              used to foster numerical stability.
!              The routine assumes that the model levels are ordered
!              in a top-down approach, e.g. level 1 denotes the uppermost
!              full model level.
!
!              This routine is based on an implementation which was
!              developed for the NCAR Community Atmosphere Model (CAM).
!              Adjustments for other models will be necessary.
!
!              The routine provides both updates of the state variables
!              u, v, T, q (these are local copies of u,v,T,q within this physics
!              routine) and also collects their time tendencies.
!              The latter might be used to couple the physics and dynamics
!              in a process-split way. For a time-split coupling, the final
!              state should be given to the dynamical core for the next time step.
! Test:      0 = Reed and Jablonowski (2011) tropical cyclone test case (test 5-1)
!            1 = Moist baroclinic instability test (test 4-3)
!
!
! Reference: <NAME>. and <NAME> (2012), Idealized tropical cyclone 
!            simulations of intermediate complexity: A test case for AGCMs, 
!            J. Adv. Model. Earth Syst., Vol. 4, M04001, doi:10.1029/2011MS000099
!-----------------------------------------------------------------------
  ! use physics_types     , only: physics_dme_adjust   ! This is for CESM/CAM
  ! use cam_diagnostics,    only: diag_phys_writeout   ! This is for CESM/CAM

   implicit none

   integer, parameter :: r8 = selected_real_kind(12)

!
! Input arguments - MODEL DEPENDENT
!
   integer, intent(in)  :: pcols        ! Set number of atmospheric columns       
   integer, intent(in)  :: pver         ! Set number of model levels
   real(r8), intent(in) :: dtime        ! Set model physics timestep
   real(r8), intent(in) :: lat(pcols)   ! Latitude 
   integer, intent(in)  :: test         ! Test number

!JOY adding new input variables
    integer, intent(in) :: do_lsc       ! Switch for large scale condensation
    integer, intent(in) :: do_pbl       ! Switch for simple boundary layer
    integer, intent(in) :: do_surf_flux ! Switch for surface fluxes
    integer, intent(in) :: do_qflux     ! Switch for surface latent heat fluxes
    integer, intent(in) :: do_momflux   ! Switch for surface momentum fluxes
    integer, intent(in) :: do_tflux     ! Switch for surface sensible heat fluxes<commit_msg>Changed data type of real to c_double, to ensure match with cython.<commit_after>MODULE Simple_Physics
!JOY adding binding and c-binding module

use iso_c_binding
implicit none
contains

subroutine simple_physics_func (pcols, pver, dtime, lat, t, q, u, v, pmid, pint, &
        pdel, rpdel, ps, precl, test,&
        do_lsc, do_pbl, do_surf_flux,&
        do_qflux, do_momflux, do_tflux,&
        use_ts_ext, ts) bind(c,name='dcmipSimplePhysics')
    !JOY adding new variables
!----------------------------------------------------------------------- 
! 
! Purpose: Simple Physics Package
!
! Author: <NAME> (University of Michigan, <EMAIL>)
!         version 5 
!         July/8/2012
!
!  Change log:
!  v2: removal of some NCAR CAM-specific 'use' associations
!  v3: corrected precl(i) computation, the precipitation rate is now computed via a vertical integral, the previous single-level computation in v2 was a bug
!  v3: corrected dtdt(i,1) computation, the term '-(i,1)' was missing the temperature variable: '-t(i,1)'
!  v4: modified and enhanced parameter list to make the routine truly standalone, the number of columns and vertical levels have been added: pcols, pver
!  v4: 'ncol' has been removed, 'pcols' is used instead
!  v5: the sea surface temperature (SST) field Tsurf is now an array, the SST now depends on the latitude
!  v5: addition of the latitude array 'lat' and the flag 'test' in the parameter list
!      if test = 0: constant SST is used, correct setting for the tropical cyclone test case 5-1
!      if test = 1: newly added latitude-dependent SST is used, correct setting for the moist baroclinic wave test with simple-physics (test 4-3)
! 
! Description: Includes large-scale precipitation, surface fluxes and
!              boundary-leyer mixing. The processes are time-split
!              in that order. A partially implicit formulation is
!              used to foster numerical stability.
!              The routine assumes that the model levels are ordered
!              in a top-down approach, e.g. level 1 denotes the uppermost
!              full model level.
!
!              This routine is based on an implementation which was
!              developed for the NCAR Community Atmosphere Model (CAM).
!              Adjustments for other models will be necessary.
!
!              The routine provides both updates of the state variables
!              u, v, T, q (these are local copies of u,v,T,q within this physics
!              routine) and also collects their time tendencies.
!              The latter might be used to couple the physics and dynamics
!              in a process-split way. For a time-split coupling, the final
!              state should be given to the dynamical core for the next time step.
! Test:      0 = Reed and Jablonowski (2011) tropical cyclone test case (test 5-1)
!            1 = Moist baroclinic instability test (test 4-3)
!
!
! Reference: <NAME>. and <NAME> (2012), Idealized tropical cyclone 
!            simulations of intermediate complexity: A test case for AGCMs, 
!            J. Adv. Model. Earth Syst., Vol. 4, M04001, doi:10.1029/2011MS000099
!-----------------------------------------------------------------------
  ! use physics_types     , only: physics_dme_adjust   ! This is for CESM/CAM
  ! use cam_diagnostics,    only: diag_phys_writeout   ! This is for CESM/CAM

   implicit none

   integer, parameter :: r8 = c_double

!
! Input arguments - MODEL DEPENDENT
!
   integer, intent(in)  :: pcols        ! Set number of atmospheric columns       
   integer, intent(in)  :: pver         ! Set number of model levels
   real(r8), intent(in) :: dtime        ! Set model physics timestep
   real(r8), intent(in) :: lat(pcols)   ! Latitude 
   integer, intent(in)  :: test         ! Test number

!JOY adding new input variables
    integer, intent(in) :: do_lsc       ! Switch for large scale condensation
    integer, intent(in) :: do_pbl       ! Switch for simple boundary layer
    integer, intent(in) :: do_surf_flux ! Switch for surface fluxes
    integer, intent(in) :: do_qflux     ! Switch for surface latent heat fluxes
    integer, intent(in) :: do_momflux   ! Switch for surface momentum fluxes
    integer, intent(in) :: do_tflux     ! Switch for surface sensible heat fluxes
{'fraction_non_alphanumeric': 0.10673234811165845, 'fraction_numerical': 0.0150129017124091, 'mean_word_length': 2.525010334849111, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736181', 'n_tokens_mistral': 2480, 'n_tokens_neox': 2332, 'n_words': 1006}