Skip to content
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

代码优化(驱动插值,网格映射方法,驱动降尺度,共享pixelset) #269

Merged
merged 5 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions CaMa/src/MOD_CaMa_Vars.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ MODULE MOD_CaMa_Vars
USE MOD_Precision
USE MOD_Grid
USE MOD_DataType
USE MOD_Mapping_Pset2Grid
USE MOD_Mapping_Grid2Pset
USE YOS_CMF_INPUT, only: DMIS

USE MOD_SpatialMapping
USE YOS_CMF_INPUT, only: RMIS, DMIS
USE MOD_Vars_Global, only: spval


real(r8) :: nacc ! number of accumulation
real(r8), allocatable :: a_rnof_cama (:) ! on worker : total runoff [mm/s]
type(block_data_real8_2d) :: f_rnof_cama ! on IO : total runoff [mm/s]
Expand All @@ -58,8 +59,8 @@ MODULE MOD_CaMa_Vars
real(r8), allocatable :: finfg_2d (:,:) ! on Master : total runoff [mm/s]
type(grid_type) :: gcama

type (mapping_pset2grid_type) :: mp2g_cama ! mapping pset to grid
type (mapping_grid2pset_type) :: mg2p_cama ! mapping grid to pset
type (spatial_mapping_type) :: mp2g_cama ! mapping pset to grid
type (spatial_mapping_type) :: mg2p_cama ! mapping grid to pset

type (grid_concat_type) :: cama_gather ! gather grid

Expand Down Expand Up @@ -551,7 +552,6 @@ SUBROUTINE colm2cama_real8 (WorkerVar, IOVar, MasterVar)
USE MOD_Block
USE MOD_DataType
USE MOD_LandPatch
USE MOD_Mapping_Pset2Grid
USE MOD_Vars_TimeInvariants, only : patchtype
USE MOD_Forcing, only : forcmask_pch

Expand All @@ -562,7 +562,6 @@ SUBROUTINE colm2cama_real8 (WorkerVar, IOVar, MasterVar)
real(r8), intent(inout) :: MasterVar(:,:) !varialbe on master processer

type(block_data_real8_2d) :: sumwt !sum of weight
real(r8), allocatable :: vectmp(:) !temporary vector
logical, allocatable :: filter(:) !filter for patchtype
!----------------------- Dummy argument --------------------------------
integer :: xblk, yblk, xloc, yloc
Expand All @@ -582,23 +581,19 @@ SUBROUTINE colm2cama_real8 (WorkerVar, IOVar, MasterVar)

IF (numpatch > 0) THEN
allocate (filter (numpatch))
allocate (vectmp (numpatch))

filter(:) = patchtype < 99
IF (DEF_forcing%has_missing_value) THEN
filter = filter .and. forcmask_pch
ENDIF
vectmp (:) = 1.
ENDIF
ENDIF

CALL mp2g_cama%map (WorkerVar, IOVar, spv = spval, msk = filter)
CALL mp2g_cama%pset2grid (WorkerVar, IOVar, spv = spval, msk = filter)

IF (p_is_io) THEN
CALL allocate_block_data (gcama, sumwt)
ENDIF
IF (p_is_io) CALL allocate_block_data (gcama, sumwt)
CALL mp2g_cama%get_sumarea (sumwt, filter)

CALL mp2g_cama%map (vectmp, sumwt, spv = spval, msk = filter)

IF (p_is_io) THEN
DO yblk = 1, gblock%nyblk
Expand Down Expand Up @@ -674,7 +669,6 @@ SUBROUTINE colm2cama_real8 (WorkerVar, IOVar, MasterVar)
ENDIF

IF (allocated(filter)) deallocate(filter)
IF (allocated(vectmp)) deallocate(vectmp)

END SUBROUTINE colm2cama_real8

Expand All @@ -700,7 +694,6 @@ SUBROUTINE cama2colm_real8 (MasterVar, IOVar, WorkerVar)
USE MOD_Block
USE MOD_DataType
USE MOD_LandPatch
USE MOD_Mapping_Pset2Grid
USE MOD_Vars_TimeInvariants, only : patchtype
USE MOD_Grid

