def makePRFfile(data, MEMtype):
    """ makes Dysnomia .prf control file from Dysnomia GUI controls
    
    :param dict data: GSAS-II phase data
    :param int MEMtype: 1 for neutron data with negative scattering lengths
                        0 otherwise
    :returns str: name of Dysnomia control file
    """
    generalData = data['General']
    pName = generalData['Name'].replace(' ', '_')
    DysData = data['Dysnomia']
    prfName = pName + '.prf'
    prf = open(prfName, 'w')
    prf.write('$PREFERENCES\n')
    prf.write(pName + '.mem\n')
    prf.write(pName + '.out\n')
    prf.write(pName + '.pgrid\n')
    prf.write(pName + '.fba\n')
    prf.write(pName + '_eps.raw\n')
    prf.write('%d\n' % MEMtype)
    if DysData['DenStart'] == 'uniform':
        prf.write('0\n')
    else:
        prf.write('1\n')
    if DysData['Optimize'] == 'ZSPA':
        prf.write('0\n')
    else:
        prf.write('1\n')
    prf.write('1\n')
    if DysData['Lagrange'][0] == 'user':
        prf.write('0\n')
    else:
        prf.write('1\n')
    prf.write('%.4f %d\n' % (DysData['Lagrange'][1], DysData['wt pwr']))
    prf.write('%.3f\n' % DysData['Lagrange'][2])
    prf.write('%.2f\n' % DysData['E_factor'])
    prf.write('1\n')
    prf.write('0\n')
    prf.write('%d\n' % DysData['Ncyc'])
    prf.write('1\n')
    prf.write('1 0 0 0 0 0 0 0\n')
    if DysData['prior'] == 'uniform':
        prf.write('0\n')
    else:
        prf.write('1\n')
    prf.close()
    return prfName
