[MITgcm-support] hfac function

michael schaferkotter schaferk at bellsouth.net
Wed Jul 30 16:07:40 EDT 2014


this error message can occur if hfac.m is not on the matlab path. (let's assume that it is).

i don't see where delZ is instantiated before the call to hfac. that could be a problem.

another possibility is that topog.canyon  and delZ are  mixed types.

if i had to guess, you/ll need to recast the topog.canyon data as single by using the cast function 

newTopo=cast(myD,'single')


On Jul 30, 2014, at 1:39 PM, Robert Nazarian wrote:

> Hi,
> 
> I'm trying to use the function hfac and am getting an error in Matlab. Specifically, I'm using hfac based on the online documentation  found at http://mitgcm.org/viewvc/MITgcm/MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/mitgcm_tools/hfac.m?annotate=1.1.1.1&hideattic=1&sortby=file&sortdir=down. I'm using the following code in MATLAB:
> 
> fid=fopen('topog.canyon','r','b');
> myD=fread(fid,'real*8');
> fclose(fid);
> myD=reshape(myD,nx,ny);
> 
> hfacmin=0.2;
> hfacmindz=4;
> [hfacC,ddz]=hfac(delZ',myD,hfacmin,hfacmindz);
> ddzu=min(ddz,ddz([end 1:end-1],:,:));
> mT=1+0*hfacC;
> mT(find(hfacC==0))=0;
> mU=mT.*mT([end 1:end-1],:,:);
> 
> % Vertical coordinate
> zw=[0 -cumsum(squeeze(delZ)')]; % coordinate of W points
> zc=(zw(1:end-1)+zw(2:end))/2;   % coordinate of T points
> zw=zw(1:end-1);                 % truncate to N points for plotting
> 
> where size(delZ) is nz x 1, and size(myD) is nx x ny. I'm getting the error message: 
> "??? Undefined function or method 'hfac' for input arguments of type 'double'"
> for the bolded line of code, where hfacC and ddz are being defined.
> 
> If anyone can suggest where I'm going wrong, I'd greatly appreciate it. Thanks so much!
> Rob
> 
> Robert Nazarian
> PhD Candidate
> Program in Atmospheric and Oceanic Sciences
> Princeton University
> rn2 at princeton.edu
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20140730/263040b9/attachment-0001.htm>


More information about the MITgcm-support mailing list