Skip to content

Commit

Permalink
rename tile_coord%pfaf to tile_coord%pfaf_index; add matlab reader fo…
Browse files Browse the repository at this point in the history
…r tile file (ASCII and nc4) (#78)
  • Loading branch information
gmao-rreichle authored Feb 22, 2025
2 parents f48d06e + 53f6825 commit f2635ee
Show file tree
Hide file tree
Showing 7 changed files with 571 additions and 78 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated subroutine read_obs_sm_ASCAT_EUMET() to work with both original and revised file name templates.
- Updated subroutines read_obs_sm_ASCAT_EUMET(), read_obs_SMAP_halforbit_Tb(), read_obs_SMOS() and read_obs_MODIS_SCF() with hardcoded time ranges for when observations are available and should be read.
- Revised variable names (SHORT_NAME) and descriptions (LONG_NAME) to match M21C file specs.
- Renamed tilecoord%pfaf to %pfaf_index; added matlab tile file reader.

### Fixed

Expand Down
20 changes: 10 additions & 10 deletions GEOSldas_App/preprocess_ldas_routines.F90
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ subroutine domain_setup( &

! locals

integer :: n, this_tileid, this_catpfaf, N_exclude, N_include, indomain, rc
integer :: n, this_tileid, N_exclude, N_include, indomain, rc

integer, dimension(N_cat_global) :: ExcludeList, IncludeList, tmp_d2g

Expand Down Expand Up @@ -2964,7 +2964,7 @@ subroutine LDAS_read_til_file( tile_file, catch_file, tile_grid_g, tile_coord_la

read (tmpline,*) &
tile_coord(i)%typ, & ! 1
tile_coord(i)%pfaf, & ! 2
tile_coord(i)%pfaf_index, & ! 2
tile_coord(i)%com_lon, & ! 3
tile_coord(i)%com_lat, & ! 4
tile_coord(i)%i_indg, & ! 5
Expand All @@ -2985,7 +2985,7 @@ subroutine LDAS_read_til_file( tile_file, catch_file, tile_grid_g, tile_coord_la

read (tmpline,*) &
tile_coord(i)%typ, & ! 1
tile_coord(i)%pfaf, & ! 2 *
tile_coord(i)%pfaf_index, & ! 2 *
tile_coord(i)%com_lon, & ! 3
tile_coord(i)%com_lat, & ! 4
tile_coord(i)%i_indg, & ! 5
Expand All @@ -3009,7 +3009,7 @@ subroutine LDAS_read_til_file( tile_file, catch_file, tile_grid_g, tile_coord_la
tile_coord(i)%j_indg, & ! 6
tile_coord(i)%frac_cell, & ! 7
tmpint1, & ! 8
tile_coord(i)%pfaf, & ! 9 *
tile_coord(i)%pfaf_index, & ! 9 *
tmpint2, & ! 10
tile_coord(i)%frac_pfaf, & ! 11
tmpint3 ! 12 * (previously "tile_id")
Expand Down Expand Up @@ -3250,7 +3250,7 @@ subroutine read_catchment_def( catchment_def_file, N_tile, tile_coord )
!
! Header line: N_tile
!
! Columns: tile_id, Pfaf, min_lon, max_lon, min_lat, max_lat, [elev]
! Columns: tile_id, pfaf_index, min_lon, max_lon, min_lat, max_lat, [elev]
!
! Elevation [m] is ONLY available for EASE grid tile definitions

Expand All @@ -3266,7 +3266,7 @@ subroutine read_catchment_def( catchment_def_file, N_tile, tile_coord )

integer :: i, istat, tmpint1, sweep

integer, dimension(N_tile) :: tmp_tileid, tmp_pfaf
integer, dimension(N_tile) :: tmp_tileid, tmp_pfafindex

character(len=*), parameter :: Iam = 'read_catchment_def'
character(len=400) :: err_msg
Expand Down Expand Up @@ -3305,7 +3305,7 @@ subroutine read_catchment_def( catchment_def_file, N_tile, tile_coord )

! read 7 columns, avoid using exact format specification

read (10,*, iostat=istat) tmp_tileid(i), tmp_pfaf(i), &
read (10,*, iostat=istat) tmp_tileid(i), tmp_pfafindex(i), &
tile_coord(i)%min_lon, &
tile_coord(i)%max_lon, &
tile_coord(i)%min_lat, &
Expand All @@ -3316,7 +3316,7 @@ subroutine read_catchment_def( catchment_def_file, N_tile, tile_coord )

! read 6 columns, avoid using exact format specification

read (10,*, iostat=istat) tmp_tileid(i), tmp_pfaf(i), &
read (10,*, iostat=istat) tmp_tileid(i), tmp_pfafindex(i), &
tile_coord(i)%min_lon, &
tile_coord(i)%max_lon, &
tile_coord(i)%min_lat, &
Expand Down Expand Up @@ -3358,8 +3358,8 @@ subroutine read_catchment_def( catchment_def_file, N_tile, tile_coord )

end do ! loop through sweeps

if ( any(tile_coord(1:N_tile)%tile_id/=tmp_tileid) .or. &
any(tile_coord(1:N_tile)%pfaf /=tmp_pfaf) ) then
if ( any(tile_coord(1:N_tile)%tile_id /=tmp_tileid) .or. &
any(tile_coord(1:N_tile)%pfaf_index/=tmp_pfafindex) ) then

err_msg = 'tile_coord_file and catchment_def_file mismatch. (2)'
call ldas_abort(LDAS_GENERIC_ERROR, Iam, err_msg)
Expand Down
46 changes: 46 additions & 0 deletions GEOSldas_App/util/shared/matlab/read_catchmentdef.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function [tile_coord ] = read_catchmentdef( fname )

% read (land) tile properties from "catchment.def" file (EASEv2 and cube-sphere)
%
% reichle, 24 Jan 2025
%
% -------------------------------------------------------------

% read file

disp(['reading from ', fname])

ifp = fopen( fname, 'r' );

% read header line

tmpdata = fscanf( ifp, '%f', 1 );

tile_coord.N_tile = tmpdata(1);

% read rest of data

tmpdata = fscanf( ifp, '%f' );

fclose(ifp);

disp('done reading "catchment.def" file')

% --------------------------------------------------

% process data

tmpdata = reshape(tmpdata, [7, tile_coord.N_tile])';

tile_coord.tile_id = tmpdata(:,1);
tile_coord.pfaf_index = tmpdata(:,2);

tile_coord.min_lon = tmpdata(:,3);
tile_coord.max_lon = tmpdata(:,4);
tile_coord.min_lat = tmpdata(:,5);
tile_coord.max_lat = tmpdata(:,6);

tile_coord.elev = tmpdata(:,7);

% ========== EOF ===================================================

Loading

0 comments on commit f2635ee

Please sign in to comment.