Ignore:
Timestamp:
10/30/15 15:41:06 (9 years ago)
Author:
dubos
Message:

Progress towards NH

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/trunk/src/etat0.f90

    r353 r366  
    1313CONTAINS 
    1414   
    15   SUBROUTINE etat0(f_ps,f_mass,f_phis,f_theta_rhodz,f_u, f_q) 
     15  SUBROUTINE etat0(f_ps,f_mass,f_phis,f_theta_rhodz,f_u, f_geopot,f_w, f_q) 
    1616    USE mpipara, ONLY : is_mpi_root 
    1717    USE disvert_mod 
     
    3535    TYPE(t_field),POINTER :: f_theta_rhodz(:) 
    3636    TYPE(t_field),POINTER :: f_u(:) 
     37    TYPE(t_field),POINTER :: f_geopot(:) 
     38    TYPE(t_field),POINTER :: f_w(:) 
    3739    TYPE(t_field),POINTER :: f_q(:) 
    3840     
    3941    REAL(rstd),POINTER :: ps(:), mass(:,:) 
    40     LOGICAL :: init_mass, collocated 
     42    LOGICAL :: autoinit_mass, autoinit_geopot, collocated 
    4143    INTEGER :: ind,i,j,ij,l 
    4244 
     
    4547    ! the initial distribution of mass is taken to be the same 
    4648    ! as what the mass coordinate would dictate 
    47     ! however if etat0_XXX defines mass then the flag init_mass must be set to .FALSE. 
     49    ! however if etat0_XXX defines mass then the flag autoinit_mass must be set to .FALSE. 
    4850    ! otherwise mass will be overwritten  
    49     init_mass = (caldyn_eta == eta_lag) 
     51    autoinit_mass = (caldyn_eta == eta_lag) 
    5052 
    5153    etat0_type='jablonowsky06' 
     
    7072        CALL getin_etat0_dcmip5 
    7173    CASE ('williamson91.6') 
    72        init_mass=.FALSE. 
     74       autoinit_mass=.FALSE. 
    7375       CALL getin_etat0_williamson 
    7476    CASE DEFAULT 
    7577       collocated=.FALSE. 
     78       autoinit_mass = .FALSE. 
    7679    END SELECT 
    7780 
     
    9093   CASE DEFAULT 
    9194      IF(collocated) THEN 
    92          CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q) 
     95         CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_geopot,f_W, f_q) 
    9396      ELSE 
    9497         PRINT*, 'Bad selector for variable etat0 <',etat0_type, & 
     
    98101    END SELECT 
    99102 
    100     IF(init_mass) THEN ! initialize mass distribution using ps 
    101103!       !$OMP BARRIER 
     104    IF(autoinit_mass) THEN 
    102105       DO ind=1,ndomain 
    103106          IF (.NOT. assigned_domain(ind)) CYCLE 
     
    105108          CALL swap_geometry(ind) 
    106109          mass=f_mass(ind); ps=f_ps(ind) 
    107           CALL compute_rhodz(.TRUE., ps, mass) 
     110          CALL compute_rhodz(.TRUE., ps, mass) ! initialize mass distribution using ps 
    108111       END DO 
    109112    END IF 
    110  
     113  
    111114  END SUBROUTINE etat0 
    112115 
    113   SUBROUTINE etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q) 
     116  SUBROUTINE etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_geopot,f_W, f_q) 
    114117    USE theta2theta_rhodz_mod 
    115118    IMPLICIT NONE 
     
    119122    TYPE(t_field),POINTER :: f_theta_rhodz(:) 
    120123    TYPE(t_field),POINTER :: f_u(:) 
     124    TYPE(t_field),POINTER :: f_geopot(:) 
     125    TYPE(t_field),POINTER :: f_W(:) 
    121126    TYPE(t_field),POINTER :: f_q(:) 
    122127   
     
    128133    REAL(rstd),POINTER :: temp(:,:) 
    129134    REAL(rstd),POINTER :: u(:,:) 
     135    REAL(rstd),POINTER :: geopot(:,:) 
     136    REAL(rstd),POINTER :: W(:,:) 
    130137    REAL(rstd),POINTER :: q(:,:,:) 
    131138    INTEGER :: ind 
     
    143150      temp=f_temp(ind) 
    144151      u=f_u(ind) 
     152      geopot=f_geopot(ind) 
     153      w=f_w(ind) 
    145154      q=f_q(ind) 
    146155 
    147       IF( TRIM(etat0_type)=='williamson91.6' ) THEN  
    148        CALL compute_etat0_collocated(ps,mass, phis, theta_rhodz, u, q) 
     156      IF( TRIM(etat0_type)=='williamson91.6' ) THEN 
     157       CALL compute_etat0_collocated(ps,mass, phis, theta_rhodz, u, geopot, W, q) 
    149158      ELSE 
    150        CALL compute_etat0_collocated(ps,mass, phis, temp, u, q) 
     159       CALL compute_etat0_collocated(ps,mass, phis, temp, u, geopot, W, q) 
    151160      ENDIF 
    152161    ENDDO 
     
    158167  END SUBROUTINE etat0_collocated 
    159168 
    160   SUBROUTINE compute_etat0_collocated(ps,mass, phis, temp_i, u, q) 
     169  SUBROUTINE compute_etat0_collocated(ps,mass,phis,temp_i,u, geopot,W, q) 
    161170    USE wind_mod 
     171    USE disvert_mod 
    162172    USE etat0_jablonowsky06_mod, ONLY : compute_jablonowsky06 => compute_etat0 
    163173    USE etat0_dcmip1_mod, ONLY : compute_dcmip1 => compute_etat0 
     
    174184    REAL(rstd),INTENT(OUT) :: temp_i(iim*jjm,llm) 
    175185    REAL(rstd),INTENT(OUT) :: u(3*iim*jjm,llm) 
     186    REAL(rstd),INTENT(OUT) :: W(iim*jjm,llm+1) 
     187    REAL(rstd),INTENT(OUT) :: geopot(iim*jjm,llm+1) 
    176188    REAL(rstd),INTENT(OUT) :: q(iim*jjm,llm,nqtot) 
    177189 
     
    183195    REAL(rstd) :: phis_e(3*iim*jjm) 
    184196    REAL(rstd) :: temp_e(3*iim*jjm,llm) 
     197    REAL(rstd) :: geopot_e(3*iim*jjm,llm+1) 
    185198    REAL(rstd) :: ulon_e(3*iim*jjm,llm) 
    186199    REAL(rstd) :: ulat_e(3*iim*jjm,llm) 
     
    188201 
    189202    INTEGER :: l,i,j,ij 
     203    REAL :: p_ik, v_ik, mass_ik 
     204    LOGICAL :: autoinit_mass, autoinit_NH 
     205 
     206    ! For NH geopotential and vertical momentum must be initialized. 
     207    ! Unless autoinit_mass is set to .FALSE. , they will be initialized 
     208    ! to hydrostatic geopotential and zero 
     209    autoinit_mass = .TRUE. 
     210    autoinit_NH = .NOT. hydrostatic 
     211    w(:,:) = 0 
    190212 
    191213    !$OMP BARRIER 
     
    208230       CALL compute_dcmip2(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e)       
    209231    CASE('dcmip3') 
    210        CALL compute_dcmip3(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q) 
    211        CALL compute_dcmip3(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e) 
     232       CALL compute_dcmip3(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, geopot, q) 
     233       CALL compute_dcmip3(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, geopot_e, q_e) 
     234       autoinit_NH = .FALSE. ! compute_dcmip3 initializes geopot 
    212235    CASE('dcmip4') 
    213236       CALL compute_dcmip4(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q) 
     
    219242       CALL compute_w91_6(iim*jjm,lon_i,lat_i, phis, mass(:,1), temp_i(:,1), ulon_i(:,1), ulat_i(:,1)) 
    220243       CALL compute_w91_6(3*iim*jjm,lon_e,lat_e, phis_e, mass_e(:,1), temp_e(:,1), ulon_e(:,1), ulat_e(:,1)) 
     244       autoinit_mass = .FALSE. ! do not overwrite mass 
    221245    END SELECT 
     246 
     247    IF(autoinit_mass) CALL compute_rhodz(.TRUE., ps, mass) ! initialize mass distribution using ps 
     248    IF(autoinit_NH) THEN 
     249       geopot(:,1) = phis(:) ! surface geopotential 
     250       DO l = 1, llm 
     251          DO ij=1,iim*jjm 
     252             ! hybrid pressure coordinate 
     253             p_ik = ptop + mass_ak(l) + mass_bk(l)*ps(ij) 
     254             mass_ik = (mass_dak(l) + mass_dbk(l)*ps(ij))/g 
     255             ! v=R.T/p, R=kappa*cpp 
     256             v_ik = kappa*cpp*temp_i(ij,l)/p_ik 
     257             geopot(ij,l+1) = geopot(ij,l) + mass_ik*v_ik*g 
     258          END DO 
     259       END DO 
     260    END IF 
    222261 
    223262    !$OMP BARRIER 
Note: See TracChangeset for help on using the changeset viewer.