| 1 | gforget | 1.1 | function [field_cur]=gpcp_load_fields(list_years); | 
| 2 |  |  | %loads the fields and does the interpolation to the 1x1 ECCO grid | 
| 3 |  |  | domaine_global_def; | 
| 4 |  |  |  | 
| 5 |  |  | mask=squeeze(tmask3D(:,:,1)); | 
| 6 |  |  |  | 
| 7 |  |  | rep_in='/net/ross/raid0/gforget/DATAbin/forcing/GPCP/'; | 
| 8 |  |  |  | 
| 9 |  |  | jpig=144; jpjg=72; | 
| 10 |  |  | lon2D_g=[1.25:2.5:358.75]'*ones(1,jpjg); lat2D_g=ones(jpig,1)*[-88.75:2.5:88.75]; | 
| 11 |  |  | mask_g=ones(jpig,jpjg); recl=jpig*jpjg*4; | 
| 12 |  |  |  | 
| 13 |  |  | [x1,y1] = meshgrid([lon2D_g(end,1)-360  lon2D_g(:,1)' lon2D_g(1:2,1)'+360],lat2D_g(1,:)); | 
| 14 |  |  | [x2,y2] = meshgrid(lon2D_t(:,1),lat2D_t(1,:)); | 
| 15 |  |  |  | 
| 16 |  |  |  | 
| 17 |  |  | nb_cur=zeros(1,12); field_cur=zeros(jpi,jpj,12); | 
| 18 |  |  | for ycur=list_years | 
| 19 |  |  | fid=fopen([rep_in 'gpcp_v2_psg.' num2str(ycur)],'r','b'); | 
| 20 |  |  | status=fseek(fid,576,'bof'); %skip header | 
| 21 |  |  | for mcur=1:12; | 
| 22 |  |  | field_in=flipdim(fread(fid,[jpig jpjg],'float32'),2); | 
| 23 |  |  | %interpolate: | 
| 24 |  |  | tmp1=[field_in(end,:);field_in;field_in(1,:);field_in(2,:)]'; | 
| 25 |  |  | field_out=interp2(x1,y1,tmp1,x2,y2)'; | 
| 26 |  |  | %units: | 
| 27 |  |  | field_out=field_out.*mask/86400; | 
| 28 |  |  | %sum: | 
| 29 |  |  | field_cur(:,:,mcur)=field_cur(:,:,mcur)+field_out; nb_cur(mcur)=nb_cur(mcur)+1; | 
| 30 |  |  | end; | 
| 31 |  |  | fclose(fid); | 
| 32 |  |  | end%for ycur=list_years | 
| 33 |  |  |  | 
| 34 |  |  | %sum2average: | 
| 35 |  |  | for tcur=1:12; field_cur(:,:,tcur)=field_cur(:,:,tcur)/nb_cur(tcur); end; | 
| 36 |  |  |  | 
| 37 |  |  |  | 
| 38 |  |  |  |