	PRO disk2_mo, mo_disk, wk_path, mo_wk_no, $
		progress = progress, qdebug = qdebug
;	-----------------------------------------------------------
;+							26-May-93
;	NAME: disk2_mo
;	PURPOSE: Write reformatted data (ref. by wk_path and mo_wk_no)
;		to an MO (mo_disk)
;
;	CALLING SEQUENCE:
;		disk2_mo, mo_disk, wk_path, mo_wk_no, progress
;
;		mo_disk		"top" dir on MO or mount point
;		wk_path		path to reformatted data
;		mo_wk_no	selected index to the MO disk map.
;		progress	wk status: wk 1 of 2, or 2 of 2.
;
;	HISTORY: written 13-May-93, gal
;		26-May-93, gal, added mv for "m" type dirs.
;		3-Oct-95, LS, changed path to new mo_mount style /mo/flareN.X
;			changed default machine to flare15
;			have to parse mo_disk 's new style
;		1-Nov-95, LS, changed message about how long the process will take.
;			with the larger capacity MOs, it takes more like 1.5 hrs.
;-
;	----------------------------------------------------------

;	SET-UP DEFAULTS:
	account = 'mocreate'		;default account for MO making
	acc_sw  = '-l '+account+' -n '  ;rsh account cmd
	if (n_elements(mo_disk) eq 0) then mo_disk = '/mo/flare15.0'
			
	fpos = strpos(mo_disk, 'flare', 0)	;find which machine 
	mach = strmid(mo_disk, fpos, strpos(mo_disk,'.',0)-fpos )
	spawn, 'ping '+mach, ping_ans		;ck machine status
        status_p = strpos(ping_ans, 'unknown', 0)
	if status_p(0) ne -1 then begin
	  Print, 'Error: ', strtrim(mach,2), 'is not available!!'
	  return
	endif

;	USE MDM's MO Database with "mo_wk_no" to determine the week
;	and files to copy to the MO.
   	mdm2do = Rd_modb( mo_wk_no, tape_label )
	
	first_fid = string(mdm2do.st$first_fid)
	last_fid = string(mdm2do.st$last_fid)

	fids = mk_fidlist(first_fid, last_fid, path=wk_path)

	IF fids(0) eq '' THEN BEGIN
	  print, 'NO valid data on : ', wk_path
	  return
	ENDIF

	fids = '*'+fids		;copy all files with that FID

;	Assuming the MO is mounted.  Define the path to the MO 
;	archive directory and the "on-line" data directory. Then
;	copy files to the MO.

	week = string(mdm2do.st$week)	;get the offical week name
	IF wk_path ne '' THEN BEGIN
	  week_dir = wk_path
	ENDIF ELSE BEGIN 
          week_dir = strmid(week, 0, 5)	;The on-line directory name
					;directory has already been ck.
;	  maybe this is ok	
	ENDELSE

	dir1 = concat_dir(mo_disk, 'yohkoh')
	exist = file_exist( dir1, /direct)
    	if (not exist) then begin
	  cmd = 'cd ' + mo_disk + '; mkdir yohkoh; chmod 777 yohkoh'
	  print, cmd
	  if (not keyword_set(qdebug)) then spawn, cmd
	endif

	dir2 = concat_dir(dir1, week)
	exist = file_exist( dir2, /direct)
	if (not exist) then begin
	  cmd = 'cd ' + dir1 + '; mkdir ' + week + '; chmod 777 ' + week
	  print, cmd
	  if (not keyword_set(qdebug)) then spawn, cmd
	endif
        mo_dir2 = dir2

  	Print, 'Moving Files to MO on: ', mach
  	Print, 'This takes about 1.5 hours... and bell rings when done.'

	if (not keyword_set(qdebug)) then begin
	  week_type = strmid(week_dir(0),strlen(week_dir)-2,1)
	  if (week_type(0) eq 'm') then begin 	;for weekly for MO only
	    cp_fns, fids, week_dir, mo_dir2, mach=mach, acc_sw=acc_sw, /mv
	  endif else begin 
	    cp_fns, fids, week_dir, mo_dir2, mach=mach, acc_sw=acc_sw
	  endelse
	endif else begin
	  cp_fns, fids, week_dir, mo_dir2, mach=mach, acc_sw=acc_sw, /qdebug
	endelse

	bell, 5
	Print, 'Copy for week: '+strtrim(week,2)+' to MO completed!'
	bell, 5

	END
