-
Notifications
You must be signed in to change notification settings - Fork 67
Add Fortran modules for CFSR and GEFS data sources and add a new subroutine to get data stream parameters from ESMF configuration files #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4fd370e
Update CDEPS (#2)
binli2337 d0a8444
Add subroutines used for CFSR data source (#5)
binli2337 6983ee5
Update emc/develop branch with recent changes in master branch of ESC…
binli2337 7ca7a3d
Update CDEPS to latest ESCOMP/CDEPS master and add variables for opti…
binli2337 8bbb84f
Update CDEPS to the latest ESCOMP/CDEPS master branch (#12)
binli2337 c4c30bd
Add Fortran module for GEFS data source in CDEPS (#13)
binli2337 69a3a61
remove FoX depdencies (#17)
junwang-noaa 6e439bc
Revised streams/dshr_stream_mod.F90. (#19)
binli2337 d381a78
Update emc/develop branch to include most recent updates from ESCOMP/…
binli2337 4c7729d
Merge remote-tracking branch 'upstream/master' into feature/update20
binli2337 31711d4
Remove commented code.
binli2337 8d0f499
Merge branch 'master' into feature/update20
jedwards4b b9a965a
Merge branch 'master' into feature/update20
jedwards4b 8242f4f
Merge branch 'master' into feature/update20
jedwards4b File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,252 @@ | ||
| module datm_datamode_cfsr_mod | ||
|
|
||
| use ESMF , only : ESMF_State, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO | ||
| use NUOPC , only : NUOPC_Advertise | ||
| use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs | ||
| use shr_sys_mod , only : shr_sys_abort | ||
| use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp | ||
| use shr_mpi_mod , only : shr_mpi_max | ||
| use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair | ||
| use dshr_methods_mod , only : dshr_state_getfldptr, chkerr | ||
| use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer | ||
| use dshr_mod , only : dshr_restart_read, dshr_restart_write | ||
| use dshr_strdata_mod , only : shr_strdata_type | ||
| use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add | ||
|
|
||
| implicit none | ||
| private ! except | ||
|
|
||
| public :: datm_datamode_cfsr_advertise | ||
| public :: datm_datamode_cfsr_init_pointers | ||
| public :: datm_datamode_cfsr_advance | ||
| public :: datm_datamode_cfsr_restart_write | ||
| public :: datm_datamode_cfsr_restart_read | ||
|
|
||
| ! export state data | ||
| real(r8), pointer :: Sa_z(:) => null() | ||
| real(r8), pointer :: Sa_u(:) => null() | ||
| real(r8), pointer :: Sa_v(:) => null() | ||
| real(r8), pointer :: Sa_tbot(:) => null() | ||
| real(r8), pointer :: Sa_shum(:) => null() | ||
| real(r8), pointer :: Sa_pbot(:) => null() | ||
| real(r8), pointer :: Sa_u10m(:) => null() | ||
| real(r8), pointer :: Sa_v10m(:) => null() | ||
| real(r8), pointer :: Sa_t2m(:) => null() | ||
| real(r8), pointer :: Sa_q2m(:) => null() | ||
| real(r8), pointer :: Sa_pslv(:) => null() | ||
| real(r8), pointer :: Faxa_lwdn(:) => null() | ||
| real(r8), pointer :: Faxa_rain(:) => null() | ||
| real(r8), pointer :: Faxa_snow(:) => null() | ||
| real(r8), pointer :: Faxa_swndr(:) => null() | ||
| real(r8), pointer :: Faxa_swndf(:) => null() | ||
| real(r8), pointer :: Faxa_swvdr(:) => null() | ||
| real(r8), pointer :: Faxa_swvdf(:) => null() | ||
|
|
||
| ! stream data | ||
| real(r8), pointer :: strm_mask(:) => null() | ||
|
|
||
| real(r8) :: tbotmax ! units detector | ||
| real(r8) :: maskmax ! units detector | ||
|
|
||
| real(r8) , parameter :: tKFrz = SHR_CONST_TKFRZ | ||
| real(r8) , parameter :: rdair = SHR_CONST_RDAIR ! dry air gas constant ~ J/K/kg | ||
| real(r8) , parameter :: rhofw = SHR_CONST_RHOFW ! density of fresh water ~ kg/m^3 | ||
|
|
||
| character(*), parameter :: nullstr = 'undefined' | ||
| character(*), parameter :: rpfile = 'rpointer.atm' | ||
| character(*), parameter :: u_FILE_u = & | ||
| __FILE__ | ||
|
|
||
| !=============================================================================== | ||
| contains | ||
| !=============================================================================== | ||
|
|
||
| subroutine datm_datamode_cfsr_advertise(exportState, fldsexport, & | ||
| flds_scalar_name, rc) | ||
|
|
||
| ! input/output variables | ||
| type(esmf_State) , intent(inout) :: exportState | ||
| type(fldlist_type) , pointer :: fldsexport | ||
| character(len=*) , intent(in) :: flds_scalar_name | ||
| integer , intent(out) :: rc | ||
|
|
||
| ! local variables | ||
| type(fldlist_type), pointer :: fldList | ||
| !------------------------------------------------------------------------------- | ||
|
|
||
| rc = ESMF_SUCCESS | ||
|
|
||
| call dshr_fldList_add(fldsExport, trim(flds_scalar_name)) | ||
| call dshr_fldList_add(fldsExport, 'Sa_z' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_u' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_v' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_tbot' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_pbot' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_shum' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_u10m' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_v10m' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_t2m' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_q2m' ) | ||
| call dshr_fldList_add(fldsExport, 'Sa_pslv' ) | ||
| call dshr_fldList_add(fldsExport, 'Faxa_rain' ) | ||
| call dshr_fldList_add(fldsExport, 'Faxa_snow' ) | ||
| call dshr_fldList_add(fldsExport, 'Faxa_swndr' ) | ||
| call dshr_fldList_add(fldsExport, 'Faxa_swvdr' ) | ||
| call dshr_fldList_add(fldsExport, 'Faxa_swndf' ) | ||
| call dshr_fldList_add(fldsExport, 'Faxa_swvdf' ) | ||
| call dshr_fldList_add(fldsExport, 'Faxa_lwdn' ) | ||
|
|
||
| fldlist => fldsExport ! the head of the linked list | ||
| do while (associated(fldlist)) | ||
| call NUOPC_Advertise(exportState, standardName=fldlist%stdname, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call ESMF_LogWrite('(datm_comp_advertise): Fr_atm '//trim(fldList%stdname), ESMF_LOGMSG_INFO) | ||
| fldList => fldList%next | ||
| enddo | ||
|
|
||
| end subroutine datm_datamode_cfsr_advertise | ||
|
|
||
| !=============================================================================== | ||
| subroutine datm_datamode_cfsr_init_pointers(exportState, sdat, rc) | ||
|
|
||
| ! input/output variables | ||
| type(ESMF_State) , intent(inout) :: exportState | ||
| type(shr_strdata_type) , intent(in) :: sdat | ||
| integer , intent(out) :: rc | ||
|
|
||
| ! local variables | ||
| character(len=*), parameter :: subname='(datm_init_pointers): ' | ||
| !------------------------------------------------------------------------------- | ||
|
|
||
| rc = ESMF_SUCCESS | ||
|
|
||
| ! initialize pointers for module level stream arrays | ||
| call shr_strdata_get_stream_pointer( sdat, 'Sa_mask' , strm_mask , rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
|
|
||
| ! get export state pointers | ||
| call dshr_state_getfldptr(exportState, 'Sa_z' , fldptr1=Sa_z , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_u' , fldptr1=Sa_u , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_v' , fldptr1=Sa_v , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_tbot' , fldptr1=Sa_tbot , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_pbot' , fldptr1=Sa_pbot , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_shum' , fldptr1=Sa_shum , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_u10m' , fldptr1=Sa_u10m , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_v10m' , fldptr1=Sa_v10m , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_t2m' , fldptr1=Sa_t2m , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_q2m' , fldptr1=Sa_q2m , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Sa_pslv' , fldptr1=Sa_pslv , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Faxa_rain' , fldptr1=Faxa_rain , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Faxa_snow' , fldptr1=Faxa_snow, rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Faxa_swvdr' , fldptr1=Faxa_swvdr , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Faxa_swvdf' , fldptr1=Faxa_swvdf , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Faxa_swndr' , fldptr1=Faxa_swndr , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Faxa_swndf' , fldptr1=Faxa_swndf , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
| call dshr_state_getfldptr(exportState, 'Faxa_lwdn' , fldptr1=Faxa_lwdn , rc=rc) | ||
| if (ChkErr(rc,__LINE__,u_FILE_u)) return | ||
|
|
||
| end subroutine datm_datamode_cfsr_init_pointers | ||
|
|
||
| !=============================================================================== | ||
| subroutine datm_datamode_cfsr_advance(exportstate, masterproc, logunit, mpicom, target_ymd, target_tod, model_calendar, rc) | ||
|
|
||
| ! input/output variables | ||
| type(ESMF_State) , intent(inout) :: exportState | ||
| logical , intent(in) :: masterproc | ||
| integer , intent(in) :: logunit | ||
| integer , intent(in) :: mpicom | ||
| integer , intent(in) :: target_ymd | ||
| integer , intent(in) :: target_tod | ||
| character(len=*) , intent(in) :: model_calendar | ||
| integer , intent(out) :: rc | ||
|
|
||
| ! local variables | ||
| logical :: first_time = .true. | ||
| integer :: n ! indices | ||
| integer :: lsize ! size of attr vect | ||
| real(r8) :: rtmp | ||
| real(r8) :: tbot, pbot | ||
| character(len=*), parameter :: subname='(datm_datamode_cfsr_advance): ' | ||
| !------------------------------------------------------------------------------- | ||
|
|
||
| rc = ESMF_SUCCESS | ||
|
|
||
| lsize = size(strm_mask) | ||
|
|
||
| if (first_time) then | ||
| ! determine tbotmax (see below for use) | ||
| rtmp = maxval(Sa_tbot(:)) | ||
| call shr_mpi_max(rtmp, tbotmax, mpicom, 'datm_tbot', all=.true.) | ||
| if (masterproc) write(logunit,*) trim(subname),' tbotmax = ',tbotmax | ||
|
|
||
| ! determine maskmax (see below for use) | ||
| rtmp = maxval(strm_mask(:)) | ||
| call shr_mpi_max(rtmp, maskmax, mpicom, 'datm_mask', all=.true.) | ||
| if (masterproc) write(logunit,*) trim(subname),' maskmax = ',maskmax | ||
|
|
||
| ! reset first_time | ||
| first_time = .false. | ||
| end if | ||
|
|
||
| do n = 1, lsize | ||
| !--- temperature --- | ||
| if (tbotmax < 50.0_r8) Sa_tbot(n) = Sa_tbot(n) + tkFrz | ||
| ! Limit very cold forcing to 180K | ||
| Sa_tbot(n) = max(180._r8, Sa_tbot(n)) | ||
| end do | ||
|
|
||
| end subroutine datm_datamode_cfsr_advance | ||
|
|
||
| !=============================================================================== | ||
| subroutine datm_datamode_cfsr_restart_write(case_name, inst_suffix, ymd, tod, & | ||
| logunit, my_task, sdat) | ||
|
|
||
| ! input/output variables | ||
| character(len=*) , intent(in) :: case_name | ||
| character(len=*) , intent(in) :: inst_suffix | ||
| integer , intent(in) :: ymd ! model date | ||
| integer , intent(in) :: tod ! model sec into model date | ||
| integer , intent(in) :: logunit | ||
| integer , intent(in) :: my_task | ||
| type(shr_strdata_type) , intent(inout) :: sdat | ||
| !------------------------------------------------------------------------------- | ||
|
|
||
| call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & | ||
| logunit, my_task, sdat) | ||
|
|
||
| end subroutine datm_datamode_cfsr_restart_write | ||
|
|
||
| !=============================================================================== | ||
| subroutine datm_datamode_cfsr_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) | ||
|
|
||
| ! input/output arguments | ||
| character(len=*) , intent(inout) :: rest_filem | ||
| character(len=*) , intent(in) :: inst_suffix | ||
| integer , intent(in) :: logunit | ||
| integer , intent(in) :: my_task | ||
| integer , intent(in) :: mpicom | ||
| type(shr_strdata_type) , intent(inout) :: sdat | ||
| !------------------------------------------------------------------------------- | ||
|
|
||
| call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) | ||
|
|
||
| end subroutine datm_datamode_cfsr_restart_read | ||
|
|
||
| end module datm_datamode_cfsr_mod | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to put some information to this PR about how data need to be downloaded for CFSR (which data repository, Information if data requires pre-processing etc.) and how ESMF Mesh file is created. This will help to other users that plan to use CFSR streams.