@@ -469,6 +469,8 @@ subroutine import_fields( gcomp, cam_in, restart_init, rc)
469
469
use physconst , only : mwco2
470
470
use time_manager , only : is_first_step, get_nstep
471
471
use physics_grid , only : columns_on_task
472
+ use runtime_obj , only : wv_stdname
473
+ use ccpp_scheme_utils , only : ccpp_constituent_index
472
474
473
475
! input/output variabes
474
476
type (ESMF_GridComp) :: gcomp
@@ -479,12 +481,15 @@ subroutine import_fields( gcomp, cam_in, restart_init, rc)
479
481
! local variables
480
482
type (ESMF_State) :: importState
481
483
integer :: i,n ! loop indices
484
+ integer :: ierr
482
485
integer :: nstep
486
+ integer :: wv_const_index
483
487
logical :: overwrite_flds
484
488
logical :: exists
485
489
logical :: exists_fco2_ocn
486
490
logical :: exists_fco2_lnd
487
491
character (len= 128 ) :: fldname
492
+ character (len= 512 ) :: errmsg
488
493
real (r8 ), pointer :: fldptr2d(:,:)
489
494
real (r8 ), pointer :: fldptr1d(:)
490
495
real (r8 ), pointer :: fldptr_lat(:)
@@ -522,6 +527,14 @@ subroutine import_fields( gcomp, cam_in, restart_init, rc)
522
527
overwrite_flds = .true.
523
528
if (present (restart_init)) overwrite_flds = .not. restart_init
524
529
530
+ ! Find CCPP constituents index for water vapor,
531
+ ! as it is needed to properly pass evaporation into
532
+ ! the constituent fluxes array:
533
+ call ccpp_constituent_index(wv_stdname, wv_const_index, ierr, errmsg)
534
+ if (ierr /= 0 ) then
535
+ call shr_sys_abort(subname// ' :: Failed to get water vapor CCPP constituent index with the following error: ' // errmsg)
536
+ end if
537
+
525
538
!- -------------------------
526
539
! Required atmosphere input fields
527
540
!- -------------------------
@@ -536,10 +549,13 @@ subroutine import_fields( gcomp, cam_in, restart_init, rc)
536
549
call state_getfldptr(importState, ' Faxx_evap' , fldptr= fldptr_evap, rc= rc)
537
550
if (ChkErr(rc,__LINE__,u_FILE_u)) return
538
551
do i = 1 , columns_on_task
539
- cam_in% wsx(i) = - fldptr_taux(i) * med2mod_areacor(i)
540
- cam_in% wsy(i) = - fldptr_tauy(i) * med2mod_areacor(i)
541
- cam_in% shf(i) = - fldptr_sen(i) * med2mod_areacor(i)
542
- cam_in% cflx(i,1 ) = - fldptr_evap(i) * med2mod_areacor(i)
552
+ cam_in% wsx(i) = - fldptr_taux(i) * med2mod_areacor(i)
553
+ cam_in% wsy(i) = - fldptr_tauy(i) * med2mod_areacor(i)
554
+ cam_in% shf(i) = - fldptr_sen(i) * med2mod_areacor(i)
555
+ ! Add water vapor to constituent fluxes array if present:
556
+ if (wv_const_index > 0 ) then
557
+ cam_in% cflx(i, wv_const_index) = - fldptr_evap(i) * med2mod_areacor(i)
558
+ end if
543
559
end do
544
560
end if ! end of overwrite_flds
545
561
@@ -678,7 +694,7 @@ subroutine import_fields( gcomp, cam_in, restart_init, rc)
678
694
#endif
679
695
680
696
#if 0
681
- ! Ignoring depvel for now as it has a problematic second dimension (number of dry deposited species)
697
+ ! Ignoring depvel for now as it has a problematic second dimension (number of dry deposited species)
682
698
! and it was determined that it probably will not be used in CAM-SIMA for some time
683
699
! dry dep velocities
684
700
call state_getfldptr(importState, 'Sl_ddvel', fldptr2d=fldptr2d, exists=exists, rc=rc)
0 commit comments