@@ -32,7 +32,7 @@ module model_mod
32
32
nc_begin_define_mode, nc_end_define_mode, &
33
33
nc_open_file_readonly, nc_close_file, &
34
34
nc_get_variable, nc_get_variable_size, &
35
- NF90_MAX_NAME
35
+ NF90_MAX_NAME, nc_get_attribute_from_variable
36
36
37
37
use quad_utils_mod, only : quad_interp_handle, init_quad_interp, &
38
38
set_quad_coords, quad_lon_lat_locate, &
@@ -97,6 +97,7 @@ module model_mod
97
97
real (r8 ), allocatable :: geolon(:,:), geolat(:,:), & ! T
98
98
geolon_u(:,:), geolat_u(:,:), & ! U
99
99
geolon_v(:,:), geolat_v(:,:) ! V
100
+ logical , allocatable :: mask(:,:), mask_u(:,:), mask_v(:,:) ! geolat/lon/u/v has missing values
100
101
type (quad_interp_handle) :: interp_t_grid, &
101
102
interp_u_grid, &
102
103
interp_v_grid
@@ -595,6 +596,7 @@ subroutine read_horizontal_grid()
595
596
596
597
integer :: ncid
597
598
integer :: nxy(2 ) ! (nx,ny)
599
+ real (r8 ) :: fillval
598
600
599
601
character (len=* ), parameter :: routine = ' read_horizontal_grid'
600
602
@@ -606,22 +608,48 @@ subroutine read_horizontal_grid()
606
608
allocate (geolon(nx,ny), geolat(nx,ny)) ! T grid
607
609
allocate (geolon_u(nx,ny), geolat_u(nx,ny)) ! U grid
608
610
allocate (geolon_v(nx,ny), geolat_v(nx,ny)) ! V grid
611
+ allocate (mask(nx,ny)) ! missing values
612
+ allocate (mask_u(nx,ny)) ! missing values
613
+ allocate (mask_v(nx,ny)) ! missing values
609
614
610
615
call nc_get_variable(ncid, ' geolon' , geolon, routine)
611
616
call nc_get_variable(ncid, ' geolon_u' , geolon_u, routine)
612
617
call nc_get_variable(ncid, ' geolon_v' , geolon_v, routine)
613
618
614
-
615
- ! mom6 example file has longitude > 360
616
- ! DART uses [0,360]
617
- where (geolon > 360.0_r8 ) geolon = geolon - 360.0_r8
618
- where (geolon_u > 360.0_r8 ) geolon_u = geolon_u - 360.0_r8
619
- where (geolon_v > 360.0_r8 ) geolon_v = geolon_v - 360.0_r8
620
-
621
619
call nc_get_variable(ncid, ' geolat' , geolat, routine)
622
620
call nc_get_variable(ncid, ' geolat_u' , geolat_u, routine)
623
621
call nc_get_variable(ncid, ' geolat_v' , geolat_v, routine)
624
622
623
+ ! mom6 has missing values in the grid
624
+ ! and set missing value to a land point to prevent set_location erroring
625
+ mask(:,:) = .false.
626
+ mask_u(:,:) = .false.
627
+ mask_v(:,:) = .false.
628
+ call nc_get_attribute_from_variable(ncid, ' geolon' , ' _FillValue' , fillval)
629
+ where (geolon == fillval) mask = .true.
630
+ where (geolon == fillval) geolon = 72.51
631
+ where (geolat == fillval) geolat = 42.56
632
+
633
+ call nc_get_attribute_from_variable(ncid, ' geolon_u' , ' _FillValue' , fillval)
634
+ where (geolon_u == fillval) mask_u = .true.
635
+ where (geolon_u == fillval) geolon_u = 72.51
636
+ where (geolat_u == fillval) geolat_u = 42.56
637
+
638
+ call nc_get_attribute_from_variable(ncid, ' geolon_v' , ' _FillValue' , fillval)
639
+ where (geolon_v == fillval) mask_v = .true.
640
+ where (geolon_v == fillval) geolon_v = 72.51
641
+ where (geolat_v == fillval) geolat_v = 42.56
642
+
643
+ ! mom6 example files have longitude > 360 and longitudes < 0
644
+ ! DART uses [0,360]
645
+ geolon = mod (geolon, 360.0 )
646
+ geolon_u = mod (geolon_u, 360.0 )
647
+ geolon_v = mod (geolon_v, 360.0 )
648
+
649
+ where (geolon < 0.0 ) geolon = geolon + 360
650
+ where (geolon_u < 0.0 ) geolon_u = geolon_u + 360
651
+ where (geolon_v < 0.0 ) geolon_v = geolon_v + 360
652
+
625
653
call nc_close_file(ncid)
626
654
627
655
end subroutine read_horizontal_grid
@@ -831,15 +859,15 @@ subroutine setup_interpolation()
831
859
global= .true. , spans_lon_zero= .true. , pole_wrap= .true. , &
832
860
interp_handle= interp_t_grid)
833
861
834
- call set_quad_coords(interp_t_grid, geolon, geolat)
862
+ call set_quad_coords(interp_t_grid, geolon, geolat, mask )
835
863
836
864
! U
837
865
call init_quad_interp(GRID_QUAD_FULLY_IRREGULAR, nx, ny, &
838
866
QUAD_LOCATED_CELL_CENTERS, &
839
867
global= .true. , spans_lon_zero= .true. , pole_wrap= .true. , &
840
868
interp_handle= interp_u_grid)
841
869
842
- call set_quad_coords(interp_u_grid, geolon_u, geolat_u)
870
+ call set_quad_coords(interp_u_grid, geolon_u, geolat_u, mask_u )
843
871
844
872
845
873
! V
@@ -848,7 +876,7 @@ subroutine setup_interpolation()
848
876
global= .true. , spans_lon_zero= .true. , pole_wrap= .true. , &
849
877
interp_handle= interp_v_grid)
850
878
851
- call set_quad_coords(interp_v_grid, geolon_v, geolat_v)
879
+ call set_quad_coords(interp_v_grid, geolon_v, geolat_v, mask_v )
852
880
853
881
end subroutine setup_interpolation
854
882
0 commit comments