Ignore:
Timestamp:
Jan 16, 2023, 4:47:08 PM (23 months ago)
Author:
jleconte
Message:

Big cleanup of interface_v4. M_TSURF is now P_TSURF.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/WRF.COMMON/INTERFACES_V4/module_lmd_driver.F

    r2866 r2868  
    2626        P8W,DZ8W,T8W,Z,HT,MUT,DNW, &
    2727        U,V,TH,T,P,EXNER,RHO, &
     28        P_HYD, P_HYD_W, &
    2829        PTOP, &
    2930        RADT, &
     
    3536        planet_type, &
    3637        M_ALBEDO,M_TI,M_CO2ICE,M_EMISS, &
    37         M_H2OICE,M_TSOIL,M_Q2,M_TSURF, &
     38        M_H2OICE,M_TSOIL,M_Q2,P_TSURF, &
    3839        M_FLUXRAD,M_WSTAR,M_ISOIL,M_DSOIL,&
    3940        M_Z0, CST_Z0, M_GW, &
     
    4142        CST_AL, CST_TI, &
    4243        isfflx, diff_opt, km_opt, &
    43         HISTORY_INTERVAL, &
    44         HR_SW,HR_LW,HR_DYN,DDT,DT_RAD,DT_VDF,DT_AJS,&
     44        HR_SW,HR_LW,HR_DYN,DDT,DT_RAD,DT_VDF,&
    4545        CLOUDFRAC,TOTCLOUDFRAC,RH, &
    4646        DQICE,DQVAP,REEVAP,SURFRAIN,ALBEQ,FLUXTOP_DN,FLUXABS_SW,FLUXTOP_LW,FLUXSURF_SW,&
     
    9494REAL, INTENT(IN  ) :: CST_AL, CST_TI
    9595REAL, INTENT(IN  ) :: PTOP
    96 INTEGER, INTENT(IN   ) :: HISTORY_INTERVAL
    9796! 2D arrays         
    9897REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT)  :: &
     
    103102     SLPX,SLPY, &
    104103     M_CO2ICE,M_H2OICE, &
    105      M_TSURF, M_Z0, &
     104     P_TSURF, M_Z0, &
    106105     M_FLUXRAD,M_WSTAR, &
    107106     PSFC,TSK
     
    116115! 3D arrays
    117116REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(IN ) :: &
    118      dz8w,p8w,p,exner,t,t8w,rho,u,v,z,th
     117     dz8w,p8w,p,exner,t,t8w,rho,u,v,z,th,p_hyd,p_hyd_w
    119118REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(OUT ) :: &
    120119     RTHBLTEN,RUBLTEN,RVBLTEN, &
    121      HR_SW,HR_LW,HR_DYN,DDT,DT_RAD,DT_VDF,DT_AJS,RDUST,VMR_ICE,RICE,&
     120     HR_SW,HR_LW,HR_DYN,DDT,DT_RAD,DT_VDF,RDUST,VMR_ICE,RICE,&
    122121     CLOUDFRAC,RH,DQICE,DQVAP,DTLSC,DTRAIN,DT_MOIST,H2OICE_REFF
    123122REAL, DIMENSION( ims:ime, kms:kme+1, jms:jme ), INTENT(INOUT ) :: &
     
    156155   ! <------ outputs:
    157156   !     physical tendencies
    158    REAL*8,DIMENSION(:,:),ALLOCATABLE :: pdtheta
    159157   ! ... intermediate arrays
    160158   REAL, DIMENSION(:), ALLOCATABLE  :: &
     
    171169   LOGICAL, SAVE :: firstcall = .true.
    172170   INTEGER, SAVE :: previous_id = 0
    173 !**************************************************
    174 ! IMPORTANT: pour travailler avec grid nesting
    175 ! --- deux comportements distincts du save
    176 ! ... ex1: ferme planeto avec PGF+MPI: standard
    177 ! ... ex2: iDataPlex avec IFORT+MPI: SPECIAL_NEST_SAVE
    178 !**************************************************
    179 #ifdef SPECIAL_NEST_SAVE
    180       !  une dimension supplementaire liee au nest
    181       REAL, DIMENSION(:,:), ALLOCATABLE, SAVE :: &
    182              dp_save
    183       REAL, DIMENSION(:,:,:), ALLOCATABLE, SAVE :: &
    184              du_save, dv_save, dt_save,dtheta_save
    185       REAL, DIMENSION(:,:,:,:), ALLOCATABLE, SAVE :: &
    186              dq_save     
    187 #else
    188       REAL, DIMENSION(:), ALLOCATABLE, SAVE :: &
    189              dp_save
    190       REAL, DIMENSION(:,:), ALLOCATABLE, SAVE :: &
    191              du_save, dv_save, dt_save,dtheta_save
    192       REAL, DIMENSION(:,:,:), ALLOCATABLE, SAVE :: &
    193              dq_save     
    194 #endif
     171   REAL, DIMENSION(:), ALLOCATABLE, SAVE :: dp_save
     172   REAL, DIMENSION(:,:), ALLOCATABLE, SAVE :: du_save, dv_save, dt_save
     173   REAL, DIMENSION(:,:,:), ALLOCATABLE, SAVE :: dq_save     
    195174
    196175!!!IDEALIZED IDEALIZED
     
    270249! DIMENSIONS FOR THE PHYSICS !
    271250!----------------------------!
    272 !day_ini = JULDAY - 1      !! GCM convention  !! pday at firstcall is day_ini
    273251wappel_phys = RADT
    274252zdt_split = dt*wappel_phys            ! physical timestep (s)
     
    282260lastcall = .false.
    283261! **** needed but hardcoded
    284 
    285           !PRINT *, ips, ipe, jps, jpe
    286           !PRINT *, ngrid
    287262
    288263elaps = (float(itimestep)-1.)*dt  ! elapsed seconds of simulation
     
    300275  !firstcall=.false. !! just in case you'd want to get rid of the physics
    301276test=0
    302 #ifdef SPECIAL_NEST_SAVE
    303 PRINT *, 'ALLOCATED dp_save ???', ALLOCATED( dp_save ), id
    304 IF( .NOT. ALLOCATED( dp_save  ) ) THEN
    305    PRINT *, '**** check **** OK I ALLOCATE one save ARRAY for all NESTS ', max_dom, id
    306    !! here are the arrays that would be useful to save physics tendencies
    307    ALLOCATE(dp_save(ngrid,max_dom))
    308    ALLOCATE(du_save(ngrid,nlayer,max_dom))
    309    ALLOCATE(dv_save(ngrid,nlayer,max_dom))
    310    ALLOCATE(dt_save(ngrid,nlayer,max_dom))
    311    ALLOCATE(dtheta_save(ngrid,nlayer,max_dom))
    312    ALLOCATE(dq_save(ngrid,nlayer,nq,max_dom))
    313    dp_save(:,:)=0.    !! initialize these arrays ...
    314    du_save(:,:,:)=0.
    315    dv_save(:,:,:)=0.
    316    dt_save(:,:,:)=0.
    317    dtheta_save(:,:,:)=0.
    318    dq_save(:,:,:,:)=0.
    319 ENDIF
    320 IF (id .lt. max_dom) THEN
    321    flag_first_restart=.true.
    322 ELSE
    323    flag_first_restart=.false.
    324 ENDIF
    325 #else
    326277IF( .NOT. ALLOCATED( dp_save  ) ) THEN
    327278ALLOCATE(dp_save(ngrid)) !! here are the arrays that would be useful to save physics tendencies
     
    329280ALLOCATE(dv_save(ngrid,nlayer))
    330281ALLOCATE(dt_save(ngrid,nlayer))
    331 ALLOCATE(dtheta_save(ngrid,nlayer))
    332282ALLOCATE(dq_save(ngrid,nlayer,nq))
    333283ENDIF
     
    336286dv_save(:,:)=0.
    337287dt_save(:,:)=0.
    338 dtheta_save(:,:)=0.
    339288dq_save(:,:,:)=0.
    340289flag_first_restart=.false.
    341 #endif
    342 ELSE
     290
     291ELSE ! is_first_step
    343292!-------------------------------------------------!
    344293! what is done for the other steps of simulation  !
     
    396345!----------!
    397346CALL allocate_interface(ngrid,nlayer,nq)
    398 ALLOCATE(pdtheta(ngrid,nlayer))
    399347!!!
    400348!!! BIG LOOP : 1. no call for physics, used saved values
     
    402350IF (test.NE.0) THEN
    403351print *,'** ',planet_type,'** NO CALL FOR PHYSICS, go to next step...',test
    404 #ifdef SPECIAL_NEST_SAVE
    405 zdpsrf_omp(:)=dp_save(:,id)
    406 zdufi_omp(:,:)=du_save(:,:,id)
    407 zdvfi_omp(:,:)=dv_save(:,:,id)
    408 zdtfi_omp(:,:)=dt_save(:,:,id)
    409 pdtheta(:,:)=dtheta_save(:,:,id)
    410 zdqfi_omp(:,:,:)=dq_save(:,:,:,id)
    411 #else
    412352print*,'else'
    413353zdpsrf_omp(:)=dp_save(:)
     
    415355zdvfi_omp(:,:)=dv_save(:,:)
    416356zdtfi_omp(:,:)=dt_save(:,:)
    417 pdtheta(:,:)=dtheta_save(:,:)
    418357zdqfi_omp(:,:,:)=dq_save(:,:,:)
    419 #endif
    420358!!!
    421359!!! BIG LOOP : 2. calculate physical tendencies
    422360!!!
    423 ELSE
     361ELSE ! if (test.EQ.0)
    424362!----------!
    425363! ALLOCATE !
     
    489427!--------------------------------------!
    490428dz8w_prof(:) = dz8w(i,kps:kpe,j)   ! dz between full levels (m)   
    491 !p_prof(:) = p(i,kps:kpe,j)         ! pressure half level (Pa) >> zplay_omp
     429p_prof(:) = p_hyd(i,kps:kpe,j)         ! hydrostatic pressure at layers >> zplay_omp
     430p8w_prof(:) = p_hyd_w(i,kps:kpe+1,j)         ! hydrostatic pressure at levels
     431!JL22 using hydrostatic pressures to conserve mass
    492432t_prof(:) = t(i,kps:kpe,j)         ! temperature half level (K) >> pt
    493433t8w_prof(:) = t8w(i,kps:kpe,j)     ! temperature full level (K)
     
    495435v_prof(:) = v(i,kps:kpe,j)         ! meridional wind (A-grid: unstaggered) half level (m/s) >> pv
    496436z_prof(:) = z(i,kps:kpe,j)         ! geopotential height half level (m) >> zphi_omp/g
    497 
    498 
    499 !------------------------------------------------------------!
    500 ! reconstructing hydrostatic level pressure to conserve mass !
    501 !------------------------------------------------------------!
    502 p8w_prof(kpe+1) = ptop
    503 if (TRACER_MODE .ge. 42) then
    504   do k=kpe,kps,-1
    505     p8w_prof(k) = p8w_prof(k+1) - dnw(k) * mut(i,j) * (1.d0 + moist(i,k,j,P_QV))
    506     p_prof(k) = 0.5d0*(p8w_prof(k+1)+p8w_prof(k))         ! pressure half level (Pa) >> zplay_omp
    507   enddo
    508 else
    509   do k=kpe,kps,-1
    510     p8w_prof(k) = p8w_prof(k+1) - dnw(k) * mut(i,j)
    511     p_prof(k) = 0.5d0*(p8w_prof(k+1)+p8w_prof(k))         ! pressure half level (Pa) >> zplay_omp
    512   enddo
    513 endif
    514 !p8w_prof(:) = p8w(i,kps:kpe,j)     ! pressure full level (Pa) >> zplev_omp
    515437
    516438
     
    644566            M_TI,CST_TI,&
    645567            M_ISOIL,M_DSOIL,&
    646             M_TSOIL,M_TSURF)
     568            M_TSOIL,P_TSURF)
    647569!!!
    648570CALL update_inputs_physiq_surf( &
     
    651573            JULYR,TRACER_MODE,&
    652574            M_ALBEDO,CST_AL,&
    653             M_TSURF,M_EMISS,M_CO2ICE,&
     575            P_TSURF,M_EMISS,M_CO2ICE,&
    654576            M_GW,M_Z0,CST_Z0,&
    655577            M_H2OICE,&
     
    678600!!!!!!!!!!!!!!!!!!!!!!
    679601
    680 call_physics : IF (wappel_phys .ne. 0.) THEN
    681602!!! initialize tendencies (security)
    682603zdpsrf_omp(:)=0.
     
    684605zdvfi_omp(:,:)=0.
    685606zdtfi_omp(:,:)=0.
    686 pdtheta(:,:)=0.
    687607zdqfi_omp(:,:,:)=0.
     608
     609call_physics : IF (wappel_phys .ne. 0.) THEN
    688610!print *, '** ',planet_type,'** CALL TO LMD PHYSICS'
    689611!!!
     
    699621!!!
    700622
    701 !! specific scenario. necessary to add the right amount of dust.
    702 #ifdef DUSTSTORM
    703 IF (firstcall .EQV. .true.) THEN
    704   zdqfi_omp(:,:,:) = zdqfi_omp(:,:,:) / dt
    705 ENDIF
    706 #endif
    707 
    708 IF (planet_type .eq. "venus" ) THEN
    709   DO j=jps,jpe
    710   DO i=ips,ipe
    711     do k=kps,kpe
    712       subs=(j-jps)*(ipe-ips+1)+(i-ips+1)
    713       tk1=(ztfi_omp(subs,k)**nu + nu*TT00**nu*log((p1000mb/zplay_omp(subs,k))**rcp))**(1/nu)
    714       tk2=((ztfi_omp(subs,k) + zdtfi_omp(subs,k))**nu + nu*TT00**nu*log((p1000mb/zplay_omp(subs,k))**rcp))**(1/nu)
    715       pdtheta(subs,k)=tk2-tk1
    716     enddo
    717   ENDDO
    718   ENDDO
    719 ENDIF
    720 
    721 !print *, '** ',planet_type,'** CALL TO LMD PHYSICS DONE'
    722 
    723623!---------------------------------------------------------------------------------!
    724624! PHYSIQ TENDENCIES ARE SAVED TO BE SPLIT WITHIN INTERMEDIATE DYNAMICAL TIMESTEPS !
    725625!---------------------------------------------------------------------------------!
    726 #ifdef SPECIAL_NEST_SAVE
    727 dp_save(:,id)=zdpsrf_omp(:)
    728 du_save(:,:,id)=zdufi_omp(:,:)
    729 dv_save(:,:,id)=zdvfi_omp(:,:)
    730 dt_save(:,:,id)=zdtfi_omp(:,:)
    731 dtheta_save(:,:,id)=pdtheta(:,:)
    732 dq_save(:,:,:,id)=zdqfi_omp(:,:,:)
    733 #else
    734626dp_save(:)=zdpsrf_omp(:)
    735627du_save(:,:)=zdufi_omp(:,:)
    736628dv_save(:,:)=zdvfi_omp(:,:)
    737629dt_save(:,:)=zdtfi_omp(:,:)
    738 dtheta_save(:,:)=pdtheta(:,:)
    739630dq_save(:,:,:)=zdqfi_omp(:,:,:)
    740 #endif
    741631
    742632!! OUTPUT OUTPUT OUTPUT
     
    749639            ips,ipe,jps,jpe,&
    750640            TRACER_MODE,&
    751             M_TSURF,M_CO2ICE,&
     641            P_TSURF,M_CO2ICE,&
    752642            M_H2OICE)
    753643!!!
     
    812702
    813703    ! zonal wind
    814   RUBLTEN(i,kps:kpe,j) = zdufi_omp(subs,kps:kpe) 
     704  RUBLTEN(i,kps:kpe,j) = zdufi_omp(subs,kps:kpe)
    815705    ! meridional wind
    816706  RVBLTEN(i,kps:kpe,j) = zdvfi_omp(subs,kps:kpe)
    817707    ! potential temperature
    818708    ! (dT = dtheta * exner for isobaric coordinates or if pressure variations are negligible)
    819   IF (planet_type .eq. "venus" ) THEN
    820     RTHBLTEN(i,kps:kpe,j) = pdtheta(subs,kps:kpe)
    821   ELSE
    822     RTHBLTEN(i,kps:kpe,j) = zdtfi_omp(subs,kps:kpe) / exner(i,kps:kpe,j)
    823   ENDIF
     709  RTHBLTEN(i,kps:kpe,j) = zdtfi_omp(subs,kps:kpe) / exner(i,kps:kpe,j)
    824710    ! update surface pressure (cf CO2 cycle in physics)
    825711    ! here dt is needed
     
    841727      scalar(i,kps:kpe,j,P_QH2O_ICE)=scalar(i,kps:kpe,j,P_QH2O_ICE) &
    842728           +zdqfi_omp(subs,kps:kpe,2)*dt * (1.d0+moist(i,kps:kpe,j,P_QV))
    843       ! if you want to use this mode, RTHBLTEN should be corrected as below.
    844       ! we keep it like that for the moment for testing.
     729       ! if you want to use this mode, RTHBLTEN should be corrected as below.
     730       ! we keep it like that for the moment for testing.
    845731    CASE(43)
    846732      moist(i,kps:kpe,j,P_QV)=moist(i,kps:kpe,j,P_QV) &
     
    864750ENDDO
    865751CALL deallocate_interface
    866 DEALLOCATE(pdtheta)
    867752!!*****!!
    868753!! END !!
Note: See TracChangeset for help on using the changeset viewer.