Expand Down Expand Up @@ -770,7 +763,7 @@ SUBROUTINE cama2colm_real8 (MasterVar, IOVar, WorkerVar)
ENDDO
ENDIF

CALL mg2p_cama%map_aweighted (IOVar, WorkerVar) !mapping grid to pset_type
CALL mg2p_cama%grid2pset (IOVar, WorkerVar) !mapping grid to pset_type

END SUBROUTINE cama2colm_real8

Expand Down
6 changes: 3 additions & 3 deletions CaMa/src/MOD_CaMa_colmCaMa.F90
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ SUBROUTINE colm_CaMa_init
CALL mpi_bcast (real(D1LAT,kind=8) , 1, MPI_REAL8, p_root, p_comm_glb, p_err) !
CALL mpi_bcast (real(D1LON,kind=8) , 1, MPI_REAL8, p_root, p_comm_glb, p_err) !

!allocate the data structure for cama
CALL gcama%define_by_center (D1LAT,D1LON,real(SOUTH,kind=8), real(NORTH,kind=8), real(WEST,kind=8), real(EAST,kind=8)) !define the grid for cama
CALL mp2g_cama%build (landpatch, gcama) !build the mappcing between cama and mpi
CALL mg2p_cama%build (gcama, landpatch)

CALL mp2g_cama%build_arealweighted (gcama, landpatch) !build the mapping between cama and mpi
CALL mg2p_cama%build_arealweighted (gcama, landpatch)
CALL cama_gather%set (gcama)

!allocate the cama-flood related variable for accumulation
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ OBJS_SHARED = \
MOD_NetCDFVectorOneS.o \
MOD_NetCDFVectorOneP.o \
MOD_RangeCheck.o \
MOD_Mapping_Grid2Pset.o \
MOD_Mapping_Pset2Grid.o \
MOD_InterpBilinear.o \
MOD_SpatialMapping.o \
MOD_AggregationRequestData.o \
MOD_PixelsetShared.o \
MOD_LandElm.o \
Expand Down
7 changes: 5 additions & 2 deletions include/Makeoptions.gnu
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

FF = mpif90 -fopenmp

NETCDF_LIB = /usr/lib/x86_64-linux-gnu
NETCDF_INC = /usr/include
NETCDF_LIB = /usr/lib/x86_64-linux-gnu
NETCDF_INC = /usr/include

# NETCDF_LIB = /opt/netcdf-c-4.9.2-fortran-4.6.0-gnu/lib
# NETCDF_INC = /opt/netcdf-c-4.9.2-fortran-4.6.0-gnu/include

MOD_CMD = -J

Expand Down
8 changes: 3 additions & 5 deletions include/Makeoptions.intel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
# mpif90 - ifort
#

FF = mpif90 -f90=ifort
FF = mpif90

NETCDF_LIB = /usr/lib/x86_64-linux-gnu
NETCDF_INC = /usr/include

MATH_LIB = /share/home/dq013/software//miniconda3/lib/ #MKL LIB_PATH
NETCDF_LIB = /opt/netcdf-c-4.9.2-fortran-4.6.0-intel/lib
NETCDF_INC = /opt/netcdf-c-4.9.2-fortran-4.6.0-intel/include

MOD_CMD = -module

Expand Down
14 changes: 4 additions & 10 deletions main/DA/MOD_DA_GRACE.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
MODULE MOD_DA_GRACE

USE MOD_DataType
USE MOD_Mapping_Grid2Pset
IMPLICIT NONE

PUBLIC :: init_DA_GRACE
Expand All @@ -26,7 +25,7 @@ MODULE MOD_DA_GRACE
integer, allocatable :: obsyear (:)
integer, allocatable :: obsmonth (:)

type (mapping_grid2pset_type) :: mg2p_grace
type (spatial_mapping_type) :: mg2p_grace

