;+ ; ; @file_comments ; calcul d'une matrice 3D de conductivité sigma=f(T,S) en fonction de T et S ; de ORCA, sur la grille T ; ; @categories ; orca grid ; ; @param orcares {in}{required}{type=string} ; code of ORCA grid to use for output results ; must be 'ORCA2' ; ; @param iyear {in}{required}{type=integer} ; real year ; ; @param ian {in}{required}{type=integer} ; simulation year ; ; @keyword DRAKKAR_EXP {type=string} ; code for Drakkar experiment ; only used when orcares = ORCA025 ; must be G42 ++ G70 ; ; @restrictions ; - Requires SAXO tools ; ; @todo ; validation of ORCA2 processing (now some NaN in output files !) ; add ORCA025 ; provide tools to plot output files ; produce a NetCDF GDT or CF compliant ; add divchoice parameter to choose either div or divfred ; ; @pre ; see geomag_profile.sh ; be sure to have ++ in the directory defined in ${GEOMAG_ID}/ ; ; @post ; see geomag_profile.sh ; ++ in the directory defined in ${GEOMAG_OD}/ ; ; @examples ; for ORCA2 ; IDL> .run forcagequimarche ; IDL> forcagequimarche, 'ORCA2', '1993', '01' ; ; @history ; fplod 2007-09-19T15:41:28Z aedon.locean-ipsl.upmc.fr (Darwin) ; externalisation of outputs see forcage_output ++ ; fplod 2007-07-30T10:12:38Z aedon.locean-ipsl.upmc.fr (Darwin) ; restore divfred call instead of div ("official" saxo divergence module) ; fplod 2007-07-27T10:29:18Z cerbere.locean-ipsl.upmc.fr (Linux) ; add orcares in the name of output files ; fplod 2007-07-27T10:29:18Z cerbere.locean-ipsl.upmc.fr (Linux) ; add orcares parameter ; add optional keyword drakkar_exp ; add header for idldoc ; add check of io directories ; replace io directories user dependant to $GEOMAG_ID and $GEOMAG_OD ; replace call of divfred by call of div ; ; @version ; $Id$ ; ;- ; PRO forcagequimarche, orcares, iyear, ian, DRAKKAR_EXP = drakkar_exp ; ;---- ; check input parameters ;---- ; ; check orcares definition ; CASE orcares OF 'ORCA2': BEGIN msg = 'iii : valid orcares parameter = ' + orcares ras = report(msg) filename_oce = 'meshmask_bab.nc' IF keyword_set(DRAKKAR_EXP) THEN BEGIN msg = 'www : unused DRAKKAR_EXP keyword = ' + drakkar_exp ras = report(msg) END END ELSE : BEGIN msg = 'eee : invalid orcares parameter = ' + orcares ras = report(msg) msg = 'eee : orcares must be ORCA2 or ORCA025++' ras = report(msg) RETURN END ENDCASE ; ++ check iyear ; ++ check ian ;++@init2 ; init grid initocemeshmask, orcares, DRAKKAR_EXP = drakkar_exp @common ; ; check for input files ; ; test if ${GEOMAG_ID} defined geomag_id_env=GETENV('GEOMAG_ID') CASE geomag_id_env OF '' : BEGIN msg = 'eee : ${GEOMAG_ID} is not defined' ras = report(msg) RETURN END ELSE: BEGIN msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env ras = report(msg) END ENDCASE ; iodirin = isadirectory(geomag_id_env) ; ; existence and protection of ${GEOMAG_ID} IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirin + ' is not accessible.' ras = report(msg) RETURN ENDIF ; ; test if ${GEOMAG_OD} defined geomag_od_env=GETENV('GEOMAG_OD') CASE geomag_od_env OF '' : BEGIN msg = 'eee : ${GEOMAG_OD} is not defined' ras = report(msg) RETURN END ELSE: BEGIN msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env ras = report(msg) END ENDCASE ; ; check if output data will be possible iodirout = isadirectory(geomag_od_env) ; ; existence and protection IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirout + ' was not found.' ras = report(msg) RETURN ENDIF ; e_exp='ESS' key_portrait = 0 ; stockage des fichiers brut ioDATA=geomag_id_env CASE orcares OF 'ORCA2': BEGIN file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc' file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc' file_T=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_T.nc' jpt = 73 ;time counter des fichiers ci-dessus END ENDCASE file_Sed= geomag_id_env+'cond_sed_'+orcares+'.nc' file_Br= geomag_id_env+'Br_'+orcares + '.nc' ; ; title t_exp= e_exp t_bt = 'bar_transp' ioORLN2 = geomag_id_env ; ;facteur d'echelle vertical for partial steps e3v3d=read_ncdf('e3v_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') e3u3d=read_ncdf('e3u_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') SIGMAsed=read_ncdf('cond_sed',0,/timestep,/nostruct,/tout,filename=file_Sed,/cont_nofill) ;BR=read_ncdf('Br',0,/timestep,/nostruct,/tout,filename=file_Br) BR=read_ncdf('Br',0,/timestep,/nostruct,/tout,filename=file_Br,/cont_nofill) ; ; vertical integration: e3t3d=make_array(jpi,jpj,jpk) for k=0, jpk-1 do begin &$ for j=0,jpj-1 do begin &$ for i=0,jpi-1 do begin &$ e3t3d(i,j,k) = e3t(k) &$ endfor &$ endfor &$ endfor ; ;vud = make_array(jpi,jpj,jpt) ;vvd = make_array(jpi, jpj, jpt) divBustar = make_array(jpi, jpj, jpt) diver3=replicate(0.,182,149,1,jpt) sigma3=replicate(0.,182,149,1,jpt) ; FOR jt = 0, jpt-1 DO BEGIN &$ ; ; ouverture des fichiers et stockage en memoire partial steps vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U) &$ ;stop vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V) &$ ;stop ; lecture salinite & temperature temp= read_ncdf('votemper',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) ;stop salin=read_ncdf('vosaline',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) ;stop conduct=0.02047780622061 + 0.00273147624197*temp + 0.00035133182334*temp*temp + 0.09139808809909*salin + 0.00241425798890*salin*temp -0.00023998958774*salin*salin mask_t=where(conduct GT 1.e+19) conduct(mask_t)=0. ; Somme conduct au point T ; ; Calcul SIGMA ; SIGMAoc=total(conduct*e3t3d*tmask,3) SIGMA=SIGMAsed+SIGMAoc ; SIGMA_u=(SIGMA+shift(SIGMA,-1,0))/2. SIGMA_v=(SIGMA+shift(SIGMA,0,1))/2. ; ; Calcul B en points u et v ; BR_u=(BR+shift(BR,-1,0))/2. BR_v=(BR+shift(BR,0,1))/2. ; ; Calcul integrale conduct ; conduct_u=(conduct+shift(conduct,-1,0,0))/2. conduct_v=(conduct+shift(conduct,0,1,0))/2. ; u_cond_u=total( vu*conduct_u*e3u3d*umask(),3) v_cond_v=total( vv*conduct_v*e3v3d*vmask(),3) ; Bu_star= BR_u*u_cond_u/SIGMA_u Bv_star= BR_v*v_cond_v/SIGMA_v ; Transport horizontal T_u=total( vu*e3u3d*umask(),3) T_v=total( vv*e3v3d*vmask(),3) ; ; Divergence du champ Diver=divfred(Bu_star,Bv_star) Diver=Diver*1e-6 ;stop lecontinent=where(Diver GT 1.E08) Diver(lecontinent)=0. ;stop ;bande de recouvrement:: diver3(1:180,0:147,*,jt)=Diver(*,*) diver3(0,*,*,*)=diver3(180,*,*,*) diver3(181,*,*,*)=diver3(1,*,*,*) sigma3(1:180,0:147,*,jt)=SIGMA(*,*) sigma3(0,*,*,*)=sigma3(180,*,*,*) sigma3(181,*,*,*)=sigma3(1,*,*,*) print, jt ENDFOR ; on ferme le NetCDF ;NCDF_CLOSE,id3 ;NCDF_CLOSE,id4 temps=fltarr(73) temps(0)=0. for jt=0,71 do begin &$ temps(jt+1)=temps(jt) +5*86400. &$ endfor print,temps vargrid = 'T' iodir = geomag_od_env ; Nom idout = NCDF_CREATE(iodir+'DivBustar_5d_'+iyear+'_grid_T_'+orcares+'.nc',/clobber) print, 'Creation du fichier Netcdf' NCDF_CONTROL, idout, /nofill ; Dimension xidout = NCDF_DIMDEF(idout, 'x',jpiglo) yidout = NCDF_DIMDEF(idout, 'y',jpjglo) didout = NCDF_DIMDEF(idout, 'deptht',1) tidout = NCDF_DIMDEF(idout, 'time_counter', /unlimited) didout1 = NCDF_DIMDEF(idout, 'deptht1',jpk) ; Attributs globaux id0 = NCDF_VARDEF(idout, 'nav_lon' , [xidout, yidout ], /FLOAT) id1 = NCDF_VARDEF(idout, 'nav_lat' , [xidout, yidout ], /FLOAT) id2 = NCDF_VARDEF(idout, 'deptht' , [ didout1 ], /FLOAT) id3 = NCDF_VARDEF(idout, 'time_counter', [ tidout], /FLOAT) id4 = NCDF_VARDEF(idout, 'Diver' , [xidout, yidout, didout, tidout], /DOUBLE) ; Variable 0 NCDF_ATTPUT, idout, id0, 'units', 'degrees_east' NCDF_ATTPUT, idout, id0, 'long_name', 'Longitude' NCDF_ATTPUT, idout, id0, 'nav_model', 'Default grid' ; Variable 1 NCDF_ATTPUT, idout, id1, 'units', 'degrees_north' NCDF_ATTPUT, idout, id1, 'long_name', 'Latitude' NCDF_ATTPUT, idout, id1, 'nav_model', 'Default grid' ; Variable 2 NCDF_ATTPUT, idout, id2, 'units','meters' NCDF_ATTPUT, idout, id2, 'long_name','Depth' NCDF_ATTPUT, idout, id2, 'nav_model','Default grid' ; Variable3 NCDF_ATTPUT, idout, id3, 'units', 'seconds since 0001-01-01 00:00:00 ' NCDF_ATTPUT, idout, id3, 'calendar','noleap' NCDF_ATTPUT, idout, id3, 'title', 'Time' NCDF_ATTPUT, idout, id3, 'long_name', 'Time axis' NCDF_ATTPUT, idout, id3, 'time_origin','0001-JAN-01 00:00:00' ; Variables NCDF_ATTPUT, idout, id4, 'long_name', 'Divergence' NCDF_CONTROL, idout, /ENDEF ; Creation de la longitude print,glamt[0:20,0] ; ++ debug pb nav_lon print,glamt[30:50,0] print,glamt[50:70,0] NCDF_VARPUT, idout, id0, glamt ; Creation de la latitude NCDF_VARPUT, idout, id1, gphit ; Creation de la profondeur NCDF_VARPUT, idout, id2, gdept ; Creation du calendrier NCDF_VARPUT, idout, id3, temps ; Ecriture des donnees ; ecriture des glam_8 NCDF_VARPUT, idout, id4 , diver3 NCDF_CLOSE, idout ; ++ l'équivalent avec forcage_output forcage_output, orcares, variable, 'Divergence', long_name, jpiglo, jpjglo, gphit, glamt,diver3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;meme topo pour SIGMA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; idout = NCDF_CREATE(iodir+'Sigma_5d_'+iyear+'_grid_T_'+orcares+'.nc',/clobber) print, 'Creation du fichier Netcdf' NCDF_CONTROL, idout, /nofill ; Dimension xidout = NCDF_DIMDEF(idout, 'x',jpiglo) yidout = NCDF_DIMDEF(idout, 'y',jpjglo) didout = NCDF_DIMDEF(idout, 'deptht',1) tidout = NCDF_DIMDEF(idout, 'time_counter', /unlimited) didout1 = NCDF_DIMDEF(idout, 'deptht1',jpk) ; Attributs globaux id0 = NCDF_VARDEF(idout, 'nav_lon' , [xidout, yidout ], /FLOAT) id1 = NCDF_VARDEF(idout, 'nav_lat' , [xidout, yidout ], /FLOAT) id2 = NCDF_VARDEF(idout, 'deptht' , [ didout1 ], /FLOAT) id3 = NCDF_VARDEF(idout, 'time_counter', [ tidout], /FLOAT) id4 = NCDF_VARDEF(idout, 'Sigma' , [xidout, yidout, didout, tidout], /DOUBLE) ; Variable 0 NCDF_ATTPUT, idout, id0, 'units', 'degrees_east' NCDF_ATTPUT, idout, id0, 'long_name', 'Longitude' NCDF_ATTPUT, idout, id0, 'nav_model', 'Default grid' ; Variable 1 NCDF_ATTPUT, idout, id1, 'units', 'degrees_north' NCDF_ATTPUT, idout, id1, 'long_name', 'Latitude' NCDF_ATTPUT, idout, id1, 'nav_model', 'Default grid' ; Variable 2 NCDF_ATTPUT, idout, id2, 'units','meters' NCDF_ATTPUT, idout, id2, 'long_name','Depth' NCDF_ATTPUT, idout, id2, 'nav_model','Default grid' ; Variable3 NCDF_ATTPUT, idout, id3, 'units', 'seconds since 0001-01-01 00:00:00 ' NCDF_ATTPUT, idout, id3, 'calendar','noleap' NCDF_ATTPUT, idout, id3, 'title', 'Time' NCDF_ATTPUT, idout, id3, 'long_name', 'Time axis' NCDF_ATTPUT, idout, id3, 'time_origin','0001-JAN-01 00:00:00' ; Variables NCDF_ATTPUT, idout, id4, 'long_name', 'Total Conductance' NCDF_CONTROL, idout, /ENDEF ; Creation de la longitude NCDF_VARPUT, idout, id0, glamt ; Creation de la latitude NCDF_VARPUT, idout, id1, gphit ; Creation de la profondeur NCDF_VARPUT, idout, id2, gdept ; Creation du calendrier NCDF_VARPUT, idout, id3, temps ; Ecriture des donnees ; ecriture des glam_8 NCDF_VARPUT, idout, id4 , sigma3 NCDF_CLOSE, idout END