| 1 | gforget | 1.1 |  | 
| 2 |  |  | domaine_global_def; domaine; | 
| 3 |  |  | mask=squeeze(tmask3D(:,:,1)); recl=jpi*jpj*4; | 
| 4 |  |  |  | 
| 5 |  |  | choice_plot=0; | 
| 6 |  |  | rep_out='./'; | 
| 7 |  |  |  | 
| 8 |  |  | for choiceDataSet=1:2; | 
| 9 |  |  | %1->NCEP 2->ECMWF | 
| 10 |  |  | if choiceDataSet==1; data_cur='.ncep_noicemask.'; ycur0=1992; ycurMax=2006; | 
| 11 |  |  | else choiceDataSet==2; data_cur='.ecmwf_noicemask.'; ycur0=1992; ycurMax=2006; | 
| 12 |  |  | end; fprintf([data_cur ' flux \n']); | 
| 13 |  |  |  | 
| 14 |  |  | fid_runoff=fopen('/net/ross/raid0/gforget/DATAbin/forcing/CORE/runoffannual1x1','r','b'); | 
| 15 |  |  | runoff=fread(fid_runoff,[jpi jpj],'float32').*mask; | 
| 16 |  |  | fclose(fid_runoff); | 
| 17 |  |  |  | 
| 18 |  |  | %SST and ICE data: | 
| 19 |  |  | fid_sst=fopen('/net/ross/raid0/gforget/DATAbin/ICECONC/HADLEY/HadISST1_SST_9206_monthly','r','b'); | 
| 20 |  |  | field_sst=fread(fid_sst,jpi*jpj*12,'float32'); fclose(fid_sst); field_sst=reshape(field_sst,jpi,jpj,12); | 
| 21 |  |  | fid_ice=fopen('/net/ross/raid0/gforget/DATAbin/ICECONC/HADLEY/HadISST1_ICE_9206_monthly','r','b'); | 
| 22 |  |  | field_ice=fread(fid_ice,jpi*jpj*12,'float32'); fclose(fid_ice); field_ice=reshape(field_ice,jpi,jpj,12); | 
| 23 |  |  |  | 
| 24 |  |  | %for interannual sst: | 
| 25 |  |  | rep_sst='/net/ross/raid2/king/data_1x1_92-03/obs/'; pref_sst='SST_monthly_r2_'; suff_sst=''; | 
| 26 |  |  |  | 
| 27 |  |  |  | 
| 28 |  |  | for ycur=ycur0:ycurMax | 
| 29 |  |  |  | 
| 30 |  |  | suff_out=[data_cur 'flux.' num2str(ycur) '.daily.bin']; list_tcur=[1:365]; | 
| 31 |  |  | doInitFiles=1; doWriteMean=0; | 
| 32 |  |  |  | 
| 33 |  |  | for tcur=list_tcur | 
| 34 |  |  |  | 
| 35 |  |  | for ttcur=1:4 | 
| 36 |  |  |  | 
| 37 |  |  | hcur=(tcur-1)*4+ttcur; | 
| 38 |  |  |  | 
| 39 |  |  | %part a: load fields | 
| 40 |  |  | if choiceDataSet==1; [dataFlds]=ncep_load_fluxes(ycur,hcur); | 
| 41 |  |  | else; [dataFlds]=ecmwf_load_fluxes(ycur,hcur); | 
| 42 |  |  | end; | 
| 43 |  |  |  | 
| 44 |  |  | %part b: time interpolate sst and ice fields from monthly atlas | 
| 45 |  |  | [mcur,mcurW]=coeff_MonthlyAtlasInterp(tcur); | 
| 46 |  |  | ice=(1-mcurW)*field_ice(:,:,mcur(1))+mcurW*field_ice(:,:,mcur(2)); ice=ice.*mask; | 
| 47 |  |  |  | 
| 48 |  |  | dataFlds=setfield(dataFlds,'ice',ice); | 
| 49 |  |  | dataFlds=setfield(dataFlds,'runoff',runoff); | 
| 50 |  |  |  | 
| 51 |  |  |  | 
| 52 |  |  | %part 2: net fluxes | 
| 53 |  |  | qnet = ( dataFlds.turbflux + dataFlds.swflux ); | 
| 54 |  |  | empmr = ( dataFlds.emp ) - dataFlds.runoff; | 
| 55 |  |  |  | 
| 56 |  |  |  | 
| 57 |  |  | %part 3: time average | 
| 58 |  |  | %writeFlds=struct('ustress',dataFlds.ustress,'vstress',dataFlds.vstress,'qnet',qnet,'empmr',empmr); | 
| 59 |  |  | turbflux=dataFlds.turbflux; swflux=dataFlds.swflux; | 
| 60 |  |  | writeFlds=struct('ustress',dataFlds.ustress,'vstress',dataFlds.vstress,'qnet',qnet,'empmr',empmr,'turbflux',turbflux,'swflux',swflux); | 
| 61 |  |  |  | 
| 62 |  |  | averagesFields(doInitFiles,doWriteMean,rep_out,suff_out,writeFlds); | 
| 63 |  |  | doInitFiles=0; | 
| 64 |  |  |  | 
| 65 |  |  | %part 4: plot results | 
| 66 |  |  | if choice_plot==1; fig0=6+(choiceDataSet-1)*1; | 
| 67 |  |  | %sign conventions are not the same in exf and largyeager ... I use largeyeager | 
| 68 |  |  | %convention for plot, positive=into the ocean | 
| 69 |  |  | figure(fig0+1); | 
| 70 |  |  | subplot(2,2,1); pcolor(lon2D_t,lat2D_t,dataFlds.ustress); shading flat; caxis([-1 1]*0.2); colorbar; | 
| 71 |  |  | subplot(2,2,2); pcolor(lon2D_t,lat2D_t,dataFlds.vstress); shading flat; caxis([-1 1]*0.1); colorbar; | 
| 72 |  |  | subplot(2,2,3); pcolor(lon2D_t,lat2D_t,-qnet); shading flat; caxis([-1 1]*200); colorbar; | 
| 73 |  |  | subplot(2,2,4); pcolor(lon2D_t,lat2D_t,-empmr); shading flat; caxis([-1 1]*1e-4); colorbar; | 
| 74 |  |  | return; | 
| 75 |  |  | end%if choice_plot==1 | 
| 76 |  |  |  | 
| 77 |  |  | end%for ttcur=1:4 | 
| 78 |  |  | doWriteMean=1; | 
| 79 |  |  | averagesFields(doInitFiles,doWriteMean,rep_out,suff_out,writeFlds); | 
| 80 |  |  | doWriteMean=0; | 
| 81 |  |  | end%for tcur=1:365 | 
| 82 |  |  |  | 
| 83 |  |  | doInitFiles=-1; doWriteMean=0; | 
| 84 |  |  | averagesFields(doInitFiles,doWriteMean,rep_out,suff_out,writeFlds); | 
| 85 |  |  |  | 
| 86 |  |  | end%for ycur=ycur0:ycurMax | 
| 87 |  |  | end%for choiceDataSet=1:2; | 
| 88 |  |  |  | 
| 89 |  |  |  |