real(r8), allocatable :: lwe_obs_this (:)
real(r8), allocatable :: err_obs_this (:)
Expand Down Expand Up @@ -69,7 +68,6 @@ SUBROUTINE init_DA_GRACE ()
USE MOD_LandCrop
#endif
USE MOD_Pixelset
USE MOD_Mapping_Grid2pset
USE MOD_Vars_TimeInvariants, only : patchtype
USE MOD_Forcing, only : forcmask_pch
USE MOD_RangeCheck
Expand Down Expand Up @@ -105,7 +103,7 @@ SUBROUTINE init_DA_GRACE ()

CALL grid_grace%define_by_center (latgrace,longrace)

CALL mg2p_grace%build (grid_grace, landelm)
CALL mg2p_grace%build_arealweighted (grid_grace, landelm)

IF (p_is_worker) THEN
IF (numelm > 0) THEN
Expand Down Expand Up @@ -133,11 +131,7 @@ SUBROUTINE init_DA_GRACE ()
ENDIF

IF (p_is_worker) THEN
#ifdef CROP
CALL elm_patch%build (landelm, landpatch, use_frac = .true., sharedfrac = pctshrpch)
#else
CALL elm_patch%build (landelm, landpatch, use_frac = .true.)
#endif
ENDIF

IF (p_is_worker) THEN
Expand Down Expand Up @@ -248,8 +242,8 @@ SUBROUTINE do_DA_GRACE (idate, deltim)
CALL ncio_read_block_time (file_grace, 'uncertainty' , grid_grace, itime, f_grace_err)
ENDIF

CALL mg2p_grace%map_aweighted (f_grace_lwe, lwe_obs_this)
CALL mg2p_grace%map_aweighted (f_grace_err, err_obs_this)
CALL mg2p_grace%grid2pset (f_grace_lwe, lwe_obs_this)
CALL mg2p_grace%grid2pset (f_grace_err, err_obs_this)

IF (p_is_worker) THEN

Expand Down
10 changes: 5 additions & 5 deletions main/HYDRO/MOD_Catch_RiverLakeNetwork.F90
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ SUBROUTINE calc_riverdepth_from_runoff ()
USE MOD_Block
USE MOD_Mesh
USE MOD_Grid
USE MOD_Mapping_Grid2Pset
USE MOD_SpatialMapping
USE MOD_LandElm
USE MOD_ElmVector
USE MOD_ElementNeighbour
Expand All @@ -719,8 +719,8 @@ SUBROUTINE calc_riverdepth_from_runoff ()
! Local Variables
character(len=256) :: file_rnof, file_rivdpt
type(grid_type) :: grid_rnof
type(block_data_real8_2d) :: f_rnof
type(mapping_grid2pset_type) :: mg2p_rnof
type(block_data_real8_2d) :: f_rnof
type(spatial_mapping_type) :: mg2p_rnof

real(r8), allocatable :: bsnrnof(:) , bsndis(:)
integer, allocatable :: nups_riv(:), iups_riv(:), b_up2down(:)
Expand All @@ -739,7 +739,7 @@ SUBROUTINE calc_riverdepth_from_runoff ()

CALL grid_rnof%define_from_file (file_rnof, 'lat', 'lon')

CALL mg2p_rnof%build (grid_rnof, landelm)
CALL mg2p_rnof%build_arealweighted (grid_rnof, landelm)

IF (p_is_io) THEN
CALL allocate_block_data (grid_rnof, f_rnof)
Expand All @@ -760,7 +760,7 @@ SUBROUTINE calc_riverdepth_from_runoff ()
IF (numelm > 0) allocate (bsnrnof (numelm))
ENDIF

CALL mg2p_rnof%map_aweighted (f_rnof, bsnrnof)
CALL mg2p_rnof%grid2pset (f_rnof, bsnrnof)

