FUNCTION nc_build, cmd, fld, direc, grid_type @com_eg @common ; direc= data type (x,xy,xyzt,yt,etc...) ; grid_type = grid type (to select right arrays) ; output : cdf_description (using also common in com_eg) ; X,Y,Z,T = structures containing attributes for each direction : ; x.name, x.units, x.long_name, x.data (+t.calendar for time) ; + Global = global attributes: title and origin ; grid IF debug_w THEN print, ' ' IF debug_w THEN print, ' ENTER nc_build...' IF debug_w THEN print, ' direc = ', direc xpos = strpos(direc, 'x') ypos = strpos(direc, 'y') zpos = strpos(direc, 'z') tpos = strpos(direc, 't') str_x = '' str_y = '' str_z = '' str_t = '' IF xpos NE -1 THEN BEGIN CASE grid_type OF 'T': xdata = glamt 'U': xdata = glamu 'V': xdata = glamv 'W': xdata = glamt ENDCASE ENDIF ELSE BEGIN ; degenerated dimension case xdata=0. ENDELSE x_att = {name:'nav_lon', units:'degrees_east', long_name:'Longitude', data:xdata} str_x = ',X=x_att' IF ypos NE -1 THEN BEGIN IF xpos NE -1 THEN BEGIN CASE grid_type OF 'T': ydata = gphit 'U': ydata = gphiu 'V': ydata = gphiv 'W': ydata = gphit ENDCASE ENDIF ELSE BEGIN ; degenerated dimension case idx = where(gphit EQ max(gphit)) idx = idx MOD jpi boite_pltz = [idx[0], idx[0], -90,90] domdef, boite_pltz, /xindex ; indice pour x ydata = reform(gphit[idx[0], firstyt:lastyt],lastyt-firstyt+1) print, ' firstyt:lastyt', lastyt-firstyt+1 ENDELSE ENDIF ELSE BEGIN ; degenerated dimension case ydata=0. ENDELSE y_att = {name:'nav_lat', units:'degrees_north', long_name:'Latitude', data:ydata} str_y = ',Y=y_att' IF zpos NE -1 THEN BEGIN CASE grid_type OF 'T': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END 'U': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END 'V': BEGIN & zdata = gdept & z_txt = 'Vertical T levels' & END 'W': BEGIN & zdata = gdepw & z_txt = 'Vertical W levels' & END ENDCASE ENDIF ELSE BEGIN ; degenerated dimension case zdata=0. z_txt = 'No vertical dimension' ENDELSE z_att = {name:'deptht', units:'m', long_name:z_txt, data:zdata} str_z = ',Z=z_att' IF tpos NE -1 THEN BEGIN t_att_name = '' CASE calendar_type OF 1: t_att_calendar = 'Gregorian' 0: t_att_calendar = '365 days per year' ELSE: t_att_calendar =strtrim(string(calendar_type), 2)+' days per month' ENDCASE t_att_long_name = 'Time axis' t_att_data = time IF time(0) GT 1 THEN BEGIN t_att_origin = '0001-JAN-01 00:00:00' ENDIF ELSE t_att_origin = def_time_origin(cmd.timave, cmd.date1) t_att_units = 'Days since '+t_att_origin t_att = {name:t_att_name, calendar:t_att_calendar, origin:t_att_origin, units:t_att_units, long_name:t_att_long_name, data:t_att_data} str_t = ',T=t_att' ENDIF ; global attributes global_attributes = {title:'Data generated by nc_put', origin:fld.origin, conventions:'GDT 1.2', software: 'post_it'} cdf_description = str_x+str_y+str_z+str_t+',GLOBAL=global_attributes' IF debug_w THEN print, ' cdf_description = ', cdf_description IF debug_w THEN print, ' ...EXIT nc_build' return, cdf_description END