[20498] | 1 | Index: ../trunk-jpl/src/m/coordsystems/gmtmaskparallel.m
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/coordsystems/gmtmaskparallel.m (revision 0)
|
---|
| 4 | +++ ../trunk-jpl/src/m/coordsystems/gmtmaskparallel.m (revision 20060)
|
---|
| 5 | @@ -0,0 +1,49 @@
|
---|
| 6 | +function mask = gmtmaskparallel(lat,long,ncores)
|
---|
| 7 | +%GMTMASKPARALLEL- parallel driver for the gmtmask utility
|
---|
| 8 | +%
|
---|
| 9 | +% Usage:
|
---|
| 10 | +% mask.ocean = gmtmaskparallel(md.mesh.lat,md.mesh.long,8);
|
---|
| 11 | +%
|
---|
| 12 | +
|
---|
| 13 | + %First, write our lat,long file for gmt:
|
---|
| 14 | + nv=length(lat);
|
---|
| 15 | +
|
---|
| 16 | + %Split:
|
---|
| 17 | + nnv=1:floor(nv/ncores):nv;
|
---|
| 18 | + nnv(end)=nv+1;
|
---|
| 19 | +
|
---|
| 20 | + %For each segment, write all vertices file:
|
---|
| 21 | + for i=1:length(nnv)-1,
|
---|
| 22 | + dlmwrite(['./all_vertices' num2str(i) '.txt'],[long(nnv(i):nnv(i+1)-1) lat(nnv(i):nnv(i+1)-1) (nnv(i):nnv(i+1)-1)'],'delimiter','\t');
|
---|
| 23 | + end
|
---|
| 24 | +
|
---|
| 25 | + if ismac,
|
---|
| 26 | + dyld_library_path_old=getenv('DYLD_LIBRARY_PATH');
|
---|
| 27 | + setenv('DYLD_LIBRARY_PATH',[ issmdir '/externalpackages/curl/install/lib:' issmdir '/externalpackages/hdf5/install/lib:' issmdir '/externalpackages/netcdf/install/lib' ]);
|
---|
| 28 | + end
|
---|
| 29 | +
|
---|
| 30 | + %Build xjobs script:
|
---|
| 31 | + fid=fopen('xjobs.script','w');
|
---|
| 32 | + for i=1:length(nnv)-1,
|
---|
| 33 | + fprintf(fid,'gmt gmtselect ./all_vertices%i.txt -h0 -Df -R0/360/-90/90 -A0 -JQ180/200 -Nk/s/s/k/s > ./oce_vertices%i.txt\n',i,i);
|
---|
| 34 | + end
|
---|
| 35 | + fclose(fid);
|
---|
| 36 | +
|
---|
| 37 | + %Call xjobs:
|
---|
| 38 | + system(sprintf('xjobs -j %i -s ./xjobs.script',ncores));
|
---|
| 39 | +
|
---|
| 40 | + %reset DYLD_LIBRARY_PATH to what it was:
|
---|
| 41 | + if ismac,
|
---|
| 42 | + setenv('DYLD_LIBRARY_PATH',dyld_library_path_old);
|
---|
| 43 | + end
|
---|
| 44 | +
|
---|
| 45 | + %concatenate:
|
---|
| 46 | + system('cat oce_vertices*.txt | grep -v Command | awk ''{printf("%s\n",$3);}''> vertices.txt');
|
---|
| 47 | +
|
---|
| 48 | + %read the vertices.txt file and flag our mesh vertices on the continent
|
---|
| 49 | + flags=dlmread('./vertices.txt');
|
---|
| 50 | +
|
---|
| 51 | + mask=zeros(nv,1);
|
---|
| 52 | + mask(flags)=1;
|
---|
| 53 | +
|
---|
| 54 | + system('rm -rf ./all_vertices*.txt ./oce_vertices*.txt vertices.txt ./gmt.history');
|
---|