IF (p_is_worker) THEN
IF (numelm > 0) THEN
Expand Down
36 changes: 18 additions & 18 deletions main/MOD_Aerosol.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MODULE MOD_Aerosol
USE MOD_Precision
USE MOD_Grid
USE MOD_DataType
USE MOD_Mapping_Grid2Pset
USE MOD_SpatialMapping
USE MOD_Vars_Global, only: maxsnl
IMPLICIT NONE
SAVE
Expand All @@ -27,8 +27,8 @@ MODULE MOD_Aerosol
character(len=256) :: file_aerosol

type(grid_type) :: grid_aerosol
type(block_data_real8_2d) :: f_aerdep
type(mapping_grid2pset_type) :: mg2p_aerdep
type(block_data_real8_2d) :: f_aerdep
type(spatial_mapping_type) :: mg2p_aerdep

integer, parameter :: start_year = 1849
integer, parameter :: end_year = 2001
Expand Down Expand Up @@ -319,7 +319,7 @@ SUBROUTINE AerosolDepInit ()

CALL allocate_block_data (grid_aerosol, f_aerdep)

CALL mg2p_aerdep%build (grid_aerosol, landpatch)
CALL mg2p_aerdep%build_arealweighted (grid_aerosol, landpatch)

month_p = -1

Expand Down Expand Up @@ -365,59 +365,59 @@ SUBROUTINE AerosolDepReadin (idate)

! BCPHIDRY , hydrophilic BC dry deposition
CALL ncio_read_block_time (file_aerosol, 'BCPHIDRY', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(1,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(1,:))

! BCPHODRY , hydrophobic BC dry deposition
CALL ncio_read_block_time (file_aerosol, 'BCPHODRY', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(2,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(2,:))

! BCDEPWET , hydrophilic BC wet deposition
CALL ncio_read_block_time (file_aerosol, 'BCDEPWET', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(3,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(3,:))

! OCPHIDRY , hydrophilic OC dry deposition
CALL ncio_read_block_time (file_aerosol, 'OCPHIDRY', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(4,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(4,:))

! OCPHODRY , hydrophobic OC dry deposition
CALL ncio_read_block_time (file_aerosol, 'OCPHODRY', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(5,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(5,:))

! OCDEPWET , hydrophilic OC wet deposition
CALL ncio_read_block_time (file_aerosol, 'OCDEPWET', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(6,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(6,:))

! DSTX01WD , DSTX01 wet deposition flux at bottom
CALL ncio_read_block_time (file_aerosol, 'DSTX01WD', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(7,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(7,:))

! DSTX01DD , DSTX01 dry deposition flux at bottom
CALL ncio_read_block_time (file_aerosol, 'DSTX01DD', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(8,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(8,:))

! DSTX02WD , DSTX02 wet deposition flux at bottom
CALL ncio_read_block_time (file_aerosol, 'DSTX02WD', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(9,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(9,:))

! DSTX02DD , DSTX02 dry deposition flux at bottom
CALL ncio_read_block_time (file_aerosol, 'DSTX02DD', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(10,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(10,:))

! DSTX03WD , DSTX03 wet deposition flux at bottom
CALL ncio_read_block_time (file_aerosol, 'DSTX03WD', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(11,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(11,:))

! DSTX03DD , DSTX03 dry deposition flux at bottom
CALL ncio_read_block_time (file_aerosol, 'DSTX03DD', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(12,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(12,:))

! DSTX04WD , DSTX04 wet deposition flux at bottom
CALL ncio_read_block_time (file_aerosol, 'DSTX04WD', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(13,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(13,:))

! DSTX04DD , DSTX04 dry deposition flux at bottom
CALL ncio_read_block_time (file_aerosol, 'DSTX04DD', grid_aerosol, itime, f_aerdep)
CALL mg2p_aerdep%map_aweighted (f_aerdep, forc_aerdep(14,:))
CALL mg2p_aerdep%grid2pset (f_aerdep, forc_aerdep(14,:))

#ifdef RangeCheck
!CALL check_block_data ('aerosol', f_aerdep)
Expand Down
Loading