Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/cs_grid/bk_line/save_bk_line.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
6f2602a7ee Jean*0001 function [svNpts,svFlg,svIuv,svJuv,svXsg,svYsg,svXx1,svYy1]=save_bk_line( ...
28aaff1409 Jean*0002          nf1,nf2,nc,ydim,yl,dylat,XYout,xMid,xx0,yy0,yy1, ...
                0003          savI,savJ,savF,isav,jsav,xsav,ncut,icut,xcut,ycut);
6f2602a7ee Jean*0004 % [svNpts,svFlg,svIuv,svJuv,svXsg,svYsg,svXx1,svYy1]=save_bk_line( ...
                0005 %        nf1,nf2,nc,ydim,yl,dylat,XYout,xMid,xx0,yy0,yy1, ...
                0006 %        savI,savJ,savF,isav,jsav,xsav,ncut,icut,xcut,ycut);
                0007 %- output : put together the pieces of bk-lines from the 6 faces
323aa12fe2 Jean*0008 
                0009 %--------------------------------------
                0010 
                0011 %- output arrays:
                0012 % ylat=-87:3:87;
                0013 % if ydim > 1,  ydim=length(ylat); end
                0014 % savNpts=zeros(ydim,1);
                0015 % savFlg=zeros(6*nc,ydim);
                0016 % savIuv=zeros(6*nc,ydim); savJuv=zeros(6*nc,ydim);
                0017 % savXsg=zeros(6*nc,ydim); savYsg=zeros(6*nc,ydim);
28aaff1409 Jean*0018   ncp=nc+1;
                0019   svNpts=zeros(1,1);
                0020   svFlg=zeros(6*ncp,1);
                0021   svIuv=zeros(6*ncp,1); svJuv=zeros(6*ncp,1);
                0022   svXsg=zeros(6*ncp,1); svYsg=zeros(6*ncp,1);
                0023   svXx1=zeros(6*ncp,1); svYy1=zeros(6*ncp,1);
323aa12fe2 Jean*0024 
                0025 ii=0; misfit=0;
                0026 for n=nf1:nf2, for in=1:ncut(n),
                0027 %if icut(in,3,n) >= 0  & icut(in,4,n) > icut(in,3,n),
                0028  if icut(in,6,n) >= 0 & icut(in,3,n) > 0  & icut(in,4,n) > icut(in,3,n),
                0029   ii=ii+1; ninv(ii)=n; jinv(ii)=in;
                0030   x1loc(ii)=xcut(in,3,n) ;
                0031 end; end ; end ; nSegm=ii; 
                0032 x2loc=zeros(nSegm,1); x2loc=x1loc(1:nSegm);
                0033 
                0034 it=0;
                0035 for ns=1:nSegm,
                0036   Xmn=min(x2loc); ii=find(x2loc==Xmn);
                0037   n=ninv(ii); in=jinv(ii);
                0038   if it == 0,
28aaff1409 Jean*0039    svXx1(1)=xcut(in,3,n); 
                0040    svYy1(1)=ycut(in,3,n); 
                0041    svXsg(1)=xx0(isav(icut(in,3,n),n),jsav(icut(in,3,n),n),n);
                0042    svYsg(1)=yy0(isav(icut(in,3,n),n),jsav(icut(in,3,n),n),n);
323aa12fe2 Jean*0043   else
28aaff1409 Jean*0044    if svXx1(it+1) ~= xcut(in,3,n) | svYy1(it+1) ~= ycut(in,3,n),
323aa12fe2 Jean*0045     fprintf('=> conection Pb: previous Seg end= %8.3f %8.3f \n', ...
28aaff1409 Jean*0046             svXx1(it+1),svYy1(it+1) );
323aa12fe2 Jean*0047     fprintf(['  next Seg: ns= %i ; n,in,icut= %i %i %i %i ;', ...
                0048              ' X,Y= %8.3f %8.3f \n'], ...
                0049             ns,n,in,icut(in,3,n),icut(in,4,n),xcut(in,3,n),ycut(in,3,n));
                0050     misfit=misfit+1;
                0051    end
                0052   end
                0053   for i=icut(in,3,n):icut(in,4,n)-1,
                0054    it = it + 1;
28aaff1409 Jean*0055    svFlg(it)=savF(i,n);
                0056    svIuv(it)=savI(i,n)+nc*(n-1);
                0057    svJuv(it)=savJ(i,n);
                0058 %- a hack to distinguish between for isolat / great-circle cases:
                0059    svXx1(it+1)=xsav(i+1,n);
                0060    svYy1(it+1)=yy1(isav(i+1,n),jsav(i+1,n),n);
                0061    svXsg(it+1)=xx0(isav(i+1,n),jsav(i+1,n),n);
                0062    svYsg(it+1) =yy0(isav(i+1,n),jsav(i+1,n),n);
                0063    
323aa12fe2 Jean*0064   end
                0065   x2loc(ii)=XYout;
                0066 end
28aaff1409 Jean*0067  svNpts=it;
323aa12fe2 Jean*0068 
                0069 %--------------------------------------------------------------------
                0070 return