Error in extract_bath.m program

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
manhnt181
Posts: 33
Joined: Wed Feb 03, 2021 5:07 pm
Location: Institute of Geophysics

Error in extract_bath.m program

#1 Unread post by manhnt181 »

Hi ROMS Community,
I got the problem when I used the extract_bath.m program with the etopo5 data to create the bathymetry data. It was successful for the USeast area like the COAWST manual, but I modified it to another are but it failed without error or warning.
This is my program:

Code: Select all

%
%  EXTRACT_BATH:  Driver script to extract bathymetry data
%
%  This user modifiable script can extract bathymetry from ETOPO-5 database
%  at the specified coordinates.
%
% svn $Id: extract_bath.m 996 2020-01-10 04:28:56Z arango $
%===========================================================================%
%  Copyright (c) 2002-2020 The ROMS/TOMS Group                              %
%    Licensed under a MIT/X style license                                   %
%    See License_ROMS.txt                           Hernan G. Arango        %
%===========================================================================%
job='seagrid';          %  prepare bathymetry for seagrid
%job='netcdf';           %  Extract a bathymetry NetCDF file
database='etopo5';
switch job,
  case 'seagrid'
    Oname='vn_bathy.mat';
    %Oname='US_bathy.mat';
  case 'netcdf'
    Oname='uswest_bath.nc';
end,
switch database,
  case 'etopo5'
    Bname='etopo5.nc';
end,
%Llon=-134.0;              % Left   corner longitude     % US west Coast
%Rlon=-118.0;              % Right  corner longitude
%Blat=33.0;                % Bottom corner latitude
%Tlat=49.0;                % Top    corner latitude
%original
Llon=105.0;              % Left   corner longitude     
Rlon=125.0;              % Right  corner longitude
Blat=25.0;                % Bottom corner latitude
Tlat=5.0;                % Top    corner latitude
%-----------------------------------------------------------------------
%  Read and extract bathymetry.
%-----------------------------------------------------------------------
%x=ncread('etopo5.nc','topo_lon')
%y=ncread('etopo5.nc','topo_lat')
switch database,
  case 'etopo5'
    [lon,lat,h]=x_etopo(Llon,Rlon,Blat,Tlat,database);      
 end
%-----------------------------------------------------------------------
%  Process extracted data for requested task.
%-----------------------------------------------------------------------
switch job,
  case 'seagrid'
    xbathy=reshape(lon,1,prod(size(lon)))';
    ybathy=reshape(lat,1,prod(size(lat)))';
    zbathy=reshape(h,1,prod(size(h)))';
    zbathy=-zbathy;
    ind=find(zbathy<0);
    if (~isempty(ind)),
      zbathy(ind)=0;
    end;
    save(Oname,'xbathy','ybathy','zbathy');
    case 'netcdf'
    [Im,Jm]=size(h);  
    status=c_bath(Im,Jm,Oname);
    status=nc_write(Oname,'spherical',1);
    status=nc_write(Oname,'lon',lon);
    status=nc_write(Oname,'lat',lat);
    status=nc_write(Oname,'hraw',h,1);
end,
The detail of this issue was attached in the below.
Please help me to resolve this problem.
Many thanks,
Attachments
VNbathy.PNG
VNbathy.PNG (22.97 KiB) Viewed 5417 times

User avatar
wilkin
Posts: 922
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: Error in extract_bath.m program

#2 Unread post by wilkin »

Blat=25.0; % Bottom corner latitude
Tlat=5.0; % Top corner latitude
Could it be that Blat > Tlat ?
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

manhnt181
Posts: 33
Joined: Wed Feb 03, 2021 5:07 pm
Location: Institute of Geophysics

Re: Error in extract_bath.m program

#3 Unread post by manhnt181 »

Hi Wilkin,
Thank you for your help.
This is my typing mistake, I changed that and this error doesn't occur again.
Thank you very much!
Last edited by manhnt181 on Thu Jul 29, 2021 3:08 pm, edited 1 time in total.

Post Reply