DOI-USGS / COAWST

COAWST modeling system git repository
Other
105 stars 50 forks source link

SCRIP - NetCDF Attribute not found error - nested ROMS and single WRF grid #137

Closed gnalbat closed 1 year ago

gnalbat commented 1 year ago

Hi, I'm trying to run SCRIP for 2 nested ROMS grids and 1 WRF grid but I get the following error:

================================================
  Read input_file for SCRIP_COAWST Wrapper
 ================================================
 Ngrid_roms=           2
 Ngrid_swan=           0
 Ngrid_ww3=            0
 Ngrid_wrf =           1
 Ngrid_hyd =           0
 Common netcdf file is: scrip_karding_static.nc

 Number of netcdf subgroups            4
 Input ROMS grid 1  = Karding_parent_f.nc
 Input ROMS grid 2  = Karding_child_f2.nc
 Input WRF grid  1  = wrfinput_d01
 ================================================
 Reading ROMS grids
 Error in netCDF: NetCDF: Attribute not found

The Attribute not found error does not occur when only using one of the ROMS grid (either the coarse or the refinement grid), so I'm at loss to where the issue comes from. As expected running the coupled model with the incorrect weights leads to MCT::m_SparseMatrixPlus::initFromRoot_:: FATAL--length of vector y different from row count of sMat.Length of y = 96748 Number of rows in sMat = 30104, so I would like to get any idea on why the attribute not found error occurs and a possible solution. Both the ROMS and WRF models work standalone.

Here is my scrip.in:

$INPUTS

OUTPUT_NCFILE='scrip_karding_static.nc'

NGRIDS_ROMS=2,
NGRIDS_SWAN=0,
NGRIDS_WW3=0,
NGRIDS_WRF=1,

ROMS_GRIDS(1)='Karding_parent_f.nc',
ROMS_GRIDS(2)='Karding_child_f2.nc',
WRF_GRIDS(1)='wrfinput_d01',

$END 

And I can send my grid files if needed. Thank you for any help!

jcwarner-usgs commented 1 year ago

that is kinda strange. if you can put the grids somewhere, i can give it try. -j

gnalbat commented 1 year ago

that is kinda strange. if you can put the grids somewhere, i can give it try. -j

Hi, I have uploaded them here: https://drive.google.com/drive/folders/1B-632UPbBiHzPEJlt0mZMQS8iuG1odXL

jcwarner-usgs commented 1 year ago

ok i found the issue. when scrip is reading the roms child grid, it wants

    ncstat=nf_get_att_int(nc_file_id,NF_GLOBAL,                   &
 &                           'parent_Imin',ngrd_rm(mo)%istr_o)

it actually needs: parent_Imin parent_Imax parent_Jmin parent_Jmax parent_refine_factor

I see your child grid has donor_Imin = 15 donor_Imax = 155 donor_Jmin = 50 donor_Jmax = 260 sampling_factor = 1

then i see in coarse2fine: if (Gfactor == 1) status = nc_attadd(Gout, 'donor_grid', Ginp); if (status ~= 0), return, end

status = nc_attadd(Gout, 'donor_Imin', int32(Imin)); if (status ~= 0), return, end

status = nc_attadd(Gout, 'donor_Imax', int32(Imax)); if (status ~= 0), return, end

status = nc_attadd(Gout, 'donor_Jmin', int32(Jmin)); if (status ~= 0), return, end

status = nc_attadd(Gout, 'donor_Jmax', int32(Jmax)); if (status ~= 0), return, end

status = nc_attadd(Gout, 'sampling_factor', int32(Gfactor)); if (status ~= 0), return, end else status = nc_attadd(Gout, 'parent_grid', Ginp); if (status ~= 0), return, end

status = nc_attadd(Gout, 'parent_Imin', int32(Imin)); if (status ~= 0), return, end

status = nc_attadd(Gout, 'parent_Imax', int32(Imax)); if (status ~= 0), return, end

status = nc_attadd(Gout, 'parent_Jmin', int32(Jmin)); if (status ~= 0), return, end

status = nc_attadd(Gout, 'parent_Jmax', int32(Jmax)); if (status ~= 0), return, end

status = nc_attadd(Gout, 'refine_factor', int32(Gfactor)); if (status ~= 0), return, end end

I am not sure why it is set that way. But you have Gfactor = 1. so it is not really a refinement. I suppose you could change the child netcdf attirbutes to be the parent_*, or you could change the read_roms.f from

      ncstat=nf_get_att_int(nc_file_id,NF_GLOBAL,                   &
 &                           'parent_Imin',ngrd_rm(mo)%istr_o)
      ncstat=nf_get_att_int(nc_file_id,NF_GLOBAL,                   &
 &                           'parent_Imax',ngrd_rm(mo)%iend_o)
      ncstat=nf_get_att_int(nc_file_id,NF_GLOBAL,                   &
 &                           'parent_Jmin',ngrd_rm(mo)%jstr_o)
      ncstat=nf_get_att_int(nc_file_id,NF_GLOBAL,                   &
 &                           'parent_Jmax',ngrd_rm(mo)%jend_o)
      ncstat=nf_get_att_int(nc_file_id,NF_GLOBAL,                   &
 &                           'refine_factor',ngrd_rm(mo)%ref_fac)

to use the donor_Imin, donor_Imax , donor_Jmin , donor_Jmax , and sampling_factor and recompile. do you know what i mean?

-j

gnalbat commented 1 year ago

Yes, I got it. Sorry about that, I was using another program to make the grids.

Thank you, closing the issue now.