|
| 1 | +module dice_datamode_cplhist_mod |
| 2 | + |
| 3 | + use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS |
| 4 | + use NUOPC , only : NUOPC_Advertise |
| 5 | + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs |
| 6 | + use shr_const_mod , only : shr_const_TkFrzsw |
| 7 | + use shr_sys_mod , only : shr_sys_abort |
| 8 | + use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr |
| 9 | + use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add |
| 10 | + use dshr_mod , only : dshr_restart_read, dshr_restart_write |
| 11 | + use dshr_strdata_mod , only : shr_strdata_type |
| 12 | + |
| 13 | + implicit none |
| 14 | + private ! except |
| 15 | + |
| 16 | + public :: dice_datamode_cplhist_advertise |
| 17 | + public :: dice_datamode_cplhist_init_pointers |
| 18 | + public :: dice_datamode_cplhist_advance |
| 19 | + public :: dice_datamode_cplhist_restart_read |
| 20 | + public :: dice_datamode_cplhist_restart_write |
| 21 | + |
| 22 | + ! export fields |
| 23 | + ! ice to atm in CMEPS/mediator/esmFldsExchange_ufs_mod.F90 |
| 24 | + real(r8), pointer :: Si_ifrac(:) => null() |
| 25 | + real(r8), pointer :: Si_imask(:) => null() |
| 26 | + real(r8), pointer :: Faii_taux(:) => null() |
| 27 | + real(r8), pointer :: Faii_tauy(:) => null() |
| 28 | + real(r8), pointer :: Faii_lat(:) => null() |
| 29 | + real(r8), pointer :: Faii_sen(:) => null() |
| 30 | + real(r8), pointer :: Faii_lwup(:) => null() |
| 31 | + real(r8), pointer :: Faii_evap(:) => null() |
| 32 | + real(r8), pointer :: Si_vice(:) => null() |
| 33 | + real(r8), pointer :: Si_vsno(:) => null() |
| 34 | + real(r8), pointer :: Si_t(:) => null() |
| 35 | + real(r8), pointer :: Si_avsdr(:) => null() |
| 36 | + real(r8), pointer :: Si_avsdf(:) => null() |
| 37 | + real(r8), pointer :: Si_anidr(:) => null() |
| 38 | + real(r8), pointer :: Si_anidf(:) => null() |
| 39 | + |
| 40 | + character(*) , parameter :: u_FILE_u = & |
| 41 | + __FILE__ |
| 42 | + |
| 43 | +!=============================================================================== |
| 44 | +contains |
| 45 | +!=============================================================================== |
| 46 | + |
| 47 | + subroutine dice_datamode_cplhist_advertise(exportState, fldsexport, flds_scalar_name, rc) |
| 48 | + |
| 49 | + ! input/output variables |
| 50 | + type(esmf_State) , intent(inout) :: exportState |
| 51 | + type(fldlist_type) , pointer :: fldsexport |
| 52 | + character(len=*) , intent(in) :: flds_scalar_name |
| 53 | + integer , intent(out) :: rc |
| 54 | + |
| 55 | + ! local variables |
| 56 | + type(fldlist_type), pointer :: fldList |
| 57 | + !------------------------------------------------------------------------------- |
| 58 | + |
| 59 | + rc = ESMF_SUCCESS |
| 60 | + |
| 61 | + ! Advertise export fields |
| 62 | + call dshr_fldList_add(fldsExport, trim(flds_scalar_name)) |
| 63 | + call dshr_fldList_add(fldsExport, 'Si_ifrac' ) |
| 64 | + call dshr_fldList_add(fldsExport, 'Si_imask' ) |
| 65 | + call dshr_fldList_add(fldsExport, 'Faii_taux' ) |
| 66 | + call dshr_fldList_add(fldsExport, 'Faii_tauy' ) |
| 67 | + call dshr_fldList_add(fldsExport, 'Faii_lat' ) |
| 68 | + call dshr_fldList_add(fldsExport, 'Faii_sen' ) |
| 69 | + call dshr_fldList_add(fldsExport, 'Faii_lwup' ) |
| 70 | + call dshr_fldList_add(fldsExport, 'Faii_evap' ) |
| 71 | + call dshr_fldList_add(fldsExport, 'Si_vice' ) |
| 72 | + call dshr_fldList_add(fldsExport, 'Si_vsno' ) |
| 73 | + call dshr_fldList_add(fldsExport, 'Si_t' ) |
| 74 | + call dshr_fldList_add(fldsExport, 'Si_avsdr' ) |
| 75 | + call dshr_fldList_add(fldsExport, 'Si_avsdf' ) |
| 76 | + call dshr_fldList_add(fldsExport, 'Si_anidr' ) |
| 77 | + call dshr_fldList_add(fldsExport, 'Si_anidf' ) |
| 78 | + |
| 79 | + fldlist => fldsExport ! the head of the linked list |
| 80 | + do while (associated(fldlist)) |
| 81 | + call NUOPC_Advertise(exportState, standardName=fldlist%stdname, rc=rc) |
| 82 | + if (ChkErr(rc,__LINE__,u_FILE_u)) return |
| 83 | + call ESMF_LogWrite('(dice_comp_advertise): Fr_ice'//trim(fldList%stdname), ESMF_LOGMSG_INFO) |
| 84 | + fldList => fldList%next |
| 85 | + enddo |
| 86 | + |
| 87 | + end subroutine dice_datamode_cplhist_advertise |
| 88 | + |
| 89 | + !=============================================================================== |
| 90 | + subroutine dice_datamode_cplhist_init_pointers(importState, exportState,sdat,rc) |
| 91 | + |
| 92 | + ! input/output variables |
| 93 | + type(ESMF_State) , intent(inout) :: importState |
| 94 | + type(ESMF_State) , intent(inout) :: exportState |
| 95 | + type(shr_strdata_type) , intent(in) :: sdat |
| 96 | + integer , intent(out) :: rc |
| 97 | + |
| 98 | + ! local variables |
| 99 | + character(len=*), parameter :: subname='(dice_init_pointers): ' |
| 100 | + !------------------------------------------------------------------------------- |
| 101 | + |
| 102 | + rc = ESMF_SUCCESS |
| 103 | + |
| 104 | + ! initialize pointers to export fields |
| 105 | + call dshr_state_getfldptr(exportState, 'Si_ifrac' , fldptr1=Si_ifrac , rc=rc) |
| 106 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 107 | + call dshr_state_getfldptr(exportState, 'Si_imask' , fldptr1=Si_imask , rc=rc) |
| 108 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 109 | + call dshr_state_getfldptr(exportState, 'Faii_taux' , fldptr1=Faii_taux , allowNullReturn=.true., rc=rc) |
| 110 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 111 | + call dshr_state_getfldptr(exportState, 'Faii_tauy' , fldptr1=Faii_tauy , allowNullReturn=.true., rc=rc) |
| 112 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 113 | + call dshr_state_getfldptr(exportState, 'Faii_lat' , fldptr1=Faii_lat , allowNullReturn=.true., rc=rc) |
| 114 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 115 | + call dshr_state_getfldptr(exportState, 'Faii_sen', fldptr1=Faii_sen, allowNullReturn=.true., rc=rc) |
| 116 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 117 | + call dshr_state_getfldptr(exportState, 'Faii_lwup', fldptr1=Faii_lwup, allowNullReturn=.true., rc=rc) |
| 118 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 119 | + call dshr_state_getfldptr(exportState, 'Faii_evap', fldptr1=Faii_evap, allowNullReturn=.true., rc=rc) |
| 120 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 121 | + call dshr_state_getfldptr(exportState, 'Si_vice', fldptr1=Si_vice, allowNullReturn=.true., rc=rc) |
| 122 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 123 | + call dshr_state_getfldptr(exportState, 'Si_vsno', fldptr1=Si_vsno, allowNullReturn=.true., rc=rc) |
| 124 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 125 | + call dshr_state_getfldptr(exportState, 'Si_t', fldptr1=Si_t, allowNullReturn=.true., rc=rc) |
| 126 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 127 | + call dshr_state_getfldptr(exportState, 'Si_avsdr', fldptr1=Si_avsdr, allowNullReturn=.true., rc=rc) |
| 128 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 129 | + call dshr_state_getfldptr(exportState, 'Si_avsdf', fldptr1=Si_avsdf, allowNullReturn=.true., rc=rc) |
| 130 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 131 | + call dshr_state_getfldptr(exportState, 'Si_anidr', fldptr1=Si_anidr, allowNullReturn=.true., rc=rc) |
| 132 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 133 | + call dshr_state_getfldptr(exportState, 'Si_anidf', fldptr1=Si_anidf, allowNullReturn=.true., rc=rc) |
| 134 | + if (chkerr(rc,__LINE__,u_FILE_u)) return |
| 135 | + |
| 136 | + !Initialize (e.g., =0)? |
| 137 | + |
| 138 | + end subroutine dice_datamode_cplhist_init_pointers |
| 139 | + |
| 140 | + !=============================================================================== |
| 141 | + subroutine dice_datamode_cplhist_advance(rc) |
| 142 | + |
| 143 | + ! input/output variables |
| 144 | + integer, intent(out) :: rc |
| 145 | + |
| 146 | + ! local variables |
| 147 | + character(len=*), parameter :: subname='(dice_datamode_cplhist_advance): ' |
| 148 | + !------------------------------------------------------------------------------- |
| 149 | + |
| 150 | + rc = ESMF_SUCCESS |
| 151 | + |
| 152 | + !Unit conversions, calculations,.... |
| 153 | + !Where aice=0, Si_t=0K (as missing value). Interpolation in time between ice that comes or goes then has issues |
| 154 | + where(Si_t .LT. 10) Si_t = shr_const_TkFrzsw |
| 155 | + |
| 156 | + end subroutine dice_datamode_cplhist_advance |
| 157 | + |
| 158 | + !=============================================================================== |
| 159 | + subroutine dice_datamode_cplhist_restart_write(rpfile, case_name, inst_suffix, ymd, tod, & |
| 160 | + logunit, my_task, sdat) |
| 161 | + |
| 162 | + ! input/output variables |
| 163 | + character(len=*) , intent(in) :: rpfile |
| 164 | + character(len=*) , intent(in) :: case_name |
| 165 | + character(len=*) , intent(in) :: inst_suffix |
| 166 | + integer , intent(in) :: ymd ! model date |
| 167 | + integer , intent(in) :: tod ! model sec into model date |
| 168 | + integer , intent(in) :: logunit |
| 169 | + integer , intent(in) :: my_task |
| 170 | + type(shr_strdata_type) , intent(inout) :: sdat |
| 171 | + |
| 172 | + ! local variables |
| 173 | + integer :: rc |
| 174 | + !------------------------------------------------------------------------------- |
| 175 | + |
| 176 | + call dshr_restart_write(rpfile, case_name, 'dice', inst_suffix, ymd, tod, & |
| 177 | + logunit, my_task, sdat, rc) |
| 178 | + if (ChkErr(rc,__LINE__,u_FILE_u)) return |
| 179 | + |
| 180 | + end subroutine dice_datamode_cplhist_restart_write |
| 181 | + |
| 182 | + !=============================================================================== |
| 183 | + subroutine dice_datamode_cplhist_restart_read(rest_filem, rpfile, logunit, my_task, mpicom, sdat) |
| 184 | + |
| 185 | + ! input/output arguments |
| 186 | + character(len=*) , intent(inout) :: rest_filem |
| 187 | + character(len=*) , intent(inout) :: rpfile |
| 188 | + integer , intent(in) :: logunit |
| 189 | + integer , intent(in) :: my_task |
| 190 | + integer , intent(in) :: mpicom |
| 191 | + type(shr_strdata_type) , intent(inout) :: sdat |
| 192 | + |
| 193 | + ! local variables |
| 194 | + integer :: rc |
| 195 | + !------------------------------------------------------------------------------- |
| 196 | + |
| 197 | + call dshr_restart_read(rest_filem, rpfile, logunit, my_task, mpicom, sdat, rc) |
| 198 | + if (ChkErr(rc,__LINE__,u_FILE_u)) return |
| 199 | + |
| 200 | + end subroutine dice_datamode_cplhist_restart_read |
| 201 | + |
| 202 | +end module dice_datamode_cplhist_mod |
0 commit comments